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.
- package/README.md +5 -0
- package/alert/index.es.js +37 -11
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +311 -77
- package/auto-complete/index.umd.js +3 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +81 -70
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +29 -4
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5632 -87
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +56 -29
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +364 -234
- package/checkbox/index.umd.js +1 -1
- package/checkbox/style.css +1 -1
- package/date-picker/index.es.js +310 -157
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +28 -3
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +125 -45
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +437 -22
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +490 -605
- package/form/index.umd.js +15 -15
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +29 -5
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +71 -50
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +109 -13
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +34 -11
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +330 -130
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +272 -199
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +34 -6
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +34 -10
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/modal/index.es.js +126 -27
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +125 -25
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/CheckboxGroup.js +3 -0
- package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
- package/nuxt/components/FORM_TOKEN.js +3 -0
- package/nuxt/components/Icon.js +1 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/formControlProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/nuxt/components/iconProps.js +1 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/overlay/index.es.js +31 -9
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +2 -1
- package/pagination/index.es.js +135 -124
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/popover/index.es.js +198 -83
- package/popover/index.umd.js +16 -16
- package/popover/style.css +1 -1
- package/progress/index.es.js +76 -20
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +161 -140
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +48 -16
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +108 -12
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/search/index.es.js +379 -167
- package/search/index.umd.js +17 -17
- package/search/style.css +1 -1
- package/select/index.es.js +7339 -556
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +37 -12
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +34 -10
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +201 -84
- package/splitter/index.umd.js +14 -14
- package/splitter/style.css +1 -1
- package/status/index.es.js +26 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +30 -6
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +6808 -585
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +136 -70
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +31 -7
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +5631 -80
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/timeline/index.es.js +108 -12
- package/timeline/index.umd.js +1 -1
- package/timeline/style.css +1 -1
- package/tooltip/index.es.js +190 -74
- package/tooltip/index.umd.js +17 -17
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +376 -256
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +138 -34
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +6770 -5769
- package/vue-devui.umd.js +27 -21
- package/comment/index.d.ts +0 -7
- package/comment/index.es.js +0 -84
- package/comment/index.umd.js +0 -1
- package/comment/package.json +0 -7
- package/comment/style.css +0 -1
- package/nuxt/components/Comment.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/ReadTip.js +0 -3
- package/nuxt/components/commentProps.js +0 -3
- package/nuxt/components/readTipProps.js +0 -3
- package/read-tip/index.d.ts +0 -7
- package/read-tip/index.es.js +0 -261
- package/read-tip/index.umd.js +0 -1
- package/read-tip/package.json +0 -7
- package/read-tip/style.css +0 -1
package/checkbox/index.es.js
CHANGED
|
@@ -17,14 +17,13 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import {
|
|
21
|
-
var checkbox = "";
|
|
20
|
+
import { inject, computed, toRef, provide, defineComponent, createVNode, mergeProps } from "vue";
|
|
22
21
|
const commonProps = {
|
|
23
22
|
name: {
|
|
24
23
|
type: String,
|
|
25
24
|
default: void 0
|
|
26
25
|
},
|
|
27
|
-
|
|
26
|
+
halfChecked: {
|
|
28
27
|
type: Boolean,
|
|
29
28
|
default: false
|
|
30
29
|
},
|
|
@@ -50,27 +49,23 @@ const commonProps = {
|
|
|
50
49
|
beforeChange: {
|
|
51
50
|
type: Function,
|
|
52
51
|
default: void 0
|
|
52
|
+
},
|
|
53
|
+
size: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "md"
|
|
53
56
|
}
|
|
54
57
|
};
|
|
55
58
|
const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
56
|
-
halfchecked: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false
|
|
59
|
-
},
|
|
60
59
|
checked: {
|
|
61
60
|
type: Boolean,
|
|
62
61
|
default: false
|
|
63
62
|
},
|
|
64
63
|
value: {
|
|
65
|
-
type: String
|
|
64
|
+
type: [Number, String]
|
|
66
65
|
},
|
|
67
66
|
label: {
|
|
68
67
|
type: String,
|
|
69
|
-
default:
|
|
70
|
-
},
|
|
71
|
-
title: {
|
|
72
|
-
type: String,
|
|
73
|
-
default: void 0
|
|
68
|
+
default: ""
|
|
74
69
|
},
|
|
75
70
|
"onUpdate:checked": {
|
|
76
71
|
type: Function,
|
|
@@ -85,6 +80,10 @@ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
|
85
80
|
},
|
|
86
81
|
"onUpdate:modelValue": {
|
|
87
82
|
type: Function
|
|
83
|
+
},
|
|
84
|
+
border: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: false
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
89
|
const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
@@ -111,158 +110,283 @@ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
|
111
110
|
"onUpdate:modelValue": {
|
|
112
111
|
type: Function,
|
|
113
112
|
default: void 0
|
|
113
|
+
},
|
|
114
|
+
border: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: false
|
|
117
|
+
},
|
|
118
|
+
max: {
|
|
119
|
+
type: Number,
|
|
120
|
+
default: void 0
|
|
121
|
+
},
|
|
122
|
+
textColor: {
|
|
123
|
+
type: String,
|
|
124
|
+
default: ""
|
|
114
125
|
}
|
|
115
126
|
});
|
|
116
127
|
const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
|
|
128
|
+
function createBem(namespace, element, modifier) {
|
|
129
|
+
let cls = namespace;
|
|
130
|
+
if (element) {
|
|
131
|
+
cls += `__${element}`;
|
|
132
|
+
}
|
|
133
|
+
if (modifier) {
|
|
134
|
+
cls += `--${modifier}`;
|
|
135
|
+
}
|
|
136
|
+
return cls;
|
|
137
|
+
}
|
|
138
|
+
function useNamespace(block, needDot = false) {
|
|
139
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
140
|
+
const b = () => createBem(namespace);
|
|
141
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
142
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
143
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
144
|
+
return {
|
|
145
|
+
b,
|
|
146
|
+
e,
|
|
147
|
+
m,
|
|
148
|
+
em
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function useCheckbox(props, ctx) {
|
|
152
|
+
const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
|
|
153
|
+
const isChecked = computed(() => props.checked || props.modelValue);
|
|
154
|
+
const mergedChecked = computed(() => {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
|
|
157
|
+
});
|
|
158
|
+
const isLimitDisabled = computed(() => {
|
|
159
|
+
const max = checkboxGroupConf == null ? void 0 : checkboxGroupConf.max.value;
|
|
160
|
+
return !!max && (checkboxGroupConf == null ? void 0 : checkboxGroupConf.modelValue.value.length) >= max && !mergedChecked.value;
|
|
161
|
+
});
|
|
162
|
+
const mergedDisabled = computed(() => {
|
|
163
|
+
return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled || isLimitDisabled.value;
|
|
164
|
+
});
|
|
165
|
+
const mergedIsShowTitle = computed(() => {
|
|
166
|
+
var _a;
|
|
167
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
|
|
168
|
+
});
|
|
169
|
+
const mergedShowAnimation = computed(() => {
|
|
170
|
+
var _a;
|
|
171
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
|
|
172
|
+
});
|
|
173
|
+
const mergedColor = computed(() => {
|
|
174
|
+
var _a;
|
|
175
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
|
|
176
|
+
});
|
|
177
|
+
const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
|
|
178
|
+
const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
|
|
179
|
+
const canChange = (checked, val) => {
|
|
180
|
+
var _a;
|
|
181
|
+
if (mergedDisabled.value) {
|
|
182
|
+
return Promise.resolve(false);
|
|
183
|
+
}
|
|
184
|
+
const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
|
|
185
|
+
if (beforeChange) {
|
|
186
|
+
const res = beforeChange(checked, val);
|
|
187
|
+
if (typeof res === "boolean") {
|
|
188
|
+
return Promise.resolve(res);
|
|
189
|
+
}
|
|
190
|
+
return res;
|
|
191
|
+
}
|
|
192
|
+
return Promise.resolve(true);
|
|
193
|
+
};
|
|
194
|
+
const toggle = () => {
|
|
195
|
+
const current = !isChecked.value;
|
|
196
|
+
checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
|
|
197
|
+
ctx.emit("update:checked", current);
|
|
198
|
+
ctx.emit("update:modelValue", current);
|
|
199
|
+
ctx.emit("change", current);
|
|
200
|
+
};
|
|
201
|
+
const handleClick = () => {
|
|
202
|
+
canChange(!isChecked.value, props.label).then((res) => res && toggle());
|
|
203
|
+
};
|
|
204
|
+
const size = computed(() => {
|
|
205
|
+
var _a;
|
|
206
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.size.value) != null ? _a : props.size;
|
|
207
|
+
});
|
|
208
|
+
const border = computed(() => {
|
|
209
|
+
var _a;
|
|
210
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.border.value) != null ? _a : props.border;
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
mergedChecked,
|
|
214
|
+
mergedDisabled,
|
|
215
|
+
mergedIsShowTitle,
|
|
216
|
+
mergedShowAnimation,
|
|
217
|
+
mergedColor,
|
|
218
|
+
itemWidth,
|
|
219
|
+
direction,
|
|
220
|
+
handleClick,
|
|
221
|
+
size,
|
|
222
|
+
border
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function useCheckboxGroup(props, ctx) {
|
|
226
|
+
const valList = toRef(props, "modelValue");
|
|
227
|
+
const defaultOpt = {
|
|
228
|
+
checked: false,
|
|
229
|
+
isShowTitle: true,
|
|
230
|
+
halfChecked: false,
|
|
231
|
+
showAnimation: true,
|
|
232
|
+
disabled: false
|
|
233
|
+
};
|
|
234
|
+
const toggleGroupVal = (val) => {
|
|
235
|
+
let index2 = -1;
|
|
236
|
+
if (["string", "number"].includes(typeof valList.value[0])) {
|
|
237
|
+
index2 = valList.value.findIndex((item) => item === val);
|
|
238
|
+
} else if (typeof valList.value[0] === "object") {
|
|
239
|
+
index2 = valList.value.findIndex((item) => item.value === val);
|
|
240
|
+
}
|
|
241
|
+
if (index2 === -1) {
|
|
242
|
+
if (typeof props.options[0] === "object") {
|
|
243
|
+
const newOne = props.options.find((item) => item.value === val);
|
|
244
|
+
const res2 = [...valList.value, newOne];
|
|
245
|
+
ctx.emit("update:modelValue", res2);
|
|
246
|
+
ctx.emit("change", res2);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const res = [...valList.value, val];
|
|
250
|
+
ctx.emit("update:modelValue", res);
|
|
251
|
+
ctx.emit("change", res);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
valList.value.splice(index2, 1);
|
|
255
|
+
ctx.emit("update:modelValue", valList.value);
|
|
256
|
+
ctx.emit("change", valList.value);
|
|
257
|
+
};
|
|
258
|
+
const isItemChecked = (itemVal) => {
|
|
259
|
+
if (["string", "number"].includes(typeof valList.value[0])) {
|
|
260
|
+
return valList.value.includes(itemVal);
|
|
261
|
+
} else if (typeof valList.value[0] === "object") {
|
|
262
|
+
return valList.value.some((item) => item.value === itemVal);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
provide(checkboxGroupInjectionKey, {
|
|
266
|
+
disabled: toRef(props, "disabled"),
|
|
267
|
+
isShowTitle: toRef(props, "isShowTitle"),
|
|
268
|
+
color: toRef(props, "color"),
|
|
269
|
+
showAnimation: toRef(props, "showAnimation"),
|
|
270
|
+
beforeChange: props.beforeChange,
|
|
271
|
+
isItemChecked,
|
|
272
|
+
toggleGroupVal,
|
|
273
|
+
itemWidth: toRef(props, "itemWidth"),
|
|
274
|
+
direction: toRef(props, "direction"),
|
|
275
|
+
size: toRef(props, "size"),
|
|
276
|
+
border: toRef(props, "border"),
|
|
277
|
+
max: toRef(props, "max"),
|
|
278
|
+
modelValue: toRef(props, "modelValue"),
|
|
279
|
+
textColor: toRef(props, "textColor")
|
|
280
|
+
});
|
|
281
|
+
return { defaultOpt };
|
|
282
|
+
}
|
|
283
|
+
function useCheckboxButton() {
|
|
284
|
+
const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
|
|
285
|
+
const mergedTextColor = computed(() => {
|
|
286
|
+
var _a;
|
|
287
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.textColor.value) != null ? _a : void 0;
|
|
288
|
+
});
|
|
289
|
+
return {
|
|
290
|
+
mergedTextColor
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
var checkbox = "";
|
|
117
294
|
var Checkbox = defineComponent({
|
|
118
295
|
name: "DCheckbox",
|
|
119
296
|
props: checkboxProps,
|
|
120
297
|
emits: ["change", "update:checked", "update:modelValue"],
|
|
121
298
|
setup(props, ctx) {
|
|
122
|
-
const
|
|
123
|
-
const isChecked = computed(() => props.checked || props.modelValue);
|
|
124
|
-
const mergedDisabled = computed(() => {
|
|
125
|
-
return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
|
|
126
|
-
});
|
|
127
|
-
const mergedChecked = computed(() => {
|
|
128
|
-
var _a, _b;
|
|
129
|
-
return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
|
|
130
|
-
});
|
|
131
|
-
const mergedIsShowTitle = computed(() => {
|
|
132
|
-
var _a;
|
|
133
|
-
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
|
|
134
|
-
});
|
|
135
|
-
const mergedShowAnimation = computed(() => {
|
|
136
|
-
var _a;
|
|
137
|
-
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
|
|
138
|
-
});
|
|
139
|
-
const mergedColor = computed(() => {
|
|
140
|
-
var _a;
|
|
141
|
-
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
|
|
142
|
-
});
|
|
143
|
-
const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
|
|
144
|
-
const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
|
|
145
|
-
const canChange = (checked, val) => {
|
|
146
|
-
var _a;
|
|
147
|
-
if (mergedDisabled.value) {
|
|
148
|
-
return Promise.resolve(false);
|
|
149
|
-
}
|
|
150
|
-
const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
|
|
151
|
-
if (beforeChange) {
|
|
152
|
-
const res = beforeChange(checked, val);
|
|
153
|
-
if (typeof res === "boolean") {
|
|
154
|
-
return Promise.resolve(res);
|
|
155
|
-
}
|
|
156
|
-
return res;
|
|
157
|
-
}
|
|
158
|
-
return Promise.resolve(true);
|
|
159
|
-
};
|
|
160
|
-
const toggle = () => {
|
|
161
|
-
const current = !isChecked.value;
|
|
162
|
-
checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
|
|
163
|
-
ctx.emit("update:checked", current);
|
|
164
|
-
ctx.emit("update:modelValue", current);
|
|
165
|
-
ctx.emit("change", current);
|
|
166
|
-
};
|
|
167
|
-
const handleClick = () => {
|
|
168
|
-
canChange(!isChecked.value, props.label).then((res) => res && toggle());
|
|
169
|
-
};
|
|
170
|
-
return {
|
|
171
|
-
itemWidth,
|
|
172
|
-
direction,
|
|
173
|
-
mergedColor,
|
|
174
|
-
mergedDisabled,
|
|
175
|
-
mergedIsShowTitle,
|
|
176
|
-
mergedChecked,
|
|
177
|
-
mergedShowAnimation,
|
|
178
|
-
handleClick
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
render() {
|
|
182
|
-
var _a;
|
|
299
|
+
const ns = useNamespace("checkbox");
|
|
183
300
|
const {
|
|
184
|
-
itemWidth,
|
|
185
|
-
direction,
|
|
186
301
|
mergedChecked,
|
|
187
302
|
mergedDisabled,
|
|
188
303
|
mergedIsShowTitle,
|
|
189
304
|
mergedShowAnimation,
|
|
190
|
-
halfchecked,
|
|
191
|
-
title,
|
|
192
|
-
label,
|
|
193
|
-
handleClick,
|
|
194
|
-
name,
|
|
195
|
-
value,
|
|
196
305
|
mergedColor,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
306
|
+
itemWidth,
|
|
307
|
+
direction,
|
|
308
|
+
handleClick,
|
|
309
|
+
size,
|
|
310
|
+
border
|
|
311
|
+
} = useCheckbox(props, ctx);
|
|
312
|
+
return () => {
|
|
313
|
+
var _a, _b;
|
|
314
|
+
const wrapperCls = {
|
|
315
|
+
[ns.e("column-margin")]: direction === "column",
|
|
316
|
+
[ns.e("wrap")]: typeof itemWidth !== "undefined"
|
|
317
|
+
};
|
|
318
|
+
const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
|
|
319
|
+
const checkboxCls = {
|
|
320
|
+
[ns.b()]: true,
|
|
321
|
+
active: mergedChecked.value,
|
|
322
|
+
"half-checked": props.halfChecked,
|
|
323
|
+
disabled: mergedDisabled.value,
|
|
324
|
+
unchecked: !mergedChecked.value
|
|
325
|
+
};
|
|
326
|
+
const labelTitle = mergedIsShowTitle.value ? props.title || props.label : "";
|
|
327
|
+
const bgImgStyle = mergedColor.value && props.halfChecked || mergedColor.value ? `linear-gradient(${mergedColor.value}, ${mergedColor.value})` : "";
|
|
328
|
+
const spanStyle = [`border-color:${(mergedChecked.value || props.halfChecked) && mergedColor.value ? mergedColor.value : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor.value && props.halfChecked ? mergedColor.value : ""}`];
|
|
329
|
+
const spanCls = {
|
|
330
|
+
[ns.e("material")]: true,
|
|
331
|
+
"custom-color": mergedColor.value,
|
|
332
|
+
[ns.m("no-label")]: !props.label && !ctx.slots.default,
|
|
333
|
+
[ns.m("no-animation")]: !mergedShowAnimation.value,
|
|
334
|
+
[ns.e("default-background")]: !props.halfChecked
|
|
335
|
+
};
|
|
336
|
+
const polygonCls = {
|
|
337
|
+
[ns.e("tick")]: true,
|
|
338
|
+
[ns.m("no-animation")]: !mergedShowAnimation.value
|
|
339
|
+
};
|
|
340
|
+
const labelCls = {
|
|
341
|
+
[ns.m(size.value)]: border.value,
|
|
342
|
+
[ns.m("bordered")]: border.value
|
|
343
|
+
};
|
|
344
|
+
const stopPropagation = ($event) => $event.stopPropagation();
|
|
345
|
+
const inputProps = {
|
|
346
|
+
indeterminate: props.halfChecked
|
|
347
|
+
};
|
|
348
|
+
return createVNode("div", {
|
|
349
|
+
"class": wrapperCls,
|
|
350
|
+
"style": wrapperStyle
|
|
351
|
+
}, [createVNode("div", {
|
|
352
|
+
"class": checkboxCls
|
|
353
|
+
}, [createVNode("label", {
|
|
354
|
+
"title": labelTitle,
|
|
355
|
+
"onClick": handleClick,
|
|
356
|
+
"class": labelCls,
|
|
357
|
+
"style": {
|
|
358
|
+
width: itemWidth ? "100%" : "auto"
|
|
359
|
+
}
|
|
360
|
+
}, [createVNode("input", mergeProps({
|
|
361
|
+
"name": props.name || props.value,
|
|
362
|
+
"class": ns.e("input"),
|
|
363
|
+
"type": "checkbox"
|
|
364
|
+
}, inputProps, {
|
|
365
|
+
"checked": mergedChecked.value,
|
|
366
|
+
"disabled": mergedDisabled.value,
|
|
367
|
+
"onClick": stopPropagation,
|
|
368
|
+
"onChange": stopPropagation
|
|
369
|
+
}), null), createVNode("span", {
|
|
370
|
+
"style": spanStyle,
|
|
371
|
+
"class": spanCls
|
|
372
|
+
}, [createVNode("span", {
|
|
373
|
+
"class": ns.e("halfchecked-bg")
|
|
374
|
+
}, null), createVNode("svg", {
|
|
375
|
+
"viewBox": "0 0 16 16",
|
|
376
|
+
"version": "1.1",
|
|
377
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
378
|
+
"class": ns.e("tick-wrap")
|
|
379
|
+
}, [createVNode("g", {
|
|
380
|
+
"stroke": "none",
|
|
381
|
+
"stroke-width": "1",
|
|
382
|
+
"fill": "none",
|
|
383
|
+
"fill-rule": "evenodd"
|
|
384
|
+
}, [createVNode("polygon", {
|
|
385
|
+
"fill-rule": "nonzero",
|
|
386
|
+
"points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
|
|
387
|
+
"class": polygonCls
|
|
388
|
+
}, null)])])]), props.label || ((_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a))])])]);
|
|
228
389
|
};
|
|
229
|
-
return createVNode("div", {
|
|
230
|
-
"class": wrapperCls,
|
|
231
|
-
"style": wrapperStyle
|
|
232
|
-
}, [createVNode("div", {
|
|
233
|
-
"class": checkboxCls
|
|
234
|
-
}, [createVNode("label", {
|
|
235
|
-
"title": labelTitle,
|
|
236
|
-
"onClick": handleClick
|
|
237
|
-
}, [createVNode("input", mergeProps({
|
|
238
|
-
"name": name || value,
|
|
239
|
-
"class": "devui-checkbox-input",
|
|
240
|
-
"type": "checkbox"
|
|
241
|
-
}, inputProps, {
|
|
242
|
-
"checked": mergedChecked,
|
|
243
|
-
"disabled": mergedDisabled,
|
|
244
|
-
"onClick": stopPropagation,
|
|
245
|
-
"onChange": stopPropagation
|
|
246
|
-
}), null), createVNode("span", {
|
|
247
|
-
"style": spanStyle,
|
|
248
|
-
"class": spanCls
|
|
249
|
-
}, [createVNode("span", {
|
|
250
|
-
"class": "devui-checkbox-halfchecked-bg"
|
|
251
|
-
}, null), createVNode("svg", {
|
|
252
|
-
"viewBox": "0 0 16 16",
|
|
253
|
-
"version": "1.1",
|
|
254
|
-
"xmlns": "http://www.w3.org/2000/svg",
|
|
255
|
-
"class": "devui-checkbox-tick"
|
|
256
|
-
}, [createVNode("g", {
|
|
257
|
-
"stroke": "none",
|
|
258
|
-
"stroke-width": "1",
|
|
259
|
-
"fill": "none",
|
|
260
|
-
"fill-rule": "evenodd"
|
|
261
|
-
}, [createVNode("polygon", {
|
|
262
|
-
"fill-rule": "nonzero",
|
|
263
|
-
"points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
|
|
264
|
-
"class": polygonCls
|
|
265
|
-
}, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
|
|
266
390
|
}
|
|
267
391
|
});
|
|
268
392
|
var checkboxGroup = "";
|
|
@@ -271,92 +395,97 @@ var CheckboxGroup = defineComponent({
|
|
|
271
395
|
props: checkboxGroupProps,
|
|
272
396
|
emits: ["change", "update:modelValue"],
|
|
273
397
|
setup(props, ctx) {
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
checked: false,
|
|
277
|
-
isShowTitle: true,
|
|
278
|
-
halfchecked: false,
|
|
279
|
-
showAnimation: true,
|
|
280
|
-
disabled: false
|
|
281
|
-
};
|
|
282
|
-
const toggleGroupVal = (val) => {
|
|
283
|
-
let index2 = -1;
|
|
284
|
-
if (typeof valList.value[0] === "string") {
|
|
285
|
-
index2 = valList.value.findIndex((item) => item === val);
|
|
286
|
-
} else if (typeof valList.value[0] === "object") {
|
|
287
|
-
index2 = valList.value.findIndex((item) => item.value === val);
|
|
288
|
-
}
|
|
289
|
-
if (index2 === -1) {
|
|
290
|
-
if (typeof props.options[0] === "object") {
|
|
291
|
-
const newOne = props.options.find((item) => item.value === val);
|
|
292
|
-
const res2 = [...valList.value, newOne];
|
|
293
|
-
ctx.emit("update:modelValue", res2);
|
|
294
|
-
ctx.emit("change", res2);
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
const res = [...valList.value, val];
|
|
298
|
-
ctx.emit("update:modelValue", res);
|
|
299
|
-
ctx.emit("change", res);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
valList.value.splice(index2, 1);
|
|
303
|
-
ctx.emit("update:modelValue", valList.value);
|
|
304
|
-
ctx.emit("change", valList.value);
|
|
305
|
-
};
|
|
306
|
-
const isItemChecked = (itemVal) => {
|
|
307
|
-
if (typeof valList.value[0] === "string") {
|
|
308
|
-
return valList.value.includes(itemVal);
|
|
309
|
-
} else if (typeof valList.value[0] === "object") {
|
|
310
|
-
return valList.value.some((item) => item.value === itemVal);
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
provide(checkboxGroupInjectionKey, {
|
|
314
|
-
disabled: toRef(props, "disabled"),
|
|
315
|
-
isShowTitle: toRef(props, "isShowTitle"),
|
|
316
|
-
color: toRef(props, "color"),
|
|
317
|
-
showAnimation: toRef(props, "showAnimation"),
|
|
318
|
-
beforeChange: props.beforeChange,
|
|
319
|
-
isItemChecked,
|
|
320
|
-
toggleGroupVal,
|
|
321
|
-
itemWidth: toRef(props, "itemWidth"),
|
|
322
|
-
direction: toRef(props, "direction")
|
|
323
|
-
});
|
|
324
|
-
return {
|
|
398
|
+
const ns = useNamespace("checkbox");
|
|
399
|
+
const {
|
|
325
400
|
defaultOpt
|
|
401
|
+
} = useCheckboxGroup(props, ctx);
|
|
402
|
+
return () => {
|
|
403
|
+
var _a, _b;
|
|
404
|
+
let children = (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a);
|
|
405
|
+
const getContent = () => {
|
|
406
|
+
var _a2;
|
|
407
|
+
if (children) {
|
|
408
|
+
return children;
|
|
409
|
+
} else {
|
|
410
|
+
if (((_a2 = props.options) == null ? void 0 : _a2.length) > 0) {
|
|
411
|
+
children = props.options.map((opt) => {
|
|
412
|
+
let mergedOpt = null;
|
|
413
|
+
if (typeof opt === "string") {
|
|
414
|
+
mergedOpt = Object.assign({}, defaultOpt, {
|
|
415
|
+
label: opt,
|
|
416
|
+
value: opt
|
|
417
|
+
});
|
|
418
|
+
} else if (typeof opt === "object") {
|
|
419
|
+
mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
|
|
420
|
+
label: opt.name
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
return createVNode(Checkbox, mergedOpt, null);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
return children;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
return createVNode("div", {
|
|
430
|
+
"class": ns.e("group")
|
|
431
|
+
}, [createVNode("div", {
|
|
432
|
+
"class": {
|
|
433
|
+
[ns.m("list-inline")]: props.direction === "row"
|
|
434
|
+
}
|
|
435
|
+
}, [getContent()])]);
|
|
326
436
|
};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
var checkboxButton = "";
|
|
440
|
+
var CheckboxButton = defineComponent({
|
|
441
|
+
name: "DCheckboxButton",
|
|
442
|
+
props: checkboxProps,
|
|
443
|
+
emits: ["change", "update:checked", "update:modelValue"],
|
|
444
|
+
setup(props, ctx) {
|
|
445
|
+
const ns = useNamespace("checkbox-button");
|
|
330
446
|
const {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
"
|
|
357
|
-
"
|
|
358
|
-
|
|
359
|
-
|
|
447
|
+
mergedChecked,
|
|
448
|
+
mergedDisabled,
|
|
449
|
+
mergedIsShowTitle,
|
|
450
|
+
mergedColor,
|
|
451
|
+
handleClick,
|
|
452
|
+
size
|
|
453
|
+
} = useCheckbox(props, ctx);
|
|
454
|
+
const {
|
|
455
|
+
mergedTextColor
|
|
456
|
+
} = useCheckboxButton();
|
|
457
|
+
return () => {
|
|
458
|
+
var _a, _b;
|
|
459
|
+
const labelTitle = mergedIsShowTitle.value ? props.title || props.label : "";
|
|
460
|
+
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 : ""}`];
|
|
461
|
+
const labelCls = {
|
|
462
|
+
[ns.b()]: true,
|
|
463
|
+
active: mergedChecked.value,
|
|
464
|
+
disabled: mergedDisabled.value,
|
|
465
|
+
unchecked: !mergedChecked.value
|
|
466
|
+
};
|
|
467
|
+
const spanCls = {
|
|
468
|
+
[ns.e("content")]: true,
|
|
469
|
+
[ns.m(size.value)]: true
|
|
470
|
+
};
|
|
471
|
+
const stopPropagation = ($event) => $event.stopPropagation();
|
|
472
|
+
return createVNode("label", {
|
|
473
|
+
"title": labelTitle,
|
|
474
|
+
"onClick": handleClick,
|
|
475
|
+
"class": labelCls
|
|
476
|
+
}, [createVNode("input", {
|
|
477
|
+
"name": props.name || props.value,
|
|
478
|
+
"class": ns.e("input"),
|
|
479
|
+
"type": "checkbox",
|
|
480
|
+
"checked": mergedChecked.value,
|
|
481
|
+
"disabled": mergedDisabled.value,
|
|
482
|
+
"onClick": stopPropagation,
|
|
483
|
+
"onChange": stopPropagation
|
|
484
|
+
}, null), createVNode("span", {
|
|
485
|
+
"style": spanStyle,
|
|
486
|
+
"class": spanCls
|
|
487
|
+
}, [props.label || ((_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a))])]);
|
|
488
|
+
};
|
|
360
489
|
}
|
|
361
490
|
});
|
|
362
491
|
var index = {
|
|
@@ -366,6 +495,7 @@ var index = {
|
|
|
366
495
|
install(app) {
|
|
367
496
|
app.component(Checkbox.name, Checkbox);
|
|
368
497
|
app.component(CheckboxGroup.name, CheckboxGroup);
|
|
498
|
+
app.component(CheckboxButton.name, CheckboxButton);
|
|
369
499
|
}
|
|
370
500
|
};
|
|
371
|
-
export { Checkbox, checkboxGroupInjectionKey, checkboxGroupProps, checkboxProps, index as default };
|
|
501
|
+
export { Checkbox, CheckboxButton, CheckboxGroup, checkboxGroupInjectionKey, checkboxGroupProps, checkboxProps, index as default };
|