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