@volverjs/ui-vue 0.0.4 → 0.0.5-beta.1
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 +2 -2
- package/auto-imports.d.ts +12 -3
- package/bin/icons.cjs +1 -73
- package/dist/Volver.d.ts +19 -11
- package/dist/components/VvAccordion/VvAccordion.es.js +165 -106
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +4 -1
- package/dist/components/VvAccordion/index.d.ts +8 -3
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +264 -164
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +15 -12
- package/dist/components/VvAccordionGroup/index.d.ts +8 -0
- package/dist/components/VvAction/VvAction.es.js +266 -98
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +12 -12
- package/dist/components/VvAction/index.d.ts +2 -2
- package/dist/components/VvBadge/VvBadge.es.js +203 -44
- package/dist/components/VvBadge/VvBadge.umd.js +1 -1
- package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
- package/dist/components/VvBadge/index.d.ts +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +237 -75
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +11 -11
- package/dist/components/VvBreadcrumb/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +636 -360
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +18 -18
- package/dist/components/VvButton/index.d.ts +13 -13
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +251 -79
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
- package/dist/components/VvButtonGroup/index.d.ts +1 -1
- package/dist/components/VvCard/VvCard.es.js +57 -38
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +552 -274
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +2 -2
- package/dist/components/VvCheckbox/index.d.ts +5 -5
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +651 -340
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +7 -7
- package/dist/components/VvCheckboxGroup/index.d.ts +3 -3
- package/dist/components/VvCombobox/VvCombobox.es.js +1532 -983
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +125 -51
- package/dist/components/VvCombobox/index.d.ts +36 -10
- package/dist/components/VvDialog/VvDialog.es.js +377 -141
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDialog/VvDialog.vue.d.ts +12 -3
- package/dist/components/VvDialog/index.d.ts +4 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +440 -244
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +113 -41
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +13 -13
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -2
- package/dist/components/VvDropdown/index.d.ts +35 -11
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +363 -160
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +43 -28
- package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +275 -90
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +113 -65
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +7 -7
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputPasswordAction.d.ts +2 -2
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +974 -460
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +96 -16
- package/dist/components/VvInputText/VvInputTextActions.d.ts +1 -1
- package/dist/components/VvInputText/index.d.ts +64 -11
- package/dist/components/VvProgress/VvProgress.es.js +206 -45
- package/dist/components/VvProgress/VvProgress.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
- package/dist/components/VvProgress/index.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +489 -238
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +2 -2
- package/dist/components/VvRadio/index.d.ts +5 -5
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +588 -304
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +7 -7
- package/dist/components/VvRadioGroup/index.d.ts +3 -3
- package/dist/components/VvSelect/VvSelect.es.js +621 -324
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +13 -13
- package/dist/components/VvSelect/index.d.ts +3 -3
- package/dist/components/VvTextarea/VvTextarea.es.js +664 -353
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +10 -10
- package/dist/components/VvTextarea/index.d.ts +2 -2
- package/dist/components/VvTooltip/VvTooltip.es.js +205 -47
- package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +7 -7
- package/dist/components/VvTooltip/index.d.ts +2 -2
- package/dist/components/index.es.js +3508 -2231
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/dropdown/useInjectDropdown.d.ts +1 -1
- package/dist/composables/dropdown/useProvideDropdown.d.ts +3 -3
- package/dist/composables/group/useInjectedGroupState.d.ts +2 -2
- package/dist/composables/group/useProvideGroupState.d.ts +1 -1
- package/dist/composables/useComponentFocus.d.ts +1 -1
- package/dist/composables/useComponentIcon.d.ts +7 -7
- package/dist/composables/useDebouncedInput.d.ts +4 -1
- package/dist/composables/useDefaults.d.ts +2 -0
- package/dist/composables/useModifiers.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/composables/useTextCount.d.ts +3 -3
- package/dist/composables/useUniqueId.d.ts +1 -1
- package/dist/composables/useVolver.d.ts +1 -1
- package/dist/directives/index.es.js +215 -55
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +212 -53
- package/dist/directives/v-tooltip.umd.js +1 -1
- package/dist/icons.es.js +38 -23
- package/dist/icons.umd.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +112 -3607
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +40 -16
- package/dist/resolvers/unplugin.d.ts +7 -1
- package/dist/resolvers/unplugin.es.js +77 -37
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/InputText/InputText.settings.d.ts +53 -0
- package/dist/stories/argTypes.d.ts +1 -1
- package/package.json +114 -36
- package/src/Volver.ts +49 -22
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAccordion/VvAccordion.vue +19 -22
- package/src/components/VvAccordion/index.ts +12 -4
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +19 -10
- package/src/components/VvAccordionGroup/index.ts +8 -0
- package/src/components/VvAction/VvAction.vue +7 -7
- package/src/components/VvAction/index.ts +1 -1
- package/src/components/VvBadge/VvBadge.vue +2 -2
- package/src/components/VvBadge/index.ts +1 -1
- package/src/components/VvBreadcrumb/VvBreadcrumb.vue +3 -3
- package/src/components/VvButton/VvButton.vue +11 -11
- package/src/components/VvButton/index.ts +10 -9
- package/src/components/VvButtonGroup/VvButtonGroup.vue +4 -7
- package/src/components/VvButtonGroup/index.ts +1 -1
- package/src/components/VvCard/VvCard.vue +2 -2
- package/src/components/VvCheckbox/VvCheckbox.vue +3 -7
- package/src/components/VvCheckbox/index.ts +11 -7
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +7 -10
- package/src/components/VvCheckboxGroup/index.ts +1 -1
- package/src/components/VvCombobox/VvCombobox.vue +39 -23
- package/src/components/VvCombobox/index.ts +1 -1
- package/src/components/VvDialog/VvDialog.vue +28 -11
- package/src/components/VvDialog/index.ts +5 -2
- package/src/components/VvDropdown/VvDropdown.vue +6 -5
- package/src/components/VvDropdown/VvDropdownAction.vue +7 -5
- package/src/components/VvDropdown/VvDropdownOption.vue +17 -10
- package/src/components/VvDropdown/index.ts +3 -3
- package/src/components/VvIcon/VvIcon.vue +3 -3
- package/src/components/VvIcon/index.ts +3 -3
- package/src/components/VvInputText/VvInputClearAction.ts +2 -2
- package/src/components/VvInputText/VvInputPasswordAction.ts +3 -4
- package/src/components/VvInputText/VvInputStepAction.ts +3 -2
- package/src/components/VvInputText/VvInputText.vue +128 -35
- package/src/components/VvInputText/VvInputTextActions.ts +5 -8
- package/src/components/VvInputText/index.ts +62 -1
- package/src/components/VvProgress/VvProgress.vue +2 -2
- package/src/components/VvProgress/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +3 -7
- package/src/components/VvRadio/index.ts +11 -7
- package/src/components/VvRadioGroup/VvRadioGroup.vue +7 -10
- package/src/components/VvRadioGroup/index.ts +1 -1
- package/src/components/VvSelect/VvSelect.vue +4 -4
- package/src/components/VvSelect/index.ts +1 -1
- package/src/components/VvTextarea/VvTextarea.vue +4 -4
- package/src/components/VvTextarea/index.ts +1 -1
- package/src/components/VvTooltip/VvTooltip.vue +2 -2
- package/src/components/VvTooltip/index.ts +3 -3
- package/src/composables/dropdown/useInjectDropdown.ts +2 -2
- package/src/composables/dropdown/useProvideDropdown.ts +2 -2
- package/src/composables/group/useInjectedGroupState.ts +1 -1
- package/src/composables/group/useProvideGroupState.ts +1 -1
- package/src/composables/useComponentIcon.ts +1 -1
- package/src/composables/useDebouncedInput.ts +10 -3
- package/src/composables/useDefaults.ts +89 -0
- package/src/composables/useModifiers.ts +4 -2
- package/src/composables/useOptions.ts +1 -1
- package/src/composables/useVolver.ts +2 -2
- package/src/directives/index.ts +1 -1
- package/src/directives/v-tooltip.ts +2 -2
- package/src/index.ts +0 -2
- package/src/props/index.ts +8 -8
- package/src/resolvers/unplugin.ts +15 -1
- package/src/stories/Accordion/Accordion.stories.mdx +8 -2
- package/src/stories/Accordion/Accordion.test.ts +21 -15
- package/src/stories/Accordion/AccordionSlots.stories.mdx +8 -8
- package/src/stories/AccordionGroup/AccordionGroup.stories.mdx +17 -1
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +18 -12
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.mdx +1 -1
- package/src/stories/InputText/InputText.settings.ts +53 -0
- package/src/stories/InputText/InputText.stories.mdx +40 -0
- package/src/stories/InputText/InputText.test.ts +5 -2
- package/src/stories/argTypes.ts +2 -2
- package/src/types/group.d.ts +5 -0
|
@@ -1,112 +1,184 @@
|
|
|
1
|
-
import { unref
|
|
2
|
-
import { toReactive
|
|
3
|
-
import { nanoid
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { unref, toRefs, computed, h, inject, toRef, defineComponent, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, isRef, vModelCheckbox, renderSlot, createTextVNode, toDisplayString, createVNode, provide, createCommentVNode, Fragment, renderList, createBlock, mergeProps } from "vue";
|
|
2
|
+
import { toReactive, useVModel } from "@vueuse/core";
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
4
|
+
var Side = /* @__PURE__ */ ((Side2) => {
|
|
5
|
+
Side2["left"] = "left";
|
|
6
|
+
Side2["right"] = "right";
|
|
7
|
+
Side2["top"] = "top";
|
|
8
|
+
Side2["bottom"] = "bottom";
|
|
9
|
+
return Side2;
|
|
10
|
+
})(Side || {});
|
|
11
|
+
var Placement = /* @__PURE__ */ ((Placement2) => {
|
|
12
|
+
Placement2["topStart"] = "top-start";
|
|
13
|
+
Placement2["topEnd"] = "top-end";
|
|
14
|
+
Placement2["bottomStart"] = "bottom-start";
|
|
15
|
+
Placement2["bottomEnd"] = "bottom-end";
|
|
16
|
+
Placement2["leftStart"] = "left-start";
|
|
17
|
+
Placement2["leftEnd"] = "left-end";
|
|
18
|
+
Placement2["rightStart"] = "right-start";
|
|
19
|
+
Placement2["rightEnd"] = "right-end";
|
|
20
|
+
return Placement2;
|
|
21
|
+
})(Placement || {});
|
|
22
|
+
var Position = /* @__PURE__ */ ((Position2) => {
|
|
23
|
+
Position2["before"] = "before";
|
|
24
|
+
Position2["after"] = "after";
|
|
25
|
+
return Position2;
|
|
26
|
+
})(Position || {});
|
|
27
|
+
var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
|
|
28
|
+
ButtonType2["button"] = "button";
|
|
29
|
+
ButtonType2["submit"] = "submit";
|
|
30
|
+
ButtonType2["reset"] = "reset";
|
|
31
|
+
return ButtonType2;
|
|
32
|
+
})(ButtonType || {});
|
|
33
|
+
var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
34
|
+
AnchorTarget2["_blank"] = "_blank";
|
|
35
|
+
AnchorTarget2["_self"] = "_self";
|
|
36
|
+
AnchorTarget2["_parent"] = "_parent";
|
|
37
|
+
AnchorTarget2["_top"] = "_top";
|
|
38
|
+
return AnchorTarget2;
|
|
39
|
+
})(AnchorTarget || {});
|
|
40
|
+
const INJECTION_KEY_CHECK_GROUP = Symbol.for("checkGroup");
|
|
41
|
+
function equals(obj1, obj2, field) {
|
|
42
|
+
if (field)
|
|
43
|
+
return resolveFieldData(obj1, field) === resolveFieldData(obj2, field);
|
|
44
|
+
else
|
|
45
|
+
return deepEquals(obj1, obj2);
|
|
8
46
|
}
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
47
|
+
function deepEquals(a, b) {
|
|
48
|
+
if (a === b)
|
|
49
|
+
return true;
|
|
50
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
51
|
+
const arrA = Array.isArray(a);
|
|
52
|
+
const arrB = Array.isArray(b);
|
|
53
|
+
let i, length, key;
|
|
54
|
+
if (arrA && arrB) {
|
|
55
|
+
length = a.length;
|
|
56
|
+
if (length != b.length)
|
|
57
|
+
return false;
|
|
58
|
+
for (i = length; i-- !== 0; )
|
|
59
|
+
if (!deepEquals(a[i], b[i]))
|
|
60
|
+
return false;
|
|
61
|
+
return true;
|
|
22
62
|
}
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
if (arrA != arrB)
|
|
64
|
+
return false;
|
|
65
|
+
const dateA = a instanceof Date, dateB = b instanceof Date;
|
|
66
|
+
if (dateA != dateB)
|
|
67
|
+
return false;
|
|
68
|
+
if (dateA && dateB)
|
|
69
|
+
return a.getTime() == b.getTime();
|
|
70
|
+
const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
|
|
71
|
+
if (regexpA != regexpB)
|
|
72
|
+
return false;
|
|
73
|
+
if (regexpA && regexpB)
|
|
74
|
+
return a.toString() == b.toString();
|
|
75
|
+
const keys = Object.keys(a);
|
|
76
|
+
length = keys.length;
|
|
77
|
+
if (length !== Object.keys(b).length)
|
|
78
|
+
return false;
|
|
79
|
+
for (i = length; i-- !== 0; )
|
|
80
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
81
|
+
return false;
|
|
82
|
+
for (i = length; i-- !== 0; ) {
|
|
83
|
+
key = keys[i];
|
|
84
|
+
if (!deepEquals(a[key], b[key]))
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
45
88
|
}
|
|
46
|
-
return
|
|
89
|
+
return a !== a && b !== b;
|
|
47
90
|
}
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
50
|
-
if (
|
|
51
|
-
return
|
|
52
|
-
{
|
|
53
|
-
const
|
|
54
|
-
let
|
|
55
|
-
for (let
|
|
56
|
-
if (
|
|
91
|
+
function resolveFieldData(data, field) {
|
|
92
|
+
if (data && Object.keys(data).length && field) {
|
|
93
|
+
if (field.indexOf(".") === -1) {
|
|
94
|
+
return data[field];
|
|
95
|
+
} else {
|
|
96
|
+
const fields = field.split(".");
|
|
97
|
+
let value = data;
|
|
98
|
+
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
99
|
+
if (data == null) {
|
|
57
100
|
return null;
|
|
58
|
-
|
|
101
|
+
}
|
|
102
|
+
value = value[fields[i]];
|
|
59
103
|
}
|
|
60
|
-
return
|
|
104
|
+
return value;
|
|
61
105
|
}
|
|
62
|
-
} else
|
|
106
|
+
} else {
|
|
63
107
|
return null;
|
|
108
|
+
}
|
|
64
109
|
}
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
for (const
|
|
68
|
-
if (
|
|
69
|
-
return
|
|
110
|
+
function contains(value, list) {
|
|
111
|
+
if (value != null && list && list.length) {
|
|
112
|
+
for (const val of list) {
|
|
113
|
+
if (equals(value, val)) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
70
117
|
}
|
|
71
|
-
return
|
|
118
|
+
return false;
|
|
72
119
|
}
|
|
73
|
-
function
|
|
74
|
-
return ((
|
|
120
|
+
function isEmpty(value) {
|
|
121
|
+
return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
|
|
75
122
|
}
|
|
76
|
-
function
|
|
77
|
-
return typeof
|
|
123
|
+
function isString(value) {
|
|
124
|
+
return typeof value === "string" || value instanceof String;
|
|
78
125
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
126
|
+
function joinLines(errors) {
|
|
127
|
+
if (Array.isArray(errors)) {
|
|
128
|
+
return errors.filter((e) => isString(e)).join(" ");
|
|
129
|
+
}
|
|
130
|
+
return errors;
|
|
81
131
|
}
|
|
82
|
-
function
|
|
132
|
+
function HintSlotFactory(parentProps, parentSlots) {
|
|
133
|
+
const {
|
|
134
|
+
invalid: invalidSlot,
|
|
135
|
+
valid: validSlot,
|
|
136
|
+
hint: hintSlot,
|
|
137
|
+
loading: loadingSlot
|
|
138
|
+
} = parentSlots;
|
|
83
139
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
140
|
+
hintLabel,
|
|
141
|
+
modelValue,
|
|
142
|
+
valid,
|
|
143
|
+
validLabel,
|
|
144
|
+
invalid,
|
|
145
|
+
invalidLabel,
|
|
146
|
+
...otherProps
|
|
147
|
+
} = toRefs(parentProps);
|
|
148
|
+
const loading = resolveFieldData(otherProps, "loading");
|
|
149
|
+
const loadingLabel = resolveFieldData(otherProps, "loadingLabel");
|
|
150
|
+
const hasInvalid = computed(() => {
|
|
151
|
+
if (!invalid.value) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (invalid.value && invalidSlot) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
if ((invalidLabel == null ? void 0 : invalidLabel.value) && Array.isArray(invalidLabel.value) && invalidLabel.value.length > 0) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if ((invalidLabel == null ? void 0 : invalidLabel.value) && !isEmpty(invalidLabel)) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
});
|
|
165
|
+
const hasHint = computed(
|
|
166
|
+
() => !!(hintLabel && hintLabel.value || hintSlot)
|
|
167
|
+
);
|
|
168
|
+
const hasValid = computed(
|
|
169
|
+
() => !!(validLabel && validLabel.value || validSlot)
|
|
170
|
+
);
|
|
171
|
+
const hasLoading = computed(
|
|
172
|
+
() => !!((loading == null ? void 0 : loading.value) && loadingSlot || (loading == null ? void 0 : loading.value) && (loadingLabel == null ? void 0 : loadingLabel.value))
|
|
173
|
+
);
|
|
174
|
+
const isVisible = computed(
|
|
175
|
+
() => hasHint.value || hasValid.value || hasInvalid.value || hasLoading.value
|
|
104
176
|
);
|
|
105
177
|
return {
|
|
106
|
-
hasInvalid
|
|
107
|
-
hasHint
|
|
108
|
-
hasValid
|
|
109
|
-
hasLoading
|
|
178
|
+
hasInvalid,
|
|
179
|
+
hasHint,
|
|
180
|
+
hasValid,
|
|
181
|
+
hasLoading,
|
|
110
182
|
HintSlot: {
|
|
111
183
|
name: "HintSlot",
|
|
112
184
|
props: {
|
|
@@ -115,42 +187,50 @@ function Z(e, t) {
|
|
|
115
187
|
default: () => ({})
|
|
116
188
|
}
|
|
117
189
|
},
|
|
118
|
-
setup(
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
hintLabel
|
|
122
|
-
modelValue
|
|
123
|
-
valid
|
|
124
|
-
validLabel
|
|
125
|
-
invalid
|
|
126
|
-
invalidLabel
|
|
127
|
-
loading
|
|
128
|
-
loadingLabel
|
|
129
|
-
...
|
|
190
|
+
setup(props) {
|
|
191
|
+
const hintContent = computed(() => {
|
|
192
|
+
const slotProps = toReactive({
|
|
193
|
+
hintLabel,
|
|
194
|
+
modelValue,
|
|
195
|
+
valid,
|
|
196
|
+
validLabel,
|
|
197
|
+
invalid,
|
|
198
|
+
invalidLabel,
|
|
199
|
+
loading,
|
|
200
|
+
loadingLabel,
|
|
201
|
+
...props.params
|
|
130
202
|
});
|
|
131
|
-
|
|
203
|
+
if (invalid == null ? void 0 : invalid.value) {
|
|
204
|
+
return (invalidSlot == null ? void 0 : invalidSlot(slotProps)) || joinLines(invalidLabel == null ? void 0 : invalidLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
205
|
+
}
|
|
206
|
+
if (valid == null ? void 0 : valid.value)
|
|
207
|
+
return (validSlot == null ? void 0 : validSlot(slotProps)) || joinLines(validLabel == null ? void 0 : validLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
208
|
+
if (loading == null ? void 0 : loading.value)
|
|
209
|
+
return (loadingSlot == null ? void 0 : loadingSlot(slotProps)) || joinLines(loadingLabel == null ? void 0 : loadingLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
210
|
+
return (hintSlot == null ? void 0 : hintSlot(slotProps)) || joinLines(hintLabel == null ? void 0 : hintLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
132
211
|
});
|
|
133
212
|
return {
|
|
134
|
-
isVisible
|
|
135
|
-
hasInvalid
|
|
136
|
-
hasValid
|
|
137
|
-
hintContent
|
|
213
|
+
isVisible,
|
|
214
|
+
hasInvalid,
|
|
215
|
+
hasValid,
|
|
216
|
+
hintContent
|
|
138
217
|
};
|
|
139
218
|
},
|
|
140
219
|
render() {
|
|
141
|
-
if (this.isVisible)
|
|
142
|
-
return
|
|
220
|
+
if (this.isVisible) {
|
|
221
|
+
return h(
|
|
143
222
|
"small",
|
|
144
223
|
{
|
|
145
224
|
role: this.hasInvalid ? "alert" : this.hasValid ? "status" : void 0
|
|
146
225
|
},
|
|
147
226
|
this.hintContent
|
|
148
227
|
);
|
|
228
|
+
}
|
|
149
229
|
}
|
|
150
230
|
}
|
|
151
231
|
};
|
|
152
232
|
}
|
|
153
|
-
const
|
|
233
|
+
const LinkProps = {
|
|
154
234
|
/**
|
|
155
235
|
* The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
|
|
156
236
|
* @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
|
|
@@ -167,7 +247,7 @@ const xe = {
|
|
|
167
247
|
*/
|
|
168
248
|
target: {
|
|
169
249
|
type: String,
|
|
170
|
-
validator: (
|
|
250
|
+
validator: (value) => Object.values(AnchorTarget).includes(value)
|
|
171
251
|
},
|
|
172
252
|
/**
|
|
173
253
|
* Anchor rel
|
|
@@ -176,7 +256,8 @@ const xe = {
|
|
|
176
256
|
type: String,
|
|
177
257
|
default: "noopener noreferrer"
|
|
178
258
|
}
|
|
179
|
-
}
|
|
259
|
+
};
|
|
260
|
+
const ValidProps = {
|
|
180
261
|
/**
|
|
181
262
|
* Valid status
|
|
182
263
|
*/
|
|
@@ -185,7 +266,8 @@ const xe = {
|
|
|
185
266
|
* Valid label
|
|
186
267
|
*/
|
|
187
268
|
validLabel: [String, Array]
|
|
188
|
-
}
|
|
269
|
+
};
|
|
270
|
+
const InvalidProps = {
|
|
189
271
|
/**
|
|
190
272
|
* Invalid status
|
|
191
273
|
*/
|
|
@@ -194,39 +276,47 @@ const xe = {
|
|
|
194
276
|
* Invalid label
|
|
195
277
|
*/
|
|
196
278
|
invalidLabel: [String, Array]
|
|
197
|
-
}
|
|
279
|
+
};
|
|
280
|
+
const DisabledProps = {
|
|
198
281
|
/**
|
|
199
282
|
* Whether the form control is disabled
|
|
200
283
|
*/
|
|
201
284
|
disabled: Boolean
|
|
202
|
-
}
|
|
285
|
+
};
|
|
286
|
+
const ActiveProps = {
|
|
203
287
|
/**
|
|
204
288
|
* Whether the item is active
|
|
205
289
|
*/
|
|
206
290
|
active: Boolean
|
|
207
|
-
}
|
|
291
|
+
};
|
|
292
|
+
const PressedProps = {
|
|
208
293
|
/**
|
|
209
294
|
* Whether the item is pressed
|
|
210
295
|
*/
|
|
211
296
|
pressed: Boolean
|
|
212
|
-
}
|
|
297
|
+
};
|
|
298
|
+
const LabelProps = {
|
|
213
299
|
/**
|
|
214
300
|
* The item label
|
|
215
301
|
*/
|
|
216
302
|
label: [String, Number]
|
|
217
|
-
}
|
|
303
|
+
};
|
|
304
|
+
const ReadonlyProps = {
|
|
218
305
|
/**
|
|
219
306
|
* The value is not editable
|
|
220
307
|
*/
|
|
221
308
|
readonly: Boolean
|
|
222
|
-
}
|
|
309
|
+
};
|
|
310
|
+
const ModifiersProps = {
|
|
223
311
|
/**
|
|
224
312
|
* Component BEM modifiers
|
|
225
313
|
*/
|
|
226
314
|
modifiers: [String, Array]
|
|
227
|
-
}
|
|
315
|
+
};
|
|
316
|
+
const HintProps = {
|
|
228
317
|
hintLabel: { type: String, default: "" }
|
|
229
|
-
}
|
|
318
|
+
};
|
|
319
|
+
const OptionsProps = {
|
|
230
320
|
/**
|
|
231
321
|
* List of options, can be string[] or object[]
|
|
232
322
|
*/
|
|
@@ -247,39 +337,140 @@ const xe = {
|
|
|
247
337
|
*/
|
|
248
338
|
disabledKey: { type: [String, Function], default: "disabled" }
|
|
249
339
|
};
|
|
250
|
-
|
|
251
|
-
|
|
340
|
+
({
|
|
341
|
+
/**
|
|
342
|
+
* VvIcon name or props
|
|
343
|
+
* @see VVIcon
|
|
344
|
+
*/
|
|
345
|
+
icon: { type: [String, Object] },
|
|
346
|
+
/**
|
|
347
|
+
* VvIcon position
|
|
348
|
+
*/
|
|
349
|
+
iconPosition: {
|
|
350
|
+
type: String,
|
|
351
|
+
default: Position.before,
|
|
352
|
+
validation: (value) => Object.values(Position).includes(value)
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
const TabindexProps = {
|
|
252
356
|
/**
|
|
253
357
|
* Global attribute tabindex
|
|
254
358
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
|
|
255
359
|
*/
|
|
256
360
|
tabindex: { type: [String, Number], default: 0 }
|
|
257
|
-
}
|
|
361
|
+
};
|
|
362
|
+
const IdProps = {
|
|
258
363
|
/**
|
|
259
364
|
* Global attribute id
|
|
260
365
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
|
|
261
366
|
*/
|
|
262
367
|
id: [String, Number]
|
|
263
368
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
369
|
+
({
|
|
370
|
+
/**
|
|
371
|
+
* Dropdown placement
|
|
372
|
+
*/
|
|
373
|
+
placement: {
|
|
374
|
+
type: String,
|
|
375
|
+
default: Side.bottom,
|
|
376
|
+
validator: (value) => {
|
|
377
|
+
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
/**
|
|
381
|
+
* Dropdown show / hide transition name
|
|
382
|
+
*/
|
|
383
|
+
transitionName: {
|
|
384
|
+
type: String
|
|
385
|
+
},
|
|
386
|
+
/**
|
|
387
|
+
* Offset of the dropdown from the trigger
|
|
388
|
+
* @see https://floating-ui.com/docs/offset
|
|
389
|
+
*/
|
|
390
|
+
offset: {
|
|
391
|
+
type: [Number, String, Object],
|
|
392
|
+
default: 0
|
|
393
|
+
},
|
|
394
|
+
/**
|
|
395
|
+
* Move dropdown to the side if there is no space in the default position
|
|
396
|
+
* @see https://floating-ui.com/docs/shift
|
|
397
|
+
*/
|
|
398
|
+
shift: {
|
|
399
|
+
type: [Boolean, Object],
|
|
400
|
+
default: false
|
|
401
|
+
},
|
|
402
|
+
/**
|
|
403
|
+
* Flip dropdown position if there is no space in the default position
|
|
404
|
+
* @see https://floating-ui.com/docs/flip
|
|
405
|
+
*/
|
|
406
|
+
flip: {
|
|
407
|
+
type: [Boolean, Object],
|
|
408
|
+
default: true
|
|
409
|
+
},
|
|
410
|
+
/**
|
|
411
|
+
* Size of the dropdown
|
|
412
|
+
* @see https://floating-ui.com/docs/size
|
|
413
|
+
*/
|
|
414
|
+
size: {
|
|
415
|
+
type: [Boolean, Object],
|
|
416
|
+
default: () => ({ padding: 10 })
|
|
417
|
+
},
|
|
418
|
+
/**
|
|
419
|
+
* Automatically change the position of the dropdown
|
|
420
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
421
|
+
*/
|
|
422
|
+
autoPlacement: {
|
|
423
|
+
type: [Boolean, Object],
|
|
424
|
+
default: false
|
|
425
|
+
},
|
|
426
|
+
/**
|
|
427
|
+
* Add arrow to the dropdown
|
|
428
|
+
* @see https://floating-ui.com/docs/arrow
|
|
429
|
+
*/
|
|
430
|
+
arrow: {
|
|
431
|
+
type: Boolean,
|
|
432
|
+
default: false
|
|
433
|
+
},
|
|
434
|
+
/**
|
|
435
|
+
* Close dropdown on click outside
|
|
436
|
+
*/
|
|
437
|
+
autoClose: {
|
|
438
|
+
type: Boolean,
|
|
439
|
+
default: true
|
|
440
|
+
},
|
|
441
|
+
/**
|
|
442
|
+
* Autofocus first item on dropdown open
|
|
443
|
+
*/
|
|
444
|
+
autofocusFirst: {
|
|
445
|
+
type: Boolean,
|
|
446
|
+
default: true
|
|
447
|
+
},
|
|
448
|
+
/**
|
|
449
|
+
* Set dropdown width to the same as the trigger
|
|
450
|
+
*/
|
|
451
|
+
triggerWidth: {
|
|
452
|
+
type: Boolean
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
const IdNameProps = {
|
|
456
|
+
...IdProps,
|
|
267
457
|
/**
|
|
268
458
|
* Input / Textarea name
|
|
269
459
|
* Name of the form control. Submitted with the form as part of a name/value pair
|
|
270
460
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
|
|
271
461
|
*/
|
|
272
|
-
name: { type: String, required:
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
...
|
|
276
|
-
...
|
|
277
|
-
...
|
|
278
|
-
...
|
|
279
|
-
|
|
280
|
-
...
|
|
281
|
-
...
|
|
282
|
-
...
|
|
462
|
+
name: { type: String, required: true }
|
|
463
|
+
};
|
|
464
|
+
const CheckboxRadioProps = {
|
|
465
|
+
...IdNameProps,
|
|
466
|
+
...TabindexProps,
|
|
467
|
+
...ValidProps,
|
|
468
|
+
...InvalidProps,
|
|
469
|
+
...HintProps,
|
|
470
|
+
...DisabledProps,
|
|
471
|
+
...ReadonlyProps,
|
|
472
|
+
...ModifiersProps,
|
|
473
|
+
...LabelProps,
|
|
283
474
|
/**
|
|
284
475
|
* Input value
|
|
285
476
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
|
|
@@ -289,72 +480,79 @@ const Ne = {
|
|
|
289
480
|
* Input value
|
|
290
481
|
*/
|
|
291
482
|
modelValue: [Object, Number, Boolean, String]
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
...
|
|
295
|
-
...
|
|
296
|
-
...
|
|
297
|
-
|
|
298
|
-
...
|
|
299
|
-
...
|
|
300
|
-
...
|
|
483
|
+
};
|
|
484
|
+
const CheckboxRadioGroupProps = {
|
|
485
|
+
...ValidProps,
|
|
486
|
+
...InvalidProps,
|
|
487
|
+
...OptionsProps,
|
|
488
|
+
...HintProps,
|
|
489
|
+
...DisabledProps,
|
|
490
|
+
...ReadonlyProps,
|
|
491
|
+
...ModifiersProps,
|
|
492
|
+
...LabelProps,
|
|
301
493
|
/**
|
|
302
494
|
* Input value
|
|
303
495
|
*/
|
|
304
|
-
modelValue: [String, Array],
|
|
496
|
+
modelValue: [String, Array, Boolean, Number, Symbol],
|
|
305
497
|
/**
|
|
306
498
|
* Input name
|
|
307
499
|
*/
|
|
308
|
-
name: { type: String, required:
|
|
500
|
+
name: { type: String, required: true },
|
|
309
501
|
/**
|
|
310
502
|
* If true, the group will be displayed in a vertical column
|
|
311
503
|
*/
|
|
312
504
|
vertical: Boolean
|
|
313
505
|
};
|
|
314
506
|
({
|
|
315
|
-
|
|
316
|
-
...
|
|
317
|
-
...
|
|
318
|
-
...
|
|
319
|
-
...
|
|
507
|
+
...DisabledProps,
|
|
508
|
+
...LabelProps,
|
|
509
|
+
...PressedProps,
|
|
510
|
+
...ActiveProps,
|
|
511
|
+
...LinkProps,
|
|
320
512
|
/**
|
|
321
513
|
* Button type
|
|
322
514
|
*/
|
|
323
|
-
type:
|
|
515
|
+
type: {
|
|
516
|
+
type: String,
|
|
517
|
+
default: ButtonType.button,
|
|
518
|
+
validator: (value) => Object.values(ButtonType).includes(value)
|
|
519
|
+
}
|
|
324
520
|
});
|
|
325
|
-
function
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
521
|
+
function useInjectedGroupState(groupKey) {
|
|
522
|
+
const group = inject(groupKey, void 0);
|
|
523
|
+
const isInGroup = computed(() => !isEmpty(group));
|
|
524
|
+
function getGroupOrLocalRef(propName, props, emit) {
|
|
525
|
+
if (group == null ? void 0 : group.value) {
|
|
526
|
+
const groupPropValue = unref(group.value)[propName];
|
|
527
|
+
return computed({
|
|
331
528
|
get() {
|
|
332
|
-
return
|
|
529
|
+
return groupPropValue == null ? void 0 : groupPropValue.value;
|
|
333
530
|
},
|
|
334
|
-
set(
|
|
335
|
-
|
|
531
|
+
set(value) {
|
|
532
|
+
groupPropValue.value = value;
|
|
336
533
|
}
|
|
337
534
|
});
|
|
338
535
|
}
|
|
339
|
-
const
|
|
340
|
-
return
|
|
536
|
+
const propRef = toRef(props, propName);
|
|
537
|
+
return computed({
|
|
341
538
|
get() {
|
|
342
|
-
return
|
|
539
|
+
return propRef.value;
|
|
343
540
|
},
|
|
344
|
-
set(
|
|
345
|
-
|
|
541
|
+
set(value) {
|
|
542
|
+
if (emit)
|
|
543
|
+
emit(`update:${propName}`, value);
|
|
346
544
|
}
|
|
347
545
|
});
|
|
348
546
|
}
|
|
349
547
|
return {
|
|
350
|
-
group
|
|
351
|
-
isInGroup
|
|
352
|
-
getGroupOrLocalRef
|
|
548
|
+
group,
|
|
549
|
+
isInGroup,
|
|
550
|
+
getGroupOrLocalRef
|
|
353
551
|
};
|
|
354
552
|
}
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
...
|
|
553
|
+
const VvCheckboxProps = {
|
|
554
|
+
...CheckboxRadioProps,
|
|
555
|
+
...ModifiersProps,
|
|
358
556
|
/**
|
|
359
557
|
* If true, the input will be indeterminated
|
|
360
558
|
*/
|
|
@@ -367,199 +565,312 @@ const He = {
|
|
|
367
565
|
* If true, the input will be displayed as a switch
|
|
368
566
|
*/
|
|
369
567
|
switch: Boolean
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
568
|
+
};
|
|
569
|
+
const VvCheckboxEvents = ["click", "update:modelValue", "change", "blur"];
|
|
570
|
+
function useGroupProps(props, emit) {
|
|
571
|
+
const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(INJECTION_KEY_CHECK_GROUP);
|
|
572
|
+
const { id, switch: propsSwitch, indeterminate } = toRefs(props);
|
|
573
|
+
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
574
|
+
const valid = getGroupOrLocalRef("valid", props);
|
|
575
|
+
const invalid = getGroupOrLocalRef("invalid", props);
|
|
576
|
+
const readonly = computed(
|
|
577
|
+
() => {
|
|
578
|
+
var _a;
|
|
579
|
+
return Boolean(props.readonly || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
const disabled = computed(
|
|
583
|
+
() => {
|
|
584
|
+
var _a;
|
|
585
|
+
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
586
|
+
}
|
|
587
|
+
);
|
|
373
588
|
return {
|
|
374
589
|
// local props
|
|
375
|
-
id
|
|
376
|
-
propsSwitch
|
|
377
|
-
indeterminate
|
|
590
|
+
id,
|
|
591
|
+
propsSwitch,
|
|
592
|
+
indeterminate,
|
|
378
593
|
// global props
|
|
379
|
-
group
|
|
380
|
-
isInGroup
|
|
381
|
-
modelValue
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
594
|
+
group,
|
|
595
|
+
isInGroup,
|
|
596
|
+
modelValue,
|
|
597
|
+
valid,
|
|
598
|
+
invalid,
|
|
599
|
+
readonly,
|
|
600
|
+
disabled
|
|
386
601
|
};
|
|
387
602
|
}
|
|
388
|
-
const
|
|
389
|
-
function
|
|
390
|
-
return
|
|
391
|
-
const
|
|
392
|
-
[
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
603
|
+
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
604
|
+
function useModifiers(prefix, modifiers, others) {
|
|
605
|
+
return computed(() => {
|
|
606
|
+
const toReturn = {
|
|
607
|
+
[prefix]: true
|
|
608
|
+
};
|
|
609
|
+
const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
|
|
610
|
+
if (modifiersArray) {
|
|
611
|
+
if (Array.isArray(modifiersArray)) {
|
|
612
|
+
modifiersArray.forEach((modifier) => {
|
|
613
|
+
if (modifier) {
|
|
614
|
+
toReturn[`${prefix}--${modifier}`] = true;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (others) {
|
|
620
|
+
Object.keys(others.value).forEach((key) => {
|
|
621
|
+
toReturn[`${prefix}--${key}`] = unref(others.value[key]);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
return toReturn;
|
|
399
625
|
});
|
|
400
626
|
}
|
|
401
|
-
const
|
|
627
|
+
const _hoisted_1$1 = ["for"];
|
|
628
|
+
const _hoisted_2$1 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid"];
|
|
629
|
+
const __default__$1 = {
|
|
402
630
|
name: "VvCheckbox"
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
631
|
+
};
|
|
632
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
633
|
+
...__default__$1,
|
|
634
|
+
props: VvCheckboxProps,
|
|
635
|
+
emits: VvCheckboxEvents,
|
|
636
|
+
setup(__props, { emit }) {
|
|
637
|
+
const props = __props;
|
|
638
|
+
const slots = useSlots();
|
|
639
|
+
const {
|
|
640
|
+
id,
|
|
641
|
+
disabled,
|
|
642
|
+
readonly,
|
|
643
|
+
valid,
|
|
644
|
+
invalid,
|
|
645
|
+
propsSwitch,
|
|
646
|
+
modelValue,
|
|
647
|
+
indeterminate,
|
|
648
|
+
isInGroup
|
|
649
|
+
} = useGroupProps(props, emit);
|
|
650
|
+
const hasId = useUniqueId(id);
|
|
651
|
+
const tabindex = computed(() => isDisabled.value ? -1 : props.tabindex);
|
|
652
|
+
const input = ref();
|
|
653
|
+
const isBinary = computed(
|
|
654
|
+
() => props.uncheckedValue !== void 0 && !isInGroup.value
|
|
655
|
+
);
|
|
656
|
+
const isDisabled = computed(() => disabled.value || readonly.value);
|
|
657
|
+
const isInvalid = computed(() => {
|
|
658
|
+
if (invalid.value === true) {
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
if (valid.value === true) {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
return void 0;
|
|
665
|
+
});
|
|
666
|
+
const isChecked = computed(() => {
|
|
667
|
+
if (isBinary.value) {
|
|
668
|
+
return modelValue.value === props.value;
|
|
669
|
+
}
|
|
670
|
+
return Array.isArray(modelValue.value) ? contains(props.value, modelValue.value) : equals(props.value, modelValue.value);
|
|
671
|
+
});
|
|
672
|
+
const isIndeterminated = computed(() => {
|
|
673
|
+
if (indeterminate.value) {
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
676
|
+
if (!isChecked.value && isBinary.value && props.uncheckedValue !== modelValue.value) {
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
return false;
|
|
680
|
+
});
|
|
681
|
+
const hasValue = computed(() => {
|
|
682
|
+
if (isBinary.value) {
|
|
683
|
+
return void 0;
|
|
684
|
+
}
|
|
685
|
+
return ["string", "number", "boolean"].includes(typeof props.value) ? props.value : true;
|
|
686
|
+
});
|
|
687
|
+
const localModelValue = computed({
|
|
429
688
|
get() {
|
|
430
|
-
return
|
|
689
|
+
return isChecked.value;
|
|
431
690
|
},
|
|
432
|
-
set(
|
|
433
|
-
if (
|
|
434
|
-
|
|
435
|
-
else if (Array.isArray(
|
|
436
|
-
const
|
|
437
|
-
Array.isArray(
|
|
691
|
+
set(newValue) {
|
|
692
|
+
if (isBinary.value) {
|
|
693
|
+
modelValue.value = newValue ? props.value : props.uncheckedValue;
|
|
694
|
+
} else if (Array.isArray(modelValue.value) || isInGroup.value) {
|
|
695
|
+
const toReturn = new Set(
|
|
696
|
+
Array.isArray(modelValue.value) ? modelValue.value : modelValue.value !== void 0 ? [modelValue.value] : []
|
|
438
697
|
);
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
698
|
+
if (newValue) {
|
|
699
|
+
toReturn.add(props.value);
|
|
700
|
+
} else {
|
|
701
|
+
toReturn.delete(props.value);
|
|
702
|
+
}
|
|
703
|
+
modelValue.value = [...toReturn];
|
|
704
|
+
} else {
|
|
705
|
+
modelValue.value = newValue ? props.value : void 0;
|
|
706
|
+
}
|
|
707
|
+
emit("change", newValue);
|
|
443
708
|
}
|
|
444
|
-
})
|
|
709
|
+
});
|
|
710
|
+
const { modifiers } = toRefs(props);
|
|
711
|
+
const bemCssClasses = useModifiers(
|
|
445
712
|
"vv-checkbox",
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
switch:
|
|
449
|
-
valid:
|
|
450
|
-
invalid:
|
|
451
|
-
disabled:
|
|
452
|
-
readonly:
|
|
453
|
-
indeterminate:
|
|
713
|
+
modifiers,
|
|
714
|
+
computed(() => ({
|
|
715
|
+
switch: propsSwitch.value,
|
|
716
|
+
valid: valid.value,
|
|
717
|
+
invalid: invalid.value,
|
|
718
|
+
disabled: disabled.value,
|
|
719
|
+
readonly: readonly.value,
|
|
720
|
+
indeterminate: indeterminate.value
|
|
454
721
|
}))
|
|
455
722
|
);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
723
|
+
watchEffect(() => {
|
|
724
|
+
if (isBinary.value && Array.isArray(modelValue.value)) {
|
|
725
|
+
console.warn(
|
|
726
|
+
`[VvCheckbox] The model value is an array but the component is in binary mode.`
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
watch(
|
|
731
|
+
() => isIndeterminated.value,
|
|
732
|
+
(newValue) => {
|
|
733
|
+
if (newValue) {
|
|
734
|
+
input.value.indeterminate = true;
|
|
735
|
+
} else {
|
|
736
|
+
input.value.indeterminate = false;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
);
|
|
740
|
+
onMounted(() => {
|
|
741
|
+
if (isIndeterminated.value) {
|
|
742
|
+
input.value.indeterminate = true;
|
|
464
743
|
}
|
|
465
|
-
), pe(() => {
|
|
466
|
-
B.value && (g.value.indeterminate = !0);
|
|
467
744
|
});
|
|
468
|
-
const { HintSlot
|
|
469
|
-
return (
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
745
|
+
const { HintSlot } = HintSlotFactory(props, slots);
|
|
746
|
+
return (_ctx, _cache) => {
|
|
747
|
+
return openBlock(), createElementBlock("label", {
|
|
748
|
+
class: normalizeClass(unref(bemCssClasses)),
|
|
749
|
+
for: unref(hasId)
|
|
750
|
+
}, [
|
|
751
|
+
withDirectives(createElementVNode("input", {
|
|
752
|
+
id: unref(hasId),
|
|
753
|
+
ref_key: "input",
|
|
754
|
+
ref: input,
|
|
755
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localModelValue) ? localModelValue.value = $event : null),
|
|
756
|
+
type: "checkbox",
|
|
757
|
+
class: "vv-checkbox__input",
|
|
758
|
+
name: _ctx.name,
|
|
759
|
+
disabled: unref(isDisabled),
|
|
760
|
+
value: unref(hasValue),
|
|
761
|
+
tabindex: unref(tabindex),
|
|
762
|
+
"aria-invalid": unref(isInvalid)
|
|
763
|
+
}, null, 8, _hoisted_2$1), [
|
|
764
|
+
[vModelCheckbox, unref(localModelValue)]
|
|
765
|
+
]),
|
|
766
|
+
renderSlot(_ctx.$slots, "default", { value: unref(modelValue) }, () => [
|
|
767
|
+
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
768
|
+
]),
|
|
769
|
+
createVNode(unref(HintSlot), {
|
|
770
|
+
class: "vv-checkbox__hint",
|
|
771
|
+
params: { value: unref(modelValue) }
|
|
772
|
+
}, null, 8, ["params"])
|
|
773
|
+
], 10, _hoisted_1$1);
|
|
774
|
+
};
|
|
496
775
|
}
|
|
497
|
-
})
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
776
|
+
});
|
|
777
|
+
const VvCheckboxGroupProps = CheckboxRadioGroupProps;
|
|
778
|
+
const VvCheckboxGroupEvents = ["update:modelValue", "change"];
|
|
779
|
+
function useProvideGroupState(groupState) {
|
|
780
|
+
if (Object.keys(groupState).some(
|
|
781
|
+
(k) => k !== "key" && !isRef(groupState[k])
|
|
501
782
|
))
|
|
502
783
|
throw Error("One or more groupState props aren't ref.");
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
784
|
+
provide(
|
|
785
|
+
groupState.key,
|
|
786
|
+
computed(() => groupState)
|
|
506
787
|
);
|
|
507
788
|
}
|
|
508
|
-
function
|
|
509
|
-
const { options
|
|
789
|
+
function useOptions(props) {
|
|
790
|
+
const { options, labelKey, valueKey, disabledKey } = toRefs(props);
|
|
791
|
+
const getOptionLabel = (option) => {
|
|
792
|
+
if (typeof option !== "object" && option !== null)
|
|
793
|
+
return option;
|
|
794
|
+
return typeof labelKey.value === "function" ? labelKey.value(option) : option[labelKey.value];
|
|
795
|
+
};
|
|
796
|
+
const getOptionValue = (option) => {
|
|
797
|
+
if (typeof option !== "object" && option !== null)
|
|
798
|
+
return option;
|
|
799
|
+
return typeof valueKey.value === "function" ? valueKey.value(option) : option[valueKey.value];
|
|
800
|
+
};
|
|
801
|
+
const getOptionDisabled = (option) => {
|
|
802
|
+
if (typeof option !== "object" && option !== null)
|
|
803
|
+
return false;
|
|
804
|
+
return typeof disabledKey.value === "function" ? disabledKey.value(option) : option[disabledKey.value];
|
|
805
|
+
};
|
|
510
806
|
return {
|
|
511
|
-
options
|
|
512
|
-
getOptionLabel
|
|
513
|
-
getOptionValue
|
|
514
|
-
getOptionDisabled
|
|
807
|
+
options,
|
|
808
|
+
getOptionLabel,
|
|
809
|
+
getOptionValue,
|
|
810
|
+
getOptionDisabled
|
|
515
811
|
};
|
|
516
812
|
}
|
|
517
|
-
const
|
|
813
|
+
const _hoisted_1 = ["textContent"];
|
|
814
|
+
const _hoisted_2 = { class: "vv-checkbox-group__wrapper" };
|
|
815
|
+
const __default__ = {
|
|
518
816
|
name: "VvCheckboxGroup"
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
817
|
+
};
|
|
818
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
819
|
+
...__default__,
|
|
820
|
+
props: VvCheckboxGroupProps,
|
|
821
|
+
emits: VvCheckboxGroupEvents,
|
|
822
|
+
setup(__props, { emit }) {
|
|
823
|
+
const props = __props;
|
|
824
|
+
const slots = useSlots();
|
|
825
|
+
const modelValue = useVModel(props, "modelValue", emit);
|
|
826
|
+
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
827
|
+
useProvideGroupState({
|
|
828
|
+
key: INJECTION_KEY_CHECK_GROUP,
|
|
829
|
+
modelValue,
|
|
830
|
+
disabled,
|
|
831
|
+
readonly,
|
|
832
|
+
valid,
|
|
833
|
+
invalid
|
|
532
834
|
});
|
|
533
|
-
const { getOptionLabel
|
|
835
|
+
const { getOptionLabel, getOptionValue } = useOptions(props);
|
|
836
|
+
const bemCssClasses = useModifiers(
|
|
534
837
|
"vv-checkbox-group",
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
disabled:
|
|
538
|
-
readonly:
|
|
539
|
-
horizontal: !
|
|
540
|
-
valid:
|
|
541
|
-
invalid:
|
|
838
|
+
modifiers,
|
|
839
|
+
computed(() => ({
|
|
840
|
+
disabled: disabled.value,
|
|
841
|
+
readonly: readonly.value,
|
|
842
|
+
horizontal: !vertical.value,
|
|
843
|
+
valid: valid.value,
|
|
844
|
+
invalid: invalid.value
|
|
542
845
|
}))
|
|
543
|
-
)
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
846
|
+
);
|
|
847
|
+
const getOptionProps = (option, index) => {
|
|
848
|
+
return {
|
|
849
|
+
id: `${props.name}_opt${index}`,
|
|
850
|
+
name: props.name,
|
|
851
|
+
label: getOptionLabel(option),
|
|
852
|
+
value: getOptionValue(option)
|
|
853
|
+
};
|
|
854
|
+
};
|
|
855
|
+
const { HintSlot } = HintSlotFactory(props, slots);
|
|
856
|
+
return (_ctx, _cache) => {
|
|
857
|
+
return openBlock(), createElementBlock("fieldset", {
|
|
858
|
+
class: normalizeClass(unref(bemCssClasses))
|
|
859
|
+
}, [
|
|
860
|
+
_ctx.label ? (openBlock(), createElementBlock("legend", {
|
|
861
|
+
key: 0,
|
|
862
|
+
textContent: toDisplayString(_ctx.label)
|
|
863
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("", true),
|
|
864
|
+
createElementVNode("div", _hoisted_2, [
|
|
865
|
+
_ctx.options.length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.options, (option, index) => {
|
|
866
|
+
return openBlock(), createBlock(_sfc_main$1, mergeProps({ key: index }, getOptionProps(option, index)), null, 16);
|
|
867
|
+
}), 128)) : renderSlot(_ctx.$slots, "default", { key: 1 })
|
|
868
|
+
]),
|
|
869
|
+
createVNode(unref(HintSlot), { class: "vv-checkbox-group__hint" })
|
|
870
|
+
], 2);
|
|
871
|
+
};
|
|
561
872
|
}
|
|
562
873
|
});
|
|
563
874
|
export {
|
|
564
|
-
|
|
875
|
+
_sfc_main as default
|
|
565
876
|
};
|