@phreshos/react-ui 0.1.26 → 0.1.28

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
@@ -8,8 +8,8 @@ Environment-neutral React components and the visual language of PhreshOS.
8
8
 
9
9
  ## Role
10
10
 
11
- React UI interprets Core Appearance and Theme contracts as reusable visual
12
- primitives. The Desktop and Programs compose those primitives instead of
11
+ React UI owns reusable visual contracts that accept the corresponding PhreshOS
12
+ System values directly. The Desktop and Programs compose those primitives instead of
13
13
  reimplementing material, spacing, color, radius, or interaction behavior.
14
14
 
15
15
  The package does not depend on a Client or Server runtime and does not own
@@ -25,9 +25,8 @@ applications own composition.
25
25
  | Bun | `bun add @phreshos/react-ui` |
26
26
  | Yarn | `yarn add @phreshos/react-ui` |
27
27
 
28
- Core is a built-in runtime dependency. React and React DOM remain peer
29
- dependencies because the application and React UI must share one React
30
- runtime.
28
+ React and React DOM are peer dependencies because the application and React UI
29
+ must share one React runtime.
31
30
 
32
31
  ```tsx
33
32
  import { Button, Surface } from "@phreshos/react-ui"
@@ -37,21 +36,23 @@ import { Button, Surface } from "@phreshos/react-ui"
37
36
  </Surface>
38
37
  ```
39
38
 
40
- Without a provider, components use Core's `defaultAppearance` and reactively
39
+ Without a provider, components use React UI's `defaultAppearance` and reactively
41
40
  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.
