@phreshos/react-ui 0.2.2 → 0.3.0

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/dist/dialog.d.ts CHANGED
@@ -20,6 +20,8 @@ export interface DialogBackdropProps extends Omit<AriaModalOverlayProps, AriaOve
20
20
  readonly dismissable?: boolean;
21
21
  /** Whether Escape closes the Dialog. */
22
22
  readonly keyboardDismissable?: boolean;
23
+ /** DOM container the Dialog is drawn in, such as one that scales what it holds; the document's body by default. */
24
+ readonly portalContainer?: Element;
23
25
  readonly style?: CSSProperties;
24
26
  }
25
27
  export declare const DialogBackdrop: import("react").ForwardRefExoticComponent<DialogBackdropProps & import("react").RefAttributes<HTMLDivElement>>;
package/dist/dialog.js CHANGED
@@ -22,7 +22,7 @@ export const DialogTrigger = forwardRef(function DialogTrigger(properties, ref)
22
22
  const backdropDimming = 0.5;
23
23
  /** The share of the Appearance material's blur a backdrop takes: lighter than a frosted Surface. */
24
24
  const backdropBlurShare = 0.5;
25
- export const DialogBackdrop = forwardRef(function DialogBackdrop({ children, className, dir, dismissable = false, keyboardDismissable = true, style, ...attributes }, ref) {
25
+ export const DialogBackdrop = forwardRef(function DialogBackdrop({ children, className, dir, dismissable = false, keyboardDismissable = true, portalContainer, style, ...attributes }, ref) {
26
26
  const visual = useVisual();
27
27
  const inset = scale(visual.spacing, "medium");
28
28
  const colors = visual.colors;
@@ -33,7 +33,7 @@ export const DialogBackdrop = forwardRef(function DialogBackdrop({ children, cla
33
33
  const blur = visual.material.backdrop > 0 ? `blur(${visual.material.backdrop * backdropBlurShare}px)` : undefined;
34
34
  const transition = overlayTransition(visual);
35
35
  const direction = resolveDirection(dir, useDirection());
36
- return _jsxs(_Fragment, { children: [_jsx(MotionStyle, {}), _jsx(AriaModalOverlay, { ...attributes, isDismissable: dismissable, isKeyboardDismissDisabled: !keyboardDismissable, ref: ref, dir: direction, className: [backdropMotionClass, className].filter(Boolean).join(" "), style: {
36
+ return _jsxs(_Fragment, { children: [_jsx(MotionStyle, {}), _jsx(AriaModalOverlay, { ...attributes, isDismissable: dismissable, isKeyboardDismissDisabled: !keyboardDismissable, UNSTABLE_portalContainer: portalContainer, ref: ref, dir: direction, className: [backdropMotionClass, className].filter(Boolean).join(" "), style: {
37
37
  ...transition,
38
38
  backdropFilter: blur,
39
39
  WebkitBackdropFilter: blur,
@@ -109,7 +109,9 @@ export const DialogDescription = forwardRef(function DialogDescription({ style,
109
109
  } });
110
110
  });
111
111
  export const DialogBody = forwardRef(function DialogBody({ style, ...properties }, ref) {
112
- return _jsx("div", { ...properties, ref: ref, style: { minWidth: 0, minHeight: 0, ...style } });
112
+ // What a Body holds stands apart, as the Header's and the Footer's parts do.
113
+ const gap = scale(useVisual().spacing, "medium");
114
+ return _jsx("div", { ...properties, ref: ref, style: { display: "grid", gap, minWidth: 0, minHeight: 0, ...style } });
113
115
  });
114
116
  export const DialogFooter = forwardRef(function DialogFooter({ style, ...properties }, ref) {
115
117
  const gap = scale(useVisual().spacing, "small");
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, createElement, forwardRef, useContext, useId, useInsertionEffect } from "react";
3
- import { canvasDarkness, colorOpacity, contrast, mixColor, readableColor, recessColor, resolveColor, separateColor } from "../foundation/color.js";
3
+ import { canvasDarkness, colorOpacity, contrast, mixColor, perceivedDistance, readableColor, recessColor, resolveColor, separateColor } from "../foundation/color.js";
4
4
  import { resolveRadius } from "../foundation/radius.js";
5
5
  import { useVisual } from "../foundation/visual.js";
6
6
  import { grainSeed, grainSize, grainTexture } from "./grain.js";
@@ -114,14 +114,20 @@ export function surfacePaint(visual, color, depth, options, shadowOptions, inter
114
114
  const darkness = canvasDarkness(colors);
115
115
  // A recess moves away from its surroundings toward whichever extreme has
116
116
  // room, by one constant perceptual difference on any canvas.
117
- const own = depth === "recessed" ? surfaceColor(color, depth, colors) : base;
117
+ const recess = depth === "recessed" ? surfaceColor(color, depth, colors) : base;
118
+ // A recess that would vanish into paint like its own, such as a field or a checkbox in a well,
119
+ // sinks one step below that paint instead.
120
+ const own = depth === "recessed" && surroundings !== null && (perceivedDistance(recess, surroundings) ?? Infinity) < nestingDistance(darkness)
121
+ ? recessColor(surroundings)
122
+ : recess;
118
123
  // A clear Surface, with no depth or a transparent color, has no substance of
119
124
  // its own: it paints nothing at rest, takes the content color of whatever it
120
125
  // sits on, and only reveals interaction as a veil. With no depth, a color
121
126
  // other than the neutral one colors its content instead of a fill.
122
127
  const clear = depth === "none" || base === "transparent";
123
128
  // A raised or level Surface nested in another keeps apart from it, however deep the nesting goes.
124
- // A recess keeps its own constant depth below its color, so a well reads the same wherever it is.
129
+ // A recess keeps its own constant depth below its color, so a well reads the same wherever it is,
130
+ // unless it would vanish into what it sits on (above).
125
131
  const rest = clear || depth === "recessed" || surroundings === null ? own : separateColor(own, surroundings, nestingDistance(darkness));
126
132
  const tinted = depth === "none" && base !== "transparent" && base !== colors.default;
127
133
  const fill = clear
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react-ui",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
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.2.0",
60
+ "@phreshos/core": "^0.3.0",
61
61
  "colorjs.io": "^0.7.1",
62
62
  "lucide-react": "^1.48.0",
63
63
  "react-aria": "^3.51.0",