@leaflink/stash 50.0.6 → 50.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Input.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as P, useSlots as U, useCssModule as G, useAttrs as L, ref as v, computed as c, watchEffect as W, onMounted as j, openBlock as f, createBlock as k, mergeProps as N, unref as l, createSlots as q, withCtx as x, createElementVNode as B, withDirectives as H, vModelDynamic as J, createElementBlock as C, normalizeClass as y, renderSlot as h, createCommentVNode as I } from "vue";
2
- import $ from "lodash-es/isNil";
3
- import { convertDecimal as E, sanitizeDecimal as K, decimalSeparator as b } from "./utils/i18n.js";
4
- import { _ as Q } from "./Field.vue_vue_type_script_setup_true_lang--tBfZB2K.js";
1
+ import { defineComponent as P, useSlots as U, useCssModule as q, useAttrs as G, ref as y, computed as c, watchEffect as L, onMounted as W, openBlock as f, createBlock as V, mergeProps as B, unref as l, createSlots as j, withCtx as k, createElementVNode as N, withDirectives as H, vModelDynamic as J, createElementBlock as x, normalizeClass as v, renderSlot as b, createCommentVNode as I } from "vue";
2
+ import C from "lodash-es/isNil";
3
+ import { convertDecimal as D, sanitizeDecimal as K, decimalSeparator as h } from "./utils/i18n.js";
4
+ import { _ as Q } from "./Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js";
5
5
  import X from "./Icon.js";
6
6
  import { _ as Y } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
7
  const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-invalid", "autocomplete", "placeholder", "type", "disabled", "readonly"], te = /* @__PURE__ */ P({
@@ -9,41 +9,45 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
9
9
  inheritAttrs: !1,
10
10
  __name: "Input",
11
11
  props: {
12
- addBottomSpace: { type: Boolean },
13
- errorText: { default: void 0 },
14
- hintText: { default: void 0 },
15
- id: { default: void 0 },
16
- label: { default: void 0 },
17
- showOptionalInLabel: { type: Boolean },
18
12
  autocomplete: { default: "off" },
19
13
  modelValue: { default: "" },
20
14
  value: { default: null },
21
15
  type: { default: "text" },
22
16
  placeholder: { default: void 0 },
23
- disabled: { type: Boolean, default: !1 },
24
- isReadOnly: { type: Boolean, default: !1 }
17
+ addBottomSpace: { type: Boolean },
18
+ errorText: {},
19
+ hintText: {},
20
+ id: {},
21
+ errorId: {},
22
+ isReadOnly: { type: Boolean },
23
+ isRequired: { type: Boolean },
24
+ label: {},
25
+ showOptionalInLabel: { type: Boolean },
26
+ fieldset: { type: Boolean },
27
+ isDisabled: { type: Boolean },
28
+ disabled: { type: Boolean }
25
29
  },
26
30
  emits: ["update:model-value", "change", "focus", "blur"],
