@phreshos/react-ui 0.1.39 → 0.1.40

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.
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { Heading as AriaHeading, Keyboard as AriaKeyboard, Text as AriaText } from "react-aria-components";
4
+ import { controlFontSizes, controlFontWeight, controlOpacity, useControlMetrics } from "./control/control.js";
5
+ import { scale, scaleMultiplier } from "./foundation/scale.js";
6
+ import { useVisual } from "./foundation/visual.js";
7
+ import { Surface } from "./surface/surface.js";
8
+ /** The size each heading level takes unless `size` says otherwise. */
9
+ const levelSizes = Object.freeze({ 1: "xlarge", 2: "large", 3: "medium", 4: "small", 5: "xsmall", 6: "xsmall" });
10
+ /**
11
+ * Headings grow by the same ladder Appearance values scale by, anchored at the
12
+ * large step: a medium heading is one and a half times its surrounding text,
13
+ * an xlarge heading twice.
14
+ */
15
+ const headingGrowth = scale(1, "large");
16
+ /** A heading sized relative to the text around it, so it fits any context. */
17
+ export const Heading = forwardRef(function Heading({ level = 2, size, style, ...properties }, ref) {
18
+ return _jsx(AriaHeading, { ...properties, ref: ref, level: level, style: {
19
+ margin: 0,
20
+ fontSize: `${scaleMultiplier(headingGrowth, size ?? levelSizes[level])}em`,
21
+ fontWeight: controlFontWeight,
22
+ lineHeight: 1.2,
23
+ textWrap: "balance",
24
+ ...style
25
+ } });
26
+ });
27
+ /** Running text in the tone and scale of the interface. */
28
+ export const Text = forwardRef(function Text({ tone = "default", size, style, ...properties }, ref) {
29
+ return _jsx(AriaText, { ...properties, ref: ref, style: {
30
+ fontSize: size === undefined ? undefined : controlFontSizes[size],
31
+ lineHeight: textLineHeight,
32
+ opacity: tone === "secondary" ? controlOpacity.secondary : undefined,
33
+ ...style
34
+ } });
35
+ });
36
+ /** Running text sets its lines at this height, relative to its size. */
37
+ const textLineHeight = 1.45;
38
+ /**
39
+ * A key to press, drawn as a small raised keycap. Its label takes the control
40
+ * text scale, and the cap is as tall as the line of text around it, so it
41
+ * never stretches the line.
42
+ */
43
+ export const Kbd = forwardRef(function Kbd({ children, className, style }, ref) {
44
+ const metrics = useControlMetrics("xsmall");
45
+ const label = Number.parseFloat(controlFontSizes.medium);
46
+ const cap = `${textLineHeight / label}em`;
47
+ return _jsx(AriaKeyboard, { ref: ref, className: className, style: { display: "inline-block", verticalAlign: "middle", lineHeight: 1 }, children: _jsx(Surface, { as: "span", radius: metrics.radius, shadow: false, style: {
48
+ display: "inline-flex",
49
+ alignItems: "center",
50
+ justifyContent: "center",
51
+ minWidth: cap,
52
+ height: cap,
53
+ paddingInline: metrics.gap,
54
+ boxSizing: "border-box",
55
+ fontSize: controlFontSizes.medium,
56
+ fontWeight: controlFontWeight,
57
+ fontVariantNumeric: "tabular-nums",
58
+ lineHeight: 1,
59
+ ...style
60
+ }, children: children }) });
61
+ });
62
+ /** Code inside text, set in the system monospace font in a shallow recess. */
63
+ export const Code = forwardRef(function Code({ children, className, style }, ref) {
64
+ const visual = useVisual();
65
+ return _jsx(Surface, { as: "code", ref: ref, className: className, color: "background", depth: "recessed", radius: scale(visual.radius, "small"), style: {
66
+ paddingInline: scale(visual.spacing, "xsmall"),
67
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
68
+ fontSize: "0.9em",
69
+ ...style
70
+ }, children: children });
71
+ });
package/dist/window.d.ts CHANGED
@@ -3,7 +3,10 @@ import type { BeginWindowMoveGesture } from "@phreshos/core";
3
3
  import { type ButtonActionProps } from "./button.js";
4
4
  import { type Color } from "./foundation/color.js";
5
5
  import { type SurfaceProps } from "./surface/surface.js";
6
- /** The material shell that establishes the complete header-and-content layout. */
6
+ /**
7
+ * The material shell that establishes the complete header-and-content layout.
8
+ * The Window owns its shape: nothing inside is drawn past its edges or corners.
9
+ */
7
10
  export type WindowProps = SurfaceProps;
8
11
  /** The remaining window area. Its consumer owns content behavior, including overflow. */
9
12
  export type WindowContentProps = HTMLAttributes<HTMLDivElement>;
package/dist/window.js CHANGED
@@ -23,6 +23,8 @@ const WindowRoot = forwardRef(function WindowRoot({ children, style, ...properti
23
23
  flexDirection: "column",
24
24
  minWidth: 0,
25
25
  minHeight: 0,
26
+ // Clips to the rounded shape without becoming a scroll container.
27
+ overflow: "clip",
26
28
  ...style
27
29
  }, children: children });
28
30
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react-ui",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "React components for coherent PhreshOS Program interfaces.",
5
5
  "type": "module",
6
6
  "sideEffects": false,