@leaflink/stash 51.2.0 → 51.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CurrencyInput.js +1 -0
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/CurrencyInput.vue.d.ts +4 -0
- package/dist/DataViewFilters.js +1 -1
- package/dist/Field.js +1 -1
- package/dist/Field.vue.d.ts +7 -0
- package/dist/{Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js → Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js} +21 -19
- package/dist/Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js.map +1 -0
- package/dist/FilterSelect.js +16 -15
- package/dist/FilterSelect.js.map +1 -1
- package/dist/FilterSelect.vue.d.ts +4 -0
- package/dist/Filters.vue.d.ts +27 -0
- package/dist/Input.js +16 -15
- package/dist/Input.js.map +1 -1
- package/dist/Input.vue.d.ts +4 -0
- package/dist/InputOptions.js +20 -19
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +4 -0
- package/dist/Label.js +1 -1
- package/dist/Label.vue.d.ts +7 -0
- package/dist/{Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js → Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js} +13 -11
- package/dist/Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js.map +1 -0
- package/dist/ListView.vue.d.ts +36 -0
- package/dist/RadioGroup.js +48 -47
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioGroup.vue.d.ts +4 -0
- package/dist/Select.js +2 -1
- package/dist/Select.js.map +1 -1
- package/dist/Select.vue.d.ts +4 -0
- package/dist/TextEditor.js +2 -1
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +4 -0
- package/dist/Textarea.js +24 -23
- package/dist/Textarea.js.map +1 -1
- package/dist/Textarea.vue.d.ts +4 -0
- package/package.json +1 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js.map +0 -1
- package/dist/Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js.map +0 -1
package/dist/Filters.vue.d.ts
CHANGED
|
@@ -528,6 +528,9 @@ type: PropType<boolean>;
|
|
|
528
528
|
showOptionalInLabel: {
|
|
529
529
|
type: PropType<boolean>;
|
|
530
530
|
};
|
|
531
|
+
isLabelSrOnly: {
|
|
532
|
+
type: PropType<boolean>;
|
|
533
|
+
};
|
|
531
534
|
placeholder: {
|
|
532
535
|
type: PropType<string>;
|
|
533
536
|
default: undefined;
|
|
@@ -610,6 +613,9 @@ type: PropType<boolean>;
|
|
|
610
613
|
showOptionalInLabel: {
|
|
611
614
|
type: PropType<boolean>;
|
|
612
615
|
};
|
|
616
|
+
isLabelSrOnly: {
|
|
617
|
+
type: PropType<boolean>;
|
|
618
|
+
};
|
|
613
619
|
placeholder: {
|
|
614
620
|
type: PropType<string>;
|
|
615
621
|
default: undefined;
|
|
@@ -684,6 +690,9 @@ type: PropType<boolean>;
|
|
|
684
690
|
showOptionalInLabel: {
|
|
685
691
|
type: PropType<boolean>;
|
|
686
692
|
};
|
|
693
|
+
isLabelSrOnly: {
|
|
694
|
+
type: PropType<boolean>;
|
|
695
|
+
};
|
|
687
696
|
placeholder: {
|
|
688
697
|
type: PropType<string>;
|
|
689
698
|
default: undefined;
|
|
@@ -771,6 +780,9 @@ type: PropType<boolean>;
|
|
|
771
780
|
showOptionalInLabel: {
|
|
772
781
|
type: PropType<boolean>;
|
|
773
782
|
};
|
|
783
|
+
isLabelSrOnly: {
|
|
784
|
+
type: PropType<boolean>;
|
|
785
|
+
};
|
|
774
786
|
placeholder: {
|
|
775
787
|
type: PropType<string>;
|
|
776
788
|
default: undefined;
|
|
@@ -886,6 +898,9 @@ type: PropType<boolean>;
|
|
|
886
898
|
showOptionalInLabel: {
|
|
887
899
|
type: PropType<boolean>;
|
|
888
900
|
};
|
|
901
|
+
isLabelSrOnly: {
|
|
902
|
+
type: PropType<boolean>;
|
|
903
|
+
};
|
|
889
904
|
placeholder: {
|
|
890
905
|
type: PropType<string>;
|
|
891
906
|
default: undefined;
|
|
@@ -985,6 +1000,9 @@ type: PropType<boolean>;
|
|
|
985
1000
|
showOptionalInLabel: {
|
|
986
1001
|
type: PropType<boolean>;
|
|
987
1002
|
};
|
|
1003
|
+
isLabelSrOnly: {
|
|
1004
|
+
type: PropType<boolean>;
|
|
1005
|
+
};
|
|
988
1006
|
placeholder: {
|
|
989
1007
|
type: PropType<string>;
|
|
990
1008
|
default: undefined;
|
|
@@ -1182,6 +1200,9 @@ type: PropType<boolean>;
|
|
|
1182
1200
|
showOptionalInLabel: {
|
|
1183
1201
|
type: PropType<boolean>;
|
|
1184
1202
|
};
|
|
1203
|
+
isLabelSrOnly: {
|
|
1204
|
+
type: PropType<boolean>;
|
|
1205
|
+
};
|
|
1185
1206
|
placeholder: {
|
|
1186
1207
|
type: PropType<string>;
|
|
1187
1208
|
default: string;
|
|
@@ -1391,6 +1412,9 @@ type: PropType<boolean>;
|
|
|
1391
1412
|
showOptionalInLabel: {
|
|
1392
1413
|
type: PropType<boolean>;
|
|
1393
1414
|
};
|
|
1415
|
+
isLabelSrOnly: {
|
|
1416
|
+
type: PropType<boolean>;
|
|
1417
|
+
};
|
|
1394
1418
|
placeholder: {
|
|
1395
1419
|
type: PropType<string>;
|
|
1396
1420
|
default: string;
|
|
@@ -1590,6 +1614,9 @@ type: PropType<boolean>;
|
|
|
1590
1614
|
showOptionalInLabel: {
|
|
1591
1615
|
type: PropType<boolean>;
|
|
1592
1616
|
};
|
|
1617
|
+
isLabelSrOnly: {
|
|
1618
|
+
type: PropType<boolean>;
|
|
1619
|
+
};
|
|
1593
1620
|
placeholder: {
|
|
1594
1621
|
type: PropType<string>;
|
|
1595
1622
|
default: string;
|
package/dist/Input.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as L, useSlots as P, useCssModule as U, useAttrs as q, ref as y, computed as c, watchEffect as G, onMounted as W, createBlock as B, openBlock as f, mergeProps as V, unref as l, createSlots as j, withCtx as k, createElementVNode as N, withDirectives as H, createElementBlock as x, createCommentVNode as I, vModelDynamic as J, normalizeClass as v, renderSlot as b } from "vue";
|
|
2
2
|
import C from "lodash-es/isNil";
|
|
3
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-
|
|
4
|
+
import { _ as Q } from "./Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js";
|
|
5
5
|
import X from "./Icon.js";
|
|
6
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__ */
|
|
7
|
+
const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-invalid", "autocomplete", "placeholder", "type", "disabled", "readonly"], te = /* @__PURE__ */ L({
|
|
8
8
|
name: "ll-input",
|
|
9
9
|
inheritAttrs: !1,
|
|
10
10
|
__name: "Input",
|
|
@@ -23,21 +23,22 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
|
|
|
23
23
|
isRequired: { type: Boolean },
|
|
24
24
|
label: {},
|
|
25
25
|
showOptionalInLabel: { type: Boolean },
|
|
26
|
+
isLabelSrOnly: { type: Boolean },
|
|
26
27
|
fieldset: { type: Boolean },
|
|
27
28
|
isDisabled: { type: Boolean },
|
|
28
29
|
disabled: { type: Boolean }
|
|
29
30
|
},
|
|
30
31
|
emits: ["update:model-value", "change", "focus", "blur"],
|
|
31
|
-
setup(
|
|
32
|
-
const e =
|
|
33
|
-
|
|
32
|
+
setup(S, { expose: $, emit: E }) {
|
|
33
|
+
const e = S, m = E, r = P(), s = U(), u = q(), _ = y();
|
|
34
|
+
$({ inputEl: _ });
|
|
34
35
|
const n = y(e.modelValue);
|
|
35
36
|
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"),
|
|
37
|
+
const i = y(!1), M = c(() => e.isReadOnly || "readonly" in u && u.readonly !== !1), d = c(() => e.type === "number"), O = c(() => {
|
|
37
38
|
const o = { ...u };
|
|
38
39
|
return delete o.class, o;
|
|
39
|
-
}),
|
|
40
|
-
|
|
40
|
+
}), A = c(() => d.value || e.type === "password" && i.value ? "text" : e.type);
|
|
41
|
+
G(() => {
|
|
41
42
|
n.value = w(e.modelValue);
|
|
42
43
|
});
|
|
43
44
|
function g(o = "", a = !1) {
|
|
@@ -60,7 +61,7 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
|
|
|
60
61
|
function w(o) {
|
|
61
62
|
return d.value ? K(o, h) : o;
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
+
function F() {
|
|
64
65
|
const o = d.value ? g(n.value) : n.value;
|
|
65
66
|
m("change", o);
|
|
66
67
|
}
|
|
@@ -75,13 +76,13 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
|
|
|
75
76
|
throw new Error("ll-input: use :model-value or v-model instead of :value.");
|
|
76
77
|
if (u.onInput)
|
|
77
78
|
throw new Error("ll-input: use the @update:model-value event instead of @input");
|
|
78
|
-
}), (o, a) => (f(),
|
|
79
|
+
}), (o, a) => (f(), B(Q, V(e, {
|
|
79
80
|
class: ["stash-input", [l(s).root, l(u).class]],
|
|
80
81
|
"data-test": "ll-input"
|
|
81
82
|
}), j({
|
|
82
83
|
default: k(({ fieldId: t, fieldErrorId: T, hasError: z }) => [
|
|
83
84
|
N("div", Z, [
|
|
84
|
-
H(N("input",
|
|
85
|
+
H(N("input", V(O.value, {
|
|
85
86
|
id: t,
|
|
86
87
|
ref_key: "inputEl",
|
|
87
88
|
ref: _,
|
|
@@ -95,10 +96,10 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
|
|
|
95
96
|
{ [l(s)["input-appended"]]: !!l(r).append || e.type === "password" },
|
|
96
97
|
{ [l(s)["has-error"]]: !!e.errorText }
|
|
97
98
|
],
|
|
98
|
-
type:
|
|
99
|
+
type: A.value,
|
|
99
100
|
disabled: e.isDisabled || e.disabled,
|
|
100
101
|
readonly: M.value,
|
|
101
|
-
onChange:
|
|
102
|
+
onChange: F,
|
|
102
103
|
onInput: R,
|
|
103
104
|
onBlur: a[1] || (a[1] = (p) => m("blur", p)),
|
|
104
105
|
onFocus: a[2] || (a[2] = (p) => m("focus", p))
|
|
@@ -115,7 +116,7 @@ const Z = { class: "tw-relative" }, ee = ["id", "aria-errormessage", "aria-inval
|
|
|
115
116
|
key: 1,
|
|
116
117
|
class: v(["stash-input-append font-semibold", [l(s).symbol, l(s)["symbol--append"]]])
|
|
117
118
|
}, [
|
|
118
|
-
l(r).append ? b(o.$slots, "append", { key: 0 }) : (f(),
|
|
119
|
+
l(r).append ? b(o.$slots, "append", { key: 0 }) : (f(), B(X, {
|
|
119
120
|
key: 1,
|
|
120
121
|
name: i.value ? "hide" : "show",
|
|
121
122
|
class: v(["tw-cursor-pointer", { "tw-text-ice-500": e.isDisabled || e.disabled }]),
|
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 { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n import Icon from '../Icon/Icon.vue';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CE,UAAMA,IAAQC,GAQRC,IAAOC,GAmBPC,IAAQC,EAAS,GACjBC,IAAUC,EAAa,GACvBC,IAAQC,EAAS,GAIjBC,IAAUC,EAAsB;AAIzB,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,EAAM;AAE7B,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,IAAA;AAQ7D,aAASJ,EAAOE,GAAwB;AACtC,aAAIP,EAAS,QACJW,EAAgBJ,GAAOX,CAAgB,IAGzCW;AAAA,IAAA;AAMT,aAASK,IAAe;AAEtB,YAAMC,IAAcb,EAAS,QAAQM,EAAYZ,EAAc,KAAK,IAAIA,EAAc;AACtF,MAAAX,EAAK,UAAU8B,CAAW;AAAA,IAAA;AAM5B,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,IAAA;AAGxC,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 { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n import Icon from '../Icon/Icon.vue';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CE,UAAMA,IAAQC,GAQRC,IAAOC,GAmBPC,IAAQC,EAAS,GACjBC,IAAUC,EAAa,GACvBC,IAAQC,EAAS,GAIjBC,IAAUC,EAAsB;AAIzB,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,EAAM;AAE7B,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,IAAA;AAQ7D,aAASJ,EAAOE,GAAwB;AACtC,aAAIP,EAAS,QACJW,EAAgBJ,GAAOX,CAAgB,IAGzCW;AAAA,IAAA;AAMT,aAASK,IAAe;AAEtB,YAAMC,IAAcb,EAAS,QAAQM,EAAYZ,EAAc,KAAK,IAAIA,EAAc;AACtF,MAAAX,EAAK,UAAU8B,CAAW;AAAA,IAAA;AAM5B,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,IAAA;AAGxC,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
|
@@ -107,6 +107,10 @@ declare interface FieldProps {
|
|
|
107
107
|
* Show "(optional)" to the right of the label text
|
|
108
108
|
*/
|
|
109
109
|
showOptionalInLabel?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Indicates whether the label should be visually hidden (screen reader only).
|
|
112
|
+
*/
|
|
113
|
+
isLabelSrOnly?: boolean;
|
|
110
114
|
/**
|
|
111
115
|
* Indicates wheter the field is a fieldset or not
|
|
112
116
|
*/
|
package/dist/InputOptions.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as O, useSlots as $, useAttrs as E, useCssModule as T, ref as u, watchEffect as D, watch as v, createBlock as j, openBlock as p, mergeProps as M, createSlots as R, withCtx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { _ as
|
|
5
|
-
import { _ as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as O, useSlots as $, useAttrs as E, useCssModule as T, ref as u, watchEffect as D, watch as v, createBlock as j, openBlock as p, mergeProps as M, createSlots as R, withCtx as y, createElementBlock as h, createElementVNode as F, toDisplayString as f, normalizeClass as _, unref as d, renderSlot as b, createVNode as w } from "vue";
|
|
2
|
+
import L from "./Input.js";
|
|
3
|
+
import N from "./Select.js";
|
|
4
|
+
import { _ as U } from "./Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js";
|
|
5
|
+
import { _ as q } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const z = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "tw-flex tw-h-input tw-items-center tw-text-sm"
|
|
9
|
-
},
|
|
9
|
+
}, A = ["id", "aria-labelledby"], P = /* @__PURE__ */ O({
|
|
10
10
|
name: "ll-input-options",
|
|
11
11
|
__name: "InputOptions",
|
|
12
12
|
props: {
|
|
@@ -26,6 +26,7 @@ const A = {
|
|
|
26
26
|
isRequired: { type: Boolean },
|
|
27
27
|
label: {},
|
|
28
28
|
showOptionalInLabel: { type: Boolean },
|
|
29
|
+
isLabelSrOnly: { type: Boolean },
|
|
29
30
|
fieldset: { type: Boolean },
|
|
30
31
|
isDisabled: { type: Boolean },
|
|
31
32
|
disabled: { type: Boolean }
|
|
@@ -49,7 +50,7 @@ const A = {
|
|
|
49
50
|
type: "input"
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function S(l) {
|
|
53
54
|
t.value = l, o("change", {
|
|
54
55
|
value: a.value,
|
|
55
56
|
option: t.value,
|
|
@@ -80,25 +81,25 @@ const A = {
|
|
|
80
81
|
throw new Error("ll-input-options: use :model-value or v-model instead of :value.");
|
|
81
82
|
if (r.onInput)
|
|
82
83
|
throw new Error("ll-input-options: use the @update:model-value event instead of @input");
|
|
83
|
-
return (l, s) => (p(), j(
|
|
84
|
+
return (l, s) => (p(), j(U, M(e, {
|
|
84
85
|
class: "stash-input-options",
|
|
85
86
|
"data-test": "stash-input-options"
|
|
86
87
|
}), R({
|
|
87
|
-
default:
|
|
88
|
+
default: y(({ fieldId: i, labelId: I }) => {
|
|
88
89
|
var m;
|
|
89
90
|
return [
|
|
90
|
-
e.isReadOnly ? (p(),
|
|
91
|
+
e.isReadOnly ? (p(), h("div", z, [
|
|
91
92
|
F("span", {
|
|
92
93
|
id: i,
|
|
93
|
-
"aria-labelledby":
|
|
94
|
+
"aria-labelledby": I,
|
|
94
95
|
class: "tw-h-min"
|
|
95
|
-
}, f(a.value || 0) + " " + f((m = t.value) == null ? void 0 : m.name), 9,
|
|
96
|
-
])) : (p(),
|
|
96
|
+
}, f(a.value || 0) + " " + f((m = t.value) == null ? void 0 : m.name), 9, A)
|
|
97
|
+
])) : (p(), h("div", {
|
|
97
98
|
key: 1,
|
|
98
99
|
class: _(["tw-flex", [d(n)["input-wrapper"], { [d(n)["has-error"]]: !!e.errorText }]])
|
|
99
100
|
}, [
|
|
100
101
|
b(l.$slots, "default", { fieldId: i }, () => [
|
|
101
|
-
w(
|
|
102
|
+
w(L, {
|
|
102
103
|
id: i,
|
|
103
104
|
class: "stash-input-options__input",
|
|
104
105
|
"data-test": "stash-input-options|input",
|
|
@@ -112,7 +113,7 @@ const A = {
|
|
|
112
113
|
onFocus: s[1] || (s[1] = (x) => c.value = !0)
|
|
113
114
|
}, null, 8, ["id", "type", "model-value", "disabled", "placeholder"])
|
|
114
115
|
]),
|
|
115
|
-
w(
|
|
116
|
+
w(N, {
|
|
116
117
|
single: "",
|
|
117
118
|
"hide-search": "",
|
|
118
119
|
"prevent-empty": "",
|
|
@@ -124,7 +125,7 @@ const A = {
|
|
|
124
125
|
"display-by": e.displayBy,
|
|
125
126
|
"track-by": e.trackBy,
|
|
126
127
|
disabled: e.isDisabled || e.disabled,
|
|
127
|
-
"onUpdate:modelValue":
|
|
128
|
+
"onUpdate:modelValue": S
|
|
128
129
|
}, null, 8, ["class", "no-truncate", "options", "model-value", "display-by", "track-by", "disabled"])
|
|
129
130
|
], 2))
|
|
130
131
|
];
|
|
@@ -133,7 +134,7 @@ const A = {
|
|
|
133
134
|
}, [
|
|
134
135
|
V.hint ? {
|
|
135
136
|
name: "hint",
|
|
136
|
-
fn:
|
|
137
|
+
fn: y(() => [
|
|
137
138
|
b(l.$slots, "hint")
|
|
138
139
|
]),
|
|
139
140
|
key: "0"
|
|
@@ -146,7 +147,7 @@ const A = {
|
|
|
146
147
|
select: G
|
|
147
148
|
}, J = {
|
|
148
149
|
$style: H
|
|
149
|
-
}, Z = /* @__PURE__ */
|
|
150
|
+
}, Z = /* @__PURE__ */ q(P, [["__cssModules", J]]);
|
|
150
151
|
export {
|
|
151
152
|
Z as default
|
|
152
153
|
};
|
package/dist/InputOptions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputOptions.js","sources":["../src/components/InputOptions/InputOptions.vue"],"sourcesContent":["<script lang=\"ts\">\n import { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type Option = any;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type SelectedOption = any;\n\n export interface InputOptionsProps extends FieldProps {\n /**\n * The current value inclusive of the input & select\n */\n modelValue?: { value: string; option?: SelectedOption };\n\n /**\n * Input type\n */\n type?: string extends 'button' | 'checkbox' | 'radio' | 'submit' ? never : string;\n\n /**\n * Prevents the Selected Option from being truncated, if true\n */\n noTruncate?: boolean;\n\n /**\n * Options for the select\n */\n options?: Option[];\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 * If `options` are an object, this is what prop to use for display.\n */\n displayBy?: string;\n\n /**\n * Default field to track selected options by.\n */\n trackBy?: string;\n }\n</script>\n\n<script lang=\"ts\" setup>\n import { ref, useAttrs, useCssModule, watch, watchEffect } from 'vue';\n\n import Input from '../Input/Input.vue';\n import Select from '../Select/Select.vue';\n\n defineOptions({\n name: 'll-input-options',\n });\n\n const props = withDefaults(defineProps<InputOptionsProps>(), {\n modelValue: () => ({ value: '', option: undefined }),\n noTruncate: false,\n options: () => [],\n type: 'text',\n placeholder: undefined,\n displayBy: undefined,\n trackBy: undefined,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the model value changes\n */\n (\n e: 'update:model-value',\n v: { value?: string; option?: SelectedOption; isValueChange: boolean; type: 'input' | 'select' },\n ): void;\n /**\n * Emitted when either the input or select changes\n */\n (\n e: 'change',\n v: { value?: string; option?: SelectedOption; isValueChange: boolean; type: 'input' | 'select' },\n ): void;\n }>();\n\n const slots = defineSlots<{\n /**\n * Default slot for rendering a custom input field.\n */\n default: (props: { fieldId: string }) => void;\n /**\n * Hint slot for rendering a custom hint text.\n */\n hint: () => void;\n }>();\n\n const attrs = useAttrs();\n const classes = useCssModule();\n const internalInput = ref<string>();\n const isInputFocused = ref(false);\n const selectedOption = ref<Option | undefined>();\n\n // Input value changed\n function handleInput(val?: string | number) {\n internalInput.value = String(val);\n\n emit('update:model-value', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: true,\n type: 'input',\n });\n }\n\n // Input blurred\n function handleInputChange() {\n emit('change', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: true,\n type: 'input',\n });\n }\n\n function handleSelectChange(val?: Option) {\n selectedOption.value = val;\n\n emit('change', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: false,\n type: 'select',\n });\n emit('update:model-value', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: false,\n type: 'select',\n });\n }\n\n watchEffect(() => {\n if (!selectedOption.value) {\n selectedOption.value = props.options[0];\n }\n });\n\n watch(\n () => props.modelValue.value,\n () => {\n internalInput.value = props.modelValue.value;\n },\n { immediate: true },\n );\n\n watch(\n () => props.modelValue.option,\n () => {\n selectedOption.value = props.modelValue.option;\n },\n { immediate: true },\n );\n\n if (attrs.value) {\n throw new Error('ll-input-options: use :model-value or v-model instead of :value.');\n }\n\n if (attrs.onInput) {\n throw new Error('ll-input-options: use the @update:model-value event instead of @input');\n }\n</script>\n\n<template>\n <Field v-bind=\"props\" class=\"stash-input-options\" data-test=\"stash-input-options\">\n <template #default=\"{ fieldId, labelId }\">\n <div v-if=\"props.isReadOnly\" class=\"tw-flex tw-h-input tw-items-center tw-text-sm\">\n <span :id=\"fieldId\" :aria-labelledby=\"labelId\" class=\"tw-h-min\">\n {{ internalInput || 0 }} {{ selectedOption?.name }}\n </span>\n </div>\n <div v-else class=\"tw-flex\" :class=\"[classes['input-wrapper'], { [classes['has-error']]: !!props.errorText }]\">\n <slot :field-id=\"fieldId\">\n <Input\n :id=\"fieldId\"\n class=\"stash-input-options__input\"\n data-test=\"stash-input-options|input\"\n :type=\"props.type\"\n :model-value=\"internalInput\"\n :disabled=\"props.isDisabled || props.disabled\"\n :placeholder=\"props.placeholder\"\n @change=\"handleInputChange\"\n @update:model-value=\"handleInput\"\n @blur=\"isInputFocused = false\"\n @focus=\"isInputFocused = true\"\n />\n </slot>\n\n <Select\n single\n hide-search\n prevent-empty\n class=\"stash-input-options__select tw-min-w-20\"\n data-test=\"stash-input-options|select\"\n :class=\"classes.select\"\n :no-truncate=\"noTruncate\"\n :options=\"options\"\n :model-value=\"selectedOption\"\n :display-by=\"props.displayBy\"\n :track-by=\"props.trackBy\"\n :disabled=\"props.isDisabled || props.disabled\"\n @update:model-value=\"handleSelectChange\"\n />\n </div>\n </template>\n <template v-if=\"slots.hint\" #hint>\n <!-- @slot Hint slot for rendering text below the input -->\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style module>\n .input-wrapper {\n & > div:has(input) {\n display: inline-block;\n flex: 1;\n margin-right: -1px;\n }\n\n & input {\n border-bottom-right-radius: 0;\n border-top-right-radius: 0;\n }\n\n &.has-error input,\n &.has-error input:hover:not(:focus),\n &.has-error :global(.stash-select__content),\n &.has-error :global(.stash-select__content:hover:not(:focus)) {\n border-color: var(--color-red-500);\n }\n\n & div:has(input:focus) {\n z-index: 200 !important;\n }\n }\n\n .select :global(.stash-select__content) {\n border-bottom-left-radius: 0;\n border-top-left-radius: 0;\n }\n\n .select:global(.stash-select--active .stash-select__content) {\n min-width: 0;\n }\n</style>\n"],"names":["props","__props","emit","__emit","slots","_useSlots","attrs","useAttrs","classes","useCssModule","internalInput","ref","isInputFocused","selectedOption","handleInput","val","handleInputChange","handleSelectChange","watchEffect","watch"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InputOptions.js","sources":["../src/components/InputOptions/InputOptions.vue"],"sourcesContent":["<script lang=\"ts\">\n import { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type Option = any;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type SelectedOption = any;\n\n export interface InputOptionsProps extends FieldProps {\n /**\n * The current value inclusive of the input & select\n */\n modelValue?: { value: string; option?: SelectedOption };\n\n /**\n * Input type\n */\n type?: string extends 'button' | 'checkbox' | 'radio' | 'submit' ? never : string;\n\n /**\n * Prevents the Selected Option from being truncated, if true\n */\n noTruncate?: boolean;\n\n /**\n * Options for the select\n */\n options?: Option[];\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 * If `options` are an object, this is what prop to use for display.\n */\n displayBy?: string;\n\n /**\n * Default field to track selected options by.\n */\n trackBy?: string;\n }\n</script>\n\n<script lang=\"ts\" setup>\n import { ref, useAttrs, useCssModule, watch, watchEffect } from 'vue';\n\n import Input from '../Input/Input.vue';\n import Select from '../Select/Select.vue';\n\n defineOptions({\n name: 'll-input-options',\n });\n\n const props = withDefaults(defineProps<InputOptionsProps>(), {\n modelValue: () => ({ value: '', option: undefined }),\n noTruncate: false,\n options: () => [],\n type: 'text',\n placeholder: undefined,\n displayBy: undefined,\n trackBy: undefined,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the model value changes\n */\n (\n e: 'update:model-value',\n v: { value?: string; option?: SelectedOption; isValueChange: boolean; type: 'input' | 'select' },\n ): void;\n /**\n * Emitted when either the input or select changes\n */\n (\n e: 'change',\n v: { value?: string; option?: SelectedOption; isValueChange: boolean; type: 'input' | 'select' },\n ): void;\n }>();\n\n const slots = defineSlots<{\n /**\n * Default slot for rendering a custom input field.\n */\n default: (props: { fieldId: string }) => void;\n /**\n * Hint slot for rendering a custom hint text.\n */\n hint: () => void;\n }>();\n\n const attrs = useAttrs();\n const classes = useCssModule();\n const internalInput = ref<string>();\n const isInputFocused = ref(false);\n const selectedOption = ref<Option | undefined>();\n\n // Input value changed\n function handleInput(val?: string | number) {\n internalInput.value = String(val);\n\n emit('update:model-value', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: true,\n type: 'input',\n });\n }\n\n // Input blurred\n function handleInputChange() {\n emit('change', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: true,\n type: 'input',\n });\n }\n\n function handleSelectChange(val?: Option) {\n selectedOption.value = val;\n\n emit('change', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: false,\n type: 'select',\n });\n emit('update:model-value', {\n value: internalInput.value,\n option: selectedOption.value,\n isValueChange: false,\n type: 'select',\n });\n }\n\n watchEffect(() => {\n if (!selectedOption.value) {\n selectedOption.value = props.options[0];\n }\n });\n\n watch(\n () => props.modelValue.value,\n () => {\n internalInput.value = props.modelValue.value;\n },\n { immediate: true },\n );\n\n watch(\n () => props.modelValue.option,\n () => {\n selectedOption.value = props.modelValue.option;\n },\n { immediate: true },\n );\n\n if (attrs.value) {\n throw new Error('ll-input-options: use :model-value or v-model instead of :value.');\n }\n\n if (attrs.onInput) {\n throw new Error('ll-input-options: use the @update:model-value event instead of @input');\n }\n</script>\n\n<template>\n <Field v-bind=\"props\" class=\"stash-input-options\" data-test=\"stash-input-options\">\n <template #default=\"{ fieldId, labelId }\">\n <div v-if=\"props.isReadOnly\" class=\"tw-flex tw-h-input tw-items-center tw-text-sm\">\n <span :id=\"fieldId\" :aria-labelledby=\"labelId\" class=\"tw-h-min\">\n {{ internalInput || 0 }} {{ selectedOption?.name }}\n </span>\n </div>\n <div v-else class=\"tw-flex\" :class=\"[classes['input-wrapper'], { [classes['has-error']]: !!props.errorText }]\">\n <slot :field-id=\"fieldId\">\n <Input\n :id=\"fieldId\"\n class=\"stash-input-options__input\"\n data-test=\"stash-input-options|input\"\n :type=\"props.type\"\n :model-value=\"internalInput\"\n :disabled=\"props.isDisabled || props.disabled\"\n :placeholder=\"props.placeholder\"\n @change=\"handleInputChange\"\n @update:model-value=\"handleInput\"\n @blur=\"isInputFocused = false\"\n @focus=\"isInputFocused = true\"\n />\n </slot>\n\n <Select\n single\n hide-search\n prevent-empty\n class=\"stash-input-options__select tw-min-w-20\"\n data-test=\"stash-input-options|select\"\n :class=\"classes.select\"\n :no-truncate=\"noTruncate\"\n :options=\"options\"\n :model-value=\"selectedOption\"\n :display-by=\"props.displayBy\"\n :track-by=\"props.trackBy\"\n :disabled=\"props.isDisabled || props.disabled\"\n @update:model-value=\"handleSelectChange\"\n />\n </div>\n </template>\n <template v-if=\"slots.hint\" #hint>\n <!-- @slot Hint slot for rendering text below the input -->\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style module>\n .input-wrapper {\n & > div:has(input) {\n display: inline-block;\n flex: 1;\n margin-right: -1px;\n }\n\n & input {\n border-bottom-right-radius: 0;\n border-top-right-radius: 0;\n }\n\n &.has-error input,\n &.has-error input:hover:not(:focus),\n &.has-error :global(.stash-select__content),\n &.has-error :global(.stash-select__content:hover:not(:focus)) {\n border-color: var(--color-red-500);\n }\n\n & div:has(input:focus) {\n z-index: 200 !important;\n }\n }\n\n .select :global(.stash-select__content) {\n border-bottom-left-radius: 0;\n border-top-left-radius: 0;\n }\n\n .select:global(.stash-select--active .stash-select__content) {\n min-width: 0;\n }\n</style>\n"],"names":["props","__props","emit","__emit","slots","_useSlots","attrs","useAttrs","classes","useCssModule","internalInput","ref","isInputFocused","selectedOption","handleInput","val","handleInputChange","handleSelectChange","watchEffect","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DE,UAAMA,IAAQC,GAURC,IAAOC,GAiBPC,IAAQC,EASV,GAEEC,IAAQC,EAAS,GACjBC,IAAUC,EAAa,GACvBC,IAAgBC,EAAY,GAC5BC,IAAiBD,EAAI,EAAK,GAC1BE,IAAiBF,EAAwB;AAG/C,aAASG,EAAYC,GAAuB;AAC5B,MAAAL,EAAA,QAAQ,OAAOK,CAAG,GAEhCb,EAAK,sBAAsB;AAAA,QACzB,OAAOQ,EAAc;AAAA,QACrB,QAAQG,EAAe;AAAA,QACvB,eAAe;AAAA,QACf,MAAM;AAAA,MAAA,CACP;AAAA,IAAA;AAIH,aAASG,IAAoB;AAC3B,MAAAd,EAAK,UAAU;AAAA,QACb,OAAOQ,EAAc;AAAA,QACrB,QAAQG,EAAe;AAAA,QACvB,eAAe;AAAA,QACf,MAAM;AAAA,MAAA,CACP;AAAA,IAAA;AAGH,aAASI,EAAmBF,GAAc;AACxC,MAAAF,EAAe,QAAQE,GAEvBb,EAAK,UAAU;AAAA,QACb,OAAOQ,EAAc;AAAA,QACrB,QAAQG,EAAe;AAAA,QACvB,eAAe;AAAA,QACf,MAAM;AAAA,MAAA,CACP,GACDX,EAAK,sBAAsB;AAAA,QACzB,OAAOQ,EAAc;AAAA,QACrB,QAAQG,EAAe;AAAA,QACvB,eAAe;AAAA,QACf,MAAM;AAAA,MAAA,CACP;AAAA,IAAA;AAyBH,QAtBAK,EAAY,MAAM;AACZ,MAACL,EAAe,UACHA,EAAA,QAAQb,EAAM,QAAQ,CAAC;AAAA,IACxC,CACD,GAEDmB;AAAA,MACE,MAAMnB,EAAM,WAAW;AAAA,MACvB,MAAM;AACU,QAAAU,EAAA,QAAQV,EAAM,WAAW;AAAA,MACzC;AAAA,MACA,EAAE,WAAW,GAAK;AAAA,IACpB,GAEAmB;AAAA,MACE,MAAMnB,EAAM,WAAW;AAAA,MACvB,MAAM;AACW,QAAAa,EAAA,QAAQb,EAAM,WAAW;AAAA,MAC1C;AAAA,MACA,EAAE,WAAW,GAAK;AAAA,IACpB,GAEIM,EAAM;AACF,YAAA,IAAI,MAAM,kEAAkE;AAGpF,QAAIA,EAAM;AACF,YAAA,IAAI,MAAM,uEAAuE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -153,6 +153,10 @@ declare interface FieldProps {
|
|
|
153
153
|
* Show "(optional)" to the right of the label text
|
|
154
154
|
*/
|
|
155
155
|
showOptionalInLabel?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Indicates whether the label should be visually hidden (screen reader only).
|
|
158
|
+
*/
|
|
159
|
+
isLabelSrOnly?: boolean;
|
|
156
160
|
/**
|
|
157
161
|
* Indicates wheter the field is a fieldset or not
|
|
158
162
|
*/
|
package/dist/Label.js
CHANGED
package/dist/Label.vue.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ isRequired: boolean;
|
|
|
39
39
|
showOptional: boolean;
|
|
40
40
|
legend: boolean;
|
|
41
41
|
isDisabled: boolean;
|
|
42
|
+
isSrOnly: boolean;
|
|
42
43
|
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<LabelProps>, {
|
|
43
44
|
for: undefined;
|
|
44
45
|
hasError: boolean;
|
|
@@ -46,12 +47,14 @@ isRequired: boolean;
|
|
|
46
47
|
showOptional: boolean;
|
|
47
48
|
legend: boolean;
|
|
48
49
|
isDisabled: boolean;
|
|
50
|
+
isSrOnly: boolean;
|
|
49
51
|
}>>> & Readonly<{}>, {
|
|
50
52
|
legend: boolean;
|
|
51
53
|
for: string;
|
|
52
54
|
hasError: boolean;
|
|
53
55
|
isRequired: boolean;
|
|
54
56
|
showOptional: boolean;
|
|
57
|
+
isSrOnly: boolean;
|
|
55
58
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, {
|
|
56
59
|
default?(_: {}): any;
|
|
57
60
|
}>;
|
|
@@ -82,6 +85,10 @@ export declare interface LabelProps {
|
|
|
82
85
|
* Indicates whether the label is disabled.
|
|
83
86
|
*/
|
|
84
87
|
disabled?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Indicates whether the label should be visually hidden (screen reader only).
|
|
90
|
+
*/
|
|
91
|
+
isSrOnly?: boolean;
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
export { }
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as n, computed as r, createBlock as i, openBlock as t, resolveDynamicComponent as d, normalizeClass as c, withCtx as
|
|
2
|
-
import { t as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as n, computed as r, createBlock as i, openBlock as t, resolveDynamicComponent as d, normalizeClass as c, withCtx as f, renderSlot as p, createElementBlock as a, createCommentVNode as u, toDisplayString as m, unref as w } from "vue";
|
|
2
|
+
import { t as y } from "./locale.js";
|
|
3
|
+
const b = {
|
|
4
4
|
key: 0,
|
|
5
5
|
class: "tw-font-semibold tw-text-red-500",
|
|
6
6
|
title: "Required",
|
|
7
7
|
"aria-label": "required"
|
|
8
|
-
},
|
|
8
|
+
}, h = {
|
|
9
9
|
key: 1,
|
|
10
10
|
class: "tw-text-ice-700"
|
|
11
11
|
}, x = /* @__PURE__ */ n({
|
|
@@ -16,22 +16,24 @@ const h = {
|
|
|
16
16
|
isRequired: { type: Boolean, default: !1 },
|
|
17
17
|
showOptional: { type: Boolean, default: !1 },
|
|
18
18
|
legend: { type: Boolean, default: !1 },
|
|
19
|
-
disabled: { type: Boolean }
|
|
19
|
+
disabled: { type: Boolean },
|
|
20
|
+
isSrOnly: { type: Boolean, default: !1 }
|
|
20
21
|
},
|
|
21
22
|
setup(l) {
|
|
22
23
|
const e = l, o = r(() => e.legend ? "legend" : "label");
|
|
23
|
-
return (s,
|
|
24
|
+
return (s, _) => (t(), i(d(o.value), {
|
|
24
25
|
class: c(["stash-label tw-block tw-truncate tw-text-sm tw-font-medium tw-leading-6", {
|
|
25
26
|
"tw-animate-shake": e.hasError,
|
|
26
27
|
"stash-label--disabled tw-text-ice-700": e.disabled,
|
|
27
|
-
"tw-text-ice-900": !e.disabled
|
|
28
|
+
"tw-text-ice-900": !e.disabled,
|
|
29
|
+
"tw-sr-only": e.isSrOnly
|
|
28
30
|
}]),
|
|
29
31
|
for: e.for,
|
|
30
32
|
"data-test": "stash-label"
|
|
31
33
|
}, {
|
|
32
|
-
default:
|
|
33
|
-
|
|
34
|
-
e.isRequired ? (t(), a("span",
|
|
34
|
+
default: f(() => [
|
|
35
|
+
p(s.$slots, "default"),
|
|
36
|
+
e.isRequired ? (t(), a("span", b, " * ")) : e.showOptional ? (t(), a("span", h, " (" + m(w(y)("ll.optional")) + ")", 1)) : u("", !0)
|
|
35
37
|
]),
|
|
36
38
|
_: 3
|
|
37
39
|
}, 8, ["class", "for"]));
|
|
@@ -40,4 +42,4 @@ const h = {
|
|
|
40
42
|
export {
|
|
41
43
|
x as _
|
|
42
44
|
};
|
|
43
|
-
//# sourceMappingURL=Label.vue_vue_type_script_setup_true_lang-
|
|
45
|
+
//# sourceMappingURL=Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js","sources":["../src/components/Label/Label.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue';\n\n import { t } from '../../locale';\n\n export interface LabelProps {\n /**\n * The `id` of the input element that this label is associated with.\n */\n for?: string;\n\n /**\n * Indicates whether the label should be styled as an error.\n */\n hasError?: boolean;\n\n /**\n * Indicates whether the input element that this label is associated with is required.\n */\n isRequired?: boolean;\n\n /**\n * Indicates whether the label should show that the input is optional.\n */\n showOptional?: boolean;\n\n /**\n * Indicates whether the wrapper element to be rendered should be a label or a legend.\n */\n legend?: boolean;\n\n /**\n * Indicates whether the label is disabled.\n */\n disabled?: boolean;\n\n /**\n * Indicates whether the label should be visually hidden (screen reader only).\n */\n isSrOnly?: boolean;\n }\n\n const props = withDefaults(defineProps<LabelProps>(), {\n for: undefined,\n hasError: false,\n isRequired: false,\n showOptional: false,\n legend: false,\n isDisabled: false,\n isSrOnly: false,\n });\n\n const is = computed(() => {\n return props.legend ? 'legend' : 'label';\n });\n</script>\n\n<template>\n <component\n :is=\"is\"\n class=\"stash-label tw-block tw-truncate tw-text-sm tw-font-medium tw-leading-6\"\n :class=\"{\n 'tw-animate-shake': props.hasError,\n 'stash-label--disabled tw-text-ice-700': props.disabled,\n 'tw-text-ice-900': !props.disabled,\n 'tw-sr-only': props.isSrOnly,\n }\"\n :for=\"props.for\"\n data-test=\"stash-label\"\n >\n <!-- @slot The label text -->\n <slot></slot>\n <span v-if=\"props.isRequired\" class=\"tw-font-semibold tw-text-red-500\" title=\"Required\" aria-label=\"required\">\n *\n </span>\n <span v-else-if=\"props.showOptional\" class=\"tw-text-ice-700\"> ({{ t('ll.optional') }})</span>\n </component>\n</template>\n"],"names":["props","__props","is","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CE,UAAMA,IAAQC,GAURC,IAAKC,EAAS,MACXH,EAAM,SAAS,WAAW,OAClC;;;;;;;;;;;;;;;;;;;"}
|
package/dist/ListView.vue.d.ts
CHANGED
|
@@ -1798,6 +1798,9 @@ type: PropType<boolean>;
|
|
|
1798
1798
|
showOptionalInLabel: {
|
|
1799
1799
|
type: PropType<boolean>;
|
|
1800
1800
|
};
|
|
1801
|
+
isLabelSrOnly: {
|
|
1802
|
+
type: PropType<boolean>;
|
|
1803
|
+
};
|
|
1801
1804
|
placeholder: {
|
|
1802
1805
|
type: PropType<string>;
|
|
1803
1806
|
default: undefined;
|
|
@@ -1880,6 +1883,9 @@ type: PropType<boolean>;
|
|
|
1880
1883
|
showOptionalInLabel: {
|
|
1881
1884
|
type: PropType<boolean>;
|
|
1882
1885
|
};
|
|
1886
|
+
isLabelSrOnly: {
|
|
1887
|
+
type: PropType<boolean>;
|
|
1888
|
+
};
|
|
1883
1889
|
placeholder: {
|
|
1884
1890
|
type: PropType<string>;
|
|
1885
1891
|
default: undefined;
|
|
@@ -1954,6 +1960,9 @@ type: PropType<boolean>;
|
|
|
1954
1960
|
showOptionalInLabel: {
|
|
1955
1961
|
type: PropType<boolean>;
|
|
1956
1962
|
};
|
|
1963
|
+
isLabelSrOnly: {
|
|
1964
|
+
type: PropType<boolean>;
|
|
1965
|
+
};
|
|
1957
1966
|
placeholder: {
|
|
1958
1967
|
type: PropType<string>;
|
|
1959
1968
|
default: undefined;
|
|
@@ -2041,6 +2050,9 @@ type: PropType<boolean>;
|
|
|
2041
2050
|
showOptionalInLabel: {
|
|
2042
2051
|
type: PropType<boolean>;
|
|
2043
2052
|
};
|
|
2053
|
+
isLabelSrOnly: {
|
|
2054
|
+
type: PropType<boolean>;
|
|
2055
|
+
};
|
|
2044
2056
|
placeholder: {
|
|
2045
2057
|
type: PropType<string>;
|
|
2046
2058
|
default: undefined;
|
|
@@ -2156,6 +2168,9 @@ type: PropType<boolean>;
|
|
|
2156
2168
|
showOptionalInLabel: {
|
|
2157
2169
|
type: PropType<boolean>;
|
|
2158
2170
|
};
|
|
2171
|
+
isLabelSrOnly: {
|
|
2172
|
+
type: PropType<boolean>;
|
|
2173
|
+
};
|
|
2159
2174
|
placeholder: {
|
|
2160
2175
|
type: PropType<string>;
|
|
2161
2176
|
default: undefined;
|
|
@@ -2255,6 +2270,9 @@ type: PropType<boolean>;
|
|
|
2255
2270
|
showOptionalInLabel: {
|
|
2256
2271
|
type: PropType<boolean>;
|
|
2257
2272
|
};
|
|
2273
|
+
isLabelSrOnly: {
|
|
2274
|
+
type: PropType<boolean>;
|
|
2275
|
+
};
|
|
2258
2276
|
placeholder: {
|
|
2259
2277
|
type: PropType<string>;
|
|
2260
2278
|
default: undefined;
|
|
@@ -2446,6 +2464,9 @@ type: PropType<boolean>;
|
|
|
2446
2464
|
showOptionalInLabel: {
|
|
2447
2465
|
type: PropType<boolean>;
|
|
2448
2466
|
};
|
|
2467
|
+
isLabelSrOnly: {
|
|
2468
|
+
type: PropType<boolean>;
|
|
2469
|
+
};
|
|
2449
2470
|
placeholder: {
|
|
2450
2471
|
type: PropType<string>;
|
|
2451
2472
|
default: string;
|
|
@@ -2655,6 +2676,9 @@ type: PropType<boolean>;
|
|
|
2655
2676
|
showOptionalInLabel: {
|
|
2656
2677
|
type: PropType<boolean>;
|
|
2657
2678
|
};
|
|
2679
|
+
isLabelSrOnly: {
|
|
2680
|
+
type: PropType<boolean>;
|
|
2681
|
+
};
|
|
2658
2682
|
placeholder: {
|
|
2659
2683
|
type: PropType<string>;
|
|
2660
2684
|
default: string;
|
|
@@ -2854,6 +2878,9 @@ type: PropType<boolean>;
|
|
|
2854
2878
|
showOptionalInLabel: {
|
|
2855
2879
|
type: PropType<boolean>;
|
|
2856
2880
|
};
|
|
2881
|
+
isLabelSrOnly: {
|
|
2882
|
+
type: PropType<boolean>;
|
|
2883
|
+
};
|
|
2857
2884
|
placeholder: {
|
|
2858
2885
|
type: PropType<string>;
|
|
2859
2886
|
default: string;
|
|
@@ -4530,6 +4557,9 @@ type: PropType<boolean>;
|
|
|
4530
4557
|
showOptionalInLabel: {
|
|
4531
4558
|
type: PropType<boolean>;
|
|
4532
4559
|
};
|
|
4560
|
+
isLabelSrOnly: {
|
|
4561
|
+
type: PropType<boolean>;
|
|
4562
|
+
};
|
|
4533
4563
|
placeholder: {
|
|
4534
4564
|
type: PropType<string>;
|
|
4535
4565
|
default: undefined;
|
|
@@ -4612,6 +4642,9 @@ type: PropType<boolean>;
|
|
|
4612
4642
|
showOptionalInLabel: {
|
|
4613
4643
|
type: PropType<boolean>;
|
|
4614
4644
|
};
|
|
4645
|
+
isLabelSrOnly: {
|
|
4646
|
+
type: PropType<boolean>;
|
|
4647
|
+
};
|
|
4615
4648
|
placeholder: {
|
|
4616
4649
|
type: PropType<string>;
|
|
4617
4650
|
default: undefined;
|
|
@@ -4686,6 +4719,9 @@ type: PropType<boolean>;
|
|
|
4686
4719
|
showOptionalInLabel: {
|
|
4687
4720
|
type: PropType<boolean>;
|
|
4688
4721
|
};
|
|
4722
|
+
isLabelSrOnly: {
|
|
4723
|
+
type: PropType<boolean>;
|
|
4724
|
+
};
|
|
4689
4725
|
placeholder: {
|
|
4690
4726
|
type: PropType<string>;
|
|
4691
4727
|
default: undefined;
|