vue-devui 1.0.0-rc.8 → 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 (123) hide show
  1. package/alert/index.es.js +2 -2
  2. package/alert/index.umd.js +1 -1
  3. package/auto-complete/index.es.js +282 -84
  4. package/auto-complete/index.umd.js +3 -5
  5. package/auto-complete/style.css +1 -1
  6. package/avatar/index.es.js +59 -74
  7. package/avatar/index.umd.js +1 -1
  8. package/badge/index.es.js +2 -2
  9. package/badge/index.umd.js +1 -1
  10. package/button/index.es.js +111 -38
  11. package/button/index.umd.js +15 -15
  12. package/button/style.css +1 -1
  13. package/card/index.es.js +2 -2
  14. package/card/index.umd.js +1 -1
  15. package/checkbox/index.es.js +340 -228
  16. package/checkbox/index.umd.js +1 -1
  17. package/checkbox/style.css +1 -1
  18. package/date-picker/index.es.js +264 -63
  19. package/date-picker/index.umd.js +1 -1
  20. package/date-picker/style.css +1 -1
  21. package/drawer/index.es.js +2 -2
  22. package/drawer/index.umd.js +1 -1
  23. package/dropdown/index.es.js +104 -48
  24. package/dropdown/index.umd.js +1 -1
  25. package/dropdown/style.css +1 -1
  26. package/editable-select/index.es.js +423 -8
  27. package/editable-select/index.umd.js +1 -1
  28. package/editable-select/style.css +1 -1
  29. package/form/index.es.js +304 -184
  30. package/form/index.umd.js +15 -15
  31. package/form/style.css +1 -1
  32. package/fullscreen/index.es.js +2 -2
  33. package/fullscreen/index.umd.js +1 -1
  34. package/grid/index.es.js +8 -6
  35. package/grid/index.umd.js +1 -1
  36. package/icon/index.es.js +109 -13
  37. package/icon/index.umd.js +1 -1
  38. package/icon/style.css +1 -0
  39. package/image-preview/index.es.js +2 -2
  40. package/image-preview/index.umd.js +1 -1
  41. package/input/index.es.js +278 -30
  42. package/input/index.umd.js +1 -1
  43. package/input/style.css +1 -1
  44. package/input-number/index.es.js +272 -199
  45. package/input-number/index.umd.js +1 -1
  46. package/input-number/style.css +1 -1
  47. package/layout/index.es.js +2 -2
  48. package/layout/index.umd.js +1 -1
  49. package/loading/index.es.js +2 -2
  50. package/loading/index.umd.js +1 -1
  51. package/modal/index.es.js +105 -32
  52. package/modal/index.umd.js +1 -1
  53. package/modal/style.css +1 -1
  54. package/notification/index.es.js +105 -32
  55. package/notification/index.umd.js +1 -1
  56. package/notification/style.css +1 -1
  57. package/nuxt/components/CheckboxButton.js +3 -0
  58. package/nuxt/components/Icon.js +1 -0
  59. package/nuxt/components/LABEL_DATA.js +3 -0
  60. package/nuxt/components/Option.js +3 -0
  61. package/nuxt/components/iconProps.js +1 -0
  62. package/nuxt/components/svgIconProps.js +3 -0
  63. package/overlay/index.es.js +2 -2
  64. package/overlay/index.umd.js +1 -1
  65. package/package.json +2 -1
  66. package/pagination/index.es.js +2 -2
  67. package/pagination/index.umd.js +1 -1
  68. package/popover/index.es.js +153 -67
  69. package/popover/index.umd.js +15 -15
  70. package/popover/style.css +1 -1
  71. package/progress/index.es.js +2 -2
  72. package/progress/index.umd.js +2 -2
  73. package/radio/index.es.js +139 -143
  74. package/radio/index.umd.js +1 -1
  75. package/rate/index.es.js +16 -8
  76. package/rate/index.umd.js +1 -1
  77. package/result/index.es.js +108 -12
  78. package/result/index.umd.js +1 -1
  79. package/result/style.css +1 -1
  80. package/search/index.es.js +316 -60
  81. package/search/index.umd.js +16 -16
  82. package/search/style.css +1 -1
  83. package/select/index.es.js +7334 -574
  84. package/select/index.umd.js +27 -1
  85. package/select/style.css +1 -1
  86. package/skeleton/index.es.js +2 -2
  87. package/skeleton/index.umd.js +1 -1
  88. package/slider/index.es.js +2 -2
  89. package/slider/index.umd.js +1 -1
  90. package/splitter/index.es.js +178 -89
  91. package/splitter/index.umd.js +17 -17
  92. package/splitter/style.css +1 -1
  93. package/status/index.es.js +2 -2
  94. package/status/index.umd.js +1 -1
  95. package/style.css +1 -1
  96. package/switch/index.es.js +2 -2
  97. package/switch/index.umd.js +1 -1
  98. package/table/index.es.js +1301 -524
  99. package/table/index.umd.js +18 -18
  100. package/table/style.css +1 -1
  101. package/tabs/index.es.js +114 -72
  102. package/tabs/index.umd.js +1 -1
  103. package/tabs/style.css +1 -1
  104. package/tag/index.es.js +6 -7
  105. package/tag/index.umd.js +1 -1
  106. package/textarea/index.es.js +5545 -11
  107. package/textarea/index.umd.js +35 -1
  108. package/timeline/index.es.js +108 -12
  109. package/timeline/index.umd.js +1 -1
  110. package/timeline/style.css +1 -1
  111. package/tooltip/index.es.js +168 -79
  112. package/tooltip/index.umd.js +15 -15
  113. package/tooltip/style.css +1 -1
  114. package/tree/index.es.js +338 -227
  115. package/tree/index.umd.js +1 -1
  116. package/tree/style.css +1 -1
  117. package/upload/index.es.js +105 -32
  118. package/upload/index.umd.js +1 -1
  119. package/upload/style.css +1 -1
  120. package/vue-devui.es.js +3269 -1742
  121. package/vue-devui.umd.js +29 -23
  122. package/nuxt/components/FormControl.js +0 -3
  123. package/nuxt/components/FormLabel.js +0 -3
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;
@@ -79,8 +79,8 @@ function createBem(namespace, element, modifier) {
79
79
  }
