@stackone/malachite 2.123.0 → 2.123.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.
@@ -1,38 +1,38 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { useRef as w, useCallback as F, useState as R, useEffect as u } from "react";
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { useRef as F, useCallback as R, useState as g, useEffect as u } from "react";
3
3
  import { createPortal as I } from "react-dom";
4
4
  import { ensureDroppedFocusTracking as S } from "./components/droppedFocus.js";
5
- import { useFontInjection as g, FontInjectionProvider as j } from "./fontInjection.js";
5
+ import { useFontInjection as j, FontInjectionProvider as T } from "./fontInjection.js";
6
6
  import { ensureInterFontFace as v } from "./inter-font.js";
7
7
  import { adoptTailwindSheet as y } from "./tailwindSheet.js";
8
- import { ensureThemeInitialized as T, applyThemeVars as k, registerShadowRoot as b, unregisterShadowRoot as E } from "./theme.js";
8
+ import { ensureThemeInitialized as k, applyThemeVars as l, getCurrentThemeMode as b, registerShadowRoot as C, unregisterShadowRoot as E } from "./theme.js";
9
9
  const A = ({
10
- children: l,
11
- theme: n,
10
+ children: f,
11
+ theme: t,
12
12
  hostStyle: a,
13
13
  hostProps: c,
14
14
  hostRef: i,
15
- fillHeight: f = !1,
15
+ fillHeight: p = !1,
16
16
  injectFonts: h
17
17
  }) => {
18
- const p = g(), s = h ?? p, t = w(null), d = F(
18
+ const m = j(), s = h ?? m, e = F(null), d = R(
19
19
  (r) => {
20
- t.current = r, i && (i.current = r);
20
+ e.current = r, i && (i.current = r);
21
21
  },
22
22
  [i]
23
- ), [o, m] = R(null);
23
+ ), [o, w] = g(null);
24
24
  return u(() => {
25
- if (t.current && !o) {
26
- const r = t.current.shadowRoot ?? t.current.attachShadow({ mode: "open" });
27
- y(r), m(r);
25
+ if (e.current && !o) {
26
+ const r = e.current.shadowRoot ?? e.current.attachShadow({ mode: "open" });
27
+ y(r), k(), l(r, t ?? b()), w(r);
28
28
  }
29
- }, [o]), u(() => {
29
+ }, [o, t]), u(() => {
30
30
  if (o) {
31
- if (T(), S(), s && v(), n) {
32
- k(o, n);
31
+ if (S(), s && v(), t) {
32
+ l(o, t);
33
33
  return;
34
34
  }
35
- return b(o), () => {
35
+ return C(o), () => {
36
36
  try {
37
37
  E(o);
38
38
  } catch (r) {
@@ -40,7 +40,7 @@ const A = ({
40
40
  }
41
41
  };
42
42
  }
43
- }, [o, n, s]), o === null ? /* @__PURE__ */ e(
43
+ }, [o, t, s]), o === null ? /* @__PURE__ */ n(
44
44
  "div",
45
45
  {
46
46
  ...c,
@@ -48,12 +48,12 @@ const A = ({
48
48
  "data-testid": "shadow-root-wrapper",
49
49
  style: a
50
50
  }
51
- ) : /* @__PURE__ */ e("div", { ...c, ref: d, style: a, children: o && I(
52
- /* @__PURE__ */ e(j, { enabled: s, children: /* @__PURE__ */ e(
51
+ ) : /* @__PURE__ */ n("div", { ...c, ref: d, style: a, children: o && I(
52
+ /* @__PURE__ */ n(T, { enabled: s, children: /* @__PURE__ */ n(
53
53
  "div",
54
54
  {
55
- style: f ? { isolation: "isolate", height: "100%" } : { isolation: "isolate" },
56
- children: l
55
+ style: p ? { isolation: "isolate", height: "100%" } : { isolation: "isolate" },
56
+ children: f
57
57
  }
58
58
  ) }),
59
59
  o
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport { FontInjectionProvider, useFontInjection } from './fontInjection';\nimport { ensureInterFontFace } from './inter-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n /** Set `false` to skip Malachite's font injection (Inter, and Geist / Stack Sans for the\n * components that use them), for a consumer that loads the fonts itself. Inherited from an\n * enclosing wrapper when omitted, otherwise on. */\n injectFonts?: boolean;\n}> = ({\n children,\n theme,\n hostStyle,\n hostProps,\n hostRef: externalHostRef,\n fillHeight = false,\n injectFonts,\n}) => {\n const inheritedInjectFonts = useFontInjection();\n const shouldInjectFonts = injectFonts ?? inheritedInjectFonts;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n setShadowRoot(shadow);\n }\n }, [shadowRoot]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n // Both of these belong to the document, not the shadow root: @font-face does not\n // load fonts from inside a shadow root, and the theme's custom properties are set on\n // documentElement so light-DOM content and portals resolve them too.\n ensureThemeInitialized();\n ensureDroppedFocusTracking();\n if (shouldInjectFonts) {\n ensureInterFontFace();\n }\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme, shouldInjectFonts]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <FontInjectionProvider enabled={shouldInjectFonts}>\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>\n </FontInjectionProvider>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","injectFonts","inheritedInjectFonts","useFontInjection","shouldInjectFonts","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","ensureDroppedFocusTracking","ensureInterFontFace","applyThemeVars","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal","FontInjectionProvider"],"mappings":";;;;;;;;AAcO,MAAMA,IAoBR,CAAC;AAAA,EACF,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAASC;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,aAAAC;AACJ,MAAM;AACF,QAAMC,IAAuBC,EAAA,GACvBC,IAAoBH,KAAeC,GACnCG,IAAUC,EAA8B,IAAI,GAC5CC,IAAWC;AAAA,IACb,CAACC,MAAgC;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ACAe;AAAA,EAAA,GAEZ;AAER;"}
1
+ {"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport { FontInjectionProvider, useFontInjection } from './fontInjection';\nimport { ensureInterFontFace } from './inter-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n getCurrentThemeMode,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n /** Set `false` to skip Malachite's font injection (Inter, and Geist / Stack Sans for the\n * components that use them), for a consumer that loads the fonts itself. Inherited from an\n * enclosing wrapper when omitted, otherwise on. */\n injectFonts?: boolean;\n}> = ({\n children,\n theme,\n hostStyle,\n hostProps,\n hostRef: externalHostRef,\n fillHeight = false,\n injectFonts,\n}) => {\n const inheritedInjectFonts = useFontInjection();\n const shouldInjectFonts = injectFonts ?? inheritedInjectFonts;\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet and theme before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n ensureThemeInitialized();\n applyThemeVars(shadow, theme ?? getCurrentThemeMode());\n setShadowRoot(shadow);\n }\n }, [shadowRoot, theme]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n ensureDroppedFocusTracking();\n // @font-face belongs to the document, not the shadow root: it does not load fonts\n // from inside a shadow root.\n if (shouldInjectFonts) {\n ensureInterFontFace();\n }\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme, shouldInjectFonts]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <FontInjectionProvider enabled={shouldInjectFonts}>\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>\n </FontInjectionProvider>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","injectFonts","inheritedInjectFonts","useFontInjection","shouldInjectFonts","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","applyThemeVars","getCurrentThemeMode","ensureDroppedFocusTracking","ensureInterFontFace","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal","FontInjectionProvider"],"mappings":";;;;;;;;AAeO,MAAMA,IAoBR,CAAC;AAAA,EACF,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAASC;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,aAAAC;AACJ,MAAM;AACF,QAAMC,IAAuBC,EAAA,GACvBC,IAAoBH,KAAeC,GACnCG,IAAUC,EAA8B,IAAI,GAC5CC,IAAWC;AAAA,IACb,CAACC,MAAgC;AAC7B,MAAAJ,EAAQ,UAAUI,GACdV,MACAA,EAAgB,UAAUU;AAAA,IAElC;AAAA,IACA,CAACV,CAAe;AAAA,EAAA,GAEd,CAACW,GAAYC,CAAa,IAAIC,EAA4B,IAAI;AA0CpE,SAxCAC,EAAU,MAAM;AACZ,QAAIR,EAAQ,WAAW,CAACK,GAAY;AAChC,YAAMI,IACFT,EAAQ,QAAQ,cAAcA,EAAQ,QAAQ,aAAa,EAAE,MAAM,QAAQ;AAK/E,MAAAU,EAAmBD,CAAM,GACzBE,EAAA,GACAC,EAAeH,GAAQlB,KAASsB,GAAqB,GACrDP,EAAcG,CAAM;AAAA,IACxB;AAAA,EACJ,GAAG,CAACJ,GAAYd,CAAK,CAAC,GAEtBiB,EAAU,MAAM;AACZ,QAAKH,GASL;AAAA,UANAS,EAAA,GAGIf,KACAgB,EAAA,GAEAxB,GAAO;AACP,QAAAqB,EAAeP,GAAYd,CAAK;AAChC;AAAA,MACJ;AACA,aAAAyB,EAAmBX,CAAU,GACtB,MAAM;AACT,YAAI;AACA,UAAAY,EAAqBZ,CAAU;AAAA,QACnC,SAASa,GAAO;AAEZ,kBAAQ,KAAK,qCAAqCA,CAAK;AAAA,QAC3D;AAAA,MACJ;AAAA;AAAA,EACJ,GAAG,CAACb,GAAYd,GAAOQ,CAAiB,CAAC,GAErCM,MAAe,OAGX,gBAAAc;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG1B;AAAA,MACJ,KAAKS;AAAA,MACL,eAAY;AAAA,MACZ,OAAOV;AAAA,IAAA;AAAA,EAAA,IAOf,gBAAA2B,EAAC,SAAK,GAAG1B,GAAW,KAAKS,GAAU,OAAOV,GACrC,UAAAa,KACGe;AAAA,IACI,gBAAAD,EAACE,GAAA,EAAsB,SAAStB,GAChC,UAAA,gBAAAoB;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,OACIxB,IACM,EAAE,WAAW,WAAW,QAAQ,OAAA,IAChC,EAAE,WAAW,UAAA;AAAA,QAGtB,UAAAL;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,IACAe;AAAA,EAAA,GAEZ;AAER;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/malachite",
3
- "version": "2.123.0",
3
+ "version": "2.123.1",
4
4
  "description": "StackOne's themeable React component library — Shadow DOM isolated, scoped Tailwind, theme-token driven.",
5
5
  "license": "MIT",
6
6
  "author": "StackOne",