@solibo/solibo-ui 1.0.7 → 1.0.9

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.
Files changed (48) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/assets/index15.css +1 -1
  3. package/dist/assets/index19.css +1 -1
  4. package/dist/assets/index32.css +1 -1
  5. package/dist/assets/index38.css +1 -1
  6. package/dist/assets/index39.css +1 -1
  7. package/dist/assets/index46.css +1 -1
  8. package/dist/assets/index51.css +1 -1
  9. package/dist/assets/index8.css +1 -1
  10. package/dist/assets/index9.css +1 -1
  11. package/dist/components/card/index.cjs +1 -1
  12. package/dist/components/card/index.js +45 -45
  13. package/dist/components/dialog/index.cjs +1 -1
  14. package/dist/components/dialog/index.cjs.map +1 -1
  15. package/dist/components/dialog/index.js +39 -37
  16. package/dist/components/dialog/index.js.map +1 -1
  17. package/dist/components/dropdown/index.cjs +1 -1
  18. package/dist/components/dropdown/index.js +70 -70
  19. package/dist/components/icon/index.cjs +1 -1
  20. package/dist/components/icon/index.js +22 -22
  21. package/dist/components/iframe/index.cjs +1 -1
  22. package/dist/components/iframe/index.cjs.map +1 -1
  23. package/dist/components/iframe/index.js +46 -49
  24. package/dist/components/iframe/index.js.map +1 -1
  25. package/dist/components/message/index.cjs +1 -1
  26. package/dist/components/message/index.js +18 -18
  27. package/dist/components/popover/index.cjs +1 -1
  28. package/dist/components/popover/index.cjs.map +1 -1
  29. package/dist/components/popover/index.js +10 -10
  30. package/dist/components/popover/index.js.map +1 -1
  31. package/dist/components/search/index.cjs +1 -1
  32. package/dist/components/search/index.js +29 -29
  33. package/dist/components/select/index.cjs +1 -1
  34. package/dist/components/select/index.js +1 -1
  35. package/dist/components/sortable/index.cjs +1 -1
  36. package/dist/components/sortable/index.cjs.map +1 -1
  37. package/dist/components/sortable/index.js +141 -134
  38. package/dist/components/sortable/index.js.map +1 -1
  39. package/dist/{index-oL8GYbhj.cjs → index-BPIK2dxs.cjs} +2 -2
  40. package/dist/{index-oL8GYbhj.cjs.map → index-BPIK2dxs.cjs.map} +1 -1
  41. package/dist/{index-CMfR_USP.js → index-C_YiNpZP.js} +8 -8
  42. package/dist/{index-CMfR_USP.js.map → index-C_YiNpZP.js.map} +1 -1
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.ts +13 -2
  45. package/dist/index.js +37 -36
  46. package/dist/tokens.css +3 -1
  47. package/dist/tokens.json +46 -19
  48. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/iframe/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { type ComponentPropsWithoutRef, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Button } from '../button';\nimport { Dialog } from '../dialog';\nimport styles from './styles.module.css';\n\nconst MIN_AUTO_HEIGHT = 120;\nconst MAX_AUTO_HEIGHT = 12000;\nconst AUTO_HEIGHT_BUFFER = 8;\n\nexport type IframeProps = Omit<ComponentPropsWithoutRef<'iframe'>, 'src' | 'srcDoc' | 'title'> & {\n accessibleLabel: string;\n autoResize?: boolean;\n closeFullscreenLabel?: string;\n fullscreenLabel?: string;\n hasFullscreenView?: boolean;\n srcDoc: string;\n};\n\nexport const Iframe = ({\n accessibleLabel,\n autoResize = false,\n className,\n closeFullscreenLabel = 'Close fullscreen',\n fullscreenLabel = 'View in fullscreen',\n hasFullscreenView = true,\n loading = 'lazy',\n onLoad,\n referrerPolicy = 'no-referrer',\n sandbox = '',\n srcDoc,\n style,\n ...props\n}: IframeProps) => {\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const measurementFrameRef = useRef<number | null>(null);\n const followUpMeasurementTimeoutRef = useRef<number | null>(null);\n const [measuredHeight, setMeasuredHeight] = useState(MIN_AUTO_HEIGHT);\n const [isFullscreenOpen, setIsFullscreenOpen] = useState(false);\n\n const clearScheduledMeasurements = useCallback(() => {\n if (measurementFrameRef.current !== null) {\n window.cancelAnimationFrame(measurementFrameRef.current);\n measurementFrameRef.current = null;\n }\n\n if (followUpMeasurementTimeoutRef.current !== null) {\n window.clearTimeout(followUpMeasurementTimeoutRef.current);\n followUpMeasurementTimeoutRef.current = null;\n }\n }, []);\n\n const measureSize = useCallback(() => {\n if (!autoResize) return;\n\n const iframe = iframeRef.current;\n const iframeDocument = iframe?.contentDocument;\n if (!iframe || !iframeDocument) return;\n\n const renderedHeight = iframe.style.height;\n\n try {\n // measure from a stable viewport height so content sized with percentages or\n // viewport units cannot feed the iframe's previous height back into itself\n iframe.style.height = `${MIN_AUTO_HEIGHT}px`;\n\n const content =\n iframeDocument.querySelector<HTMLElement>('[data-iframe-content]') ?? iframeDocument.body;\n const contentRect = content.getBoundingClientRect();\n const { body, documentElement } = iframeDocument;\n const height = Math.min(\n Math.max(\n Math.ceil(\n Math.max(\n content.scrollHeight,\n content.offsetHeight,\n contentRect.height,\n body.scrollHeight,\n body.offsetHeight,\n documentElement.scrollHeight,\n documentElement.offsetHeight\n ) + AUTO_HEIGHT_BUFFER\n ),\n MIN_AUTO_HEIGHT\n ),\n MAX_AUTO_HEIGHT\n );\n\n setMeasuredHeight(height);\n } catch {\n // cross-origin iframe content cannot be measured; retain minimum height\n } finally {\n iframe.style.height = renderedHeight;\n }\n }, [autoResize]);\n\n const scheduleSizeMeasurement = useCallback(() => {\n if (!autoResize || measurementFrameRef.current !== null) return;\n\n measurementFrameRef.current = window.requestAnimationFrame(() => {\n measurementFrameRef.current = null;\n measureSize();\n\n if (followUpMeasurementTimeoutRef.current !== null) {\n window.clearTimeout(followUpMeasurementTimeoutRef.current);\n }\n\n followUpMeasurementTimeoutRef.current = window.setTimeout(() => {\n followUpMeasurementTimeoutRef.current = null;\n measureSize();\n }, 250);\n });\n }, [autoResize, measureSize]);\n\n const handleLoad: NonNullable<IframeProps['onLoad']> = (event) => {\n scheduleSizeMeasurement();\n\n const iframeDocument = iframeRef.current?.contentDocument;\n Array.from(iframeDocument?.images ?? []).forEach((image) => {\n if (image.complete) return;\n image.addEventListener('load', scheduleSizeMeasurement, { once: true });\n image.addEventListener('error', scheduleSizeMeasurement, { once: true });\n });\n iframeDocument?.fonts?.ready.then(scheduleSizeMeasurement).catch(() => undefined);\n\n onLoad?.(event);\n };\n\n useEffect(() => {\n if (!autoResize) return undefined;\n\n clearScheduledMeasurements();\n setMeasuredHeight(MIN_AUTO_HEIGHT);\n scheduleSizeMeasurement();\n\n return clearScheduledMeasurements;\n }, [autoResize, clearScheduledMeasurements, scheduleSizeMeasurement, srcDoc]);\n\n useEffect(() => {\n if (!autoResize) return undefined;\n\n window.addEventListener('resize', scheduleSizeMeasurement);\n window.visualViewport?.addEventListener('resize', scheduleSizeMeasurement);\n\n return () => {\n window.removeEventListener('resize', scheduleSizeMeasurement);\n window.visualViewport?.removeEventListener('resize', scheduleSizeMeasurement);\n };\n }, [autoResize, scheduleSizeMeasurement]);\n\n return (\n <div className={styles.wrapper}>\n {hasFullscreenView && (\n <div className={styles.toolbar}>\n <Button\n aria-expanded={isFullscreenOpen}\n aria-haspopup='dialog'\n onClick={() => setIsFullscreenOpen(true)}\n variant='tertiary'\n >\n {fullscreenLabel}\n </Button>\n </div>\n )}\n <iframe\n {...props}\n className={cx(styles.iframe, className)}\n loading={loading}\n onLoad={handleLoad}\n ref={iframeRef}\n referrerPolicy={referrerPolicy}\n sandbox={sandbox}\n srcDoc={srcDoc}\n style={\n autoResize\n ? {\n ...style,\n height: measuredHeight,\n minHeight: MIN_AUTO_HEIGHT,\n }\n : style\n }\n title={accessibleLabel}\n />\n {isFullscreenOpen && (\n <Dialog\n aria-label={`${accessibleLabel} fullscreen`}\n className={styles['fullscreen-dialog']}\n open\n setOpen={setIsFullscreenOpen}\n >\n <div className={styles['fullscreen-toolbar']}>\n <Button\n autoFocus\n onClick={() => setIsFullscreenOpen(false)}\n >\n {closeFullscreenLabel}\n </Button>\n </div>\n <iframe\n {...props}\n className={cx(styles.iframe, styles['fullscreen-iframe'], className)}\n loading='eager'\n referrerPolicy={referrerPolicy}\n sandbox={sandbox}\n srcDoc={srcDoc}\n title={`${accessibleLabel} fullscreen`}\n />\n </Dialog>\n )}\n </div>\n );\n};\n"],"names":["MIN_AUTO_HEIGHT","MAX_AUTO_HEIGHT","AUTO_HEIGHT_BUFFER","Iframe","accessibleLabel","autoResize","className","closeFullscreenLabel","fullscreenLabel","hasFullscreenView","loading","onLoad","referrerPolicy","sandbox","srcDoc","style","props","iframeRef","useRef","measurementFrameRef","followUpMeasurementTimeoutRef","measuredHeight","setMeasuredHeight","useState","isFullscreenOpen","setIsFullscreenOpen","clearScheduledMeasurements","useCallback","current","window","cancelAnimationFrame","clearTimeout","measureSize","iframe","iframeDocument","contentDocument","renderedHeight","height","content","querySelector","body","contentRect","getBoundingClientRect","documentElement","Math","min","max","ceil","scrollHeight","offsetHeight","scheduleSizeMeasurement","requestAnimationFrame","setTimeout","handleLoad","event","Array","from","images","forEach","image","complete","addEventListener","once","fonts","ready","then","catch","useEffect","visualViewport","removeEventListener","styles","wrapper","toolbar","jsx","Button","cx","minHeight","jsxs","Dialog"],"mappings":";;;;;;;;;;;;GAOMA,IAAkB,KAClBC,IAAkB,MAClBC,IAAqB,GAWdC,IAASA,CAAC;AAAA,EACrBC,iBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,WAAAA;AAAAA,EACAC,sBAAAA,IAAuB;AAAA,EACvBC,iBAAAA,IAAkB;AAAA,EAClBC,mBAAAA,IAAoB;AAAA,EACpBC,SAAAA,IAAU;AAAA,EACVC,QAAAA;AAAAA,EACAC,gBAAAA,IAAiB;AAAA,EACjBC,SAAAA,IAAU;AAAA,EACVC,QAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAMC,IAAYC,EAA0B,IAAI,GAC1CC,IAAsBD,EAAsB,IAAI,GAChDE,IAAgCF,EAAsB,IAAI,GAC1D,CAACG,GAAgBC,CAAiB,IAAIC,EAASvB,CAAe,GAC9D,CAACwB,GAAkBC,CAAmB,IAAIF,EAAS,EAAK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CAAC,qBAGrC,OAAA,EAAI,WAAWoB,EAAOC,SAAQ,kBAAA,UAC5B9D,UAAAA;AAAAA,IAAAA,uBACE,OAAA,EAAI,WAAW6D,EAAOE,SACrB,UAAA,gBAAAC,EAACC,KACC,iBAAelD,GACf,iBAAc,UACd,SAAS,MAAMC,EAAoB,EAAI,GACvC,SAAQ,YAEPjB,aACH,EAAA,CACF;AAAA,sBAED,UAAA,EACC,GAAIQ,GACJ,WAAW2D,EAAGL,EAAOrC,QAAQ3B,CAAS,GACtC,SAAAI,GACA,QAAQ2C,GACR,KAAKpC,GACL,gBAAAL,GACA,SAAAC,GACA,QAAAC,GACA,OACET,IACI;AAAA,MACE,GAAGU;AAAAA,MACHsB,QAAQhB;AAAAA,MACRuD,WAAW5E;AAAAA,IAAAA,IAEbe,GAEN,OAAOX,GAAgB;AAAA,IAExBoB,KACC,gBAAAqD,EAACC,GAAA,EACC,cAAY,GAAG1E,CAAe,eAC9B,WAAWkE,EAAO,mBAAmB,GACrC,MAAI,IACJ,SAAS7C,GAET,UAAA;AAAA,MAAA,gBAAAgD,EAAC,OAAA,EAAI,WAAWH,EAAO,oBAAoB,GACzC,UAAA,gBAAAG,EAACC,GAAA,EACC,WAAS,IACT,SAAS,MAAMjD,EAAoB,EAAK,GAEvClB,aACH,GACF;AAAA,MACA,gBAAAkE,EAAC,YACC,GAAIzD,GACJ,WAAW2D,EAAGL,EAAOrC,QAAQqC,EAAO,mBAAmB,GAAGhE,CAAS,GACnE,SAAQ,SACR,gBAAAM,GACA,SAAAC,GACA,QAAAC,GACA,OAAO,GAAGV,CAAe,cAAA,CAAc;AAAA,IAAA,EAAA,CAE3C;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/iframe/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { type ComponentPropsWithoutRef, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Button } from '../button';\nimport { Controls } from '../controls';\nimport { Dialog } from '../dialog';\nimport { Header } from '../header';\nimport styles from './styles.module.css';\n\nconst MIN_AUTO_HEIGHT = 120;\nconst MAX_AUTO_HEIGHT = 12000;\nconst AUTO_HEIGHT_BUFFER = 8;\n\nexport type IframeProps = Omit<ComponentPropsWithoutRef<'iframe'>, 'src' | 'srcDoc' | 'title'> & {\n accessibleLabel: string;\n autoResize?: boolean;\n closeFullscreenLabel?: string;\n fullscreenLabel?: string;\n hasFullscreenView?: boolean;\n srcDoc: string;\n};\n\nexport const Iframe = ({\n accessibleLabel,\n autoResize = false,\n className,\n closeFullscreenLabel = 'Close fullscreen',\n fullscreenLabel = 'View in fullscreen',\n hasFullscreenView = true,\n loading = 'lazy',\n onLoad,\n referrerPolicy = 'no-referrer',\n sandbox = '',\n srcDoc,\n style,\n ...props\n}: IframeProps) => {\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const measurementFrameRef = useRef<number | null>(null);\n const followUpMeasurementTimeoutRef = useRef<number | null>(null);\n const [measuredHeight, setMeasuredHeight] = useState(MIN_AUTO_HEIGHT);\n const [isFullscreenOpen, setIsFullscreenOpen] = useState(false);\n\n const clearScheduledMeasurements = useCallback(() => {\n if (measurementFrameRef.current !== null) {\n window.cancelAnimationFrame(measurementFrameRef.current);\n measurementFrameRef.current = null;\n }\n\n if (followUpMeasurementTimeoutRef.current !== null) {\n window.clearTimeout(followUpMeasurementTimeoutRef.current);\n followUpMeasurementTimeoutRef.current = null;\n }\n }, []);\n\n const measureSize = useCallback(() => {\n if (!autoResize) return;\n\n const iframe = iframeRef.current;\n const iframeDocument = iframe?.contentDocument;\n if (!iframe || !iframeDocument) return;\n\n const renderedHeight = iframe.style.height;\n\n try {\n // measure from a stable viewport height so content sized with percentages or\n // viewport units cannot feed the iframe's previous height back into itself\n iframe.style.height = `${MIN_AUTO_HEIGHT}px`;\n\n const content =\n iframeDocument.querySelector<HTMLElement>('[data-iframe-content]') ?? iframeDocument.body;\n const contentRect = content.getBoundingClientRect();\n const { body, documentElement } = iframeDocument;\n const height = Math.min(\n Math.max(\n Math.ceil(\n Math.max(\n content.scrollHeight,\n content.offsetHeight,\n contentRect.height,\n body.scrollHeight,\n body.offsetHeight,\n documentElement.scrollHeight,\n documentElement.offsetHeight\n ) + AUTO_HEIGHT_BUFFER\n ),\n MIN_AUTO_HEIGHT\n ),\n MAX_AUTO_HEIGHT\n );\n\n setMeasuredHeight(height);\n } catch {\n // cross-origin iframe content cannot be measured; retain minimum height\n } finally {\n iframe.style.height = renderedHeight;\n }\n }, [autoResize]);\n\n const scheduleSizeMeasurement = useCallback(() => {\n if (!autoResize || measurementFrameRef.current !== null) return;\n\n measurementFrameRef.current = window.requestAnimationFrame(() => {\n measurementFrameRef.current = null;\n measureSize();\n\n if (followUpMeasurementTimeoutRef.current !== null) {\n window.clearTimeout(followUpMeasurementTimeoutRef.current);\n }\n\n followUpMeasurementTimeoutRef.current = window.setTimeout(() => {\n followUpMeasurementTimeoutRef.current = null;\n measureSize();\n }, 250);\n });\n }, [autoResize, measureSize]);\n\n const handleLoad: NonNullable<IframeProps['onLoad']> = (event) => {\n scheduleSizeMeasurement();\n\n const iframeDocument = iframeRef.current?.contentDocument;\n Array.from(iframeDocument?.images ?? []).forEach((image) => {\n if (image.complete) return;\n image.addEventListener('load', scheduleSizeMeasurement, { once: true });\n image.addEventListener('error', scheduleSizeMeasurement, { once: true });\n });\n iframeDocument?.fonts?.ready.then(scheduleSizeMeasurement).catch(() => undefined);\n\n onLoad?.(event);\n };\n\n useEffect(() => {\n if (!autoResize) return undefined;\n\n clearScheduledMeasurements();\n setMeasuredHeight(MIN_AUTO_HEIGHT);\n scheduleSizeMeasurement();\n\n return clearScheduledMeasurements;\n }, [autoResize, clearScheduledMeasurements, scheduleSizeMeasurement, srcDoc]);\n\n useEffect(() => {\n if (!autoResize) return undefined;\n\n window.addEventListener('resize', scheduleSizeMeasurement);\n window.visualViewport?.addEventListener('resize', scheduleSizeMeasurement);\n\n return () => {\n window.removeEventListener('resize', scheduleSizeMeasurement);\n window.visualViewport?.removeEventListener('resize', scheduleSizeMeasurement);\n };\n }, [autoResize, scheduleSizeMeasurement]);\n\n return (\n <div className={styles.wrapper}>\n {hasFullscreenView && (\n <div className={styles.toolbar}>\n <Button\n aria-expanded={isFullscreenOpen}\n aria-haspopup='dialog'\n onClick={() => setIsFullscreenOpen(true)}\n variant='tertiary'\n >\n {fullscreenLabel}\n </Button>\n </div>\n )}\n <iframe\n {...props}\n className={cx(styles.iframe, className)}\n loading={loading}\n onLoad={handleLoad}\n ref={iframeRef}\n referrerPolicy={referrerPolicy}\n sandbox={sandbox}\n srcDoc={srcDoc}\n style={\n autoResize\n ? {\n ...style,\n height: measuredHeight,\n minHeight: MIN_AUTO_HEIGHT,\n }\n : style\n }\n title={accessibleLabel}\n />\n {isFullscreenOpen && (\n <Dialog\n aria-label={`${accessibleLabel} fullscreen`}\n controls={\n <Controls>\n <Button onClick={() => setIsFullscreenOpen(false)}>{closeFullscreenLabel}</Button>\n </Controls>\n }\n fullscreen\n header={\n <Header>\n <h2>{accessibleLabel}</h2>\n </Header>\n }\n open\n setOpen={setIsFullscreenOpen}\n >\n <iframe\n {...props}\n className={cx(styles.iframe, styles['fullscreen-iframe'], className)}\n loading='eager'\n referrerPolicy={referrerPolicy}\n sandbox={sandbox}\n srcDoc={srcDoc}\n title={`${accessibleLabel} fullscreen`}\n />\n </Dialog>\n )}\n </div>\n );\n};\n"],"names":["MIN_AUTO_HEIGHT","MAX_AUTO_HEIGHT","AUTO_HEIGHT_BUFFER","Iframe","accessibleLabel","autoResize","className","closeFullscreenLabel","fullscreenLabel","hasFullscreenView","loading","onLoad","referrerPolicy","sandbox","srcDoc","style","props","iframeRef","useRef","measurementFrameRef","followUpMeasurementTimeoutRef","measuredHeight","setMeasuredHeight","useState","isFullscreenOpen","setIsFullscreenOpen","clearScheduledMeasurements","useCallback","current","window","cancelAnimationFrame","clearTimeout","measureSize","iframe","iframeDocument","contentDocument","renderedHeight","height","content","querySelector","body","contentRect","getBoundingClientRect","documentElement","Math","min","max","ceil","scrollHeight","offsetHeight","scheduleSizeMeasurement","requestAnimationFrame","setTimeout","handleLoad","event","Array","from","images","forEach","image","complete","addEventListener","once","fonts","ready","then","catch","useEffect","visualViewport","removeEventListener","styles","wrapper","toolbar","jsx","Button","cx","minHeight","Dialog","Controls","Header"],"mappings":";;;;;;;;;;;;GASMA,IAAkB,KAClBC,IAAkB,MAClBC,IAAqB,GAWdC,KAASA,CAAC;AAAA,EACrBC,iBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,WAAAA;AAAAA,EACAC,sBAAAA,IAAuB;AAAA,EACvBC,iBAAAA,IAAkB;AAAA,EAClBC,mBAAAA,IAAoB;AAAA,EACpBC,SAAAA,IAAU;AAAA,EACVC,QAAAA;AAAAA,EACAC,gBAAAA,IAAiB;AAAA,EACjBC,SAAAA,IAAU;AAAA,EACVC,QAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAMC,IAAYC,EAA0B,IAAI,GAC1CC,IAAsBD,EAAsB,IAAI,GAChDE,IAAgCF,EAAsB,IAAI,GAC1D,CAACG,GAAgBC,CAAiB,IAAIC,EAASvB,CAAe,GAC9D,CAACwB,GAAkBC,CAAmB,IAAIF,EAAS,EAAK,GAExDG,IAA6BC,EAAY,MAAM;AACnD,IAAIR,EAAoBS,YAAY,SAClCC,OAAOC,qBAAqBX,EAAoBS,OAAO,GACvDT,EAAoBS,UAAU,OAG5BR,EAA8BQ,YAAY,SAC5CC,OAAOE,aAAaX,EAA8BQ,OAAO,GACzDR,EAA8BQ,UAAU;AAAA,EAE5C,GAAG,CAAA,CAAE,GAECI,IAAcL,EAAY,MAAM;AACpC,QAAI,CAACtB,EAAY;AAEjB,UAAM4B,IAAShB,EAAUW,SACnBM,IAAiBD,KAAAA,gBAAAA,EAAQE;AAC/B,QAAI,CAACF,KAAU,CAACC,EAAgB;AAEhC,UAAME,IAAiBH,EAAOlB,MAAMsB;AAEpC,QAAI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B,QAAQhB;AAAAA,MACRuD,WAAW5E;AAAAA,IAAAA,IAEbe,GAEN,OAAOX,GAAgB;AAAA,IAExBoB,KACC,gBAAAiD,EAACI,GAAA,EACC,cAAY,GAAGzE,CAAe,eAC9B,UACE,gBAAAqE,EAACK,GAAA,EACC,UAAA,gBAAAL,EAACC,GAAA,EAAO,SAAS,MAAMjD,EAAoB,EAAK,GAAIlB,UAAAA,EAAAA,CAAqB,EAAA,CAC3E,GAEF,YAAU,IACV,QACE,gBAAAkE,EAACM,GAAA,EACC,UAAA,gBAAAN,EAAC,MAAA,EAAIrE,UAAAA,EAAAA,CAAgB,GACvB,GAEF,MAAI,IACJ,SAASqB,GAET,UAAA,gBAAAgD,EAAC,UAAA,EACC,GAAIzD,GACJ,WAAW2D,EAAGL,EAAOrC,QAAQqC,EAAO,mBAAmB,GAAGhE,CAAS,GACnE,SAAQ,SACR,gBAAAM,GACA,SAAAC,GACA,QAAAC,GACA,OAAO,GAAGV,CAAe,cAAA,CAAc,EAAA,CAE3C;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -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"),x=require("../avatar/index.cjs"),b=require("../icon/index.cjs"),j="_message_1bnsh_1",f="_timestamp_1bnsh_91",w="_attachments_1bnsh_96",S="_preview_1bnsh_115",t={"message-group":"_message-group_1bnsh_1",message:j,timestamp:f,attachments:w,preview:S},q=({appearance:o="default",attachments:i,author:a,authorColor:r,authorImageUrl:l,authorRole:d,content:g,iconName:_="info",id:p,preview:u,timestamp:m,timestampText:h,type:s="default"})=>{const n=m?new Date(m):void 0,c=n?e.jsx("time",{className:t.timestamp,dateTime:n.toISOString(),children:h??n.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,u&&t.preview),"data-appearance":o,"data-id":p,"data-type":s,children:[s=="system"&&e.jsx(b.Icon,{fill:!0,gap:"right",name:_}),g]}),i&&e.jsx("div",{className:t.attachments,children:i}),s!=="system"&&c]})};exports.Message=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index15.css');const e=require("react/jsx-runtime"),x=require("../../classix-5H4IWnMA.cjs"),j=require("../avatar/index.cjs"),h=require("../icon/index.cjs"),f="_message_8sz6c_1",w="_timestamp_8sz6c_87",z="_attachments_8sz6c_92",S="_preview_8sz6c_111",t={"message-group":"_message-group_8sz6c_1",message:f,timestamp:w,attachments:z,preview:S},b=({appearance:o="default",attachments:c,author:a,authorColor:r,authorImageUrl:l,authorRole:d,content:g,iconName:_="info",id:p,preview:u,timestamp:i,timestampText:v,type:s="default"})=>{const n=i?new Date(i):void 0,m=n?e.jsx("time",{className:t.timestamp,dateTime:n.toISOString(),children:v??n.toLocaleString()}):null;return e.jsxs("div",{className:t["message-group"],"data-message-type":s,"data-component":"message",children:[a&&e.jsx(j.Avatar,{accessibleLabel:a,color:r,imageUrl:l,name:a,role:d}),s==="system"&&m,e.jsxs("div",{className:x.t(t.message,u&&t.preview),"data-appearance":o,"data-id":p,"data-type":s,children:[s=="system"&&e.jsx(h.Icon,{fill:!0,gap:"right",name:_}),g]}),c&&e.jsx("div",{className:t.attachments,children:c}),s!=="system"&&m]})};exports.Message=b;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,41 +1,41 @@
1
1
  import { jsx as a, jsxs as r } from "react/jsx-runtime";
2
- import { t as b } from "../../classix-DG18itHa.js";
3
- import { Avatar as u } from "../avatar/index.js";
4
- import { Icon as w } from "../icon/index.js";
5
- import '../../assets/index15.css';const N = "_message_1bnsh_1", x = "_timestamp_1bnsh_91", S = "_attachments_1bnsh_96", j = "_preview_1bnsh_115", s = {
6
- "message-group": "_message-group_1bnsh_1",
2
+ import { t as u } from "../../classix-DG18itHa.js";
3
+ import { Avatar as w } from "../avatar/index.js";
4
+ import { Icon as z } from "../icon/index.js";
5
+ import '../../assets/index15.css';const N = "_message_8sz6c_1", x = "_timestamp_8sz6c_87", S = "_attachments_8sz6c_92", b = "_preview_8sz6c_111", s = {
6
+ "message-group": "_message-group_8sz6c_1",
7
7
  message: N,
8
8
  timestamp: x,
9
9
  attachments: S,
10
- preview: j
11
- }, D = ({
12
- appearance: c = "default",
13
- attachments: n,
10
+ preview: b
11
+ }, A = ({
12
+ appearance: n = "default",
13
+ attachments: c,
14
14
  author: t,
15
15
  authorColor: l,
16
16
  authorImageUrl: d,
17
17
  authorRole: g,
18
18
  content: p,
19
19
  iconName: _ = "info",
20
- id: h,
21
- preview: v,
20
+ id: v,
21
+ preview: f,
22
22
  timestamp: i,
23
- timestampText: f,
23
+ timestampText: h,
24
24
  type: e = "default"
25
25
  }) => {
26
- const m = i ? new Date(i) : void 0, o = m ? /* @__PURE__ */ a("time", { className: s.timestamp, dateTime: m.toISOString(), children: f ?? m.toLocaleString() }) : null;
26
+ const m = i ? new Date(i) : void 0, o = m ? /* @__PURE__ */ a("time", { className: s.timestamp, dateTime: m.toISOString(), children: h ?? m.toLocaleString() }) : null;
27
27
  return /* @__PURE__ */ r("div", { className: s["message-group"], "data-message-type": e, "data-component": "message", children: [
28
- t && /* @__PURE__ */ a(u, { accessibleLabel: t, color: l, imageUrl: d, name: t, role: g }),
28
+ t && /* @__PURE__ */ a(w, { accessibleLabel: t, color: l, imageUrl: d, name: t, role: g }),
29
29
  e === "system" && o,
30
- /* @__PURE__ */ r("div", { className: b(s.message, v && s.preview), "data-appearance": c, "data-id": h, "data-type": e, children: [
31
- e == "system" && /* @__PURE__ */ a(w, { fill: !0, gap: "right", name: _ }),
30
+ /* @__PURE__ */ r("div", { className: u(s.message, f && s.preview), "data-appearance": n, "data-id": v, "data-type": e, children: [
31
+ e == "system" && /* @__PURE__ */ a(z, { fill: !0, gap: "right", name: _ }),
32
32
  p
33
33
  ] }),
34
- n && /* @__PURE__ */ a("div", { className: s.attachments, children: n }),
34
+ c && /* @__PURE__ */ a("div", { className: s.attachments, children: c }),
35
35
  e !== "system" && o
36
36
  ] });
37
37
  };
38
38
  export {
39
- D as Message
39
+ A as Message
40
40
  };
41
41
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index17.css');const m=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:w,inline:n=!1,position:f="left",triggerAccessibleLabel:L,triggerAriaHasPopup:F,triggerButtonContent:y})=>{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=f==="auto"?"right":f,[v,E]=o.useState(g),h=({initialFocus:e}={})=>{R.current=e,k(!1),E(g),x(!0)},c=o.useCallback(({restoreFocus:e=!0}={})=>{var i;x(!1),e&&((i=l.current)==null||i.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=i=>{var r,_;const p=i.target;(r=P.current)!=null&&r.contains(p)||(_=b.current)!=null&&_.contains(p)||c({restoreFocus:!1})};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[c,t]);const a=o.useCallback(()=>{const e=b.current,i=l.current;if(!e||!i)return;const p=e.getBoundingClientRect(),r=i.getBoundingClientRect(),_=r.top,j=window.innerHeight-r.bottom;k(p.height>j&&_>j),E(f==="auto"&&p.width>window.innerWidth-r.left&&r.right>window.innerWidth-r.left?"left":g)},[f,g]);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 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(" "),z=t?m.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 w=="function"?w({close:c,initialFocus:R.current,isOpen:t}):w}):null;return m.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?m.jsx("span",{...B,ref:l,role:"button",tabIndex:0,children:y}):m.jsx(O.Button,{...B,ref:l,variant:"simple",children:y}),n&&z&&typeof document<"u"?K.createPortal(z,document.body):z]})};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 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,EAAMC,MAAQ,SAAWD,EAAMC,MAAQ,KAAM,CAC1DD,EAAMG,eAAAA,EACNX,EAAAA,EACA,MACF,CAEA,GAAIQ,EAAMC,MAAQ,YAAa,CAC7BD,EAAMG,eAAAA,EACNX,EAA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EACX,UAAWe,EACX,QAAUC,GAAU,CACd7B,KAAcgC,eAAAA,EAClBH,EAAM8B,gBAAAA,CACR,EACA,IAAKtD,EAAa,iBAAA,UAEjBL,SAAAA,CAAAA,EACCqE,EAAAA,IAAC,QACC,GAAIT,EACJ,IAAKhD,EACL,KAAK,SACL,SAAU,EAETR,WACH,EAEAiE,EAAAA,IAACM,UACC,GAAIf,EACJ,IAAKhD,EACL,QAAQ,YAEPR,SAAAA,CAAAA,CACH,EAEDJ,GAAUyC,GAAS,OAAOJ,SAAa,IACpCuC,EAAAA,aAAanC,EAAOJ,SAASwC,IAAI,EACjCpC,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 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='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","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,OAAu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AA,aAAanC,EAAOJ,SAASwC,IAAI,EACjCpC,CAAAA,EACN,CAEJ"}
@@ -23,7 +23,7 @@ import '../../assets/index17.css';const G = "_popover_1szho_1", J = "_inline_1sz
23
23
  triggerButtonContent: P
24
24
  }) => {
25
25
  var T;
26
- const D = h(null), E = h(void 0), _ = h(null), k = S(), a = h(null), [o, B] = y(!1), [u, R] = y(!1), d = f === "auto" ? "right" : f, [g, x] = y(d), v = ({
26
+ const D = h(null), E = h(void 0), _ = h(null), k = S(), a = h(null), [o, B] = y(!1), [u, R] = y(!1), d = f === "auto" ? "right" : f, [g, x] = y(d), m = ({
27
27
  initialFocus: e
28
28
  } = {}) => {
29
29
  E.current = e, R(!1), x(d), B(!0);
@@ -37,16 +37,16 @@ import '../../assets/index17.css';const G = "_popover_1szho_1", J = "_inline_1sz
37
37
  }, H = (e) => {
38
38
  if (!o) {
39
39
  if (t && (e.key === "Enter" || e.key === " ")) {
40
- e.preventDefault(), v();
40
+ e.preventDefault(), m();
41
41
  return;
42
42
  }
43
43
  if (e.key === "ArrowDown") {
44
- e.preventDefault(), v({
44
+ e.preventDefault(), m({
45
45
  initialFocus: "first"
46
46
  });
47
47
  return;
48
48
  }
49
- e.key === "ArrowUp" && (e.preventDefault(), v({
49
+ e.key === "ArrowUp" && (e.preventDefault(), m({
50
50
  initialFocus: "last"
51
51
  }));
52
52
  }
@@ -55,9 +55,9 @@ import '../../assets/index17.css';const G = "_popover_1szho_1", J = "_inline_1sz
55
55
  if (!o)
56
56
  return;
57
57
  const e = (s) => {
58
- var n, m;
58
+ var n, v;
59
59
  const p = s.target;
60
- (n = D.current) != null && n.contains(p) || (m = _.current) != null && m.contains(p) || l({
60
+ (n = D.current) != null && n.contains(p) || (v = _.current) != null && v.contains(p) || l({
61
61
  restoreFocus: !1
62
62
  });
63
63
  };
@@ -68,8 +68,8 @@ import '../../assets/index17.css';const G = "_popover_1szho_1", J = "_inline_1sz
68
68
  const i = A(() => {
69
69
  const e = _.current, s = a.current;
70
70
  if (!e || !s) return;
71
- const p = e.getBoundingClientRect(), n = s.getBoundingClientRect(), m = n.top, C = window.innerHeight - n.bottom;
72
- R(p.height > C && m > C), x(f === "auto" && p.width > window.innerWidth - n.left && n.right > window.innerWidth - n.left ? "left" : d);
71
+ const p = e.getBoundingClientRect(), n = s.getBoundingClientRect(), v = n.top, C = window.innerHeight - n.bottom;
72
+ R(p.height > C && v > C), x(f === "auto" && p.width > window.innerWidth - n.left && n.right > window.innerWidth - n.left ? "left" : d);
73
73
  }, [f, d]);
74
74
  X(() => {
75
75
  if (o)
@@ -80,7 +80,7 @@ import '../../assets/index17.css';const G = "_popover_1szho_1", J = "_inline_1sz
80
80
  const N = (e) => {
81
81
  t && e.preventDefault(), e.stopPropagation(), o ? l({
82
82
  restoreFocus: !1
83
- }) : v();
83
+ }) : m();
84
84
  }, L = {
85
85
  "aria-controls": o ? k : void 0,
86
86
  "aria-expanded": o,
@@ -102,7 +102,7 @@ import '../../assets/index17.css';const G = "_popover_1szho_1", J = "_inline_1sz
102
102
  return /* @__PURE__ */ W("div", { className: F(r.popover, t && r.inline), "data-open": o, onKeyDown: j, onClick: (e) => {
103
103
  t && e.preventDefault(), e.stopPropagation();
104
104
  }, ref: D, "data-component": "popover", children: [
105
- t ? /* @__PURE__ */ z("span", { ...L, ref: a, role: "button", tabIndex: 0, children: P }) : /* @__PURE__ */ z(q, { ...L, ref: a, variant: "secondary", children: P }),
105
+ t ? /* @__PURE__ */ z("span", { ...L, ref: a, role: "button", tabIndex: 0, children: P }) : /* @__PURE__ */ z(q, { ...L, ref: a, variant: "simple", children: P }),
106
106
  t && b && typeof document < "u" ? Y(b, document.body) : b
107
107
  ] });
108
108
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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":";;;;;;;;;;;;;;;;GA0CaA,KAAUA,CAAC;AAAA,EACtBC,UAAAA;AAAAA,EACAC,QAAAA,IAAS;AAAA,EACTC,UAAAA,IAAW;AAAA,EACXC,wBAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,sBAAAA;AACY,MAAM;;AAClB,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAkBD,EAAwCE,MAAS,GACnEC,IAAWH,EAAuB,IAAI,GACtCI,IAAUC,EAAAA,GACVC,IAAaN,EAA4C,IAAI,GAC7D,CAACO,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAYC,CAAa,IAAIF,EAAS,EAAK,GAC5CG,IAA+BjB,MAAa,SAAS,UAAUA,GAC/D,CAACkB,GAAqBC,CAAsB,IAAIL,EACpDG,CACF,GAEMG,IAAcA,CAAC;AAAA,IAAEC,cAAAA;AAAAA,EAAAA,IAAqC,OAAO;AACjEf,IAAAA,EAAgBgB,UAAUD,GAC1BL,EAAc,EAAK,GACnBG,EAAuBF,CAA4B,GACnDJ,EAAU,EAAI;AAAA,EAChB,GAEMU,IAAeC,EAAY,CAAC;AAAA,IAAEC,cAAAA,IAAe;AAAA,EAAA,IAA8B,OAAO;;AACtFZ,IAAAA,EAAU,EAAK,GAEXY,OACFd,IAAAA,EAAWW,YA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,eAAe,GACtBA,EAAO9C,IAAa,UAAU,OAAO,GACrChB,KAAU8D,EAAO,cAAc,GAC/B,CAAC9D,KAAU8D,EAAO3C,CAAmB,CACvC,GACA,6BAA2BA,GAC3B,kBAAgBH,IAAa,UAAU,SACvC,IAAIN,GACJ,KAAKD,GACL,OACEoC,IACI;AAAA,IACEU,MAAMpC,MAAwB,SAAS0B,EAAcW,QAAQX,EAAcU;AAAAA,IAC3EtD,UAAU;AAAA,IACV8C,KAAK/B,IAAa6B,EAAcE,MAAMF,EAAcM;AAAAA,IACpDoB,WAAWN,KAAmBzD;AAAAA,EAAAA,IAEhCA,QAGL,UAAA,OAAOT,KAAa,aACjBA,EAAS;AAAA,IAAEyE,OAAOhD;AAAAA,IAAcF,cAAcf,EAAgBgB;AAAAA,IAASV,QAAAA;AAAAA,EAAAA,CAAQ,IAC/Ed,EAAAA,CACN,IACE;AAEJ,SACE,gBAAA0E,EAAC,OAAA,EACC,WAAWH,EAAGR,EAAOY,SAAS1E,KAAU8D,EAAO9D,MAAM,GACrD,aAAWa,GACX,WAAWe,GACX,SAAUC,CAAAA,MAAU;AAClB,IAAI7B,OAAcgC,eAAAA,GAClBH,EAAM8B,gBAAAA;AAAAA,EACR,GACA,KAAKtD,GAAa,kBAAA,WAEjBL,UAAAA;AAAAA,IAAAA,IACC,gBAAAqE,EAAC,UACC,GAAIT,GACJ,KAAKhD,GACL,MAAK,UACL,UAAU,GAETR,aACH,IAEA,gBAAAiE,EAACM,KACC,GAAIf,GACJ,KAAKhD,GACL,SAAQ,aAEPR,UAAAA,EAAAA,CACH;AAAA,IAEDJ,KAAUyC,KAAS,OAAOJ,WAAa,MACpCuC,EAAanC,GAAOJ,SAASwC,IAAI,IACjCpC;AAAAA,EAAAA,GACN;AAEJ;"}
1
+ {"version":3,"file":"index.js","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='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","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":";;;;;;;;;;;;;;;;GA0CaA,KAAUA,CAAC;AAAA,EACtBC,UAAAA;AAAAA,EACAC,QAAAA,IAAS;AAAA,EACTC,UAAAA,IAAW;AAAA,EACXC,wBAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,sBAAAA;AACY,MAAM;;AAClB,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAkBD,EAAwCE,MAAS,GACnEC,IAAWH,EAAuB,IAAI,GACtCI,IAAUC,EAAAA,GACVC,IAAaN,EAA4C,IAAI,GAC7D,CAACO,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAYC,CAAa,IAAIF,EAAS,EAAK,GAC5CG,IAA+BjB,MAAa,SAAS,UAAUA,GAC/D,CAACkB,GAAqBC,CAAsB,IAAIL,EACpDG,CACF,GAEMG,IAAcA,CAAC;AAAA,IAAEC,cAAAA;AAAAA,EAAAA,IAAqC,OAAO;AACjEf,IAAAA,EAAgBgB,UAAUD,GAC1BL,EAAc,EAAK,GACnBG,EAAuBF,CAA4B,GACnDJ,EAAU,EAAI;AAAA,EAChB,GAEMU,IAAeC,EAAY,CAAC;AAAA,IAAEC,cAAAA,IAAe;AAAA,EAAA,IAA8B,OAAO;;AACtFZ,IAAAA,EAAU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D,EAAC,OAAA,EACC,WAAWC,EACTR,EAAO,eAAe,GACtBA,EAAO9C,IAAa,UAAU,OAAO,GACrChB,KAAU8D,EAAO,cAAc,GAC/B,CAAC9D,KAAU8D,EAAO3C,CAAmB,CACvC,GACA,6BAA2BA,GAC3B,kBAAgBH,IAAa,UAAU,SACvC,IAAIN,GACJ,KAAKD,GACL,OACEoC,IACI;AAAA,IACEU,MAAMpC,MAAwB,SAAS0B,EAAcW,QAAQX,EAAcU;AAAAA,IAC3EtD,UAAU;AAAA,IACV8C,KAAK/B,IAAa6B,EAAcE,MAAMF,EAAcM;AAAAA,IACpDoB,WAAWN,KAAmBzD;AAAAA,EAAAA,IAEhCA,QAGL,UAAA,OAAOT,KAAa,aACjBA,EAAS;AAAA,IAAEyE,OAAOhD;AAAAA,IAAcF,cAAcf,EAAgBgB;AAAAA,IAASV,QAAAA;AAAAA,EAAAA,CAAQ,IAC/Ed,EAAAA,CACN,IACE;AAEJ,SACE,gBAAA0E,EAAC,OAAA,EACC,WAAWH,EAAGR,EAAOY,SAAS1E,KAAU8D,EAAO9D,MAAM,GACrD,aAAWa,GACX,WAAWe,GACX,SAAUC,CAAAA,MAAU;AAClB,IAAI7B,OAAcgC,eAAAA,GAClBH,EAAM8B,gBAAAA;AAAAA,EACR,GACA,KAAKtD,GAAa,kBAAA,WAEjBL,UAAAA;AAAAA,IAAAA,IACC,gBAAAqE,EAAC,UACC,GAAIT,GACJ,KAAKhD,GACL,MAAK,UACL,UAAU,GAETR,aACH,IAEA,gBAAAiE,EAACM,KACC,GAAIf,GACJ,KAAKhD,GACL,SAAQ,UAEPR,UAAAA,EAAAA,CACH;AAAA,IAEDJ,KAAUyC,KAAS,OAAOJ,WAAa,MACpCuC,EAAanC,GAAOJ,SAASwC,IAAI,IACjCpC;AAAAA,EAAAA,GACN;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index9.css');const n=require("react/jsx-runtime"),h=require("react"),p=require("../button/index.cjs"),D=require("../checkbox/index.cjs"),M=require("../chip/index.cjs"),N=require("../controls/index.cjs"),C=require("../dialog/index.cjs"),I=require("../header/index.cjs"),O=require("../../index-CEzqxRIu.cjs"),R="_search_lzc4l_3",w="_controls_lzc4l_15",B="_chips_lzc4l_29",l={search:R,controls:w,chips:B,"filter-groups":"_filter-groups_lzc4l_36","filter-group":"_filter-group_lzc4l_36"},S=({closeLabel:m="Close",filterButtonLabel:_="Filters",filterDialogTitle:b="Filters",filterGroups:o=[],onChange:j,onSelectedFiltersChange:c,removeFilterLabel:v=r=>`Remove ${r.label} filter`,resetLabel:g="Reset",searchLabel:y="Search",searchPlaceholder:k="Search",selectedFilters:t=[],value:f=""})=>{const r=h.useId(),[x,i]=h.useState(!1),q=h.useMemo(()=>new Map(o.flatMap(e=>e.options).map(e=>[e.value,e])),[o]),u=t.flatMap(e=>{const s=q.get(e);return s?[s]:[]}),d=(e,s)=>{c&&c(s?[...new Set([...t,e])]:t.filter(a=>a!==e))};return n.jsxs("div",{className:l.search,"data-component":"search",children:[n.jsxs("div",{className:l.controls,children:[n.jsx(O.Input,{"aria-label":y,icon:"search",onChange:e=>j(e.target.value),placeholder:k,type:"search",value:f}),o.length>0&&n.jsx(p.Button,{"aria-expanded":x,"aria-haspopup":"dialog",badge:u.length,icon:"funnel",onClick:()=>i(!0),variant:"tertiary",children:_})]}),u.length>0&&n.jsxs("div",{"aria-label":_,className:l.chips,children:[u.map(e=>n.jsx(M.Chip,{accessibleLabel:v(e),label:e.label,onClick:()=>d(e.value,!1),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),d(e.value,!1))},role:"button"},e.value)),n.jsx(p.Button,{onClick:()=>c==null?void 0:c([]),variant:"tertiary",children:g})]}),x&&n.jsx(C.Dialog,{"aria-labelledby":r,controls:n.jsx(N.Controls,{children:n.jsx(p.Button,{onClick:()=>i(!1),children:m})}),header:n.jsx(I.Header,{children:n.jsx("h2",{id:r,children:b})}),open:!0,setOpen:i,children:n.jsx("div",{className:l["filter-groups"],children:o.map((e,s)=>n.jsxs("fieldset",{className:l["filter-group"],children:[e.label&&n.jsx("legend",{children:e.label}),e.options.map(a=>n.jsx(D.Checkbox,{checked:t.includes(a.value),label:a.label,onChange:z=>d(a.value,z.target.checked)},a.value))]},e.label??s))})})]})};exports.Search=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index9.css');const n=require("react/jsx-runtime"),h=require("react"),p=require("../button/index.cjs"),M=require("../checkbox/index.cjs"),N=require("../chip/index.cjs"),C=require("../controls/index.cjs"),I=require("../dialog/index.cjs"),O=require("../header/index.cjs"),R=require("../../index-CEzqxRIu.cjs"),w="_search_14b9n_3",B="_controls_14b9n_15",S="_chips_14b9n_29",o={search:w,controls:B,chips:S,"filter-groups":"_filter-groups_14b9n_36","filter-group":"_filter-group_14b9n_36"},T=({closeLabel:b="Close",filterButtonLabel:_="Filters",filterDialogTitle:m="Filters",filterGroups:l=[],onChange:j,onSelectedFiltersChange:c,removeFilterLabel:v=r=>`Remove ${r.label} filter`,resetLabel:g="Reset",searchLabel:y="Search",searchPlaceholder:k="Search",selectedFilters:t=[],value:f=""})=>{const r=h.useId(),[x,i]=h.useState(!1),q=h.useMemo(()=>new Map(l.flatMap(e=>e.options).map(e=>[e.value,e])),[l]),u=t.flatMap(e=>{const s=q.get(e);return s?[s]:[]}),d=(e,s)=>{c&&c(s?[...new Set([...t,e])]:t.filter(a=>a!==e))};return n.jsxs("div",{className:o.search,"data-component":"search",children:[n.jsxs("div",{className:o.controls,children:[n.jsx(R.Input,{"aria-label":y,icon:"search",onChange:e=>j(e.target.value),placeholder:k,type:"search",value:f}),l.length>0&&n.jsx(p.Button,{"aria-expanded":x,"aria-haspopup":"dialog",badge:u.length,icon:"funnel",onClick:()=>i(!0),variant:"tertiary",children:_})]}),u.length>0&&n.jsxs("div",{"aria-label":_,className:o.chips,children:[u.map(e=>n.jsx(N.Chip,{accessibleLabel:v(e),label:e.label,onClick:()=>d(e.value,!1),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),d(e.value,!1))},role:"button"},e.value)),n.jsx(p.Button,{onClick:()=>c==null?void 0:c([]),variant:"tertiary",children:g})]}),x&&n.jsx(I.Dialog,{"aria-labelledby":r,controls:n.jsx(C.Controls,{children:n.jsx(p.Button,{onClick:()=>i(!1),children:b})}),header:n.jsx(O.Header,{children:n.jsx("h2",{id:r,children:m})}),open:!0,setOpen:i,children:n.jsx("div",{className:o["filter-groups"],children:l.map((e,s)=>n.jsxs("fieldset",{className:o["filter-group"],children:[e.label&&n.jsx("legend",{children:e.label}),e.options.map(a=>n.jsx(M.Checkbox,{checked:t.includes(a.value),label:a.label,onChange:D=>d(a.value,D.target.checked)},a.value))]},e.label??s))})})]})};exports.Search=T;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,52 +1,52 @@
1
1
  import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { useId as N, useState as C, useMemo as M } from "react";
2
+ import { useId as C, useState as M, useMemo as w } from "react";
3
3
  import { Button as d } from "../button/index.js";
4
- import { Checkbox as w } from "../checkbox/index.js";
5
- import { Chip as O } from "../chip/index.js";
6
- import { Controls as j } from "../controls/index.js";
7
- import { Dialog as R } from "../dialog/index.js";
8
- import { Header as B } from "../header/index.js";
9
- import { I as E } from "../../index-BHgGZxsR.js";
10
- import '../../assets/index9.css';const H = "_search_lzc4l_3", K = "_controls_lzc4l_15", T = "_chips_lzc4l_29", c = {
11
- search: H,
12
- controls: K,
13
- chips: T,
14
- "filter-groups": "_filter-groups_lzc4l_36",
15
- "filter-group": "_filter-group_lzc4l_36"
4
+ import { Checkbox as O } from "../checkbox/index.js";
5
+ import { Chip as j } from "../chip/index.js";
6
+ import { Controls as R } from "../controls/index.js";
7
+ import { Dialog as B } from "../dialog/index.js";
8
+ import { Header as E } from "../header/index.js";
9
+ import { I as H } from "../../index-BHgGZxsR.js";
10
+ import '../../assets/index9.css';const K = "_search_14b9n_3", T = "_controls_14b9n_15", $ = "_chips_14b9n_29", n = {
11
+ search: K,
12
+ controls: T,
13
+ chips: $,
14
+ "filter-groups": "_filter-groups_14b9n_36",
15
+ "filter-group": "_filter-group_14b9n_36"
16
16
  }, V = ({
17
- closeLabel: b = "Close",
17
+ closeLabel: f = "Close",
18
18
  filterButtonLabel: u = "Filters",
19
19
  filterDialogTitle: v = "Filters",
20
- filterGroups: s = [],
20
+ filterGroups: c = [],
21
21
  onChange: _,
22
22
  onSelectedFiltersChange: o,
23
- removeFilterLabel: g = (n) => `Remove ${n.label} filter`,
23
+ removeFilterLabel: g = (i) => `Remove ${i.label} filter`,
24
24
  resetLabel: k = "Reset",
25
25
  searchLabel: y = "Search",
26
26
  searchPlaceholder: x = "Search",
27
- selectedFilters: i = [],
28
- value: z = ""
27
+ selectedFilters: s = [],
28
+ value: D = ""
29
29
  }) => {
30
- const n = N(), [f, p] = C(!1), D = M(() => new Map(s.flatMap((a) => a.options).map((a) => [a.value, a])), [s]), h = i.flatMap((a) => {
31
- const l = D.get(a);
30
+ const i = C(), [b, p] = M(!1), I = w(() => new Map(c.flatMap((a) => a.options).map((a) => [a.value, a])), [c]), h = s.flatMap((a) => {
31
+ const l = I.get(a);
32
32
  return l ? [l] : [];
33
33
  }), m = (a, l) => {
34
- o && o(l ? [.../* @__PURE__ */ new Set([...i, a])] : i.filter((r) => r !== a));
34
+ o && o(l ? [.../* @__PURE__ */ new Set([...s, a])] : s.filter((r) => r !== a));
35
35
  };
36
- return /* @__PURE__ */ t("div", { className: c.search, "data-component": "search", children: [
37
- /* @__PURE__ */ t("div", { className: c.controls, children: [
38
- /* @__PURE__ */ e(E, { "aria-label": y, icon: "search", onChange: (a) => _(a.target.value), placeholder: x, type: "search", value: z }),
39
- s.length > 0 && /* @__PURE__ */ e(d, { "aria-expanded": f, "aria-haspopup": "dialog", badge: h.length, icon: "funnel", onClick: () => p(!0), variant: "tertiary", children: u })
36
+ return /* @__PURE__ */ t("div", { className: n.search, "data-component": "search", children: [
37
+ /* @__PURE__ */ t("div", { className: n.controls, children: [
38
+ /* @__PURE__ */ e(H, { "aria-label": y, icon: "search", onChange: (a) => _(a.target.value), placeholder: x, type: "search", value: D }),
39
+ c.length > 0 && /* @__PURE__ */ e(d, { "aria-expanded": b, "aria-haspopup": "dialog", badge: h.length, icon: "funnel", onClick: () => p(!0), variant: "tertiary", children: u })
40
40
  ] }),
41
- h.length > 0 && /* @__PURE__ */ t("div", { "aria-label": u, className: c.chips, children: [
42
- h.map((a) => /* @__PURE__ */ e(O, { accessibleLabel: g(a), label: a.label, onClick: () => m(a.value, !1), onKeyDown: (l) => {
41
+ h.length > 0 && /* @__PURE__ */ t("div", { "aria-label": u, className: n.chips, children: [
42
+ h.map((a) => /* @__PURE__ */ e(j, { accessibleLabel: g(a), label: a.label, onClick: () => m(a.value, !1), onKeyDown: (l) => {
43
43
  (l.key === "Enter" || l.key === " ") && (l.preventDefault(), m(a.value, !1));
44
44
  }, role: "button" }, a.value)),
45
45
  /* @__PURE__ */ e(d, { onClick: () => o == null ? void 0 : o([]), variant: "tertiary", children: k })
46
46
  ] }),
47
- f && /* @__PURE__ */ e(R, { "aria-labelledby": n, controls: /* @__PURE__ */ e(j, { children: /* @__PURE__ */ e(d, { onClick: () => p(!1), children: b }) }), header: /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e("h2", { id: n, children: v }) }), open: !0, setOpen: p, children: /* @__PURE__ */ e("div", { className: c["filter-groups"], children: s.map((a, l) => /* @__PURE__ */ t("fieldset", { className: c["filter-group"], children: [
47
+ b && /* @__PURE__ */ e(B, { "aria-labelledby": i, controls: /* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(d, { onClick: () => p(!1), children: f }) }), header: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e("h2", { id: i, children: v }) }), open: !0, setOpen: p, children: /* @__PURE__ */ e("div", { className: n["filter-groups"], children: c.map((a, l) => /* @__PURE__ */ t("fieldset", { className: n["filter-group"], children: [
48
48
  a.label && /* @__PURE__ */ e("legend", { children: a.label }),
49
- a.options.map((r) => /* @__PURE__ */ e(w, { checked: i.includes(r.value), label: r.label, onChange: (I) => m(r.value, I.target.checked) }, r.value))
49
+ a.options.map((r) => /* @__PURE__ */ e(O, { checked: s.includes(r.value), label: r.label, onChange: (N) => m(r.value, N.target.checked) }, r.value))
50
50
  ] }, a.label ?? l)) }) })
51
51
  ] });
52
52
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("../../icons-Dx0NQYLH.cjs");const e=require("../../index-oL8GYbhj.cjs");require("../../use-touched-D_TJ8wDc.cjs");exports.Select=e.Select;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("../../icons-Dx0NQYLH.cjs");const e=require("../../index-BPIK2dxs.cjs");require("../../use-touched-D_TJ8wDc.cjs");exports.Select=e.Select;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../classix-DG18itHa.js";
3
3
  import "../../icons-BFgf_lJN.js";
4
- import { S as e } from "../../index-CMfR_USP.js";
4
+ import { S as e } from "../../index-C_YiNpZP.js";
5
5
  import "../../use-touched-DXIJVVzz.js";
6
6
  export {
7
7
  e as Select
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index8.css');const H=require("react/jsx-runtime"),O=require("../../classix-5H4IWnMA.cjs"),c=require("react"),G=require("../list/index.cjs"),J="_sortable_12gha_1",K="_dragging_12gha_13",Q="_dropping_12gha_28",tt="_columns_12gha_42",et="_pseudo_12gha_51",f={sortable:J,dragging:K,dropping:Q,columns:tt,pseudo:et,"target-above":"_target-above_12gha_66","target-below":"_target-below_12gha_67"},X=c.createContext(null);function nt(){return c.useContext(X)}function rt({children:M,className:$,columns:E=1,isRearranging:x=!1,onChangeOrder:k,...A}){const B=Number.isFinite(E)?Math.max(1,Math.floor(E)):1,S=c.useMemo(()=>c.Children.toArray(M),[M]),u=c.useRef(-1),R=c.useMemo(()=>typeof window<"u"&&(navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches),[]),i=c.useRef(!1),D=c.useRef(null),v=c.useRef(null),b=c.useRef(null),T=c.useRef(!1),_=c.useRef(null),d=c.useRef(null),[w,F]=c.useState({height:0,width:0}),[h,g]=c.useState(null),[z,q]=c.useState(null),L={...A.style,"--height":`calc(${w.height}px - var(--scale-16))`,"--width":B>1?`calc(${w.width}px - var(--scale-16))`:`${w.width}px`},V=o=>{k(o.map((t,s)=>({id:String(c.isValidElement(t)?t.props["data-id"]??`idx-${s}`:`idx-${s}`),weight:o.length-1-s})))},y=(o,t)=>{if(t<0||t>=S.length||o===t)return;const s=S.slice(),[e]=s.splice(o,1);s.splice(t,0,e),q(t),V(s)},m=()=>{v.current!==null&&(clearTimeout(v.current),v.current=null)},C=()=>{d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)},W=o=>{let t=(o==null?void 0:o.parentElement)??null;for(;t;){const{overflowY:s}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(s)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return document.scrollingElement instanceof HTMLElement?document.scrollingElement:null},P=()=>{m(),C(),_.current=null,i.current=!1,D.current=null,b.current=null,T.current=!1,u.current=-1,g(null)},U=o=>o instanceof Element&&!!o.closest('button, a, input, textarea, select, option, [role="button"], [contenteditable="true"]'),Y=(o,t)=>{var N;const s=(N=document.elementFromPoint(o,t))==null?void 0:N.closest("[data-sortable-index]");if(!s)return;const e=Number(s.dataset.sortableIndex),n=u.current;if(!Number.isInteger(e)||n<0||e===n)return;const r=s.getBoundingClientRect(),a=e===n+1?w.height:r.height,l=t>r.top+a/2?e+1:e,I=l>n?l-1:l;D.current=I,g(I)},Z=o=>{const t=W(o);if(!t)return;const s=72,e=18,n=()=>{if(!i.current){d.current=null;return}const r=_.current;if(!r){d.current=requestAnimationFrame(n);return}const a=t===document.scrollingElement?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect();let p=0;if(r.y<a.top+s){const l=Math.max(0,r.y-a.top);p=-e*(1-l/s)}else if(r.y>a.bottom-s){const l=Math.max(0,a.bottom-r.y);p=e*(1-l/s)}p!==0&&(t.scrollBy({top:p,behavior:"auto"}),Y(r.x,r.y)),d.current=requestAnimationFrame(n)};C(),d.current=requestAnimationFrame(n)},j=()=>{u.current=-1,g(null)};return c.useEffect(()=>{x||q(null)},[x]),c.useEffect(()=>()=>{m(),C()},[]),c.useEffect(()=>{const o=t=>{i.current&&t.preventDefault()};return window.addEventListener("touchmove",o,{passive:!1}),()=>{m(),window.removeEventListener("touchmove",o)}},[]),H.jsx(G.List,{className:O.t($,f.sortable,B>1&&f.columns),columns:E,ordered:!0,style:L,...A,"data-component":"sortable",children:S.map((o,t)=>{const s=c.isValidElement(o)?o.key:null;return H.jsx("li",{"data-sortable-index":t,onClickCapture:e=>{T.current&&(e.preventDefault(),e.stopPropagation(),T.current=!1)},className:O.t(h!==null&&h>t-10&&h<t+10&&f.pseudo,h===t&&u.current<t&&f["target-below"],h===t&&u.current>t&&f["target-above"],u.current===t&&f.dragging,z===t&&x&&f.dropping),onContextMenu:e=>{(i.current||v.current!==null)&&e.preventDefault()},onTouchStart:e=>{if(x||U(e.target))return;const n=e.touches[0];if(!n)return;const r=e.currentTarget;b.current={index:t,x:n.clientX,y:n.clientY},m(),v.current=setTimeout(()=>{u.current=t,i.current=!0,D.current=t,T.current=!0,F({height:r.offsetHeight,width:r.offsetWidth}),g(t),_.current={x:n.clientX,y:n.clientY},Z(r)},350)},onTouchMove:e=>{const n=e.touches[0];if(n){if(_.current={x:n.clientX,y:n.clientY},!i.current){const r=b.current;if(!r)return;Math.hypot(n.clientX-r.x,n.clientY-r.y)>8&&(m(),b.current=null);return}Y(n.clientX,n.clientY)}},onTouchEnd:e=>{if(m(),!i.current){b.current=null;return}e.preventDefault();const n=u.current,r=D.current;n>=0&&r!==null&&n!==r&&y(n,r),P()},onTouchCancel:()=>P(),draggable:!x&&!R,onDragEnd:()=>j(),onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move";const n=u.current;if(n<0||n===t)return;const r=e.currentTarget.getBoundingClientRect(),a=t===n+1?w.height:r.height,l=e.clientY>r.top+a/2?t+1:t,I=l>n?l-1:l;g(I)},onDragStart:e=>{if(R){e.preventDefault();return}u.current=t,F({height:e.currentTarget.offsetHeight,width:e.currentTarget.offsetWidth}),e.dataTransfer.setData("text/plain",""),e.dataTransfer.effectAllowed="move",g(t)},onDrop:e=>{e.preventDefault();const n=u.current,r=h;n<0||r===null||n===r||(y(n,r),j())},"data-component":"sortable",children:H.jsx(X.Provider,{value:{canMoveDown:t<S.length-1,canMoveUp:t>0,index:t,moveDown:()=>y(t,t+1),moveUp:()=>y(t,t-1)},children:o})},s??t)})})}exports.Sortable=rt;exports.useOptionalSortableItem=nt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index8.css');const q=require("react/jsx-runtime"),X=require("../../classix-5H4IWnMA.cjs"),s=require("react"),Z=require("../list/index.cjs"),G="_sortable_iw0r0_1",J="_dragging_iw0r0_13",K="_columns_iw0r0_38",Q="_pseudo_iw0r0_47",b={sortable:G,dragging:J,columns:K,pseudo:Q,"target-above":"_target-above_iw0r0_62","target-below":"_target-below_iw0r0_63"},k=s.createContext(null);function tt(){return s.useContext(k)}const h=a=>Number.parseFloat(a)||0,et=a=>{const w=a.firstElementChild,i=a.getBoundingClientRect();if(w){const y=w.getBoundingClientRect();return{borderRadius:window.getComputedStyle(w).borderRadius,height:y.height,width:y.width,wrapperHeight:i.height}}const u=window.getComputedStyle(a),A=h(u.borderLeftWidth)+h(u.borderRightWidth)+h(u.paddingLeft)+h(u.paddingRight),T=h(u.borderBottomWidth)+h(u.borderTopWidth)+h(u.paddingBottom)+h(u.paddingTop);return{borderRadius:u.borderRadius,height:Math.max(0,i.height-T),width:Math.max(0,i.width-A),wrapperHeight:i.height}};function nt({children:a,className:w,columns:i=1,isRearranging:u=!1,onChangeOrder:A,...T}){const y=Number.isFinite(i)?Math.max(1,Math.floor(i)):1,R=s.useMemo(()=>s.Children.toArray(a),[a]),l=s.useRef(-1),L=s.useMemo(()=>typeof window<"u"&&(navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches),[]),p=s.useRef(!1),_=s.useRef(null),v=s.useRef(null),x=s.useRef(null),I=s.useRef(0),C=s.useRef(null),g=s.useRef(null),E=s.useRef(o=>o.preventDefault()).current,[M,O]=s.useState({borderRadius:"0px",height:0,width:0,wrapperHeight:0}),[m,S]=s.useState(null),W={...T.style,"--sortable-placeholder-height":`${M.height}px`,"--sortable-placeholder-radius":M.borderRadius,"--sortable-placeholder-width":`${M.width}px`},H=(o,t)=>{if(t<0||t>=R.length||o===t)return;const c=R.slice(),[e]=c.splice(o,1);c.splice(t,0,e),A(c.map((n,r)=>({id:String(s.isValidElement(n)?n.props["data-id"]??`idx-${r}`:`idx-${r}`),weight:c.length-1-r})))},D=()=>{v.current!==null&&(clearTimeout(v.current),v.current=null)},B=()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null)},$=o=>{let t=(o==null?void 0:o.parentElement)??null;for(;t;){const{overflowY:c}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(c)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return document.scrollingElement instanceof HTMLElement?document.scrollingElement:null},P=(o=!1)=>{D(),B(),window.removeEventListener("touchmove",E),C.current=null,p.current=!1,_.current=null,x.current=null,I.current=o?Date.now()+500:0,l.current=-1,S(null)},N=(o,t)=>{l.current=o,O(et(t)),S(o)},U=o=>o instanceof Element&&!!o.closest('button, a, input, textarea, select, option, [role="button"], [contenteditable="true"]'),Y=(o,t,c)=>{const e=l.current;if(!Number.isInteger(t)||e<0||t===e)return null;const n=o.getBoundingClientRect(),r=t===e+1?M.wrapperHeight:n.height,d=c>n.top+r/2?t+1:t;return d>e?d-1:d},j=(o,t)=>{var n;const c=(n=document.elementFromPoint(o,t))==null?void 0:n.closest("[data-sortable-index]");if(!c)return;const e=Y(c,Number(c.dataset.sortableIndex),t);e!==null&&(_.current=e,S(e))},V=o=>{const t=$(o);if(!t)return;const c=72,e=18,n=()=>{if(!p.current){g.current=null;return}const r=C.current;if(!r){g.current=requestAnimationFrame(n);return}const f=t===document.scrollingElement?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect();let d=0;if(r.y<f.top+c){const F=Math.max(0,r.y-f.top);d=-e*(1-F/c)}else if(r.y>f.bottom-c){const F=Math.max(0,f.bottom-r.y);d=e*(1-F/c)}d!==0&&(t.scrollBy({top:d,behavior:"auto"}),j(r.x,r.y)),g.current=requestAnimationFrame(n)};B(),g.current=requestAnimationFrame(n)},z=()=>{l.current=-1,S(null)};return s.useEffect(()=>()=>{D(),B(),window.removeEventListener("touchmove",E)},[E]),q.jsx(Z.List,{className:X.t(w,b.sortable,y>1&&b.columns),columns:i,ordered:!0,style:W,...T,"data-component":"sortable",children:R.map((o,t)=>{const c=s.isValidElement(o)?o.key:null;return q.jsx("li",{"data-sortable-index":t,onClickCapture:e=>{I.current<=Date.now()||(e.preventDefault(),e.stopPropagation(),I.current=0)},className:X.t(m!==null&&m>t-10&&m<t+10&&b.pseudo,m===t&&l.current<t&&b["target-below"],m===t&&l.current>t&&b["target-above"],l.current===t&&b.dragging),onContextMenu:e=>{(p.current||v.current!==null)&&e.preventDefault()},onTouchStart:e=>{if(u||U(e.target))return;I.current=0;const n=e.touches[0];if(!n)return;const r=e.currentTarget;x.current={x:n.clientX,y:n.clientY},D(),v.current=setTimeout(()=>{N(t,r),p.current=!0,_.current=t,C.current={x:n.clientX,y:n.clientY},window.addEventListener("touchmove",E,{passive:!1}),V(r)},350)},onTouchMove:e=>{const n=e.touches[0];if(n){if(C.current={x:n.clientX,y:n.clientY},!p.current){const r=x.current;if(!r)return;Math.hypot(n.clientX-r.x,n.clientY-r.y)>8&&(D(),x.current=null);return}j(n.clientX,n.clientY)}},onTouchEnd:e=>{if(D(),!p.current){x.current=null;return}e.preventDefault();const n=l.current,r=_.current;n>=0&&r!==null&&n!==r&&H(n,r),P(!0)},onTouchCancel:()=>P(),draggable:!u&&!L,onDragEnd:()=>z(),onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move";const n=Y(e.currentTarget,t,e.clientY);n!==null&&S(n)},onDragStart:e=>{if(L){e.preventDefault();return}N(t,e.currentTarget),e.dataTransfer.setData("text/plain",""),e.dataTransfer.effectAllowed="move"},onDrop:e=>{e.preventDefault();const n=l.current,r=m;n<0||r===null||n===r||(H(n,r),z())},"data-component":"sortable",children:q.jsx(k.Provider,{value:{canMoveDown:t<R.length-1,canMoveUp:t>0,index:t,moveDown:()=>H(t,t+1),moveUp:()=>H(t,t-1)},children:o})},c??t)})})}exports.Sortable=nt;exports.useOptionalSortableItem=tt;
2
2
  //# sourceMappingURL=index.cjs.map