80
80
  return cls;
81
81
  }
82
- function useNamespace(block) {
83
- const namespace = `devui-${block}`;
82
+ function useNamespace(block, needDot = false) {
83
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
84
84
  const b = () => createBem(namespace);
85
85
  const e = (element) => element ? createBem(namespace, element) : "";
86
86
  const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
@@ -159,6 +159,10 @@ const commonProps = {
159
159
  beforeChange: {
160
160
  type: Function,
161
161
  default: void 0
162
+ },
163
+ size: {
164
+ type: String,
165
+ default: "md"
162
166
  }
163
167
  };
164
168
  const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
@@ -167,11 +171,11 @@ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
167
171
  default: false
168
172
  },
169
173
  value: {
170
- type: String
174
+ type: [Number, String]
171
175
  },
172
176
  label: {
173
177
  type: String,
174
- default: void 0
178
+ default: ""
175
179
  },
176
180
  "onUpdate:checked": {
177
181
  type: Function,
@@ -186,6 +190,10 @@ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
186
190
  },
187
191
  "onUpdate:modelValue": {
188
192
  type: Function
193
+ },
194
+ border: {
195
+ type: Boolean,
196
+ default: false
189
197
  }
190
198
  });
191
199
  const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
@@ -212,162 +220,260 @@ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
212
220
  "onUpdate:modelValue": {
213
221
  type: Function,
214
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: ""
215
235
  }
216
236
  });
217
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
+ }
218
380
  var checkbox = "";
