@leaflink/stash 50.0.5 → 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.
Files changed (37) hide show
  1. package/dist/CurrencyInput.js +55 -50
  2. package/dist/CurrencyInput.js.map +1 -1
  3. package/dist/CurrencyInput.vue.d.ts +31 -6
  4. package/dist/DatePicker.js +7 -7
  5. package/dist/DatePicker.js.map +1 -1
  6. package/dist/Field.js +1 -1
  7. package/dist/Field.vue.d.ts +11 -0
  8. package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js +88 -0
  9. package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js.map +1 -0
  10. package/dist/FilterSelect.js +67 -56
  11. package/dist/FilterSelect.js.map +1 -1
  12. package/dist/FilterSelect.vue.d.ts +54 -2
  13. package/dist/Filters.vue.d.ts +162 -96
  14. package/dist/Input.js +97 -91
  15. package/dist/Input.js.map +1 -1
  16. package/dist/Input.vue.d.ts +31 -21
  17. package/dist/InputOptions.js +83 -62
  18. package/dist/InputOptions.js.map +1 -1
  19. package/dist/InputOptions.vue.d.ts +49 -16
  20. package/dist/ListView.vue.d.ts +231 -134
  21. package/dist/RadioGroup.js +67 -70
  22. package/dist/RadioGroup.js.map +1 -1
  23. package/dist/RadioGroup.vue.d.ts +54 -45
  24. package/dist/Select.js +350 -336
  25. package/dist/Select.js.map +1 -1
  26. package/dist/Select.vue.d.ts +54 -47
  27. package/dist/TextEditor.js +671 -684
  28. package/dist/TextEditor.js.map +1 -1
  29. package/dist/TextEditor.vue.d.ts +54 -61
  30. package/dist/Textarea.js +65 -59
  31. package/dist/Textarea.js.map +1 -1
  32. package/dist/Textarea.vue.d.ts +50 -32
  33. package/dist/components.css +2 -2
  34. package/package.json +1 -1
  35. package/styles/backwards-compat.css +3 -3
  36. package/dist/Field.vue_vue_type_script_setup_true_lang-DjxUvSRF.js +0 -95
  37. package/dist/Field.vue_vue_type_script_setup_true_lang-DjxUvSRF.js.map +0 -1
package/dist/Input.js CHANGED
@@ -1,147 +1,153 @@
1
- import { defineComponent as U, useSlots as G, useCssModule as L, useAttrs as O, ref as f, computed as v, watchEffect as W, onMounted as j, openBlock as m, createBlock as V, mergeProps as k, unref as l, createSlots as q, withCtx as N, createElementVNode as x, withDirectives as H, vModelDynamic as J, createElementBlock as B, normalizeClass as y, renderSlot as h, createCommentVNode as C } from "vue";
2
- import I from "lodash-es/isNil";
3
- import { convertDecimal as $, sanitizeDecimal as K, decimalSeparator as b } from "./utils/i18n.js";
4
- import { _ as Q } from "./Field.vue_vue_type_script_setup_true_lang-DjxUvSRF.js";
5
- import R from "./Icon.js";
6
- import { _ as X } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
- const Y = { class: "tw-relative" }, Z = ["id", "aria-errormessage", "aria-invalid", "autocomplete", "placeholder", "type", "disabled"], ee = /* @__PURE__ */ U({
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
+ import X from "./Icon.js";
6
+ import { _ as Y } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
+ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-invalid", "autocomplete", "placeholder", "type", "disabled", "readonly"], te = /* @__PURE__ */ P({
8
8
  name: "ll-input",
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 }
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 }
24
29
  },
25
30
  emits: ["update:model-value", "change", "focus", "blur"],
26
- setup(E, { expose: S, emit: D }) {
27
- const t = E, i = D, r = G(), s = L(), c = O(), _ = f();
28
- S({ inputEl: _ });
29
- const n = f(t.modelValue);
30
- t.type === "number" && (t.modelValue || t.modelValue === 0) && (n.value = $(t.modelValue, b));
31
- const p = f(!1), d = v(() => t.type === "number"), M = v(() => {
32
- const o = { ...c };
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 };
33
38
  return delete o.class, o;
34
- }), A = v(() => d.value || t.type === "password" && p.value ? "text" : t.type);
35
- W(() => {
36
- n.value = g(t.modelValue);
39
+ }), F = c(() => d.value || e.type === "password" && i.value ? "text" : e.type);
40
+ L(() => {
41
+ n.value = w(e.modelValue);
37
42
  });
