@tdesign/uniapp 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +32 -2
- package/dist/action-sheet/README.md +1 -1
- package/dist/action-sheet/action-sheet.vue +158 -150
- package/dist/action-sheet/props.ts +2 -2
- package/dist/action-sheet/type.ts +1 -1
- package/dist/avatar/avatar.vue +89 -87
- package/dist/avatar-group/avatar-group.vue +69 -67
- package/dist/back-top/back-top.vue +60 -58
- package/dist/badge/badge.vue +69 -59
- package/dist/button/button.vue +121 -116
- package/dist/button/props.ts +2 -2
- package/dist/button/type.ts +1 -1
- package/dist/calendar/calendar-header.vue +4 -4
- package/dist/calendar/calendar.vue +308 -297
- package/dist/calendar/template.vue +1 -1
- package/dist/cascader/README.en-US.md +2 -1
- package/dist/cascader/README.md +2 -1
- package/dist/cascader/cascader.vue +340 -328
- package/dist/cascader/props.ts +6 -1
- package/dist/cascader/type.ts +6 -0
- package/dist/cell/cell.vue +127 -121
- package/dist/cell-group/cell-group.vue +32 -30
- package/dist/check-tag/check-tag.vue +73 -71
- package/dist/checkbox/README.en-US.md +6 -6
- package/dist/checkbox/README.md +5 -5
- package/dist/checkbox/checkbox.vue +127 -127
- package/dist/checkbox/props.ts +6 -6
- package/dist/checkbox/type.ts +6 -4
- package/dist/checkbox-group/checkbox-group.vue +175 -173
- package/dist/checkbox-group/props.ts +6 -6
- package/dist/checkbox-group/type.ts +6 -4
- package/dist/col/col.vue +26 -24
- package/dist/collapse/collapse.vue +83 -81
- package/dist/collapse-panel/collapse-panel.vue +121 -119
- package/dist/collapse-panel/props.ts +4 -4
- package/dist/collapse-panel/type.ts +2 -2
- package/dist/color-picker/README.md +1 -1
- package/dist/color-picker/color-picker.vue +324 -322
- package/dist/color-picker/props.ts +2 -2
- package/dist/color-picker/template.vue +14 -10
- package/dist/common/common.ts +1 -0
- package/dist/common/style/theme/index.css +57 -61
- package/dist/common/utils.js +7 -2
- package/dist/common/validator.js +172 -0
- package/dist/config-provider/README.en-US.md +184 -0
- package/dist/config-provider/README.md +234 -0
- package/dist/config-provider/config-provider.vue +105 -0
- package/dist/config-provider/config-store.js +70 -0
- package/dist/config-provider/props.ts +16 -0
- package/dist/config-provider/reactive-state.js +39 -0
- package/dist/config-provider/type.ts +401 -0
- package/dist/config-provider/use-config.js +29 -0
- package/dist/config-provider/utils.js +29 -0
- package/dist/count-down/count-down.vue +98 -97
- package/dist/date-time-picker/date-time-picker.vue +410 -395
- package/dist/demo/demo.vue +1 -0
- package/dist/dialog/dialog.vue +176 -173
- package/dist/divider/divider.vue +38 -36
- package/dist/draggable/draggable.vue +60 -58
- package/dist/drawer/README.md +1 -1
- package/dist/drawer/drawer.vue +48 -46
- package/dist/dropdown-item/dropdown-item.vue +209 -207
- package/dist/dropdown-item/props.ts +4 -4
- package/dist/dropdown-item/type.ts +3 -3
- package/dist/dropdown-menu/dropdown-menu.vue +93 -99
- package/dist/empty/empty.vue +43 -42
- package/dist/fab/fab.vue +88 -86
- package/dist/footer/footer.vue +36 -34
- package/dist/form/README.en-US.md +17 -24
- package/dist/form/README.md +18 -25
- package/dist/form/form.css +1 -166
- package/dist/form/form.vue +251 -236
- package/dist/form/props.ts +2 -21
- package/dist/form/type.ts +7 -70
- package/dist/form-item/README.en-US.md +4 -5
- package/dist/form-item/README.md +4 -5
- package/dist/form-item/form-item.css +69 -96
- package/dist/form-item/form-item.vue +315 -336
- package/dist/form-item/form-model.ts +125 -173
- package/dist/form-item/props.ts +4 -17
- package/dist/form-item/type.ts +43 -1
- package/dist/grid/grid.vue +53 -51
- package/dist/grid-item/grid-item.vue +121 -119
- package/dist/guide/README.md +1 -1
- package/dist/guide/guide.vue +281 -277
- package/dist/icon/README.md +2 -4
- package/dist/icon/icon.vue +78 -76
- package/dist/image/README.md +1 -1
- package/dist/image/image.vue +103 -101
- package/dist/image-viewer/image-viewer.vue +160 -158
- package/dist/image-viewer/props.ts +2 -2
- package/dist/image-viewer/type.ts +1 -1
- package/dist/index.js +3 -0
- package/dist/indexes/indexes.vue +264 -267
- package/dist/indexes-anchor/indexes-anchor.vue +41 -41
- package/dist/input/input.vue +192 -192
- package/dist/input/props.ts +6 -6
- package/dist/input/type.ts +3 -3
- package/dist/link/link.vue +73 -71
- package/dist/loading/loading.vue +59 -59
- package/dist/locale/ar_KW.ts +157 -0
- package/dist/locale/en_US.ts +146 -0
- package/dist/locale/it_IT.ts +145 -0
- package/dist/locale/ja_JP.ts +132 -0
- package/dist/locale/ko_KR.ts +132 -0
- package/dist/locale/ru_RU.ts +157 -0
- package/dist/locale/zh_CN.ts +133 -0
- package/dist/locale/zh_TW.ts +132 -0
- package/dist/message/message.vue +181 -173
- package/dist/message/props.ts +2 -2
- package/dist/message/type.ts +1 -1
- package/dist/message-item/message-item.vue +192 -184
- package/dist/mixins/using-config.js +39 -0
- package/dist/navbar/navbar.vue +201 -199
- package/dist/notice-bar/notice-bar.vue +175 -171
- package/dist/notice-bar/props.ts +2 -2
- package/dist/notice-bar/type.ts +1 -1
- package/dist/npm/dayjs/esm/locale/ar.js +81 -0
- package/dist/npm/dayjs/esm/locale/it.js +39 -0
- package/dist/overlay/overlay.vue +50 -48
- package/dist/picker/picker.vue +168 -161
- package/dist/picker-item/picker-item.vue +269 -269
- package/dist/popover/README.md +1 -1
- package/dist/popover/popover.vue +262 -261
- package/dist/popover/props.ts +4 -4
- package/dist/popover/type.ts +2 -2
- package/dist/popup/popup.vue +46 -45
- package/dist/progress/README.md +1 -1
- package/dist/progress/progress.vue +76 -76
- package/dist/pull-down-refresh/props.ts +2 -2
- package/dist/pull-down-refresh/pull-down-refresh.vue +240 -234
- package/dist/pull-down-refresh/type.ts +1 -1
- package/dist/qrcode/README.md +1 -1
- package/dist/qrcode/components/qrcode-canvas/qrcode-canvas.vue +340 -338
- package/dist/qrcode/components/qrcode-status/qrcode-status.vue +6 -6
- package/dist/qrcode/qrcode.vue +93 -87
- package/dist/radio/props.ts +6 -6
- package/dist/radio/radio.vue +118 -120
- package/dist/radio/type.ts +3 -3
- package/dist/radio-group/props.ts +4 -4
- package/dist/radio-group/radio-group.vue +136 -134
- package/dist/radio-group/type.ts +4 -4
- package/dist/rate/computed.js +2 -2
- package/dist/rate/props.ts +4 -4
- package/dist/rate/rate.vue +155 -154
- package/dist/rate/type.ts +2 -2
- package/dist/result/result.vue +41 -39
- package/dist/row/row.vue +38 -36
- package/dist/scroll-view/scroll-view.vue +24 -22
- package/dist/search/props.ts +2 -2
- package/dist/search/search.vue +127 -125
- package/dist/search/type.ts +1 -1
- package/dist/side-bar/side-bar.vue +57 -55
- package/dist/side-bar-item/side-bar-item.vue +86 -86
- package/dist/skeleton/skeleton.vue +126 -124
- package/dist/slider/README.md +1 -1
- package/dist/slider/props.ts +2 -2
- package/dist/slider/slider.vue +457 -457
- package/dist/slider/type.ts +1 -1
- package/dist/step-item/step-item.vue +77 -75
- package/dist/stepper/props.ts +2 -2
- package/dist/stepper/stepper.vue +168 -149
- package/dist/stepper/type.ts +1 -1
- package/dist/steps/props.ts +2 -2
- package/dist/steps/steps.vue +83 -81
- package/dist/steps/type.ts +1 -1
- package/dist/sticky/sticky.vue +104 -102
- package/dist/swipe-cell/swipe-cell.vue +91 -89
- package/dist/swiper/README.md +1 -1
- package/dist/swiper/swiper.vue +91 -89
- package/dist/swiper-nav/swiper-nav.vue +38 -36
- package/dist/switch/props.ts +2 -2
- package/dist/switch/switch.vue +62 -62
- package/dist/switch/type.ts +1 -1
- package/dist/tab-bar/tab-bar.vue +88 -86
- package/dist/tab-bar-item/tab-bar-item.vue +85 -82
- package/dist/tab-panel/tab-panel.vue +66 -64
- package/dist/tabs/tabs.vue +294 -287
- package/dist/tag/tag.vue +79 -77
- package/dist/textarea/props.ts +6 -6
- package/dist/textarea/textarea.vue +127 -126
- package/dist/textarea/type.ts +3 -3
- package/dist/toast/toast.vue +107 -106
- package/dist/transition/transition.vue +30 -28
- package/dist/tree-select/tree-select.vue +151 -151
- package/dist/types/config-provider.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/popover.d.ts +7 -0
- package/dist/upload/README.en-US.md +13 -14
- package/dist/upload/README.md +11 -12
- package/dist/upload/props.ts +2 -4
- package/dist/upload/type.ts +12 -11
- package/dist/upload/upload.css +1 -1
- package/dist/upload/upload.vue +672 -512
- package/dist/watermark/watermark.vue +151 -149
- package/global.d.ts +2 -0
- package/package.json +16 -2
- package/dist/form/form-item-props.ts +0 -56
package/dist/drawer/README.md
CHANGED
package/dist/drawer/drawer.vue
CHANGED
|
@@ -75,64 +75,66 @@ import tools from '../common/utils.wxs';
|
|
|
75
75
|
const name = `${prefix}-drawer`;
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
export default
|
|
79
|
-
name,
|
|
80
|
-
options: {
|
|
81
|
-
styleIsolation: 'shared',
|
|
82
|
-
},
|
|
83
|
-
mixins: [
|
|
84
|
-
useCustomNavbar,
|
|
85
|
-
],
|
|
78
|
+
export default {
|
|
86
79
|
components: {
|
|
87
80
|
TPopup,
|
|
88
81
|
TIcon,
|
|
89
82
|
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
'update:visible',
|
|
95
|
-
'close',
|
|
96
|
-
'overlay-click',
|
|
97
|
-
'item-click',
|
|
98
|
-
],
|
|
99
|
-
data() {
|
|
100
|
-
return {
|
|
101
|
-
classPrefix: name,
|
|
102
|
-
tools,
|
|
103
|
-
dataVisible: coalesce(this.visible, this.defaultVisible),
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
watch: {
|
|
107
|
-
visible(e) {
|
|
108
|
-
this.dataVisible = e;
|
|
83
|
+
...uniComponent({
|
|
84
|
+
name,
|
|
85
|
+
options: {
|
|
86
|
+
styleIsolation: 'shared',
|
|
109
87
|
},
|
|
110
|
-
|
|
111
|
-
|
|
88
|
+
mixins: [
|
|
89
|
+
useCustomNavbar,
|
|
90
|
+
],
|
|
91
|
+
props: {
|
|
92
|
+
...props,
|
|
93
|
+
},
|
|
94
|
+
emits: [
|
|
95
|
+
'update:visible',
|
|
96
|
+
'close',
|
|
97
|
+
'overlay-click',
|
|
98
|
+
'item-click',
|
|
99
|
+
],
|
|
100
|
+
data() {
|
|
101
|
+
return {
|
|
102
|
+
classPrefix: name,
|
|
103
|
+
tools,
|
|
104
|
+
dataVisible: coalesce(this.visible, this.defaultVisible),
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
watch: {
|
|
108
|
+
visible(e) {
|
|
109
|
+
this.dataVisible = e;
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
methods: {
|
|
112
113
|
// closeOnOverlayClick 为 true 时才能触发 popup 的 visible-change 事件
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
onVisibleChange(detail) {
|
|
115
|
+
const { visible } = detail;
|
|
116
|
+
const { showOverlay } = this;
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
this.dataVisible = visible;
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
if (!visible) {
|
|
121
|
+
this.$emit('close', { trigger: 'overlay' });
|
|
122
|
+
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
if (showOverlay) {
|
|
125
|
+
this.$emit('overlay-click', { visible });
|
|
126
|
+
}
|
|
127
|
+
this.$emit('update:visible', visible);
|
|
128
|
+
},
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
onItemClick(detail) {
|
|
131
|
+
const { index, item } = detail.currentTarget.dataset;
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
this.$emit('item-click', { index, item });
|
|
134
|
+
},
|
|
133
135
|
},
|
|
134
|
-
},
|
|
135
|
-
}
|
|
136
|
+
}),
|
|
137
|
+
};
|
|
136
138
|
</script>
|
|
137
139
|
<style scoped src="./drawer.css"></style>
|
|
138
140
|
<style>
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
<view
|
|
3
3
|
v-if="wrapperVisible"
|
|
4
4
|
:class="classPrefix + ' ' + tClass"
|
|
5
|
-
:style="tools._style([getStyles(top, zIndex), customStyle])"
|
|
5
|
+
:style="'' + tools._style([getStyles(top, zIndex), customStyle])"
|
|
6
6
|
>
|
|
7
7
|
<view
|
|
8
8
|
v-if="show"
|
|
9
9
|
:class="classPrefix + '__mask'"
|
|
10
|
-
:style="tools._style(['height:' + maskHeight + 'px', customStyle])"
|
|
10
|
+
:style="'' + tools._style(['height:' + maskHeight + 'px', customStyle])"
|
|
11
11
|
@click="handleMaskClick"
|
|
12
12
|
@touchmove.stop.prevent="closeDropdown"
|
|
13
13
|
/>
|
|
@@ -137,24 +137,7 @@ import { canUseVirtualHost } from '../common/version';
|
|
|
137
137
|
const name = `${prefix}-dropdown-item`;
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
export default
|
|
141
|
-
name,
|
|
142
|
-
options: {
|
|
143
|
-
styleIsolation: 'shared',
|
|
144
|
-
},
|
|
145
|
-
controlledProps: [{
|
|
146
|
-
key: 'value',
|
|
147
|
-
event: 'change',
|
|
148
|
-
}],
|
|
149
|
-
externalClasses: [
|
|
150
|
-
`${prefix}-class`,
|
|
151
|
-
`${prefix}-class-content`,
|
|
152
|
-
`${prefix}-class-column`,
|
|
153
|
-
`${prefix}-class-column-item`,
|
|
154
|
-
`${prefix}-class-column-item-label`,
|
|
155
|
-
`${prefix}-class-footer`,
|
|
156
|
-
],
|
|
157
|
-
mixins: [ChildrenMixin(RELATION_MAP.DropdownItem)],
|
|
140
|
+
export default {
|
|
158
141
|
components: {
|
|
159
142
|
TButton,
|
|
160
143
|
TRadio,
|
|
@@ -163,227 +146,246 @@ export default uniComponent({
|
|
|
163
146
|
TCheckboxGroup,
|
|
164
147
|
TPopup,
|
|
165
148
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
data() {
|
|
171
|
-
return {
|
|
172
|
-
prefix,
|
|
173
|
-
classPrefix: name,
|
|
174
|
-
show: false,
|
|
175
|
-
top: 0,
|
|
176
|
-
maskHeight: 0,
|
|
177
|
-
initValue: null,
|
|
178
|
-
hasChanged: false,
|
|
179
|
-
duration: menuProps.duration.default,
|
|
180
|
-
zIndex: menuProps.zIndex.default,
|
|
181
|
-
overlay: menuProps.showOverlay.default,
|
|
182
|
-
labelAlias: 'label',
|
|
183
|
-
valueAlias: 'value',
|
|
184
|
-
computedLabel: '',
|
|
185
|
-
firstCheckedValue: '',
|
|
186
|
-
|
|
187
|
-
dataValue: coalesce(this.value, this.defaultValue),
|
|
188
|
-
|
|
189
|
-
wrapperVisible: false,
|
|
190
|
-
tools,
|
|
191
|
-
|
|
192
|
-
windowTop: 0,
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
computed: {
|
|
196
|
-
footerBtnTClass() {
|
|
197
|
-
return canUseVirtualHost() ? this.footerBtnRealClass : '';
|
|
149
|
+
...uniComponent({
|
|
150
|
+
name,
|
|
151
|
+
options: {
|
|
152
|
+
styleIsolation: 'shared',
|
|
198
153
|
},
|
|
199
|
-
|
|
200
|
-
|
|
154
|
+
controlledProps: [{
|
|
155
|
+
key: 'value',
|
|
156
|
+
event: 'change',
|
|
157
|
+
}],
|
|
158
|
+
externalClasses: [
|
|
159
|
+
`${prefix}-class`,
|
|
160
|
+
`${prefix}-class-content`,
|
|
161
|
+
`${prefix}-class-column`,
|
|
162
|
+
`${prefix}-class-column-item`,
|
|
163
|
+
`${prefix}-class-column-item-label`,
|
|
164
|
+
`${prefix}-class-footer`,
|
|
165
|
+
],
|
|
166
|
+
mixins: [ChildrenMixin(RELATION_MAP.DropdownItem)],
|
|
167
|
+
props: {
|
|
168
|
+
...props,
|
|
201
169
|
},
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return
|
|
170
|
+
emits: ['close', 'closed', 'change', 'reset', 'confirm', 'opened', 'open'],
|
|
171
|
+
data() {
|
|
172
|
+
return {
|
|
173
|
+
prefix,
|
|
174
|
+
classPrefix: name,
|
|
175
|
+
show: false,
|
|
176
|
+
top: 0,
|
|
177
|
+
maskHeight: 0,
|
|
178
|
+
initValue: null,
|
|
179
|
+
hasChanged: false,
|
|
180
|
+
duration: menuProps.duration.default,
|
|
181
|
+
zIndex: menuProps.zIndex.default,
|
|
182
|
+
overlay: menuProps.showOverlay.default,
|
|
183
|
+
labelAlias: 'label',
|
|
184
|
+
valueAlias: 'value',
|
|
185
|
+
computedLabel: '',
|
|
186
|
+
firstCheckedValue: '',
|
|
187
|
+
|
|
188
|
+
dataValue: coalesce(this.value, this.defaultValue),
|
|
189
|
+
|
|
190
|
+
wrapperVisible: false,
|
|
191
|
+
tools,
|
|
192
|
+
|
|
193
|
+
windowTop: 0,
|
|
194
|
+
};
|
|
205
195
|
},
|
|
196
|
+
computed: {
|
|
197
|
+
footerBtnTClass() {
|
|
198
|
+
return canUseVirtualHost() ? this.footerBtnRealClass : '';
|
|
199
|
+
},
|
|
200
|
+
footerBtnClass() {
|
|
201
|
+
return !canUseVirtualHost() ? this.footerBtnRealClass : '';
|
|
202
|
+
},
|
|
203
|
+
footerBtnRealClass() {
|
|
204
|
+
const { classPrefix } = this;
|
|
205
|
+
return `${classPrefix}__footer-btn ${classPrefix}__reset-btn`;
|
|
206
|
+
},
|
|
206
207
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
208
|
+
confirmBtnTClass() {
|
|
209
|
+
return canUseVirtualHost() ? this.confirmBtnRealClass : '';
|
|
210
|
+
},
|
|
211
|
+
confirmBtnClass() {
|
|
212
|
+
return !canUseVirtualHost() ? this.confirmBtnRealClass : '';
|
|
213
|
+
},
|
|
214
|
+
confirmBtnRealClass() {
|
|
215
|
+
const { classPrefix } = this;
|
|
216
|
+
return `${classPrefix}__footer-btn ${classPrefix}__confirm-btn`;
|
|
217
|
+
},
|
|
217
218
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
radioGroupCustomStyle() {
|
|
220
|
+
return tools._style([
|
|
221
|
+
{
|
|
222
|
+
width: '100%',
|
|
223
|
+
overflow: 'scroll',
|
|
224
|
+
boxSizing: 'border-box',
|
|
224
225
|
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
display: 'grid',
|
|
227
|
+
gridGap: '0px',
|
|
227
228
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
|
|
230
|
+
},
|
|
231
|
+
]);
|
|
232
|
+
},
|
|
233
|
+
checkboxGroupCustomStyle() {
|
|
234
|
+
return tools._style([
|
|
235
|
+
{
|
|
236
|
+
width: '100%',
|
|
237
|
+
overflow: 'scroll',
|
|
238
|
+
boxSizing: 'border-box',
|
|
239
|
+
|
|
240
|
+
display: 'grid',
|
|
241
|
+
gridGap: '12px',
|
|
242
|
+
|
|
243
|
+
gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
|
|
244
|
+
padding: '16px',
|
|
245
|
+
},
|
|
246
|
+
]);
|
|
247
|
+
},
|
|
231
248
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
{
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
boxSizing: 'border-box',
|
|
238
|
-
|
|
239
|
-
display: 'grid',
|
|
240
|
-
gridGap: '12px',
|
|
241
|
-
|
|
242
|
-
gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
|
|
243
|
-
padding: '16px',
|
|
249
|
+
watch: {
|
|
250
|
+
keys: {
|
|
251
|
+
handler(obj) {
|
|
252
|
+
this.labelAlias = obj?.label || 'label';
|
|
253
|
+
this.valueAlias = obj?.value || 'value';
|
|
244
254
|
},
|
|
245
|
-
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
watch: {
|
|
249
|
-
keys: {
|
|
250
|
-
handler(obj) {
|
|
251
|
-
this.labelAlias = obj?.label || 'label';
|
|
252
|
-
this.valueAlias = obj?.value || 'value';
|
|
255
|
+
immediate: true,
|
|
253
256
|
},
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
value: {
|
|
258
|
+
handler(value) {
|
|
259
|
+
this.dataValue = value;
|
|
260
|
+
},
|
|
261
|
+
immediate: true,
|
|
259
262
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
handler(v) {
|
|
264
|
-
const { options, labelAlias, valueAlias } = this;
|
|
263
|
+
dataValue: {
|
|
264
|
+
handler(v) {
|
|
265
|
+
const { options, labelAlias, valueAlias } = this;
|
|
265
266
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
if (this.multiple) {
|
|
268
|
+
if (v && !Array.isArray(v)) throw TypeError('应传入数组类型的 value');
|
|
269
|
+
}
|
|
269
270
|
|
|
270
|
-
|
|
271
|
+
const target = options.find(item => item[valueAlias] === v);
|
|
271
272
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
if (target) {
|
|
274
|
+
this.computedLabel = target[labelAlias];
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
immediate: true,
|
|
275
278
|
},
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
label: 'getParentAllItems',
|
|
280
|
+
computedLabel: 'getParentAllItems',
|
|
281
|
+
disabled: 'getParentAllItems',
|
|
282
|
+
show: {
|
|
283
|
+
handler(visible) {
|
|
284
|
+
if (visible) {
|
|
285
|
+
this.getParentBottom(() => {
|
|
286
|
+
this.wrapperVisible = true;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
immediate: true,
|
|
288
291
|
},
|
|
289
|
-
immediate: true,
|
|
290
292
|
},
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
this.windowTop = windowTop || 0;
|
|
295
|
-
},
|
|
296
|
-
methods: {
|
|
297
|
-
getStyles,
|
|
298
|
-
innerAfterLinked(target) {
|
|
299
|
-
const { zIndex, duration, showOverlay } = target;
|
|
300
|
-
|
|
301
|
-
this.zIndex = zIndex;
|
|
302
|
-
this.duration = duration;
|
|
303
|
-
this.showOverlay = showOverlay;
|
|
304
|
-
},
|
|
305
|
-
getParentAllItems() {
|
|
306
|
-
this[RELATION_MAP.DropdownItem]?.getAllItems();
|
|
307
|
-
},
|
|
308
|
-
closeDropdown() {
|
|
309
|
-
this[RELATION_MAP.DropdownItem].activeIdx = -1;
|
|
310
|
-
this.show = false;
|
|
311
|
-
this.$emit('close');
|
|
293
|
+
mounted() {
|
|
294
|
+
const { windowTop } = getWindowInfo();
|
|
295
|
+
this.windowTop = windowTop || 0;
|
|
312
296
|
},
|
|
297
|
+
methods: {
|
|
298
|
+
getStyles,
|
|
299
|
+
innerAfterLinked(target) {
|
|
300
|
+
const { zIndex, duration, showOverlay } = target;
|
|
301
|
+
|
|
302
|
+
this.zIndex = zIndex;
|
|
303
|
+
this.duration = duration;
|
|
304
|
+
this.showOverlay = showOverlay;
|
|
305
|
+
},
|
|
306
|
+
getParentAllItems() {
|
|
307
|
+
this[RELATION_MAP.DropdownItem]?.getAllItems();
|
|
308
|
+
},
|
|
309
|
+
closeDropdown() {
|
|
310
|
+
this[RELATION_MAP.DropdownItem].activeIdx = -1;
|
|
311
|
+
this.show = false;
|
|
312
|
+
this.$emit('close');
|
|
313
|
+
},
|
|
313
314
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
getParentBottom(cb) {
|
|
316
|
+
getRect(this[RELATION_MAP.DropdownItem], `#${prefix}-bar`).then((rect) => {
|
|
317
|
+
this.top = rect.bottom + (this.windowTop || 0);
|
|
318
|
+
this.maskHeight = rect.top;
|
|
318
319
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
setTimeout(() => {
|
|
321
|
+
cb();
|
|
322
|
+
}, 20);
|
|
323
|
+
});
|
|
324
|
+
},
|
|
324
325
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
handleTreeClick(e) {
|
|
327
|
+
const { level, value: itemValue } = e.currentTarget.dataset;
|
|
328
|
+
const { dataValue } = this;
|
|
328
329
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
dataValue[level] = itemValue;
|
|
331
|
+
this._trigger('change', { value: dataValue });
|
|
332
|
+
},
|
|
332
333
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
334
|
+
onRadioChange(e, curValue) {
|
|
335
|
+
this.handleRadioChange({ value: curValue });
|
|
336
|
+
},
|
|
337
|
+
onCheckboxChange(e) {
|
|
338
|
+
const { checkAll, dataIndeterminate } = this.$refs.checkboxGroupRef;
|
|
339
|
+
const { context: { value, label }, checked } = e;
|
|
340
|
+
this.$refs.checkboxGroupRef.updateValue({
|
|
341
|
+
value,
|
|
342
|
+
checkAll,
|
|
343
|
+
indeterminate: dataIndeterminate,
|
|
344
|
+
checked,
|
|
345
|
+
item: { label, value, checked },
|
|
346
|
+
validChildren: false,
|
|
347
|
+
});
|
|
348
|
+
},
|
|
348
349
|
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
handleRadioChange(e) {
|
|
351
|
+
const { value } = e;
|
|
351
352
|
|
|
352
|
-
|
|
353
|
+
this._trigger('change', { value });
|
|
353
354
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
if (!this.multiple) {
|
|
356
|
+
this.closeDropdown();
|
|
357
|
+
} else {
|
|
358
|
+
const firstChecked = this.options.find(item => value.includes(item.value));
|
|
359
|
+
if (firstChecked) {
|
|
360
|
+
this.firstCheckedValue = firstChecked.value;
|
|
361
|
+
}
|
|
360
362
|
}
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
+
},
|
|
363
364
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
handleMaskClick() {
|
|
366
|
+
if (this[RELATION_MAP.DropdownItem]?.closeOnClickOverlay) {
|
|
367
|
+
this.closeDropdown();
|
|
368
|
+
}
|
|
369
|
+
},
|
|
369
370
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
handleReset() {
|
|
372
|
+
this._trigger('change', { value: [] });
|
|
373
|
+
this._trigger('reset');
|
|
374
|
+
},
|
|
374
375
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
handleConfirm() {
|
|
377
|
+
this._trigger('confirm', { value: this.dataValue });
|
|
378
|
+
this.closeDropdown();
|
|
378
379
|
// 在关闭 popup 后才自动滚动到首个选项
|
|
379
380
|
// this.firstCheckedValue = this.firstCheckedValue;
|
|
380
|
-
|
|
381
|
+
},
|
|
381
382
|
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
onLeaved() {
|
|
384
|
+
this.wrapperVisible = false;
|
|
385
|
+
},
|
|
384
386
|
},
|
|
385
|
-
},
|
|
386
|
-
}
|
|
387
|
+
}),
|
|
388
|
+
};
|
|
387
389
|
|
|
388
390
|
</script>
|
|
389
391
|
<style scoped src="./dropdown-item.css"></style>
|
|
@@ -40,13 +40,13 @@ export default {
|
|
|
40
40
|
},
|
|
41
41
|
/** 选中值 */
|
|
42
42
|
value: {
|
|
43
|
-
type: [String, Number, Array],
|
|
44
|
-
default:
|
|
43
|
+
type: [String, Number, Array, null],
|
|
44
|
+
default: null as TdDropdownItemProps['value'],
|
|
45
45
|
},
|
|
46
46
|
/** 选中值,非受控属性 */
|
|
47
47
|
defaultValue: {
|
|
48
|
-
type: [String, Number, Array],
|
|
49
|
-
default:
|
|
48
|
+
type: [String, Number, Array, null],
|
|
49
|
+
default: null as TdDropdownItemProps['defaultValue'],
|
|
50
50
|
},
|
|
51
51
|
/** 值改变时触发 */
|
|
52
52
|
onChange: {
|
|
@@ -44,11 +44,11 @@ export interface TdDropdownItemProps {
|
|
|
44
44
|
/**
|
|
45
45
|
* 选中值
|
|
46
46
|
*/
|
|
47
|
-
value?: DropdownValue;
|
|
47
|
+
value?: DropdownValue | null;
|
|
48
48
|
/**
|
|
49
49
|
* 选中值,非受控属性
|
|
50
50
|
*/
|
|
51
|
-
defaultValue?: DropdownValue;
|
|
51
|
+
defaultValue?: DropdownValue | null;
|
|
52
52
|
/**
|
|
53
53
|
* 值改变时触发
|
|
54
54
|
*/
|
|
@@ -70,7 +70,7 @@ export interface TdDropdownItemProps {
|
|
|
70
70
|
export interface DropdownOption {
|
|
71
71
|
label: string;
|
|
72
72
|
disabled: boolean;
|
|
73
|
-
value: DropdownValue;
|
|
73
|
+
value: DropdownValue | null;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export type DropdownValue = string | number | Array<DropdownValue>;
|