@volverjs/ui-vue 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/bin/icons.js +1 -93
  2. package/dist/components/VvAccordion/VvAccordion.es.js +1 -366
  3. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +2 -1
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +2 -702
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +3 -2
  6. package/dist/components/VvAction/VvAction.es.js +1 -302
  7. package/dist/components/VvAction/VvAction.vue.d.ts +2 -1
  8. package/dist/components/VvAlert/VvAlert.es.js +1 -527
  9. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +2 -1
  11. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +1 -730
  12. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  13. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +2 -1
  14. package/dist/components/VvAvatar/VvAvatar.es.js +1 -132
  15. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +2 -1
  16. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +1 -250
  17. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +2 -1
  18. package/dist/components/VvBadge/VvBadge.es.js +1 -131
  19. package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -1
  20. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +1 -410
  21. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +2 -1
  22. package/dist/components/VvButton/VvButton.es.js +1 -882
  23. package/dist/components/VvButton/VvButton.umd.js +1 -1
  24. package/dist/components/VvButton/VvButton.vue.d.ts +2 -1
  25. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +1 -214
  26. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -1
  27. package/dist/components/VvCard/VvCard.es.js +1 -152
  28. package/dist/components/VvCard/VvCard.vue.d.ts +2 -1
  29. package/dist/components/VvCheckbox/VvCheckbox.es.js +1 -741
  30. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +3 -2
  31. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +1 -981
  32. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -1
  33. package/dist/components/VvCombobox/VvCombobox.es.js +1 -3463
  34. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  35. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +263 -317
  36. package/dist/components/VvDialog/VvDialog.es.js +1 -317
  37. package/dist/components/VvDialog/VvDialog.vue.d.ts +2 -1
  38. package/dist/components/VvDropdown/VvDropdown.es.js +1 -750
  39. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +2 -1
  40. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +5 -4
  41. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +2 -1
  42. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +10 -2
  43. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -1
  44. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +1 -448
  45. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +1 -149
  46. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +1 -104
  47. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  48. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -281
  49. package/dist/components/VvIcon/VvIcon.es.js +1 -143
  50. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  51. package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -1
  52. package/dist/components/VvInputFile/VvInputFile.es.js +1 -1704
  53. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  54. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +2 -1
  55. package/dist/components/VvInputText/VvInputText.es.js +4 -2790
  56. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  57. package/dist/components/VvInputText/VvInputText.vue.d.ts +2 -1
  58. package/dist/components/VvNav/VvNav.es.js +1 -438
  59. package/dist/components/VvNav/VvNav.vue.d.ts +2 -1
  60. package/dist/components/VvNav/VvNavItem.vue.d.ts +2 -1
  61. package/dist/components/VvNav/VvNavSeparator.vue.d.ts +2 -1
  62. package/dist/components/VvNavItem/VvNavItem.es.js +1 -337
  63. package/dist/components/VvNavSeparator/VvNavSeparator.es.js +1 -24
  64. package/dist/components/VvProgress/VvProgress.es.js +1 -163
  65. package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -1
  66. package/dist/components/VvRadio/VvRadio.es.js +1 -661
  67. package/dist/components/VvRadio/VvRadio.vue.d.ts +3 -2
  68. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +1 -901
  69. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -1
  70. package/dist/components/VvSelect/VvSelect.es.js +1 -1103
  71. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  72. package/dist/components/VvSelect/VvSelect.vue.d.ts +130 -71
  73. package/dist/components/VvTab/VvTab.es.js +1 -558
  74. package/dist/components/VvTab/VvTab.vue.d.ts +2 -1
  75. package/dist/components/VvTextarea/VvTextarea.es.js +2 -1989
  76. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  77. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +2 -1
  78. package/dist/components/VvTooltip/VvTooltip.es.js +1 -154
  79. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +2 -1
  80. package/dist/components/index.es.js +6 -8558
  81. package/dist/components/index.umd.js +1 -1
  82. package/dist/composables/index.es.js +2 -247
  83. package/dist/composables/index.umd.js +1 -1
  84. package/dist/directives/index.es.js +2 -311
  85. package/dist/directives/index.umd.js +1 -1
  86. package/dist/directives/v-contextmenu.es.js +2 -142
  87. package/dist/directives/v-contextmenu.umd.js +1 -1
  88. package/dist/directives/v-tooltip.es.js +1 -172
  89. package/dist/icons.es.js +1 -39
  90. package/dist/icons.umd.js +1 -1
  91. package/dist/index.es.js +1 -219
  92. package/dist/resolvers/unplugin.es.js +1 -187
  93. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +14 -14
  94. package/package.json +37 -37
