@vue-interface/input-field 2.0.21 → 3.0.0

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,16 +1,33 @@
1
- import { defineComponent as S, useModel as D, useTemplateRef as d, openBlock as a, createElementBlock as m, normalizeClass as w, unref as t, renderSlot as l, toDisplayString as f, createCommentVNode as c, createElementVNode as s, normalizeProps as v, guardReactiveProps as y, withDirectives as E, mergeProps as I, vModelDynamic as P, createVNode as T, Transition as x, withCtx as p, createBlock as z, createTextVNode as R, mergeModels as g } from "vue";
2
- import { ActivityIndicator as G } from "@vue-interface/activity-indicator";
3
- import { useFormControl as U, FormControlErrors as j, FormControlFeedback as q } from "@vue-interface/form-control";
4
- const H = ["for"], J = { class: "form-control-inner" }, K = { class: "form-control-activity-indicator" }, L = {
1
+ import { openBlock as l, createElementBlock as c, createElementVNode as i, defineComponent as P, useModel as R, computed as x, useTemplateRef as u, normalizeClass as D, unref as t, renderSlot as a, toDisplayString as b, createCommentVNode as f, normalizeProps as m, guardReactiveProps as v, withDirectives as j, mergeProps as G, vModelDynamic as U, withModifiers as q, createVNode as I, createBlock as C, Transition as H, withCtx as w, createTextVNode as J, mergeModels as A } from "vue";
2
+ import { ActivityIndicator as K } from "@vue-interface/activity-indicator";
3
+ import { useFormControl as L, FormControlErrors as O, FormControlFeedback as Q } from "@vue-interface/form-control";
4
+ function W(e, B) {
5
+ return l(), c("svg", {
6
+ xmlns: "http://www.w3.org/2000/svg",
7
+ fill: "none",
8
+ viewBox: "0 0 24 24",
9
+ "stroke-width": "1.5",
10
+ stroke: "currentColor",
11
+ "aria-hidden": "true",
12
+ "data-slot": "icon"
13
+ }, [
14
+ i("path", {
15
+ "stroke-linecap": "round",
16
+ "stroke-linejoin": "round",
17
+ d: "M6 18 18 6M6 6l12 12"
18
+ })
19
+ ]);
20
+ }
21
+ const X = ["for"], Y = { class: "form-control-inner" }, Z = { class: "form-control-activity-indicator" }, _ = {
5
22
  invalid: "",
6
23
  class: "invalid-feedback"
7
- }, O = {
24
+ }, ee = {
8
25
  valid: "",
9
26
  class: "valid-feedback"
10
- }, Y = /* @__PURE__ */ S({
27
+ }, re = /* @__PURE__ */ P({
11
28
  inheritAttrs: !1,
12
29
  __name: "InputField",
13
- props: /* @__PURE__ */ g({
30
+ props: /* @__PURE__ */ A({
14
31
  activity: { type: Boolean },
15
32
  disabled: { type: Boolean },
16
33
  error: {},
@@ -31,111 +48,127 @@ const H = ["for"], J = { class: "form-control-inner" }, K = { class: "form-contr
31
48
  color: {},
32
49
  readonly: { type: Boolean },
33
50
  valid: { type: Boolean },
34
- value: {}
51
+ value: {},
52
+ clearable: { type: Boolean, default: !1 }
35
53
  }, {
36
54
  modelValue: {},
37
55
  modelModifiers: {}
38
56
  }),
39
- emits: /* @__PURE__ */ g(["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: F, emit: A }) {
41
- const u = e, b = D(e, "modelValue"), M = A, {
57
+ emits: /* @__PURE__ */ A(["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"]),
58
+ setup(e, { expose: B, emit: N }) {
59
+ const r = e, y = R(e, "modelValue"), S = N, {
42
60
  controlAttributes: k,
43
- formGroupClasses: N,
44
- listeners: h
45
- } = U({ model: b, props: u, emit: M }), C = d("activity"), $ = d("help"), B = d("label"), n = d("field"), V = d("wrapper");
46
- return F({
47
- activity: C,
48
- help: $,
49
- field: n,
50
- label: B,
51
- wrapper: V,
52
- focus: () => n.value?.focus(),
53
- blur: () => n.value?.blur()
54
- }), (o, r) => (a(), m("div", {
61
+ formGroupClasses: E,
62
+ isDirty: $,
63
+ listeners: g
64
+ } = L({ model: y, props: r, emit: S }), p = x(() => !r.disabled && !r.readonly), h = x(() => r.clearable && $.value && p.value);
65
+ function V() {
66
+ p.value && (y.value = void 0);
67
+ }
68
+ const z = u("activity"), T = u("help"), M = u("label"), d = u("field"), F = u("wrapper");
69
+ return B({
70
+ activity: z,
71
+ help: T,
72
+ field: d,
73
+ label: M,
74
+ wrapper: F,
75
+ focus: () => d.value?.focus(),
76
+ blur: () => d.value?.blur()
77
+ }), (o, n) => (l(), c("div", {
55
78
  ref_key: "wrapper",
56
- ref: V,
57
- class: w(["input-field", t(N)])
79
+ ref: F,
80
+ class: D(["input-field", [t(E), { "has-clear-button": h.value }]])
58
81
  }, [
59
- l(o.$slots, "label", {}, () => [
60
- u.label ? (a(), m("label", {
82
+ a(o.$slots, "label", {}, () => [
83
+ r.label ? (l(), c("label", {
61
84
  key: 0,
62
85
  ref_key: "label",
63
- ref: B,
64
- class: w(e.labelClass),
86
+ ref: M,
87
+ class: D(e.labelClass),
65
88
  for: t(k).id
66
- }, f(u.label), 11, H)) : c("", !0)
89
+ }, b(r.label), 11, X)) : f("", !0)
67
90
  ]),
68
- s("div", J, [
69
- l(o.$slots, "control", v(y({ controlAttributes: t(k), listeners: t(h) })), () => [
70
- o.$slots.icon ? (a(), m("div", {
91
+ i("div", Y, [
92
+ a(o.$slots, "control", m(v({ controlAttributes: t(k), listeners: t(g) })), () => [
93
+ o.$slots.icon ? (l(), c("div", {
71
94
  key: 0,
72
95
  class: "form-control-inner-icon",
73
- onClick: r[0] || (r[0] = (i) => n.value?.focus())
96
+ onClick: n[0] || (n[0] = (s) => d.value?.focus())
74
97
  }, [
75
- l(o.$slots, "icon")
76
- ])) : c("", !0),
77
- E(s("input", I({
98
+ a(o.$slots, "icon")
99
+ ])) : f("", !0),
100
+ j(i("input", G({
78
101
  ref_key: "field",
79
- ref: n,
80
- "onUpdate:modelValue": r[1] || (r[1] = (i) => b.value = i)
81
- }, { ...t(k), ...t(h) }), null, 16), [
82
- [P, b.value]
102
+ ref: d,
103
+ "onUpdate:modelValue": n[1] || (n[1] = (s) => y.value = s)
104
+ }, { ...t(k), ...t(g) }), null, 16), [
105
+ [U, y.value]
83
106
  ])
84
107
  ]),
85
- s("div", K, [
86
- l(o.$slots, "activity", {}, () => [
87
- T(x, { name: "input-field-fade" }, {
88
- default: p(() => [
89
- u.activity && e.indicator ? (a(), z(t(G), {
108
+ i("div", Z, [
109
+ a(o.$slots, "activity", m(v({ canClear: h.value, clear: V, isDirty: t($), isInteractive: p.value })), () => [
110
+ h.value ? (l(), c("button", {
111
+ key: 0,
112
+ type: "button",
113
+ class: "input-field-close-button",
114
+ onClick: q(V, ["stop"])
115
+ }, [
116
+ I(t(W), { class: "size-[1.25em]" })
117
+ ])) : (l(), C(H, {
118
+ key: 1,
119
+ name: "input-field-fade"
120
+ }, {
121
+ default: w(() => [
122
+ r.activity && e.indicator ? (l(), C(t(K), {
90
123
  key: "activity",
91
124
  ref_key: "activity",
92
- ref: C,
125
+ ref: z,
93
126
  type: e.indicator,
94
127
  size: e.indicatorSize
95
- }, null, 8, ["type", "size"])) : c("", !0)
128
+ }, null, 8, ["type", "size"])) : f("", !0)
96
129
  ]),
97
130
  _: 1
98
- })
131
+ }))
99
132
  ])
100
133
  ])
101
134
  ]),
102
- l(o.$slots, "errors", v(y({ error: e.error, errors: e.errors, id: o.$attrs.id, name: o.$attrs.name })), () => [
103
- e.error || e.errors ? (a(), z(t(j), {
135
+ a(o.$slots, "errors", m(v({ error: e.error, errors: e.errors, id: o.$attrs.id, name: o.$attrs.name })), () => [
136
+ e.error || e.errors ? (l(), C(t(O), {
104
137
  key: 0,
105
138
  id: e.id,
106
139
  name: e.name,
107
140
  error: e.error,
108
141
  errors: e.errors
109
142
  }, {
110
- default: p(({ error: i }) => [
111
- s("div", L, [
112
- R(f(i), 1),
113
- r[2] || (r[2] = s("br", null, null, -1))
143
+ default: w(({ error: s }) => [
144
+ i("div", _, [
145
+ J(b(s), 1),
146
+ n[2] || (n[2] = i("br", null, null, -1))
114
147
  ])
115
148
  ]),
116
149
  _: 1
117
- }, 8, ["id", "name", "error", "errors"])) : c("", !0)
150
+ }, 8, ["id", "name", "error", "errors"])) : f("", !0)
118
151
  ]),
119
- l(o.$slots, "feedback", v(y({ feedback: e.feedback })), () => [
120
- T(t(q), { feedback: e.feedback }, {
121
- default: p(({ feedback: i }) => [
122
- s("div", O, f(i), 1)
152
+ a(o.$slots, "feedback", m(v({ feedback: e.feedback })), () => [
153
+ I(t(Q), { feedback: e.feedback }, {
154
+ default: w(({ feedback: s }) => [
155
+ i("div", ee, b(s), 1)
123
156
  ]),
124
157
  _: 1
125
158
  }, 8, ["feedback"])
126
159
  ]),
127
- l(o.$slots, "help", v(y({ helpText: e.helpText })), () => [
128
- e.helpText ? (a(), m("small", {
160
+ a(o.$slots, "help", m(v({ helpText: e.helpText })), () => [
161
+ e.helpText ? (l(), c("small", {
129
162
  key: 0,
130
163
  ref_key: "help",
131
- ref: $,
164
+ ref: T,
132
165
  class: "form-help"
133
- }, f(e.helpText), 513)) : c("", !0)
166
+ }, b(e.helpText), 513)) : f("", !0)
134
167
  ])
135
168
  ], 2));
136
169
  }
137
170
  });
138
171
  export {
139
- Y as InputField
172
+ re as InputField
140
173
  };
141
174
  //# sourceMappingURL=input-field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-field.js","sources":["../src/InputField.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, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<InputFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-control',\n labelClass: 'form-label',\n size: 'form-control-md'\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<InputFieldControlSizePrefix,ModelValue>>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners\n} = useFormControl<InputHTMLAttributes, InputFieldControlSizePrefix, 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<HTMLInputElement>('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</script>\n\n<script lang=\"ts\">\nexport type InputFieldControlSizePrefix = 'form-control';\n\nexport type InputFieldProps<ModelValue, Value> = FormControlProps<\n InputHTMLAttributes, \n InputFieldControlSizePrefix, \n ModelValue, \n Value\n>;\n</script>\n\n<template>\n <div\n ref=\"wrapper\"\n class=\"input-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"props.label\"\n ref=\"label\"\n :class=\"labelClass\"\n :for=\"controlAttributes.id\">\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 <input\n ref=\"field\"\n v-model=\"model\"\n v-bind=\"{...controlAttributes, ...listeners}\">\n </slot>\n \n <div class=\"form-control-activity-indicator\">\n <slot name=\"activity\">\n <Transition name=\"input-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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"id\"\n v-slot=\"{ error }\"\n :name=\"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 class=\"form-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","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_toDisplayString","_hoisted_1","_createElementVNode","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","_cache","$event","_withDirectives","_mergeProps","_hoisted_3","_createVNode","_Transition","_createBlock","ActivityIndicator","$attrs","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,UAAMA,IAAQC,GAURC,IAAQC,EAAuBF,GAAA,YAAC,GAIhCG,IAAOC,GAEP;AAAA,MACF,mBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,WAAAC;AAAA,IAAA,IACAC,EAA8F,EAAE,OAAAP,GAAO,OAAAF,GAAO,MAAAI,GAAM,GAElHM,IAAWC,EAA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OC,EAAA,QAAA,QAAAK,EAAAC,EAAA,EAAA,UAPO1B,EAAA,SAAA,CAAQ,CAAA,GAFtB,MASO;AAAA,QALOA,EAAA,iBADVgB,EAKQ,SAAA;AAAA;mBAHA;AAAA,UAAJ,KAAIL;AAAA,UACJ,OAAM;AAAA,QAAA,KACHX,EAAA,QAAQ,GAAA,GAAA;;;;;"}
1
+ {"version":3,"file":"input-field.js","sources":["../../../node_modules/.pnpm/@heroicons+vue@2.2.0_vue@3.5.27_typescript@5.9.3_/node_modules/@heroicons/vue/24/outline/esm/XMarkIcon.js","../src/InputField.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n \"stroke-width\": \"1.5\",\n stroke: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", {\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n d: \"M6 18 18 6M6 6l12 12\"\n })\n ]))\n}","<script setup lang=\"ts\" generic=\"ModelValue, Value\">\nimport { XMarkIcon } from '@heroicons/vue/24/outline';\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, computed, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<InputFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-control',\n labelClass: 'form-label',\n size: 'form-control-md',\n clearable: false\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<InputFieldControlSizePrefix,ModelValue>>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n isDirty,\n listeners\n} = useFormControl<InputHTMLAttributes, InputFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });\n\nconst isInteractive = computed(() => !props.disabled && !props.readonly);\n\nconst canClear = computed(() => {\n return props.clearable && isDirty.value && isInteractive.value;\n});\n\nfunction clear() {\n if (!isInteractive.value) return;\n model.value = undefined;\n}\n\nconst activity = useTemplateRef<InstanceType<typeof ActivityIndicator>>('activity');\nconst help = useTemplateRef<HTMLElement>('help');\nconst label = useTemplateRef<HTMLLabelElement>('label');\nconst field = useTemplateRef<HTMLInputElement>('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</script>\n\n<script lang=\"ts\">\nexport type InputFieldControlSizePrefix = 'form-control';\n\nexport type InputFieldProps<ModelValue, Value> = FormControlProps<\n InputHTMLAttributes, \n InputFieldControlSizePrefix, \n ModelValue, \n Value\n> & {\n clearable?: boolean;\n}\n</script>\n\n<template>\n <div\n ref=\"wrapper\"\n class=\"input-field\"\n :class=\"[formGroupClasses, { 'has-clear-button': canClear }]\">\n <slot name=\"label\">\n <label\n v-if=\"props.label\"\n ref=\"label\"\n :class=\"labelClass\"\n :for=\"controlAttributes.id\">\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 <input\n ref=\"field\"\n v-model=\"model\"\n v-bind=\"{...controlAttributes, ...listeners}\">\n </slot>\n \n <div class=\"form-control-activity-indicator\">\n <slot name=\"activity\" v-bind=\"{ canClear, clear, isDirty, isInteractive }\">\n <button\n v-if=\"canClear\"\n type=\"button\"\n class=\"input-field-close-button\"\n @click.stop=\"clear\">\n <XMarkIcon class=\"size-[1.25em]\" />\n </button>\n <Transition name=\"input-field-fade\" v-else>\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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"id\"\n v-slot=\"{ error }\"\n :name=\"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 class=\"form-help\">\n {{ helpText }}\n </small>\n </slot>\n </div>\n</template>"],"names":["render","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","props","__props","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","isDirty","listeners","useFormControl","isInteractive","computed","canClear","clear","activity","useTemplateRef","help","label","field","wrapper","__expose","_normalizeClass","_unref","_renderSlot","_toDisplayString","_hoisted_1","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","$event","_withDirectives","_mergeProps","_hoisted_3","_createVNode","XMarkIcon","_createBlock","_Transition","ActivityIndicator","$attrs","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5"],"mappings":";;;AAEe,SAASA,EAAOC,GAAMC,GAAQ;AAC3C,SAAQC,EAAU,GAAIC,EAAoB,OAAO;AAAA,IAC/C,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAA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AImB;AAAA,UACJ,OAAM;AAAA,QAAA,KACHhB,EAAA,QAAQ,GAAA,GAAA;;;;;","x_google_ignoreList":[0]}
@@ -1,2 +1,2 @@
1
- (function(r,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):(r=typeof globalThis<"u"?globalThis:r||self,e(r.InputField={},r.Vue,r.VueInterfaceActivityIndicator,r.VueInterfaceFormControl))})(this,(function(r,e,k,s){"use strict";const b=["for"],h={class:"form-control-inner"},V={class:"form-control-activity-indicator"},C={invalid:"",class:"invalid-feedback"},B={valid:"",class:"valid-feedback"},S=e.defineComponent({inheritAttrs:!1,__name:"InputField",props:e.mergeModels({activity:{type:Boolean},disabled:{type:Boolean},error:{},errors:{},feedback:{},formControlClass:{default:"form-control"},helpText:{},id:{},indicator:{},indicatorSize:{},invalid:{type:Boolean},label:{},labelClass:{default:"form-label"},modelValue:{},name:{},plaintext:{type:Boolean},size:{default:"form-control-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:N}){const a=t,c=e.useModel(t,"modelValue"),g=N,{controlAttributes:d,formGroupClasses:z,listeners:f}=s.useFormControl({model:c,props:a,emit:g}),m=e.useTemplateRef("activity"),y=e.useTemplateRef("help"),p=e.useTemplateRef("label"),i=e.useTemplateRef("field"),u=e.useTemplateRef("wrapper");return T({activity:m,help:y,field:i,label:p,wrapper:u,focus:()=>i.value?.focus(),blur:()=>i.value?.blur()}),(o,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapper",ref:u,class:e.normalizeClass(["input-field",e.unref(z)])},[e.renderSlot(o.$slots,"label",{},()=>[a.label?(e.openBlock(),e.createElementBlock("label",{key:0,ref_key:"label",ref:p,class:e.normalizeClass(t.labelClass),for:e.unref(d).id},e.toDisplayString(a.label),11,b)):e.createCommentVNode("",!0)]),e.createElementVNode("div",h,[e.renderSlot(o.$slots,"control",e.normalizeProps(e.guardReactiveProps({controlAttributes:e.unref(d),listeners:e.unref(f)})),()=>[o.$slots.icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-control-inner-icon",onClick:l[0]||(l[0]=n=>i.value?.focus())},[e.renderSlot(o.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({ref_key:"field",ref:i,"onUpdate:modelValue":l[1]||(l[1]=n=>c.value=n)},{...e.unref(d),...e.unref(f)}),null,16),[[e.vModelDynamic,c.value]])]),e.createElementVNode("div",V,[e.renderSlot(o.$slots,"activity",{},()=>[e.createVNode(e.Transition,{name:"input-field-fade"},{default:e.withCtx(()=>[a.activity&&t.indicator?(e.openBlock(),e.createBlock(e.unref(k.ActivityIndicator),{key:"activity",ref_key:"activity",ref:m,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:o.$attrs.id,name:o.$attrs.name})),()=>[t.error||t.errors?(e.openBlock(),e.createBlock(e.unref(s.FormControlErrors),{key:0,id:t.id,name:t.name,error:t.error,errors:t.errors},{default:e.withCtx(({error:n})=>[e.createElementVNode("div",C,[e.createTextVNode(e.toDisplayString(n),1),l[2]||(l[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(s.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_key:"help",ref:y,class:"form-help"},e.toDisplayString(t.helpText),513)):e.createCommentVNode("",!0)])],2))}});r.InputField=S,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(r,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):(r=typeof globalThis<"u"?globalThis:r||self,e(r.InputField={},r.Vue,r.VueInterfaceActivityIndicator,r.VueInterfaceFormControl))})(this,(function(r,e,V,s){"use strict";function w(t,p){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18 18 6M6 6l12 12"})])}const g=["for"],N={class:"form-control-inner"},S={class:"form-control-activity-indicator"},T={invalid:"",class:"invalid-feedback"},E={valid:"",class:"valid-feedback"},z=e.defineComponent({inheritAttrs:!1,__name:"InputField",props:e.mergeModels({activity:{type:Boolean},disabled:{type:Boolean},error:{},errors:{},feedback:{},formControlClass:{default:"form-control"},helpText:{},id:{},indicator:{},indicatorSize:{},invalid:{type:Boolean},label:{},labelClass:{default:"form-label"},modelValue:{},name:{},plaintext:{type:Boolean},size:{default:"form-control-md"},color:{},readonly:{type:Boolean},valid:{type:Boolean},value:{},clearable:{type:Boolean,default:!1}},{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:p,emit:P}){const l=t,c=e.useModel(t,"modelValue"),$=P,{controlAttributes:d,formGroupClasses:R,isDirty:u,listeners:k}=s.useFormControl({model:c,props:l,emit:$}),f=e.computed(()=>!l.disabled&&!l.readonly),m=e.computed(()=>l.clearable&&u.value&&f.value);function y(){f.value&&(c.value=void 0)}const b=e.useTemplateRef("activity"),h=e.useTemplateRef("help"),B=e.useTemplateRef("label"),i=e.useTemplateRef("field"),C=e.useTemplateRef("wrapper");return p({activity:b,help:h,field:i,label:B,wrapper:C,focus:()=>i.value?.focus(),blur:()=>i.value?.blur()}),(o,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapper",ref:C,class:e.normalizeClass(["input-field",[e.unref(R),{"has-clear-button":m.value}]])},[e.renderSlot(o.$slots,"label",{},()=>[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,ref_key:"label",ref:B,class:e.normalizeClass(t.labelClass),for:e.unref(d).id},e.toDisplayString(l.label),11,g)):e.createCommentVNode("",!0)]),e.createElementVNode("div",N,[e.renderSlot(o.$slots,"control",e.normalizeProps(e.guardReactiveProps({controlAttributes:e.unref(d),listeners:e.unref(k)})),()=>[o.$slots.icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-control-inner-icon",onClick:n[0]||(n[0]=a=>i.value?.focus())},[e.renderSlot(o.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({ref_key:"field",ref:i,"onUpdate:modelValue":n[1]||(n[1]=a=>c.value=a)},{...e.unref(d),...e.unref(k)}),null,16),[[e.vModelDynamic,c.value]])]),e.createElementVNode("div",S,[e.renderSlot(o.$slots,"activity",e.normalizeProps(e.guardReactiveProps({canClear:m.value,clear:y,isDirty:e.unref(u),isInteractive:f.value})),()=>[m.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"input-field-close-button",onClick:e.withModifiers(y,["stop"])},[e.createVNode(e.unref(w),{class:"size-[1.25em]"})])):(e.openBlock(),e.createBlock(e.Transition,{key:1,name:"input-field-fade"},{default:e.withCtx(()=>[l.activity&&t.indicator?(e.openBlock(),e.createBlock(e.unref(V.ActivityIndicator),{key:"activity",ref_key:"activity",ref:b,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:o.$attrs.id,name:o.$attrs.name})),()=>[t.error||t.errors?(e.openBlock(),e.createBlock(e.unref(s.FormControlErrors),{key:0,id:t.id,name:t.name,error:t.error,errors:t.errors},{default:e.withCtx(({error:a})=>[e.createElementVNode("div",T,[e.createTextVNode(e.toDisplayString(a),1),n[2]||(n[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(s.FormControlFeedback),{feedback:t.feedback},{default:e.withCtx(({feedback:a})=>[e.createElementVNode("div",E,e.toDisplayString(a),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_key:"help",ref:h,class:"form-help"},e.toDisplayString(t.helpText),513)):e.createCommentVNode("",!0)])],2))}});r.InputField=z,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=input-field.umd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-field.umd.cjs","sources":["../src/InputField.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, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<InputFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-control',\n labelClass: 'form-label',\n size: 'form-control-md'\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<InputFieldControlSizePrefix,ModelValue>>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n listeners\n} = useFormControl<InputHTMLAttributes, InputFieldControlSizePrefix, 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<HTMLInputElement>('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</script>\n\n<script lang=\"ts\">\nexport type InputFieldControlSizePrefix = 'form-control';\n\nexport type InputFieldProps<ModelValue, Value> = FormControlProps<\n InputHTMLAttributes, \n InputFieldControlSizePrefix, \n ModelValue, \n Value\n>;\n</script>\n\n<template>\n <div\n ref=\"wrapper\"\n class=\"input-field\"\n :class=\"formGroupClasses\">\n <slot name=\"label\">\n <label\n v-if=\"props.label\"\n ref=\"label\"\n :class=\"labelClass\"\n :for=\"controlAttributes.id\">\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 <input\n ref=\"field\"\n v-model=\"model\"\n v-bind=\"{...controlAttributes, ...listeners}\">\n </slot>\n \n <div class=\"form-control-activity-indicator\">\n <slot name=\"activity\">\n <Transition name=\"input-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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"id\"\n v-slot=\"{ error }\"\n :name=\"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 class=\"form-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","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_toDisplayString","_hoisted_1","_createElementVNode","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","_cache","$event","_withDirectives","_mergeProps","_hoisted_3","_createVNode","_Transition","_createBlock","ActivityIndicator","$attrs","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5"],"mappings":"ohDAMA,MAAMA,EAAQC,EAURC,EAAQC,EAAAA,SAAuBF,EAAA,YAAC,EAIhCG,EAAOC,EAEP,CACF,kBAAAC,EACA,iBAAAC,EACA,UAAAC,CAAA,EACAC,EAAAA,eA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AAAA,gBADCsB,CAAQ,EAAA,CAAA,CAAA,0BAKvBxB,EAAAA,WASOC,EAAA,OAAA,OAAAK,EAAAA,eAAAC,EAAAA,mBAAA,CAAA,SAPO1B,EAAA,QAAA,CAAQ,CAAA,EAFtB,IASO,CALOA,EAAA,wBADVgB,EAAAA,mBAKQ,QAAA,eAHA,OAAJ,IAAIL,EACJ,MAAM,WAAA,oBACHX,EAAA,QAAQ,EAAA,GAAA"}
1
+ {"version":3,"file":"input-field.umd.cjs","sources":["../../../node_modules/.pnpm/@heroicons+vue@2.2.0_vue@3.5.27_typescript@5.9.3_/node_modules/@heroicons/vue/24/outline/esm/XMarkIcon.js","../src/InputField.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n \"stroke-width\": \"1.5\",\n stroke: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", {\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n d: \"M6 18 18 6M6 6l12 12\"\n })\n ]))\n}","<script setup lang=\"ts\" generic=\"ModelValue, Value\">\nimport { XMarkIcon } from '@heroicons/vue/24/outline';\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, computed, useTemplateRef } from 'vue';\n\nconst props = withDefaults(defineProps<InputFieldProps<ModelValue,Value>>(), {\n formControlClass: 'form-control',\n labelClass: 'form-label',\n size: 'form-control-md',\n clearable: false\n});\n\ndefineOptions({\n inheritAttrs: false\n});\n\nconst model = defineModel<ModelValue>();\n\ndefineSlots<FormControlSlots<InputFieldControlSizePrefix,ModelValue>>();\n\nconst emit = defineEmits<FormControlEvents>();\n\nconst {\n controlAttributes,\n formGroupClasses,\n isDirty,\n listeners\n} = useFormControl<InputHTMLAttributes, InputFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });\n\nconst isInteractive = computed(() => !props.disabled && !props.readonly);\n\nconst canClear = computed(() => {\n return props.clearable && isDirty.value && isInteractive.value;\n});\n\nfunction clear() {\n if (!isInteractive.value) return;\n model.value = undefined;\n}\n\nconst activity = useTemplateRef<InstanceType<typeof ActivityIndicator>>('activity');\nconst help = useTemplateRef<HTMLElement>('help');\nconst label = useTemplateRef<HTMLLabelElement>('label');\nconst field = useTemplateRef<HTMLInputElement>('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</script>\n\n<script lang=\"ts\">\nexport type InputFieldControlSizePrefix = 'form-control';\n\nexport type InputFieldProps<ModelValue, Value> = FormControlProps<\n InputHTMLAttributes, \n InputFieldControlSizePrefix, \n ModelValue, \n Value\n> & {\n clearable?: boolean;\n}\n</script>\n\n<template>\n <div\n ref=\"wrapper\"\n class=\"input-field\"\n :class=\"[formGroupClasses, { 'has-clear-button': canClear }]\">\n <slot name=\"label\">\n <label\n v-if=\"props.label\"\n ref=\"label\"\n :class=\"labelClass\"\n :for=\"controlAttributes.id\">\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 <input\n ref=\"field\"\n v-model=\"model\"\n v-bind=\"{...controlAttributes, ...listeners}\">\n </slot>\n \n <div class=\"form-control-activity-indicator\">\n <slot name=\"activity\" v-bind=\"{ canClear, clear, isDirty, isInteractive }\">\n <button\n v-if=\"canClear\"\n type=\"button\"\n class=\"input-field-close-button\"\n @click.stop=\"clear\">\n <XMarkIcon class=\"size-[1.25em]\" />\n </button>\n <Transition name=\"input-field-fade\" v-else>\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: $attrs.id, name: $attrs.name }\"> \n <FormControlErrors\n v-if=\"!!(error || errors)\"\n :id=\"id\"\n v-slot=\"{ error }\"\n :name=\"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 class=\"form-help\">\n {{ helpText }}\n </small>\n </slot>\n </div>\n</template>"],"names":["render","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","props","__props","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","isDirty","listeners","useFormControl","isInteractive","computed","canClear","clear","activity","useTemplateRef","help","label","field","wrapper","__expose","_normalizeClass","_unref","_renderSlot","_toDisplayString","_hoisted_1","_hoisted_2","_normalizeProps","_guardReactiveProps","$slots","$event","_withDirectives","_mergeProps","_hoisted_3","_createVNode","XMarkIcon","_createBlock","_Transition","ActivityIndicator","$attrs","FormControlErrors","_withCtx","error","_hoisted_4","FormControlFeedback","feedback","_hoisted_5"],"mappings":"odAEe,SAASA,EAAOC,EAAMC,EAAQ,CAC3C,OAAQC,EAAAA,UAAU,EAAIC,EAAAA,mBAAoB,MAAO,C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
@@ -1,7 +1,9 @@
1
1
  import { FormControlProps, FormControlSlots } from '@vue-interface/form-control';
2
2
  import { InputHTMLAttributes } from 'vue';
3
3
  export type InputFieldControlSizePrefix = 'form-control';
4
- export type InputFieldProps<ModelValue, Value> = FormControlProps<InputHTMLAttributes, InputFieldControlSizePrefix, ModelValue, Value>;
4
+ export type InputFieldProps<ModelValue, Value> = FormControlProps<InputHTMLAttributes, InputFieldControlSizePrefix, ModelValue, Value> & {
5
+ clearable?: boolean;
6
+ };
5
7
  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
8
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
7
9
  readonly onInput?: ((event: Event) => any) | undefined;
@@ -63,7 +65,9 @@ declare const _default: <ModelValue, Value>(__VLS_props: NonNullable<Awaited<typ
63
65
  readonly?: boolean;
64
66
  valid?: boolean;
65
67
  value?: Value | undefined;
66
- } & Omit<InputHTMLAttributes, "size">) & Partial<{}>> & import('vue').PublicProps;
68
+ } & Omit<InputHTMLAttributes, "size"> & {
69
+ clearable?: boolean;
70
+ }) & Partial<{}>> & import('vue').PublicProps;
67
71
  expose(exposed: import('vue').ShallowUnwrapRef<{
68
72
  activity: Readonly<import('vue').ShallowRef<import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
69
73
  size?: import('@vue-interface/activity-indicator').ActivityIndicatorSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/input-field",
3
- "version": "2.0.21",
3
+ "version": "3.0.0",
4
4
  "description": "A Vue input field component.",
5
5
  "type": "module",
6
6
  "main": "./dist/input-field.umd.cjs",
@@ -46,7 +46,7 @@
46
46
  "peerDependencies": {
47
47
  "vue": "^3.3.4",
48
48
  "@vue-interface/activity-indicator": "3.0.8",
49
- "@vue-interface/form-control": "2.0.20"
49
+ "@vue-interface/form-control": "2.0.21"
50
50
  },
51
51
  "scripts": {
52
52
  "dev": "vite",
@@ -1,13 +1,15 @@
1
1
  <script setup lang="ts" generic="ModelValue, Value">
2
+ import { XMarkIcon } from '@heroicons/vue/24/outline';
2
3
  import { ActivityIndicator } from '@vue-interface/activity-indicator';
3
4
  import type { FormControlEvents, FormControlProps, FormControlSlots } from '@vue-interface/form-control';
4
5
  import { FormControlErrors, FormControlFeedback, useFormControl } from '@vue-interface/form-control';
5
- import { InputHTMLAttributes, useTemplateRef } from 'vue';
6
+ import { InputHTMLAttributes, computed, useTemplateRef } from 'vue';
6
7
 
7
8
  const props = withDefaults(defineProps<InputFieldProps<ModelValue,Value>>(), {
8
9
  formControlClass: 'form-control',
9
10
  labelClass: 'form-label',
10
- size: 'form-control-md'
11
+ size: 'form-control-md',
12
+ clearable: false
11
13
  });
12
14
 
13
15
  defineOptions({
@@ -23,9 +25,21 @@ const emit = defineEmits<FormControlEvents>();
23
25
  const {
24
26
  controlAttributes,
25
27
  formGroupClasses,
28
+ isDirty,
26
29
  listeners
27
30
  } = useFormControl<InputHTMLAttributes, InputFieldControlSizePrefix, ModelValue|undefined, Value>({ model, props, emit });
28
31
 
32
+ const isInteractive = computed(() => !props.disabled && !props.readonly);
33
+
34
+ const canClear = computed(() => {
35
+ return props.clearable && isDirty.value && isInteractive.value;
36
+ });
37
+
38
+ function clear() {
39
+ if (!isInteractive.value) return;
40
+ model.value = undefined;
41
+ }
42
+
29
43
  const activity = useTemplateRef<InstanceType<typeof ActivityIndicator>>('activity');
30
44
  const help = useTemplateRef<HTMLElement>('help');
31
45
  const label = useTemplateRef<HTMLLabelElement>('label');
@@ -51,14 +65,16 @@ export type InputFieldProps<ModelValue, Value> = FormControlProps<
51
65
  InputFieldControlSizePrefix,
52
66
  ModelValue,
53
67
  Value
54
- >;
68
+ > & {
69
+ clearable?: boolean;
70
+ }
55
71
  </script>
56
72
 
57
73
  <template>
58
74
  <div
59
75
  ref="wrapper"
60
76
  class="input-field"
61
- :class="formGroupClasses">
77
+ :class="[formGroupClasses, { 'has-clear-button': canClear }]">
62
78
  <slot name="label">
63
79
  <label
64
80
  v-if="props.label"
@@ -86,8 +102,15 @@ export type InputFieldProps<ModelValue, Value> = FormControlProps<
86
102
  </slot>
87
103
 
88
104
  <div class="form-control-activity-indicator">
89
- <slot name="activity">
90
- <Transition name="input-field-fade">
105
+ <slot name="activity" v-bind="{ canClear, clear, isDirty, isInteractive }">
106
+ <button
107
+ v-if="canClear"
108
+ type="button"
109
+ class="input-field-close-button"
110
+ @click.stop="clear">
111
+ <XMarkIcon class="size-[1.25em]" />
112
+ </button>
113
+ <Transition name="input-field-fade" v-else>
91
114
  <ActivityIndicator
92
115
  v-if="props.activity && indicator"
93
116
  key="activity"