@leaflink/stash 49.3.2 → 49.3.4
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/AddressSelect.js +2 -2
- package/dist/Badge.vue.d.ts +1 -1
- package/dist/CurrencyInput.js +4 -3
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/CurrencyInput.vue.d.ts +4 -0
- package/dist/DataViewFilters.js +2 -2
- package/dist/DatePicker.js +2 -2
- package/dist/Field.js +2 -2
- package/dist/Field.vue.d.ts +7 -0
- package/dist/{Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js → Field.vue_vue_type_script_setup_true_lang-3ea26741.js} +22 -19
- package/dist/Field.vue_vue_type_script_setup_true_lang-3ea26741.js.map +1 -0
- package/dist/FilterSelect.js +2 -2
- package/dist/Filters.js +2 -2
- package/dist/Filters.vue.d.ts +38 -0
- package/dist/InlineEdit.js +2 -2
- package/dist/Input.js +61 -59
- package/dist/Input.js.map +1 -1
- package/dist/Input.vue.d.ts +7 -0
- package/dist/InputOptions.js +52 -49
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +7 -0
- package/dist/Label.js +1 -1
- package/dist/Label.vue.d.ts +6 -0
- package/dist/Label.vue_vue_type_script_setup_true_lang-b6ba2f02.js +43 -0
- package/dist/Label.vue_vue_type_script_setup_true_lang-b6ba2f02.js.map +1 -0
- package/dist/ListView.js +2 -2
- package/dist/ListView.vue.d.ts +76 -19
- package/dist/Module.js +12 -12
- package/dist/Module.js.map +1 -1
- package/dist/ModuleHeader.js +13 -12
- package/dist/ModuleHeader.js.map +1 -1
- package/dist/RadioGroup.js +2 -2
- package/dist/SearchBar.js +2 -2
- package/dist/Select.js +82 -81
- package/dist/Select.js.map +1 -1
- package/dist/SelectStatus.js +2 -2
- package/dist/Table.js +50 -47
- package/dist/Table.js.map +1 -1
- package/dist/TextEditor.js +6 -6
- package/dist/TextEditor.js.map +1 -1
- package/dist/Textarea.js +38 -34
- package/dist/Textarea.js.map +1 -1
- package/dist/Textarea.vue.d.ts +7 -0
- package/dist/components.css +2 -2
- package/package.json +1 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js.map +0 -1
- package/dist/Label.vue_vue_type_script_setup_true_lang-4b02087f.js +0 -38
- package/dist/Label.vue_vue_type_script_setup_true_lang-4b02087f.js.map +0 -1
package/dist/Textarea.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as M, useAttrs as S, useSlots as k, useCssModule as H, ref as x, computed as O, watch as A, onMounted as I, nextTick as P, onBeforeUnmount as V, openBlock as $, createBlock as q, mergeProps as _, unref as
|
|
1
|
+
import { defineComponent as M, useAttrs as S, useSlots as k, useCssModule as H, ref as x, computed as O, watch as A, onMounted as I, nextTick as P, onBeforeUnmount as V, openBlock as $, createBlock as q, mergeProps as _, unref as u, createSlots as j, withCtx as g, createElementVNode as D, renderSlot as F } from "vue";
|
|
2
2
|
import L from "lodash-es/uniqueId";
|
|
3
|
-
import { _ as N } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
3
|
+
import { _ as N } from "./Field.vue_vue_type_script_setup_true_lang-3ea26741.js";
|
|
4
4
|
import { _ as U } from "./_plugin-vue_export-helper-dad06003.js";
|
|
5
|
-
import "./Label.vue_vue_type_script_setup_true_lang-
|
|
5
|
+
import "./Label.vue_vue_type_script_setup_true_lang-b6ba2f02.js";
|
|
6
6
|
import "./locale.js";
|
|
7
7
|
import "lodash-es/get";
|
|
8
|
-
const W = ["id", "value"], Y = /* @__PURE__ */ M({
|
|
8
|
+
const W = ["id", "value", "disabled"], Y = /* @__PURE__ */ M({
|
|
9
9
|
name: "ll-textarea",
|
|
10
10
|
__name: "Textarea",
|
|
11
11
|
props: {
|
|
@@ -15,11 +15,12 @@ const W = ["id", "value"], Y = /* @__PURE__ */ M({
|
|
|
15
15
|
errorText: { default: "" },
|
|
16
16
|
hintText: { default: "" },
|
|
17
17
|
showOptionalInLabel: { type: Boolean, default: !1 },
|
|
18
|
-
resize: { type: [Boolean, Object], default: !1 }
|
|
18
|
+
resize: { type: [Boolean, Object], default: !1 },
|
|
19
|
+
disabled: { type: Boolean, default: !1 }
|
|
19
20
|
},
|
|
20
21
|
emits: ["update:model-value"],
|
|
21
22
|
setup(w, { emit: b }) {
|
|
22
|
-
const y = L("textarea-"), p = S(), z = k(), m = H(), s = w,
|
|
23
|
+
const y = L("textarea-"), p = S(), z = k(), m = H(), s = w, B = b, d = x(), l = x(), T = O(() => {
|
|
23
24
|
const e = { ...p };
|
|
24
25
|
return delete e["data-test"], delete e.class, e;
|
|
25
26
|
});
|
|
@@ -27,40 +28,40 @@ const W = ["id", "value"], Y = /* @__PURE__ */ M({
|
|
|
27
28
|
() => s.resize,
|
|
28
29
|
(e) => {
|
|
29
30
|
var t;
|
|
30
|
-
e ?
|
|
31
|
+
e ? h() : (t = l.value) == null || t.disconnect();
|
|
31
32
|
}
|
|
32
33
|
);
|
|
33
34
|
const C = (e) => {
|
|
34
|
-
|
|
35
|
-
},
|
|
35
|
+
B("update:model-value", e.target.value);
|
|
36
|
+
}, h = () => {
|
|
36
37
|
l.value || !d.value || (l.value = new ResizeObserver(([e]) => {
|
|
37
|
-
const { target: t } = e, o =
|
|
38
|
-
let
|
|
38
|
+
const { target: t } = e, o = v(d.value) || document.documentElement, { scrollTop: a } = o;
|
|
39
|
+
let r = 0;
|
|
39
40
|
if (o === document.documentElement) {
|
|
40
|
-
const { top:
|
|
41
|
-
|
|
41
|
+
const { top: n, height: i } = E(t), { innerHeight: c } = window;
|
|
42
|
+
r = Math.max(n + i - (c + a), 0);
|
|
42
43
|
} else {
|
|
43
|
-
const { top:
|
|
44
|
-
|
|
44
|
+
const { top: n, height: i } = t.getBoundingClientRect(), { top: c } = o.getBoundingClientRect(), { offsetHeight: f } = o, R = n - c;
|
|
45
|
+
r = Math.max(R + i - f, 0);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
o.scrollTop = a +
|
|
47
|
+
r && requestAnimationFrame(() => {
|
|
48
|
+
o.scrollTop = a + r;
|
|
48
49
|
});
|
|
49
50
|
}), l.value.observe(d.value));
|
|
50
|
-
},
|
|
51
|
+
}, v = (e) => {
|
|
51
52
|
const t = e.parentElement;
|
|
52
53
|
if (!t)
|
|
53
54
|
return null;
|
|
54
55
|
const { overflowY: o } = getComputedStyle(t);
|
|
55
|
-
return o !== "visible" ? t : t === document.body ? document.documentElement :
|
|
56
|
+
return o !== "visible" ? t : t === document.body ? document.documentElement : v(t);
|
|
56
57
|
}, E = (e) => {
|
|
57
58
|
const { offsetWidth: t, offsetHeight: o } = e;
|
|
58
|
-
let a = 0,
|
|
59
|
-
const
|
|
60
|
-
a += i,
|
|
59
|
+
let a = 0, r = 0;
|
|
60
|
+
const n = function({ offsetLeft: i, offsetTop: c, offsetParent: f }) {
|
|
61
|
+
a += i, r += c, f && n(f);
|
|
61
62
|
};
|
|
62
|
-
return
|
|
63
|
-
top:
|
|
63
|
+
return n(e), {
|
|
64
|
+
top: r,
|
|
64
65
|
left: a,
|
|
65
66
|
width: t,
|
|
66
67
|
height: o
|
|
@@ -72,13 +73,13 @@ const W = ["id", "value"], Y = /* @__PURE__ */ M({
|
|
|
72
73
|
throw new Error("ll-input: use :model-value or v-model instead of :value.");
|
|
73
74
|
if (p.onInput)
|
|
74
75
|
throw new Error("ll-input: use the @update:model-value event instead of @input");
|
|
75
|
-
(typeof s.resize == "boolean" && s.resize || (e = s.resize) != null && e.forceBrowserScroll) && (await P(),
|
|
76
|
+
(typeof s.resize == "boolean" && s.resize || (e = s.resize) != null && e.forceBrowserScroll) && (await P(), h());
|
|
76
77
|
}), V(() => {
|
|
77
78
|
var e;
|
|
78
79
|
(e = l.value) == null || e.disconnect();
|
|
79
80
|
}), (e, t) => ($(), q(N, _(s, {
|
|
80
|
-
id:
|
|
81
|
-
class: ["stash-textarea", [
|
|
81
|
+
id: u(y),
|
|
82
|
+
class: ["stash-textarea", [u(m).root, u(p).class]],
|
|
82
83
|
"data-test": "stash-textarea"
|
|
83
84
|
}), j({
|
|
84
85
|
default: g(({ fieldId: o, hasError: a }) => [
|
|
@@ -87,16 +88,19 @@ const W = ["id", "value"], Y = /* @__PURE__ */ M({
|
|
|
87
88
|
ref_key: "textareaRef",
|
|
88
89
|
ref: d,
|
|
89
90
|
class: [
|
|
90
|
-
|
|
91
|
+
u(m).textarea,
|
|
91
92
|
{ "stash-textarea--error": a, "tw-resize-y": s.resize, "tw-resize-none": !s.resize }
|
|
92
93
|
],
|
|
93
94
|
value: s.modelValue,
|
|
94
95
|
"data-test": "stash-textarea|textarea"
|
|
95
|
-
},
|
|
96
|
+
}, T.value, {
|
|
97
|
+
disabled: s.disabled,
|
|
98
|
+
onInput: C
|
|
99
|
+
}), null, 16, W)
|
|
96
100
|
]),
|
|
97
101
|
_: 2
|
|
98
102
|
}, [
|
|
99
|
-
|
|
103
|
+
u(z).hint ? {
|
|
100
104
|
name: "hint",
|
|
101
105
|
fn: g(() => [
|
|
102
106
|
F(e.$slots, "hint")
|
|
@@ -105,14 +109,14 @@ const W = ["id", "value"], Y = /* @__PURE__ */ M({
|
|
|
105
109
|
} : void 0
|
|
106
110
|
]), 1040, ["id", "class"]));
|
|
107
111
|
}
|
|
108
|
-
}), G = "
|
|
112
|
+
}), G = "_root_1agcr_2", J = "_textarea_1agcr_7", K = {
|
|
109
113
|
root: G,
|
|
110
114
|
textarea: J,
|
|
111
|
-
"stash-textarea--error": "_stash-textarea--
|
|
115
|
+
"stash-textarea--error": "_stash-textarea--error_1agcr_28"
|
|
112
116
|
}, Q = {
|
|
113
117
|
$style: K
|
|
114
|
-
},
|
|
118
|
+
}, re = /* @__PURE__ */ U(Y, [["__cssModules", Q]]);
|
|
115
119
|
export {
|
|
116
|
-
|
|
120
|
+
re as default
|
|
117
121
|
};
|
|
118
122
|
//# sourceMappingURL=Textarea.js.map
|
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 uniqueId from 'lodash-es/uniqueId';\n import { computed, nextTick, onBeforeUnmount, onMounted, ref, useAttrs, useCssModule, useSlots, watch } from 'vue';\n\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 {\n /**\n * Label text for the textarea element.\n */\n label?: string;\n\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 * Error text for the textarea element.\n */\n errorText?: string;\n\n /**\n * Hint text for the textarea element.\n */\n hintText?: string;\n\n /**\n * Render \"(optional)\" to the right of the label text\n */\n showOptionalInLabel?: boolean;\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 defineOptions({\n name: 'll-textarea',\n });\n\n /**\n * Unique ID for the textarea, required for accessibility purposes\n */\n const id = uniqueId('textarea-');\n\n const attrs = useAttrs();\n const slots = useSlots();\n const classes = useCssModule();\n\n const props = withDefaults(defineProps<TextAreaProps>(), {\n label: ' ',\n modelValue: '',\n value: null,\n errorText: '',\n hintText: '',\n showOptionalInLabel: false,\n resize: false,\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\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 v ? setupResizeObserver() : observer.value?.disconnect();\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\" :id=\"id\" class=\"stash-textarea\" :class=\"[classes.root, attrs.class]\" data-test=\"stash-textarea\">\n <template #default=\"{ fieldId, hasError }\">\n <textarea\n :id=\"fieldId\"\n ref=\"textareaRef\"\n :class=\"[\n classes.textarea,\n { 'stash-textarea--error': hasError, 'tw-resize-y': props.resize, 'tw-resize-none': !props.resize },\n ]\"\n :value=\"props.modelValue\"\n data-test=\"stash-textarea|textarea\"\n v-bind=\"inputAttrs\"\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: 1px solid;\n border-color: var(--color-ice-500);\n border-radius: theme('borderRadius.DEFAULT');\n color: var(--color-ice-700);\n display: block;\n min-height: 100px;\n outline: none;\n padding: theme('spacing[1.5]');\n width: 100%;\n\n &:hover {\n border-color: var(--color-ice-500);\n }\n\n &:focus,\n &:active {\n border-color: var(--color-blue-500);\n }\n\n &.stash-textarea--error {\n border-color: var(--color-red-500);\n color: var(--color-red-500);\n }\n\n &::placeholder {\n color: var(--color-ice-500);\n opacity: 1;\n }\n\n &[disabled],\n &[readonly] {\n background-color: var(--color-ice-200);\n border-color: var(--color-ice-500);\n color: var(--color-ice-700);\n pointer-events: none;\n }\n\n &[disabled]:active,\n &[readonly]:active,\n &[disabled]:focus,\n &[readonly]:focus {\n box-shadow: none;\n }\n\n &[disabled]::placeholder,\n &[readonly]::placeholder {\n text-transform: none;\n }\n }\n</style>\n"],"names":["id","uniqueId","attrs","useAttrs","slots","useSlots","classes","useCssModule","props","__props","emits","__emit","textareaRef","ref","observer","inputAttrs","computed","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":";;;;;;;;;;;;;;;;;;;;;AA2DQ,UAAAA,IAAKC,EAAS,WAAW,GAEzBC,IAAQC,KACRC,IAAQC,KACRC,IAAUC,KAEVC,IAAQC,GAURC,IAAQC,GAORC,IAAcC,KACdC,IAAWD,KAEXE,IAAaC,EAAS,MAAM;AAC1B,YAAAC,IAAW,EAAE,GAAGf;AAEtB,oBAAOe,EAAS,WAAW,GAC3B,OAAOA,EAAS,OAETA;AAAA,IAAA,CACR;AAED,IAAAC;AAAA,MACE,MAAMV,EAAM;AAAA,MACZ,CAACW,MAAM;;AACL,QAAAA,IAAIC,EAAoB,KAAIC,IAAAP,EAAS,UAAT,QAAAO,EAAgB;AAAA,MAC9C;AAAA,IAAA;AAGI,UAAAC,IAAU,CAACC,MAAiB;AAC1B,MAAAb,EAAA,sBAAuBa,EAAM,OAA+B,KAAK;AAAA,IAAA,GAGnEH,IAAsB,MAAM;AAChC,MAAIN,EAAS,SAAS,CAACF,EAAY,UAKnCE,EAAS,QAAQ,IAAI,eAAe,CAAC,CAACU,CAAK,MAAM;AACzC,cAAA,EAAE,QAAAC,EAAW,IAAAD,GACbE,IAASC,EAAqBf,EAAY,KAA4B,KAAK,SAAS,iBAEpF,EAAE,WAAWgB,EAAmB,IAAAF;AACtC,YAAIG,IAAa;AAGb,YAAAH,MAAW,SAAS,iBAAiB;AACvC,gBAAM,EAAE,KAAAI,GAAK,QAAAC,EAAO,IAAIC,EAAkBP,CAAqB,GACzD,EAAE,aAAaQ,EAA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E,OAAA,OAAOM,EAAM,UAAW,aAAaA,EAAM,WAC3Ca,IAAAb,EAAM,WAAN,QAAAa,EAAwC,wBAEzC,MAAMwB,EAAS,GACKzB;IACtB,CACD,GAED0B,EAAgB,MAAM;;AACpB,OAAAzB,IAAAP,EAAS,UAAT,QAAAO,EAAgB;AAAA,IAAW,CAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, nextTick, onBeforeUnmount, onMounted, ref, useAttrs, useCssModule, useSlots, watch } from 'vue';\n\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 {\n /**\n * Label text for the textarea element.\n */\n label?: string;\n\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 * Error text for the textarea element.\n */\n errorText?: string;\n\n /**\n * Hint text for the textarea element.\n */\n hintText?: string;\n\n /**\n * Render \"(optional)\" to the right of the label text\n */\n showOptionalInLabel?: boolean;\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 * Indicates whether the textarea is disabled.\n */\n disabled?: boolean;\n }\n\n defineOptions({\n name: 'll-textarea',\n });\n\n /**\n * Unique ID for the textarea, required for accessibility purposes\n */\n const id = uniqueId('textarea-');\n\n const attrs = useAttrs();\n const slots = useSlots();\n const classes = useCssModule();\n\n const props = withDefaults(defineProps<TextAreaProps>(), {\n label: ' ',\n modelValue: '',\n value: null,\n errorText: '',\n hintText: '',\n showOptionalInLabel: false,\n resize: false,\n disabled: false,\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\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 v ? setupResizeObserver() : observer.value?.disconnect();\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\" :id=\"id\" class=\"stash-textarea\" :class=\"[classes.root, attrs.class]\" data-test=\"stash-textarea\">\n <template #default=\"{ fieldId, hasError }\">\n <textarea\n :id=\"fieldId\"\n ref=\"textareaRef\"\n :class=\"[\n classes.textarea,\n { 'stash-textarea--error': hasError, 'tw-resize-y': props.resize, 'tw-resize-none': !props.resize },\n ]\"\n :value=\"props.modelValue\"\n data-test=\"stash-textarea|textarea\"\n v-bind=\"inputAttrs\"\n :disabled=\"props.disabled\"\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: 1px solid;\n border-color: var(--color-ice-500);\n border-radius: theme('borderRadius.DEFAULT');\n color: var(--color-ice-700);\n display: block;\n min-height: 100px;\n outline: none;\n padding: theme('spacing[1.5]');\n width: 100%;\n\n &:hover {\n border-color: var(--color-ice-500);\n }\n\n &:focus,\n &:active {\n border-color: var(--color-blue-500);\n }\n\n &.stash-textarea--error {\n border-color: var(--color-red-500);\n color: var(--color-red-500);\n }\n\n &::placeholder {\n color: var(--color-ice-500);\n opacity: 1;\n }\n\n &[disabled],\n &[readonly] {\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 &[readonly]:active,\n &[disabled]:focus,\n &[readonly]:focus {\n box-shadow: none;\n }\n\n &[disabled]::placeholder,\n &[readonly]::placeholder {\n text-transform: none;\n color: var(--color-ice-500);\n }\n }\n</style>\n"],"names":["id","uniqueId","attrs","useAttrs","slots","useSlots","classes","useCssModule","props","__props","emits","__emit","textareaRef","ref","observer","inputAttrs","computed","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":";;;;;;;;;;;;;;;;;;;;;;AAgEQ,UAAAA,IAAKC,EAAS,WAAW,GAEzBC,IAAQC,KACRC,IAAQC,KACRC,IAAUC,KAEVC,IAAQC,GAWRC,IAAQC,GAORC,IAAcC,KACdC,IAAWD,KAEXE,IAAaC,EAAS,MAAM;AAC1B,YAAAC,IAAW,EAAE,GAAGf;AAEtB,oBAAOe,EAAS,WAAW,GAC3B,OAAOA,EAAS,OAETA;AAAA,IAAA,CACR;AAED,IAAAC;AAAA,MACE,MAAMV,EAAM;AAAA,MACZ,CAACW,MAAM;;AACL,QAAAA,IAAIC,EAAoB,KAAIC,IAAAP,EAAS,UAAT,QAAAO,EAAgB;AAAA,MAC9C;AAAA,IAAA;AAGI,UAAAC,IAAU,CAACC,MAAiB;AAC1B,MAAAb,EAAA,sBAAuBa,EAAM,OAA+B,KAAK;AAAA,IAAA,GAGnEH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AAY,WAAAN,GAAW,cAAAO,KAA6B;AACtE,QAAAH,KAAAE,GACDZ,KAAAM,GAEHO,KACFF,EAAQE,CAA2B;AAAA,MACrC;AAGF,aAAAF,EAAQJ,CAAE,GAEH;AAAA,QACL,KAAAP;AAAA,QACA,MAAAU;AAAA,QACA,OAAAD;AAAA,QACA,QAAAR;AAAA,MAAA;AAAA,IACF;AAGF,WAAAa,EAAU,YAAY;;AAChB,UAAApC,EAAM,UAAU;AACZ,cAAA,IAAI,MAAM,0DAA0D;AAG5E,UAAIN,EAAM;AACF,cAAA,IAAI,MAAM,+DAA+D;AAI9E,OAAA,OAAOM,EAAM,UAAW,aAAaA,EAAM,WAC3Ca,IAAAb,EAAM,WAAN,QAAAa,EAAwC,wBAEzC,MAAMwB,EAAS,GACKzB;IACtB,CACD,GAED0B,EAAgB,MAAM;;AACpB,OAAAzB,IAAAP,EAAS,UAAT,QAAAO,EAAgB;AAAA,IAAW,CAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/Textarea.vue.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<ExtractPropTypes
|
|
|
40
40
|
hintText: string;
|
|
41
41
|
showOptionalInLabel: boolean;
|
|
42
42
|
resize: boolean;
|
|
43
|
+
disabled: boolean;
|
|
43
44
|
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
44
45
|
"update:model-value": (value: string) => void;
|
|
45
46
|
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<TextAreaProps>, {
|
|
@@ -50,10 +51,12 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<ExtractPropTypes
|
|
|
50
51
|
hintText: string;
|
|
51
52
|
showOptionalInLabel: boolean;
|
|
52
53
|
resize: boolean;
|
|
54
|
+
disabled: boolean;
|
|
53
55
|
}>>> & Readonly<{
|
|
54
56
|
"onUpdate:model-value"?: ((value: string) => any) | undefined;
|
|
55
57
|
}>, {
|
|
56
58
|
resize: boolean | TextareaResizeOptions;
|
|
59
|
+
disabled: boolean;
|
|
57
60
|
label: string;
|
|
58
61
|
errorText: string;
|
|
59
62
|
hintText: string;
|
|
@@ -96,6 +99,10 @@ export declare interface TextAreaProps {
|
|
|
96
99
|
* Alternatively if you want to disable automatic scroll when resizing, you can set `{ forceBrowserScroll: false }`
|
|
97
100
|
*/
|
|
98
101
|
resize?: boolean | TextareaResizeOptions;
|
|
102
|
+
/**
|
|
103
|
+
* Indicates whether the textarea is disabled.
|
|
104
|
+
*/
|
|
105
|
+
disabled?: boolean;
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
export declare interface TextareaResizeOptions {
|