@phreshos/react-ui 0.1.46 → 0.1.47

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.
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useCallback, useContext, useEffect, useRef } from "react";
2
+ import { Children, cloneElement, forwardRef, useCallback, useContext, useEffect, useRef } from "react";
3
+ import { ClearPressResponder } from "react-aria/private/interactions/PressResponder";
3
4
  import { MenuTrigger as AriaMenuTrigger, OverlayTriggerStateContext, Pressable as AriaPressable } from "react-aria-components";
4
5
  import { ariaOpenState } from "./control/open-state.js";
5
6
  import { Menu } from "./menu.js";
@@ -8,7 +9,12 @@ export function ContextMenuRoot({ children, ...state }) {
8
9
  return _jsx(AriaMenuTrigger, { ...ariaOpenState(state), trigger: "contextMenu", children: children });
9
10
  }
10
11
  export const ContextMenuTrigger = forwardRef(function ContextMenuTrigger({ children, disabled }, ref) {
11
- return _jsx(AriaPressable, { ref: ref, isDisabled: disabled, children: children });
12
+ // The menu's press state belongs to the trigger alone. What the trigger holds, such as the rows of a
13
+ // list, keeps its own presses instead of all showing the menu's.
14
+ const child = Children.only(children);
15
+ const held = child.props.children;
16
+ const content = held === undefined ? child : cloneElement(child, undefined, _jsx(ClearPressResponder, { children: held }));
17
+ return _jsx(AriaPressable, { ref: ref, isDisabled: disabled, children: content });
12
18
  });
13
19
  function setRef(ref, value) {
14
20
  if (typeof ref === "function")
@@ -14,8 +14,10 @@ export type { ShadowOptions } from "./shadow-options.js";
14
14
  * flat — a region level with its surroundings: only a boundary.
15
15
  * recessed — something that holds content: a slightly deeper paint and an
16
16
  * inner shadow instead of an outer one.
17
+ * none — part of its surroundings: nothing painted at rest; hover, press,
18
+ * and focus still show.
17
19
  */
18
- export type SurfaceDepth = "raised" | "flat" | "recessed";
20
+ export type SurfaceDepth = "raised" | "flat" | "recessed" | "none";
19
21
  export interface SurfaceOwnProps extends MaterialOverrides, ShadowOverrides, RadiusProps {
20
22
  readonly color?: Color;
21
23
  readonly depth?: SurfaceDepth;
@@ -79,9 +79,12 @@ export function surfacePaint(visual, color, depth, options, shadowOptions, inter
79
79
  // A recess moves away from its surroundings toward whichever extreme has
80
80
  // room, by one constant perceptual difference on any canvas.
81
81
  const rest = depth === "recessed" ? recessColor(base) : base;
82
- // A transparent Surface has no substance of its own: it takes the content
83
- // color of whatever it sits on and only reveals interaction as a veil.
84
- const clear = base === "transparent";
82
+ // A clear Surface, with no depth or a transparent color, has no substance of
83
+ // its own: it paints nothing at rest, takes the content color of whatever it
84
+ // sits on, and only reveals interaction as a veil. With no depth, a color
85
+ // other than the neutral one colors its content instead of a fill.
86
+ const clear = depth === "none" || base === "transparent";
87
+ const tinted = depth === "none" && base !== "transparent" && base !== colors.default;
85
88
  const fill = clear
86
89
  ? shift > 0 ? colorOpacity(colors.foreground, shift * clearVeil) : "transparent"
87
90
  : mixColor(rest, colors.foreground, shift);
@@ -131,7 +134,7 @@ export function surfacePaint(visual, color, depth, options, shadowOptions, inter
131
134
  fill,
132
135
  // The label is chosen once for the resting paint: interaction shades stay
133
136
  // close to it, and re-deciding per state would flip text on near-ties.
134
- text: clear ? "inherit" : readableColor(rest, colors),
137
+ text: tinted ? base : clear ? "inherit" : readableColor(rest, colors),
135
138
  ring: colorOpacity(ringBase, 0.34),
136
139
  shadow: [hairline, outer === "none" ? null : outer].filter(Boolean).join(", ") || "none",
137
140
  distortion: level >= materialLevel.full && translucent ? material.distortion : 0,
@@ -188,6 +191,11 @@ const edgeLightEnds = Object.freeze({
188
191
  recessed: {
189
192
  light: { edge: 0.45, side: 0.12, spill: 0, hairline: 0.12 },
190
193
  dark: { edge: 0.12, side: 0.04, spill: 0, hairline: 0.45 }
194
+ },
195
+ // Without depth nothing is edged; the ends only complete the table.
196
+ none: {
197
+ light: { edge: 0, side: 0, spill: 0, hairline: 0 },
198
+ dark: { edge: 0, side: 0, spill: 0, hairline: 0 }
191
199
  }
192
200
  });
193
201
  /** A separate compositor pass for refraction, present only when it is visible. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react-ui",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "React components for coherent PhreshOS Program interfaces.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@base-ui/react": "^1.7.0",
59
59
  "@internationalized/date": "^3.12.3",
60
- "@phreshos/core": "^0.1.63",
60
+ "@phreshos/core": "^0.1.65",
61
61
  "colorjs.io": "^0.7.1",
62
62
  "lucide-react": "^1.48.0",
63
63
  "react-aria": "^3.51.0",