vue-devui 1.0.0-rc.4 → 1.0.0-rc.7

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.
Files changed (151) hide show
  1. package/README.md +21 -7
  2. package/auto-complete/index.es.js +26 -4
  3. package/auto-complete/index.umd.js +3 -3
  4. package/auto-complete/style.css +1 -1
  5. package/badge/index.es.js +2 -1
  6. package/badge/index.umd.js +1 -1
  7. package/button/index.es.js +4 -3
  8. package/button/index.umd.js +1 -1
  9. package/button/style.css +1 -1
  10. package/card/index.es.js +35 -29
  11. package/card/index.umd.js +1 -1
  12. package/card/style.css +1 -1
  13. package/checkbox/index.es.js +1 -1
  14. package/checkbox/index.umd.js +1 -1
  15. package/{comment → date-picker}/index.d.ts +0 -0
  16. package/date-picker/index.es.js +1145 -0
  17. package/date-picker/index.umd.js +1 -0
  18. package/date-picker/package.json +7 -0
  19. package/date-picker/style.css +1 -0
  20. package/{read-tip → drawer}/index.d.ts +0 -0
  21. package/drawer/index.es.js +236 -0
  22. package/drawer/index.umd.js +1 -0
  23. package/{comment → drawer}/package.json +1 -1
  24. package/drawer/style.css +1 -0
  25. package/{tag-input → dropdown}/index.d.ts +0 -0
  26. package/dropdown/index.es.js +718 -0
  27. package/dropdown/index.umd.js +1 -0
  28. package/{read-tip → dropdown}/package.json +1 -1
  29. package/dropdown/style.css +1 -0
  30. package/editable-select/index.es.js +14 -14
  31. package/editable-select/index.umd.js +1 -1
  32. package/editable-select/style.css +1 -1
  33. package/form/index.d.ts +7 -0
  34. package/form/index.es.js +7511 -0
  35. package/form/index.umd.js +27 -0
  36. package/{tag-input → form}/package.json +1 -1
  37. package/form/style.css +1 -0
  38. package/fullscreen/index.es.js +1 -1
  39. package/fullscreen/index.umd.js +1 -1
  40. package/image-preview/style.css +1 -1
  41. package/input/index.es.js +13 -19
  42. package/input/index.umd.js +1 -1
  43. package/input/style.css +1 -1
  44. package/input-number/index.d.ts +7 -0
  45. package/input-number/index.es.js +251 -0
  46. package/input-number/index.umd.js +1 -0
  47. package/input-number/package.json +7 -0
  48. package/input-number/style.css +1 -0
  49. package/loading/style.css +1 -1
  50. package/modal/index.es.js +15 -3
  51. package/modal/index.umd.js +1 -1
  52. package/modal/style.css +1 -1
  53. package/notification/style.css +1 -1
  54. package/nuxt/components/CheckboxGroup.js +3 -0
  55. package/nuxt/components/Column.js +3 -0
  56. package/nuxt/components/DatePicker.js +3 -0
  57. package/nuxt/components/Drawer.js +3 -0
  58. package/nuxt/components/DrawerService.js +3 -0
  59. package/nuxt/components/Dropdown.js +3 -0
  60. package/nuxt/components/DropdownMenu.js +3 -0
  61. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  62. package/nuxt/components/FORM_TOKEN.js +3 -0
  63. package/nuxt/components/Form.js +3 -0
  64. package/nuxt/components/FormControl.js +3 -0
  65. package/nuxt/components/FormItem.js +3 -0
  66. package/nuxt/components/FormLabel.js +3 -0
  67. package/nuxt/components/FormOperation.js +3 -0
  68. package/nuxt/components/InputNumber.js +3 -0
  69. package/nuxt/components/Select.js +3 -0
  70. package/nuxt/components/StickSlider.js +3 -0
  71. package/nuxt/components/Tab.js +3 -0
  72. package/nuxt/components/Table.js +3 -0
  73. package/nuxt/components/Tabs.js +3 -0
  74. package/nuxt/components/Tooltip.js +3 -0
  75. package/nuxt/components/Tree.js +3 -0
  76. package/nuxt/components/dropdownMenuProps.js +3 -0
  77. package/nuxt/components/formControlProps.js +3 -0
  78. package/nuxt/components/formItemProps.js +3 -0
  79. package/nuxt/components/formProps.js +3 -0
  80. package/nuxt/components/tabsProps.js +3 -0
  81. package/nuxt/components/tooltipProps.js +3 -0
  82. package/nuxt/components/treeProps.js +3 -0
  83. package/overlay/index.es.js +15 -3
  84. package/overlay/index.umd.js +1 -1
  85. package/overlay/style.css +1 -1
  86. package/package.json +2 -2
  87. package/pagination/index.es.js +80 -96
  88. package/pagination/index.umd.js +1 -1
  89. package/pagination/style.css +1 -1
  90. package/popover/index.es.js +15 -3
  91. package/popover/index.umd.js +9 -9
  92. package/popover/style.css +1 -1
  93. package/progress/index.es.js +48 -14
  94. package/progress/index.umd.js +3 -3
  95. package/progress/style.css +1 -1
  96. package/rate/index.es.js +29 -36
  97. package/rate/index.umd.js +1 -1
  98. package/rate/style.css +1 -1
  99. package/search/index.es.js +15 -19
  100. package/search/index.umd.js +12 -12
  101. package/search/style.css +1 -1
  102. package/select/index.d.ts +7 -0
  103. package/select/index.es.js +696 -0
  104. package/select/index.umd.js +1 -0
  105. package/select/package.json +7 -0
  106. package/select/style.css +1 -0
  107. package/slider/index.es.js +18 -6
  108. package/slider/index.umd.js +1 -1
  109. package/splitter/index.es.js +15 -3
  110. package/splitter/index.umd.js +11 -11
  111. package/splitter/style.css +1 -1
  112. package/style.css +1 -1
  113. package/table/index.d.ts +7 -0
  114. package/table/index.es.js +2662 -0
  115. package/table/index.umd.js +1 -0
  116. package/table/package.json +7 -0
  117. package/table/style.css +1 -0
  118. package/tabs/index.d.ts +7 -0
  119. package/tabs/index.es.js +194 -0
  120. package/tabs/index.umd.js +1 -0
  121. package/tabs/package.json +7 -0
  122. package/tabs/style.css +1 -0
  123. package/textarea/style.css +1 -1
  124. package/tooltip/index.d.ts +7 -0
  125. package/tooltip/index.es.js +5847 -0
  126. package/tooltip/index.umd.js +27 -0
  127. package/tooltip/package.json +7 -0
  128. package/tooltip/style.css +1 -0
  129. package/tree/index.d.ts +7 -0
  130. package/tree/index.es.js +1021 -0
  131. package/tree/index.umd.js +1 -0
  132. package/tree/package.json +7 -0
  133. package/tree/style.css +1 -0
  134. package/upload/style.css +1 -1
  135. package/vue-devui.es.js +11482 -6434
  136. package/vue-devui.umd.js +24 -24
  137. package/comment/index.es.js +0 -84
  138. package/comment/index.umd.js +0 -1
  139. package/comment/style.css +0 -1
  140. package/nuxt/components/Comment.js +0 -3
  141. package/nuxt/components/ReadTip.js +0 -3
  142. package/nuxt/components/TagInput.js +0 -3
  143. package/nuxt/components/commentProps.js +0 -3
  144. package/nuxt/components/readTipProps.js +0 -3
  145. package/nuxt/components/tagInputProps.js +0 -3
  146. package/read-tip/index.es.js +0 -261
  147. package/read-tip/index.umd.js +0 -1
  148. package/read-tip/style.css +0 -1
  149. package/tag-input/index.es.js +0 -328
  150. package/tag-input/index.umd.js +0 -1
  151. package/tag-input/style.css +0 -1
