@vue-interface/select-field 1.0.0-beta.16 → 1.0.0-beta.17

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.
@@ -1,4 +1,4 @@
1
- import { defineComponent as z, ref as N, onMounted as w, useSlots as k, openBlock as t, createElementBlock as u, normalizeClass as $, unref as o, renderSlot as s, toDisplayString as f, createCommentVNode as a, createElementVNode as i, normalizeProps as p, guardReactiveProps as m, withDirectives as A, mergeProps as E, isRef as M, vModelSelect as P, createVNode as B, Transition as D, withCtx as y, createBlock as h, createTextVNode as R } from "vue";
1
+ import { defineComponent as z, ref as A, onMounted as N, useSlots as k, openBlock as s, createElementBlock as u, normalizeClass as $, unref as o, renderSlot as t, toDisplayString as f, createCommentVNode as a, createElementVNode as i, normalizeProps as p, guardReactiveProps as m, withDirectives as w, mergeProps as E, isRef as M, vModelSelect as P, createVNode as B, Transition as D, withCtx as y, createBlock as h, createTextVNode as R } from "vue";
2
2
  import { ActivityIndicator as G } from "@vue-interface/activity-indicator";
3
3
  import { useFormControl as I, FormControlErrors as U, FormControlFeedback as j } from "@vue-interface/form-control";
