@stackone/malachite 2.108.1 → 2.110.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 +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 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,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,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;"}
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/** `above-app-overlays` lifts the overlay stack clear of chrome pinned near max-int. */\nexport type OverlayStacking = 'default' | 'above-app-overlays';\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","ensure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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;"}
@@ -1,38 +1,41 @@
1
- import { useState as m, useEffect as d } from "react";
2
- const f = 1200, g = (c) => {
3
- var r;
4
- const [e, n] = m({ key: c, generation: 0, outcome: "idle", copies: 0 });
5
- Object.is(e.key, c) || n((t) => ({
6
- key: c,
7
- generation: t.generation + 1,
1
+ import { useState as p, useEffect as d } from "react";
2
+ const l = 1200, m = () => {
3
+ var e;
4
+ return typeof navigator < "u" && !!((e = navigator.clipboard) != null && e.writeText);
5
+ }, g = (e) => {
6
+ const [t, n] = p({ key: e, generation: 0, outcome: "idle", copies: 0 });
7
+ Object.is(t.key, e) || n((o) => ({
8
+ key: e,
9
+ generation: o.generation + 1,
8
10
  outcome: "idle",
9
- copies: t.copies
11
+ copies: o.copies
10
12
  })), d(() => {
11
- if (e.outcome !== "copied")
13
+ if (t.outcome !== "copied")
12
14
  return;
13
- const t = setTimeout(
15
+ const o = setTimeout(
14
16
  () => n((i) => ({ ...i, outcome: "idle" })),
15
- f
17
+ l
16
18
  );
17
- return () => clearTimeout(t);
18
- }, [e.outcome, e.copies]);
19
- const a = typeof navigator < "u" && !!((r = navigator.clipboard) != null && r.writeText), u = async (t) => {
19
+ return () => clearTimeout(o);
20
+ }, [t.outcome, t.copies]);
21
+ const a = m(), s = async (o) => {
20
22
  if (!a)
21
23
  return !1;
22
- const i = e.generation, s = (p) => n(
23
- (o) => o.generation === i ? { ...o, outcome: p, copies: o.copies + 1 } : o
24
+ const i = t.generation, r = (u) => n(
25
+ (c) => c.generation === i ? { ...c, outcome: u, copies: c.copies + 1 } : c
24
26
  );
25
27
  try {
26
- await navigator.clipboard.writeText(t);
28
+ await navigator.clipboard.writeText(o);
27
29
  } catch {
28
- return s("failed"), !1;
30
+ return r("failed"), !1;
29
31
  }
30
- return s("copied"), !0;
32
+ return r("copied"), !0;
31
33
  };
32
- return { outcome: e.outcome, canCopy: a, copy: u };
34
+ return { outcome: t.outcome, canCopy: a, copy: s };
33
35
  };
34
36
  export {
35
- f as COPIED_FEEDBACK_MS,
37
+ l as COPIED_FEEDBACK_MS,
38
+ m as canCopyToClipboard,
36
39
  g as useClipboardCopy
37
40
  };
38
41
  //# sourceMappingURL=useClipboardCopy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useClipboardCopy.js","sources":["../../src/components/useClipboardCopy.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport const COPIED_FEEDBACK_MS = 1200;\n\nexport type CopyOutcome = 'idle' | 'copied' | 'failed';\n\n/**\n * Copies text and reports how it went, reverting `copied` to `idle` after a beat. A change\n * of `resetKey` clears the outcome and orphans any write still in flight, so a late\n * resolution cannot mark newer content as copied.\n */\nexport const useClipboardCopy = (\n resetKey: unknown,\n): { outcome: CopyOutcome; canCopy: boolean; copy: (text: string) => Promise<boolean> } => {\n const [state, setState] = useState<{\n key: unknown;\n generation: number;\n outcome: CopyOutcome;\n copies: number;\n }>({ key: resetKey, generation: 0, outcome: 'idle', copies: 0 });\n if (!Object.is(state.key, resetKey)) {\n setState((previous) => ({\n key: resetKey,\n generation: previous.generation + 1,\n outcome: 'idle',\n copies: previous.copies,\n }));\n }\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: a second copy while the first still shows restarts the beat\n useEffect(() => {\n if (state.outcome !== 'copied') {\n return;\n }\n const timer = setTimeout(\n () => setState((previous) => ({ ...previous, outcome: 'idle' })),\n COPIED_FEEDBACK_MS,\n );\n return () => clearTimeout(timer);\n }, [state.outcome, state.copies]);\n\n // Absent outside a secure context.\n const canCopy = typeof navigator !== 'undefined' && !!navigator.clipboard?.writeText;\n\n const copy = async (text: string): Promise<boolean> => {\n if (!canCopy) {\n return false;\n }\n const generation = state.generation;\n const settle = (outcome: CopyOutcome) =>\n setState((previous) =>\n previous.generation === generation\n ? { ...previous, outcome, copies: previous.copies + 1 }\n : previous,\n );\n try {\n await navigator.clipboard.writeText(text);\n } catch {\n settle('failed');\n return false;\n }\n settle('copied');\n return true;\n };\n\n return { outcome: state.outcome, canCopy, copy };\n};\n"],"names":["COPIED_FEEDBACK_MS","useClipboardCopy","resetKey","state","setState","useState","previous","useEffect","timer","canCopy","_a","copy","text","generation","settle","outcome"],"mappings":";AAEO,MAAMA,IAAqB,MASrBC,IAAmB,CAC5BC,MACuF;;AACvF,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAKvB,EAAE,KAAKH,GAAU,YAAY,GAAG,SAAS,QAAQ,QAAQ,GAAG;AAC/D,EAAK,OAAO,GAAGC,EAAM,KAAKD,CAAQ,KAC9BE,EAAS,CAACE,OAAc;AAAA,IACpB,KAAKJ;AAAA,IACL,YAAYI,EAAS,aAAa;AAAA,IAClC,SAAS;AAAA,IACT,QAAQA,EAAS;AAAA,EAAA,EACnB,GAINC,EAAU,MAAM;AACZ,QAAIJ,EAAM,YAAY;AAClB;AAEJ,UAAMK,IAAQ;AAAA,MACV,MAAMJ,EAAS,CAACE,OAAc,EAAE,GAAGA,GAAU,SAAS,OAAA,EAAS;AAAA,MAC/DN;AAAA,IAAA;AAEJ,WAAO,MAAM,aAAaQ,CAAK;AAAA,EACnC,GAAG,CAACL,EAAM,SAASA,EAAM,MAAM,CAAC;AAGhC,QAAMM,IAAU,OAAO,YAAc,OAAe,CAAC,GAACC,IAAA,UAAU,cAAV,QAAAA,EAAqB,YAErEC,IAAO,OAAOC,MAAmC;AACnD,QAAI,CAACH;AACD,aAAO;AAEX,UAAMI,IAAaV,EAAM,YACnBW,IAAS,CAACC,MACZX;AAAA,MAAS,CAACE,MACNA,EAAS,eAAeO,IAClB,EAAE,GAAGP,GAAU,SAAAS,GAAS,QAAQT,EAAS,SAAS,MAClDA;AAAA,IAAA;AAEd,QAAI;AACA,YAAM,UAAU,UAAU,UAAUM,CAAI;AAAA,IAC5C,QAAQ;AACJ,aAAAE,EAAO,QAAQ,GACR;AAAA,IACX;AACA,WAAAA,EAAO,QAAQ,GACR;AAAA,EACX;AAEA,SAAO,EAAE,SAASX,EAAM,SAAS,SAAAM,GAAS,MAAAE,EAAA;AAC9C;"}
1
+ {"version":3,"file":"useClipboardCopy.js","sources":["../../src/components/useClipboardCopy.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport const COPIED_FEEDBACK_MS = 1200;\n\n/** Absent outside a secure context. */\nexport const canCopyToClipboard = (): boolean =>\n typeof navigator !== 'undefined' && !!navigator.clipboard?.writeText;\n\nexport type CopyOutcome = 'idle' | 'copied' | 'failed';\n\n/**\n * Copies text and reports how it went, reverting `copied` to `idle` after a beat. A change\n * of `resetKey` clears the outcome and orphans any write still in flight, so a late\n * resolution cannot mark newer content as copied.\n */\nexport const useClipboardCopy = (\n resetKey: unknown,\n): { outcome: CopyOutcome; canCopy: boolean; copy: (text: string) => Promise<boolean> } => {\n const [state, setState] = useState<{\n key: unknown;\n generation: number;\n outcome: CopyOutcome;\n copies: number;\n }>({ key: resetKey, generation: 0, outcome: 'idle', copies: 0 });\n if (!Object.is(state.key, resetKey)) {\n setState((previous) => ({\n key: resetKey,\n generation: previous.generation + 1,\n outcome: 'idle',\n copies: previous.copies,\n }));\n }\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: a second copy while the first still shows restarts the beat\n useEffect(() => {\n if (state.outcome !== 'copied') {\n return;\n }\n const timer = setTimeout(\n () => setState((previous) => ({ ...previous, outcome: 'idle' })),\n COPIED_FEEDBACK_MS,\n );\n return () => clearTimeout(timer);\n }, [state.outcome, state.copies]);\n\n const canCopy = canCopyToClipboard();\n\n const copy = async (text: string): Promise<boolean> => {\n if (!canCopy) {\n return false;\n }\n const generation = state.generation;\n const settle = (outcome: CopyOutcome) =>\n setState((previous) =>\n previous.generation === generation\n ? { ...previous, outcome, copies: previous.copies + 1 }\n : previous,\n );\n try {\n await navigator.clipboard.writeText(text);\n } catch {\n settle('failed');\n return false;\n }\n settle('copied');\n return true;\n };\n\n return { outcome: state.outcome, canCopy, copy };\n};\n"],"names":["COPIED_FEEDBACK_MS","canCopyToClipboard","_a","useClipboardCopy","resetKey","state","setState","useState","previous","useEffect","timer","canCopy","copy","text","generation","settle","outcome"],"mappings":";AAEO,MAAMA,IAAqB,MAGrBC,IAAqB,MAAA;;AAC9B,gBAAO,YAAc,OAAe,CAAC,GAACC,IAAA,UAAU,cAAV,QAAAA,EAAqB;AAAA,GASlDC,IAAmB,CAC5BC,MACuF;AACvF,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAKvB,EAAE,KAAKH,GAAU,YAAY,GAAG,SAAS,QAAQ,QAAQ,GAAG;AAC/D,EAAK,OAAO,GAAGC,EAAM,KAAKD,CAAQ,KAC9BE,EAAS,CAACE,OAAc;AAAA,IACpB,KAAKJ;AAAA,IACL,YAAYI,EAAS,aAAa;AAAA,IAClC,SAAS;AAAA,IACT,QAAQA,EAAS;AAAA,EAAA,EACnB,GAINC,EAAU,MAAM;AACZ,QAAIJ,EAAM,YAAY;AAClB;AAEJ,UAAMK,IAAQ;AAAA,MACV,MAAMJ,EAAS,CAACE,OAAc,EAAE,GAAGA,GAAU,SAAS,OAAA,EAAS;AAAA,MAC/DR;AAAA,IAAA;AAEJ,WAAO,MAAM,aAAaU,CAAK;AAAA,EACnC,GAAG,CAACL,EAAM,SAASA,EAAM,MAAM,CAAC;AAEhC,QAAMM,IAAUV,EAAA,GAEVW,IAAO,OAAOC,MAAmC;AACnD,QAAI,CAACF;AACD,aAAO;AAEX,UAAMG,IAAaT,EAAM,YACnBU,IAAS,CAACC,MACZV;AAAA,MAAS,CAACE,MACNA,EAAS,eAAeM,IAClB,EAAE,GAAGN,GAAU,SAAAQ,GAAS,QAAQR,EAAS,SAAS,MAClDA;AAAA,IAAA;AAEd,QAAI;AACA,YAAM,UAAU,UAAU,UAAUK,CAAI;AAAA,IAC5C,QAAQ;AACJ,aAAAE,EAAO,QAAQ,GACR;AAAA,IACX;AACA,WAAAA,EAAO,QAAQ,GACR;AAAA,EACX;AAEA,SAAO,EAAE,SAASV,EAAM,SAAS,SAAAM,GAAS,MAAAC,EAAA;AAC9C;"}
package/dist/index.d.ts CHANGED
@@ -1249,12 +1249,17 @@ export declare interface CodePreviewProps {
1249
1249
  title: string;
1250
1250
  /** At the right of the header in the mono face, e.g. `POST · acc_8f2…`. */
1251
1251
  meta?: default_2.ReactNode;
1252
+ /** Drops the header, `meta` with it, for a payload whose surroundings already name it. The
1253
+ * title still names it for assistive tech. */
1254
+ titleHidden?: boolean;
1252
1255
  code: string;
1253
1256
  /** How many lines show until the reader asks for all of them. `Infinity` shows them all. */
1254
1257
  previewLines?: number;
1255
1258
  /** 1-based line numbers to flag, such as the fields a scanner caught. Colour alone, so say why nearby. */
1256
1259
  highlightLines?: readonly number[];
1257
1260
  showLineNumbers?: boolean;
1261
+ /** A button over the body copies the whole payload, folded lines too. */
1262
+ copyable?: boolean;
1258
1263
  /** The most lines the expanded body mounts; past it a note says how many are not shown. */
1259
1264
  maxRenderedLines?: number;
1260
1265
  className?: string;
@@ -1434,6 +1439,8 @@ export declare interface ConfirmationDialogProps {
1434
1439
  message: string;
1435
1440
  };
1436
1441
  size?: ModalSize;
1442
+ /** See `Modal`'s `stacking`. */
1443
+ stacking?: OverlayStacking;
1437
1444
  /** Accessible dialog name; required when `title` isn't a plain string. */
1438
1445
  'aria-label'?: string;
1439
1446
  /** ID of a visible element naming the dialog (alternative to `aria-label`). */
@@ -3574,6 +3581,8 @@ export declare interface MalachiteTheme {
3574
3581
  glowLg?: string;
3575
3582
  /** Optional so adding a shadow never breaks a consumer building a full theme literal. */
3576
3583
  accent?: string;
3584
+ /** A SidePanel's sheet: cast upward, as it rises over the body. Optional, as `accent`. */
3585
+ sheet?: string;
3577
3586
  success: string;
3578
3587
  warning: string;
3579
3588
  error: string;
@@ -3602,6 +3611,8 @@ export declare interface MalachiteTheme {
3602
3611
  overlay: {
3603
3612
  /** Dimming layer drawn behind modal overlays (e.g. SidePanel). */
3604
3613
  scrim: string;
3614
+ /** Dims a SidePanel's body behind its sheet, a step deeper than `scrim`. Optional, as `shadows.accent`. */
3615
+ sheetScrim?: string;
3605
3616
  };
3606
3617
  alert: {
3607
3618
  info: {
@@ -4079,6 +4090,12 @@ export declare interface ModalProps {
4079
4090
  * always reaches `onClose` and whether to abort is left to the caller.
4080
4091
  */
4081
4092
  busy?: boolean;
4093
+ /**
4094
+ * `above-app-overlays` lifts the overlay stack clear of chrome pinned near max-int, for a
4095
+ * dialog opened from a consumer's own drawer up there. Without it the dialog still follows
4096
+ * a SidePanel that elevated the stack.
4097
+ */
4098
+ stacking?: OverlayStacking;
4082
4099
  children: default_2.ReactNode;
4083
4100
  }
4084
4101
 
@@ -4263,6 +4280,9 @@ declare interface OverflowRowProps {
4263
4280
  renderOverflow?: (hiddenCount: number) => default_2.ReactNode;
4264
4281
  }
4265
4282
 
4283
+ /** `above-app-overlays` lifts the overlay stack clear of chrome pinned near max-int. */
4284
+ export declare type OverlayStacking = 'default' | 'above-app-overlays';
4285
+
4266
4286
  export declare const Padded: default_2.FC<PaddedProps>;
4267
4287
 
4268
4288
  declare interface PaddedProps {
@@ -5220,6 +5240,10 @@ export declare interface SidePanelNavFooterProps {
5220
5240
  canPreviousTab?: boolean;
5221
5241
  canNextTab?: boolean;
5222
5242
  actions?: default_2.ReactNode;
5243
+ /** The reader's place, such as `Step 2 of 5`. Default: `Navigate`. */
5244
+ navigateLabel?: string;
5245
+ /** Says what ESC does. Default: `Close`. */
5246
+ escapeLabel?: string;
5223
5247
  className?: string;
5224
5248
  }
5225
5249
 
@@ -5266,7 +5290,7 @@ export declare interface SidePanelProps {
5266
5290
  /** Whether the body gets default padding. Default: true. */
5267
5291
  bodyPadding?: boolean;
5268
5292
  /** `above-app-overlays` lifts the overlay stack clear of chrome pinned near max-int. */
5269
- stacking?: 'default' | 'above-app-overlays';
5293
+ stacking?: OverlayStacking;
5270
5294
  /** Full-width Alert bands at the top of the body, above `children`, in order. Unaffected by
5271
5295
  * `bodyPadding`, and announced ahead of `description`. The message is markdown. */
5272
5296
  callouts?: {
@@ -5280,6 +5304,25 @@ export declare interface SidePanelProps {
5280
5304
  * up with them. The aside is never narrower than 360px: a window too narrow for both
5281
5305
  * columns scrolls the panel sideways. */
5282
5306
  aside?: SidePanelAside;
5307
+ /** A drill-in raised over the body and footer, dimming the header; see `SidePanelSheet`. */
5308
+ sheet?: SidePanelSheet;
5309
+ children: default_2.ReactNode;
5310
+ }
5311
+
5312
+ export declare interface SidePanelSheet {
5313
+ /** Names the sheet for assistive tech, and its close button. */
5314
+ 'aria-label': string;
5315
+ /** The sheet's header, before `headerExtra`. */
5316
+ title: default_2.ReactNode;
5317
+ /** Content pinned right in the sheet's header, before its close button. */
5318
+ headerExtra?: default_2.ReactNode;
5319
+ /** Pinned at the bottom of the sheet. */
5320
+ footer?: default_2.ReactNode;
5321
+ /** Also called just before the panel's `onClose` when the panel closes, so only one of the two
5322
+ * should navigate. */
5323
+ onClose: () => void;
5324
+ /** Whether the sheet's body gets default padding. Default: true. */
5325
+ bodyPadding?: boolean;
5283
5326
  children: default_2.ReactNode;
5284
5327
  }
5285
5328
 
@@ -5755,6 +5798,8 @@ export declare const SyntheticWebhookIcon: React.FC<IconProps_111>;
5755
5798
  export declare interface TabItem {
5756
5799
  key: string;
5757
5800
  label: default_2.ReactNode;
5801
+ /** A count after the label, such as how many rows the tab lists. */
5802
+ count?: number;
5758
5803
  disabled?: boolean;
5759
5804
  /**
5760
5805
  * The tab's panel. Give it on any item and `Tabs` renders a `tabpanel` per item below the