@volverjs/ui-vue 0.0.11 → 0.0.13-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/bin/icons.js +1 -93
- package/dist/components/VvAccordion/VvAccordion.es.js +1 -366
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +7 -2
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +2 -702
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +5 -2
- package/dist/components/VvAction/VvAction.es.js +1 -302
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +3 -2
- package/dist/components/VvAlert/VvAlert.es.js +1 -527
- package/dist/components/VvAlert/VvAlert.vue.d.ts +3 -2
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +1 -730
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +3 -3
- package/dist/components/VvAvatar/VvAvatar.es.js +1 -132
- package/dist/components/VvAvatar/VvAvatar.vue.d.ts +2 -2
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +1 -250
- package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +2 -2
- package/dist/components/VvBadge/VvBadge.es.js +1 -131
- package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +1 -410
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +2 -2
- package/dist/components/VvButton/VvButton.es.js +1 -882
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +3 -2
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +1 -214
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
- package/dist/components/VvCard/VvCard.es.js +1 -152
- package/dist/components/VvCard/VvCard.vue.d.ts +2 -2
- package/dist/components/VvCheckbox/VvCheckbox.es.js +1 -741
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +2 -2
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +1 -981
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -2
- package/dist/components/VvCombobox/VvCombobox.es.js +1 -3463
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +16 -7
- package/dist/components/VvDialog/VvDialog.es.js +1 -317
- package/dist/components/VvDialog/VvDialog.vue.d.ts +4 -2
- package/dist/components/VvDropdown/VvDropdown.es.js +1 -750
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +14 -2
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +2 -2
- package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +2 -2
- package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +11 -4
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -2
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +1 -448
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +1 -149
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +1 -104
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -281
- package/dist/components/VvIcon/VvIcon.es.js +1 -143
- package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
- package/dist/components/VvInputFile/VvInputFile.es.js +1 -1704
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +34 -4
- package/dist/components/VvInputFile/index.d.ts +7 -0
- package/dist/components/VvInputText/VvInputText.es.js +4 -2790
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +8 -3
- package/dist/components/VvNav/VvNav.es.js +1 -438
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/VvNav.vue.d.ts +2 -2
- package/dist/components/VvNav/VvNavItem.vue.d.ts +2 -2
- package/dist/components/VvNav/VvNavSeparator.vue.d.ts +1 -1
- package/dist/components/VvNavItem/VvNavItem.es.js +1 -337
- package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
- package/dist/components/VvNavSeparator/VvNavSeparator.es.js +1 -24
- package/dist/components/VvProgress/VvProgress.es.js +1 -163
- package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
- package/dist/components/VvRadio/VvRadio.es.js +1 -661
- package/dist/components/VvRadio/VvRadio.vue.d.ts +2 -2
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +1 -901
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -2
- package/dist/components/VvSelect/VvSelect.es.js +1 -1103
- package/dist/components/VvSelect/VvSelect.vue.d.ts +11 -7
- package/dist/components/VvTab/VvTab.es.js +1 -558
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTab/VvTab.vue.d.ts +2 -2
- package/dist/components/VvTextarea/VvTextarea.es.js +2 -1989
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +3 -3
- package/dist/components/VvTooltip/VvTooltip.es.js +1 -154
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +2 -2
- package/dist/components/index.es.js +6 -8558
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/index.es.js +2 -247
- package/dist/composables/index.umd.js +1 -1
- package/dist/directives/index.es.js +2 -311
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-contextmenu.es.js +2 -142
- package/dist/directives/v-contextmenu.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +1 -172
- package/dist/icons.es.js +1 -39
- package/dist/icons.umd.js +1 -1
- package/dist/index.es.js +1 -219
- package/dist/props/index.d.ts +7 -0
- package/dist/resolvers/unplugin.es.js +1 -187
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +2 -2
- package/dist/stories/Avatar/Avatar.settings.d.ts +1 -1
- package/package.json +47 -40
|
@@ -1,741 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
3
|
-
StorageType2["local"] = "local";
|
|
4
|
-
StorageType2["session"] = "session";
|
|
5
|
-
return StorageType2;
|
|
6
|
-
})(StorageType || {});
|
|
7
|
-
var Side = /* @__PURE__ */ ((Side2) => {
|
|
8
|
-
Side2["left"] = "left";
|
|
9
|
-
Side2["right"] = "right";
|
|
10
|
-
Side2["top"] = "top";
|
|
11
|
-
Side2["bottom"] = "bottom";
|
|
12
|
-
return Side2;
|
|
13
|
-
})(Side || {});
|
|
14
|
-
var Position = /* @__PURE__ */ ((Position2) => {
|
|
15
|
-
Position2["before"] = "before";
|
|
16
|
-
Position2["after"] = "after";
|
|
17
|
-
return Position2;
|
|
18
|
-
})(Position || {});
|
|
19
|
-
var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
|
|
20
|
-
ButtonType2["button"] = "button";
|
|
21
|
-
ButtonType2["submit"] = "submit";
|
|
22
|
-
ButtonType2["reset"] = "reset";
|
|
23
|
-
return ButtonType2;
|
|
24
|
-
})(ButtonType || {});
|
|
25
|
-
var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
|
|
26
|
-
ActionTag2["nuxtLink"] = "nuxt-link";
|
|
27
|
-
ActionTag2["routerLink"] = "router-link";
|
|
28
|
-
ActionTag2["a"] = "a";
|
|
29
|
-
ActionTag2["button"] = "button";
|
|
30
|
-
return ActionTag2;
|
|
31
|
-
})(ActionTag || {});
|
|
32
|
-
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
33
|
-
const INJECTION_KEY_CHECK_GROUP = Symbol.for(
|
|
34
|
-
"checkGroup"
|
|
35
|
-
);
|
|
36
|
-
const ValidProps = {
|
|
37
|
-
/**
|
|
38
|
-
* Valid status
|
|
39
|
-
*/
|
|
40
|
-
valid: { type: Boolean, default: false },
|
|
41
|
-
/**
|
|
42
|
-
* Valid label
|
|
43
|
-
*/
|
|
44
|
-
validLabel: { type: [String, Array], default: void 0 }
|
|
45
|
-
};
|
|
46
|
-
const InvalidProps = {
|
|
47
|
-
/**
|
|
48
|
-
* Invalid status
|
|
49
|
-
*/
|
|
50
|
-
invalid: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
/**
|
|
55
|
-
* Invalid label
|
|
56
|
-
*/
|
|
57
|
-
invalidLabel: { type: [String, Array], default: void 0 }
|
|
58
|
-
};
|
|
59
|
-
const LoadingProps = {
|
|
60
|
-
/**
|
|
61
|
-
* Loading status
|
|
62
|
-
*/
|
|
63
|
-
loading: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* Loading label
|
|
69
|
-
*/
|
|
70
|
-
loadingLabel: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: "Loading..."
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const DisabledProps = {
|
|
76
|
-
/**
|
|
77
|
-
* Whether the form control is disabled
|
|
78
|
-
*/
|
|
79
|
-
disabled: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
default: false
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const LabelProps = {
|
|
85
|
-
/**
|
|
86
|
-
* The item label
|
|
87
|
-
*/
|
|
88
|
-
label: {
|
|
89
|
-
type: [String, Number],
|
|
90
|
-
default: void 0
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const ReadonlyProps = {
|
|
94
|
-
/**
|
|
95
|
-
* The value is not editable
|
|
96
|
-
*/
|
|
97
|
-
readonly: {
|
|
98
|
-
type: Boolean,
|
|
99
|
-
default: false
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const ModifiersProps = {
|
|
103
|
-
/**
|
|
104
|
-
* Component BEM modifiers
|
|
105
|
-
*/
|
|
106
|
-
modifiers: {
|
|
107
|
-
type: [String, Array],
|
|
108
|
-
default: void 0
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const HintProps = {
|
|
112
|
-
hintLabel: { type: String, default: "" }
|
|
113
|
-
};
|
|
114
|
-
({
|
|
115
|
-
/**
|
|
116
|
-
* VvIcon position
|
|
117
|
-
*/
|
|
118
|
-
iconPosition: {
|
|
119
|
-
default: Position.before
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
const TabindexProps = {
|
|
123
|
-
/**
|
|
124
|
-
* Global attribute tabindex
|
|
125
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
|
|
126
|
-
*/
|
|
127
|
-
tabindex: { type: [String, Number], default: 0 }
|
|
128
|
-
};
|
|
129
|
-
const IdProps = {
|
|
130
|
-
/**
|
|
131
|
-
* Global attribute id
|
|
132
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
|
|
133
|
-
*/
|
|
134
|
-
id: [String, Number]
|
|
135
|
-
};
|
|
136
|
-
({
|
|
137
|
-
/**
|
|
138
|
-
* Dropdown placement
|
|
139
|
-
*/
|
|
140
|
-
placement: {
|
|
141
|
-
default: Side.bottom
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const IdNameProps = {
|
|
145
|
-
...IdProps,
|
|
146
|
-
/**
|
|
147
|
-
* Input / Textarea name
|
|
148
|
-
* Name of the form control. Submitted with the form as part of a name/value pair
|
|
149
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
|
|
150
|
-
*/
|
|
151
|
-
name: { type: String, required: true }
|
|
152
|
-
};
|
|
153
|
-
const CheckboxRadioProps = {
|
|
154
|
-
...IdNameProps,
|
|
155
|
-
...TabindexProps,
|
|
156
|
-
...ValidProps,
|
|
157
|
-
...InvalidProps,
|
|
158
|
-
...HintProps,
|
|
159
|
-
...DisabledProps,
|
|
160
|
-
...ReadonlyProps,
|
|
161
|
-
...ModifiersProps,
|
|
162
|
-
...LabelProps,
|
|
163
|
-
...LoadingProps,
|
|
164
|
-
/**
|
|
165
|
-
* Input value
|
|
166
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
|
|
167
|
-
*/
|
|
168
|
-
value: {
|
|
169
|
-
type: [String, Number, Boolean],
|
|
170
|
-
default: void 0
|
|
171
|
-
},
|
|
172
|
-
/**
|
|
173
|
-
* Input value
|
|
174
|
-
*/
|
|
175
|
-
modelValue: {
|
|
176
|
-
type: [Object, Number, Boolean, String],
|
|
177
|
-
default: void 0
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
({
|
|
181
|
-
/**
|
|
182
|
-
* Button type
|
|
183
|
-
*/
|
|
184
|
-
type: {
|
|
185
|
-
default: ButtonType.button
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* Default tag for the action
|
|
189
|
-
*/
|
|
190
|
-
defaultTag: {
|
|
191
|
-
default: ActionTag.button
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
({
|
|
195
|
-
storageType: {
|
|
196
|
-
default: StorageType.local
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
function useGroupStateInject(groupKey) {
|
|
200
|
-
const group = inject(groupKey, void 0);
|
|
201
|
-
const isInGroup = computed(() => group !== void 0);
|
|
202
|
-
function getGroupOrLocalRef(propName, props, emit) {
|
|
203
|
-
const groupPropValue = group?.[propName];
|
|
204
|
-
if (groupPropValue) {
|
|
205
|
-
return computed({
|
|
206
|
-
get() {
|
|
207
|
-
return groupPropValue.value;
|
|
208
|
-
},
|
|
209
|
-
set(value) {
|
|
210
|
-
groupPropValue.value = value;
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const propRef = toRef(props, propName);
|
|
215
|
-
return computed({
|
|
216
|
-
get() {
|
|
217
|
-
return propRef.value;
|
|
218
|
-
},
|
|
219
|
-
set(value) {
|
|
220
|
-
if (emit) {
|
|
221
|
-
emit(`update:${propName}`, value);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
group,
|
|
228
|
-
isInGroup,
|
|
229
|
-
getGroupOrLocalRef
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
const VvCheckboxProps = {
|
|
233
|
-
...CheckboxRadioProps,
|
|
234
|
-
...ModifiersProps,
|
|
235
|
-
/**
|
|
236
|
-
* If true, the input will be indeterminated
|
|
237
|
-
*/
|
|
238
|
-
indeterminate: Boolean,
|
|
239
|
-
/**
|
|
240
|
-
* Value associated with the unchecked state
|
|
241
|
-
*/
|
|
242
|
-
uncheckedValue: [String, Number, Boolean],
|
|
243
|
-
/**
|
|
244
|
-
* If true, the input will be displayed as a switch
|
|
245
|
-
*/
|
|
246
|
-
switch: Boolean
|
|
247
|
-
};
|
|
248
|
-
const VvCheckboxEvents = ["click", "update:modelValue", "change", "blur"];
|
|
249
|
-
function useGroupProps(props, emit) {
|
|
250
|
-
const { group, isInGroup, getGroupOrLocalRef } = useGroupStateInject(INJECTION_KEY_CHECK_GROUP);
|
|
251
|
-
const { id, switch: propsSwitch, indeterminate } = toRefs(props);
|
|
252
|
-
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
253
|
-
const valid = getGroupOrLocalRef("valid", props);
|
|
254
|
-
const invalid = getGroupOrLocalRef("invalid", props);
|
|
255
|
-
const readonly = computed(
|
|
256
|
-
() => Boolean(props.readonly || group?.readonly.value)
|
|
257
|
-
);
|
|
258
|
-
const disabled = computed(
|
|
259
|
-
() => Boolean(props.disabled || group?.disabled.value)
|
|
260
|
-
);
|
|
261
|
-
return {
|
|
262
|
-
// local props
|
|
263
|
-
id,
|
|
264
|
-
propsSwitch,
|
|
265
|
-
indeterminate,
|
|
266
|
-
// global props
|
|
267
|
-
group,
|
|
268
|
-
isInGroup,
|
|
269
|
-
modelValue,
|
|
270
|
-
valid,
|
|
271
|
-
invalid,
|
|
272
|
-
readonly,
|
|
273
|
-
disabled
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function equals(obj1, obj2, field) {
|
|
277
|
-
return deepEquals(obj1, obj2);
|
|
278
|
-
}
|
|
279
|
-
function deepEquals(a, b) {
|
|
280
|
-
if (a === b)
|
|
281
|
-
return true;
|
|
282
|
-
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
283
|
-
const arrA = Array.isArray(a);
|
|
284
|
-
const arrB = Array.isArray(b);
|
|
285
|
-
let i, length, key;
|
|
286
|
-
if (arrA && arrB) {
|
|
287
|
-
length = a.length;
|
|
288
|
-
if (length !== b.length)
|
|
289
|
-
return false;
|
|
290
|
-
for (i = length; i-- !== 0; ) {
|
|
291
|
-
if (!deepEquals(a[i], b[i]))
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
if (arrA !== arrB)
|
|
297
|
-
return false;
|
|
298
|
-
const dateA = a instanceof Date;
|
|
299
|
-
const dateB = b instanceof Date;
|
|
300
|
-
if (dateA !== dateB)
|
|
301
|
-
return false;
|
|
302
|
-
if (dateA && dateB)
|
|
303
|
-
return a.getTime() === b.getTime();
|
|
304
|
-
const regexpA = a instanceof RegExp;
|
|
305
|
-
const regexpB = b instanceof RegExp;
|
|
306
|
-
if (regexpA !== regexpB)
|
|
307
|
-
return false;
|
|
308
|
-
if (regexpA && regexpB)
|
|
309
|
-
return a.toString() === b.toString();
|
|
310
|
-
const keys = Object.keys(a);
|
|
311
|
-
length = keys.length;
|
|
312
|
-
if (length !== Object.keys(b).length)
|
|
313
|
-
return false;
|
|
314
|
-
for (i = length; i-- !== 0; ) {
|
|
315
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
for (i = length; i-- !== 0; ) {
|
|
319
|
-
key = keys[i];
|
|
320
|
-
if (!deepEquals(a[key], b[key]))
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
return true;
|
|
324
|
-
}
|
|
325
|
-
return Number.isNaN(a) && Number.isNaN(b);
|
|
326
|
-
}
|
|
327
|
-
function contains(value, list) {
|
|
328
|
-
if (value != null && list && list.length) {
|
|
329
|
-
for (const val of list) {
|
|
330
|
-
if (equals(value, val)) {
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
function isString(value) {
|
|
338
|
-
return typeof value === "string";
|
|
339
|
-
}
|
|
340
|
-
function joinLines(items) {
|
|
341
|
-
if (Array.isArray(items)) {
|
|
342
|
-
return items.filter((item) => isString(item)).join(" ");
|
|
343
|
-
}
|
|
344
|
-
return items;
|
|
345
|
-
}
|
|
346
|
-
function HintSlotFactory(propsOrRef, slots) {
|
|
347
|
-
const props = computed(() => {
|
|
348
|
-
if (isRef(propsOrRef)) {
|
|
349
|
-
return propsOrRef.value;
|
|
350
|
-
}
|
|
351
|
-
return propsOrRef;
|
|
352
|
-
});
|
|
353
|
-
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
354
|
-
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
355
|
-
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
356
|
-
const hintLabel = computed(() => props.value.hintLabel);
|
|
357
|
-
const hasLoadingLabelOrSlot = computed(
|
|
358
|
-
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
359
|
-
);
|
|
360
|
-
const hasInvalidLabelOrSlot = computed(
|
|
361
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
362
|
-
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
363
|
-
)
|
|
364
|
-
);
|
|
365
|
-
const hasValidLabelOrSlot = computed(
|
|
366
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
367
|
-
);
|
|
368
|
-
const hasHintLabelOrSlot = computed(
|
|
369
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
370
|
-
);
|
|
371
|
-
const isVisible = computed(
|
|
372
|
-
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
373
|
-
);
|
|
374
|
-
const hintSlotScope = computed(() => ({
|
|
375
|
-
modelValue: props.value.modelValue,
|
|
376
|
-
valid: props.value.valid,
|
|
377
|
-
invalid: props.value.invalid,
|
|
378
|
-
loading: props.value.loading
|
|
379
|
-
}));
|
|
380
|
-
const HintSlot = defineComponent({
|
|
381
|
-
name: "HintSlot",
|
|
382
|
-
props: {
|
|
383
|
-
tag: {
|
|
384
|
-
type: String,
|
|
385
|
-
default: "small"
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
setup() {
|
|
389
|
-
return {
|
|
390
|
-
isVisible,
|
|
391
|
-
invalidLabel,
|
|
392
|
-
validLabel,
|
|
393
|
-
loadingLabel,
|
|
394
|
-
hintLabel,
|
|
395
|
-
hasInvalidLabelOrSlot,
|
|
396
|
-
hasValidLabelOrSlot,
|
|
397
|
-
hasLoadingLabelOrSlot,
|
|
398
|
-
hasHintLabelOrSlot
|
|
399
|
-
};
|
|
400
|
-
},
|
|
401
|
-
render() {
|
|
402
|
-
if (this.isVisible) {
|
|
403
|
-
let role;
|
|
404
|
-
if (this.hasInvalidLabelOrSlot) {
|
|
405
|
-
role = "alert";
|
|
406
|
-
}
|
|
407
|
-
if (this.hasValidLabelOrSlot) {
|
|
408
|
-
role = "status";
|
|
409
|
-
}
|
|
410
|
-
if (this.hasLoadingLabelOrSlot) {
|
|
411
|
-
return h(
|
|
412
|
-
this.tag,
|
|
413
|
-
{
|
|
414
|
-
role
|
|
415
|
-
},
|
|
416
|
-
this.$slots.loading?.() ?? this.loadingLabel
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
if (this.hasInvalidLabelOrSlot) {
|
|
420
|
-
return h(
|
|
421
|
-
this.tag,
|
|
422
|
-
{
|
|
423
|
-
role
|
|
424
|
-
},
|
|
425
|
-
this.$slots.invalid?.() ?? this.$slots.invalid ?? this.invalidLabel
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
if (this.hasValidLabelOrSlot) {
|
|
429
|
-
return h(
|
|
430
|
-
this.tag,
|
|
431
|
-
{
|
|
432
|
-
role
|
|
433
|
-
},
|
|
434
|
-
this.$slots.valid?.() ?? this.validLabel
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
return h(
|
|
438
|
-
this.tag,
|
|
439
|
-
{
|
|
440
|
-
role
|
|
441
|
-
},
|
|
442
|
-
this.$slots.hint?.() ?? this.$slots.hint ?? this.hintLabel
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
return null;
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
return {
|
|
449
|
-
hasInvalidLabelOrSlot,
|
|
450
|
-
hasHintLabelOrSlot,
|
|
451
|
-
hasValidLabelOrSlot,
|
|
452
|
-
hasLoadingLabelOrSlot,
|
|
453
|
-
hintSlotScope,
|
|
454
|
-
HintSlot
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
function useVolver() {
|
|
458
|
-
return inject(INJECTION_KEY_VOLVER, void 0);
|
|
459
|
-
}
|
|
460
|
-
function useDefaults(componentName, propsDefinition, props) {
|
|
461
|
-
const volver = useVolver();
|
|
462
|
-
const volverComponentDefaults = computed(() => {
|
|
463
|
-
if (!volver || !volver.defaults.value?.[componentName]) {
|
|
464
|
-
return void 0;
|
|
465
|
-
}
|
|
466
|
-
return volver.defaults.value[componentName];
|
|
467
|
-
});
|
|
468
|
-
return computed(() => {
|
|
469
|
-
if (volverComponentDefaults.value === void 0) {
|
|
470
|
-
return props;
|
|
471
|
-
}
|
|
472
|
-
const componentDefaults = volverComponentDefaults.value;
|
|
473
|
-
const simplifiedPropsDefinition = propsDefinition;
|
|
474
|
-
const simplifiedProps = props;
|
|
475
|
-
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
476
|
-
const propValue = simplifiedProps[key];
|
|
477
|
-
acc[key] = propValue;
|
|
478
|
-
if (key in componentDefaults) {
|
|
479
|
-
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
480
|
-
const typeArray = simplifiedPropsDefinition[key];
|
|
481
|
-
if (typeArray.length) {
|
|
482
|
-
const typeFunction = typeArray[0];
|
|
483
|
-
if (typeFunction === propValue) {
|
|
484
|
-
acc[key] = componentDefaults[key];
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
489
|
-
const typeFunction = simplifiedPropsDefinition[key];
|
|
490
|
-
if (typeFunction() === propValue) {
|
|
491
|
-
acc[key] = componentDefaults[key];
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
495
|
-
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
496
|
-
if (typeof defaultValue === "function") {
|
|
497
|
-
defaultValue = defaultValue();
|
|
498
|
-
}
|
|
499
|
-
if (typeof defaultValue === "object") {
|
|
500
|
-
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
501
|
-
acc[key] = componentDefaults[key];
|
|
502
|
-
}
|
|
503
|
-
} else if (defaultValue === propValue) {
|
|
504
|
-
acc[key] = componentDefaults[key];
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
return acc;
|
|
509
|
-
}, {});
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
function useUniqueId(id) {
|
|
513
|
-
return computed(() => String(id?.value || useId()));
|
|
514
|
-
}
|
|
515
|
-
function useModifiers(prefix, modifiers, others) {
|
|
516
|
-
return computed(() => {
|
|
517
|
-
const toReturn = {
|
|
518
|
-
[prefix]: true
|
|
519
|
-
};
|
|
520
|
-
const modifiersArray = typeof modifiers?.value === "string" ? modifiers.value.split(" ") : modifiers?.value;
|
|
521
|
-
if (modifiersArray) {
|
|
522
|
-
if (Array.isArray(modifiersArray)) {
|
|
523
|
-
modifiersArray.forEach((modifier) => {
|
|
524
|
-
if (modifier) {
|
|
525
|
-
toReturn[`${prefix}--${modifier}`] = true;
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if (others) {
|
|
531
|
-
Object.keys(others.value).forEach((key) => {
|
|
532
|
-
toReturn[`${prefix}--${key}`] = unref(others.value[key]);
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
return toReturn;
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
const _hoisted_1 = ["for"];
|
|
539
|
-
const _hoisted_2 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid", "aria-describedby", "aria-errormessage"];
|
|
540
|
-
const __default__ = {
|
|
541
|
-
name: "VvCheckbox"
|
|
542
|
-
};
|
|
543
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
544
|
-
...__default__,
|
|
545
|
-
props: VvCheckboxProps,
|
|
546
|
-
emits: VvCheckboxEvents,
|
|
547
|
-
setup(__props, { emit: __emit }) {
|
|
548
|
-
const props = __props;
|
|
549
|
-
const emit = __emit;
|
|
550
|
-
const slots = useSlots();
|
|
551
|
-
const propsDefaults = useDefaults(
|
|
552
|
-
"VvCheckbox",
|
|
553
|
-
VvCheckboxProps,
|
|
554
|
-
props
|
|
555
|
-
);
|
|
556
|
-
const {
|
|
557
|
-
id,
|
|
558
|
-
disabled,
|
|
559
|
-
readonly,
|
|
560
|
-
valid,
|
|
561
|
-
invalid,
|
|
562
|
-
propsSwitch,
|
|
563
|
-
modelValue,
|
|
564
|
-
indeterminate,
|
|
565
|
-
isInGroup
|
|
566
|
-
} = useGroupProps(props, emit);
|
|
567
|
-
const hasId = useUniqueId(id);
|
|
568
|
-
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
569
|
-
const tabindex = computed(() => isDisabled.value ? -1 : props.tabindex);
|
|
570
|
-
const input = ref();
|
|
571
|
-
const isBinary = computed(
|
|
572
|
-
() => props.uncheckedValue !== void 0 && !isInGroup.value
|
|
573
|
-
);
|
|
574
|
-
const isDisabled = computed(() => disabled.value || readonly.value);
|
|
575
|
-
const isInvalid = computed(() => {
|
|
576
|
-
if (invalid.value === true) {
|
|
577
|
-
return true;
|
|
578
|
-
}
|
|
579
|
-
if (valid.value === true) {
|
|
580
|
-
return false;
|
|
581
|
-
}
|
|
582
|
-
return void 0;
|
|
583
|
-
});
|
|
584
|
-
const isChecked = computed(() => {
|
|
585
|
-
if (isBinary.value) {
|
|
586
|
-
return modelValue.value === props.value;
|
|
587
|
-
}
|
|
588
|
-
return Array.isArray(modelValue.value) ? contains(props.value, modelValue.value) : equals(props.value, modelValue.value);
|
|
589
|
-
});
|
|
590
|
-
const isIndeterminated = computed(() => {
|
|
591
|
-
if (indeterminate.value) {
|
|
592
|
-
return true;
|
|
593
|
-
}
|
|
594
|
-
if (!isChecked.value && isBinary.value && props.uncheckedValue !== modelValue.value) {
|
|
595
|
-
return true;
|
|
596
|
-
}
|
|
597
|
-
return false;
|
|
598
|
-
});
|
|
599
|
-
const hasValue = computed(() => {
|
|
600
|
-
if (isBinary.value) {
|
|
601
|
-
return void 0;
|
|
602
|
-
}
|
|
603
|
-
return ["string", "number", "boolean"].includes(typeof props.value) ? props.value : true;
|
|
604
|
-
});
|
|
605
|
-
const localModelValue = computed({
|
|
606
|
-
get() {
|
|
607
|
-
return isChecked.value;
|
|
608
|
-
},
|
|
609
|
-
set(newValue) {
|
|
610
|
-
if (isBinary.value) {
|
|
611
|
-
modelValue.value = newValue ? props.value : props.uncheckedValue;
|
|
612
|
-
} else if (Array.isArray(modelValue.value) || isInGroup.value) {
|
|
613
|
-
const currentValue = modelValue.value ?? [];
|
|
614
|
-
const toReturn = new Set(
|
|
615
|
-
Array.isArray(currentValue) ? currentValue : [currentValue]
|
|
616
|
-
);
|
|
617
|
-
if (newValue) {
|
|
618
|
-
toReturn.add(props.value);
|
|
619
|
-
} else {
|
|
620
|
-
toReturn.delete(props.value);
|
|
621
|
-
}
|
|
622
|
-
modelValue.value = [...toReturn];
|
|
623
|
-
} else {
|
|
624
|
-
modelValue.value = newValue ? props.value : void 0;
|
|
625
|
-
}
|
|
626
|
-
emit("change", newValue);
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
const { modifiers } = toRefs(props);
|
|
630
|
-
const bemCssClasses = useModifiers(
|
|
631
|
-
"vv-checkbox",
|
|
632
|
-
modifiers,
|
|
633
|
-
computed(() => ({
|
|
634
|
-
switch: propsSwitch.value,
|
|
635
|
-
valid: valid.value,
|
|
636
|
-
invalid: invalid.value,
|
|
637
|
-
disabled: disabled.value,
|
|
638
|
-
readonly: readonly.value,
|
|
639
|
-
indeterminate: indeterminate.value
|
|
640
|
-
}))
|
|
641
|
-
);
|
|
642
|
-
watchEffect(() => {
|
|
643
|
-
if (isBinary.value && Array.isArray(modelValue.value)) {
|
|
644
|
-
console.warn(
|
|
645
|
-
`[VvCheckbox] The model value is an array but the component is in binary mode.`
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
watch(
|
|
650
|
-
() => isIndeterminated.value,
|
|
651
|
-
(newValue) => {
|
|
652
|
-
if (newValue) {
|
|
653
|
-
input.value.indeterminate = true;
|
|
654
|
-
} else {
|
|
655
|
-
input.value.indeterminate = false;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
);
|
|
659
|
-
onMounted(() => {
|
|
660
|
-
if (isIndeterminated.value) {
|
|
661
|
-
input.value.indeterminate = true;
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
const {
|
|
665
|
-
HintSlot,
|
|
666
|
-
hasHintLabelOrSlot,
|
|
667
|
-
hasInvalidLabelOrSlot,
|
|
668
|
-
hintSlotScope
|
|
669
|
-
} = HintSlotFactory(propsDefaults, slots);
|
|
670
|
-
return (_ctx, _cache) => {
|
|
671
|
-
return openBlock(), createElementBlock("label", {
|
|
672
|
-
class: normalizeClass(unref(bemCssClasses)),
|
|
673
|
-
for: unref(hasId)
|
|
674
|
-
}, [
|
|
675
|
-
withDirectives(createElementVNode("input", {
|
|
676
|
-
id: unref(hasId),
|
|
677
|
-
ref_key: "input",
|
|
678
|
-
ref: input,
|
|
679
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localModelValue) ? localModelValue.value = $event : null),
|
|
680
|
-
type: "checkbox",
|
|
681
|
-
class: "vv-checkbox__input",
|
|
682
|
-
name: _ctx.name,
|
|
683
|
-
disabled: unref(isDisabled),
|
|
684
|
-
value: unref(hasValue),
|
|
685
|
-
tabindex: unref(tabindex),
|
|
686
|
-
"aria-invalid": unref(isInvalid),
|
|
687
|
-
"aria-describedby": unref(hasHintLabelOrSlot) ? unref(hasHintId) : void 0,
|
|
688
|
-
"aria-errormessage": unref(hasInvalidLabelOrSlot) ? unref(hasHintId) : void 0
|
|
689
|
-
}, null, 8, _hoisted_2), [
|
|
690
|
-
[vModelCheckbox, unref(localModelValue)]
|
|
691
|
-
]),
|
|
692
|
-
renderSlot(_ctx.$slots, "default", { value: unref(modelValue) }, () => [
|
|
693
|
-
createTextVNode(
|
|
694
|
-
toDisplayString(_ctx.label),
|
|
695
|
-
1
|
|
696
|
-
/* TEXT */
|
|
697
|
-
)
|
|
698
|
-
]),
|
|
699
|
-
createVNode(unref(HintSlot), {
|
|
700
|
-
id: unref(hasHintId),
|
|
701
|
-
class: "vv-checkbox__hint"
|
|
702
|
-
}, createSlots({
|
|
703
|
-
_: 2
|
|
704
|
-
/* DYNAMIC */
|
|
705
|
-
}, [
|
|
706
|
-
_ctx.$slots.hint ? {
|
|
707
|
-
name: "hint",
|
|
708
|
-
fn: withCtx(() => [
|
|
709
|
-
renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
710
|
-
]),
|
|
711
|
-
key: "0"
|
|
712
|
-
} : void 0,
|
|
713
|
-
_ctx.$slots.loading ? {
|
|
714
|
-
name: "loading",
|
|
715
|
-
fn: withCtx(() => [
|
|
716
|
-
renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
717
|
-
]),
|
|
718
|
-
key: "1"
|
|
719
|
-
} : void 0,
|
|
720
|
-
_ctx.$slots.valid ? {
|
|
721
|
-
name: "valid",
|
|
722
|
-
fn: withCtx(() => [
|
|
723
|
-
renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
724
|
-
]),
|
|
725
|
-
key: "2"
|
|
726
|
-
} : void 0,
|
|
727
|
-
_ctx.$slots.invalid ? {
|
|
728
|
-
name: "invalid",
|
|
729
|
-
fn: withCtx(() => [
|
|
730
|
-
renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
731
|
-
]),
|
|
732
|
-
key: "3"
|
|
733
|
-
} : void 0
|
|
734
|
-
]), 1032, ["id"])
|
|
735
|
-
], 10, _hoisted_1);
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
});
|
|
739
|
-
export {
|
|
740
|
-
_sfc_main as default
|
|
741
|
-
};
|
|
1
|
+
import{inject as e,computed as a,toRef as l,toRefs as t,isRef as i,defineComponent as n,h as o,useId as r,unref as u,useSlots as s,ref as d,watchEffect as v,watch as f,onMounted as c,createElementBlock as b,openBlock as h,normalizeClass as y,withDirectives as g,renderSlot as p,createVNode as m,createElementVNode as S,vModelCheckbox as L,createTextVNode as k,toDisplayString as O,createSlots as A,withCtx as V,normalizeProps as $,guardReactiveProps as x}from"vue";var B=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))(B||{}),N=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(N||{}),j=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(j||{}),I=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(I||{}),w=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(w||{});const G=/* @__PURE__ */Symbol.for("volver"),H=/* @__PURE__ */Symbol.for("checkGroup"),_={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},E={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},R={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},C={disabled:{type:Boolean,default:!1}},T={label:{type:[String,Number],default:void 0}},D={readonly:{type:Boolean,default:!1}},J={modifiers:{type:[String,Array],default:void 0}},q={hintLabel:{type:String,default:""}};j.before;const P={tabindex:{type:[String,Number],default:0}},U={id:[String,Number]};N.bottom;const z={...{...U,name:{type:String,required:!0}},...P,..._,...E,...q,...C,...D,...J,...T,...R,value:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[Object,Number,Boolean,String],default:void 0}};I.button,w.button,B.local;const F={...z,...J,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function K(i,n){const{group:o,isInGroup:r,getGroupOrLocalRef:u}=function(t){const i=e(t,void 0),n=a(()=>void 0!==i);return{group:i,isInGroup:n,getGroupOrLocalRef:function(e,t,n){const o=i?.[e];if(o)return a({get:()=>o.value,set(e){o.value=e}});const r=l(t,e);return a({get:()=>r.value,set(a){n&&n(`update:${e}`,a)}})}}}(H),{id:s,switch:d,indeterminate:v}=t(i),f=u("modelValue",i,n),c=u("valid",i),b=u("invalid",i),h=a(()=>Boolean(i.readonly||o?.readonly.value)),y=a(()=>Boolean(i.disabled||o?.disabled.value));return{id:s,propsSwitch:d,indeterminate:v,group:o,isInGroup:r,modelValue:f,valid:c,invalid:b,readonly:h,disabled:y}}function M(e,a,l){return Q(e,a)}function Q(e,a){if(e===a)return!0;if(e&&a&&"object"==typeof e&&"object"==typeof a){const l=Array.isArray(e),t=Array.isArray(a);let i,n,o;if(l&&t){if(n=e.length,n!==a.length)return!1;for(i=n;0!==i--;)if(!Q(e[i],a[i]))return!1;return!0}if(l!==t)return!1;const r=e instanceof Date,u=a instanceof Date;if(r!==u)return!1;if(r&&u)return e.getTime()===a.getTime();const s=e instanceof RegExp,d=a instanceof RegExp;if(s!==d)return!1;if(s&&d)return e.toString()===a.toString();const v=Object.keys(e);if(n=v.length,n!==Object.keys(a).length)return!1;for(i=n;0!==i--;)if(!Object.prototype.hasOwnProperty.call(a,v[i]))return!1;for(i=n;0!==i--;)if(o=v[i],!Q(e[o],a[o]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(a)}function W(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).join(" "):e}function X(l,t,i){const n=e(G,void 0),o=a(()=>{if(n&&n.defaults.value?.[l])return n.defaults.value[l]});return a(()=>{if(void 0===o.value)return i;const e=o.value,a=t,l=i;return Object.keys(a).reduce((t,i)=>{const n=l[i];if(t[i]=n,i in e){if(Array.isArray(a[i])){const l=a[i];if(l.length){l[0]===n&&(t[i]=e[i])}}if("function"==typeof a[i]){(0,a[i])()===n&&(t[i]=e[i])}if("object"==typeof a[i]){let l=a[i].default;"function"==typeof l&&(l=l()),"object"==typeof l?JSON.stringify(l)===JSON.stringify(n)&&(t[i]=e[i]):l===n&&(t[i]=e[i])}}return t},{})})}const Y=["for"],Z=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],ee=/* @__PURE__ */n({name:"VvCheckbox",props:F,emits:["click","update:modelValue","change","blur"],setup(e,{emit:l}){const B=e,N=l,j=s(),I=X("VvCheckbox",F,B),{id:w,disabled:G,readonly:H,valid:_,invalid:E,propsSwitch:R,modelValue:C,indeterminate:T,isInGroup:D}=K(B,N),J=function(e){return a(()=>String(e?.value||r()))}(w),q=a(()=>`${J.value}-hint`),P=a(()=>Q.value?-1:B.tabindex),U=d(),z=a(()=>void 0!==B.uncheckedValue&&!D.value),Q=a(()=>G.value||H.value),ee=a(()=>!0===E.value||!0!==_.value&&void 0),ae=a(()=>z.value?C.value===B.value:Array.isArray(C.value)?function(e,a){if(null!=e&&a&&a.length)for(const l of a)if(M(e,l))return!0;return!1}(B.value,C.value):M(B.value,C.value)),le=a(()=>!!T.value||!(ae.value||!z.value||B.uncheckedValue===C.value)),te=a(()=>{if(!z.value)return!["string","number","boolean"].includes(typeof B.value)||B.value}),ie=a({get:()=>ae.value,set(e){if(z.value)C.value=e?B.value:B.uncheckedValue;else if(Array.isArray(C.value)||D.value){const a=C.value??[],l=new Set(Array.isArray(a)?a:[a]);e?l.add(B.value):l.delete(B.value),C.value=[...l]}else C.value=e?B.value:void 0;N("change",e)}}),{modifiers:ne}=t(B),oe=function(e,l,t){return a(()=>{const a={[e]:!0},i="string"==typeof l?.value?l.value.split(" "):l?.value;return i&&Array.isArray(i)&&i.forEach(l=>{l&&(a[`${e}--${l}`]=!0)}),t&&Object.keys(t.value).forEach(l=>{a[`${e}--${l}`]=u(t.value[l])}),a})}("vv-checkbox",ne,a(()=>({switch:R.value,valid:_.value,invalid:E.value,disabled:G.value,readonly:H.value,indeterminate:T.value})));v(()=>{z.value&&Array.isArray(C.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")}),f(()=>le.value,e=>{U.value.indeterminate=!!e}),c(()=>{le.value&&(U.value.indeterminate=!0)});const{HintSlot:re,hasHintLabelOrSlot:ue,hasInvalidLabelOrSlot:se,hintSlotScope:de}=function(e,l){const t=a(()=>i(e)?e.value:e),r=a(()=>W(t.value.invalidLabel)),u=a(()=>W(t.value.validLabel)),s=a(()=>t.value.loadingLabel),d=a(()=>t.value.hintLabel),v=a(()=>Boolean(t.value.loading&&(l.loading||s.value))),f=a(()=>!v.value&&Boolean(t.value.invalid&&(l.invalid||r.value))),c=a(()=>!v.value&&!f.value&&Boolean(t.value.valid&&(l.valid||u.value))),b=a(()=>!v.value&&!f.value&&!c.value&&Boolean(l.hint||d.value)),h=a(()=>f.value||c.value||v.value||b.value),y=a(()=>({modelValue:t.value.modelValue,valid:t.value.valid,invalid:t.value.invalid,loading:t.value.loading})),g=n({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:h,invalidLabel:r,validLabel:u,loadingLabel:s,hintLabel:d,hasInvalidLabelOrSlot:f,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:v,hasHintLabelOrSlot:b}),render(){if(this.isVisible){let e;return this.hasInvalidLabelOrSlot&&(e="alert"),this.hasValidLabelOrSlot&&(e="status"),this.hasLoadingLabelOrSlot?o(this.tag,{role:e},this.$slots.loading?.()??this.loadingLabel):this.hasInvalidLabelOrSlot?o(this.tag,{role:e},this.$slots.invalid?.()??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?o(this.tag,{role:e},this.$slots.valid?.()??this.validLabel):o(this.tag,{role:e},this.$slots.hint?.()??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:f,hasHintLabelOrSlot:b,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:v,hintSlotScope:y,HintSlot:g}}(I,j);return(e,a)=>(h(),b("label",{class:y(u(oe)),for:u(J)},[g(S("input",{id:u(J),ref_key:"input",ref:U,"onUpdate:modelValue":a[0]||(a[0]=e=>i(ie)?ie.value=e:null),type:"checkbox",class:"vv-checkbox__input",name:e.name,disabled:u(Q),value:u(te),tabindex:u(P),"aria-invalid":u(ee),"aria-describedby":u(ue)?u(q):void 0,"aria-errormessage":u(se)?u(q):void 0},null,8,Z),[[L,u(ie)]]),p(e.$slots,"default",{value:u(C)},()=>[k(O(e.label),1)]),m(u(re),{id:u(q),class:"vv-checkbox__hint"},A({_:2},[e.$slots.hint?{name:"hint",fn:V(()=>[p(e.$slots,"hint",$(x(u(de))))]),key:"0"}:void 0,e.$slots.loading?{name:"loading",fn:V(()=>[p(e.$slots,"loading",$(x(u(de))))]),key:"1"}:void 0,e.$slots.valid?{name:"valid",fn:V(()=>[p(e.$slots,"valid",$(x(u(de))))]),key:"2"}:void 0,e.$slots.invalid?{name:"invalid",fn:V(()=>[p(e.$slots,"invalid",$(x(u(de))))]),key:"3"}:void 0]),1032,["id"])],10,Y))}});export{ee as default};
|