@leaflink/stash 50.2.0 → 50.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.
@@ -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 Field, { type FieldProps } 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 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 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 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\" class=\"stash-textarea\" :class=\"[classes.root]\" 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 :placeholder=\"props.placeholder\"\n v-bind=\"inputAttrs\"\n :disabled=\"props.disabled\"\n :readonly=\"isReadOnly\"\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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyCE,UAAMA,IAAQC,KACRC,IAAQC,KACRC,IAAUC,KAEVC,IAAQC,GAORC,IAAQC,GAORC,IAAcC,KACdC,IAAWD,KACXE,IAAaC,EAAS,MAAMR,EAAM,cAAe,cAAcN,KAASA,EAAM,aAAa,EAAM,GAEjGe,IAAaD,EAAS,MAAM;AAC1B,YAAAE,IAAW,EAAE,GAAGhB;AAEtB,oBAAOgB,EAAS,WAAW,GAC3B,OAAOA,EAAS,OAETA;AAAA,IAAA,CACR;AAED,IAAAC;AAAA,MACE,MAAMX,EAAM;AAAA,MACZ,CAACY,MAAM;;AACL,QAAAA,IAAIC,EAAoB,KAAIC,IAAAR,EAAS,UAAT,QAAAQ,EAAgB;AAAA,MAC9C;AAAA,IAAA;AAGI,UAAAC,IAAU,CAACC,MAAiB;AAC1B,MAAAd,EAAA,sBAAuBc,EAAM,OAA+B,KAAK;AAAA,IAAA,GAGnEH,IAAsB,MAAM;AAChC,MAAIP,EAAS,SAAS,CAACF,EAAY,UAKnCE,EAAS,QAAQ,IAAI,eAAe,CAAC,CAACW,CAAK,MAAM;AACzC,cAAA,EAAE,QAAAC,EAAW,IAAAD,GACbE,IAASC,EAAqBhB,EAAY,KAA4B,KAAK,SAAS,iB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,QACA,OAAAD;AAAA,QACA,QAAAR;AAAA,MAAA;AAAA,IACF;AAGF,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;IACtB,CACD,GAED0B,EAAgB,MAAM;;AACpB,OAAAzB,IAAAR,EAAS,UAAT,QAAAQ,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 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 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 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\" class=\"stash-textarea\" :class=\"[classes.root]\" 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 :placeholder=\"props.placeholder\"\n v-bind=\"inputAttrs\"\n :disabled=\"props.disabled\"\n :readonly=\"isReadOnly\"\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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0CE,UAAMA,IAAQC,KACRC,IAAQC,KACRC,IAAUC,KAEVC,IAAQC,GAORC,IAAQC,GAORC,IAAcC,KACdC,IAAWD,KACXE,IAAaC,EAAS,MAAMR,EAAM,cAAe,cAAcN,KAASA,EAAM,aAAa,EAAM,GAEjGe,IAAaD,EAAS,MAAM;AAC1B,YAAAE,IAAW,EAAE,GAAGhB;AAEtB,oBAAOgB,EAAS,WAAW,GAC3B,OAAOA,EAAS,OAETA;AAAA,IAAA,CACR;AAED,IAAAC;AAAA,MACE,MAAMX,EAAM;AAAA,MACZ,CAACY,MAAM;;AACL,QAAAA,IAAIC,EAAoB,KAAIC,IAAAR,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qBD,CAAM;AAAA,IAAA,GAM9BM,IAAoB,CAACK,MAAoB;AAC7C,YAAM,EAAE,aAAaE,GAAO,cAAcR,MAAWM;AAErD,UAAIG,IAAO,GACPV,IAAM;AAEV,YAAMW,IAAU,SAAU,EAAE,YAAAC,GAAY,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,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;IACtB,CACD,GAED0B,EAAgB,MAAM;;AACpB,OAAAzB,IAAAR,EAAS,UAAT,QAAAQ,EAAgB;AAAA,IAAW,CAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/Tooltip.js CHANGED
@@ -1,131 +1,10 @@
1
- import { getCurrentScope as C, onScopeDispose as D, unref as M, ref as p, watch as $, defineComponent as F, computed as A, openBlock as Y, createElementBlock as P, createElementVNode as X, renderSlot as E, createBlock as j, Teleport as I, normalizeStyle as k, createTextVNode as R, toDisplayString as V } from "vue";
2
- import { u as z, a as L, f as N, o as G, b as U } from "./floating-ui.vue-BmfQDqE-.js";
3
- function q(e) {
4
- return C() ? (D(e), !0) : !1;
5
- }
6
- function B(e) {
7
- return typeof e == "function" ? e() : M(e);
8
- }
9
- const J = typeof window < "u" && typeof document < "u";
10
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
11
- const K = Object.prototype.toString, Q = (e) => K.call(e) === "[object Object]", Z = () => {
12
- }, W = J ? window : void 0;
13
- function H(e) {
14
- var s;
15
- const n = B(e);
16
- return (s = n == null ? void 0 : n.$el) != null ? s : n;
17
- }
18
- function b(...e) {
19
- let s, n, l, i;
20
- if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([n, l, i] = e, s = W) : [s, n, l, i] = e, !s)
21
- return Z;
22
- Array.isArray(n) || (n = [n]), Array.isArray(l) || (l = [l]);
23
- const c = [], f = () => {
24
- c.forEach((o) => o()), c.length = 0;
25
- }, y = (o, r, u, a) => (o.addEventListener(r, u, a), () => o.removeEventListener(r, u, a)), d = $(
26
- () => [H(s), B(i)],
27
- ([o, r]) => {
28
- if (f(), !o)
29
- return;
30
- const u = Q(r) ? { ...r } : r;
31
- c.push(
32
- ...n.flatMap((a) => l.map((m) => y(o, a, m, u)))
33
- );
34
- },
35
- { immediate: !0, flush: "post" }
36
- ), w = () => {
37
- d(), f();
38
- };
39
- return q(w), w;
40
- }
41
- const ee = {
42
- page: (e) => [e.pageX, e.pageY],
43
- client: (e) => [e.clientX, e.clientY],
44
- screen: (e) => [e.screenX, e.screenY],
45
- movement: (e) => e instanceof Touch ? null : [e.movementX, e.movementY]
46
- };
47
- function te(e = {}) {
48
- const {
49
- type: s = "page",
50
- touch: n = !0,
51
- resetOnTouchEnds: l = !1,
52
- initialValue: i = { x: 0, y: 0 },
53
- window: c = W,
54
- target: f = c,
55
- scroll: y = !0,
56
- eventFilter: d
57
- } = e;
58
- let w = null;
59
- const o = p(i.x), r = p(i.y), u = p(null), a = typeof s == "function" ? s : ee[s], m = (t) => {
60
- const h = a(t);
61
- w = t, h && ([o.value, r.value] = h, u.value = "mouse");
62
- }, v = (t) => {
63
- if (t.touches.length > 0) {
64
- const h = a(t.touches[0]);
65
- h && ([o.value, r.value] = h, u.value = "touch");
66
- }
67
- }, g = () => {
68
- if (!w || !c)
69
- return;
70
- const t = a(w);
71
- w instanceof MouseEvent && t && (o.value = t[0] + c.scrollX, r.value = t[1] + c.scrollY);
72
- }, x = () => {
73
- o.value = i.x, r.value = i.y;
74
- }, S = d ? (t) => d(() => m(t), {}) : (t) => m(t), O = d ? (t) => d(() => v(t), {}) : (t) => v(t), _ = d ? () => d(() => g(), {}) : () => g();
75
- if (f) {
76
- const t = { passive: !0 };
77
- b(f, ["mousemove", "dragover"], S, t), n && s !== "movement" && (b(f, ["touchstart", "touchmove"], O, t), l && b(f, "touchend", x, t)), y && s === "page" && b(c, "scroll", _, { passive: !0 });
78
- }
79
- return {
80
- x: o,
81
- y: r,
82
- sourceType: u
83
- };
84
- }
85
- function oe(e, s = {}) {
86
- const {
87
- handleOutside: n = !0,
88
- window: l = W
89
- } = s, i = s.type || "page", { x: c, y: f, sourceType: y } = te(s), d = p(e ?? (l == null ? void 0 : l.document.body)), w = p(0), o = p(0), r = p(0), u = p(0), a = p(0), m = p(0), v = p(!0);
90
- let g = () => {
91
- };
92
- return l && (g = $(
93
- [d, c, f],
94
- () => {
95
- const x = H(d);
96
- if (!x || !(x instanceof Element))
97
- return;
98
- const {
99
- left: S,
100
- top: O,
101
- width: _,
102
- height: t
103
- } = x.getBoundingClientRect();
104
- r.value = S + (i === "page" ? l.pageXOffset : 0), u.value = O + (i === "page" ? l.pageYOffset : 0), a.value = t, m.value = _;
105
- const h = c.value - r.value, T = f.value - u.value;
106
- v.value = _ === 0 || t === 0 || h < 0 || T < 0 || h > _ || T > t, (n || !v.value) && (w.value = h, o.value = T);
107
- },
108
- { immediate: !0 }
109
- ), b(document, "mouseleave", () => {
110
- v.value = !0;
111
- })), {
112
- x: c,
113
- y: f,
114
- sourceType: y,
115
- elementX: w,
116
- elementY: o,
117
- elementPositionX: r,
118
- elementPositionY: u,
119
- elementHeight: a,
120
- elementWidth: m,
121
- isOutside: v,
122
- stop: g
123
- };
124
- }
125
- const ne = {
1
+ import { defineComponent as g, ref as n, computed as r, openBlock as d, createElementBlock as S, createElementVNode as i, renderSlot as l, createBlock as T, Teleport as E, normalizeStyle as u, unref as $, createTextVNode as k, toDisplayString as O } from "vue";
2
+ import { u as A, a as B, f as F, o as D, b as I } from "./floating-ui.vue-BmfQDqE-.js";
3
+ import { u as P } from "./index-Ck3Dl09q.js";
4
+ const z = {
126
5
  ref: "wrapper",
127
6
  class: "stash-tooltip__wrapper tw-relative tw-inline-flex tw-h-fit tw-w-fit"
128
- }, se = 6, le = 12, ce = /* @__PURE__ */ F({
7
+ }, M = 6, N = 12, X = /* @__PURE__ */ g({
129
8
  __name: "Tooltip",
130
9
  props: {
131
10
  disableTeleport: { type: Boolean, default: !1 },
@@ -134,59 +13,59 @@ const ne = {
134
13
  teleportTo: { default: "#stash-menus-mount-node" },
135
14
  text: { default: "" }
136
15
  },
137
- setup(e) {
138
- const s = {
16
+ setup(f) {
17
+ const m = {
139
18
  top: "bottom",
140
19
  right: "left",
141
20
  bottom: "top",
142
21
  left: "right"
143
- }, n = e, l = p(null), i = p(null), c = p(null), { isOutside: f } = oe(l), y = A(() => !f.value || n.isOpen), d = A(() => n.side), { floatingStyles: w, middlewareData: o, placement: r } = z(l, c, {
144
- whileElementsMounted: L,
145
- placement: d,
146
- middleware: [N(), G(le), U({ element: i })]
147
- }), u = A(() => {
148
- var m, v;
149
- const a = s[r.value];
22
+ }, e = f, a = n(null), p = n(null), c = n(null), { isOutside: h } = P(a), _ = r(() => !h.value || e.isOpen), y = r(() => e.side), { floatingStyles: x, middlewareData: o, placement: v } = A(a, c, {
23
+ whileElementsMounted: B,
24
+ placement: y,
25
+ middleware: [F(), D(N), I({ element: p })]
26
+ }), b = r(() => {
27
+ var s, w;
28
+ const t = m[v.value];
150
29
  return {
151
- left: ((m = o.value.arrow) == null ? void 0 : m.x) != null ? `${o.value.arrow.x}px` : "",
152
- top: ((v = o.value.arrow) == null ? void 0 : v.y) != null ? `${o.value.arrow.y}px` : "",
153
- [a]: `-${se}px`
30
+ left: ((s = o.value.arrow) == null ? void 0 : s.x) != null ? `${o.value.arrow.x}px` : "",
31
+ top: ((w = o.value.arrow) == null ? void 0 : w.y) != null ? `${o.value.arrow.y}px` : "",
32
+ [t]: `-${M}px`
154
33
  };
155
34
  });
156
- return (a, m) => (Y(), P("div", ne, [
157
- X("span", {
35
+ return (t, s) => (d(), S("div", z, [
36
+ i("span", {
158
37
  ref_key: "anchor",
159
- ref: l,
38
+ ref: a,
160
39
  "data-test": "stash-tooltip|anchor",
161
40
  class: "stash-tooltip__anchor"
162
41
  }, [
163
- E(a.$slots, "default")
42
+ l(t.$slots, "default")
164
43
  ], 512),
165
- (Y(), j(I, {
166
- to: n.teleportTo,
167
- disabled: n.disableTeleport
44
+ (d(), T(E, {
45
+ to: e.teleportTo,
46
+ disabled: e.disableTeleport
168
47
  }, [
169
- X("div", {
48
+ i("div", {
170
49
  ref_key: "tooltip",
171
50
  ref: c,
172
51
  "data-test": "stash-tooltip",
173
52
  class: "stash-tooltip tw-pointer-events-none tw-z-screen tw-flex tw-w-[148px] tw-flex-col tw-items-center tw-whitespace-normal tw-rounded tw-bg-ice-900 tw-p-3 tw-text-center tw-text-xs tw-text-white tw-opacity-0 tw-shadow tw-transition-opacity",
174
53
  role: "tooltip",
175
- style: k({
176
- ...M(w),
177
- opacity: y.value ? 0.95 : 0
54
+ style: u({
55
+ ...$(x),
56
+ opacity: _.value ? 0.95 : 0
178
57
  })
179
58
  }, [
180
- E(a.$slots, "icon"),
181
- E(a.$slots, "content", {}, () => [
182
- R(V(n.text), 1)
59
+ l(t.$slots, "icon"),
60
+ l(t.$slots, "content", {}, () => [
61
+ k(O(e.text), 1)
183
62
  ]),
184
- E(a.$slots, "secondaryIcon"),
185
- X("div", {
63
+ l(t.$slots, "secondaryIcon"),
64
+ i("div", {
186
65
  ref_key: "floatingArrow",
187
- ref: i,
66
+ ref: p,
188
67
  class: "stash-tooltip__arrow tw-absolute tw-z-behind tw-h-[12px] tw-w-[12px] tw-rotate-45 tw-bg-ice-900",
189
- style: k(u.value)
68
+ style: u(b.value)
190
69
  }, null, 4)
191
70
  ], 4)
192
71
  ], 8, ["to", "disabled"]))
@@ -194,6 +73,6 @@ const ne = {
194
73
  }
195
74
  });
196
75
  export {
197
- ce as default
76
+ X as default
198
77
  };
199
78
  //# sourceMappingURL=Tooltip.js.map