@leaflink/stash 50.0.6 → 50.0.8
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/CurrencyInput.js +23 -19
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/CurrencyInput.vue.d.ts +31 -10
- package/dist/Field.js +1 -1
- package/dist/Field.vue.d.ts +9 -0
- package/dist/{Field.vue_vue_type_script_setup_true_lang--tBfZB2K.js → Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js} +35 -32
- package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js.map +1 -0
- package/dist/FilterSelect.js +67 -56
- package/dist/FilterSelect.js.map +1 -1
- package/dist/FilterSelect.vue.d.ts +54 -2
- package/dist/Filters.vue.d.ts +162 -105
- package/dist/Input.js +71 -68
- package/dist/Input.js.map +1 -1
- package/dist/Input.vue.d.ts +31 -28
- package/dist/InputOptions.js +76 -68
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +55 -23
- package/dist/ListView.vue.d.ts +213 -146
- package/dist/RadioGroup.js +67 -70
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioGroup.vue.d.ts +54 -45
- package/dist/Select.js +223 -224
- package/dist/Select.js.map +1 -1
- package/dist/Select.vue.d.ts +54 -51
- package/dist/TextEditor.js +671 -684
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +54 -61
- package/dist/Textarea.js +63 -60
- package/dist/Textarea.js.map +1 -1
- package/dist/Textarea.vue.d.ts +50 -39
- package/dist/components.css +2 -2
- package/package.json +1 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang--tBfZB2K.js.map +0 -1
package/dist/Input.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as P, useSlots as U, useCssModule as
|
|
2
|
-
import
|
|
3
|
-
import { convertDecimal as
|
|
4
|
-
import { _ as Q } from "./Field.vue_vue_type_script_setup_true_lang
|
|
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
|
-
|
|
24
|
-
|
|
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(
|
|
28
|
-
const e =
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
e.type === "number" && (e.modelValue || e.modelValue === 0) && (
|
|
32
|
-
const
|
|
33
|
-
const o = { ...
|
|
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(() =>
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
40
|
-
if (!
|
|
43
|
+
function g(o = "", a = !1) {
|
|
44
|
+
if (!d.value)
|
|
41
45
|
return o;
|
|
42
46
|
let t = o;
|
|
43
|
-
if (
|
|
44
|
-
if (
|
|
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 (
|
|
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
|
|
57
|
-
return
|
|
60
|
+
function w(o) {
|
|
61
|
+
return d.value ? K(o, h) : o;
|
|
58
62
|
}
|
|
59
63
|
function O() {
|
|
60
|
-
const o =
|
|
64
|
+
const o = d.value ? g(n.value) : n.value;
|
|
61
65
|
m("change", o);
|
|
62
66
|
}
|
|
63
|
-
function
|
|
67
|
+
function R(o) {
|
|
64
68
|
const a = o.target.value;
|
|
65
|
-
|
|
66
|
-
const t =
|
|
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
|
|
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 (
|
|
76
|
+
if (u.onInput)
|
|
73
77
|
throw new Error("ll-input: use the @update:model-value event instead of @input");
|
|
74
|
-
}), (o, a) => (f(),
|
|
75
|
-
"
|
|
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
|
-
}),
|
|
79
|
-
default:
|
|
80
|
-
|
|
81
|
-
H(
|
|
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] = (
|
|
86
|
-
"aria-errormessage":
|
|
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(
|
|
92
|
-
{ [l(
|
|
93
|
-
{ [l(
|
|
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:
|
|
99
|
+
disabled: e.isDisabled || e.disabled,
|
|
100
|
+
readonly: M.value,
|
|
98
101
|
onChange: O,
|
|
99
|
-
onInput:
|
|
100
|
-
onBlur: a[1] || (a[1] = (
|
|
101
|
-
onFocus: a[2] || (a[2] = (
|
|
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,
|
|
106
|
+
[J, n.value]
|
|
104
107
|
]),
|
|
105
|
-
l(r).prepend ? (f(),
|
|
108
|
+
l(r).prepend ? (f(), x("div", {
|
|
106
109
|
key: 0,
|
|
107
|
-
class:
|
|
110
|
+
class: v(["stash-input-prepend font-semibold", [l(s).symbol, l(s)["symbol--prepend"]]])
|
|
108
111
|
}, [
|
|
109
|
-
|
|
112
|
+
b(o.$slots, "prepend")
|
|
110
113
|
], 2)) : I("", !0),
|
|
111
|
-
l(r).append || e.type === "password" ? (f(),
|
|
114
|
+
l(r).append || e.type === "password" ? (f(), x("div", {
|
|
112
115
|
key: 1,
|
|
113
|
-
class:
|
|
116
|
+
class: v(["stash-input-append font-semibold", [l(s).symbol, l(s)["symbol--append"]]])
|
|
114
117
|
}, [
|
|
115
|
-
l(r).append ?
|
|
118
|
+
l(r).append ? b(o.$slots, "append", { key: 0 }) : (f(), V(X, {
|
|
116
119
|
key: 1,
|
|
117
|
-
name:
|
|
118
|
-
class:
|
|
119
|
-
"data-test":
|
|
120
|
-
onClick: a[3] || (a[3] = (
|
|
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:
|
|
130
|
-
|
|
132
|
+
fn: k(() => [
|
|
133
|
+
b(o.$slots, "hint")
|
|
131
134
|
]),
|
|
132
135
|
key: "0"
|
|
133
136
|
} : void 0
|
|
134
|
-
]), 1040, ["
|
|
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
|
-
},
|
|
147
|
+
}, se = {
|
|
145
148
|
$style: ae
|
|
146
|
-
}, me = /* @__PURE__ */ Y(te, [["__cssModules",
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/Input.vue.d.ts
CHANGED
|
@@ -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
|
-
|
|
73
|
+
declare interface FieldProps {
|
|
92
74
|
/**
|
|
93
|
-
* Adds spacing under the field that is consistent whether
|
|
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;
|
package/dist/InputOptions.js
CHANGED
|
@@ -1,143 +1,151 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { _ as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as S, useAttrs as O, useSlots as E, useCssModule as T, ref as p, watchEffect as $, watch as h, openBlock as d, createBlock as D, mergeProps as M, createSlots as R, withCtx as f, createElementBlock as y, createElementVNode as z, toDisplayString as _, normalizeClass as r, unref as s, createVNode as b, renderSlot as F } from "vue";
|
|
2
|
+
import N from "./Input.js";
|
|
3
|
+
import U from "./Select.js";
|
|
4
|
+
import { _ as q } from "./Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js";
|
|
5
|
+
import { _ as A } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const L = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "tw-flex tw-h-input tw-items-center tw-text-sm"
|
|
9
|
-
},
|
|
9
|
+
}, P = ["id", "aria-labelledby"], j = /* @__PURE__ */ S({
|
|
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
|
-
|
|
22
|
-
|
|
18
|
+
displayBy: { default: void 0 },
|
|
19
|
+
trackBy: { default: void 0 },
|
|
20
|
+
addBottomSpace: { type: Boolean },
|
|
21
|
+
errorText: {},
|
|
22
|
+
hintText: {},
|
|
23
|
+
id: {},
|
|
24
|
+
errorId: {},
|
|
25
|
+
isReadOnly: { type: Boolean },
|
|
26
|
+
isRequired: { type: Boolean },
|
|
27
|
+
label: {},
|
|
28
|
+
showOptionalInLabel: { type: Boolean },
|
|
29
|
+
fieldset: { type: Boolean },
|
|
30
|
+
isDisabled: { type: Boolean },
|
|
31
|
+
disabled: { type: Boolean }
|
|
23
32
|
},
|
|
24
33
|
emits: ["update:model-value", "change"],
|
|
25
|
-
setup(
|
|
26
|
-
const e =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function B(l) {
|
|
31
|
-
a.value = String(l), n("update:model-value", {
|
|
32
|
-
value: a.value,
|
|
34
|
+
setup(w, { emit: g }) {
|
|
35
|
+
const e = w, o = g, c = O(), B = E(), i = T(), l = p(), u = p(!1), t = p();
|
|
36
|
+
function V(a) {
|
|
37
|
+
l.value = String(a), o("update:model-value", {
|
|
38
|
+
value: l.value,
|
|
33
39
|
option: t.value,
|
|
34
40
|
isValueChange: !0,
|
|
35
41
|
type: "input"
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
44
|
function k() {
|
|
39
|
-
|
|
40
|
-
value:
|
|
45
|
+
o("change", {
|
|
46
|
+
value: l.value,
|
|
41
47
|
option: t.value,
|
|
42
48
|
isValueChange: !0,
|
|
43
49
|
type: "input"
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
|
-
function
|
|
47
|
-
t.value =
|
|
48
|
-
value:
|
|
52
|
+
function C(a) {
|
|
53
|
+
t.value = a, o("change", {
|
|
54
|
+
value: l.value,
|
|
49
55
|
option: t.value,
|
|
50
56
|
isValueChange: !1,
|
|
51
57
|
type: "select"
|
|
52
|
-
}),
|
|
53
|
-
value:
|
|
58
|
+
}), o("update:model-value", {
|
|
59
|
+
value: l.value,
|
|
54
60
|
option: t.value,
|
|
55
61
|
isValueChange: !1,
|
|
56
62
|
type: "select"
|
|
57
63
|
});
|
|
58
64
|
}
|
|
59
|
-
if (
|
|
65
|
+
if ($(() => {
|
|
60
66
|
t.value || (t.value = e.options[0]);
|
|
61
|
-
}),
|
|
67
|
+
}), h(
|
|
62
68
|
() => e.modelValue.value,
|
|
63
69
|
() => {
|
|
64
|
-
|
|
70
|
+
l.value = e.modelValue.value;
|
|
65
71
|
},
|
|
66
72
|
{ immediate: !0 }
|
|
67
|
-
),
|
|
73
|
+
), h(
|
|
68
74
|
() => e.modelValue.option,
|
|
69
75
|
() => {
|
|
70
76
|
t.value = e.modelValue.option;
|
|
71
77
|
},
|
|
72
78
|
{ immediate: !0 }
|
|
73
|
-
),
|
|
79
|
+
), c.value)
|
|
74
80
|
throw new Error("ll-input-options: use :model-value or v-model instead of :value.");
|
|
75
|
-
if (
|
|
81
|
+
if (c.onInput)
|
|
76
82
|
throw new Error("ll-input-options: use the @update:model-value event instead of @input");
|
|
77
|
-
return (
|
|
83
|
+
return (a, n) => (d(), D(q, M(e, {
|
|
78
84
|
class: "stash-input-options",
|
|
79
85
|
"data-test": "stash-input-options"
|
|
80
|
-
}),
|
|
81
|
-
default:
|
|
86
|
+
}), R({
|
|
87
|
+
default: f(({ fieldId: m, labelId: x }) => {
|
|
82
88
|
var v;
|
|
83
89
|
return [
|
|
84
|
-
e.isReadOnly ? (
|
|
85
|
-
|
|
86
|
-
id:
|
|
87
|
-
"aria-labelledby":
|
|
90
|
+
e.isReadOnly ? (d(), y("div", L, [
|
|
91
|
+
z("span", {
|
|
92
|
+
id: m,
|
|
93
|
+
"aria-labelledby": x,
|
|
88
94
|
class: "tw-h-min"
|
|
89
|
-
}, _(
|
|
90
|
-
])) : (
|
|
95
|
+
}, _(l.value || 0) + " " + _((v = t.value) == null ? void 0 : v.name), 9, P)
|
|
96
|
+
])) : (d(), y("div", {
|
|
91
97
|
key: 1,
|
|
92
|
-
class:
|
|
98
|
+
class: r(["tw-flex", { [s(i)["has-error"]]: !!e.errorText }])
|
|
93
99
|
}, [
|
|
94
|
-
|
|
95
|
-
id:
|
|
96
|
-
class:
|
|
100
|
+
b(N, {
|
|
101
|
+
id: m,
|
|
102
|
+
class: r(["stash-input-options__input -tw-mr-[1px] tw-inline-block tw-flex-1", [s(i).input, { "tw-z-control": u.value }]]),
|
|
97
103
|
"data-test": "stash-input-options|input",
|
|
98
104
|
type: e.type,
|
|
99
|
-
"model-value":
|
|
100
|
-
disabled: e.disabled,
|
|
105
|
+
"model-value": l.value,
|
|
106
|
+
disabled: e.isDisabled || e.disabled,
|
|
101
107
|
placeholder: e.placeholder,
|
|
102
108
|
onChange: k,
|
|
103
|
-
"onUpdate:modelValue":
|
|
104
|
-
onBlur:
|
|
105
|
-
onFocus:
|
|
109
|
+
"onUpdate:modelValue": V,
|
|
110
|
+
onBlur: n[0] || (n[0] = (I) => u.value = !1),
|
|
111
|
+
onFocus: n[1] || (n[1] = (I) => u.value = !0)
|
|
106
112
|
}, null, 8, ["id", "class", "type", "model-value", "disabled", "placeholder"]),
|
|
107
|
-
|
|
113
|
+
b(U, {
|
|
108
114
|
single: "",
|
|
109
115
|
"hide-search": "",
|
|
110
116
|
"prevent-empty": "",
|
|
111
|
-
class: ["stash-input-options__select tw-min-w-20",
|
|
117
|
+
class: r(["stash-input-options__select tw-min-w-20", s(i).select]),
|
|
112
118
|
"data-test": "stash-input-options|select",
|
|
113
|
-
"no-truncate":
|
|
114
|
-
options:
|
|
119
|
+
"no-truncate": a.noTruncate,
|
|
120
|
+
options: a.options,
|
|
115
121
|
"model-value": t.value,
|
|
116
|
-
|
|
117
|
-
"
|
|
118
|
-
|
|
122
|
+
"display-by": e.displayBy,
|
|
123
|
+
"track-by": e.trackBy,
|
|
124
|
+
disabled: e.isDisabled || e.disabled,
|
|
125
|
+
"onUpdate:modelValue": C
|
|
126
|
+
}, null, 8, ["class", "no-truncate", "options", "model-value", "display-by", "track-by", "disabled"])
|
|
119
127
|
], 2))
|
|
120
128
|
];
|
|
121
129
|
}),
|
|
122
130
|
_: 2
|
|
123
131
|
}, [
|
|
124
|
-
|
|
132
|
+
s(B).hint ? {
|
|
125
133
|
name: "hint",
|
|
126
|
-
fn:
|
|
127
|
-
|
|
134
|
+
fn: f(() => [
|
|
135
|
+
F(a.$slots, "hint")
|
|
128
136
|
]),
|
|
129
137
|
key: "0"
|
|
130
138
|
} : void 0
|
|
131
139
|
]), 1040));
|
|
132
140
|
}
|
|
133
|
-
}),
|
|
134
|
-
input:
|
|
135
|
-
select:
|
|
141
|
+
}), G = "_input_gn7he_2", H = "_select_gn7he_7", J = {
|
|
142
|
+
input: G,
|
|
143
|
+
select: H,
|
|
136
144
|
"has-error": "_has-error_gn7he_16"
|
|
137
|
-
},
|
|
138
|
-
$style:
|
|
139
|
-
},
|
|
145
|
+
}, K = {
|
|
146
|
+
$style: J
|
|
147
|
+
}, ee = /* @__PURE__ */ A(j, [["__cssModules", K]]);
|
|
140
148
|
export {
|
|
141
|
-
|
|
149
|
+
ee as default
|
|
142
150
|
};
|
|
143
151
|
//# sourceMappingURL=InputOptions.js.map
|