@xds/react 1.0.0-rc.1 → 1.0.0
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/dist/Accordion.js +3 -2
- package/dist/Button.js +5 -3
- package/dist/Card.js +1 -1
- package/dist/DatePicker.js +167 -170
- package/dist/DateRangePicker.js +91 -94
- package/dist/Menu.js +83 -75
- package/dist/SearchField.js +4 -2
- package/dist/Select.js +123 -98
- package/dist/Slider.d.ts +1 -1
- package/dist/Slider.js +44 -35
- package/dist/TextField.js +130 -107
- package/dist/Toast.d.ts +1 -1
- package/dist/Toast.js +50 -45
- package/dist/Tooltip.js +54 -40
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -1
- package/dist/picture.js +2 -2
- package/dist/portal.d.ts +6 -4
- package/dist/portal.js +61 -9
- package/eject/files/Accordion.tsx +5 -2
- package/eject/files/Avatar.tsx +1 -1
- package/eject/files/AvatarStack.tsx +1 -1
- package/eject/files/Badge.tsx +1 -1
- package/eject/files/Banner.tsx +1 -1
- package/eject/files/Button.tsx +9 -5
- package/eject/files/Card.tsx +2 -2
- package/eject/files/Checkbox.tsx +1 -1
- package/eject/files/Chip.tsx +1 -1
- package/eject/files/ChipBar.tsx +1 -1
- package/eject/files/CountBadge.tsx +1 -1
- package/eject/files/DatePicker.tsx +32 -23
- package/eject/files/DateRangePicker.tsx +34 -23
- package/eject/files/Dialog.tsx +1 -1
- package/eject/files/Divider.tsx +1 -1
- package/eject/files/EmptyState.tsx +1 -1
- package/eject/files/Icon.tsx +1 -1
- package/eject/files/IconButton.tsx +1 -1
- package/eject/files/ListRow.tsx +1 -1
- package/eject/files/MediaCard.tsx +1 -1
- package/eject/files/Menu.tsx +7 -7
- package/eject/files/ProgressBar.tsx +1 -1
- package/eject/files/RadioGroup.tsx +1 -1
- package/eject/files/SearchField.tsx +6 -2
- package/eject/files/SectionHeader.tsx +1 -1
- package/eject/files/SegmentedControl.tsx +1 -1
- package/eject/files/Select.tsx +20 -22
- package/eject/files/Sidebar.tsx +1 -1
- package/eject/files/Skeleton.tsx +1 -1
- package/eject/files/Slider.tsx +11 -5
- package/eject/files/Spinner.tsx +1 -1
- package/eject/files/Switch.tsx +1 -1
- package/eject/files/Tabs.tsx +1 -1
- package/eject/files/Text.tsx +1 -1
- package/eject/files/TextField.tsx +18 -4
- package/eject/files/Thumbnail.tsx +1 -1
- package/eject/files/Toast.tsx +11 -15
- package/eject/files/Tooltip.tsx +9 -3
- package/eject/files/accordion.css +1 -1
- package/eject/files/accordion.ts +1 -1
- package/eject/files/avatar-stack.ts +1 -1
- package/eject/files/avatar.ts +1 -1
- package/eject/files/badge.ts +1 -1
- package/eject/files/banner.ts +1 -1
- package/eject/files/base.css +1 -1
- package/eject/files/button.css +3 -3
- package/eject/files/button.ts +1 -1
- package/eject/files/card.ts +1 -1
- package/eject/files/checkbox.ts +1 -1
- package/eject/files/chip-bar.ts +1 -1
- package/eject/files/chip.ts +1 -1
- package/eject/files/count-badge.ts +1 -1
- package/eject/files/date-picker.css +5 -5
- package/eject/files/date-picker.ts +30 -11
- package/eject/files/date-range-picker.ts +16 -8
- package/eject/files/dialog.css +6 -6
- package/eject/files/dialog.ts +1 -1
- package/eject/files/divider.ts +1 -1
- package/eject/files/empty-state.ts +1 -1
- package/eject/files/icon.ts +1 -1
- package/eject/files/list-row.ts +1 -1
- package/eject/files/media-card.ts +1 -1
- package/eject/files/menu.css +4 -4
- package/eject/files/menu.ts +1 -1
- package/eject/files/overlay.css +40 -0
- package/eject/files/parts.ts +1 -1
- package/eject/files/progress-bar.ts +1 -1
- package/eject/files/radio-group.css +1 -1
- package/eject/files/radio-group.ts +1 -1
- package/eject/files/section-header.ts +1 -1
- package/eject/files/segmented-control.ts +1 -1
- package/eject/files/select.css +17 -6
- package/eject/files/select.ts +1 -1
- package/eject/files/sidebar.ts +1 -1
- package/eject/files/skeleton.ts +1 -1
- package/eject/files/slider.css +1 -1
- package/eject/files/slider.ts +17 -5
- package/eject/files/spinner.ts +1 -1
- package/eject/files/switch.ts +1 -1
- package/eject/files/tabs.css +1 -1
- package/eject/files/tabs.ts +1 -1
- package/eject/files/text-field.css +4 -8
- package/eject/files/text-field.ts +1 -1
- package/eject/files/text.ts +1 -1
- package/eject/files/thumbnail.ts +1 -1
- package/eject/files/toast.ts +1 -1
- package/eject/files/tooltip.css +3 -3
- package/eject/files/tooltip.ts +1 -1
- package/eject/manifest.json +4 -2
- package/package.json +3 -3
- package/styles.css +15 -11
- package/tailwind.css +21 -14
package/dist/portal.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
|
-
* Renders `children` at the end of the body, where an overlay is above the page
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Renders `children` at the end of the body, where an overlay is above the page, while mirroring
|
|
4
|
+
* any subtree `[data-theme]` and `[data-xds-theme]` attributes from where the portal sits so
|
|
5
|
+
* scoped themes reach portaled overlays. A page rendered by a server has no body to render into,
|
|
6
|
+
* and the render that hydrates it must match the server's, so there the overlay comes in the
|
|
7
|
+
* render after.
|
|
6
8
|
*/
|
|
7
9
|
export declare function Portal({ children }: {
|
|
8
10
|
children: ReactNode;
|
|
9
|
-
}): import("react").
|
|
11
|
+
}): import("react").JSX.Element;
|
package/dist/portal.js
CHANGED
|
@@ -1,23 +1,75 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { syncThemeScope } from "@xds/core";
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useSyncExternalStore } from "react";
|
|
3
4
|
import { createPortal } from "react-dom";
|
|
5
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
6
|
const subscribe = () => () => {};
|
|
7
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5
8
|
export function Portal(t0) {
|
|
6
|
-
const $ = _c(
|
|
9
|
+
const $ = _c(9);
|
|
7
10
|
const {
|
|
8
11
|
children
|
|
9
12
|
} = t0;
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const hostRef = useRef(null);
|
|
10
15
|
const client = useSyncExternalStore(subscribe, _temp, _temp2);
|
|
11
16
|
let t1;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
let t2;
|
|
18
|
+
if ($[0] !== client) {
|
|
19
|
+
t1 = () => {
|
|
20
|
+
if (!client) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return syncThemeScope(anchorRef.current, hostRef.current);
|
|
24
|
+
};
|
|
25
|
+
t2 = [client];
|
|
26
|
+
$[0] = client;
|
|
27
|
+
$[1] = t1;
|
|
28
|
+
$[2] = t2;
|
|
17
29
|
} else {
|
|
18
|
-
t1 = $[
|
|
30
|
+
t1 = $[1];
|
|
31
|
+
t2 = $[2];
|
|
19
32
|
}
|
|
20
|
-
|
|
33
|
+
useIsomorphicLayoutEffect(t1, t2);
|
|
34
|
+
let t3;
|
|
35
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
36
|
+
t3 = /*#__PURE__*/_jsx("span", {
|
|
37
|
+
ref: anchorRef,
|
|
38
|
+
hidden: true,
|
|
39
|
+
style: {
|
|
40
|
+
display: "none"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
$[3] = t3;
|
|
44
|
+
} else {
|
|
45
|
+
t3 = $[3];
|
|
46
|
+
}
|
|
47
|
+
let t4;
|
|
48
|
+
if ($[4] !== children || $[5] !== client) {
|
|
49
|
+
t4 = client ? createPortal(/*#__PURE__*/_jsx("div", {
|
|
50
|
+
ref: hostRef,
|
|
51
|
+
style: {
|
|
52
|
+
display: "contents"
|
|
53
|
+
},
|
|
54
|
+
children: children
|
|
55
|
+
}), document.body) : null;
|
|
56
|
+
$[4] = children;
|
|
57
|
+
$[5] = client;
|
|
58
|
+
$[6] = t4;
|
|
59
|
+
} else {
|
|
60
|
+
t4 = $[6];
|
|
61
|
+
}
|
|
62
|
+
let t5;
|
|
63
|
+
if ($[7] !== t4) {
|
|
64
|
+
t5 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
|
+
children: [t3, t4]
|
|
66
|
+
});
|
|
67
|
+
$[7] = t4;
|
|
68
|
+
$[8] = t5;
|
|
69
|
+
} else {
|
|
70
|
+
t5 = $[8];
|
|
71
|
+
}
|
|
72
|
+
return t5;
|
|
21
73
|
}
|
|
22
74
|
function _temp2() {
|
|
23
75
|
return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -7,6 +7,7 @@ import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
|
7
7
|
import {
|
|
8
8
|
type HTMLAttributes,
|
|
9
9
|
type ReactNode,
|
|
10
|
+
useEffect,
|
|
10
11
|
useId,
|
|
11
12
|
useLayoutEffect,
|
|
12
13
|
useRef,
|
|
@@ -22,6 +23,8 @@ import {
|
|
|
22
23
|
import { Icon } from "./Icon.tsx";
|
|
23
24
|
import { classes } from "./parts.ts";
|
|
24
25
|
|
|
26
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
27
|
+
|
|
25
28
|
export type AccordionItem<Value extends string = string> = AccordionItemBase<Value> & {
|
|
26
29
|
/** The body, shown under the title while the item is open. */
|
|
27
30
|
content: ReactNode;
|
|
@@ -127,7 +130,7 @@ function Panel({
|
|
|
127
130
|
// effect from then on.
|
|
128
131
|
const [closedAtFirst] = useState(!open);
|
|
129
132
|
// Before the browser paints, so a closed panel never shows for a frame.
|
|
130
|
-
|
|
133
|
+
useIsomorphicLayoutEffect(() => {
|
|
131
134
|
if (!panel.current) return;
|
|
132
135
|
const stop = setPanelOpen(
|
|
133
136
|
panel.current,
|
package/eject/files/Avatar.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults, usePicture } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults } from "@xds/react/base";
|
package/eject/files/Badge.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults } from "@xds/react/base";
|
package/eject/files/Banner.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults } from "@xds/react/base";
|
package/eject/files/Button.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults, useTrigger } from "@xds/react/base";
|
|
5
|
-
import type { ReactNode } from "react";
|
|
5
|
+
import type { MouseEvent, ReactNode } from "react";
|
|
6
6
|
import { BUTTON_ICON, type ButtonBaseProps, buttonClass, isHeld } from "./button.ts";
|
|
7
7
|
import { Icon } from "./Icon.tsx";
|
|
8
8
|
import { classes } from "./parts.ts";
|
|
@@ -59,9 +59,13 @@ export function Button(props: ButtonProps) {
|
|
|
59
59
|
"data-pending": loading ? "" : undefined,
|
|
60
60
|
"aria-pressed": selected,
|
|
61
61
|
"aria-label": label,
|
|
62
|
-
onClick: () => {
|
|
63
|
-
// The press was taken already.
|
|
64
|
-
if (
|
|
62
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => {
|
|
63
|
+
// The press was taken already: block keyboard Enter/Space form submit or reset too.
|
|
64
|
+
if (loading) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
onPress?.();
|
|
65
69
|
},
|
|
66
70
|
},
|
|
67
71
|
loading,
|
package/eject/files/Card.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -47,7 +47,7 @@ export function Card({
|
|
|
47
47
|
const parts = (
|
|
48
48
|
<>
|
|
49
49
|
{media != null && <Box className={cardMediaClass(flush)}>{media}</Box>}
|
|
50
|
-
{(title || (actions && !onPress)) && (
|
|
50
|
+
{(title || description || (actions && !onPress)) && (
|
|
51
51
|
<Header className={CARD_PARTS.header}>
|
|
52
52
|
<Box className={CARD_PARTS.heading}>
|
|
53
53
|
{title && <Title className={CARD_PARTS.title}>{title}</Title>}
|
package/eject/files/Checkbox.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
package/eject/files/Chip.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
package/eject/files/ChipBar.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Portal,
|
|
6
|
+
type RootProps,
|
|
7
|
+
readCssPx,
|
|
8
|
+
space,
|
|
9
|
+
underlayLayerStyle,
|
|
10
|
+
useModalPopover,
|
|
11
|
+
usePresence,
|
|
12
|
+
} from "@xds/react/base";
|
|
5
13
|
import * as datePicker from "@zag-js/date-picker";
|
|
6
14
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
7
15
|
import { type MouseEvent, useEffect, useId, useRef } from "react";
|
|
@@ -46,10 +54,15 @@ export function DatePicker({ onChange, className, style, ...props }: DatePickerP
|
|
|
46
54
|
const { label, value, placeholder, description, error, name } = props;
|
|
47
55
|
const id = useId();
|
|
48
56
|
const ids = datePickerIds(id);
|
|
49
|
-
const locale = datePickerLocale();
|
|
57
|
+
const locale = datePickerLocale(props.locale);
|
|
50
58
|
const service = useMachine(
|
|
51
59
|
datePicker.machine,
|
|
52
|
-
datePickerMachineProps(props, {
|
|
60
|
+
datePickerMachineProps(props, {
|
|
61
|
+
id,
|
|
62
|
+
locale,
|
|
63
|
+
onChange,
|
|
64
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
65
|
+
}),
|
|
53
66
|
);
|
|
54
67
|
const api = datePicker.connect(service, normalizeProps);
|
|
55
68
|
const trigger = api.getTriggerProps();
|
|
@@ -61,6 +74,7 @@ export function DatePicker({ onChange, className, style, ...props }: DatePickerP
|
|
|
61
74
|
const month = api.visibleRange.start.toString();
|
|
62
75
|
useEffect(() => keepDayFocused(api.open, surface.current), [api.open, focused, month]);
|
|
63
76
|
const invalid = error !== undefined;
|
|
77
|
+
const positionerProps = api.getPositionerProps();
|
|
64
78
|
return (
|
|
65
79
|
<div
|
|
66
80
|
{...mergeProps(api.getRootProps(), {
|
|
@@ -90,20 +104,18 @@ export function DatePicker({ onChange, className, style, ...props }: DatePickerP
|
|
|
90
104
|
<Icon name="calendar" size="sm" className="text-xds-field-placeholder" />
|
|
91
105
|
</button>
|
|
92
106
|
</div>
|
|
93
|
-
{/* One line under the box: the help, or the error in its place.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
</div>
|
|
106
|
-
)}
|
|
107
|
+
{/* One line under the box: the help, or the error in its place. The error stays mounted as
|
|
108
|
+
a live region so assistive technology announces it when it appears. */}
|
|
109
|
+
<div className="{{prefix}}-date-picker__footer">
|
|
110
|
+
{!invalid && description && (
|
|
111
|
+
<span id={ids.description} className="{{prefix}}-date-picker__description">
|
|
112
|
+
{description}
|
|
113
|
+
</span>
|
|
114
|
+
)}
|
|
115
|
+
<span id={ids.error} className="{{prefix}}-date-picker__error" aria-live="polite">
|
|
116
|
+
{error}
|
|
117
|
+
</span>
|
|
118
|
+
</div>
|
|
107
119
|
{/* What a form submits. Zag gives the name to its text input, which is not drawn. */}
|
|
108
120
|
{name !== undefined && <input type="hidden" name={name} value={value ?? ""} />}
|
|
109
121
|
<Portal>
|
|
@@ -113,14 +125,11 @@ export function DatePicker({ onChange, className, style, ...props }: DatePickerP
|
|
|
113
125
|
// oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- not a control: the handler only keeps the focus where it is
|
|
114
126
|
<div
|
|
115
127
|
className="{{prefix}}-date-picker__underlay"
|
|
128
|
+
style={underlayLayerStyle(positionerProps.style)}
|
|
116
129
|
onMouseDown={(event) => event.preventDefault()}
|
|
117
130
|
/>
|
|
118
131
|
)}
|
|
119
|
-
<div
|
|
120
|
-
{...api.getPositionerProps()}
|
|
121
|
-
ref={positioner}
|
|
122
|
-
className="{{prefix}}-date-picker__positioner"
|
|
123
|
-
>
|
|
132
|
+
<div {...positionerProps} ref={positioner} className="{{prefix}}-date-picker__positioner">
|
|
124
133
|
{/* Shown until its exit animation ends; Zag would hide it as it closes. */}
|
|
125
134
|
{/* oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- a dialog: datePickerContentAttrs gives it the role */}
|
|
126
135
|
<div
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Portal,
|
|
6
|
+
type RootProps,
|
|
7
|
+
readCssPx,
|
|
8
|
+
space,
|
|
9
|
+
underlayLayerStyle,
|
|
10
|
+
useModalPopover,
|
|
11
|
+
usePresence,
|
|
12
|
+
} from "@xds/react/base";
|
|
5
13
|
import * as datePicker from "@zag-js/date-picker";
|
|
6
14
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
7
15
|
import { type MouseEvent, useEffect, useId, useRef, useState } from "react";
|
|
@@ -61,14 +69,21 @@ export function DateRangePicker({ onChange, className, style, ...props }: DateRa
|
|
|
61
69
|
const { label, value, placeholder, description, error, startName, endName } = props;
|
|
62
70
|
const id = useId();
|
|
63
71
|
const ids = datePickerIds(id);
|
|
64
|
-
const locale = datePickerLocale();
|
|
72
|
+
const locale = datePickerLocale(props.locale);
|
|
65
73
|
// A start alone while the end is chosen; null while the calendar shows the chosen range.
|
|
66
74
|
const [draft, setDraft] = useState<RangeDraft | null>(null);
|
|
67
75
|
const [months, setMonths] = useState(1);
|
|
68
76
|
const shown = shownRange(value, draft);
|
|
69
77
|
const service = useMachine(
|
|
70
78
|
datePicker.machine,
|
|
71
|
-
dateRangeMachineProps(props, shown, {
|
|
79
|
+
dateRangeMachineProps(props, shown, {
|
|
80
|
+
id,
|
|
81
|
+
locale,
|
|
82
|
+
months,
|
|
83
|
+
onDraft: setDraft,
|
|
84
|
+
onChange,
|
|
85
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
86
|
+
}),
|
|
72
87
|
);
|
|
73
88
|
const api = datePicker.connect(service, normalizeProps);
|
|
74
89
|
const trigger = api.getTriggerProps();
|
|
@@ -85,6 +100,7 @@ export function DateRangePicker({ onChange, className, style, ...props }: DateRa
|
|
|
85
100
|
useEffect(() => keepRangePreview(service, shown, api.open), [focused]);
|
|
86
101
|
const summary = rangeSummary(shown, props, locale);
|
|
87
102
|
const invalid = error !== undefined;
|
|
103
|
+
const positionerProps = api.getPositionerProps();
|
|
88
104
|
return (
|
|
89
105
|
<div
|
|
90
106
|
{...mergeProps(api.getRootProps(), {
|
|
@@ -115,20 +131,18 @@ export function DateRangePicker({ onChange, className, style, ...props }: DateRa
|
|
|
115
131
|
<Icon name="calendar" size="sm" className="text-xds-field-placeholder" />
|
|
116
132
|
</button>
|
|
117
133
|
</div>
|
|
118
|
-
{/* One line under the box: the help, or the error in its place.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
</div>
|
|
131
|
-
)}
|
|
134
|
+
{/* One line under the box: the help, or the error in its place. The error stays mounted as
|
|
135
|
+
a live region so assistive technology announces it when it appears. */}
|
|
136
|
+
<div className="{{prefix}}-date-picker__footer">
|
|
137
|
+
{!invalid && description && (
|
|
138
|
+
<span id={ids.description} className="{{prefix}}-date-picker__description">
|
|
139
|
+
{description}
|
|
140
|
+
</span>
|
|
141
|
+
)}
|
|
142
|
+
<span id={ids.error} className="{{prefix}}-date-picker__error" aria-live="polite">
|
|
143
|
+
{error}
|
|
144
|
+
</span>
|
|
145
|
+
</div>
|
|
132
146
|
{/* What a form submits. Zag gives the names to its text inputs, which are not drawn. */}
|
|
133
147
|
{startName !== undefined && (
|
|
134
148
|
<input type="hidden" name={startName} value={value?.start ?? ""} />
|
|
@@ -141,14 +155,11 @@ export function DateRangePicker({ onChange, className, style, ...props }: DateRa
|
|
|
141
155
|
// oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- not a control: the handler only keeps the focus where it is
|
|
142
156
|
<div
|
|
143
157
|
className="{{prefix}}-date-picker__underlay"
|
|
158
|
+
style={underlayLayerStyle(positionerProps.style)}
|
|
144
159
|
onMouseDown={(event) => event.preventDefault()}
|
|
145
160
|
/>
|
|
146
161
|
)}
|
|
147
|
-
<div
|
|
148
|
-
{...api.getPositionerProps()}
|
|
149
|
-
ref={positioner}
|
|
150
|
-
className="{{prefix}}-date-picker__positioner"
|
|
151
|
-
>
|
|
162
|
+
<div {...positionerProps} ref={positioner} className="{{prefix}}-date-picker__positioner">
|
|
152
163
|
{/* Shown until its exit animation ends; Zag would hide it as it closes. */}
|
|
153
164
|
{/* oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- a dialog: datePickerContentAttrs gives it the role */}
|
|
154
165
|
<div
|
package/eject/files/Dialog.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import {
|
package/eject/files/Divider.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
package/eject/files/Icon.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { icons, type RootProps, useDefaults } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults, useTrigger } from "@xds/react/base";
|
package/eject/files/ListRow.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import { type RootProps, useDefaults } from "@xds/react/base";
|
package/eject/files/Menu.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
leaveEscapeToFields,
|
|
7
7
|
Portal,
|
|
8
8
|
type RootProps,
|
|
9
|
+
readCssPx,
|
|
9
10
|
space,
|
|
10
11
|
TriggerContext,
|
|
11
12
|
type TriggerProps,
|
|
13
|
+
underlayLayerStyle,
|
|
12
14
|
useMergedProps,
|
|
13
15
|
useModalPopover,
|
|
14
16
|
usePresence,
|
|
@@ -50,7 +52,7 @@ export function Menu({ trigger, label, items, align = "start", className, style
|
|
|
50
52
|
"aria-label": label,
|
|
51
53
|
positioning: {
|
|
52
54
|
placement: `bottom-${align}`,
|
|
53
|
-
gutter: space[1],
|
|
55
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
54
56
|
getAnchorRect: (anchor) => (anchor instanceof HTMLElement ? layoutRect(anchor) : null),
|
|
55
57
|
},
|
|
56
58
|
onSelect: (details) => {
|
|
@@ -114,6 +116,7 @@ export function Menu({ trigger, label, items, align = "start", className, style
|
|
|
114
116
|
api.setHighlightedValue(value),
|
|
115
117
|
),
|
|
116
118
|
});
|
|
119
|
+
const positionerProps = api.getPositionerProps();
|
|
117
120
|
return (
|
|
118
121
|
<>
|
|
119
122
|
<TriggerContext value={provided}>{trigger}</TriggerContext>
|
|
@@ -126,14 +129,11 @@ export function Menu({ trigger, label, items, align = "start", className, style
|
|
|
126
129
|
// oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- not a control: the handler only keeps the focus where it is
|
|
127
130
|
<div
|
|
128
131
|
className="{{prefix}}-menu__underlay"
|
|
132
|
+
style={underlayLayerStyle(positionerProps.style)}
|
|
129
133
|
onMouseDown={(event) => event.preventDefault()}
|
|
130
134
|
/>
|
|
131
135
|
)}
|
|
132
|
-
<div
|
|
133
|
-
{...api.getPositionerProps()}
|
|
134
|
-
ref={positioner}
|
|
135
|
-
className="{{prefix}}-menu__positioner"
|
|
136
|
-
>
|
|
136
|
+
<div {...positionerProps} ref={positioner} className="{{prefix}}-menu__positioner">
|
|
137
137
|
{/* Shown until its exit animation ends; Zag would hide it as it closes. */}
|
|
138
138
|
<div {...content} ref={surface} hidden={!present}>
|
|
139
139
|
{items.map((item, index) =>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -46,6 +46,7 @@ export function SearchField({
|
|
|
46
46
|
<input
|
|
47
47
|
ref={input}
|
|
48
48
|
type="text"
|
|
49
|
+
role="searchbox"
|
|
49
50
|
className="{{prefix}}-text-field__input"
|
|
50
51
|
aria-label={label}
|
|
51
52
|
enterKeyHint="search"
|
|
@@ -59,7 +60,10 @@ export function SearchField({
|
|
|
59
60
|
onKeyDown={(event) => {
|
|
60
61
|
// While a composition is open, Enter and Escape belong to the input method.
|
|
61
62
|
if (event.nativeEvent.isComposing) return;
|
|
62
|
-
if (event.key === "Enter"
|
|
63
|
+
if (event.key === "Enter" && onSubmit) {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
onSubmit(value);
|
|
66
|
+
}
|
|
63
67
|
if (event.key === "Escape" && value !== "") {
|
|
64
68
|
event.stopPropagation();
|
|
65
69
|
onChange("");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from `@xds/react` 1.0.0
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0 by `xds eject`. This copy is the app's own: change it
|
|
2
2
|
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
3
|
|
|
4
4
|
import type { RootProps } from "@xds/react/base";
|