@volverjs/ui-vue 0.0.5-beta.2 → 0.0.5-beta.3

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 (30) hide show
  1. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +7 -1
  2. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  3. package/dist/components/VvCombobox/VvCombobox.es.js +157 -61
  4. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  5. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +0 -8
  6. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +6 -0
  7. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +237 -0
  8. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -0
  9. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +7 -1
  10. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  11. package/dist/components/VvSelect/VvSelect.es.js +42 -10
  12. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  13. package/dist/components/VvSelect/VvSelect.vue.d.ts +4 -3
  14. package/dist/components/index.es.js +227 -131
  15. package/dist/components/index.umd.js +1 -1
  16. package/dist/composables/useOptions.d.ts +1 -0
  17. package/dist/icons.es.js +3 -3
  18. package/dist/icons.umd.js +1 -1
  19. package/dist/resolvers/unplugin.es.js +2 -1
  20. package/dist/resolvers/unplugin.umd.js +1 -1
  21. package/package.json +9 -1
  22. package/src/assets/icons/detailed.json +1 -1
  23. package/src/assets/icons/normal.json +1 -1
  24. package/src/assets/icons/simple.json +1 -1
  25. package/src/components/VvCombobox/VvCombobox.vue +80 -25
  26. package/src/components/VvDropdown/VvDropdownOptgroup.vue +18 -0
  27. package/src/components/VvSelect/VvSelect.vue +38 -10
  28. package/src/composables/useOptions.ts +6 -0
  29. package/src/resolvers/unplugin.ts +2 -1
  30. package/src/types/generic.d.ts +2 -1
@@ -124,10 +124,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
124
124
  padding: number;
125
125
  };
126
126
  };
127
- /**
128
- * Function triggered on input of checkbox or radio (multple or single mode)
129
- * @param event on input event (checkbox or radio input)
130
- */
131
127
  autoPlacement: {
132
128
  type: globalThis.PropType<boolean | Partial<import("@floating-ui/core").AutoPlacementOptions & {
133
129
  rootBoundary: import("@floating-ui/core").RootBoundary;
@@ -325,10 +321,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
325
321
  padding: number;
326
322
  };
327
323
  };