4
4
  const q = ["for"], H = { class: "form-group-inner" }, J = {
@@ -8,6 +8,7 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
8
8
  valid: "",
9
9
  class: "valid-feedback"
10
10
  }, X = /* @__PURE__ */ z({
11
+ inheritAttrs: !1,
11
12
  __name: "SelectField",
12
13
  props: {
13
14
  activity: { type: Boolean },
@@ -40,22 +41,22 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
40
41
  onClick: C,
41
42
  onBlur: v,
42
43
  onFocus: b
43
- } = I({ props: g, emit: F }), d = N();
44
+ } = I({ props: g, emit: F }), d = A();
44
45
  function V(e) {
45
46
  C(e), d.value.focus();
46
47
  }
47
- return w(() => {
48
+ return N(() => {
48
49
  if (k().default)
49
50
  for (const e of k().default()) {
50
51
  if (!e.props)
51
52
  return;
52
53
  "selected" in e.props && (e.props.value ?? e.children) && (n.value = e.props.value ?? e.children);
53
54
  }
54
- }), (e, l) => (t(), u("div", {
55
+ }), (e, l) => (s(), u("div", {
55
56
  class: $(["select-field", o(T)])
56
57
  }, [
57
- s(e.$slots, "label", {}, () => [
58
- e.label ? (t(), u("label", {
58
+ t(e.$slots, "label", {}, () => [
59
+ e.label ? (s(), u("label", {
59
60
  key: 0,
60
61
  ref: "label",
61
62
  for: o(c).id,
@@ -63,16 +64,16 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
63
64
  }, f(e.label), 11, q)) : a("", !0)
64
65
  ]),
65
66
  i("div", H, [
66
- s(e.$slots, "control", p(m({ onClick: o(C), onBlur: o(v), onFocus: o(b), controlAttributes: o(c) })), () => [
67
- k().icon ? (t(), u("div", {
67
+ t(e.$slots, "control", p(m({ onClick: o(C), onBlur: o(v), onFocus: o(b), controlAttributes: o(c) })), () => [
68
+ k().icon ? (s(), u("div", {
68
69
  key: 0,
69
70
  class: "form-group-inner-icon",
70
71
  onClick: l[0] || (l[0] = //@ts-ignore
71
72
  (...r) => d.value.focus && d.value.focus(...r))
72
73
  }, [
73
- s(e.$slots, "icon")
74
+ t(e.$slots, "icon")
74
75
  ])) : a("", !0),
75
- A(i("select", E({
76
+ w(i("select", E({
76
77
  ref_key: "field",
77
78
  ref: d,
78
79
  "onUpdate:modelValue": l[1] || (l[1] = (r) => M(n) ? n.value = r : null),
@@ -84,15 +85,15 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
84
85
  onFocus: l[3] || (l[3] = //@ts-ignore
85
86
  (...r) => o(b) && o(b)(...r))
86
87
  }), [
87
- s(e.$slots, "default")
88
+ t(e.$slots, "default")
88
89
  ], 16), [
89
90
  [P, o(n)]
90
91
  ])
91
92
  ]),
92
- s(e.$slots, "activity", {}, () => [
93
+ t(e.$slots, "activity", {}, () => [
93
94
  B(D, { name: "select-field-fade" }, {
94
95
  default: y(() => [
95
- e.activity && e.indicator ? (t(), h(o(G), {
96
+ e.activity && e.indicator ? (s(), h(o(G), {
96
97
  key: "activity",
97
98
  ref: "activity",
98
99
  type: e.indicator,
@@ -103,8 +104,8 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
103
104
  })
104
105
  ])
105
106
  ]),
106
- s(e.$slots, "errors", p(m({ error: e.error, errors: e.errors, id: e.$attrs.id, name: e.$attrs.name })), () => [
107
- e.error || e.errors ? (t(), h(o(U), {
107
+ t(e.$slots, "errors", p(m({ error: e.error, errors: e.errors, id: e.$attrs.id, name: e.$attrs.name })), () => [
108
+ e.error || e.errors ? (s(), h(o(U), {
108
109
  key: 0,
109
110
  id: e.$attrs.id && String(e.$attrs.id),
110
111
  name: e.$attrs.name && String(e.$attrs.name),
@@ -120,7 +121,7 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
120
121
  _: 1
121
122
  }, 8, ["id", "name", "error", "errors"])) : a("", !0)
122
123
  ]),
123
- s(e.$slots, "feedback", p(m({ feedback: e.feedback })), () => [
124
+ t(e.$slots, "feedback", p(m({ feedback: e.feedback })), () => [
124
125
  B(o(j), { feedback: e.feedback }, {
125
126
  default: y(({ feedback: r }) => [
126
127
  i("div", L, f(r), 1)
@@ -128,8 +129,8 @@ const q = ["for"], H = { class: "form-group-inner" }, J = {
128
129
  _: 1
129
130
  }, 8, ["feedback"])
130
131
  ]),
131
- s(e.$slots, "help", p(m({ helpText: e.helpText })), () => [
132
- e.helpText ? (t(), u("small", {
132
+ t(e.$slots, "help", p(m({ helpText: e.helpText })), () => [
133
+ e.helpText ? (s(), u("small", {
133
134
  key: 0,
134
135
  ref: "help"
135
136
  }, f(e.helpText), 513)) : a("", !0)
@@ -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 { CheckedFormControlProps, FormControlSlots } from '@vue-interface/form-control';\nimport { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';\nimport { onMounted, ref, useSlots } from 'vue';\n\ndefineSlots<FormControlSlots<T>>();\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: T): void;\n}>();\n\nconst props = withDefaults(defineProps<CheckedFormControlProps<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 class=\"form-select\"\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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"$attrs.id && String($attrs.id)\"\n v-slot=\"{ error }\"\n :name=\"$attrs.name && String($attrs.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":["controlAttributes","formGroupClasses","model","onClick","onBlur","onFocus","useFormControl","props","emit","field","ref","onMousedown","onMounted","useSlots","child"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBM;AAAA,MACF,mBAAAA;AAAA,MACA,kBAAAC;AAAA,MACA,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,QAAAC;AAAA,MACA,SAAAC;AAAA,IACA,IAAAC,EAAoB,EAAE,OAAAC,GAAO,MAAAC,EAAM,CAAA,GAEjCC,IAAQC;AAEd,aAASC,EAAY,GAAG;AACpB,MAAAR,EAAQ,CAAC,GAETM,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,cACxDZ,EAAM,QAAQY,EAAM,MAAM,SAASA,EAAM;AAAA,QAEjD;AAAA,IAAA,CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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 { CheckedFormControlProps, 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<{\n (e: 'update:modelValue', value: T): void;\n}>();\n\nconst props = withDefaults(defineProps<CheckedFormControlProps<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 class=\"form-select\"\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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"$attrs.id && String($attrs.id)\"\n v-slot=\"{ error }\"\n :name=\"$attrs.name && String($attrs.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":["controlAttributes","formGroupClasses","model","onClick","onBlur","onFocus","useFormControl","props","emit","field","ref","onMousedown","onMounted","useSlots","child"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqBM;AAAA,MACF,mBAAAA;AAAA,MACA,kBAAAC;AAAA,MACA,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,QAAAC;AAAA,MACA,SAAAC;AAAA,IACA,IAAAC,EAAoB,EAAE,OAAAC,GAAO,MAAAC,EAAM,CAAA,GAEjCC,IAAQC;AAEd,aAASC,EAAY,GAAG;AACpB,MAAAR,EAAQ,CAAC,GAETM,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,cACxDZ,EAAM,QAAQY,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"],y={class:"form-group-inner"},k={invalid:"",class:"invalid-feedback"},S=e.createElementVNode("br",null,null,-1),b={valid:"",class:"valid-feedback"},B=e.defineComponent({__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:{},checked:{type:Boolean}},emits:["update:modelValue"],setup(C,{emit:u}){const V=C,{controlAttributes:s,formGroupClasses:h,model:n,onClick:c,onBlur:d,onFocus:f}=a.useFormControl({props:V,emit:u}),i=e.ref();function $(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(h)])},[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",y,[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),class:"form-select"},e.unref(s),{onMousedown:$,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.$attrs.id,name:r.$attrs.name})),()=>[r.error||r.errors?(e.openBlock(),e.createBlock(e.unref(a.FormControlErrors),{key:0,id:r.$attrs.id&&String(r.$attrs.id),name:r.$attrs.name&&String(r.$attrs.name),error:r.error,errors:r.errors},{default:e.withCtx(({error:o})=>[e.createElementVNode("div",k,[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=B,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
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"],y={class:"form-group-inner"},k={invalid:"",class:"invalid-feedback"},S=e.createElementVNode("br",null,null,-1),b={valid:"",class:"valid-feedback"},B=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:{},checked:{type:Boolean}},emits:["update:modelValue"],setup(C,{emit:u}){const V=C,{controlAttributes:s,formGroupClasses:h,model:n,onClick:c,onBlur:d,onFocus:f}=a.useFormControl({props:V,emit:u}),i=e.ref();function $(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(h)])},[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",y,[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),class:"form-select"},e.unref(s),{onMousedown:$,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.$attrs.id,name:r.$attrs.name})),()=>[r.error||r.errors?(e.openBlock(),e.createBlock(e.unref(a.FormControlErrors),{key:0,id:r.$attrs.id&&String(r.$attrs.id),name:r.$attrs.name&&String(r.$attrs.name),error:r.error,errors:r.errors},{default:e.withCtx(({error:o})=>[e.createElementVNode("div",k,[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=B,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 { CheckedFormControlProps, FormControlSlots } from '@vue-interface/form-control';\nimport { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';\nimport { onMounted, ref, useSlots } from 'vue';\n\ndefineSlots<FormControlSlots<T>>();\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: T): void;\n}>();\n\nconst props = withDefaults(defineProps<CheckedFormControlProps<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 class=\"form-select\"\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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"$attrs.id && String($attrs.id)\"\n v-slot=\"{ error }\"\n :name=\"$attrs.name && String($attrs.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":["controlAttributes","formGroupClasses","model","onClick","onBlur","onFocus","useFormControl","props","emit","field","ref","onMousedown","e","onMounted","useSlots","child"],"mappings":"ukCAiBM,CACF,kBAAAA,EACA,iBAAAC,EACA,MAAAC,EACA,QAAAC,EACA,OAAAC,EACA,QAAAC,CACA,EAAAC,iBAAoB,CAAE,MAAAC,EAAO,KAAAC,CAAM,CAAA,EAEjCC,EAAQC,EAAAA,MAEd,SAASC,EAAYC,EAAG,CACpBT,EAAQS,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,YACxDb,EAAM,MAAQa,EAAM,MAAM,OAASA,EAAM,SAEjD,CAAA,CACH"}
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 { CheckedFormControlProps, 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<{\n (e: 'update:modelValue', value: T): void;\n}>();\n\nconst props = withDefaults(defineProps<CheckedFormControlProps<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 class=\"form-select\"\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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"$attrs.id && String($attrs.id)\"\n v-slot=\"{ error }\"\n :name=\"$attrs.name && String($attrs.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":["controlAttributes","formGroupClasses","model","onClick","onBlur","onFocus","useFormControl","props","emit","field","ref","onMousedown","e","onMounted","useSlots","child"],"mappings":"ulCAqBM,CACF,kBAAAA,EACA,iBAAAC,EACA,MAAAC,EACA,QAAAC,EACA,OAAAC,EACA,QAAAC,CACA,EAAAC,iBAAoB,CAAE,MAAAC,EAAO,KAAAC,CAAM,CAAA,EAEjCC,EAAQC,EAAAA,MAEd,SAASC,EAAYC,EAAG,CACpBT,EAAQS,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,YACxDb,EAAM,MAAQa,EAAM,MAAM,OAASA,EAAM,SAEjD,CAAA,CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/select-field",
3
- "version": "1.0.0-beta.16",
3
+ "version": "1.0.0-beta.17",
4
4
  "description": "A Vue select field component.",
5
5
  "files": [
6
6
  "dist"