@@ -1,661 +1 @@
1
- import { inject, computed, toRef, toRefs, isRef, defineComponent, h, useId, unref, useSlots, ref, createElementBlock, openBlock, normalizeClass, withDirectives, renderSlot, createVNode, createElementVNode, vModelRadio, createTextVNode, toDisplayString, createSlots, withCtx, normalizeProps, guardReactiveProps } from "vue";
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_RADIO_GROUP = Symbol.for(
34
- "radioGroup"
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 VvRadioProps = CheckboxRadioProps;
233
- const VvRadioEvents = ["click", "update:modelValue", "change", "blur"];
234
- function useGroupProps(props, emit) {
235
- const { id } = toRefs(props);
236
- const { group, isInGroup, getGroupOrLocalRef } = useGroupStateInject(INJECTION_KEY_RADIO_GROUP);
237
- const modelValue = getGroupOrLocalRef("modelValue", props, emit);
238
- const valid = getGroupOrLocalRef("valid", props);
239
- const invalid = getGroupOrLocalRef("invalid", props);
240
- const readonly = computed(
241
- () => Boolean(props.readonly || group?.readonly.value)
242
- );
243
- const disabled = computed(
244
- () => Boolean(props.disabled || group?.disabled.value)
245
- );
246
- return {
247
- // local props
248
- id,
249
- // global props
250
- group,
251
- isInGroup,
252
- modelValue,
253
- valid,
254
- invalid,
255
- readonly,
256
- disabled
257
- };
258
- }
259
- function equals(obj1, obj2, field) {
260
- return deepEquals(obj1, obj2);
261
- }
262
- function deepEquals(a, b) {
263
- if (a === b)
264
- return true;
265
- if (a && b && typeof a == "object" && typeof b == "object") {
266
- const arrA = Array.isArray(a);
267
- const arrB = Array.isArray(b);
268
- let i, length, key;
269
- if (arrA && arrB) {
270
- length = a.length;
271
- if (length !== b.length)
272
- return false;
273
- for (i = length; i-- !== 0; ) {
274
- if (!deepEquals(a[i], b[i]))
275
- return false;
276
- }
277
- return true;
278
- }
279
- if (arrA !== arrB)
280
- return false;
281
- const dateA = a instanceof Date;
282
- const dateB = b instanceof Date;
283
- if (dateA !== dateB)
284
- return false;
285
- if (dateA && dateB)
286
- return a.getTime() === b.getTime();
287
- const regexpA = a instanceof RegExp;
288
- const regexpB = b instanceof RegExp;
289
- if (regexpA !== regexpB)
290
- return false;
291
- if (regexpA && regexpB)
292
- return a.toString() === b.toString();
293
- const keys = Object.keys(a);
294
- length = keys.length;
295
- if (length !== Object.keys(b).length)
296
- return false;
297
- for (i = length; i-- !== 0; ) {
298
- if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
299
- return false;
300
- }
301
- for (i = length; i-- !== 0; ) {
302
- key = keys[i];
303
- if (!deepEquals(a[key], b[key]))
304
- return false;
305
- }
306
- return true;
307
- }
308
- return Number.isNaN(a) && Number.isNaN(b);
309
- }
310
- function contains(value, list) {
311
- if (value != null && list && list.length) {
312
- for (const val of list) {
313
- if (equals(value, val)) {
314
- return true;
315
- }
316
- }
317
- }
318
- return false;
319
- }
320
- function isString(value) {
321
- return typeof value === "string";
322
- }
323
- function joinLines(items) {
324
- if (Array.isArray(items)) {
325
- return items.filter((item) => isString(item)).join(" ");
326
- }
327
- return items;
328
- }
329
- function HintSlotFactory(propsOrRef, slots) {
330
- const props = computed(() => {
331
- if (isRef(propsOrRef)) {
332
- return propsOrRef.value;
333
- }
334
- return propsOrRef;
335
- });
336
- const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
337
- const validLabel = computed(() => joinLines(props.value.validLabel));
338
- const loadingLabel = computed(() => props.value.loadingLabel);
339
- const hintLabel = computed(() => props.value.hintLabel);
340
- const hasLoadingLabelOrSlot = computed(
341
- () => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
342
- );
343
- const hasInvalidLabelOrSlot = computed(
344
- () => !hasLoadingLabelOrSlot.value && Boolean(
345
- props.value.invalid && (slots.invalid || invalidLabel.value)
346
- )
347
- );
348
- const hasValidLabelOrSlot = computed(
349
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
350
- );
351
- const hasHintLabelOrSlot = computed(
352
- () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
353
- );
354
- const isVisible = computed(
355
- () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
356
- );
357
- const hintSlotScope = computed(() => ({
358
- modelValue: props.value.modelValue,
359
- valid: props.value.valid,
360
- invalid: props.value.invalid,
361
- loading: props.value.loading
362
- }));
363
- const HintSlot = defineComponent({
364
- name: "HintSlot",
365
- props: {
366
- tag: {
367
- type: String,
368
- default: "small"
369
- }
370
- },
371
- setup() {
372
- return {
373
- isVisible,
374
- invalidLabel,
375
- validLabel,
376
- loadingLabel,
377
- hintLabel,
378
- hasInvalidLabelOrSlot,
379
- hasValidLabelOrSlot,
380
- hasLoadingLabelOrSlot,
381
- hasHintLabelOrSlot
382
- };
383
- },
384
- render() {
385
- if (this.isVisible) {
386
- let role;
387
- if (this.hasInvalidLabelOrSlot) {
388
- role = "alert";
389
- }
390
- if (this.hasValidLabelOrSlot) {
391
- role = "status";
392
- }
393
- if (this.hasLoadingLabelOrSlot) {
394
- return h(
395
- this.tag,
396
- {
397
- role
398
- },
399
- this.$slots.loading?.() ?? this.loadingLabel
400
- );
401
- }
402
- if (this.hasInvalidLabelOrSlot) {
403
- return h(
404
- this.tag,
405
- {
406
- role
407
- },
408
- this.$slots.invalid?.() ?? this.$slots.invalid ?? this.invalidLabel
409
- );
410
- }
411
- if (this.hasValidLabelOrSlot) {
412
- return h(
413
- this.tag,
414
- {
415
- role
416
- },
417
- this.$slots.valid?.() ?? this.validLabel
418
- );
419
- }
420
- return h(
421
- this.tag,
422
- {
423
- role
424
- },
425
- this.$slots.hint?.() ?? this.$slots.hint ?? this.hintLabel
426
- );
427
- }
428
- return null;
429
- }
430
- });
431
- return {
432
- hasInvalidLabelOrSlot,
433
- hasHintLabelOrSlot,
434
- hasValidLabelOrSlot,
435
- hasLoadingLabelOrSlot,
436
- hintSlotScope,
437
- HintSlot
438
- };
439
- }
440
- function useVolver() {
441
- return inject(INJECTION_KEY_VOLVER, void 0);
442
- }
443
- function useDefaults(componentName, propsDefinition, props) {
444
- const volver = useVolver();
445
- const volverComponentDefaults = computed(() => {
446
- if (!volver || !volver.defaults.value?.[componentName]) {
447
- return void 0;
448
- }
449
- return volver.defaults.value[componentName];
450
- });
451
- return computed(() => {
452
- if (volverComponentDefaults.value === void 0) {
453
- return props;
454
- }
455
- const componentDefaults = volverComponentDefaults.value;
456
- const simplifiedPropsDefinition = propsDefinition;
457
- const simplifiedProps = props;
458
- return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
459
- const propValue = simplifiedProps[key];
460
- acc[key] = propValue;
461
- if (key in componentDefaults) {
462
- if (Array.isArray(simplifiedPropsDefinition[key])) {
463
- const typeArray = simplifiedPropsDefinition[key];
464
- if (typeArray.length) {
465
- const typeFunction = typeArray[0];
466
- if (typeFunction === propValue) {
467
- acc[key] = componentDefaults[key];
468
- }
469
- }
470
- }
471
- if (typeof simplifiedPropsDefinition[key] === "function") {
472
- const typeFunction = simplifiedPropsDefinition[key];
473
- if (typeFunction() === propValue) {
474
- acc[key] = componentDefaults[key];
475
- }
476
- }
477
- if (typeof simplifiedPropsDefinition[key] === "object") {
478
- let defaultValue = simplifiedPropsDefinition[key].default;
479
- if (typeof defaultValue === "function") {
480
- defaultValue = defaultValue();
481
- }
482
- if (typeof defaultValue === "object") {
483
- if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
484
- acc[key] = componentDefaults[key];
485
- }
486
- } else if (defaultValue === propValue) {
487
- acc[key] = componentDefaults[key];
488
- }
489
- }
490
- }
491
- return acc;
492
- }, {});
493
- });
494
- }
495
- function useUniqueId(id) {
496
- return computed(() => String(id?.value || useId()));
497
- }
498
- function useModifiers(prefix, modifiers, others) {
499
- return computed(() => {
500
- const toReturn = {
501
- [prefix]: true
502
- };
503
- const modifiersArray = typeof modifiers?.value === "string" ? modifiers.value.split(" ") : modifiers?.value;
504
- if (modifiersArray) {
505
- if (Array.isArray(modifiersArray)) {
506
- modifiersArray.forEach((modifier) => {
507
- if (modifier) {
508
- toReturn[`${prefix}--${modifier}`] = true;
509
- }
510
- });
511
- }
512
- }
513
- if (others) {
514
- Object.keys(others.value).forEach((key) => {
515
- toReturn[`${prefix}--${key}`] = unref(others.value[key]);
516
- });
517
- }
518
- return toReturn;
519
- });
520
- }
521
- const _hoisted_1 = ["for"];
522
- const _hoisted_2 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid", "aria-describedby", "aria-errormessage"];
523
- const __default__ = {
524
- name: "VvRadio"
525
- };
526
- const _sfc_main = /* @__PURE__ */ defineComponent({
527
- ...__default__,
528
- props: VvRadioProps,
529
- emits: VvRadioEvents,
530
- setup(__props, { emit: __emit }) {
531
- const props = __props;
532
- const emit = __emit;
533
- const slots = useSlots();
534
- const propsDefaults = useDefaults(
535
- "VvRadio",
536
- VvRadioProps,
537
- props
538
- );
539
- const { id, disabled, readonly, modelValue, valid, invalid } = useGroupProps(props, emit);
540
- const hasId = useUniqueId(id);
541
- const hasHintId = computed(() => `${hasId.value}-hint`);
542
- const tabindex = computed(() => isDisabled.value ? -1 : props.tabindex);
543
- const input = ref();
544
- const isDisabled = computed(() => disabled.value || readonly.value);
545
- const isInvalid = computed(() => {
546
- if (invalid.value === true) {
547
- return true;
548
- }
549
- if (valid.value === true) {
550
- return false;
551
- }
552
- return void 0;
553
- });
554
- const isChecked = computed(
555
- () => Array.isArray(modelValue.value) ? contains(props.value, modelValue.value) : equals(props.value, modelValue.value)
556
- );
557
- const hasValue = computed(
558
- () => ["string", "number", "boolean"].includes(typeof props.value) ? props.value : true
559
- );
560
- const localModelValue = computed({
561
- get() {
562
- return isChecked.value ? hasValue.value : null;
563
- },
564
- set(newValue) {
565
- if (Array.isArray(modelValue.value)) {
566
- modelValue.value = [props.value];
567
- } else {
568
- modelValue.value = props.value;
569
- }
570
- emit("change", newValue);
571
- }
572
- });
573
- const { modifiers } = toRefs(props);
574
- const bemCssClasses = useModifiers(
575
- "vv-radio",
576
- modifiers,
577
- computed(() => ({
578
- valid: valid.value,
579
- invalid: invalid.value,
580
- disabled: disabled.value,
581
- readonly: readonly.value
582
- }))
583
- );
584
- const {
585
- HintSlot,
586
- hasHintLabelOrSlot,
587
- hasInvalidLabelOrSlot,
588
- hintSlotScope
589
- } = HintSlotFactory(propsDefaults, slots);
590
- return (_ctx, _cache) => {
591
- return openBlock(), createElementBlock("label", {
592
- class: normalizeClass(unref(bemCssClasses)),
593
- for: unref(hasId)
594
- }, [
595
- withDirectives(createElementVNode("input", {
596
- id: unref(hasId),
597
- ref_key: "input",
598
- ref: input,
599
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localModelValue) ? localModelValue.value = $event : null),
600
- type: "radio",
601
- class: "vv-radio__input",
602
- name: _ctx.name,
603
- disabled: unref(isDisabled),
604
- value: unref(hasValue),
605
- tabindex: unref(tabindex),
606
- "aria-invalid": unref(isInvalid),
607
- "aria-describedby": unref(hasHintLabelOrSlot) ? unref(hasHintId) : void 0,
608
- "aria-errormessage": unref(hasInvalidLabelOrSlot) ? unref(hasHintId) : void 0
609
- }, null, 8, _hoisted_2), [
610
- [vModelRadio, unref(localModelValue)]
611
- ]),
612
- renderSlot(_ctx.$slots, "default", { value: unref(modelValue) }, () => [
613
- createTextVNode(
614
- toDisplayString(_ctx.label),
615
- 1
616
- /* TEXT */
617
- )
618
- ]),
619
- createVNode(unref(HintSlot), {
620
- id: unref(hasHintId),
621
- class: "vv-radio__hint"
622
- }, createSlots({
623
- _: 2
624
- /* DYNAMIC */
625
- }, [
626
- _ctx.$slots.hint ? {
627
- name: "hint",
628
- fn: withCtx(() => [
629
- renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
630
- ]),
631
- key: "0"
632
- } : void 0,
633
- _ctx.$slots.loading ? {
634
- name: "loading",
635
- fn: withCtx(() => [
636
- renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
637
- ]),
638
- key: "1"
639
- } : void 0,
640
- _ctx.$slots.valid ? {
641
- name: "valid",
642
- fn: withCtx(() => [
643
- renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
644
- ]),
645
- key: "2"
646
- } : void 0,
647
- _ctx.$slots.invalid ? {
648
- name: "invalid",
649
- fn: withCtx(() => [
650
- renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
651
- ]),
652
- key: "3"
653
- } : void 0
654
- ]), 1032, ["id"])
655
- ], 10, _hoisted_1);
656
- };
657
- }
658
- });
659
- export {
660
- _sfc_main as default
661
- };
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,createElementBlock as v,openBlock as f,normalizeClass as b,withDirectives as c,renderSlot as g,createVNode as y,createElementVNode as h,vModelRadio as p,createTextVNode as m,toDisplayString as S,createSlots as L,withCtx as O,normalizeProps as $,guardReactiveProps as A}from"vue";var V=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))(V||{}),k=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(k||{}),B=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(B||{}),N=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(N||{}),j=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(j||{});const x=Symbol.for("volver"),I=Symbol.for("radioGroup"),G={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},H={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},R={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},_={disabled:{type:Boolean,default:!1}},E={label:{type:[String,Number],default:void 0}},D={readonly:{type:Boolean,default:!1}},J={modifiers:{type:[String,Array],default:void 0}},T={hintLabel:{type:String,default:""}};B.before;const q={tabindex:{type:[String,Number],default:0}},w={id:[String,Number]};k.bottom;const P={...{...w,name:{type:String,required:!0}},...q,...G,...H,...T,..._,...D,...J,...E,...R,value:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[Object,Number,Boolean,String],default:void 0}};N.button,j.button,V.local;const U=P;function z(i,n){const{id:o}=t(i),{group:r,isInGroup:u,getGroupOrLocalRef:s}=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)}})}}}(I),d=s("modelValue",i,n),v=s("valid",i),f=s("invalid",i),b=a(()=>Boolean(i.readonly||r?.readonly.value)),c=a(()=>Boolean(i.disabled||r?.disabled.value));return{id:o,group:r,isInGroup:u,modelValue:d,valid:v,invalid:f,readonly:b,disabled:c}}function C(e,a,l){return F(e,a)}function F(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(!F(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],!F(e[o],a[o]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(a)}function K(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).join(" "):e}function M(l,t,i){const n=e(x,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 Q=["for"],W=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],X=/* @__PURE__ */n({name:"VvRadio",props:U,emits:["click","update:modelValue","change","blur"],setup(e,{emit:l}){const V=e,k=l,B=s(),N=M("VvRadio",U,V),{id:j,disabled:x,readonly:I,modelValue:G,valid:H,invalid:R}=z(V,k),_=function(e){return a(()=>String(e?.value||r()))}(j),E=a(()=>`${_.value}-hint`),D=a(()=>T.value?-1:V.tabindex),J=d(),T=a(()=>x.value||I.value),q=a(()=>!0===R.value||!0!==H.value&&void 0),w=a(()=>Array.isArray(G.value)?function(e,a){if(null!=e&&a&&a.length)for(const l of a)if(C(e,l))return!0;return!1}(V.value,G.value):C(V.value,G.value)),P=a(()=>!["string","number","boolean"].includes(typeof V.value)||V.value),F=a({get:()=>w.value?P.value:null,set(e){Array.isArray(G.value)?G.value=[V.value]:G.value=V.value,k("change",e)}}),{modifiers:X}=t(V),Y=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-radio",X,a(()=>({valid:H.value,invalid:R.value,disabled:x.value,readonly:I.value}))),{HintSlot:Z,hasHintLabelOrSlot:ee,hasInvalidLabelOrSlot:ae,hintSlotScope:le}=function(e,l){const t=a(()=>i(e)?e.value:e),r=a(()=>K(t.value.invalidLabel)),u=a(()=>K(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))),b=a(()=>!v.value&&!f.value&&Boolean(t.value.valid&&(l.valid||u.value))),c=a(()=>!v.value&&!f.value&&!b.value&&Boolean(l.hint||d.value)),g=a(()=>f.value||b.value||v.value||c.value),y=a(()=>({modelValue:t.value.modelValue,valid:t.value.valid,invalid:t.value.invalid,loading:t.value.loading})),h=n({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:g,invalidLabel:r,validLabel:u,loadingLabel:s,hintLabel:d,hasInvalidLabelOrSlot:f,hasValidLabelOrSlot:b,hasLoadingLabelOrSlot:v,hasHintLabelOrSlot:c}),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:c,hasValidLabelOrSlot:b,hasLoadingLabelOrSlot:v,hintSlotScope:y,HintSlot:h}}(N,B);return(e,a)=>(f(),v("label",{class:b(u(Y)),for:u(_)},[c(h("input",{id:u(_),ref_key:"input",ref:J,"onUpdate:modelValue":a[0]||(a[0]=e=>i(F)?F.value=e:null),type:"radio",class:"vv-radio__input",name:e.name,disabled:u(T),value:u(P),tabindex:u(D),"aria-invalid":u(q),"aria-describedby":u(ee)?u(E):void 0,"aria-errormessage":u(ae)?u(E):void 0},null,8,W),[[p,u(F)]]),g(e.$slots,"default",{value:u(G)},()=>[m(S(e.label),1)]),y(u(Z),{id:u(E),class:"vv-radio__hint"},L({_:2},[e.$slots.hint?{name:"hint",fn:O(()=>[g(e.$slots,"hint",$(A(u(le))))]),key:"0"}:void 0,e.$slots.loading?{name:"loading",fn:O(()=>[g(e.$slots,"loading",$(A(u(le))))]),key:"1"}:void 0,e.$slots.valid?{name:"valid",fn:O(()=>[g(e.$slots,"valid",$(A(u(le))))]),key:"2"}:void 0,e.$slots.invalid?{name:"invalid",fn:O(()=>[g(e.$slots,"invalid",$(A(u(le))))]),key:"3"}:void 0]),1032,["id"])],10,Q))}});export{X as default};
@@ -1,4 +1,4 @@
1
- declare const _default: __VLS_WithSlots<import("vue").DefineComponent<globalThis.ExtractPropTypes<{
1
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<globalThis.ExtractPropTypes<{
2
2
  value: {
3
3
  type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
4
4
  default: undefined;
@@ -139,7 +139,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<globalThis
139
139
  tabindex: string | number;
140
140
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
141
141
  default?: (props: {
142
- value: string | number | boolean | Record<string, any>;
142
+ value: unknown;
143
143
  }) => any;
144
144
  } & {
145
145
  hint?: (props: {
@@ -170,6 +170,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<globalThis
170
170
  loading: boolean;
171
171
  }) => any;
172
172
  }>;
173
+ declare const _default: typeof __VLS_export;
173
174
  export default _default;
174
175
  type __VLS_WithSlots<T, S> = T & {
175
176
  new (): {