@phreshos/react-ui 0.1.30 → 0.1.32
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 +162 -18
- package/dist/accordion.d.ts +45 -0
- package/dist/accordion.js +62 -0
- package/dist/alert-dialog.d.ts +0 -1
- package/dist/alert-dialog.js +0 -1
- package/dist/appearance.d.ts +6 -1
- package/dist/aria-direction.d.ts +9 -0
- package/dist/aria-direction.js +49 -0
- package/dist/calendar-layout.d.ts +8 -0
- package/dist/calendar-layout.js +103 -0
- package/dist/calendar-trigger.d.ts +5 -0
- package/dist/calendar-trigger.js +30 -0
- package/dist/calendar.d.ts +18 -0
- package/dist/calendar.js +13 -0
- package/dist/color.d.ts +16 -1
- package/dist/color.js +60 -11
- package/dist/combo-box.d.ts +20 -0
- package/dist/combo-box.js +68 -0
- package/dist/context-menu.d.ts +2 -4
- package/dist/context-menu.js +0 -1
- package/dist/control-surface.d.ts +2 -1
- package/dist/control-surface.js +2 -2
- package/dist/control.d.ts +1 -1
- package/dist/control.js +7 -8
- package/dist/date-control.d.ts +24 -0
- package/dist/date-control.js +69 -0
- package/dist/date-field.d.ts +19 -0
- package/dist/date-field.js +13 -0
- package/dist/date-picker.d.ts +19 -0
- package/dist/date-picker.js +16 -0
- package/dist/date-range-picker.d.ts +20 -0
- package/dist/date-range-picker.js +25 -0
- package/dist/date-range.d.ts +6 -0
- package/dist/date-range.js +0 -0
- package/dist/dialog.d.ts +4 -2
- package/dist/dialog.js +24 -7
- package/dist/disclosure.d.ts +42 -0
- package/dist/disclosure.js +97 -0
- package/dist/dropdown-menu.d.ts +0 -2
- package/dist/dropdown-menu.js +0 -1
- package/dist/list-box.d.ts +49 -0
- package/dist/list-box.js +129 -0
- package/dist/main.d.ts +27 -11
- package/dist/main.js +25 -9
- package/dist/material-paint.js +19 -1
- package/dist/menu.d.ts +22 -4
- package/dist/menu.js +25 -6
- package/dist/panel.d.ts +0 -1
- package/dist/panel.js +0 -1
- package/dist/popover.d.ts +0 -1
- package/dist/popover.js +13 -3
- package/dist/preferences.d.ts +8 -0
- package/dist/progress-bar.d.ts +22 -0
- package/dist/progress-bar.js +46 -0
- package/dist/radio.d.ts +5 -5
- package/dist/radio.js +8 -4
- package/dist/radius.js +1 -1
- package/dist/range-calendar.d.ts +19 -0
- package/dist/range-calendar.js +15 -0
- package/dist/scroll-area.d.ts +4 -1
- package/dist/scroll-area.js +3 -3
- package/dist/select.js +4 -14
- package/dist/selection.d.ts +18 -0
- package/dist/selection.js +28 -0
- package/dist/slider.js +1 -1
- package/dist/spacing.js +1 -1
- package/dist/table.d.ts +78 -0
- package/dist/table.js +148 -0
- package/dist/tabs.d.ts +45 -0
- package/dist/tabs.js +103 -0
- package/dist/time-field.d.ts +22 -0
- package/dist/time-field.js +13 -0
- package/dist/toggle-indicator.js +1 -1
- package/dist/toolbar.d.ts +46 -0
- package/dist/toolbar.js +121 -0
- package/dist/tooltip.d.ts +0 -1
- package/dist/tooltip.js +0 -1
- package/dist/tree.d.ts +56 -0
- package/dist/tree.js +134 -0
- package/dist/ui-provider.d.ts +4 -4
- package/dist/ui-provider.js +47 -8
- package/dist/window.d.ts +6 -3
- package/dist/window.js +10 -7
- package/package.json +4 -2
package/dist/calendar.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Calendar as AriaCalendar } from "react-aria-components";
|
|
4
|
+
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
5
|
+
import { CalendarLayout, calendarRootStyle } from "./calendar-layout.js";
|
|
6
|
+
import { useControlTheme } from "./control.js";
|
|
7
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
8
|
+
/** A locale-aware, keyboard-navigable month view for selecting one date. */
|
|
9
|
+
export const Calendar = forwardRef(function Calendar({ disabled, readOnly, invalid, size, color, radius, style, className, isDateUnavailable, ...properties }, ref) {
|
|
10
|
+
const theme = useControlTheme({ size, color, radius });
|
|
11
|
+
const direction = resolveDirection(properties.dir, useDirection());
|
|
12
|
+
return _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaCalendar, { ...properties, ref: ref, dir: direction, className: className, isDisabled: disabled, isReadOnly: readOnly, isInvalid: invalid, isDateUnavailable: isDateUnavailable == null ? undefined : date => isDateUnavailable(date), style: calendarRootStyle(theme, disabled, style), children: _jsx(CalendarLayout, { color: color, size: size, theme: theme }) }) });
|
|
13
|
+
});
|
package/dist/color.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function orderColors(first: string, second: string): {
|
|
|
31
31
|
export declare function opaqueColor(value: string): string;
|
|
32
32
|
/** Changes only perceptual lightness; theme names never determine direction. */
|
|
33
33
|
export declare function colorShade(value: string, amount: number): string;
|
|
34
|
-
/** Chooses
|
|
34
|
+
/** Chooses the perceptually opposite Appearance color for the actual painted fill. */
|
|
35
35
|
export declare function onColor(fill: string, background: string, foreground: string): string;
|
|
36
36
|
/** Chooses readable content when the fill can be evaluated, otherwise preserves Appearance foreground. */
|
|
37
37
|
export declare function contrastingColor(value: Color, colors: AppearanceColors): string;
|
|
@@ -50,3 +50,18 @@ export declare function solidColors(base: string, background: string, foreground
|
|
|
50
50
|
color: string;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
/** Low-emphasis interaction paints derived from the same component-owned base. */
|
|
54
|
+
export declare function subtleColors(base: string, background: string, foreground: string): {
|
|
55
|
+
rest: {
|
|
56
|
+
background: string;
|
|
57
|
+
color: string;
|
|
58
|
+
};
|
|
59
|
+
hover: {
|
|
60
|
+
background: string;
|
|
61
|
+
color: string;
|
|
62
|
+
};
|
|
63
|
+
pressed: {
|
|
64
|
+
background: string;
|
|
65
|
+
color: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
package/dist/color.js
CHANGED
|
@@ -5,7 +5,6 @@ import parse from "colorjs.io/src/parse.js";
|
|
|
5
5
|
import serialize from "colorjs.io/src/serialize.js";
|
|
6
6
|
import to from "colorjs.io/src/to.js";
|
|
7
7
|
import toGamut from "colorjs.io/src/toGamut.js";
|
|
8
|
-
import contrastWCAG21 from "colorjs.io/src/contrast/WCAG21.js";
|
|
9
8
|
import sRGB from "colorjs.io/src/spaces/srgb.js";
|
|
10
9
|
import sRGB_Linear from "colorjs.io/src/spaces/srgb-linear.js";
|
|
11
10
|
import HSL from "colorjs.io/src/spaces/hsl.js";
|
|
@@ -51,9 +50,12 @@ export function color(value) {
|
|
|
51
50
|
/** Resolves the same named treatment for solid paint and contrast calculations. */
|
|
52
51
|
export function resolveColorLevel(value, level) {
|
|
53
52
|
if (level === "base")
|
|
54
|
-
return
|
|
53
|
+
return resolvableOpaqueColor(value) ?? value;
|
|
54
|
+
const opaque = resolvableOpaqueColor(value);
|
|
55
|
+
if (opaque == null)
|
|
56
|
+
return color(value)[level];
|
|
55
57
|
const { weight, target } = treatments[level];
|
|
56
|
-
return opaqueColor(serialize(mix(
|
|
58
|
+
return opaqueColor(serialize(mix(opaque, target, 1 - weight / 100, { space: "oklch" })));
|
|
57
59
|
}
|
|
58
60
|
/** Returns the complete visual treatments derived from one concrete color. */
|
|
59
61
|
export function useColor(value) {
|
|
@@ -68,7 +70,7 @@ export function resolveColor(value, colors) {
|
|
|
68
70
|
/** Resolves opaque control paint from an already selected Appearance branch. */
|
|
69
71
|
export function resolveSolidColor(value, colors) {
|
|
70
72
|
const semantic = parseSemanticColor(value, colors);
|
|
71
|
-
return semantic ? resolveColorLevel(semantic.source, semantic.level) :
|
|
73
|
+
return semantic ? resolveColorLevel(semantic.source, semantic.level) : resolvableOpaqueColor(value) ?? value;
|
|
72
74
|
}
|
|
73
75
|
/** Applies material opacity without restricting the source CSS color syntax. */
|
|
74
76
|
export function colorOpacity(value, opacity) {
|
|
@@ -98,11 +100,15 @@ export function colorShade(value, amount) {
|
|
|
98
100
|
result.coords[0] = Math.max(0, Math.min(1, lightness + (lightness > 0.6 ? -amount : amount)));
|
|
99
101
|
return opaqueColor(serialize(result));
|
|
100
102
|
}
|
|
101
|
-
/** Chooses
|
|
103
|
+
/** Chooses the perceptually opposite Appearance color for the actual painted fill. */
|
|
102
104
|
export function onColor(fill, background, foreground) {
|
|
103
105
|
const first = opaqueColor(background);
|
|
104
106
|
const second = opaqueColor(foreground);
|
|
105
|
-
|
|
107
|
+
const candidates = orderColors(first, second);
|
|
108
|
+
const darker = colorLightness(candidates.darker);
|
|
109
|
+
const lighter = colorLightness(candidates.lighter);
|
|
110
|
+
const threshold = darker + (lighter - darker) * 2 / 3;
|
|
111
|
+
return colorLightness(opaqueColor(fill)) < threshold ? candidates.lighter : candidates.darker;
|
|
106
112
|
}
|
|
107
113
|
/** Chooses readable content when the fill can be evaluated, otherwise preserves Appearance foreground. */
|
|
108
114
|
export function contrastingColor(value, colors) {
|
|
@@ -116,14 +122,57 @@ export function contrastingColor(value, colors) {
|
|
|
116
122
|
/** Solid controls start at base; interaction shades preserve its text choice. */
|
|
117
123
|
export function solidColors(base, background, foreground) {
|
|
118
124
|
const fill = resolveColorLevel(base, "base");
|
|
119
|
-
const
|
|
120
|
-
const paint = (background) => ({ background, color });
|
|
125
|
+
const content = resolvableOnColor(fill, background, foreground) ?? foreground;
|
|
126
|
+
const paint = (background) => ({ background, color: content });
|
|
127
|
+
const concrete = resolvableOpaqueColor(fill);
|
|
128
|
+
if (concrete == null)
|
|
129
|
+
return {
|
|
130
|
+
rest: paint(fill),
|
|
131
|
+
hover: paint(cssInteractionColor(fill, foreground, 0.045)),
|
|
132
|
+
pressed: paint(cssInteractionColor(fill, foreground, 0.085))
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
rest: paint(concrete),
|
|
136
|
+
hover: paint(colorShade(concrete, 0.045)),
|
|
137
|
+
pressed: paint(colorShade(concrete, 0.085))
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Low-emphasis interaction paints derived from the same component-owned base. */
|
|
141
|
+
export function subtleColors(base, background, foreground) {
|
|
142
|
+
const fill = resolveColorLevel(base, "base");
|
|
143
|
+
const canvas = resolvableOpaqueColor(background) ?? background;
|
|
144
|
+
const concrete = resolvableOpaqueColor(fill);
|
|
145
|
+
const paint = (weight) => {
|
|
146
|
+
const mixed = concrete == null
|
|
147
|
+
? `color-mix(in oklch, ${canvas} ${Math.round((1 - weight) * 10_000) / 100}%, ${fill})`
|
|
148
|
+
: opaqueColor(serialize(mix(canvas, concrete, weight, { space: "oklch" })));
|
|
149
|
+
return { background: mixed, color: resolvableOnColor(mixed, background, foreground) ?? foreground };
|
|
150
|
+
};
|
|
121
151
|
return {
|
|
122
|
-
rest: paint(
|
|
123
|
-
hover: paint(
|
|
124
|
-
pressed: paint(
|
|
152
|
+
rest: paint(0.25),
|
|
153
|
+
hover: paint(0.5),
|
|
154
|
+
pressed: paint(0.65)
|
|
125
155
|
};
|
|
126
156
|
}
|
|
157
|
+
function resolvableOpaqueColor(value) {
|
|
158
|
+
try {
|
|
159
|
+
return opaqueColor(value);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function resolvableOnColor(fill, background, foreground) {
|
|
166
|
+
try {
|
|
167
|
+
return onColor(fill, background, foreground);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function cssInteractionColor(base, target, amount) {
|
|
174
|
+
return `color-mix(in oklch, ${base} ${Math.round((1 - amount) * 10_000) / 100}%, ${target})`;
|
|
175
|
+
}
|
|
127
176
|
function parseSemanticColor(value, colors) {
|
|
128
177
|
const separator = value.indexOf(":");
|
|
129
178
|
if (separator < 0 || value.indexOf(":", separator + 1) >= 0)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComboBoxProps as AriaComboBoxProps } from "react-aria-components";
|
|
2
|
+
import type { ControlOverrides, ControlProps, FieldProps } from "./control.js";
|
|
3
|
+
import type { MaterialOverrides } from "./material-options.js";
|
|
4
|
+
import type { RadiusProps } from "./radius.js";
|
|
5
|
+
import type { SelectOption } from "./select.js";
|
|
6
|
+
import type { ShadowOverrides } from "./shadow-options.js";
|
|
7
|
+
export type ComboBoxOption = SelectOption;
|
|
8
|
+
export interface ComboBoxProps extends Omit<AriaComboBoxProps<ComboBoxOption>, ControlOverrides | "allowsCustomValue" | "defaultItems" | "defaultInputValue" | "defaultSelectedKey" | "defaultValue" | "disabledKeys" | "inputValue" | "isReadOnly" | "items" | "onChange" | "onInputChange" | "onSelectionChange" | "selectedKey" | "selectionMode" | "value">, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
9
|
+
readonly options: readonly ComboBoxOption[];
|
|
10
|
+
readonly value?: string | null;
|
|
11
|
+
readonly defaultValue?: string | null;
|
|
12
|
+
readonly onChange?: (value: string | null) => void;
|
|
13
|
+
readonly inputValue?: string;
|
|
14
|
+
readonly defaultInputValue?: string;
|
|
15
|
+
readonly onInputChange?: (value: string) => void;
|
|
16
|
+
readonly placeholder?: string;
|
|
17
|
+
readonly readOnly?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** A searchable single-selection field whose query filters string-valued options. */
|
|
20
|
+
export declare const ComboBox: import("react").ForwardRefExoticComponent<ComboBoxProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import { Button, ComboBox as AriaComboBox, Group, Input as AriaInput } from "react-aria-components";
|
|
4
|
+
import { controlPaint, FieldFeedback, FieldLabel, fieldStyle, useControlTheme } from "./control.js";
|
|
5
|
+
import { SurfaceField } from "./control-surface.js";
|
|
6
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
7
|
+
import FieldStyle, { textControlClass } from "./field-style.js";
|
|
8
|
+
import { ListBox } from "./list-box.js";
|
|
9
|
+
import { PopoverContent } from "./popover.js";
|
|
10
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
11
|
+
/** A searchable single-selection field whose query filters string-valued options. */
|
|
12
|
+
export const ComboBox = forwardRef(function ComboBox({ label, description, errorMessage, disabled = false, readOnly = false, required = false, invalid = false, options, value, defaultValue, onChange, inputValue, defaultInputValue, onInputChange, placeholder, size = "medium", color, radius = "medium", style, material, shadow, ...properties }, ref) {
|
|
13
|
+
const theme = useControlTheme({ size, color, radius });
|
|
14
|
+
const direction = resolveDirection(properties.dir, useDirection());
|
|
15
|
+
const disabledValues = useMemo(() => options.filter(option => option.disabled).map(option => option.value), [options]);
|
|
16
|
+
return _jsx(AriaComboBox, { ...properties, ref: ref, dir: direction, value: value, defaultValue: defaultValue, onChange: key => onChange?.(key == null ? null : String(key)), inputValue: inputValue, defaultInputValue: defaultInputValue, onInputChange: onInputChange, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, style: fieldStyle(theme, disabled, style), children: state => _jsxs(_Fragment, { children: [_jsx(FieldStyle, {}), _jsx(FieldLabel, { label: label }), _jsx(Group, { style: group => ({
|
|
17
|
+
position: "relative",
|
|
18
|
+
minWidth: 0,
|
|
19
|
+
height: theme.height,
|
|
20
|
+
borderRadius: theme.radius,
|
|
21
|
+
outline: group.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
|
|
22
|
+
outlineOffset: 1
|
|
23
|
+
}), children: group => _jsxs(SurfaceField, { material: material, shadow: shadow, radius: theme.radius, paint: controlPaint(theme, group.isFocusWithin, group.isInvalid, group.isHovered), style: {
|
|
24
|
+
position: "absolute",
|
|
25
|
+
inset: 0,
|
|
26
|
+
gridTemplateColumns: "minmax(0, 1fr) auto"
|
|
27
|
+
}, children: [_jsx(AriaInput, { className: textControlClass, placeholder: placeholder, style: {
|
|
28
|
+
appearance: "none",
|
|
29
|
+
boxSizing: "border-box",
|
|
30
|
+
width: "100%",
|
|
31
|
+
minWidth: 0,
|
|
32
|
+
height: theme.height,
|
|
33
|
+
paddingBlock: 0,
|
|
34
|
+
paddingInlineStart: Math.max(8, theme.spacing),
|
|
35
|
+
paddingInlineEnd: theme.gap,
|
|
36
|
+
border: 0,
|
|
37
|
+
borderRadius: "inherit",
|
|
38
|
+
outline: "none",
|
|
39
|
+
background: "transparent",
|
|
40
|
+
color: "inherit",
|
|
41
|
+
caretColor: "currentColor",
|
|
42
|
+
font: "inherit",
|
|
43
|
+
lineHeight: 1.5
|
|
44
|
+
} }), _jsx(Button, { "aria-label": "Show options", style: {
|
|
45
|
+
...theme.transition,
|
|
46
|
+
display: "grid",
|
|
47
|
+
placeItems: "center",
|
|
48
|
+
width: theme.height,
|
|
49
|
+
height: theme.height,
|
|
50
|
+
padding: 0,
|
|
51
|
+
border: 0,
|
|
52
|
+
borderRadius: "inherit",
|
|
53
|
+
outline: "none",
|
|
54
|
+
background: "transparent",
|
|
55
|
+
color: "inherit",
|
|
56
|
+
cursor: disabled || readOnly ? "default" : "pointer"
|
|
57
|
+
}, children: _jsx("svg", { "aria-hidden": "true", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", style: {
|
|
58
|
+
...theme.transition,
|
|
59
|
+
transitionProperty: "transform",
|
|
60
|
+
transform: `rotate(${state.isOpen ? 180 : 0}deg)`
|
|
61
|
+
}, children: _jsx("path", { d: "m2 4 4 4 4-4" }) }) })] }) }), _jsx(PopoverContent, { dir: direction, placement: "bottom start", offset: theme.gap, style: {
|
|
62
|
+
width: "var(--trigger-width)",
|
|
63
|
+
maxHeight: `min(calc(100vh - ${theme.spacing * 2}px), ${theme.height * 8}px)`,
|
|
64
|
+
padding: 0,
|
|
65
|
+
display: "flex",
|
|
66
|
+
flexDirection: "column"
|
|
67
|
+
}, children: _jsx(ScrollArea, { style: { flex: "1 1 auto", minHeight: 0 }, children: _jsx(ListBox, { color: color, radius: radius, size: size, disabledValues: disabledValues, children: options.map(option => _jsx(ListBox.Item, { id: option.value, textValue: option.label, disabled: option.disabled, children: option.label }, option.value)) }) }) }), _jsx(FieldFeedback, { theme: theme, description: description, errorMessage: errorMessage })] }) });
|
|
68
|
+
});
|
package/dist/context-menu.d.ts
CHANGED
|
@@ -5,16 +5,14 @@ import { type PopoverContentProps } from "./popover.js";
|
|
|
5
5
|
export type ContextMenuRootProps = Omit<AriaMenuTriggerProps, "trigger">;
|
|
6
6
|
export declare function ContextMenuRoot(properties: ContextMenuRootProps): import("react").JSX.Element;
|
|
7
7
|
export type ContextMenuTriggerProps = ComponentProps<typeof AriaPressable>;
|
|
8
|
-
export declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<Omit<import("react-aria
|
|
8
|
+
export declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<Omit<import("react-aria").PressableProps & import("react").RefAttributes<import("@react-types/shared").FocusableElement>, "ref"> & import("react").RefAttributes<import("@react-types/shared").FocusableElement>>;
|
|
9
9
|
export type ContextMenuContentProps = Omit<PopoverContentProps, "isNonModal">;
|
|
10
10
|
export declare const ContextMenuContent: import("react").ForwardRefExoticComponent<ContextMenuContentProps & import("react").RefAttributes<HTMLElement>>;
|
|
11
11
|
/** A context-requested overlay sharing the same Menu contract as DropdownMenu. */
|
|
12
12
|
export declare const ContextMenu: typeof ContextMenuRoot & {
|
|
13
|
-
|
|
14
|
-
Trigger: import("react").ForwardRefExoticComponent<Omit<import("react-aria/Pressable").PressableProps & import("react").RefAttributes<import("@react-types/shared").FocusableElement>, "ref"> & import("react").RefAttributes<import("@react-types/shared").FocusableElement>>;
|
|
13
|
+
Trigger: import("react").ForwardRefExoticComponent<Omit<import("react-aria").PressableProps & import("react").RefAttributes<import("@react-types/shared").FocusableElement>, "ref"> & import("react").RefAttributes<import("@react-types/shared").FocusableElement>>;
|
|
15
14
|
Content: import("react").ForwardRefExoticComponent<ContextMenuContentProps & import("react").RefAttributes<HTMLElement>>;
|
|
16
15
|
Menu: import("./menu.js").MenuRootComponent & {
|
|
17
|
-
Root: import("./menu.js").MenuRootComponent;
|
|
18
16
|
Item: import("./menu.js").MenuItemComponent;
|
|
19
17
|
Section: <T>(props: import("react-aria-components").MenuSectionProps<T> & React.RefAttributes<HTMLElement>) => import("react").ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
20
18
|
Header: import("react").ForwardRefExoticComponent<import("react-aria-components").HeaderProps & import("react").RefAttributes<HTMLElement>>;
|
package/dist/context-menu.js
CHANGED
|
@@ -38,7 +38,6 @@ export const ContextMenuContent = forwardRef(function ContextMenuContent(propert
|
|
|
38
38
|
});
|
|
39
39
|
/** A context-requested overlay sharing the same Menu contract as DropdownMenu. */
|
|
40
40
|
export const ContextMenu = Object.assign(ContextMenuRoot, {
|
|
41
|
-
Root: ContextMenuRoot,
|
|
42
41
|
Trigger: ContextMenuTrigger,
|
|
43
42
|
Content: ContextMenuContent,
|
|
44
43
|
Menu
|
|
@@ -11,9 +11,10 @@ export declare function SurfaceButton({ native, paint, material: options, shadow
|
|
|
11
11
|
readonly paint: Paint;
|
|
12
12
|
} & MaterialOverrides & ShadowOverrides): import("react").JSX.Element;
|
|
13
13
|
/** Void text controls use a material host while retaining native sizing. */
|
|
14
|
-
export declare function SurfaceField({ paint, radius, children, material: options, shadow }: Readonly<{
|
|
14
|
+
export declare function SurfaceField({ paint, radius, children, material: options, shadow, style }: Readonly<{
|
|
15
15
|
paint: Paint;
|
|
16
16
|
radius: CSSProperties["borderRadius"];
|
|
17
17
|
children: ReactNode;
|
|
18
|
+
style?: CSSProperties;
|
|
18
19
|
} & MaterialOverrides & ShadowOverrides>): import("react").JSX.Element;
|
|
19
20
|
export {};
|
package/dist/control-surface.js
CHANGED
|
@@ -6,6 +6,6 @@ export function SurfaceButton({ native, paint, material: options, shadow }) {
|
|
|
6
6
|
return _jsx(Surface, { ...properties, as: "button", color: paint.background, material: options, shadow: shadow, ref: ref, style: { ...style, color: paint.color }, children: children });
|
|
7
7
|
}
|
|
8
8
|
/** Void text controls use a material host while retaining native sizing. */
|
|
9
|
-
export function SurfaceField({ paint, radius, children, material: options, shadow }) {
|
|
10
|
-
return _jsx(Surface, { as: "span", color: paint.background, material: options, shadow: shadow, radius: radius, style: { color: paint.color, display: "grid", minWidth: 0 }, children: children });
|
|
9
|
+
export function SurfaceField({ paint, radius, children, material: options, shadow, style }) {
|
|
10
|
+
return _jsx(Surface, { as: "span", color: paint.background, material: options, shadow: shadow, radius: radius, style: { color: paint.color, display: "grid", minWidth: 0, ...style }, children: children });
|
|
11
11
|
}
|
package/dist/control.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface ControlTheme {
|
|
|
47
47
|
readonly danger: string;
|
|
48
48
|
readonly paints: {
|
|
49
49
|
readonly palette: SolidColors;
|
|
50
|
-
readonly
|
|
50
|
+
readonly subtle: SolidColors;
|
|
51
51
|
readonly danger: SolidColors;
|
|
52
52
|
};
|
|
53
53
|
readonly radius: CSSProperties["borderRadius"];
|
package/dist/control.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FieldError, Label, Text } from "react-aria-components";
|
|
|
4
4
|
import { useResolvedAppearance } from "./appearance-context.js";
|
|
5
5
|
import { resolveRadius } from "./radius.js";
|
|
6
6
|
import { scale } from "./scale.js";
|
|
7
|
-
import { colorOpacity, solidColors } from "./color.js";
|
|
7
|
+
import { colorOpacity, solidColors, subtleColors } from "./color.js";
|
|
8
8
|
import { resolveSolidColor } from "./color.js";
|
|
9
9
|
import { controlTransition, visualTransition } from "./motion-style.js";
|
|
10
10
|
export const controlFontSizes = Object.freeze({
|
|
@@ -32,15 +32,15 @@ export function useControlTheme({ size = "medium", color, radius = "medium" }) {
|
|
|
32
32
|
const spacing = scale(appearance.spacing, size);
|
|
33
33
|
const foreground = colors.foreground;
|
|
34
34
|
const background = colors.background;
|
|
35
|
+
// One owner-provided base drives every ordinary interaction state; adding
|
|
36
|
+
// hidden state colors here would make the public color contract incomplete.
|
|
35
37
|
const tint = resolveSolidColor(color ?? "default:base", colors);
|
|
36
|
-
const neutral = resolveSolidColor("default:base", colors);
|
|
37
|
-
const focus = resolveSolidColor("warning:base", colors);
|
|
38
38
|
const danger = resolveSolidColor("danger:base", colors);
|
|
39
39
|
const paints = useMemo(() => ({
|
|
40
40
|
palette: solidColors(tint, background, foreground),
|
|
41
|
-
|
|
41
|
+
subtle: subtleColors(tint, background, foreground),
|
|
42
42
|
danger: solidColors(danger, background, foreground)
|
|
43
|
-
}), [tint,
|
|
43
|
+
}), [tint, background, foreground, danger]);
|
|
44
44
|
return useMemo(() => ({
|
|
45
45
|
transition,
|
|
46
46
|
motionTransition,
|
|
@@ -49,7 +49,7 @@ export function useControlTheme({ size = "medium", color, radius = "medium" }) {
|
|
|
49
49
|
foreground,
|
|
50
50
|
background,
|
|
51
51
|
tint,
|
|
52
|
-
focusColor: colorOpacity(
|
|
52
|
+
focusColor: colorOpacity(tint, 0.2),
|
|
53
53
|
danger,
|
|
54
54
|
paints,
|
|
55
55
|
radius: resolveRadius(radius, appearance),
|
|
@@ -57,7 +57,7 @@ export function useControlTheme({ size = "medium", color, radius = "medium" }) {
|
|
|
57
57
|
indicatorSize: Math.max(16, 16 + spacing / 4),
|
|
58
58
|
height: Math.max(24, 24 + spacing),
|
|
59
59
|
gap: Math.max(4, spacing / 2)
|
|
60
|
-
}), [appearance, colors, transition, motionTransition, resolved.preferences.animations, spacing, foreground, background, tint,
|
|
60
|
+
}), [appearance, colors, transition, motionTransition, resolved.preferences.animations, spacing, foreground, background, tint, danger, paints, radius, size]);
|
|
61
61
|
}
|
|
62
62
|
export function fieldStyle(theme, disabled = false, style) {
|
|
63
63
|
return {
|
|
@@ -66,7 +66,6 @@ export function fieldStyle(theme, disabled = false, style) {
|
|
|
66
66
|
display: "grid",
|
|
67
67
|
gap: theme.gap,
|
|
68
68
|
minWidth: 0,
|
|
69
|
-
color: theme.foreground,
|
|
70
69
|
fontFamily: "inherit",
|
|
71
70
|
fontSize: theme.fontSize,
|
|
72
71
|
lineHeight: 1.5,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } 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
|
+
/** Shared visual and segmented-input boundary for date and time controls. */
|
|
6
|
+
export declare function DateControl({ active, children, disabled, end, endFocusVisible, endRequiresVisibleFocus, group, invalid, material, shadow, theme }: Readonly<{
|
|
7
|
+
active?: boolean;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
end?: ReactNode;
|
|
11
|
+
endFocusVisible?: boolean;
|
|
12
|
+
endRequiresVisibleFocus?: boolean;
|
|
13
|
+
group?: boolean;
|
|
14
|
+
invalid: boolean;
|
|
15
|
+
material: MaterialOverrides["material"];
|
|
16
|
+
shadow: ShadowOverrides["shadow"];
|
|
17
|
+
theme: ControlTheme;
|
|
18
|
+
}>): import("react").JSX.Element;
|
|
19
|
+
/** Segmented input used once for a date and twice for a date range. */
|
|
20
|
+
export declare function DateSegments({ compact, slot, theme }: Readonly<{
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
slot?: "start" | "end";
|
|
23
|
+
theme: ControlTheme;
|
|
24
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { DateInput, DateSegment, Group } from "react-aria-components";
|
|
4
|
+
import { controlOpacity, controlPaint, controlStyle } from "./control.js";
|
|
5
|
+
import { Surface } from "./surface.js";
|
|
6
|
+
/** Shared visual and segmented-input boundary for date and time controls. */
|
|
7
|
+
export function DateControl({ active = false, children, disabled, end, endFocusVisible, endRequiresVisibleFocus = false, group = false, invalid, material, shadow, theme }) {
|
|
8
|
+
const [focused, setFocused] = useState(false);
|
|
9
|
+
const [endFocused, setEndFocused] = useState(false);
|
|
10
|
+
const [hovered, setHovered] = useState(false);
|
|
11
|
+
// Popovers restore trigger focus after pointer dismissal; only keyboard-visible
|
|
12
|
+
// focus on that end control should reactivate the field paint.
|
|
13
|
+
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
|
+
const surface = {
|
|
23
|
+
color: paint.background,
|
|
24
|
+
material,
|
|
25
|
+
shadow,
|
|
26
|
+
radius: theme.radius,
|
|
27
|
+
onFocusCapture: (event) => {
|
|
28
|
+
setFocused(true);
|
|
29
|
+
setEndFocused(event.target instanceof Element && event.target.closest("[data-date-control-end]") != null);
|
|
30
|
+
},
|
|
31
|
+
onBlurCapture,
|
|
32
|
+
onPointerEnter: () => setHovered(true),
|
|
33
|
+
onPointerLeave: () => setHovered(false),
|
|
34
|
+
style: {
|
|
35
|
+
...style,
|
|
36
|
+
display: "flex",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
cursor: disabled ? "not-allowed" : "text"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const content = _jsxs(_Fragment, { children: [children ?? _jsx(DateSegments, { theme: theme }), end] });
|
|
42
|
+
return group
|
|
43
|
+
? _jsx(Surface, { as: Group, ...surface, children: content })
|
|
44
|
+
: _jsx(Surface, { ...surface, children: content });
|
|
45
|
+
}
|
|
46
|
+
/** Segmented input used once for a date and twice for a date range. */
|
|
47
|
+
export function DateSegments({ compact = false, slot, theme }) {
|
|
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) }) });
|
|
54
|
+
}
|
|
55
|
+
function segmentStyle(theme, state) {
|
|
56
|
+
const selected = state.isFocused ? theme.paints.subtle.pressed : null;
|
|
57
|
+
return {
|
|
58
|
+
...theme.transition,
|
|
59
|
+
minWidth: state.type === "literal" ? undefined : "1ch",
|
|
60
|
+
paddingInline: state.type === "literal" ? 0 : 1,
|
|
61
|
+
borderRadius: Math.max(2, theme.spacing / 3),
|
|
62
|
+
outline: "none",
|
|
63
|
+
background: selected?.background ?? "transparent",
|
|
64
|
+
color: selected?.color ?? "inherit",
|
|
65
|
+
opacity: state.isPlaceholder ? controlOpacity.placeholder : 1,
|
|
66
|
+
fontVariantNumeric: "tabular-nums",
|
|
67
|
+
textAlign: "center"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CalendarDate } from "@internationalized/date";
|
|
2
|
+
import type { DateFieldProps as AriaDateFieldProps } from "react-aria-components";
|
|
3
|
+
import type { ControlOverrides, ControlProps, FieldProps } from "./control.js";
|
|
4
|
+
import type { MaterialOverrides } from "./material-options.js";
|
|
5
|
+
import type { RadiusProps } from "./radius.js";
|
|
6
|
+
import type { ShadowOverrides } from "./shadow-options.js";
|
|
7
|
+
type DateFieldOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isDateUnavailable" | "granularity" | "hourCycle" | "hideTimeZone";
|
|
8
|
+
export interface DateFieldProps extends Omit<AriaDateFieldProps<CalendarDate>, DateFieldOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
9
|
+
readonly value?: CalendarDate | null;
|
|
10
|
+
readonly defaultValue?: CalendarDate | null;
|
|
11
|
+
readonly onChange?: (value: CalendarDate | null) => void;
|
|
12
|
+
readonly minValue?: CalendarDate | null;
|
|
13
|
+
readonly maxValue?: CalendarDate | null;
|
|
14
|
+
readonly isDateUnavailable?: (date: CalendarDate) => boolean;
|
|
15
|
+
readonly readOnly?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** A locale-aware date-only field whose year, month, and day are edited as independent segments. */
|
|
18
|
+
export declare const DateField: import("react").ForwardRefExoticComponent<DateFieldProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { DateField as AriaDateField } from "react-aria-components";
|
|
4
|
+
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
5
|
+
import { FieldFeedback, FieldLabel, fieldStyle, useControlTheme } from "./control.js";
|
|
6
|
+
import { DateControl } from "./date-control.js";
|
|
7
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
8
|
+
/** 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, shadow, style, className, isDateUnavailable, ...properties }, ref) {
|
|
10
|
+
const theme = useControlTheme({ size, color, radius });
|
|
11
|
+
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(theme, disabled, style), children: state => _jsxs(_Fragment, { children: [_jsx(FieldLabel, { label: label }), _jsx(DateControl, { disabled: state.isDisabled, invalid: state.isInvalid, material: material, shadow: shadow, theme: theme }), _jsx(FieldFeedback, { theme: theme, description: description, errorMessage: errorMessage })] }) }) });
|
|
13
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CalendarDate } from "@internationalized/date";
|
|
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
|
+
import type { ShadowOverrides } from "./shadow-options.js";
|
|
7
|
+
type DatePickerOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isDateUnavailable" | "granularity" | "hourCycle" | "hideTimeZone";
|
|
8
|
+
export interface DatePickerProps extends Omit<AriaDatePickerProps<CalendarDate>, DatePickerOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
9
|
+
readonly value?: CalendarDate | null;
|
|
10
|
+
readonly defaultValue?: CalendarDate | null;
|
|
11
|
+
readonly onChange?: (value: CalendarDate | null) => void;
|
|
12
|
+
readonly minValue?: CalendarDate | null;
|
|
13
|
+
readonly maxValue?: CalendarDate | null;
|
|
14
|
+
readonly isDateUnavailable?: (date: CalendarDate) => boolean;
|
|
15
|
+
readonly readOnly?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** A date-only segmented field with a calendar selection popover. */
|
|
18
|
+
export declare const DatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { DatePicker as AriaDatePicker } from "react-aria-components";
|
|
4
|
+
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
5
|
+
import { Calendar } from "./calendar.js";
|
|
6
|
+
import { CalendarTrigger } from "./calendar-trigger.js";
|
|
7
|
+
import { FieldFeedback, FieldLabel, fieldStyle, useControlTheme } from "./control.js";
|
|
8
|
+
import { DateControl } from "./date-control.js";
|
|
9
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
10
|
+
import { PopoverContent, PopoverDialog } from "./popover.js";
|
|
11
|
+
/** 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, shadow, style, className, isDateUnavailable, ...properties }, ref) {
|
|
13
|
+
const theme = useControlTheme({ size, color, radius });
|
|
14
|
+
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(theme, disabled, 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, shadow: shadow, theme: theme, end: _jsx(CalendarTrigger, { theme: theme }) }), _jsx(FieldFeedback, { theme: theme, description: description, errorMessage: errorMessage }), _jsx(PopoverContent, { placement: "bottom start", children: _jsx(PopoverDialog, { children: _jsx(Calendar, { color: color, size: size, radius: radius }) }) })] }) }) });
|
|
16
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CalendarDate } from "@internationalized/date";
|
|
2
|
+
import type { DateRangePickerProps as AriaDateRangePickerProps } from "react-aria-components";
|
|
3
|
+
import { type ControlOverrides, type ControlProps, type FieldProps } from "./control.js";
|
|
4
|
+
import type { DateRange } from "./date-range.js";
|
|
5
|
+
import type { MaterialOverrides } from "./material-options.js";
|
|
6
|
+
import type { RadiusProps } from "./radius.js";
|
|
7
|
+
import type { ShadowOverrides } from "./shadow-options.js";
|
|
8
|
+
type DateRangePickerOverrides = ControlOverrides | "isReadOnly" | "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isDateUnavailable" | "granularity" | "hourCycle" | "hideTimeZone";
|
|
9
|
+
export interface DateRangePickerProps extends Omit<AriaDateRangePickerProps<CalendarDate>, DateRangePickerOverrides>, ControlProps, FieldProps, RadiusProps, MaterialOverrides, ShadowOverrides {
|
|
10
|
+
readonly value?: DateRange | null;
|
|
11
|
+
readonly defaultValue?: DateRange | null;
|
|
12
|
+
readonly onChange?: (value: DateRange | null) => void;
|
|
13
|
+
readonly minValue?: CalendarDate | null;
|
|
14
|
+
readonly maxValue?: CalendarDate | null;
|
|
15
|
+
readonly isDateUnavailable?: (date: CalendarDate, anchorDate: CalendarDate | null) => boolean;
|
|
16
|
+
readonly readOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Two date-only segmented fields backed by one inclusive range calendar. */
|
|
19
|
+
export declare const DateRangePicker: import("react").ForwardRefExoticComponent<DateRangePickerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { DateRangePicker as AriaDateRangePicker } from "react-aria-components";
|
|
4
|
+
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
5
|
+
import { CalendarTrigger } from "./calendar-trigger.js";
|
|
6
|
+
import { controlOpacity, FieldFeedback, FieldLabel, fieldStyle, useControlTheme } from "./control.js";
|
|
7
|
+
import { DateControl, DateSegments } from "./date-control.js";
|
|
8
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
9
|
+
import { PopoverContent, PopoverDialog } from "./popover.js";
|
|
10
|
+
import { RangeCalendar } from "./range-calendar.js";
|
|
11
|
+
/** 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, shadow, style, className, isDateUnavailable, ...properties }, ref) {
|
|
13
|
+
const theme = useControlTheme({ size, color, radius });
|
|
14
|
+
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
|
|
16
|
+
? undefined
|
|
17
|
+
: (date, anchorDate) => isDateUnavailable(date, anchorDate), style: fieldStyle(theme, disabled, 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, shadow: shadow, theme: theme, end: _jsx(CalendarTrigger, { theme: theme }), children: _jsxs("div", { style: {
|
|
18
|
+
display: "flex",
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
justifyContent: "flex-start",
|
|
21
|
+
flex: "1 1 auto",
|
|
22
|
+
minWidth: 0,
|
|
23
|
+
gap: Math.max(2, theme.gap / 2)
|
|
24
|
+
}, children: [_jsx(DateSegments, { compact: true, slot: "start", theme: theme }), _jsx("span", { "aria-hidden": "true", style: { flex: "0 0 auto", opacity: controlOpacity.secondary }, children: "\u2013" }), _jsx(DateSegments, { compact: true, slot: "end", theme: theme })] }) }), _jsx(FieldFeedback, { theme: theme, description: description, errorMessage: errorMessage }), _jsx(PopoverContent, { placement: "bottom start", children: _jsx(PopoverDialog, { children: _jsx(RangeCalendar, { color: color, size: size, radius: radius }) }) })] }) }) });
|
|
25
|
+
});
|
|
File without changes
|
package/dist/dialog.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { ComponentProps, CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
2
2
|
import type { DialogProps as AriaDialogProps, DialogTriggerProps as AriaDialogTriggerProps, HeadingProps as AriaHeadingProps, ModalOverlayProps as AriaModalOverlayProps, TextProps as AriaTextProps } from "react-aria-components";
|
|
3
|
+
import { type Color } from "./color.js";
|
|
3
4
|
import { type ButtonProps } from "./button.js";
|
|
4
5
|
import { type SurfaceOwnProps } from "./surface.js";
|
|
5
6
|
export type DialogRootProps = AriaDialogTriggerProps;
|
|
6
7
|
export declare function DialogRoot(properties: DialogRootProps): import("react").JSX.Element;
|
|
7
8
|
export type DialogTriggerProps = ButtonProps;
|
|
8
9
|
export declare const DialogTrigger: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
-
export interface DialogBackdropProps extends Omit<AriaModalOverlayProps, "children" | "className" | "style"> {
|
|
10
|
+
export interface DialogBackdropProps extends Omit<AriaModalOverlayProps, "children" | "className" | "color" | "style"> {
|
|
10
11
|
readonly children?: ReactNode;
|
|
11
12
|
readonly className?: string;
|
|
13
|
+
/** Base color rendered with the backdrop's derived opacity. */
|
|
14
|
+
readonly color?: Color;
|
|
12
15
|
readonly style?: CSSProperties;
|
|
13
16
|
}
|
|
14
17
|
export declare const DialogBackdrop: import("react").ForwardRefExoticComponent<DialogBackdropProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -32,7 +35,6 @@ export type DialogCloseProps = ButtonProps;
|
|
|
32
35
|
export declare const DialogClose: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
36
|
/** A modal dialog whose behavioral and structural roles remain independently composable. */
|
|
34
37
|
export declare const Dialog: typeof DialogRoot & {
|
|
35
|
-
Root: typeof DialogRoot;
|
|
36
38
|
Trigger: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
37
39
|
Backdrop: import("react").ForwardRefExoticComponent<DialogBackdropProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
40
|
Content: import("react").ForwardRefExoticComponent<DialogContentProps & import("react").RefAttributes<HTMLElement>>;
|