@phreshos/react-ui 0.1.35 → 0.1.37
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.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 +12 -24
- package/dist/button.js +34 -39
- 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 +34 -0
- package/dist/control/item.js +53 -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 +22 -8
- 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 +7 -4
- 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} +3 -5
- package/dist/{ui-provider.js → foundation/provider.js} +14 -26
- 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 +27 -16
- 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 +19 -5
- 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 -25
- 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 +6 -0
- package/dist/surface/paint-class.js +36 -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 +73 -0
- package/dist/surface/surface.js +230 -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 +13 -4
- package/dist/tooltip.js +17 -15
- package/dist/tree.d.ts +22 -27
- package/dist/tree.js +54 -99
- package/dist/window.d.ts +2 -2
- 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/material-paint.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
/** The fill, refraction definition, and grain of one Surface. */
|
|
4
|
-
export function MaterialPaint({ color, distortion, grain, grainAmount, identity, opacity, transition }) {
|
|
5
|
-
const grainSeed = useMemo(() => grainSeeds[seedFrom(identity) % grainSeeds.length] ?? grainSeeds[0], [identity]);
|
|
6
|
-
const hasPaint = opacity > 0;
|
|
7
|
-
const hasGrain = hasPaint && grain > 0 && grainAmount > 0;
|
|
8
|
-
const hasDistortion = distortion > 0;
|
|
9
|
-
const grainResource = useMemo(() => hasGrain ? grainImage(grainSeed, grainAmount) : null, [grainSeed, grainAmount, hasGrain]);
|
|
10
|
-
if (!hasPaint && !hasDistortion)
|
|
11
|
-
return null;
|
|
12
|
-
return _jsxs("span", { "data-material-paint": "", "aria-hidden": "true", style: {
|
|
13
|
-
position: "absolute",
|
|
14
|
-
zIndex: -1,
|
|
15
|
-
inset: 0,
|
|
16
|
-
display: "block",
|
|
17
|
-
width: "100%",
|
|
18
|
-
height: "100%",
|
|
19
|
-
overflow: "hidden",
|
|
20
|
-
borderRadius: "inherit",
|
|
21
|
-
pointerEvents: "none"
|
|
22
|
-
}, children: [hasDistortion && _jsx("svg", { width: "0", height: "0", focusable: "false", style: { position: "absolute" }, children: _jsx("defs", { children: _jsx(DistortionFilter, { distortion: distortion, identity: identity }) }) }), hasPaint && _jsx("span", { "data-material-fill": "", "data-material-base": "", style: {
|
|
23
|
-
position: "absolute",
|
|
24
|
-
inset: 0,
|
|
25
|
-
borderRadius: "inherit",
|
|
26
|
-
background: color,
|
|
27
|
-
opacity,
|
|
28
|
-
...transition,
|
|
29
|
-
transitionProperty: "background-color, opacity"
|
|
30
|
-
}, children: hasGrain && _jsx("span", { "data-material-grain": "", style: {
|
|
31
|
-
position: "absolute",
|
|
32
|
-
inset: 0,
|
|
33
|
-
borderRadius: "inherit",
|
|
34
|
-
backgroundImage: grainResource ?? undefined,
|
|
35
|
-
backgroundRepeat: "repeat",
|
|
36
|
-
backgroundSize: `${patternSize}px ${patternSize}px`,
|
|
37
|
-
opacity: grain,
|
|
38
|
-
...transition,
|
|
39
|
-
transitionProperty: "opacity"
|
|
40
|
-
} }) })] });
|
|
41
|
-
}
|
|
42
|
-
function DistortionFilter({ distortion, identity }) {
|
|
43
|
-
return _jsxs("filter", { id: `${identity}-distortion`, "data-material-distortion": "", x: "-20%", y: "-20%", width: "140%", height: "140%", colorInterpolationFilters: "sRGB", children: [_jsx("feTurbulence", { "data-material-distortion-noise": "", "data-material-distortion-field": "organic", type: "fractalNoise", baseFrequency: "0.008 0.008", numOctaves: 2, seed: 92, result: `${identity}-organic-noise` }), _jsx("feGaussianBlur", { in: `${identity}-organic-noise`, stdDeviation: 2, result: `${identity}-organic-noise-blurred` }), _jsx("feDisplacementMap", { "data-material-distortion-stage": "organic", in: "SourceGraphic", in2: `${identity}-organic-noise-blurred`, scale: distortion, xChannelSelector: "R", yChannelSelector: "G" })] });
|
|
44
|
-
}
|
|
45
|
-
function grainImage(seed, amount) {
|
|
46
|
-
const key = `${seed}:${amount}`;
|
|
47
|
-
const cached = grainResources.get(key);
|
|
48
|
-
if (cached !== undefined) {
|
|
49
|
-
grainResources.delete(key);
|
|
50
|
-
grainResources.set(key, cached);
|
|
51
|
-
return cached;
|
|
52
|
-
}
|
|
53
|
-
const paths = grainPaths(seed, amount)
|
|
54
|
-
.map((path, tone) => path
|
|
55
|
-
? `<path d="${path}" fill="rgb(${toneChannel(tone)} ${toneChannel(tone)} ${toneChannel(tone)})"/>`
|
|
56
|
-
: "")
|
|
57
|
-
.join("");
|
|
58
|
-
const resource = `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${patternSize}" height="${patternSize}" viewBox="0 0 ${patternSize} ${patternSize}">${paths}</svg>`)}")`;
|
|
59
|
-
// Preserve the exact texture while avoiding the same expensive SVG generation
|
|
60
|
-
// for every Surface. The bound prevents live grain controls from growing it forever.
|
|
61
|
-
if (grainResources.size >= grainResourceLimit) {
|
|
62
|
-
const oldest = grainResources.keys().next().value;
|
|
63
|
-
if (oldest !== undefined)
|
|
64
|
-
grainResources.delete(oldest);
|
|
65
|
-
}
|
|
66
|
-
grainResources.set(key, resource);
|
|
67
|
-
return resource;
|
|
68
|
-
}
|
|
69
|
-
/** Preserve the original contract: amount is the monotonic density of visible grain pixels. */
|
|
70
|
-
function grainPaths(seed, amount) {
|
|
71
|
-
const tones = Array.from({ length: toneCount }, () => []);
|
|
72
|
-
for (let y = 0; y < patternSize; y += 1) {
|
|
73
|
-
for (let x = 0; x < patternSize; x += 1) {
|
|
74
|
-
const pointX = x + seed * 41;
|
|
75
|
-
const pointY = y + seed * 17;
|
|
76
|
-
const presence = shaderHash(pointX + 71.9, pointY + 13.7);
|
|
77
|
-
if (presence > amount)
|
|
78
|
-
continue;
|
|
79
|
-
const fine = shaderHash(Math.floor(pointX * 1.18), Math.floor(pointY * 1.18));
|
|
80
|
-
const clustered = shaderHash(Math.floor(pointX * 0.47) + 31.7, Math.floor(pointY * 0.47) + 31.7);
|
|
81
|
-
const value = clamp(fine * 0.8 + clustered * 0.2, 0, 1);
|
|
82
|
-
const tone = Math.min(toneCount - 1, Math.floor(value * toneCount));
|
|
83
|
-
tones[tone]?.push(`M${x} ${y}h1v1h-1z`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return tones.map(tone => tone.join(""));
|
|
87
|
-
}
|
|
88
|
-
function toneChannel(tone) {
|
|
89
|
-
return Math.round(tone / (toneCount - 1) * 255);
|
|
90
|
-
}
|
|
91
|
-
function shaderHash(x, y) {
|
|
92
|
-
let red = fract(x * 0.1031);
|
|
93
|
-
let green = fract(y * 0.1031);
|
|
94
|
-
let blue = fract(x * 0.1031);
|
|
95
|
-
const product = red * (green + 33.33) + green * (blue + 33.33) + blue * (red + 33.33);
|
|
96
|
-
red += product;
|
|
97
|
-
green += product;
|
|
98
|
-
blue += product;
|
|
99
|
-
return fract((red + green) * blue);
|
|
100
|
-
}
|
|
101
|
-
function seedFrom(value) {
|
|
102
|
-
let seed = 2166136261;
|
|
103
|
-
for (const character of value) {
|
|
104
|
-
seed ^= character.codePointAt(0) ?? 0;
|
|
105
|
-
seed = Math.imul(seed, 16777619);
|
|
106
|
-
}
|
|
107
|
-
return (seed >>> 0) % 997 + 1;
|
|
108
|
-
}
|
|
109
|
-
function fract(value) {
|
|
110
|
-
return value - Math.floor(value);
|
|
111
|
-
}
|
|
112
|
-
function clamp(value, minimum, maximum) {
|
|
113
|
-
return Math.min(maximum, Math.max(minimum, value));
|
|
114
|
-
}
|
|
115
|
-
const patternSize = 64;
|
|
116
|
-
const toneCount = 16;
|
|
117
|
-
const grainSeeds = [19, 47, 83, 131];
|
|
118
|
-
const grainResourceLimit = 64;
|
|
119
|
-
const grainResources = new Map();
|
package/dist/motion-style.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from "react";
|
|
2
|
-
import type { Transition } from "motion/react";
|
|
3
|
-
import type { AppearanceTransaction } from "./appearance.js";
|
|
4
|
-
export declare function controlTransition(transaction: AppearanceTransaction, animations: boolean): Transition;
|
|
5
|
-
/** Per-overlay variables consumed by the shared entrance keyframes. */
|
|
6
|
-
export declare function overlayTransition(transaction: AppearanceTransaction, animations: boolean): CSSProperties;
|
|
7
|
-
export declare const overlayMotionClass = "phreshos-ui-overlay";
|
|
8
|
-
export declare const backdropMotionClass = "phreshos-ui-backdrop";
|
|
9
|
-
export declare function transitionTiming(transaction: AppearanceTransaction, animations: boolean): CSSProperties;
|
|
10
|
-
export declare function visualTransition(transaction: AppearanceTransaction, animations: boolean): CSSProperties;
|
|
11
|
-
export declare function paintTransition(transaction: AppearanceTransaction, animations: boolean): CSSProperties;
|
|
12
|
-
/** React hoists and deduplicates this stylesheet, including portals. */
|
|
13
|
-
export default function MotionStyle(): import("react").JSX.Element;
|
package/dist/motion-style.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
const visualProperties = "background-color, color, border-color, border-radius, box-shadow";
|
|
3
|
-
const paintProperties = "fill, stroke, opacity";
|
|
4
|
-
export function controlTransition(transaction, animations) {
|
|
5
|
-
return {
|
|
6
|
-
type: "tween",
|
|
7
|
-
duration: animations ? transaction.duration / 1_000 : 0,
|
|
8
|
-
ease: motionEasing(transaction.easing)
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
/** Per-overlay variables consumed by the shared entrance keyframes. */
|
|
12
|
-
export function overlayTransition(transaction, animations) {
|
|
13
|
-
return {
|
|
14
|
-
"--phreshos-ui-motion-duration": `${animations ? transaction.duration : 0}ms`,
|
|
15
|
-
"--phreshos-ui-motion-easing": cssEasing(transaction.easing)
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export const overlayMotionClass = "phreshos-ui-overlay";
|
|
19
|
-
export const backdropMotionClass = "phreshos-ui-backdrop";
|
|
20
|
-
export function transitionTiming(transaction, animations) {
|
|
21
|
-
return {
|
|
22
|
-
transitionDuration: `${animations ? transaction.duration : 0}ms`,
|
|
23
|
-
transitionTimingFunction: cssEasing(transaction.easing)
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export function visualTransition(transaction, animations) {
|
|
27
|
-
return { ...transitionTiming(transaction, animations), transitionProperty: visualProperties };
|
|
28
|
-
}
|
|
29
|
-
export function paintTransition(transaction, animations) {
|
|
30
|
-
return { ...transitionTiming(transaction, animations), transitionProperty: paintProperties };
|
|
31
|
-
}
|
|
32
|
-
function cssEasing(easing) {
|
|
33
|
-
return typeof easing === "string" ? easing : `cubic-bezier(${easing.join(", ")})`;
|
|
34
|
-
}
|
|
35
|
-
function motionEasing(easing) {
|
|
36
|
-
if (typeof easing !== "string")
|
|
37
|
-
return [...easing];
|
|
38
|
-
if (easing === "ease")
|
|
39
|
-
return [0.25, 0.1, 0.25, 1];
|
|
40
|
-
if (easing === "ease-in")
|
|
41
|
-
return "easeIn";
|
|
42
|
-
if (easing === "ease-out")
|
|
43
|
-
return "easeOut";
|
|
44
|
-
if (easing === "ease-in-out")
|
|
45
|
-
return "easeInOut";
|
|
46
|
-
return easing;
|
|
47
|
-
}
|
|
48
|
-
const stylesheet = `
|
|
49
|
-
.phreshos-ui-overlay[data-entering] {
|
|
50
|
-
animation: phreshos-ui-overlay-enter var(--phreshos-ui-motion-duration) var(--phreshos-ui-motion-easing) both;
|
|
51
|
-
}
|
|
52
|
-
.phreshos-ui-overlay[data-exiting] {
|
|
53
|
-
animation: phreshos-ui-overlay-enter var(--phreshos-ui-motion-duration) var(--phreshos-ui-motion-easing) reverse both;
|
|
54
|
-
pointer-events: none;
|
|
55
|
-
}
|
|
56
|
-
.phreshos-ui-backdrop[data-entering] {
|
|
57
|
-
animation: phreshos-ui-backdrop-enter var(--phreshos-ui-motion-duration) var(--phreshos-ui-motion-easing) both;
|
|
58
|
-
}
|
|
59
|
-
.phreshos-ui-backdrop[data-exiting] {
|
|
60
|
-
animation: phreshos-ui-backdrop-enter var(--phreshos-ui-motion-duration) var(--phreshos-ui-motion-easing) reverse both;
|
|
61
|
-
pointer-events: none;
|
|
62
|
-
}
|
|
63
|
-
@keyframes phreshos-ui-overlay-enter {
|
|
64
|
-
from { opacity: 0; scale: 1.05; }
|
|
65
|
-
to { opacity: 1; scale: 1; }
|
|
66
|
-
}
|
|
67
|
-
@keyframes phreshos-ui-backdrop-enter {
|
|
68
|
-
from { opacity: 0; }
|
|
69
|
-
to { opacity: 1; }
|
|
70
|
-
}
|
|
71
|
-
`;
|
|
72
|
-
/** React hoists and deduplicates this stylesheet, including portals. */
|
|
73
|
-
export default function MotionStyle() {
|
|
74
|
-
return _jsx("style", { href: "phreshos-react-ui-motion", precedence: "phreshos", children: stylesheet });
|
|
75
|
-
}
|
package/dist/preferences.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DesktopPreferences } from "@phreshos/core";
|
|
2
|
-
/** Complete environment preferences consumed by React UI. */
|
|
3
|
-
export type Preferences = Pick<DesktopPreferences, "theme" | "animations">;
|
|
4
|
-
/** At least one preference merged with the nearest UIProvider. */
|
|
5
|
-
export type PreferencesUpdate = Readonly<{
|
|
6
|
-
theme: Preferences["theme"];
|
|
7
|
-
animations?: Preferences["animations"];
|
|
8
|
-
}> | Readonly<{
|
|
9
|
-
theme?: Preferences["theme"];
|
|
10
|
-
animations: Preferences["animations"];
|
|
11
|
-
}>;
|
|
12
|
-
export type Theme = Preferences["theme"];
|
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
|