@phreshos/react-ui 0.1.44 → 0.1.45

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,12 @@
1
+ /**
2
+ * Keeps the document's color scheme on the Theme of the nearest UIProvider,
3
+ * or on the browser's without one. It writes the Theme into the document's
4
+ * `<meta name="color-scheme">`, creating the element when the document has
5
+ * none, before the browser paints, and follows every change. It renders
6
+ * nothing; place it once, where the Theme that owns the page is provided.
7
+ *
8
+ * A page embedded in a frame needs its color scheme to match the frame's, or
9
+ * the browser paints the frame opaque instead of letting what is behind it
10
+ * show.
11
+ */
12
+ export declare function DocumentTheme(): null;
@@ -0,0 +1,29 @@
1
+ import { useLayoutEffect } from "react";
2
+ import { usePreferences } from "./foundation/visual.js";
3
+ /**
4
+ * Keeps the document's color scheme on the Theme of the nearest UIProvider,
5
+ * or on the browser's without one. It writes the Theme into the document's
6
+ * `<meta name="color-scheme">`, creating the element when the document has
7
+ * none, before the browser paints, and follows every change. It renders
8
+ * nothing; place it once, where the Theme that owns the page is provided.
9
+ *
10
+ * A page embedded in a frame needs its color scheme to match the frame's, or
11
+ * the browser paints the frame opaque instead of letting what is behind it
12
+ * show.
13
+ */
14
+ export function DocumentTheme() {
15
+ const { theme } = usePreferences();
16
+ useLayoutEffect(() => {
17
+ const existing = document.head.querySelector('meta[name="color-scheme" i]');
18
+ const meta = existing ?? document.head.appendChild(Object.assign(document.createElement("meta"), { name: "color-scheme" }));
19
+ const previous = meta.content;
20
+ meta.content = theme;
21
+ return () => {
22
+ if (existing)
23
+ meta.content = previous;
24
+ else
25
+ meta.remove();
26
+ };
27
+ }, [theme]);
28
+ return null;
29
+ }
package/dist/main.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  export { appearanceLimits, defaultAppearance, type Appearance, type AppearanceColor, type AppearanceColors, type AppearanceMaterial, type AppearanceRange, type AppearanceShadow, type AppearanceTransaction, type AppearanceUpdate, type Easing, type ThemedValue } from "./foundation/appearance.js";
8
8
  export { UIProvider, type UIProviderProps } from "./foundation/provider.js";
9
+ export { DocumentTheme } from "./document-theme.js";
9
10
  export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./foundation/visual.js";
10
11
  export { useDirection, useDocumentDirection, type Direction } from "./foundation/direction.js";
11
12
  export type { Preferences, PreferencesUpdate, Theme } from "./foundation/preferences.js";
package/dist/main.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  export { appearanceLimits, defaultAppearance } from "./foundation/appearance.js";
8
8
  export { UIProvider } from "./foundation/provider.js";
9
+ export { DocumentTheme } from "./document-theme.js";
9
10
  export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./foundation/visual.js";
10
11
  export { useDirection, useDocumentDirection } from "./foundation/direction.js";
11
12
  export { Flex } from "./flex.js";
package/dist/tabs.js CHANGED
@@ -21,7 +21,6 @@ const TabsRoot = forwardRef(function Tabs({ className, color = "default", defaul
21
21
  gap: metrics.gap,
22
22
  minWidth: 0,
23
23
  fontFamily: "inherit",
24
- fontSize: metrics.fontSize,
25
24
  ...style
26
25
  } }) }) });
27
26
  });
@@ -29,7 +28,8 @@ const TabsRoot = forwardRef(function Tabs({ className, color = "default", defaul
29
28
  const TabsListImplementation = forwardRef(function TabsList({ className, style, ...properties }, ref) {
30
29
  const { color, material, metrics, orientation } = useTabsStyle();
31
30
  const selectedKey = useContext(TabListStateContext)?.selectedKey;
32
- return _jsx(SelectionTrack, { metrics: metrics, color: color, material: material, orientation: orientation, selectedKey: selectedKey, className: className, style: style, children: _jsx(AriaTabList, { ...properties, ref: ref, "data-selection-list": "", style: selectionListStyle(orientation) }) });
31
+ // Only the Tabs take the Tabs' size: the Panels hold consumer content, which keeps its own.
32
+ return _jsx(SelectionTrack, { metrics: metrics, color: color, material: material, orientation: orientation, selectedKey: selectedKey, className: className, style: { fontSize: metrics.fontSize, ...style }, children: _jsx(AriaTabList, { ...properties, ref: ref, "data-selection-list": "", style: selectionListStyle(orientation) }) });
33
33
  });
34
34
  const TabsTab = forwardRef(function TabsTab({ children, className, disabled = false, style, ...properties }, ref) {
35
35
  const { color, metrics, orientation } = useTabsStyle();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react-ui",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "React components for coherent PhreshOS Program interfaces.",
5
5
  "type": "module",
6
6
  "sideEffects": false,