@stackone/malachite 2.108.1 → 2.109.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,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;
@@ -3574,6 +3579,8 @@ export declare interface MalachiteTheme {
3574
3579
  glowLg?: string;
3575
3580
  /** Optional so adding a shadow never breaks a consumer building a full theme literal. */
3576
3581
  accent?: string;
3582
+ /** A SidePanel's sheet: cast upward, as it rises over the body. Optional, as `accent`. */
3583
+ sheet?: string;
3577
3584
  success: string;
3578
3585
  warning: string;
3579
3586
  error: string;
@@ -3602,6 +3609,8 @@ export declare interface MalachiteTheme {
3602
3609
  overlay: {
3603
3610
  /** Dimming layer drawn behind modal overlays (e.g. SidePanel). */
3604
3611
  scrim: string;
3612
+ /** Dims a SidePanel's body behind its sheet, a step deeper than `scrim`. Optional, as `shadows.accent`. */
3613
+ sheetScrim?: string;
3605
3614
  };
3606
3615
  alert: {
3607
3616
  info: {
@@ -5220,6 +5229,10 @@ export declare interface SidePanelNavFooterProps {
5220
5229
  canPreviousTab?: boolean;
5221
5230
  canNextTab?: boolean;
5222
5231
  actions?: default_2.ReactNode;
5232
+ /** The reader's place, such as `Step 2 of 5`. Default: `Navigate`. */
5233
+ navigateLabel?: string;
5234
+ /** Says what ESC does. Default: `Close`. */
5235
+ escapeLabel?: string;
5223
5236
  className?: string;
5224
5237
  }
5225
5238
 
@@ -5280,6 +5293,25 @@ export declare interface SidePanelProps {
5280
5293
  * up with them. The aside is never narrower than 360px: a window too narrow for both
5281
5294
  * columns scrolls the panel sideways. */
5282
5295
  aside?: SidePanelAside;
5296
+ /** A drill-in raised over the body and footer, dimming the header; see `SidePanelSheet`. */
5297
+ sheet?: SidePanelSheet;
5298
+ children: default_2.ReactNode;
5299
+ }
5300
+
5301
+ export declare interface SidePanelSheet {
5302
+ /** Names the sheet for assistive tech, and its close button. */
5303
+ 'aria-label': string;
5304
+ /** The sheet's header, before `headerExtra`. */
5305
+ title: default_2.ReactNode;
5306
+ /** Content pinned right in the sheet's header, before its close button. */
5307
+ headerExtra?: default_2.ReactNode;
5308
+ /** Pinned at the bottom of the sheet. */
5309
+ footer?: default_2.ReactNode;
5310
+ /** Also called just before the panel's `onClose` when the panel closes, so only one of the two
5311
+ * should navigate. */
5312
+ onClose: () => void;
5313
+ /** Whether the sheet's body gets default padding. Default: true. */
5314
+ bodyPadding?: boolean;
5283
5315
  children: default_2.ReactNode;
5284
5316
  }
5285
5317
 
@@ -5755,6 +5787,8 @@ export declare const SyntheticWebhookIcon: React.FC<IconProps_111>;
5755
5787
  export declare interface TabItem {
5756
5788
  key: string;
5757
5789
  label: default_2.ReactNode;
5790
+ /** A count after the label, such as how many rows the tab lists. */
5791
+ count?: number;
5758
5792
  disabled?: boolean;
5759
5793
  /**
5760
5794
  * The tab's panel. Give it on any item and `Tabs` renders a `tabpanel` per item below the