@phreshos/react-ui 0.1.36 → 0.1.38
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 +147 -167
- package/dist/accordion.d.ts +7 -6
- package/dist/accordion.js +5 -5
- package/dist/alert-dialog.d.ts +2 -2
- package/dist/alert-dialog.js +3 -1
- package/dist/alert.d.ts +17 -0
- package/dist/alert.js +30 -0
- package/dist/app-layout.d.ts +13 -0
- package/dist/app-layout.js +84 -0
- package/dist/button.d.ts +31 -27
- package/dist/button.js +48 -40
- package/dist/calendar-layout.d.ts +9 -5
- package/dist/calendar-layout.js +67 -78
- package/dist/calendar-trigger.d.ts +4 -4
- package/dist/calendar-trigger.js +7 -29
- package/dist/calendar.d.ts +2 -2
- package/dist/calendar.js +6 -5
- package/dist/checkbox.d.ts +4 -4
- package/dist/checkbox.js +16 -6
- package/dist/color-area.d.ts +20 -0
- package/dist/color-area.js +30 -0
- package/dist/color-field.d.ts +17 -0
- package/dist/color-field.js +17 -0
- package/dist/color-picker.d.ts +24 -0
- package/dist/color-picker.js +30 -0
- package/dist/color-slider.d.ts +19 -0
- package/dist/color-slider.js +29 -0
- package/dist/color-swatch-picker.d.ts +23 -0
- package/dist/color-swatch-picker.js +36 -0
- package/dist/color-swatch.d.ts +18 -0
- package/dist/color-swatch.js +20 -0
- package/dist/combo-box.d.ts +18 -10
- package/dist/combo-box.js +43 -58
- package/dist/context-menu.d.ts +14 -10
- package/dist/context-menu.js +7 -6
- package/dist/control/color-thumb.d.ts +13 -0
- package/dist/control/color-thumb.js +33 -0
- package/dist/control/color-value.d.ts +6 -0
- package/dist/control/color-value.js +7 -0
- package/dist/control/control.d.ts +60 -0
- package/dist/control/control.js +71 -0
- package/dist/control/field-button.d.ts +13 -0
- package/dist/control/field-button.js +28 -0
- package/dist/control/field.d.ts +20 -0
- package/dist/control/field.js +34 -0
- package/dist/control/icon.d.ts +11 -0
- package/dist/control/icon.js +8 -0
- package/dist/control/item.d.ts +37 -0
- package/dist/control/item.js +57 -0
- package/dist/control/open-state.d.ts +25 -0
- package/dist/control/open-state.js +8 -0
- package/dist/control/selection-track.d.ts +39 -0
- package/dist/control/selection-track.js +122 -0
- package/dist/control/selection.d.ts +44 -0
- package/dist/{selection.js → control/selection.js} +16 -0
- package/dist/control/surface-render.d.ts +10 -0
- package/dist/control/surface-render.js +12 -0
- package/dist/control/text-control.d.ts +32 -0
- package/dist/control/text-control.js +31 -0
- package/dist/control/toggle.d.ts +32 -0
- package/dist/control/toggle.js +80 -0
- package/dist/date-control.d.ts +9 -9
- package/dist/date-control.js +31 -34
- package/dist/date-field.d.ts +7 -6
- package/dist/date-field.js +8 -6
- package/dist/date-picker.d.ts +13 -6
- package/dist/date-picker.js +9 -6
- package/dist/date-range-picker.d.ts +15 -6
- package/dist/date-range-picker.js +12 -9
- package/dist/dialog.d.ts +29 -15
- package/dist/dialog.js +37 -28
- package/dist/disclosure.d.ts +8 -7
- package/dist/disclosure.js +31 -52
- package/dist/drop-zone.d.ts +18 -0
- package/dist/drop-zone.js +32 -0
- package/dist/dropdown-menu.d.ts +11 -8
- package/dist/dropdown-menu.js +5 -4
- package/dist/fieldset.d.ts +13 -0
- package/dist/fieldset.js +26 -0
- package/dist/file-trigger.d.ts +13 -0
- package/dist/file-trigger.js +6 -0
- package/dist/flex.d.ts +1 -1
- package/dist/flex.js +5 -4
- package/dist/foundation/appearance.d.ts +83 -0
- package/dist/foundation/appearance.js +38 -0
- package/dist/{aria-direction.js → foundation/aria-direction.js} +3 -1
- package/dist/foundation/color.d.ts +61 -0
- package/dist/foundation/color.js +247 -0
- package/dist/{layout.d.ts → foundation/layout.d.ts} +6 -4
- package/dist/{layout.js → foundation/layout.js} +7 -5
- package/dist/foundation/motion-style.d.ts +9 -0
- package/dist/foundation/motion-style.js +50 -0
- package/dist/foundation/preferences.d.ts +15 -0
- package/dist/{ui-provider.d.ts → foundation/provider.d.ts} +9 -5
- package/dist/{ui-provider.js → foundation/provider.js} +18 -27
- package/dist/{radius.d.ts → foundation/radius.d.ts} +6 -3
- package/dist/foundation/radius.js +11 -0
- package/dist/foundation/spacing.d.ts +11 -0
- package/dist/foundation/spacing.js +4 -0
- package/dist/foundation/visual.d.ts +42 -0
- package/dist/{appearance-context.js → foundation/visual.js} +41 -27
- package/dist/grid.d.ts +1 -1
- package/dist/grid.js +5 -4
- package/dist/icons/main.d.ts +5 -3
- package/dist/icons/main.js +5 -3
- package/dist/input.d.ts +2 -2
- package/dist/input.js +9 -7
- package/dist/list-box.d.ts +24 -19
- package/dist/list-box.js +52 -109
- package/dist/main.d.ts +28 -17
- package/dist/main.js +22 -9
- package/dist/menu.d.ts +28 -32
- package/dist/menu.js +47 -93
- package/dist/number-field.d.ts +17 -0
- package/dist/number-field.js +28 -0
- package/dist/panel.d.ts +10 -5
- package/dist/panel.js +33 -12
- package/dist/popover.d.ts +26 -12
- package/dist/popover.js +22 -15
- package/dist/progress-bar.d.ts +8 -10
- package/dist/progress-bar.js +18 -34
- package/dist/radio.d.ts +15 -12
- package/dist/radio.js +27 -37
- package/dist/range-calendar.d.ts +5 -3
- package/dist/range-calendar.js +8 -7
- package/dist/scroll-area.d.ts +2 -2
- package/dist/scroll-area.js +10 -9
- package/dist/segmented-control.d.ts +23 -0
- package/dist/segmented-control.js +38 -0
- package/dist/select.d.ts +40 -13
- package/dist/select.js +63 -18
- package/dist/slider.d.ts +7 -3
- package/dist/slider.js +51 -50
- package/dist/spinner.d.ts +5 -8
- package/dist/spinner.js +12 -27
- package/dist/surface/grain.d.ts +12 -0
- package/dist/surface/grain.js +65 -0
- package/dist/{material-options.d.ts → surface/material-options.d.ts} +1 -2
- package/dist/{material-options.js → surface/material-options.js} +2 -2
- package/dist/surface/paint-class.d.ts +13 -0
- package/dist/surface/paint-class.js +47 -0
- package/dist/{shadow-options.d.ts → surface/shadow-options.d.ts} +13 -1
- package/dist/{shadow-options.js → surface/shadow-options.js} +17 -2
- package/dist/surface/surface.d.ts +80 -0
- package/dist/surface/surface.js +239 -0
- package/dist/switch.d.ts +4 -5
- package/dist/switch.js +17 -8
- package/dist/table.d.ts +29 -32
- package/dist/table.js +68 -106
- package/dist/tabs.d.ts +16 -15
- package/dist/tabs.js +44 -86
- package/dist/textarea.d.ts +2 -2
- package/dist/textarea.js +10 -14
- package/dist/time-field.d.ts +6 -6
- package/dist/time-field.js +8 -6
- package/dist/toolbar.d.ts +6 -4
- package/dist/toolbar.js +16 -15
- package/dist/tooltip.d.ts +17 -8
- package/dist/tooltip.js +17 -15
- package/dist/tree.d.ts +22 -27
- package/dist/tree.js +54 -99
- package/dist/window.d.ts +4 -4
- package/dist/window.js +18 -20
- package/package.json +3 -3
- package/dist/appearance-context.d.ts +0 -54
- package/dist/appearance.d.ts +0 -11
- package/dist/appearance.js +0 -11
- package/dist/color.d.ts +0 -69
- package/dist/color.js +0 -192
- package/dist/control-surface.d.ts +0 -20
- package/dist/control-surface.js +0 -11
- package/dist/control.d.ts +0 -70
- package/dist/control.js +0 -105
- package/dist/field-style.d.ts +0 -3
- package/dist/field-style.js +0 -12
- package/dist/material-paint.d.ts +0 -13
- package/dist/material-paint.js +0 -119
- package/dist/motion-style.d.ts +0 -13
- package/dist/motion-style.js +0 -75
- package/dist/preferences.d.ts +0 -12
- package/dist/radius.js +0 -11
- package/dist/readiness.d.ts +0 -37
- package/dist/readiness.js +0 -134
- package/dist/selection.d.ts +0 -18
- package/dist/spacing.d.ts +0 -8
- package/dist/spacing.js +0 -8
- package/dist/surface-edge.d.ts +0 -11
- package/dist/surface-edge.js +0 -55
- package/dist/surface.d.ts +0 -27
- package/dist/surface.js +0 -92
- package/dist/text-control.d.ts +0 -10
- package/dist/text-control.js +0 -0
- package/dist/toggle-indicator.d.ts +0 -18
- package/dist/toggle-indicator.js +0 -49
- /package/dist/{aria-direction.d.ts → foundation/aria-direction.d.ts} +0 -0
- /package/dist/{direction.d.ts → foundation/direction.d.ts} +0 -0
- /package/dist/{direction.js → foundation/direction.js} +0 -0
- /package/dist/{overlay-placement.d.ts → foundation/overlay-placement.d.ts} +0 -0
- /package/dist/{overlay-placement.js → foundation/overlay-placement.js} +0 -0
- /package/dist/{preferences.js → foundation/preferences.js} +0 -0
- /package/dist/{scale.d.ts → foundation/scale.d.ts} +0 -0
- /package/dist/{scale.js → foundation/scale.js} +0 -0
package/dist/radius.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isScaleLevel, scale } from "./scale.js";
|
|
2
|
-
/** Resolves a Radius while preserving explicit CSS and pixel values. */
|
|
3
|
-
export function resolveRadius(value, appearance) {
|
|
4
|
-
if (value === "full")
|
|
5
|
-
return "9999px";
|
|
6
|
-
if (!isScaleLevel(value))
|
|
7
|
-
return value;
|
|
8
|
-
if (!appearance)
|
|
9
|
-
throw new Error("A semantic radius requires an Appearance value");
|
|
10
|
-
return scale(appearance.radius, value);
|
|
11
|
-
}
|
package/dist/readiness.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from "react";
|
|
2
|
-
/** One requirement observed during the boundary's initial readiness cycle. */
|
|
3
|
-
export interface ReadinessRequirement {
|
|
4
|
-
readonly message: string;
|
|
5
|
-
readonly createdAt: Date;
|
|
6
|
-
readonly readyAt: Date | null;
|
|
7
|
-
}
|
|
8
|
-
export interface ReadinessProps {
|
|
9
|
-
/** Interface prepared behind this initial readiness boundary. */
|
|
10
|
-
readonly children: ReactNode;
|
|
11
|
-
/** Optional presentation rendered while initial requirements remain pending. */
|
|
12
|
-
readonly fallback?: (requirements: readonly ReadinessRequirement[]) => ReactNode;
|
|
13
|
-
/** Message used when the oldest pending requirement has none of its own. */
|
|
14
|
-
readonly message?: string;
|
|
15
|
-
}
|
|
16
|
-
/** Prevents interaction with one React subtree until its initial requirements are ready. */
|
|
17
|
-
export declare function ReadinessRoot({ children, fallback, message }: ReadinessProps): import("react").JSX.Element;
|
|
18
|
-
export interface ReadinessRequirementProps {
|
|
19
|
-
/** Message exposed while this mounted requirement remains pending. */
|
|
20
|
-
readonly message?: string;
|
|
21
|
-
}
|
|
22
|
-
/** One declarative requirement whose pending lifetime matches this component's mount. */
|
|
23
|
-
export declare function ReadinessRequirement({ message }: ReadinessRequirementProps): null;
|
|
24
|
-
/** Registers one requirement and returns its stable, idempotent completion. */
|
|
25
|
-
export declare function useRequirement(message?: string): () => void;
|
|
26
|
-
/** Reads the nearest boundary's current initial-readiness state. */
|
|
27
|
-
export declare function useReadiness(): Readonly<{
|
|
28
|
-
ready: boolean;
|
|
29
|
-
requirements: readonly ReadinessRequirement[];
|
|
30
|
-
}>;
|
|
31
|
-
interface ReadinessComponent {
|
|
32
|
-
(properties: ReadinessProps): ReactElement | null;
|
|
33
|
-
readonly Requirement: typeof ReadinessRequirement;
|
|
34
|
-
}
|
|
35
|
-
export declare const Readiness: ReadinessComponent;
|
|
36
|
-
export type ReadinessFallback = NonNullable<ReadinessProps["fallback"]>;
|
|
37
|
-
export {};
|
package/dist/readiness.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
3
|
-
const ReadinessContext = createContext(null);
|
|
4
|
-
/** Prevents interaction with one React subtree until its initial requirements are ready. */
|
|
5
|
-
export function ReadinessRoot({ children, fallback, message = "Loading…" }) {
|
|
6
|
-
const parent = useContext(ReadinessContext);
|
|
7
|
-
const requirements = useRef(new Map());
|
|
8
|
-
const revealedRef = useRef(false);
|
|
9
|
-
const [revealed, setRevealed] = useState(false);
|
|
10
|
-
const [revision, invalidate] = useReducer(value => value + 1, 0);
|
|
11
|
-
const registry = useMemo(() => ({
|
|
12
|
-
register(identity, nextMessage) {
|
|
13
|
-
if (revealedRef.current)
|
|
14
|
-
return;
|
|
15
|
-
const current = requirements.current.get(identity);
|
|
16
|
-
if (current != null) {
|
|
17
|
-
if (current.readyAt == null)
|
|
18
|
-
return;
|
|
19
|
-
// React Strict Mode restores mounted effects before the initial tree settles.
|
|
20
|
-
requirements.current.set(identity, {
|
|
21
|
-
...current,
|
|
22
|
-
message: nextMessage,
|
|
23
|
-
readyAt: null
|
|
24
|
-
});
|
|
25
|
-
invalidate();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
requirements.current.set(identity, {
|
|
29
|
-
message: nextMessage,
|
|
30
|
-
createdAt: new Date(),
|
|
31
|
-
readyAt: null
|
|
32
|
-
});
|
|
33
|
-
invalidate();
|
|
34
|
-
},
|
|
35
|
-
update(identity, nextMessage) {
|
|
36
|
-
if (revealedRef.current)
|
|
37
|
-
return;
|
|
38
|
-
const current = requirements.current.get(identity);
|
|
39
|
-
if (current == null || current.message === nextMessage)
|
|
40
|
-
return;
|
|
41
|
-
requirements.current.set(identity, { ...current, message: nextMessage });
|
|
42
|
-
invalidate();
|
|
43
|
-
},
|
|
44
|
-
complete(identity) {
|
|
45
|
-
if (revealedRef.current)
|
|
46
|
-
return;
|
|
47
|
-
const current = requirements.current.get(identity);
|
|
48
|
-
if (current == null || current.readyAt != null)
|
|
49
|
-
return;
|
|
50
|
-
requirements.current.set(identity, { ...current, readyAt: new Date() });
|
|
51
|
-
invalidate();
|
|
52
|
-
},
|
|
53
|
-
release(identity) {
|
|
54
|
-
if (revealedRef.current)
|
|
55
|
-
return;
|
|
56
|
-
const current = requirements.current.get(identity);
|
|
57
|
-
if (current == null || current.readyAt != null)
|
|
58
|
-
return;
|
|
59
|
-
requirements.current.set(identity, { ...current, readyAt: new Date() });
|
|
60
|
-
invalidate();
|
|
61
|
-
}
|
|
62
|
-
}), []);
|
|
63
|
-
const currentRequirements = useMemo(() => {
|
|
64
|
-
return [...requirements.current.values()].map(requirement => ({
|
|
65
|
-
message: requirement.message ?? message,
|
|
66
|
-
createdAt: new Date(requirement.createdAt),
|
|
67
|
-
readyAt: requirement.readyAt == null ? null : new Date(requirement.readyAt)
|
|
68
|
-
}));
|
|
69
|
-
}, [message, revision]);
|
|
70
|
-
const currentMessage = currentRequirements.find(requirement => requirement.readyAt == null)?.message ?? message;
|
|
71
|
-
const completeParent = useManagedRequirement(parent?.registry ?? null, currentMessage);
|
|
72
|
-
useLayoutEffect(() => {
|
|
73
|
-
if (revealedRef.current
|
|
74
|
-
|| [...requirements.current.values()].some(requirement => requirement.readyAt == null))
|
|
75
|
-
return;
|
|
76
|
-
// Descendant layout effects register first, so an empty set here represents a settled commit.
|
|
77
|
-
revealedRef.current = true;
|
|
78
|
-
setRevealed(true);
|
|
79
|
-
}, [revision]);
|
|
80
|
-
useLayoutEffect(() => {
|
|
81
|
-
if (revealed)
|
|
82
|
-
completeParent();
|
|
83
|
-
}, [completeParent, revealed]);
|
|
84
|
-
const context = useMemo(() => ({
|
|
85
|
-
ready: revealed,
|
|
86
|
-
requirements: currentRequirements,
|
|
87
|
-
registry
|
|
88
|
-
}), [currentRequirements, registry, revealed]);
|
|
89
|
-
return _jsxs(ReadinessContext.Provider, { value: context, children: [_jsx("div", { "data-readiness": "", "data-ready": revealed ? "true" : "false", inert: revealed ? undefined : true, style: { display: "contents" }, children: children }), !revealed && fallback?.(currentRequirements)] });
|
|
90
|
-
}
|
|
91
|
-
/** One declarative requirement whose pending lifetime matches this component's mount. */
|
|
92
|
-
export function ReadinessRequirement({ message }) {
|
|
93
|
-
useRequirement(message);
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
/** Registers one requirement and returns its stable, idempotent completion. */
|
|
97
|
-
export function useRequirement(message) {
|
|
98
|
-
const context = useContext(ReadinessContext);
|
|
99
|
-
if (context == null)
|
|
100
|
-
throw new Error("useRequirement must be used inside Readiness");
|
|
101
|
-
return useManagedRequirement(context.registry, message);
|
|
102
|
-
}
|
|
103
|
-
/** Reads the nearest boundary's current initial-readiness state. */
|
|
104
|
-
export function useReadiness() {
|
|
105
|
-
const context = useContext(ReadinessContext);
|
|
106
|
-
if (context == null)
|
|
107
|
-
throw new Error("useReadiness must be used inside Readiness");
|
|
108
|
-
return useMemo(() => ({
|
|
109
|
-
ready: context.ready,
|
|
110
|
-
requirements: context.requirements
|
|
111
|
-
}), [context.ready, context.requirements]);
|
|
112
|
-
}
|
|
113
|
-
function useManagedRequirement(registry, message) {
|
|
114
|
-
const identity = useRef({});
|
|
115
|
-
const completed = useRef(false);
|
|
116
|
-
useLayoutEffect(() => {
|
|
117
|
-
if (!completed.current)
|
|
118
|
-
registry?.register(identity.current, message);
|
|
119
|
-
return () => registry?.release(identity.current);
|
|
120
|
-
}, [registry]);
|
|
121
|
-
useLayoutEffect(() => {
|
|
122
|
-
if (!completed.current)
|
|
123
|
-
registry?.update(identity.current, message);
|
|
124
|
-
}, [message, registry]);
|
|
125
|
-
return useCallback(() => {
|
|
126
|
-
if (completed.current)
|
|
127
|
-
return;
|
|
128
|
-
completed.current = true;
|
|
129
|
-
registry?.complete(identity.current);
|
|
130
|
-
}, [registry]);
|
|
131
|
-
}
|
|
132
|
-
export const Readiness = Object.assign(ReadinessRoot, {
|
|
133
|
-
Requirement: ReadinessRequirement
|
|
134
|
-
});
|
package/dist/selection.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Key, Selection } from "react-aria-components";
|
|
2
|
-
export type MultipleStringSelection = readonly string[] | "all";
|
|
3
|
-
export type SingleStringSelectionProps = Readonly<{
|
|
4
|
-
value?: string | null;
|
|
5
|
-
defaultValue?: string | null;
|
|
6
|
-
onChange?: (value: string | null) => void;
|
|
7
|
-
}>;
|
|
8
|
-
export type MultipleStringSelectionProps = Readonly<{
|
|
9
|
-
value?: MultipleStringSelection;
|
|
10
|
-
defaultValue?: MultipleStringSelection;
|
|
11
|
-
onChange?: (value: MultipleStringSelection) => void;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function toAriaSelection(value: string | null | MultipleStringSelection | undefined): "all" | Set<string> | undefined;
|
|
14
|
-
export declare function stringKey(value: Key): string;
|
|
15
|
-
export declare function optionalStringKey(value: Key | null): string | null;
|
|
16
|
-
export declare function singleSelection(selection: Selection): string | null;
|
|
17
|
-
export declare function multipleSelection(selection: Selection): MultipleStringSelection;
|
|
18
|
-
export declare function stringKeys(values: Iterable<Key>): readonly string[];
|
package/dist/spacing.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from "react";
|
|
2
|
-
import type { Appearance } from "./appearance.js";
|
|
3
|
-
import { type ScaleLevel } from "./scale.js";
|
|
4
|
-
/** An Appearance-derived level, pixel value, or explicit CSS spacing value. */
|
|
5
|
-
export type Spacing = ScaleLevel | number | (string & {});
|
|
6
|
-
/** Resolves spacing while preserving explicit CSS and pixel values. */
|
|
7
|
-
export declare function resolveSpacing(value: ScaleLevel, appearance: Appearance | null): number;
|
|
8
|
-
export declare function resolveSpacing(value: Spacing | undefined, appearance: Appearance | null): CSSProperties["gap"];
|
package/dist/spacing.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { isScaleLevel, scale } from "./scale.js";
|
|
2
|
-
export function resolveSpacing(value, appearance) {
|
|
3
|
-
if (!isScaleLevel(value))
|
|
4
|
-
return value;
|
|
5
|
-
if (!appearance)
|
|
6
|
-
throw new Error("Semantic spacing requires an Appearance value");
|
|
7
|
-
return scale(appearance.spacing, value);
|
|
8
|
-
}
|
package/dist/surface-edge.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties } from "react";
|
|
2
|
-
type EdgeMaterial = Readonly<{
|
|
3
|
-
color: string;
|
|
4
|
-
opacity: number;
|
|
5
|
-
}>;
|
|
6
|
-
/** Paints the boundary owned by one Surface from the material it contains. */
|
|
7
|
-
export declare function SurfaceEdge({ material, transition }: Readonly<{
|
|
8
|
-
material: EdgeMaterial;
|
|
9
|
-
transition: CSSProperties;
|
|
10
|
-
}>): import("react").JSX.Element | null;
|
|
11
|
-
export {};
|
package/dist/surface-edge.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from "react";
|
|
3
|
-
import { scale } from "./scale.js";
|
|
4
|
-
const edgeLayer = {
|
|
5
|
-
position: "absolute",
|
|
6
|
-
zIndex: 1,
|
|
7
|
-
inset: 0,
|
|
8
|
-
boxSizing: "border-box",
|
|
9
|
-
borderRadius: "inherit",
|
|
10
|
-
pointerEvents: "none"
|
|
11
|
-
};
|
|
12
|
-
const edgeScale = 0.8;
|
|
13
|
-
const outerEdgeThickness = edgeScale;
|
|
14
|
-
const illuminatedEdgeThickness = 0.3;
|
|
15
|
-
const illuminatedEdgeBoundary = Math.round((outerEdgeThickness + illuminatedEdgeThickness) * 100) / 100;
|
|
16
|
-
const horizontalIllumination = "linear-gradient(90deg, var(--phreshos-surface-edge-light-minimum) 0%, var(--phreshos-surface-edge-light-minimum) 12%, var(--phreshos-surface-edge-light-soft) 34%, var(--phreshos-surface-edge-light-peak) 50%, var(--phreshos-surface-edge-light-soft) 66%, var(--phreshos-surface-edge-light-minimum) 88%, var(--phreshos-surface-edge-light-minimum) 100%)";
|
|
17
|
-
const edgeMask = "linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)";
|
|
18
|
-
/** Paints the boundary owned by one Surface from the material it contains. */
|
|
19
|
-
export function SurfaceEdge({ material, transition }) {
|
|
20
|
-
const visible = material.opacity > 0;
|
|
21
|
-
if (!visible)
|
|
22
|
-
return null;
|
|
23
|
-
const opacity = Math.min(1, scale(material.opacity, "xlarge"));
|
|
24
|
-
const peak = illumination(material.color, 92);
|
|
25
|
-
return _jsxs(Fragment, { children: [_jsx("span", { "data-surface-edge-light": "", "aria-hidden": "true", style: {
|
|
26
|
-
...transition,
|
|
27
|
-
...edgeLayer,
|
|
28
|
-
transitionProperty: "opacity",
|
|
29
|
-
padding: illuminatedEdgeBoundary,
|
|
30
|
-
background: horizontalIllumination,
|
|
31
|
-
opacity,
|
|
32
|
-
WebkitMask: edgeMask,
|
|
33
|
-
WebkitMaskComposite: "xor",
|
|
34
|
-
mask: edgeMask,
|
|
35
|
-
maskComposite: "exclude",
|
|
36
|
-
"--phreshos-surface-edge-light-peak": peak,
|
|
37
|
-
"--phreshos-surface-edge-light-soft": illumination(material.color, 56),
|
|
38
|
-
"--phreshos-surface-edge-light-minimum": illumination(material.color, 24)
|
|
39
|
-
} }), _jsx("span", { "data-surface-edge": "", "aria-hidden": "true", style: {
|
|
40
|
-
...transition,
|
|
41
|
-
...edgeLayer,
|
|
42
|
-
transitionProperty: "border-color, opacity",
|
|
43
|
-
borderStyle: "solid",
|
|
44
|
-
borderWidth: outerEdgeThickness,
|
|
45
|
-
borderColor: "var(--phreshos-surface-edge-dark)",
|
|
46
|
-
opacity,
|
|
47
|
-
"--phreshos-surface-edge-dark": darkEdge(material.color)
|
|
48
|
-
} })] });
|
|
49
|
-
}
|
|
50
|
-
function darkEdge(color) {
|
|
51
|
-
return `color-mix(in srgb, color-mix(in oklch, ${color} 72%, black) 38%, transparent)`;
|
|
52
|
-
}
|
|
53
|
-
function illumination(color, opacity) {
|
|
54
|
-
return `color-mix(in srgb, color-mix(in oklch, ${color} 64%, white) ${opacity}%, transparent)`;
|
|
55
|
-
}
|
package/dist/surface.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ComponentPropsWithRef, CSSProperties, ElementType, ReactElement, ReactNode } from "react";
|
|
2
|
-
import { type Color } from "./color.js";
|
|
3
|
-
import { type MaterialOverrides } from "./material-options.js";
|
|
4
|
-
import { type RadiusProps } from "./radius.js";
|
|
5
|
-
import { type ShadowOverrides } from "./shadow-options.js";
|
|
6
|
-
import type { Direction } from "./direction.js";
|
|
7
|
-
export type { MaterialMode, MaterialOptions } from "./material-options.js";
|
|
8
|
-
export type { ShadowOptions } from "./shadow-options.js";
|
|
9
|
-
export interface SurfaceOwnProps extends MaterialOverrides, ShadowOverrides, RadiusProps {
|
|
10
|
-
readonly color?: Color;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The structural properties a component must preserve when it hosts a Surface.
|
|
14
|
-
* The component must apply `style` and render `children` on the same host element,
|
|
15
|
-
* and it must forward its ref to that element.
|
|
16
|
-
*/
|
|
17
|
-
export interface SurfaceHostProps {
|
|
18
|
-
readonly children?: ReactNode;
|
|
19
|
-
readonly dir?: Direction;
|
|
20
|
-
readonly style?: CSSProperties;
|
|
21
|
-
}
|
|
22
|
-
export type SurfaceHost = ElementType<SurfaceHostProps>;
|
|
23
|
-
export type SurfaceProps<As extends SurfaceHost = "div"> = SurfaceOwnProps & Readonly<{
|
|
24
|
-
as?: As;
|
|
25
|
-
}> & Omit<ComponentPropsWithRef<As>, keyof SurfaceOwnProps | "as" | "color">;
|
|
26
|
-
export type SurfaceComponent = <As extends SurfaceHost = "div">(properties: SurfaceProps<As>) => ReactElement | null;
|
|
27
|
-
export declare const Surface: SurfaceComponent;
|
package/dist/surface.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createElement, forwardRef, useId } from "react";
|
|
3
|
-
import { useResolvedAppearance } from "./appearance-context.js";
|
|
4
|
-
import { contrastingColor, defaultColor, resolveColor } from "./color.js";
|
|
5
|
-
import { resolveMaterialOptions } from "./material-options.js";
|
|
6
|
-
import { MaterialPaint } from "./material-paint.js";
|
|
7
|
-
import { paintTransition, transitionTiming, visualTransition } from "./motion-style.js";
|
|
8
|
-
import { resolveRadius } from "./radius.js";
|
|
9
|
-
import { resolveShadowOptions, shadowStyle } from "./shadow-options.js";
|
|
10
|
-
import { SurfaceEdge } from "./surface-edge.js";
|
|
11
|
-
/** One material- and shadow-owning element. The host is a div unless `as` selects another element. */
|
|
12
|
-
const SurfaceRoot = forwardRef(function Surface({ as: Element = "div", color, material: options, shadow: shadowOptions, radius, children, style, ...properties }, ref) {
|
|
13
|
-
const resolved = useResolvedAppearance();
|
|
14
|
-
const transition = visualTransition(resolved.transaction, resolved.preferences.animations);
|
|
15
|
-
const material = resolveSurface(color, options, resolved);
|
|
16
|
-
const resolvedShadow = resolveShadowOptions(typeof shadowOptions === "object" ? shadowOptions : {}, resolved.shadow);
|
|
17
|
-
const shadow = shadowOptions === false ? "none" : shadowStyle(resolvedShadow);
|
|
18
|
-
const resolvedRadius = resolveRadius(radius ?? "medium", resolved.appearance);
|
|
19
|
-
const timing = transitionTiming(resolved.transaction, resolved.preferences.animations);
|
|
20
|
-
const paintTiming = paintTransition(resolved.transaction, resolved.preferences.animations);
|
|
21
|
-
return createElement(Element, {
|
|
22
|
-
...properties,
|
|
23
|
-
ref,
|
|
24
|
-
style: {
|
|
25
|
-
...transition,
|
|
26
|
-
...style,
|
|
27
|
-
background: material.enabled ? "transparent" : material.color,
|
|
28
|
-
boxShadow: shadow,
|
|
29
|
-
color: style?.color ?? material.foreground,
|
|
30
|
-
borderRadius: radius === undefined ? style?.borderRadius ?? resolvedRadius : resolvedRadius,
|
|
31
|
-
position: style?.position ?? "relative",
|
|
32
|
-
isolation: "isolate"
|
|
33
|
-
}
|
|
34
|
-
}, material.enabled && _jsx(SurfaceLayers, { material: material, paintTransition: paintTiming }), material.enabled && _jsx(SurfaceEdge, { material: material, transition: timing }), children);
|
|
35
|
-
});
|
|
36
|
-
export const Surface = SurfaceRoot;
|
|
37
|
-
function resolveSurface(color, options, resolved) {
|
|
38
|
-
const mode = typeof options === "object" ? "full" : options ?? "basic";
|
|
39
|
-
const level = materialLevel[mode];
|
|
40
|
-
const material = resolveMaterialOptions(typeof options === "object" ? options : {}, resolved.material);
|
|
41
|
-
const fill = resolveColor(color, resolved.colors);
|
|
42
|
-
const opacity = level >= materialLevel.extended ? material.opacity : 1;
|
|
43
|
-
const backdrop = level >= materialLevel.full;
|
|
44
|
-
const grain = level === materialLevel.basic
|
|
45
|
-
? material.grain * material.opacity
|
|
46
|
-
: material.grain;
|
|
47
|
-
return {
|
|
48
|
-
...material,
|
|
49
|
-
enabled: level >= materialLevel.basic,
|
|
50
|
-
opacity,
|
|
51
|
-
fillOpacity: opacity,
|
|
52
|
-
grain,
|
|
53
|
-
backdrop: backdrop ? material.backdrop : 0,
|
|
54
|
-
distortion: backdrop ? material.distortion : 0,
|
|
55
|
-
saturation: backdrop ? material.saturation : 1,
|
|
56
|
-
color: fill,
|
|
57
|
-
foreground: contrastingColor(color ?? defaultColor, resolved.colors)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const materialLevel = Object.freeze({
|
|
61
|
-
none: 0,
|
|
62
|
-
basic: 1,
|
|
63
|
-
extended: 2,
|
|
64
|
-
full: 3
|
|
65
|
-
});
|
|
66
|
-
const layerStyle = {
|
|
67
|
-
position: "absolute",
|
|
68
|
-
inset: 0,
|
|
69
|
-
borderRadius: "inherit",
|
|
70
|
-
pointerEvents: "none"
|
|
71
|
-
};
|
|
72
|
-
function SurfaceLayers({ material, paintTransition }) {
|
|
73
|
-
const filtersVisible = material.fillOpacity < 1;
|
|
74
|
-
const backdrop = filtersVisible ? material.backdrop : 0;
|
|
75
|
-
const saturation = filtersVisible ? material.saturation : 1;
|
|
76
|
-
const distortion = filtersVisible ? material.distortion : 0;
|
|
77
|
-
const frost = [
|
|
78
|
-
backdrop === 0 ? "" : `blur(${backdrop}px)`,
|
|
79
|
-
saturation === 1 ? "" : `saturate(${saturation})`
|
|
80
|
-
].filter(Boolean).join(" ");
|
|
81
|
-
const identity = `phresh-material-${useId().replaceAll(":", "")}`;
|
|
82
|
-
return _jsxs("span", { "data-material": "", "aria-hidden": "true", style: layerStyle, children: [distortion > 0 && _jsx(BackdropLayer, { name: "refraction", filter: `url("#${identity}-distortion")`, zIndex: -3 }), frost && _jsx(BackdropLayer, { name: "frost", filter: frost, zIndex: -2 }), _jsx(MaterialPaint, { identity: identity, distortion: distortion, color: material.color, grain: material.grain, grainAmount: material.grainAmount, opacity: material.fillOpacity, transition: paintTransition })] });
|
|
83
|
-
}
|
|
84
|
-
/** Keep refraction and native frost in independent compositor passes. */
|
|
85
|
-
function BackdropLayer({ filter, name, zIndex }) {
|
|
86
|
-
return _jsx("span", { "data-material-backdrop": name, "aria-hidden": "true", style: {
|
|
87
|
-
...layerStyle,
|
|
88
|
-
zIndex,
|
|
89
|
-
backdropFilter: filter,
|
|
90
|
-
WebkitBackdropFilter: filter
|
|
91
|
-
} });
|
|
92
|
-
}
|
package/dist/text-control.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TextFieldProps } from "react-aria-components";
|
|
2
|
-
import type { ControlOverrides, ControlProps, FieldProps } from "./control.js";
|
|
3
|
-
import type { RadiusProps } from "./radius.js";
|
|
4
|
-
import type { MaterialOverrides } from "./material-options.js";
|
|
5
|
-
import type { ShadowOverrides } from "./shadow-options.js";
|
|
6
|
-
/** Shared contract for native text-entry controls. */
|
|
7
|
-
export interface TextControlProps extends Omit<TextFieldProps, ControlOverrides | "isReadOnly">, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
8
|
-
readonly placeholder?: string;
|
|
9
|
-
readonly readOnly?: boolean;
|
|
10
|
-
}
|
package/dist/text-control.js
DELETED
|
File without changes
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from "react";
|
|
2
|
-
import type { ControlTheme } from "./control.js";
|
|
3
|
-
import type { MaterialOverrides } from "./material-options.js";
|
|
4
|
-
import type { ShadowOverrides } from "./shadow-options.js";
|
|
5
|
-
import type { Direction } from "./direction.js";
|
|
6
|
-
/** Shared paint only. Selection, focus, validation, and native input behavior belong to React Aria. */
|
|
7
|
-
export declare function ToggleIndicator({ kind, direction, selected, indeterminate, focused, invalid, hovered, pressed, theme, material: options, shadow }: Readonly<{
|
|
8
|
-
kind: "checkbox" | "radio" | "switch";
|
|
9
|
-
direction?: Direction;
|
|
10
|
-
selected: boolean;
|
|
11
|
-
indeterminate?: boolean;
|
|
12
|
-
focused: boolean;
|
|
13
|
-
invalid?: boolean;
|
|
14
|
-
hovered?: boolean;
|
|
15
|
-
pressed?: boolean;
|
|
16
|
-
theme: ControlTheme;
|
|
17
|
-
} & MaterialOverrides & ShadowOverrides>): import("react").JSX.Element;
|
|
18
|
-
export declare function toggleStyle(theme: ControlTheme, disabled: boolean, readOnly: boolean): CSSProperties;
|
package/dist/toggle-indicator.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { motion } from "motion/react";
|
|
3
|
-
import { Surface } from "./surface.js";
|
|
4
|
-
/** Shared paint only. Selection, focus, validation, and native input behavior belong to React Aria. */
|
|
5
|
-
export function ToggleIndicator({ kind, direction = "ltr", selected, indeterminate = false, focused, invalid = false, hovered = false, pressed = false, theme, material: options, shadow }) {
|
|
6
|
-
const { animations, motionTransition: transition } = theme;
|
|
7
|
-
const diameter = theme.indicatorSize;
|
|
8
|
-
const active = selected || indeterminate;
|
|
9
|
-
const paints = invalid ? theme.paints.danger : active ? theme.paints.palette : theme.paints.subtle;
|
|
10
|
-
const paint = pressed ? paints.pressed : hovered ? paints.hover : paints.rest;
|
|
11
|
-
const radius = kind === "checkbox" ? Math.min(diameter / 4, typeof theme.radius === "number" ? theme.radius : diameter / 4) : diameter;
|
|
12
|
-
const switching = kind === "switch";
|
|
13
|
-
const thumbWidth = diameter - 6 + (pressed && animations ? 3 : 0);
|
|
14
|
-
const travel = (diameter * 2 - thumbWidth) / 2 - 3;
|
|
15
|
-
return _jsx(Surface, { as: motion.span, material: options, shadow: shadow, color: paint.background, "aria-hidden": "true", initial: false, animate: { scale: !animations || switching ? 1 : pressed ? 0.94 : hovered ? 1.03 : 1 }, transition: transition, style: {
|
|
16
|
-
color: paint.color,
|
|
17
|
-
...theme.transition,
|
|
18
|
-
display: "inline-grid",
|
|
19
|
-
placeItems: "center",
|
|
20
|
-
position: "relative",
|
|
21
|
-
boxSizing: "border-box",
|
|
22
|
-
flexShrink: 0,
|
|
23
|
-
width: switching ? diameter * 2 : diameter,
|
|
24
|
-
height: diameter,
|
|
25
|
-
borderRadius: radius,
|
|
26
|
-
border: "none",
|
|
27
|
-
outline: focused ? `1px solid ${theme.focusColor}` : "none",
|
|
28
|
-
outlineOffset: 1,
|
|
29
|
-
}, children: switching ? _jsx(motion.span, { initial: false, animate: { width: thumbWidth, x: (selected ? travel : -travel) * (direction === "rtl" ? -1 : 1) }, transition: transition, style: {
|
|
30
|
-
...theme.transition,
|
|
31
|
-
height: diameter - 6, borderRadius: diameter,
|
|
32
|
-
background: paint.color
|
|
33
|
-
} }) : _jsx(motion.span, { initial: false, animate: { opacity: active ? 1 : 0, scale: active ? 1 : 0.7 }, transition: transition, style: { display: "grid", placeItems: "center" }, children: kind === "radio" ? _jsx("span", { style: { ...theme.transition, width: diameter / 2, height: diameter / 2, borderRadius: "50%", background: "currentColor" } })
|
|
34
|
-
: _jsxs("svg", { width: diameter - 4, height: diameter - 4, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx(motion.path, { d: "m3 8 3 3 7-7", initial: false, animate: { pathLength: selected && !indeterminate ? 1 : 0, opacity: selected && !indeterminate ? 1 : 0 }, transition: transition }), _jsx(motion.path, { d: "M4 8h8", initial: false, animate: { pathLength: indeterminate ? 1 : 0, opacity: indeterminate ? 1 : 0 }, transition: transition })] }) }) });
|
|
35
|
-
}
|
|
36
|
-
export function toggleStyle(theme, disabled, readOnly) {
|
|
37
|
-
return {
|
|
38
|
-
// React Aria's focusable native input is visually hidden with absolute
|
|
39
|
-
// positioning. Anchor it here so focus cannot scroll an ancestor viewport
|
|
40
|
-
// toward a position outside the visible toggle.
|
|
41
|
-
position: "relative",
|
|
42
|
-
display: "flex",
|
|
43
|
-
alignItems: "center",
|
|
44
|
-
gap: theme.gap,
|
|
45
|
-
minHeight: theme.height,
|
|
46
|
-
width: "fit-content",
|
|
47
|
-
cursor: disabled ? "not-allowed" : readOnly ? "default" : "pointer"
|
|
48
|
-
};
|
|
49
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|