219
381
  var Checkbox = defineComponent({
220
382
  name: "DCheckbox",
221
383
  props: checkboxProps,
222
384
  emits: ["change", "update:checked", "update:modelValue"],
223
385
  setup(props, ctx) {
224
- const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
225
386
  const ns2 = useNamespace("checkbox");
226
- const isChecked = computed(() => props.checked || props.modelValue);
227
- const mergedDisabled = computed(() => {
228
- return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
229
- });
230
- const mergedChecked = computed(() => {
231
- var _a, _b;
232
- return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
233
- });
234
- const mergedIsShowTitle = computed(() => {
235
- var _a;
236
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
237
- });
238
- const mergedShowAnimation = computed(() => {
239
- var _a;
240
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
241
- });
242
- const mergedColor = computed(() => {
243
- var _a;
244
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
245
- });
246
- const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
247
- const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
248
- const canChange = (checked, val) => {
249
- var _a;
250
- if (mergedDisabled.value) {
251
- return Promise.resolve(false);
252
- }
253
- const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
254
- if (beforeChange) {
255
- const res = beforeChange(checked, val);
256
- if (typeof res === "boolean") {
257
- return Promise.resolve(res);
258
- }
259
- return res;
260
- }
261
- return Promise.resolve(true);
262
- };
263
- const toggle = () => {
264
- const current = !isChecked.value;
265
- checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
266
- ctx.emit("update:checked", current);
267
- ctx.emit("update:modelValue", current);
268
- ctx.emit("change", current);
269
- };
270
- const handleClick = () => {
271
- canChange(!isChecked.value, props.label).then((res) => res && toggle());
272
- };
273
- return {
274
- itemWidth,
275
- direction,
276
- mergedColor,
277
- mergedDisabled,
278
- mergedIsShowTitle,
279
- mergedChecked,
280
- mergedShowAnimation,
281
- handleClick,
282
- ns: ns2
283
- };
284
- },
285
- render() {
286
- var _a;
287
387
  const {
288
- itemWidth,
289
- direction,
290
388
  mergedChecked,
291
389
  mergedDisabled,
292
390
  mergedIsShowTitle,
293
391
  mergedShowAnimation,
294
- halfChecked,
295
- title,
296
- label,
297
- handleClick,
298
- name,
299
- value,
300
392
  mergedColor,
301
- ns: ns2,
302
- $slots
303
- } = this;
304
- const wrapperCls = {
305
- [ns2.e("column-margin")]: direction === "column",
306
- [ns2.e("wrap")]: typeof itemWidth !== "undefined"
307
- };
308
- const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
309
- const checkboxCls = {
310
- [ns2.b()]: true,
311
- active: mergedChecked,
312
- "half-checked": halfChecked,
313
- disabled: mergedDisabled,
314
- unchecked: !mergedChecked
315
- };
316
- const labelTitle = mergedIsShowTitle ? title || label : "";
317
- const bgImgStyle = mergedColor && halfChecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
318
- const spanStyle = [`border-color:${(mergedChecked || halfChecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfChecked ? mergedColor : ""}`];
319
- const spanCls = {
320
- [ns2.e("material")]: true,
321
- "custom-color": mergedColor,
322
- [ns2.m("no-label")]: !label && !$slots.default,
323
- [ns2.m("no-animation")]: !mergedShowAnimation,
324
- [ns2.e("default-background")]: !halfChecked
325
- };
326
- const polygonCls = {
327
- [ns2.e("tick")]: true,
328
- [ns2.m("no-animation")]: !mergedShowAnimation
329
- };
330
- const stopPropagation = ($event) => $event.stopPropagation();
331
- const inputProps = {
332
- indeterminate: halfChecked
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))])])]);
333
476
  };
