@phreshos/react-ui 0.1.51 → 0.1.53

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.
@@ -30,7 +30,11 @@ type ItemState = Readonly<{
30
30
  }>;
31
31
  /** One item of a SelectionTrack; its label reads against the selection when selected. */
32
32
  export declare function selectionItemStyle(metrics: ControlMetrics, color: Color, orientation: Orientation, state: ItemState): CSSProperties;
33
- /** An item's label: an optional leading icon and text, centered a gap apart. */
33
+ /**
34
+ * An item's label: an optional leading icon and text, a gap apart. It fills its item and follows the
35
+ * item's alignment, so a label stays centered in a centered item, and content given the item's whole
36
+ * width, such as a tab's title with its close button at the end, can take it.
37
+ */
34
38
  export declare function SelectionItemLabel({ metrics, emphasized, children }: Readonly<{
35
39
  metrics: ControlMetrics;
36
40
  emphasized: boolean;
@@ -63,11 +63,17 @@ export function selectionItemStyle(metrics, color, orientation, state) {
63
63
  color: state.isSelected ? readableColor(resolveColor(color, colors), colors) : colors.foreground
64
64
  };
65
65
  }
66
- /** An item's label: an optional leading icon and text, centered a gap apart. */
66
+ /**
67
+ * An item's label: an optional leading icon and text, a gap apart. It fills its item and follows the
68
+ * item's alignment, so a label stays centered in a centered item, and content given the item's whole
69
+ * width, such as a tab's title with its close button at the end, can take it.
70
+ */
67
71
  export function SelectionItemLabel({ metrics, emphasized, children }) {
68
72
  return _jsx("span", { style: {
69
73
  ...transition(metrics.visual, "opacity"),
70
74
  display: "flex",
75
+ flex: "1 1 auto",
76
+ justifyContent: "inherit",
71
77
  alignItems: "center",
72
78
  gap: metrics.gap,
73
79
  minWidth: 0,
package/dist/main.d.ts CHANGED
@@ -13,7 +13,7 @@ export { useDirection, useDocumentDirection, type Direction } from "./foundation
13
13
  export type { Preferences, PreferencesUpdate, Theme } from "./foundation/preferences.js";
14
14
  export { Flex, type FlexProps } from "./flex.js";
15
15
  export { Grid, type GridProps } from "./grid.js";
16
- export { Surface, type MaterialMode, type MaterialOptions, type ShadowOptions, type SurfaceComponent, type SurfaceDepth, type SurfaceHost, type SurfaceHostProps, type SurfaceOwnProps, type SurfaceProps } from "./surface/surface.js";
16
+ export { Surface, useSurfaceColor, type MaterialMode, type MaterialOptions, type ShadowOptions, type SurfaceComponent, type SurfaceDepth, type SurfaceHost, type SurfaceHostProps, type SurfaceOwnProps, type SurfaceProps } from "./surface/surface.js";
17
17
  export { resolveColor, useColor, useContrastingColor, type Color, type ColorLevel, type ColorScale } from "./foundation/color.js";
18
18
  export { Panel, type PanelProps, type PanelHeaderProps, type PanelContentProps } from "./panel.js";
19
19
  export { Window, type WindowProps, type WindowContentProps, type WindowHeaderProps, type WindowIdentityProps, type WindowCenterProps, type WindowActionsProps, type WindowActionProps, type WindowControlProps, type WindowMaximizeProps, type WindowCloseProps, type WindowMoveCaptureProps } from "./window.js";
package/dist/main.js CHANGED
@@ -12,7 +12,7 @@ export { timing } from "./foundation/timing.js";
12
12
  export { useDirection, useDocumentDirection } from "./foundation/direction.js";
13
13
  export { Flex } from "./flex.js";
14
14
  export { Grid } from "./grid.js";
15
- export { Surface } from "./surface/surface.js";
15
+ export { Surface, useSurfaceColor } from "./surface/surface.js";
16
16
  export { resolveColor, useColor, useContrastingColor } from "./foundation/color.js";
17
17
  // Context-dependent parts are public only through their owning component family.
18
18
  export { Panel } from "./panel.js";
@@ -71,6 +71,15 @@ export declare const interactionShift: Readonly<{
71
71
  }>;
72
72
  /** A clear Surface has no paint to move, so it shows the same shift as a slightly stronger veil. */
73
73
  export declare const clearVeil = 1.3;
74
+ /**
75
+ * The color a Surface of this color and depth is painted with at rest, before its material: a recess
76
+ * sinks below the color it is given; a clear Surface, with no depth or a transparent color, paints
77
+ * nothing. Whatever draws on a Surface and must match it, such as a terminal telling its programs
78
+ * what it stands on, takes this color.
79
+ */
80
+ export declare function surfaceColor(color: Color, depth: SurfaceDepth, colors: Visual["colors"]): string;
81
+ /** The color a Surface of this color and depth is painted with at rest, in the active Appearance. */
82
+ export declare function useSurfaceColor(color?: Color, depth?: SurfaceDepth): string;
74
83
  /** Resolves every visual value of one Surface. Pure over its inputs. */
75
84
  export declare function surfacePaint(visual: Visual, color: Color, depth: SurfaceDepth, options: MaterialMode | MaterialOptions | undefined, shadowOptions: ShadowOverrides["shadow"], interaction: SurfaceInteraction | undefined): {
76
85
  fill: string;
@@ -67,6 +67,23 @@ const materialLevel = Object.freeze({ none: 0, basic: 1, extended: 2, full: 3 })
67
67
  export const interactionShift = Object.freeze({ hovered: 0.05, pressed: 0.1 });
68
68
  /** A clear Surface has no paint to move, so it shows the same shift as a slightly stronger veil. */
69
69
  export const clearVeil = 1.3;
70
+ /**
71
+ * The color a Surface of this color and depth is painted with at rest, before its material: a recess
72
+ * sinks below the color it is given; a clear Surface, with no depth or a transparent color, paints
73
+ * nothing. Whatever draws on a Surface and must match it, such as a terminal telling its programs
74
+ * what it stands on, takes this color.
75
+ */
76
+ export function surfaceColor(color, depth, colors) {
77
+ const base = resolveColor(color, colors);
78
+ if (depth === "none" || base === "transparent")
79
+ return "transparent";
80
+ return depth === "recessed" ? recessColor(base) : base;
81
+ }
82
+ /** The color a Surface of this color and depth is painted with at rest, in the active Appearance. */
83
+ export function useSurfaceColor(color = "background", depth = "raised") {
84
+ const { colors } = useVisual();
85
+ return surfaceColor(color, depth, colors);
86
+ }
70
87
  /** Resolves every visual value of one Surface. Pure over its inputs. */
71
88
  export function surfacePaint(visual, color, depth, options, shadowOptions, interaction) {
72
89
  const { colors } = visual;
@@ -78,7 +95,7 @@ export function surfacePaint(visual, color, depth, options, shadowOptions, inter
78
95
  const darkness = canvasDarkness(colors);
79
96
  // A recess moves away from its surroundings toward whichever extreme has
80
97
  // room, by one constant perceptual difference on any canvas.
81
- const rest = depth === "recessed" ? recessColor(base) : base;
98
+ const rest = depth === "recessed" ? surfaceColor(color, depth, colors) : base;
82
99
  // A clear Surface, with no depth or a transparent color, has no substance of
83
100
  // its own: it paints nothing at rest, takes the content color of whatever it
84
101
  // sits on, and only reveals interaction as a veil. With no depth, a color
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react-ui",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "description": "React components for coherent PhreshOS Program interfaces.",
5
5
  "type": "module",
6
6
  "sideEffects": false,