@phreshos/react-ui 0.1.33 → 0.1.34
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/color.d.ts +2 -0
- package/dist/color.js +6 -0
- package/dist/main.d.ts +2 -2
- package/dist/main.js +1 -1
- package/dist/window.d.ts +6 -0
- package/dist/window.js +25 -5
- package/package.json +1 -1
package/dist/color.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare function color(value: string): ColorScale;
|
|
|
14
14
|
export declare function resolveColorLevel(value: string, level: ColorLevel): string;
|
|
15
15
|
/** Returns the complete visual treatments derived from one concrete color. */
|
|
16
16
|
export declare function useColor(value: string): ColorScale;
|
|
17
|
+
/** Returns the readable Appearance content color for one semantic or CSS fill. */
|
|
18
|
+
export declare function useContrastingColor(value: Color): string;
|
|
17
19
|
/** Resolves a semantic color from an already selected Appearance branch. */
|
|
18
20
|
export declare function resolveColor(value: Color | undefined, colors: AppearanceColors): string;
|
|
19
21
|
/** Resolves opaque control paint from an already selected Appearance branch. */
|
package/dist/color.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { useResolvedAppearance } from "./appearance-context.js";
|
|
2
3
|
import ColorSpace from "colorjs.io/src/ColorSpace.js";
|
|
3
4
|
import { mix } from "colorjs.io/src/interpolation.js";
|
|
4
5
|
import parse from "colorjs.io/src/parse.js";
|
|
@@ -61,6 +62,11 @@ export function resolveColorLevel(value, level) {
|
|
|
61
62
|
export function useColor(value) {
|
|
62
63
|
return useMemo(() => color(value), [value]);
|
|
63
64
|
}
|
|
65
|
+
/** Returns the readable Appearance content color for one semantic or CSS fill. */
|
|
66
|
+
export function useContrastingColor(value) {
|
|
67
|
+
const { colors } = useResolvedAppearance();
|
|
68
|
+
return useMemo(() => contrastingColor(value, colors), [value, colors]);
|
|
69
|
+
}
|
|
64
70
|
/** Resolves a semantic color from an already selected Appearance branch. */
|
|
65
71
|
export function resolveColor(value, colors) {
|
|
66
72
|
const resolved = value ?? defaultColor;
|
package/dist/main.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { Grid, type GridProps } from "./grid.js";
|
|
|
13
13
|
export { Surface, type MaterialMode, type MaterialOptions, type ShadowOptions, type SurfaceComponent, type SurfaceHost, type SurfaceHostProps, type SurfaceOwnProps, type SurfaceProps } from "./surface.js";
|
|
14
14
|
export { defaultColor, type Color, type ColorLevel, type ColorScale } from "./color.js";
|
|
15
15
|
export { Panel, type PanelProps, type PanelHeaderProps, type PanelContentProps } from "./panel.js";
|
|
16
|
-
export { Window, type WindowProps, type WindowContentProps, type WindowHeaderProps, type WindowIdentityProps, type WindowCenterProps, type WindowActionsProps, type WindowActionProps, type WindowControlProps, type WindowMaximizeProps, type WindowCloseProps } from "./window.js";
|
|
16
|
+
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";
|
|
17
17
|
export { default as useWindowMoveHandle, type WindowMoveHandle } from "./use-window-move-handle.js";
|
|
18
18
|
export { Button, type ButtonColor, type ButtonProps } from "./button.js";
|
|
19
19
|
export { Input, type InputProps } from "./input.js";
|
|
@@ -51,5 +51,5 @@ export type { ControlColor } from "./control.js";
|
|
|
51
51
|
export type { LayoutAlignment, LayoutGap, LayoutJustification } from "./layout.js";
|
|
52
52
|
export { resolveRadius, type Radius, type RadiusProps } from "./radius.js";
|
|
53
53
|
export { resolveSpacing, type Spacing } from "./spacing.js";
|
|
54
|
-
export { useColor } from "./color.js";
|
|
54
|
+
export { useColor, useContrastingColor } from "./color.js";
|
|
55
55
|
export { useScale, type NumericScale, type ScaleLevel } from "./scale.js";
|
package/dist/main.js
CHANGED
|
@@ -47,5 +47,5 @@ export { AlertDialog } from "./alert-dialog.js";
|
|
|
47
47
|
export { Tooltip } from "./tooltip.js";
|
|
48
48
|
export { resolveRadius } from "./radius.js";
|
|
49
49
|
export { resolveSpacing } from "./spacing.js";
|
|
50
|
-
export { useColor } from "./color.js";
|
|
50
|
+
export { useColor, useContrastingColor } from "./color.js";
|
|
51
51
|
export { useScale } from "./scale.js";
|
package/dist/window.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export interface WindowHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
14
14
|
readonly color?: Color;
|
|
15
15
|
/** Hands an intentional header drag to its host after the pointer threshold. */
|
|
16
16
|
readonly beginMoveGesture?: BeginWindowMoveGesture;
|
|
17
|
+
/** Whether the represented window is currently maximized. */
|
|
18
|
+
readonly maximized?: boolean;
|
|
19
|
+
/** Toggles the represented window between maximized and restored states. */
|
|
20
|
+
readonly onMaximize?: () => void;
|
|
17
21
|
/** Receives a synchronous or asynchronous move handoff failure. */
|
|
18
22
|
readonly onMoveError?: (error: unknown) => void;
|
|
19
23
|
}
|
|
@@ -29,6 +33,7 @@ export interface WindowMaximizeProps extends WindowControlProps {
|
|
|
29
33
|
readonly maximized?: boolean;
|
|
30
34
|
}
|
|
31
35
|
export type WindowCloseProps = WindowControlProps;
|
|
36
|
+
export type WindowMoveCaptureProps = HTMLAttributes<HTMLDivElement>;
|
|
32
37
|
/** One Surface with a ready-to-use header-and-content composition. */
|
|
33
38
|
export declare const Window: import("react").ForwardRefExoticComponent<Omit<WindowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
|
|
34
39
|
Header: import("react").ForwardRefExoticComponent<WindowHeaderProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
@@ -41,4 +46,5 @@ export declare const Window: import("react").ForwardRefExoticComponent<Omit<Wind
|
|
|
41
46
|
Close: import("react").ForwardRefExoticComponent<WindowControlProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
42
47
|
};
|
|
43
48
|
Content: import("react").ForwardRefExoticComponent<WindowContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
|
+
MoveCapture: import("react").ForwardRefExoticComponent<WindowMoveCaptureProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
44
50
|
};
|
package/dist/window.js
CHANGED
|
@@ -33,7 +33,7 @@ const WindowContent = forwardRef(function WindowContent({ style, ...properties }
|
|
|
33
33
|
} });
|
|
34
34
|
});
|
|
35
35
|
/** The composable top region of a window; its enclosing Surface owns the material. */
|
|
36
|
-
const HeaderRoot = forwardRef(function HeaderRoot({ active = true, beginMoveGesture, children, color, onLostPointerCapture, onMoveError, onPointerCancel, onPointerDown, onPointerMove, onPointerUp, style, ...properties }, ref) {
|
|
36
|
+
const HeaderRoot = forwardRef(function HeaderRoot({ active = true, beginMoveGesture, children, color, maximized = false, onDoubleClick, onLostPointerCapture, onMaximize, onMoveError, onPointerCancel, onPointerDown, onPointerMove, onPointerUp, style, ...properties }, ref) {
|
|
37
37
|
const resolved = useResolvedAppearance();
|
|
38
38
|
const spacing = resolved.appearance.spacing;
|
|
39
39
|
const foreground = style?.color ?? resolveColor(color ?? "foreground:base", resolved.colors);
|
|
@@ -41,6 +41,8 @@ const HeaderRoot = forwardRef(function HeaderRoot({ active = true, beginMoveGest
|
|
|
41
41
|
active,
|
|
42
42
|
foreground,
|
|
43
43
|
iconRadius: scale(resolved.appearance.radius, "xsmall"),
|
|
44
|
+
maximized,
|
|
45
|
+
onMaximize,
|
|
44
46
|
spacing,
|
|
45
47
|
transition: transitionTiming(resolved.transaction, resolved.preferences.animations)
|
|
46
48
|
};
|
|
@@ -49,7 +51,11 @@ const HeaderRoot = forwardRef(function HeaderRoot({ active = true, beginMoveGest
|
|
|
49
51
|
onPointerDown?.(event);
|
|
50
52
|
if (!event.defaultPrevented)
|
|
51
53
|
move.onPointerDown(event);
|
|
52
|
-
}, onPointerMove: event => { onPointerMove?.(event); move.onPointerMove(event); }, onPointerUp: event => { onPointerUp?.(event); move.onPointerUp(event); }, onPointerCancel: event => { onPointerCancel?.(event); move.onPointerCancel(event); }, onLostPointerCapture: event => { onLostPointerCapture?.(event); move.onLostPointerCapture(event); },
|
|
54
|
+
}, onPointerMove: event => { onPointerMove?.(event); move.onPointerMove(event); }, onPointerUp: event => { onPointerUp?.(event); move.onPointerUp(event); }, onPointerCancel: event => { onPointerCancel?.(event); move.onPointerCancel(event); }, onLostPointerCapture: event => { onLostPointerCapture?.(event); move.onLostPointerCapture(event); }, onDoubleClick: event => {
|
|
55
|
+
onDoubleClick?.(event);
|
|
56
|
+
if (!event.defaultPrevented)
|
|
57
|
+
onMaximize?.();
|
|
58
|
+
}, style: {
|
|
53
59
|
boxSizing: "border-box",
|
|
54
60
|
display: "flex",
|
|
55
61
|
alignItems: "center",
|
|
@@ -118,8 +124,10 @@ const WindowAction = forwardRef(function WindowAction({ ...properties }, ref) {
|
|
|
118
124
|
const WindowMinimize = forwardRef(function WindowMinimize({ "aria-label": label = "Minimize", preventFocusOnPress = true, ...properties }, ref) {
|
|
119
125
|
return _jsx(WindowAction, { ...properties, ref: ref, "aria-label": label, preventFocusOnPress: preventFocusOnPress, children: _jsx(ControlIcon, { children: _jsx("path", { d: "M1.5 7.5h7" }) }) });
|
|
120
126
|
});
|
|
121
|
-
const WindowMaximize = forwardRef(function WindowMaximize({ "aria-label": label, maximized
|
|
122
|
-
|
|
127
|
+
const WindowMaximize = forwardRef(function WindowMaximize({ "aria-label": label, maximized, onPress, ...properties }, ref) {
|
|
128
|
+
const header = useHeader();
|
|
129
|
+
const selected = maximized ?? header.maximized;
|
|
130
|
+
return _jsx(WindowAction, { ...properties, ref: ref, onPress: onPress ?? header.onMaximize, "aria-label": label ?? (selected ? "Restore" : "Maximize"), children: _jsx(ControlIcon, { children: selected
|
|
123
131
|
? _jsx("path", { d: "M1 4h5v5H1zM4 1h5v5H6.5", strokeWidth: "1.3", strokeLinejoin: "round" })
|
|
124
132
|
: _jsx("path", { d: "M1.5 1.5h7v7h-7z", strokeWidth: "1.3", strokeLinejoin: "round" }) }) });
|
|
125
133
|
});
|
|
@@ -138,8 +146,20 @@ const Header = Object.assign(HeaderRoot, {
|
|
|
138
146
|
Maximize: WindowMaximize,
|
|
139
147
|
Close: WindowClose
|
|
140
148
|
});
|
|
149
|
+
/** The active full-viewport side of a Window move handoff. */
|
|
150
|
+
const WindowMoveCapture = forwardRef(function WindowMoveCapture({ style, ...properties }, ref) {
|
|
151
|
+
return _jsx("div", { ...properties, ref: ref, style: {
|
|
152
|
+
position: "fixed",
|
|
153
|
+
inset: 0,
|
|
154
|
+
touchAction: "none",
|
|
155
|
+
userSelect: "none",
|
|
156
|
+
cursor: "grab",
|
|
157
|
+
...style
|
|
158
|
+
} });
|
|
159
|
+
});
|
|
141
160
|
/** One Surface with a ready-to-use header-and-content composition. */
|
|
142
161
|
export const Window = Object.assign(WindowRoot, {
|
|
143
162
|
Header,
|
|
144
|
-
Content: WindowContent
|
|
163
|
+
Content: WindowContent,
|
|
164
|
+
MoveCapture: WindowMoveCapture
|
|
145
165
|
});
|