334
- return createVNode("div", {
335
- "class": wrapperCls,
336
- "style": wrapperStyle
337
- }, [createVNode("div", {
338
- "class": checkboxCls
339
- }, [createVNode("label", {
340
- "title": labelTitle,
341
- "onClick": handleClick
342
- }, [createVNode("input", mergeProps({
343
- "name": name || value,
344
- "class": ns2.e("input"),
345
- "type": "checkbox"
346
- }, inputProps, {
347
- "checked": mergedChecked,
348
- "disabled": mergedDisabled,
349
- "onClick": stopPropagation,
350
- "onChange": stopPropagation
351
- }), null), createVNode("span", {
352
- "style": spanStyle,
353
- "class": spanCls
354
- }, [createVNode("span", {
355
- "class": ns2.e("halfchecked-bg")
356
- }, null), createVNode("svg", {
357
- "viewBox": "0 0 16 16",
358
- "version": "1.1",
359
- "xmlns": "http://www.w3.org/2000/svg",
360
- "class": ns2.e("tick-wrap")
361
- }, [createVNode("g", {
362
- "stroke": "none",
363
- "stroke-width": "1",
364
- "fill": "none",
365
- "fill-rule": "evenodd"
366
- }, [createVNode("polygon", {
367
- "fill-rule": "nonzero",
368
- "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
369
- "class": polygonCls
370
- }, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
371
477
  }
372
478
  });
373
479
  var checkboxGroup = "";
@@ -376,92 +482,97 @@ defineComponent({
376
482
  props: checkboxGroupProps,
377
483
  emits: ["change", "update:modelValue"],
378
484
  setup(props, ctx) {
379
- const valList = toRef(props, "modelValue");
380
- const defaultOpt = {
381
- checked: false,
382
- isShowTitle: true,
383
- halfChecked: false,
384
- showAnimation: true,
385
- disabled: false
386
- };
387
- const toggleGroupVal = (val) => {
388
- let index2 = -1;
389
- if (typeof valList.value[0] === "string") {
390
- index2 = valList.value.findIndex((item) => item === val);
391
- } else if (typeof valList.value[0] === "object") {
392
- index2 = valList.value.findIndex((item) => item.value === val);
393
- }
394
- if (index2 === -1) {
395
- if (typeof props.options[0] === "object") {
396
- const newOne = props.options.find((item) => item.value === val);
397
- const res2 = [...valList.value, newOne];
398
- ctx.emit("update:modelValue", res2);
399
- ctx.emit("change", res2);
400
- return;
401
- }
402
- const res = [...valList.value, val];
403
- ctx.emit("update:modelValue", res);
404
- ctx.emit("change", res);
405
- return;
406
- }
407
- valList.value.splice(index2, 1);
408
- ctx.emit("update:modelValue", valList.value);
409
- ctx.emit("change", valList.value);
410
- };
411
- const isItemChecked = (itemVal) => {
412
- if (typeof valList.value[0] === "string") {
413
- return valList.value.includes(itemVal);
414
- } else if (typeof valList.value[0] === "object") {
415
- return valList.value.some((item) => item.value === itemVal);
416
- }
417
- };
418
- provide(checkboxGroupInjectionKey, {
419
- disabled: toRef(props, "disabled"),
420
- isShowTitle: toRef(props, "isShowTitle"),
421
- color: toRef(props, "color"),
422
- showAnimation: toRef(props, "showAnimation"),
423
- beforeChange: props.beforeChange,
424
- isItemChecked,
425
- toggleGroupVal,
426
- itemWidth: toRef(props, "itemWidth"),
427
- direction: toRef(props, "direction")
428
- });
429
- return {
485
+ const ns2 = useNamespace("checkbox");
486
+ const {
430
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()])]);
431
523
  };
432
- },
433
- render() {
434
- 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");
435
533
  const {
436
- direction,
437
- $slots,
438
- defaultOpt,
439
- options
440
- } = this;
441
- let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
442
- if ((options == null ? void 0 : options.length) > 0) {
443
- children = options.map((opt) => {
444
- let mergedOpt = null;
445
- if (typeof opt === "string") {
446
- mergedOpt = Object.assign({}, defaultOpt, {
447
- label: opt,
448
- value: opt
449
- });
450
- } else if (typeof opt === "object") {
451
- mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
452
- label: opt.name
453
- }));
454
- }
455
- return createVNode(Checkbox, mergedOpt, null);
456
- });
457
- }
458
- return createVNode("div", {
459
- "class": "devui-checkbox-group"
460
- }, [createVNode("div", {
461
- "class": {
462
- "devui-checkbox-list-inline": direction === "row"
463
- }
464
- }, [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
+ };
465
576
  }
466
577
  });
467
578
  const ns = useNamespace("tree");