@solibo/solibo-ui 1.0.7 → 1.0.10

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 (52) 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/editor/index.cjs +25 -25
  20. package/dist/components/editor/index.cjs.map +1 -1
  21. package/dist/components/editor/index.js +1561 -1550
  22. package/dist/components/editor/index.js.map +1 -1
  23. package/dist/components/icon/index.cjs +1 -1
  24. package/dist/components/icon/index.js +22 -22
  25. package/dist/components/iframe/index.cjs +1 -1
  26. package/dist/components/iframe/index.cjs.map +1 -1
  27. package/dist/components/iframe/index.js +46 -49
  28. package/dist/components/iframe/index.js.map +1 -1
  29. package/dist/components/message/index.cjs +1 -1
  30. package/dist/components/message/index.js +18 -18
  31. package/dist/components/popover/index.cjs +1 -1
  32. package/dist/components/popover/index.cjs.map +1 -1
  33. package/dist/components/popover/index.js +10 -10
  34. package/dist/components/popover/index.js.map +1 -1
  35. package/dist/components/search/index.cjs +1 -1
  36. package/dist/components/search/index.js +29 -29
  37. package/dist/components/select/index.cjs +1 -1
  38. package/dist/components/select/index.js +1 -1
  39. package/dist/components/sortable/index.cjs +1 -1
  40. package/dist/components/sortable/index.cjs.map +1 -1
  41. package/dist/components/sortable/index.js +141 -134
  42. package/dist/components/sortable/index.js.map +1 -1
  43. package/dist/{index-oL8GYbhj.cjs → index-BPIK2dxs.cjs} +2 -2
  44. package/dist/{index-oL8GYbhj.cjs.map → index-BPIK2dxs.cjs.map} +1 -1
  45. package/dist/{index-CMfR_USP.js → index-C_YiNpZP.js} +8 -8
  46. package/dist/{index-CMfR_USP.js.map → index-C_YiNpZP.js.map} +1 -1
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.d.ts +13 -2
  49. package/dist/index.js +37 -36
  50. package/dist/tokens.css +3 -1
  51. package/dist/tokens.json +46 -19
  52. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index46.css');const r=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),t=require("../../icons-Dx0NQYLH.cjs"),m="_icon_vhz6u_1",u="_small_vhz6u_10",_="_medium_vhz6u_15",g="_large_vhz6u_20",d="_danger_vhz6u_25",e={icon:m,small:u,medium:_,large:g,danger:d,"gap-right":"_gap-right_vhz6u_29","gap-left":"_gap-left_vhz6u_33"},h={large:e.large,medium:e.medium,small:e.small},v={danger:e.danger},z=({fill:o,gap:n="none",name:a,size:c="medium",variant:s})=>{const i={maskImage:t.iconSVG(a,o??!1)};return r.jsx("span",{"aria-hidden":"true",className:l.t(n!=="none"&&e[`gap-${n}`],h[c],e.icon,s&&v[s]),style:i,"data-component":"icon"})},p=()=>Object.keys(t.iconPaths);exports.Icon=z;exports.Icons=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index46.css');const m=require("react/jsx-runtime"),r=require("../../classix-5H4IWnMA.cjs"),t=require("../../icons-Dx0NQYLH.cjs"),l="_icon_ihnm9_1",_="_small_ihnm9_10",g="_medium_ihnm9_15",d="_large_ihnm9_20",u="_danger_ihnm9_25",n={icon:l,small:_,medium:g,large:d,danger:u,"gap-right":"_gap-right_ihnm9_29","gap-left":"_gap-left_ihnm9_33"},h={large:n.large,medium:n.medium,small:n.small},p={danger:n.danger},y=({fill:i,gap:e="none",name:o,size:a="medium",variant:s})=>{const c={maskImage:t.iconSVG(o,i??!1)};return m.jsx("span",{"aria-hidden":"true",className:r.t(e!=="none"&&n[`gap-${e}`],h[a],n.icon,s&&p[s]),style:c,"data-component":"icon"})},I=()=>Object.keys(t.iconPaths);exports.Icon=y;exports.Icons=I;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,34 +1,34 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { t as c } from "../../classix-DG18itHa.js";
