@stackone/malachite 2.94.1 → 2.95.1

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.
@@ -0,0 +1,22 @@
1
+ const u = (r, e) => {
2
+ if (r && !r.disabled) {
3
+ r.focus({ preventScroll: !0 });
4
+ return;
5
+ }
6
+ if (!e)
7
+ return;
8
+ const t = e.getAttribute("tabindex"), n = () => t === null ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", t);
9
+ e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }), e.getRootNode().activeElement === e ? e.addEventListener("blur", n, { once: !0 }) : n();
10
+ }, o = (r, e) => {
11
+ const { activeElement: t } = e;
12
+ return !!t && r.contains(t);
13
+ }, s = ({ body: r, section: e }) => {
14
+ const t = e.ownerDocument;
15
+ return o(r, e.getRootNode()) || !t.activeElement || t.activeElement === t.body;
16
+ };
17
+ export {
18
+ u as focusSection,
19
+ o as holdsFocus,
20
+ s as isFocusLost
21
+ };
22
+ //# sourceMappingURL=collapseFocus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapseFocus.js","sources":["../../src/components/collapseFocus.ts"],"sourcesContent":["// Moving focus out of an Accordion body as it collapses; see `CollapseFocusHandOff`.\n\nexport const focusSection = (toggle: HTMLButtonElement | null, section: HTMLElement | null) => {\n if (toggle && !toggle.disabled) {\n toggle.focus({ preventScroll: true });\n return;\n }\n if (!section) {\n return;\n }\n // Focusable for this one stop, then back to whatever tabindex the consumer gave it.\n const previous = section.getAttribute('tabindex');\n const restore = () =>\n previous === null\n ? section.removeAttribute('tabindex')\n : section.setAttribute('tabindex', previous);\n section.setAttribute('tabindex', '-1');\n section.focus({ preventScroll: true });\n // Ignored inside an inert ancestor, where no blur would ever come to restore it.\n if ((section.getRootNode() as Document | ShadowRoot).activeElement === section) {\n section.addEventListener('blur', restore, { once: true });\n } else {\n restore();\n }\n};\n\n// Taken before the commit: an instant body is detached from its section by the update.\nexport interface FocusSnapshot {\n body: HTMLElement;\n section: HTMLElement;\n}\n\nexport const holdsFocus = (body: HTMLElement, root: Node) => {\n const { activeElement } = root as Document | ShadowRoot;\n return !!activeElement && body.contains(activeElement);\n};\n\n// Still inside a body that is inert or detached, or dropped to the page.\nexport const isFocusLost = ({ body, section }: FocusSnapshot) => {\n const page = section.ownerDocument;\n return (\n holdsFocus(body, section.getRootNode()) ||\n !page.activeElement ||\n page.activeElement === page.body\n );\n};\n"],"names":["focusSection","toggle","section","previous","restore","holdsFocus","body","root","activeElement","isFocusLost","page"],"mappings":"AAEO,MAAMA,IAAe,CAACC,GAAkCC,MAAgC;AAC3F,MAAID,KAAU,CAACA,EAAO,UAAU;AAC5B,IAAAA,EAAO,MAAM,EAAE,eAAe,GAAA,CAAM;AACpC;AAAA,EACJ;AACA,MAAI,CAACC;AACD;AAGJ,QAAMC,IAAWD,EAAQ,aAAa,UAAU,GAC1CE,IAAU,MACZD,MAAa,OACPD,EAAQ,gBAAgB,UAAU,IAClCA,EAAQ,aAAa,YAAYC,CAAQ;AACnD,EAAAD,EAAQ,aAAa,YAAY,IAAI,GACrCA,EAAQ,MAAM,EAAE,eAAe,GAAA,CAAM,GAEhCA,EAAQ,cAAwC,kBAAkBA,IACnEA,EAAQ,iBAAiB,QAAQE,GAAS,EAAE,MAAM,IAAM,IAExDA,EAAA;AAER,GAQaC,IAAa,CAACC,GAAmBC,MAAe;AACzD,QAAM,EAAE,eAAAC,MAAkBD;AAC1B,SAAO,CAAC,CAACC,KAAiBF,EAAK,SAASE,CAAa;AACzD,GAGaC,IAAc,CAAC,EAAE,MAAAH,GAAM,SAAAJ,QAA6B;AAC7D,QAAMQ,IAAOR,EAAQ;AACrB,SACIG,EAAWC,GAAMJ,EAAQ,YAAA,CAAa,KACtC,CAACQ,EAAK,iBACNA,EAAK,kBAAkBA,EAAK;AAEpC;"}
@@ -1,27 +1,27 @@
1
- import { version as u } from "react";
2
- const e = (n, o) => {
1
+ import { IS_REACT_19 as p } from "./reactVersion.js";
2
+ const u = (n, o) => {
3
3
  if (typeof n == "function")
4
4
  return n(o);
5
5
  n && (n.current = o);
6
- }, i = (...n) => (o) => {
7
- const t = n.map((c) => e(c, o));
6
+ }, a = (...n) => (o) => {
7
+ const t = n.map((c) => u(c, o));
8
8
  if (t.some((c) => typeof c == "function"))
9
9
  return () => {
10
- n.forEach((c, r) => {
11
- const f = t[r];
10
+ n.forEach((c, e) => {
11
+ const f = t[e];
12
12
  if (typeof f == "function") {
13
13
  f();
14
14
  return;
15
15
  }
16
- e(c, null);
16
+ u(c, null);
17
17
  });
18
18
  };
19
- }, p = Number(u.split(".")[0]) >= 19, a = (n) => p ? n.props.ref : n.ref, l = (n, o) => (t) => {
19
+ }, s = (n) => p ? n.props.ref : n.ref, i = (n, o) => (t) => {
20
20
  n == null || n(t), t.defaultPrevented || o(t);
21
21
  };
22
22
  export {
23
- l as chainHandler,
24
- i as composeRefs,
25
- a as elementRef
23
+ i as chainHandler,
24
+ a as composeRefs,
25
+ s as elementRef
26
26
  };
27
27
  //# sourceMappingURL=composeRefs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"composeRefs.js","sources":["../../src/components/composeRefs.ts"],"sourcesContent":["import type React from 'react';\nimport { version } from 'react';\n\ntype AnyRef<T> = React.Ref<T> | undefined;\n\nconst setRef = <T>(ref: AnyRef<T>, node: T | null): void | (() => void) => {\n if (typeof ref === 'function') {\n return ref(node);\n }\n if (ref) {\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n};\n\nexport const composeRefs =\n <T>(...refs: AnyRef<T>[]) =>\n (node: T | null): void | (() => void) => {\n const cleanups = refs.map((ref) => setRef(ref, node));\n if (!cleanups.some((cleanup) => typeof cleanup === 'function')) {\n return;\n }\n return () => {\n refs.forEach((ref, index) => {\n const cleanup = cleanups[index];\n if (typeof cleanup === 'function') {\n cleanup();\n return;\n }\n setRef(ref, null);\n });\n };\n };\n\nconst REF_IN_PROPS = Number(version.split('.')[0]) >= 19;\n\nexport const elementRef = <T>(element: React.ReactElement): AnyRef<T> =>\n (REF_IN_PROPS\n ? (element.props as { ref?: React.Ref<T> }).ref\n : (element as unknown as { ref?: React.Ref<T> }).ref) as AnyRef<T>;\n\nexport const chainHandler =\n <E extends React.SyntheticEvent>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n ) =>\n (event: E): void => {\n theirs?.(event);\n if (!event.defaultPrevented) {\n ours(event);\n }\n };\n"],"names":["setRef","ref","node","composeRefs","refs","cleanups","cleanup","index","REF_IN_PROPS","version","elementRef","element","chainHandler","theirs","ours","event"],"mappings":";AAKA,MAAMA,IAAS,CAAIC,GAAgBC,MAAwC;AACvE,MAAI,OAAOD,KAAQ;AACf,WAAOA,EAAIC,CAAI;AAEnB,EAAID,MACCA,EAAyC,UAAUC;AAE5D,GAEaC,IACT,IAAOC,MACP,CAACF,MAAwC;AACrC,QAAMG,IAAWD,EAAK,IAAI,CAACH,MAAQD,EAAOC,GAAKC,CAAI,CAAC;AACpD,MAAKG,EAAS,KAAK,CAACC,MAAY,OAAOA,KAAY,UAAU;AAG7D,WAAO,MAAM;AACT,MAAAF,EAAK,QAAQ,CAACH,GAAKM,MAAU;AACzB,cAAMD,IAAUD,EAASE,CAAK;AAC9B,YAAI,OAAOD,KAAY,YAAY;AAC/B,UAAAA,EAAA;AACA;AAAA,QACJ;AACA,QAAAN,EAAOC,GAAK,IAAI;AAAA,MACpB,CAAC;AAAA,IACL;AACJ,GAEEO,IAAe,OAAOC,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAEzCC,IAAa,CAAIC,MACzBH,IACMG,EAAQ,MAAiC,MACzCA,EAA8C,KAE5CC,IACT,CACIC,GACAC,MAEJ,CAACC,MAAmB;AAChB,EAAAF,KAAA,QAAAA,EAASE,IACJA,EAAM,oBACPD,EAAKC,CAAK;AAElB;"}
1
+ {"version":3,"file":"composeRefs.js","sources":["../../src/components/composeRefs.ts"],"sourcesContent":["import type React from 'react';\nimport { IS_REACT_19 } from './reactVersion';\n\ntype AnyRef<T> = React.Ref<T> | undefined;\n\nconst setRef = <T>(ref: AnyRef<T>, node: T | null): void | (() => void) => {\n if (typeof ref === 'function') {\n return ref(node);\n }\n if (ref) {\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n};\n\nexport const composeRefs =\n <T>(...refs: AnyRef<T>[]) =>\n (node: T | null): void | (() => void) => {\n const cleanups = refs.map((ref) => setRef(ref, node));\n if (!cleanups.some((cleanup) => typeof cleanup === 'function')) {\n return;\n }\n return () => {\n refs.forEach((ref, index) => {\n const cleanup = cleanups[index];\n if (typeof cleanup === 'function') {\n cleanup();\n return;\n }\n setRef(ref, null);\n });\n };\n };\n\nexport const elementRef = <T>(element: React.ReactElement): AnyRef<T> =>\n (IS_REACT_19\n ? (element.props as { ref?: React.Ref<T> }).ref\n : (element as unknown as { ref?: React.Ref<T> }).ref) as AnyRef<T>;\n\nexport const chainHandler =\n <E extends React.SyntheticEvent>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n ) =>\n (event: E): void => {\n theirs?.(event);\n if (!event.defaultPrevented) {\n ours(event);\n }\n };\n"],"names":["setRef","ref","node","composeRefs","refs","cleanups","cleanup","index","elementRef","element","IS_REACT_19","chainHandler","theirs","ours","event"],"mappings":";AAKA,MAAMA,IAAS,CAAIC,GAAgBC,MAAwC;AACvE,MAAI,OAAOD,KAAQ;AACf,WAAOA,EAAIC,CAAI;AAEnB,EAAID,MACCA,EAAyC,UAAUC;AAE5D,GAEaC,IACT,IAAOC,MACP,CAACF,MAAwC;AACrC,QAAMG,IAAWD,EAAK,IAAI,CAACH,MAAQD,EAAOC,GAAKC,CAAI,CAAC;AACpD,MAAKG,EAAS,KAAK,CAACC,MAAY,OAAOA,KAAY,UAAU;AAG7D,WAAO,MAAM;AACT,MAAAF,EAAK,QAAQ,CAACH,GAAKM,MAAU;AACzB,cAAMD,IAAUD,EAASE,CAAK;AAC9B,YAAI,OAAOD,KAAY,YAAY;AAC/B,UAAAA,EAAA;AACA;AAAA,QACJ;AACA,QAAAN,EAAOC,GAAK,IAAI;AAAA,MACpB,CAAC;AAAA,IACL;AACJ,GAESO,IAAa,CAAIC,MACzBC,IACMD,EAAQ,MAAiC,MACzCA,EAA8C,KAE5CE,IACT,CACIC,GACAC,MAEJ,CAACC,MAAmB;AAChB,EAAAF,KAAA,QAAAA,EAASE,IACJA,EAAM,oBACPD,EAAKC,CAAK;AAElB;"}
@@ -0,0 +1,6 @@
1
+ import { IS_REACT_19 as t } from "./reactVersion.js";
2
+ const n = (r) => r ? { inert: t ? !0 : "" } : {};
3
+ export {
4
+ n as inertWhen
5
+ };
6
+ //# sourceMappingURL=inert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inert.js","sources":["../../src/components/inert.ts"],"sourcesContent":["import type React from 'react';\nimport { IS_REACT_19 } from './reactVersion';\n\n// React 19 takes `inert` as a boolean; React 18 only passes a string through to the DOM.\nexport const inertWhen = (on: boolean) =>\n (on ? { inert: IS_REACT_19 ? true : '' } : {}) as React.HTMLAttributes<HTMLDivElement>;\n"],"names":["inertWhen","on","IS_REACT_19"],"mappings":";AAIO,MAAMA,IAAY,CAACC,MACrBA,IAAK,EAAE,OAAOC,IAAc,KAAO,OAAO,CAAA;"}
@@ -0,0 +1,6 @@
1
+ import { version as o } from "react";
2
+ const t = Number(o.split(".")[0]) >= 19;
3
+ export {
4
+ t as IS_REACT_19
5
+ };
6
+ //# sourceMappingURL=reactVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactVersion.js","sources":["../../src/components/reactVersion.ts"],"sourcesContent":["import { version } from 'react';\n\nexport const IS_REACT_19 = Number(version.split('.')[0]) >= 19;\n"],"names":["IS_REACT_19","version"],"mappings":";AAEO,MAAMA,IAAc,OAAOC,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;"}
package/dist/index.d.ts CHANGED
@@ -280,7 +280,7 @@ export declare interface AppLogoProps {
280
280
  nameWeight?: FontWeight;
281
281
  /** Rendered as a tag after the name, e.g. `v1.2.0` or `Legacy`. */
282
282
  version?: string;
283
- /** Truncates a long name with an ellipsis and reveals the full value on hover. */
283
+ /** Truncates a long name with an ellipsis, and reveals it on hover once it is cut off. */
284
284
  truncate?: boolean;
285
285
  className?: string;
286
286
  }
@@ -1036,6 +1036,11 @@ export declare interface CheckboxProps {
1036
1036
  onChange?: (checked: boolean) => void;
1037
1037
  disabled?: boolean;
1038
1038
  size?: number;
1039
+ /**
1040
+ * `warning` draws attention to this box in every state, unchecked included, for a choice
1041
+ * that needs a second look such as an unsaved change.
1042
+ */
1043
+ tone?: CheckboxTone;
1039
1044
  /**
1040
1045
  * Render a visual-only indicator (a non-interactive, non-focusable `<span>`,
1041
1046
  * `aria-hidden`) instead of an interactive checkbox. Use this inside a clickable
@@ -1048,6 +1053,8 @@ export declare interface CheckboxProps {
1048
1053
  id?: string;
1049
1054
  }
1050
1055
 
1056
+ export declare type CheckboxTone = 'default' | 'warning';
1057
+
1051
1058
  export declare const CheckCircleFilled: React.FC<IconProps_24>;
1052
1059
 
1053
1060
  export declare const CheckIcon: React.FC<IconProps_25>;