@vue-interface/select-field 2.0.16 → 2.0.18
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 +76 -63
- package/dist/select-field.js.map +1 -1
- package/dist/select-field.umd.cjs +1 -1
- package/dist/select-field.umd.cjs.map +1 -1
- package/dist/src/SelectField.vue.d.ts +28 -3
- package/dist/vite.config.d.ts +3 -0
- package/package.json +3 -3
- package/src/SelectField.vue +20 -4
package/dist/select-field.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ActivityIndicator as
|
|
3
|
-
import { useFormControl as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as N, mergeModels as V, useModel as x, useTemplateRef as d, onMounted as E, useSlots as P, createElementBlock as m, openBlock as s, normalizeClass as g, unref as t, renderSlot as r, createElementVNode as n, createCommentVNode as c, toDisplayString as v, normalizeProps as y, guardReactiveProps as b, withDirectives as D, mergeProps as R, vModelSelect as G, createVNode as w, Transition as I, withCtx as h, createBlock as T, createTextVNode as U } from "vue";
|
|
2
|
+
import { ActivityIndicator as j } from "@vue-interface/activity-indicator";
|
|
3
|
+
import { useFormControl as q, FormControlErrors as H, FormControlFeedback as J } from "@vue-interface/form-control";
|
|
4
|
+
const K = ["for"], L = { class: "form-control-inner" }, O = { class: "form-control-activity-indicator" }, Q = {
|
|
5
5
|
invalid: "",
|
|
6
6
|
class: "invalid-feedback"
|
|
7
|
-
},
|
|
7
|
+
}, W = {
|
|
8
8
|
valid: "",
|
|
9
9
|
class: "valid-feedback"
|
|
10
|
-
},
|
|
10
|
+
}, _ = /* @__PURE__ */ N({
|
|
11
11
|
inheritAttrs: !1,
|
|
12
12
|
__name: "SelectField",
|
|
13
|
-
props: /* @__PURE__ */
|
|
13
|
+
props: /* @__PURE__ */ V({
|
|
14
14
|
activity: { type: Boolean },
|
|
15
15
|
disabled: { type: Boolean },
|
|
16
16
|
error: {},
|
|
@@ -27,7 +27,7 @@ const j = ["for"], p = { class: "form-control-inner" }, q = { class: "form-contr
|
|
|
27
27
|
modelValue: {},
|
|
28
28
|
name: {},
|
|
29
29
|
plaintext: { type: Boolean },
|
|
30
|
-
size: {},
|
|
30
|
+
size: { default: "form-select-md" },
|
|
31
31
|
color: {},
|
|
32
32
|
readonly: { type: Boolean },
|
|
33
33
|
valid: { type: Boolean },
|
|
@@ -36,103 +36,116 @@ const j = ["for"], p = { class: "form-control-inner" }, q = { class: "form-contr
|
|
|
36
36
|
modelValue: {},
|
|
37
37
|
modelModifiers: {}
|
|
38
38
|
}),
|
|
39
|
-
emits: /* @__PURE__ */
|
|
40
|
-
setup(e, { emit:
|
|
41
|
-
const
|
|
42
|
-
controlAttributes:
|
|
43
|
-
formGroupClasses:
|
|
44
|
-
listeners:
|
|
45
|
-
} =
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
emits: /* @__PURE__ */ V(["blur", "focus", "focusin", "focusout", "click", "doubleclick", "contextmenu", "mousedown", "mouseup", "mouseover", "mouseout", "mouseenter", "mouseleave", "mousemove", "keydown", "keyup", "keypress", "select", "selectionchange", "invalid", "submit", "reset", "scroll", "wheel", "copy", "cut", "paste", "touchstart", "touchend", "touchmove", "touchcancel", "change", "input", "beforeinput"], ["update:modelValue"]),
|
|
40
|
+
setup(e, { expose: z, emit: F }) {
|
|
41
|
+
const u = e, f = x(e, "modelValue"), M = F, {
|
|
42
|
+
controlAttributes: k,
|
|
43
|
+
formGroupClasses: A,
|
|
44
|
+
listeners: p
|
|
45
|
+
} = q({ model: f, props: u, emit: M }), C = d("activity"), $ = d("help"), S = d("label"), a = d("field"), B = d("wrapper");
|
|
46
|
+
return z({
|
|
47
|
+
activity: C,
|
|
48
|
+
help: $,
|
|
49
|
+
field: a,
|
|
50
|
+
label: S,
|
|
51
|
+
wrapper: B,
|
|
52
|
+
focus: () => a.value?.focus(),
|
|
53
|
+
blur: () => a.value?.blur()
|
|
54
|
+
}), E(() => {
|
|
55
|
+
const o = P().default;
|
|
56
|
+
if (o)
|
|
57
|
+
for (const l of o()) {
|
|
50
58
|
if (!l.props)
|
|
51
59
|
return;
|
|
52
|
-
"selected" in l.props && (l.props.value ?? l.children) && (
|
|
60
|
+
"selected" in l.props && (l.props.value ?? l.children) && (f.value = l.props.value ?? l.children);
|
|
53
61
|
}
|
|
54
|
-
}), (
|
|
55
|
-
|
|
62
|
+
}), (o, l) => (s(), m("div", {
|
|
63
|
+
ref_key: "wrapper",
|
|
64
|
+
ref: B,
|
|
65
|
+
class: g(["select-field", t(A)])
|
|
56
66
|
}, [
|
|
57
|
-
r(
|
|
58
|
-
|
|
67
|
+
r(o.$slots, "label", {}, () => [
|
|
68
|
+
u.label ? (s(), m("label", {
|
|
59
69
|
key: 0,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
ref_key: "label",
|
|
71
|
+
ref: S,
|
|
72
|
+
for: t(k).id,
|
|
73
|
+
class: g(e.labelClass),
|
|
74
|
+
onClick: l[0] || (l[0] = (i) => a.value?.click())
|
|
75
|
+
}, v(u.label), 11, K)) : c("", !0)
|
|
65
76
|
]),
|
|
66
|
-
n("div",
|
|
67
|
-
r(
|
|
68
|
-
|
|
77
|
+
n("div", L, [
|
|
78
|
+
r(o.$slots, "control", y(b({ controlAttributes: t(k), listeners: t(p) })), () => [
|
|
79
|
+
o.$slots.icon ? (s(), m("div", {
|
|
69
80
|
key: 0,
|
|
70
81
|
class: "form-control-inner-icon",
|
|
71
|
-
onClick: l[1] || (l[1] = (i) =>
|
|
82
|
+
onClick: l[1] || (l[1] = (i) => a.value?.focus())
|
|
72
83
|
}, [
|
|
73
|
-
r(
|
|
74
|
-
])) :
|
|
75
|
-
|
|
84
|
+
r(o.$slots, "icon")
|
|
85
|
+
])) : c("", !0),
|
|
86
|
+
D(n("select", R({
|
|
76
87
|
ref_key: "field",
|
|
77
|
-
ref:
|
|
78
|
-
"onUpdate:modelValue": l[2] || (l[2] = (i) =>
|
|
79
|
-
}, { ...
|
|
80
|
-
r(
|
|
88
|
+
ref: a,
|
|
89
|
+
"onUpdate:modelValue": l[2] || (l[2] = (i) => f.value = i)
|
|
90
|
+
}, { ...t(k), ...t(p) }), [
|
|
91
|
+
r(o.$slots, "default")
|
|
81
92
|
], 16), [
|
|
82
|
-
[
|
|
93
|
+
[G, f.value]
|
|
83
94
|
])
|
|
84
95
|
]),
|
|
85
|
-
n("div",
|
|
86
|
-
r(
|
|
87
|
-
|
|
88
|
-
default:
|
|
89
|
-
|
|
96
|
+
n("div", O, [
|
|
97
|
+
r(o.$slots, "activity", {}, () => [
|
|
98
|
+
w(I, { name: "select-field-fade" }, {
|
|
99
|
+
default: h(() => [
|
|
100
|
+
u.activity && e.indicator ? (s(), T(t(j), {
|
|
90
101
|
key: "activity",
|
|
91
|
-
|
|
102
|
+
ref_key: "activity",
|
|
103
|
+
ref: C,
|
|
92
104
|
type: e.indicator,
|
|
93
105
|
size: e.indicatorSize
|
|
94
|
-
}, null, 8, ["type", "size"])) :
|
|
106
|
+
}, null, 8, ["type", "size"])) : c("", !0)
|
|
95
107
|
]),
|
|
96
108
|
_: 1
|
|
97
109
|
})
|
|
98
110
|
])
|
|
99
111
|
])
|
|
100
112
|
]),
|
|
101
|
-
r(
|
|
102
|
-
e.error || e.errors ? (
|
|
113
|
+
r(o.$slots, "errors", y(b({ error: e.error, errors: e.errors, id: e.id, name: e.name })), () => [
|
|
114
|
+
e.error || e.errors ? (s(), T(t(H), {
|
|
103
115
|
key: 0,
|
|
104
116
|
id: e.id && String(e.id),
|
|
105
117
|
name: e.name && String(e.name),
|
|
106
118
|
error: e.error,
|
|
107
119
|
errors: e.errors
|
|
108
120
|
}, {
|
|
109
|
-
default:
|
|
110
|
-
n("div",
|
|
111
|
-
|
|
121
|
+
default: h(({ error: i }) => [
|
|
122
|
+
n("div", Q, [
|
|
123
|
+
U(v(i), 1),
|
|
112
124
|
l[3] || (l[3] = n("br", null, null, -1))
|
|
113
125
|
])
|
|
114
126
|
]),
|
|
115
127
|
_: 1
|
|
116
|
-
}, 8, ["id", "name", "error", "errors"])) :
|
|
128
|
+
}, 8, ["id", "name", "error", "errors"])) : c("", !0)
|
|
117
129
|
]),
|
|
118
|
-
r(
|
|
119
|
-
|
|
120
|
-
default:
|
|
121
|
-
n("div",
|
|
130
|
+
r(o.$slots, "feedback", y(b({ feedback: e.feedback })), () => [
|
|
131
|
+
w(t(J), { feedback: e.feedback }, {
|
|
132
|
+
default: h(({ feedback: i }) => [
|
|
133
|
+
n("div", W, v(i), 1)
|
|
122
134
|
]),
|
|
123
135
|
_: 1
|
|
124
136
|
}, 8, ["feedback"])
|
|
125
137
|
]),
|
|
126
|
-
r(
|
|
127
|
-
e.helpText ? (
|
|
138
|
+
r(o.$slots, "help", y(b({ helpText: e.helpText })), () => [
|
|
139
|
+
e.helpText ? (s(), m("small", {
|
|
128
140
|
key: 0,
|
|
129
|
-
|
|
130
|
-
|
|
141
|
+
ref_key: "help",
|
|
142
|
+
ref: $
|
|
143
|
+
}, v(e.helpText), 513)) : c("", !0)
|
|
131
144
|
])
|
|
132
145
|
], 2));
|
|
133
146
|
}
|
|
134
147
|
});
|
|
135
148
|
export {
|
|
136
|
-
|
|
149
|
+
_ as SelectField
|
|
137
150
|
};
|
|
138
151
|
//# sourceMappingURL=select-field.js.map
|
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=\"ModelValue, Value\">\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 { InputHTMLAttributes, onMounted, SelectHTMLAttributes, useSlots, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<SelectFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label'\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<SelectFieldControlSizePrefix,ModelValue> & {\n default: () => unknown\n}>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners,\n} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });\n\nconst field = useTemplateRef<HTMLSelectElement>('field');\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 const slot = useSlots().default;\n\n if(!slot) {\n return;\n }\n\n for(const child of slot()) {\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<script lang=\"ts\">\nexport type SelectFieldControlSizePrefix = 'form-select';\n\nexport type SelectFieldProps<ModelValue, Value> = FormControlProps<\n SelectHTMLAttributes, \n SelectFieldControlSizePrefix, \n ModelValue, \n Value\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 @click=\"field?.click()\">\n {{ label }}\n </label>\n </slot>\n\n <div class=\"form-control-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ controlAttributes, listeners }\">\n <div\n v-if=\"$slots.icon\"\n class=\"form-control-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, ...listeners}\">\n <slot />\n </select>\n </slot>\n \n <div class=\"form-control-activity-indicator\">\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 </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":["props","__props","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","listeners","useFormControl","
|
|
1
|
+
{"version":3,"file":"select-field.js","sources":["../src/SelectField.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"ModelValue, Value\">\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 { InputHTMLAttributes, onMounted, SelectHTMLAttributes, useSlots, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<SelectFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label',\n size: 'form-select-md'\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<SelectFieldControlSizePrefix,ModelValue> & {\n default: () => unknown\n}>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners,\n} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });\n\nconst activity = useTemplateRef<InstanceType<typeof ActivityIndicator>>('activity');\nconst help = useTemplateRef<HTMLElement>('help');\nconst label = useTemplateRef<HTMLLabelElement>('label');\nconst field = useTemplateRef<HTMLSelectElement>('field');\nconst wrapper = useTemplateRef<HTMLDivElement>('wrapper');\n\ndefineExpose({\n activity,\n help,\n field,\n label,\n wrapper,\n focus: () => field.value?.focus(),\n blur: () => field.value?.blur(),\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 const slot = useSlots().default;\n\n if(!slot) {\n return;\n }\n\n for(const child of slot()) {\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<script lang=\"ts\">\nexport type SelectFieldControlSizePrefix = 'form-select';\n\nexport type SelectFieldProps<ModelValue, Value> = FormControlProps<\n SelectHTMLAttributes, \n SelectFieldControlSizePrefix, \n ModelValue, \n Value\n>;\n</script>\n\n<template>\n <div\n ref=\"wrapper\"\n class=\"select-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"props.label\"\n ref=\"label\"\n :for=\"controlAttributes.id\"\n :class=\"labelClass\"\n @click=\"field?.click()\">\n {{ props.label }}\n </label>\n </slot>\n\n <div class=\"form-control-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ controlAttributes, listeners }\">\n <div\n v-if=\"$slots.icon\"\n class=\"form-control-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, ...listeners}\">\n <slot />\n </select>\n </slot>\n \n <div class=\"form-control-activity-indicator\">\n <slot name=\"activity\">\n <Transition name=\"select-field-fade\">\n <ActivityIndicator\n v-if=\"props.activity && indicator\"\n key=\"activity\"\n ref=\"activity\"\n :type=\"indicator\"\n :size=\"indicatorSize\" />\n </Transition>\n </slot>\n </div> \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":["props","__props","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","listeners","useFormControl","activity","useTemplateRef","help","label","field","wrapper","__expose","onMounted","slot","useSlots","child","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_cache","$event","_toDisplayString","_hoisted_1","_createElementVNode","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","_withDirectives","_mergeProps","_hoisted_3","_createVNode","_Transition","_createBlock","ActivityIndicator","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,UAAMA,IAAQC,GAURC,IAAQC,EAAuBF,GAAA,YAAC,GAMhCG,IAAOC,GAEP;AAAA,MACF,mBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,WAAAC;AAAA,IAAA,IACAC,EAA+F,EAAE,OAAAP,GAAO,OAAAF,GAAO,MAAAI,GAAM,GAEnHM,IAAWC,EAAuD,UAAU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CD,CAAK,GAAA,CAAA;AAAA,8BAAGd,EAAI,MAAA,MAAA,MAAA,EAAA;AAAA,YAAA;;;;;MAK3BN,EAYOC,EAAA,QAAA,YAAAO,EAAAC,EAAA,EAAA,UAVOhC,EAAA,SAAA,CAAQ,CAAA,GAFtB,MAYO;AAAA,QATHqC,EAQsBf,EAAAuB,CAAA,GAAA,EANjB,UAAU7C,EAAA,YAAQ;AAAA,UACnB,SAAA0C,EAAA,CAIM,EANI,UAAAI,QAAQ;AAAA,YAElBjB,EAIM,OAJNkB,GAIMpB,EADCmB,CAAQ,GAAA,CAAA;AAAA,UAAA;;;;MAKvBvB,EAQOC,EAAA,QAAA,QAAAO,EAAAC,EAAA,EAAA,UANOhC,EAAA,SAAA,CAAQ,CAAA,GAFtB,MAQO;AAAA,QAJOA,EAAA,iBADVoB,EAIQ,SAAA;AAAA;mBAFA;AAAA,UAAJ,KAAIT;AAAA,QAAA,KACDX,EAAA,QAAQ,GAAA,GAAA;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(l,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):(l=typeof globalThis<"u"?globalThis:l||self,e(l.SelectField={},l.Vue,l.VueInterfaceActivityIndicator,l.VueInterfaceFormControl))})(this,(function(l,e,
|
|
1
|
+
(function(l,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):(l=typeof globalThis<"u"?globalThis:l||self,e(l.SelectField={},l.Vue,l.VueInterfaceActivityIndicator,l.VueInterfaceFormControl))})(this,(function(l,e,p,c){"use strict";const b=["for"],h={class:"form-control-inner"},S={class:"form-control-activity-indicator"},V={invalid:"",class:"invalid-feedback"},C={valid:"",class:"valid-feedback"},B=e.defineComponent({inheritAttrs:!1,__name:"SelectField",props:e.mergeModels({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},size:{default:"form-select-md"},color:{},readonly:{type:Boolean},valid:{type:Boolean},value:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["blur","focus","focusin","focusout","click","doubleclick","contextmenu","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","keydown","keyup","keypress","select","selectionchange","invalid","submit","reset","scroll","wheel","copy","cut","paste","touchstart","touchend","touchmove","touchcancel","change","input","beforeinput"],["update:modelValue"]),setup(t,{expose:T,emit:g}){const a=t,s=e.useModel(t,"modelValue"),N=g,{controlAttributes:d,formGroupClasses:z,listeners:f}=c.useFormControl({model:s,props:a,emit:N}),m=e.useTemplateRef("activity"),y=e.useTemplateRef("help"),k=e.useTemplateRef("label"),i=e.useTemplateRef("field"),u=e.useTemplateRef("wrapper");return T({activity:m,help:y,field:i,label:k,wrapper:u,focus:()=>i.value?.focus(),blur:()=>i.value?.blur()}),e.onMounted(()=>{const r=e.useSlots().default;if(r)for(const o of r()){if(!o.props)return;"selected"in o.props&&(o.props.value??o.children)&&(s.value=o.props.value??o.children)}}),(r,o)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapper",ref:u,class:e.normalizeClass(["select-field",e.unref(z)])},[e.renderSlot(r.$slots,"label",{},()=>[a.label?(e.openBlock(),e.createElementBlock("label",{key:0,ref_key:"label",ref:k,for:e.unref(d).id,class:e.normalizeClass(t.labelClass),onClick:o[0]||(o[0]=n=>i.value?.click())},e.toDisplayString(a.label),11,b)):e.createCommentVNode("",!0)]),e.createElementVNode("div",h,[e.renderSlot(r.$slots,"control",e.normalizeProps(e.guardReactiveProps({controlAttributes:e.unref(d),listeners:e.unref(f)})),()=>[r.$slots.icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-control-inner-icon",onClick:o[1]||(o[1]=n=>i.value?.focus())},[e.renderSlot(r.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({ref_key:"field",ref:i,"onUpdate:modelValue":o[2]||(o[2]=n=>s.value=n)},{...e.unref(d),...e.unref(f)}),[e.renderSlot(r.$slots,"default")],16),[[e.vModelSelect,s.value]])]),e.createElementVNode("div",S,[e.renderSlot(r.$slots,"activity",{},()=>[e.createVNode(e.Transition,{name:"select-field-fade"},{default:e.withCtx(()=>[a.activity&&t.indicator?(e.openBlock(),e.createBlock(e.unref(p.ActivityIndicator),{key:"activity",ref_key:"activity",ref:m,type:t.indicator,size:t.indicatorSize},null,8,["type","size"])):e.createCommentVNode("",!0)]),_:1})])])]),e.renderSlot(r.$slots,"errors",e.normalizeProps(e.guardReactiveProps({error:t.error,errors:t.errors,id:t.id,name:t.name})),()=>[t.error||t.errors?(e.openBlock(),e.createBlock(e.unref(c.FormControlErrors),{key:0,id:t.id&&String(t.id),name:t.name&&String(t.name),error:t.error,errors:t.errors},{default:e.withCtx(({error:n})=>[e.createElementVNode("div",V,[e.createTextVNode(e.toDisplayString(n),1),o[3]||(o[3]=e.createElementVNode("br",null,null,-1))])]),_:1},8,["id","name","error","errors"])):e.createCommentVNode("",!0)]),e.renderSlot(r.$slots,"feedback",e.normalizeProps(e.guardReactiveProps({feedback:t.feedback})),()=>[e.createVNode(e.unref(c.FormControlFeedback),{feedback:t.feedback},{default:e.withCtx(({feedback:n})=>[e.createElementVNode("div",C,e.toDisplayString(n),1)]),_:1},8,["feedback"])]),e.renderSlot(r.$slots,"help",e.normalizeProps(e.guardReactiveProps({helpText:t.helpText})),()=>[t.helpText?(e.openBlock(),e.createElementBlock("small",{key:0,ref_key:"help",ref:y},e.toDisplayString(t.helpText),513)):e.createCommentVNode("",!0)])],2))}});l.SelectField=B,Object.defineProperty(l,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=\"ModelValue, Value\">\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 { InputHTMLAttributes, onMounted, SelectHTMLAttributes, useSlots, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<SelectFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label'\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<SelectFieldControlSizePrefix,ModelValue> & {\n default: () => unknown\n}>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners,\n} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });\n\nconst field = useTemplateRef<HTMLSelectElement>('field');\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 const slot = useSlots().default;\n\n if(!slot) {\n return;\n }\n\n for(const child of slot()) {\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<script lang=\"ts\">\nexport type SelectFieldControlSizePrefix = 'form-select';\n\nexport type SelectFieldProps<ModelValue, Value> = FormControlProps<\n SelectHTMLAttributes, \n SelectFieldControlSizePrefix, \n ModelValue, \n Value\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 @click=\"field?.click()\">\n {{ label }}\n </label>\n </slot>\n\n <div class=\"form-control-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ controlAttributes, listeners }\">\n <div\n v-if=\"$slots.icon\"\n class=\"form-control-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, ...listeners}\">\n <slot />\n </select>\n </slot>\n \n <div class=\"form-control-activity-indicator\">\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 </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":["props","__props","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","listeners","useFormControl","
|
|
1
|
+
{"version":3,"file":"select-field.umd.cjs","sources":["../src/SelectField.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"ModelValue, Value\">\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 { InputHTMLAttributes, onMounted, SelectHTMLAttributes, useSlots, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<SelectFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-select',\n labelClass: 'form-label',\n size: 'form-select-md'\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<SelectFieldControlSizePrefix,ModelValue> & {\n default: () => unknown\n}>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners,\n} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });\n\nconst activity = useTemplateRef<InstanceType<typeof ActivityIndicator>>('activity');\nconst help = useTemplateRef<HTMLElement>('help');\nconst label = useTemplateRef<HTMLLabelElement>('label');\nconst field = useTemplateRef<HTMLSelectElement>('field');\nconst wrapper = useTemplateRef<HTMLDivElement>('wrapper');\n\ndefineExpose({\n activity,\n help,\n field,\n label,\n wrapper,\n focus: () => field.value?.focus(),\n blur: () => field.value?.blur(),\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 const slot = useSlots().default;\n\n if(!slot) {\n return;\n }\n\n for(const child of slot()) {\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<script lang=\"ts\">\nexport type SelectFieldControlSizePrefix = 'form-select';\n\nexport type SelectFieldProps<ModelValue, Value> = FormControlProps<\n SelectHTMLAttributes, \n SelectFieldControlSizePrefix, \n ModelValue, \n Value\n>;\n</script>\n\n<template>\n <div\n ref=\"wrapper\"\n class=\"select-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"props.label\"\n ref=\"label\"\n :for=\"controlAttributes.id\"\n :class=\"labelClass\"\n @click=\"field?.click()\">\n {{ props.label }}\n </label>\n </slot>\n\n <div class=\"form-control-inner\">\n <slot\n name=\"control\"\n v-bind=\"{ controlAttributes, listeners }\">\n <div\n v-if=\"$slots.icon\"\n class=\"form-control-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, ...listeners}\">\n <slot />\n </select>\n </slot>\n \n <div class=\"form-control-activity-indicator\">\n <slot name=\"activity\">\n <Transition name=\"select-field-fade\">\n <ActivityIndicator\n v-if=\"props.activity && indicator\"\n key=\"activity\"\n ref=\"activity\"\n :type=\"indicator\"\n :size=\"indicatorSize\" />\n </Transition>\n </slot>\n </div> \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":["props","__props","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","listeners","useFormControl","activity","useTemplateRef","help","label","field","wrapper","__expose","onMounted","slot","useSlots","child","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_cache","$event","_toDisplayString","_hoisted_1","_createElementVNode","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","_withDirectives","_mergeProps","_hoisted_3","_createVNode","_Transition","_createBlock","ActivityIndicator","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5"],"mappings":"ohDAMA,MAAMA,EAAQC,EAURC,EAAQC,EAAAA,SAAuBF,EAAA,YAAC,EAMhCG,EAAOC,EAEP,CACF,kBAAAC,EACA,iBAAAC,EACA,UAAAC,CAAA,EACAC,EAAAA,eAA+F,CAAE,MAAAP,EAAO,MAAAF,EAAO,KAAAI,EAAM,EAEnHM,EAAWC,EAAAA,eAAuD,UAAU,EAC5EC,EAAOD,EAAAA,eAA4B,MAAM,EACzCE,EAAQF,EAAAA,eAAiC,OAAO,EAChDG,EAAQH,EAAAA,eAAkC,OAAO,EACjDI,EAAUJ,EAAAA,eAA+B,SAAS,EAExD,OAAAK,EAAa,CACT,SAAAN,EACA,KAAAE,EACA,MAAAE,EACA,MAAAD,EACA,QAAAE,EACA,MAAO,IAAMD,EAAM,OAAO,MAAA,EAC1B,KAAM,IAAMA,EAAM,OAAO,KAAA,CAAK,CACjC,EAKDG,EAAAA,UAAU,IAAM,CACZ,MAAMC,EAAOC,EAAAA,WAAW,QAExB,GAAID,EAIJ,UAAUE,KAASF,IAAQ,CACvB,GAAG,CAACE,EAAM,MACN,OAGD,aAAcA,EAAM,QAAUA,EAAM,MAAM,OAASA,EAAM,YACxDlB,EAAM,MAAQkB,EAAM,MAAM,OAASA,EAAM,SAEjD,CACJ,CAAC,wBAeGC,EAAAA,mBAwFM,MAAA,SAvFE,UAAJ,IAAIN,EACJ,MAAKO,EAAAA,eAAA,CAAC,eACEC,EAAAA,MAAAhB,CAAA,CAAgB,CAAA,CAAA,GACxBiB,EAAAA,WASOC,oBATP,IASO,CAPOzB,EAAM,qBADhBqB,EAAAA,mBAOQ,QAAA,eALA,QAAJ,IAAIR,EACH,IAAKU,EAAAA,MAAAjB,CAAA,EAAkB,GACvB,uBAAOL,EAAA,UAAU,EACjB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,OAASA,EAAA,sBADtBuC,EAAAA,YAYoBjB,QAAAmB,EAAAA,iBAAA,EAAA,OAVf,GAAIzC,EAAA,IAAM,OAAOA,EAAA,EAAE,EAEnB,KAAMA,EAAA,MAAQ,OAAOA,EAAA,IAAI,EACzB,MAAOA,EAAA,MACP,OAAQA,EAAA,MAAA,GACT,QAAA0C,EAAAA,QAAA,CAIM,CARI,MAAAC,KAAK,CAIfd,EAAAA,mBAIM,MAJNe,EAIM,qCADCD,CAAK,EAAA,CAAA,cAAGd,EAAAA,mBAAI,KAAA,KAAA,KAAA,EAAA,EAAA,2EAK3BN,EAAAA,WAYOC,EAAA,OAAA,WAAAO,EAAAA,eAAAC,EAAAA,mBAAA,CAAA,SAVOhC,EAAA,QAAA,CAAQ,CAAA,EAFtB,IAYO,CATHqC,EAAAA,YAQsBf,EAAAA,MAAAuB,qBAAA,EAAA,CANjB,SAAU7C,EAAA,UAAQ,CACnB,QAAA0C,EAAAA,QAAA,CAIM,CANI,SAAAI,KAAQ,CAElBjB,EAAAA,mBAIM,MAJNkB,EAIMpB,EAAAA,gBADCmB,CAAQ,EAAA,CAAA,CAAA,0BAKvBvB,EAAAA,WAQOC,EAAA,OAAA,OAAAO,EAAAA,eAAAC,EAAAA,mBAAA,CAAA,SANOhC,EAAA,QAAA,CAAQ,CAAA,EAFtB,IAQO,CAJOA,EAAA,wBADVoB,EAAAA,mBAIQ,QAAA,eAFA,OAAJ,IAAIT,CAAA,oBACDX,EAAA,QAAQ,EAAA,GAAA"}
|
|
@@ -51,20 +51,45 @@ declare const _default: <ModelValue, Value>(__VLS_props: NonNullable<Awaited<typ
|
|
|
51
51
|
helpText?: string;
|
|
52
52
|
id?: string;
|
|
53
53
|
indicator?: import('vue').Component;
|
|
54
|
-
indicatorSize?: import('@vue-interface/activity-indicator').
|
|
54
|
+
indicatorSize?: import('@vue-interface/sizeable').ComponentSize<import('@vue-interface/activity-indicator').ActivityIndicatorSizePrefix>;
|
|
55
55
|
invalid?: boolean;
|
|
56
56
|
label?: string;
|
|
57
57
|
labelClass?: string;
|
|
58
58
|
modelValue?: ModelValue | undefined;
|
|
59
59
|
name?: string;
|
|
60
60
|
plaintext?: boolean;
|
|
61
|
-
size?: import('@vue-interface/form-control').FormControlSize<"form-select"
|
|
61
|
+
size?: import('@vue-interface/form-control').FormControlSize<"form-select"> | undefined;
|
|
62
62
|
color?: string;
|
|
63
63
|
readonly?: boolean;
|
|
64
64
|
valid?: boolean;
|
|
65
65
|
value?: Value | undefined;
|
|
66
66
|
} & Omit<SelectHTMLAttributes, "size">) & Partial<{}>> & import('vue').PublicProps;
|
|
67
|
-
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
67
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
68
|
+
activity: Readonly<import('vue').ShallowRef<import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
|
|
69
|
+
size?: import('@vue-interface/sizeable').ComponentSize<import('@vue-interface/activity-indicator').ActivityIndicatorSizePrefix>;
|
|
70
|
+
type: import('vue').Component;
|
|
71
|
+
}> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
|
|
72
|
+
size: import('@vue-interface/sizeable').ComponentSize<import('@vue-interface/activity-indicator').ActivityIndicatorSizePrefix>;
|
|
73
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
|
74
|
+
P: {};
|
|
75
|
+
B: {};
|
|
76
|
+
D: {};
|
|
77
|
+
C: {};
|
|
78
|
+
M: {};
|
|
79
|
+
Defaults: {};
|
|
80
|
+
}, Readonly<{
|
|
81
|
+
size?: import('@vue-interface/sizeable').ComponentSize<import('@vue-interface/activity-indicator').ActivityIndicatorSizePrefix>;
|
|
82
|
+
type: import('vue').Component;
|
|
83
|
+
}> & Readonly<{}>, {}, {}, {}, {}, {
|
|
84
|
+
size: import('@vue-interface/sizeable').ComponentSize<import('@vue-interface/activity-indicator').ActivityIndicatorSizePrefix>;
|
|
85
|
+
}> | null>>;
|
|
86
|
+
help: Readonly<import('vue').ShallowRef<HTMLElement | null>>;
|
|
87
|
+
field: Readonly<import('vue').ShallowRef<HTMLSelectElement | null>>;
|
|
88
|
+
label: Readonly<import('vue').ShallowRef<HTMLLabelElement | null>>;
|
|
89
|
+
wrapper: Readonly<import('vue').ShallowRef<HTMLDivElement | null>>;
|
|
90
|
+
focus: () => void | undefined;
|
|
91
|
+
blur: () => void | undefined;
|
|
92
|
+
}>): void;
|
|
68
93
|
attrs: any;
|
|
69
94
|
slots: Readonly<FormControlSlots<"form-select", ModelValue> & {
|
|
70
95
|
default: () => unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-interface/select-field",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
4
4
|
"description": "A Vue select field component.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/select-field.umd.cjs",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"vue": "^3.3.4",
|
|
48
|
-
"@vue-interface/activity-indicator": "3.0.
|
|
49
|
-
"@vue-interface/form-control": "2.0.
|
|
48
|
+
"@vue-interface/activity-indicator": "3.0.7",
|
|
49
|
+
"@vue-interface/form-control": "2.0.18"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"dev": "vite",
|
package/src/SelectField.vue
CHANGED
|
@@ -6,7 +6,8 @@ import { InputHTMLAttributes, onMounted, SelectHTMLAttributes, useSlots, useTemp
|
|
|
6
6
|
|
|
7
7
|
const props = withDefaults(defineProps<SelectFieldProps<ModelValue,Value>>(), {
|
|
8
8
|
formControlClass: 'form-select',
|
|
9
|
-
labelClass: 'form-label'
|
|
9
|
+
labelClass: 'form-label',
|
|
10
|
+
size: 'form-select-md'
|
|
10
11
|
});
|
|
11
12
|
|
|
12
13
|
defineOptions({
|
|
@@ -27,7 +28,21 @@ const {
|
|
|
27
28
|
listeners,
|
|
28
29
|
} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });
|
|
29
30
|
|
|
31
|
+
const activity = useTemplateRef<InstanceType<typeof ActivityIndicator>>('activity');
|
|
32
|
+
const help = useTemplateRef<HTMLElement>('help');
|
|
33
|
+
const label = useTemplateRef<HTMLLabelElement>('label');
|
|
30
34
|
const field = useTemplateRef<HTMLSelectElement>('field');
|
|
35
|
+
const wrapper = useTemplateRef<HTMLDivElement>('wrapper');
|
|
36
|
+
|
|
37
|
+
defineExpose({
|
|
38
|
+
activity,
|
|
39
|
+
help,
|
|
40
|
+
field,
|
|
41
|
+
label,
|
|
42
|
+
wrapper,
|
|
43
|
+
focus: () => field.value?.focus(),
|
|
44
|
+
blur: () => field.value?.blur(),
|
|
45
|
+
});
|
|
31
46
|
|
|
32
47
|
// Check the option slots for selected options. If the field has hardcoded
|
|
33
48
|
// selected options, this will ensure the value of the field is always set to
|
|
@@ -64,16 +79,17 @@ export type SelectFieldProps<ModelValue, Value> = FormControlProps<
|
|
|
64
79
|
|
|
65
80
|
<template>
|
|
66
81
|
<div
|
|
82
|
+
ref="wrapper"
|
|
67
83
|
class="select-field"
|
|
68
84
|
:class="formGroupClasses">
|
|
69
85
|
<slot name="label">
|
|
70
86
|
<label
|
|
71
|
-
v-if="label"
|
|
87
|
+
v-if="props.label"
|
|
72
88
|
ref="label"
|
|
73
89
|
:for="controlAttributes.id"
|
|
74
90
|
:class="labelClass"
|
|
75
91
|
@click="field?.click()">
|
|
76
|
-
{{ label }}
|
|
92
|
+
{{ props.label }}
|
|
77
93
|
</label>
|
|
78
94
|
</slot>
|
|
79
95
|
|
|
@@ -99,7 +115,7 @@ export type SelectFieldProps<ModelValue, Value> = FormControlProps<
|
|
|
99
115
|
<slot name="activity">
|
|
100
116
|
<Transition name="select-field-fade">
|
|
101
117
|
<ActivityIndicator
|
|
102
|
-
v-if="activity && indicator"
|
|
118
|
+
v-if="props.activity && indicator"
|
|
103
119
|
key="activity"
|
|
104
120
|
ref="activity"
|
|
105
121
|
:type="indicator"
|