@solibo/solibo-ui 1.0.4 → 1.0.5
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/index13.css +1 -1
- package/dist/assets/index17.css +1 -1
- package/dist/assets/index31.css +1 -1
- package/dist/assets/index32.css +1 -1
- package/dist/assets/index39.css +1 -1
- package/dist/assets/index41.css +1 -1
- package/dist/assets/index47.css +1 -1
- package/dist/components/button/index.cjs +1 -1
- package/dist/components/button/index.js +10 -10
- package/dist/components/card/index.cjs +1 -1
- package/dist/components/card/index.cjs.map +1 -1
- package/dist/components/card/index.js +41 -31
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.cjs +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/dropdown/index.cjs +1 -1
- package/dist/components/dropdown/index.js +3 -3
- package/dist/components/editor/index.cjs +21 -21
- package/dist/components/editor/index.cjs.map +1 -1
- package/dist/components/editor/index.js +1646 -1636
- package/dist/components/editor/index.js.map +1 -1
- 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 +14 -13
- 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 +15 -14
- package/dist/components/message/index.js.map +1 -1
- package/dist/components/nav/index.cjs +1 -1
- package/dist/components/nav/index.cjs.map +1 -1
- package/dist/components/nav/index.js +35 -30
- package/dist/components/nav/index.js.map +1 -1
- package/dist/components/popover/index.cjs +1 -1
- package/dist/components/popover/index.cjs.map +1 -1
- package/dist/components/popover/index.js +83 -39
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/search/index.cjs +1 -1
- package/dist/components/search/index.js +1 -1
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +2 -2
- package/dist/{icons-DYCSlAoX.cjs → icons-BROXUtPz.cjs} +2 -2
- package/dist/{icons-DYCSlAoX.cjs.map → icons-BROXUtPz.cjs.map} +1 -1
- package/dist/{icons-CKzd_L4D.js → icons-CH48JQqt.js} +6 -2
- package/dist/{icons-CKzd_L4D.js.map → icons-CH48JQqt.js.map} +1 -1
- package/dist/{index-DFXqYJat.js → index-BrGCs_7h.js} +2 -2
- package/dist/{index-DFXqYJat.js.map → index-BrGCs_7h.js.map} +1 -1
- package/dist/{index-CP5A_BGJ.cjs → index-CIugi8vq.cjs} +2 -2
- package/dist/{index-CP5A_BGJ.cjs.map → index-CIugi8vq.cjs.map} +1 -1
- package/dist/{index-B9xtLe2w.js → index-CRAuAHow.js} +2 -2
- package/dist/{index-B9xtLe2w.js.map → index-CRAuAHow.js.map} +1 -1
- package/dist/{index-N4IMha5Q.cjs → index-CSYOtiWJ.cjs} +2 -2
- package/dist/{index-N4IMha5Q.cjs.map → index-CSYOtiWJ.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +32 -10
- package/dist/index.js +39 -38
- package/dist/tokens.json +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index46.css');const r=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),t=require("../../icons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index46.css');const r=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),t=require("../../icons-BROXUtPz.cjs"),m="_icon_vhz6u_1",u="_small_vhz6u_10",_="_medium_vhz6u_15",g="_large_vhz6u_20",d="_danger_vhz6u_25",e={icon:m,small:u,medium:_,large:g,danger:d,"gap-right":"_gap-right_vhz6u_29","gap-left":"_gap-left_vhz6u_33"},h={large:e.large,medium:e.medium,small:e.small},v={danger:e.danger},z=({fill:o,gap:n="none",name:a,size:c="medium",variant:s})=>{const i={maskImage:t.iconSVG(a,o??!1)};return r.jsx("span",{"aria-hidden":"true",className:l.t(n!=="none"&&e[`gap-${n}`],h[c],e.icon,s&&v[s]),style:i,"data-component":"icon"})},p=()=>Object.keys(t.iconPaths);exports.Icon=z;exports.Icons=p;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { t as c } from "../../classix-DG18itHa.js";
|
|
3
|
-
import { i, a as l } from "../../icons-
|
|
3
|
+
import { i, a as l } from "../../icons-CH48JQqt.js";
|
|
4
4
|
import '../../assets/index46.css';const _ = "_icon_vhz6u_1", g = "_small_vhz6u_10", u = "_medium_vhz6u_15", d = "_large_vhz6u_20", h = "_danger_vhz6u_25", n = {
|
|
5
5
|
icon: _,
|
|
6
6
|
small: g,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("react");require("../../icons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("react");require("../../icons-BROXUtPz.cjs");const e=require("../../index-CIugi8vq.cjs");require("../../use-touched-D_TJ8wDc.cjs");exports.Input=e.Input;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../classix-DG18itHa.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import "../../icons-
|
|
5
|
-
import { I as a } from "../../index-
|
|
4
|
+
import "../../icons-CH48JQqt.js";
|
|
5
|
+
import { I as a } from "../../index-BrGCs_7h.js";
|
|
6
6
|
import "../../use-touched-DXIJVVzz.js";
|
|
7
7
|
export {
|
|
8
8
|
a as Input
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index16.css');const r=require("react/jsx-runtime"),m=require("../../classix-5H4IWnMA.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index16.css');const r=require("react/jsx-runtime"),m=require("../../classix-5H4IWnMA.cjs"),p=require("react"),b=require("../button/index.cjs"),x=require("../icon/index.cjs"),h=require("../list/index.cjs"),j=require("../popover/index.cjs"),v="_list_z7awx_3",y="_item_z7awx_15",w="_active_z7awx_38",D="_danger_z7awx_47",l={list:v,item:y,active:w,danger:D};function q(o){return o.filter(s=>!!(s&&!s.disabled))}const k=({close:o,initialFocus:s,items:u,menuAccessibleLabel:d,onItemSelect:a})=>{const c=p.useRef([]),t=p.useCallback(e=>{const n=q(c.current);if(n.length===0)return;if(e==="first"){n[0].focus();return}if(e==="last"){n[n.length-1].focus();return}const i=n.indexOf(document.activeElement),g=e==="next"?(i+1)%n.length:(i-1+n.length)%n.length;n[g].focus()},[]);p.useEffect(()=>{t(s??"first")},[t,s]);const f=e=>{if(e.key==="ArrowDown"){e.preventDefault(),t("next");return}if(e.key==="ArrowUp"){e.preventDefault(),t("previous");return}if(e.key==="Home"){e.preventDefault(),t("first");return}e.key==="End"&&(e.preventDefault(),t("last"))},_=e=>{var n;(n=e.onSelect)==null||n.call(e),a==null||a(e),o()};return r.jsx(h.List,{"aria-label":d,className:l.list,onKeyDown:f,role:"menu","data-component":"menupanel",children:u.map((e,n)=>r.jsx("li",{role:"none",children:r.jsxs(b.Button,{"aria-current":e.isActive?"true":void 0,"aria-label":e.accessibleLabel,className:m.t(l.item,e.isActive&&l.active,e.isDanger&&l.danger),disabled:e.disabled,onClick:()=>_(e),ref:i=>{c.current[n]=i},role:"menuitem",variant:"tertiary",children:[e.icon&&r.jsx(x.Icon,{fill:!0,gap:"right",name:e.icon,size:"small"}),r.jsx("span",{children:e.label})]})},e.id??n))})},z=({inline:o=!1,items:s,menuAccessibleLabel:u="Menu",onItemSelect:d,position:a="left",triggerAccessibleLabel:c="Open menu"})=>r.jsx(j.Popover,{inline:o,position:a,triggerAccessibleLabel:c,triggerAriaHasPopup:"menu",triggerButtonContent:r.jsx(x.Icon,{name:"dots",size:"medium"}),"data-component":"menu",children:({close:t,initialFocus:f})=>r.jsx(k,{close:t,initialFocus:f,items:s,menuAccessibleLabel:u,onItemSelect:d})});exports.Menu=z;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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\nexport type MenuProps = {\n items: MenuItem[];\n menuAccessibleLabel?: string;\n onItemSelect?: (item: MenuItem) => void;\n position?: 'left' | 'right';\n triggerAccessibleLabel?: string;\n};\n\ntype MenuFocusTarget = 'first' | 'last' | 'next' | 'previous';\n\ntype MenuPanelProps = Pick<MenuProps, 'items' | 'menuAccessibleLabel' | 'onItemSelect'> & {\n close: PopoverRenderProps['close'];\n initialFocus?: PopoverInitialFocus;\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 <List\n aria-label={menuAccessibleLabel}\n className={styles.list}\n onKeyDown={handleKeyDown}\n role='menu'\n >\n {items.map((item, index) => (\n <li\n key={item.id ?? index}\n role='none'\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={() => handleItemSelect(item)}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n role='menuitem'\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};\n\nexport const Menu = ({\n items,\n menuAccessibleLabel = 'Menu',\n onItemSelect,\n position = 'left',\n triggerAccessibleLabel = 'Open menu',\n}: MenuProps) => {\n return (\n <Popover\n position={position}\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":["getFocusableItems","items","filter","item","Boolean","disabled","MenuPanel","close","initialFocus","menuAccessibleLabel","onItemSelect","itemRefs","useRef","focusItem","useCallback","target","focusableItems","current","length","focus","currentIndex","indexOf","document","activeElement","nextIndex","useEffect","handleKeyDown","event","key","preventDefault","handleItemSelect","onSelect","jsx","List","styles","list","map","index","jsxs","Button","isActive","undefined","accessibleLabel","cx","active","isDanger","danger","node","icon","Icon","label","id","Menu","position","triggerAccessibleLabel","Popover"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","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\nexport type MenuProps = {\n inline?: boolean;\n items: MenuItem[];\n menuAccessibleLabel?: string;\n onItemSelect?: (item: MenuItem) => void;\n position?: 'auto' | 'left' | 'right';\n triggerAccessibleLabel?: string;\n};\n\ntype MenuFocusTarget = 'first' | 'last' | 'next' | 'previous';\n\ntype MenuPanelProps = Pick<MenuProps, 'items' | 'menuAccessibleLabel' | 'onItemSelect'> & {\n close: PopoverRenderProps['close'];\n initialFocus?: PopoverInitialFocus;\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 <List\n aria-label={menuAccessibleLabel}\n className={styles.list}\n onKeyDown={handleKeyDown}\n role='menu'\n >\n {items.map((item, index) => (\n <li\n key={item.id ?? index}\n role='none'\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={() => handleItemSelect(item)}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n role='menuitem'\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};\n\nexport const Menu = ({\n inline = false,\n items,\n menuAccessibleLabel = 'Menu',\n onItemSelect,\n position = 'left',\n triggerAccessibleLabel = 'Open menu',\n}: MenuProps) => {\n return (\n <Popover\n inline={inline}\n position={position}\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":["getFocusableItems","items","filter","item","Boolean","disabled","MenuPanel","close","initialFocus","menuAccessibleLabel","onItemSelect","itemRefs","useRef","focusItem","useCallback","target","focusableItems","current","length","focus","currentIndex","indexOf","document","activeElement","nextIndex","useEffect","handleKeyDown","event","key","preventDefault","handleItemSelect","onSelect","jsx","List","styles","list","map","index","jsxs","Button","isActive","undefined","accessibleLabel","cx","active","isDanger","danger","node","icon","Icon","label","id","Menu","inline","position","triggerAccessibleLabel","Popover"],"mappings":"oaAsCA,SAASA,EAAkBC,EAAwC,CACjE,OAAOA,EAAMC,OAAQC,GAAoCC,GAAQD,GAAQ,CAACA,EAAKE,SAAS,CAC1F,CAEA,MAAMC,EAAYA,CAAC,CACjBC,MAAAA,EACAC,aAAAA,EACAP,MAAAA,EACAQ,oBAAAA,EACAC,aAAAA,CACc,IAAM,CACpB,MAAMC,EAAWC,EAAAA,OAAwC,EAAE,EAErDC,EAAYC,cAAaC,GAA4B,CACzD,MAAMC,EAAiBhB,EAAkBW,EAASM,OAAO,EAEzD,GAAID,EAAeE,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uC,gBACjB,UAAWC,EAAAA,EACTT,EAAO/B,KACPA,EAAKqC,UAAYN,EAAOU,OACxBzC,EAAK0C,UAAYX,EAAOY,MAC1B,EACA,SAAU3C,EAAKE,SACf,QAAS,IAAMyB,EAAiB3B,CAAI,EACpC,IAAM4C,GAAS,CACbpC,EAASM,QAAQoB,CAAK,EAAIU,CAC5B,EACA,KAAK,WACL,QAAQ,WAEP5C,SAAAA,CAAAA,EAAK6C,MACJhB,EAAAA,IAACiB,EAAAA,KAAA,CACC,KAAI,GACJ,IAAI,QACJ,KAAM9C,EAAK6C,KACX,KAAK,OAAA,CAAO,EAGhBhB,EAAAA,IAAC,OAAA,CAAM7B,SAAAA,EAAK+C,KAAAA,CAAM,CAAA,CAAA,CACpB,CAAA,EA5BK/C,EAAKgD,IAAMd,CA6BlB,CACD,CAAA,CACH,CAEJ,EAEae,EAAOA,CAAC,CACnBC,OAAAA,EAAS,GACTpD,MAAAA,EACAQ,oBAAAA,EAAsB,OACtBC,aAAAA,EACA4C,SAAAA,EAAW,OACXC,uBAAAA,EAAyB,WAChB,UAENC,EAAAA,QAAA,CACC,OAAAH,EACA,SAAAC,EACA,uBAAAC,EACA,oBAAoB,OACpB,qBACEvB,EAAAA,IAACiB,EAAAA,KAAA,CACC,KAAK,OACL,KAAK,WAER,iBAAA,OAEA,SAAA,CAAC,CAAE1C,MAAAA,EAAOC,aAAAA,CAAAA,UACRF,EAAA,CACC,MAAAC,EACA,aAAAC,EACA,MAAAP,EACA,oBAAAQ,EACA,aAAAC,EAA2B,EAGjC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as o, jsxs as h } from "react/jsx-runtime";
|
|
|
2
2
|
import { t as x } from "../../classix-DG18itHa.js";
|
|
3
3
|
import { useRef as _, useCallback as b, useEffect as w } from "react";
|
|
4
4
|
import { Button as v } from "../button/index.js";
|
|
5
|
-
import { Icon as
|
|
5
|
+
import { Icon as m } from "../icon/index.js";
|
|
6
6
|
import { List as y } from "../list/index.js";
|
|
7
7
|
import { Popover as D } from "../popover/index.js";
|
|
8
8
|
import '../../assets/index16.css';const k = "_list_z7awx_3", z = "_item_z7awx_15", A = "_active_z7awx_38", B = "_danger_z7awx_47", c = {
|
|
@@ -39,7 +39,7 @@ const E = ({
|
|
|
39
39
|
w(() => {
|
|
40
40
|
r(t ?? "first");
|
|
41
41
|
}, [r, t]);
|
|
42
|
-
const
|
|
42
|
+
const d = (e) => {
|
|
43
43
|
if (e.key === "ArrowDown") {
|
|
44
44
|
e.preventDefault(), r("next");
|
|
45
45
|
return;
|
|
@@ -57,22 +57,23 @@ const E = ({
|
|
|
57
57
|
var n;
|
|
58
58
|
(n = e.onSelect) == null || n.call(e), s == null || s(e), a();
|
|
59
59
|
};
|
|
60
|
-
return /* @__PURE__ */ o(y, { "aria-label": f, className: c.list, onKeyDown:
|
|
60
|
+
return /* @__PURE__ */ o(y, { "aria-label": f, className: c.list, onKeyDown: d, role: "menu", "data-component": "menupanel", children: u.map((e, n) => /* @__PURE__ */ o("li", { role: "none", children: /* @__PURE__ */ h(v, { "aria-current": e.isActive ? "true" : void 0, "aria-label": e.accessibleLabel, className: x(c.item, e.isActive && c.active, e.isDanger && c.danger), disabled: e.disabled, onClick: () => p(e), ref: (i) => {
|
|
61
61
|
l.current[n] = i;
|
|
62
62
|
}, role: "menuitem", variant: "tertiary", children: [
|
|
63
|
-
e.icon && /* @__PURE__ */ o(
|
|
63
|
+
e.icon && /* @__PURE__ */ o(m, { fill: !0, gap: "right", name: e.icon, size: "small" }),
|
|
64
64
|
/* @__PURE__ */ o("span", { children: e.label })
|
|
65
65
|
] }) }, e.id ?? n)) });
|
|
66
66
|
}, N = ({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
inline: a = !1,
|
|
68
|
+
items: t,
|
|
69
|
+
menuAccessibleLabel: u = "Menu",
|
|
70
|
+
onItemSelect: f,
|
|
71
|
+
position: s = "left",
|
|
72
|
+
triggerAccessibleLabel: l = "Open menu"
|
|
73
|
+
}) => /* @__PURE__ */ o(D, { inline: a, position: s, triggerAccessibleLabel: l, triggerAriaHasPopup: "menu", triggerButtonContent: /* @__PURE__ */ o(m, { name: "dots", size: "medium" }), "data-component": "menu", children: ({
|
|
74
|
+
close: r,
|
|
75
|
+
initialFocus: d
|
|
76
|
+
}) => /* @__PURE__ */ o(E, { close: r, initialFocus: d, items: t, menuAccessibleLabel: u, onItemSelect: f }) });
|
|
76
77
|
export {
|
|
77
78
|
N as Menu
|
|
78
79
|
};
|
|
@@ -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\nexport type MenuProps = {\n items: MenuItem[];\n menuAccessibleLabel?: string;\n onItemSelect?: (item: MenuItem) => void;\n position?: 'left' | 'right';\n triggerAccessibleLabel?: string;\n};\n\ntype MenuFocusTarget = 'first' | 'last' | 'next' | 'previous';\n\ntype MenuPanelProps = Pick<MenuProps, 'items' | 'menuAccessibleLabel' | 'onItemSelect'> & {\n close: PopoverRenderProps['close'];\n initialFocus?: PopoverInitialFocus;\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 <List\n aria-label={menuAccessibleLabel}\n className={styles.list}\n onKeyDown={handleKeyDown}\n role='menu'\n >\n {items.map((item, index) => (\n <li\n key={item.id ?? index}\n role='none'\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={() => handleItemSelect(item)}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n role='menuitem'\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};\n\nexport const Menu = ({\n items,\n menuAccessibleLabel = 'Menu',\n onItemSelect,\n position = 'left',\n triggerAccessibleLabel = 'Open menu',\n}: MenuProps) => {\n return (\n <Popover\n position={position}\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":["getFocusableItems","items","filter","item","Boolean","disabled","MenuPanel","close","initialFocus","menuAccessibleLabel","onItemSelect","itemRefs","useRef","focusItem","useCallback","target","focusableItems","current","length","focus","currentIndex","indexOf","document","activeElement","nextIndex","useEffect","handleKeyDown","event","key","preventDefault","handleItemSelect","onSelect","jsx","List","styles","list","map","index","jsxs","Button","isActive","undefined","accessibleLabel","cx","active","isDanger","danger","node","icon","Icon","label","id","Menu","position","triggerAccessibleLabel","Popover"],"mappings":";;;;;;;;;;;;;
|
|
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\nexport type MenuProps = {\n inline?: boolean;\n items: MenuItem[];\n menuAccessibleLabel?: string;\n onItemSelect?: (item: MenuItem) => void;\n position?: 'auto' | 'left' | 'right';\n triggerAccessibleLabel?: string;\n};\n\ntype MenuFocusTarget = 'first' | 'last' | 'next' | 'previous';\n\ntype MenuPanelProps = Pick<MenuProps, 'items' | 'menuAccessibleLabel' | 'onItemSelect'> & {\n close: PopoverRenderProps['close'];\n initialFocus?: PopoverInitialFocus;\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 <List\n aria-label={menuAccessibleLabel}\n className={styles.list}\n onKeyDown={handleKeyDown}\n role='menu'\n >\n {items.map((item, index) => (\n <li\n key={item.id ?? index}\n role='none'\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={() => handleItemSelect(item)}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n role='menuitem'\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};\n\nexport const Menu = ({\n inline = false,\n items,\n menuAccessibleLabel = 'Menu',\n onItemSelect,\n position = 'left',\n triggerAccessibleLabel = 'Open menu',\n}: MenuProps) => {\n return (\n <Popover\n inline={inline}\n position={position}\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":["getFocusableItems","items","filter","item","Boolean","disabled","MenuPanel","close","initialFocus","menuAccessibleLabel","onItemSelect","itemRefs","useRef","focusItem","useCallback","target","focusableItems","current","length","focus","currentIndex","indexOf","document","activeElement","nextIndex","useEffect","handleKeyDown","event","key","preventDefault","handleItemSelect","onSelect","jsx","List","styles","list","map","index","jsxs","Button","isActive","undefined","accessibleLabel","cx","active","isDanger","danger","node","icon","Icon","label","id","Menu","inline","position","triggerAccessibleLabel","Popover"],"mappings":";;;;;;;;;;;;;AAsCA,SAASA,EAAkBC,GAAwC;AACjE,SAAOA,EAAMC,OAAO,CAACC,MAAoCC,GAAQD,KAAQ,CAACA,EAAKE,SAAS;AAC1F;AAEA,MAAMC,IAAYA,CAAC;AAAA,EACjBC,OAAAA;AAAAA,EACAC,cAAAA;AAAAA,EACAP,OAAAA;AAAAA,EACAQ,qBAAAA;AAAAA,EACAC,cAAAA;AACc,MAAM;AACpB,QAAMC,IAAWC,EAAwC,EAAE,GAErDC,IAAY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;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index15.css');const e=require("react/jsx-runtime"),
|
|
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"),b=require("../icon/index.cjs"),y="_message_ugbdy_1",j="_timestamp_ugbdy_78",h="_attachments_ugbdy_83",f="_preview_ugbdy_101",s={"message-group":"_message-group_ugbdy_1",message:y,timestamp:j,attachments:h,preview:f},w=({appearance:m="default",attachments:i,author:a,authorColor:r,authorImageUrl:o,authorRole:d,content:g,iconName:l="info",id:_,preview:u,timestamp:c,timestampText:p,type:t="default"})=>{const n=c?new Date(c):void 0;return e.jsxs("div",{className:s["message-group"],"data-message-type":t,"data-component":"message",children:[a&&e.jsx(x.Avatar,{accessibleLabel:a,color:r,imageUrl:o,name:a,role:d}),e.jsxs("div",{className:v.t(s.message,u&&s.preview),"data-appearance":m,"data-id":_,"data-type":t,children:[t=="system"&&e.jsx(b.Icon,{fill:!0,gap:"right",name:l}),g]}),i&&e.jsx("div",{className:s.attachments,children:i}),n&&e.jsx("time",{className:s.timestamp,dateTime:n.toISOString(),children:p??n.toLocaleString()})]})};exports.Message=w;
|
|
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 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 type = 'default',\n}: MessageOptions) => {\n const date = timestamp ? new Date(timestamp) : undefined;\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 <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 {date && (\n <time\n className={styles.timestamp}\n dateTime={date.toISOString()}\n >\n {date.toLocaleString()}\n </time>\n )}\n </div>\n );\n};\n"],"names":["Message","appearance","attachments","author","authorColor","authorImageUrl","authorRole","content","iconName","id","preview","timestamp","type","date","Date","undefined","jsxs","styles","jsx","Avatar","cx","message","Icon","toISOString","toLocaleString"],"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\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 <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 {date && (\n <time\n className={styles.timestamp}\n dateTime={date.toISOString()}\n >\n {timestampText ?? date.toLocaleString()}\n </time>\n )}\n </div>\n );\n};\n"],"names":["Message","appearance","attachments","author","authorColor","authorImageUrl","authorRole","content","iconName","id","preview","timestamp","timestampText","type","date","Date","undefined","jsxs","styles","jsx","Avatar","cx","message","Icon","toISOString","toLocaleString"],"mappings":"sZAwBaA,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,OAE/C,OACEC,OAAC,OACC,UAAWC,EAAO,eAAe,EACjC,oBAAmBL,EAAK,iBAAA,UAEvBV,SAAAA,CAAAA,GACCgB,EAAAA,IAACC,EAAAA,OAAA,CACC,gBAAiBjB,EACjB,MAAOC,EACP,SAAUC,EACV,KAAMF,EACN,KAAMG,CAAAA,CAAW,EAGrBW,EAAAA,KAAC,MAAA,CACC,UAAWI,EAAAA,EAAGH,EAAOI,QAASZ,GAAWQ,EAAOR,OAAO,EACvD,kBAAiBT,EACjB,UAASQ,EACT,YAAWI,EAEVA,SAAAA,CAAAA,GAAQ,gBACNU,EAAAA,KAAA,CACC,KAAI,GACJ,IAAI,QACJ,KAAMf,CAAAA,CAAS,EAGlBD,CAAAA,EACH,EACCL,GAAeiB,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAOhB,YAAcA,SAAAA,EAAY,EAChEY,GACCK,EAAAA,IAAC,OAAA,CACC,UAAWD,EAAOP,UAClB,SAAUG,EAAKU,YAAAA,EAEdZ,SAAAA,GAAiBE,EAAKW,gBAAe,CACxC,CAAA,EAEJ,CAEJ"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs as o, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { t as
|
|
3
|
-
import { Avatar as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import '../../assets/index15.css';const
|
|
2
|
+
import { t as f } from "../../classix-DG18itHa.js";
|
|
3
|
+
import { Avatar as b } from "../avatar/index.js";
|
|
4
|
+
import { Icon as y } from "../icon/index.js";
|
|
5
|
+
import '../../assets/index15.css';const h = "_message_ugbdy_1", w = "_timestamp_ugbdy_78", N = "_attachments_ugbdy_83", x = "_preview_ugbdy_101", e = {
|
|
6
6
|
"message-group": "_message-group_ugbdy_1",
|
|
7
|
-
message:
|
|
8
|
-
timestamp:
|
|
9
|
-
attachments:
|
|
10
|
-
preview:
|
|
11
|
-
},
|
|
7
|
+
message: h,
|
|
8
|
+
timestamp: w,
|
|
9
|
+
attachments: N,
|
|
10
|
+
preview: x
|
|
11
|
+
}, A = ({
|
|
12
12
|
appearance: c = "default",
|
|
13
13
|
attachments: i,
|
|
14
14
|
author: s,
|
|
@@ -20,20 +20,21 @@ import '../../assets/index15.css';const y = "_message_ugbdy_1", h = "_timestamp_
|
|
|
20
20
|
id: _,
|
|
21
21
|
preview: u,
|
|
22
22
|
timestamp: r,
|
|
23
|
+
timestampText: v,
|
|
23
24
|
type: t = "default"
|
|
24
25
|
}) => {
|
|
25
26
|
const m = r ? new Date(r) : void 0;
|
|
26
27
|
return /* @__PURE__ */ o("div", { className: e["message-group"], "data-message-type": t, "data-component": "message", children: [
|
|
27
|
-
s && /* @__PURE__ */ a(
|
|
28
|
-
/* @__PURE__ */ o("div", { className:
|
|
29
|
-
t == "system" && /* @__PURE__ */ a(
|
|
28
|
+
s && /* @__PURE__ */ a(b, { accessibleLabel: s, color: n, imageUrl: d, name: s, role: g }),
|
|
29
|
+
/* @__PURE__ */ o("div", { className: f(e.message, u && e.preview), "data-appearance": c, "data-id": _, "data-type": t, children: [
|
|
30
|
+
t == "system" && /* @__PURE__ */ a(y, { fill: !0, gap: "right", name: p }),
|
|
30
31
|
l
|
|
31
32
|
] }),
|
|
32
33
|
i && /* @__PURE__ */ a("div", { className: e.attachments, children: i }),
|
|
33
|
-
m && /* @__PURE__ */ a("time", { className: e.timestamp, dateTime: m.toISOString(), children: m.toLocaleString() })
|
|
34
|
+
m && /* @__PURE__ */ a("time", { className: e.timestamp, dateTime: m.toISOString(), children: v ?? m.toLocaleString() })
|
|
34
35
|
] });
|
|
35
36
|
};
|
|
36
37
|
export {
|
|
37
|
-
|
|
38
|
+
A as Message
|
|
38
39
|
};
|
|
39
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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 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 type = 'default',\n}: MessageOptions) => {\n const date = timestamp ? new Date(timestamp) : undefined;\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 <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 {date && (\n <time\n className={styles.timestamp}\n dateTime={date.toISOString()}\n >\n {date.toLocaleString()}\n </time>\n )}\n </div>\n );\n};\n"],"names":["Message","appearance","attachments","author","authorColor","authorImageUrl","authorRole","content","iconName","id","preview","timestamp","type","date","Date","undefined","jsxs","styles","jsx","Avatar","cx","message","Icon","toISOString","toLocaleString"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","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\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 <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 {date && (\n <time\n className={styles.timestamp}\n dateTime={date.toISOString()}\n >\n {timestampText ?? date.toLocaleString()}\n </time>\n )}\n </div>\n );\n};\n"],"names":["Message","appearance","attachments","author","authorColor","authorImageUrl","authorRole","content","iconName","id","preview","timestamp","timestampText","type","date","Date","undefined","jsxs","styles","jsx","Avatar","cx","message","Icon","toISOString","toLocaleString"],"mappings":";;;;;;;;;;GAwBaA,IAAUA,CAAC;AAAA,EACtBC,YAAAA,IAAa;AAAA,EACbC,aAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,IAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,MAAAA,IAAO;AACO,MAAM;AACpB,QAAMC,IAAOH,IAAY,IAAII,KAAKJ,CAAS,IAAIK;AAE/C,SACE,gBAAAC,EAAC,SACC,WAAWC,EAAO,eAAe,GACjC,qBAAmBL,GAAK,kBAAA,WAEvBV,UAAAA;AAAAA,IAAAA,KACC,gBAAAgB,EAACC,GAAA,EACC,iBAAiBjB,GACjB,OAAOC,GACP,UAAUC,GACV,MAAMF,GACN,MAAMG,EAAAA,CAAW;AAAA,IAGrB,gBAAAW,EAAC,OAAA,EACC,WAAWI,EAAGH,EAAOI,SAASZ,KAAWQ,EAAOR,OAAO,GACvD,mBAAiBT,GACjB,WAASQ,GACT,aAAWI,GAEVA,UAAAA;AAAAA,MAAAA,KAAQ,8BACNU,GAAA,EACC,MAAI,IACJ,KAAI,SACJ,MAAMf,EAAAA,CAAS;AAAA,MAGlBD;AAAAA,IAAAA,GACH;AAAA,IACCL,KAAe,gBAAAiB,EAAC,OAAA,EAAI,WAAWD,EAAOhB,aAAcA,UAAAA,GAAY;AAAA,IAChEY,KACC,gBAAAK,EAAC,QAAA,EACC,WAAWD,EAAOP,WAClB,UAAUG,EAAKU,YAAAA,GAEdZ,UAAAA,KAAiBE,EAAKW,iBAAe,CACxC;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index13.css');const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index13.css');const i=require("react/jsx-runtime"),r=require("../../classix-5H4IWnMA.cjs"),p=require("react"),v=require("../../icons-BROXUtPz.cjs"),f="_nav_1ecsd_3",h="_label_1ecsd_9",m="_horizontal_1ecsd_17",N="_sidebar_1ecsd_27",g="_tabs_1ecsd_73",w="_pills_1ecsd_93",e={nav:f,label:h,horizontal:m,sidebar:N,tabs:g,pills:w},x={default:e.default,pills:e.pills,sidebar:e.sidebar,tabs:e.tabs},j=({className:a,...s})=>i.jsx("span",{className:r.t(a,e.label),...s,"data-component":"navlabel"}),q=({animation:a,children:s,className:c,horizontal:l=!1,variant:n="default",...d})=>{const[b,o]=p.useState(!1),u={"--icon-svg":v.iconSVG("chevron")};return i.jsx("nav",{className:r.t(c,l&&e.horizontal,e.nav,x[n]),"data-animation":a,"data-open":b?"true":"false","data-orientation":l?"horizontal":"vertical",onBlurCapture:t=>{if(n!=="pills"||window.innerWidth>960)return;const _=t.relatedTarget;t.currentTarget.contains(_)||o(!1)},onClick:()=>{n!=="pills"||window.innerWidth>960||o(t=>!t)},style:u,...d,"data-component":"nav",children:s})};exports.Nav=q;exports.NavLabel=j;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/nav/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useState } from 'react';\n\nimport { iconSVG } from '@/components/icon/icons.ts';\n\nimport styles from './styles.module.css';\n\nconst variants = {\n default: styles.default,\n pills: styles.pills,\n sidebar: styles.sidebar,\n tabs: styles.tabs,\n};\n\nexport type NavProps = React.HTMLAttributes<HTMLElement> & {\n animation?: string;\n children?: React.ReactNode;\n className?: string;\n horizontal?: boolean;\n variant?: keyof typeof variants;\n};\n\nexport const Nav = ({\n animation,\n children,\n className,\n horizontal = false,\n variant = 'default',\n ...props\n}: NavProps) => {\n const [open, setOpen] = useState(false);\n\n type withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n };\n const withVars: withVars = {\n '--icon-svg': iconSVG('chevron'),\n };\n\n return (\n <nav\n className={cx(className, horizontal && styles.horizontal, styles.nav, variants[variant])}\n data-animation={animation}\n data-open={open ? 'true' : 'false'}\n data-orientation={horizontal ? 'horizontal' : 'vertical'}\n onBlurCapture={(e) => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n const next = e.relatedTarget as Node | null;\n if (!e.currentTarget.contains(next)) {\n setOpen(false);\n }\n }}\n onClick={() => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n setOpen((v) => !v);\n }}\n style={withVars}\n {...props}\n >\n {children}\n </nav>\n );\n};\n"],"names":["variants","default","styles","pills","sidebar","tabs","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/nav/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useState } from 'react';\n\nimport { iconSVG } from '@/components/icon/icons.ts';\n\nimport styles from './styles.module.css';\n\nconst variants = {\n default: styles.default,\n pills: styles.pills,\n sidebar: styles.sidebar,\n tabs: styles.tabs,\n};\n\nexport type NavProps = React.HTMLAttributes<HTMLElement> & {\n animation?: string;\n children?: React.ReactNode;\n className?: string;\n horizontal?: boolean;\n variant?: keyof typeof variants;\n};\n\nexport type NavLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const NavLabel = ({ className, ...props }: NavLabelProps) => (\n <span\n className={cx(className, styles.label)}\n {...props}\n />\n);\n\nexport const Nav = ({\n animation,\n children,\n className,\n horizontal = false,\n variant = 'default',\n ...props\n}: NavProps) => {\n const [open, setOpen] = useState(false);\n\n type withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n };\n const withVars: withVars = {\n '--icon-svg': iconSVG('chevron'),\n };\n\n return (\n <nav\n className={cx(className, horizontal && styles.horizontal, styles.nav, variants[variant])}\n data-animation={animation}\n data-open={open ? 'true' : 'false'}\n data-orientation={horizontal ? 'horizontal' : 'vertical'}\n onBlurCapture={(e) => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n const next = e.relatedTarget as Node | null;\n if (!e.currentTarget.contains(next)) {\n setOpen(false);\n }\n }}\n onClick={() => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n setOpen((v) => !v);\n }}\n style={withVars}\n {...props}\n >\n {children}\n </nav>\n );\n};\n"],"names":["variants","default","styles","pills","sidebar","tabs","NavLabel","className","props","jsx","cx","label","Nav","animation","children","horizontal","variant","open","setOpen","useState","withVars","iconSVG","nav","e","window","innerWidth","next","relatedTarget","currentTarget","contains","v"],"mappings":"wYAOMA,EAAW,CACfC,QAASC,EAAOD,QAChBE,MAAOD,EAAOC,MACdC,QAASF,EAAOE,QAChBC,KAAMH,EAAOG,IACf,EAYaC,EAAWA,CAAC,CAAEC,UAAAA,EAAW,GAAGC,CAAqB,IAC5DC,MAAC,OAAA,CACC,UAAWC,EAAAA,EAAGH,EAAWL,EAAOS,KAAK,EACrC,GAAIH,EAAM,iBAAA,UAAA,CAAA,EAIDI,EAAMA,CAAC,CAClBC,UAAAA,EACAC,SAAAA,EACAP,UAAAA,EACAQ,WAAAA,EAAa,GACbC,QAAAA,EAAU,UACV,GAAGR,CACK,IAAM,CACd,KAAM,CAACS,EAAMC,CAAO,EAAIC,EAAAA,SAAS,EAAK,EAKhCC,EAAqB,CACzB,aAAcC,EAAAA,QAAQ,SAAS,CAAA,EAGjC,OACEZ,EAAAA,IAAC,MAAA,CACC,UAAWC,EAAAA,EAAGH,EAAWQ,GAAcb,EAAOa,WAAYb,EAAOoB,IAAKtB,EAASgB,CAAO,CAAC,EACvF,iBAAgBH,EAChB,YAAWI,EAAO,OAAS,QAC3B,mBAAkBF,EAAa,aAAe,WAC9C,cAAgBQ,GAAM,CACpB,GAAIP,IAAY,SAAWQ,OAAOC,WAAa,IAAK,OAEpD,MAAMC,EAAOH,EAAEI,cACVJ,EAAEK,cAAcC,SAASH,CAAI,GAChCR,EAAQ,EAAK,CAEjB,EACA,QAAS,IAAM,CACTF,IAAY,SAAWQ,OAAOC,WAAa,KAE/CP,EAASY,GAAM,CAACA,CAAC,CACnB,EACA,MAAOV,EACP,GAAIZ,EAAM,iBAAA,MAETM,SAAAA,EACH,CAEJ"}
|
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { t as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { i as
|
|
5
|
-
import '../../assets/index13.css';const
|
|
6
|
-
nav:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { t as r } from "../../classix-DG18itHa.js";
|
|
3
|
+
import { useState as f } from "react";
|
|
4
|
+
import { i as m } from "../../icons-CH48JQqt.js";
|
|
5
|
+
import '../../assets/index13.css';const u = "_nav_1ecsd_3", v = "_label_1ecsd_9", h = "_horizontal_1ecsd_17", w = "_sidebar_1ecsd_27", z = "_tabs_1ecsd_73", N = "_pills_1ecsd_93", a = {
|
|
6
|
+
nav: u,
|
|
7
|
+
label: v,
|
|
8
|
+
horizontal: h,
|
|
9
|
+
sidebar: w,
|
|
10
|
+
tabs: z,
|
|
11
|
+
pills: N
|
|
11
12
|
}, g = {
|
|
12
|
-
default:
|
|
13
|
-
pills:
|
|
14
|
-
sidebar:
|
|
15
|
-
tabs:
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
default: a.default,
|
|
14
|
+
pills: a.pills,
|
|
15
|
+
sidebar: a.sidebar,
|
|
16
|
+
tabs: a.tabs
|
|
17
|
+
}, T = ({
|
|
18
|
+
className: s,
|
|
19
|
+
...n
|
|
20
|
+
}) => /* @__PURE__ */ i("span", { className: r(s, a.label), ...n, "data-component": "navlabel" }), V = ({
|
|
21
|
+
animation: s,
|
|
22
|
+
children: n,
|
|
23
|
+
className: c,
|
|
24
|
+
horizontal: o = !1,
|
|
25
|
+
variant: e = "default",
|
|
26
|
+
...d
|
|
23
27
|
}) => {
|
|
24
|
-
const [
|
|
25
|
-
"--icon-svg":
|
|
28
|
+
const [p, l] = f(!1), _ = {
|
|
29
|
+
"--icon-svg": m("chevron")
|
|
26
30
|
};
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
+
return /* @__PURE__ */ i("nav", { className: r(c, o && a.horizontal, a.nav, g[e]), "data-animation": s, "data-open": p ? "true" : "false", "data-orientation": o ? "horizontal" : "vertical", onBlurCapture: (t) => {
|
|
32
|
+
if (e !== "pills" || window.innerWidth > 960) return;
|
|
33
|
+
const b = t.relatedTarget;
|
|
34
|
+
t.currentTarget.contains(b) || l(!1);
|
|
31
35
|
}, onClick: () => {
|
|
32
|
-
|
|
33
|
-
}, style:
|
|
36
|
+
e !== "pills" || window.innerWidth > 960 || l((t) => !t);
|
|
37
|
+
}, style: _, ...d, "data-component": "nav", children: n });
|
|
34
38
|
};
|
|
35
39
|
export {
|
|
36
|
-
|
|
40
|
+
V as Nav,
|
|
41
|
+
T as NavLabel
|
|
37
42
|
};
|
|
38
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/nav/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useState } from 'react';\n\nimport { iconSVG } from '@/components/icon/icons.ts';\n\nimport styles from './styles.module.css';\n\nconst variants = {\n default: styles.default,\n pills: styles.pills,\n sidebar: styles.sidebar,\n tabs: styles.tabs,\n};\n\nexport type NavProps = React.HTMLAttributes<HTMLElement> & {\n animation?: string;\n children?: React.ReactNode;\n className?: string;\n horizontal?: boolean;\n variant?: keyof typeof variants;\n};\n\nexport const Nav = ({\n animation,\n children,\n className,\n horizontal = false,\n variant = 'default',\n ...props\n}: NavProps) => {\n const [open, setOpen] = useState(false);\n\n type withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n };\n const withVars: withVars = {\n '--icon-svg': iconSVG('chevron'),\n };\n\n return (\n <nav\n className={cx(className, horizontal && styles.horizontal, styles.nav, variants[variant])}\n data-animation={animation}\n data-open={open ? 'true' : 'false'}\n data-orientation={horizontal ? 'horizontal' : 'vertical'}\n onBlurCapture={(e) => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n const next = e.relatedTarget as Node | null;\n if (!e.currentTarget.contains(next)) {\n setOpen(false);\n }\n }}\n onClick={() => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n setOpen((v) => !v);\n }}\n style={withVars}\n {...props}\n >\n {children}\n </nav>\n );\n};\n"],"names":["variants","default","styles","pills","sidebar","tabs","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/nav/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useState } from 'react';\n\nimport { iconSVG } from '@/components/icon/icons.ts';\n\nimport styles from './styles.module.css';\n\nconst variants = {\n default: styles.default,\n pills: styles.pills,\n sidebar: styles.sidebar,\n tabs: styles.tabs,\n};\n\nexport type NavProps = React.HTMLAttributes<HTMLElement> & {\n animation?: string;\n children?: React.ReactNode;\n className?: string;\n horizontal?: boolean;\n variant?: keyof typeof variants;\n};\n\nexport type NavLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const NavLabel = ({ className, ...props }: NavLabelProps) => (\n <span\n className={cx(className, styles.label)}\n {...props}\n />\n);\n\nexport const Nav = ({\n animation,\n children,\n className,\n horizontal = false,\n variant = 'default',\n ...props\n}: NavProps) => {\n const [open, setOpen] = useState(false);\n\n type withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n };\n const withVars: withVars = {\n '--icon-svg': iconSVG('chevron'),\n };\n\n return (\n <nav\n className={cx(className, horizontal && styles.horizontal, styles.nav, variants[variant])}\n data-animation={animation}\n data-open={open ? 'true' : 'false'}\n data-orientation={horizontal ? 'horizontal' : 'vertical'}\n onBlurCapture={(e) => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n const next = e.relatedTarget as Node | null;\n if (!e.currentTarget.contains(next)) {\n setOpen(false);\n }\n }}\n onClick={() => {\n if (variant !== 'pills' || window.innerWidth > 960) return;\n\n setOpen((v) => !v);\n }}\n style={withVars}\n {...props}\n >\n {children}\n </nav>\n );\n};\n"],"names":["variants","default","styles","pills","sidebar","tabs","NavLabel","className","props","jsx","cx","label","Nav","animation","children","horizontal","variant","open","setOpen","useState","withVars","iconSVG","nav","e","window","innerWidth","next","relatedTarget","currentTarget","contains","v"],"mappings":";;;;;;;;;;;GAOMA,IAAW;AAAA,EACfC,SAASC,EAAOD;AAAAA,EAChBE,OAAOD,EAAOC;AAAAA,EACdC,SAASF,EAAOE;AAAAA,EAChBC,MAAMH,EAAOG;AACf,GAYaC,IAAWA,CAAC;AAAA,EAAEC,WAAAA;AAAAA,EAAW,GAAGC;AAAqB,MAC5D,gBAAAC,EAAC,QAAA,EACC,WAAWC,EAAGH,GAAWL,EAAOS,KAAK,GACrC,GAAIH,GAAM,kBAAA,WAAA,CAAA,GAIDI,IAAMA,CAAC;AAAA,EAClBC,WAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAP,WAAAA;AAAAA,EACAQ,YAAAA,IAAa;AAAA,EACbC,SAAAA,IAAU;AAAA,EACV,GAAGR;AACK,MAAM;AACd,QAAM,CAACS,GAAMC,CAAO,IAAIC,EAAS,EAAK,GAKhCC,IAAqB;AAAA,IACzB,cAAcC,EAAQ,SAAS;AAAA,EAAA;AAGjC,SACE,gBAAAZ,EAAC,OAAA,EACC,WAAWC,EAAGH,GAAWQ,KAAcb,EAAOa,YAAYb,EAAOoB,KAAKtB,EAASgB,CAAO,CAAC,GACvF,kBAAgBH,GAChB,aAAWI,IAAO,SAAS,SAC3B,oBAAkBF,IAAa,eAAe,YAC9C,eAAgBQ,CAAAA,MAAM;AACpB,QAAIP,MAAY,WAAWQ,OAAOC,aAAa,IAAK;AAEpD,UAAMC,IAAOH,EAAEI;AACf,IAAKJ,EAAEK,cAAcC,SAASH,CAAI,KAChCR,EAAQ,EAAK;AAAA,EAEjB,GACA,SAAS,MAAM;AACb,IAAIF,MAAY,WAAWQ,OAAOC,aAAa,OAE/CP,EAASY,CAAAA,MAAM,CAACA,CAAC;AAAA,EACnB,GACA,OAAOV,GACP,GAAIZ,GAAM,kBAAA,OAETM,UAAAA,GACH;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index17.css');const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index17.css');const w=require("react/jsx-runtime"),C=require("../../classix-5H4IWnMA.cjs"),o=require("react"),K=require("react-dom"),O=require("../button/index.cjs"),H="_popover_1szho_1",N="_inline_1szho_6",W="_below_1szho_38",M="_above_1szho_43",U="_left_1szho_53",X="_right_1szho_58",Y="_trigger_1szho_63",s={popover:H,inline:N,"popover-panel":"_popover-panel_1szho_21",below:W,above:M,"inline-panel":"_inline-panel_1szho_48",left:U,right:X,trigger:Y,"inline-trigger":"_inline-trigger_1szho_77"},G=({children:m,inline:n=!1,position:p="left",triggerAccessibleLabel:L,triggerAriaHasPopup:F,triggerButtonContent:z})=>{var T;const P=o.useRef(null),R=o.useRef(void 0),b=o.useRef(null),D=o.useId(),l=o.useRef(null),[t,x]=o.useState(!1),[d,k]=o.useState(!1),g=p==="auto"?"right":p,[v,E]=o.useState(g),h=({initialFocus:e}={})=>{R.current=e,k(!1),E(g),x(!0)},c=o.useCallback(({restoreFocus:e=!0}={})=>{var a;x(!1),e&&((a=l.current)==null||a.focus())},[]),q=e=>{t&&e.key==="Escape"&&c()},A=e=>{if(!t){if(n&&(e.key==="Enter"||e.key===" ")){e.preventDefault(),h();return}if(e.key==="ArrowDown"){e.preventDefault(),h({initialFocus:"first"});return}e.key==="ArrowUp"&&(e.preventDefault(),h({initialFocus:"last"}))}};o.useEffect(()=>{if(!t)return;const e=a=>{var r,_;const f=a.target;(r=P.current)!=null&&r.contains(f)||(_=b.current)!=null&&_.contains(f)||c({restoreFocus:!1})};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[c,t]);const i=o.useCallback(()=>{const e=b.current,a=l.current;if(!e||!a)return;const f=e.getBoundingClientRect(),r=a.getBoundingClientRect(),_=r.top,j=window.innerHeight-r.bottom;k(f.height>j&&_>j),E(p==="auto"&&f.width>window.innerWidth-r.left&&r.right>window.innerWidth-r.left?"left":g)},[p,g]);o.useLayoutEffect(()=>{if(t)return i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[t,i]);const S=e=>{n&&e.preventDefault(),e.stopPropagation(),t?c({restoreFocus:!1}):h()},B={"aria-controls":t?D:void 0,"aria-expanded":t,"aria-haspopup":F,"aria-label":L,className:n?s["inline-trigger"]:s.trigger,onClick:S,onKeyDown:A},u=n?(T=l.current)==null?void 0:T.getBoundingClientRect():void 0,I=[v==="left"?"translateX(-100%)":"",d?"translateY(calc(-100% - var(--shape-spacing-2xs)))":""].filter(Boolean).join(" "),y=t?w.jsx("div",{className:C.t(s["popover-panel"],s[d?"above":"below"],n&&s["inline-panel"],!n&&s[v]),"data-horizontal-placement":v,"data-placement":d?"above":"below",id:D,ref:b,style:u?{left:v==="left"?u.right:u.left,position:"fixed",top:d?u.top:u.bottom,transform:I||void 0}:void 0,children:typeof m=="function"?m({close:c,initialFocus:R.current,isOpen:t}):m}):null;return w.jsxs("div",{className:C.t(s.popover,n&&s.inline),"data-open":t,onKeyDown:q,onClick:e=>{n&&e.preventDefault(),e.stopPropagation()},ref:P,"data-component":"popover",children:[n?w.jsx("span",{...B,ref:l,role:"button",tabIndex:0,children:z}):w.jsx(O.Button,{...B,ref:l,variant:"secondary",children:z}),n&&y&&typeof document<"u"?K.createPortal(y,document.body):y]})};exports.Popover=G;
|
|
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 useRef,\n useState,\n} from 'react';\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 position?: 'left' | 'right';\n triggerAccessibleLabel?: string;\n triggerAriaHasPopup?: AriaAttributes['aria-haspopup'];\n triggerButtonContent: ReactNode;\n};\n\nexport const Popover = ({\n children,\n position = 'left',\n triggerAccessibleLabel,\n triggerAriaHasPopup,\n triggerButtonContent,\n}: PopoverProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const initialFocusRef = useRef<PopoverInitialFocus | undefined>(undefined);\n const panelId = useId();\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n\n const openPopover = ({ initialFocus }: PopoverOpenOptions = {}) => {\n initialFocusRef.current = initialFocus;\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<HTMLButtonElement>) => {\n if (isOpen) {\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 if (!containerRef.current?.contains(event.target as Node)) {\n closePopover({ restoreFocus: false });\n }\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [closePopover, isOpen]);\n\n return (\n <div\n className={styles.popover}\n onKeyDown={handleKeyDown}\n onClick={(e) => e.stopPropagation()}\n ref={containerRef}\n >\n <Button\n aria-controls={isOpen ? panelId : undefined}\n aria-expanded={isOpen}\n aria-haspopup={triggerAriaHasPopup}\n aria-label={triggerAccessibleLabel}\n className={cx(styles.trigger)}\n onKeyDown={handleTriggerKeyDown}\n onClick={() => (isOpen ? closePopover({ restoreFocus: false }) : openPopover())}\n ref={triggerRef}\n variant='secondary'\n >\n {triggerButtonContent}\n </Button>\n {isOpen && (\n <div\n className={cx(styles['popover-panel'], styles[position])}\n id={panelId}\n >\n {typeof children === 'function'\n ? children({ close: closePopover, initialFocus: initialFocusRef.current, isOpen })\n : children}\n </div>\n )}\n </div>\n );\n};\n"],"names":["Popover","children","position","triggerAccessibleLabel","triggerAriaHasPopup","triggerButtonContent","containerRef","useRef","initialFocusRef","undefined","panelId","useId","triggerRef","isOpen","setIsOpen","useState","openPopover","initialFocus","current","closePopover","useCallback","restoreFocus","focus","handleKeyDown","event","key","handleTriggerKeyDown","preventDefault","useEffect","handlePointerDown","contains","target","document","addEventListener","removeEventListener","jsxs","styles","popover","e","stopPropagation","jsx","Button","cx","trigger","close"],"mappings":"mXAuCaA,EAAUA,CAAC,CACtBC,SAAAA,EACAC,SAAAA,EAAW,OACXC,uBAAAA,EACAC,oBAAAA,EACAC,qBAAAA,CACY,IAAM,CAClB,MAAMC,EAAeC,EAAAA,OAAuB,IAAI,EAC1CC,EAAkBD,EAAAA,OAAwCE,MAAS,EACnEC,EAAUC,EAAAA,MAAAA,EACVC,EAAaL,EAAAA,OAA0B,IAAI,EAC3C,CAACM,EAAQC,CAAS,EAAIC,EAAAA,SAAS,EAAK,EAEpCC,EAAcA,CAAC,CAAEC,aAAAA,CAAAA,EAAqC,KAAO,CACjET,EAAgBU,QAAUD,EAC1BH,EAAU,EAAI,CAChB,EAEMK,EAAeC,EAAAA,YAAY,CAAC,CAAEC,aAAAA,EAAe,EAAA,EAA8B,KAAO,OACtFP,EAAU,EAAK,EAEXO,KACFT,EAAAA,EAAWM,UAAXN,MAAAA,EAAoBU,QAExB,EAAG,CAAA,CAAE,EAECC,EAAiBC,GAA+C,CAChEX,GAAUW,EAAMC,MAAQ,UAC1BN,EAAAA,CAEJ,EAEMO,EAAwBF,GAAkD,CAC9E,GAAIX,CAAAA,EAIJ,IAAIW,EAAMC,MAAQ,YAAa,CAC7BD,EAAMG,eAAAA,EACNX,EAAY,CAAEC,aAAc,OAAA,CAAS,EACrC,MACF,CAEIO,EAAMC,MAAQ,YAChBD,EAAMG,eAAAA,EACNX,EAAY,CAAEC,aAAc,MAAA,CAAQ,GAExC,EAEAW,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAI,CAACf,EACH,OAGF,MAAMgB,EAAqBL,GAAsB,QAC1ClB,EAAAA,EAAaY,UAAbZ,MAAAA,EAAsBwB,SAASN,EAAMO,SACxCZ,EAAa,CAAEE,aAAc,EAAA,CAAO,CAExC,EAEAW,gBAASC,iBAAiB,YAAaJ,CAAiB,EAEjD,IAAM,CACXG,SAASE,oBAAoB,YAAaL,CAAiB,CAC7D,CACF,EAAG,CAACV,EAAcN,CAAM,CAAC,EAGvBsB,EAAAA,KAAC,MAAA,CACC,UAAWC,EAAOC,QAClB,UAAWd,EACX,QAAUe,GAAMA,EAAEC,kBAClB,IAAKjC,EAAa,iBAAA,UAElB,SAAA,CAAAkC,EAAAA,IAACC,EAAAA,OAAA,CACC,gBAAe5B,EAASH,EAAUD,OAClC,gBAAeI,EACf,gBAAeT,EACf,aAAYD,EACZ,UAAWuC,EAAAA,EAAGN,EAAOO,OAAO,EAC5B,UAAWjB,EACX,QAAS,IAAOb,EAASM,EAAa,CAAEE,aAAc,EAAA,CAAO,EAAIL,EAAAA,EACjE,IAAKJ,EACL,QAAQ,YAEPP,SAAAA,EACH,EACCQ,GACC2B,EAAAA,IAAC,MAAA,CACC,UAAWE,IAAGN,EAAO,eAAe,EAAGA,EAAOlC,CAAQ,CAAC,EACvD,GAAIQ,EAEH,SAAA,OAAOT,GAAa,WACjBA,EAAS,CAAE2C,MAAOzB,EAAcF,aAAcT,EAAgBU,QAASL,OAAAA,CAAAA,CAAQ,EAC/EZ,CAAAA,CACN,CAAA,EAEJ,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 position?: 'auto' | 'left' | 'right';\n triggerAccessibleLabel?: string;\n triggerAriaHasPopup?: AriaAttributes['aria-haspopup'];\n triggerButtonContent: ReactNode;\n};\n\nexport const Popover = ({\n children,\n inline = false,\n position = 'left',\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 preferredHorizontalPlacement = position === 'auto' ? 'right' : position;\n const [horizontalPlacement, setHorizontalPlacement] = useState<'left' | 'right'>(\n preferredHorizontalPlacement\n );\n\n const openPopover = ({ initialFocus }: PopoverOpenOptions = {}) => {\n initialFocusRef.current = initialFocus;\n setOpensAbove(false);\n setHorizontalPlacement(preferredHorizontalPlacement);\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 position === 'auto' &&\n panelBounds.width > window.innerWidth - triggerBounds.left &&\n triggerBounds.right > window.innerWidth - triggerBounds.left\n ? 'left'\n : preferredHorizontalPlacement\n );\n }, [position, preferredHorizontalPlacement]);\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='secondary'\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","position","triggerAccessibleLabel","triggerAriaHasPopup","triggerButtonContent","containerRef","useRef","initialFocusRef","undefined","panelRef","panelId","useId","triggerRef","isOpen","setIsOpen","useState","opensAbove","setOpensAbove","preferredHorizontalPlacement","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","transform","close","jsxs","popover","Button","createPortal","body"],"mappings":"ojBA0CaA,EAAUA,CAAC,CACtBC,SAAAA,EACAC,OAAAA,EAAS,GACTC,SAAAA,EAAW,OACXC,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,EAC5CG,EAA+BjB,IAAa,OAAS,QAAUA,EAC/D,CAACkB,EAAqBC,CAAsB,EAAIL,EAAAA,SACpDG,CACF,EAEMG,EAAcA,CAAC,CAAEC,aAAAA,CAAAA,EAAqC,KAAO,CACjEf,EAAgBgB,QAAUD,EAC1BL,EAAc,EAAK,EACnBG,EAAuBF,CAA4B,EACnDJ,EAAU,EAAI,CAChB,EAEMU,EAAeC,EAAAA,YAAY,CAAC,CAAEC,aAAAA,EAAe,EAAA,EAA8B,KAAO,OACtFZ,EAAU,EAAK,EAEXY,KACFd,EAAAA,EAAWW,UAAXX,MAAAA,EAAoBe,QAExB,EAAG,CAAA,CAAE,EAECC,EAAiBC,GAA+C,CAChEhB,GAAUgB,EAAMC,MAAQ,UAC1BN,EAAAA,CAEJ,EAEMO,EAAwBF,GAA4C,CACxE,GAAIhB,CAAAA,EAIJ,IAAIb,IAAW6B,EAAM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