@vue-interface/select-field 1.0.0-beta.22 → 1.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/select-field.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as A, ref as N, onMounted as w, useSlots as k, openBlock as
|
|
1
|
+
import { defineComponent as A, ref as N, onMounted as w, useSlots as k, openBlock as s, createElementBlock as u, normalizeClass as h, unref as o, renderSlot as i, toDisplayString as f, createCommentVNode as t, createElementVNode as a, normalizeProps as p, guardReactiveProps as m, withDirectives as E, mergeProps as M, isRef as P, vModelSelect as D, createVNode as B, Transition as R, withCtx as y, createBlock as S, createTextVNode as G } from "vue";
|
|
2
2
|
import { ActivityIndicator as I } from "@vue-interface/activity-indicator";
|
|
3
3
|
import { useFormControl as U, FormControlErrors as j, FormControlFeedback as q } from "@vue-interface/form-control";
|
|
4
4
|
const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
@@ -51,11 +51,11 @@ const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
|
51
51
|
return;
|
|
52
52
|
"selected" in e.props && (e.props.value ?? e.children) && (n.value = e.props.value ?? e.children);
|
|
53
53
|
}
|
|
54
|
-
}), (e, l) => (
|
|
54
|
+
}), (e, l) => (s(), u("div", {
|
|
55
55
|
class: h(["select-field", o(V)])
|
|
56
56
|
}, [
|
|
57
|
-
|
|
58
|
-
e.label ? (
|
|
57
|
+
i(e.$slots, "label", {}, () => [
|
|
58
|
+
e.label ? (s(), u("label", {
|
|
59
59
|
key: 0,
|
|
60
60
|
ref: "label",
|
|
61
61
|
for: o(c).id,
|
|
@@ -63,20 +63,19 @@ const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
|
63
63
|
}, f(e.label), 11, H)) : t("", !0)
|
|
64
64
|
]),
|
|
65
65
|
a("div", J, [
|
|
66
|
-
|
|
67
|
-
k().icon ? (
|
|
66
|
+
i(e.$slots, "control", p(m({ onClick: o(C), onBlur: o(v), onFocus: o(b), controlAttributes: o(c) })), () => [
|
|
67
|
+
k().icon ? (s(), u("div", {
|
|
68
68
|
key: 0,
|
|
69
69
|
class: "form-group-inner-icon",
|
|
70
70
|
onClick: l[0] || (l[0] = //@ts-ignore
|
|
71
71
|
(...r) => d.value.focus && d.value.focus(...r))
|
|
72
72
|
}, [
|
|
73
|
-
|
|
73
|
+
i(e.$slots, "icon")
|
|
74
74
|
])) : t("", !0),
|
|
75
75
|
E(a("select", M({
|
|
76
76
|
ref_key: "field",
|
|
77
77
|
ref: d,
|
|
78
|
-
"onUpdate:modelValue": l[1] || (l[1] = (r) => P(n) ? n.value = r : null)
|
|
79
|
-
class: "form-select"
|
|
78
|
+
"onUpdate:modelValue": l[1] || (l[1] = (r) => P(n) ? n.value = r : null)
|
|
80
79
|
}, o(c), {
|
|
81
80
|
onMousedown: z,
|
|
82
81
|
onBlur: l[2] || (l[2] = //@ts-ignore
|
|
@@ -84,15 +83,15 @@ const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
|
84
83
|
onFocus: l[3] || (l[3] = //@ts-ignore
|
|
85
84
|
(...r) => o(b) && o(b)(...r))
|
|
86
85
|
}), [
|
|
87
|
-
|
|
86
|
+
i(e.$slots, "default")
|
|
88
87
|
], 16), [
|
|
89
88
|
[D, o(n)]
|
|
90
89
|
])
|
|
91
90
|
]),
|
|
92
|
-
|
|
91
|
+
i(e.$slots, "activity", {}, () => [
|
|
93
92
|
B(R, { name: "select-field-fade" }, {
|
|
94
93
|
default: y(() => [
|
|
95
|
-
e.activity && e.indicator ? (
|
|
94
|
+
e.activity && e.indicator ? (s(), S(o(I), {
|
|
96
95
|
key: "activity",
|
|
97
96
|
ref: "activity",
|
|
98
97
|
type: e.indicator,
|
|
@@ -103,8 +102,8 @@ const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
|
103
102
|
})
|
|
104
103
|
])
|
|
105
104
|
]),
|
|
106
|
-
|
|
107
|
-
e.error || e.errors ? (
|
|
105
|
+
i(e.$slots, "errors", p(m({ error: e.error, errors: e.errors, id: e.id, name: e.name })), () => [
|
|
106
|
+
e.error || e.errors ? (s(), S(o(j), {
|
|
108
107
|
key: 0,
|
|
109
108
|
id: e.id && String(e.id),
|
|
110
109
|
name: e.name && String(e.name),
|
|
@@ -120,7 +119,7 @@ const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
|
120
119
|
_: 1
|
|
121
120
|
}, 8, ["id", "name", "error", "errors"])) : t("", !0)
|
|
122
121
|
]),
|
|
123
|
-
|
|
122
|
+
i(e.$slots, "feedback", p(m({ feedback: e.feedback })), () => [
|
|
124
123
|
B(o(q), { feedback: e.feedback }, {
|
|
125
124
|
default: y(({ feedback: r }) => [
|
|
126
125
|
a("div", O, f(r), 1)
|
|
@@ -128,8 +127,8 @@ const H = ["for"], J = { class: "form-group-inner" }, K = {
|
|
|
128
127
|
_: 1
|
|
129
128
|
}, 8, ["feedback"])
|
|
130
129
|
]),
|
|
131
|
-
|
|
132
|
-
e.helpText ? (
|
|
130
|
+
i(e.$slots, "help", p(m({ helpText: e.helpText })), () => [
|
|
131
|
+
e.helpText ? (s(), u("small", {
|
|
133
132
|
key: 0,
|
|
134
133
|
ref: "help"
|
|
135
134
|
}, f(e.helpText), 513)) : t("", !0)
|
package/dist/select-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-field.js","sources":["../src/SelectField.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T, V\">\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport type { FormControlEvents, FormControlProps, FormControlSlots } from '@vue-interface/form-control';\nimport { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';\nimport { onMounted, ref, useSlots } from 'vue';\n\ndefineOptions({\n inheritAttrs: false\n});\n\ndefineSlots<FormControlSlots<T>>();\n\nconst emit = defineEmits<FormControlEvents<T>>();\n\nconst props = withDefaults(defineProps<FormControlProps<T, V>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label'\n});\n\nconst {\n controlAttributes,\n formGroupClasses,\n model,\n onClick,\n onBlur,\n onFocus\n} = useFormControl<T,V>({ props, emit });\n\nconst field = ref<HTMLSelectElement>();\n\nfunction onMousedown(e) {\n onClick(e);\n\n field.value.focus();\n}\n\n// Check the option slots for selected options. If the field has hardcoded\n// selected options, this will ensure the value of the field is always set to\n// the property. This will ensure the model is updated to the selected value.\nonMounted(() => {\n if(!useSlots().default) {\n return;\n }\n\n for(const child of useSlots().default()) {\n if(!child.props) {\n return;\n }\n \n if('selected' in child.props && (child.props.value ?? child.children)) {\n model.value = child.props.value ?? child.children;\n }\n }\n});\n</script>\n\n<template>\n <div\n class=\"select-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"label\"\n ref=\"label\"\n :for=\"controlAttributes.id\"\n :class=\"labelClass\">\n {{ label }}\n </label>\n </slot>\n\n <div class=\"form-group-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ onClick, onBlur, onFocus, controlAttributes }\">\n <div\n v-if=\"useSlots().icon\"\n class=\"form-group-inner-icon\"\n @click=\"field.focus\">\n <slot name=\"icon\" />\n </div>\n <select\n ref=\"field\"\n v-model=\"model\"\n
|
|
1
|
+
{"version":3,"file":"select-field.js","sources":["../src/SelectField.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T, V\">\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport type { FormControlEvents, FormControlProps, FormControlSlots } from '@vue-interface/form-control';\nimport { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';\nimport { onMounted, ref, useSlots } from 'vue';\n\ndefineOptions({\n inheritAttrs: false\n});\n\ndefineSlots<FormControlSlots<T>>();\n\nconst emit = defineEmits<FormControlEvents<T>>();\n\nconst props = withDefaults(defineProps<FormControlProps<T, V>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label'\n});\n\nconst {\n controlAttributes,\n formGroupClasses,\n model,\n onClick,\n onBlur,\n onFocus\n} = useFormControl<T,V>({ props, emit });\n\nconst field = ref<HTMLSelectElement>();\n\nfunction onMousedown(e) {\n onClick(e);\n\n field.value.focus();\n}\n\n// Check the option slots for selected options. If the field has hardcoded\n// selected options, this will ensure the value of the field is always set to\n// the property. This will ensure the model is updated to the selected value.\nonMounted(() => {\n if(!useSlots().default) {\n return;\n }\n\n for(const child of useSlots().default()) {\n if(!child.props) {\n return;\n }\n \n if('selected' in child.props && (child.props.value ?? child.children)) {\n model.value = child.props.value ?? child.children;\n }\n }\n});\n</script>\n\n<template>\n <div\n class=\"select-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"label\"\n ref=\"label\"\n :for=\"controlAttributes.id\"\n :class=\"labelClass\">\n {{ label }}\n </label>\n </slot>\n\n <div class=\"form-group-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ onClick, onBlur, onFocus, controlAttributes }\">\n <div\n v-if=\"useSlots().icon\"\n class=\"form-group-inner-icon\"\n @click=\"field.focus\">\n <slot name=\"icon\" />\n </div>\n <select\n ref=\"field\"\n v-model=\"model\"\n v-bind=\"controlAttributes\"\n @mousedown=\"onMousedown\"\n @blur=\"onBlur\"\n @focus=\"onFocus\">\n <slot />\n </select>\n </slot>\n\n <slot name=\"activity\">\n <Transition name=\"select-field-fade\">\n <ActivityIndicator\n v-if=\"activity && indicator\"\n key=\"activity\"\n ref=\"activity\"\n :type=\"indicator\"\n :size=\"indicatorSize\" />\n </Transition>\n </slot>\n </div>\n\n <slot\n name=\"errors\"\n v-bind=\"{ error, errors, id, name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"id && String(id)\"\n v-slot=\"{ error }\"\n :name=\"name && String(name)\"\n :error=\"error\"\n :errors=\"errors\">\n <div\n invalid\n class=\"invalid-feedback\">\n {{ error }}<br>\n </div>\n </FormControlErrors>\n </slot>\n \n <slot\n name=\"feedback\"\n v-bind=\"{ feedback }\">\n <FormControlFeedback\n v-slot=\"{ feedback }\"\n :feedback=\"feedback\">\n <div\n valid\n class=\"valid-feedback\">\n {{ feedback }}\n </div>\n </FormControlFeedback>\n </slot>\n\n <slot\n name=\"help\"\n v-bind=\"{ helpText }\">\n <small\n v-if=\"helpText\"\n ref=\"help\">\n {{ helpText }}\n </small>\n </slot>\n </div>\n</template>"],"names":["emit","__emit","props","__props","controlAttributes","formGroupClasses","model","onClick","onBlur","onFocus","useFormControl","field","ref","onMousedown","onMounted","useSlots","child"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,UAAMA,IAAOC,GAEPC,IAAQC,GAKR;AAAA,MACF,mBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,QAAAC;AAAA,MACA,SAAAC;AAAA,IACA,IAAAC,EAAoB,EAAE,OAAAR,GAAO,MAAAF,EAAM,CAAA,GAEjCW,IAAQC;AAEd,aAASC,EAAY,GAAG;AACpB,MAAAN,EAAQ,CAAC,GAETI,EAAM,MAAM;IAChB;AAKA,WAAAG,EAAU,MAAM;AACT,UAACC,EAAS,EAAE;AAIf,mBAAUC,KAASD,EAAW,EAAA,QAAA,GAAW;AAClC,cAAA,CAACC,EAAM;AACN;AAGJ,UAAG,cAAcA,EAAM,UAAUA,EAAM,MAAM,SAASA,EAAM,cACxDV,EAAM,QAAQU,EAAM,MAAM,SAASA,EAAM;AAAA,QAEjD;AAAA,IAAA,CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vue-interface/activity-indicator"),require("@vue-interface/form-control")):typeof define=="function"&&define.amd?define(["exports","vue","@vue-interface/activity-indicator","@vue-interface/form-control"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.SelectField={},t.Vue,t.VueInterfaceActivityIndicator,t.VueInterfaceFormControl))})(this,function(t,e,p,a){"use strict";const m=["for"],k={class:"form-group-inner"},y={invalid:"",class:"invalid-feedback"},S=e.createElementVNode("br",null,null,-1),b={valid:"",class:"valid-feedback"},u=e.defineComponent({inheritAttrs:!1,__name:"SelectField",props:{activity:{type:Boolean},disabled:{type:Boolean},error:{},errors:{},feedback:{},formControlClass:{default:"form-select"},helpText:{},id:{},indicator:{},indicatorSize:{},invalid:{type:Boolean},label:{},labelClass:{default:"form-label"},modelValue:{},name:{},plaintext:{type:Boolean},readonly:{type:Boolean},valid:{type:Boolean},value:{}},emits:["blur","change","click","focus","update:modelValue"],setup(B,{emit:C}){const V=C,h=B,{controlAttributes:s,formGroupClasses:g,model:n,onClick:c,onBlur:d,onFocus:f}=a.useFormControl({props:h,emit:V}),i=e.ref();function N(r){c(r),i.value.focus()}return e.onMounted(()=>{if(e.useSlots().default)for(const r of e.useSlots().default()){if(!r.props)return;"selected"in r.props&&(r.props.value??r.children)&&(n.value=r.props.value??r.children)}}),(r,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["select-field",e.unref(g)])},[e.renderSlot(r.$slots,"label",{},()=>[r.label?(e.openBlock(),e.createElementBlock("label",{key:0,ref:"label",for:e.unref(s).id,class:e.normalizeClass(r.labelClass)},e.toDisplayString(r.label),11,m)):e.createCommentVNode("",!0)]),e.createElementVNode("div",k,[e.renderSlot(r.$slots,"control",e.normalizeProps(e.guardReactiveProps({onClick:e.unref(c),onBlur:e.unref(d),onFocus:e.unref(f),controlAttributes:e.unref(s)})),()=>[e.useSlots().icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-group-inner-icon",onClick:l[0]||(l[0]=(...o)=>i.value.focus&&i.value.focus(...o))},[e.renderSlot(r.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({ref_key:"field",ref:i,"onUpdate:modelValue":l[1]||(l[1]=o=>e.isRef(n)?n.value=o:null)
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vue-interface/activity-indicator"),require("@vue-interface/form-control")):typeof define=="function"&&define.amd?define(["exports","vue","@vue-interface/activity-indicator","@vue-interface/form-control"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.SelectField={},t.Vue,t.VueInterfaceActivityIndicator,t.VueInterfaceFormControl))})(this,function(t,e,p,a){"use strict";const m=["for"],k={class:"form-group-inner"},y={invalid:"",class:"invalid-feedback"},S=e.createElementVNode("br",null,null,-1),b={valid:"",class:"valid-feedback"},u=e.defineComponent({inheritAttrs:!1,__name:"SelectField",props:{activity:{type:Boolean},disabled:{type:Boolean},error:{},errors:{},feedback:{},formControlClass:{default:"form-select"},helpText:{},id:{},indicator:{},indicatorSize:{},invalid:{type:Boolean},label:{},labelClass:{default:"form-label"},modelValue:{},name:{},plaintext:{type:Boolean},readonly:{type:Boolean},valid:{type:Boolean},value:{}},emits:["blur","change","click","focus","update:modelValue"],setup(B,{emit:C}){const V=C,h=B,{controlAttributes:s,formGroupClasses:g,model:n,onClick:c,onBlur:d,onFocus:f}=a.useFormControl({props:h,emit:V}),i=e.ref();function N(r){c(r),i.value.focus()}return e.onMounted(()=>{if(e.useSlots().default)for(const r of e.useSlots().default()){if(!r.props)return;"selected"in r.props&&(r.props.value??r.children)&&(n.value=r.props.value??r.children)}}),(r,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["select-field",e.unref(g)])},[e.renderSlot(r.$slots,"label",{},()=>[r.label?(e.openBlock(),e.createElementBlock("label",{key:0,ref:"label",for:e.unref(s).id,class:e.normalizeClass(r.labelClass)},e.toDisplayString(r.label),11,m)):e.createCommentVNode("",!0)]),e.createElementVNode("div",k,[e.renderSlot(r.$slots,"control",e.normalizeProps(e.guardReactiveProps({onClick:e.unref(c),onBlur:e.unref(d),onFocus:e.unref(f),controlAttributes:e.unref(s)})),()=>[e.useSlots().icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-group-inner-icon",onClick:l[0]||(l[0]=(...o)=>i.value.focus&&i.value.focus(...o))},[e.renderSlot(r.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({ref_key:"field",ref:i,"onUpdate:modelValue":l[1]||(l[1]=o=>e.isRef(n)?n.value=o:null)},e.unref(s),{onMousedown:N,onBlur:l[2]||(l[2]=(...o)=>e.unref(d)&&e.unref(d)(...o)),onFocus:l[3]||(l[3]=(...o)=>e.unref(f)&&e.unref(f)(...o))}),[e.renderSlot(r.$slots,"default")],16),[[e.vModelSelect,e.unref(n)]])]),e.renderSlot(r.$slots,"activity",{},()=>[e.createVNode(e.Transition,{name:"select-field-fade"},{default:e.withCtx(()=>[r.activity&&r.indicator?(e.openBlock(),e.createBlock(e.unref(p.ActivityIndicator),{key:"activity",ref:"activity",type:r.indicator,size:r.indicatorSize},null,8,["type","size"])):e.createCommentVNode("",!0)]),_:1})])]),e.renderSlot(r.$slots,"errors",e.normalizeProps(e.guardReactiveProps({error:r.error,errors:r.errors,id:r.id,name:r.name})),()=>[r.error||r.errors?(e.openBlock(),e.createBlock(e.unref(a.FormControlErrors),{key:0,id:r.id&&String(r.id),name:r.name&&String(r.name),error:r.error,errors:r.errors},{default:e.withCtx(({error:o})=>[e.createElementVNode("div",y,[e.createTextVNode(e.toDisplayString(o),1),S])]),_:1},8,["id","name","error","errors"])):e.createCommentVNode("",!0)]),e.renderSlot(r.$slots,"feedback",e.normalizeProps(e.guardReactiveProps({feedback:r.feedback})),()=>[e.createVNode(e.unref(a.FormControlFeedback),{feedback:r.feedback},{default:e.withCtx(({feedback:o})=>[e.createElementVNode("div",b,e.toDisplayString(o),1)]),_:1},8,["feedback"])]),e.renderSlot(r.$slots,"help",e.normalizeProps(e.guardReactiveProps({helpText:r.helpText})),()=>[r.helpText?(e.openBlock(),e.createElementBlock("small",{key:0,ref:"help"},e.toDisplayString(r.helpText),513)):e.createCommentVNode("",!0)])],2))}});t.SelectField=u,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=select-field.umd.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-field.umd.cjs","sources":["../src/SelectField.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T, V\">\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport type { FormControlEvents, FormControlProps, FormControlSlots } from '@vue-interface/form-control';\nimport { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';\nimport { onMounted, ref, useSlots } from 'vue';\n\ndefineOptions({\n inheritAttrs: false\n});\n\ndefineSlots<FormControlSlots<T>>();\n\nconst emit = defineEmits<FormControlEvents<T>>();\n\nconst props = withDefaults(defineProps<FormControlProps<T, V>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label'\n});\n\nconst {\n controlAttributes,\n formGroupClasses,\n model,\n onClick,\n onBlur,\n onFocus\n} = useFormControl<T,V>({ props, emit });\n\nconst field = ref<HTMLSelectElement>();\n\nfunction onMousedown(e) {\n onClick(e);\n\n field.value.focus();\n}\n\n// Check the option slots for selected options. If the field has hardcoded\n// selected options, this will ensure the value of the field is always set to\n// the property. This will ensure the model is updated to the selected value.\nonMounted(() => {\n if(!useSlots().default) {\n return;\n }\n\n for(const child of useSlots().default()) {\n if(!child.props) {\n return;\n }\n \n if('selected' in child.props && (child.props.value ?? child.children)) {\n model.value = child.props.value ?? child.children;\n }\n }\n});\n</script>\n\n<template>\n <div\n class=\"select-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"label\"\n ref=\"label\"\n :for=\"controlAttributes.id\"\n :class=\"labelClass\">\n {{ label }}\n </label>\n </slot>\n\n <div class=\"form-group-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ onClick, onBlur, onFocus, controlAttributes }\">\n <div\n v-if=\"useSlots().icon\"\n class=\"form-group-inner-icon\"\n @click=\"field.focus\">\n <slot name=\"icon\" />\n </div>\n <select\n ref=\"field\"\n v-model=\"model\"\n
|
|
1
|
+
{"version":3,"file":"select-field.umd.cjs","sources":["../src/SelectField.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T, V\">\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport type { FormControlEvents, FormControlProps, FormControlSlots } from '@vue-interface/form-control';\nimport { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';\nimport { onMounted, ref, useSlots } from 'vue';\n\ndefineOptions({\n inheritAttrs: false\n});\n\ndefineSlots<FormControlSlots<T>>();\n\nconst emit = defineEmits<FormControlEvents<T>>();\n\nconst props = withDefaults(defineProps<FormControlProps<T, V>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label'\n});\n\nconst {\n controlAttributes,\n formGroupClasses,\n model,\n onClick,\n onBlur,\n onFocus\n} = useFormControl<T,V>({ props, emit });\n\nconst field = ref<HTMLSelectElement>();\n\nfunction onMousedown(e) {\n onClick(e);\n\n field.value.focus();\n}\n\n// Check the option slots for selected options. If the field has hardcoded\n// selected options, this will ensure the value of the field is always set to\n// the property. This will ensure the model is updated to the selected value.\nonMounted(() => {\n if(!useSlots().default) {\n return;\n }\n\n for(const child of useSlots().default()) {\n if(!child.props) {\n return;\n }\n \n if('selected' in child.props && (child.props.value ?? child.children)) {\n model.value = child.props.value ?? child.children;\n }\n }\n});\n</script>\n\n<template>\n <div\n class=\"select-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"label\"\n ref=\"label\"\n :for=\"controlAttributes.id\"\n :class=\"labelClass\">\n {{ label }}\n </label>\n </slot>\n\n <div class=\"form-group-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ onClick, onBlur, onFocus, controlAttributes }\">\n <div\n v-if=\"useSlots().icon\"\n class=\"form-group-inner-icon\"\n @click=\"field.focus\">\n <slot name=\"icon\" />\n </div>\n <select\n ref=\"field\"\n v-model=\"model\"\n v-bind=\"controlAttributes\"\n @mousedown=\"onMousedown\"\n @blur=\"onBlur\"\n @focus=\"onFocus\">\n <slot />\n </select>\n </slot>\n\n <slot name=\"activity\">\n <Transition name=\"select-field-fade\">\n <ActivityIndicator\n v-if=\"activity && indicator\"\n key=\"activity\"\n ref=\"activity\"\n :type=\"indicator\"\n :size=\"indicatorSize\" />\n </Transition>\n </slot>\n </div>\n\n <slot\n name=\"errors\"\n v-bind=\"{ error, errors, id, name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"id && String(id)\"\n v-slot=\"{ error }\"\n :name=\"name && String(name)\"\n :error=\"error\"\n :errors=\"errors\">\n <div\n invalid\n class=\"invalid-feedback\">\n {{ error }}<br>\n </div>\n </FormControlErrors>\n </slot>\n \n <slot\n name=\"feedback\"\n v-bind=\"{ feedback }\">\n <FormControlFeedback\n v-slot=\"{ feedback }\"\n :feedback=\"feedback\">\n <div\n valid\n class=\"valid-feedback\">\n {{ feedback }}\n </div>\n </FormControlFeedback>\n </slot>\n\n <slot\n name=\"help\"\n v-bind=\"{ helpText }\">\n <small\n v-if=\"helpText\"\n ref=\"help\">\n {{ helpText }}\n </small>\n </slot>\n </div>\n</template>"],"names":["emit","__emit","props","__props","controlAttributes","formGroupClasses","model","onClick","onBlur","onFocus","useFormControl","field","ref","onMousedown","e","onMounted","useSlots","child"],"mappings":"slCAYA,MAAMA,EAAOC,EAEPC,EAAQC,EAKR,CACF,kBAAAC,EACA,iBAAAC,EACA,MAAAC,EACA,QAAAC,EACA,OAAAC,EACA,QAAAC,CACA,EAAAC,iBAAoB,CAAE,MAAAR,EAAO,KAAAF,CAAM,CAAA,EAEjCW,EAAQC,EAAAA,MAEd,SAASC,EAAYC,EAAG,CACpBP,EAAQO,CAAC,EAETH,EAAM,MAAM,OAChB,CAKAI,OAAAA,EAAAA,UAAU,IAAM,CACT,GAACC,EAAAA,SAAS,EAAE,QAIf,UAAUC,KAASD,WAAW,EAAA,QAAA,EAAW,CAClC,GAAA,CAACC,EAAM,MACN,OAGD,aAAcA,EAAM,QAAUA,EAAM,MAAM,OAASA,EAAM,YACxDX,EAAM,MAAQW,EAAM,MAAM,OAASA,EAAM,SAEjD,CAAA,CACH"}
|
|
@@ -2,7 +2,7 @@ import type { FormControlEvents, FormControlSlots } from '@vue-interface/form-co
|
|
|
2
2
|
declare const _default: <T, V>(__VLS_props: {
|
|
3
3
|
onBlur?: (event: FocusEvent) => any;
|
|
4
4
|
onChange?: (value: T) => any;
|
|
5
|
-
onClick?: (
|
|
5
|
+
onClick?: (event: PointerEvent) => any;
|
|
6
6
|
onFocus?: (event: FocusEvent) => any;
|
|
7
7
|
"onUpdate:modelValue"?: (value: T) => any;
|
|
8
8
|
activity?: boolean;
|
|
@@ -32,7 +32,7 @@ declare const _default: <T, V>(__VLS_props: {
|
|
|
32
32
|
props: {
|
|
33
33
|
onBlur?: (event: FocusEvent) => any;
|
|
34
34
|
onChange?: (value: T) => any;
|
|
35
|
-
onClick?: (
|
|
35
|
+
onClick?: (event: PointerEvent) => any;
|
|
36
36
|
onFocus?: (event: FocusEvent) => any;
|
|
37
37
|
"onUpdate:modelValue"?: (value: T) => any;
|
|
38
38
|
activity?: boolean;
|
|
@@ -66,7 +66,7 @@ declare const _default: <T, V>(__VLS_props: {
|
|
|
66
66
|
props: {
|
|
67
67
|
onBlur?: (event: FocusEvent) => any;
|
|
68
68
|
onChange?: (value: T) => any;
|
|
69
|
-
onClick?: (
|
|
69
|
+
onClick?: (event: PointerEvent) => any;
|
|
70
70
|
onFocus?: (event: FocusEvent) => any;
|
|
71
71
|
"onUpdate:modelValue"?: (value: T) => any;
|
|
72
72
|
activity?: boolean;
|