@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 +9 -7
- package/dist/ui-provider.d.ts +2 -2
- package/dist/ui-provider.js +15 -12
- package/package.json +1 -1
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
|
|
43
|
-
|
|
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
|
|
51
|
-
inheritance without creating a layout box.
|
|
52
|
-
|
|
53
|
-
|
|
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"
|
package/dist/ui-provider.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
7
|
-
export declare function UIProvider({ appearance, children, direction, preferences }: UIProviderProps):
|
|
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;
|
package/dist/ui-provider.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import {} from "@phreshos/core";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
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
|
-
/**
|
|
8
|
+
/** Establishes only the explicitly supplied UI values for a React subtree. */
|
|
10
9
|
export function UIProvider({ appearance, children, direction, preferences }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
}
|