328
- /**
329
- * Function triggered on input of checkbox or radio (multple or single mode)
330
- * @param event on input event (checkbox or radio input)
331
- */
332
324
  autoPlacement: {
333
325
  type: globalThis.PropType<boolean | Partial<import("@floating-ui/core").AutoPlacementOptions & {
334
326
  rootBoundary: import("@floating-ui/core").RootBoundary;
@@ -0,0 +1,6 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ label: (StringConstructor | NumberConstructor)[];
3
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
4
+ label: (StringConstructor | NumberConstructor)[];
5
+ }>>, {}>;
6
+ export default _default;
@@ -0,0 +1,237 @@
1
+ import { defineComponent, openBlock, createElementBlock, toDisplayString } from "vue";
2
+ var Side = /* @__PURE__ */ ((Side2) => {
3
+ Side2["left"] = "left";
4
+ Side2["right"] = "right";
5
+ Side2["top"] = "top";
6
+ Side2["bottom"] = "bottom";
7
+ return Side2;
8
+ })(Side || {});
9
+ var Placement = /* @__PURE__ */ ((Placement2) => {
10
+ Placement2["topStart"] = "top-start";
11
+ Placement2["topEnd"] = "top-end";
12
+ Placement2["bottomStart"] = "bottom-start";
13
+ Placement2["bottomEnd"] = "bottom-end";
14
+ Placement2["leftStart"] = "left-start";
15
+ Placement2["leftEnd"] = "left-end";
16
+ Placement2["rightStart"] = "right-start";
17
+ Placement2["rightEnd"] = "right-end";
18
+ return Placement2;
19
+ })(Placement || {});
20
+ var Position = /* @__PURE__ */ ((Position2) => {
21
+ Position2["before"] = "before";
22
+ Position2["after"] = "after";
23
+ return Position2;
24
+ })(Position || {});
25
+ var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
26
+ ButtonType2["button"] = "button";
27
+ ButtonType2["submit"] = "submit";
28
+ ButtonType2["reset"] = "reset";
29
+ return ButtonType2;
30
+ })(ButtonType || {});
31
+ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
32
+ AnchorTarget2["_blank"] = "_blank";
33
+ AnchorTarget2["_self"] = "_self";
34
+ AnchorTarget2["_parent"] = "_parent";
35
+ AnchorTarget2["_top"] = "_top";
36
+ return AnchorTarget2;
37
+ })(AnchorTarget || {});
38
+ const LinkProps = {
39
+ /**
40
+ * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
41
+ * @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
42
+ */
43
+ to: {
44
+ type: [String, Object]
45
+ },
46
+ /**
47
+ * Anchor href
48
+ */
49
+ href: String,
50
+ /**
51
+ * Anchor target
52
+ */
53
+ target: {
54
+ type: String,
55
+ validator: (value) => Object.values(AnchorTarget).includes(value)
56
+ },
57
+ /**
58
+ * Anchor rel
59
+ */
60
+ rel: {
61
+ type: String,
62
+ default: "noopener noreferrer"
63
+ }
64
+ };
65
+ const DisabledProps = {
66
+ /**
67
+ * Whether the form control is disabled
68
+ */
69
+ disabled: Boolean
70
+ };
71
+ const ActiveProps = {
72
+ /**
73
+ * Whether the item is active
74
+ */
75
+ active: Boolean
76
+ };
77
+ const PressedProps = {
78
+ /**
79
+ * Whether the item is pressed
80
+ */
81
+ pressed: Boolean
82
+ };
83
+ const LabelProps = {
84
+ /**
85
+ * The item label
86
+ */
87
+ label: [String, Number]
88
+ };
89
+ ({
90
+ /**
91
+ * VvIcon name or props
92
+ * @see VVIcon
93
+ */
94
+ icon: { type: [String, Object] },
95
+ /**
96
+ * VvIcon position
97
+ */
98
+ iconPosition: {
99
+ type: String,
100
+ default: Position.before,
101
+ validation: (value) => Object.values(Position).includes(value)
102
+ }
103
+ });
104
+ ({
105
+ /**
106
+ * Dropdown placement
107
+ */
108
+ placement: {
109
+ type: String,
110
+ default: Side.bottom,
111
+ validator: (value) => {
112
+ return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
113
+ }
114
+ },
115
+ /**
116
+ * Dropdown strategy
117
+ */
118
+ strategy: {
119
+ type: String,
120
+ default: "absolute",
121
+ validator: (value) => {
122
+ return ["fixed", "absolute"].includes(value);
123
+ }
124
+ },
125
+ /**
126
+ * Dropdown show / hide transition name
127
+ */
128
+ transitionName: {
129
+ type: String
130
+ },
131
+ /**
132
+ * Offset of the dropdown from the trigger
133
+ * @see https://floating-ui.com/docs/offset
134
+ */
135
+ offset: {
136
+ type: [Number, String, Object],
137
+ default: 0
138
+ },
139
+ /**
140
+ * Move dropdown to the side if there is no space in the default position
141
+ * @see https://floating-ui.com/docs/shift
142
+ */
143
+ shift: {
144
+ type: [Boolean, Object],
145
+ default: false
146
+ },
147
+ /**
148
+ * Flip dropdown position if there is no space in the default position
149
+ * @see https://floating-ui.com/docs/flip
150
+ */
151
+ flip: {
152
+ type: [Boolean, Object],
153
+ default: true
154
+ },
155
+ /**
156
+ * Size of the dropdown
157
+ * @see https://floating-ui.com/docs/size
158
+ */
159
+ size: {
160
+ type: [Boolean, Object],
161
+ default: () => ({ padding: 10 })
162
+ },
163
+ /**
164
+ * Automatically change the position of the dropdown
165
+ * @see https://floating-ui.com/docs/autoPlacement
166
+ */
167
+ autoPlacement: {
168
+ type: [Boolean, Object],
169
+ default: false
170
+ },
171
+ /**
172
+ * Add arrow to the dropdown
173
+ * @see https://floating-ui.com/docs/arrow
174
+ */
175
+ arrow: {
176
+ type: Boolean,
177
+ default: false
178
+ },
179
+ /**
180
+ * Close dropdown on click outside
181
+ */
182
+ autoClose: {
183
+ type: Boolean,
184
+ default: true
185
+ },
186
+ /**
187
+ * Autofocus first item on dropdown open
188
+ */
189
+ autofocusFirst: {
190
+ type: Boolean,
191
+ default: true
192
+ },
193
+ /**
194
+ * Set dropdown width to the same as the trigger
195
+ */
196
+ triggerWidth: {
197
+ type: Boolean
198
+ }
199
+ });
200
+ ({
201
+ ...DisabledProps,
202
+ ...LabelProps,
203
+ ...PressedProps,
204
+ ...ActiveProps,
205
+ ...LinkProps,
206
+ /**
207
+ * Button type
208
+ */
209
+ type: {
210
+ type: String,
211
+ default: ButtonType.button,
212
+ validator: (value) => Object.values(ButtonType).includes(value)
213
+ }
214
+ });
215
+ const _hoisted_1 = {
216
+ class: "vv-dropdown-optgroup",
217
+ role: "presentation",
218
+ tabindex: "-1"
219
+ };
220
+ const __default__ = {
221
+ name: "VvDropdownOptgroup"
222
+ };
223
+ const _sfc_main = /* @__PURE__ */ defineComponent({
224
+ ...__default__,
225
+ props: {
226
+ ...LabelProps
227
+ },
228
+ setup(__props) {
229
+ const props = __props;
230
+ return (_ctx, _cache) => {
231
+ return openBlock(), createElementBlock("li", _hoisted_1, toDisplayString(props.label), 1);
232
+ };
233
+ }
234
+ });
235
+ export {
236
+ _sfc_main as default
237
+ };
@@ -0,0 +1 @@
1
+ !function(o,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):(o="undefined"!=typeof globalThis?globalThis:o||self).VvDropdownOptgroup=e(o.vue)}(this,(function(o){"use strict";var e=(o=>(o.left="left",o.right="right",o.top="top",o.bottom="bottom",o))(e||{}),t=(o=>(o.before="before",o.after="after",o))(t||{}),n=(o=>(o.button="button",o.submit="submit",o.reset="reset",o))(n||{});Boolean,Boolean,Boolean;const r={label:[String,Number]};t.before,e.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,n.button;const l={class:"vv-dropdown-optgroup",role:"presentation",tabindex:"-1"};return o.defineComponent({name:"VvDropdownOptgroup",props:{...r},setup(e){const t=e;return(e,n)=>(o.openBlock(),o.createElementBlock("li",l,o.toDisplayString(t.label),1))}})}));
@@ -734,11 +734,17 @@ function useOptions(props) {
734
734
  return false;
735
735
  return typeof disabledKey.value === "function" ? disabledKey.value(option) : option[disabledKey.value];
736
736
  };
737
+ const getOptionGrouped = (option) => {
738
+ if (typeof option !== "object" && option !== null)
739
+ return [];
740
+ return option.options;
741
+ };
737
742
  return {
738
743
  options,
739
744
  getOptionLabel,
740
745
  getOptionValue,
741
- getOptionDisabled
746
+ getOptionDisabled,
747
+ getOptionGrouped
742
748
  };
743
749
  }
744
750
  const _hoisted_1 = ["textContent"];