@@ -0,0 +1,696 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { defineComponent, toRefs, createVNode, inject, computed, mergeProps, toRef, provide, onMounted, onBeforeUnmount, ref, Transition, withDirectives, vShow } from "vue";
21
+ const selectProps = {
22
+ modelValue: {
23
+ type: [String, Number, Array],
24
+ default: ""
25
+ },
26
+ "onUpdate:modelValue": {
27
+ type: Function,
28
+ default: void 0
29
+ },
30
+ options: {
31
+ type: Array,
32
+ default: () => []
33
+ },
34
+ size: {
35
+ type: String,
36
+ default: "md"
37
+ },
38
+ overview: {
39
+ type: String,
40
+ default: "border"
41
+ },
42
+ placeholder: {
43
+ type: String,
44
+ default: "\u8BF7\u9009\u62E9"
45
+ },
46
+ multiple: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ disabled: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ allowClear: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ optionDisabledKey: {
59
+ type: String,
60
+ default: ""
61
+ },
62
+ onToggleChange: {
63
+ type: Function,
64
+ default: void 0
65
+ },
66
+ onValueChange: {
67
+ type: Function,
68
+ default: void 0
69
+ }
70
+ };
71
+ const iconProps = {
72
+ name: {
73
+ type: String,
74
+ default: "",
75
+ required: true
76
+ },
77
+ size: {
78
+ type: String,
79
+ default: "inherit"
80
+ },
81
+ color: {
82
+ type: String,
83
+ default: "inherit"
84
+ },
85
+ classPrefix: {
86
+ type: String,
87
+ default: "icon"
88
+ }
89
+ };
90
+ var Icon = defineComponent({
91
+ name: "DIcon",
92
+ props: iconProps,
93
+ setup(props) {
94
+ const {
95
+ name,
96
+ size,
97
+ color,
98
+ classPrefix
99
+ } = toRefs(props);
100
+ return () => {
101
+ return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
102
+ "src": name.value,
103
+ "alt": name.value.split("/")[name.value.split("/").length - 1],
104
+ "style": {
105
+ width: size.value,
106
+ verticalAlign: "text-bottom"
107
+ }
108
+ }, null) : createVNode("i", {
109
+ "class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
110
+ "style": {
111
+ fontSize: size.value,
112
+ color: color.value
113
+ }
114
+ }, null);
115
+ };
116
+ }
117
+ });
118
+ var checkbox = "";
119
+ const commonProps = {
120
+ name: {
121
+ type: String,
122
+ default: void 0
123
+ },
124
+ halfchecked: {
125
+ type: Boolean,
126
+ default: false
127
+ },
128
+ isShowTitle: {
129
+ type: Boolean,
130
+ default: true
131
+ },
132
+ title: {
133
+ type: String
134
+ },
135
+ color: {
136
+ type: String,
137
+ default: void 0
138
+ },
139
+ showAnimation: {
140
+ type: Boolean,
141
+ default: true
142
+ },
143
+ disabled: {
144
+ type: Boolean,
145
+ default: false
146
+ },
147
+ beforeChange: {
148
+ type: Function,
149
+ default: void 0
150
+ }
151
+ };
152
+ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
153
+ halfchecked: {
154
+ type: Boolean,
155
+ default: false
156
+ },
157
+ checked: {
158
+ type: Boolean,
159
+ default: false
160
+ },
161
+ value: {
162
+ type: String
163
+ },
164
+ label: {
165
+ type: String,
166
+ default: void 0
167
+ },
168
+ title: {
169
+ type: String,
170
+ default: void 0
171
+ },
172
+ "onUpdate:checked": {
173
+ type: Function,
174
+ default: void 0
175
+ },
176
+ onChange: {
177
+ type: Function,
178
+ default: void 0
179
+ },
180
+ modelValue: {
181
+ type: Boolean
182
+ },
183
+ "onUpdate:modelValue": {
184
+ type: Function
185
+ }
186
+ });
187
+ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
188
+ modelValue: {
189
+ type: Array,
190
+ required: true
191
+ },
192
+ direction: {
193
+ type: String,
194
+ default: "column"
195
+ },
196
+ itemWidth: {
197
+ type: Number,
198
+ default: void 0
199
+ },
200
+ options: {
201
+ type: Array,
202
+ default: () => []
203
+ },
204
+ onChange: {
205
+ type: Function,
206
+ default: void 0
207
+ },
208
+ "onUpdate:modelValue": {
209
+ type: Function,
210
+ default: void 0
211
+ }
212
+ });
213
+ const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
214
+ var Checkbox = defineComponent({
215
+ name: "DCheckbox",
216
+ props: checkboxProps,
217
+ emits: ["change", "update:checked", "update:modelValue"],
218
+ setup(props, ctx) {
219
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
220
+ const isChecked = computed(() => props.checked || props.modelValue);
221
+ const mergedDisabled = computed(() => {
222
+ return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
223
+ });
224
+ const mergedChecked = computed(() => {
225
+ var _a, _b;
226
+ return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
227
+ });
228
+ const mergedIsShowTitle = computed(() => {
229
+ var _a;
230
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
231
+ });
232
+ const mergedShowAnimation = computed(() => {
233
+ var _a;
234
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
235
+ });
236
+ const mergedColor = computed(() => {
237
+ var _a;
238
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
239
+ });
240
+ const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
241
+ const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
242
+ const canChange = (checked, val) => {
243
+ var _a;
244
+ if (mergedDisabled.value) {
245
+ return Promise.resolve(false);
246
+ }
247
+ const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
248
+ if (beforeChange) {
249
+ const res = beforeChange(checked, val);
250
+ if (typeof res === "boolean") {
251
+ return Promise.resolve(res);
252
+ }
253
+ return res;
254
+ }
255
+ return Promise.resolve(true);
256
+ };
257
+ const toggle = () => {
258
+ const current = !isChecked.value;
259
+ checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
260
+ ctx.emit("update:checked", current);
261
+ ctx.emit("update:modelValue", current);
262
+ ctx.emit("change", current);
263
+ };
264
+ const handleClick = () => {
265
+ canChange(!isChecked.value, props.label).then((res) => res && toggle());
266
+ };
267
+ return {
268
+ itemWidth,
269
+ direction,
270
+ mergedColor,
271
+ mergedDisabled,
272
+ mergedIsShowTitle,
273
+ mergedChecked,
274
+ mergedShowAnimation,
275
+ handleClick
276
+ };
277
+ },
278
+ render() {
279
+ var _a;
280
+ const {
281
+ itemWidth,
282
+ direction,
283
+ mergedChecked,
284
+ mergedDisabled,
285
+ mergedIsShowTitle,
286
+ mergedShowAnimation,
287
+ halfchecked,
288
+ title,
289
+ label,
290
+ handleClick,
291
+ name,
292
+ value,
293
+ mergedColor,
294
+ $slots
295
+ } = this;
296
+ const wrapperCls = {
297
+ "devui-checkbox-column-margin": direction === "column",
298
+ "devui-checkbox-wrap": typeof itemWidth !== "undefined"
299
+ };
300
+ const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
301
+ const checkboxCls = {
302
+ "devui-checkbox": true,
303
+ active: mergedChecked,
304
+ halfchecked,
305
+ disabled: mergedDisabled,
306
+ unchecked: !mergedChecked
307
+ };
308
+ const labelTitle = mergedIsShowTitle ? title || label : "";
309
+ const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
310
+ const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
311
+ const spanCls = {
312
+ "devui-checkbox-material": true,
313
+ "custom-color": mergedColor,
314
+ "devui-checkbox-no-label": !label && !$slots.default,
315
+ "devui-no-animation": !mergedShowAnimation,
316
+ "devui-checkbox-default-background": !halfchecked
317
+ };
318
+ const polygonCls = {
319
+ "devui-tick": true,
320
+ "devui-no-animation": !mergedShowAnimation
321
+ };
322
+ const stopPropagation = ($event) => $event.stopPropagation();
323
+ const inputProps = {
324
+ indeterminate: halfchecked
325
+ };
326
+ return createVNode("div", {
327
+ "class": wrapperCls,
328
+ "style": wrapperStyle
329
+ }, [createVNode("div", {
330
+ "class": checkboxCls
331
+ }, [createVNode("label", {
332
+ "title": labelTitle,
333
+ "onClick": handleClick
334
+ }, [createVNode("input", mergeProps({
335
+ "name": name || value,
336
+ "class": "devui-checkbox-input",
337
+ "type": "checkbox"
338
+ }, inputProps, {
339
+ "checked": mergedChecked,
340
+ "disabled": mergedDisabled,
341
+ "onClick": stopPropagation,
342
+ "onChange": stopPropagation
343
+ }), null), createVNode("span", {
344
+ "style": spanStyle,
345
+ "class": spanCls
346
+ }, [createVNode("span", {
347
+ "class": "devui-checkbox-halfchecked-bg"
348
+ }, null), createVNode("svg", {
349
+ "viewBox": "0 0 16 16",
350
+ "version": "1.1",
351
+ "xmlns": "http://www.w3.org/2000/svg",
352
+ "class": "devui-checkbox-tick"
353
+ }, [createVNode("g", {
354
+ "stroke": "none",
355
+ "stroke-width": "1",
356
+ "fill": "none",
357
+ "fill-rule": "evenodd"
358
+ }, [createVNode("polygon", {
359
+ "fill-rule": "nonzero",
360
+ "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
361
+ "class": polygonCls
362
+ }, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
363
+ }
364
+ });
365
+ var checkboxGroup = "";
366
+ defineComponent({
367
+ name: "DCheckboxGroup",
368
+ props: checkboxGroupProps,
369
+ emits: ["change", "update:modelValue"],
370
+ setup(props, ctx) {
371
+ const valList = toRef(props, "modelValue");
372
+ const defaultOpt = {
373
+ checked: false,
374
+ isShowTitle: true,
375
+ halfchecked: false,
376
+ showAnimation: true,
377
+ disabled: false
378
+ };
379
+ const toggleGroupVal = (val) => {
380
+ let index2 = -1;
381
+ if (typeof valList.value[0] === "string") {
382
+ index2 = valList.value.findIndex((item) => item === val);
383
+ } else if (typeof valList.value[0] === "object") {
384
+ index2 = valList.value.findIndex((item) => item.value === val);
385
+ }
386
+ if (index2 === -1) {
387
+ if (typeof props.options[0] === "object") {
388
+ const newOne = props.options.find((item) => item.value === val);
389
+ const res2 = [...valList.value, newOne];
390
+ ctx.emit("update:modelValue", res2);
391
+ ctx.emit("change", res2);
392
+ return;
393
+ }
394
+ const res = [...valList.value, val];
395
+ ctx.emit("update:modelValue", res);
396
+ ctx.emit("change", res);
397
+ return;
398
+ }
399
+ valList.value.splice(index2, 1);
400
+ ctx.emit("update:modelValue", valList.value);
401
+ ctx.emit("change", valList.value);
402
+ };
403
+ const isItemChecked = (itemVal) => {
404
+ if (typeof valList.value[0] === "string") {
405
+ return valList.value.includes(itemVal);
406
+ } else if (typeof valList.value[0] === "object") {
407
+ return valList.value.some((item) => item.value === itemVal);
408
+ }
409
+ };
410
+ provide(checkboxGroupInjectionKey, {
411
+ disabled: toRef(props, "disabled"),
412
+ isShowTitle: toRef(props, "isShowTitle"),
413
+ color: toRef(props, "color"),
414
+ showAnimation: toRef(props, "showAnimation"),
415
+ beforeChange: props.beforeChange,
416
+ isItemChecked,
417
+ toggleGroupVal,
418
+ itemWidth: toRef(props, "itemWidth"),
419
+ direction: toRef(props, "direction")
420
+ });
421
+ return {
422
+ defaultOpt
423
+ };
424
+ },
425
+ render() {
426
+ var _a;
427
+ const {
428
+ direction,
429
+ $slots,
430
+ defaultOpt,
431
+ options
432
+ } = this;
433
+ let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
434
+ if ((options == null ? void 0 : options.length) > 0) {
435
+ children = options.map((opt) => {
436
+ let mergedOpt = null;
437
+ if (typeof opt === "string") {
438
+ mergedOpt = Object.assign({}, defaultOpt, {
439
+ label: opt,
440
+ value: opt
441
+ });
442
+ } else if (typeof opt === "object") {
443
+ mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
444
+ label: opt.name
445
+ }));
446
+ }
447
+ return createVNode(Checkbox, mergedOpt, null);
448
+ });
449
+ }
450
+ return createVNode("div", {
451
+ "class": "devui-checkbox-group"
452
+ }, [createVNode("div", {
453
+ "class": {
454
+ "devui-checkbox-list-inline": direction === "row"
455
+ }
456
+ }, [children])]);
457
+ }
458
+ });
459
+ function className(classStr, classOpt) {
460
+ let classname = classStr;
461
+ if (typeof classOpt === "object") {
462
+ Object.keys(classOpt).forEach((key) => {
463
+ classOpt[key] && (classname += ` ${key}`);
464
+ });
465
+ }
466
+ return classname;
467
+ }
468
+ function useCacheOptions(mergeOptions) {
469
+ const cacheOptions = computed(() => {
470
+ const map = /* @__PURE__ */ new Map();
471
+ mergeOptions.value.forEach((item) => {
472
+ map.set(item.value, item);
473
+ });
474
+ return map;
475
+ });
476
+ const getValuesOption = (values) => values.map((value) => cacheOptions.value.get(value));
477
+ return getValuesOption;
478
+ }
479
+ function useSelectOutsideClick(refs, isOpen, toggleChange) {
480
+ function onGlobalMouseDown(e) {
481
+ var _a, _b;
482
+ let target = e.target;
483
+ if (target.shadowRoot && e.composed) {
484
+ target = e.composedPath()[0] || target;
485
+ }
486
+ const element = [(_a = refs[0]) == null ? void 0 : _a.value, (_b = refs[1]) == null ? void 0 : _b.value];
487
+ if (isOpen.value && element.every((el) => el && !el.contains(target) && el !== target)) {
488
+ toggleChange(false);
489
+ }
490
+ }
491
+ onMounted(() => {
492
+ document.body.addEventListener("mousedown", onGlobalMouseDown, false);
493
+ });
494
+ onBeforeUnmount(() => {
495
+ document.body.addEventListener("mousedown", onGlobalMouseDown, false);
496
+ });
497
+ }
498
+ var select = "";
499
+ var Select = defineComponent({
500
+ name: "DSelect",
501
+ props: selectProps,
502
+ emits: ["toggleChange", "valueChange", "update:modelValue"],
503
+ setup(props, ctx) {
504
+ const containerRef = ref(null);
505
+ const dropdownRef = ref(null);
506
+ const isOpen = ref(false);
507
+ function toggleChange(bool) {
508
+ if (props.disabled) {
509
+ return;
510
+ }
511
+ isOpen.value = bool;
512
+ ctx.emit("toggleChange", bool);
513
+ }
514
+ useSelectOutsideClick([containerRef, dropdownRef], isOpen, toggleChange);
515
+ const mergeOptions = computed(() => {
516
+ const {
517
+ multiple,
518
+ modelValue
519
+ } = props;
520
+ return props.options.map((item) => {
521
+ let option;
522
+ if (typeof item === "object") {
523
+ option = __spreadValues({
524
+ name: item.name ? item.name : item.value + "",
525
+ _checked: false
526
+ }, item);
527
+ } else {
528
+ option = {
529
+ name: item + "",
530
+ value: item,
531
+ _checked: false
532
+ };
533
+ }
534
+ if (multiple) {
535
+ if (Array.isArray(modelValue)) {
536
+ option._checked = modelValue.includes(option.value);
537
+ } else {
538
+ option._checked = false;
539
+ }
540
+ }
541
+ return option;
542
+ });
543
+ });
544
+ const getValuesOption = useCacheOptions(mergeOptions);
545
+ const inputValue = computed(() => {
546
+ var _a;
547
+ if (props.multiple && Array.isArray(props.modelValue)) {
548
+ const selectedOptions = getValuesOption(props.modelValue);
549
+ return selectedOptions.map((item) => (item == null ? void 0 : item.name) || "").join(",");
550
+ } else if (!Array.isArray(props.modelValue)) {
551
+ return ((_a = getValuesOption([props.modelValue])[0]) == null ? void 0 : _a.name) || "";
552
+ }
553
+ return "";
554
+ });
555
+ const mergeClearable = computed(() => {
556
+ return !props.disabled && props.allowClear && inputValue.value.length > 0;
557
+ });
558
+ function valueChange(item, index2) {
559
+ const {
560
+ multiple,
561
+ optionDisabledKey: disabledKey
562
+ } = props;
563
+ let {
564
+ modelValue
565
+ } = props;
566
+ if (disabledKey && !!item[disabledKey]) {
567
+ return;
568
+ }
569
+ if (multiple) {
570
+ item._checked = !item._checked;
571
+ modelValue = mergeOptions.value.filter((item1) => item1._checked).map((item2) => item2.value);
572
+ ctx.emit("update:modelValue", modelValue);
573
+ } else {
574
+ ctx.emit("update:modelValue", item.value);
575
+ toggleChange(false);
576
+ }
577
+ ctx.emit("valueChange", item, index2);
578
+ }
579
+ function getItemClassName(item) {
580
+ const {
581
+ optionDisabledKey: disabledKey
582
+ } = props;
583
+ return className("devui-select-item", {
584
+ active: item.value === props.modelValue,
585
+ disabled: disabledKey ? !!item[disabledKey] : false
586
+ });
587
+ }
588
+ function handleClear(e) {
589
+ e.preventDefault();
590
+ e.stopPropagation();
591
+ if (props.multiple) {
592
+ ctx.emit("update:modelValue", []);
593
+ } else {
594
+ ctx.emit("update:modelValue", "");
595
+ }
596
+ }
597
+ return {
598
+ isOpen,
599
+ containerRef,
600
+ dropdownRef,
601
+ inputValue,
602
+ mergeOptions,
603
+ mergeClearable,
604
+ valueChange,
605
+ toggleChange,
606
+ getItemClassName,
607
+ handleClear
608
+ };
609
+ },
610
+ render() {
611
+ const {
612
+ mergeOptions,
613
+ isOpen,
614
+ inputValue,
615
+ size,
616
+ multiple,
617
+ disabled,
618
+ optionDisabledKey: disabledKey,
619
+ placeholder,
620
+ overview,
621
+ valueChange,
622
+ toggleChange,
623
+ getItemClassName,
624
+ mergeClearable,
625
+ handleClear
626
+ } = this;
627
+ const selectCls = className("devui-select", {
628
+ "devui-select-open": isOpen,
629
+ "devui-dropdown-menu-multiple": multiple,
630
+ "devui-select-lg": size === "lg",
631
+ "devui-select-sm": size === "sm",
632
+ "devui-select-underlined": overview === "underlined",
633
+ "devui-select-disabled": disabled
634
+ });
635
+ const inputCls = className("devui-select-input", {
636
+ "devui-select-input-lg": size === "lg",
637
+ "devui-select-input-sm": size === "sm"
638
+ });
639
+ const selectionCls = className("devui-select-selection", {
640
+ "devui-select-clearable": mergeClearable
641
+ });
642
+ return createVNode("div", {
643
+ "class": selectCls,
644
+ "ref": "containerRef"
645
+ }, [createVNode("div", {
646
+ "class": selectionCls,
647
+ "onClick": () => toggleChange(!isOpen)
648
+ }, [createVNode("input", {
649
+ "value": inputValue,
650
+ "type": "text",
651
+ "class": inputCls,
652
+ "placeholder": placeholder,
653
+ "readonly": true,
654
+ "disabled": disabled
655
+ }, null), createVNode("span", {
656
+ "onClick": handleClear,
657
+ "class": "devui-select-clear"
658
+ }, [createVNode(Icon, {
659
+ "name": "close"
660
+ }, null)]), createVNode("span", {
661
+ "class": "devui-select-arrow"
662
+ }, [createVNode(Icon, {
663
+ "name": "select-arrow"
664
+ }, null)])]), createVNode(Transition, {
665
+ "name": "fade",
666
+ "ref": "dropdownRef"
667
+ }, {
668
+ default: () => [withDirectives(createVNode("div", {
669
+ "class": "devui-select-dropdown"
670
+ }, [createVNode("ul", {
671
+ "class": "devui-select-dropdown-list devui-scrollbar"
672
+ }, [mergeOptions.map((item, i) => createVNode("li", {
673
+ "onClick": (e) => {
674
+ e.preventDefault();
675
+ e.stopPropagation();
676
+ valueChange(item, i);
677
+ },
678
+ "class": getItemClassName(item),
679
+ "key": i
680
+ }, [multiple ? createVNode(Checkbox, {
681
+ "modelValue": item._checked,
682
+ "label": item.name,
683
+ "disabled": disabledKey ? !!item[disabledKey] : false
684
+ }, null) : item.name]))])]), [[vShow, isOpen]])]
685
+ })]);
686
+ }
687
+ });
688
+ var index = {
689
+ title: "Select \u4E0B\u62C9\u6846",
690
+ category: "\u6570\u636E\u5F55\u5165",
691
+ status: "10%",
692
+ install(app) {
693
+ app.component(Select.name, Select);
694
+ }
695
+ };
696
+ export { Select, index as default };