@uzum-tech/ui 2.4.7 → 2.4.8
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/dist/index.js +212 -73
- package/dist/index.mjs +212 -73
- package/dist/index.prod.js +2 -2
- package/dist/index.prod.mjs +3 -3
- package/es/components.d.ts +33 -10
- package/es/dynamic-tags/index.d.ts +3 -3
- package/es/dynamic-tags/index.mjs +2 -1
- package/es/dynamic-tags/src/DynamicTags.d.ts +74 -1177
- package/es/dynamic-tags/src/DynamicTags.mjs +150 -107
- package/es/dynamic-tags/src/interface.d.ts +1146 -6
- package/es/dynamic-tags/src/interface.mjs +34 -1
- package/es/dynamic-tags/src/styles/index.cssr.mjs +35 -3
- package/es/dynamic-tags/styles/dark.mjs +4 -2
- package/es/dynamic-tags/styles/light.d.ts +2 -0
- package/es/dynamic-tags/styles/light.mjs +4 -2
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/components.d.ts +33 -10
- package/lib/dynamic-tags/index.d.ts +3 -3
- package/lib/dynamic-tags/index.js +3 -2
- package/lib/dynamic-tags/src/DynamicTags.d.ts +74 -1177
- package/lib/dynamic-tags/src/DynamicTags.js +142 -77
- package/lib/dynamic-tags/src/interface.d.ts +1146 -6
- package/lib/dynamic-tags/src/interface.js +24 -0
- package/lib/dynamic-tags/src/styles/index.cssr.js +34 -2
- package/lib/dynamic-tags/styles/dark.js +4 -2
- package/lib/dynamic-tags/styles/light.d.ts +2 -0
- package/lib/dynamic-tags/styles/light.js +4 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/web-types.json +11 -1
|
@@ -8,37 +8,9 @@ import { UButton } from "../../button/index.mjs";
|
|
|
8
8
|
import { UInput } from "../../input/index.mjs";
|
|
9
9
|
import { USpace } from "../../space/index.mjs";
|
|
10
10
|
import { UTag } from "../../tag/index.mjs";
|
|
11
|
-
import commonProps from "../../tag/src/common-props.mjs";
|
|
12
11
|
import { dynamicTagsLight } from "../styles/index.mjs";
|
|
12
|
+
import { dynamicTagsProps } from "./interface.mjs";
|
|
13
13
|
import style from "./styles/index.cssr.mjs";
|
|
14
|
-
export const dynamicTagsProps = Object.assign(Object.assign(Object.assign({}, useTheme.props), commonProps), {
|
|
15
|
-
size: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: 'medium'
|
|
18
|
-
},
|
|
19
|
-
closable: {
|
|
20
|
-
type: Boolean,
|
|
21
|
-
default: true
|
|
22
|
-
},
|
|
23
|
-
defaultValue: {
|
|
24
|
-
type: Array,
|
|
25
|
-
default: () => []
|
|
26
|
-
},
|
|
27
|
-
value: Array,
|
|
28
|
-
inputStyle: [String, Object],
|
|
29
|
-
inputProps: Object,
|
|
30
|
-
max: Number,
|
|
31
|
-
tagStyle: [String, Object],
|
|
32
|
-
renderTag: Function,
|
|
33
|
-
onCreate: {
|
|
34
|
-
type: Function,
|
|
35
|
-
default: label => label
|
|
36
|
-
},
|
|
37
|
-
'onUpdate:value': [Function, Array],
|
|
38
|
-
onUpdateValue: [Function, Array],
|
|
39
|
-
// deprecated
|
|
40
|
-
onChange: [Function, Array]
|
|
41
|
-
});
|
|
42
14
|
export default defineComponent({
|
|
43
15
|
name: 'DynamicTags',
|
|
44
16
|
props: dynamicTagsProps,
|
|
@@ -51,24 +23,23 @@ export default defineComponent({
|
|
|
51
23
|
}
|
|
52
24
|
});
|
|
53
25
|
}
|
|
26
|
+
const {
|
|
27
|
+
localeRef
|
|
28
|
+
} = useLocale('DynamicTags');
|
|
54
29
|
const {
|
|
55
30
|
mergedClsPrefixRef,
|
|
56
31
|
inlineThemeDisabled
|
|
57
32
|
} = useConfig(props);
|
|
58
|
-
const {
|
|
59
|
-
localeRef
|
|
60
|
-
} = useLocale('DynamicTags');
|
|
61
33
|
const formItem = useFormItem(props);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
} = formItem;
|
|
34
|
+
const themeRef = useTheme('DynamicTags', '-dynamic-tags', style, dynamicTagsLight, props, mergedClsPrefixRef);
|
|
35
|
+
const inputInstRef = ref(null);
|
|
65
36
|
const inputValueRef = ref('');
|
|
66
37
|
const showInputRef = ref(false);
|
|
67
38
|
const inputForceFocusedRef = ref(true);
|
|
68
|
-
const inputInstRef = ref(null);
|
|
69
|
-
const themeRef = useTheme('DynamicTags', '-dynamic-tags', style, dynamicTagsLight, props, mergedClsPrefixRef);
|
|
70
39
|
const uncontrolledValueRef = ref(props.defaultValue);
|
|
71
40
|
const controlledValueRef = toRef(props, 'value');
|
|
41
|
+
const dragIndexRef = ref(null);
|
|
42
|
+
const dragOverIndexRef = ref(null);
|
|
72
43
|
const mergedValueRef = useMergedState(controlledValueRef, uncontrolledValueRef);
|
|
73
44
|
const localizedAddRef = computed(() => {
|
|
74
45
|
return localeRef.value.add;
|
|
@@ -76,38 +47,47 @@ export default defineComponent({
|
|
|
76
47
|
const inputSizeRef = computed(() => {
|
|
77
48
|
return smallerSize(props.size);
|
|
78
49
|
});
|
|
50
|
+
const buttonSizeRef = computed(() => {
|
|
51
|
+
return smallerSize(props.size);
|
|
52
|
+
});
|
|
79
53
|
const triggerDisabledRef = computed(() => {
|
|
80
|
-
return mergedDisabledRef.value || !!props.max && mergedValueRef.value.length >= props.max;
|
|
54
|
+
return formItem.mergedDisabledRef.value || !!props.max && mergedValueRef.value.length >= props.max;
|
|
81
55
|
});
|
|
82
|
-
|
|
56
|
+
const cssVarsRef = computed(() => {
|
|
83
57
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
self: {
|
|
59
|
+
inputWidth,
|
|
60
|
+
draggingOpacity,
|
|
61
|
+
dropIndicatorColor
|
|
62
|
+
}
|
|
63
|
+
} = themeRef.value;
|
|
64
|
+
return {
|
|
65
|
+
'--u-input-width': inputWidth,
|
|
66
|
+
'--u-dragging-opacity': draggingOpacity,
|
|
67
|
+
'--u-drop-indicator-color': dropIndicatorColor
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
const tagSizeRef = computed(() => {
|
|
88
71
|
const {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
72
|
+
size
|
|
73
|
+
} = props;
|
|
74
|
+
return size === 'huge' ? 'medium' : 'small';
|
|
75
|
+
});
|
|
76
|
+
const themeClassHandle = inlineThemeDisabled ? useThemeClass('dynamic-tags', undefined, cssVarsRef, props) : undefined;
|
|
77
|
+
const doChange = value => {
|
|
78
|
+
if (props.onChange) call(props.onChange, value);
|
|
79
|
+
if (props.onUpdateValue) call(props.onUpdateValue, value);
|
|
80
|
+
if (props['onUpdate:value']) call(props['onUpdate:value'], value);
|
|
95
81
|
uncontrolledValueRef.value = value;
|
|
96
|
-
triggerFormInput();
|
|
97
|
-
triggerFormChange();
|
|
98
|
-
}
|
|
99
|
-
|
|
82
|
+
formItem.triggerFormInput();
|
|
83
|
+
formItem.triggerFormChange();
|
|
84
|
+
};
|
|
85
|
+
const handleCloseClick = index => {
|
|
100
86
|
const tags = mergedValueRef.value.slice(0);
|
|
101
87
|
tags.splice(index, 1);
|
|
102
88
|
doChange(tags);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
switch (e.key) {
|
|
106
|
-
case 'Enter':
|
|
107
|
-
handleInputConfirm();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function handleInputConfirm(externalValue) {
|
|
89
|
+
};
|
|
90
|
+
const handleInputConfirm = externalValue => {
|
|
111
91
|
const nextValue = externalValue !== null && externalValue !== void 0 ? externalValue : inputValueRef.value;
|
|
112
92
|
if (nextValue) {
|
|
113
93
|
const tags = mergedValueRef.value.slice(0);
|
|
@@ -117,56 +97,99 @@ export default defineComponent({
|
|
|
117
97
|
showInputRef.value = false;
|
|
118
98
|
inputForceFocusedRef.value = true;
|
|
119
99
|
inputValueRef.value = '';
|
|
120
|
-
}
|
|
121
|
-
|
|
100
|
+
};
|
|
101
|
+
const handleInputKeyUp = event => {
|
|
102
|
+
if (event.key === 'Enter') handleInputConfirm();
|
|
103
|
+
};
|
|
104
|
+
const handleInputBlur = () => {
|
|
122
105
|
handleInputConfirm();
|
|
123
|
-
}
|
|
124
|
-
|
|
106
|
+
};
|
|
107
|
+
const handleAddClick = () => {
|
|
125
108
|
showInputRef.value = true;
|
|
126
109
|
void nextTick(() => {
|
|
127
110
|
var _a;
|
|
128
111
|
(_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.focus();
|
|
129
112
|
inputForceFocusedRef.value = false;
|
|
130
113
|
});
|
|
131
|
-
}
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
114
|
+
};
|
|
115
|
+
const moveItem = (from, to) => {
|
|
116
|
+
if (from === to) return;
|
|
117
|
+
const values = [...mergedValueRef.value];
|
|
118
|
+
const [item] = values.splice(from, 1);
|
|
119
|
+
values.splice(to, 0, item);
|
|
120
|
+
doChange(values);
|
|
121
|
+
};
|
|
122
|
+
const resetDrag = () => {
|
|
123
|
+
dragIndexRef.value = null;
|
|
124
|
+
dragOverIndexRef.value = null;
|
|
125
|
+
};
|
|
126
|
+
const handleDragStart = (event, index) => {
|
|
127
|
+
dragIndexRef.value = index;
|
|
128
|
+
if (event.dataTransfer) {
|
|
129
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
130
|
+
event.dataTransfer.setData('text/plain', String(index));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const handleDragOver = (event, index) => {
|
|
134
|
+
if (dragIndexRef.value === null) return;
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
dragOverIndexRef.value = index;
|
|
137
|
+
};
|
|
138
|
+
const handleDragLeave = (event, index) => {
|
|
139
|
+
if (dragOverIndexRef.value !== index) return;
|
|
140
|
+
const current = event.currentTarget;
|
|
141
|
+
const related = event.relatedTarget;
|
|
142
|
+
if (current && related && current.contains(related)) return;
|
|
143
|
+
dragOverIndexRef.value = null;
|
|
144
|
+
};
|
|
145
|
+
const handleDrop = (event, index) => {
|
|
146
|
+
if (dragIndexRef.value === null) return;
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
moveItem(dragIndexRef.value, index);
|
|
149
|
+
resetDrag();
|
|
150
|
+
};
|
|
151
|
+
const getDragProps = index => {
|
|
152
|
+
if (!props.draggable || formItem.mergedDisabledRef.value) return {};
|
|
153
|
+
const prefix = `${mergedClsPrefixRef.value}-dynamic-tags__tag`;
|
|
154
|
+
const from = dragIndexRef.value;
|
|
155
|
+
const isOver = from !== null && dragOverIndexRef.value === index;
|
|
138
156
|
return {
|
|
139
|
-
|
|
157
|
+
class: [prefix, `${prefix}--draggable`, {
|
|
158
|
+
[`${prefix}--dragging`]: from === index,
|
|
159
|
+
[`${prefix}--drop-before`]: isOver && from > index,
|
|
160
|
+
[`${prefix}--drop-after`]: isOver && from < index
|
|
161
|
+
}],
|
|
162
|
+
draggable: true,
|
|
163
|
+
onDragstart: event => handleDragStart(event, index),
|
|
164
|
+
onDragover: event => handleDragOver(event, index),
|
|
165
|
+
onDragleave: event => handleDragLeave(event, index),
|
|
166
|
+
onDrop: event => handleDrop(event, index),
|
|
167
|
+
onDragend: resetDrag
|
|
140
168
|
};
|
|
141
|
-
}
|
|
142
|
-
const tagSizeRef = computed(() => {
|
|
143
|
-
const {
|
|
144
|
-
size
|
|
145
|
-
} = props;
|
|
146
|
-
return size === 'huge' ? 'medium' : 'small';
|
|
147
|
-
});
|
|
148
|
-
const themeClassHandle = inlineThemeDisabled ? useThemeClass('dynamic-tags', undefined, cssVarsRef, props) : undefined;
|
|
169
|
+
};
|
|
149
170
|
return {
|
|
150
171
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
151
172
|
inputInstRef,
|
|
152
173
|
localizedAdd: localizedAddRef,
|
|
153
174
|
inputSize: inputSizeRef,
|
|
154
175
|
inputValue: inputValueRef,
|
|
176
|
+
buttonSize: buttonSizeRef,
|
|
155
177
|
showInput: showInputRef,
|
|
156
178
|
inputForceFocused: inputForceFocusedRef,
|
|
157
179
|
mergedValue: mergedValueRef,
|
|
158
|
-
mergedDisabled: mergedDisabledRef,
|
|
180
|
+
mergedDisabled: formItem.mergedDisabledRef,
|
|
159
181
|
triggerDisabled: triggerDisabledRef,
|
|
182
|
+
mergedTheme: themeRef,
|
|
183
|
+
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
|
|
184
|
+
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
185
|
+
tagSize: tagSizeRef,
|
|
160
186
|
handleInputKeyUp,
|
|
161
187
|
handleAddClick,
|
|
162
188
|
handleInputBlur,
|
|
163
189
|
handleCloseClick,
|
|
164
190
|
handleInputConfirm,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
168
|
-
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender,
|
|
169
|
-
tagSize: tagSizeRef
|
|
191
|
+
getDragProps,
|
|
192
|
+
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
170
193
|
};
|
|
171
194
|
},
|
|
172
195
|
render() {
|
|
@@ -174,12 +197,13 @@ export default defineComponent({
|
|
|
174
197
|
mergedTheme,
|
|
175
198
|
cssVars,
|
|
176
199
|
mergedClsPrefix,
|
|
200
|
+
themeClass,
|
|
177
201
|
onRender,
|
|
178
202
|
renderTag
|
|
179
203
|
} = this;
|
|
180
204
|
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
181
205
|
return h(USpace, {
|
|
182
|
-
class: [`${mergedClsPrefix}-dynamic-tags`,
|
|
206
|
+
class: [`${mergedClsPrefix}-dynamic-tags`, themeClass],
|
|
183
207
|
size: "small",
|
|
184
208
|
style: cssVars,
|
|
185
209
|
theme: mergedTheme.peers.Space,
|
|
@@ -189,42 +213,61 @@ export default defineComponent({
|
|
|
189
213
|
default: () => {
|
|
190
214
|
const {
|
|
191
215
|
mergedTheme,
|
|
216
|
+
mergedValue,
|
|
192
217
|
tagStyle,
|
|
218
|
+
tagSize,
|
|
193
219
|
type,
|
|
194
220
|
round,
|
|
195
221
|
color,
|
|
196
222
|
closable,
|
|
197
223
|
mergedDisabled,
|
|
224
|
+
draggable,
|
|
198
225
|
showInput,
|
|
199
226
|
inputValue,
|
|
200
227
|
inputStyle,
|
|
228
|
+
inputProps,
|
|
201
229
|
inputSize,
|
|
230
|
+
buttonSize,
|
|
202
231
|
inputForceFocused,
|
|
203
232
|
triggerDisabled,
|
|
233
|
+
$slots,
|
|
204
234
|
handleInputKeyUp,
|
|
205
235
|
handleInputBlur,
|
|
206
236
|
handleAddClick,
|
|
207
237
|
handleCloseClick,
|
|
208
238
|
handleInputConfirm,
|
|
209
|
-
|
|
239
|
+
getDragProps
|
|
210
240
|
} = this;
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
disabled: mergedDisabled,
|
|
222
|
-
onClose: () => {
|
|
223
|
-
handleCloseClick(index);
|
|
241
|
+
return mergedValue.map((tag, index) => {
|
|
242
|
+
if (renderTag) {
|
|
243
|
+
const customTag = renderTag(tag, index);
|
|
244
|
+
if (!draggable) return customTag;
|
|
245
|
+
const dragProps = getDragProps(index);
|
|
246
|
+
return h("div", Object.assign({
|
|
247
|
+
key: index
|
|
248
|
+
}, dragProps, {
|
|
249
|
+
class: [`${mergedClsPrefix}-dynamic-tags__tag-wrapper`, dragProps.class]
|
|
250
|
+
}), customTag);
|
|
224
251
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
252
|
+
return h(UTag, Object.assign({
|
|
253
|
+
key: index
|
|
254
|
+
}, getDragProps(index), {
|
|
255
|
+
theme: mergedTheme.peers.Tag,
|
|
256
|
+
themeOverrides: mergedTheme.peerOverrides.Tag,
|
|
257
|
+
style: tagStyle,
|
|
258
|
+
type: type,
|
|
259
|
+
round: round,
|
|
260
|
+
size: tagSize,
|
|
261
|
+
color: color,
|
|
262
|
+
closable: closable,
|
|
263
|
+
disabled: mergedDisabled,
|
|
264
|
+
onClose: () => {
|
|
265
|
+
handleCloseClick(index);
|
|
266
|
+
}
|
|
267
|
+
}), {
|
|
268
|
+
default: () => typeof tag === 'string' ? tag : tag.label
|
|
269
|
+
});
|
|
270
|
+
}).concat(showInput ? $slots.input ? $slots.input({
|
|
228
271
|
submit: handleInputConfirm,
|
|
229
272
|
deactivate: handleInputBlur
|
|
230
273
|
}) : h(UInput, Object.assign({
|
|
@@ -232,7 +275,7 @@ export default defineComponent({
|
|
|
232
275
|
size: inputSize,
|
|
233
276
|
style: inputStyle,
|
|
234
277
|
autosize: true
|
|
235
|
-
},
|
|
278
|
+
}, inputProps, {
|
|
236
279
|
ref: "inputInstRef",
|
|
237
280
|
value: inputValue,
|
|
238
281
|
onUpdateValue: v => {
|
|
@@ -251,7 +294,7 @@ export default defineComponent({
|
|
|
251
294
|
disabled: triggerDisabled,
|
|
252
295
|
theme: mergedTheme.peers.Button,
|
|
253
296
|
themeOverrides: mergedTheme.peerOverrides.Button,
|
|
254
|
-
size:
|
|
297
|
+
size: buttonSize,
|
|
255
298
|
onClick: handleAddClick
|
|
256
299
|
}, {
|
|
257
300
|
icon: () => h(UBaseIcon, {
|