@@ -1 +1 @@
1
- !function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadioGroup=l(e.vue,e.core,e.nanoid)}(this,(function(e,l,n){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),o=(e=>(e.before="before",e.after="after",e))(o||{}),a=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(a||{});const u=Symbol.for("radioGroup");function i(e,l,n){return n?d(e,n)===d(l,n):r(e,l)}function r(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const n=Array.isArray(e),t=Array.isArray(l);let o,a,u;if(n&&t){if(a=e.length,a!=l.length)return!1;for(o=a;0!=o--;)if(!r(e[o],l[o]))return!1;return!0}if(n!=t)return!1;const i=e instanceof Date,d=l instanceof Date;if(i!=d)return!1;if(i&&d)return e.getTime()==l.getTime();const v=e instanceof RegExp,s=l instanceof RegExp;if(v!=s)return!1;if(v&&s)return e.toString()==l.toString();const c=Object.keys(e);if(a=c.length,a!==Object.keys(l).length)return!1;for(o=a;0!=o--;)if(!Object.prototype.hasOwnProperty.call(l,c[o]))return!1;for(o=a;0!=o--;)if(u=c[o],!r(e[u],l[u]))return!1;return!0}return e!=e&&l!=l}function d(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const n=l.split(".");let t=e;for(let l=0,o=n.length;l<o;++l){if(null==e)return null;t=t[n[l]]}return t}}return null}function v(l){return null==(n=e.unref(l))||""===n||Array.isArray(n)&&0===n.length||!(n instanceof Date)&&"object"==typeof n&&0===Object.keys(n).length;var n}function s(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function c(n,t){const{invalid:o,valid:a,hint:u,loading:i}=t,{hintLabel:r,modelValue:c,valid:f,validLabel:p,invalid:m,invalidLabel:b,...y}=e.toRefs(n),g=d(y,"loading"),h=d(y,"loadingLabel"),S=e.computed((()=>!!m.value&&(!(!m.value||!o)||(!!((null==b?void 0:b.value)&&Array.isArray(b.value)&&b.value.length>0)||!(!(null==b?void 0:b.value)||v(b)))))),B=e.computed((()=>!!(r&&r.value||u))),V=e.computed((()=>!!(p&&p.value||a))),k=e.computed((()=>!!((null==g?void 0:g.value)&&i||(null==g?void 0:g.value)&&(null==h?void 0:h.value)))),A=e.computed((()=>B.value||V.value||S.value||k.value));return{hasInvalid:S,hasHint:B,hasValid:V,hasLoading:k,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(n){const t=e.computed((()=>{const e=l.toReactive({hintLabel:r,modelValue:c,valid:f,validLabel:p,invalid:m,invalidLabel:b,loading:g,loadingLabel:h,...n.params});return(null==m?void 0:m.value)?(null==o?void 0:o(e))||s(null==b?void 0:b.value)||(null==r?void 0:r.value):(null==f?void 0:f.value)?(null==a?void 0:a(e))||s(null==p?void 0:p.value)||(null==r?void 0:r.value):(null==g?void 0:g.value)?(null==i?void 0:i(e))||s(null==h?void 0:h.value)||(null==r?void 0:r.value):(null==u?void 0:u(e))||s(null==r?void 0:r.value)||(null==r?void 0:r.value)}));return{isVisible:A,hasInvalid:S,hasValid:V,hintContent:t}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}const f={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},m={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},g={modifiers:[String,Array]},h={hintLabel:{type:String,default:""}},S={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};o.before;const B={tabindex:{type:[String,Number],default:0}},V={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const k={...{...V,name:{type:String,required:!0}},...B,...f,...p,...h,...m,...y,...g,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},A={...f,...p,...S,...h,...m,...y,...g,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};a.button;const O=k;function j(l,n){const{id:t}=e.toRefs(l),{group:o,isInGroup:a,getGroupOrLocalRef:i}=function(l){const n=e.inject(l,void 0),t=e.computed((()=>!v(n)));return{group:n,isInGroup:t,getGroupOrLocalRef:function(l,t,o){if(null==n?void 0:n.value){const t=e.unref(n.value)[l];return e.computed({get:()=>null==t?void 0:t.value,set(e){t.value=e}})}const a=e.toRef(t,l);return e.computed({get:()=>a.value,set(e){o&&o(`update:${l}`,e)}})}}}(u),r=i("modelValue",l,n),d=i("valid",l),s=i("invalid",l),c=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))})),f=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))}));return{id:t,group:o,isInGroup:a,modelValue:r,valid:d,invalid:s,readonly:c,disabled:f}}function L(l,n,t){return e.computed((()=>{const o={[l]:!0},a="string"==typeof(null==n?void 0:n.value)?n.value.split(" "):null==n?void 0:n.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(o[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((n=>{o[`${l}--${n}`]=e.unref(t.value[n])})),o}))}const R=["for"],x=["id","name","disabled","value","tabindex","aria-invalid"],N=e.defineComponent({name:"VvRadio",props:O,emits:["click","update:modelValue","change","blur"],setup(l,{emit:t}){const o=l,a=e.useSlots(),{id:u,disabled:r,readonly:d,modelValue:v,valid:s,invalid:f}=j(o,t),p=(l=>e.computed((()=>String((null==l?void 0:l.value)||n.nanoid()))))(u),m=e.computed((()=>y.value?-1:o.tabindex)),b=e.ref(),y=e.computed((()=>r.value||d.value)),g=e.computed((()=>!0===f.value||!0!==s.value&&void 0)),h=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const n of l)if(i(e,n))return!0;return!1}(o.value,v.value):i(o.value,v.value))),S=e.computed((()=>!["string","number","boolean"].includes(typeof o.value)||o.value)),B=e.computed({get:()=>h.value?S.value:null,set(e){Array.isArray(v.value)?v.value=[o.value]:v.value=o.value,t("change",e)}}),{modifiers:V}=e.toRefs(o),k=L("vv-radio",V,e.computed((()=>({valid:s.value,invalid:f.value,disabled:r.value,readonly:d.value})))),{HintSlot:A}=c(o,a);return(l,n)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(k)),for:e.unref(p)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(p),ref_key:"input",ref:b,"onUpdate:modelValue":n[0]||(n[0]=l=>e.isRef(B)?B.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(y),value:e.unref(S),tabindex:e.unref(m),"aria-invalid":e.unref(g)},null,8,x),[[e.vModelRadio,e.unref(B)]]),e.renderSlot(l.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(A),{class:"vv-radio__hint",params:{value:e.unref(v)}},null,8,["params"])],10,R))}}),E=A;const _=["textContent"],C={class:"vv-radio-group__wrapper"};return e.defineComponent({name:"VvRadioGroup",props:E,emits:["update:modelValue","change"],setup(n,{emit:t}){const o=n,a=e.useSlots(),i=l.useVModel(o,"modelValue",t),{disabled:r,readonly:d,vertical:v,valid:s,invalid:f,modifiers:p}=e.toRefs(o);!function(l){if(Object.keys(l).some((n=>"key"!==n&&!e.isRef(l[n]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:u,modelValue:i,disabled:r,readonly:d,valid:s,invalid:f});const{getOptionLabel:m,getOptionValue:b}=function(l){const{options:n,labelKey:t,valueKey:o,disabledKey:a}=e.toRefs(l);return{options:n,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:"function"==typeof t.value?t.value(e):e[t.value],getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof o.value?o.value(e):e[o.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof a.value?a.value(e):e[a.value])}}(o),y=L("vv-radio-group",p,e.computed((()=>({disabled:r.value,readonly:d.value,horizontal:!v.value,valid:s.value,invalid:f.value})))),{HintSlot:g}=c(o,a);return(l,n)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,_)):e.createCommentVNode("",!0),e.createElementVNode("div",C,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,n)=>(e.openBlock(),e.createBlock(N,e.mergeProps({key:n},((e,l)=>({id:`${o.name}_opt${l}`,name:o.name,label:m(e),value:b(e)}))(l,n)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(g),{class:"vv-radio-group__hint"})],2))}})}));
1
+ !function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadioGroup=l(e.vue,e.core,e.nanoid)}(this,(function(e,l,n){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),o=(e=>(e.before="before",e.after="after",e))(o||{}),a=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(a||{});const u=Symbol.for("radioGroup");function i(e,l,n){return n?d(e,n)===d(l,n):r(e,l)}function r(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const n=Array.isArray(e),t=Array.isArray(l);let o,a,u;if(n&&t){if(a=e.length,a!=l.length)return!1;for(o=a;0!=o--;)if(!r(e[o],l[o]))return!1;return!0}if(n!=t)return!1;const i=e instanceof Date,d=l instanceof Date;if(i!=d)return!1;if(i&&d)return e.getTime()==l.getTime();const v=e instanceof RegExp,s=l instanceof RegExp;if(v!=s)return!1;if(v&&s)return e.toString()==l.toString();const c=Object.keys(e);if(a=c.length,a!==Object.keys(l).length)return!1;for(o=a;0!=o--;)if(!Object.prototype.hasOwnProperty.call(l,c[o]))return!1;for(o=a;0!=o--;)if(u=c[o],!r(e[u],l[u]))return!1;return!0}return e!=e&&l!=l}function d(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const n=l.split(".");let t=e;for(let l=0,o=n.length;l<o;++l){if(null==e)return null;t=t[n[l]]}return t}}return null}function v(l){return null==(n=e.unref(l))||""===n||Array.isArray(n)&&0===n.length||!(n instanceof Date)&&"object"==typeof n&&0===Object.keys(n).length;var n}function s(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function c(n,t){const{invalid:o,valid:a,hint:u,loading:i}=t,{hintLabel:r,modelValue:c,valid:f,validLabel:p,invalid:m,invalidLabel:b,...y}=e.toRefs(n),g=d(y,"loading"),h=d(y,"loadingLabel"),S=e.computed((()=>!!m.value&&(!(!m.value||!o)||(!!((null==b?void 0:b.value)&&Array.isArray(b.value)&&b.value.length>0)||!(!(null==b?void 0:b.value)||v(b)))))),B=e.computed((()=>!!(r&&r.value||u))),V=e.computed((()=>!!(p&&p.value||a))),k=e.computed((()=>!!((null==g?void 0:g.value)&&i||(null==g?void 0:g.value)&&(null==h?void 0:h.value)))),A=e.computed((()=>B.value||V.value||S.value||k.value));return{hasInvalid:S,hasHint:B,hasValid:V,hasLoading:k,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(n){const t=e.computed((()=>{const e=l.toReactive({hintLabel:r,modelValue:c,valid:f,validLabel:p,invalid:m,invalidLabel:b,loading:g,loadingLabel:h,...n.params});return(null==m?void 0:m.value)?(null==o?void 0:o(e))||s(null==b?void 0:b.value)||(null==r?void 0:r.value):(null==f?void 0:f.value)?(null==a?void 0:a(e))||s(null==p?void 0:p.value)||(null==r?void 0:r.value):(null==g?void 0:g.value)?(null==i?void 0:i(e))||s(null==h?void 0:h.value)||(null==r?void 0:r.value):(null==u?void 0:u(e))||s(null==r?void 0:r.value)||(null==r?void 0:r.value)}));return{isVisible:A,hasInvalid:S,hasValid:V,hintContent:t}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}const f={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},m={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},g={modifiers:[String,Array]},h={hintLabel:{type:String,default:""}},S={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};o.before;const B={tabindex:{type:[String,Number],default:0}},V={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const k={...{...V,name:{type:String,required:!0}},...B,...f,...p,...h,...m,...y,...g,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},A={...f,...p,...S,...h,...m,...y,...g,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};a.button;const O=k;function j(l,n){const{id:t}=e.toRefs(l),{group:o,isInGroup:a,getGroupOrLocalRef:i}=function(l){const n=e.inject(l,void 0),t=e.computed((()=>!v(n)));return{group:n,isInGroup:t,getGroupOrLocalRef:function(l,t,o){if(null==n?void 0:n.value){const t=e.unref(n.value)[l];return e.computed({get:()=>null==t?void 0:t.value,set(e){t.value=e}})}const a=e.toRef(t,l);return e.computed({get:()=>a.value,set(e){o&&o(`update:${l}`,e)}})}}}(u),r=i("modelValue",l,n),d=i("valid",l),s=i("invalid",l),c=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))})),f=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))}));return{id:t,group:o,isInGroup:a,modelValue:r,valid:d,invalid:s,readonly:c,disabled:f}}function L(l,n,t){return e.computed((()=>{const o={[l]:!0},a="string"==typeof(null==n?void 0:n.value)?n.value.split(" "):null==n?void 0:n.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(o[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((n=>{o[`${l}--${n}`]=e.unref(t.value[n])})),o}))}const R=["for"],x=["id","name","disabled","value","tabindex","aria-invalid"],N=e.defineComponent({name:"VvRadio",props:O,emits:["click","update:modelValue","change","blur"],setup(l,{emit:t}){const o=l,a=e.useSlots(),{id:u,disabled:r,readonly:d,modelValue:v,valid:s,invalid:f}=j(o,t),p=(l=>e.computed((()=>String((null==l?void 0:l.value)||n.nanoid()))))(u),m=e.computed((()=>y.value?-1:o.tabindex)),b=e.ref(),y=e.computed((()=>r.value||d.value)),g=e.computed((()=>!0===f.value||!0!==s.value&&void 0)),h=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const n of l)if(i(e,n))return!0;return!1}(o.value,v.value):i(o.value,v.value))),S=e.computed((()=>!["string","number","boolean"].includes(typeof o.value)||o.value)),B=e.computed({get:()=>h.value?S.value:null,set(e){Array.isArray(v.value)?v.value=[o.value]:v.value=o.value,t("change",e)}}),{modifiers:V}=e.toRefs(o),k=L("vv-radio",V,e.computed((()=>({valid:s.value,invalid:f.value,disabled:r.value,readonly:d.value})))),{HintSlot:A}=c(o,a);return(l,n)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(k)),for:e.unref(p)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(p),ref_key:"input",ref:b,"onUpdate:modelValue":n[0]||(n[0]=l=>e.isRef(B)?B.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(y),value:e.unref(S),tabindex:e.unref(m),"aria-invalid":e.unref(g)},null,8,x),[[e.vModelRadio,e.unref(B)]]),e.renderSlot(l.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(A),{class:"vv-radio__hint",params:{value:e.unref(v)}},null,8,["params"])],10,R))}}),E=A;const _=["textContent"],C={class:"vv-radio-group__wrapper"};return e.defineComponent({name:"VvRadioGroup",props:E,emits:["update:modelValue","change"],setup(n,{emit:t}){const o=n,a=e.useSlots(),i=l.useVModel(o,"modelValue",t),{disabled:r,readonly:d,vertical:v,valid:s,invalid:f,modifiers:p}=e.toRefs(o);!function(l){if(Object.keys(l).some((n=>"key"!==n&&!e.isRef(l[n]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:u,modelValue:i,disabled:r,readonly:d,valid:s,invalid:f});const{getOptionLabel:m,getOptionValue:b}=function(l){const{options:n,labelKey:t,valueKey:o,disabledKey:a}=e.toRefs(l);return{options:n,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:"function"==typeof t.value?t.value(e):e[t.value],getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof o.value?o.value(e):e[o.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof a.value?a.value(e):e[a.value]),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options}}(o),y=L("vv-radio-group",p,e.computed((()=>({disabled:r.value,readonly:d.value,horizontal:!v.value,valid:s.value,invalid:f.value})))),{HintSlot:g}=c(o,a);return(l,n)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,_)):e.createCommentVNode("",!0),e.createElementVNode("div",C,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,n)=>(e.openBlock(),e.createBlock(N,e.mergeProps({key:n},((e,l)=>({id:`${o.name}_opt${l}`,name:o.name,label:m(e),value:b(e)}))(l,n)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(g),{class:"vv-radio-group__hint"})],2))}})}));
@@ -787,11 +787,17 @@ function useOptions(props) {
787
787
  return false;
788
788
  return typeof disabledKey.value === "function" ? disabledKey.value(option) : option[disabledKey.value];
789
789
  };
