@phreshos/react-ui 0.1.29 → 0.1.31
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/README.md +197 -39
- package/dist/accordion.d.ts +45 -0
- package/dist/accordion.js +62 -0
- package/dist/alert-dialog.d.ts +0 -1
- package/dist/alert-dialog.js +0 -1
- package/dist/aria-direction.d.ts +9 -0
- package/dist/aria-direction.js +49 -0
- package/dist/calendar-layout.d.ts +8 -0
- package/dist/calendar-layout.js +103 -0
- package/dist/calendar-trigger.d.ts +5 -0
- package/dist/calendar-trigger.js +30 -0
- package/dist/calendar.d.ts +18 -0
- package/dist/calendar.js +13 -0
- package/dist/color.d.ts +16 -1
- package/dist/color.js +60 -11
- package/dist/combo-box.d.ts +20 -0
- package/dist/combo-box.js +68 -0
- package/dist/context-menu.d.ts +2 -4
- package/dist/context-menu.js +0 -1
- package/dist/control-surface.d.ts +2 -1
- package/dist/control-surface.js +2 -2
- package/dist/control.d.ts +1 -1
- package/dist/control.js +7 -8
- package/dist/date-control.d.ts +24 -0
- package/dist/date-control.js +69 -0
- package/dist/date-field.d.ts +19 -0
- package/dist/date-field.js +13 -0
- package/dist/date-picker.d.ts +19 -0
- package/dist/date-picker.js +16 -0
- package/dist/date-range-picker.d.ts +20 -0
- package/dist/date-range-picker.js +25 -0
- package/dist/date-range.d.ts +6 -0
- package/dist/date-range.js +0 -0
- package/dist/dialog.d.ts +4 -2
- package/dist/dialog.js +24 -7
- package/dist/disclosure.d.ts +42 -0
- package/dist/disclosure.js +97 -0
- package/dist/dropdown-menu.d.ts +0 -2
- package/dist/dropdown-menu.js +0 -1
- package/dist/list-box.d.ts +49 -0
- package/dist/list-box.js +129 -0
- package/dist/main.d.ts +27 -11
- package/dist/main.js +26 -10
- package/dist/material-options.d.ts +4 -2
- package/dist/material-paint.js +19 -1
- package/dist/menu.d.ts +22 -4
- package/dist/menu.js +25 -6
- package/dist/panel.d.ts +0 -1
- package/dist/panel.js +0 -1
- package/dist/popover.d.ts +0 -1
- package/dist/popover.js +13 -3
- package/dist/progress-bar.d.ts +22 -0
- package/dist/progress-bar.js +46 -0
- package/dist/radio.d.ts +5 -5
- package/dist/radio.js +8 -4
- package/dist/radius.js +1 -1
- package/dist/range-calendar.d.ts +19 -0
- package/dist/range-calendar.js +15 -0
- package/dist/scroll-area.d.ts +4 -1
- package/dist/scroll-area.js +3 -3
- package/dist/select.js +4 -14
- package/dist/selection.d.ts +18 -0
- package/dist/selection.js +28 -0
- package/dist/slider.js +1 -1
- package/dist/spacing.js +1 -1
- package/dist/surface.d.ts +1 -1
- package/dist/surface.js +22 -3
- package/dist/table.d.ts +78 -0
- package/dist/table.js +148 -0
- package/dist/tabs.d.ts +45 -0
- package/dist/tabs.js +103 -0
- package/dist/time-field.d.ts +22 -0
- package/dist/time-field.js +13 -0
- package/dist/toggle-indicator.js +1 -1
- package/dist/toolbar.d.ts +46 -0
- package/dist/toolbar.js +121 -0
- package/dist/tooltip.d.ts +0 -1
- package/dist/tooltip.js +0 -1
- package/dist/tree.d.ts +56 -0
- package/dist/tree.js +134 -0
- package/dist/window.d.ts +39 -0
- package/dist/{window-header.js → window.js} +57 -31
- package/package.json +4 -2
- package/dist/window-header.d.ts +0 -42
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, RefAttributes } from "react";
|
|
2
|
+
import { Collection as AriaCollection } from "react-aria-components";
|
|
3
|
+
import type { CollectionProps as AriaCollectionProps, TreeItemContentProps as AriaTreeItemContentProps, TreeItemProps as AriaTreeItemProps, TreeProps as AriaTreeProps } from "react-aria-components";
|
|
4
|
+
import type { ControlColor } from "./control.js";
|
|
5
|
+
import type { RadiusProps } from "./radius.js";
|
|
6
|
+
import type { ScaleLevel } from "./scale.js";
|
|
7
|
+
import { type MultipleStringSelection, type MultipleStringSelectionProps, type SingleStringSelectionProps } from "./selection.js";
|
|
8
|
+
type TreeRootBaseProps<T extends object> = Omit<AriaTreeProps<T>, "className" | "defaultExpandedKeys" | "defaultSelectedKeys" | "disabledKeys" | "expandedKeys" | "onAction" | "onExpandedChange" | "onSelectionChange" | "selectedKeys" | "selectionMode" | "style"> & RadiusProps & Readonly<{
|
|
9
|
+
className?: string;
|
|
10
|
+
color?: ControlColor;
|
|
11
|
+
defaultExpanded?: readonly string[];
|
|
12
|
+
disabledValues?: readonly string[];
|
|
13
|
+
expanded?: readonly string[];
|
|
14
|
+
onExpandedChange?: (values: readonly string[]) => void;
|
|
15
|
+
onItemAction?: (value: string) => void;
|
|
16
|
+
size?: ScaleLevel;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
}>;
|
|
19
|
+
export type TreeNoSelectionProps = Readonly<{
|
|
20
|
+
selectionMode?: "none";
|
|
21
|
+
value?: never;
|
|
22
|
+
defaultValue?: never;
|
|
23
|
+
onChange?: never;
|
|
24
|
+
}>;
|
|
25
|
+
export type TreeSingleSelectionProps = SingleStringSelectionProps & Readonly<{
|
|
26
|
+
selectionMode: "single";
|
|
27
|
+
}>;
|
|
28
|
+
export type TreeMultipleValue = MultipleStringSelection;
|
|
29
|
+
export type TreeMultipleSelectionProps = MultipleStringSelectionProps & Readonly<{
|
|
30
|
+
selectionMode: "multiple";
|
|
31
|
+
}>;
|
|
32
|
+
export type TreeRootProps<T extends object = object> = TreeRootBaseProps<T> & (TreeNoSelectionProps | TreeSingleSelectionProps | TreeMultipleSelectionProps);
|
|
33
|
+
export type TreeRootComponent = <T extends object = object>(properties: TreeRootProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
34
|
+
export declare const TreeRoot: TreeRootComponent;
|
|
35
|
+
export interface TreeItemProps<T = object> extends Omit<AriaTreeItemProps<T>, "className" | "id" | "isDisabled" | "style"> {
|
|
36
|
+
readonly className?: string;
|
|
37
|
+
readonly disabled?: boolean;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly style?: CSSProperties;
|
|
40
|
+
}
|
|
41
|
+
export type TreeItemComponent = <T = object>(properties: TreeItemProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
42
|
+
export declare const TreeItem: TreeItemComponent;
|
|
43
|
+
export interface TreeContentProps extends AriaTreeItemContentProps {
|
|
44
|
+
readonly children: AriaTreeItemContentProps["children"];
|
|
45
|
+
}
|
|
46
|
+
export declare const TreeContent: import("react").ForwardRefExoticComponent<TreeContentProps & RefAttributes<Element>>;
|
|
47
|
+
export type TreeCollectionProps<T extends object = object> = AriaCollectionProps<T>;
|
|
48
|
+
export declare const TreeCollection: typeof AriaCollection;
|
|
49
|
+
/** Hierarchical navigation with independently controlled expansion, selection, and item actions. */
|
|
50
|
+
export declare const Tree: TreeRootComponent & {
|
|
51
|
+
Item: TreeItemComponent;
|
|
52
|
+
Content: import("react").ForwardRefExoticComponent<TreeContentProps & RefAttributes<Element>>;
|
|
53
|
+
Collection: typeof AriaCollection;
|
|
54
|
+
};
|
|
55
|
+
export type TreeProps<T extends object = object> = TreeRootProps<T>;
|
|
56
|
+
export {};
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useContext, useMemo } from "react";
|
|
3
|
+
import { Button as AriaButton, Collection as AriaCollection, Tree as AriaTree, TreeItem as AriaTreeItem, TreeItemContent as AriaTreeItemContent } from "react-aria-components";
|
|
4
|
+
import { controlOpacity, useControlTheme } from "./control.js";
|
|
5
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
6
|
+
import { multipleSelection, singleSelection, stringKey, stringKeys, toAriaSelection } from "./selection.js";
|
|
7
|
+
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
8
|
+
const TreeThemeContext = createContext(null);
|
|
9
|
+
const TreeRootImplementation = forwardRef(function TreeRoot(properties, ref) {
|
|
10
|
+
const { className, color, defaultExpanded, defaultValue, disabledValues, expanded, onChange, onExpandedChange, onItemAction, radius = "medium", selectionMode = "none", size = "medium", style, value, ...native } = properties;
|
|
11
|
+
const theme = useControlTheme({ color, radius, size });
|
|
12
|
+
const direction = resolveDirection(native.dir, useDirection());
|
|
13
|
+
const context = useMemo(() => ({ direction, interactive: selectionMode !== "none" || onItemAction != null, theme }), [direction, onItemAction, selectionMode, theme]);
|
|
14
|
+
return _jsx(TreeThemeContext.Provider, { value: context, children: _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaTree, { ...native, ...selectionProperties(properties), ...expansionProperties({ defaultExpanded, expanded, onExpandedChange }), ref: ref, dir: direction, className: className, disabledKeys: disabledValues, selectionMode: selectionMode, onAction: onItemAction == null ? undefined : key => onItemAction(stringKey(key)), style: {
|
|
15
|
+
display: "grid",
|
|
16
|
+
alignContent: "start",
|
|
17
|
+
gap: theme.gap,
|
|
18
|
+
minWidth: 0,
|
|
19
|
+
padding: theme.gap,
|
|
20
|
+
boxSizing: "border-box",
|
|
21
|
+
outline: "none",
|
|
22
|
+
fontFamily: "inherit",
|
|
23
|
+
fontSize: theme.fontSize,
|
|
24
|
+
...style
|
|
25
|
+
} }) }) });
|
|
26
|
+
});
|
|
27
|
+
export const TreeRoot = TreeRootImplementation;
|
|
28
|
+
function selectionProperties(properties) {
|
|
29
|
+
const selectedKeys = toAriaSelection(properties.value);
|
|
30
|
+
const defaultSelectedKeys = toAriaSelection(properties.defaultValue);
|
|
31
|
+
const onSelectionChange = properties.onChange == null
|
|
32
|
+
? undefined
|
|
33
|
+
: (selection) => {
|
|
34
|
+
if (properties.selectionMode === "multiple") {
|
|
35
|
+
properties.onChange?.(multipleSelection(selection));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (properties.selectionMode === "single")
|
|
39
|
+
properties.onChange?.(singleSelection(selection));
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
...(selectedKeys !== undefined ? { selectedKeys } : {}),
|
|
43
|
+
...(defaultSelectedKeys !== undefined ? { defaultSelectedKeys } : {}),
|
|
44
|
+
...(onSelectionChange !== undefined ? { onSelectionChange } : {})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function expansionProperties({ defaultExpanded, expanded, onExpandedChange }) {
|
|
48
|
+
return {
|
|
49
|
+
...(expanded !== undefined ? { expandedKeys: new Set(expanded) } : {}),
|
|
50
|
+
...(defaultExpanded !== undefined ? { defaultExpandedKeys: new Set(defaultExpanded) } : {}),
|
|
51
|
+
...(onExpandedChange !== undefined
|
|
52
|
+
? { onExpandedChange: (keys) => onExpandedChange(stringKeys(keys)) }
|
|
53
|
+
: {})
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const TreeItemImplementation = forwardRef(function TreeItem({ className, disabled = false, onAction, style, ...properties }, ref) {
|
|
57
|
+
const { interactive, theme } = useTreeTheme();
|
|
58
|
+
return _jsx(AriaTreeItem, { ...properties, ref: ref, className: className, isDisabled: disabled, onAction: onAction, style: state => {
|
|
59
|
+
const responds = interactive || onAction != null || state.hasChildItems;
|
|
60
|
+
return {
|
|
61
|
+
...theme.transition,
|
|
62
|
+
display: "flex",
|
|
63
|
+
alignItems: "center",
|
|
64
|
+
gap: theme.gap,
|
|
65
|
+
minWidth: 0,
|
|
66
|
+
minHeight: theme.height,
|
|
67
|
+
paddingBlock: 0,
|
|
68
|
+
paddingInlineEnd: Math.max(8, theme.spacing),
|
|
69
|
+
paddingInlineStart: Math.max(8, theme.spacing) + Math.max(0, state.level - 1) * theme.spacing,
|
|
70
|
+
boxSizing: "border-box",
|
|
71
|
+
borderRadius: theme.radius,
|
|
72
|
+
outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
|
|
73
|
+
outlineOffset: 1,
|
|
74
|
+
cursor: disabled ? "not-allowed" : responds ? "pointer" : "default",
|
|
75
|
+
opacity: disabled ? controlOpacity.disabled : 1,
|
|
76
|
+
userSelect: "none",
|
|
77
|
+
...(state.isSelected
|
|
78
|
+
? state.isPressed
|
|
79
|
+
? theme.paints.palette.pressed
|
|
80
|
+
: state.isHovered
|
|
81
|
+
? theme.paints.palette.hover
|
|
82
|
+
: theme.paints.palette.rest
|
|
83
|
+
: state.isHovered && responds
|
|
84
|
+
? theme.paints.subtle.hover
|
|
85
|
+
: { background: "transparent", color: "inherit" }),
|
|
86
|
+
...style
|
|
87
|
+
};
|
|
88
|
+
} });
|
|
89
|
+
});
|
|
90
|
+
export const TreeItem = TreeItemImplementation;
|
|
91
|
+
export const TreeContent = forwardRef(function TreeContent({ children }, ref) {
|
|
92
|
+
const { direction, theme } = useTreeTheme();
|
|
93
|
+
return _jsx(AriaTreeItemContent, { ref: ref, children: state => _jsxs(_Fragment, { children: [state.hasChildItems
|
|
94
|
+
? _jsx(AriaButton, { slot: "chevron", style: ({ isFocusVisible }) => ({
|
|
95
|
+
...theme.transition,
|
|
96
|
+
appearance: "none",
|
|
97
|
+
display: "inline-grid",
|
|
98
|
+
flex: "0 0 auto",
|
|
99
|
+
placeItems: "center",
|
|
100
|
+
width: theme.indicatorSize,
|
|
101
|
+
height: theme.indicatorSize,
|
|
102
|
+
padding: 0,
|
|
103
|
+
border: 0,
|
|
104
|
+
borderRadius: theme.radius,
|
|
105
|
+
outline: isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
|
|
106
|
+
outlineOffset: 1,
|
|
107
|
+
background: "transparent",
|
|
108
|
+
color: "inherit",
|
|
109
|
+
cursor: state.isDisabled ? "not-allowed" : "pointer",
|
|
110
|
+
font: "inherit"
|
|
111
|
+
}), children: _jsx(Chevron, { direction: direction, expanded: state.isExpanded, theme: theme }) })
|
|
112
|
+
: _jsx("span", { "aria-hidden": "true", style: { flex: `0 0 ${theme.indicatorSize}px`, width: theme.indicatorSize } }), _jsx("span", { style: { flex: "1 1 auto", minWidth: 0 }, children: typeof children === "function" ? children(state) : children })] }) });
|
|
113
|
+
});
|
|
114
|
+
function Chevron({ direction, expanded, theme }) {
|
|
115
|
+
const collapsedRotation = direction === "rtl" ? 180 : 0;
|
|
116
|
+
return _jsx("svg", { "aria-hidden": "true", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", style: {
|
|
117
|
+
...theme.transition,
|
|
118
|
+
transitionProperty: "transform",
|
|
119
|
+
transform: `rotate(${expanded ? 90 : collapsedRotation}deg)`
|
|
120
|
+
}, children: _jsx("path", { d: "m4 2 4 4-4 4" }) });
|
|
121
|
+
}
|
|
122
|
+
export const TreeCollection = AriaCollection;
|
|
123
|
+
/** Hierarchical navigation with independently controlled expansion, selection, and item actions. */
|
|
124
|
+
export const Tree = Object.assign(TreeRoot, {
|
|
125
|
+
Item: TreeItem,
|
|
126
|
+
Content: TreeContent,
|
|
127
|
+
Collection: TreeCollection
|
|
128
|
+
});
|
|
129
|
+
function useTreeTheme() {
|
|
130
|
+
const value = useContext(TreeThemeContext);
|
|
131
|
+
if (value == null)
|
|
132
|
+
throw new Error("Tree parts must be used inside Tree");
|
|
133
|
+
return value;
|
|
134
|
+
}
|
package/dist/window.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import { type ButtonProps } from "./button.js";
|
|
3
|
+
import { type Color } from "./color.js";
|
|
4
|
+
import { type SurfaceProps } from "./surface.js";
|
|
5
|
+
/** The material shell that establishes the complete header-and-content layout. */
|
|
6
|
+
export type WindowProps = SurfaceProps;
|
|
7
|
+
/** The remaining window area. Its consumer owns content behavior, including overflow. */
|
|
8
|
+
export type WindowContentProps = HTMLAttributes<HTMLDivElement>;
|
|
9
|
+
export interface WindowHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, "color"> {
|
|
10
|
+
/** Attenuates the identity when this header is not active. */
|
|
11
|
+
readonly active?: boolean;
|
|
12
|
+
/** Base color inherited by header-owned text and icons. */
|
|
13
|
+
readonly color?: Color;
|
|
14
|
+
}
|
|
15
|
+
export interface WindowIdentityProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
16
|
+
readonly icon?: string;
|
|
17
|
+
readonly title?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export type WindowCenterProps = HTMLAttributes<HTMLDivElement>;
|
|
20
|
+
export type WindowActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
21
|
+
export type WindowActionProps = Omit<ButtonProps, "size">;
|
|
22
|
+
export type WindowControlProps = Omit<WindowActionProps, "children">;
|
|
23
|
+
export interface WindowMaximizeProps extends WindowControlProps {
|
|
24
|
+
readonly maximized?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type WindowCloseProps = WindowControlProps;
|
|
27
|
+
/** One Surface with a ready-to-use header-and-content composition. */
|
|
28
|
+
export declare const Window: import("react").ForwardRefExoticComponent<Omit<WindowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
|
|
29
|
+
Header: import("react").ForwardRefExoticComponent<WindowHeaderProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
30
|
+
Identity: import("react").ForwardRefExoticComponent<WindowIdentityProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
31
|
+
Center: import("react").ForwardRefExoticComponent<WindowCenterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
Actions: import("react").ForwardRefExoticComponent<WindowActionsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
33
|
+
Action: import("react").ForwardRefExoticComponent<WindowActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
34
|
+
Minimize: import("react").ForwardRefExoticComponent<WindowControlProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
|
+
Maximize: import("react").ForwardRefExoticComponent<WindowMaximizeProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
36
|
+
Close: import("react").ForwardRefExoticComponent<WindowControlProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
37
|
+
};
|
|
38
|
+
Content: import("react").ForwardRefExoticComponent<WindowContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
39
|
+
};
|
|
@@ -2,27 +2,48 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, forwardRef, useContext } from "react";
|
|
3
3
|
import { useResolvedAppearance } from "./appearance-context.js";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
|
+
import { resolveColor } from "./color.js";
|
|
5
6
|
import { transitionTiming } from "./motion-style.js";
|
|
6
7
|
import { scale } from "./scale.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import { Surface } from "./surface.js";
|
|
9
|
+
const HeaderContext = createContext(null);
|
|
10
|
+
function useHeader() {
|
|
11
|
+
const value = useContext(HeaderContext);
|
|
10
12
|
if (value === null)
|
|
11
|
-
throw new Error("
|
|
13
|
+
throw new Error("Window.Header parts require Window.Header");
|
|
12
14
|
return value;
|
|
13
15
|
}
|
|
16
|
+
const WindowRoot = forwardRef(function WindowRoot({ children, style, ...properties }, ref) {
|
|
17
|
+
return _jsx(Surface, { ...properties, ref: ref, style: {
|
|
18
|
+
display: "flex",
|
|
19
|
+
flexDirection: "column",
|
|
20
|
+
minWidth: 0,
|
|
21
|
+
minHeight: 0,
|
|
22
|
+
...style
|
|
23
|
+
}, children: children });
|
|
24
|
+
});
|
|
25
|
+
const WindowContent = forwardRef(function WindowContent({ style, ...properties }, ref) {
|
|
26
|
+
return _jsx("div", { ...properties, ref: ref, style: {
|
|
27
|
+
position: "relative",
|
|
28
|
+
flex: "1 1 auto",
|
|
29
|
+
minWidth: 0,
|
|
30
|
+
minHeight: 0,
|
|
31
|
+
...style
|
|
32
|
+
} });
|
|
33
|
+
});
|
|
14
34
|
/** The composable top region of a window; its enclosing Surface owns the material. */
|
|
15
|
-
|
|
35
|
+
const HeaderRoot = forwardRef(function HeaderRoot({ active = true, children, color, onPointerDown, style, ...properties }, ref) {
|
|
16
36
|
const resolved = useResolvedAppearance();
|
|
17
37
|
const spacing = resolved.appearance.spacing;
|
|
38
|
+
const foreground = style?.color ?? resolveColor(color ?? "foreground:base", resolved.colors);
|
|
18
39
|
const state = {
|
|
19
40
|
active,
|
|
20
|
-
foreground
|
|
41
|
+
foreground,
|
|
21
42
|
iconRadius: scale(resolved.appearance.radius, "xsmall"),
|
|
22
43
|
spacing,
|
|
23
44
|
transition: transitionTiming(resolved.transaction, resolved.preferences.animations)
|
|
24
45
|
};
|
|
25
|
-
return _jsx(
|
|
46
|
+
return _jsx(HeaderContext.Provider, { value: state, children: _jsx("div", { ...properties, ref: ref, onPointerDown: onPointerDown, style: {
|
|
26
47
|
boxSizing: "border-box",
|
|
27
48
|
display: "flex",
|
|
28
49
|
alignItems: "center",
|
|
@@ -34,12 +55,13 @@ export const WindowHeaderRoot = forwardRef(function WindowHeaderRoot({ active =
|
|
|
34
55
|
userSelect: "none",
|
|
35
56
|
touchAction: onPointerDown ? "none" : undefined,
|
|
36
57
|
cursor: onPointerDown ? "grab" : undefined,
|
|
58
|
+
color: foreground,
|
|
37
59
|
...style
|
|
38
60
|
}, children: children }) });
|
|
39
61
|
});
|
|
40
62
|
/** The icon and truncating title share the window's active treatment. */
|
|
41
|
-
|
|
42
|
-
const { active, iconRadius, spacing, transition } =
|
|
63
|
+
const WindowIdentity = forwardRef(function WindowIdentity({ icon, title, style, ...properties }, ref) {
|
|
64
|
+
const { active, iconRadius, spacing, transition } = useHeader();
|
|
43
65
|
return _jsxs("div", { ...properties, ref: ref, style: {
|
|
44
66
|
...transition,
|
|
45
67
|
transitionProperty: "opacity",
|
|
@@ -66,13 +88,13 @@ export const WindowHeaderIdentity = forwardRef(function WindowHeaderIdentity({ i
|
|
|
66
88
|
}, children: title })] });
|
|
67
89
|
});
|
|
68
90
|
/** Optional flexible space for application-owned content. */
|
|
69
|
-
|
|
70
|
-
|
|
91
|
+
const WindowCenter = forwardRef(function WindowCenter({ onDoubleClick, onPointerDown, style, ...properties }, ref) {
|
|
92
|
+
useHeader();
|
|
71
93
|
return _jsx("div", { ...properties, ref: ref, onDoubleClick: event => { event.stopPropagation(); onDoubleClick?.(event); }, onPointerDown: event => { event.stopPropagation(); onPointerDown?.(event); }, style: { display: "flex", alignItems: "center", flex: "1 1 auto", minWidth: 0, ...style } });
|
|
72
94
|
});
|
|
73
95
|
/** End-aligned controls that do not begin a header drag or double-click action. */
|
|
74
|
-
|
|
75
|
-
const { spacing } =
|
|
96
|
+
const WindowActions = forwardRef(function WindowActions({ onDoubleClick, onPointerDown, style, ...properties }, ref) {
|
|
97
|
+
const { spacing } = useHeader();
|
|
76
98
|
return _jsx("div", { ...properties, ref: ref, onDoubleClick: event => { event.stopPropagation(); onDoubleClick?.(event); }, onPointerDown: event => { event.stopPropagation(); onPointerDown?.(event); }, style: {
|
|
77
99
|
display: "flex",
|
|
78
100
|
alignItems: "center",
|
|
@@ -83,31 +105,35 @@ export const WindowHeaderActions = forwardRef(function WindowHeaderActions({ onD
|
|
|
83
105
|
} });
|
|
84
106
|
});
|
|
85
107
|
/** A compact header action; extra actions use the same treatment as the standard controls. */
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return _jsx(Button, { ...properties, ref: ref, size: "xsmall"
|
|
108
|
+
const WindowAction = forwardRef(function WindowAction({ ...properties }, ref) {
|
|
109
|
+
useHeader();
|
|
110
|
+
return _jsx(Button, { ...properties, ref: ref, size: "xsmall" });
|
|
89
111
|
});
|
|
90
|
-
|
|
91
|
-
return _jsx(
|
|
112
|
+
const WindowMinimize = forwardRef(function WindowMinimize({ "aria-label": label = "Minimize", preventFocusOnPress = true, ...properties }, ref) {
|
|
113
|
+
return _jsx(WindowAction, { ...properties, ref: ref, "aria-label": label, preventFocusOnPress: preventFocusOnPress, children: _jsx(ControlIcon, { children: _jsx("path", { d: "M1.5 7.5h7" }) }) });
|
|
92
114
|
});
|
|
93
|
-
|
|
94
|
-
return _jsx(
|
|
115
|
+
const WindowMaximize = forwardRef(function WindowMaximize({ "aria-label": label, maximized = false, ...properties }, ref) {
|
|
116
|
+
return _jsx(WindowAction, { ...properties, ref: ref, "aria-label": label ?? (maximized ? "Restore" : "Maximize"), children: _jsx(ControlIcon, { children: maximized
|
|
95
117
|
? _jsx("path", { d: "M1 4h5v5H1zM4 1h5v5H6.5", strokeWidth: "1.3", strokeLinejoin: "round" })
|
|
96
118
|
: _jsx("path", { d: "M1.5 1.5h7v7h-7z", strokeWidth: "1.3", strokeLinejoin: "round" }) }) });
|
|
97
119
|
});
|
|
98
|
-
|
|
99
|
-
return _jsx(
|
|
120
|
+
const WindowClose = forwardRef(function WindowClose({ "aria-label": label = "Close", color = "danger:base", preventFocusOnPress = true, ...properties }, ref) {
|
|
121
|
+
return _jsx(WindowAction, { ...properties, ref: ref, "aria-label": label, color: color, preventFocusOnPress: preventFocusOnPress, children: _jsx(ControlIcon, { children: _jsx("path", { d: "M1.5 1.5 8.5 8.5M8.5 1.5 1.5 8.5" }) }) });
|
|
100
122
|
});
|
|
101
123
|
function ControlIcon({ children }) {
|
|
102
124
|
return _jsx("svg", { "aria-hidden": "true", width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: children });
|
|
103
125
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
126
|
+
const Header = Object.assign(HeaderRoot, {
|
|
127
|
+
Identity: WindowIdentity,
|
|
128
|
+
Center: WindowCenter,
|
|
129
|
+
Actions: WindowActions,
|
|
130
|
+
Action: WindowAction,
|
|
131
|
+
Minimize: WindowMinimize,
|
|
132
|
+
Maximize: WindowMaximize,
|
|
133
|
+
Close: WindowClose
|
|
134
|
+
});
|
|
135
|
+
/** One Surface with a ready-to-use header-and-content composition. */
|
|
136
|
+
export const Window = Object.assign(WindowRoot, {
|
|
137
|
+
Header,
|
|
138
|
+
Content: WindowContent
|
|
113
139
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/react-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "React components for coherent PhreshOS Program interfaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -56,9 +56,11 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@base-ui/react": "^1.7.0",
|
|
59
|
-
"@
|
|
59
|
+
"@internationalized/date": "^3.12.3",
|
|
60
|
+
"@phreshos/core": "^0.1.55",
|
|
60
61
|
"colorjs.io": "^0.7.1",
|
|
61
62
|
"motion": "^13.2.0",
|
|
63
|
+
"react-aria": "^3.51.0",
|
|
62
64
|
"react-aria-components": "^1.20.0"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
package/dist/window-header.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps, HTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import { type ButtonProps } from "./button.js";
|
|
3
|
-
export interface WindowHeaderRootProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
/** Attenuates the identity when this header is not active. */
|
|
5
|
-
readonly active?: boolean;
|
|
6
|
-
}
|
|
7
|
-
/** The composable top region of a window; its enclosing Surface owns the material. */
|
|
8
|
-
export declare const WindowHeaderRoot: import("react").ForwardRefExoticComponent<WindowHeaderRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
|
-
export interface WindowHeaderIdentityProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
10
|
-
readonly icon?: string;
|
|
11
|
-
readonly title?: ReactNode;
|
|
12
|
-
}
|
|
13
|
-
/** The icon and truncating title share the window's active treatment. */
|
|
14
|
-
export declare const WindowHeaderIdentity: import("react").ForwardRefExoticComponent<WindowHeaderIdentityProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
-
export type WindowHeaderCenterProps = HTMLAttributes<HTMLDivElement>;
|
|
16
|
-
/** Optional flexible space for application-owned content. */
|
|
17
|
-
export declare const WindowHeaderCenter: import("react").ForwardRefExoticComponent<WindowHeaderCenterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
18
|
-
export type WindowHeaderActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
19
|
-
/** End-aligned controls that do not begin a header drag or double-click action. */
|
|
20
|
-
export declare const WindowHeaderActions: import("react").ForwardRefExoticComponent<WindowHeaderActionsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
|
-
export type WindowHeaderActionProps = Omit<ButtonProps, "size">;
|
|
22
|
-
/** A compact header action; extra actions use the same treatment as the standard controls. */
|
|
23
|
-
export declare const WindowHeaderAction: import("react").ForwardRefExoticComponent<WindowHeaderActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
24
|
-
export type WindowHeaderControlProps = Omit<WindowHeaderActionProps, "children">;
|
|
25
|
-
export declare const WindowHeaderMinimize: import("react").ForwardRefExoticComponent<WindowHeaderControlProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
26
|
-
export interface WindowHeaderMaximizeProps extends WindowHeaderControlProps {
|
|
27
|
-
readonly maximized?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export declare const WindowHeaderMaximize: import("react").ForwardRefExoticComponent<WindowHeaderMaximizeProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
30
|
-
export type WindowHeaderCloseProps = Omit<WindowHeaderControlProps, "color">;
|
|
31
|
-
export declare const WindowHeaderClose: import("react").ForwardRefExoticComponent<WindowHeaderCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
32
|
-
export declare const WindowHeader: import("react").ForwardRefExoticComponent<WindowHeaderRootProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
33
|
-
Root: import("react").ForwardRefExoticComponent<WindowHeaderRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
-
Identity: import("react").ForwardRefExoticComponent<WindowHeaderIdentityProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
-
Center: import("react").ForwardRefExoticComponent<WindowHeaderCenterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
|
-
Actions: import("react").ForwardRefExoticComponent<WindowHeaderActionsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
37
|
-
Action: import("react").ForwardRefExoticComponent<WindowHeaderActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
38
|
-
Minimize: import("react").ForwardRefExoticComponent<WindowHeaderControlProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
39
|
-
Maximize: import("react").ForwardRefExoticComponent<WindowHeaderMaximizeProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
40
|
-
Close: import("react").ForwardRefExoticComponent<WindowHeaderCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
41
|
-
};
|
|
42
|
-
export type WindowHeaderProps = ComponentProps<typeof WindowHeaderRoot>;
|