@phreshos/react-ui 0.1.26 → 0.1.27

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.
package/README.md CHANGED
@@ -39,19 +39,21 @@ import { Button, Surface } from "@phreshos/react-ui"
39
39
 
40
40
  Without a provider, components use Core's `defaultAppearance` and reactively
41
41
  follow the browser's complete visual preferences. `UIProvider` supplies the
42
- Appearance, Preferences, and direction shared by a React UI subtree. Omitted
43
- Appearance and Preferences values inherit from the nearest provider.
42
+ Appearance, Preferences, and direction explicitly established for a React UI
43
+ subtree. Each omitted property inherits independently from the nearest provider
44
+ or follows its own default resolution. A provider with no properties introduces
45
+ no boundary or behavior.
44
46
  React UI also exports that same canonical `defaultAppearance` value for callers
45
47
  that need it explicitly.
46
48
  See [Appearance](https://docs.phreshos.com/system/appearance) for the contract
47
49
  interpreted by the provider and components.
48
50
 
49
51
  React UI is neutral between left-to-right and right-to-left interfaces.
50
- `UIProvider` creates a direction boundary that participates in native DOM
51
- inheritance without creating a layout box. Its direction follows `<html dir>`
52
- unless `direction` supplies an explicit override. React UI reads that same
53
- resolved value only for JavaScript behavior and portals that cannot rely on
54
- native inheritance.
52
+ An explicit `UIProvider` direction creates a boundary that participates in
53
+ native DOM inheritance without creating a layout box. When direction is
54
+ omitted, the provider leaves DOM inheritance unchanged. React UI reads the
55
+ nearest explicit direction—or `<html dir>` when there is none—only for
56
+ JavaScript behavior and portals that cannot rely on native inheritance.
55
57
 
56
58
  ```tsx
57
59
  import { UIProvider, Select } from "@phreshos/react-ui"
@@ -3,8 +3,8 @@ import { type Appearance, type DesktopPreferences as Preferences } from "@phresh
3
3
  import { type Direction } from "./direction.js";
4
4
  export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
5
5
  export { useDirection, useDocumentDirection } from "./direction.js";
6
- /** Supplies the complete shared environment of a React UI subtree. */
7
- export declare function UIProvider({ appearance, children, direction, preferences }: UIProviderProps): import("react").JSX.Element;
6
+ /** Establishes only the explicitly supplied UI values for a React subtree. */
7
+ export declare function UIProvider({ appearance, children, direction, preferences }: UIProviderProps): ReactNode;
8
8
  export interface UIProviderProps {
9
9
  readonly appearance?: Appearance;
10
10
  readonly children: ReactNode;
@@ -1,18 +1,21 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import {} from "@phreshos/core";
3
- import MotionStyle from "./motion-style.js";
4
- import { AppearanceContext, PreferencesContext, useAppearance, usePreferences } from "./appearance-context.js";
5
- import { DirectionContext, useDocumentDirection } from "./direction.js";
3
+ import { AppearanceContext, PreferencesContext } from "./appearance-context.js";
4
+ import { DirectionContext } from "./direction.js";
6
5
  export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
7
6
  export { useDirection, useDocumentDirection } from "./direction.js";
8
7
  const directionBoundaryStyle = { display: "contents" };
9
- /** Supplies the complete shared environment of a React UI subtree. */
8
+ /** Establishes only the explicitly supplied UI values for a React subtree. */
10
9
  export function UIProvider({ appearance, children, direction, preferences }) {
11
- const inheritedAppearance = useAppearance();
12
- const inheritedPreferences = usePreferences();
13
- const documentDirection = useDocumentDirection();
14
- const resolvedAppearance = appearance ?? inheritedAppearance;
15
- const resolvedDirection = direction ?? documentDirection;
16
- const resolvedPreferences = preferences ?? inheritedPreferences;
17
- return _jsx(DirectionContext.Provider, { value: resolvedDirection, children: _jsx("div", { dir: resolvedDirection, style: directionBoundaryStyle, children: _jsx(AppearanceContext.Provider, { value: resolvedAppearance, children: _jsxs(PreferencesContext.Provider, { value: resolvedPreferences, children: [_jsx(MotionStyle, {}), children] }) }) }) });
10
+ let subtree = children;
11
+ if (preferences !== undefined) {
12
+ subtree = _jsx(PreferencesContext.Provider, { value: preferences, children: subtree });
13
+ }
14
+ if (appearance !== undefined) {
15
+ subtree = _jsx(AppearanceContext.Provider, { value: appearance, children: subtree });
16
+ }
17
+ if (direction !== undefined) {
18
+ subtree = _jsx(DirectionContext.Provider, { value: direction, children: _jsx("div", { dir: direction, style: directionBoundaryStyle, children: subtree }) });
19
+ }
20
+ return subtree;
18
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react-ui",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "React components for coherent PhreshOS Program interfaces.",
5
5
  "type": "module",
6
6
  "sideEffects": false,