@vue-interface/input-field 2.0.21 → 3.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.
@@ -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, ref as R, useModel as j, computed as F, useTemplateRef as f, normalizeClass as x, unref as o, renderSlot as a, toDisplayString as b, createCommentVNode as m, normalizeProps as v, guardReactiveProps as y, withDirectives as G, mergeProps as U, vModelDynamic as q, withModifiers as H, createVNode as I, createBlock as C, Transition as J, withCtx as w, createTextVNode as K, mergeModels as A } from "vue";
2
+ import { ActivityIndicator as L } from "@vue-interface/activity-indicator";
3
+ import { useFormControl as O, FormControlErrors as Q, FormControlFeedback as W } from "@vue-interface/form-control";
4
+ function X(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 Y = ["for"], Z = { class: "form-control-inner" }, _ = { class: "form-control-activity-indicator" }, ee = {
5
22
  invalid: "",
6
23
  class: "invalid-feedback"
7
- }, O = {
24
+ }, te = {
8
25
  valid: "",
9
26
  class: "valid-feedback"
10
- }, Y = /* @__PURE__ */ S({
27
+ }, ae = /* @__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,126 @@ 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, S = R(), d = j(e, "modelValue"), D = 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
+ listeners: $
63
+ } = O({ model: d, props: r, emit: D }), p = F(() => !r.disabled && !r.readonly), h = F(() => r.clearable && (!!S.value || !!d.value) && p.value);
64
+ function g() {
65
+ p.value && (d.value = void 0);
66
+ }
67
+ const V = f("activity"), z = f("help"), T = f("label"), u = f("field"), M = f("wrapper");
68
+ return B({
69
+ activity: V,
70
+ help: z,
71
+ field: u,
72
+ label: T,
73
+ wrapper: M,
74
+ focus: () => u.value?.focus(),
75
+ blur: () => u.value?.blur()
76
+ }), (t, n) => (l(), c("div", {
55
77
  ref_key: "wrapper",
56
- ref: V,
57
- class: w(["input-field", t(N)])
78
+ ref: M,
79
+ class: x(["input-field", [o(E), { "has-clear-button": h.value }]])
58
80
  }, [
59
- l(o.$slots, "label", {}, () => [
60
- u.label ? (a(), m("label", {
81
+ a(t.$slots, "label", {}, () => [
82
+ r.label ? (l(), c("label", {
61
83
  key: 0,
62
84
  ref_key: "label",
63
- ref: B,
64
- class: w(e.labelClass),
65
- for: t(k).id
66
- }, f(u.label), 11, H)) : c("", !0)
85
+ ref: T,
86
+ class: x(e.labelClass),
87
+ for: o(k).id
88
+ }, b(r.label), 11, Y)) : m("", !0)
67
89
  ]),
68
- s("div", J, [
69
- l(o.$slots, "control", v(y({ controlAttributes: t(k), listeners: t(h) })), () => [
70
- o.$slots.icon ? (a(), m("div", {
90
+ i("div", Z, [
91
+ a(t.$slots, "control", v(y({ controlAttributes: o(k), listeners: o($) })), () => [
92
+ t.$slots.icon ? (l(), c("div", {
71
93
  key: 0,
72
94
  class: "form-control-inner-icon",
73
- onClick: r[0] || (r[0] = (i) => n.value?.focus())
95
+ onClick: n[0] || (n[0] = (s) => u.value?.focus())
74
96
  }, [
75
- l(o.$slots, "icon")
76
- ])) : c("", !0),
77
- E(s("input", I({
97
+ a(t.$slots, "icon")
98
+ ])) : m("", !0),
99
+ G(i("input", U({
78
100
  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]
101
+ ref: u,
102
+ "onUpdate:modelValue": n[1] || (n[1] = (s) => d.value = s)
103
+ }, { ...o(k), ...o($) }), null, 16), [
104
+ [q, d.value]
83
105
  ])
84
106
  ]),
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), {
107
+ i("div", _, [
108
+ a(t.$slots, "activity", v(y({ canClear: h.value, clear: g, isInteractive: p.value })), () => [
109
+ h.value ? (l(), c("button", {
110
+ key: 0,
111
+ type: "button",
112
+ class: "input-field-close-button",
113
+ onClick: H(g, ["stop"])
114
+ }, [
115
+ I(o(X), { class: "size-[1.25em]" })
116
+ ])) : (l(), C(J, {
117
+ key: 1,
118
+ name: "input-field-fade"
119
+ }, {
120
+ default: w(() => [
121
+ r.activity && e.indicator ? (l(), C(o(L), {
90
122
  key: "activity",
91
123
  ref_key: "activity",
92
- ref: C,
124
+ ref: V,
93
125
  type: e.indicator,
94
126
  size: e.indicatorSize
95
- }, null, 8, ["type", "size"])) : c("", !0)
127
+ }, null, 8, ["type", "size"])) : m("", !0)
96
128
  ]),
97
129
  _: 1
98
- })
130
+ }))
99
131
  ])
100
132
  ])
101
133
  ]),
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), {
134
+ a(t.$slots, "errors", v(y({ error: e.error, errors: e.errors, id: t.$attrs.id, name: t.$attrs.name })), () => [
135
+ e.error || e.errors ? (l(), C(o(Q), {
104
136
  key: 0,
105
137
  id: e.id,
106
138
  name: e.name,
107
139
  error: e.error,
108
140
  errors: e.errors
109
141
  }, {
110
- default: p(({ error: i }) => [
111
- s("div", L, [
112
- R(f(i), 1),
113
- r[2] || (r[2] = s("br", null, null, -1))
142
+ default: w(({ error: s }) => [
143
+ i("div", ee, [
144
+ K(b(s), 1),
145
+ n[2] || (n[2] = i("br", null, null, -1))
114
146
  ])
115
147
  ]),
116
148
  _: 1
117
- }, 8, ["id", "name", "error", "errors"])) : c("", !0)
149
+ }, 8, ["id", "name", "error", "errors"])) : m("", !0)
118
150
  ]),
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)
151
+ a(t.$slots, "feedback", v(y({ feedback: e.feedback })), () => [
152
+ I(o(W), { feedback: e.feedback }, {
153
+ default: w(({ feedback: s }) => [
154
+ i("div", te, b(s), 1)
123
155
  ]),
124
156
  _: 1
125
157
  }, 8, ["feedback"])
126
158
  ]),
127
- l(o.$slots, "help", v(y({ helpText: e.helpText })), () => [
128
- e.helpText ? (a(), m("small", {
159
+ a(t.$slots, "help", v(y({ helpText: e.helpText })), () => [
160
+ e.helpText ? (l(), c("small", {
129
161
  key: 0,
130
162
  ref_key: "help",
131
- ref: $,
163
+ ref: z,
132
164
  class: "form-help"
133
- }, f(e.helpText), 513)) : c("", !0)
165
+ }, b(e.helpText), 513)) : m("", !0)
134
166
  ])
135
167
  ], 2));
136
168
  }
137
169
  });
138
170
  export {
139
- Y as InputField
171
+ ae as InputField
140
172
  };
141
173
  //# 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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MAKvBxB,EASOC,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, ref } 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 input = ref<string>();\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 isInteractive = computed(() => !props.disabled && !props.readonly);\n\nconst canClear = computed(() => {\n return props.clearable && (!!input.value || !!model.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, 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","input","ref","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","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,IAC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B;AAAA,UACJ,OAAM;AAAA,QAAA,KACHjB,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,C,s){"use strict";function V(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 w=["for"],g={class:"form-control-inner"},N={class:"form-control-activity-indicator"},S={invalid:"",class:"invalid-feedback"},T={valid:"",class:"valid-feedback"},E=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:z}){const l=t,P=e.ref(),i=e.useModel(t,"modelValue"),$=z,{controlAttributes:d,formGroupClasses:R,listeners:u}=s.useFormControl({model:i,props:l,emit:$}),f=e.computed(()=>!l.disabled&&!l.readonly),m=e.computed(()=>l.clearable&&(!!P.value||!!i.value)&&f.value);function k(){f.value&&(i.value=void 0)}const y=e.useTemplateRef("activity"),b=e.useTemplateRef("help"),h=e.useTemplateRef("label"),c=e.useTemplateRef("field"),B=e.useTemplateRef("wrapper");return p({activity:y,help:b,field:c,label:h,wrapper:B,focus:()=>c.value?.focus(),blur:()=>c.value?.blur()}),(o,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapper",ref:B,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:h,class:e.normalizeClass(t.labelClass),for:e.unref(d).id},e.toDisplayString(l.label),11,w)):e.createCommentVNode("",!0)]),e.createElementVNode("div",g,[e.renderSlot(o.$slots,"control",e.normalizeProps(e.guardReactiveProps({controlAttributes:e.unref(d),listeners:e.unref(u)})),()=>[o.$slots.icon?(e.openBlock(),e.createElementBlock("div",{key:0,class:"form-control-inner-icon",onClick:n[0]||(n[0]=a=>c.value?.focus())},[e.renderSlot(o.$slots,"icon")])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({ref_key:"field",ref:c,"onUpdate:modelValue":n[1]||(n[1]=a=>i.value=a)},{...e.unref(d),...e.unref(u)}),null,16),[[e.vModelDynamic,i.value]])]),e.createElementVNode("div",N,[e.renderSlot(o.$slots,"activity",e.normalizeProps(e.guardReactiveProps({canClear:m.value,clear:k,isInteractive:f.value})),()=>[m.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"input-field-close-button",onClick:e.withModifiers(k,["stop"])},[e.createVNode(e.unref(V),{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(C.ActivityIndicator),{key:"activity",ref_key:"activity",ref:y,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",S,[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",T,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:b,class:"form-help"},e.toDisplayString(t.helpText),513)):e.createCommentVNode("",!0)])],2))}});r.InputField=E,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,eAA8F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A,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, ref } 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 input = ref<string>();\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 isInteractive = computed(() => !props.disabled && !props.readonly);\n\nconst canClear = computed(() => {\n return props.clearable && (!!input.value || !!model.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, 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","input","ref","model","_useModel","emit","__emit","controlAttributes","formGroupClasses","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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,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.1",
4
4
  "description": "A Vue input field component.",
5
5
  "type": "module",
6
6
  "main": "./dist/input-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.8",
49
- "@vue-interface/form-control": "2.0.20"
48
+ "@vue-interface/form-control": "2.0.21",
49
+ "@vue-interface/activity-indicator": "3.0.8"
50
50
  },
51
51
  "scripts": {
52
52
  "dev": "vite",
@@ -1,19 +1,22 @@
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, ref } 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({
14
16
  inheritAttrs: false
15
17
  });
16
18
 
19
+ const input = ref<string>();
17
20
  const model = defineModel<ModelValue>();
18
21
 
19
22
  defineSlots<FormControlSlots<InputFieldControlSizePrefix,ModelValue>>();
@@ -26,6 +29,17 @@ const {
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 && (!!input.value || !!model.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, 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"