27
- setup(S, { expose: D, emit: M }) {
28
- const e = S, m = M, r = U(), n = G(), p = L(), _ = v();
29
- D({ inputEl: _ });
30
- const s = v(e.modelValue);
31
- e.type === "number" && (e.modelValue || e.modelValue === 0) && (s.value = E(e.modelValue, b));
32
- const d = v(!1), g = c(() => e.isReadOnly || "readonly" in p && p.readonly !== !1), i = c(() => e.type === "number"), A = c(() => {
33
- const o = { ...p };
31
+ setup($, { expose: E, emit: S }) {
32
+ const e = $, m = S, r = U(), s = q(), u = G(), _ = y();
33
+ E({ inputEl: _ });
34
+ const n = y(e.modelValue);
35
+ e.type === "number" && (e.modelValue || e.modelValue === 0) && (n.value = D(e.modelValue, h));
36
+ const i = y(!1), M = c(() => e.isReadOnly || "readonly" in u && u.readonly !== !1), d = c(() => e.type === "number"), A = c(() => {
37
+ const o = { ...u };
34
38
  return delete o.class, o;
35
- }), F = c(() => i.value || e.type === "password" && d.value ? "text" : e.type);
36
- W(() => {
37
- s.value = V(e.modelValue);
39
+ }), F = c(() => d.value || e.type === "password" && i.value ? "text" : e.type);
40
+ L(() => {
41
+ n.value = w(e.modelValue);
38
42
  });
39
- function w(o = "", a = !1) {
40
- if (!i.value)
43
+ function g(o = "", a = !1) {
44
+ if (!d.value)
41
45
  return o;
42
46
  let t = o;
43
- if ($(t) || `${t}`.length === 0) return "";
44
- if (b !== "." && (t = E(t, ".")), a && (t === "." && (t = "0."), t.toString().startsWith("0.")))
47
+ if (C(t) || `${t}`.length === 0) return "";
48
+ if (h !== "." && (t = D(t, ".")), a && (t === "." && (t = "0."), t.toString().startsWith("0.")))
45
49
  return t;
46
- if (!$(t) && `${t}`.length)
50
+ if (!C(t) && `${t}`.length)
47
51
  t = Intl.NumberFormat("en-US", {
48
52
  style: "decimal",
49
53
  maximumFractionDigits: 7,
@@ -53,71 +57,70 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
53
57
  return "";
54
58
  return isNaN(Number(t)) ? "" : parseFloat(t);
55
59
  }
56
- function V(o) {
57
- return i.value ? K(o, b) : o;
60
+ function w(o) {
61
+ return d.value ? K(o, h) : o;
58
62
  }
59
63
  function O() {
60
- const o = i.value ? w(s.value) : s.value;
64
+ const o = d.value ? g(n.value) : n.value;
61
65
  m("change", o);
62
66
  }
63
- function T(o) {
67
+ function R(o) {
64
68
  const a = o.target.value;
65
- s.value = V(a);
66
- const t = i.value ? w(s.value, !0) : a;
69
+ n.value = w(a);
70
+ const t = d.value ? g(n.value, !0) : a;
67
71
  m("update:model-value", t);
68
72
  }
69
- return j(() => {
73
+ return W(() => {
70
74
  if (e.value !== null)
71
75
  throw new Error("ll-input: use :model-value or v-model instead of :value.");
72
- if (p.onInput)
76
+ if (u.onInput)
73
77
  throw new Error("ll-input: use the @update:model-value event instead of @input");
74
- }), (o, a) => (f(), k(Q, N(e, {
75
- "is-read-only": g.value,
76
- class: ["stash-input", [l(n).root, l(p).class]],
78
+ }), (o, a) => (f(), V(Q, B(e, {
79
+ class: ["stash-input", [l(s).root, l(u).class]],
77
80
  "data-test": "ll-input"
78
- }), q({
79
- default: x(({ fieldId: t, fieldErrorId: R, hasError: z }) => [
80
- B("div", Z, [
81
- H(B("input", N(A.value, {
81
+ }), j({
82
+ default: k(({ fieldId: t, fieldErrorId: T, hasError: z }) => [
83
+ N("div", Z, [
84
+ H(N("input", B(A.value, {
82
85
  id: t,
83
86
  ref_key: "inputEl",
84
87
  ref: _,
85
- "onUpdate:modelValue": a[0] || (a[0] = (u) => s.value = u),
86
- "aria-errormessage": R,
88
+ "onUpdate:modelValue": a[0] || (a[0] = (p) => n.value = p),
89
+ "aria-errormessage": T,
87
90
  "aria-invalid": z,
88
91
  autocomplete: o.autocomplete,
89
92
  placeholder: e.placeholder,
90
93
  class: [
91
- { [l(n)["input-prepended"]]: !!l(r).prepend },
92
- { [l(n)["input-appended"]]: !!l(r).append || e.type === "password" },
93
- { [l(n)["has-error"]]: !!e.errorText }
94
+ { [l(s)["input-prepended"]]: !!l(r).prepend },
95
+ { [l(s)["input-appended"]]: !!l(r).append || e.type === "password" },
96
+ { [l(s)["has-error"]]: !!e.errorText }
94
97
  ],
95
98
  type: F.value,
96
- disabled: e.disabled,
97
- readonly: g.value,
99
+ disabled: e.isDisabled || e.disabled,
100
+ readonly: M.value,
98
101
  onChange: O,
99
- onInput: T,
100
- onBlur: a[1] || (a[1] = (u) => m("blur", u)),
101
- onFocus: a[2] || (a[2] = (u) => m("focus", u))
102
+ onInput: R,
103
+ onBlur: a[1] || (a[1] = (p) => m("blur", p)),
104
+ onFocus: a[2] || (a[2] = (p) => m("focus", p))
102
105
  }), null, 16, ee), [
103
- [J, s.value]
106
+ [J, n.value]
104
107
  ]),
105
- l(r).prepend ? (f(), C("div", {
108
+ l(r).prepend ? (f(), x("div", {
106
109
  key: 0,
107
- class: y(["stash-input-prepend font-semibold", [l(n).symbol, l(n)["symbol--prepend"]]])
110
+ class: v(["stash-input-prepend font-semibold", [l(s).symbol, l(s)["symbol--prepend"]]])
108
111
  }, [
109
- h(o.$slots, "prepend")
112
+ b(o.$slots, "prepend")
110
113
  ], 2)) : I("", !0),
111
- l(r).append || e.type === "password" ? (f(), C("div", {
114
+ l(r).append || e.type === "password" ? (f(), x("div", {
112
115
  key: 1,
113
- class: y(["stash-input-append font-semibold", [l(n).symbol, l(n)["symbol--append"]]])
116
+ class: v(["stash-input-append font-semibold", [l(s).symbol, l(s)["symbol--append"]]])
114
117
  }, [
115
- l(r).append ? h(o.$slots, "append", { key: 0 }) : (f(), k(X, {
118
+ l(r).append ? b(o.$slots, "append", { key: 0 }) : (f(), V(X, {
116
119
  key: 1,
117
- name: d.value ? "hide" : "show",
118
- class: y(["tw-cursor-pointer", { "tw-text-ice-500": e.disabled }]),
119
- "data-test": d.value ? "hide-password-icon" : "show-password-icon",
120
- onClick: a[3] || (a[3] = (u) => d.value = !d.value)
120
+ name: i.value ? "hide" : "show",
121
+ class: v(["tw-cursor-pointer", { "tw-text-ice-500": e.isDisabled || e.disabled }]),
122
+ "data-test": i.value ? "hide-password-icon" : "show-password-icon",
123
+ onClick: a[3] || (a[3] = (p) => i.value = !i.value)
121
124
  }, null, 8, ["name", "class", "data-test"]))
122
125
  ], 2)) : I("", !0)
123
126
  ])
@@ -126,12 +129,12 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
126
129
  }, [
127
130
  l(r).hint ? {
128
131
  name: "hint",
129
- fn: x(() => [
130
- h(o.$slots, "hint")
132
+ fn: k(() => [
133
+ b(o.$slots, "hint")
131
134
  ]),
132
135
  key: "0"
133
136
  } : void 0
134
- ]), 1040, ["is-read-only", "class"]));
137
+ ]), 1040, ["class"]));
135
138
  }
136
139
  }), oe = "_root_1tgop_2", le = "_symbol_1tgop_46", ae = {
137
140
  root: oe,
@@ -141,9 +144,9 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
141
144
  symbol: le,
142
145
  "symbol--prepend": "_symbol--prepend_1tgop_57",
143
146
  "symbol--append": "_symbol--append_1tgop_63"
144
- }, ne = {
147
+ }, se = {
145
148
  $style: ae
146
- }, me = /* @__PURE__ */ Y(te, [["__cssModules", ne]]);
149
+ }, me = /* @__PURE__ */ Y(te, [["__cssModules", se]]);
147
150
  export {
148
151
  me as default
149
152
  };
package/dist/Input.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sources":["../src/components/Input/Input.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import isNil from 'lodash-es/isNil';\n import { computed, onMounted, ref, useAttrs, useCssModule, useSlots, watchEffect } from 'vue';\n\n import { convertDecimal, decimalSeparator, sanitizeDecimal } from '../../utils/i18n';\n import Field from '../Field/Field.vue';\n import Icon from '../Icon/Icon.vue';\n\n export type InputValue = string | number | undefined;\n\n export interface InputProps {\n /**\n * Adds spacing under the field that is consistent whether or not hint/error text is displayed.\n */\n addBottomSpace?: boolean;\n\n /**\n * Error text to display. Replaces `hintText` (if provided) & adds error styling.\n */\n errorText?: string;\n\n /**\n * Displays text below the input; hidden when the isReadOnly prop is truthy.\n */\n hintText?: string;\n\n /**\n * ID for the Label and Input; must be unique\n */\n id?: string;\n\n /**\n * Label to render above the input.\n */\n label?: string;\n\n /**\n * Show \"(optional)\" to the right of the label text\n */\n showOptionalInLabel?: boolean;\n\n /**\n * Autocomplete takes in a string of off or on\n */\n autocomplete?: string;\n\n /**\n * Value for the input element.\n */\n modelValue?: string | number;\n\n /**\n * @deprecated Use :model-value or v-model instead of :value.\n */\n value?: string | number | null;\n\n /**\n * Input type. Excludes certain types that have a dedicated component.\n *\n * Note: For distinguishing between text & number internally, passing `number`\n * will still render an input with a type of `text` (for localization).\n */\n type?: string extends 'button' | 'checkbox' | 'radio' | 'submit' ? never : string;\n\n /**\n * Placeholder text for the input.\n * **Note:** placeholders should be used to display examples; they should not be used as labels because they are not accessible as labels. If a real label cannot be used, use the `aria-label` attribute.\n */\n placeholder?: string;\n\n /**\n * Indicates whether the input is disabled.\n */\n disabled?: boolean;\n\n /**\n * Indicates whether the input is read-only.\n */\n isReadOnly?: boolean;\n }\n\n defineOptions({\n name: 'll-input',\n inheritAttrs: false,\n });\n\n const props = withDefaults(defineProps<InputProps>(), {\n autocomplete: 'off',\n type: 'text',\n modelValue: '',\n value: null,\n errorText: undefined,\n hintText: undefined,\n label: undefined,\n id: undefined,\n placeholder: undefined,\n disabled: false,\n isReadOnly: false,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the input value changes.\n */\n (e: 'update:model-value', v: string | number): void;\n /**\n * Emitted when the input value changes.\n */\n (e: 'change', v: string | number): void;\n /**\n * Emitted when the input is focused\n */\n (e: 'focus', evt: Event): void;\n /**\n * Emitted when the input is blurred\n */\n (e: 'blur', evt: Event): void;\n }>();\n\n const slots = useSlots();\n const classes = useCssModule();\n const attrs = useAttrs();\n\n // declare a ref to hold the element reference\n // the name must match template ref value\n const inputEl = ref<HTMLInputElement>();\n\n // this exposes the input ref to any parent that renders the `Input` component\n // and gives it a template ref, giving parent components access to the DOM element.\n defineExpose({ inputEl });\n\n const internalValue = ref<string | number>(props.modelValue);\n\n if (props.type === 'number' && (props.modelValue || props.modelValue === 0)) {\n internalValue.value = convertDecimal(props.modelValue, decimalSeparator);\n }\n\n const showPassword = ref(false);\n\n const isReadOnly = computed(() => props.isReadOnly || ('readonly' in attrs && attrs.readonly !== false));\n const isNumber = computed(() => props.type === 'number');\n\n const inputAttrs = computed(() => {\n const tempAttrs = { ...attrs };\n\n delete tempAttrs.class;\n\n return tempAttrs;\n });\n\n const inputType = computed(() => {\n // type 'number' is a special use case and requires\n // that the type be 'text' to support internationalization\n if (isNumber.value) {\n return 'text';\n }\n\n if (props.type === 'password' && showPassword.value) {\n return 'text';\n }\n\n return props.type;\n });\n\n watchEffect(() => {\n internalValue.value = format(props.modelValue);\n });\n\n /**\n * Converts the localized number to a valid number (to emit). i.e. 12,50 > 12.50\n *\n * @param {string|number} value - Number you want to parse.\n * @returns {number|string} number or empty string (for empty input)\n */\n function parseNumber(value: string | number = '', isUserTyping = false): string | number {\n // If this isn't a number input, we shouldn't be calling this function\n if (!isNumber.value) {\n return value;\n }\n\n let tempValue = value;\n\n // If blank, just stop\n if (isNil(tempValue) || `${tempValue}`.length === 0) return '';\n\n // clean out different locale decimals\n if (decimalSeparator !== '.') {\n tempValue = convertDecimal(tempValue, '.');\n }\n\n // If the user is in the middle of an input, let them finish the number\n if (isUserTyping) {\n // Prefix values with a 0 if the user starts with a decimal point\n if (tempValue === '.') tempValue = '0.';\n\n // This is to prevent the parsing from correcting 0. to 0 and causing the value to be reset\n if (tempValue.toString().startsWith('0.')) return tempValue;\n }\n\n // Empty or null values convert to 0 with NumberFormat, so return '';\n if (!isNil(tempValue) && `${tempValue}`.length) {\n tempValue = Intl.NumberFormat('en-US', {\n style: 'decimal',\n maximumFractionDigits: 7,\n useGrouping: false,\n }).format(Number(tempValue));\n } else {\n return '';\n }\n\n // Ensure valid number, otherwise clear value\n return isNaN(Number(tempValue)) ? '' : parseFloat(tempValue);\n }\n\n /**\n * Formats the input based on conditions\n *\n * @param {number|string} value - The value to format.\n */\n function format(value: string | number) {\n if (isNumber.value) {\n return sanitizeDecimal(value, decimalSeparator);\n }\n\n return value;\n }\n\n /**\n * Fire after focusing out of input, if value has changed.\n */\n function handleChange() {\n // Parse the final value on blur\n const parsedValue = isNumber.value ? parseNumber(internalValue.value) : internalValue.value;\n emit('change', parsedValue);\n }\n\n /**\n * Fired when typing on input.\n */\n function handleInput(e: Event) {\n const value = (e.target as HTMLInputElement).value;\n\n // Update the internal value with a sanitized version\n internalValue.value = format(value);\n\n const parsedValue = isNumber.value ? parseNumber(internalValue.value, true) : value;\n\n emit('update:model-value', parsedValue);\n }\n\n onMounted(() => {\n if (props.value !== null) {\n throw new Error('ll-input: use :model-value or v-model instead of :value.');\n }\n\n if (attrs.onInput) {\n throw new Error('ll-input: use the @update:model-value event instead of @input');\n }\n });\n</script>\n\n<template>\n <Field\n v-bind=\"props\"\n :is-read-only=\"isReadOnly\"\n class=\"stash-input\"\n :class=\"[classes.root, attrs.class]\"\n data-test=\"ll-input\"\n >\n <template #default=\"{ fieldId, fieldErrorId, hasError }\">\n <div class=\"tw-relative\">\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"inputEl\"\n v-model=\"internalValue\"\n :aria-errormessage=\"fieldErrorId\"\n :aria-invalid=\"hasError\"\n :autocomplete=\"autocomplete\"\n :placeholder=\"props.placeholder\"\n :class=\"[\n { [classes['input-prepended']]: !!slots.prepend },\n { [classes['input-appended']]: !!slots.append || props.type === 'password' },\n { [classes['has-error']]: !!props.errorText },\n ]\"\n :type=\"inputType\"\n :disabled=\"props.disabled\"\n :readonly=\"isReadOnly\"\n @change=\"handleChange\"\n @input=\"handleInput\"\n @blur=\"(evt) => emit('blur', evt)\"\n @focus=\"(evt) => emit('focus', evt)\"\n />\n\n <div\n v-if=\"slots.prepend\"\n class=\"stash-input-prepend font-semibold\"\n :class=\"[classes.symbol, classes['symbol--prepend']]\"\n >\n <!-- @slot renders content on the left side of the input -->\n <slot name=\"prepend\"> </slot>\n </div>\n\n <div\n v-if=\"slots.append || props.type === 'password'\"\n class=\"stash-input-append font-semibold\"\n :class=\"[classes.symbol, classes['symbol--append']]\"\n >\n <!-- @slot renders content on the right side of the input -->\n <slot v-if=\"slots.append\" name=\"append\"></slot>\n <Icon\n v-else\n :name=\"showPassword ? 'hide' : 'show'\"\n class=\"tw-cursor-pointer\"\n :class=\"{ 'tw-text-ice-500': props.disabled }\"\n :data-test=\"showPassword ? 'hide-password-icon' : 'show-password-icon'\"\n @click=\"showPassword = !showPassword\"\n />\n </div>\n </div>\n </template>\n <template v-if=\"slots.hint\" #hint>\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style module>\n .root {\n position: relative;\n }\n\n .root input {\n background: var(--color-white);\n border: 1px solid var(--color-ice-500);\n border-radius: theme('borderRadius.DEFAULT');\n color: var(--color-ice-700);\n display: block;\n height: theme('height.input');\n font-size: theme('fontSize.sm');\n font-weight: theme('fontWeight.normal');\n outline: none;\n padding: 0 theme('spacing.3');\n width: 100%;\n }\n\n .root input:hover {\n border-color: var(--color-ice-500);\n }\n\n .root input:active,\n .root input:focus {\n border-color: var(--color-blue-500);\n }\n\n .root input::placeholder {\n color: var(--color-ice-500);\n opacity: 1;\n }\n\n .root input.has-error:not(:focus) {\n border-color: var(--color-red-500);\n }\n\n .root input.input-prepended {\n padding-left: 36px;\n }\n\n .root input.input-appended {\n padding-right: 36px;\n }\n\n .symbol {\n align-items: center;\n display: flex;\n height: theme('height.input');\n justify-content: center;\n overflow: hidden;\n position: absolute;\n top: 0;\n width: theme('height.input');\n }\n\n .symbol--prepend {\n border-bottom-left-radius: theme('borderRadius.DEFAULT');\n border-top-left-radius: theme('borderRadius.DEFAULT');\n left: 0;\n }\n\n .symbol--append {\n border-bottom-right-radius: theme('borderRadius.DEFAULT');\n border-top-right-radius: theme('borderRadius.DEFAULT');\n right: 0;\n }\n\n .root input[disabled] {\n background-color: var(--color-ice-100) !important;\n border-color: var(--color-ice-500) !important;\n color: var(--color-ice-500) !important;\n pointer-events: none;\n outline-color: var(--color-ice-500) !important;\n\n & + .symbol--prepend,\n & + .symbol--append {\n color: var(--color-ice-500);\n }\n }\n\n .root input[readonly] {\n border-color: transparent;\n background-color: transparent;\n padding-left: 0;\n padding-right: 0;\n }\n\n .root input[disabled]:active,\n .root input[readonly]:active,\n .root input[disabled]:focus,\n .root input[readonly]:focus {\n box-shadow: none !important;\n }\n\n .root input[disabled]::placeholder {\n text-transform: none;\n }\n</style>\n"],"names":["props","__props","emit","__emit","slots","useSlots","classes","useCssModule","attrs","useAttrs","inputEl","ref","__expose","internalValue","convertDecimal","decimalSeparator","showPassword","isReadOnly","computed","isNumber","inputAttrs","tempAttrs","inputType","watchEffect","format","parseNumber","value","isUserTyping","tempValue","isNil","sanitizeDecimal","handleChange","parsedValue","handleInput","e","onMounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFE,UAAMA,IAAQC,GAcRC,IAAOC,GAmBPC,IAAQC,KACRC,IAAUC,KACVC,IAAQC,KAIRC,IAAUC;AAIH,IAAAC,EAAA,EAAE,SAAAF,GAAS;AAElB,UAAAG,IAAgBF,EAAqBX,EAAM,UAAU;AAE3D,IAAIA,EAAM,SAAS,aAAaA,EAAM,cAAcA,EAAM,eAAe,OACvEa,EAAc,QAAQC,EAAed,EAAM,YAAYe,CAAgB;AAGnE,UAAAC,IAAeL,EAAI,EAAK,GAExBM,IAAaC,EAAS,MAAMlB,EAAM,cAAe,cAAcQ,KAASA,EAAM,aAAa,EAAM,GACjGW,IAAWD,EAAS,MAAMlB,EAAM,SAAS,QAAQ,GAEjDoB,IAAaF,EAAS,MAAM;AAC1B,YAAAG,IAAY,EAAE,GAAGb;AAEvB,oBAAOa,EAAU,OAEVA;AAAA,IAAA,CACR,GAEKC,IAAYJ,EAAS,MAGrBC,EAAS,SAITnB,EAAM,SAAS,cAAcgB,EAAa,QACrC,SAGFhB,EAAM,IACd;AAED,IAAAuB,EAAY,MAAM;AACF,MAAAV,EAAA,QAAQW,EAAOxB,EAAM,UAAU;AAAA,IAAA,CAC9C;AAQD,aAASyB,EAAYC,IAAyB,IAAIC,IAAe,IAAwB;AAEnF,UAAA,CAACR,EAAS;AACL,eAAAO;AAGT,UAAIE,IAAYF;AAGZ,UAAAG,EAAMD,CAAS,KAAK,GAAGA,CAAS,GAAG,WAAW,EAAU,QAAA;AAQ5D,UALIb,MAAqB,QACXa,IAAAd,EAAec,GAAW,GAAG,IAIvCD,MAEEC,MAAc,QAAiBA,IAAA,OAG/BA,EAAU,SAAS,EAAE,WAAW,IAAI;AAAU,eAAAA;AAIpD,UAAI,CAACC,EAAMD,CAAS,KAAK,GAAGA,CAAS,GAAG;AAC1B,QAAAA,IAAA,KAAK,aAAa,SAAS;AAAA,UACrC,OAAO;AAAA,UACP,uBAAuB;AAAA,UACvB,aAAa;AAAA,QACd,CAAA,EAAE,OAAO,OAAOA,CAAS,CAAC;AAAA;AAEpB,eAAA;AAIT,aAAO,MAAM,OAAOA,CAAS,CAAC,IAAI,KAAK,WAAWA,CAAS;AAAA,IAC7D;AAOA,aAASJ,EAAOE,GAAwB;AACtC,aAAIP,EAAS,QACJW,EAAgBJ,GAAOX,CAAgB,IAGzCW;AAAA,IACT;AAKA,aAASK,IAAe;AAEtB,YAAMC,IAAcb,EAAS,QAAQM,EAAYZ,EAAc,KAAK,IAAIA,EAAc;AACtF,MAAAX,EAAK,UAAU8B,CAAW;AAAA,IAC5B;AAKA,aAASC,EAAYC,GAAU;AACvB,YAAAR,IAASQ,EAAE,OAA4B;AAG/B,MAAArB,EAAA,QAAQW,EAAOE,CAAK;AAElC,YAAMM,IAAcb,EAAS,QAAQM,EAAYZ,EAAc,OAAO,EAAI,IAAIa;AAE9E,MAAAxB,EAAK,sBAAsB8B,CAAW;AAAA,IACxC;AAEA,WAAAG,EAAU,MAAM;AACV,UAAAnC,EAAM,UAAU;AACZ,cAAA,IAAI,MAAM,0DAA0D;AAG5E,UAAIQ,EAAM;AACF,cAAA,IAAI,MAAM,+DAA+D;AAAA,IACjF,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Input.js","sources":["../src/components/Input/Input.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import isNil from 'lodash-es/isNil';\n import { computed, onMounted, ref, useAttrs, useCssModule, useSlots, watchEffect } from 'vue';\n\n import { convertDecimal, decimalSeparator, sanitizeDecimal } from '../../utils/i18n';\n import Field, { type FieldProps } from '../Field/Field.vue';\n import Icon from '../Icon/Icon.vue';\n\n export type InputValue = string | number | undefined;\n\n export interface InputProps extends FieldProps {\n /**\n * Autocomplete takes in a string of off or on\n */\n autocomplete?: string;\n\n /**\n * Value for the input element.\n */\n modelValue?: string | number;\n\n /**\n * @deprecated Use :model-value or v-model instead of :value.\n */\n value?: string | number | null;\n\n /**\n * Input type. Excludes certain types that have a dedicated component.\n *\n * Note: For distinguishing between text & number internally, passing `number`\n * will still render an input with a type of `text` (for localization).\n */\n type?: string extends 'button' | 'checkbox' | 'radio' | 'submit' ? never : string;\n\n /**\n * Placeholder text for the input.\n * **Note:** placeholders should be used to display examples; they should not be used as labels because they are not accessible as labels. If a real label cannot be used, use the `aria-label` attribute.\n */\n placeholder?: string;\n }\n\n defineOptions({\n name: 'll-input',\n inheritAttrs: false,\n });\n\n const props = withDefaults(defineProps<InputProps>(), {\n autocomplete: 'off',\n type: 'text',\n modelValue: '',\n value: null,\n placeholder: undefined,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the input value changes.\n */\n (e: 'update:model-value', v: string | number): void;\n /**\n * Emitted when the input value changes.\n */\n (e: 'change', v: string | number): void;\n /**\n * Emitted when the input is focused\n */\n (e: 'focus', evt: Event): void;\n /**\n * Emitted when the input is blurred\n */\n (e: 'blur', evt: Event): void;\n }>();\n\n const slots = useSlots();\n const classes = useCssModule();\n const attrs = useAttrs();\n\n // declare a ref to hold the element reference\n // the name must match template ref value\n const inputEl = ref<HTMLInputElement>();\n\n // this exposes the input ref to any parent that renders the `Input` component\n // and gives it a template ref, giving parent components access to the DOM element.\n defineExpose({ inputEl });\n\n const internalValue = ref<string | number>(props.modelValue);\n\n if (props.type === 'number' && (props.modelValue || props.modelValue === 0)) {\n internalValue.value = convertDecimal(props.modelValue, decimalSeparator);\n }\n\n const showPassword = ref(false);\n\n const isReadOnly = computed(() => props.isReadOnly || ('readonly' in attrs && attrs.readonly !== false));\n const isNumber = computed(() => props.type === 'number');\n\n const inputAttrs = computed(() => {\n const tempAttrs = { ...attrs };\n\n delete tempAttrs.class;\n\n return tempAttrs;\n });\n\n const inputType = computed(() => {\n // type 'number' is a special use case and requires\n // that the type be 'text' to support internationalization\n if (isNumber.value) {\n return 'text';\n }\n\n if (props.type === 'password' && showPassword.value) {\n return 'text';\n }\n\n return props.type;\n });\n\n watchEffect(() => {\n internalValue.value = format(props.modelValue);\n });\n\n /**\n * Converts the localized number to a valid number (to emit). i.e. 12,50 > 12.50\n *\n * @param {string|number} value - Number you want to parse.\n * @returns {number|string} number or empty string (for empty input)\n */\n function parseNumber(value: string | number = '', isUserTyping = false): string | number {\n // If this isn't a number input, we shouldn't be calling this function\n if (!isNumber.value) {\n return value;\n }\n\n let tempValue = value;\n\n // If blank, just stop\n if (isNil(tempValue) || `${tempValue}`.length === 0) return '';\n\n // clean out different locale decimals\n if (decimalSeparator !== '.') {\n tempValue = convertDecimal(tempValue, '.');\n }\n\n // If the user is in the middle of an input, let them finish the number\n if (isUserTyping) {\n // Prefix values with a 0 if the user starts with a decimal point\n if (tempValue === '.') tempValue = '0.';\n\n // This is to prevent the parsing from correcting 0. to 0 and causing the value to be reset\n if (tempValue.toString().startsWith('0.')) return tempValue;\n }\n\n // Empty or null values convert to 0 with NumberFormat, so return '';\n if (!isNil(tempValue) && `${tempValue}`.length) {\n tempValue = Intl.NumberFormat('en-US', {\n style: 'decimal',\n maximumFractionDigits: 7,\n useGrouping: false,\n }).format(Number(tempValue));\n } else {\n return '';\n }\n\n // Ensure valid number, otherwise clear value\n return isNaN(Number(tempValue)) ? '' : parseFloat(tempValue);\n }\n\n /**\n * Formats the input based on conditions\n *\n * @param {number|string} value - The value to format.\n */\n function format(value: string | number) {\n if (isNumber.value) {\n return sanitizeDecimal(value, decimalSeparator);\n }\n\n return value;\n }\n\n /**\n * Fire after focusing out of input, if value has changed.\n */\n function handleChange() {\n // Parse the final value on blur\n const parsedValue = isNumber.value ? parseNumber(internalValue.value) : internalValue.value;\n emit('change', parsedValue);\n }\n\n /**\n * Fired when typing on input.\n */\n function handleInput(e: Event) {\n const value = (e.target as HTMLInputElement).value;\n\n // Update the internal value with a sanitized version\n internalValue.value = format(value);\n\n const parsedValue = isNumber.value ? parseNumber(internalValue.value, true) : value;\n\n emit('update:model-value', parsedValue);\n }\n\n onMounted(() => {\n if (props.value !== null) {\n throw new Error('ll-input: use :model-value or v-model instead of :value.');\n }\n\n if (attrs.onInput) {\n throw new Error('ll-input: use the @update:model-value event instead of @input');\n }\n });\n</script>\n\n<template>\n <Field v-bind=\"props\" class=\"stash-input\" :class=\"[classes.root, attrs.class]\" data-test=\"ll-input\">\n <template #default=\"{ fieldId, fieldErrorId, hasError }\">\n <div class=\"tw-relative\">\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"inputEl\"\n v-model=\"internalValue\"\n :aria-errormessage=\"fieldErrorId\"\n :aria-invalid=\"hasError\"\n :autocomplete=\"autocomplete\"\n :placeholder=\"props.placeholder\"\n :class=\"[\n { [classes['input-prepended']]: !!slots.prepend },\n { [classes['input-appended']]: !!slots.append || props.type === 'password' },\n { [classes['has-error']]: !!props.errorText },\n ]\"\n :type=\"inputType\"\n :disabled=\"props.isDisabled || props.disabled\"\n :readonly=\"isReadOnly\"\n @change=\"handleChange\"\n @input=\"handleInput\"\n @blur=\"(evt) => emit('blur', evt)\"\n @focus=\"(evt) => emit('focus', evt)\"\n />\n\n <div\n v-if=\"slots.prepend\"\n class=\"stash-input-prepend font-semibold\"\n :class=\"[classes.symbol, classes['symbol--prepend']]\"\n >\n <!-- @slot renders content on the left side of the input -->\n <slot name=\"prepend\"> </slot>\n </div>\n\n <div\n v-if=\"slots.append || props.type === 'password'\"\n class=\"stash-input-append font-semibold\"\n :class=\"[classes.symbol, classes['symbol--append']]\"\n >\n <!-- @slot renders content on the right side of the input -->\n <slot v-if=\"slots.append\" name=\"append\"></slot>\n <Icon\n v-else\n :name=\"showPassword ? 'hide' : 'show'\"\n class=\"tw-cursor-pointer\"\n :class=\"{ 'tw-text-ice-500': props.isDisabled || props.disabled }\"\n :data-test=\"showPassword ? 'hide-password-icon' : 'show-password-icon'\"\n @click=\"showPassword = !showPassword\"\n />\n </div>\n </div>\n </template>\n <template v-if=\"slots.hint\" #hint>\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style module>\n .root {\n position: relative;\n }\n\n .root input {\n background: var(--color-white);\n border: 1px solid var(--color-ice-500);\n border-radius: theme('borderRadius.DEFAULT');\n color: var(--color-ice-700);\n display: block;\n height: theme('height.input');\n font-size: theme('fontSize.sm');\n font-weight: theme('fontWeight.normal');\n outline: none;\n padding: 0 theme('spacing.3');\n width: 100%;\n }\n\n .root input:hover {\n border-color: var(--color-ice-500);\n }\n\n .root input:active,\n .root input:focus {\n border-color: var(--color-blue-500);\n }\n\n .root input::placeholder {\n color: var(--color-ice-500);\n opacity: 1;\n }\n\n .root input.has-error:not(:focus) {\n border-color: var(--color-red-500);\n }\n\n .root input.input-prepended {\n padding-left: 36px;\n }\n\n .root input.input-appended {\n padding-right: 36px;\n }\n\n .symbol {\n align-items: center;\n display: flex;\n height: theme('height.input');\n justify-content: center;\n overflow: hidden;\n position: absolute;\n top: 0;\n width: theme('height.input');\n }\n\n .symbol--prepend {\n border-bottom-left-radius: theme('borderRadius.DEFAULT');\n border-top-left-radius: theme('borderRadius.DEFAULT');\n left: 0;\n }\n\n .symbol--append {\n border-bottom-right-radius: theme('borderRadius.DEFAULT');\n border-top-right-radius: theme('borderRadius.DEFAULT');\n right: 0;\n }\n\n .root input[disabled] {\n background-color: var(--color-ice-100) !important;\n border-color: var(--color-ice-500) !important;\n color: var(--color-ice-500) !important;\n pointer-events: none;\n outline-color: var(--color-ice-500) !important;\n\n & + .symbol--prepend,\n & + .symbol--append {\n color: var(--color-ice-500);\n }\n }\n\n .root input[readonly] {\n border-color: transparent;\n background-color: transparent;\n padding-left: 0;\n padding-right: 0;\n }\n\n .root input[disabled]:active,\n .root input[readonly]:active,\n .root input[disabled]:focus,\n .root input[readonly]:focus {\n box-shadow: none !important;\n }\n\n .root input[disabled]::placeholder {\n text-transform: none;\n }\n</style>\n"],"names":["props","__props","emit","__emit","slots","useSlots","classes","useCssModule","attrs","useAttrs","inputEl","ref","__expose","internalValue","convertDecimal","decimalSeparator","showPassword","isReadOnly","computed","isNumber","inputAttrs","tempAttrs","inputType","watchEffect","format","parseNumber","value","isUserTyping","tempValue","isNil","sanitizeDecimal","handleChange","parsedValue","handleInput","e","onMounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CE,UAAMA,IAAQC,GAQRC,IAAOC,GAmBPC,IAAQC,KACRC,IAAUC,KACVC,IAAQC,KAIRC,IAAUC;AAIH,IAAAC,EAAA,EAAE,SAAAF,GAAS;AAElB,UAAAG,IAAgBF,EAAqBX,EAAM,UAAU;AAE3D,IAAIA,EAAM,SAAS,aAAaA,EAAM,cAAcA,EAAM,eAAe,OACvEa,EAAc,QAAQC,EAAed,EAAM,YAAYe,CAAgB;AAGnE,UAAAC,IAAeL,EAAI,EAAK,GAExBM,IAAaC,EAAS,MAAMlB,EAAM,cAAe,cAAcQ,KAASA,EAAM,aAAa,EAAM,GACjGW,IAAWD,EAAS,MAAMlB,EAAM,SAAS,QAAQ,GAEjDoB,IAAaF,EAAS,MAAM;AAC1B,YAAAG,IAAY,EAAE,GAAGb;AAEvB,oBAAOa,EAAU,OAEVA;AAAA,IAAA,CACR,GAEKC,IAAYJ,EAAS,MAGrBC,EAAS,SAITnB,EAAM,SAAS,cAAcgB,EAAa,QACrC,SAGFhB,EAAM,IACd;AAED,IAAAuB,EAAY,MAAM;AACF,MAAAV,EAAA,QAAQW,EAAOxB,EAAM,UAAU;AAAA,IAAA,CAC9C;AAQD,aAASyB,EAAYC,IAAyB,IAAIC,IAAe,IAAwB;AAEnF,UAAA,CAACR,EAAS;AACL,eAAAO;AAGT,UAAIE,IAAYF;AAGZ,UAAAG,EAAMD,CAAS,KAAK,GAAGA,CAAS,GAAG,WAAW,EAAU,QAAA;AAQ5D,UALIb,MAAqB,QACXa,IAAAd,EAAec,GAAW,GAAG,IAIvCD,MAEEC,MAAc,QAAiBA,IAAA,OAG/BA,EAAU,SAAS,EAAE,WAAW,IAAI;AAAU,eAAAA;AAIpD,UAAI,CAACC,EAAMD,CAAS,KAAK,GAAGA,CAAS,GAAG;AAC1B,QAAAA,IAAA,KAAK,aAAa,SAAS;AAAA,UACrC,OAAO;AAAA,UACP,uBAAuB;AAAA,UACvB,aAAa;AAAA,QACd,CAAA,EAAE,OAAO,OAAOA,CAAS,CAAC;AAAA;AAEpB,eAAA;AAIT,aAAO,MAAM,OAAOA,CAAS,CAAC,IAAI,KAAK,WAAWA,CAAS;AAAA,IAC7D;AAOA,aAASJ,EAAOE,GAAwB;AACtC,aAAIP,EAAS,QACJW,EAAgBJ,GAAOX,CAAgB,IAGzCW;AAAA,IACT;AAKA,aAASK,IAAe;AAEtB,YAAMC,IAAcb,EAAS,QAAQM,EAAYZ,EAAc,KAAK,IAAIA,EAAc;AACtF,MAAAX,EAAK,UAAU8B,CAAW;AAAA,IAC5B;AAKA,aAASC,EAAYC,GAAU;AACvB,YAAAR,IAASQ,EAAE,OAA4B;AAG/B,MAAArB,EAAA,QAAQW,EAAOE,CAAK;AAElC,YAAMM,IAAcb,EAAS,QAAQM,EAAYZ,EAAc,OAAO,EAAI,IAAIa;AAE9E,MAAAxB,EAAK,sBAAsB8B,CAAW;AAAA,IACxC;AAEA,WAAAG,EAAU,MAAM;AACV,UAAAnC,EAAM,UAAU;AACZ,cAAA,IAAI,MAAM,0DAA0D;AAG5E,UAAIQ,EAAM;AACF,cAAA,IAAI,MAAM,+DAA+D;AAAA,IACjF,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -38,13 +38,7 @@ autocomplete: string;
38
38
  type: string;
39
39
  modelValue: string;
40
40
  value: null;
41
- errorText: undefined;
42
- hintText: undefined;
43
- label: undefined;
44
- id: undefined;
45
41
  placeholder: undefined;
46
- disabled: boolean;
47
- isReadOnly: boolean;
48
42
  }>>, {
49
43
  inputEl: Ref<HTMLInputElement | undefined, HTMLInputElement | undefined>;
50
44
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
@@ -57,13 +51,7 @@ autocomplete: string;
57
51
  type: string;
58
52
  modelValue: string;
59
53
  value: null;
60
- errorText: undefined;
61
- hintText: undefined;
62
- label: undefined;
63
- id: undefined;
64
54
  placeholder: undefined;
65
- disabled: boolean;
66
- isReadOnly: boolean;
67
55
  }>>> & Readonly<{
68
56
  onBlur?: ((evt: Event) => any) | undefined;
69
57
  onChange?: ((v: string | number) => any) | undefined;
@@ -71,12 +59,6 @@ onFocus?: ((evt: Event) => any) | undefined;
71
59
  "onUpdate:model-value"?: ((v: string | number) => any) | undefined;
72
60
  }>, {
73
61
  type: string;
74
- disabled: boolean;
75
- label: string;
76
- id: string;
77
- errorText: string;
78
- hintText: string;
79
- isReadOnly: boolean;
80
62
  placeholder: string;
81
63
  modelValue: string | number;
82
64
  value: string | number | null;
@@ -88,9 +70,9 @@ autocomplete: string;
88
70
  }>;
89
71
  export default _default;
90
72
 
91
- export declare interface InputProps {
73
+ declare interface FieldProps {
92
74
  /**
93
- * Adds spacing under the field that is consistent whether or not hint/error text is displayed.
75
+ * Adds spacing under the field that is consistent whether hint/error text is displayed.
94
76
  */
95
77
  addBottomSpace?: boolean;
96
78
  /**
@@ -105,6 +87,18 @@ export declare interface InputProps {
105
87
  * ID for the Label and Input; must be unique
106
88
  */
107
89
  id?: string;
90
+ /**
91
+ * ID for the error text element; useful for aria-errormessage
92
+ */
93
+ errorId?: string;
94
+ /**
95
+ * Whether it's a readonly field.
96
+ */
97
+ isReadOnly?: boolean;
98
+ /**
99
+ * Whether the field is required.
100
+ */
101
+ isRequired?: boolean;
108
102
  /**
109
103
  * Label to render above the input.
110
104
  */
@@ -113,6 +107,23 @@ export declare interface InputProps {
113
107
  * Show "(optional)" to the right of the label text
114
108
  */
115
109
  showOptionalInLabel?: boolean;
110
+ /**
111
+ * Indicates wheter the field is a fieldset or not
112
+ */
113
+ fieldset?: boolean;
114
+ /**
115
+ * Indicates whether the field is disabled.
116
+ */
117
+ isDisabled?: boolean;
118
+ /**
119
+ * Indicates whether the field is disabled.
120
+ *
121
+ * @deprecated Use `isDisabled` instead.
122
+ */
123
+ disabled?: boolean;
124
+ }
125
+
126
+ export declare interface InputProps extends FieldProps {
116
127
  /**
117
128
  * Autocomplete takes in a string of off or on
118
129
  */
@@ -137,14 +148,6 @@ export declare interface InputProps {
137
148
  * **Note:** placeholders should be used to display examples; they should not be used as labels because they are not accessible as labels. If a real label cannot be used, use the `aria-label` attribute.
138
149
  */
139
150
  placeholder?: string;
140
- /**
141
- * Indicates whether the input is disabled.
142
- */
143
- disabled?: boolean;
144
- /**
145
- * Indicates whether the input is read-only.
146
- */
147
- isReadOnly?: boolean;
148
151
  }
149
152
 
150
153
  export declare type InputValue = string | number | undefined;
@@ -1,142 +1,149 @@
1
- import { defineComponent as O, useAttrs as T, useSlots as $, useCssModule as M, ref as r, computed as z, watchEffect as A, watch as m, openBlock as c, createBlock as F, mergeProps as f, createSlots as N, withCtx as h, createElementBlock as y, createElementVNode as R, toDisplayString as _, normalizeClass as w, unref as u, createVNode as g, renderSlot as U } from "vue";
2
- import { _ as D } from "./Field.vue_vue_type_script_setup_true_lang--tBfZB2K.js";
3
- import P from "./Input.js";
4
- import j from "./Select.js";
5
- import { _ as q } from "./_plugin-vue_export-helper-CHgC5LLL.js";
6
- const G = {
1
+ import { defineComponent as E, useAttrs as T, useSlots as $, useCssModule as D, ref as r, computed as M, watchEffect as R, watch as v, openBlock as c, createBlock as z, mergeProps as h, createSlots as A, withCtx as f, createElementBlock as y, createElementVNode as F, toDisplayString as _, normalizeClass as w, unref as i, createVNode as b, renderSlot as N } from "vue";
2
+ import U from "./Input.js";
3
+ import q from "./Select.js";
4
+ import { _ as L } from "./Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js";
5
+ import { _ as P } from "./_plugin-vue_export-helper-CHgC5LLL.js";
6
+ const j = {
7
7
  key: 0,
8
8
  class: "tw-flex tw-h-input tw-items-center tw-text-sm"
9
- }, H = ["id", "aria-labelledby"], J = /* @__PURE__ */ O({
9
+ }, G = ["id", "aria-labelledby"], H = /* @__PURE__ */ E({
10
10
  name: "ll-input-options",
11
11
  __name: "InputOptions",
12
12
  props: {
13
- errorText: { default: void 0 },
14
- hintText: { default: void 0 },
15
- label: { default: void 0 },
16
13
  modelValue: { default: () => ({ value: "", option: void 0 }) },
17
14
  type: { default: "text" },
18
15
  noTruncate: { type: Boolean, default: !1 },
19
16
  options: { default: () => [] },
20
17
  placeholder: { default: void 0 },
21
- disabled: { type: Boolean, default: !1 },
22
- isReadOnly: { type: Boolean, default: !1 }
18
+ disabled: { type: Boolean },
19
+ isReadOnly: { type: Boolean },
20
+ addBottomSpace: { type: Boolean },
21
+ errorText: {},
22
+ hintText: {},
23
+ id: {},
24
+ errorId: {},
25
+ isRequired: { type: Boolean },
26
+ label: {},
27
+ showOptionalInLabel: { type: Boolean },
28
+ fieldset: { type: Boolean },
29
+ isDisabled: { type: Boolean }
23
30
  },
24
31
  emits: ["update:model-value", "change"],
25
- setup(b, { emit: V }) {
26
- const e = b, n = V, i = T(), C = $(), p = M(), a = r(), d = r(!1), t = r(), x = z(() => {
27
- const { disabled: l, displayBy: o, trackBy: s } = i;
28
- return { disabled: l, displayBy: o, trackBy: s };
32
+ setup(g, { emit: B }) {
33
+ const e = g, n = B, u = T(), V = $(), p = D(), o = r(), d = r(!1), t = r(), C = M(() => {
34
+ const { disabled: l, displayBy: a, trackBy: s } = u;
35
+ return { disabled: l, displayBy: a, trackBy: s };
29
36
  });
30
- function B(l) {
31
- a.value = String(l), n("update:model-value", {
32
- value: a.value,
37
+ function x(l) {
38
+ o.value = String(l), n("update:model-value", {
39
+ value: o.value,
33
40
  option: t.value,
34
41
  isValueChange: !0,
35
42
  type: "input"
36
43
  });
37
44
  }
38
- function k() {
45
+ function I() {
39
46
  n("change", {
40
- value: a.value,
47
+ value: o.value,
41
48
  option: t.value,
42
49
  isValueChange: !0,
43
50
  type: "input"
44
51
  });
45
52
  }
46
- function I(l) {
53
+ function k(l) {
47
54
  t.value = l, n("change", {
48
- value: a.value,
55
+ value: o.value,
49
56
  option: t.value,
50
57
  isValueChange: !1,
51
58
  type: "select"
52
59
  }), n("update:model-value", {
53
- value: a.value,
60
+ value: o.value,
54
61
  option: t.value,
55
62
  isValueChange: !1,
56
63
  type: "select"
57
64
  });
58
65
  }
59
- if (A(() => {
66
+ if (R(() => {
60
67
  t.value || (t.value = e.options[0]);
61
- }), m(
68
+ }), v(
62
69
  () => e.modelValue.value,
63
70
  () => {
64
- a.value = e.modelValue.value;
71
+ o.value = e.modelValue.value;
65
72
  },
66
73
  { immediate: !0 }
67
- ), m(
74
+ ), v(
68
75
  () => e.modelValue.option,
69
76
  () => {
70
77
  t.value = e.modelValue.option;
71
78
  },
72
79
  { immediate: !0 }
73
- ), i.value)
80
+ ), u.value)
74
81
  throw new Error("ll-input-options: use :model-value or v-model instead of :value.");
75
- if (i.onInput)
82
+ if (u.onInput)
76
83
  throw new Error("ll-input-options: use the @update:model-value event instead of @input");
77
- return (l, o) => (c(), F(D, f(e, {
84
+ return (l, a) => (c(), z(L, h(e, {
78
85
  class: "stash-input-options",
79
86
  "data-test": "stash-input-options"
80
- }), N({
81
- default: h(({ fieldId: s, labelId: S }) => {
82
- var v;
87
+ }), A({
88
+ default: f(({ fieldId: s, labelId: S }) => {
89
+ var m;
83
90
  return [
84
- e.isReadOnly ? (c(), y("div", G, [
85
- R("span", {
91
+ e.isReadOnly ? (c(), y("div", j, [
92
+ F("span", {
86
93
  id: s,
87
94
  "aria-labelledby": S,
88
95
  class: "tw-h-min"
89
- }, _(a.value || 0) + " " + _((v = t.value) == null ? void 0 : v.name), 9, H)
96
+ }, _(o.value || 0) + " " + _((m = t.value) == null ? void 0 : m.name), 9, G)
90
97
  ])) : (c(), y("div", {
91
98
  key: 1,
92
- class: w(["tw-flex", { [u(p)["has-error"]]: !!e.errorText }])
99
+ class: w(["tw-flex", { [i(p)["has-error"]]: !!e.errorText }])
93
100
  }, [
94
- g(P, {
101
+ b(U, {
95
102
  id: s,
96
- class: w(["stash-input-options__input -tw-mr-[1px] tw-inline-block tw-flex-1", [u(p).input, { "tw-z-control": d.value }]]),
103
+ class: w(["stash-input-options__input -tw-mr-[1px] tw-inline-block tw-flex-1", [i(p).input, { "tw-z-control": d.value }]]),
97
104
  "data-test": "stash-input-options|input",
98
105
  type: e.type,
99
- "model-value": a.value,
100
- disabled: e.disabled,
106
+ "model-value": o.value,
107
+ disabled: e.isDisabled || e.disabled,
101
108
  placeholder: e.placeholder,
102
- onChange: k,
103
- "onUpdate:modelValue": B,
104
- onBlur: o[0] || (o[0] = (E) => d.value = !1),
105
- onFocus: o[1] || (o[1] = (E) => d.value = !0)
109
+ onChange: I,
110
+ "onUpdate:modelValue": x,
111
+ onBlur: a[0] || (a[0] = (O) => d.value = !1),
112
+ onFocus: a[1] || (a[1] = (O) => d.value = !0)
106
113
  }, null, 8, ["id", "class", "type", "model-value", "disabled", "placeholder"]),
107
- g(j, f(x.value, {
114
+ b(q, h(C.value, {
108
115
  single: "",
109
116
  "hide-search": "",
110
117
  "prevent-empty": "",
111
- class: ["stash-input-options__select tw-min-w-20", u(p).select],
118
+ class: ["stash-input-options__select tw-min-w-20", i(p).select],
112
119
  "data-test": "stash-input-options|select",
113
120
  "no-truncate": l.noTruncate,
114
121
  options: l.options,
115
122
  "model-value": t.value,
116
- disabled: e.disabled,
117
- "onUpdate:modelValue": I
123
+ disabled: e.isDisabled || e.disabled,
124
+ "onUpdate:modelValue": k
118
125
  }), null, 16, ["class", "no-truncate", "options", "model-value", "disabled"])
119
126
  ], 2))
120
127
  ];
121
128
  }),
122
129
  _: 2
123
130
  }, [
124
- u(C).hint ? {
131
+ i(V).hint ? {
125
132
  name: "hint",
126
- fn: h(() => [
127
- U(l.$slots, "hint")
133
+ fn: f(() => [
134
+ N(l.$slots, "hint")
128
135
  ]),
129
136
  key: "0"
130
137
  } : void 0
131
138
  ]), 1040));
132
139
  }
133
- }), K = "_input_gn7he_2", L = "_select_gn7he_7", Q = {
134
- input: K,
135
- select: L,
140
+ }), J = "_input_gn7he_2", K = "_select_gn7he_7", Q = {
141
+ input: J,
142
+ select: K,
136
143
  "has-error": "_has-error_gn7he_16"
137
144
  }, W = {
138
145
  $style: Q
139
- }, le = /* @__PURE__ */ q(J, [["__cssModules", W]]);
146
+ }, le = /* @__PURE__ */ P(H, [["__cssModules", W]]);
140
147
  export {
141
148
  le as default
142
149
  };