38
- function w(o = "", a = !1) {
43
+ function g(o = "", a = !1) {
39
44
  if (!d.value)
40
45
  return o;
41
- let e = o;
42
- if (I(e) || `${e}`.length === 0) return "";
43
- if (b !== "." && (e = $(e, ".")), a && (e === "." && (e = "0."), e.toString().startsWith("0.")))
44
- return e;
45
- if (!I(e) && `${e}`.length)
46
- e = Intl.NumberFormat("en-US", {
46
+ let t = o;
47
+ if (C(t) || `${t}`.length === 0) return "";
48
+ if (h !== "." && (t = D(t, ".")), a && (t === "." && (t = "0."), t.toString().startsWith("0.")))
49
+ return t;
50
+ if (!C(t) && `${t}`.length)
51
+ t = Intl.NumberFormat("en-US", {
47
52
  style: "decimal",
48
53
  maximumFractionDigits: 7,
49
54
  useGrouping: !1
50
- }).format(Number(e));
55
+ }).format(Number(t));
51
56
  else
52
57
  return "";
53
- return isNaN(Number(e)) ? "" : parseFloat(e);
58
+ return isNaN(Number(t)) ? "" : parseFloat(t);
54
59
  }
55
- function g(o) {
56
- return d.value ? K(o, b) : o;
60
+ function w(o) {
61
+ return d.value ? K(o, h) : o;
57
62
  }
58
- function F() {
59
- const o = d.value ? w(n.value) : n.value;
60
- i("change", o);
63
+ function O() {
64
+ const o = d.value ? g(n.value) : n.value;
65
+ m("change", o);
61
66
  }
62
- function T(o) {
67
+ function R(o) {
63
68
  const a = o.target.value;
64
- n.value = g(a);
65
- const e = d.value ? w(n.value, !0) : a;
66
- i("update:model-value", e);
69
+ n.value = w(a);
70
+ const t = d.value ? g(n.value, !0) : a;
71
+ m("update:model-value", t);
67
72
  }
68
- return j(() => {
69
- if (t.value !== null)
73
+ return W(() => {
74
+ if (e.value !== null)
70
75
  throw new Error("ll-input: use :model-value or v-model instead of :value.");
71
- if (c.onInput)
76
+ if (u.onInput)
72
77
  throw new Error("ll-input: use the @update:model-value event instead of @input");
73
- }), (o, a) => (m(), V(Q, k(t, {
74
- class: ["stash-input", [l(s).root, l(c).class]],
78
+ }), (o, a) => (f(), V(Q, B(e, {
79
+ class: ["stash-input", [l(s).root, l(u).class]],
75
80
  "data-test": "ll-input"
76
- }), q({
77
- default: N(({ fieldId: e, fieldErrorId: z, hasError: P }) => [
78
- x("div", Y, [
79
- H(x("input", k(M.value, {
80
- id: e,
81
+ }), j({
82
+ default: k(({ fieldId: t, fieldErrorId: T, hasError: z }) => [
83
+ N("div", Z, [
84
+ H(N("input", B(A.value, {
85
+ id: t,
81
86
  ref_key: "inputEl",
82
87
  ref: _,
83
- "onUpdate:modelValue": a[0] || (a[0] = (u) => n.value = u),
84
- "aria-errormessage": z,
85
- "aria-invalid": P,
88
+ "onUpdate:modelValue": a[0] || (a[0] = (p) => n.value = p),
89
+ "aria-errormessage": T,
90
+ "aria-invalid": z,
86
91
  autocomplete: o.autocomplete,
87
- placeholder: t.placeholder,
92
+ placeholder: e.placeholder,
88
93
  class: [
89
94
  { [l(s)["input-prepended"]]: !!l(r).prepend },
90
- { [l(s)["input-appended"]]: !!l(r).append || t.type === "password" },
91
- { [l(s)["has-error"]]: !!t.errorText }
95
+ { [l(s)["input-appended"]]: !!l(r).append || e.type === "password" },
96
+ { [l(s)["has-error"]]: !!e.errorText }
92
97
  ],
93
- type: A.value,
94
- disabled: t.disabled,
95
- onChange: F,
96
- onInput: T,
97
- onBlur: a[1] || (a[1] = (u) => i("blur", u)),
98
- onFocus: a[2] || (a[2] = (u) => i("focus", u))
99
- }), null, 16, Z), [
98
+ type: F.value,
99
+ disabled: e.isDisabled || e.disabled,
100
+ readonly: M.value,
101
+ onChange: O,
102
+ onInput: R,
103
+ onBlur: a[1] || (a[1] = (p) => m("blur", p)),
104
+ onFocus: a[2] || (a[2] = (p) => m("focus", p))
105
+ }), null, 16, ee), [
100
106
  [J, n.value]
101
107
  ]),
102
- l(r).prepend ? (m(), B("div", {
108
+ l(r).prepend ? (f(), x("div", {
103
109
  key: 0,
104
- class: y(["stash-input-prepend font-semibold", [l(s).symbol, l(s)["symbol--prepend"]]])
110
+ class: v(["stash-input-prepend font-semibold", [l(s).symbol, l(s)["symbol--prepend"]]])
105
111
  }, [
106
- h(o.$slots, "prepend")
107
- ], 2)) : C("", !0),
108
- l(r).append || t.type === "password" ? (m(), B("div", {
112
+ b(o.$slots, "prepend")
113
+ ], 2)) : I("", !0),
114
+ l(r).append || e.type === "password" ? (f(), x("div", {
109
115
  key: 1,
110
- class: y(["stash-input-append font-semibold", [l(s).symbol, l(s)["symbol--append"]]])
116
+ class: v(["stash-input-append font-semibold", [l(s).symbol, l(s)["symbol--append"]]])
111
117
  }, [
112
- l(r).append ? h(o.$slots, "append", { key: 0 }) : (m(), V(R, {
118
+ l(r).append ? b(o.$slots, "append", { key: 0 }) : (f(), V(X, {
113
119
  key: 1,
114
- name: p.value ? "hide" : "show",
115
- class: y(["tw-cursor-pointer", { "tw-text-ice-500": t.disabled }]),
116
- "data-test": p.value ? "hide-password-icon" : "show-password-icon",
117
- onClick: a[3] || (a[3] = (u) => p.value = !p.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)
118
124
  }, null, 8, ["name", "class", "data-test"]))
119
- ], 2)) : C("", !0)
125
+ ], 2)) : I("", !0)
120
126
  ])
121
127
  ]),
122
128
  _: 2
123
129
  }, [
124
130
  l(r).hint ? {
125
131
  name: "hint",
126
- fn: N(() => [
127
- h(o.$slots, "hint")
132
+ fn: k(() => [
133
+ b(o.$slots, "hint")
128
134
  ]),
129
135
  key: "0"
130
136
  } : void 0
131
137
  ]), 1040, ["class"]));
132
138
  }
133
- }), te = "_root_12641_2", oe = "_symbol_12641_46", le = {
134
- root: te,
135
- "has-error": "_has-error_12641_34",
136
- "input-prepended": "_input-prepended_12641_38",
137
- "input-appended": "_input-appended_12641_42",
138
- symbol: oe,
139
- "symbol--prepend": "_symbol--prepend_12641_57",
140
- "symbol--append": "_symbol--append_12641_63"
141
- }, ae = {
142
- $style: le
143
- }, ie = /* @__PURE__ */ X(ee, [["__cssModules", ae]]);
139
+ }), oe = "_root_1tgop_2", le = "_symbol_1tgop_46", ae = {
140
+ root: oe,
141
+ "has-error": "_has-error_1tgop_34",
142
+ "input-prepended": "_input-prepended_1tgop_38",
143
+ "input-appended": "_input-appended_1tgop_42",
144
+ symbol: le,
145
+ "symbol--prepend": "_symbol--prepend_1tgop_57",
146
+ "symbol--append": "_symbol--append_1tgop_63"
147
+ }, se = {
148
+ $style: ae
149
+ }, me = /* @__PURE__ */ Y(te, [["__cssModules", se]]);
144
150
  export {
145
- ie as default
151
+ me as default
146
152
  };
147
153
  //# sourceMappingURL=Input.js.map
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 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 });\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 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.disabled\"\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 .root input[readonly] {\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[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 .root input[readonly]::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","isNumber","computed","inputAttrs","tempAttrs","inputType","watchEffect","format","parseNumber","value","isUserTyping","tempValue","isNil","sanitizeDecimal","handleChange","parsedValue","handleInput","e","onMounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiFE,UAAMA,IAAQC,GAaRC,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,IAAWC,EAAS,MAAMlB,EAAM,SAAS,QAAQ,GAEjDmB,IAAaD,EAAS,MAAM;AAC1B,YAAAE,IAAY,EAAE,GAAGZ;AAEvB,oBAAOY,EAAU,OAEVA;AAAA,IAAA,CACR,GAEKC,IAAYH,EAAS,MAGrBD,EAAS,SAITjB,EAAM,SAAS,cAAcgB,EAAa,QACrC,SAGFhB,EAAM,IACd;AAED,IAAAsB,EAAY,MAAM;AACF,MAAAT,EAAA,QAAQU,EAAOvB,EAAM,UAAU;AAAA,IAAA,CAC9C;AAQD,aAASwB,EAAYC,IAAyB,IAAIC,IAAe,IAAwB;AAEnF,UAAA,CAACT,EAAS;AACL,eAAAQ;AAGT,UAAIE,IAAYF;AAGZ,UAAAG,EAAMD,CAAS,KAAK,GAAGA,CAAS,GAAG,WAAW,EAAU,QAAA;AAQ5D,UALIZ,MAAqB,QACXY,IAAAb,EAAea,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,aAAIR,EAAS,QACJY,EAAgBJ,GAAOV,CAAgB,IAGzCU;AAAA,IACT;AAKA,aAASK,IAAe;AAEtB,YAAMC,IAAcd,EAAS,QAAQO,EAAYX,EAAc,KAAK,IAAIA,EAAc;AACtF,MAAAX,EAAK,UAAU6B,CAAW;AAAA,IAC5B;AAKA,aAASC,EAAYC,GAAU;AACvB,YAAAR,IAASQ,EAAE,OAA4B;AAG/B,MAAApB,EAAA,QAAQU,EAAOE,CAAK;AAElC,YAAMM,IAAcd,EAAS,QAAQO,EAAYX,EAAc,OAAO,EAAI,IAAIY;AAE9E,MAAAvB,EAAK,sBAAsB6B,CAAW;AAAA,IACxC;AAEA,WAAAG,EAAU,MAAM;AACV,UAAAlC,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,12 +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
42
  }>>, {
48
43
  inputEl: Ref<HTMLInputElement | undefined, HTMLInputElement | undefined>;
49
44
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
@@ -56,12 +51,7 @@ autocomplete: string;
56
51
  type: string;
57
52
  modelValue: string;
58
53
  value: null;
59
- errorText: undefined;
60
- hintText: undefined;
61
- label: undefined;
62
- id: undefined;
63
54
  placeholder: undefined;
64
- disabled: boolean;
65
55
  }>>> & Readonly<{
66
56
  onBlur?: ((evt: Event) => any) | undefined;
67
57
  onChange?: ((v: string | number) => any) | undefined;
@@ -69,11 +59,6 @@ onFocus?: ((evt: Event) => any) | undefined;
69
59
  "onUpdate:model-value"?: ((v: string | number) => any) | undefined;
70
60
  }>, {
71
61
  type: string;
72
- disabled: boolean;
73
- label: string;
74
- id: string;
75
- errorText: string;
76
- hintText: string;
77
62
  placeholder: string;
78
63
  modelValue: string | number;
79
64
  value: string | number | null;
@@ -85,9 +70,9 @@ autocomplete: string;
85
70
  }>;
86
71
  export default _default;
87
72
 
88
- export declare interface InputProps {
73
+ declare interface FieldProps {
89
74
  /**
90
- * 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.
91
76
  */
92
77
  addBottomSpace?: boolean;
93
78
  /**
@@ -102,6 +87,18 @@ export declare interface InputProps {
102
87
  * ID for the Label and Input; must be unique
103
88
  */
104
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;
105
102
  /**
106
103
  * Label to render above the input.
107
104
  */
@@ -110,6 +107,23 @@ export declare interface InputProps {
110
107
  * Show "(optional)" to the right of the label text
111
108
  */
112
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 {
113
127
  /**
114
128
  * Autocomplete takes in a string of off or on
115
129
  */
@@ -134,10 +148,6 @@ export declare interface InputProps {
134
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.
135
149
  */
136
150
  placeholder?: string;
137
- /**
138
- * Indicates whether the input is disabled.
139
- */
140
- disabled?: boolean;
141
151
  }
142
152
 
143
153
  export declare type InputValue = string | number | undefined;
@@ -1,29 +1,40 @@
1
- import { defineComponent as I, useAttrs as B, useSlots as S, useCssModule as k, ref as r, computed as T, watchEffect as $, watch as c, openBlock as E, createBlock as M, mergeProps as v, createSlots as O, withCtx as m, createElementVNode as z, normalizeClass as f, unref as s, createVNode as h, renderSlot as A } from "vue";
2
- import { _ as F } from "./Field.vue_vue_type_script_setup_true_lang-DjxUvSRF.js";
3
- import N from "./Input.js";
4
- import U from "./Select.js";
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
5
  import { _ as P } from "./_plugin-vue_export-helper-CHgC5LLL.js";
6
- const j = /* @__PURE__ */ I({
6
+ const j = {
7
+ key: 0,
8
+ class: "tw-flex tw-h-input tw-items-center tw-text-sm"
9
+ }, G = ["id", "aria-labelledby"], H = /* @__PURE__ */ E({
7
10
  name: "ll-input-options",
8
11
  __name: "InputOptions",
9
12
  props: {
10
- errorText: { default: void 0 },
11
- hintText: { default: void 0 },
12
- label: { default: void 0 },
13
13
  modelValue: { default: () => ({ value: "", option: void 0 }) },
14
14
  type: { default: "text" },
15
15
  noTruncate: { type: Boolean, default: !1 },
16
16
  options: { default: () => [] },
17
17
  placeholder: { default: void 0 },
18
- disabled: { 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 }
19
30
  },
20
31
  emits: ["update:model-value", "change"],
21
- setup(_, { emit: y }) {
22
- const e = _, n = y, u = B(), g = S(), i = k(), o = r(), p = r(!1), t = r(), w = T(() => {
23
- const { disabled: l, displayBy: a, trackBy: d } = u;
24
- return { disabled: l, displayBy: a, trackBy: d };
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 };
25
36
  });
26
- function V(l) {
37
+ function x(l) {
27
38
  o.value = String(l), n("update:model-value", {
28
39
  value: o.value,
29
40
  option: t.value,
@@ -31,7 +42,7 @@ const j = /* @__PURE__ */ I({
31
42
  type: "input"
32
43
  });
33
44
  }
34
- function C() {
45
+ function I() {
35
46
  n("change", {
36
47
  value: o.value,
37
48
  option: t.value,
@@ -39,7 +50,7 @@ const j = /* @__PURE__ */ I({
39
50
  type: "input"
40
51
  });
41
52
  }
42
- function b(l) {
53
+ function k(l) {
43
54
  t.value = l, n("change", {
44
55
  value: o.value,
45
56
  option: t.value,
@@ -52,15 +63,15 @@ const j = /* @__PURE__ */ I({
52
63
  type: "select"
53
64
  });
54
65
  }
55
- if ($(() => {
66
+ if (R(() => {
56
67
  t.value || (t.value = e.options[0]);
57
- }), c(
68
+ }), v(
58
69
  () => e.modelValue.value,
59
70
  () => {
60
71
  o.value = e.modelValue.value;
61
72
  },
62
73
  { immediate: !0 }
63
- ), c(
74
+ ), v(
64
75
  () => e.modelValue.option,
65
76
  () => {
66
77
  t.value = e.modelValue.option;
@@ -70,60 +81,70 @@ const j = /* @__PURE__ */ I({
70
81
  throw new Error("ll-input-options: use :model-value or v-model instead of :value.");
71
82
  if (u.onInput)
72
83
  throw new Error("ll-input-options: use the @update:model-value event instead of @input");
73
- return (l, a) => (E(), M(F, v(e, {
84
+ return (l, a) => (c(), z(L, h(e, {
74
85
  class: "stash-input-options",
75
86
  "data-test": "stash-input-options"
76
- }), O({
77
- default: m(({ fieldId: d }) => [
78
- z("div", {
79
- class: f(["tw-flex", { [s(i)["has-error"]]: !!e.errorText }])
80
- }, [
81
- h(N, {
82
- id: d,
83
- class: f(["stash-input-options__input -tw-mr-[1px] tw-inline-block tw-flex-1", [s(i).input, { "tw-z-control": p.value }]]),
84
- "data-test": "stash-input-options|input",
85
- type: e.type,
86
- "model-value": o.value,
87
- disabled: e.disabled,
88
- placeholder: e.placeholder,
89
- onChange: C,
90
- "onUpdate:modelValue": V,
91
- onBlur: a[0] || (a[0] = (x) => p.value = !1),
92
- onFocus: a[1] || (a[1] = (x) => p.value = !0)
93
- }, null, 8, ["id", "class", "type", "model-value", "disabled", "placeholder"]),
94
- h(U, v(w.value, {
95
- single: "",
96
- "hide-search": "",
97
- "prevent-empty": "",
98
- class: ["stash-input-options__select tw-min-w-20", s(i).select],
99
- "data-test": "stash-input-options|select",
100
- "no-truncate": l.noTruncate,
101
- options: l.options,
102
- "model-value": t.value,
103
- disabled: e.disabled,
104
- "onUpdate:modelValue": b
105
- }), null, 16, ["class", "no-truncate", "options", "model-value", "disabled"])
106
- ], 2)
107
- ]),
87
+ }), A({
88
+ default: f(({ fieldId: s, labelId: S }) => {
89
+ var m;
90
+ return [
91
+ e.isReadOnly ? (c(), y("div", j, [
92
+ F("span", {
93
+ id: s,
94
+ "aria-labelledby": S,
95
+ class: "tw-h-min"
96
+ }, _(o.value || 0) + " " + _((m = t.value) == null ? void 0 : m.name), 9, G)
97
+ ])) : (c(), y("div", {
98
+ key: 1,
99
+ class: w(["tw-flex", { [i(p)["has-error"]]: !!e.errorText }])
100
+ }, [
101
+ b(U, {
102
+ id: s,
103
+ class: w(["stash-input-options__input -tw-mr-[1px] tw-inline-block tw-flex-1", [i(p).input, { "tw-z-control": d.value }]]),
104
+ "data-test": "stash-input-options|input",
105
+ type: e.type,
106
+ "model-value": o.value,
107
+ disabled: e.isDisabled || e.disabled,
108
+ placeholder: e.placeholder,
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)
113
+ }, null, 8, ["id", "class", "type", "model-value", "disabled", "placeholder"]),
114
+ b(q, h(C.value, {
115
+ single: "",
116
+ "hide-search": "",
117
+ "prevent-empty": "",
118
+ class: ["stash-input-options__select tw-min-w-20", i(p).select],
119
+ "data-test": "stash-input-options|select",
120
+ "no-truncate": l.noTruncate,
121
+ options: l.options,
122
+ "model-value": t.value,
123
+ disabled: e.isDisabled || e.disabled,
124
+ "onUpdate:modelValue": k
125
+ }), null, 16, ["class", "no-truncate", "options", "model-value", "disabled"])
126
+ ], 2))
127
+ ];
128
+ }),
108
129
  _: 2
109
130
  }, [
110
- s(g).hint ? {
131
+ i(V).hint ? {
111
132
  name: "hint",
112
- fn: m(() => [
113
- A(l.$slots, "hint")
133
+ fn: f(() => [
134
+ N(l.$slots, "hint")
114
135
  ]),
115
136
  key: "0"
116
137
  } : void 0
117
138
  ]), 1040));
118
139
  }
119
- }), q = "_input_gn7he_2", D = "_select_gn7he_7", G = {
120
- input: q,
121
- select: D,
140
+ }), J = "_input_gn7he_2", K = "_select_gn7he_7", Q = {
141
+ input: J,
142
+ select: K,
122
143
  "has-error": "_has-error_gn7he_16"
123
- }, H = {
124
- $style: G
125
- }, W = /* @__PURE__ */ P(j, [["__cssModules", H]]);
144
+ }, W = {
145
+ $style: Q
146
+ }, le = /* @__PURE__ */ P(H, [["__cssModules", W]]);
126
147
  export {
127
- W as default
148
+ le as default
128
149
  };
129
150
  //# sourceMappingURL=InputOptions.js.map