790
+ const getOptionGrouped = (option) => {
791
+ if (typeof option !== "object" && option !== null)
792
+ return [];
793
+ return option.options;
794
+ };
790
795
  return {
791
796
  options,
792
797
  getOptionLabel,
793
798
  getOptionValue,
794
- getOptionDisabled
799
+ getOptionDisabled,
800
+ getOptionGrouped
795
801
  };
796
802
  }
797
803
  const _hoisted_1 = ["for"];
@@ -804,7 +810,9 @@ const _hoisted_4 = { class: "vv-select__inner" };
804
810
  const _hoisted_5 = ["id"];
805
811
  const _hoisted_6 = ["disabled", "hidden"];
806
812
  const _hoisted_7 = ["disabled", "value"];
807
- const _hoisted_8 = {
813
+ const _hoisted_8 = ["disabled", "label"];
814
+ const _hoisted_9 = ["disabled", "value"];
815
+ const _hoisted_10 = {
808
816
  key: 1,
809
817
  class: "vv-select__input-after"
810
818
  };
@@ -896,7 +904,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
896
904
  invalid: props.invalid,
897
905
  modelValue: props.modelValue
898
906
  }));
899
- const { getOptionLabel, getOptionValue, getOptionDisabled } = useOptions(props);
907
+ const {
908
+ getOptionLabel,
909
+ getOptionValue,
910
+ getOptionDisabled,
911
+ getOptionGrouped
912
+ } = useOptions(props);
900
913
  const localModelValue = computed({
901
914
  get: () => {
902
915
  return props.modelValue;
@@ -908,6 +921,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
908
921
  emit("update:modelValue", newValue);
909
922
  }
910
923
  });
