@vue-interface/select-field 2.0.0 → 2.0.1

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Justin Kimbrell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Select Field
2
+
3
+ The `select-field` component provides flexible and customizable select dropdown fields with customizable sizes and states.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm i @vue-interface/select-field
9
+ ```
10
+
11
+ ```bash
12
+ yarn add @vue-interface/select-field
13
+ ```
14
+
15
+ ```bash
16
+ npm i @vue-interface/select-field
17
+ ```
18
+
19
+ ```bash
20
+ bun i @vue-interface/select-field
21
+ ```
22
+
23
+ ## Basic Usage
24
+
25
+ ```vue
26
+ <SelectField v-model="value" label="Regular Field" tabindex="1">
27
+ <option value="1">Option 1</option>
28
+ <option value="2">Option 2</option>
29
+ <option value="3">Option 3</option>
30
+ </SelectField>
31
+ ```
32
+
33
+ For more comprehensive documentation and examples, please visit the [online documentation](https://vue-interface.github.io/packages/select-field/).
34
+
@@ -0,0 +1,2 @@
1
+ import { default as SelectField } from './src/SelectField.vue';
2
+ export { SelectField };
@@ -0,0 +1,141 @@
1
+ import { defineComponent as M, mergeModels as h, useModel as T, ref as F, onMounted as A, useSlots as N, createElementBlock as c, openBlock as n, normalizeClass as C, unref as t, renderSlot as r, createElementVNode as a, createCommentVNode as s, toDisplayString as u, normalizeProps as m, guardReactiveProps as f, withDirectives as E, mergeProps as P, vModelSelect as x, createVNode as S, Transition as D, withCtx as k, createBlock as V, createTextVNode as G } from "vue";
2
+ import { ActivityIndicator as I } from "@vue-interface/activity-indicator";
3
+ import { useFormControl as L, FormControlErrors as R, FormControlFeedback as U } from "@vue-interface/form-control";
4
+ const j = ["for"], p = { class: "form-control-inner" }, q = { class: "form-control-activity-indicator" }, H = {
5
+ invalid: "",
6
+ class: "invalid-feedback"
7
+ }, J = {
8
+ valid: "",
9
+ class: "valid-feedback"
10
+ }, W = /* @__PURE__ */ M({
11
+ inheritAttrs: !1,
12
+ __name: "SelectField",
13
+ props: /* @__PURE__ */ h({
14
+ activity: { type: Boolean },
15
+ disabled: { type: Boolean },
16
+ error: {},
17
+ errors: {},
18
+ feedback: {},
19
+ formControlClass: { default: "form-select" },
20
+ helpText: {},
21
+ id: {},
22
+ indicator: {},
23
+ indicatorSize: {},
24
+ invalid: { type: Boolean },
25
+ label: {},
26
+ labelClass: { default: "form-label" },
27
+ modelValue: {},
28
+ name: {},
29
+ plaintext: { type: Boolean },
30
+ size: {},
31
+ color: {},
32
+ readonly: { type: Boolean },
33
+ valid: { type: Boolean },
34
+ value: {}
35
+ }, {
36
+ modelValue: {},
37
+ modelModifiers: {}
38
+ }),
39
+ emits: /* @__PURE__ */ h(["update:modelValue", "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, { emit: $ }) {
41
+ const B = e, d = T(e, "modelValue"), g = $, {
42
+ controlAttributes: v,
43
+ formGroupClasses: w,
44
+ listeners: b
45
+ } = L({ model: d, props: B, emit: g }), y = F();
46
+ function z(o) {
47
+ b.onClick(o), y.value?.focus();
48
+ }
49
+ return A(() => {
50
+ const o = N().default;
51
+ if (o)
52
+ for (const l of o()) {
53
+ if (!l.props)
54
+ return;
55
+ "selected" in l.props && (l.props.value ?? l.children) && (d.value = l.props.value ?? l.children);
56
+ }
57
+ }), (o, l) => (n(), c("div", {
58
+ class: C(["select-field", t(w)])
59
+ }, [
60
+ r(o.$slots, "label", {}, () => [
61
+ e.label ? (n(), c("label", {
62
+ key: 0,
63
+ ref: "label",
64
+ for: t(v).id,
65
+ class: C(e.labelClass),
66
+ onMousedown: z
67
+ }, u(e.label), 43, j)) : s("", !0)
68
+ ]),
69
+ a("div", p, [
70
+ r(o.$slots, "control", m(f({ controlAttributes: t(v), listeners: t(b) })), () => [
71
+ o.$slots.icon ? (n(), c("div", {
72
+ key: 0,
73
+ class: "form-control-inner-icon",
74
+ onClick: l[0] || (l[0] = (i) => y.value?.focus())
75
+ }, [
76
+ r(o.$slots, "icon")
77
+ ])) : s("", !0),
78
+ E(a("select", P({
79
+ ref_key: "field",
80
+ ref: y,
81
+ "onUpdate:modelValue": l[1] || (l[1] = (i) => d.value = i)
82
+ }, { ...t(v), ...t(b) }), [
83
+ r(o.$slots, "default")
84
+ ], 16), [
85
+ [x, d.value]
86
+ ])
87
+ ]),
88
+ a("div", q, [
89
+ r(o.$slots, "activity", {}, () => [
90
+ S(D, { name: "select-field-fade" }, {
91
+ default: k(() => [
92
+ e.activity && e.indicator ? (n(), V(t(I), {
93
+ key: "activity",
94
+ ref: "activity",
95
+ type: e.indicator,
96
+ size: e.indicatorSize
97
+ }, null, 8, ["type", "size"])) : s("", !0)
98
+ ]),
99
+ _: 1
100
+ })
101
+ ])
102
+ ])
103
+ ]),
104
+ r(o.$slots, "errors", m(f({ error: e.error, errors: e.errors, id: e.id, name: e.name })), () => [
105
+ e.error || e.errors ? (n(), V(t(R), {
106
+ key: 0,
107
+ id: e.id && String(e.id),
108
+ name: e.name && String(e.name),
109
+ error: e.error,
110
+ errors: e.errors
111
+ }, {
112
+ default: k(({ error: i }) => [
113
+ a("div", H, [
114
+ G(u(i), 1),
115
+ l[2] || (l[2] = a("br", null, null, -1))
116
+ ])
117
+ ]),
118
+ _: 1
119
+ }, 8, ["id", "name", "error", "errors"])) : s("", !0)
120
+ ]),
121
+ r(o.$slots, "feedback", m(f({ feedback: e.feedback })), () => [
122
+ S(t(U), { feedback: e.feedback }, {
123
+ default: k(({ feedback: i }) => [
124
+ a("div", J, u(i), 1)
125
+ ]),
126
+ _: 1
127
+ }, 8, ["feedback"])
128
+ ]),
129
+ r(o.$slots, "help", m(f({ helpText: e.helpText })), () => [
130
+ e.helpText ? (n(), c("small", {
131
+ key: 0,
132
+ ref: "help"
133
+ }, u(e.helpText), 513)) : s("", !0)
134
+ ])
135
+ ], 2));
136
+ }
137
+ });
138
+ export {
139
+ W as SelectField
140
+ };
141
+ //# sourceMappingURL=select-field.js.map
@@ -0,0 +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, ref, SelectHTMLAttributes, useSlots } 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<ModelValue>>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners,\n} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue, Value>({ model, props, emit });\n\nconst field = ref<HTMLSelectElement>();\n\nfunction onMousedownLabel(e: MouseEvent) {\n listeners.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 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 @mousedown=\"onMousedownLabel\">\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","field","ref","onMousedownLabel","e","onMounted","slot","useSlots","child","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_hoisted_1","_createElementVNode","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","_cache","$event","_withDirectives","_mergeProps","_hoisted_3","_createVNode","_Transition","_createBlock","ActivityIndicator","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,UAAMA,IAAQC,GASRC,IAAQC,EAAuBF,GAAA,YAAC,GAMhCG,IAAOC,GAEP;AAAA,MACF,mBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,WAAAC;AAAA,IAAA,IACAC,EAAqF,EAAE,OAAAP,GAAO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ADCF,CAAQ,GAAA,CAAA;AAAA,UAAA;;;;MAKvBtB,EAQOC,EAAA,QAAA,QAAAI,EAAAC,EAAA,EAAA,UANO1B,EAAA,SAAA,CAAQ,CAAA,GAFtB,MAQO;AAAA,QAJOA,EAAA,iBADViB,EAIQ,SAAA;AAAA;UAFJ,KAAI;AAAA,QAAA,KACDjB,EAAA,QAAQ,GAAA,GAAA;;;;;"}
@@ -0,0 +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,f,a){"use strict";const m=["for"],u={class:"form-control-inner"},y={class:"form-control-activity-indicator"},k={invalid:"",class:"invalid-feedback"},b={valid:"",class:"valid-feedback"},h=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:{},color:{},readonly:{type:Boolean},valid:{type:Boolean},value:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","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,{emit:S}){const V=t,i=e.useModel(t,"modelValue"),C=S,{controlAttributes:c,formGroupClasses:B,listeners:d}=a.useFormControl({model:i,props:V,emit:C}),s=e.ref();function p(o){d.onClick(o),s.value?.focus()}return e.onMounted(()=>{const o=e.useSlots().default;if(o)for(const r of o()){if(!r.props)return;"selected"in r.props&&(r.props.value??r.children)&&(i.value=r.props.value??r.children)}}),(o,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["select-field",e.unref(B)])},[e.renderSlot(o.$slots,"label",{},()=>[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,ref:"label",for:e.unref(c).id,class:e.normalizeClass(t.labelClass),onMousedown:p},e.toDisplayString(t.label),43,m)):e.createCommentVNode("",!0)]),e.createElementVNode("div",u,[e.renderSlot(o.$slots,"control",e.normalizeProps(e.guardReactiveProps({controlAttributes:e.unref(c),listeners:e.unref(d)})),()=>[o.$slots.icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-control-inner-icon",onClick:r[0]||(r[0]=n=>s.value?.focus())},[e.renderSlot(o.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({ref_key:"field",ref:s,"onUpdate:modelValue":r[1]||(r[1]=n=>i.value=n)},{...e.unref(c),...e.unref(d)}),[e.renderSlot(o.$slots,"default")],16),[[e.vModelSelect,i.value]])]),e.createElementVNode("div",y,[e.renderSlot(o.$slots,"activity",{},()=>[e.createVNode(e.Transition,{name:"select-field-fade"},{default:e.withCtx(()=>[t.activity&&t.indicator?(e.openBlock(),e.createBlock(e.unref(f.ActivityIndicator),{key:"activity",ref:"activity",type:t.indicator,size:t.indicatorSize},null,8,["type","size"])):e.createCommentVNode("",!0)]),_:1})])])]),e.renderSlot(o.$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(a.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",k,[e.createTextVNode(e.toDisplayString(n),1),r[2]||(r[2]=e.createElementVNode("br",null,null,-1))])]),_:1},8,["id","name","error","errors"])):e.createCommentVNode("",!0)]),e.renderSlot(o.$slots,"feedback",e.normalizeProps(e.guardReactiveProps({feedback:t.feedback})),()=>[e.createVNode(e.unref(a.FormControlFeedback),{feedback:t.feedback},{default:e.withCtx(({feedback:n})=>[e.createElementVNode("div",b,e.toDisplayString(n),1)]),_:1},8,["feedback"])]),e.renderSlot(o.$slots,"help",e.normalizeProps(e.guardReactiveProps({helpText:t.helpText})),()=>[t.helpText?(e.openBlock(),e.createElementBlock("small",{key:0,ref:"help"},e.toDisplayString(t.helpText),513)):e.createCommentVNode("",!0)])],2))}});l.SelectField=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
2
+ //# sourceMappingURL=select-field.umd.cjs.map
@@ -0,0 +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, ref, SelectHTMLAttributes, useSlots } 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<ModelValue>>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners,\n} = useFormControl<InputHTMLAttributes, SelectFieldControlSizePrefix, ModelValue, Value>({ model, props, emit });\n\nconst field = ref<HTMLSelectElement>();\n\nfunction onMousedownLabel(e: MouseEvent) {\n listeners.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 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 @mousedown=\"onMousedownLabel\">\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","field","ref","onMousedownLabel","e","onMounted","slot","useSlots","child","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_hoisted_1","_createElementVNode","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","_cache","$event","_withDirectives","_mergeProps","_hoisted_3","_createVNode","_Transition","_createBlock","ActivityIndicator","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5","_toDisplayString"],"mappings":"ugDAMA,MAAMA,EAAQC,EASRC,EAAQC,EAAAA,SAAuBF,EAAA,YAAC,EAMhCG,EAAOC,EAEP,CACF,kBAAAC,EACA,iBAAAC,EACA,UAAAC,CAAA,EACAC,EAAAA,eAAqF,CAAE,MAAAP,EAAO,MAAAF,EAAO,KAAAI,EAAM,EAEzGM,EAAQC,EAAAA,IAAA,EAEd,SAASC,EAAiBC,EAAe,CACrCL,EAAU,QAAQK,CAAC,EAEnBH,EAAM,OAAO,MAAA,CACjB,CAKAI,OAAAA,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,YACxDf,EAAM,MAAQe,EAAM,MAAM,OAASA,EAAM,SAEjD,CACJ,CAAC,wBAeGC,EAAAA,mBAuFM,MAAA,CAtFF,MAAKC,EAAAA,eAAA,CAAC,eACEC,EAAAA,MAAAb,CAAA,CAAgB,CAAA,CAAA,GACxBc,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A,EAAA,KAAI,CAAA,EAFrC,IAgBO,CAZUA,EAAA,OAASA,EAAA,sBADtBmC,EAAAA,YAYoBhB,QAAAkB,EAAAA,iBAAA,EAAA,OAVf,GAAIrC,EAAA,IAAM,OAAOA,EAAA,EAAE,EAEnB,KAAMA,EAAA,MAAQ,OAAOA,EAAA,IAAI,EACzB,MAAOA,EAAA,MACP,OAAQA,EAAA,MAAA,GACT,QAAAsC,EAAAA,QAAA,CAIM,CARI,MAAAC,KAAK,CAIfhB,EAAAA,mBAIM,MAJNiB,EAIM,qCADCD,CAAK,EAAA,CAAA,cAAGhB,EAAAA,mBAAI,KAAA,KAAA,KAAA,EAAA,EAAA,2EAK3BH,EAAAA,WAYOC,EAAA,OAAA,WAAAI,EAAAA,eAAAC,EAAAA,mBAAA,CAAA,SAVO1B,EAAA,QAAA,CAAQ,CAAA,EAFtB,IAYO,CATHiC,EAAAA,YAQsBd,EAAAA,MAAAsB,qBAAA,EAAA,CANjB,SAAUzC,EAAA,UAAQ,CACnB,QAAAsC,EAAAA,QAAA,CAIM,CANI,SAAAI,KAAQ,CAElBnB,EAAAA,mBAIM,MAJNoB,EAIMC,EAAAA,gBADCF,CAAQ,EAAA,CAAA,CAAA,0BAKvBtB,EAAAA,WAQOC,EAAA,OAAA,OAAAI,EAAAA,eAAAC,EAAAA,mBAAA,CAAA,SANO1B,EAAA,QAAA,CAAQ,CAAA,EAFtB,IAQO,CAJOA,EAAA,wBADViB,EAAAA,mBAIQ,QAAA,OAFJ,IAAI,MAAA,oBACDjB,EAAA,QAAQ,EAAA,GAAA"}
@@ -0,0 +1,81 @@
1
+ import { FormControlProps, FormControlSlots } from '@vue-interface/form-control';
2
+ import { SelectHTMLAttributes } from 'vue';
3
+ export type SelectFieldControlSizePrefix = 'form-select';
4
+ export type SelectFieldProps<ModelValue, Value> = FormControlProps<SelectHTMLAttributes, SelectFieldControlSizePrefix, ModelValue, Value>;
5
+ declare const _default: <ModelValue, Value>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
6
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
7
+ readonly onInput?: ((event: Event) => any) | undefined;
8
+ readonly onSelect?: ((event: Event) => any) | undefined;
9
+ readonly "onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
10
+ readonly onBlur?: ((event: FocusEvent) => any) | undefined;
11
+ readonly onFocus?: ((event: FocusEvent) => any) | undefined;
12
+ readonly onFocusin?: ((event: FocusEvent) => any) | undefined;
13
+ readonly onFocusout?: ((event: FocusEvent) => any) | undefined;
14
+ readonly onClick?: ((event: MouseEvent) => any) | undefined;
15
+ readonly onDoubleclick?: ((event: MouseEvent) => any) | undefined;
16
+ readonly onContextmenu?: ((event: MouseEvent) => any) | undefined;
17
+ readonly onMousedown?: ((event: MouseEvent) => any) | undefined;
18
+ readonly onMouseup?: ((event: MouseEvent) => any) | undefined;
19
+ readonly onMouseover?: ((event: MouseEvent) => any) | undefined;
20
+ readonly onMouseout?: ((event: MouseEvent) => any) | undefined;
21
+ readonly onMouseenter?: ((event: MouseEvent) => any) | undefined;
22
+ readonly onMouseleave?: ((event: MouseEvent) => any) | undefined;
23
+ readonly onMousemove?: ((event: MouseEvent) => any) | undefined;
24
+ readonly onKeydown?: ((event: KeyboardEvent) => any) | undefined;
25
+ readonly onKeyup?: ((event: KeyboardEvent) => any) | undefined;
26
+ readonly onKeypress?: ((event: KeyboardEvent) => any) | undefined;
27
+ readonly onSelectionchange?: ((event: Event) => any) | undefined;
28
+ readonly onInvalid?: ((event: Event) => any) | undefined;
29
+ readonly onSubmit?: ((event: Event) => any) | undefined;
30
+ readonly onReset?: ((event: Event) => any) | undefined;
31
+ readonly onScroll?: ((event: Event) => any) | undefined;
32
+ readonly onWheel?: ((event: WheelEvent) => any) | undefined;
33
+ readonly onCopy?: ((event: ClipboardEvent) => any) | undefined;
34
+ readonly onCut?: ((event: ClipboardEvent) => any) | undefined;
35
+ readonly onPaste?: ((event: ClipboardEvent) => any) | undefined;
36
+ readonly onTouchstart?: ((event: TouchEvent) => any) | undefined;
37
+ readonly onTouchend?: ((event: TouchEvent) => any) | undefined;
38
+ readonly onTouchmove?: ((event: TouchEvent) => any) | undefined;
39
+ readonly onTouchcancel?: ((event: TouchEvent) => any) | undefined;
40
+ readonly onChange?: ((event: Event) => any) | undefined;
41
+ readonly onBeforeinput?: ((event: Event) => any) | undefined;
42
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onCopy" | "onCut" | "onPaste" | "onFocus" | "onFocusin" | "onFocusout" | "onBlur" | "onChange" | "onBeforeinput" | "onInput" | "onReset" | "onSubmit" | "onInvalid" | "onKeydown" | "onKeypress" | "onKeyup" | "onMousedown" | "onMouseenter" | "onMouseleave" | "onMousemove" | "onMouseout" | "onMouseover" | "onMouseup" | "onSelect" | "onScroll" | "onTouchcancel" | "onTouchend" | "onTouchmove" | "onTouchstart" | "onClick" | "onContextmenu" | "onWheel" | "onDoubleclick" | "onSelectionchange" | "onUpdate:modelValue"> & ({
43
+ modelValue?: ModelValue;
44
+ } & {
45
+ activity?: boolean;
46
+ disabled?: boolean;
47
+ error?: import('@vue-interface/form-control').FormControlErrorProp;
48
+ errors?: import('@vue-interface/form-control').FormControlErrorPropArray | import('@vue-interface/form-control').FormControlErrorPropRecord;
49
+ feedback?: import('@vue-interface/form-control').FormControlFeedbackProp;
50
+ formControlClass?: string;
51
+ helpText?: string;
52
+ id?: string;
53
+ indicator?: import('vue').Component;
54
+ indicatorSize?: import('@vue-interface/activity-indicator').ActivityIndicatorSize;
55
+ invalid?: boolean;
56
+ label?: string;
57
+ labelClass?: string;
58
+ modelValue?: ModelValue | undefined;
59
+ name?: string;
60
+ plaintext?: boolean;
61
+ size?: import('@vue-interface/form-control').FormControlSize<"form-select", import('@vue-interface/form-control').PredeterminedSize> | undefined;
62
+ color?: string;
63
+ readonly?: boolean;
64
+ valid?: boolean;
65
+ value?: Value | undefined;
66
+ } & SelectHTMLAttributes) & Partial<{}>> & import('vue').PublicProps;
67
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
68
+ attrs: any;
69
+ slots: Readonly<FormControlSlots<"form-select", ModelValue> & {
70
+ default: () => unknown;
71
+ }> & FormControlSlots<"form-select", ModelValue> & {
72
+ default: () => unknown;
73
+ };
74
+ emit: (((evt: "input", event: Event) => void) & ((evt: "select", event: Event) => void) & ((evt: "update:modelValue", value: ModelValue) => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "focus", event: FocusEvent) => void) & ((evt: "focusin", event: FocusEvent) => void) & ((evt: "focusout", event: FocusEvent) => void) & ((evt: "click", event: MouseEvent) => void) & ((evt: "doubleclick", event: MouseEvent) => void) & ((evt: "contextmenu", event: MouseEvent) => void) & ((evt: "mousedown", event: MouseEvent) => void) & ((evt: "mouseup", event: MouseEvent) => void) & ((evt: "mouseover", event: MouseEvent) => void) & ((evt: "mouseout", event: MouseEvent) => void) & ((evt: "mouseenter", event: MouseEvent) => void) & ((evt: "mouseleave", event: MouseEvent) => void) & ((evt: "mousemove", event: MouseEvent) => void) & ((evt: "keydown", event: KeyboardEvent) => void) & ((evt: "keyup", event: KeyboardEvent) => void) & ((evt: "keypress", event: KeyboardEvent) => void) & ((evt: "selectionchange", event: Event) => void) & ((evt: "invalid", event: Event) => void) & ((evt: "submit", event: Event) => void) & ((evt: "reset", event: Event) => void) & ((evt: "scroll", event: Event) => void) & ((evt: "wheel", event: WheelEvent) => void) & ((evt: "copy", event: ClipboardEvent) => void) & ((evt: "cut", event: ClipboardEvent) => void) & ((evt: "paste", event: ClipboardEvent) => void) & ((evt: "touchstart", event: TouchEvent) => void) & ((evt: "touchend", event: TouchEvent) => void) & ((evt: "touchmove", event: TouchEvent) => void) & ((evt: "touchcancel", event: TouchEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "beforeinput", event: Event) => void)) & ((evt: "update:modelValue", value: ModelValue) => void);
75
+ }>) => import('vue').VNode & {
76
+ __ctx?: Awaited<typeof __VLS_setup>;
77
+ };
78
+ export default _default;
79
+ type __VLS_PrettifyLocal<T> = {
80
+ [K in keyof T]: T[K];
81
+ } & {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/select-field",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A Vue select field component.",
5
5
  "type": "module",
6
6
  "main": "./dist/select-field.umd.js",
@@ -17,7 +17,7 @@
17
17
  "browserslist": "last 2 versions, > 0.5%, ie >= 11",
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git+https://github.com/vue-interface/select-field"
20
+ "url": "git+https://github.com/vue-interface/vue-interface.github.io"
21
21
  },
22
22
  "keywords": [
23
23
  "Select",
@@ -28,15 +28,22 @@
28
28
  "Bootstrap"
29
29
  ],
30
30
  "author": "Justin Kimbrell",
31
- "license": "ISC",
31
+ "license": "MIT",
32
32
  "bugs": {
33
- "url": "https://github.com/vue-interface/select-field"
33
+ "url": "https://github.com/vue-interface/vue-interface.github.io"
34
34
  },
35
35
  "homepage": "https://github.com/vue-interface/vue-interface",
36
+ "readme": "README.md",
37
+ "files": [
38
+ "dist",
39
+ "index.css",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
36
43
  "peerDependencies": {
37
44
  "vue": "^3.3.4",
38
- "@vue-interface/activity-indicator": "3.0.0",
39
- "@vue-interface/form-control": "2.0.0"
45
+ "@vue-interface/activity-indicator": "3.0.1",
46
+ "@vue-interface/form-control": "2.0.1"
40
47
  },
41
48
  "scripts": {
42
49
  "dev": "vite",
package/CHANGELOG.md DELETED
@@ -1,12 +0,0 @@
1
- # @vue-interface/select-field
2
-
3
- ## 2.0.0
4
-
5
- ### Major Changes
6
-
7
- - 0da678a: Add support for TailwindCSS v4
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies [0da678a]
12
- - @vue-interface/form-control@2.0.0
package/demo.css DELETED
@@ -1,12 +0,0 @@
1
- @import "tailwindcss";
2
- @import "./index.css";
3
-
4
- @source "../activity-indicator/src/**/*.vue";
5
-
6
- @variant dark {
7
- body {
8
- @apply text-white;
9
- }
10
- }
11
-
12
- @custom-variant dark (&:where(.dark, .dark *));