@leaflink/stash 51.1.1 → 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/EmptyState.js +22 -21
- package/dist/EmptyState.js.map +1 -1
- package/dist/EmptyState.vue.d.ts +7 -0
- 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 +66 -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/TextEditor.vue.d.ts
CHANGED
|
@@ -91,6 +91,10 @@ declare interface FieldProps {
|
|
|
91
91
|
* Show "(optional)" to the right of the label text
|
|
92
92
|
*/
|
|
93
93
|
showOptionalInLabel?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Indicates whether the label should be visually hidden (screen reader only).
|
|
96
|
+
*/
|
|
97
|
+
isLabelSrOnly?: boolean;
|
|
94
98
|
/**
|
|
95
99
|
* Indicates wheter the field is a fieldset or not
|
|
96
100
|
*/
|
package/dist/Textarea.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as M, useAttrs as k, useSlots as E, useCssModule as H, ref as x, computed as w, watch as A, onMounted as I, nextTick as P, onBeforeUnmount as V, createBlock as $, openBlock as q, mergeProps as y, unref as p, createSlots as D, withCtx as b, createElementVNode as
|
|
2
|
-
import { _ as
|
|
1
|
+
import { defineComponent as M, useAttrs as k, useSlots as E, useCssModule as H, ref as x, computed as w, watch as A, onMounted as I, nextTick as P, onBeforeUnmount as V, createBlock as $, openBlock as q, mergeProps as y, unref as p, createSlots as D, withCtx as b, createElementVNode as L, renderSlot as j } from "vue";
|
|
2
|
+
import { _ as F } from "./Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js";
|
|
3
3
|
import { _ as N } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
4
4
|
const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "placeholder", "disabled", "readonly", "rows"], W = /* @__PURE__ */ M({
|
|
5
5
|
name: "ll-textarea",
|
|
@@ -20,13 +20,14 @@ const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "pla
|
|
|
20
20
|
isRequired: { type: Boolean },
|
|
21
21
|
label: {},
|
|
22
22
|
showOptionalInLabel: { type: Boolean },
|
|
23
|
+
isLabelSrOnly: { type: Boolean },
|
|
23
24
|
fieldset: { type: Boolean },
|
|
24
25
|
isDisabled: { type: Boolean },
|
|
25
26
|
disabled: { type: Boolean }
|
|
26
27
|
},
|
|
27
28
|
emits: ["update:model-value"],
|
|
28
29
|
setup(g, { emit: _ }) {
|
|
29
|
-
const c = k(), B = E(), m = H(), t = g, z = _, u = x(), l = x(), R = w(() => t.isReadOnly || "readonly" in c && c.readonly !== !1),
|
|
30
|
+
const c = k(), B = E(), m = H(), t = g, z = _, u = x(), l = x(), R = w(() => t.isReadOnly || "readonly" in c && c.readonly !== !1), O = w(() => {
|
|
30
31
|
const e = { ...c };
|
|
31
32
|
return delete e["data-test"], delete e.class, e;
|
|
32
33
|
});
|
|
@@ -37,21 +38,21 @@ const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "pla
|
|
|
37
38
|
e ? h() : (o = l.value) == null || o.disconnect();
|
|
38
39
|
}
|
|
39
40
|
);
|
|
40
|
-
const
|
|
41
|
+
const T = (e) => {
|
|
41
42
|
z("update:model-value", e.target.value);
|
|
42
43
|
}, h = () => {
|
|
43
44
|
l.value || !u.value || (l.value = new ResizeObserver(([e]) => {
|
|
44
|
-
const { target: o } = e, a = v(u.value) || document.documentElement, { scrollTop:
|
|
45
|
+
const { target: o } = e, a = v(u.value) || document.documentElement, { scrollTop: n } = a;
|
|
45
46
|
let s = 0;
|
|
46
47
|
if (a === document.documentElement) {
|
|
47
|
-
const { top:
|
|
48
|
-
s = Math.max(
|
|
48
|
+
const { top: r, height: i } = S(o), { innerHeight: d } = window;
|
|
49
|
+
s = Math.max(r + i - (d + n), 0);
|
|
49
50
|
} else {
|
|
50
|
-
const { top:
|
|
51
|
-
s = Math.max(
|
|
51
|
+
const { top: r, height: i } = o.getBoundingClientRect(), { top: d } = a.getBoundingClientRect(), { offsetHeight: f } = a, C = r - d;
|
|
52
|
+
s = Math.max(C + i - f, 0);
|
|
52
53
|
}
|
|
53
54
|
s && requestAnimationFrame(() => {
|
|
54
|
-
a.scrollTop =
|
|
55
|
+
a.scrollTop = n + s;
|
|
55
56
|
});
|
|
56
57
|
}), l.value.observe(u.value));
|
|
57
58
|
}, v = (e) => {
|
|
@@ -60,15 +61,15 @@ const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "pla
|
|
|
60
61
|
return null;
|
|
61
62
|
const { overflowY: a } = getComputedStyle(o);
|
|
62
63
|
return a !== "visible" ? o : o === document.body ? document.documentElement : v(o);
|
|
63
|
-
},
|
|
64
|
+
}, S = (e) => {
|
|
64
65
|
const { offsetWidth: o, offsetHeight: a } = e;
|
|
65
|
-
let
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
let n = 0, s = 0;
|
|
67
|
+
const r = function({ offsetLeft: i, offsetTop: d, offsetParent: f }) {
|
|
68
|
+
n += i, s += d, f && r(f);
|
|
68
69
|
};
|
|
69
|
-
return
|
|
70
|
+
return r(e), {
|
|
70
71
|
top: s,
|
|
71
|
-
left:
|
|
72
|
+
left: n,
|
|
72
73
|
width: o,
|
|
73
74
|
height: a
|
|
74
75
|
};
|
|
@@ -83,16 +84,16 @@ const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "pla
|
|
|
83
84
|
}), V(() => {
|
|
84
85
|
var e;
|
|
85
86
|
(e = l.value) == null || e.disconnect();
|
|
86
|
-
}), (e, o) => (q(), $(
|
|
87
|
+
}), (e, o) => (q(), $(F, y(t, {
|
|
87
88
|
class: ["stash-textarea", [p(m).root]],
|
|
88
89
|
"data-test": "stash-textarea"
|
|
89
90
|
}), D({
|
|
90
|
-
default: b(({ fieldId: a, fieldErrorId:
|
|
91
|
-
|
|
91
|
+
default: b(({ fieldId: a, fieldErrorId: n, hasError: s }) => [
|
|
92
|
+
L("textarea", y({
|
|
92
93
|
id: a,
|
|
93
94
|
ref_key: "textareaRef",
|
|
94
95
|
ref: u,
|
|
95
|
-
"aria-errormessage":
|
|
96
|
+
"aria-errormessage": n,
|
|
96
97
|
"aria-invalid": s,
|
|
97
98
|
class: [
|
|
98
99
|
p(m).textarea,
|
|
@@ -109,11 +110,11 @@ const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "pla
|
|
|
109
110
|
value: t.modelValue,
|
|
110
111
|
"data-test": "stash-textarea|textarea",
|
|
111
112
|
placeholder: t.placeholder
|
|
112
|
-
},
|
|
113
|
+
}, O.value, {
|
|
113
114
|
disabled: t.disabled,
|
|
114
115
|
readonly: R.value,
|
|
115
116
|
rows: t.rows,
|
|
116
|
-
onInput:
|
|
117
|
+
onInput: T
|
|
117
118
|
}), null, 16, U)
|
|
118
119
|
]),
|
|
119
120
|
_: 2
|
|
@@ -121,7 +122,7 @@ const U = ["id", "aria-errormessage", "aria-invalid", "maxlength", "value", "pla
|
|
|
121
122
|
p(B).hint ? {
|
|
122
123
|
name: "hint",
|
|
123
124
|
fn: b(() => [
|
|
124
|
-
|
|
125
|
+
j(e.$slots, "hint")
|
|
125
126
|
]),
|
|
126
127
|
key: "0"
|
|
127
128
|
} : void 0
|
package/dist/Textarea.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { computed, nextTick, onBeforeUnmount, onMounted, ref, useAttrs, useCssModule, useSlots, watch } from 'vue';\n\n import { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n\n export interface TextareaResizeOptions {\n /**\n * It will automatically scroll the page down when it reaches the bottom of the viewport/element\n */\n forceBrowserScroll: boolean;\n }\n\n export interface TextAreaProps extends FieldProps {\n /**\n * Value for the textarea element.\n */\n modelValue?: string;\n\n /**\n * Deprecated. Use :model-value or v-model instead of :value.\n * @deprecated Use :model-value or v-model instead of :value.\n */\n value?: string | number | null;\n\n /**\n * Allow textarea to be resizable vertically.\n * Alternatively if you want to disable automatic scroll when resizing, you can set `{ forceBrowserScroll: false }`\n */\n resize?: boolean | TextareaResizeOptions;\n\n /**\n * Placeholder text for the textarea element.\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 * Number of rows to display in the textarea.\n */\n rows?: number;\n\n /**\n * Maximum number of characters allowed in the textarea.\n */\n maxlength?: number;\n }\n\n defineOptions({\n name: 'll-textarea',\n });\n\n const attrs = useAttrs();\n const slots = useSlots();\n const classes = useCssModule();\n\n const props = withDefaults(defineProps<TextAreaProps>(), {\n modelValue: '',\n value: null,\n resize: false,\n maxlength: undefined,\n rows: undefined,\n placeholder: undefined,\n });\n\n const emits = defineEmits<{\n /**\n * Emitted when the model value changes.\n */\n (e: 'update:model-value', value: string): void;\n }>();\n\n const textareaRef = ref<HTMLTextAreaElement>();\n const observer = ref<ResizeObserver>();\n const isReadOnly = computed(() => props.isReadOnly || ('readonly' in attrs && attrs.readonly !== false));\n\n const inputAttrs = computed(() => {\n const allAttrs = { ...attrs };\n\n delete allAttrs['data-test'];\n delete allAttrs.class;\n\n return allAttrs;\n });\n\n watch(\n () => props.resize,\n (v) => {\n if (v) {\n setupResizeObserver();\n } else {\n observer.value?.disconnect();\n }\n },\n );\n\n const onInput = (event: Event) => {\n emits('update:model-value', (event.target as HTMLTextAreaElement).value);\n };\n\n const setupResizeObserver = () => {\n if (observer.value || !textareaRef.value) {\n return;\n }\n\n // the ResizeObserver will be in charge to detect if page needs to scroll when resizing the component\n observer.value = new ResizeObserver(([entry]) => {\n const { target } = entry;\n const parent = findParentScrollable(textareaRef.value as HTMLTextAreaElement) || document.documentElement;\n\n const { scrollTop: scrollPosition } = parent;\n let offsetDiff = 0;\n\n // checks if the closest parent element scrollable is the document page\n if (parent === document.documentElement) {\n const { top, height } = getOffsetClipRect(target as HTMLElement);\n const { innerHeight: viewportHeight } = window;\n\n offsetDiff = Math.max(top + height - (viewportHeight + scrollPosition), 0);\n } else {\n const { top, height } = (target as HTMLElement).getBoundingClientRect();\n const { top: parentTop } = parent.getBoundingClientRect();\n const { offsetHeight: parentHeight } = parent;\n const offsetTop = top - parentTop;\n\n offsetDiff = Math.max(offsetTop + height - parentHeight, 0);\n }\n\n if (offsetDiff) {\n requestAnimationFrame(() => {\n parent.scrollTop = scrollPosition + offsetDiff;\n });\n }\n });\n\n observer.value.observe(textareaRef.value);\n };\n\n /**\n * Retrieve the closest parent that has a scroll. Defaults to the document page.\n */\n const findParentScrollable = (el: HTMLElement): HTMLElement | null => {\n const parent = el.parentElement as HTMLElement;\n if (!parent) {\n return null;\n }\n\n const { overflowY } = getComputedStyle(parent);\n if (overflowY !== 'visible') {\n return parent;\n }\n\n if (parent === document.body) {\n return document.documentElement;\n }\n\n return findParentScrollable(parent);\n };\n\n /**\n * Retrieve element absolute positioning relative to the page.\n */\n const getOffsetClipRect = (el: HTMLElement) => {\n const { offsetWidth: width, offsetHeight: height } = el;\n\n let left = 0;\n let top = 0;\n\n const findPos = function ({ offsetLeft, offsetTop, offsetParent }: HTMLElement) {\n left += offsetLeft;\n top += offsetTop;\n\n if (offsetParent) {\n findPos(offsetParent as HTMLElement);\n }\n };\n\n findPos(el);\n\n return {\n top,\n left,\n width,\n height,\n };\n };\n\n onMounted(async () => {\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 if (\n (typeof props.resize === 'boolean' && props.resize) ||\n (props.resize as TextareaResizeOptions)?.forceBrowserScroll\n ) {\n await nextTick();\n setupResizeObserver();\n }\n });\n\n onBeforeUnmount(() => {\n observer.value?.disconnect();\n });\n</script>\n\n<template>\n <Field v-bind=\"props\" class=\"stash-textarea\" :class=\"[classes.root]\" data-test=\"stash-textarea\">\n <template #default=\"{ fieldId, fieldErrorId, hasError }\">\n <textarea\n :id=\"fieldId\"\n ref=\"textareaRef\"\n :aria-errormessage=\"fieldErrorId\"\n :aria-invalid=\"hasError\"\n :class=\"[\n classes.textarea,\n 'tw-border tw-border-ice-500',\n {\n 'stash-textarea--error tw-border-red-500 tw-text-red-500': hasError,\n 'tw-text-ice-700 hover:tw-border-ice-500 focus:tw-border-blue-500 active:tw-border-blue-500':\n !hasError && !props.disabled,\n 'tw-resize-y': props.resize,\n 'tw-min-h-[100px]': !props.rows,\n 'tw-resize-none': !props.resize,\n },\n ]\"\n :maxlength=\"props.maxlength\"\n :value=\"props.modelValue\"\n data-test=\"stash-textarea|textarea\"\n :placeholder=\"props.placeholder\"\n v-bind=\"inputAttrs\"\n :disabled=\"props.disabled\"\n :readonly=\"isReadOnly\"\n :rows=\"props.rows\"\n @input=\"onInput\"\n ></textarea>\n </template>\n <template v-if=\"slots.hint\" #hint>\n <!-- @slot Hint content -->\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style module>\n .root {\n position: relative;\n width: 100%;\n }\n\n .textarea {\n background: var(--color-white);\n border-radius: theme('borderRadius.DEFAULT');\n display: block;\n outline: none;\n padding: theme('spacing[1.5]');\n width: 100%;\n\n &::placeholder {\n color: var(--color-ice-500);\n opacity: 1;\n }\n\n &[disabled] {\n background-color: var(--color-ice-100);\n border-color: var(--color-ice-500);\n color: var(--color-ice-500);\n pointer-events: none;\n }\n\n &[disabled]:active,\n &[disabled]:focus {\n box-shadow: none;\n }\n\n &[disabled]::placeholder {\n text-transform: none;\n color: var(--color-ice-500);\n }\n\n &[readonly] {\n border-color: transparent;\n background-color: transparent;\n padding-left: 0;\n padding-right: 0;\n min-height: unset;\n }\n }\n</style>\n"],"names":["attrs","useAttrs","slots","useSlots","classes","useCssModule","props","__props","emits","__emit","textareaRef","ref","observer","isReadOnly","computed","inputAttrs","allAttrs","watch","v","setupResizeObserver","_a","onInput","event","entry","target","parent","findParentScrollable","scrollPosition","offsetDiff","top","height","getOffsetClipRect","viewportHeight","parentTop","parentHeight","offsetTop","el","overflowY","width","left","findPos","offsetLeft","offsetParent","onMounted","n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AAAQ,EAAgB;AAAA,IAAW,CAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { computed, nextTick, onBeforeUnmount, onMounted, ref, useAttrs, useCssModule, useSlots, watch } from 'vue';\n\n import { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n\n export interface TextareaResizeOptions {\n /**\n * It will automatically scroll the page down when it reaches the bottom of the viewport/element\n */\n forceBrowserScroll: boolean;\n }\n\n export interface TextAreaProps extends FieldProps {\n /**\n * Value for the textarea element.\n */\n modelValue?: string;\n\n /**\n * Deprecated. Use :model-value or v-model instead of :value.\n * @deprecated Use :model-value or v-model instead of :value.\n */\n value?: string | number | null;\n\n /**\n * Allow textarea to be resizable vertically.\n * Alternatively if you want to disable automatic scroll when resizing, you can set `{ forceBrowserScroll: false }`\n */\n resize?: boolean | TextareaResizeOptions;\n\n /**\n * Placeholder text for the textarea element.\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 * Number of rows to display in the textarea.\n */\n rows?: number;\n\n /**\n * Maximum number of characters allowed in the textarea.\n */\n maxlength?: number;\n }\n\n defineOptions({\n name: 'll-textarea',\n });\n\n const attrs = useAttrs();\n const slots = useSlots();\n const classes = useCssModule();\n\n const props = withDefaults(defineProps<TextAreaProps>(), {\n modelValue: '',\n value: null,\n resize: false,\n maxlength: undefined,\n rows: undefined,\n placeholder: undefined,\n });\n\n const emits = defineEmits<{\n /**\n * Emitted when the model value changes.\n */\n (e: 'update:model-value', value: string): void;\n }>();\n\n const textareaRef = ref<HTMLTextAreaElement>();\n const observer = ref<ResizeObserver>();\n const isReadOnly = computed(() => props.isReadOnly || ('readonly' in attrs && attrs.readonly !== false));\n\n const inputAttrs = computed(() => {\n const allAttrs = { ...attrs };\n\n delete allAttrs['data-test'];\n delete allAttrs.class;\n\n return allAttrs;\n });\n\n watch(\n () => props.resize,\n (v) => {\n if (v) {\n setupResizeObserver();\n } else {\n observer.value?.disconnect();\n }\n },\n );\n\n const onInput = (event: Event) => {\n emits('update:model-value', (event.target as HTMLTextAreaElement).value);\n };\n\n const setupResizeObserver = () => {\n if (observer.value || !textareaRef.value) {\n return;\n }\n\n // the ResizeObserver will be in charge to detect if page needs to scroll when resizing the component\n observer.value = new ResizeObserver(([entry]) => {\n const { target } = entry;\n const parent = findParentScrollable(textareaRef.value as HTMLTextAreaElement) || document.documentElement;\n\n const { scrollTop: scrollPosition } = parent;\n let offsetDiff = 0;\n\n // checks if the closest parent element scrollable is the document page\n if (parent === document.documentElement) {\n const { top, height } = getOffsetClipRect(target as HTMLElement);\n const { innerHeight: viewportHeight } = window;\n\n offsetDiff = Math.max(top + height - (viewportHeight + scrollPosition), 0);\n } else {\n const { top, height } = (target as HTMLElement).getBoundingClientRect();\n const { top: parentTop } = parent.getBoundingClientRect();\n const { offsetHeight: parentHeight } = parent;\n const offsetTop = top - parentTop;\n\n offsetDiff = Math.max(offsetTop + height - parentHeight, 0);\n }\n\n if (offsetDiff) {\n requestAnimationFrame(() => {\n parent.scrollTop = scrollPosition + offsetDiff;\n });\n }\n });\n\n observer.value.observe(textareaRef.value);\n };\n\n /**\n * Retrieve the closest parent that has a scroll. Defaults to the document page.\n */\n const findParentScrollable = (el: HTMLElement): HTMLElement | null => {\n const parent = el.parentElement as HTMLElement;\n if (!parent) {\n return null;\n }\n\n const { overflowY } = getComputedStyle(parent);\n if (overflowY !== 'visible') {\n return parent;\n }\n\n if (parent === document.body) {\n return document.documentElement;\n }\n\n return findParentScrollable(parent);\n };\n\n /**\n * Retrieve element absolute positioning relative to the page.\n */\n const getOffsetClipRect = (el: HTMLElement) => {\n const { offsetWidth: width, offsetHeight: height } = el;\n\n let left = 0;\n let top = 0;\n\n const findPos = function ({ offsetLeft, offsetTop, offsetParent }: HTMLElement) {\n left += offsetLeft;\n top += offsetTop;\n\n if (offsetParent) {\n findPos(offsetParent as HTMLElement);\n }\n };\n\n findPos(el);\n\n return {\n top,\n left,\n width,\n height,\n };\n };\n\n onMounted(async () => {\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 if (\n (typeof props.resize === 'boolean' && props.resize) ||\n (props.resize as TextareaResizeOptions)?.forceBrowserScroll\n ) {\n await nextTick();\n setupResizeObserver();\n }\n });\n\n onBeforeUnmount(() => {\n observer.value?.disconnect();\n });\n</script>\n\n<template>\n <Field v-bind=\"props\" class=\"stash-textarea\" :class=\"[classes.root]\" data-test=\"stash-textarea\">\n <template #default=\"{ fieldId, fieldErrorId, hasError }\">\n <textarea\n :id=\"fieldId\"\n ref=\"textareaRef\"\n :aria-errormessage=\"fieldErrorId\"\n :aria-invalid=\"hasError\"\n :class=\"[\n classes.textarea,\n 'tw-border tw-border-ice-500',\n {\n 'stash-textarea--error tw-border-red-500 tw-text-red-500': hasError,\n 'tw-text-ice-700 hover:tw-border-ice-500 focus:tw-border-blue-500 active:tw-border-blue-500':\n !hasError && !props.disabled,\n 'tw-resize-y': props.resize,\n 'tw-min-h-[100px]': !props.rows,\n 'tw-resize-none': !props.resize,\n },\n ]\"\n :maxlength=\"props.maxlength\"\n :value=\"props.modelValue\"\n data-test=\"stash-textarea|textarea\"\n :placeholder=\"props.placeholder\"\n v-bind=\"inputAttrs\"\n :disabled=\"props.disabled\"\n :readonly=\"isReadOnly\"\n :rows=\"props.rows\"\n @input=\"onInput\"\n ></textarea>\n </template>\n <template v-if=\"slots.hint\" #hint>\n <!-- @slot Hint content -->\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style module>\n .root {\n position: relative;\n width: 100%;\n }\n\n .textarea {\n background: var(--color-white);\n border-radius: theme('borderRadius.DEFAULT');\n display: block;\n outline: none;\n padding: theme('spacing[1.5]');\n width: 100%;\n\n &::placeholder {\n color: var(--color-ice-500);\n opacity: 1;\n }\n\n &[disabled] {\n background-color: var(--color-ice-100);\n border-color: var(--color-ice-500);\n color: var(--color-ice-500);\n pointer-events: none;\n }\n\n &[disabled]:active,\n &[disabled]:focus {\n box-shadow: none;\n }\n\n &[disabled]::placeholder {\n text-transform: none;\n color: var(--color-ice-500);\n }\n\n &[readonly] {\n border-color: transparent;\n background-color: transparent;\n padding-left: 0;\n padding-right: 0;\n min-height: unset;\n }\n }\n</style>\n"],"names":["attrs","useAttrs","slots","useSlots","classes","useCssModule","props","__props","emits","__emit","textareaRef","ref","observer","isReadOnly","computed","inputAttrs","allAttrs","watch","v","setupResizeObserver","_a","onInput","event","entry","target","parent","findParentScrollable","scrollPosition","offsetDiff","top","height","getOffsetClipRect","viewportHeight","parentTop","parentHeight","offsetTop","el","overflowY","width","left","findPos","offsetLeft","offsetParent","onMounted","nextTick","onBeforeUnmount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDE,UAAMA,IAAQC,EAAS,GACjBC,IAAQC,EAAS,GACjBC,IAAUC,EAAa,GAEvBC,IAAQC,GASRC,IAAQC,GAORC,IAAcC,EAAyB,GACvCC,IAAWD,EAAoB,GAC/BE,IAAaC,EAAS,MAAMR,EAAM,cAAe,cAAcN,KAASA,EAAM,aAAa,EAAM,GAEjGe,IAAaD,EAAS,MAAM;AAC1B,YAAAE,IAAW,EAAE,GAAGhB,EAAM;AAE5B,oBAAOgB,EAAS,WAAW,GAC3B,OAAOA,EAAS,OAETA;AAAA,IAAA,CACR;AAED,IAAAC;AAAA,MACE,MAAMX,EAAM;AAAA,MACZ,CAACY,MAAM;;AACL,QAAIA,IACkBC,EAAA,KAEpBC,IAAAR,EAAS,UAAT,QAAAQ,EAAgB;AAAA,MAClB;AAAA,IAEJ;AAEM,UAAAC,IAAU,CAACC,MAAiB;AAC1B,MAAAd,EAAA,sBAAuBc,EA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AMW,IAAU,SAAU,EAAE,YAAAC,GAAY,WAAAN,GAAW,cAAAO,KAA6B;AACtE,QAAAH,KAAAE,GACDZ,KAAAM,GAEHO,KACFF,EAAQE,CAA2B;AAAA,MAEvC;AAEA,aAAAF,EAAQJ,CAAE,GAEH;AAAA,QACL,KAAAP;AAAA,QACA,MAAAU;AAAA,QACA,OAAAD;AAAA,QACA,QAAAR;AAAA,MACF;AAAA,IACF;AAEA,WAAAa,EAAU,YAAY;;AAChB,UAAArC,EAAM,UAAU;AACZ,cAAA,IAAI,MAAM,0DAA0D;AAG5E,UAAIN,EAAM;AACF,cAAA,IAAI,MAAM,+DAA+D;AAI9E,OAAA,OAAOM,EAAM,UAAW,aAAaA,EAAM,WAC3Cc,IAAAd,EAAM,WAAN,QAAAc,EAAwC,wBAEzC,MAAMwB,EAAS,GACKzB,EAAA;AAAA,IACtB,CACD,GAED0B,EAAgB,MAAM;;AACpB,OAAAzB,IAAAR,EAAS,UAAT,QAAAQ,EAAgB;AAAA,IAAW,CAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/Textarea.vue.d.ts
CHANGED
|
@@ -99,6 +99,10 @@ declare interface FieldProps {
|
|
|
99
99
|
* Show "(optional)" to the right of the label text
|
|
100
100
|
*/
|
|
101
101
|
showOptionalInLabel?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Indicates whether the label should be visually hidden (screen reader only).
|
|
104
|
+
*/
|
|
105
|
+
isLabelSrOnly?: boolean;
|
|
102
106
|
/**
|
|
103
107
|
* Indicates wheter the field is a fieldset or not
|
|
104
108
|
*/
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js","sources":["../src/components/Field/Field.vue"],"sourcesContent":["<script lang=\"ts\">\n import { FieldProps } from './Field.types';\n\n export * from './Field.types';\n</script>\n\n<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, useAttrs, useSlots } from 'vue';\n\n import Label from '../Label/Label.vue';\n\n defineOptions({\n inheritAttrs: false,\n });\n\n const props = withDefaults(defineProps<FieldProps>(), {\n addBottomSpace: false,\n errorText: undefined,\n hintText: undefined,\n id: undefined,\n errorId: undefined,\n isRequired: false,\n label: undefined,\n showOptionalInLabel: false,\n fieldset: false,\n isDisabled: false,\n disabled: false,\n });\n const attrs = useAttrs();\n const slots = useSlots();\n const fieldId = computed(() => props.id || uniqueId('stash-field-'));\n const fieldErrorId = computed(() => props.errorId || uniqueId('stash-field-error-'));\n const labelId = computed(() => uniqueId('stash-field-label-'));\n const hasError = computed(() => !!props.errorText);\n const wrapperElement = computed(() => (props.fieldset ? 'fieldset' : 'div'));\n\n // Any attributes that are unique to form elements, you want to exclude from\n // being bound from the root element.\n const rootAttrs = computed(() => {\n const { placeholder, ...otherAttrs } = attrs;\n\n return otherAttrs;\n });\n</script>\n\n<template>\n <component\n :is=\"wrapperElement\"\n data-test=\"stash-field\"\n class=\"stash-field\"\n :class=\"[\n { 'tw-p-0': props.fieldset },\n { 'tw-mb-9': props.addBottomSpace && !props.errorText && !props.hintText && !slots.hint },\n { 'tw-mb-4': props.addBottomSpace && (props.errorText || props.hintText || slots.hint) },\n { 'stash-field--disabled': props.isDisabled || props.disabled },\n { 'stash-field--is-read-only': props.isReadOnly },\n { 'stash-field--is-required': props.isRequired },\n { 'stash-field--has-error': hasError },\n ]\"\n v-bind=\"rootAttrs\"\n >\n <Label\n v-if=\"props.label\"\n :id=\"labelId\"\n :for=\"fieldId\"\n :has-error=\"hasError\"\n :is-required=\"isRequired\"\n :show-optional=\"props.showOptionalInLabel\"\n :legend=\"props.fieldset\"\n :disabled=\"props.isDisabled || props.disabled\"\n >\n {{ props.label }}\n </Label>\n\n <!-- @slot for the form field; the Label can also be rendered here instead of using the label prop -->\n <slot\n :field-id=\"fieldId\"\n :field-error-id=\"fieldErrorId\"\n :has-error=\"hasError\"\n :is-required=\"isRequired\"\n :is-read-only=\"props.isReadOnly\"\n :disabled=\"props.isDisabled || props.disabled\"\n :label-id=\"labelId\"\n :show-optional-in-label=\"props.showOptionalInLabel\"\n ></slot>\n\n <span\n v-if=\"props.errorText\"\n :id=\"fieldErrorId\"\n class=\"stash-field-error tw-mt-1 tw-block tw-whitespace-pre-line tw-text-xs tw-text-red-500\"\n data-test=\"stash-field-error\"\n >\n {{ props.errorText }}\n </span>\n\n <span\n v-else-if=\"props.hintText && !props.isReadOnly\"\n class=\"stash-field-hint tw-mt-1 tw-block tw-whitespace-pre-line tw-text-xs\"\n data-test=\"stash-field-hint\"\n >\n {{ props.hintText }}\n </span>\n\n <div\n v-else-if=\"slots.hint && !props.isReadOnly\"\n class=\"stash-field-hint tw-mt-1 tw-whitespace-pre-line tw-text-xs\"\n data-test=\"stash-field-hint\"\n >\n <!-- @slot for displaying hint text below the field -->\n <slot name=\"hint\"></slot>\n </div>\n </component>\n</template>\n"],"names":["props","__props","attrs","useAttrs","slots","useSlots","fieldId","computed","uniqueId","fieldErrorId","labelId","hasError","wrapperElement","rootAttrs","placeholder","otherAttrs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBE,UAAMA,IAAQC,GAaRC,IAAQC,EAAS,GACjBC,IAAQC,EAAS,GACjBC,IAAUC,EAAS,MAAMP,EAAM,MAAMQ,EAAS,cAAc,CAAC,GAC7DC,IAAeF,EAAS,MAAMP,EAAM,WAAWQ,EAAS,oBAAoB,CAAC,GAC7EE,IAAUH,EAAS,MAAMC,EAAS,oBAAoB,CAAC,GACvDG,IAAWJ,EAAS,MAAM,CAAC,CAACP,EAAM,SAAS,GAC3CY,IAAiBL,EAAS,MAAOP,EAAM,WAAW,aAAa,KAAM,GAIrEa,IAAYN,EAAS,MAAM;AAC/B,YAAM,EAAE,aAAAO,GAAa,GAAGC,EAAA,IAAeb;AAEhC,aAAAa;AAAA,IAAA,CACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.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 const props = withDefaults(defineProps<LabelProps>(), {\n for: undefined,\n hasError: false,\n isRequired: false,\n showOptional: false,\n legend: false,\n isDisabled: 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 }\"\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":";;;;;;;;;;;;;;;;;;;;;AAqCE,UAAMA,IAAQC,GASRC,IAAKC,EAAS,MACXH,EAAM,SAAS,WAAW,OAClC;;;;;;;;;;;;;;;;;;"}
|