924
+ const isGroup = (option) => {
925
+ if (typeof option === "string")
926
+ return false;
927
+ return option && option.options && option.options.length > 0;
928
+ };
911
929
  return (_ctx, _cache) => {
912
930
  return openBlock(), createElementBlock("div", {
913
931
  class: normalizeClass(unref(bemCssClasses))
@@ -938,12 +956,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
938
956
  hidden: !_ctx.unselectable
939
957
  }, toDisplayString(_ctx.placeholder), 9, _hoisted_6)) : createCommentVNode("", true),
940
958
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (option, index) => {
941
- return openBlock(), createElementBlock("option", {
942
- key: index,
943
- disabled: unref(getOptionDisabled)(option),
944
- value: unref(getOptionValue)(option)
945
- }, toDisplayString(unref(getOptionLabel)(option)), 9, _hoisted_7);
946
- }), 128))
959
+ return openBlock(), createElementBlock(Fragment, null, [
960
+ !isGroup(option) ? (openBlock(), createElementBlock("option", {
961
+ key: index,
962
+ disabled: unref(getOptionDisabled)(option),
963
+ value: unref(getOptionValue)(option)
964
+ }, toDisplayString(unref(getOptionLabel)(option)), 9, _hoisted_7)) : (openBlock(), createElementBlock("optgroup", {
965
+ key: `group-${index}`,
966
+ disabled: unref(getOptionDisabled)(option),
967
+ label: unref(getOptionLabel)(option)
968
+ }, [
969
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptionGrouped)(option), (item, i) => {
970
+ return openBlock(), createElementBlock("option", {
971
+ key: `group-${index}-item-${i}`,
972
+ disabled: unref(getOptionDisabled)(item),
973
+ value: unref(getOptionValue)(item)
974
+ }, toDisplayString(unref(getOptionLabel)(item)), 9, _hoisted_9);
975
+ }), 128))
976
+ ], 8, _hoisted_8))
977
+ ], 64);
978
+ }), 256))
947
979
  ], 16, _hoisted_5), [
948
980
  [vModelSelect, unref(localModelValue)]
949
981
  ]),
@@ -952,7 +984,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
952
984
  class: "vv-select__icon vv-select__icon-after"
953
985
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true)
954
986
  ]),
955
- _ctx.$slots.after ? (openBlock(), createElementBlock("div", _hoisted_8, [
987
+ _ctx.$slots.after ? (openBlock(), createElementBlock("div", _hoisted_10, [
956
988
  renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps(unref(slotProps))))
957
989
  ])) : createCommentVNode("", true)
958
990
  ]),