3
- import { i, a as l } from "../../icons-BFgf_lJN.js";
4
- import '../../assets/index46.css';const _ = "_icon_vhz6u_1", g = "_small_vhz6u_10", u = "_medium_vhz6u_15", d = "_large_vhz6u_20", h = "_danger_vhz6u_25", n = {
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { t as r } from "../../classix-DG18itHa.js";
3
+ import { i as c, a as l } from "../../icons-BFgf_lJN.js";
4
+ import '../../assets/index46.css';const _ = "_icon_ihnm9_1", g = "_small_ihnm9_10", d = "_medium_ihnm9_15", h = "_large_ihnm9_20", p = "_danger_ihnm9_25", n = {
5
5
  icon: _,
6
6
  small: g,
7
- medium: u,
8
- large: d,
9
- danger: h,
10
- "gap-right": "_gap-right_vhz6u_29",
11
- "gap-left": "_gap-left_vhz6u_33"
12
- }, p = {
7
+ medium: d,
8
+ large: h,
9
+ danger: p,
10
+ "gap-right": "_gap-right_ihnm9_29",
11
+ "gap-left": "_gap-left_ihnm9_33"
12
+ }, u = {
13
13
  large: n.large,
14
14
  medium: n.medium,
15
15
  small: n.small
16
- }, z = {
16
+ }, f = {
17
17
  danger: n.danger
18
- }, I = ({
19
- fill: s,
18
+ }, k = ({
19
+ fill: a,
20
20
  gap: e = "none",
21
- name: o,
22
- size: t = "medium",
23
- variant: a
21
+ name: s,
22
+ size: o = "medium",
23
+ variant: m
24
24
  }) => {
25
- const m = {
26
- maskImage: i(o, s ?? !1)
25
+ const i = {
26
+ maskImage: c(s, a ?? !1)
27
27
  };
28
- return /* @__PURE__ */ r("span", { "aria-hidden": "true", className: c(e !== "none" && n[`gap-${e}`], p[t], n.icon, a && z[a]), style: m, "data-component": "icon" });
29
- }, j = () => Object.keys(l);
28
+ return /* @__PURE__ */ t("span", { "aria-hidden": "true", className: r(e !== "none" && n[`gap-${e}`], u[o], n.icon, m && f[m]), style: i, "data-component": "icon" });
29
+ }, x = () => Object.keys(l);
30
30
  export {
31
- I as Icon,
32
- j as Icons
31
+ k as Icon,
32
+ x as Icons
33
33
  };
34
34
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index19.css');const o=require("react/jsx-runtime"),S=require("../../classix-5H4IWnMA.cjs"),n=require("react"),q=require("../button/index.cjs"),B=require("../dialog/index.cjs"),G="_wrapper_owo4o_1",R="_toolbar_owo4o_6",V="_iframe_owo4o_16",c={wrapper:G,toolbar:R,"fullscreen-toolbar":"_fullscreen-toolbar_owo4o_7",iframe:V,"fullscreen-dialog":"_fullscreen-dialog_owo4o_22","fullscreen-iframe":"_fullscreen-iframe_owo4o_40"},f=120,$=12e3,L=8,X=({accessibleLabel:m,autoResize:l=!1,className:H,closeFullscreenLabel:A="Close fullscreen",fullscreenLabel:C="View in fullscreen",hasFullscreenView:I=!0,loading:O="lazy",onLoad:h,referrerPolicy:x="no-referrer",sandbox:y="",srcDoc:w,style:E,...b})=>{const _=n.useRef(null),i=n.useRef(null),s=n.useRef(null),[N,M]=n.useState(f),[T,g]=n.useState(!1),p=n.useCallback(()=>{i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null),s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),v=n.useCallback(()=>{if(!l)return;const t=_.current,e=t==null?void 0:t.contentDocument;if(!t||!e)return;const d=t.style.height;try{t.style.height=`${f}px`;const a=e.querySelector("[data-iframe-content]")??e.body,u=a.getBoundingClientRect(),{body:j,documentElement:F}=e,U=Math.min(Math.max(Math.ceil(Math.max(a.scrollHeight,a.offsetHeight,u.height,j.scrollHeight,j.offsetHeight,F.scrollHeight,F.offsetHeight)+L),f),$);M(U)}catch{}finally{t.style.height=d}},[l]),r=n.useCallback(()=>{!l||i.current!==null||(i.current=window.requestAnimationFrame(()=>{i.current=null,v(),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{s.current=null,v()},250)}))},[l,v]),k=t=>{var d,a;r();const e=(d=_.current)==null?void 0:d.contentDocument;Array.from((e==null?void 0:e.images)??[]).forEach(u=>{u.complete||(u.addEventListener("load",r,{once:!0}),u.addEventListener("error",r,{once:!0}))}),(a=e==null?void 0:e.fonts)==null||a.ready.then(r).catch(()=>{}),h==null||h(t)};return n.useEffect(()=>{if(l)return p(),M(f),r(),p},[l,p,r,w]),n.useEffect(()=>{var t;if(l)return window.addEventListener("resize",r),(t=window.visualViewport)==null||t.addEventListener("resize",r),()=>{var e;window.removeEventListener("resize",r),(e=window.visualViewport)==null||e.removeEventListener("resize",r)}},[l,r]),o.jsxs("div",{className:c.wrapper,"data-component":"iframe",children:[I&&o.jsx("div",{className:c.toolbar,children:o.jsx(q.Button,{"aria-expanded":T,"aria-haspopup":"dialog",onClick:()=>g(!0),variant:"tertiary",children:C})}),o.jsx("iframe",{...b,className:S.t(c.iframe,H),loading:O,onLoad:k,ref:_,referrerPolicy:x,sandbox:y,srcDoc:w,style:l?{...E,height:N,minHeight:f}:E,title:m}),T&&o.jsxs(B.Dialog,{"aria-label":`${m} fullscreen`,className:c["fullscreen-dialog"],open:!0,setOpen:g,children:[o.jsx("div",{className:c["fullscreen-toolbar"],children:o.jsx(q.Button,{autoFocus:!0,onClick:()=>g(!1),children:A})}),o.jsx("iframe",{...b,className:S.t(c.iframe,c["fullscreen-iframe"],H),loading:"eager",referrerPolicy:x,sandbox:y,srcDoc:w,title:`${m} fullscreen`})]})]})};exports.Iframe=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index19.css');const r=require("react/jsx-runtime"),S=require("../../classix-5H4IWnMA.cjs"),s=require("react"),A=require("../button/index.cjs"),N=require("../controls/index.cjs"),z=require("../dialog/index.cjs"),G=require("../header/index.cjs"),R="_wrapper_29z62_1",V="_toolbar_29z62_6",$="_iframe_29z62_12",a={wrapper:R,toolbar:V,iframe:$,"fullscreen-iframe":"_fullscreen-iframe_29z62_18"},d=120,L=12e3,X=8,J=({accessibleLabel:f,autoResize:l=!1,className:v,closeFullscreenLabel:F="Close fullscreen",fullscreenLabel:I="View in fullscreen",hasFullscreenView:O=!0,loading:b="lazy",onLoad:h,referrerPolicy:H="no-referrer",sandbox:y="",srcDoc:w,style:E,...j})=>{const _=s.useRef(null),c=s.useRef(null),i=s.useRef(null),[k,M]=s.useState(d),[T,p]=s.useState(!1),g=s.useCallback(()=>{c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null),i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]),x=s.useCallback(()=>{if(!l)return;const t=_.current,e=t==null?void 0:t.contentDocument;if(!t||!e)return;const m=t.style.height;try{t.style.height=`${d}px`;const o=e.querySelector("[data-iframe-content]")??e.body,u=o.getBoundingClientRect(),{body:q,documentElement:C}=e,B=Math.min(Math.max(Math.ceil(Math.max(o.scrollHeight,o.offsetHeight,u.height,q.scrollHeight,q.offsetHeight,C.scrollHeight,C.offsetHeight)+X),d),L);M(B)}catch{}finally{t.style.height=m}},[l]),n=s.useCallback(()=>{!l||c.current!==null||(c.current=window.requestAnimationFrame(()=>{c.current=null,x(),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,x()},250)}))},[l,x]),U=t=>{var m,o;n();const e=(m=_.current)==null?void 0:m.contentDocument;Array.from((e==null?void 0:e.images)??[]).forEach(u=>{u.complete||(u.addEventListener("load",n,{once:!0}),u.addEventListener("error",n,{once:!0}))}),(o=e==null?void 0:e.fonts)==null||o.ready.then(n).catch(()=>{}),h==null||h(t)};return s.useEffect(()=>{if(l)return g(),M(d),n(),g},[l,g,n,w]),s.useEffect(()=>{var t;if(l)return window.addEventListener("resize",n),(t=window.visualViewport)==null||t.addEventListener("resize",n),()=>{var e;window.removeEventListener("resize",n),(e=window.visualViewport)==null||e.removeEventListener("resize",n)}},[l,n]),r.jsxs("div",{className:a.wrapper,"data-component":"iframe",children:[O&&r.jsx("div",{className:a.toolbar,children:r.jsx(A.Button,{"aria-expanded":T,"aria-haspopup":"dialog",onClick:()=>p(!0),variant:"tertiary",children:I})}),r.jsx("iframe",{...j,className:S.t(a.iframe,v),loading:b,onLoad:U,ref:_,referrerPolicy:H,sandbox:y,srcDoc:w,style:l?{...E,height:k,minHeight:d}:E,title:f}),T&&r.jsx(z.Dialog,{"aria-label":`${f} fullscreen`,controls:r.jsx(N.Controls,{children:r.jsx(A.Button,{onClick:()=>p(!1),children:F})}),fullscreen:!0,header:r.jsx(G.Header,{children:r.jsx("h2",{children:f})}),open:!0,setOpen:p,children:r.jsx("iframe",{...j,className:S.t(a.iframe,a["fullscreen-iframe"],v),loading:"eager",referrerPolicy:H,sandbox:y,srcDoc:w,title:`${f} fullscreen`})})]})};exports.Iframe=J;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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":"yeAOMA,EAAkB,IAClBC,EAAkB,KAClBC,EAAqB,EAWdC,EAASA,CAAC,CACr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,CAAA,CAE3C,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"index.cjs","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":"wcASMA,EAAkB,IAClBC,EAAkB,KAClBC,EAAqB,EAWdC,EAASA,CAAC,CACrBC,gBAAAA,EACAC,WAAAA,EAAa,GACbC,UAAAA,EACAC,qBAAAA,EAAuB,mBACvBC,gBAAAA,EAAkB,qBAClBC,kBAAAA,EAAoB,GACpBC,QAAAA,EAAU,OACVC,OAAAA,EACAC,eAAAA,EAAiB,cACjBC,QAAAA,EAAU,GACVC,OAAAA,EACAC,MAAAA,EACA,GAAGC,CACQ,IAAM,CACjB,MAAMC,EAAYC,EAAAA,OAA0B,IAAI,EAC1CC,EAAsBD,EAAAA,OAAsB,IAAI,EAChDE,EAAgCF,EAAAA,OAAsB,IAAI,EAC1D,CAACG,EAAgBC,CAAiB,EAAIC,EAAAA,SAASvB,CAAe,EAC9D,CAACwB,EAAkBC,CAAmB,EAAIF,EAAAA,SAAS,EAAK,EAExDG,EAA6BC,EAAAA,YAAY,IAAM,CAC/CR,EAAoBS,UAAY,OAClCC,OAAOC,qBAAqBX,EAAoBS,OAAO,EACvDT,EAAoBS,QAAU,MAG5BR,EAA8BQ,UAAY,OAC5CC,OAAOE,aAAaX,EAA8BQ,OAAO,EACzDR,EAA8BQ,QAAU,KAE5C,EAAG,CAAA,CAAE,EAECI,EAAcL,EAAAA,YAAY,IAAM,CACpC,GAAI,CAACtB,EA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MAAOX,EAAgB,EAExBoB,GACCiD,EAAAA,IAACI,EAAAA,OAAA,CACC,aAAY,GAAGzE,CAAe,cAC9B,SACEqE,EAAAA,IAACK,EAAAA,SAAA,CACC,SAAAL,EAAAA,IAACC,EAAAA,OAAA,CAAO,QAAS,IAAMjD,EAAoB,EAAK,EAAIlB,SAAAA,CAAAA,CAAqB,CAAA,CAC3E,EAEF,WAAU,GACV,OACEkE,EAAAA,IAACM,EAAAA,OAAA,CACC,SAAAN,EAAAA,IAAC,KAAA,CAAIrE,SAAAA,CAAAA,CAAgB,EACvB,EAEF,KAAI,GACJ,QAASqB,EAET,SAAAgD,EAAAA,IAAC,SAAA,CACC,GAAIzD,EACJ,UAAW2D,EAAAA,EAAGL,EAAOrC,OAAQqC,EAAO,mBAAmB,EAAGhE,CAAS,EACnE,QAAQ,QACR,eAAAM,EACA,QAAAC,EACA,OAAAC,EACA,MAAO,GAAGV,CAAe,aAAA,CAAc,CAAA,CAE3C,CAAA,EAEJ,CAEJ"}
@@ -1,91 +1,88 @@
1
- import { jsxs as N, jsx as s } from "react/jsx-runtime";
1
+ import { jsxs as q, jsx as l } from "react/jsx-runtime";
2
2
  import { t as O } from "../../classix-DG18itHa.js";
