@solibo/solibo-ui 1.0.12 → 1.0.14
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/assets/index.css +1 -1
- package/dist/assets/index12.css +1 -1
- package/dist/assets/index15.css +1 -1
- package/dist/assets/index17.css +1 -1
- package/dist/assets/index20.css +1 -1
- package/dist/assets/index34.css +1 -1
- package/dist/assets/index41.css +1 -1
- package/dist/assets/index47.css +1 -1
- package/dist/assets/index51.css +1 -1
- package/dist/assets/index6.css +1 -1
- package/dist/components/checkbox/index.cjs +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/chip/index.cjs +1 -1
- package/dist/components/chip/index.cjs.map +1 -1
- package/dist/components/chip/index.js +30 -16
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/dropdown/index.cjs +1 -1
- package/dist/components/dropdown/index.js +3 -3
- package/dist/components/editor/index.cjs +1 -1
- package/dist/components/editor/index.js +1 -1
- package/dist/components/header/index.cjs +1 -1
- package/dist/components/header/index.js +12 -12
- package/dist/components/icon/index.cjs +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/menu/index.cjs +1 -1
- package/dist/components/menu/index.cjs.map +1 -1
- package/dist/components/menu/index.js +56 -52
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/message/index.cjs +1 -1
- package/dist/components/message/index.cjs.map +1 -1
- package/dist/components/message/index.js +25 -25
- package/dist/components/nav/index.cjs +1 -1
- package/dist/components/nav/index.js +25 -25
- package/dist/components/popover/index.cjs +1 -1
- package/dist/components/popover/index.cjs.map +1 -1
- package/dist/components/popover/index.js +21 -21
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/search/index.cjs +1 -1
- package/dist/components/search/index.cjs.map +1 -1
- package/dist/components/search/index.js +14 -14
- package/dist/components/search/index.js.map +1 -1
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +2 -2
- package/dist/{icons-BIi_mYLy.js → icons-Bq3diTRm.js} +8 -2
- package/dist/icons-Bq3diTRm.js.map +1 -0
- package/dist/icons-ovA21Oao.cjs +2 -0
- package/dist/icons-ovA21Oao.cjs.map +1 -0
- package/dist/{index-CWD8Jp0A.cjs → index-BcY9DZZ8.cjs} +2 -2
- package/dist/{index-CWD8Jp0A.cjs.map → index-BcY9DZZ8.cjs.map} +1 -1
- package/dist/{index-DVXi-Ryi.cjs → index-CjI8oRpS.cjs} +2 -2
- package/dist/{index-DVXi-Ryi.cjs.map → index-CjI8oRpS.cjs.map} +1 -1
- package/dist/{index-yIe5PqD1.js → index-ClZkChEh.js} +2 -2
- package/dist/{index-yIe5PqD1.js.map → index-ClZkChEh.js.map} +1 -1
- package/dist/{index-Clex8VE6.js → index-DwzLUapm.js} +2 -2
- package/dist/{index-Clex8VE6.js.map → index-DwzLUapm.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +2 -2
- package/dist/tokens.json +1 -1
- package/package.json +1 -1
- package/dist/icons-BIi_mYLy.js.map +0 -1
- package/dist/icons-CR-eUx2p.cjs +0 -2
- package/dist/icons-CR-eUx2p.cjs.map +0 -1
|
@@ -1,56 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s, jsxs as v } from "react/jsx-runtime";
|
|
2
2
|
import { t as x } from "../../classix-DG18itHa.js";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Button as
|
|
3
|
+
import { useRef as D, useCallback as _, useEffect as b } from "react";
|
|
4
|
+
import { Button as w } from "../button/index.js";
|
|
5
5
|
import { Icon as m } from "../icon/index.js";
|
|
6
|
-
import { List as
|
|
6
|
+
import { List as y } from "../list/index.js";
|
|
7
7
|
import { Popover as k } from "../popover/index.js";
|
|
8
|
-
import '../../assets/index16.css';const z = "_list_z7awx_3",
|
|
8
|
+
import '../../assets/index16.css';const z = "_list_z7awx_3", B = "_item_z7awx_15", A = "_active_z7awx_38", N = "_danger_z7awx_47", d = {
|
|
9
9
|
list: z,
|
|
10
|
-
item:
|
|
11
|
-
active:
|
|
12
|
-
danger:
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
menuAccessibleLabel: u,
|
|
17
|
-
onKeyDown: l,
|
|
18
|
-
onSelect: c,
|
|
19
|
-
usesMenuSemantics: i = !1
|
|
20
|
-
}) => /* @__PURE__ */ a(D, { "aria-label": u, className: d.list, onKeyDown: l, role: i ? "menu" : void 0, "data-component": "menulist", children: o.map((e, t) => /* @__PURE__ */ a("li", { role: i ? "none" : void 0, children: /* @__PURE__ */ v(y, { "aria-current": e.isActive ? "true" : void 0, "aria-label": e.accessibleLabel, className: x(d.item, e.isActive && d.active, e.isDanger && d.danger), disabled: e.disabled, onClick: () => c(e), ref: (f) => {
|
|
21
|
-
s && (s.current[t] = f);
|
|
22
|
-
}, role: i ? "menuitem" : void 0, variant: "tertiary", children: [
|
|
23
|
-
e.icon && /* @__PURE__ */ a(m, { fill: !0, gap: "right", name: e.icon, size: "small" }),
|
|
24
|
-
/* @__PURE__ */ a("span", { children: e.label })
|
|
25
|
-
] }) }, e.id ?? t)) });
|
|
26
|
-
function E(s) {
|
|
27
|
-
return s.filter((o) => !!(o && !o.disabled));
|
|
10
|
+
item: B,
|
|
11
|
+
active: A,
|
|
12
|
+
danger: N
|
|
13
|
+
};
|
|
14
|
+
function C(t) {
|
|
15
|
+
return [...t].sort((r, l) => +!!r.isDanger - +!!l.isDanger);
|
|
28
16
|
}
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
items: u,
|
|
17
|
+
const g = ({
|
|
18
|
+
itemRefs: t,
|
|
19
|
+
items: r,
|
|
33
20
|
menuAccessibleLabel: l,
|
|
34
|
-
|
|
21
|
+
onKeyDown: i,
|
|
22
|
+
onSelect: u,
|
|
23
|
+
usesMenuSemantics: c = !1
|
|
24
|
+
}) => /* @__PURE__ */ s(y, { "aria-label": l, className: d.list, onKeyDown: i, role: c ? "menu" : void 0, "data-component": "menulist", children: C(r).map((e, a) => /* @__PURE__ */ s("li", { role: c ? "none" : void 0, children: /* @__PURE__ */ v(w, { "aria-current": e.isActive ? "true" : void 0, "aria-label": e.accessibleLabel, className: x(d.item, e.isActive && d.active, e.isDanger && d.danger), disabled: e.disabled, onClick: () => u(e), ref: (f) => {
|
|
25
|
+
t && (t.current[a] = f);
|
|
26
|
+
}, role: c ? "menuitem" : void 0, variant: "tertiary", children: [
|
|
27
|
+
e.icon && /* @__PURE__ */ s(m, { fill: !0, gap: "right", name: e.icon, size: "small" }),
|
|
28
|
+
/* @__PURE__ */ s("span", { children: e.label })
|
|
29
|
+
] }) }, e.id ?? a)) });
|
|
30
|
+
function E(t) {
|
|
31
|
+
return t.filter((r) => !!(r && !r.disabled));
|
|
32
|
+
}
|
|
33
|
+
const K = ({
|
|
34
|
+
close: t,
|
|
35
|
+
initialFocus: r,
|
|
36
|
+
items: l,
|
|
37
|
+
menuAccessibleLabel: i,
|
|
38
|
+
onItemSelect: u
|
|
35
39
|
}) => {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
40
|
+
const c = D([]), e = _((n) => {
|
|
41
|
+
const o = E(c.current);
|
|
42
|
+
if (o.length === 0)
|
|
39
43
|
return;
|
|
40
44
|
if (n === "first") {
|
|
41
|
-
|
|
45
|
+
o[0].focus();
|
|
42
46
|
return;
|
|
43
47
|
}
|
|
44
48
|
if (n === "last") {
|
|
45
|
-
|
|
49
|
+
o[o.length - 1].focus();
|
|
46
50
|
return;
|
|
47
51
|
}
|
|
48
|
-
const p =
|
|
49
|
-
|
|
52
|
+
const p = o.indexOf(document.activeElement), h = n === "next" ? (p + 1) % o.length : (p - 1 + o.length) % o.length;
|
|
53
|
+
o[h].focus();
|
|
50
54
|
}, []);
|
|
51
55
|
return b(() => {
|
|
52
|
-
e(
|
|
53
|
-
}, [e,
|
|
56
|
+
e(r ?? "first");
|
|
57
|
+
}, [e, r]), /* @__PURE__ */ s(g, { itemRefs: c, items: l, menuAccessibleLabel: i, onKeyDown: (n) => {
|
|
54
58
|
if (n.key === "ArrowDown") {
|
|
55
59
|
n.preventDefault(), e("next");
|
|
56
60
|
return;
|
|
@@ -65,24 +69,24 @@ const K = ({
|
|
|
65
69
|
}
|
|
66
70
|
n.key === "End" && (n.preventDefault(), e("last"));
|
|
67
71
|
}, onSelect: (n) => {
|
|
68
|
-
var
|
|
69
|
-
(
|
|
72
|
+
var o;
|
|
73
|
+
(o = n.onSelect) == null || o.call(n), u == null || u(n), t();
|
|
70
74
|
}, usesMenuSemantics: !0, "data-component": "menupanel" });
|
|
71
|
-
},
|
|
72
|
-
inline:
|
|
73
|
-
items:
|
|
74
|
-
menuAccessibleLabel:
|
|
75
|
-
onItemSelect:
|
|
76
|
-
triggerAccessibleLabel:
|
|
77
|
-
variant:
|
|
78
|
-
}) =>
|
|
75
|
+
}, R = ({
|
|
76
|
+
inline: t = !1,
|
|
77
|
+
items: r,
|
|
78
|
+
menuAccessibleLabel: l = "Menu",
|
|
79
|
+
onItemSelect: i,
|
|
80
|
+
triggerAccessibleLabel: u = "Open menu",
|
|
81
|
+
variant: c = "popover"
|
|
82
|
+
}) => c === "simple" ? /* @__PURE__ */ s(g, { items: r, menuAccessibleLabel: l, onSelect: (a) => {
|
|
79
83
|
var f;
|
|
80
|
-
(f =
|
|
81
|
-
}, "data-component": "menu" }) : /* @__PURE__ */
|
|
84
|
+
(f = a.onSelect) == null || f.call(a), i == null || i(a);
|
|
85
|
+
}, "data-component": "menu" }) : /* @__PURE__ */ s(k, { inline: t, triggerAccessibleLabel: u, triggerAriaHasPopup: "menu", triggerButtonContent: /* @__PURE__ */ s(m, { name: "dots", size: "medium" }), "data-component": "menu", children: ({
|
|
82
86
|
close: e,
|
|
83
|
-
initialFocus:
|
|
84
|
-
}) => /* @__PURE__ */
|
|
87
|
+
initialFocus: a
|
|
88
|
+
}) => /* @__PURE__ */ s(K, { close: e, initialFocus: a, items: r, menuAccessibleLabel: l, onItemSelect: i }) });
|
|
85
89
|
export {
|
|
86
|
-
|
|
90
|
+
R as Menu
|
|
87
91
|
};
|
|
88
92
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/menu/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useCallback, useEffect, useRef } from 'react';\n\nimport { Button } from '@/components/button';\nimport { Icon } from '@/components/icon';\nimport { type IconName } from '@/components/icon/icons';\nimport { List } from '@/components/list';\nimport { Popover, type PopoverInitialFocus, type PopoverRenderProps } from '@/components/popover';\n\nimport styles from './styles.module.css';\n\nexport type MenuItem = {\n accessibleLabel?: string;\n disabled?: boolean;\n icon?: IconName;\n id?: string;\n isActive?: boolean;\n isDanger?: boolean;\n label: React.ReactNode;\n onSelect?: () => void;\n};\n\ntype MenuSharedProps = {\n items: MenuItem[];\n menuAccessibleLabel?: string;\n onItemSelect?: (item: MenuItem) => void;\n};\n\ntype PopoverMenuProps = {\n inline?: boolean;\n triggerAccessibleLabel?: string;\n variant?: 'popover';\n};\n\ntype SimpleMenuProps = {\n inline?: never;\n triggerAccessibleLabel?: never;\n variant: 'simple';\n};\n\nexport type MenuProps = MenuSharedProps & (PopoverMenuProps | SimpleMenuProps);\n\ntype MenuFocusTarget = 'first' | 'last' | 'next' | 'previous';\n\ntype MenuListProps = Pick<MenuSharedProps, 'items' | 'menuAccessibleLabel'> & {\n itemRefs?: React.RefObject<Array<HTMLButtonElement | null>>;\n onKeyDown?: React.KeyboardEventHandler<HTMLUListElement>;\n onSelect: (item: MenuItem) => void;\n usesMenuSemantics?: boolean;\n};\n\ntype MenuPanelProps = MenuSharedProps & {\n close: PopoverRenderProps['close'];\n initialFocus?: PopoverInitialFocus;\n};\n\nconst MenuList = ({\n itemRefs,\n items,\n menuAccessibleLabel,\n onKeyDown,\n onSelect,\n usesMenuSemantics = false,\n}: MenuListProps) => (\n <List\n aria-label={menuAccessibleLabel}\n className={styles.list}\n onKeyDown={onKeyDown}\n role={usesMenuSemantics ? 'menu' : undefined}\n >\n {items.map((item, index) => (\n <li\n key={item.id ?? index}\n role={usesMenuSemantics ? 'none' : undefined}\n >\n <Button\n aria-current={item.isActive ? 'true' : undefined}\n aria-label={item.accessibleLabel}\n className={cx(\n styles.item,\n item.isActive && styles.active,\n item.isDanger && styles.danger\n )}\n disabled={item.disabled}\n onClick={() => onSelect(item)}\n ref={(node) => {\n if (itemRefs) itemRefs.current[index] = node;\n }}\n role={usesMenuSemantics ? 'menuitem' : undefined}\n variant='tertiary'\n >\n {item.icon && (\n <Icon\n fill\n gap='right'\n name={item.icon}\n size='small'\n />\n )}\n <span>{item.label}</span>\n </Button>\n </li>\n ))}\n </List>\n);\n\nfunction getFocusableItems(items: Array<HTMLButtonElement | null>) {\n return items.filter((item): item is HTMLButtonElement => Boolean(item && !item.disabled));\n}\n\nconst MenuPanel = ({\n close,\n initialFocus,\n items,\n menuAccessibleLabel,\n onItemSelect,\n}: MenuPanelProps) => {\n const itemRefs = useRef<Array<HTMLButtonElement | null>>([]);\n\n const focusItem = useCallback((target: MenuFocusTarget) => {\n const focusableItems = getFocusableItems(itemRefs.current);\n\n if (focusableItems.length === 0) {\n return;\n }\n\n if (target === 'first') {\n focusableItems[0].focus();\n return;\n }\n\n if (target === 'last') {\n focusableItems[focusableItems.length - 1].focus();\n return;\n }\n\n const currentIndex = focusableItems.indexOf(document.activeElement as HTMLButtonElement);\n const nextIndex =\n target === 'next'\n ? (currentIndex + 1) % focusableItems.length\n : (currentIndex - 1 + focusableItems.length) % focusableItems.length;\n\n focusableItems[nextIndex].focus();\n }, []);\n\n useEffect(() => {\n focusItem(initialFocus ?? 'first');\n }, [focusItem, initialFocus]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusItem('next');\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusItem('previous');\n return;\n }\n\n if (event.key === 'Home') {\n event.preventDefault();\n focusItem('first');\n return;\n }\n\n if (event.key === 'End') {\n event.preventDefault();\n focusItem('last');\n }\n };\n\n const handleItemSelect = (item: MenuItem) => {\n item.onSelect?.();\n onItemSelect?.(item);\n close();\n };\n\n return (\n <MenuList\n itemRefs={itemRefs}\n items={items}\n menuAccessibleLabel={menuAccessibleLabel}\n onKeyDown={handleKeyDown}\n onSelect={handleItemSelect}\n usesMenuSemantics\n />\n );\n};\n\nexport const Menu = ({\n inline = false,\n items,\n menuAccessibleLabel = 'Menu',\n onItemSelect,\n triggerAccessibleLabel = 'Open menu',\n variant = 'popover',\n}: MenuProps) => {\n if (variant === 'simple') {\n const handleItemSelect = (item: MenuItem) => {\n item.onSelect?.();\n onItemSelect?.(item);\n };\n\n return (\n <MenuList\n items={items}\n menuAccessibleLabel={menuAccessibleLabel}\n onSelect={handleItemSelect}\n />\n );\n }\n\n return (\n <Popover\n inline={inline}\n triggerAccessibleLabel={triggerAccessibleLabel}\n triggerAriaHasPopup='menu'\n triggerButtonContent={\n <Icon\n name='dots'\n size='medium'\n />\n }\n >\n {({ close, initialFocus }) => (\n <MenuPanel\n close={close}\n initialFocus={initialFocus}\n items={items}\n menuAccessibleLabel={menuAccessibleLabel}\n onItemSelect={onItemSelect}\n />\n )}\n </Popover>\n );\n};\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/menu/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useCallback, useEffect, useRef } from 'react';\n\nimport { Button } from '@/components/button';\nimport { Icon } from '@/components/icon';\nimport { type IconName } from '@/components/icon/icons';\nimport { List } from '@/components/list';\nimport { Popover, type PopoverInitialFocus, type PopoverRenderProps } from '@/components/popover';\n\nimport styles from './styles.module.css';\n\nexport type MenuItem = {\n accessibleLabel?: string;\n disabled?: boolean;\n icon?: IconName;\n id?: string;\n isActive?: boolean;\n isDanger?: boolean;\n label: React.ReactNode;\n onSelect?: () => void;\n};\n\ntype MenuSharedProps = {\n items: MenuItem[];\n menuAccessibleLabel?: string;\n onItemSelect?: (item: MenuItem) => void;\n};\n\ntype PopoverMenuProps = {\n inline?: boolean;\n triggerAccessibleLabel?: string;\n variant?: 'popover';\n};\n\ntype SimpleMenuProps = {\n inline?: never;\n triggerAccessibleLabel?: never;\n variant: 'simple';\n};\n\nexport type MenuProps = MenuSharedProps & (PopoverMenuProps | SimpleMenuProps);\n\ntype MenuFocusTarget = 'first' | 'last' | 'next' | 'previous';\n\ntype MenuListProps = Pick<MenuSharedProps, 'items' | 'menuAccessibleLabel'> & {\n itemRefs?: React.RefObject<Array<HTMLButtonElement | null>>;\n onKeyDown?: React.KeyboardEventHandler<HTMLUListElement>;\n onSelect: (item: MenuItem) => void;\n usesMenuSemantics?: boolean;\n};\n\ntype MenuPanelProps = MenuSharedProps & {\n close: PopoverRenderProps['close'];\n initialFocus?: PopoverInitialFocus;\n};\n\nfunction sortDangerItemsLast(items: MenuItem[]) {\n return [...items].sort(\n (left, right) => Number(Boolean(left.isDanger)) - Number(Boolean(right.isDanger))\n );\n}\n\nconst MenuList = ({\n itemRefs,\n items,\n menuAccessibleLabel,\n onKeyDown,\n onSelect,\n usesMenuSemantics = false,\n}: MenuListProps) => (\n <List\n aria-label={menuAccessibleLabel}\n className={styles.list}\n onKeyDown={onKeyDown}\n role={usesMenuSemantics ? 'menu' : undefined}\n >\n {sortDangerItemsLast(items).map((item, index) => (\n <li\n key={item.id ?? index}\n role={usesMenuSemantics ? 'none' : undefined}\n >\n <Button\n aria-current={item.isActive ? 'true' : undefined}\n aria-label={item.accessibleLabel}\n className={cx(\n styles.item,\n item.isActive && styles.active,\n item.isDanger && styles.danger\n )}\n disabled={item.disabled}\n onClick={() => onSelect(item)}\n ref={(node) => {\n if (itemRefs) itemRefs.current[index] = node;\n }}\n role={usesMenuSemantics ? 'menuitem' : undefined}\n variant='tertiary'\n >\n {item.icon && (\n <Icon\n fill\n gap='right'\n name={item.icon}\n size='small'\n />\n )}\n <span>{item.label}</span>\n </Button>\n </li>\n ))}\n </List>\n);\n\nfunction getFocusableItems(items: Array<HTMLButtonElement | null>) {\n return items.filter((item): item is HTMLButtonElement => Boolean(item && !item.disabled));\n}\n\nconst MenuPanel = ({\n close,\n initialFocus,\n items,\n menuAccessibleLabel,\n onItemSelect,\n}: MenuPanelProps) => {\n const itemRefs = useRef<Array<HTMLButtonElement | null>>([]);\n\n const focusItem = useCallback((target: MenuFocusTarget) => {\n const focusableItems = getFocusableItems(itemRefs.current);\n\n if (focusableItems.length === 0) {\n return;\n }\n\n if (target === 'first') {\n focusableItems[0].focus();\n return;\n }\n\n if (target === 'last') {\n focusableItems[focusableItems.length - 1].focus();\n return;\n }\n\n const currentIndex = focusableItems.indexOf(document.activeElement as HTMLButtonElement);\n const nextIndex =\n target === 'next'\n ? (currentIndex + 1) % focusableItems.length\n : (currentIndex - 1 + focusableItems.length) % focusableItems.length;\n\n focusableItems[nextIndex].focus();\n }, []);\n\n useEffect(() => {\n focusItem(initialFocus ?? 'first');\n }, [focusItem, initialFocus]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusItem('next');\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusItem('previous');\n return;\n }\n\n if (event.key === 'Home') {\n event.preventDefault();\n focusItem('first');\n return;\n }\n\n if (event.key === 'End') {\n event.preventDefault();\n focusItem('last');\n }\n };\n\n const handleItemSelect = (item: MenuItem) => {\n item.onSelect?.();\n onItemSelect?.(item);\n close();\n };\n\n return (\n <MenuList\n itemRefs={itemRefs}\n items={items}\n menuAccessibleLabel={menuAccessibleLabel}\n onKeyDown={handleKeyDown}\n onSelect={handleItemSelect}\n usesMenuSemantics\n />\n );\n};\n\nexport const Menu = ({\n inline = false,\n items,\n menuAccessibleLabel = 'Menu',\n onItemSelect,\n triggerAccessibleLabel = 'Open menu',\n variant = 'popover',\n}: MenuProps) => {\n if (variant === 'simple') {\n const handleItemSelect = (item: MenuItem) => {\n item.onSelect?.();\n onItemSelect?.(item);\n };\n\n return (\n <MenuList\n items={items}\n menuAccessibleLabel={menuAccessibleLabel}\n onSelect={handleItemSelect}\n />\n );\n }\n\n return (\n <Popover\n inline={inline}\n triggerAccessibleLabel={triggerAccessibleLabel}\n triggerAriaHasPopup='menu'\n triggerButtonContent={\n <Icon\n name='dots'\n size='medium'\n />\n }\n >\n {({ close, initialFocus }) => (\n <MenuPanel\n close={close}\n initialFocus={initialFocus}\n items={items}\n menuAccessibleLabel={menuAccessibleLabel}\n onItemSelect={onItemSelect}\n />\n )}\n </Popover>\n );\n};\n"],"names":["sortDangerItemsLast","items","sort","left","right","Number","Boolean","isDanger","MenuList","itemRefs","menuAccessibleLabel","onKeyDown","onSelect","usesMenuSemantics","jsx","List","styles","list","undefined","map","item","index","jsxs","Button","isActive","accessibleLabel","cx","active","danger","disabled","node","current","icon","Icon","label","id","getFocusableItems","filter","MenuPanel","close","initialFocus","onItemSelect","useRef","focusItem","useCallback","target","focusableItems","length","focus","currentIndex","indexOf","document","activeElement","nextIndex","useEffect","handleKeyDown","event","key","preventDefault","handleItemSelect","Menu","inline","triggerAccessibleLabel","variant","Popover"],"mappings":";;;;;;;;;;;;;AAwDA,SAASA,EAAoBC,GAAmB;AAC9C,SAAO,CAAC,GAAGA,CAAK,EAAEC,KAChB,CAACC,GAAMC,MAAUC,CAAOC,EAAQH,EAAKI,WAAaF,CAAOC,EAAQF,EAAMG,QACzE;AACF;AAEA,MAAMC,IAAWA,CAAC;AAAA,EAChBC,UAAAA;AAAAA,EACAR,OAAAA;AAAAA,EACAS,qBAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,mBAAAA,IAAoB;AACP,MACb,gBAAAC,EAACC,GAAA,EACC,cAAYL,GACZ,WAAWM,EAAOC,MAClB,WAAAN,GACA,MAAME,IAAoB,SAASK,QAAU,kBAAA,YAE5ClB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ACD,MACLA,MAAY,6BAOXvD,GAAA,EACC,OAAAP,GACA,qBAAAS,GACA,UATqBiD,CAACvC,MAAmB;;AAC3CA,GAAAA,IAAAA,EAAKR,aAALQ,QAAAA,EAAAA,KAAAA,IACAqB,KAAAA,QAAAA,EAAerB;AACjB,GAM+B,kBAAA,QAAA,sBAM9B4C,GAAA,EACC,QAAAH,GACA,wBAAAC,GACA,qBAAoB,QACpB,sBACE,gBAAAhD,EAACmB,GAAA,EACC,MAAK,QACL,MAAK,SAAA,IAER,kBAAA,QAEA,UAAA,CAAC;AAAA,EAAEM,OAAAA;AAAAA,EAAOC,cAAAA;AAAAA,wBACRF,GAAA,EACC,OAAAC,GACA,cAAAC,GACA,OAAAvC,GACA,qBAAAS,GACA,cAAA+B,GAA2B,GAGjC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index15.css');const e=require("react/jsx-runtime"),v=require("../../classix-5H4IWnMA.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index15.css');const e=require("react/jsx-runtime"),v=require("../../classix-5H4IWnMA.cjs"),x=require("../avatar/index.cjs"),j=require("../icon/index.cjs"),h="_message_fif28_1",w="_timestamp_fif28_95",S="_attachments_fif28_100",b="_preview_fif28_119",t={"message-group":"_message-group_fif28_1",message:h,timestamp:w,attachments:S,preview:b},q=({appearance:o="default",attachments:n,author:a,authorColor:r,authorImageUrl:l,authorRole:d,content:g,iconName:_="info",id:p,preview:f,timestamp:m,timestampText:u,type:s="default"})=>{const i=m?new Date(m):void 0,c=i?e.jsx("time",{className:t.timestamp,dateTime:i.toISOString(),children:u??i.toLocaleString()}):null;return e.jsxs("div",{className:t["message-group"],"data-message-type":s,"data-component":"message",children:[a&&e.jsx(x.Avatar,{accessibleLabel:a,color:r,imageUrl:l,name:a,role:d}),s==="system"&&c,e.jsxs("div",{className:v.t(t.message,f&&t.preview),"data-appearance":o,"data-id":p,"data-type":s,children:[s=="system"&&e.jsx(j.Icon,{fill:!0,gap:"right",name:_}),g]}),n&&e.jsx("div",{className:t.attachments,children:n}),s!=="system"&&c]})};exports.Message=q;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/message/index.tsx"],"sourcesContent":["import cx from 'classix';\n\nimport { IconName } from '@/components/icon/icons.ts';\n\nimport { Avatar, type AvatarColor } from '../avatar';\nimport { Icon } from '../icon';\nimport styles from './styles.module.css';\n\nexport type MessageOptions = {\n appearance?: 'default' | 'document' | 'file';\n attachments?: React.ReactNode;\n author?: string;\n authorColor?: AvatarColor;\n authorImageUrl?: string;\n authorRole?: string;\n content: React.ReactNode;\n iconName?: IconName;\n id: string;\n preview?: boolean;\n timestamp?: Date | string;\n timestampText?: React.ReactNode;\n type?: 'default' | 'minimal' | 'system' | 'user';\n};\n\nexport const Message = ({\n appearance = 'default',\n attachments,\n author,\n authorColor,\n authorImageUrl,\n authorRole,\n content,\n iconName = 'info',\n id,\n preview,\n timestamp,\n timestampText,\n type = 'default',\n}: MessageOptions) => {\n const date = timestamp ? new Date(timestamp) : undefined;\n const timestampElement = date ? (\n <time\n className={styles.timestamp}\n dateTime={date.toISOString()}\n >\n {timestampText ?? date.toLocaleString()}\n </time>\n ) : null;\n\n return (\n <div\n className={styles['message-group']}\n data-message-type={type}\n >\n {author && (\n <Avatar\n accessibleLabel={author}\n color={authorColor}\n imageUrl={authorImageUrl}\n name={author}\n role={authorRole}\n />\n )}\n {type === 'system' && timestampElement}\n <div\n className={cx(styles.message, preview && styles.preview)}\n data-appearance={appearance}\n data-id={id}\n data-type={type}\n >\n {type == 'system' && (\n <Icon\n fill\n gap='right'\n name={iconName}\n />\n )}\n {content}\n </div>\n {attachments && <div className={styles.attachments}>{attachments}</div>}\n {type !== 'system' && timestampElement}\n </div>\n );\n};\n"],"names":["Message","appearance","attachments","author","authorColor","authorImageUrl","authorRole","content","iconName","id","preview","timestamp","timestampText","type","date","Date","undefined","timestampElement","jsx","styles","toISOString","toLocaleString","jsxs","Avatar","cx","message","Icon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/message/index.tsx"],"sourcesContent":["import cx from 'classix';\n\nimport { IconName } from '@/components/icon/icons.ts';\n\nimport { Avatar, type AvatarColor } from '../avatar';\nimport { Icon } from '../icon';\nimport styles from './styles.module.css';\n\nexport type MessageOptions = {\n appearance?: 'default' | 'document' | 'file';\n attachments?: React.ReactNode;\n author?: string;\n authorColor?: AvatarColor;\n authorImageUrl?: string;\n authorRole?: string;\n content: React.ReactNode;\n iconName?: IconName;\n id: string;\n preview?: boolean;\n timestamp?: Date | string;\n timestampText?: React.ReactNode;\n type?: 'default' | 'minimal' | 'system' | 'user';\n};\n\nexport const Message = ({\n appearance = 'default',\n attachments,\n author,\n authorColor,\n authorImageUrl,\n authorRole,\n content,\n iconName = 'info',\n id,\n preview,\n timestamp,\n timestampText,\n type = 'default',\n}: MessageOptions) => {\n const date = timestamp ? new Date(timestamp) : undefined;\n const timestampElement = date ? (\n <time\n className={styles.timestamp}\n dateTime={date.toISOString()}\n >\n {timestampText ?? date.toLocaleString()}\n </time>\n ) : null;\n\n return (\n <div\n className={styles['message-group']}\n data-message-type={type}\n >\n {author && (\n <Avatar\n accessibleLabel={author}\n color={authorColor}\n imageUrl={authorImageUrl}\n name={author}\n role={authorRole}\n />\n )}\n {type === 'system' && timestampElement}\n <div\n className={cx(styles.message, preview && styles.preview)}\n data-appearance={appearance}\n data-id={id}\n data-type={type}\n >\n {type == 'system' && (\n <Icon\n fill\n gap='right'\n name={iconName}\n />\n )}\n {content}\n </div>\n {attachments && <div className={styles.attachments}>{attachments}</div>}\n {type !== 'system' && timestampElement}\n </div>\n );\n};\n"],"names":["Message","appearance","attachments","author","authorColor","authorImageUrl","authorRole","content","iconName","id","preview","timestamp","timestampText","type","date","Date","undefined","timestampElement","jsx","styles","toISOString","toLocaleString","jsxs","Avatar","cx","message","Icon"],"mappings":"uZAwBaA,EAAUA,CAAC,CACtBC,WAAAA,EAAa,UACbC,YAAAA,EACAC,OAAAA,EACAC,YAAAA,EACAC,eAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,SAAAA,EAAW,OACXC,GAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,cAAAA,EACAC,KAAAA,EAAO,SACO,IAAM,CACpB,MAAMC,EAAOH,EAAY,IAAII,KAAKJ,CAAS,EAAIK,OACzCC,EAAmBH,EACvBI,EAAAA,IAAC,OAAA,CACC,UAAWC,EAAOR,UAClB,SAAUG,EAAKM,cAEdR,SAAAA,GAAiBE,EAAKO,eAAAA,EACzB,EACE,KAEJ,OACEC,OAAC,OACC,UAAWH,EAAO,eAAe,EACjC,oBAAmBN,EAAK,iBAAA,UAEvBV,SAAAA,CAAAA,GACCe,EAAAA,IAACK,EAAAA,OAAA,CACC,gBAAiBpB,EACjB,MAAOC,EACP,SAAUC,EACV,KAAMF,EACN,KAAMG,CAAAA,CAAW,EAGpBO,IAAS,UAAYI,EACtBK,EAAAA,KAAC,MAAA,CACC,UAAWE,EAAAA,EAAGL,EAAOM,QAASf,GAAWS,EAAOT,OAAO,EACvD,kBAAiBT,EACjB,UAASQ,EACT,YAAWI,EAEVA,SAAAA,CAAAA,GAAQ,gBACNa,EAAAA,KAAA,CACC,KAAI,GACJ,IAAI,QACJ,KAAMlB,CAAAA,CAAS,EAGlBD,CAAAA,EACH,EACCL,GAAegB,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAOjB,YAAcA,SAAAA,EAAY,EAChEW,IAAS,UAAYI,CAAAA,EACxB,CAEJ"}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { t as
|
|
3
|
-
import { Avatar as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import '../../assets/index15.css';const
|
|
6
|
-
"message-group": "_message-
|
|
7
|
-
message:
|
|
1
|
+
import { jsx as a, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { t as u } from "../../classix-DG18itHa.js";
|
|
3
|
+
import { Avatar as w } from "../avatar/index.js";
|
|
4
|
+
import { Icon as N } from "../icon/index.js";
|
|
5
|
+
import '../../assets/index15.css';const x = "_message_fif28_1", S = "_timestamp_fif28_95", b = "_attachments_fif28_100", j = "_preview_fif28_119", s = {
|
|
6
|
+
"message-group": "_message-group_fif28_1",
|
|
7
|
+
message: x,
|
|
8
8
|
timestamp: S,
|
|
9
9
|
attachments: b,
|
|
10
10
|
preview: j
|
|
11
11
|
}, D = ({
|
|
12
12
|
appearance: c = "default",
|
|
13
|
-
attachments:
|
|
14
|
-
author:
|
|
13
|
+
attachments: i,
|
|
14
|
+
author: t,
|
|
15
15
|
authorColor: l,
|
|
16
16
|
authorImageUrl: d,
|
|
17
|
-
authorRole:
|
|
18
|
-
content:
|
|
19
|
-
iconName:
|
|
20
|
-
id:
|
|
21
|
-
preview:
|
|
22
|
-
timestamp:
|
|
23
|
-
timestampText:
|
|
17
|
+
authorRole: f,
|
|
18
|
+
content: g,
|
|
19
|
+
iconName: p = "info",
|
|
20
|
+
id: _,
|
|
21
|
+
preview: v,
|
|
22
|
+
timestamp: o,
|
|
23
|
+
timestampText: h,
|
|
24
24
|
type: e = "default"
|
|
25
25
|
}) => {
|
|
26
|
-
const m =
|
|
27
|
-
return /* @__PURE__ */ n("div", { className:
|
|
28
|
-
|
|
29
|
-
e === "system" &&
|
|
30
|
-
/* @__PURE__ */ n("div", { className:
|
|
31
|
-
e == "system" && /* @__PURE__ */
|
|
32
|
-
|
|
26
|
+
const m = o ? new Date(o) : void 0, r = m ? /* @__PURE__ */ a("time", { className: s.timestamp, dateTime: m.toISOString(), children: h ?? m.toLocaleString() }) : null;
|
|
27
|
+
return /* @__PURE__ */ n("div", { className: s["message-group"], "data-message-type": e, "data-component": "message", children: [
|
|
28
|
+
t && /* @__PURE__ */ a(w, { accessibleLabel: t, color: l, imageUrl: d, name: t, role: f }),
|
|
29
|
+
e === "system" && r,
|
|
30
|
+
/* @__PURE__ */ n("div", { className: u(s.message, v && s.preview), "data-appearance": c, "data-id": _, "data-type": e, children: [
|
|
31
|
+
e == "system" && /* @__PURE__ */ a(N, { fill: !0, gap: "right", name: p }),
|
|
32
|
+
g
|
|
33
33
|
] }),
|
|
34
|
-
|
|
35
|
-
e !== "system" &&
|
|
34
|
+
i && /* @__PURE__ */ a("div", { className: s.attachments, children: i }),
|
|
35
|
+
e !== "system" && r
|
|
36
36
|
] });
|
|
37
37
|
};
|
|
38
38
|
export {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index12.css');const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index12.css');const i=require("react/jsx-runtime"),r=require("../../classix-5H4IWnMA.cjs"),f=require("react"),p=require("../../icons-ovA21Oao.cjs"),v="_nav_afcql_3",q="_label_afcql_9",h="_horizontal_afcql_17",m="_sidebar_afcql_27",N="_tabs_afcql_73",g="_pills_afcql_93",a={nav:v,label:q,horizontal:h,sidebar:m,tabs:N,pills:g},w={default:a.default,pills:a.pills,sidebar:a.sidebar,tabs:a.tabs},x=({className:e,...n})=>i.jsx("span",{className:r.t(e,a.label),...n,"data-component":"navlabel"}),j=({animation:e,children:n,className:c,horizontal:l=!1,variant:s="default",...d})=>{const[b,o]=f.useState(!1),u={"--icon-svg":p.iconSVG("chevron")};return i.jsx("nav",{className:r.t(c,l&&a.horizontal,a.nav,w[s]),"data-animation":e,"data-open":b?"true":"false","data-orientation":l?"horizontal":"vertical",onBlurCapture:t=>{if(s!=="pills"||window.innerWidth>960)return;const _=t.relatedTarget;t.currentTarget.contains(_)||o(!1)},onClick:()=>{s!=="pills"||window.innerWidth>960||o(t=>!t)},style:u,...d,"data-component":"nav",children:n})};exports.Nav=j;exports.NavLabel=x;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { t as r } from "../../classix-DG18itHa.js";
|
|
3
|
-
import { useState as
|
|
4
|
-
import { i as
|
|
5
|
-
import '../../assets/index12.css';const
|
|
6
|
-
nav:
|
|
7
|
-
label:
|
|
8
|
-
horizontal:
|
|
9
|
-
sidebar:
|
|
10
|
-
tabs:
|
|
11
|
-
pills:
|
|
12
|
-
},
|
|
3
|
+
import { useState as b } from "react";
|
|
4
|
+
import { i as m } from "../../icons-Bq3diTRm.js";
|
|
5
|
+
import '../../assets/index12.css';const u = "_nav_afcql_3", v = "_label_afcql_9", h = "_horizontal_afcql_17", q = "_sidebar_afcql_27", w = "_tabs_afcql_73", z = "_pills_afcql_93", a = {
|
|
6
|
+
nav: u,
|
|
7
|
+
label: v,
|
|
8
|
+
horizontal: h,
|
|
9
|
+
sidebar: q,
|
|
10
|
+
tabs: w,
|
|
11
|
+
pills: z
|
|
12
|
+
}, N = {
|
|
13
13
|
default: a.default,
|
|
14
14
|
pills: a.pills,
|
|
15
15
|
sidebar: a.sidebar,
|
|
16
16
|
tabs: a.tabs
|
|
17
|
-
},
|
|
17
|
+
}, S = ({
|
|
18
18
|
className: n,
|
|
19
|
-
...
|
|
20
|
-
}) => /* @__PURE__ */
|
|
19
|
+
...l
|
|
20
|
+
}) => /* @__PURE__ */ i("span", { className: r(n, a.label), ...l, "data-component": "navlabel" }), T = ({
|
|
21
21
|
animation: n,
|
|
22
|
-
children:
|
|
22
|
+
children: l,
|
|
23
23
|
className: c,
|
|
24
24
|
horizontal: o = !1,
|
|
25
25
|
variant: s = "default",
|
|
26
|
-
...
|
|
26
|
+
...f
|
|
27
27
|
}) => {
|
|
28
|
-
const [
|
|
29
|
-
"--icon-svg":
|
|
28
|
+
const [p, e] = b(!1), d = {
|
|
29
|
+
"--icon-svg": m("chevron")
|
|
30
30
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ i("nav", { className: r(c, o && a.horizontal, a.nav, N[s]), "data-animation": n, "data-open": p ? "true" : "false", "data-orientation": o ? "horizontal" : "vertical", onBlurCapture: (t) => {
|
|
32
32
|
if (s !== "pills" || window.innerWidth > 960) return;
|
|
33
|
-
const
|
|
34
|
-
t.currentTarget.contains(
|
|
33
|
+
const _ = t.relatedTarget;
|
|
34
|
+
t.currentTarget.contains(_) || e(!1);
|
|
35
35
|
}, onClick: () => {
|
|
36
|
-
s !== "pills" || window.innerWidth > 960 ||
|
|
37
|
-
}, style:
|
|
36
|
+
s !== "pills" || window.innerWidth > 960 || e((t) => !t);
|
|
37
|
+
}, style: d, ...f, "data-component": "nav", children: l });
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
T as Nav,
|
|
41
|
+
S as NavLabel
|
|
42
42
|
};
|
|
43
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index17.css');const _=require("react/jsx-runtime"),j=require("../../classix-5H4IWnMA.cjs"),o=require("react"),S=require("react-dom"),I=require("../button/index.cjs"),K="
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index17.css');const _=require("react/jsx-runtime"),j=require("../../classix-5H4IWnMA.cjs"),o=require("react"),S=require("react-dom"),I=require("../button/index.cjs"),K="_popover_1e3fx_1",O="_inline_1e3fx_6",N="_below_1e3fx_42",H="_above_1e3fx_47",W="_left_1e3fx_57",M="_right_1e3fx_62",U="_trigger_1e3fx_67",s={popover:K,inline:O,"popover-panel":"_popover-panel_1e3fx_21",below:N,above:H,"inline-panel":"_inline-panel_1e3fx_52",left:W,right:M,trigger:U,"inline-trigger":"_inline-trigger_1e3fx_77"},X=({children:w,inline:n=!1,triggerAccessibleLabel:z,triggerAriaHasPopup:C,triggerButtonContent:b})=>{var B;const x=o.useRef(null),y=o.useRef(void 0),m=o.useRef(null),P=o.useId(),l=o.useRef(null),[t,R]=o.useState(!1),[p,D]=o.useState(!1),[d,k]=o.useState("right"),g=({initialFocus:e}={})=>{y.current=e,D(!1),k("right"),R(!0)},c=o.useCallback(({restoreFocus:e=!0}={})=>{var i;R(!1),e&&((i=l.current)==null||i.focus())},[]),L=e=>{t&&e.key==="Escape"&&c()},F=e=>{if(!t){if(n&&(e.key==="Enter"||e.key===" ")){e.preventDefault(),g();return}if(e.key==="ArrowDown"){e.preventDefault(),g({initialFocus:"first"});return}e.key==="ArrowUp"&&(e.preventDefault(),g({initialFocus:"last"}))}};o.useEffect(()=>{if(!t)return;const e=i=>{var r,v;const f=i.target;(r=x.current)!=null&&r.contains(f)||(v=m.current)!=null&&v.contains(f)||c({restoreFocus:!1})};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[c,t]);const a=o.useCallback(()=>{const e=m.current,i=l.current;if(!e||!i)return;const f=e.getBoundingClientRect(),r=i.getBoundingClientRect(),v=r.top,T=window.innerHeight-r.bottom;D(f.height>T&&v>T),k(f.width>window.innerWidth-r.left&&r.right>window.innerWidth-r.left?"left":"right")},[]);o.useLayoutEffect(()=>{if(t)return a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[t,a]);const q=e=>{e.preventDefault(),e.stopPropagation(),t?c({restoreFocus:!1}):g()},E={"aria-controls":t?P:void 0,"aria-expanded":t,"aria-haspopup":C,"aria-label":z,className:n?s["inline-trigger"]:s.trigger,onClick:q,onKeyDown:F},u=n?(B=l.current)==null?void 0:B.getBoundingClientRect():void 0,A=[d==="left"?"translateX(-100%)":"",p?"translateY(calc(-100% - var(--shape-spacing-2xs)))":""].filter(Boolean).join(" "),h=t?_.jsx("div",{className:j.t(s["popover-panel"],s[p?"above":"below"],n&&s["inline-panel"],!n&&s[d]),"data-horizontal-placement":d,"data-placement":p?"above":"below",id:P,ref:m,style:u?{left:d==="left"?u.right:u.left,position:"fixed",top:p?u.top:u.bottom,transform:A||void 0}:void 0,children:typeof w=="function"?w({close:c,initialFocus:y.current,isOpen:t}):w}):null;return _.jsxs("div",{className:j.t(s.popover,n&&s.inline),"data-open":t,onKeyDown:L,onClick:e=>{e.preventDefault(),e.stopPropagation()},ref:x,"data-component":"popover",children:[n?_.jsx("span",{...E,ref:l,role:"button",tabIndex:0,children:b}):_.jsx(I.Button,{...E,ref:l,variant:"simple",children:b}),n&&h&&typeof document<"u"?S.createPortal(h,document.body):h]})};exports.Popover=X;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/popover/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport {\n type AriaAttributes,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { Button } from '@/components/button';\n\nimport styles from './styles.module.css';\n\nexport type PopoverCloseOptions = {\n restoreFocus?: boolean;\n};\n\nexport type PopoverInitialFocus = 'first' | 'last';\n\nexport type PopoverRenderProps = {\n close: (options?: PopoverCloseOptions) => void;\n initialFocus?: PopoverInitialFocus;\n isOpen: boolean;\n};\n\ntype PopoverOpenOptions = {\n initialFocus?: PopoverInitialFocus;\n};\n\nexport type PopoverProps = {\n children: ReactNode | ((props: PopoverRenderProps) => ReactNode);\n inline?: boolean;\n triggerAccessibleLabel?: string;\n triggerAriaHasPopup?: AriaAttributes['aria-haspopup'];\n triggerButtonContent: ReactNode;\n};\n\nexport const Popover = ({\n children,\n inline = false,\n triggerAccessibleLabel,\n triggerAriaHasPopup,\n triggerButtonContent,\n}: PopoverProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const initialFocusRef = useRef<PopoverInitialFocus | undefined>(undefined);\n const panelRef = useRef<HTMLDivElement>(null);\n const panelId = useId();\n const triggerRef = useRef<HTMLButtonElement | HTMLSpanElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [opensAbove, setOpensAbove] = useState(false);\n const [horizontalPlacement, setHorizontalPlacement] = useState<'left' | 'right'>('right');\n\n const openPopover = ({ initialFocus }: PopoverOpenOptions = {}) => {\n initialFocusRef.current = initialFocus;\n setOpensAbove(false);\n setHorizontalPlacement('right');\n setIsOpen(true);\n };\n\n const closePopover = useCallback(({ restoreFocus = true }: PopoverCloseOptions = {}) => {\n setIsOpen(false);\n\n if (restoreFocus) {\n triggerRef.current?.focus();\n }\n }, []);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (isOpen && event.key === 'Escape') {\n closePopover();\n }\n };\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isOpen) {\n return;\n }\n\n if (inline && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n openPopover();\n return;\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n openPopover({ initialFocus: 'first' });\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n openPopover({ initialFocus: 'last' });\n }\n };\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handlePointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (containerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n\n closePopover({ restoreFocus: false });\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [closePopover, isOpen]);\n\n const updatePosition = useCallback(() => {\n const panel = panelRef.current;\n const trigger = triggerRef.current;\n if (!panel || !trigger) return;\n\n const panelBounds = panel.getBoundingClientRect();\n const triggerBounds = trigger.getBoundingClientRect();\n const spaceAbove = triggerBounds.top;\n const spaceBelow = window.innerHeight - triggerBounds.bottom;\n\n setOpensAbove(panelBounds.height > spaceBelow && spaceAbove > spaceBelow);\n setHorizontalPlacement(\n panelBounds.width > window.innerWidth - triggerBounds.left &&\n triggerBounds.right > window.innerWidth - triggerBounds.left\n ? 'left'\n : 'right'\n );\n }, []);\n\n useLayoutEffect(() => {\n if (!isOpen) return undefined;\n\n updatePosition();\n window.addEventListener('resize', updatePosition);\n window.addEventListener('scroll', updatePosition, true);\n\n return () => {\n window.removeEventListener('resize', updatePosition);\n window.removeEventListener('scroll', updatePosition, true);\n };\n }, [isOpen, updatePosition]);\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLElement>) => {\n if (inline) event.preventDefault();\n event.stopPropagation();\n if (isOpen) {\n closePopover({ restoreFocus: false });\n } else {\n openPopover();\n }\n };\n\n const triggerProps = {\n 'aria-controls': isOpen ? panelId : undefined,\n 'aria-expanded': isOpen,\n 'aria-haspopup': triggerAriaHasPopup,\n 'aria-label': triggerAccessibleLabel,\n className: inline ? styles['inline-trigger'] : styles.trigger,\n onClick: handleTriggerClick,\n onKeyDown: handleTriggerKeyDown,\n };\n\n const triggerBounds = inline ? triggerRef.current?.getBoundingClientRect() : undefined;\n const horizontalTransform = horizontalPlacement === 'left' ? 'translateX(-100%)' : '';\n const verticalTransform = opensAbove ? 'translateY(calc(-100% - var(--shape-spacing-2xs)))' : '';\n const inlineTransform = [horizontalTransform, verticalTransform].filter(Boolean).join(' ');\n const panel = isOpen ? (\n <div\n className={cx(\n styles['popover-panel'],\n styles[opensAbove ? 'above' : 'below'],\n inline && styles['inline-panel'],\n !inline && styles[horizontalPlacement]\n )}\n data-horizontal-placement={horizontalPlacement}\n data-placement={opensAbove ? 'above' : 'below'}\n id={panelId}\n ref={panelRef}\n style={\n triggerBounds\n ? {\n left: horizontalPlacement === 'left' ? triggerBounds.right : triggerBounds.left,\n position: 'fixed',\n top: opensAbove ? triggerBounds.top : triggerBounds.bottom,\n transform: inlineTransform || undefined,\n }\n : undefined\n }\n >\n {typeof children === 'function'\n ? children({ close: closePopover, initialFocus: initialFocusRef.current, isOpen })\n : children}\n </div>\n ) : null;\n\n return (\n <div\n className={cx(styles.popover, inline && styles.inline)}\n data-open={isOpen}\n onKeyDown={handleKeyDown}\n onClick={(event) => {\n if (inline) event.preventDefault();\n event.stopPropagation();\n }}\n ref={containerRef}\n >\n {inline ? (\n <span\n {...triggerProps}\n ref={triggerRef}\n role='button'\n tabIndex={0}\n >\n {triggerButtonContent}\n </span>\n ) : (\n <Button\n {...triggerProps}\n ref={triggerRef as React.Ref<HTMLButtonElement>}\n variant='simple'\n >\n {triggerButtonContent}\n </Button>\n )}\n {inline && panel && typeof document !== 'undefined'\n ? createPortal(panel, document.body)\n : panel}\n </div>\n );\n};\n"],"names":["Popover","children","inline","triggerAccessibleLabel","triggerAriaHasPopup","triggerButtonContent","containerRef","useRef","initialFocusRef","undefined","panelRef","panelId","useId","triggerRef","isOpen","setIsOpen","useState","opensAbove","setOpensAbove","horizontalPlacement","setHorizontalPlacement","openPopover","initialFocus","current","closePopover","useCallback","restoreFocus","focus","handleKeyDown","event","key","handleTriggerKeyDown","preventDefault","useEffect","handlePointerDown","target","contains","document","addEventListener","removeEventListener","updatePosition","panel","trigger","panelBounds","getBoundingClientRect","triggerBounds","spaceAbove","top","spaceBelow","window","innerHeight","bottom","height","width","innerWidth","left","right","useLayoutEffect","handleTriggerClick","stopPropagation","triggerProps","className","styles","onClick","onKeyDown","inlineTransform","filter","Boolean","join","jsx","cx","position","transform","close","jsxs","popover","Button","createPortal","body"],"mappings":"ojBAyCaA,EAAUA,CAAC,CACtBC,SAAAA,EACAC,OAAAA,EAAS,GACTC,uBAAAA,EACAC,oBAAAA,EACAC,qBAAAA,CACY,IAAM,OAClB,MAAMC,EAAeC,EAAAA,OAAuB,IAAI,EAC1CC,EAAkBD,EAAAA,OAAwCE,MAAS,EACnEC,EAAWH,EAAAA,OAAuB,IAAI,EACtCI,EAAUC,EAAAA,MAAAA,EACVC,EAAaN,EAAAA,OAA4C,IAAI,EAC7D,CAACO,EAAQC,CA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D,EAC/B,EAAEiD,OAAOC,OAAO,EAAEC,KAAK,GAAG,EACnF3B,EAAQ3B,EACZuD,EAAAA,IAAC,MAAA,CACC,UAAWC,IACTR,EAAO,eAAe,EACtBA,EAAO7C,EAAa,QAAU,OAAO,EACrCf,GAAU4D,EAAO,cAAc,EAC/B,CAAC5D,GAAU4D,EAAO3C,CAAmB,CACvC,EACA,4BAA2BA,EAC3B,iBAAgBF,EAAa,QAAU,QACvC,GAAIN,EACJ,IAAKD,EACL,MACEmC,EACI,CACEU,KAAMpC,IAAwB,OAAS0B,EAAcW,MAAQX,EAAcU,KAC3EgB,SAAU,QACVxB,IAAK9B,EAAa4B,EAAcE,IAAMF,EAAcM,OACpDqB,UAAWP,GAAmBxD,MAAAA,EAEhCA,OAGL,SAAA,OAAOR,GAAa,WACjBA,EAAS,CAAEwE,MAAOjD,EAAcF,aAAcd,EAAgBe,QAAST,OAAAA,CAAAA,CAAQ,EAC/Eb,CAAAA,CACN,EACE,KAEJ,OACEyE,EAAAA,KAAC,MAAA,CACC,UAAWJ,EAAAA,EAAGR,EAAOa,QAASzE,GAAU4D,EAAO5D,MAAM,EACrD,YAAWY,EACX,UAAWc,EACX,QAAUC,GAAU,CACd3B,KAAc8B,eAAAA,EAClBH,EAAM8B,gBAAAA,CACR,EACA,IAAKrD,EAAa,iBAAA,UAEjBJ,SAAAA,CAAAA,EACCmE,EAAAA,IAAC,QACC,GAAIT,EACJ,IAAK/C,EACL,KAAK,SACL,SAAU,EAETR,WACH,EAEAgE,EAAAA,IAACO,UACC,GAAIhB,EACJ,IAAK/C,EACL,QAAQ,SAEPR,SAAAA,CAAAA,CACH,EAEDH,GAAUuC,GAAS,OAAOJ,SAAa,IACpCwC,EAAAA,aAAapC,EAAOJ,SAASyC,IAAI,EACjCrC,CAAAA,EACN,CAEJ"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/popover/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport {\n type AriaAttributes,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { Button } from '@/components/button';\n\nimport styles from './styles.module.css';\n\nexport type PopoverCloseOptions = {\n restoreFocus?: boolean;\n};\n\nexport type PopoverInitialFocus = 'first' | 'last';\n\nexport type PopoverRenderProps = {\n close: (options?: PopoverCloseOptions) => void;\n initialFocus?: PopoverInitialFocus;\n isOpen: boolean;\n};\n\ntype PopoverOpenOptions = {\n initialFocus?: PopoverInitialFocus;\n};\n\nexport type PopoverProps = {\n children: ReactNode | ((props: PopoverRenderProps) => ReactNode);\n inline?: boolean;\n triggerAccessibleLabel?: string;\n triggerAriaHasPopup?: AriaAttributes['aria-haspopup'];\n triggerButtonContent: ReactNode;\n};\n\nexport const Popover = ({\n children,\n inline = false,\n triggerAccessibleLabel,\n triggerAriaHasPopup,\n triggerButtonContent,\n}: PopoverProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const initialFocusRef = useRef<PopoverInitialFocus | undefined>(undefined);\n const panelRef = useRef<HTMLDivElement>(null);\n const panelId = useId();\n const triggerRef = useRef<HTMLButtonElement | HTMLSpanElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [opensAbove, setOpensAbove] = useState(false);\n const [horizontalPlacement, setHorizontalPlacement] = useState<'left' | 'right'>('right');\n\n const openPopover = ({ initialFocus }: PopoverOpenOptions = {}) => {\n initialFocusRef.current = initialFocus;\n setOpensAbove(false);\n setHorizontalPlacement('right');\n setIsOpen(true);\n };\n\n const closePopover = useCallback(({ restoreFocus = true }: PopoverCloseOptions = {}) => {\n setIsOpen(false);\n\n if (restoreFocus) {\n triggerRef.current?.focus();\n }\n }, []);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (isOpen && event.key === 'Escape') {\n closePopover();\n }\n };\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isOpen) {\n return;\n }\n\n if (inline && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n openPopover();\n return;\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n openPopover({ initialFocus: 'first' });\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n openPopover({ initialFocus: 'last' });\n }\n };\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handlePointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (containerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n\n closePopover({ restoreFocus: false });\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [closePopover, isOpen]);\n\n const updatePosition = useCallback(() => {\n const panel = panelRef.current;\n const trigger = triggerRef.current;\n if (!panel || !trigger) return;\n\n const panelBounds = panel.getBoundingClientRect();\n const triggerBounds = trigger.getBoundingClientRect();\n const spaceAbove = triggerBounds.top;\n const spaceBelow = window.innerHeight - triggerBounds.bottom;\n\n setOpensAbove(panelBounds.height > spaceBelow && spaceAbove > spaceBelow);\n setHorizontalPlacement(\n panelBounds.width > window.innerWidth - triggerBounds.left &&\n triggerBounds.right > window.innerWidth - triggerBounds.left\n ? 'left'\n : 'right'\n );\n }, []);\n\n useLayoutEffect(() => {\n if (!isOpen) return undefined;\n\n updatePosition();\n window.addEventListener('resize', updatePosition);\n window.addEventListener('scroll', updatePosition, true);\n\n return () => {\n window.removeEventListener('resize', updatePosition);\n window.removeEventListener('scroll', updatePosition, true);\n };\n }, [isOpen, updatePosition]);\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLElement>) => {\n event.preventDefault();\n event.stopPropagation();\n if (isOpen) {\n closePopover({ restoreFocus: false });\n } else {\n openPopover();\n }\n };\n\n const triggerProps = {\n 'aria-controls': isOpen ? panelId : undefined,\n 'aria-expanded': isOpen,\n 'aria-haspopup': triggerAriaHasPopup,\n 'aria-label': triggerAccessibleLabel,\n className: inline ? styles['inline-trigger'] : styles.trigger,\n onClick: handleTriggerClick,\n onKeyDown: handleTriggerKeyDown,\n };\n\n const triggerBounds = inline ? triggerRef.current?.getBoundingClientRect() : undefined;\n const horizontalTransform = horizontalPlacement === 'left' ? 'translateX(-100%)' : '';\n const verticalTransform = opensAbove ? 'translateY(calc(-100% - var(--shape-spacing-2xs)))' : '';\n const inlineTransform = [horizontalTransform, verticalTransform].filter(Boolean).join(' ');\n const panel = isOpen ? (\n <div\n className={cx(\n styles['popover-panel'],\n styles[opensAbove ? 'above' : 'below'],\n inline && styles['inline-panel'],\n !inline && styles[horizontalPlacement]\n )}\n data-horizontal-placement={horizontalPlacement}\n data-placement={opensAbove ? 'above' : 'below'}\n id={panelId}\n ref={panelRef}\n style={\n triggerBounds\n ? {\n left: horizontalPlacement === 'left' ? triggerBounds.right : triggerBounds.left,\n position: 'fixed',\n top: opensAbove ? triggerBounds.top : triggerBounds.bottom,\n transform: inlineTransform || undefined,\n }\n : undefined\n }\n >\n {typeof children === 'function'\n ? children({ close: closePopover, initialFocus: initialFocusRef.current, isOpen })\n : children}\n </div>\n ) : null;\n\n return (\n <div\n className={cx(styles.popover, inline && styles.inline)}\n data-open={isOpen}\n onKeyDown={handleKeyDown}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n }}\n ref={containerRef}\n >\n {inline ? (\n <span\n {...triggerProps}\n ref={triggerRef}\n role='button'\n tabIndex={0}\n >\n {triggerButtonContent}\n </span>\n ) : (\n <Button\n {...triggerProps}\n ref={triggerRef as React.Ref<HTMLButtonElement>}\n variant='simple'\n >\n {triggerButtonContent}\n </Button>\n )}\n {inline && panel && typeof document !== 'undefined'\n ? createPortal(panel, document.body)\n : panel}\n </div>\n );\n};\n"],"names":["Popover","children","inline","triggerAccessibleLabel","triggerAriaHasPopup","triggerButtonContent","containerRef","useRef","initialFocusRef","undefined","panelRef","panelId","useId","triggerRef","isOpen","setIsOpen","useState","opensAbove","setOpensAbove","horizontalPlacement","setHorizontalPlacement","openPopover","initialFocus","current","closePopover","useCallback","restoreFocus","focus","handleKeyDown","event","key","handleTriggerKeyDown","preventDefault","useEffect","handlePointerDown","target","contains","document","addEventListener","removeEventListener","updatePosition","panel","trigger","panelBounds","getBoundingClientRect","triggerBounds","spaceAbove","top","spaceBelow","window","innerHeight","bottom","height","width","innerWidth","left","right","useLayoutEffect","handleTriggerClick","stopPropagation","triggerProps","className","styles","onClick","onKeyDown","inlineTransform","filter","Boolean","join","jsx","cx","position","transform","close","jsxs","popover","Button","createPortal","body"],"mappings":"ojBAyCaA,EAAUA,CAAC,CACtBC,SAAAA,EACAC,OAAAA,EAAS,GACTC,uBAAAA,EACAC,oBAAAA,EACAC,qBAAAA,CACY,IAAM,OAClB,MAAMC,EAAeC,EAAAA,OAAuB,IAAI,EAC1CC,EAAkBD,EAAAA,OAAwCE,MAAS,EACnEC,EAAWH,EAAAA,OAAuB,IAAI,EACtCI,EAAUC,EAAAA,MAAAA,EACVC,EAAaN,EAAAA,OAA4C,IAAI,EAC7D,CAACO,EAAQC,CAAS,EAAIC,EAAAA,SAAS,EAAK,EACpC,CAACC,EAAYC,CAAa,EAAIF,EAAAA,SAAS,EAAK,EAC5C,CAACG,EAAqBC,CAAsB,EAAIJ,EAAAA,SAA2B,OAAO,EAElFK,EAAcA,CAAC,CAAEC,aAAAA,CAAAA,EAAqC,KAAO,CACjEd,EAAgBe,QAAUD,EAC1BJ,EAAc,EAAK,EACnBE,EAAuB,OAAO,EAC9BL,EAAU,EAAI,CAChB,EAEMS,EAAeC,EAAAA,YAAY,CAAC,CAAEC,aAAAA,EAAe,EAAA,EAA8B,KAAO,OACtFX,EAAU,EAAK,EAEXW,KACFb,EAAAA,EAAWU,UAAXV,MAAAA,EAAoBc,QAExB,EAAG,CAAA,CAAE,EAECC,EAAiBC,GAA+C,CAChEf,GAAUe,EAAMC,MAAQ,UAC1BN,EAAAA,CAEJ,EAEMO,EAAwBF,GAA4C,CACxE,GAAIf,CAAAA,EAIJ,IAAIZ,IAAW2B,EAAMC,MA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J,OACEyE,EAAAA,KAAC,MAAA,CACC,UAAWJ,EAAAA,EAAGR,EAAOa,QAASzE,GAAU4D,EAAO5D,MAAM,EACrD,YAAWY,EACX,UAAWc,EACX,QAAUC,GAAU,CAClBA,EAAMG,eAAAA,EACNH,EAAM8B,gBAAAA,CACR,EACA,IAAKrD,EAAa,iBAAA,UAEjBJ,SAAAA,CAAAA,EACCmE,EAAAA,IAAC,QACC,GAAIT,EACJ,IAAK/C,EACL,KAAK,SACL,SAAU,EAETR,WACH,EAEAgE,EAAAA,IAACO,UACC,GAAIhB,EACJ,IAAK/C,EACL,QAAQ,SAEPR,SAAAA,CAAAA,CACH,EAEDH,GAAUuC,GAAS,OAAOJ,SAAa,IACpCwC,EAAAA,aAAapC,EAAOJ,SAASyC,IAAI,EACjCrC,CAAAA,EACN,CAEJ"}
|
|
@@ -3,34 +3,34 @@ import { t as T } from "../../classix-DG18itHa.js";
|
|
|
3
3
|
import { useRef as v, useId as H, useState as b, useCallback as C, useEffect as W, useLayoutEffect as S } from "react";
|
|
4
4
|
import { createPortal as U } from "react-dom";
|
|
5
5
|
import { Button as X } from "../button/index.js";
|
|
6
|
-
import '../../assets/index17.css';const Y = "
|
|
6
|
+
import '../../assets/index17.css';const Y = "_popover_1e3fx_1", q = "_inline_1e3fx_6", G = "_below_1e3fx_42", J = "_above_1e3fx_47", M = "_left_1e3fx_57", Q = "_right_1e3fx_62", V = "_trigger_1e3fx_67", r = {
|
|
7
7
|
popover: Y,
|
|
8
8
|
inline: q,
|
|
9
|
-
"popover-panel": "_popover-
|
|
9
|
+
"popover-panel": "_popover-panel_1e3fx_21",
|
|
10
10
|
below: G,
|
|
11
11
|
above: J,
|
|
12
|
-
"inline-panel": "_inline-
|
|
12
|
+
"inline-panel": "_inline-panel_1e3fx_52",
|
|
13
13
|
left: M,
|
|
14
14
|
right: Q,
|
|
15
15
|
trigger: V,
|
|
16
|
-
"inline-trigger": "_inline-
|
|
16
|
+
"inline-trigger": "_inline-trigger_1e3fx_77"
|
|
17
17
|
}, ie = ({
|
|
18
18
|
children: m,
|
|
19
19
|
inline: o = !1,
|
|
20
20
|
triggerAccessibleLabel: F,
|
|
21
21
|
triggerAriaHasPopup: A,
|
|
22
|
-
triggerButtonContent:
|
|
22
|
+
triggerButtonContent: x
|
|
23
23
|
}) => {
|
|
24
24
|
var z;
|
|
25
|
-
const
|
|
25
|
+
const y = v(null), D = v(void 0), w = v(null), P = H(), a = v(null), [t, E] = b(!1), [p, k] = b(!1), [u, B] = b("right"), d = ({
|
|
26
26
|
initialFocus: e
|
|
27
27
|
} = {}) => {
|
|
28
|
-
|
|
28
|
+
D.current = e, k(!1), B("right"), E(!0);
|
|
29
29
|
}, l = C(({
|
|
30
30
|
restoreFocus: e = !0
|
|
31
31
|
} = {}) => {
|
|
32
32
|
var i;
|
|
33
|
-
|
|
33
|
+
E(!1), e && ((i = a.current) == null || i.focus());
|
|
34
34
|
}, []), I = (e) => {
|
|
35
35
|
t && e.key === "Escape" && l();
|
|
36
36
|
}, K = (e) => {
|
|
@@ -55,8 +55,8 @@ import '../../assets/index17.css';const Y = "_popover_1vis1_1", q = "_inline_1vi
|
|
|
55
55
|
return;
|
|
56
56
|
const e = (i) => {
|
|
57
57
|
var n, g;
|
|
58
|
-
const
|
|
59
|
-
(n =
|
|
58
|
+
const f = i.target;
|
|
59
|
+
(n = y.current) != null && n.contains(f) || (g = w.current) != null && g.contains(f) || l({
|
|
60
60
|
restoreFocus: !1
|
|
61
61
|
});
|
|
62
62
|
};
|
|
@@ -67,8 +67,8 @@ import '../../assets/index17.css';const Y = "_popover_1vis1_1", q = "_inline_1vi
|
|
|
67
67
|
const s = C(() => {
|
|
68
68
|
const e = w.current, i = a.current;
|
|
69
69
|
if (!e || !i) return;
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const f = e.getBoundingClientRect(), n = i.getBoundingClientRect(), g = n.top, L = window.innerHeight - n.bottom;
|
|
71
|
+
k(f.height > L && g > L), B(f.width > window.innerWidth - n.left && n.right > window.innerWidth - n.left ? "left" : "right");
|
|
72
72
|
}, []);
|
|
73
73
|
S(() => {
|
|
74
74
|
if (t)
|
|
@@ -77,31 +77,31 @@ import '../../assets/index17.css';const Y = "_popover_1vis1_1", q = "_inline_1vi
|
|
|
77
77
|
};
|
|
78
78
|
}, [t, s]);
|
|
79
79
|
const j = (e) => {
|
|
80
|
-
|
|
80
|
+
e.preventDefault(), e.stopPropagation(), t ? l({
|
|
81
81
|
restoreFocus: !1
|
|
82
82
|
}) : d();
|
|
83
|
-
},
|
|
84
|
-
"aria-controls": t ?
|
|
83
|
+
}, R = {
|
|
84
|
+
"aria-controls": t ? P : void 0,
|
|
85
85
|
"aria-expanded": t,
|
|
86
86
|
"aria-haspopup": A,
|
|
87
87
|
"aria-label": F,
|
|
88
88
|
className: o ? r["inline-trigger"] : r.trigger,
|
|
89
89
|
onClick: j,
|
|
90
90
|
onKeyDown: K
|
|
91
|
-
}, c = o ? (z = a.current) == null ? void 0 : z.getBoundingClientRect() : void 0, N = [u === "left" ? "translateX(-100%)" : "",
|
|
91
|
+
}, c = o ? (z = a.current) == null ? void 0 : z.getBoundingClientRect() : void 0, N = [u === "left" ? "translateX(-100%)" : "", p ? "translateY(calc(-100% - var(--shape-spacing-2xs)))" : ""].filter(Boolean).join(" "), _ = t ? /* @__PURE__ */ h("div", { className: T(r["popover-panel"], r[p ? "above" : "below"], o && r["inline-panel"], !o && r[u]), "data-horizontal-placement": u, "data-placement": p ? "above" : "below", id: P, ref: w, style: c ? {
|
|
92
92
|
left: u === "left" ? c.right : c.left,
|
|
93
93
|
position: "fixed",
|
|
94
|
-
top:
|
|
94
|
+
top: p ? c.top : c.bottom,
|
|
95
95
|
transform: N || void 0
|
|
96
96
|
} : void 0, children: typeof m == "function" ? m({
|
|
97
97
|
close: l,
|
|
98
|
-
initialFocus:
|
|
98
|
+
initialFocus: D.current,
|
|
99
99
|
isOpen: t
|
|
100
100
|
}) : m }) : null;
|
|
101
101
|
return /* @__PURE__ */ O("div", { className: T(r.popover, o && r.inline), "data-open": t, onKeyDown: I, onClick: (e) => {
|
|
102
|
-
|
|
103
|
-
}, ref:
|
|
104
|
-
o ? /* @__PURE__ */ h("span", { ...
|
|
102
|
+
e.preventDefault(), e.stopPropagation();
|
|
103
|
+
}, ref: y, "data-component": "popover", children: [
|
|
104
|
+
o ? /* @__PURE__ */ h("span", { ...R, ref: a, role: "button", tabIndex: 0, children: x }) : /* @__PURE__ */ h(X, { ...R, ref: a, variant: "simple", children: x }),
|
|
105
105
|
o && _ && typeof document < "u" ? U(_, document.body) : _
|
|
106
106
|
] });
|
|
107
107
|
};
|