@@ -1 +1 @@
1
- !function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@iconify/vue"),require("@vueuse/core"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","@vueuse/core","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvSelect=l(e.vue,e.vue$1,e.core,e.nanoid)}(this,(function(e,l,o,n){"use strict";const t={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),u=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(u||{});const r=Symbol.for("volver");function d(l,o,n){return e.computed((()=>{const t={[l]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(t[`${l}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((o=>{t[`${l}--${o}`]=e.unref(n.value[o])})),t}))}const c=e.defineComponent({name:"VvIcon",props:t,setup(o){const n=o,t=e.ref(!0),a=e.inject(r),{modifiers:i}=e.toRefs(n),u=d("vv-icon",i),c=e.computed((()=>n.provider||(null==a?void 0:a.iconsProvider))),s=e.computed((()=>{const e=n.name??"",o=`@${c.value}:${n.prefix}:${n.name}`;return l.iconExists(e)?e:l.iconExists(o)?o:(null==a?void 0:a.iconsCollections.find((o=>{const n=`@${c.value}:${o.prefix}:${e}`;if(l.iconExists(n))return n})))||e}));function v(e){const o=function(e){let l=null;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),t=(null==o?void 0:o.innerHTML.trim())||"";o&&t&&l.addIcon(`@${c.value}:${n.prefix}:${n.name}`,{body:t,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return a&&(n.src&&!l.iconExists(`@${c.value}:${n.prefix}:${n.name}`)?(t.value=!1,a.fetchIcon(n.src).then((e=>{e&&(v(e),t.value=!0)})).catch((e=>{throw new Error(`During fetch icon: ${null==e?void 0:e.message}`)}))):n.svg&&v(n.svg)),(o,n)=>e.unref(t)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:o.rotate,color:o.color,onLoad:o.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("",!0)}});function s(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const o=l.split(".");let n=e;for(let l=0,t=o.length;l<t;++l){if(null==e)return null;n=n[o[l]]}return n}}return null}function v(l){return null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function f(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const p={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},y=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},B={modifiers:[String,Array]},S={hintLabel:{type:String,default:""}},V={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}},k={icon:{type:[String,Object]},iconPosition:{type:String,default:i.before,validation:e=>Object.values(i).includes(e)}},$={tabindex:{type:[String,Number],default:0}},w={floating:Boolean},L={unselectable:{type:Boolean,default:!0}},N={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const x={...N,name:{type:String,required:!0}},A={autofocus:Boolean},E={autocomplete:{type:String,default:"off"}};u.button;const I={...x,...A,...E,...$,...p,...m,...S,...b,...g,...h,...B,...V,...k,...w,...L,...y,multiple:Boolean,required:Boolean,size:[String,Number],modelValue:{type:[String,Number,Boolean,Object,Array],default:void 0},placeholder:String};const O=["for"],_={class:"vv-select__wrapper"},j={key:0,class:"vv-select__input-before"},C={class:"vv-select__inner"},F=["id"],P=["disabled","hidden"],q=["disabled","value"],D={key:1,class:"vv-select__input-after"};return e.defineComponent({name:"VvSelect",props:I,emits:["update:modelValue","focus","blur"],setup(l,{emit:t}){const u=l,r=e.useSlots(),p=e.ref(),{HintSlot:m,hasHint:b,hasInvalid:g}=function(l,n){const{invalid:t,valid:a,hint:i,loading:u}=n,{hintLabel:r,modelValue:d,valid:c,validLabel:p,invalid:m,invalidLabel:b,...g}=e.toRefs(l),y=s(g,"loading"),h=s(g,"loadingLabel"),B=e.computed((()=>!(!m.value||(!m.value||!t)&&!((null==b?void 0:b.value)&&Array.isArray(b.value)&&b.value.length>0)&&(!(null==b?void 0:b.value)||v(b))))),S=e.computed((()=>!!(r&&r.value||i))),V=e.computed((()=>!!(p&&p.value||a))),k=e.computed((()=>!!((null==y?void 0:y.value)&&u||(null==y?void 0:y.value)&&(null==h?void 0:h.value)))),$=e.computed((()=>S.value||V.value||B.value||k.value));return{hasInvalid:B,hasHint:S,hasValid:V,hasLoading:k,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(l){const n=e.computed((()=>{const e=o.toReactive({hintLabel:r,modelValue:d,valid:c,validLabel:p,invalid:m,invalidLabel:b,loading:y,loadingLabel:h,...l.params});return(null==m?void 0:m.value)?(null==t?void 0:t(e))||f(null==b?void 0:b.value)||(null==r?void 0:r.value):(null==c?void 0:c.value)?(null==a?void 0:a(e))||f(null==p?void 0:p.value)||(null==r?void 0:r.value):(null==y?void 0:y.value)?(null==u?void 0:u(e))||f(null==h?void 0:h.value)||(null==r?void 0:r.value):(null==i?void 0:i(e))||f(null==r?void 0:r.value)||(null==r?void 0:r.value)}));return{isVisible:$,hasInvalid:B,hasValid:V,hintContent:n}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}(u,r),{id:y,modifiers:h,disabled:B,readonly:S,loading:V,icon:k,iconPosition:$,invalid:w,valid:L,floating:N,multiple:x}=e.toRefs(u),A=(l=>e.computed((()=>String((null==l?void 0:l.value)||n.nanoid()))))(y),E=e.computed((()=>`${A.value}-hint`)),{focused:I}=function(l,n){const{focused:t}=o.useFocus(l);return e.watch(t,(o=>{n(o?"focus":"blur",e.unref(l))})),{focused:t}}(p,t),z=o.useElementVisibility(p);e.watch(z,(e=>{e&&u.autofocus&&(I.value=!0)}));const{hasIcon:R,hasIconBefore:H,hasIconAfter:K}=function(l,o){const n=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.before))),t=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.after))),u=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.left))),r=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.right))),d=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.top))),c=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),hasIconLeft:u,hasIconRight:r,hasIconTop:d,hasIconBottom:c,hasIconBefore:n,hasIconAfter:t}}(k,$),M=e.computed((()=>!v(u.modelValue))),T=e.computed((()=>u.disabled||u.readonly)),J=e.computed((()=>T.value?-1:u.tabindex)),U=e.computed((()=>!0===u.invalid||!0!==u.valid&&void 0)),G=d("vv-select",h,e.computed((()=>({valid:L.value,invalid:w.value,loading:V.value,disabled:B.value,readonly:S.value,"icon-before":H.value,"icon-after":K.value,dirty:M.value,focus:I.value,floating:N.value,multiple:x.value})))),Q=e.computed((()=>({name:u.name,tabindex:J.value,disabled:T.value,required:u.required,size:u.size,autocomplete:u.autocomplete,multiple:u.multiple,"aria-invalid":U.value,"aria-describedby":!g.value&&b.value?E.value:void 0,"aria-errormessage":g.value?E.value:void 0}))),W=e.computed((()=>({valid:u.valid,invalid:u.invalid,modelValue:u.modelValue}))),{getOptionLabel:X,getOptionValue:Y,getOptionDisabled:Z}=function(l){const{options:o,labelKey:n,valueKey:t,disabledKey:a}=e.toRefs(l);return{options:o,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):e[n.value],getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof t.value?t.value(e):e[t.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof a.value?a.value(e):e[a.value])}}(u),ee=e.computed({get:()=>u.modelValue,set:e=>{Array.isArray(e)&&(e=e.filter((e=>void 0!==e))),t("update:modelValue",e)}});return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(G))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(A)},e.toDisplayString(l.label),9,O)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[l.$slots.before?(e.openBlock(),e.createElementBlock("div",j,[e.renderSlot(l.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(W))))])):e.createCommentVNode("",!0),e.createElementVNode("div",C,[e.unref(H)?(e.openBlock(),e.createBlock(c,e.mergeProps({key:0,class:"vv-select__icon"},e.unref(R)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({id:e.unref(A),ref_key:"select",ref:p,"onUpdate:modelValue":o[0]||(o[0]=l=>e.isRef(ee)?ee.value=l:null)},e.unref(Q)),[l.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,value:void 0,disabled:!l.unselectable,hidden:!l.unselectable},e.toDisplayString(l.placeholder),9,P)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,((l,o)=>(e.openBlock(),e.createElementBlock("option",{key:o,disabled:e.unref(Z)(l),value:e.unref(Y)(l)},e.toDisplayString(e.unref(X)(l)),9,q)))),128))],16,F),[[e.vModelSelect,e.unref(ee)]]),e.unref(K)?(e.openBlock(),e.createBlock(c,e.mergeProps({key:1,class:"vv-select__icon vv-select__icon-after"},e.unref(R)),null,16)):e.createCommentVNode("",!0)]),l.$slots.after?(e.openBlock(),e.createElementBlock("div",D,[e.renderSlot(l.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(W))))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(m),{id:e.unref(E),class:"vv-select__hint"},null,8,["id"])],2))}})}));
1
+ !function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@iconify/vue"),require("@vueuse/core"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","@vueuse/core","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvSelect=l(e.vue,e.vue$1,e.core,e.nanoid)}(this,(function(e,l,o,n){"use strict";const t={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{});const u=Symbol.for("volver");function d(l,o,n){return e.computed((()=>{const t={[l]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(t[`${l}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((o=>{t[`${l}--${o}`]=e.unref(n.value[o])})),t}))}const c=e.defineComponent({name:"VvIcon",props:t,setup(o){const n=o,t=e.ref(!0),a=e.inject(u),{modifiers:i}=e.toRefs(n),r=d("vv-icon",i),c=e.computed((()=>n.provider||(null==a?void 0:a.iconsProvider))),s=e.computed((()=>{const e=n.name??"",o=`@${c.value}:${n.prefix}:${n.name}`;return l.iconExists(e)?e:l.iconExists(o)?o:(null==a?void 0:a.iconsCollections.find((o=>{const n=`@${c.value}:${o.prefix}:${e}`;if(l.iconExists(n))return n})))||e}));function v(e){const o=function(e){let l=null;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),t=(null==o?void 0:o.innerHTML.trim())||"";o&&t&&l.addIcon(`@${c.value}:${n.prefix}:${n.name}`,{body:t,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return a&&(n.src&&!l.iconExists(`@${c.value}:${n.prefix}:${n.name}`)?(t.value=!1,a.fetchIcon(n.src).then((e=>{e&&(v(e),t.value=!0)})).catch((e=>{throw new Error(`During fetch icon: ${null==e?void 0:e.message}`)}))):n.svg&&v(n.svg)),(o,n)=>e.unref(t)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(r)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:o.rotate,color:o.color,onLoad:o.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("",!0)}});function s(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const o=l.split(".");let n=e;for(let l=0,t=o.length;l<t;++l){if(null==e)return null;n=n[o[l]]}return n}}return null}function v(l){return null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function p(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const f={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},g={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},b={disabled:Boolean},y=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},B={modifiers:[String,Array]},S={hintLabel:{type:String,default:""}},k={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}},V={icon:{type:[String,Object]},iconPosition:{type:String,default:i.before,validation:e=>Object.values(i).includes(e)}},$={tabindex:{type:[String,Number],default:0}},L={floating:Boolean},w={unselectable:{type:Boolean,default:!0}},E={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const N={...E,name:{type:String,required:!0}},O={autofocus:Boolean},x={autocomplete:{type:String,default:"off"}};r.button;const A={...N,...O,...x,...$,...f,...m,...S,...g,...b,...h,...B,...k,...V,...L,...w,...y,multiple:Boolean,required:Boolean,size:[String,Number],modelValue:{type:[String,Number,Boolean,Object,Array],default:void 0},placeholder:String};const I=["for"],_={class:"vv-select__wrapper"},j={key:0,class:"vv-select__input-before"},F={class:"vv-select__inner"},C=["id"],P=["disabled","hidden"],D=["disabled","value"],q=["disabled","label"],z=["disabled","value"],R={key:1,class:"vv-select__input-after"};return e.defineComponent({name:"VvSelect",props:A,emits:["update:modelValue","focus","blur"],setup(l,{emit:t}){const r=l,u=e.useSlots(),f=e.ref(),{HintSlot:m,hasHint:g,hasInvalid:b}=function(l,n){const{invalid:t,valid:a,hint:i,loading:r}=n,{hintLabel:u,modelValue:d,valid:c,validLabel:f,invalid:m,invalidLabel:g,...b}=e.toRefs(l),y=s(b,"loading"),h=s(b,"loadingLabel"),B=e.computed((()=>!(!m.value||(!m.value||!t)&&!((null==g?void 0:g.value)&&Array.isArray(g.value)&&g.value.length>0)&&(!(null==g?void 0:g.value)||v(g))))),S=e.computed((()=>!!(u&&u.value||i))),k=e.computed((()=>!!(f&&f.value||a))),V=e.computed((()=>!!((null==y?void 0:y.value)&&r||(null==y?void 0:y.value)&&(null==h?void 0:h.value)))),$=e.computed((()=>S.value||k.value||B.value||V.value));return{hasInvalid:B,hasHint:S,hasValid:k,hasLoading:V,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(l){const n=e.computed((()=>{const e=o.toReactive({hintLabel:u,modelValue:d,valid:c,validLabel:f,invalid:m,invalidLabel:g,loading:y,loadingLabel:h,...l.params});return(null==m?void 0:m.value)?(null==t?void 0:t(e))||p(null==g?void 0:g.value)||(null==u?void 0:u.value):(null==c?void 0:c.value)?(null==a?void 0:a(e))||p(null==f?void 0:f.value)||(null==u?void 0:u.value):(null==y?void 0:y.value)?(null==r?void 0:r(e))||p(null==h?void 0:h.value)||(null==u?void 0:u.value):(null==i?void 0:i(e))||p(null==u?void 0:u.value)||(null==u?void 0:u.value)}));return{isVisible:$,hasInvalid:B,hasValid:k,hintContent:n}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}(r,u),{id:y,modifiers:h,disabled:B,readonly:S,loading:k,icon:V,iconPosition:$,invalid:L,valid:w,floating:E,multiple:N}=e.toRefs(r),O=(l=>e.computed((()=>String((null==l?void 0:l.value)||n.nanoid()))))(y),x=e.computed((()=>`${O.value}-hint`)),{focused:A}=function(l,n){const{focused:t}=o.useFocus(l);return e.watch(t,(o=>{n(o?"focus":"blur",e.unref(l))})),{focused:t}}(f,t),H=o.useElementVisibility(f);e.watch(H,(e=>{e&&r.autofocus&&(A.value=!0)}));const{hasIcon:K,hasIconBefore:M,hasIconAfter:T}=function(l,o){const n=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.before))),t=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.after))),r=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.left))),u=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.right))),d=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.top))),c=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===a.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),hasIconLeft:r,hasIconRight:u,hasIconTop:d,hasIconBottom:c,hasIconBefore:n,hasIconAfter:t}}(V,$),G=e.computed((()=>!v(r.modelValue))),J=e.computed((()=>r.disabled||r.readonly)),U=e.computed((()=>J.value?-1:r.tabindex)),Q=e.computed((()=>!0===r.invalid||!0!==r.valid&&void 0)),W=d("vv-select",h,e.computed((()=>({valid:w.value,invalid:L.value,loading:k.value,disabled:B.value,readonly:S.value,"icon-before":M.value,"icon-after":T.value,dirty:G.value,focus:A.value,floating:E.value,multiple:N.value})))),X=e.computed((()=>({name:r.name,tabindex:U.value,disabled:J.value,required:r.required,size:r.size,autocomplete:r.autocomplete,multiple:r.multiple,"aria-invalid":Q.value,"aria-describedby":!b.value&&g.value?x.value:void 0,"aria-errormessage":b.value?x.value:void 0}))),Y=e.computed((()=>({valid:r.valid,invalid:r.invalid,modelValue:r.modelValue}))),{getOptionLabel:Z,getOptionValue:ee,getOptionDisabled:le,getOptionGrouped:oe}=function(l){const{options:o,labelKey:n,valueKey:t,disabledKey:a}=e.toRefs(l);return{options:o,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):e[n.value],getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof t.value?t.value(e):e[t.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof a.value?a.value(e):e[a.value]),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options}}(r),ne=e.computed({get:()=>r.modelValue,set:e=>{Array.isArray(e)&&(e=e.filter((e=>void 0!==e))),t("update:modelValue",e)}}),te=e=>"string"!=typeof e&&(e&&e.options&&e.options.length>0);return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(W))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(O)},e.toDisplayString(l.label),9,I)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[l.$slots.before?(e.openBlock(),e.createElementBlock("div",j,[e.renderSlot(l.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(Y))))])):e.createCommentVNode("",!0),e.createElementVNode("div",F,[e.unref(M)?(e.openBlock(),e.createBlock(c,e.mergeProps({key:0,class:"vv-select__icon"},e.unref(K)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({id:e.unref(O),ref_key:"select",ref:f,"onUpdate:modelValue":o[0]||(o[0]=l=>e.isRef(ne)?ne.value=l:null)},e.unref(X)),[l.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,value:void 0,disabled:!l.unselectable,hidden:!l.unselectable},e.toDisplayString(l.placeholder),9,P)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,((l,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[te(l)?(e.openBlock(),e.createElementBlock("optgroup",{key:`group-${o}`,disabled:e.unref(le)(l),label:e.unref(Z)(l)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(oe)(l),((l,n)=>(e.openBlock(),e.createElementBlock("option",{key:`group-${o}-item-${n}`,disabled:e.unref(le)(l),value:e.unref(ee)(l)},e.toDisplayString(e.unref(Z)(l)),9,z)))),128))],8,q)):(e.openBlock(),e.createElementBlock("option",{key:o,disabled:e.unref(le)(l),value:e.unref(ee)(l)},e.toDisplayString(e.unref(Z)(l)),9,D))],64)))),256))],16,C),[[e.vModelSelect,e.unref(ne)]]),e.unref(T)?(e.openBlock(),e.createBlock(c,e.mergeProps({key:1,class:"vv-select__icon vv-select__icon-after"},e.unref(K)),null,16)):e.createCommentVNode("",!0)]),l.$slots.after?(e.openBlock(),e.createElementBlock("div",R,[e.renderSlot(l.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(Y))))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(m),{id:e.unref(x),class:"vv-select__hint"},null,8,["id"])],2))}})}));
@@ -1,3 +1,4 @@
1
+ import type { Option } from '@/types/generic';
1
2
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
3
  multiple: BooleanConstructor;
3
4
  required: BooleanConstructor;
@@ -22,7 +23,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
22
23
  validation: (value: import("../../constants").Position) => boolean;
23
24
  };
24
25
  options: {
25
- type: globalThis.PropType<(string | import("../../types/generic").Option)[]>;
26
+ type: globalThis.PropType<(string | Option)[]>;
26
27
  default: () => never[];
27
28
  };
28
29
  labelKey: {
@@ -91,7 +92,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
91
92
  validation: (value: import("../../constants").Position) => boolean;
92
93
  };
93
94
  options: {
94
- type: globalThis.PropType<(string | import("../../types/generic").Option)[]>;
95
+ type: globalThis.PropType<(string | Option)[]>;
95
96
  default: () => never[];
96
97
  };
97
98
  labelKey: {
@@ -141,7 +142,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
141
142
  }, {
142
143
  modelValue: string | number | boolean | unknown[] | Record<string, any>;
143
144
  disabled: boolean;
144
- options: (string | import("../../types/generic").Option)[];
145
+ options: (string | Option)[];
145
146
  floating: boolean;
146
147
  required: boolean;
147
148
  iconPosition: "before" | "after";