@xds/react 1.0.0-rc.1 → 1.0.1

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.
Files changed (111) hide show
  1. package/dist/Accordion.js +3 -2
  2. package/dist/Button.js +5 -3
  3. package/dist/Card.js +1 -1
  4. package/dist/DatePicker.js +167 -170
  5. package/dist/DateRangePicker.js +91 -94
  6. package/dist/Menu.js +83 -75
  7. package/dist/SearchField.js +4 -2
  8. package/dist/Select.js +123 -98
  9. package/dist/Slider.d.ts +1 -1
  10. package/dist/Slider.js +44 -35
  11. package/dist/TextField.js +130 -107
  12. package/dist/Toast.d.ts +1 -1
  13. package/dist/Toast.js +50 -45
  14. package/dist/Tooltip.js +54 -40
  15. package/dist/base.d.ts +1 -1
  16. package/dist/base.js +1 -1
  17. package/dist/picture.js +2 -2
  18. package/dist/portal.d.ts +6 -4
  19. package/dist/portal.js +61 -9
  20. package/eject/files/Accordion.tsx +5 -2
  21. package/eject/files/Avatar.tsx +1 -1
  22. package/eject/files/AvatarStack.tsx +1 -1
  23. package/eject/files/Badge.tsx +1 -1
  24. package/eject/files/Banner.tsx +1 -1
  25. package/eject/files/Button.tsx +9 -5
  26. package/eject/files/Card.tsx +2 -2
  27. package/eject/files/Checkbox.tsx +1 -1
  28. package/eject/files/Chip.tsx +1 -1
  29. package/eject/files/ChipBar.tsx +1 -1
  30. package/eject/files/CountBadge.tsx +1 -1
  31. package/eject/files/DatePicker.tsx +32 -23
  32. package/eject/files/DateRangePicker.tsx +34 -23
  33. package/eject/files/Dialog.tsx +1 -1
  34. package/eject/files/Divider.tsx +1 -1
  35. package/eject/files/EmptyState.tsx +1 -1
  36. package/eject/files/Icon.tsx +1 -1
  37. package/eject/files/IconButton.tsx +1 -1
  38. package/eject/files/ListRow.tsx +1 -1
  39. package/eject/files/MediaCard.tsx +1 -1
  40. package/eject/files/Menu.tsx +7 -7
  41. package/eject/files/ProgressBar.tsx +1 -1
  42. package/eject/files/RadioGroup.tsx +1 -1
  43. package/eject/files/SearchField.tsx +6 -2
  44. package/eject/files/SectionHeader.tsx +1 -1
  45. package/eject/files/SegmentedControl.tsx +1 -1
  46. package/eject/files/Select.tsx +20 -22
  47. package/eject/files/Sidebar.tsx +1 -1
  48. package/eject/files/Skeleton.tsx +1 -1
  49. package/eject/files/Slider.tsx +11 -5
  50. package/eject/files/Spinner.tsx +1 -1
  51. package/eject/files/Switch.tsx +1 -1
  52. package/eject/files/Tabs.tsx +1 -1
  53. package/eject/files/Text.tsx +1 -1
  54. package/eject/files/TextField.tsx +18 -4
  55. package/eject/files/Thumbnail.tsx +1 -1
  56. package/eject/files/Toast.tsx +11 -15
  57. package/eject/files/Tooltip.tsx +9 -3
  58. package/eject/files/accordion.css +1 -1
  59. package/eject/files/accordion.ts +1 -1
  60. package/eject/files/avatar-stack.ts +1 -1
  61. package/eject/files/avatar.ts +1 -1
  62. package/eject/files/badge.ts +1 -1
  63. package/eject/files/banner.ts +1 -1
  64. package/eject/files/base.css +1 -1
  65. package/eject/files/button.css +3 -3
  66. package/eject/files/button.ts +1 -1
  67. package/eject/files/card.ts +1 -1
  68. package/eject/files/checkbox.ts +1 -1
  69. package/eject/files/chip-bar.ts +1 -1
  70. package/eject/files/chip.ts +1 -1
  71. package/eject/files/count-badge.ts +1 -1
  72. package/eject/files/date-picker.css +5 -5
  73. package/eject/files/date-picker.ts +30 -11
  74. package/eject/files/date-range-picker.ts +16 -8
  75. package/eject/files/dialog.css +6 -6
  76. package/eject/files/dialog.ts +1 -1
  77. package/eject/files/divider.ts +1 -1
  78. package/eject/files/empty-state.ts +1 -1
  79. package/eject/files/icon.ts +1 -1
  80. package/eject/files/list-row.ts +1 -1
  81. package/eject/files/media-card.ts +1 -1
  82. package/eject/files/menu.css +4 -4
  83. package/eject/files/menu.ts +1 -1
  84. package/eject/files/overlay.css +40 -0
  85. package/eject/files/parts.ts +1 -1
  86. package/eject/files/progress-bar.ts +1 -1
  87. package/eject/files/radio-group.css +1 -1
  88. package/eject/files/radio-group.ts +1 -1
  89. package/eject/files/section-header.ts +1 -1
  90. package/eject/files/segmented-control.ts +1 -1
  91. package/eject/files/select.css +17 -6
  92. package/eject/files/select.ts +1 -1
  93. package/eject/files/sidebar.ts +1 -1
  94. package/eject/files/skeleton.ts +1 -1
  95. package/eject/files/slider.css +1 -1
  96. package/eject/files/slider.ts +17 -5
  97. package/eject/files/spinner.ts +1 -1
  98. package/eject/files/switch.ts +1 -1
  99. package/eject/files/tabs.css +1 -1
  100. package/eject/files/tabs.ts +1 -1
  101. package/eject/files/text-field.css +4 -8
  102. package/eject/files/text-field.ts +1 -1
  103. package/eject/files/text.ts +1 -1
  104. package/eject/files/thumbnail.ts +1 -1
  105. package/eject/files/toast.ts +1 -1
  106. package/eject/files/tooltip.css +3 -3
  107. package/eject/files/tooltip.ts +1 -1
  108. package/eject/manifest.json +4 -2
  109. package/package.json +3 -3
  110. package/styles.css +15 -11
  111. package/tailwind.css +21 -14
