vue-devui 1.0.0-rc.6 → 1.0.0-rc.9

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 (168) hide show
  1. package/README.md +5 -0
  2. package/alert/index.es.js +37 -11
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +311 -77
  6. package/auto-complete/index.umd.js +3 -5
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +81 -70
  9. package/avatar/index.umd.js +1 -1
  10. package/avatar/style.css +1 -1
  11. package/badge/index.es.js +29 -4
  12. package/badge/index.umd.js +1 -1
  13. package/badge/style.css +1 -1
  14. package/button/index.es.js +5632 -87
  15. package/button/index.umd.js +27 -1
  16. package/button/style.css +1 -1
  17. package/card/index.es.js +56 -29
  18. package/card/index.umd.js +1 -1
  19. package/card/style.css +1 -1
  20. package/checkbox/index.es.js +364 -234
  21. package/checkbox/index.umd.js +1 -1
  22. package/checkbox/style.css +1 -1
  23. package/date-picker/index.es.js +310 -157
  24. package/date-picker/index.umd.js +1 -1
  25. package/date-picker/style.css +1 -1
  26. package/drawer/index.es.js +28 -3
  27. package/drawer/index.umd.js +1 -1
  28. package/drawer/style.css +1 -1
  29. package/dropdown/index.es.js +125 -45
  30. package/dropdown/index.umd.js +1 -1
  31. package/dropdown/style.css +1 -1
  32. package/editable-select/index.es.js +437 -22
  33. package/editable-select/index.umd.js +1 -1
  34. package/editable-select/style.css +1 -1
  35. package/form/index.es.js +490 -605
  36. package/form/index.umd.js +15 -15
  37. package/form/style.css +1 -1
  38. package/fullscreen/index.es.js +29 -5
  39. package/fullscreen/index.umd.js +1 -1
  40. package/fullscreen/style.css +1 -1
  41. package/grid/index.es.js +71 -50
  42. package/grid/index.umd.js +1 -1
  43. package/grid/style.css +1 -1
  44. package/icon/index.es.js +109 -13
  45. package/icon/index.umd.js +1 -1
  46. package/icon/style.css +1 -0
  47. package/image-preview/index.es.js +34 -11
  48. package/image-preview/index.umd.js +1 -1
  49. package/image-preview/style.css +1 -1
  50. package/input/index.es.js +330 -130
  51. package/input/index.umd.js +1 -1
  52. package/input/style.css +1 -1
  53. package/input-number/index.es.js +272 -199
  54. package/input-number/index.umd.js +1 -1
  55. package/input-number/style.css +1 -1
  56. package/layout/index.es.js +34 -6
  57. package/layout/index.umd.js +1 -1
  58. package/layout/style.css +1 -1
  59. package/loading/index.es.js +34 -10
  60. package/loading/index.umd.js +1 -1
  61. package/loading/style.css +1 -1
  62. package/modal/index.es.js +126 -27
  63. package/modal/index.umd.js +1 -1
  64. package/modal/style.css +1 -1
  65. package/notification/index.es.js +125 -25
  66. package/notification/index.umd.js +1 -1
  67. package/notification/style.css +1 -1
  68. package/nuxt/components/ButtonGroup.js +3 -0
  69. package/nuxt/components/CheckboxButton.js +3 -0
  70. package/nuxt/components/CheckboxGroup.js +3 -0
  71. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  72. package/nuxt/components/FORM_TOKEN.js +3 -0
  73. package/nuxt/components/Icon.js +1 -0
  74. package/nuxt/components/LABEL_DATA.js +3 -0
  75. package/nuxt/components/Option.js +3 -0
  76. package/nuxt/components/buttonGroupInjectionKey.js +3 -0
  77. package/nuxt/components/buttonGroupProps.js +3 -0
  78. package/nuxt/components/formControlProps.js +3 -0
  79. package/nuxt/components/formItemProps.js +3 -0
  80. package/nuxt/components/formProps.js +3 -0
  81. package/nuxt/components/iconProps.js +1 -0
  82. package/nuxt/components/svgIconProps.js +3 -0
  83. package/overlay/index.es.js +31 -9
  84. package/overlay/index.umd.js +1 -1
  85. package/overlay/style.css +1 -1
  86. package/package.json +2 -1
  87. package/pagination/index.es.js +135 -124
  88. package/pagination/index.umd.js +1 -1
  89. package/pagination/style.css +1 -1
  90. package/popover/index.es.js +198 -83
  91. package/popover/index.umd.js +16 -16
  92. package/popover/style.css +1 -1
  93. package/progress/index.es.js +76 -20
  94. package/progress/index.umd.js +3 -3
  95. package/progress/style.css +1 -1
  96. package/radio/index.es.js +161 -140
  97. package/radio/index.umd.js +1 -1
  98. package/radio/style.css +1 -1
  99. package/rate/index.es.js +48 -16
  100. package/rate/index.umd.js +1 -1
  101. package/rate/style.css +1 -1
  102. package/result/index.es.js +108 -12
  103. package/result/index.umd.js +1 -1
  104. package/result/style.css +1 -1
  105. package/search/index.es.js +379 -167
  106. package/search/index.umd.js +17 -17
  107. package/search/style.css +1 -1
  108. package/select/index.es.js +7339 -556
  109. package/select/index.umd.js +27 -1
  110. package/select/style.css +1 -1
  111. package/skeleton/index.es.js +37 -12
  112. package/skeleton/index.umd.js +1 -1
  113. package/skeleton/style.css +1 -1
  114. package/slider/index.es.js +34 -10
  115. package/slider/index.umd.js +1 -1
  116. package/slider/style.css +1 -1
  117. package/splitter/index.es.js +201 -84
  118. package/splitter/index.umd.js +14 -14
  119. package/splitter/style.css +1 -1
  120. package/status/index.es.js +26 -2
  121. package/status/index.umd.js +1 -1
  122. package/status/style.css +1 -1
  123. package/style.css +1 -1
  124. package/switch/index.es.js +30 -6
  125. package/switch/index.umd.js +1 -1
  126. package/switch/style.css +1 -1
  127. package/table/index.es.js +6808 -585
  128. package/table/index.umd.js +27 -1
  129. package/table/style.css +1 -1
  130. package/tabs/index.es.js +136 -70
  131. package/tabs/index.umd.js +1 -1
  132. package/tabs/style.css +1 -1
  133. package/tag/index.es.js +31 -7
  134. package/tag/index.umd.js +1 -1
  135. package/tag/style.css +1 -1
  136. package/textarea/index.es.js +5631 -80
  137. package/textarea/index.umd.js +35 -1
  138. package/textarea/style.css +1 -1
  139. package/timeline/index.es.js +108 -12
  140. package/timeline/index.umd.js +1 -1
  141. package/timeline/style.css +1 -1
  142. package/tooltip/index.es.js +190 -74
  143. package/tooltip/index.umd.js +17 -17
  144. package/tooltip/style.css +1 -1
  145. package/tree/index.es.js +376 -256
  146. package/tree/index.umd.js +1 -1
  147. package/tree/style.css +1 -1
  148. package/upload/index.es.js +138 -34
  149. package/upload/index.umd.js +1 -1
  150. package/upload/style.css +1 -1
  151. package/vue-devui.es.js +6770 -5769
  152. package/vue-devui.umd.js +27 -21
  153. package/comment/index.d.ts +0 -7
  154. package/comment/index.es.js +0 -84
  155. package/comment/index.umd.js +0 -1
  156. package/comment/package.json +0 -7
  157. package/comment/style.css +0 -1
  158. package/nuxt/components/Comment.js +0 -3
  159. package/nuxt/components/FormControl.js +0 -3
  160. package/nuxt/components/FormLabel.js +0 -3
  161. package/nuxt/components/ReadTip.js +0 -3
  162. package/nuxt/components/commentProps.js +0 -3
  163. package/nuxt/components/readTipProps.js +0 -3
  164. package/read-tip/index.d.ts +0 -7
  165. package/read-tip/index.es.js +0 -261
  166. package/read-tip/index.umd.js +0 -1
  167. package/read-tip/package.json +0 -7
  168. package/read-tip/style.css +0 -1