44
- React UI also exports that same canonical `defaultAppearance` value for callers
45
- that need it explicitly.
46
- See [Appearance](https://docs.phreshos.com/system/appearance) for the contract
47
- interpreted by the provider and components.
41
+ Appearance, Preferences, and direction explicitly established for a React UI
42
+ subtree. Each omitted property inherits independently from the nearest provider
43
+ or follows its own default resolution. A provider with no properties introduces
44
+ no boundary or behavior.
45
+ React UI also exports `defaultAppearance` for callers that need the value
46
+ explicitly. A complete System Appearance can be passed directly; React UI uses
47
+ the visual fields it owns and ignores additional System fields such as
48
+ wallpapers.
48
49
 
49
50
  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.
51
+ An explicit `UIProvider` direction creates a boundary that participates in
52
+ native DOM inheritance without creating a layout box. When direction is
53
+ omitted, the provider leaves DOM inheritance unchanged. React UI reads the
54
+ nearest explicit direction—or `<html dir>` when there is none—only for
55
+ JavaScript behavior and portals that cannot rely on native inheritance.
55
56
 
56
57
  ```tsx
57
58
  import { UIProvider, Select } from "@phreshos/react-ui"
@@ -277,8 +278,7 @@ the committed dependency graph without local package substitutions.
277
278
 
278
279
  ## Related repositories
279
280
 
280
- - [`@phreshos/core`](https://github.com/PhreshOS/core) owns Appearance, Theme,
281
- and the shared values interpreted here.
281
+ - [`@phreshos/core`](https://github.com/PhreshOS/core) owns the System contracts.
282
282
  - [`@phreshos/react`](https://github.com/PhreshOS/react) owns runtime-neutral
283
283
  React state adaptation.
284
284
  - [PhreshOS System](https://github.com/PhreshOS/system) composes the visual
@@ -1,19 +1,8 @@
1
- import { type Appearance, type DesktopPreferences as Preferences, type ThemedValue } from "@phreshos/core";
2
- export declare const AppearanceContext: import("react").Context<Readonly<{
3
- colors: ThemedValue<import("@phreshos/core").AppearanceColors>;
4
- spacing: number;
5
- radius: number;
6
- shadow: ThemedValue<import("@phreshos/core").AppearanceShadow>;
7
- material: ThemedValue<import("@phreshos/core").AppearanceMaterial>;
8
- transaction: import("@phreshos/core").AppearanceTransaction;
9
- signInWallpaper: ThemedValue<string | null>;
10
- desktopWallpaper: ThemedValue<string | null>;
11
- }>>;
12
- export declare const PreferencesContext: import("react").Context<Readonly<{
13
- theme: import("@phreshos/core").Theme;
14
- animations: boolean;
15
- }> | null>;
16
- /** Returns the nearest unresolved Appearance, or Core's complete default. */
1
+ import { type Appearance, type ThemedValue } from "./appearance.js";
2
+ import type { Preferences } from "./preferences.js";
3
+ export declare const AppearanceContext: import("react").Context<Appearance>;
4
+ export declare const PreferencesContext: import("react").Context<Preferences | null>;
5
+ /** Returns the nearest unresolved appearance, or React UI's default. */
17
6
  export declare function useAppearance(): Appearance;
18
7
  /** Returns the nearest complete Preferences, or reactively follows the browser. */
19
8
  export declare function usePreferences(): Preferences;
@@ -1,8 +1,8 @@
1
1
  import { createContext, useContext, useMemo, useSyncExternalStore } from "react";
2
- import { defaultAppearance } from "@phreshos/core";
2
+ import { defaultAppearance } from "./appearance.js";
3
3
  export const AppearanceContext = createContext(defaultAppearance);
4
4
  export const PreferencesContext = createContext(null);
5
- /** Returns the nearest unresolved Appearance, or Core's complete default. */
5
+ /** Returns the nearest unresolved appearance, or React UI's default. */
6
6
  export function useAppearance() {
7
7
  return useContext(AppearanceContext);
8
8
  }
@@ -0,0 +1,6 @@
1
+ import { appearanceLimits, type Appearance as SystemAppearance, type AppearanceColor, type AppearanceColors, type AppearanceMaterial, type AppearanceRange, type AppearanceShadow, type AppearanceTransaction, type Easing, type ThemedValue } from "@phreshos/core";
2
+ /** Complete visual input consumed by React UI. */
3
+ export type Appearance = Pick<SystemAppearance, "colors" | "spacing" | "radius" | "shadow" | "material" | "transaction">;
4
+ export { appearanceLimits, type AppearanceColor, type AppearanceColors, type AppearanceMaterial, type AppearanceRange, type AppearanceShadow, type AppearanceTransaction, type Easing, type ThemedValue };
5
+ /** React UI's default visual input, derived from the System default. */
6
+ export declare const defaultAppearance: Appearance;
@@ -0,0 +1,11 @@
1
+ import { appearanceLimits, defaultAppearance as systemDefaultAppearance } from "@phreshos/core";
2
+ export { appearanceLimits };
3
+ /** React UI's default visual input, derived from the System default. */
4
+ export const defaultAppearance = Object.freeze({
5
+ colors: systemDefaultAppearance.colors,
6
+ spacing: systemDefaultAppearance.spacing,
7
+ radius: systemDefaultAppearance.radius,
8
+ shadow: systemDefaultAppearance.shadow,
9
+ material: systemDefaultAppearance.material,
10
+ transaction: systemDefaultAppearance.transaction
11
+ });
package/dist/color.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AppearanceColor } from "@phreshos/core";
1
+ import type { AppearanceColor } from "./appearance.js";
2
2
  /** A visual treatment derived from one concrete CSS color. */
3
3
  export type ColorLevel = "subtle" | "soft" | "base" | "strong" | "intense";
4
4
  /** Every visual treatment derived from one concrete CSS color. */
package/dist/layout.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from "react";
2
- import type { Appearance } from "@phreshos/core";
2
+ import type { Appearance } from "./appearance.js";
3
3
  import { type Spacing } from "./spacing.js";
4
4
  /** Cross-axis alignment shared by layout containers. */
5
5
  export type LayoutAlignment = "start" | "center" | "end" | "stretch" | "baseline";
package/dist/main.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  * Components enter this surface only after their implementation-independent
5
5
  * behavior contract has been established by the package's tests.
6
6
  */
7
- export { defaultAppearance } from "@phreshos/core";
7
+ export { defaultAppearance, type Appearance, type AppearanceColor, type AppearanceColors, type AppearanceMaterial, type AppearanceShadow, type AppearanceTransaction, type Easing, type ThemedValue } from "./appearance.js";
8
8
  export { UIProvider, useAppearance, useBrowserPreferences, useDirection, useDocumentDirection, usePreferences, useThemedValue, type UIProviderProps } from "./ui-provider.js";
9
- export type { DesktopPreferences as Preferences } from "@phreshos/core";
9
+ export type { Preferences, Theme } from "./preferences.js";
10
10
  export type { Direction } from "./direction.js";
11
11
  export { Flex, type FlexProps } from "./flex.js";
12
12
  export { Grid, type GridProps } from "./grid.js";
package/dist/main.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Components enter this surface only after their implementation-independent
5
5
  * behavior contract has been established by the package's tests.
6
6
  */
7
- export { defaultAppearance } from "@phreshos/core";
7
+ export { defaultAppearance } from "./appearance.js";
8
8
  export { UIProvider, useAppearance, useBrowserPreferences, useDirection, useDocumentDirection, usePreferences, useThemedValue } from "./ui-provider.js";
9
9
  export { Flex } from "./flex.js";
10
10
  export { Grid } from "./grid.js";
@@ -1,4 +1,4 @@
1
- import { appearanceLimits } from "@phreshos/core";
1
+ import { appearanceLimits } from "./appearance.js";
2
2
  import { useAppearance, useThemedValue } from "./ui-provider.js";
3
3
  import { isScaleLevel, scale, scaleMultiplier } from "./scale.js";
4
4
  /** Resolves material values from the current Appearance without knowing any host geometry. */
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { defaultAppearance } from "@phreshos/core";
2
+ import { defaultAppearance } from "./appearance.js";
3
3
  import { useAppearance, usePreferences } from "./appearance-context.js";
4
4
  const visualProperties = "background-color, color, border-color, border-radius, box-shadow";
5
5
  const paintProperties = "fill, stroke, opacity";
@@ -0,0 +1,4 @@
1
+ import type { DesktopPreferences } from "@phreshos/core";
2
+ /** Complete environment preferences consumed by React UI. */
3
+ export type Preferences = Pick<DesktopPreferences, "theme" | "animations">;
4
+ export type Theme = Preferences["theme"];
File without changes
package/dist/radius.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from "react";
2
- import type { Appearance } from "@phreshos/core";
2
+ import type { Appearance } from "./appearance.js";
3
3
  import { type ScaleLevel } from "./scale.js";
4
4
  /** An Appearance-derived level, fully rounded shape, pixel value, or explicit CSS corner radius. */
5
5
  export type Radius = ScaleLevel | "full" | number | (string & {});
@@ -1,4 +1,4 @@
1
- import { appearanceLimits } from "@phreshos/core";
1
+ import { appearanceLimits } from "./appearance.js";
2
2
  import { useAppearance, useThemedValue } from "./ui-provider.js";
3
3
  import { isScaleLevel, scale } from "./scale.js";
4
4
  /** Resolves shadow values from the active Appearance branch. */
package/dist/spacing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from "react";
2
- import type { Appearance } from "@phreshos/core";
2
+ import type { Appearance } from "./appearance.js";
3
3
  import { type ScaleLevel } from "./scale.js";
4
4
  /** An Appearance-derived level, pixel value, or explicit CSS spacing value. */
5
5
  export type Spacing = ScaleLevel | number | (string & {});
package/dist/surface.js CHANGED
@@ -49,7 +49,10 @@ const layerStyle = {
49
49
  pointerEvents: "none"
50
50
  };
51
51
  function SurfaceLayers({ material }) {
52
- const { backdrop, saturation, distortion } = material;
52
+ const filtersVisible = material.opacity < 1;
53
+ const backdrop = filtersVisible ? material.backdrop : 0;
54
+ const saturation = filtersVisible ? material.saturation : 1;
55
+ const distortion = filtersVisible ? material.distortion : 0;
53
56
  const frost = [
54
57
  backdrop === 0 ? "" : `blur(${backdrop}px)`,
55
58
  saturation === 1 ? "" : `saturate(${saturation})`
@@ -1,10 +1,11 @@
1
1
  import type { ReactNode } from "react";
2
- import { type Appearance, type DesktopPreferences as Preferences } from "@phreshos/core";
2
+ import type { Appearance } from "./appearance.js";
3
3
  import { type Direction } from "./direction.js";
4
+ import type { Preferences } from "./preferences.js";
4
5
  export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
5
6
  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;
7
+ /** Establishes only the explicitly supplied UI values for a React subtree. */
8
+ export declare function UIProvider({ appearance, children, direction, preferences }: UIProviderProps): ReactNode;
8
9
  export interface UIProviderProps {
9
10
  readonly appearance?: Appearance;
10
11
  readonly children: ReactNode;
@@ -1,18 +1,20 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AppearanceContext, PreferencesContext } from "./appearance-context.js";
3
+ import { DirectionContext } from "./direction.js";
6
4
  export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
7
5
  export { useDirection, useDocumentDirection } from "./direction.js";
8
6
  const directionBoundaryStyle = { display: "contents" };
9
- /** Supplies the complete shared environment of a React UI subtree. */
7
+ /** Establishes only the explicitly supplied UI values for a React subtree. */
10
8
  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] }) }) }) });
9
+ let subtree = children;
10
+ if (preferences !== undefined) {
11
+ subtree = _jsx(PreferencesContext.Provider, { value: preferences, children: subtree });
12
+ }
13
+ if (appearance !== undefined) {
14
+ subtree = _jsx(AppearanceContext.Provider, { value: appearance, children: subtree });
15
+ }
16
+ if (direction !== undefined) {
17
+ subtree = _jsx(DirectionContext.Provider, { value: direction, children: _jsx("div", { dir: direction, style: directionBoundaryStyle, children: subtree }) });
18
+ }
19
+ return subtree;
18
20
  }
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.28",
4
4
  "description": "React components for coherent PhreshOS Program interfaces.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@base-ui/react": "^1.7.0",
59
- "@phreshos/core": "^0.1.52",
59
+ "@phreshos/core": "^0.1.53",
60
60
  "colorjs.io": "^0.7.1",
61
61
  "motion": "^13.2.0",
62
62
  "react-aria-components": "^1.20.0"