3
- import { useRef as v, useState as C, useCallback as H, useEffect as S } from "react";
4
- import { Button as U } from "../button/index.js";
3
+ import { useRef as H, useState as S, useCallback as v, useEffect as U } from "react";
4
+ import { Button as N } from "../button/index.js";
5
+ import { Controls as b } from "../controls/index.js";
5
6
  import { Dialog as L } from "../dialog/index.js";
6
- import '../../assets/index19.css';const X = "_wrapper_owo4o_1", J = "_toolbar_owo4o_6", K = "_iframe_owo4o_16", l = {
7
- wrapper: X,
8
- toolbar: J,
9
- "fullscreen-toolbar": "_fullscreen-toolbar_owo4o_7",
10
- iframe: K,
11
- "fullscreen-dialog": "_fullscreen-dialog_owo4o_22",
12
- "fullscreen-iframe": "_fullscreen-iframe_owo4o_40"
13
- }, u = 120, Q = 12e3, W = 8, R = ({
14
- accessibleLabel: m,
7
+ import { Header as X } from "../header/index.js";
8
+ import '../../assets/index19.css';const J = "_wrapper_29z62_1", K = "_toolbar_29z62_6", Q = "_iframe_29z62_12", a = {
9
+ wrapper: J,
10
+ toolbar: K,
11
+ iframe: Q,
12
+ "fullscreen-iframe": "_fullscreen-iframe_29z62_18"
13
+ }, u = 120, W = 12e3, Y = 8, ne = ({
14
+ accessibleLabel: f,
15
15
  autoResize: n = !1,
16
16
  className: E,
17
17
  closeFullscreenLabel: k = "Close fullscreen",
18
- fullscreenLabel: B = "View in fullscreen",
19
- hasFullscreenView: G = !0,
20
- loading: V = "lazy",
18
+ fullscreenLabel: z = "View in fullscreen",
19
+ hasFullscreenView: B = !0,
20
+ loading: G = "lazy",
21
21
  onLoad: d,
22
22
  referrerPolicy: y = "no-referrer",
23
23
  sandbox: M = "",
24
24
  srcDoc: h,
25
25
  style: T,
26
- ...F
26
+ ...A
27
27
  }) => {
28
- const w = v(null), i = v(null), o = v(null), [$, A] = C(u), [b, p] = C(!1), g = H(() => {
29
- i.current !== null && (window.cancelAnimationFrame(i.current), i.current = null), o.current !== null && (window.clearTimeout(o.current), o.current = null);
30
- }, []), _ = H(() => {
28
+ const p = H(null), o = H(null), i = H(null), [V, F] = S(u), [x, w] = S(!1), g = v(() => {
29
+ o.current !== null && (window.cancelAnimationFrame(o.current), o.current = null), i.current !== null && (window.clearTimeout(i.current), i.current = null);
30
+ }, []), _ = v(() => {
31
31
  if (!n) return;
32
- const r = w.current, e = r == null ? void 0 : r.contentDocument;
32
+ const r = p.current, e = r == null ? void 0 : r.contentDocument;
33
33
  if (!r || !e) return;
34
- const f = r.style.height;
34
+ const m = r.style.height;
35
35
  try {
36
36
  r.style.height = `${u}px`;
37
- const c = e.querySelector("[data-iframe-content]") ?? e.body, a = c.getBoundingClientRect(), {
38
- body: x,
37
+ const c = e.querySelector("[data-iframe-content]") ?? e.body, s = c.getBoundingClientRect(), {
38
+ body: C,
39
39
  documentElement: I
40
- } = e, q = Math.min(Math.max(Math.ceil(Math.max(c.scrollHeight, c.offsetHeight, a.height, x.scrollHeight, x.offsetHeight, I.scrollHeight, I.offsetHeight) + W), u), Q);
41
- A(q);
40
+ } = e, j = Math.min(Math.max(Math.ceil(Math.max(c.scrollHeight, c.offsetHeight, s.height, C.scrollHeight, C.offsetHeight, I.scrollHeight, I.offsetHeight) + Y), u), W);
41
+ F(j);
42
42
  } catch {
43
43
  } finally {
44
- r.style.height = f;
44
+ r.style.height = m;
45
45
  }
46
- }, [n]), t = H(() => {
47
- !n || i.current !== null || (i.current = window.requestAnimationFrame(() => {
48
- i.current = null, _(), o.current !== null && window.clearTimeout(o.current), o.current = window.setTimeout(() => {
49
- o.current = null, _();
46
+ }, [n]), t = v(() => {
47
+ !n || o.current !== null || (o.current = window.requestAnimationFrame(() => {
48
+ o.current = null, _(), i.current !== null && window.clearTimeout(i.current), i.current = window.setTimeout(() => {
49
+ i.current = null, _();
50
50
  }, 250);
51
51
  }));
52
- }, [n, _]), j = (r) => {
53
- var f, c;
52
+ }, [n, _]), $ = (r) => {
53
+ var m, c;
54
54
  t();
55
- const e = (f = w.current) == null ? void 0 : f.contentDocument;
56
- Array.from((e == null ? void 0 : e.images) ?? []).forEach((a) => {
57
- a.complete || (a.addEventListener("load", t, {
55
+ const e = (m = p.current) == null ? void 0 : m.contentDocument;
56
+ Array.from((e == null ? void 0 : e.images) ?? []).forEach((s) => {
57
+ s.complete || (s.addEventListener("load", t, {
58
58
  once: !0
59
- }), a.addEventListener("error", t, {
59
+ }), s.addEventListener("error", t, {
60
60
  once: !0
61
61
  }));
62
62
  }), (c = e == null ? void 0 : e.fonts) == null || c.ready.then(t).catch(() => {
63
63
  }), d == null || d(r);
64
64
  };
65
- return S(() => {
65
+ return U(() => {
66
66
  if (n)
67
- return g(), A(u), t(), g;
68
- }, [n, g, t, h]), S(() => {
67
+ return g(), F(u), t(), g;
68
+ }, [n, g, t, h]), U(() => {
69
69
  var r;
70
70
  if (n)
71
71
  return window.addEventListener("resize", t), (r = window.visualViewport) == null || r.addEventListener("resize", t), () => {
72
72
  var e;
73
73
  window.removeEventListener("resize", t), (e = window.visualViewport) == null || e.removeEventListener("resize", t);
74
74
  };
75
- }, [n, t]), /* @__PURE__ */ N("div", { className: l.wrapper, "data-component": "iframe", children: [
76
- G && /* @__PURE__ */ s("div", { className: l.toolbar, children: /* @__PURE__ */ s(U, { "aria-expanded": b, "aria-haspopup": "dialog", onClick: () => p(!0), variant: "tertiary", children: B }) }),
77
- /* @__PURE__ */ s("iframe", { ...F, className: O(l.iframe, E), loading: V, onLoad: j, ref: w, referrerPolicy: y, sandbox: M, srcDoc: h, style: n ? {
75
+ }, [n, t]), /* @__PURE__ */ q("div", { className: a.wrapper, "data-component": "iframe", children: [
76
+ B && /* @__PURE__ */ l("div", { className: a.toolbar, children: /* @__PURE__ */ l(N, { "aria-expanded": x, "aria-haspopup": "dialog", onClick: () => w(!0), variant: "tertiary", children: z }) }),
77
+ /* @__PURE__ */ l("iframe", { ...A, className: O(a.iframe, E), loading: G, onLoad: $, ref: p, referrerPolicy: y, sandbox: M, srcDoc: h, style: n ? {
78
78
  ...T,
79
- height: $,
79
+ height: V,
80
80
  minHeight: u
81
- } : T, title: m }),
82
- b && /* @__PURE__ */ N(L, { "aria-label": `${m} fullscreen`, className: l["fullscreen-dialog"], open: !0, setOpen: p, children: [
83
- /* @__PURE__ */ s("div", { className: l["fullscreen-toolbar"], children: /* @__PURE__ */ s(U, { autoFocus: !0, onClick: () => p(!1), children: k }) }),
84
- /* @__PURE__ */ s("iframe", { ...F, className: O(l.iframe, l["fullscreen-iframe"], E), loading: "eager", referrerPolicy: y, sandbox: M, srcDoc: h, title: `${m} fullscreen` })
85
- ] })
81
+ } : T, title: f }),
82
+ x && /* @__PURE__ */ l(L, { "aria-label": `${f} fullscreen`, controls: /* @__PURE__ */ l(b, { children: /* @__PURE__ */ l(N, { onClick: () => w(!1), children: k }) }), fullscreen: !0, header: /* @__PURE__ */ l(X, { children: /* @__PURE__ */ l("h2", { children: f }) }), open: !0, setOpen: w, children: /* @__PURE__ */ l("iframe", { ...A, className: O(a.iframe, a["fullscreen-iframe"], E), loading: "eager", referrerPolicy: y, sandbox: M, srcDoc: h, title: `${f} fullscreen` }) })
86
83
  ] });
87
84
  };
88
85
  export {
89
- R as Iframe
86
+ ne as Iframe
90
87
  };
91
88
  //# sourceMappingURL=index.js.map
@@ -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,GAExDG,IAA6BC,EAAY,MAAM;AACnD,IAAIR,EAAoBS,YAA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A,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;AAGFJ,MAAAA,EAAOlB,MAAMsB,SAAS,GAAGrC,CAAe;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,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","fil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AClBH,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,OAAuB,IAAI,EACtCI,EAAUC,EAAAA,MAAAA,EACVC,EAAaN,EAA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AEJ"}
@@ -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
  };