Skip to content

Commit 0fa32b3

Browse files
committed
2 parents f6fd5fd + ad6c65e commit 0fa32b3

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

src/phenome/components/link.jsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export default {
2626
},
2727
target: String,
2828
tooltip: String,
29+
30+
// Smart Select
31+
smartSelect: Boolean,
32+
smartSelectParams: Object,
33+
2934
...Mixins.colorProps,
3035
...Mixins.linkIconProps,
3136
...Mixins.linkRouterProps,
@@ -58,6 +63,7 @@ export default {
5863
iconIos,
5964
id,
6065
style,
66+
smartSelect,
6167
} = props;
6268

6369
const defaultSlots = self.slots.default;
@@ -131,7 +137,7 @@ export default {
131137
componentDidMount() {
132138
const self = this;
133139
const el = self.refs.el;
134-
const { tabbarLabel, tabLink, tooltip } = self.props;
140+
const { tabbarLabel, tabLink, tooltip, smartSelect, smartSelectParams } = self.props;
135141
let isTabbarLabel = false;
136142
if (tabbarLabel ||
137143
(
@@ -142,16 +148,28 @@ export default {
142148
isTabbarLabel = true;
143149
}
144150
self.setState({ isTabbarLabel });
145-
if (!tooltip) return;
151+
146152
self.$f7ready((f7) => {
147-
self.f7Tooltip = f7.tooltip.create({
148-
el: self.refs.el,
149-
text: tooltip,
150-
});
153+
if (smartSelect) {
154+
const ssParams = Utils.extend(
155+
{ el: el },
156+
smartSelectParams || {},
157+
);
158+
self.f7SmartSelect = f7.smartSelect.create(ssParams);
159+
}
160+
if (tooltip) {
161+
self.f7Tooltip = f7.tooltip.create({
162+
el: self.refs.el,
163+
text: tooltip,
164+
});
165+
}
151166
});
152167
},
153168
componentWillUnmount() {
154169
const self = this;
170+
if (self.f7SmartSelect && self.f7SmartSelect.destroy) {
171+
self.f7SmartSelect.destroy();
172+
}
155173
if (self.f7Tooltip && self.f7Tooltip.destroy) {
156174
self.f7Tooltip.destroy();
157175
self.f7Tooltip = null;
@@ -185,6 +203,7 @@ export default {
185203
tabLink,
186204
tabLinkActive,
187205
noLinkClass,
206+
smartSelect,
188207
className,
189208
} = props;
190209

@@ -196,6 +215,7 @@ export default {
196215
'tab-link': tabLink || tabLink === '',
197216
'tab-link-active': tabLinkActive,
198217
'no-fastclick': noFastclick || noFastClick,
218+
'smart-select': smartSelect,
199219
},
200220
Mixins.colorClasses(props),
201221
Mixins.linkRouterClasses(props),
@@ -205,6 +225,10 @@ export default {
205225
},
206226
methods: {
207227
onClick(event) {
228+
const self = this;
229+
if (self.props.smartSelect && self.f7SmartSelect) {
230+
self.f7SmartSelect.open();
231+
}
208232
this.dispatchEvent('click', event);
209233
},
210234
},

0 commit comments

Comments
 (0)