@uva-glass/component-library 1.1.0 → 1.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/README.md +1 -1
- package/dist/SelectListbox.module-iJtzAajj.js +23 -0
- package/dist/SelectListbox.module-iJtzAajj.js.map +1 -0
- package/dist/assets/Button.css +1 -1
- package/dist/assets/Card.css +1 -1
- package/dist/assets/IconButton.css +1 -1
- package/dist/assets/InfoMessage.css +1 -1
- package/dist/assets/SectionNotification.css +1 -1
- package/dist/assets/SelectListbox.css +1 -1
- package/dist/components/Button/Button.stories.js +1 -1
- package/dist/components/Icon/icons/index.js +52 -52
- package/dist/components/Icon/icons/index.js.map +1 -1
- package/dist/components/IconButton/IconButton.stories.js +2 -1
- package/dist/components/IconButton/IconButton.stories.js.map +1 -1
- package/dist/components/SelectListbox/SelectListBox.stories.js +19 -19
- package/dist/components/SelectListbox/SelectListBox.stories.js.map +1 -1
- package/dist/components/SelectListbox/SelectListbox.d.ts +3 -5
- package/dist/components/SelectListbox/SelectListbox.js +46 -34
- package/dist/components/SelectListbox/SelectListbox.js.map +1 -1
- package/dist/components/SelectListbox/SelectProvider.js +20 -18
- package/dist/components/SelectListbox/SelectProvider.js.map +1 -1
- package/dist/components/SelectListbox/components/SelectButton.d.ts +1 -1
- package/dist/components/SelectListbox/components/SelectButton.js +30 -36
- package/dist/components/SelectListbox/components/SelectButton.js.map +1 -1
- package/dist/components/SelectListbox/components/SelectContainer.js +1 -1
- package/dist/components/SelectListbox/components/SelectOption.js +20 -20
- package/dist/components/SelectListbox/components/SelectOption.js.map +1 -1
- package/dist/components/SelectListbox/components/SelectOptionBox.d.ts +3 -4
- package/dist/components/SelectListbox/components/SelectOptionBox.js +14 -27
- package/dist/components/SelectListbox/components/SelectOptionBox.js.map +1 -1
- package/dist/components/hooks/usePositionedFloaters.d.ts +22 -0
- package/dist/components/hooks/usePositionedFloaters.js +68 -0
- package/dist/components/hooks/usePositionedFloaters.js.map +1 -0
- package/dist/components/storyComponents/ClipboardButton/ClipboardButton.js +6 -6
- package/dist/components/storyComponents/ClipboardButton/ClipboardButton.js.map +1 -1
- package/dist/{index-CZx-Vhwf.js → index-DHAcOIyn.js} +2172 -2177
- package/dist/index-DHAcOIyn.js.map +1 -0
- package/package.json +27 -26
- package/dist/SelectListbox.module-wZfvJXBJ.js +0 -22
- package/dist/SelectListbox.module-wZfvJXBJ.js.map +0 -1
- package/dist/index-CZx-Vhwf.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOption.js","sources":["../../../../src/components/SelectListbox/components/SelectOption.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport type { KeyboardEvent, ReactNode } from 'react';\nimport type { OptionValue } from 'components/SelectListbox/SelectProvider';\n\nimport { useSelect } from 'components/SelectListbox/SelectProvider';\nimport styles from 'components/SelectListbox/SelectListbox.module.css';\n\nexport interface SelectOptionProps {\n option: OptionValue;\n index: number;\n key: string;\n children: ReactNode;\n}\n\nexport const SelectOption = ({ option, index, children }: SelectOptionProps) => {\n const selectOptionRef = useRef<HTMLLIElement>(null);\n const { isOpen, activeIndex, setActiveIndex, selectedValue, setSelectedValue, setIsOpen, options } = useSelect();\n\n const handleSelectOption = (aIndex: number) => {\n setSelectedValue(options[aIndex]);\n setIsOpen(false);\n };\n\n const onOptionKeyDown = (event: KeyboardEvent<HTMLLIElement>) => {\n switch (event.key) {\n case 'Tab':\n event.preventDefault();\n if (isOpen) {\n setIsOpen(false);\n }\n break;\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n if (!isOpen) {\n return;\n }\n if (event.key === 'ArrowDown' && activeIndex < options.length - 1) {\n setActiveIndex(
|
|
1
|
+
{"version":3,"file":"SelectOption.js","sources":["../../../../src/components/SelectListbox/components/SelectOption.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport type { KeyboardEvent, ReactNode } from 'react';\nimport type { OptionValue } from 'components/SelectListbox/SelectProvider';\n\nimport { useSelect } from 'components/SelectListbox/SelectProvider';\nimport styles from 'components/SelectListbox/SelectListbox.module.css';\n\nexport interface SelectOptionProps {\n option: OptionValue;\n index: number;\n key: string;\n children: ReactNode;\n}\n\nexport const SelectOption = ({ option, index, children }: SelectOptionProps) => {\n const selectOptionRef = useRef<HTMLLIElement>(null);\n const { isOpen, activeIndex, setActiveIndex, selectedValue, setSelectedValue, setIsOpen, options } = useSelect();\n\n const handleSelectOption = (aIndex: number) => {\n setSelectedValue(options[aIndex]);\n setIsOpen(false);\n };\n\n const onOptionKeyDown = (event: KeyboardEvent<HTMLLIElement>) => {\n switch (event.key) {\n case 'Tab':\n event.preventDefault();\n if (isOpen) {\n setIsOpen(false);\n }\n break;\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n if (!isOpen) {\n return;\n }\n if (event.key === 'ArrowDown' && activeIndex < options.length - 1) {\n setActiveIndex(activeIndex + 1);\n }\n if (event.key === 'ArrowUp' && activeIndex > 0) {\n setActiveIndex(activeIndex - 1);\n }\n break;\n case 'Enter':\n event.preventDefault();\n if (options?.length && activeIndex > -1 && !options[activeIndex].disabled) {\n handleSelectOption(activeIndex);\n }\n break;\n case 'Escape':\n if (isOpen) {\n event.stopPropagation();\n setIsOpen(false);\n }\n break;\n }\n };\n\n useEffect(() => {\n if (index === activeIndex) {\n isOpen ? selectOptionRef.current?.focus() : selectOptionRef.current?.blur();\n }\n }, [activeIndex, index, isOpen]);\n\n useEffect(() => {\n if (selectedValue.value === option.value) {\n setActiveIndex(index);\n }\n }, [index, option.value, selectedValue.value, setActiveIndex]);\n\n return (\n <li\n className={clsx(styles['select-listbox-option'], {\n [styles['select-listbox-option--active']]: index === activeIndex,\n })}\n key={`${option.value}`}\n {...(!option.disabled && {\n onClick: () => setSelectedValue(option),\n onKeyDown: onOptionKeyDown,\n tabIndex: 0,\n role: 'option',\n 'aria-selected': selectedValue.value === option.value,\n })}\n ref={selectOptionRef}\n >\n {children}\n </li>\n );\n};\n"],"names":["SelectOption","option","index","children","selectOptionRef","useRef","isOpen","activeIndex","setActiveIndex","selectedValue","setSelectedValue","setIsOpen","options","useSelect","handleSelectOption","aIndex","onOptionKeyDown","event","useEffect","_a","_b","jsx","clsx","styles"],"mappings":";;;;;AAgBO,MAAMA,IAAe,CAAC,EAAE,QAAAC,GAAQ,OAAAC,GAAO,UAAAC,QAAkC;AACxE,QAAAC,IAAkBC,EAAsB,IAAI,GAC5C,EAAE,QAAAC,GAAQ,aAAAC,GAAa,gBAAAC,GAAgB,eAAAC,GAAe,kBAAAC,GAAkB,WAAAC,GAAW,SAAAC,MAAYC,KAE/FC,IAAqB,CAACC,MAAmB;AAC5B,IAAAL,EAAAE,EAAQG,CAAM,CAAC,GAChCJ,EAAU,EAAK;AAAA,EAAA,GAGXK,IAAkB,CAACC,MAAwC;AAC/D,YAAQA,EAAM,KAAK;AAAA,MACjB,KAAK;AACH,QAAAA,EAAM,eAAe,GACjBX,KACFK,EAAU,EAAK;AAEjB;AAAA,MACF,KAAK;AAAA,MACL,KAAK;AAEH,YADAM,EAAM,eAAe,GACjB,CAACX;AACH;AAEF,QAAIW,EAAM,QAAQ,eAAeV,IAAcK,EAAQ,SAAS,KAC9DJ,EAAeD,IAAc,CAAC,GAE5BU,EAAM,QAAQ,aAAaV,IAAc,KAC3CC,EAAeD,IAAc,CAAC;AAEhC;AAAA,MACF,KAAK;AACH,QAAAU,EAAM,eAAe,GACjBL,KAAA,QAAAA,EAAS,UAAUL,IAAc,MAAM,CAACK,EAAQL,CAAW,EAAE,YAC/DO,EAAmBP,CAAW;AAEhC;AAAA,MACF,KAAK;AACH,QAAID,MACFW,EAAM,gBAAgB,GACtBN,EAAU,EAAK;AAEjB;AAAA,IACJ;AAAA,EAAA;AAGF,SAAAO,EAAU,MAAM;;AACd,IAAIhB,MAAUK,MACZD,KAASa,IAAAf,EAAgB,YAAhB,QAAAe,EAAyB,WAAUC,IAAAhB,EAAgB,YAAhB,QAAAgB,EAAyB;AAAA,EAEtE,GAAA,CAACb,GAAaL,GAAOI,CAAM,CAAC,GAE/BY,EAAU,MAAM;AACV,IAAAT,EAAc,UAAUR,EAAO,SACjCO,EAAeN,CAAK;AAAA,EACtB,GACC,CAACA,GAAOD,EAAO,OAAOQ,EAAc,OAAOD,CAAc,CAAC,GAG3D,gBAAAa;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAKC,EAAO,uBAAuB,GAAG;AAAA,QAC/C,CAACA,EAAO,+BAA+B,CAAC,GAAGrB,MAAUK;AAAA,MAAA,CACtD;AAAA,MAEA,GAAI,CAACN,EAAO,YAAY;AAAA,QACvB,SAAS,MAAMS,EAAiBT,CAAM;AAAA,QACtC,WAAWe;AAAA,QACX,UAAU;AAAA,QACV,MAAM;AAAA,QACN,iBAAiBP,EAAc,UAAUR,EAAO;AAAA,MAClD;AAAA,MACA,KAAKG;AAAA,MAEJ,UAAAD;AAAA,IAAA;AAAA,IAVI,GAAGF,EAAO,KAAK;AAAA,EAAA;AAa1B;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
export interface SelectOptionBoxProps {
|
|
4
|
-
|
|
5
|
-
maxOptionHeight?: string;
|
|
4
|
+
style: CSSProperties;
|
|
6
5
|
children: ReactNode;
|
|
7
6
|
}
|
|
8
|
-
export declare const SelectOptionBox: (
|
|
7
|
+
export declare const SelectOptionBox: import('react').ForwardRefExoticComponent<SelectOptionBoxProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
return i ? /* @__PURE__ */ l(
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as m, useRef as p } from "react";
|
|
3
|
+
import { s as t } from "../../../SelectListbox.module-iJtzAajj.js";
|
|
4
|
+
import { useSelect as d } from "../SelectProvider.js";
|
|
5
|
+
const u = m((o, e) => {
|
|
6
|
+
const { style: i, children: l } = o, { listboxId: r, isOpen: c } = d(), n = p(null);
|
|
7
|
+
return /* @__PURE__ */ s(
|
|
9
8
|
"div",
|
|
10
9
|
{
|
|
11
|
-
className:
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
children: /* @__PURE__ */ l(
|
|
16
|
-
"ul",
|
|
17
|
-
{
|
|
18
|
-
className: s["select-listbox"],
|
|
19
|
-
role: "listbox",
|
|
20
|
-
ref: c,
|
|
21
|
-
id: o,
|
|
22
|
-
tabIndex: -1,
|
|
23
|
-
style: { maxHeight: e || "" },
|
|
24
|
-
children: r
|
|
25
|
-
}
|
|
26
|
-
)
|
|
10
|
+
className: t["select-listbox__wrapper"],
|
|
11
|
+
style: { ...i, visibility: c ? "visible" : "hidden" },
|
|
12
|
+
...e && { ref: e },
|
|
13
|
+
children: /* @__PURE__ */ s("ul", { className: t["select-listbox"], role: "listbox", ref: n, id: r, tabIndex: -1, children: l })
|
|
27
14
|
}
|
|
28
|
-
)
|
|
29
|
-
};
|
|
15
|
+
);
|
|
16
|
+
});
|
|
30
17
|
export {
|
|
31
|
-
|
|
18
|
+
u as SelectOptionBox
|
|
32
19
|
};
|
|
33
20
|
//# sourceMappingURL=SelectOptionBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOptionBox.js","sources":["../../../../src/components/SelectListbox/components/SelectOptionBox.tsx"],"sourcesContent":["import { useRef } from 'react';\
|
|
1
|
+
{"version":3,"file":"SelectOptionBox.js","sources":["../../../../src/components/SelectListbox/components/SelectOptionBox.tsx"],"sourcesContent":["import { useRef, forwardRef } from 'react';\n\nimport type { CSSProperties, ReactNode } from 'react';\n\nimport styles from 'components/SelectListbox/SelectListbox.module.css';\nimport { useSelect } from 'components/SelectListbox/SelectProvider';\n\nexport interface SelectOptionBoxProps {\n style: CSSProperties;\n children: ReactNode;\n}\n\nexport const SelectOptionBox = forwardRef<HTMLDivElement, SelectOptionBoxProps>((props, ref) => {\n const { style, children } = props;\n const { listboxId, isOpen } = useSelect();\n const selectOptionBoxRef = useRef<HTMLUListElement>(null);\n\n return (\n <div\n className={styles['select-listbox__wrapper']}\n style={{ ...style, visibility: isOpen ? 'visible' : 'hidden' }}\n {...(ref && { ref: ref })}\n >\n <ul className={styles['select-listbox']} role=\"listbox\" ref={selectOptionBoxRef} id={listboxId} tabIndex={-1}>\n {children}\n </ul>\n </div>\n );\n});\n"],"names":["SelectOptionBox","forwardRef","props","ref","style","children","listboxId","isOpen","useSelect","selectOptionBoxRef","useRef","jsx","styles"],"mappings":";;;;AAYO,MAAMA,IAAkBC,EAAiD,CAACC,GAAOC,MAAQ;AACxF,QAAA,EAAE,OAAAC,GAAO,UAAAC,EAAa,IAAAH,GACtB,EAAE,WAAAI,GAAW,QAAAC,EAAO,IAAIC,EAAU,GAClCC,IAAqBC,EAAyB,IAAI;AAGtD,SAAA,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAO,yBAAyB;AAAA,MAC3C,OAAO,EAAE,GAAGR,GAAO,YAAYG,IAAS,YAAY,SAAS;AAAA,MAC5D,GAAIJ,KAAO,EAAE,KAAAA,EAAS;AAAA,MAEvB,UAAC,gBAAAQ,EAAA,MAAA,EAAG,WAAWC,EAAO,gBAAgB,GAAG,MAAK,WAAU,KAAKH,GAAoB,IAAIH,GAAW,UAAU,IACvG,UAAAD,GACH;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface positionProps {
|
|
2
|
+
style: {
|
|
3
|
+
style: {
|
|
4
|
+
inset: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
buttonStyle: {
|
|
8
|
+
buttonStyle: {
|
|
9
|
+
width: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
status: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface optionProps {
|
|
15
|
+
mouseEvent: 'click' | 'hover';
|
|
16
|
+
position: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
|
|
17
|
+
offset: number;
|
|
18
|
+
maxFixedHeight?: `${number}${'px' | 'rem'}`;
|
|
19
|
+
horizontalPosition?: 'left' | 'right';
|
|
20
|
+
}
|
|
21
|
+
export declare function usePositionedFloaters<T extends HTMLElement = HTMLElement>(positionedElement: T | null, referenceElement: T | null, options: optionProps): positionProps;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useState as h, useEffect as F } from "react";
|
|
2
|
+
const u = 10, P = 80, l = 220;
|
|
3
|
+
function p(d, i, e) {
|
|
4
|
+
const [v, H] = h(!1), w = {
|
|
5
|
+
inset: "0 auto auto 0",
|
|
6
|
+
opacity: 0,
|
|
7
|
+
maxHeight: "100%",
|
|
8
|
+
maxWidth: "100%",
|
|
9
|
+
overflowX: "hidden",
|
|
10
|
+
overflowY: "auto",
|
|
11
|
+
margin: "0rem"
|
|
12
|
+
}, [c, g] = h(w), [L, y] = h({ width: "auto" }), x = (t) => {
|
|
13
|
+
const o = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
14
|
+
return t.indexOf("rem") !== -1 ? parseFloat(t) * o : parseFloat(t);
|
|
15
|
+
}, S = (t, o) => {
|
|
16
|
+
if (!t)
|
|
17
|
+
return 0;
|
|
18
|
+
const n = o === "bottom" ? window.innerHeight - t.bottom - e.offset - u : t.top - e.offset - u;
|
|
19
|
+
return !e.maxFixedHeight || x(e.maxFixedHeight) > n ? n : x(e.maxFixedHeight);
|
|
20
|
+
}, b = (t, o) => {
|
|
21
|
+
if (!t)
|
|
22
|
+
return 0;
|
|
23
|
+
const n = o === "left" ? window.innerWidth - t.left - u : t.right - u;
|
|
24
|
+
return n <= l ? l : n;
|
|
25
|
+
}, m = () => {
|
|
26
|
+
const t = d == null ? void 0 : d.getBoundingClientRect(), o = i == null ? void 0 : i.getBoundingClientRect();
|
|
27
|
+
let n = "bottom", a = "left";
|
|
28
|
+
return !o || !t ? w : (y({ width: t.width + "px" }), window.innerHeight - o.bottom - u < P && (n = "top"), (window.innerWidth - o.left - u < l || e.horizontalPosition === "right") && (a = "right"), {
|
|
29
|
+
inset: `${n === "bottom" ? o[n] + "px" : "auto"}
|
|
30
|
+
${a === "right" ? window.innerWidth - o[a] + "px" : "auto"}
|
|
31
|
+
${n === "top" ? window.innerHeight - o[n] + "px" : "auto"}
|
|
32
|
+
${a === "left" ? o[a] + "px" : "auto"}`,
|
|
33
|
+
maxHeight: `${S(o, n)}px`,
|
|
34
|
+
maxWidth: `${b(o, a)}px`,
|
|
35
|
+
overflowX: "hidden",
|
|
36
|
+
overflowY: "auto",
|
|
37
|
+
opacity: 1,
|
|
38
|
+
margin: `${e.offset}px 0`
|
|
39
|
+
});
|
|
40
|
+
}, r = () => {
|
|
41
|
+
g({
|
|
42
|
+
...c,
|
|
43
|
+
...m()
|
|
44
|
+
}), H(!0);
|
|
45
|
+
}, f = () => {
|
|
46
|
+
v && g({
|
|
47
|
+
...c,
|
|
48
|
+
...m()
|
|
49
|
+
});
|
|
50
|
+
}, s = (t) => {
|
|
51
|
+
!i || i.contains(t.target) || !d || d.contains(t.target);
|
|
52
|
+
};
|
|
53
|
+
return F(() => (i !== null && (e.mouseEvent === "click" ? i.addEventListener("click", r) : (i.addEventListener("mouseenter", r), i.addEventListener("mouseleave", s)), document.addEventListener("mousedown", s), document.addEventListener("touchstart", s), window.addEventListener("resize", f)), () => {
|
|
54
|
+
i !== null && (e.mouseEvent === "click" ? i.removeEventListener("click", r) : (i.removeEventListener("mouseenter", r), i.removeEventListener("mouseleave", s)), document.removeEventListener("mousedown", s), document.removeEventListener("touchstart", s), window.removeEventListener("resize", f));
|
|
55
|
+
})), {
|
|
56
|
+
style: {
|
|
57
|
+
style: c
|
|
58
|
+
},
|
|
59
|
+
buttonStyle: {
|
|
60
|
+
buttonStyle: L
|
|
61
|
+
},
|
|
62
|
+
status: v
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
p as usePositionedFloaters
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=usePositionedFloaters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePositionedFloaters.js","sources":["../../../src/components/hooks/usePositionedFloaters.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ninterface positionProps {\n style: {\n style: {\n inset: string;\n };\n };\n buttonStyle: {\n buttonStyle: {\n width: string;\n };\n };\n status: boolean;\n}\n\ninterface optionProps {\n mouseEvent: 'click' | 'hover';\n position: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';\n offset: number;\n maxFixedHeight?: `${number}${'px' | 'rem'}`;\n horizontalPosition?: 'left' | 'right';\n}\n\nconst BODY_PADDING = 10;\nconst MIN_HEIGHT = 80;\nconst MIN_WIDTH = 220;\n\nexport function usePositionedFloaters<T extends HTMLElement = HTMLElement>(\n positionedElement: T | null,\n referenceElement: T | null,\n options: optionProps\n): positionProps {\n const [status, setStatus] = useState(false);\n const defaultStyle = {\n inset: '0 auto auto 0',\n opacity: 0,\n maxHeight: '100%',\n maxWidth: '100%',\n overflowX: 'hidden',\n overflowY: 'auto',\n margin: '0rem',\n };\n\n const [style, setStyle] = useState(defaultStyle);\n const [buttonStyle, setButtonStyle] = useState({ width: 'auto' });\n\n const sizeToPx = (size: `${number}${'px' | 'rem'}`): number => {\n const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);\n return size.indexOf('rem') !== -1 ? parseFloat(size) * rootFontSize : parseFloat(size);\n };\n\n const setHeight = (refRect: DOMRect, pos: string): number => {\n if (!refRect) return 0;\n\n const _maxHeight =\n pos === 'bottom'\n ? window.innerHeight - refRect.bottom - options.offset - BODY_PADDING\n : refRect.top - options.offset - BODY_PADDING;\n\n return !options.maxFixedHeight || sizeToPx(options.maxFixedHeight) > _maxHeight\n ? _maxHeight\n : sizeToPx(options.maxFixedHeight);\n };\n\n const setWidth = (refRect: DOMRect, pos: string): number => {\n if (!refRect) return 0;\n\n const _availableWidth =\n pos === 'left' ? window.innerWidth - refRect.left - BODY_PADDING : refRect.right - BODY_PADDING;\n\n return _availableWidth <= MIN_WIDTH ? MIN_WIDTH : _availableWidth;\n };\n\n const calcPosition = (): typeof defaultStyle => {\n const positionedRect = (positionedElement as HTMLElement | null)?.getBoundingClientRect();\n const referenceRect = (referenceElement as HTMLElement | null)?.getBoundingClientRect();\n let yPos = 'bottom';\n let xPos = 'left';\n\n if (!referenceRect || !positionedRect) {\n return defaultStyle;\n }\n\n setButtonStyle({ width: positionedRect.width + 'px' });\n\n if (window.innerHeight - referenceRect.bottom - BODY_PADDING < MIN_HEIGHT) {\n yPos = 'top';\n }\n\n if (window.innerWidth - referenceRect.left - BODY_PADDING < MIN_WIDTH || options.horizontalPosition === 'right') {\n xPos = 'right';\n }\n\n return {\n inset: `${yPos === 'bottom' ? referenceRect[yPos] + 'px' : 'auto'}\n ${xPos === 'right' ? window.innerWidth - referenceRect[xPos] + 'px' : 'auto'}\n ${yPos === 'top' ? window.innerHeight - referenceRect[yPos] + 'px' : 'auto'}\n ${xPos === 'left' ? referenceRect[xPos] + 'px' : 'auto'}`,\n maxHeight: `${setHeight(referenceRect, yPos)}px`,\n maxWidth: `${setWidth(referenceRect, xPos)}px`,\n overflowX: 'hidden',\n overflowY: 'auto',\n opacity: 1,\n margin: `${options.offset}px 0`,\n };\n };\n\n const handleMouseEvent = (): void => {\n setStyle({\n ...style,\n ...calcPosition(),\n });\n setStatus(true);\n };\n\n const updatePosition = (): void => {\n if (status) {\n setStyle({\n ...style,\n ...calcPosition(),\n });\n }\n };\n\n const handleClickOutside = (evt: Event): void => {\n if (\n !referenceElement ||\n (referenceElement as unknown as HTMLElement).contains(evt.target as Node) ||\n !positionedElement ||\n (positionedElement as unknown as HTMLElement).contains(evt.target as Node)\n ) {\n return;\n }\n };\n\n useEffect(() => {\n if (referenceElement !== null) {\n if (options.mouseEvent === 'click') {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('click', handleMouseEvent);\n } else {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('mouseenter', handleMouseEvent);\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('mouseleave', handleClickOutside);\n }\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('touchstart', handleClickOutside);\n window.addEventListener('resize', updatePosition);\n }\n\n return () => {\n if (referenceElement !== null) {\n if (options.mouseEvent === 'click') {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('click', handleMouseEvent);\n } else {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('mouseenter', handleMouseEvent);\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('mouseleave', handleClickOutside);\n }\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('touchstart', handleClickOutside);\n window.removeEventListener('resize', updatePosition);\n }\n };\n });\n\n return {\n style: {\n style,\n },\n buttonStyle: {\n buttonStyle,\n },\n status,\n };\n}\n"],"names":["BODY_PADDING","MIN_HEIGHT","MIN_WIDTH","usePositionedFloaters","positionedElement","referenceElement","options","status","setStatus","useState","defaultStyle","style","setStyle","buttonStyle","setButtonStyle","sizeToPx","size","rootFontSize","setHeight","refRect","pos","_maxHeight","setWidth","_availableWidth","calcPosition","positionedRect","referenceRect","yPos","xPos","handleMouseEvent","updatePosition","handleClickOutside","evt","useEffect"],"mappings":";AAwBA,MAAMA,IAAe,IACfC,IAAa,IACbC,IAAY;AAEF,SAAAC,EACdC,GACAC,GACAC,GACe;AACf,QAAM,CAACC,GAAQC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D,OAAA,iBAAiB,UAAUD,CAAc,IAG3C,MAAM;AACX,IAAIzB,MAAqB,SACnBC,EAAQ,eAAe,UAExBD,EAA4C,oBAAoB,SAASwB,CAAgB,KAGzFxB,EAA4C,oBAAoB,cAAcwB,CAAgB,GAE9FxB,EAA4C,oBAAoB,cAAc0B,CAAkB,IAE1F,SAAA,oBAAoB,aAAaA,CAAkB,GACnD,SAAA,oBAAoB,cAAcA,CAAkB,GACtD,OAAA,oBAAoB,UAAUD,CAAc;AAAA,EACrD,EAEH,GAEM;AAAA,IACL,OAAO;AAAA,MACL,OAAAnB;AAAA,IACF;AAAA,IACA,aAAa;AAAA,MACX,aAAAE;AAAA,IACF;AAAA,IACA,QAAAN;AAAA,EAAA;AAEJ;"}
|
|
@@ -3,15 +3,15 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState as i } from "react";
|
|
4
4
|
const C = {
|
|
5
5
|
"clipboard-button": "_clipboard-button_1ihmb_1"
|
|
6
|
-
}, n = 2e3,
|
|
7
|
-
const [
|
|
6
|
+
}, n = 2e3, a = ({ text: o }) => {
|
|
7
|
+
const [l, t] = i(!1);
|
|
8
8
|
return /* @__PURE__ */ e("div", { style: { position: "relative" }, children: /* @__PURE__ */ e("button", { onClick: () => {
|
|
9
|
-
|
|
9
|
+
l || navigator.clipboard.writeText(o).then(() => {
|
|
10
10
|
t(!0), setTimeout(() => {
|
|
11
11
|
t(!1);
|
|
12
12
|
}, n);
|
|
13
13
|
});
|
|
14
|
-
}, className: C["clipboard-button"], children: /* @__PURE__ */ e(
|
|
14
|
+
}, className: C["clipboard-button"], "aria-label": `Copy ${o}`, children: /* @__PURE__ */ e(
|
|
15
15
|
"svg",
|
|
16
16
|
{
|
|
17
17
|
width: "15",
|
|
@@ -20,7 +20,7 @@ const C = {
|
|
|
20
20
|
fill: "none",
|
|
21
21
|
xmlns: "http://www.w3.org/2000/svg",
|
|
22
22
|
className: "h-3 w-3",
|
|
23
|
-
children:
|
|
23
|
+
children: l ? /* @__PURE__ */ e(
|
|
24
24
|
"path",
|
|
25
25
|
{
|
|
26
26
|
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
@@ -41,6 +41,6 @@ const C = {
|
|
|
41
41
|
) }) });
|
|
42
42
|
};
|
|
43
43
|
export {
|
|
44
|
-
|
|
44
|
+
a as ClipboardButton
|
|
45
45
|
};
|
|
46
46
|
//# sourceMappingURL=ClipboardButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipboardButton.js","sources":["../../../../src/components/storyComponents/ClipboardButton/ClipboardButton.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport styles from './ClipboardButton.module.css';\n\ninterface ClipboardButtonProps {\n text: string;\n}\n\nconst DELAY = 2000;\n\nexport const ClipboardButton = ({ text }: ClipboardButtonProps) => {\n const [isCopied, setIsCopied] = useState(false);\n\n const handleCopyClick = () => {\n if (!isCopied) {\n void navigator.clipboard.writeText(text).then(() => {\n setIsCopied(true);\n setTimeout(() => {\n setIsCopied(false);\n }, DELAY);\n });\n }\n };\n\n return (\n <div style={{ position: 'relative' }}>\n <button onClick={handleCopyClick} className={styles['clipboard-button']}>\n <svg\n width=\"15\"\n height=\"15\"\n viewBox=\"0 0 15 15\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-3 w-3\"\n >\n {isCopied ? (\n <path\n d=\"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n ) : (\n <path\n d=\"M1 9.50006C1 10.3285 1.67157 11.0001 2.5 11.0001H4L4 10.0001H2.5C2.22386 10.0001 2 9.7762 2 9.50006L2 2.50006C2 2.22392 2.22386 2.00006 2.5 2.00006L9.5 2.00006C9.77614 2.00006 10 2.22392 10 2.50006V4.00002H5.5C4.67158 4.00002 4 4.67159 4 5.50002V12.5C4 13.3284 4.67158 14 5.5 14H12.5C13.3284 14 14 13.3284 14 12.5V5.50002C14 4.67159 13.3284 4.00002 12.5 4.00002H11V2.50006C11 1.67163 10.3284 1.00006 9.5 1.00006H2.5C1.67157 1.00006 1 1.67163 1 2.50006V9.50006ZM5 5.50002C5 5.22388 5.22386 5.00002 5.5 5.00002H12.5C12.7761 5.00002 13 5.22388 13 5.50002V12.5C13 12.7762 12.7761 13 12.5 13H5.5C5.22386 13 5 12.7762 5 12.5V5.50002Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n )}\n </svg>\n </button>\n </div>\n );\n};\n"],"names":["DELAY","ClipboardButton","text","isCopied","setIsCopied","useState","jsx","styles"],"mappings":";;;;GAQMA,IAAQ,KAEDC,IAAkB,CAAC,EAAE,MAAAC,QAAiC;AACjE,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK;AAa9C,
|
|
1
|
+
{"version":3,"file":"ClipboardButton.js","sources":["../../../../src/components/storyComponents/ClipboardButton/ClipboardButton.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport styles from './ClipboardButton.module.css';\n\ninterface ClipboardButtonProps {\n text: string;\n}\n\nconst DELAY = 2000;\n\nexport const ClipboardButton = ({ text }: ClipboardButtonProps) => {\n const [isCopied, setIsCopied] = useState(false);\n\n const handleCopyClick = () => {\n if (!isCopied) {\n void navigator.clipboard.writeText(text).then(() => {\n setIsCopied(true);\n setTimeout(() => {\n setIsCopied(false);\n }, DELAY);\n });\n }\n };\n\n return (\n <div style={{ position: 'relative' }}>\n <button onClick={handleCopyClick} className={styles['clipboard-button']} aria-label={`Copy ${text}`}>\n <svg\n width=\"15\"\n height=\"15\"\n viewBox=\"0 0 15 15\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-3 w-3\"\n >\n {isCopied ? (\n <path\n d=\"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n ) : (\n <path\n d=\"M1 9.50006C1 10.3285 1.67157 11.0001 2.5 11.0001H4L4 10.0001H2.5C2.22386 10.0001 2 9.7762 2 9.50006L2 2.50006C2 2.22392 2.22386 2.00006 2.5 2.00006L9.5 2.00006C9.77614 2.00006 10 2.22392 10 2.50006V4.00002H5.5C4.67158 4.00002 4 4.67159 4 5.50002V12.5C4 13.3284 4.67158 14 5.5 14H12.5C13.3284 14 14 13.3284 14 12.5V5.50002C14 4.67159 13.3284 4.00002 12.5 4.00002H11V2.50006C11 1.67163 10.3284 1.00006 9.5 1.00006H2.5C1.67157 1.00006 1 1.67163 1 2.50006V9.50006ZM5 5.50002C5 5.22388 5.22386 5.00002 5.5 5.00002H12.5C12.7761 5.00002 13 5.22388 13 5.50002V12.5C13 12.7762 12.7761 13 12.5 13H5.5C5.22386 13 5 12.7762 5 12.5V5.50002Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n )}\n </svg>\n </button>\n </div>\n );\n};\n"],"names":["DELAY","ClipboardButton","text","isCopied","setIsCopied","useState","jsx","styles"],"mappings":";;;;GAQMA,IAAQ,KAEDC,IAAkB,CAAC,EAAE,MAAAC,QAAiC;AACjE,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK;AAa9C,2BACG,OAAI,EAAA,OAAO,EAAE,UAAU,cACtB,UAAC,gBAAAC,EAAA,UAAA,EAAO,SAbY,MAAM;AAC5B,IAAKH,KACE,UAAU,UAAU,UAAUD,CAAI,EAAE,KAAK,MAAM;AAClD,MAAAE,EAAY,EAAI,GAChB,WAAW,MAAM;AACf,QAAAA,EAAY,EAAK;AAAA,SAChBJ,CAAK;AAAA,IAAA,CACT;AAAA,EACH,GAKoC,WAAWO,EAAO,kBAAkB,GAAG,cAAY,QAAQL,CAAI,IAC/F,UAAA,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAM;AAAA,MACN,QAAO;AAAA,MACP,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAM;AAAA,MACN,WAAU;AAAA,MAET,UACCH,IAAA,gBAAAG;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,GAAE;AAAA,UACF,MAAK;AAAA,UACL,UAAS;AAAA,UACT,UAAS;AAAA,QAAA;AAAA,MAAA,IAGX,gBAAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,GAAE;AAAA,UACF,MAAK;AAAA,UACL,UAAS;AAAA,UACT,UAAS;AAAA,QAAA;AAAA,MACX;AAAA,IAAA;AAAA,EAAA,EAGN,CAAA,EACF,CAAA;AAEJ;"}
|