@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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { TextFieldProps } from "react-aria-components";
|
|
3
|
+
import type { RadiusProps } from "../foundation/radius.js";
|
|
4
|
+
import type { MaterialOverrides } from "../surface/material-options.js";
|
|
5
|
+
import type { Color } from "../foundation/color.js";
|
|
6
|
+
import type { ControlMetrics, ControlOverrides, ControlProps, FieldProps } from "./control.js";
|
|
7
|
+
/** Shared contract for native text-entry fields. */
|
|
8
|
+
export interface TextControlProps extends Omit<TextFieldProps, ControlOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides {
|
|
9
|
+
readonly placeholder?: string;
|
|
10
|
+
readonly readOnly?: boolean;
|
|
11
|
+
}
|
|
12
|
+
type FieldState = Readonly<{
|
|
13
|
+
isFocused: boolean;
|
|
14
|
+
isHovered: boolean;
|
|
15
|
+
isInvalid: boolean;
|
|
16
|
+
isDisabled?: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* The recessed well that holds typed content. Native text elements cannot host
|
|
20
|
+
* Surface layers, so the well wraps the element that React Aria renders.
|
|
21
|
+
*/
|
|
22
|
+
export declare function TextWell({ children, color, material, metrics, state, style }: Readonly<{
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
color: Color;
|
|
25
|
+
material: MaterialOverrides["material"];
|
|
26
|
+
metrics: ControlMetrics;
|
|
27
|
+
state: FieldState;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
}>): import("react").JSX.Element;
|
|
30
|
+
/** Layout of the native element inside its well. */
|
|
31
|
+
export declare function nativeTextStyle(metrics: ControlMetrics, multiline: boolean): CSSProperties;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SurfaceView } from "../surface/surface.js";
|
|
3
|
+
/**
|
|
4
|
+
* The recessed well that holds typed content. Native text elements cannot host
|
|
5
|
+
* Surface layers, so the well wraps the element that React Aria renders.
|
|
6
|
+
*/
|
|
7
|
+
export function TextWell({ children, color, material, metrics, state, style }) {
|
|
8
|
+
return _jsx(SurfaceView, { as: "span", color: color, depth: "recessed", material: material, radius: metrics.radius, interaction: { hovered: state.isHovered, focusVisible: state.isFocused, invalid: state.isInvalid }, style: { display: "grid", minWidth: 0, ...style }, children: children });
|
|
9
|
+
}
|
|
10
|
+
/** Layout of the native element inside its well. */
|
|
11
|
+
export function nativeTextStyle(metrics, multiline) {
|
|
12
|
+
return {
|
|
13
|
+
appearance: "none",
|
|
14
|
+
boxSizing: "border-box",
|
|
15
|
+
width: "100%",
|
|
16
|
+
minWidth: 0,
|
|
17
|
+
height: multiline ? "auto" : metrics.height,
|
|
18
|
+
minHeight: metrics.height,
|
|
19
|
+
paddingBlock: multiline ? Math.max(6, metrics.spacing / 2) : 0,
|
|
20
|
+
paddingInline: metrics.inset,
|
|
21
|
+
border: 0,
|
|
22
|
+
borderRadius: "inherit",
|
|
23
|
+
outline: "none",
|
|
24
|
+
background: "transparent",
|
|
25
|
+
color: "inherit",
|
|
26
|
+
caretColor: "currentColor",
|
|
27
|
+
font: "inherit",
|
|
28
|
+
lineHeight: 1.45,
|
|
29
|
+
resize: multiline ? "vertical" : undefined
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import { type Color } from "../foundation/color.js";
|
|
3
|
+
import type { Direction } from "../foundation/direction.js";
|
|
4
|
+
import type { MaterialOverrides } from "../surface/material-options.js";
|
|
5
|
+
import { type Radius } from "../foundation/radius.js";
|
|
6
|
+
import { type ControlMetrics } from "./control.js";
|
|
7
|
+
export type ToggleState = Readonly<{
|
|
8
|
+
selected: boolean;
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
hovered: boolean;
|
|
11
|
+
pressed: boolean;
|
|
12
|
+
focusVisible: boolean;
|
|
13
|
+
invalid: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* The indicator shared by Checkbox, Radio, and Switch. Off, it is a recessed
|
|
18
|
+
* bed; on, the same Surface rises in the owner's color. Its mark is painted in
|
|
19
|
+
* that Surface's readable content color.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ToggleIndicator({ color, direction, kind, material, metrics, radius, state }: Readonly<{
|
|
22
|
+
color: Color;
|
|
23
|
+
direction?: Direction;
|
|
24
|
+
kind: "checkbox" | "radio" | "switch";
|
|
25
|
+
material: MaterialOverrides["material"];
|
|
26
|
+
metrics: ControlMetrics;
|
|
27
|
+
/** A checkbox's corners; radio and switch shapes are round by meaning. */
|
|
28
|
+
radius?: Radius;
|
|
29
|
+
state: ToggleState;
|
|
30
|
+
}>): import("react").JSX.Element;
|
|
31
|
+
/** The pressable row that pairs one indicator with its label. */
|
|
32
|
+
export declare function toggleRowStyle(metrics: ControlMetrics, disabled: boolean, readOnly: boolean): CSSProperties;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { lightColor } from "../foundation/color.js";
|
|
3
|
+
import { SurfaceView } from "../surface/surface.js";
|
|
4
|
+
import { resolveRadius } from "../foundation/radius.js";
|
|
5
|
+
import { isScaleLevel } from "../foundation/scale.js";
|
|
6
|
+
import { proportionalRadius, transition } from "./control.js";
|
|
7
|
+
/**
|
|
8
|
+
* The indicator shared by Checkbox, Radio, and Switch. Off, it is a recessed
|
|
9
|
+
* bed; on, the same Surface rises in the owner's color. Its mark is painted in
|
|
10
|
+
* that Surface's readable content color.
|
|
11
|
+
*/
|
|
12
|
+
export function ToggleIndicator({ color, direction = "ltr", kind, material, metrics, radius, state }) {
|
|
13
|
+
const on = state.selected || state.indeterminate === true;
|
|
14
|
+
const size = metrics.indicator;
|
|
15
|
+
const switching = kind === "switch";
|
|
16
|
+
const width = switching ? Math.round(size * 1.8) : size;
|
|
17
|
+
const thumb = size - 6;
|
|
18
|
+
const stretch = state.pressed && metrics.visual.duration > 0 ? 3 : 0;
|
|
19
|
+
const travel = (width - thumb - 6 - stretch) * (direction === "rtl" ? -1 : 1);
|
|
20
|
+
const interactive = !state.disabled;
|
|
21
|
+
return _jsxs(SurfaceView, { as: "span", "aria-hidden": "true", color: on ? color : "background", depth: on ? "raised" : "recessed", material: material, shadow: on && !switching, radius: kind !== "checkbox"
|
|
22
|
+
? "full"
|
|
23
|
+
: isScaleLevel(radius ?? "medium")
|
|
24
|
+
? proportionalRadius(metrics.visual, size, (radius ?? "medium"))
|
|
25
|
+
: resolveRadius(radius, metrics.visual.radius), interaction: {
|
|
26
|
+
hovered: interactive && state.hovered,
|
|
27
|
+
pressed: interactive && state.pressed,
|
|
28
|
+
focusVisible: state.focusVisible,
|
|
29
|
+
invalid: state.invalid
|
|
30
|
+
}, style: {
|
|
31
|
+
...transition(metrics.visual, "scale, outline-color"),
|
|
32
|
+
display: "inline-grid",
|
|
33
|
+
placeItems: "center",
|
|
34
|
+
flexShrink: 0,
|
|
35
|
+
width,
|
|
36
|
+
height: size,
|
|
37
|
+
scale: state.pressed && interactive && !switching ? "0.92" : "1"
|
|
38
|
+
}, children: [kind === "checkbox" && _jsxs("svg", { viewBox: "0 0 16 16", width: size - 6, height: size - 6, fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "m3 8.5 3 3 7-7", pathLength: 1, style: drawn(metrics, state.selected && state.indeterminate !== true) }), _jsx("path", { d: "M4 8h8", pathLength: 1, style: drawn(metrics, state.indeterminate === true) })] }), kind === "radio" && _jsx("span", { style: {
|
|
39
|
+
...transition(metrics.visual, "scale"),
|
|
40
|
+
width: Math.round(size / 3),
|
|
41
|
+
height: Math.round(size / 3),
|
|
42
|
+
borderRadius: "50%",
|
|
43
|
+
background: "currentColor",
|
|
44
|
+
scale: on ? "1" : "0"
|
|
45
|
+
} }), switching && _jsx(SurfaceView, { as: "span",
|
|
46
|
+
// A thumb is lit from above in every Theme, so it takes the lighter Appearance color.
|
|
47
|
+
color: lightColor(metrics.visual.colors), radius: "full", style: {
|
|
48
|
+
...transition(metrics.visual, "translate, width", 1.2),
|
|
49
|
+
position: "absolute",
|
|
50
|
+
top: 3,
|
|
51
|
+
insetInlineStart: 3,
|
|
52
|
+
zIndex: 2,
|
|
53
|
+
width: thumb + stretch,
|
|
54
|
+
height: thumb,
|
|
55
|
+
translate: on ? `${direction === "rtl" ? -Math.abs(travel) : travel}px 0` : "0 0"
|
|
56
|
+
} })] });
|
|
57
|
+
}
|
|
58
|
+
/** A mark drawn along its path when it appears and withdrawn when it leaves. */
|
|
59
|
+
function drawn(metrics, visible) {
|
|
60
|
+
return {
|
|
61
|
+
...transition(metrics.visual, "stroke-dashoffset", 1.4),
|
|
62
|
+
strokeDasharray: 1,
|
|
63
|
+
strokeDashoffset: visible ? 0 : 1
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** The pressable row that pairs one indicator with its label. */
|
|
67
|
+
export function toggleRowStyle(metrics, disabled, readOnly) {
|
|
68
|
+
return {
|
|
69
|
+
// React Aria visually hides the focusable input with absolute positioning;
|
|
70
|
+
// anchoring it here keeps focus from scrolling an ancestor toward it.
|
|
71
|
+
position: "relative",
|
|
72
|
+
display: "flex",
|
|
73
|
+
alignItems: "center",
|
|
74
|
+
gap: metrics.gap,
|
|
75
|
+
minHeight: Math.max(metrics.indicator, Math.round(metrics.height * 0.75)),
|
|
76
|
+
width: "fit-content",
|
|
77
|
+
cursor: disabled ? "not-allowed" : readOnly ? "default" : "pointer",
|
|
78
|
+
WebkitTapHighlightColor: "transparent"
|
|
79
|
+
};
|
|
80
|
+
}
|
package/dist/date-control.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import { type
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
5
|
-
/**
|
|
6
|
-
export declare function DateControl({ active, children, disabled, end, endFocusVisible, endRequiresVisibleFocus, group, invalid, material,
|
|
2
|
+
import { type ControlMetrics } from "./control/control.js";
|
|
3
|
+
import { type Color } from "./foundation/color.js";
|
|
4
|
+
import type { MaterialOverrides } from "./surface/material-options.js";
|
|
5
|
+
/** The recessed well shared by every date and time field. */
|
|
6
|
+
export declare function DateControl({ active, children, color, disabled, end, endFocusVisible, endRequiresVisibleFocus, group, invalid, material, metrics }: Readonly<{
|
|
7
7
|
active?: boolean;
|
|
8
8
|
children?: ReactNode;
|
|
9
|
+
color: Color;
|
|
9
10
|
disabled: boolean;
|
|
10
11
|
end?: ReactNode;
|
|
11
12
|
endFocusVisible?: boolean;
|
|
@@ -13,12 +14,11 @@ export declare function DateControl({ active, children, disabled, end, endFocusV
|
|
|
13
14
|
group?: boolean;
|
|
14
15
|
invalid: boolean;
|
|
15
16
|
material: MaterialOverrides["material"];
|
|
16
|
-
|
|
17
|
-
theme: ControlTheme;
|
|
17
|
+
metrics: ControlMetrics;
|
|
18
18
|
}>): import("react").JSX.Element;
|
|
19
19
|
/** Segmented input used once for a date and twice for a date range. */
|
|
20
|
-
export declare function DateSegments({ compact,
|
|
20
|
+
export declare function DateSegments({ compact, metrics, slot }: Readonly<{
|
|
21
21
|
compact?: boolean;
|
|
22
|
+
metrics: ControlMetrics;
|
|
22
23
|
slot?: "start" | "end";
|
|
23
|
-
theme: ControlTheme;
|
|
24
24
|
}>): import("react").JSX.Element;
|
package/dist/date-control.js
CHANGED
|
@@ -1,67 +1,64 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { DateInput, DateSegment, Group } from "react-aria-components";
|
|
4
|
-
import { controlOpacity,
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { controlOpacity, transition } from "./control/control.js";
|
|
5
|
+
import { colorLevel, readableColor } from "./foundation/color.js";
|
|
6
|
+
import { SurfaceView } from "./surface/surface.js";
|
|
7
|
+
/** The recessed well shared by every date and time field. */
|
|
8
|
+
export function DateControl({ active = false, children, color, disabled, end, endFocusVisible, endRequiresVisibleFocus = false, group = false, invalid, material, metrics }) {
|
|
8
9
|
const [focused, setFocused] = useState(false);
|
|
9
10
|
const [endFocused, setEndFocused] = useState(false);
|
|
10
11
|
const [hovered, setHovered] = useState(false);
|
|
11
12
|
// Popovers restore trigger focus after pointer dismissal; only keyboard-visible
|
|
12
|
-
// focus on that end control should reactivate the field
|
|
13
|
+
// focus on that end control should reactivate the field.
|
|
13
14
|
const engaged = active || (focused && (!endFocused || !endRequiresVisibleFocus || endFocusVisible === true));
|
|
14
|
-
const paint = controlPaint(theme, engaged, invalid, hovered);
|
|
15
|
-
const style = controlStyle(theme, engaged, invalid, hovered, focused);
|
|
16
|
-
const onBlurCapture = event => {
|
|
17
|
-
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
18
|
-
setFocused(false);
|
|
19
|
-
setEndFocused(false);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
15
|
const surface = {
|
|
23
|
-
color
|
|
16
|
+
color,
|
|
17
|
+
depth: "recessed",
|
|
24
18
|
material,
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
radius: metrics.radius,
|
|
20
|
+
interaction: { hovered, focusVisible: engaged, invalid, disabled },
|
|
27
21
|
onFocusCapture: (event) => {
|
|
28
22
|
setFocused(true);
|
|
29
23
|
setEndFocused(event.target instanceof Element && event.target.closest("[data-date-control-end]") != null);
|
|
30
24
|
},
|
|
31
|
-
onBlurCapture
|
|
25
|
+
onBlurCapture: (event) => {
|
|
26
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
27
|
+
setFocused(false);
|
|
28
|
+
setEndFocused(false);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
32
31
|
onPointerEnter: () => setHovered(true),
|
|
33
32
|
onPointerLeave: () => setHovered(false),
|
|
34
33
|
style: {
|
|
35
|
-
...style,
|
|
36
34
|
display: "flex",
|
|
37
35
|
alignItems: "center",
|
|
36
|
+
boxSizing: "border-box",
|
|
37
|
+
height: metrics.height,
|
|
38
|
+
paddingInline: metrics.inset,
|
|
38
39
|
cursor: disabled ? "not-allowed" : "text"
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
|
-
const content = _jsxs(_Fragment, { children: [children ?? _jsx(DateSegments, {
|
|
42
|
+
const content = _jsxs(_Fragment, { children: [children ?? _jsx(DateSegments, { metrics: metrics }), end] });
|
|
42
43
|
return group
|
|
43
|
-
? _jsx(
|
|
44
|
-
: _jsx(
|
|
44
|
+
? _jsx(SurfaceView, { as: Group, ...surface, children: content })
|
|
45
|
+
: _jsx(SurfaceView, { ...surface, children: content });
|
|
45
46
|
}
|
|
46
47
|
/** Segmented input used once for a date and twice for a date range. */
|
|
47
|
-
export function DateSegments({ compact = false,
|
|
48
|
-
return _jsx(DateInput, { slot: slot, style: {
|
|
49
|
-
display: "flex",
|
|
50
|
-
alignItems: "center",
|
|
51
|
-
flex: compact ? "0 1 auto" : "1 1 auto",
|
|
52
|
-
minWidth: 0
|
|
53
|
-
}, children: segment => _jsx(DateSegment, { segment: segment, style: segmentState => segmentStyle(theme, segmentState) }) });
|
|
48
|
+
export function DateSegments({ compact = false, metrics, slot }) {
|
|
49
|
+
return _jsx(DateInput, { slot: slot, style: { display: "flex", alignItems: "center", flex: compact ? "0 1 auto" : "1 1 auto", minWidth: 0 }, children: segment => _jsx(DateSegment, { segment: segment, style: state => segmentStyle(metrics, state) }) });
|
|
54
50
|
}
|
|
55
|
-
function segmentStyle(
|
|
56
|
-
const
|
|
51
|
+
function segmentStyle(metrics, state) {
|
|
52
|
+
const { colors } = metrics.visual;
|
|
53
|
+
const selected = state.isFocused ? colorLevel(colors.primary, "soft", colors) : null;
|
|
57
54
|
return {
|
|
58
|
-
...
|
|
55
|
+
...transition(metrics.visual, "background-color, color"),
|
|
59
56
|
minWidth: state.type === "literal" ? undefined : "1ch",
|
|
60
57
|
paddingInline: state.type === "literal" ? 0 : 1,
|
|
61
|
-
borderRadius:
|
|
58
|
+
borderRadius: metrics.radius,
|
|
62
59
|
outline: "none",
|
|
63
|
-
background: selected
|
|
64
|
-
color: selected
|
|
60
|
+
background: selected ?? "transparent",
|
|
61
|
+
color: selected === null ? "inherit" : readableColor(selected, colors),
|
|
65
62
|
opacity: state.isPlaceholder ? controlOpacity.placeholder : 1,
|
|
66
63
|
fontVariantNumeric: "tabular-nums",
|
|
67
64
|
textAlign: "center"
|
package/dist/date-field.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { CalendarDate } from "@internationalized/date";
|
|
2
2
|
import type { DateFieldProps as AriaDateFieldProps } from "react-aria-components";
|
|
3
|
-
import type
|
|
4
|
-
import type { MaterialOverrides } from "./material-options.js";
|
|
5
|
-
import type { RadiusProps } from "./radius.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface DateFieldProps extends Omit<AriaDateFieldProps<CalendarDate>, DateFieldOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
3
|
+
import { type ControlOverrides, type ControlProps, type FieldProps } from "./control/control.js";
|
|
4
|
+
import type { MaterialOverrides } from "./surface/material-options.js";
|
|
5
|
+
import type { RadiusProps } from "./foundation/radius.js";
|
|
6
|
+
type DateFieldOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isDateUnavailable" | "granularity" | "hourCycle" | "hideTimeZone" | "shouldForceLeadingZeros";
|
|
7
|
+
export interface DateFieldProps extends Omit<AriaDateFieldProps<CalendarDate>, DateFieldOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides {
|
|
9
8
|
readonly value?: CalendarDate | null;
|
|
10
9
|
readonly defaultValue?: CalendarDate | null;
|
|
11
10
|
readonly onChange?: (value: CalendarDate | null) => void;
|
|
12
11
|
readonly minValue?: CalendarDate | null;
|
|
13
12
|
readonly maxValue?: CalendarDate | null;
|
|
14
13
|
readonly isDateUnavailable?: (date: CalendarDate) => boolean;
|
|
14
|
+
/** Whether hours, days, and months always show two digits. */
|
|
15
|
+
readonly leadingZeros?: boolean;
|
|
15
16
|
readonly readOnly?: boolean;
|
|
16
17
|
}
|
|
17
18
|
/** A locale-aware date-only field whose year, month, and day are edited as independent segments. */
|
package/dist/date-field.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { DateField as AriaDateField } from "react-aria-components";
|
|
4
|
-
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
5
|
-
import {
|
|
4
|
+
import { AriaDirectionBoundary } from "./foundation/aria-direction.js";
|
|
5
|
+
import { useControlMetrics } from "./control/control.js";
|
|
6
|
+
import { FieldFeedback, FieldLabel, fieldStyle } from "./control/field.js";
|
|
6
7
|
import { DateControl } from "./date-control.js";
|
|
7
|
-
import { resolveDirection, useDirection } from "./direction.js";
|
|
8
|
+
import { resolveDirection, useDirection } from "./foundation/direction.js";
|
|
9
|
+
import { dimmedClass } from "./surface/surface.js";
|
|
8
10
|
/** A locale-aware date-only field whose year, month, and day are edited as independent segments. */
|
|
9
|
-
export const DateField = forwardRef(function DateField({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, material,
|
|
10
|
-
const
|
|
11
|
+
export const DateField = forwardRef(function DateField({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, material, style, className, isDateUnavailable, leadingZeros, ...properties }, ref) {
|
|
12
|
+
const metrics = useControlMetrics(size, radius);
|
|
11
13
|
const direction = resolveDirection(properties.dir, useDirection());
|
|
12
|
-
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaDateField, { ...properties, ref: ref, dir: direction, className: className, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null ? undefined : date => isDateUnavailable(date), style: fieldStyle(
|
|
14
|
+
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaDateField, { ...properties, ref: ref, dir: direction, className: dimmedClass(disabled ?? false, className), isDisabled: disabled, isReadOnly: readOnly, shouldForceLeadingZeros: leadingZeros, isRequired: required, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null ? undefined : date => isDateUnavailable(date), style: fieldStyle(metrics, style), children: state => _jsxs(_Fragment, { children: [_jsx(FieldLabel, { label: label }), _jsx(DateControl, { disabled: state.isDisabled, invalid: state.isInvalid, material: material, color: color ?? "background", metrics: metrics }), _jsx(FieldFeedback, { metrics: metrics, description: description, errorMessage: errorMessage })] }) }) });
|
|
13
15
|
});
|
package/dist/date-picker.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import type { CalendarDate } from "@internationalized/date";
|
|
2
2
|
import type { DatePickerProps as AriaDatePickerProps } from "react-aria-components";
|
|
3
|
-
import { type ControlOverrides, type ControlProps, type FieldProps } from "./control.js";
|
|
4
|
-
import type { MaterialOverrides } from "./material-options.js";
|
|
5
|
-
import type { RadiusProps } from "./radius.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface DatePickerProps extends Omit<AriaDatePickerProps<CalendarDate>, DatePickerOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
3
|
+
import { type ControlOverrides, type ControlProps, type FieldProps } from "./control/control.js";
|
|
4
|
+
import type { MaterialOverrides } from "./surface/material-options.js";
|
|
5
|
+
import type { RadiusProps } from "./foundation/radius.js";
|
|
6
|
+
type DatePickerOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isDateUnavailable" | "granularity" | "hourCycle" | "hideTimeZone" | "isOpen" | "defaultOpen" | "onOpenChange" | "shouldCloseOnSelect" | "shouldForceLeadingZeros";
|
|
7
|
+
export interface DatePickerProps extends Omit<AriaDatePickerProps<CalendarDate>, DatePickerOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides {
|
|
9
8
|
readonly value?: CalendarDate | null;
|
|
10
9
|
readonly defaultValue?: CalendarDate | null;
|
|
11
10
|
readonly onChange?: (value: CalendarDate | null) => void;
|
|
12
11
|
readonly minValue?: CalendarDate | null;
|
|
13
12
|
readonly maxValue?: CalendarDate | null;
|
|
14
13
|
readonly isDateUnavailable?: (date: CalendarDate) => boolean;
|
|
14
|
+
/** Whether the calendar popover is shown. */
|
|
15
|
+
readonly open?: boolean;
|
|
16
|
+
readonly defaultOpen?: boolean;
|
|
17
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
18
|
+
/** Whether choosing a date closes the calendar. Defaults to `true`. */
|
|
19
|
+
readonly closeOnSelect?: boolean;
|
|
20
|
+
/** Whether hours, days, and months always show two digits. */
|
|
21
|
+
readonly leadingZeros?: boolean;
|
|
15
22
|
readonly readOnly?: boolean;
|
|
16
23
|
}
|
|
17
24
|
/** A date-only segmented field with a calendar selection popover. */
|
package/dist/date-picker.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { DatePicker as AriaDatePicker } from "react-aria-components";
|
|
4
|
-
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
4
|
+
import { AriaDirectionBoundary } from "./foundation/aria-direction.js";
|
|
5
5
|
import { Calendar } from "./calendar.js";
|
|
6
6
|
import { CalendarTrigger } from "./calendar-trigger.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ariaOpenState } from "./control/open-state.js";
|
|
8
|
+
import { useControlMetrics } from "./control/control.js";
|
|
9
|
+
import { FieldFeedback, FieldLabel, fieldStyle } from "./control/field.js";
|
|
8
10
|
import { DateControl } from "./date-control.js";
|
|
9
|
-
import { resolveDirection, useDirection } from "./direction.js";
|
|
11
|
+
import { resolveDirection, useDirection } from "./foundation/direction.js";
|
|
10
12
|
import { PopoverContent, PopoverDialog } from "./popover.js";
|
|
13
|
+
import { dimmedClass } from "./surface/surface.js";
|
|
11
14
|
/** A date-only segmented field with a calendar selection popover. */
|
|
12
|
-
export const DatePicker = forwardRef(function DatePicker({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, material,
|
|
13
|
-
const
|
|
15
|
+
export const DatePicker = forwardRef(function DatePicker({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, material, style, className, isDateUnavailable, open, defaultOpen, onOpenChange, closeOnSelect, leadingZeros, ...properties }, ref) {
|
|
16
|
+
const metrics = useControlMetrics(size, radius);
|
|
14
17
|
const direction = resolveDirection(properties.dir, useDirection());
|
|
15
|
-
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaDatePicker, { ...properties, ref: ref, dir: direction, className: className, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null ? undefined : date => isDateUnavailable(date), style: fieldStyle(
|
|
18
|
+
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaDatePicker, { ...properties, ref: ref, dir: direction, className: dimmedClass(disabled ?? false, className), isDisabled: disabled, isReadOnly: readOnly, ...ariaOpenState({ open, defaultOpen, onOpenChange }), shouldCloseOnSelect: closeOnSelect, shouldForceLeadingZeros: leadingZeros, isRequired: required, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null ? undefined : date => isDateUnavailable(date), style: fieldStyle(metrics, style), children: state => _jsxs(_Fragment, { children: [_jsx(FieldLabel, { label: label }), _jsx(DateControl, { active: state.isOpen, disabled: state.isDisabled, endFocusVisible: state.isFocusVisible, endRequiresVisibleFocus: true, group: true, invalid: state.isInvalid, material: material, color: color ?? "background", metrics: metrics, end: _jsx(CalendarTrigger, { metrics: metrics }) }), _jsx(FieldFeedback, { metrics: metrics, description: description, errorMessage: errorMessage }), _jsx(PopoverContent, { placement: "bottom start", children: _jsx(PopoverDialog, { children: _jsx(Calendar, { size: size, radius: radius }) }) })] }) }) });
|
|
16
19
|
});
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import type { CalendarDate } from "@internationalized/date";
|
|
2
2
|
import type { DateRangePickerProps as AriaDateRangePickerProps } from "react-aria-components";
|
|
3
|
-
import { type ControlOverrides, type ControlProps, type FieldProps } from "./control.js";
|
|
3
|
+
import { type ControlOverrides, type ControlProps, type FieldProps } from "./control/control.js";
|
|
4
4
|
import type { DateRange } from "./date-range.js";
|
|
5
|
-
import type { MaterialOverrides } from "./material-options.js";
|
|
6
|
-
import type { RadiusProps } from "./radius.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface DateRangePickerProps extends Omit<AriaDateRangePickerProps<CalendarDate>, DateRangePickerOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
5
|
+
import type { MaterialOverrides } from "./surface/material-options.js";
|
|
6
|
+
import type { RadiusProps } from "./foundation/radius.js";
|
|
7
|
+
type DateRangePickerOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isDateUnavailable" | "granularity" | "hourCycle" | "hideTimeZone" | "isOpen" | "defaultOpen" | "onOpenChange" | "shouldCloseOnSelect" | "shouldForceLeadingZeros" | "allowsNonContiguousRanges";
|
|
8
|
+
export interface DateRangePickerProps extends Omit<AriaDateRangePickerProps<CalendarDate>, DateRangePickerOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides {
|
|
10
9
|
readonly value?: DateRange | null;
|
|
11
10
|
readonly defaultValue?: DateRange | null;
|
|
12
11
|
readonly onChange?: (value: DateRange | null) => void;
|
|
13
12
|
readonly minValue?: CalendarDate | null;
|
|
14
13
|
readonly maxValue?: CalendarDate | null;
|
|
15
14
|
readonly isDateUnavailable?: (date: CalendarDate, anchorDate: CalendarDate | null) => boolean;
|
|
15
|
+
/** Whether the calendar popover is shown. */
|
|
16
|
+
readonly open?: boolean;
|
|
17
|
+
readonly defaultOpen?: boolean;
|
|
18
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
19
|
+
/** Whether choosing a date closes the calendar. Defaults to `true`. */
|
|
20
|
+
readonly closeOnSelect?: boolean;
|
|
21
|
+
/** Whether hours, days, and months always show two digits. */
|
|
22
|
+
readonly leadingZeros?: boolean;
|
|
23
|
+
/** Whether a range may include unavailable dates. */
|
|
24
|
+
readonly nonContiguous?: boolean;
|
|
16
25
|
readonly readOnly?: boolean;
|
|
17
26
|
}
|
|
18
27
|
/** Two date-only segmented fields backed by one inclusive range calendar. */
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { DateRangePicker as AriaDateRangePicker } from "react-aria-components";
|
|
4
|
-
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
4
|
+
import { AriaDirectionBoundary } from "./foundation/aria-direction.js";
|
|
5
5
|
import { CalendarTrigger } from "./calendar-trigger.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ariaOpenState } from "./control/open-state.js";
|
|
7
|
+
import { controlOpacity, useControlMetrics } from "./control/control.js";
|
|
8
|
+
import { FieldFeedback, FieldLabel, fieldStyle } from "./control/field.js";
|
|
7
9
|
import { DateControl, DateSegments } from "./date-control.js";
|
|
8
|
-
import { resolveDirection, useDirection } from "./direction.js";
|
|
10
|
+
import { resolveDirection, useDirection } from "./foundation/direction.js";
|
|
9
11
|
import { PopoverContent, PopoverDialog } from "./popover.js";
|
|
10
12
|
import { RangeCalendar } from "./range-calendar.js";
|
|
13
|
+
import { dimmedClass } from "./surface/surface.js";
|
|
11
14
|
/** Two date-only segmented fields backed by one inclusive range calendar. */
|
|
12
|
-
export const DateRangePicker = forwardRef(function DateRangePicker({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, material,
|
|
13
|
-
const
|
|
15
|
+
export const DateRangePicker = forwardRef(function DateRangePicker({ label, description, errorMessage, disabled, readOnly, required, invalid, size, color, radius, material, style, className, isDateUnavailable, open, defaultOpen, onOpenChange, closeOnSelect, leadingZeros, nonContiguous, ...properties }, ref) {
|
|
16
|
+
const metrics = useControlMetrics(size, radius);
|
|
14
17
|
const direction = resolveDirection(properties.dir, useDirection());
|
|
15
|
-
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaDateRangePicker, { ...properties, ref: ref, dir: direction, className: className, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null
|
|
18
|
+
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaDateRangePicker, { ...properties, ref: ref, dir: direction, className: dimmedClass(disabled ?? false, className), isDisabled: disabled, isReadOnly: readOnly, ...ariaOpenState({ open, defaultOpen, onOpenChange }), shouldCloseOnSelect: closeOnSelect, shouldForceLeadingZeros: leadingZeros, allowsNonContiguousRanges: nonContiguous, isRequired: required, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null
|
|
16
19
|
? undefined
|
|
17
|
-
: (date, anchorDate) => isDateUnavailable(date, anchorDate), style: fieldStyle(
|
|
20
|
+
: (date, anchorDate) => isDateUnavailable(date, anchorDate), style: fieldStyle(metrics, style), children: state => _jsxs(_Fragment, { children: [_jsx(FieldLabel, { label: label }), _jsx(DateControl, { active: state.isOpen, disabled: state.isDisabled, endFocusVisible: state.isFocusVisible, endRequiresVisibleFocus: true, group: true, invalid: state.isInvalid, material: material, color: color ?? "background", metrics: metrics, end: _jsx(CalendarTrigger, { metrics: metrics }), children: _jsxs("div", { style: {
|
|
18
21
|
display: "flex",
|
|
19
22
|
alignItems: "center",
|
|
20
23
|
justifyContent: "flex-start",
|
|
21
24
|
flex: "1 1 auto",
|
|
22
25
|
minWidth: 0,
|
|
23
|
-
gap: Math.max(2,
|
|
24
|
-
}, children: [_jsx(DateSegments, { compact: true, slot: "start",
|
|
26
|
+
gap: Math.max(2, metrics.gap / 2)
|
|
27
|
+
}, children: [_jsx(DateSegments, { compact: true, slot: "start", metrics: metrics }), _jsx("span", { "aria-hidden": "true", style: { flex: "0 0 auto", opacity: controlOpacity.secondary }, children: "\u2013" }), _jsx(DateSegments, { compact: true, slot: "end", metrics: metrics })] }) }), _jsx(FieldFeedback, { metrics: metrics, description: description, errorMessage: errorMessage }), _jsx(PopoverContent, { placement: "bottom start", children: _jsx(PopoverDialog, { children: _jsx(RangeCalendar, { size: size, radius: radius }) }) })] }) }) });
|
|
25
28
|
});
|
package/dist/dialog.d.ts
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import type { ComponentProps, CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import type { DialogProps as AriaDialogProps,
|
|
3
|
-
import { type
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
2
|
+
import type { DialogProps as AriaDialogProps, HeadingProps as AriaHeadingProps, ModalOverlayProps as AriaModalOverlayProps, TextProps as AriaTextProps } from "react-aria-components";
|
|
3
|
+
import { type ButtonActionProps } from "./button.js";
|
|
4
|
+
import { type AriaOverlayInternals, type OverlayRootProps } from "./control/open-state.js";
|
|
5
|
+
import { type Direction } from "./foundation/direction.js";
|
|
6
|
+
import { type SurfaceOwnProps } from "./surface/surface.js";
|
|
7
|
+
export type DialogRootProps = OverlayRootProps;
|
|
8
|
+
export declare function DialogRoot({ children, ...state }: DialogRootProps): import("react").JSX.Element;
|
|
9
|
+
export type DialogTriggerProps = ButtonActionProps;
|
|
10
|
+
export declare const DialogTrigger: import("react").ForwardRefExoticComponent<ButtonActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
/**
|
|
12
|
+
* The layer behind a Dialog. Its open state belongs to the Dialog root; the
|
|
13
|
+
* backdrop only decides how the Dialog may be dismissed.
|
|
14
|
+
*/
|
|
15
|
+
export interface DialogBackdropProps extends Omit<AriaModalOverlayProps, AriaOverlayInternals | "children" | "className" | "color" | "style" | "dir"> {
|
|
11
16
|
readonly children?: ReactNode;
|
|
12
17
|
readonly className?: string;
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
readonly dir?: Direction;
|
|
19
|
+
/** Whether pressing outside the Dialog closes it. */
|
|
20
|
+
readonly dismissable?: boolean;
|
|
21
|
+
/** Whether Escape closes the Dialog. */
|
|
22
|
+
readonly keyboardDismissable?: boolean;
|
|
15
23
|
readonly style?: CSSProperties;
|
|
24
|
+
/**
|
|
25
|
+
* How the interface behind the Dialog is held back: `dim` darkens it, and
|
|
26
|
+
* `blur` blurs it with the Appearance material while darkening it lightly.
|
|
27
|
+
*/
|
|
28
|
+
readonly variant?: DialogBackdropVariant;
|
|
16
29
|
}
|
|
30
|
+
export type DialogBackdropVariant = "dim" | "blur";
|
|
17
31
|
export declare const DialogBackdrop: import("react").ForwardRefExoticComponent<DialogBackdropProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
18
32
|
export interface DialogContentProps extends Omit<AriaDialogProps, "children" | "className" | "style">, SurfaceOwnProps {
|
|
19
33
|
readonly children?: AriaDialogProps["children"];
|
|
@@ -31,11 +45,11 @@ export type DialogBodyProps = HTMLAttributes<HTMLDivElement>;
|
|
|
31
45
|
export declare const DialogBody: import("react").ForwardRefExoticComponent<DialogBodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
46
|
export type DialogFooterProps = HTMLAttributes<HTMLDivElement>;
|
|
33
47
|
export declare const DialogFooter: import("react").ForwardRefExoticComponent<DialogFooterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
-
export type DialogCloseProps =
|
|
35
|
-
export declare const DialogClose: import("react").ForwardRefExoticComponent<
|
|
48
|
+
export type DialogCloseProps = ButtonActionProps;
|
|
49
|
+
export declare const DialogClose: import("react").ForwardRefExoticComponent<ButtonActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
36
50
|
/** A modal dialog whose behavioral and structural roles remain independently composable. */
|
|
37
51
|
export declare const Dialog: typeof DialogRoot & {
|
|
38
|
-
Trigger: import("react").ForwardRefExoticComponent<
|
|
52
|
+
Trigger: import("react").ForwardRefExoticComponent<ButtonActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
39
53
|
Backdrop: import("react").ForwardRefExoticComponent<DialogBackdropProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
40
54
|
Content: import("react").ForwardRefExoticComponent<DialogContentProps & import("react").RefAttributes<HTMLElement>>;
|
|
41
55
|
Header: import("react").ForwardRefExoticComponent<DialogHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -43,6 +57,6 @@ export declare const Dialog: typeof DialogRoot & {
|
|
|
43
57
|
Description: import("react").ForwardRefExoticComponent<AriaTextProps & import("react").RefAttributes<HTMLElement>>;
|
|
44
58
|
Body: import("react").ForwardRefExoticComponent<DialogBodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
59
|
Footer: import("react").ForwardRefExoticComponent<DialogFooterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
-
Close: import("react").ForwardRefExoticComponent<
|
|
60
|
+
Close: import("react").ForwardRefExoticComponent<ButtonActionProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
47
61
|
};
|
|
48
62
|
export type DialogProps = ComponentProps<typeof DialogRoot>;
|