package/tree/index.es.js CHANGED
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { createVNode, defineComponent, toRefs, inject, computed, mergeProps, toRef, provide, renderSlot, useSlots, ref, watch } from "vue";
20
+ import { createVNode, defineComponent, toRefs, inject, computed, toRef, provide, mergeProps, renderSlot, useSlots, ref, watch } from "vue";
21
21
  const USE_TREE_TOKEN = "use-tree-token";
22
22
  const NODE_HEIGHT = 30;
23
23
  const NODE_INDENT = 24;
@@ -69,6 +69,29 @@ const IconOpen = () => createVNode("svg", {
69
69
  "height": "2",
70
70
  "fill": "#5e7ce0"
71
71
  }, null)])]);
72
+ function createBem(namespace, element, modifier) {
73
+ let cls = namespace;
74
+ if (element) {
75
+ cls += `__${element}`;
76
+ }
77
+ if (modifier) {
78
+ cls += `--${modifier}`;
79
+ }
80
+ return cls;
81
+ }
82
+ function useNamespace(block, needDot = false) {
83
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
84
+ const b = () => createBem(namespace);
85
+ const e = (element) => element ? createBem(namespace, element) : "";
86
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
87
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
88
+ return {
89
+ b,
90
+ e,
91
+ m,
92
+ em
93
+ };
94
+ }
72
95
  var DTreeNodeToggle = defineComponent({
73
96
  name: "DTreeNodeToggle",
74
97
  props: {
@@ -84,10 +107,11 @@ var DTreeNodeToggle = defineComponent({
84
107
  const {
85
108
  toggleNode
86
109
  } = inject(USE_TREE_TOKEN);
110
+ const ns2 = useNamespace("tree");
87
111
  return () => {
88
112
  var _a;
89
113
  return createVNode("span", {
90
- "class": ["devui-tree-node__folder", ((_a = data.value) == null ? void 0 : _a.disableToggle) && "toggle-disabled"],
114
+ "class": [ns2.e("node-folder"), ((_a = data.value) == null ? void 0 : _a.disableToggle) && "toggle-disabled"],
91
115
  "onClick": (event) => {
92
116
  event.stopPropagation();
93
117
  if (toggleNode) {
@@ -95,7 +119,7 @@ var DTreeNodeToggle = defineComponent({
95
119
  }
96
120
  }
97
121
  }, [data.value.isLeaf ? createVNode("span", {
98
- "class": "devui-tree-node__indent"
122
+ "class": ns2.e("node-indent")
99
123
  }, null) : data.value.expanded ? createVNode(IconOpen, {
100
124
  "class": "mr-xs"
101
125
  }, null) : createVNode(IconClose, {
@@ -104,13 +128,12 @@ var DTreeNodeToggle = defineComponent({
104
128
  };
105
129
  }
106
130
  });
107
- var checkbox = "";
108
131
  const commonProps = {
109
132
  name: {
110
133
  type: String,
111
134
  default: void 0
112
135
  },
113
- halfchecked: {
136
+ halfChecked: {
114
137
  type: Boolean,
115
138
  default: false
116
139
  },
@@ -136,27 +159,23 @@ const commonProps = {
136
159
  beforeChange: {
137
160
  type: Function,
138
161
  default: void 0
162
+ },
163
+ size: {
164
+ type: String,
165
+ default: "md"
139
166
  }
140
167
  };
141
168
  const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
142
- halfchecked: {
143
- type: Boolean,
144
- default: false
145
- },
146
169
  checked: {
147
170
  type: Boolean,
148
171
  default: false
149
172
  },
150
173
  value: {
151
- type: String
174
+ type: [Number, String]
152
175
  },
153
176
  label: {
154
177
  type: String,
155
- default: void 0
156
- },
157
- title: {
158
- type: String,
159
- default: void 0
178
+ default: ""
160
179
  },
161
180
  "onUpdate:checked": {
162
181
  type: Function,
@@ -171,6 +190,10 @@ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
171
190
  },
172
191
  "onUpdate:modelValue": {
173
192
  type: Function
193
+ },
194
+ border: {
195
+ type: Boolean,
196
+ default: false
174
197
  }
175
198
  });
176
199
  const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
@@ -197,158 +220,260 @@ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
197
220
  "onUpdate:modelValue": {
198
221
  type: Function,
199
222
  default: void 0
223
+ },
224
+ border: {
225
+ type: Boolean,
226
+ default: false
227
+ },
228
+ max: {
229
+ type: Number,
230
+ default: void 0
231
+ },
232
+ textColor: {
233
+ type: String,
234
+ default: ""
200
235
  }
201
236
  });
202
237
  const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
238
+ function useCheckbox(props, ctx) {
239
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
240
+ const isChecked = computed(() => props.checked || props.modelValue);
241
+ const mergedChecked = computed(() => {
242
+ var _a, _b;
243
+ return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
244
+ });
245
+ const isLimitDisabled = computed(() => {
246
+ const max = checkboxGroupConf == null ? void 0 : checkboxGroupConf.max.value;
247
+ return !!max && (checkboxGroupConf == null ? void 0 : checkboxGroupConf.modelValue.value.length) >= max && !mergedChecked.value;
248
+ });
249
+ const mergedDisabled = computed(() => {
250
+ return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled || isLimitDisabled.value;
251
+ });
252
+ const mergedIsShowTitle = computed(() => {
253
+ var _a;
254
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
255
+ });
256
+ const mergedShowAnimation = computed(() => {
257
+ var _a;
258
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
259
+ });
260
+ const mergedColor = computed(() => {
261
+ var _a;
262
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
263
+ });
264
+ const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
265
+ const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
266
+ const canChange = (checked, val) => {
267
+ var _a;
268
+ if (mergedDisabled.value) {
269
+ return Promise.resolve(false);
270
+ }
271
+ const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
272
+ if (beforeChange) {
273
+ const res = beforeChange(checked, val);
274
+ if (typeof res === "boolean") {
275
+ return Promise.resolve(res);
276
+ }
277
+ return res;
278
+ }
279
+ return Promise.resolve(true);
280
+ };
281
+ const toggle = () => {
282
+ const current = !isChecked.value;
283
+ checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
284
+ ctx.emit("update:checked", current);
285
+ ctx.emit("update:modelValue", current);
286
+ ctx.emit("change", current);
287
+ };
288
+ const handleClick = () => {
289
+ canChange(!isChecked.value, props.label).then((res) => res && toggle());
290
+ };
291
+ const size = computed(() => {
292
+ var _a;
293
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.size.value) != null ? _a : props.size;
294
+ });
295
+ const border = computed(() => {
296
+ var _a;
297
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.border.value) != null ? _a : props.border;
298
+ });
299
+ return {
300
+ mergedChecked,
301
+ mergedDisabled,
302
+ mergedIsShowTitle,
303
+ mergedShowAnimation,
304
+ mergedColor,
305
+ itemWidth,
306
+ direction,
307
+ handleClick,
308
+ size,
309
+ border
310
+ };
311
+ }
312
+ function useCheckboxGroup(props, ctx) {
313
+ const valList = toRef(props, "modelValue");
314
+ const defaultOpt = {
315
+ checked: false,
316
+ isShowTitle: true,
317
+ halfChecked: false,
318
+ showAnimation: true,
319
+ disabled: false
320
+ };
321
+ const toggleGroupVal = (val) => {
322
+ let index2 = -1;
323
+ if (["string", "number"].includes(typeof valList.value[0])) {
324
+ index2 = valList.value.findIndex((item) => item === val);
325
+ } else if (typeof valList.value[0] === "object") {
326
+ index2 = valList.value.findIndex((item) => item.value === val);
327
+ }
328
+ if (index2 === -1) {
329
+ if (typeof props.options[0] === "object") {
330
+ const newOne = props.options.find((item) => item.value === val);
331
+ const res2 = [...valList.value, newOne];
332
+ ctx.emit("update:modelValue", res2);
333
+ ctx.emit("change", res2);
334
+ return;
335
+ }
336
+ const res = [...valList.value, val];
337
+ ctx.emit("update:modelValue", res);
338
+ ctx.emit("change", res);
339
+ return;
340
+ }
341
+ valList.value.splice(index2, 1);
342
+ ctx.emit("update:modelValue", valList.value);
343
+ ctx.emit("change", valList.value);
344
+ };
345
+ const isItemChecked = (itemVal) => {
346
+ if (["string", "number"].includes(typeof valList.value[0])) {
347
+ return valList.value.includes(itemVal);
348
+ } else if (typeof valList.value[0] === "object") {
349
+ return valList.value.some((item) => item.value === itemVal);
350
+ }
351
+ };
352
+ provide(checkboxGroupInjectionKey, {
353
+ disabled: toRef(props, "disabled"),
354
+ isShowTitle: toRef(props, "isShowTitle"),
355
+ color: toRef(props, "color"),
356
+ showAnimation: toRef(props, "showAnimation"),
357
+ beforeChange: props.beforeChange,
358
+ isItemChecked,
359
+ toggleGroupVal,
360
+ itemWidth: toRef(props, "itemWidth"),
361
+ direction: toRef(props, "direction"),
362
+ size: toRef(props, "size"),
363
+ border: toRef(props, "border"),
364
+ max: toRef(props, "max"),
365
+ modelValue: toRef(props, "modelValue"),
366
+ textColor: toRef(props, "textColor")
367
+ });
368
+ return { defaultOpt };
369
+ }
370
+ function useCheckboxButton() {
371
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
372
+ const mergedTextColor = computed(() => {
373
+ var _a;
374
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.textColor.value) != null ? _a : void 0;
375
+ });
376
+ return {
377
+ mergedTextColor
378
+ };
379
+ }
380
+ var checkbox = "";
203
381
  var Checkbox = defineComponent({
204
382
  name: "DCheckbox",
205
383
  props: checkboxProps,
206
384
  emits: ["change", "update:checked", "update:modelValue"],
207
385
  setup(props, ctx) {
208
- const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
209
- const isChecked = computed(() => props.checked || props.modelValue);
210
- const mergedDisabled = computed(() => {
211
- return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
212
- });
213
- const mergedChecked = computed(() => {
214
- var _a, _b;
215
- return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
216
- });
217
- const mergedIsShowTitle = computed(() => {
218
- var _a;
219
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
220
- });
221
- const mergedShowAnimation = computed(() => {
222
- var _a;
223
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
224
- });
225
- const mergedColor = computed(() => {
226
- var _a;
227
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
228
- });
229
- const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
230
- const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
231
- const canChange = (checked, val) => {
232
- var _a;
233
- if (mergedDisabled.value) {
234
- return Promise.resolve(false);
235
- }
236
- const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
237
- if (beforeChange) {
238
- const res = beforeChange(checked, val);
239
- if (typeof res === "boolean") {
240
- return Promise.resolve(res);
241
- }
242
- return res;
243
- }
244
- return Promise.resolve(true);
245
- };
246
- const toggle = () => {
247
- const current = !isChecked.value;
248
- checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
249
- ctx.emit("update:checked", current);
250
- ctx.emit("update:modelValue", current);
251
- ctx.emit("change", current);
252
- };
253
- const handleClick = () => {
254
- canChange(!isChecked.value, props.label).then((res) => res && toggle());
255
- };
256
- return {
257
- itemWidth,
258
- direction,
259
- mergedColor,
260
- mergedDisabled,
261
- mergedIsShowTitle,
262
- mergedChecked,
263
- mergedShowAnimation,
264
- handleClick
265
- };
266
- },
267
- render() {
268
- var _a;
386
+ const ns2 = useNamespace("checkbox");
269
387
  const {
270
- itemWidth,
271
- direction,
272
388
  mergedChecked,
273
389
  mergedDisabled,
274
390
  mergedIsShowTitle,
275
391
  mergedShowAnimation,
276
- halfchecked,
277
- title,
278
- label,
279
- handleClick,
280
- name,
281
- value,
282
392
  mergedColor,
283
- $slots
284
- } = this;
285
- const wrapperCls = {
286
- "devui-checkbox-column-margin": direction === "column",
287
- "devui-checkbox-wrap": typeof itemWidth !== "undefined"
288
- };
289
- const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
290
- const checkboxCls = {
291
- "devui-checkbox": true,
292
- active: mergedChecked,
293
- halfchecked,
294
- disabled: mergedDisabled,
295
- unchecked: !mergedChecked
296
- };
297
- const labelTitle = mergedIsShowTitle ? title || label : "";
298
- const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
299
- const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
300
- const spanCls = {
301
- "devui-checkbox-material": true,
302
- "custom-color": mergedColor,
303
- "devui-checkbox-no-label": !label && !$slots.default,
304
- "devui-no-animation": !mergedShowAnimation,
305
- "devui-checkbox-default-background": !halfchecked
306
- };
307
- const polygonCls = {
308
- "devui-tick": true,
309
- "devui-no-animation": !mergedShowAnimation
310
- };
311
- const stopPropagation = ($event) => $event.stopPropagation();
312
- const inputProps = {
313
- indeterminate: halfchecked
314
- };
315
- return createVNode("div", {
316
- "class": wrapperCls,
317
- "style": wrapperStyle
318
- }, [createVNode("div", {
319
- "class": checkboxCls
320
- }, [createVNode("label", {
321
- "title": labelTitle,
322
- "onClick": handleClick
323
- }, [createVNode("input", mergeProps({
324
- "name": name || value,
325
- "class": "devui-checkbox-input",
326
- "type": "checkbox"
327
- }, inputProps, {
328
- "checked": mergedChecked,
329
- "disabled": mergedDisabled,
330
- "onClick": stopPropagation,
331
- "onChange": stopPropagation
332
- }), null), createVNode("span", {
333
- "style": spanStyle,
334
- "class": spanCls
335
- }, [createVNode("span", {
336
- "class": "devui-checkbox-halfchecked-bg"
337
- }, null), createVNode("svg", {
338
- "viewBox": "0 0 16 16",
339
- "version": "1.1",
340
- "xmlns": "http://www.w3.org/2000/svg",
341
- "class": "devui-checkbox-tick"
342
- }, [createVNode("g", {
343
- "stroke": "none",
344
- "stroke-width": "1",
345
- "fill": "none",
346
- "fill-rule": "evenodd"
347
- }, [createVNode("polygon", {
348
- "fill-rule": "nonzero",
349
- "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
350
- "class": polygonCls
351
- }, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
393
+ itemWidth,
394
+ direction,
395
+ handleClick,
396
+ size,
397
+ border
398
+ } = useCheckbox(props, ctx);
399
+ return () => {
400
+ var _a, _b;
401
+ const wrapperCls = {
402
+ [ns2.e("column-margin")]: direction === "column",
403
+ [ns2.e("wrap")]: typeof itemWidth !== "undefined"
404
+ };
405
+ const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
406
+ const checkboxCls = {
407
+ [ns2.b()]: true,
408
+ active: mergedChecked.value,
409
+ "half-checked": props.halfChecked,
410
+ disabled: mergedDisabled.value,
411
+ unchecked: !mergedChecked.value
412
+ };
413
+ const labelTitle = mergedIsShowTitle.value ? props.title || props.label : "";
414
+ const bgImgStyle = mergedColor.value && props.halfChecked || mergedColor.value ? `linear-gradient(${mergedColor.value}, ${mergedColor.value})` : "";
415
+ const spanStyle = [`border-color:${(mergedChecked.value || props.halfChecked) && mergedColor.value ? mergedColor.value : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor.value && props.halfChecked ? mergedColor.value : ""}`];
416
+ const spanCls = {
417
+ [ns2.e("material")]: true,
418
+ "custom-color": mergedColor.value,
419
+ [ns2.m("no-label")]: !props.label && !ctx.slots.default,
420
+ [ns2.m("no-animation")]: !mergedShowAnimation.value,
421
+ [ns2.e("default-background")]: !props.halfChecked
422
+ };
423
+ const polygonCls = {
424
+ [ns2.e("tick")]: true,
425
+ [ns2.m("no-animation")]: !mergedShowAnimation.value
426
+ };
427
+ const labelCls = {
428
+ [ns2.m(size.value)]: border.value,
429
+ [ns2.m("bordered")]: border.value
430
+ };
431
+ const stopPropagation = ($event) => $event.stopPropagation();
432
+ const inputProps = {
433
+ indeterminate: props.halfChecked
434
+ };
435
+ return createVNode("div", {
436
+ "class": wrapperCls,
437
+ "style": wrapperStyle
438
+ }, [createVNode("div", {
439
+ "class": checkboxCls
440
+ }, [createVNode("label", {
441
+ "title": labelTitle,
442
+ "onClick": handleClick,
443
+ "class": labelCls,
444
+ "style": {
445
+ width: itemWidth ? "100%" : "auto"
446
+ }
447
+ }, [createVNode("input", mergeProps({
448
+ "name": props.name || props.value,
449
+ "class": ns2.e("input"),
450
+ "type": "checkbox"
451
+ }, inputProps, {
452
+ "checked": mergedChecked.value,
453
+ "disabled": mergedDisabled.value,
454
+ "onClick": stopPropagation,
455
+ "onChange": stopPropagation
456
+ }), null), createVNode("span", {
457
+ "style": spanStyle,
458
+ "class": spanCls
459
+ }, [createVNode("span", {
460
+ "class": ns2.e("halfchecked-bg")
461
+ }, null), createVNode("svg", {
462
+ "viewBox": "0 0 16 16",
463
+ "version": "1.1",
464
+ "xmlns": "http://www.w3.org/2000/svg",
465
+ "class": ns2.e("tick-wrap")
466
+ }, [createVNode("g", {
467
+ "stroke": "none",
468
+ "stroke-width": "1",
469
+ "fill": "none",
470
+ "fill-rule": "evenodd"
471
+ }, [createVNode("polygon", {
472
+ "fill-rule": "nonzero",
473
+ "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
474
+ "class": polygonCls
475
+ }, null)])])]), props.label || ((_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a))])])]);
476
+ };
352
477
  }
353
478
  });
354
479
  var checkboxGroup = "";
@@ -357,102 +482,105 @@ defineComponent({
357
482
  props: checkboxGroupProps,
358
483
  emits: ["change", "update:modelValue"],
359
484
  setup(props, ctx) {
360
- const valList = toRef(props, "modelValue");
361
- const defaultOpt = {
362
- checked: false,
363
- isShowTitle: true,
364
- halfchecked: false,
365
- showAnimation: true,
366
- disabled: false
367
- };
368
- const toggleGroupVal = (val) => {
369
- let index2 = -1;
370
- if (typeof valList.value[0] === "string") {
371
- index2 = valList.value.findIndex((item) => item === val);
372
- } else if (typeof valList.value[0] === "object") {
373
- index2 = valList.value.findIndex((item) => item.value === val);
374
- }
375
- if (index2 === -1) {
376
- if (typeof props.options[0] === "object") {
377
- const newOne = props.options.find((item) => item.value === val);
378
- const res2 = [...valList.value, newOne];
379
- ctx.emit("update:modelValue", res2);
380
- ctx.emit("change", res2);
381
- return;
382
- }
383
- const res = [...valList.value, val];
384
- ctx.emit("update:modelValue", res);
385
- ctx.emit("change", res);
386
- return;
387
- }
388
- valList.value.splice(index2, 1);
389
- ctx.emit("update:modelValue", valList.value);
390
- ctx.emit("change", valList.value);
391
- };
392
- const isItemChecked = (itemVal) => {
393
- if (typeof valList.value[0] === "string") {
394
- return valList.value.includes(itemVal);
395
- } else if (typeof valList.value[0] === "object") {
396
- return valList.value.some((item) => item.value === itemVal);
397
- }
398
- };
399
- provide(checkboxGroupInjectionKey, {
400
- disabled: toRef(props, "disabled"),
401
- isShowTitle: toRef(props, "isShowTitle"),
402
- color: toRef(props, "color"),
403
- showAnimation: toRef(props, "showAnimation"),
404
- beforeChange: props.beforeChange,
405
- isItemChecked,
406
- toggleGroupVal,
407
- itemWidth: toRef(props, "itemWidth"),
408
- direction: toRef(props, "direction")
409
- });
410
- return {
485
+ const ns2 = useNamespace("checkbox");
486
+ const {
411
487
  defaultOpt
488
+ } = useCheckboxGroup(props, ctx);
489
+ return () => {
490
+ var _a, _b;
491
+ let children = (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a);
492
+ const getContent = () => {
493
+ var _a2;
494
+ if (children) {
495
+ return children;
496
+ } else {
497
+ if (((_a2 = props.options) == null ? void 0 : _a2.length) > 0) {
498
+ children = props.options.map((opt) => {
499
+ let mergedOpt = null;
500
+ if (typeof opt === "string") {
501
+ mergedOpt = Object.assign({}, defaultOpt, {
502
+ label: opt,
503
+ value: opt
504
+ });
505
+ } else if (typeof opt === "object") {
506
+ mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
507
+ label: opt.name
508
+ }));
509
+ }
510
+ return createVNode(Checkbox, mergedOpt, null);
511
+ });
512
+ }
513
+ return children;
514
+ }
515
+ };
516
+ return createVNode("div", {
517
+ "class": ns2.e("group")
518
+ }, [createVNode("div", {
519
+ "class": {
520
+ [ns2.m("list-inline")]: props.direction === "row"
521
+ }
522
+ }, [getContent()])]);
412
523
  };
413
- },
414
- render() {
415
- var _a;
524
+ }
525
+ });
526
+ var checkboxButton = "";
527
+ defineComponent({
528
+ name: "DCheckboxButton",
529
+ props: checkboxProps,
530
+ emits: ["change", "update:checked", "update:modelValue"],
531
+ setup(props, ctx) {
532
+ const ns2 = useNamespace("checkbox-button");
416
533
  const {
417
- direction,
418
- $slots,
419
- defaultOpt,
420
- options
421
- } = this;
422
- let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
423
- if ((options == null ? void 0 : options.length) > 0) {
424
- children = options.map((opt) => {
425
- let mergedOpt = null;
426
- if (typeof opt === "string") {
427
- mergedOpt = Object.assign({}, defaultOpt, {
428
- label: opt,
429
- value: opt
430
- });
431
- } else if (typeof opt === "object") {
432
- mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
433
- label: opt.name
434
- }));
435
- }
436
- return createVNode(Checkbox, mergedOpt, null);
437
- });
438
- }
439
- return createVNode("div", {
440
- "class": "devui-checkbox-group"
441
- }, [createVNode("div", {
442
- "class": {
443
- "devui-checkbox-list-inline": direction === "row"
444
- }
445
- }, [children])]);
534
+ mergedChecked,
535
+ mergedDisabled,
536
+ mergedIsShowTitle,
537
+ mergedColor,
538
+ handleClick,
539
+ size
540
+ } = useCheckbox(props, ctx);
541
+ const {
542
+ mergedTextColor
543
+ } = useCheckboxButton();
544
+ return () => {
545
+ var _a, _b;
546
+ const labelTitle = mergedIsShowTitle.value ? props.title || props.label : "";
547
+ const spanStyle = [`border-color:${mergedChecked.value && mergedColor.value ? mergedColor.value : ""}`, `background-color:${mergedChecked.value && mergedColor.value ? mergedColor.value : ""}`, `color:${mergedChecked.value && mergedTextColor.value ? mergedTextColor.value : ""}`];
548
+ const labelCls = {
549
+ [ns2.b()]: true,
550
+ active: mergedChecked.value,
551
+ disabled: mergedDisabled.value,
552
+ unchecked: !mergedChecked.value
553
+ };
554
+ const spanCls = {
555
+ [ns2.e("content")]: true,
556
+ [ns2.m(size.value)]: true
557
+ };
558
+ const stopPropagation = ($event) => $event.stopPropagation();
559
+ return createVNode("label", {
560
+ "title": labelTitle,
561
+ "onClick": handleClick,
562
+ "class": labelCls
563
+ }, [createVNode("input", {
564
+ "name": props.name || props.value,
565
+ "class": ns2.e("input"),
566
+ "type": "checkbox",
567
+ "checked": mergedChecked.value,
568
+ "disabled": mergedDisabled.value,
569
+ "onClick": stopPropagation,
570
+ "onChange": stopPropagation
571
+ }, null), createVNode("span", {
572
+ "style": spanStyle,
573
+ "class": spanCls
574
+ }, [props.label || ((_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a))])]);
575
+ };
446
576
  }
447
577
  });
578
+ const ns = useNamespace("tree");
448
579
  function useTreeNode(data) {
449
580
  const { getChildren } = inject(USE_TREE_TOKEN);
450
581
  const nodeClass = computed(() => {
451
582
  var _a;
452
- return [
453
- "devui-tree-node",
454
- ((_a = data.value) == null ? void 0 : _a.expanded) && "devui-tree-node__open"
455
- ];
583
+ return [ns.e("node"), ((_a = data.value) == null ? void 0 : _a.expanded) && ns.em("node", "open")];
456
584
  });
457
585
  const nodeStyle = computed(() => {
458
586
  var _a;
@@ -460,9 +588,7 @@ function useTreeNode(data) {
460
588
  });
461
589
  const nodeVLineClass = computed(() => {
462
590
  var _a, _b;
463
- return [
464
- !((_a = data.value) == null ? void 0 : _a.isLeaf) && ((_b = data.value) == null ? void 0 : _b.expanded) && "devui-tree-node__vline"
465
- ];
591
+ return [!((_a = data.value) == null ? void 0 : _a.isLeaf) && ((_b = data.value) == null ? void 0 : _b.expanded) && ns.e("node-vline")];
466
592
  });
467
593
  const nodeVLineStyle = computed(() => {
468
594
  var _a;
@@ -474,23 +600,15 @@ function useTreeNode(data) {
474
600
  });
475
601
  const nodeHLineClass = computed(() => {
476
602
  var _a;
477
- return [
478
- ((_a = data.value) == null ? void 0 : _a.level) !== 1 && "devui-tree-node__hline"
479
- ];
603
+ return [((_a = data.value) == null ? void 0 : _a.level) !== 1 && ns.e("node-hline")];
480
604
  });
481
605
  const nodeContentClass = computed(() => {
482
606
  var _a;
483
- return [
484
- "devui-tree-node__content",
485
- ((_a = data.value) == null ? void 0 : _a.selected) && "active"
486
- ];
607
+ return [ns.e("node-content"), ((_a = data.value) == null ? void 0 : _a.selected) && "active"];
487
608
  });
488
609
  const nodeTitleClass = computed(() => {
489
610
  var _a;
490
- return [
491
- "devui-tree-node__title",
492
- ((_a = data.value) == null ? void 0 : _a.disableSelect) && "select-disabled"
493
- ];
611
+ return [ns.e("node-title"), ((_a = data.value) == null ? void 0 : _a.disableSelect) && "select-disabled"];
494
612
  });
495
613
  return {
496
614
  nodeClass,
@@ -550,6 +668,7 @@ var DTreeNode = defineComponent({
550
668
  toggleNode,
551
669
  getChildren
552
670
  } = inject(USE_TREE_TOKEN);
671
+ const ns2 = useNamespace("tree");
553
672
  const {
554
673
  nodeClass,
555
674
  nodeStyle,
@@ -600,7 +719,7 @@ var DTreeNode = defineComponent({
600
719
  }) : createVNode(DTreeNodeToggle, {
601
720
  "data": data.value
602
721
  }, null), createVNode("div", {
603
- "class": "devui-tree-node__content--value-wrapper",
722
+ "class": ns2.em("node-content", "value-wrapper"),
604
723
  "style": {
605
724
  height: `${NODE_HEIGHT}px`
606
725
  }
@@ -964,6 +1083,7 @@ var Tree = defineComponent({
964
1083
  data,
965
1084
  check
966
1085
  } = toRefs(props);
1086
+ const ns2 = useNamespace("tree");
967
1087
  const userPlugins = [useSelect(), useOperate(), useMergeNodes()];
968
1088
  const checkOptions = ref({
969
1089
  checkStrategy: check.value || "both"
@@ -987,7 +1107,7 @@ var Tree = defineComponent({
987
1107
  });
988
1108
  return () => {
989
1109
  return createVNode("div", {
990
- "class": "devui-tree"
1110
+ "class": ns2.b()
991
1111
  }, [getExpendedTree == null ? void 0 : getExpendedTree().value.map((treeNode) => slots.default ? renderSlot(useSlots(), "default", {
992
1112
  treeFactory,
993
1113
  nodeData: treeNode