@destyler/dynamic 0.0.1-beta.21
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/LICENSE +21 -0
- package/dist/component.cjs +20 -0
- package/dist/component.d.cts +4 -0
- package/dist/component.d.mts +4 -0
- package/dist/component.d.ts +4 -0
- package/dist/component.mjs +9 -0
- package/dist/index.cjs +533 -0
- package/dist/index.d.cts +502 -0
- package/dist/index.d.mts +502 -0
- package/dist/index.d.ts +502 -0
- package/dist/index.mjs +526 -0
- package/dist/resolver.cjs +20 -0
- package/dist/resolver.d.cts +6 -0
- package/dist/resolver.d.mts +6 -0
- package/dist/resolver.d.ts +6 -0
- package/dist/resolver.mjs +17 -0
- package/package.json +48 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import { defineComponent, toRefs, ref, h, mergeProps, onMounted, withDirectives, nextTick, computed } from 'vue';
|
|
2
|
+
import { DestylerPrimitive } from '@destyler/primitive';
|
|
3
|
+
import { useDirection, useVModel, useForwardExpose, useFormControl, useArrowNavigation, useId } from '@destyler/composition';
|
|
4
|
+
import { createContext } from '@destyler/shared';
|
|
5
|
+
import { useFocusWithin } from '@vueuse/core';
|
|
6
|
+
import { createCollection, DestylerCollectionSlot, DestylerCollectionItem } from '@destyler/collection';
|
|
7
|
+
import { DestylerVisuallyhiddenInput } from '@destyler/visually-hidden/dist/component';
|
|
8
|
+
import { BindOnceDirective } from '@destyler/directives';
|
|
9
|
+
|
|
10
|
+
const destylerDynamicRootProps = {
|
|
11
|
+
as: {
|
|
12
|
+
type: [String, Object],
|
|
13
|
+
required: false,
|
|
14
|
+
default: "div"
|
|
15
|
+
},
|
|
16
|
+
asChild: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
required: false,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
modelValue: {
|
|
22
|
+
type: Array,
|
|
23
|
+
required: false,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
defaultValue: {
|
|
27
|
+
type: Array,
|
|
28
|
+
required: false
|
|
29
|
+
},
|
|
30
|
+
addOnPaste: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
duplicate: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
required: false
|
|
41
|
+
},
|
|
42
|
+
delimiter: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: false,
|
|
45
|
+
default: ","
|
|
46
|
+
},
|
|
47
|
+
dir: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: false
|
|
50
|
+
},
|
|
51
|
+
max: {
|
|
52
|
+
type: Number,
|
|
53
|
+
required: false,
|
|
54
|
+
default: 0
|
|
55
|
+
},
|
|
56
|
+
required: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
name: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
id: {
|
|
65
|
+
type: String,
|
|
66
|
+
required: false
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const [injectDynamicRootContext, provideDynamicRootContext] = createContext("DestylerDynamicRoot");
|
|
70
|
+
const DestylerDynamicRoot = defineComponent({
|
|
71
|
+
name: "DestylerDynamicRoot",
|
|
72
|
+
props: destylerDynamicRootProps,
|
|
73
|
+
emits: ["update:modelValue", "invalid"],
|
|
74
|
+
setup(props, { emit }) {
|
|
75
|
+
const { addOnPaste, disabled, delimiter, max, id, dir: propDir } = toRefs(props);
|
|
76
|
+
const dir = useDirection(propDir);
|
|
77
|
+
const modelValue = useVModel(props, "modelValue", emit, {
|
|
78
|
+
defaultValue: props.defaultValue,
|
|
79
|
+
passive: true,
|
|
80
|
+
deep: true
|
|
81
|
+
});
|
|
82
|
+
const { forwardRef, currentElement } = useForwardExpose();
|
|
83
|
+
const { focused } = useFocusWithin(currentElement);
|
|
84
|
+
const isFormControl = useFormControl(currentElement);
|
|
85
|
+
const { getItems } = createCollection();
|
|
86
|
+
const selectedElement = ref();
|
|
87
|
+
const isInvalidInput = ref(false);
|
|
88
|
+
provideDynamicRootContext({
|
|
89
|
+
modelValue,
|
|
90
|
+
onAddValue: (payload) => {
|
|
91
|
+
if (modelValue.value.length >= max.value && !!max.value) {
|
|
92
|
+
emit("invalid", payload);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (props.duplicate) {
|
|
96
|
+
modelValue.value.push(payload);
|
|
97
|
+
return true;
|
|
98
|
+
} else {
|
|
99
|
+
const exist = modelValue.value.includes(payload);
|
|
100
|
+
if (!exist) {
|
|
101
|
+
modelValue.value.push(payload);
|
|
102
|
+
return true;
|
|
103
|
+
} else {
|
|
104
|
+
isInvalidInput.value = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
emit("invalid", payload);
|
|
108
|
+
return false;
|
|
109
|
+
},
|
|
110
|
+
onRemoveValue: (index) => {
|
|
111
|
+
if (index !== -1)
|
|
112
|
+
modelValue.value.splice(index, 1);
|
|
113
|
+
},
|
|
114
|
+
onInputKeydown: (event) => {
|
|
115
|
+
const target = event.target;
|
|
116
|
+
const collection = getItems().map((i) => i.ref).filter((i) => i.dataset.disabled !== "");
|
|
117
|
+
if (!collection.length)
|
|
118
|
+
return;
|
|
119
|
+
const lastTag = collection.at(-1);
|
|
120
|
+
switch (event.key) {
|
|
121
|
+
case "Delete":
|
|
122
|
+
case "Backspace": {
|
|
123
|
+
if (target.selectionStart !== 0 || target.selectionEnd !== 0)
|
|
124
|
+
break;
|
|
125
|
+
if (selectedElement.value) {
|
|
126
|
+
const index = collection.findIndex((i) => i === selectedElement.value);
|
|
127
|
+
modelValue.value.splice(index, 1);
|
|
128
|
+
selectedElement.value = selectedElement.value === lastTag ? collection.at(index - 1) : collection.at(index + 1);
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
} else if (event.key === "Backspace") {
|
|
131
|
+
selectedElement.value = lastTag;
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "Home":
|
|
137
|
+
case "End":
|
|
138
|
+
case "ArrowRight":
|
|
139
|
+
case "ArrowLeft": {
|
|
140
|
+
const isArrowRight = event.key === "ArrowRight" && dir.value === "ltr" || event.key === "ArrowLeft" && dir.value === "rtl";
|
|
141
|
+
const isArrowLeft = !isArrowRight;
|
|
142
|
+
if (target.selectionStart !== 0 || target.selectionEnd !== 0)
|
|
143
|
+
break;
|
|
144
|
+
if (isArrowLeft && !selectedElement.value) {
|
|
145
|
+
selectedElement.value = lastTag;
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
} else if (isArrowRight && lastTag && selectedElement.value === lastTag) {
|
|
148
|
+
selectedElement.value = void 0;
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
} else if (selectedElement.value) {
|
|
151
|
+
const el = useArrowNavigation(event, selectedElement.value, void 0, {
|
|
152
|
+
itemsArray: collection,
|
|
153
|
+
loop: false,
|
|
154
|
+
dir: dir.value
|
|
155
|
+
});
|
|
156
|
+
if (el)
|
|
157
|
+
selectedElement.value = el;
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "ArrowUp":
|
|
163
|
+
case "ArrowDown": {
|
|
164
|
+
if (selectedElement.value)
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
default: {
|
|
169
|
+
selectedElement.value = void 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
selectedElement,
|
|
174
|
+
isInvalidInput,
|
|
175
|
+
addOnPaste,
|
|
176
|
+
dir,
|
|
177
|
+
disabled,
|
|
178
|
+
delimiter,
|
|
179
|
+
max,
|
|
180
|
+
id
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
forwardRef,
|
|
184
|
+
dir,
|
|
185
|
+
isInvalidInput,
|
|
186
|
+
disabled,
|
|
187
|
+
focused,
|
|
188
|
+
modelValue,
|
|
189
|
+
isFormControl
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
render() {
|
|
193
|
+
return h(DestylerCollectionSlot, {}, {
|
|
194
|
+
default: () => {
|
|
195
|
+
return h(DestylerPrimitive, {
|
|
196
|
+
"ref": (el) => this.forwardRef(el),
|
|
197
|
+
"dir": this.dir,
|
|
198
|
+
"as": this.$props.as,
|
|
199
|
+
"asChild": this.$props.asChild,
|
|
200
|
+
"data-invalid": this.isInvalidInput ? "" : void 0,
|
|
201
|
+
"data-disabled": this.disabled ? "" : void 0,
|
|
202
|
+
"data-focused": this.focused ? "" : void 0
|
|
203
|
+
}, {
|
|
204
|
+
default: () => {
|
|
205
|
+
return [
|
|
206
|
+
this.$slots.default?.({ modelValue: this.modelValue }),
|
|
207
|
+
this.isFormControl && this.$props.name ? h(DestylerVisuallyhiddenInput, {
|
|
208
|
+
name: this.$props.name,
|
|
209
|
+
value: this.modelValue,
|
|
210
|
+
required: this.required,
|
|
211
|
+
disabled: this.disabled
|
|
212
|
+
}) : null
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const destylerDynamicClearProps = {
|
|
222
|
+
as: {
|
|
223
|
+
type: [String, Object],
|
|
224
|
+
required: false,
|
|
225
|
+
default: "button"
|
|
226
|
+
},
|
|
227
|
+
asChild: {
|
|
228
|
+
type: Boolean,
|
|
229
|
+
required: false,
|
|
230
|
+
default: false
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const DestylerDynamicClear = defineComponent({
|
|
234
|
+
name: "DestylerDynamicClear",
|
|
235
|
+
props: destylerDynamicClearProps,
|
|
236
|
+
setup() {
|
|
237
|
+
useForwardExpose();
|
|
238
|
+
const context = injectDynamicRootContext();
|
|
239
|
+
function handleCancel() {
|
|
240
|
+
if (context.disabled.value)
|
|
241
|
+
return;
|
|
242
|
+
context.modelValue.value = [];
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
context,
|
|
246
|
+
handleCancel
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
render() {
|
|
250
|
+
return h(DestylerPrimitive, mergeProps(this.$props, {
|
|
251
|
+
"type": this.$props.as === "button" ? "button" : void 0,
|
|
252
|
+
"data-disabled": this.context.disabled.value ? "" : void 0,
|
|
253
|
+
"onClick": () => {
|
|
254
|
+
this.handleCancel();
|
|
255
|
+
}
|
|
256
|
+
}), {
|
|
257
|
+
default: () => this.$slots.default?.()
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const destylerDynamicInputProps = {
|
|
263
|
+
as: {
|
|
264
|
+
type: [String, Object],
|
|
265
|
+
required: false,
|
|
266
|
+
default: "input"
|
|
267
|
+
},
|
|
268
|
+
asChild: {
|
|
269
|
+
type: Boolean,
|
|
270
|
+
required: false,
|
|
271
|
+
default: false
|
|
272
|
+
},
|
|
273
|
+
placeholder: {
|
|
274
|
+
type: String,
|
|
275
|
+
required: false
|
|
276
|
+
},
|
|
277
|
+
autoFocus: {
|
|
278
|
+
type: Boolean,
|
|
279
|
+
required: false
|
|
280
|
+
},
|
|
281
|
+
maxLength: {
|
|
282
|
+
type: Number,
|
|
283
|
+
required: false
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const DestylerDynamicInput = defineComponent({
|
|
287
|
+
name: "DestylerDynamicInput",
|
|
288
|
+
props: destylerDynamicInputProps,
|
|
289
|
+
setup(props) {
|
|
290
|
+
const context = injectDynamicRootContext();
|
|
291
|
+
const { forwardRef, currentElement } = useForwardExpose();
|
|
292
|
+
async function handleEnter(event) {
|
|
293
|
+
await nextTick();
|
|
294
|
+
if (event.defaultPrevented)
|
|
295
|
+
return;
|
|
296
|
+
const target = event.target;
|
|
297
|
+
if (!target.value)
|
|
298
|
+
return;
|
|
299
|
+
const isAdded = context.onAddValue(target.value);
|
|
300
|
+
if (isAdded)
|
|
301
|
+
target.value = "";
|
|
302
|
+
event.preventDefault();
|
|
303
|
+
}
|
|
304
|
+
function handleInput(event) {
|
|
305
|
+
context.isInvalidInput.value = false;
|
|
306
|
+
const delimiter = context.delimiter.value;
|
|
307
|
+
if (delimiter === event.data) {
|
|
308
|
+
const target = event.target;
|
|
309
|
+
target.value = target.value.replaceAll(delimiter, "");
|
|
310
|
+
const isAdded = context.onAddValue(target.value);
|
|
311
|
+
if (isAdded)
|
|
312
|
+
target.value = "";
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function handlePaste(event) {
|
|
316
|
+
if (context.addOnPaste.value) {
|
|
317
|
+
event.preventDefault();
|
|
318
|
+
const clipboardData = event.clipboardData;
|
|
319
|
+
if (!clipboardData)
|
|
320
|
+
return;
|
|
321
|
+
const value = clipboardData.getData("text");
|
|
322
|
+
if (context.delimiter.value) {
|
|
323
|
+
const splittedValue = value.split(context.delimiter.value);
|
|
324
|
+
splittedValue.forEach((v) => {
|
|
325
|
+
context.onAddValue(v);
|
|
326
|
+
});
|
|
327
|
+
} else {
|
|
328
|
+
context.onAddValue(value);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
onMounted(() => {
|
|
333
|
+
const inputEl = currentElement.value.nodeName === "INPUT" ? currentElement.value : currentElement.value.querySelector("input");
|
|
334
|
+
if (!inputEl)
|
|
335
|
+
return;
|
|
336
|
+
setTimeout(() => {
|
|
337
|
+
if (props.autoFocus)
|
|
338
|
+
inputEl?.focus();
|
|
339
|
+
}, 1);
|
|
340
|
+
});
|
|
341
|
+
return {
|
|
342
|
+
forwardRef,
|
|
343
|
+
context,
|
|
344
|
+
handleInput,
|
|
345
|
+
handlePaste,
|
|
346
|
+
handleEnter
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
render() {
|
|
350
|
+
return withDirectives(h(DestylerPrimitive, {
|
|
351
|
+
"ref": (el) => this.forwardRef(el),
|
|
352
|
+
"type": "text",
|
|
353
|
+
"autocomplete": "off",
|
|
354
|
+
"autocorrect": "off",
|
|
355
|
+
"autocapitalize": "off",
|
|
356
|
+
"as": this.$props.as,
|
|
357
|
+
"asChild": this.$props.asChild,
|
|
358
|
+
"maxlength": this.$props.maxLength,
|
|
359
|
+
"placeholder": this.$props.placeholder,
|
|
360
|
+
"disabled": this.context.disabled.value,
|
|
361
|
+
"data-invalid": this.context.isInvalidInput.value ? "" : void 0,
|
|
362
|
+
"onInput": (event) => {
|
|
363
|
+
this.handleInput(event);
|
|
364
|
+
},
|
|
365
|
+
"onPaste": (event) => {
|
|
366
|
+
this.handlePaste(event);
|
|
367
|
+
},
|
|
368
|
+
"onKeydown": (event) => {
|
|
369
|
+
if (event.key === "Enter")
|
|
370
|
+
this.handleEnter(event);
|
|
371
|
+
else
|
|
372
|
+
this.context.onInputKeydown(event);
|
|
373
|
+
}
|
|
374
|
+
}, {
|
|
375
|
+
default: () => this.$slots.default?.()
|
|
376
|
+
}), [
|
|
377
|
+
[BindOnceDirective, { id: this.context.id?.value }]
|
|
378
|
+
]);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const destylerDynamicItemProps = {
|
|
383
|
+
as: {
|
|
384
|
+
type: [String, Object],
|
|
385
|
+
required: false,
|
|
386
|
+
default: "div"
|
|
387
|
+
},
|
|
388
|
+
asChild: {
|
|
389
|
+
type: Boolean,
|
|
390
|
+
required: false,
|
|
391
|
+
default: false
|
|
392
|
+
},
|
|
393
|
+
value: {
|
|
394
|
+
type: String,
|
|
395
|
+
required: true
|
|
396
|
+
},
|
|
397
|
+
disabled: {
|
|
398
|
+
type: Boolean,
|
|
399
|
+
required: false
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const [injectDynamicItemContext, provideDynamicItemContext] = createContext("DestylerDynamicItem");
|
|
403
|
+
const DestylerDynamicItem = defineComponent({
|
|
404
|
+
name: "DestylerDynamicItem",
|
|
405
|
+
props: destylerDynamicItemProps,
|
|
406
|
+
setup(props) {
|
|
407
|
+
const { value } = toRefs(props);
|
|
408
|
+
const context = injectDynamicRootContext();
|
|
409
|
+
const { forwardRef, currentElement } = useForwardExpose();
|
|
410
|
+
const isSelected = computed(() => context.selectedElement.value === currentElement.value);
|
|
411
|
+
const textId = useId();
|
|
412
|
+
const disabled = computed(() => props.disabled || context.disabled.value);
|
|
413
|
+
provideDynamicItemContext({
|
|
414
|
+
value,
|
|
415
|
+
isSelected,
|
|
416
|
+
disabled,
|
|
417
|
+
textId
|
|
418
|
+
});
|
|
419
|
+
return {
|
|
420
|
+
forwardRef,
|
|
421
|
+
textId,
|
|
422
|
+
isSelected,
|
|
423
|
+
disabled
|
|
424
|
+
};
|
|
425
|
+
},
|
|
426
|
+
render() {
|
|
427
|
+
return h(DestylerCollectionItem, {}, {
|
|
428
|
+
default: () => {
|
|
429
|
+
return h(DestylerPrimitive, {
|
|
430
|
+
"ref": (el) => this.forwardRef(el),
|
|
431
|
+
"as": this.$props.as,
|
|
432
|
+
"asChild": this.$props.asChild,
|
|
433
|
+
"aria-labelledby": this.textId,
|
|
434
|
+
"aria-current": this.isSelected,
|
|
435
|
+
"data-disabled": this.disabled ? "" : void 0,
|
|
436
|
+
"data-state": this.isSelected ? "active" : "inactive"
|
|
437
|
+
}, {
|
|
438
|
+
default: () => this.$slots.default?.()
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const destylerDynamicItemDeleteProps = {
|
|
446
|
+
as: {
|
|
447
|
+
type: [String, Object],
|
|
448
|
+
required: false,
|
|
449
|
+
default: "button"
|
|
450
|
+
},
|
|
451
|
+
asChild: {
|
|
452
|
+
type: Boolean,
|
|
453
|
+
required: false,
|
|
454
|
+
default: false
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const DestylerDynamicItemDelete = defineComponent({
|
|
458
|
+
name: "DestylerDynamicItemDelete",
|
|
459
|
+
props: destylerDynamicItemDeleteProps,
|
|
460
|
+
setup() {
|
|
461
|
+
useForwardExpose();
|
|
462
|
+
const context = injectDynamicRootContext();
|
|
463
|
+
const itemContext = injectDynamicItemContext();
|
|
464
|
+
const disabled = computed(() => itemContext.disabled?.value || context.disabled.value);
|
|
465
|
+
function handleDelete() {
|
|
466
|
+
if (disabled.value)
|
|
467
|
+
return;
|
|
468
|
+
const index = context.modelValue.value.findIndex((i) => i === itemContext.value.value);
|
|
469
|
+
context.onRemoveValue(index);
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
context,
|
|
473
|
+
itemContext,
|
|
474
|
+
disabled,
|
|
475
|
+
handleDelete
|
|
476
|
+
};
|
|
477
|
+
},
|
|
478
|
+
render() {
|
|
479
|
+
return h(DestylerPrimitive, mergeProps(this.$props, {
|
|
480
|
+
"tabindex": "-1",
|
|
481
|
+
"aria-labelledby": this.itemContext.textId,
|
|
482
|
+
"aria-current": this.itemContext.isSelected.value,
|
|
483
|
+
"data-state": this.itemContext.isSelected.value ? "active" : "inactive",
|
|
484
|
+
"data-disabled": this.disabled ? "" : void 0,
|
|
485
|
+
"type": this.$props.as === "button" ? "button" : void 0,
|
|
486
|
+
"onClick": () => {
|
|
487
|
+
this.handleDelete();
|
|
488
|
+
}
|
|
489
|
+
}), {
|
|
490
|
+
default: () => this.$slots.default?.()
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
const destylerDynamicItemTextProps = {
|
|
496
|
+
as: {
|
|
497
|
+
type: [String, Object],
|
|
498
|
+
required: false,
|
|
499
|
+
default: "span"
|
|
500
|
+
},
|
|
501
|
+
asChild: {
|
|
502
|
+
type: Boolean,
|
|
503
|
+
required: false,
|
|
504
|
+
default: false
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
const DestylerDynamicItemText = defineComponent({
|
|
508
|
+
name: "DestylerDynamicItemText",
|
|
509
|
+
props: destylerDynamicItemTextProps,
|
|
510
|
+
setup() {
|
|
511
|
+
const itemContext = injectDynamicItemContext();
|
|
512
|
+
useForwardExpose();
|
|
513
|
+
return {
|
|
514
|
+
itemContext
|
|
515
|
+
};
|
|
516
|
+
},
|
|
517
|
+
render() {
|
|
518
|
+
return withDirectives(h(DestylerPrimitive, this.$props, {
|
|
519
|
+
default: () => this.$slots.default ? this.$slots.default?.() : this.itemContext.value.value
|
|
520
|
+
}), [
|
|
521
|
+
[BindOnceDirective, { id: this.itemContext.textId }]
|
|
522
|
+
]);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
export { DestylerDynamicClear, DestylerDynamicInput, DestylerDynamicItem, DestylerDynamicItemDelete, DestylerDynamicItemText, DestylerDynamicRoot };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const name = "@destyler/dynamic";
|
|
4
|
+
|
|
5
|
+
const packageName = name;
|
|
6
|
+
const destylerComponentName = [
|
|
7
|
+
"DestylerTemplate"
|
|
8
|
+
];
|
|
9
|
+
function DestylerTemplateResolver() {
|
|
10
|
+
return {
|
|
11
|
+
type: "component",
|
|
12
|
+
resolve: (name2) => {
|
|
13
|
+
if (destylerComponentName.includes(name2))
|
|
14
|
+
return { name: name2, from: packageName };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.DestylerTemplateResolver = DestylerTemplateResolver;
|
|
20
|
+
exports.destylerComponentName = destylerComponentName;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const name = "@destyler/dynamic";
|
|
2
|
+
|
|
3
|
+
const packageName = name;
|
|
4
|
+
const destylerComponentName = [
|
|
5
|
+
"DestylerTemplate"
|
|
6
|
+
];
|
|
7
|
+
function DestylerTemplateResolver() {
|
|
8
|
+
return {
|
|
9
|
+
type: "component",
|
|
10
|
+
resolve: (name2) => {
|
|
11
|
+
if (destylerComponentName.includes(name2))
|
|
12
|
+
return { name: name2, from: packageName };
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { DestylerTemplateResolver, destylerComponentName };
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@destyler/dynamic",
|
|
3
|
+
"version": "0.0.1-beta.21",
|
|
4
|
+
"description": "unstyled dynamic component for vue",
|
|
5
|
+
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./resolver": {
|
|
14
|
+
"types": "./dist/resolver.d.ts",
|
|
15
|
+
"import": "./dist/resolver.mjs",
|
|
16
|
+
"require": "./dist/resolver.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./component": {
|
|
19
|
+
"types": "./dist/component.d.ts",
|
|
20
|
+
"import": "./dist/component.mjs",
|
|
21
|
+
"require": "./dist/component.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./*": "./*"
|
|
24
|
+
},
|
|
25
|
+
"main": "dist/index.cjs",
|
|
26
|
+
"module": "dist/index.mjs",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"*.d.ts",
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"vue": ">=3.3.4"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@vueuse/core": "^10.7.2",
|
|
37
|
+
"@destyler/composition": "0.0.1-beta.21",
|
|
38
|
+
"@destyler/directives": "0.0.1-beta.21",
|
|
39
|
+
"@destyler/visually-hidden": "0.0.1-beta.21",
|
|
40
|
+
"@destyler/collection": "0.0.1-beta.21",
|
|
41
|
+
"@destyler/primitive": "0.0.1-beta.21",
|
|
42
|
+
"@destyler/shared": "0.0.1-beta.21"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"clear": "rimraf ./dist",
|
|
46
|
+
"build": "pnpm run clear && unbuild"
|
|
47
|
+
}
|
|
48
|
+
}
|