@stackone/malachite 2.68.0 → 2.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { injectStyleSheet as t } from "./injectStyleSheet.js";
2
- const s = "data-malachite-overlay", e = {
2
+ const r = "data-malachite-overlay", e = {
3
3
  dropdown: "malachite-dropdown-surface",
4
4
  multiselect: "malachite-multiselect-surface",
5
5
  actionmenu: "malachite-actionmenu-surface",
@@ -7,38 +7,44 @@ const s = "data-malachite-overlay", e = {
7
7
  sidepanel: "malachite-drawer-surface",
8
8
  modal: "malachite-modal-surface",
9
9
  commandpalette: "malachite-cmdpalette-surface",
10
- popover: "malachite-popover-surface"
11
- }, R = (o) => ({
10
+ popover: "malachite-popover-surface",
11
+ toast: "malachite-toast-surface"
12
+ }, T = (o) => ({
12
13
  className: e[o],
13
- [s]: o
14
- }), i = "malachite-overlay-styles", S = 1e3, c = 2147483646, a = "data-malachite-elevated", n = (o) => Object.values(e).map((r) => `.${r}:popover-open${o}`).join(", "), l = "inset: auto; margin: 0; border: 0; padding: 0; width: auto; height: auto; overflow: visible; background: none; color: inherit;", p = [
14
+ [r]: o
15
+ }), i = "malachite-overlay-styles", O = 1e3, s = 2147483646, n = "data-malachite-elevated", c = (o) => Object.values(e).map((l) => `.${l}:popover-open${o}`).join(", "), a = "inset: auto; margin: 0; border: 0; padding: 0; width: auto; height: auto; overflow: visible; background: none; color: inherit;", p = [
15
16
  `.${e.dropdown}, .${e.multiselect}, .${e.actionmenu} { z-index: 2147483646; }`,
16
17
  `.${e.tooltip} { z-index: 2147483647; }`
17
- ], E = "malachite-overlay-menu-box", d = [
18
+ ], d = "malachite-overlay-menu-box", E = [
18
19
  `.${e.dropdown}, .${e.dropdown} *, .${e.multiselect}, .${e.multiselect} *, .${e.actionmenu}, .${e.actionmenu} * { box-sizing: border-box; }`
19
20
  ], m = "malachite-overlay-popover", u = [
20
- `.${e.popover} { z-index: ${c}; }`,
21
- `.${e.popover}:popover-open { ${l} }`,
21
+ `.${e.popover} { z-index: ${s}; }`,
22
+ `.${e.popover}:popover-open { ${a} }`,
22
23
  `.${e.popover}:popover-open::backdrop { display: none; }`
23
- ], y = () => t(m, u), O = () => (t(E, d), t(i, p)), _ = "malachite-overlay-elevated", v = [
24
- `.${e.sidepanel}[${a}], .${e.modal}[${a}] { z-index: ${c}; }`
25
- ], A = () => t(_, v), L = "malachite-overlay-top-layer", $ = [
26
- `${n("")} { ${l} }`,
27
- `${n("::backdrop")} { display: none; }`
28
- ], T = () => {
29
- const o = t(L, $);
24
+ ], R = () => t(m, u), A = () => (t(d, E), t(i, p)), _ = "malachite-overlay-elevated", $ = [
25
+ `.${e.sidepanel}[${n}], .${e.modal}[${n}] { z-index: ${s}; }`
26
+ ], Y = () => t(_, $), v = "malachite-overlay-toast", L = [
27
+ `.${e.toast} { z-index: 2147483647; }`,
28
+ `.${e.toast}:popover-open { ${a} }`,
29
+ `.${e.toast}:popover-open::backdrop { display: none; }`
30
+ ], V = () => t(v, L), S = "malachite-overlay-top-layer", h = [
31
+ `${c("")} { ${a} }`,
32
+ `${c("::backdrop")} { display: none; }`
33
+ ], b = () => {
34
+ const o = t(S, h);
30
35
  return o && o.cssRules.length > 0 ? o : null;
31
36
  };
32
37
  export {
33
- s as OVERLAY_ATTR,
38
+ r as OVERLAY_ATTR,
34
39
  e as OVERLAY_CLASS,
35
- a as OVERLAY_ELEVATED_ATTR,
36
- S as OVERLAY_Z_BASE,
37
- c as OVERLAY_Z_ELEVATED,
38
- A as ensureElevatedOverlayStyles,
39
- O as ensureOverlayStyles,
40
- y as ensurePopoverStyles,
41
- T as ensureTopLayerStyles,
42
- R as overlayIdentity
40
+ n as OVERLAY_ELEVATED_ATTR,
41
+ O as OVERLAY_Z_BASE,
42
+ s as OVERLAY_Z_ELEVATED,
43
+ Y as ensureElevatedOverlayStyles,
44
+ A as ensureOverlayStyles,
45
+ R as ensurePopoverStyles,
46
+ V as ensureToastStyles,
47
+ b as ensureTopLayerStyles,
48
+ T as overlayIdentity
43
49
  };
44
50
  //# sourceMappingURL=portalOverlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"portalOverlay.js","sources":["../../src/components/portalOverlay.ts"],"sourcesContent":["// Host \"kill the ad overlay\" CSS erases anything portaled into document.body: `body >\n// div:not([class])` matches an unclassed body child, `[style*=\"2147483\"]` a max-int z-index.\n// The second matches the style ATTRIBUTE, so declaring z-index here keeps max-int stacking.\n\nimport { injectStyleSheet } from './injectStyleSheet';\n\n/** One selector for every malachite overlay, so a host allow-lists them in one rule. */\nexport const OVERLAY_ATTR = 'data-malachite-overlay';\n\n// Values avoid `panel`/`popup`/`overlay`/`tooltip`: a class defeats `:not([class])`, but one\n// matching `[class*=\"panel\"]` trades that hole for another these elements did not have.\nexport const OVERLAY_CLASS = {\n dropdown: 'malachite-dropdown-surface',\n multiselect: 'malachite-multiselect-surface',\n actionmenu: 'malachite-actionmenu-surface',\n tooltip: 'malachite-tip-surface',\n sidepanel: 'malachite-drawer-surface',\n modal: 'malachite-modal-surface',\n commandpalette: 'malachite-cmdpalette-surface',\n popover: 'malachite-popover-surface',\n} as const;\n\nexport type OverlayName = keyof typeof OVERLAY_CLASS;\n\n// Exhaustive, so a new overlay fails to typecheck until classified, and a popup is then refused\n// by `overlayIdentity`: its only identity comes from `usePopupLayer`, which registers it.\nconst OVERLAY_ROLE = {\n dropdown: 'popup',\n multiselect: 'popup',\n actionmenu: 'popup',\n popover: 'popup',\n sidepanel: 'trap',\n modal: 'trap',\n commandpalette: 'trap',\n tooltip: 'unfocusable',\n} as const satisfies Record<OverlayName, 'popup' | 'trap' | 'unfocusable'>;\n\nexport type PopupOverlayName = {\n [Name in OverlayName]: (typeof OVERLAY_ROLE)[Name] extends 'popup' ? Name : never;\n}[OverlayName];\n\nexport const overlayIdentity = (name: Exclude<OverlayName, PopupOverlayName>) => ({\n className: OVERLAY_CLASS[name],\n [OVERLAY_ATTR]: name,\n});\n\nconst OVERLAY_STYLE_ID = 'malachite-overlay-styles';\n\n/**\n * Where SidePanel, Modal and CommandPalette start. `useOverlayBehaviour` steps one per stacked overlay, so\n * paint order follows the focus stack rather than body order — a handful above this at most.\n */\nexport const OVERLAY_Z_BASE = 1000;\n\n/**\n * The dropdown band, which clears app chrome pinned just under max-int. One integer wide: a host\n * pins its chrome at max-int-1 and the tooltip band sits at max-int, so the stack cannot step\n * per layer the way the base band does — the top layer orders it, and where popover is\n * unsupported, document order does.\n */\nexport const OVERLAY_Z_ELEVATED = 2147483646;\n\n/** Marks a host in that band — an attribute, not an inline z-index; see above. */\nexport const OVERLAY_ELEVATED_ATTR = 'data-malachite-elevated';\n\n// Every overlay class, not the four promoted by default: one the reset misses wears the UA box.\nconst promotedSelector = (suffix: string) =>\n Object.values(OVERLAY_CLASS)\n .map((name) => `.${name}:popover-open${suffix}`)\n .join(', ');\n\n// Promotion drags in the UA `[popover]` box: `inset: 0` (which survives as right/bottom and\n// stretches a panel to the viewport edge), auto margins, a border, padding and fit-content\n// sizing. Reset to what these computed before promotion; their own inline styles still win.\nconst POPOVER_RESET =\n 'inset: auto; margin: 0; border: 0; padding: 0; width: auto; height: auto; ' +\n 'overflow: visible; background: none; color: inherit;';\n\nconst OVERLAY_RULES = [\n `.${OVERLAY_CLASS.dropdown}, .${OVERLAY_CLASS.multiselect}, .${OVERLAY_CLASS.actionmenu} { z-index: 2147483646; }`,\n `.${OVERLAY_CLASS.tooltip} { z-index: 2147483647; }`,\n];\n\n// Its own id, never folded into OVERLAY_STYLE_ID: injectStyleSheet keeps one sheet per id across\n// malachite copies sharing a realm, so a copy predating this rule would win that id and leave a\n// portaled menu on the host page's box model — a 280px Options menu painting 298. No copy has\n// ever registered this one.\nconst MENU_BOX_STYLE_ID = 'malachite-overlay-menu-box';\n\n// The scoped stylesheet makes everything border-box; a portal escapes it onto a host page that\n// may have no reset at all, while the geometry is computed as a CSS width.\nconst MENU_BOX_RULES = [\n `.${OVERLAY_CLASS.dropdown}, .${OVERLAY_CLASS.dropdown} *,` +\n ` .${OVERLAY_CLASS.multiselect}, .${OVERLAY_CLASS.multiselect} *,` +\n ` .${OVERLAY_CLASS.actionmenu}, .${OVERLAY_CLASS.actionmenu} *` +\n ' { box-sizing: border-box; }',\n];\n\nconst POPOVER_STYLE_ID = 'malachite-overlay-popover';\n\nconst POPOVER_RULES = [\n `.${OVERLAY_CLASS.popover} { z-index: ${OVERLAY_Z_ELEVATED}; }`,\n `.${OVERLAY_CLASS.popover}:popover-open { ${POPOVER_RESET} }`,\n `.${OVERLAY_CLASS.popover}:popover-open::backdrop { display: none; }`,\n];\n\nexport const ensurePopoverStyles = (): CSSStyleSheet | null =>\n injectStyleSheet(POPOVER_STYLE_ID, POPOVER_RULES);\n\nexport const ensureOverlayStyles = (): CSSStyleSheet | null => {\n injectStyleSheet(MENU_BOX_STYLE_ID, MENU_BOX_RULES);\n return injectStyleSheet(OVERLAY_STYLE_ID, OVERLAY_RULES);\n};\n\n// Its own id like TOP_LAYER_STYLE_ID: a copy predating elevation would own OVERLAY_STYLE_ID.\nconst ELEVATED_STYLE_ID = 'malachite-overlay-elevated';\n\nconst ELEVATED_RULES = [\n `.${OVERLAY_CLASS.sidepanel}[${OVERLAY_ELEVATED_ATTR}], .${OVERLAY_CLASS.modal}[${OVERLAY_ELEVATED_ATTR}] { z-index: ${OVERLAY_Z_ELEVATED}; }`,\n];\n\nexport const ensureElevatedOverlayStyles = (): CSSStyleSheet | null =>\n injectStyleSheet(ELEVATED_STYLE_ID, ELEVATED_RULES);\n\n// Its own id, never folded into OVERLAY_STYLE_ID: injectStyleSheet keeps one sheet per id across\n// malachite copies sharing a realm, so a copy predating the reset would win that id and leave a\n// promoted overlay wearing the raw UA box. No copy has ever registered this one.\nconst TOP_LAYER_STYLE_ID = 'malachite-overlay-top-layer';\n\nconst TOP_LAYER_RULES = [\n `${promotedSelector('')} { ${POPOVER_RESET} }`,\n `${promotedSelector('::backdrop')} { display: none; }`,\n];\n\nexport const ensureTopLayerStyles = (): CSSStyleSheet | null => {\n // A sheet that installed does not mean its rules parsed: replaceSync (and the <style> path)\n // drop an unparseable rule silently rather than throwing, so an engine that chokes on\n // `:popover-open` or `::backdrop` hands back a valid, empty sheet.\n const sheet = injectStyleSheet(TOP_LAYER_STYLE_ID, TOP_LAYER_RULES);\n return sheet && sheet.cssRules.length > 0 ? sheet : null;\n};\n"],"names":["OVERLAY_ATTR","OVERLAY_CLASS","overlayIdentity","name","OVERLAY_STYLE_ID","OVERLAY_Z_BASE","OVERLAY_Z_ELEVATED","OVERLAY_ELEVATED_ATTR","promotedSelector","suffix","POPOVER_RESET","OVERLAY_RULES","MENU_BOX_STYLE_ID","MENU_BOX_RULES","POPOVER_STYLE_ID","POPOVER_RULES","ensurePopoverStyles","injectStyleSheet","ensureOverlayStyles","ELEVATED_STYLE_ID","ELEVATED_RULES","ensureElevatedOverlayStyles","TOP_LAYER_STYLE_ID","TOP_LAYER_RULES","ensureTopLayerStyles","sheet"],"mappings":";AAOO,MAAMA,IAAe,0BAIfC,IAAgB;AAAA,EACzB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,SAAS;AACb,GAqBaC,IAAkB,CAACC,OAAkD;AAAA,EAC9E,WAAWF,EAAcE,CAAI;AAAA,EAC7B,CAACH,CAAY,GAAGG;AACpB,IAEMC,IAAmB,4BAMZC,IAAiB,KAQjBC,IAAqB,YAGrBC,IAAwB,2BAG/BC,IAAmB,CAACC,MACtB,OAAO,OAAOR,CAAa,EACtB,IAAI,CAACE,MAAS,IAAIA,CAAI,gBAAgBM,CAAM,EAAE,EAC9C,KAAK,IAAI,GAKZC,IACF,kIAGEC,IAAgB;AAAA,EAClB,IAAIV,EAAc,QAAQ,MAAMA,EAAc,WAAW,MAAMA,EAAc,UAAU;AAAA,EACvF,IAAIA,EAAc,OAAO;AAC7B,GAMMW,IAAoB,8BAIpBC,IAAiB;AAAA,EACnB,IAAIZ,EAAc,QAAQ,MAAMA,EAAc,QAAQ,QAC7CA,EAAc,WAAW,MAAMA,EAAc,WAAW,QACxDA,EAAc,UAAU,MAAMA,EAAc,UAAU;AAEnE,GAEMa,IAAmB,6BAEnBC,IAAgB;AAAA,EAClB,IAAId,EAAc,OAAO,eAAeK,CAAkB;AAAA,EAC1D,IAAIL,EAAc,OAAO,mBAAmBS,CAAa;AAAA,EACzD,IAAIT,EAAc,OAAO;AAC7B,GAEae,IAAsB,MAC/BC,EAAiBH,GAAkBC,CAAa,GAEvCG,IAAsB,OAC/BD,EAAiBL,GAAmBC,CAAc,GAC3CI,EAAiBb,GAAkBO,CAAa,IAIrDQ,IAAoB,8BAEpBC,IAAiB;AAAA,EACnB,IAAInB,EAAc,SAAS,IAAIM,CAAqB,OAAON,EAAc,KAAK,IAAIM,CAAqB,gBAAgBD,CAAkB;AAC7I,GAEae,IAA8B,MACvCJ,EAAiBE,GAAmBC,CAAc,GAKhDE,IAAqB,+BAErBC,IAAkB;AAAA,EACpB,GAAGf,EAAiB,EAAE,CAAC,MAAME,CAAa;AAAA,EAC1C,GAAGF,EAAiB,YAAY,CAAC;AACrC,GAEagB,IAAuB,MAA4B;AAI5D,QAAMC,IAAQR,EAAiBK,GAAoBC,CAAe;AAClE,SAAOE,KAASA,EAAM,SAAS,SAAS,IAAIA,IAAQ;AACxD;"}
1
+ {"version":3,"file":"portalOverlay.js","sources":["../../src/components/portalOverlay.ts"],"sourcesContent":["// Host \"kill the ad overlay\" CSS erases anything portaled into document.body: `body >\n// div:not([class])` matches an unclassed body child, `[style*=\"2147483\"]` a max-int z-index.\n// The second matches the style ATTRIBUTE, so declaring z-index here keeps max-int stacking.\n\nimport { injectStyleSheet } from './injectStyleSheet';\n\n/** One selector for every malachite overlay, so a host allow-lists them in one rule. */\nexport const OVERLAY_ATTR = 'data-malachite-overlay';\n\n// Values avoid `panel`/`popup`/`overlay`/`tooltip`: a class defeats `:not([class])`, but one\n// matching `[class*=\"panel\"]` trades that hole for another these elements did not have.\nexport const OVERLAY_CLASS = {\n dropdown: 'malachite-dropdown-surface',\n multiselect: 'malachite-multiselect-surface',\n actionmenu: 'malachite-actionmenu-surface',\n tooltip: 'malachite-tip-surface',\n sidepanel: 'malachite-drawer-surface',\n modal: 'malachite-modal-surface',\n commandpalette: 'malachite-cmdpalette-surface',\n popover: 'malachite-popover-surface',\n toast: 'malachite-toast-surface',\n} as const;\n\nexport type OverlayName = keyof typeof OVERLAY_CLASS;\n\n// Exhaustive, so a new overlay fails to typecheck until classified, and a popup is then refused\n// by `overlayIdentity`: its only identity comes from `usePopupLayer`, which registers it.\nconst OVERLAY_ROLE = {\n dropdown: 'popup',\n multiselect: 'popup',\n actionmenu: 'popup',\n popover: 'popup',\n sidepanel: 'trap',\n modal: 'trap',\n commandpalette: 'trap',\n tooltip: 'unfocusable',\n toast: 'unfocusable',\n} as const satisfies Record<OverlayName, 'popup' | 'trap' | 'unfocusable'>;\n\nexport type PopupOverlayName = {\n [Name in OverlayName]: (typeof OVERLAY_ROLE)[Name] extends 'popup' ? Name : never;\n}[OverlayName];\n\nexport const overlayIdentity = (name: Exclude<OverlayName, PopupOverlayName>) => ({\n className: OVERLAY_CLASS[name],\n [OVERLAY_ATTR]: name,\n});\n\nconst OVERLAY_STYLE_ID = 'malachite-overlay-styles';\n\n/**\n * Where SidePanel, Modal and CommandPalette start. `useOverlayBehaviour` steps one per stacked overlay, so\n * paint order follows the focus stack rather than body order — a handful above this at most.\n */\nexport const OVERLAY_Z_BASE = 1000;\n\n/**\n * The dropdown band, which clears app chrome pinned just under max-int. One integer wide: a host\n * pins its chrome at max-int-1 and the tooltip band sits at max-int, so the stack cannot step\n * per layer the way the base band does — the top layer orders it, and where popover is\n * unsupported, document order does.\n */\nexport const OVERLAY_Z_ELEVATED = 2147483646;\n\n/** Marks a host in that band — an attribute, not an inline z-index; see above. */\nexport const OVERLAY_ELEVATED_ATTR = 'data-malachite-elevated';\n\n// Every overlay class, not the four promoted by default: one the reset misses wears the UA box.\nconst promotedSelector = (suffix: string) =>\n Object.values(OVERLAY_CLASS)\n .map((name) => `.${name}:popover-open${suffix}`)\n .join(', ');\n\n// Promotion drags in the UA `[popover]` box: `inset: 0` (which survives as right/bottom and\n// stretches a panel to the viewport edge), auto margins, a border, padding and fit-content\n// sizing. Reset to what these computed before promotion; their own inline styles still win.\nconst POPOVER_RESET =\n 'inset: auto; margin: 0; border: 0; padding: 0; width: auto; height: auto; ' +\n 'overflow: visible; background: none; color: inherit;';\n\nconst OVERLAY_RULES = [\n `.${OVERLAY_CLASS.dropdown}, .${OVERLAY_CLASS.multiselect}, .${OVERLAY_CLASS.actionmenu} { z-index: 2147483646; }`,\n `.${OVERLAY_CLASS.tooltip} { z-index: 2147483647; }`,\n];\n\n// Its own id, never folded into OVERLAY_STYLE_ID: injectStyleSheet keeps one sheet per id across\n// malachite copies sharing a realm, so a copy predating this rule would win that id and leave a\n// portaled menu on the host page's box model — a 280px Options menu painting 298. No copy has\n// ever registered this one.\nconst MENU_BOX_STYLE_ID = 'malachite-overlay-menu-box';\n\n// The scoped stylesheet makes everything border-box; a portal escapes it onto a host page that\n// may have no reset at all, while the geometry is computed as a CSS width.\nconst MENU_BOX_RULES = [\n `.${OVERLAY_CLASS.dropdown}, .${OVERLAY_CLASS.dropdown} *,` +\n ` .${OVERLAY_CLASS.multiselect}, .${OVERLAY_CLASS.multiselect} *,` +\n ` .${OVERLAY_CLASS.actionmenu}, .${OVERLAY_CLASS.actionmenu} *` +\n ' { box-sizing: border-box; }',\n];\n\nconst POPOVER_STYLE_ID = 'malachite-overlay-popover';\n\nconst POPOVER_RULES = [\n `.${OVERLAY_CLASS.popover} { z-index: ${OVERLAY_Z_ELEVATED}; }`,\n `.${OVERLAY_CLASS.popover}:popover-open { ${POPOVER_RESET} }`,\n `.${OVERLAY_CLASS.popover}:popover-open::backdrop { display: none; }`,\n];\n\nexport const ensurePopoverStyles = (): CSSStyleSheet | null =>\n injectStyleSheet(POPOVER_STYLE_ID, POPOVER_RULES);\n\nexport const ensureOverlayStyles = (): CSSStyleSheet | null => {\n injectStyleSheet(MENU_BOX_STYLE_ID, MENU_BOX_RULES);\n return injectStyleSheet(OVERLAY_STYLE_ID, OVERLAY_RULES);\n};\n\n// Its own id like TOP_LAYER_STYLE_ID: a copy predating elevation would own OVERLAY_STYLE_ID.\nconst ELEVATED_STYLE_ID = 'malachite-overlay-elevated';\n\nconst ELEVATED_RULES = [\n `.${OVERLAY_CLASS.sidepanel}[${OVERLAY_ELEVATED_ATTR}], .${OVERLAY_CLASS.modal}[${OVERLAY_ELEVATED_ATTR}] { z-index: ${OVERLAY_Z_ELEVATED}; }`,\n];\n\nexport const ensureElevatedOverlayStyles = (): CSSStyleSheet | null =>\n injectStyleSheet(ELEVATED_STYLE_ID, ELEVATED_RULES);\n\n// Its own id, reset included: an older copy may own the shared sheets without the toast class.\nconst TOAST_STYLE_ID = 'malachite-overlay-toast';\n\nconst TOAST_RULES = [\n `.${OVERLAY_CLASS.toast} { z-index: 2147483647; }`,\n `.${OVERLAY_CLASS.toast}:popover-open { ${POPOVER_RESET} }`,\n `.${OVERLAY_CLASS.toast}:popover-open::backdrop { display: none; }`,\n];\n\nexport const ensureToastStyles = (): CSSStyleSheet | null =>\n injectStyleSheet(TOAST_STYLE_ID, TOAST_RULES);\n\n// Its own id, never folded into OVERLAY_STYLE_ID: injectStyleSheet keeps one sheet per id across\n// malachite copies sharing a realm, so a copy predating the reset would win that id and leave a\n// promoted overlay wearing the raw UA box. No copy has ever registered this one.\nconst TOP_LAYER_STYLE_ID = 'malachite-overlay-top-layer';\n\nconst TOP_LAYER_RULES = [\n `${promotedSelector('')} { ${POPOVER_RESET} }`,\n `${promotedSelector('::backdrop')} { display: none; }`,\n];\n\nexport const ensureTopLayerStyles = (): CSSStyleSheet | null => {\n // A sheet that installed does not mean its rules parsed: replaceSync (and the <style> path)\n // drop an unparseable rule silently rather than throwing, so an engine that chokes on\n // `:popover-open` or `::backdrop` hands back a valid, empty sheet.\n const sheet = injectStyleSheet(TOP_LAYER_STYLE_ID, TOP_LAYER_RULES);\n return sheet && sheet.cssRules.length > 0 ? sheet : null;\n};\n"],"names":["OVERLAY_ATTR","OVERLAY_CLASS","overlayIdentity","name","OVERLAY_STYLE_ID","OVERLAY_Z_BASE","OVERLAY_Z_ELEVATED","OVERLAY_ELEVATED_ATTR","promotedSelector","suffix","POPOVER_RESET","OVERLAY_RULES","MENU_BOX_STYLE_ID","MENU_BOX_RULES","POPOVER_STYLE_ID","POPOVER_RULES","ensurePopoverStyles","injectStyleSheet","ensureOverlayStyles","ELEVATED_STYLE_ID","ELEVATED_RULES","ensureElevatedOverlayStyles","TOAST_STYLE_ID","TOAST_RULES","ensureToastStyles","TOP_LAYER_STYLE_ID","TOP_LAYER_RULES","ensureTopLayerStyles","sheet"],"mappings":";AAOO,MAAMA,IAAe,0BAIfC,IAAgB;AAAA,EACzB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,OAAO;AACX,GAsBaC,IAAkB,CAACC,OAAkD;AAAA,EAC9E,WAAWF,EAAcE,CAAI;AAAA,EAC7B,CAACH,CAAY,GAAGG;AACpB,IAEMC,IAAmB,4BAMZC,IAAiB,KAQjBC,IAAqB,YAGrBC,IAAwB,2BAG/BC,IAAmB,CAACC,MACtB,OAAO,OAAOR,CAAa,EACtB,IAAI,CAACE,MAAS,IAAIA,CAAI,gBAAgBM,CAAM,EAAE,EAC9C,KAAK,IAAI,GAKZC,IACF,kIAGEC,IAAgB;AAAA,EAClB,IAAIV,EAAc,QAAQ,MAAMA,EAAc,WAAW,MAAMA,EAAc,UAAU;AAAA,EACvF,IAAIA,EAAc,OAAO;AAC7B,GAMMW,IAAoB,8BAIpBC,IAAiB;AAAA,EACnB,IAAIZ,EAAc,QAAQ,MAAMA,EAAc,QAAQ,QAC7CA,EAAc,WAAW,MAAMA,EAAc,WAAW,QACxDA,EAAc,UAAU,MAAMA,EAAc,UAAU;AAEnE,GAEMa,IAAmB,6BAEnBC,IAAgB;AAAA,EAClB,IAAId,EAAc,OAAO,eAAeK,CAAkB;AAAA,EAC1D,IAAIL,EAAc,OAAO,mBAAmBS,CAAa;AAAA,EACzD,IAAIT,EAAc,OAAO;AAC7B,GAEae,IAAsB,MAC/BC,EAAiBH,GAAkBC,CAAa,GAEvCG,IAAsB,OAC/BD,EAAiBL,GAAmBC,CAAc,GAC3CI,EAAiBb,GAAkBO,CAAa,IAIrDQ,IAAoB,8BAEpBC,IAAiB;AAAA,EACnB,IAAInB,EAAc,SAAS,IAAIM,CAAqB,OAAON,EAAc,KAAK,IAAIM,CAAqB,gBAAgBD,CAAkB;AAC7I,GAEae,IAA8B,MACvCJ,EAAiBE,GAAmBC,CAAc,GAGhDE,IAAiB,2BAEjBC,IAAc;AAAA,EAChB,IAAItB,EAAc,KAAK;AAAA,EACvB,IAAIA,EAAc,KAAK,mBAAmBS,CAAa;AAAA,EACvD,IAAIT,EAAc,KAAK;AAC3B,GAEauB,IAAoB,MAC7BP,EAAiBK,GAAgBC,CAAW,GAK1CE,IAAqB,+BAErBC,IAAkB;AAAA,EACpB,GAAGlB,EAAiB,EAAE,CAAC,MAAME,CAAa;AAAA,EAC1C,GAAGF,EAAiB,YAAY,CAAC;AACrC,GAEamB,IAAuB,MAA4B;AAI5D,QAAMC,IAAQX,EAAiBQ,GAAoBC,CAAe;AAClE,SAAOE,KAASA,EAAM,SAAS,SAAS,IAAIA,IAAQ;AACxD;"}
@@ -0,0 +1,12 @@
1
+ import { useContext as o, createContext as e } from "react";
2
+ const r = e(null), n = () => {
3
+ const t = o(r);
4
+ if (!t)
5
+ throw new Error("useToast must be used within a ToastProvider");
6
+ return t;
7
+ };
8
+ export {
9
+ r as ToastContext,
10
+ n as useToast
11
+ };
12
+ //# sourceMappingURL=toastContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toastContext.js","sources":["../../src/components/toastContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { ToastApi } from './toastTypes';\n\nexport const ToastContext = createContext<ToastApi | null>(null);\n\n/** Shows a toast from anywhere under a `ToastProvider`. Throws outside one. */\nexport const useToast = (): ToastApi => {\n const api = useContext(ToastContext);\n if (!api) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return api;\n};\n"],"names":["ToastContext","createContext","useToast","api","useContext"],"mappings":";AAGO,MAAMA,IAAeC,EAA+B,IAAI,GAGlDC,IAAW,MAAgB;AACpC,QAAMC,IAAMC,EAAWJ,CAAY;AACnC,MAAI,CAACG;AACD,UAAM,IAAI,MAAM,8CAA8C;AAElE,SAAOA;AACX;"}
@@ -0,0 +1,6 @@
1
+ const T = 3e3, _ = 5e3;
2
+ export {
3
+ _ as TOAST_ANNOUNCEMENT_LIFETIME_MS,
4
+ T as TOAST_DEFAULT_DURATION_MS
5
+ };
6
+ //# sourceMappingURL=toastTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toastTypes.js","sources":["../../src/components/toastTypes.ts"],"sourcesContent":["export type ToastVariant = 'success' | 'error';\n\nexport interface ToastOptions {\n message: string;\n /** Defaults to `'success'`. */\n variant?: ToastVariant;\n}\n\nexport interface ToastApi {\n show: (options: ToastOptions) => void;\n}\n\nexport interface QueuedToast {\n id: number;\n message: string;\n variant: ToastVariant;\n}\n\nexport const TOAST_DEFAULT_DURATION_MS = 3000;\nexport const TOAST_MAX_VISIBLE = 3;\nexport const TOAST_ANNOUNCEMENT_LIFETIME_MS = 5000;\n"],"names":["TOAST_DEFAULT_DURATION_MS","TOAST_ANNOUNCEMENT_LIFETIME_MS"],"mappings":"AAkBO,MAAMA,IAA4B,KAE5BC,IAAiC;"}
package/dist/index.d.ts CHANGED
@@ -5326,6 +5326,26 @@ export declare const ThumbsDownIcon: React.FC<IconProps_107>;
5326
5326
 
5327
5327
  export declare const ThumbsUpIcon: React.FC<IconProps_108>;
5328
5328
 
5329
+ export declare interface ToastApi {
5330
+ show: (options: ToastOptions) => void;
5331
+ }
5332
+
5333
+ export declare interface ToastOptions {
5334
+ message: string;
5335
+ /** Defaults to `'success'`. */
5336
+ variant?: ToastVariant;
5337
+ }
5338
+
5339
+ export declare const ToastProvider: React.FC<ToastProviderProps>;
5340
+
5341
+ export declare interface ToastProviderProps {
5342
+ children?: React.ReactNode;
5343
+ /** How long each toast stays, in ms. Defaults to 3000. */
5344
+ duration?: number;
5345
+ }
5346
+
5347
+ export declare type ToastVariant = 'success' | 'error';
5348
+
5329
5349
  export declare const Toggle: default_2.ForwardRefExoticComponent<ToggleProps & default_2.RefAttributes<HTMLElement>>;
5330
5350
 
5331
5351
  declare interface ToggleProps {
@@ -5516,6 +5536,9 @@ export declare const useHasOpenOverlay: () => boolean;
5516
5536
 
5517
5537
  export declare const useSidebarCollapsed: () => boolean;
5518
5538
 
5539
+ /** Shows a toast from anywhere under a `ToastProvider`. Throws outside one. */
5540
+ export declare const useToast: () => ToastApi;
5541
+
5519
5542
  export declare const WarningCircleFilled: React.FC<IconProps_114>;
5520
5543
 
5521
5544
  export declare const WarningTriangleIcon: React.FC<IconProps_115>;