@@ -1,11 +1,13 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 {
5
5
  keepListKeys,
6
6
  Portal,
7
7
  type RootProps,
8
+ readCssPx,
8
9
  space,
10
+ underlayLayerStyle,
9
11
  useModalPopover,
10
12
  usePresence,
11
13
  } from "@xds/react/base";
@@ -76,10 +78,10 @@ export function Select<Value extends string = string>({
76
78
  name,
77
79
  positioning: {
78
80
  placement: "bottom-start",
79
- gutter: space[1],
81
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
80
82
  sameWidth: true,
81
83
  // The list keeps this far from the window's edges.
82
- overflowPadding: space[3],
84
+ overflowPadding: readCssPx(null, "--xds-space-3", space[3]),
83
85
  },
84
86
  });
85
87
  const api = select.connect(service, normalizeProps);
@@ -116,6 +118,7 @@ export function Select<Value extends string = string>({
116
118
  };
117
119
  useModalPopover(api.open, () => positioner.current);
118
120
  const present = usePresence(api.open, () => [surface.current]);
121
+ const positionerProps = api.getPositionerProps();
119
122
  return (
120
123
  <div
121
124
  {...mergeProps(api.getRootProps(), {
@@ -147,20 +150,18 @@ export function Select<Value extends string = string>({
147
150
  </span>
148
151
  <Icon name="chevrons-up-down" size="sm" className="text-xds-field-placeholder" />
149
152
  </button>
150
- {/* One line under the box: the help, or the error in its place. */}
151
- {(invalid || description) && (
152
- <div className="{{prefix}}-select__footer">
153
- {invalid ? (
154
- <span id={errorId} className="{{prefix}}-select__error">
155
- {error}
156
- </span>
157
- ) : (
158
- <span id={descriptionId} className="{{prefix}}-select__description">
159
- {description}
160
- </span>
161
- )}
162
- </div>
163
- )}
153
+ {/* One line under the box: the help, or the error in its place. The error stays mounted as
154
+ a live region so assistive technology announces it when it appears. */}
155
+ <div className="{{prefix}}-select__footer">
156
+ {!invalid && description && (
157
+ <span id={descriptionId} className="{{prefix}}-select__description">
158
+ {description}
159
+ </span>
160
+ )}
161
+ <span id={errorId} className="{{prefix}}-select__error" aria-live="polite">
162
+ {error}
163
+ </span>
164
+ </div>
164
165
  {/* What a form submits; the first option stands for no choice. */}
165
166
  <select {...api.getHiddenSelectProps()}>
166
167
  {/* oxlint-disable-next-line jsx-a11y/control-has-associated-label -- Zag's props hide the select from assistive technology, which uses the trigger */}
@@ -178,14 +179,11 @@ export function Select<Value extends string = string>({
178
179
  // oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- not a control: the handler only keeps the focus where it is
179
180
  <div
180
181
  className="{{prefix}}-select__underlay"
182
+ style={underlayLayerStyle(positionerProps.style)}
181
183
  onMouseDown={(event) => event.preventDefault()}
182
184
  />
183
185
  )}
184
- <div
185
- {...api.getPositionerProps()}
186
- ref={positioner}
187
- className="{{prefix}}-select__positioner"
188
- >
186
+ <div {...positionerProps} ref={positioner} className="{{prefix}}-select__positioner">
189
187
  {/* Shown until its exit animation ends; Zag would hide it as it closes. */}
190
188
  <div {...content} ref={surface} hidden={!present} className="{{prefix}}-select__content">
191
189
  <div {...api.getListProps()} className="{{prefix}}-select__list">
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 IconName, type RootProps, useTrigger } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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, useMergedProps } from "@xds/react/base";
@@ -35,12 +35,15 @@ export function Slider({
35
35
  step = 1,
36
36
  disabled = false,
37
37
  showValue = false,
38
+ name,
39
+ locale,
38
40
  className,
39
41
  style,
40
42
  }: SliderProps) {
41
43
  const pageSize = sliderPageSize({ min, max, step });
42
44
  const service = useMachine(slider.machine, {
43
45
  id: useId(),
46
+ name,
44
47
  value: [value],
45
48
  // One thumb, so one number.
46
49
  onValueChange: (details) => onChange(details.value[0] ?? min),
@@ -51,13 +54,13 @@ export function Slider({
51
54
  disabled,
52
55
  // The thumb's center is on the value, at the ends too; the band is inset to make room.
53
56
  thumbAlignment: "center",
54
- getAriaValueText: (details) => sliderValueText(details.value),
57
+ getAriaValueText: (details) => sliderValueText(details.value, locale),
55
58
  });
56
59
  const api = slider.connect(service, normalizeProps);
57
60
  const thumbElement = useRef<HTMLDivElement>(null);
58
61
  const thumb = mergeProps(api.getThumbProps({ index: 0 }), {
59
62
  // Up and Down move a horizontal slider too, as they move a native range input.
60
- onKeyDown: (event: { key: string; shiftKey: boolean }) => {
63
+ onKeyDown: (event: { key: string; shiftKey: boolean; preventDefault(): void }) => {
61
64
  if (disabled) return;
62
65
  const next = sliderArrowValue(event, {
63
66
  value: api.value[0] ?? min,
@@ -66,7 +69,10 @@ export function Slider({
66
69
  step,
67
70
  pageSize,
68
71
  });
69
- if (next !== undefined) api.setThumbValue(0, next);
72
+ if (next !== undefined) {
73
+ event.preventDefault();
74
+ api.setThumbValue(0, next);
75
+ }
70
76
  },
71
77
  });
72
78
  const control = useMergedProps(api.getControlProps(), {
@@ -93,7 +99,7 @@ export function Slider({
93
99
  {showValue && (
94
100
  // Read when asked for, not at every step: the slider itself announces its value.
95
101
  <output {...api.getValueTextProps()} aria-live="off" className="{{prefix}}-slider__output">
96
- {sliderValueText(api.value[0] ?? value)}
102
+ {sliderValueText(api.value[0] ?? value, locale)}
97
103
  </output>
98
104
  )}
99
105
  <div {...control} className="{{prefix}}-slider__control">
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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";
@@ -1,8 +1,8 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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";
5
- import { type ReactNode, useId } from "react";
5
+ import { type ReactNode, useEffect, useId, useRef } from "react";
6
6
  import { classes } from "./parts.ts";
7
7
  import type { TextFieldBaseProps } from "./text-field.ts";
8
8
 
@@ -49,9 +49,13 @@ export function TextField({
49
49
  style,
50
50
  }: TextFieldProps) {
51
51
  const id = useId();
52
+ const inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null);
52
53
  const descriptionId = `${id}-description`;
53
54
  const errorId = `${id}-error`;
54
55
  const invalid = error !== undefined;
56
+ useEffect(() => {
57
+ inputRef.current?.setCustomValidity(error ?? "");
58
+ }, [error, multiline]);
55
59
  // The box is drawn by the input itself until something has to sit inside it beside the
56
60
  // text; then a group draws the box and the input inside it has none.
57
61
  const grouped = leading != null || trailing != null;
@@ -74,9 +78,19 @@ export function TextField({
74
78
  "aria-describedby": invalid ? errorId : description ? descriptionId : undefined,
75
79
  };
76
80
  const field = multiline ? (
77
- <textarea {...shared} rows={rows} onChange={(event) => onChange(event.currentTarget.value)} />
81
+ <textarea
82
+ {...shared}
83
+ ref={inputRef}
84
+ rows={rows}
85
+ onChange={(event) => onChange(event.currentTarget.value)}
86
+ />
78
87
  ) : (
79
- <input {...shared} type={type} onChange={(event) => onChange(event.currentTarget.value)} />
88
+ <input
89
+ {...shared}
90
+ ref={inputRef}
91
+ type={type}
92
+ onChange={(event) => onChange(event.currentTarget.value)}
93
+ />
80
94
  );
81
95
  return (
82
96
  <div className={classes("{{prefix}}-text-field", className)} style={style}>
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { pictureClass, type RootProps, useDefaults, usePicture } from "@xds/react/base";
@@ -1,7 +1,7 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { motion, type RootProps } from "@xds/react/base";
4
+ import { motion, type RootProps, readCssMs } from "@xds/react/base";
5
5
  import { useEffect, useEffectEvent, useRef, useState } from "react";
6
6
  import { classes, rootPart } from "./parts.ts";
7
7
  import { TOAST_PARTS, type ToastBaseProps } from "./toast.ts";
@@ -19,15 +19,7 @@ export type ToastProps = ToastBaseProps &
19
19
  *
20
20
  * Do not put the only way to do something in a toast: it is gone in a few seconds.
21
21
  */
22
- export function Toast({
23
- open,
24
- onClose,
25
- message,
26
- action,
27
- duration = motion.duration.toast,
28
- className,
29
- style,
30
- }: ToastProps) {
22
+ export function Toast({ open, onClose, message, action, duration, className, style }: ToastProps) {
31
23
  const region = useRef<HTMLDivElement>(null);
32
24
  const [hovered, setHovered] = useState(false);
33
25
  const [focused, setFocused] = useState(false);
@@ -41,7 +33,9 @@ export function Toast({
41
33
  const element = region.current;
42
34
  if (!element?.showPopover) return;
43
35
  element.showPopover();
44
- return () => element.hidePopover();
36
+ return () => {
37
+ if (element.isConnected && element.matches(":popover-open")) element.hidePopover();
38
+ };
45
39
  }, []);
46
40
 
47
41
  useEffect(() => {
@@ -50,10 +44,12 @@ export function Toast({
50
44
  setHovered(false);
51
45
  setFocused(false);
52
46
  }
53
- if (!open || held || duration <= 0) return;
54
- const timer = setTimeout(() => close(), duration);
47
+ const ms =
48
+ duration ?? readCssMs(region.current, "--xds-motion-duration-toast", motion.duration.toast);
49
+ if (!open || held || ms <= 0) return;
50
+ const timer = setTimeout(() => close(), ms);
55
51
  return () => clearTimeout(timer);
56
- }, [open, held, duration]);
52
+ }, [open, held, duration, message]);
57
53
 
58
54
  return (
59
55
  <div ref={region} role="status" popover="manual" className={TOAST_PARTS.region}>
@@ -1,10 +1,12 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 {
5
5
  motion,
6
6
  Portal,
7
7
  type RootProps,
8
+ readCssMs,
9
+ readCssPx,
8
10
  space,
9
11
  TriggerContext,
10
12
  usePresence,
@@ -80,13 +82,17 @@ function Overlay({
80
82
  }) {
81
83
  const service = useMachine(tooltip.machine, {
82
84
  id: useId(),
83
- openDelay: motion.duration.tooltipDelay,
85
+ openDelay: readCssMs(
86
+ null,
87
+ "--xds-motion-duration-tooltip-delay",
88
+ motion.duration.tooltipDelay,
89
+ ),
84
90
  closeDelay: 0,
85
91
  // It stays and follows its control when the page scrolls, for as long as the control keeps
86
92
  // focus or the pointer. Tabbing to a control out of view scrolls the page, and a tooltip
87
93
  // closed by that scroll would never show for it.
88
94
  closeOnScroll: false,
89
- positioning: { placement, gutter: space[1] },
95
+ positioning: { placement, gutter: readCssPx(null, "--xds-space-1", space[1]) },
90
96
  });
91
97
  const api = tooltip.connect(service, normalizeProps);
92
98
  const trigger = useProvideTrigger(api.getTriggerProps());
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
2
+ * Ejected from `@xds/react` 1.0.1 by `xds eject`. This copy is the app's own: change it
3
3
  * as you need. `xds eject --list` says which ejected files differ from what was copied.
4
4
  */
5
5
  /*
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { afterAnimations, focusWithoutRing } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { AVATAR_SIZE, type AvatarSize } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { initials } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { IconName } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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
  const TONE = {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
2
+ * Ejected from `@xds/react` 1.0.1 by `xds eject`. This copy is the app's own: change it
3
3
  * as you need. `xds eject --list` says which ejected files differ from what was copied.
4
4
  */
5
5
  /*
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
2
+ * Ejected from `@xds/react` 1.0.1 by `xds eject`. This copy is the app's own: change it
3
3
  * as you need. `xds eject --list` says which ejected files differ from what was copied.
4
4
  */
5
5
  /*
@@ -59,12 +59,12 @@
59
59
  }
60
60
 
61
61
  /* A press shrinks the button a little: feedback that does not depend on color. */
62
- .{{prefix}}-button:active:not(:disabled) {
62
+ .{{prefix}}-button:active:not(:disabled):not([data-pending]) {
63
63
  transform: scale(var(--xds-motion-press-scale));
64
64
  }
65
65
 
66
66
  @media (prefers-reduced-motion: reduce) {
67
- .{{prefix}}-button:active:not(:disabled) {
67
+ .{{prefix}}-button:active:not(:disabled):not([data-pending]) {
68
68
  transform: none;
69
69
  }
70
70
  }
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { IconName, IconSize } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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
  /** Card's props in every framework, short of `onPress`, its content, `actions` and `media`. */
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { PEER_FOCUS } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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
  /** ChipBar's props in every framework, short of the chips. */
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { IconName } from "@xds/react/base";
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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
  /** CountBadge's props in every framework, short of the child it sits on. */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
2
+ * Ejected from `@xds/react` 1.0.1 by `xds eject`. This copy is the app's own: change it
3
3
  * as you need. `xds eject --list` says which ejected files differ from what was copied.
4
4
  */
5
5
  /*
@@ -15,7 +15,7 @@
15
15
  * States on a day: `:hover`, `:active`, `:focus-visible`, `[data-selected]`, `[data-today]`,
16
16
  * `[data-disabled]` (outside `min`..`max`), `[data-outside-range]` (a day of the month before
17
17
  * or after). On the content: `[data-side]`, and `[data-state="closed"]` while it animates out.
18
- * The positioner stacks by `--xds-layer-overlay` and Zag's `--layer-index`.
18
+ * The positioner stacks by `--{{prefix}}-layer-overlay` and Zag's `--layer-index`.
19
19
  *
20
20
  * DateRangePicker draws the same calendar under `.{{prefix}}-date-range-picker` (its root, beside
21
21
  * `.{{prefix}}-date-picker`) and `.{{prefix}}-date-range-picker__content`, with more parts: `__summary` (the two ends
@@ -33,11 +33,11 @@
33
33
  .{{prefix}}-date-picker__underlay {
34
34
  position: fixed;
35
35
  inset: 0;
36
- z-index: var(--xds-layer-overlay);
36
+ z-index: calc(var(--{{prefix}}-layer-overlay) + var(--layer-index, 0));
37
37
  }
38
38
 
39
39
  .{{prefix}}-date-picker__positioner {
40
- z-index: calc(var(--xds-layer-overlay) + var(--layer-index, 0));
40
+ z-index: calc(var(--{{prefix}}-layer-overlay) + var(--layer-index, 0));
41
41
  }
42
42
 
43
43
  /* A raised surface, as wide as seven days and its inset. */
@@ -63,7 +63,7 @@
63
63
 
64
64
  /* After the rules above, which it replaces. A closing calendar takes no more presses. */
65
65
  .{{prefix}}-date-picker__content[data-state="closed"] {
66
- animation: xds-overlay-exit var(--xds-motion-duration-fast) var(--xds-motion-easing-exit)
66
+ animation: {{prefix}}-overlay-exit var(--xds-motion-duration-fast) var(--xds-motion-easing-exit)
67
67
  forwards;
68
68
  pointer-events: none;
69
69
  }
@@ -1,4 +1,4 @@
1
- // Ejected from `@xds/react` 1.0.0-rc.1 by `xds eject`. This copy is the app's own: change it
1
+ // Ejected from `@xds/react` 1.0.1 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 { buttonClass, space } from "@xds/react/base";
@@ -31,13 +31,27 @@ export type DatePickerBaseProps = {
31
31
  previousLabel?: string;
32
32
  /** Names the calendar's button to the month after, for assistive technology. */
33
33
  nextLabel?: string;
34
+ /** Formats dates and calendar headings in a fixed locale (avoids SSR locale mismatches). */
35
+ locale?: string;
34
36
  };
35
37
 
38
+ /** Parses a strict calendar `YYYY-MM-DD` day, returning `undefined` for malformed or impossible dates. */
39
+ export function parseIsoDate(value: IsoDate | undefined): DateValue | undefined {
40
+ if (value === undefined || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return undefined;
41
+ try {
42
+ const parsed = parseDate(value);
43
+ return parsed.toString() === value ? parsed : undefined;
44
+ } catch {
45
+ return undefined;
46
+ }
47
+ }
48
+
36
49
  /**
37
50
  * The day as the field shows it: the locale's medium form ("Mar 10, 2026", "2026. 3. 10.").
38
51
  * Read at noon UTC and formatted in UTC, so no time zone can move it to another day.
39
52
  */
40
53
  export function formatDay(value: IsoDate, locale: string): string {
54
+ if (!parseIsoDate(value)) return "";
41
55
  return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(
42
56
  new Date(`${value}T12:00:00Z`),
43
57
  );
@@ -50,6 +64,8 @@ export function todayIso(): IsoDate {
50
64
 
51
65
  /** `day`, or the nearer of `min` and `max` when it is outside them. */
52
66
  export function clampDay(day: IsoDate, min?: IsoDate, max?: IsoDate): IsoDate {
67
+ // Inverted bounds leave nothing to clamp between; keep `day` as given.
68
+ if (min !== undefined && max !== undefined && min > max) return day;
53
69
  // Strings of the same form sort as the days they name.
54
70
  if (min !== undefined && day < min) return min;
55
71
  if (max !== undefined && day > max) return max;
@@ -64,15 +80,16 @@ export function openingDay(
64
80
  props: Pick<DatePickerBaseProps, "value" | "min" | "max">,
65
81
  now: IsoDate = todayIso(),
66
82
  ): IsoDate {
67
- return clampDay(props.value ?? now, props.min, props.max);
83
+ const valid = (value: IsoDate | undefined) => (parseIsoDate(value) ? value : undefined);
84
+ return clampDay(valid(props.value) ?? now, valid(props.min), valid(props.max));
68
85
  }
69
86
 
70
87
  /**
71
88
  * The language of the names of the days and months, and of the field's form of a day: the
72
- * page's, as a native date input takes it. Zag's own default is English.
89
+ * explicit `locale` prop if given, otherwise the page's language (falling back to English on SSR).
73
90
  */
74
- export function datePickerLocale(): string {
75
- return typeof navigator === "undefined" ? "en-US" : navigator.language;
91
+ export function datePickerLocale(locale?: string): string {
92
+ return locale ?? (typeof navigator === "undefined" ? "en-US" : navigator.language);
76
93
  }
77
94
 
78
95
  /** The ids of the parts the library names itself, under the DatePicker's own id. */
@@ -94,17 +111,19 @@ type Ids = ReturnType<typeof datePickerIds>;
94
111
  */
95
112
  export function datePickerMachineProps(
96
113
  props: DatePickerBaseProps,
97
- options: { id: string; locale: string; onChange: (value: IsoDate) => void },
114
+ options: { id: string; locale: string; onChange: (value: IsoDate) => void; gutter?: number },
98
115
  ): datePicker.Props {
99
- const day = (value: IsoDate | undefined) => (value === undefined ? undefined : parseDate(value));
116
+ const value = parseIsoDate(props.value);
117
+ const min = parseIsoDate(props.min);
118
+ const max = parseIsoDate(props.max);
100
119
  return {
101
120
  id: options.id,
102
121
  locale: options.locale,
103
122
  // Today is the day where the page runs; Zag's own is the day in UTC.
104
123
  timeZone: getLocalTimeZone(),
105
- value: props.value === undefined ? [] : [parseDate(props.value)],
106
- min: day(props.min),
107
- max: day(props.max),
124
+ value: value === undefined ? [] : [value],
125
+ min,
126
+ max,
108
127
  defaultFocusedValue: parseDate(openingDay(props)),
109
128
  onValueChange: (details) => {
110
129
  const next = details.value[0];
@@ -117,7 +136,7 @@ export function datePickerMachineProps(
117
136
  outsideDaySelectable: false,
118
137
  minView: "day",
119
138
  maxView: "day",
120
- positioning: { placement: "bottom-start", gutter: space[1] },
139
+ positioning: { placement: "bottom-start", gutter: options.gutter ?? space[1] },
121
140
  translations: datePickerTranslations(props),
122
141
  };
123
142
  }