rift-ds 1.41.0 → 1.42.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.
Files changed (187) hide show
  1. package/behaviors/LoadingImage.d.ts +2 -0
  2. package/behaviors/LoadingImage.js +34 -0
  3. package/behaviors/ScrollRegion.js +15 -2
  4. package/behaviors/VisuallyHidden.d.ts +30 -0
  5. package/behaviors/VisuallyHidden.js +17 -0
  6. package/behaviors/loading-image.css +30 -0
  7. package/behaviors/quietFocus.d.ts +4 -0
  8. package/behaviors/quietFocus.js +14 -0
  9. package/behaviors/useFocusScope.d.ts +3 -1
  10. package/behaviors/useFocusScope.js +4 -6
  11. package/bin/rift-ds.mjs +1 -0
  12. package/bin/templates/app/components/rift/ColorModeScript.tsx +3 -1
  13. package/bin/templates/app/components/rift/RiftRoot.tsx +40 -1
  14. package/bin/templates/blocks/app/dashboard/page.tsx +7 -5
  15. package/bin/templates/blocks/app/landing/page.tsx +1 -1
  16. package/bin/templates/blocks/app/pricing/page.module.css +15 -1
  17. package/bin/templates/blocks/app/pricing/page.tsx +8 -1
  18. package/bin/templates/blocks/app/sign-in/page.tsx +10 -2
  19. package/bin/templates/blocks/app/sign-up/page.module.css +83 -0
  20. package/bin/templates/blocks/app/sign-up/page.tsx +126 -0
  21. package/bin/templates/blocks/app/starter/page.tsx +1 -1
  22. package/bin/templates/blocks/components/blocks/AppShell.module.css +0 -10
  23. package/bin/templates/blocks/components/blocks/AppShell.tsx +39 -115
  24. package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
  25. package/bin/templates/blocks/registry.json +44 -6
  26. package/components/AgentPlan/AgentPlan.css +1 -1
  27. package/components/AlertDialog/AlertDialog.css +14 -0
  28. package/components/AlertDialog/AlertDialog.d.ts +35 -3
  29. package/components/AlertDialog/AlertDialog.js +16 -5
  30. package/components/AppSidebar/AppSidebar.css +13 -2
  31. package/components/AppSidebar/AppSidebar.js +7 -2
  32. package/components/Attachment/AttachmentGroup.js +2 -1
  33. package/components/Attachment/AttachmentTile.js +2 -1
  34. package/components/Badge/Badge.css +6 -0
  35. package/components/Breadcrumb/Breadcrumb.css +4 -1
  36. package/components/Button/Button.css +20 -1
  37. package/components/Button/Button.js +6 -1
  38. package/components/Card/Card.css +11 -0
  39. package/components/Card/Card.d.ts +9 -3
  40. package/components/Card/Card.js +21 -2
  41. package/components/Chart/AreaChart.d.ts +7 -0
  42. package/components/Chart/AreaChart.js +51 -45
  43. package/components/Chart/BarChart.d.ts +7 -0
  44. package/components/Chart/BarChart.js +52 -46
  45. package/components/Chart/Chart.css +122 -1
  46. package/components/Chart/ChartSkeleton.d.ts +32 -0
  47. package/components/Chart/ChartSkeleton.js +149 -0
  48. package/components/Chart/ComboChart.d.ts +7 -0
  49. package/components/Chart/ComboChart.js +80 -74
  50. package/components/Chart/LineChart.d.ts +17 -3
  51. package/components/Chart/LineChart.js +61 -39
  52. package/components/Chart/PieChart.d.ts +7 -0
  53. package/components/Chart/PieChart.js +41 -34
  54. package/components/Chart/RadarChart.d.ts +7 -0
  55. package/components/Chart/RadarChart.js +38 -32
  56. package/components/Chart/RadialChart.d.ts +7 -0
  57. package/components/Chart/RadialChart.js +5 -1
  58. package/components/Chart/ScatterChart.d.ts +7 -0
  59. package/components/Chart/ScatterChart.js +46 -40
  60. package/components/Chart/StackedBarChart.d.ts +10 -1
  61. package/components/Chart/StackedBarChart.js +51 -43
  62. package/components/Chart/Treemap.d.ts +7 -0
  63. package/components/Chart/Treemap.js +17 -11
  64. package/components/Checkbox/Checkbox.css +25 -1
  65. package/components/Checkbox/Checkbox.d.ts +8 -4
  66. package/components/Checkbox/Checkbox.js +17 -8
  67. package/components/Chip/Chip.css +5 -3
  68. package/components/ContactCard/ContactCard.css +4 -3
  69. package/components/ContributionGraph/ContributionGraph.css +20 -0
  70. package/components/ContributionGraph/ContributionGraph.d.ts +4 -0
  71. package/components/ContributionGraph/ContributionGraph.js +11 -6
  72. package/components/DataTable/DataTable.css +28 -4
  73. package/components/DataTable/DataTable.d.ts +16 -2
  74. package/components/DataTable/DataTable.js +5 -0
  75. package/components/DateInput/DateInput.css +3 -1
  76. package/components/DatePicker/DatePicker.css +16 -0
  77. package/components/DatePicker/DatePicker.d.ts +13 -0
  78. package/components/DatePicker/DatePicker.js +21 -27
  79. package/components/DatePicker/MonthGrid.d.ts +2 -2
  80. package/components/DatePicker/MonthGrid.js +1 -1
  81. package/components/DatePicker/today.d.ts +15 -0
  82. package/components/DatePicker/today.js +17 -0
  83. package/components/DateRangePicker/DateRangePicker.d.ts +14 -1
  84. package/components/DateRangePicker/DateRangePicker.js +18 -7
  85. package/components/DescriptionList/DescriptionList.css +11 -0
  86. package/components/DescriptionList/DescriptionList.d.ts +5 -1
  87. package/components/DescriptionList/DescriptionList.js +21 -6
  88. package/components/Dialog/Dialog.css +9 -0
  89. package/components/Dialog/Dialog.d.ts +9 -0
  90. package/components/Dialog/Dialog.js +32 -19
  91. package/components/DocumentChip/DocumentChip.css +1 -1
  92. package/components/Drawer/Drawer.d.ts +9 -0
  93. package/components/Drawer/Drawer.js +8 -0
  94. package/components/Dropdown/Dropdown.css +3 -1
  95. package/components/EmptyState/EmptyState.css +8 -1
  96. package/components/Field/Field.css +2 -2
  97. package/components/FileInput/FileInput.css +1 -1
  98. package/components/FilterBar/FilterBar.d.ts +6 -1
  99. package/components/FunnelChart/FunnelChart.d.ts +7 -0
  100. package/components/FunnelChart/FunnelChart.js +44 -30
  101. package/components/GanttChart/GanttChart.css +10 -0
  102. package/components/GanttChart/GanttChart.d.ts +4 -0
  103. package/components/GanttChart/GanttChart.js +66 -33
  104. package/components/Gauge/Gauge.css +23 -0
  105. package/components/Gauge/Gauge.d.ts +4 -0
  106. package/components/Gauge/Gauge.js +14 -8
  107. package/components/ImageCompare/ImageCompare.js +2 -1
  108. package/components/Input/Input.css +3 -1
  109. package/components/List/List.css +1 -1
  110. package/components/NotificationCenter/NotificationCenter.css +16 -0
  111. package/components/NotificationCenter/NotificationCenter.d.ts +4 -0
  112. package/components/NotificationCenter/NotificationCenter.js +23 -1
  113. package/components/NumberInput/NumberInput.css +2 -0
  114. package/components/PageHeader/PageHeader.css +12 -4
  115. package/components/Panel/Panel.d.ts +1 -1
  116. package/components/Prose/Prose.css +1 -1
  117. package/components/RadioButton/RadioButton.css +1 -1
  118. package/components/RadioButton/RadioButton.d.ts +4 -2
  119. package/components/RadioButton/RadioButton.js +5 -2
  120. package/components/ResourceTimeline/ResourceTimeline.css +12 -0
  121. package/components/ResourceTimeline/ResourceTimeline.d.ts +5 -1
  122. package/components/ResourceTimeline/ResourceTimeline.js +94 -52
  123. package/components/RichDropdown/RichDropdown.css +3 -1
  124. package/components/SelectionCard/SelectionCard.css +29 -0
  125. package/components/SelectionCard/SelectionCard.d.ts +7 -0
  126. package/components/SelectionCard/SelectionCard.js +25 -2
  127. package/components/Sparkline/Sparkline.css +20 -0
  128. package/components/Sparkline/Sparkline.d.ts +4 -0
  129. package/components/Sparkline/Sparkline.js +14 -8
  130. package/components/Stat/Stat.css +31 -0
  131. package/components/Stat/Stat.d.ts +23 -2
  132. package/components/Stat/Stat.js +21 -6
  133. package/components/Table/Table.css +101 -16
  134. package/components/Table/Table.d.ts +4 -0
  135. package/components/Table/Table.js +43 -28
  136. package/components/Textarea/Textarea.css +4 -2
  137. package/components/ThemeToggle/colorMode.d.ts +10 -2
  138. package/components/ThemeToggle/colorMode.js +4 -2
  139. package/components/ThreadHistory/ThreadHistory.css +11 -0
  140. package/components/ThreadHistory/ThreadHistory.d.ts +5 -1
  141. package/components/ThreadHistory/ThreadHistory.js +6 -1
  142. package/components/ThreadPanel/ThreadPanel.d.ts +4 -0
  143. package/components/ThreadPanel/ThreadPanel.js +5 -1
  144. package/components/TimePicker/TimePicker.css +3 -1
  145. package/components/TimePicker/TimePicker.d.ts +4 -2
  146. package/components/TimePicker/TimePicker.js +11 -3
  147. package/components/Timeline/Timeline.css +15 -0
  148. package/components/Timeline/Timeline.d.ts +8 -0
  149. package/components/Timeline/Timeline.js +21 -0
  150. package/components/Toast/Toast.css +16 -0
  151. package/components/Toast/Toast.d.ts +7 -2
  152. package/components/ToggleGroup/ToggleGroup.css +28 -2
  153. package/components/ToggleSwitch/ToggleSwitch.css +1 -1
  154. package/components/Tooltip/Tooltip.d.ts +9 -0
  155. package/components/Tooltip/Tooltip.js +34 -8
  156. package/components/TreeView/TreeView.css +12 -0
  157. package/components/TreeView/TreeView.d.ts +4 -0
  158. package/components/TreeView/TreeView.js +20 -0
  159. package/components/UsageCard/UsageCard.css +11 -0
  160. package/components/UsageCard/UsageCard.d.ts +4 -0
  161. package/components/UsageCard/UsageCard.js +25 -16
  162. package/components/Widget/Widget.css +7 -0
  163. package/components/Widget/Widget.d.ts +4 -0
  164. package/components/Widget/Widget.js +14 -2
  165. package/components/registry.json +4 -1
  166. package/components/registry.json.d.ts +4 -1
  167. package/components/registry.json.js +1 -1
  168. package/package.json +7 -2
  169. package/tokens/presets/contrast.css +4 -4
  170. package/tokens/presets/coral.css +3 -4
  171. package/tokens/presets/forest.css +16 -4
  172. package/tokens/presets/gold.css +4 -3
  173. package/tokens/presets/marquee.css +2 -3
  174. package/tokens/presets/mono.css +28 -28
  175. package/tokens/presets/pink.css +5 -4
  176. package/tokens/presets/terminal.css +4 -3
  177. package/tokens/presets/violet.css +3 -4
  178. package/tokens/presets/warm.css +16 -4
  179. package/tokens/presets/zest.css +2 -2
  180. package/tokens/registry.json +1 -0
  181. package/tokens/registry.json.d.ts +1 -0
  182. package/tokens/registry.json.js +1 -1
  183. package/tokens/tokens-dark.css +4 -0
  184. package/tokens/tokens-light.css +4 -0
  185. package/tokens/values.d.ts +14 -1
  186. package/tokens/values.js +14 -1
  187. package/tokens/values.json.js +1 -1
@@ -15,8 +15,9 @@
15
15
  align-items: center;
16
16
  gap: var(--gap-200); /* 8px */
17
17
 
18
- /* Spacing — 32px tall at default size */
19
- padding: var(--padding-150) var(--padding-300); /* 6px 12px */
18
+ /* Spacing: 32px tall at the default size, the compact control height.
19
+ The hairline counts toward it, so the block padding gives it back. */
20
+ padding: calc(var(--padding-150) - var(--border-025)) var(--padding-300); /* 5px 12px */
20
21
 
21
22
  /* Shape */
22
23
  border: var(--border-025) solid var(--color-bg-container-border);
@@ -50,7 +51,8 @@
50
51
  ============================================ */
51
52
 
52
53
  .ds-chip--large {
53
- padding: var(--padding-200) var(--padding-500); /* 8px 20px */
54
+ /* 40px tall, the default control height, hairline included. */
55
+ padding: calc(var(--padding-200) - var(--border-025)) var(--padding-500); /* 7px 20px */
54
56
  font-family: var(--font-paragraph-emphasis-family);
55
57
  font-size: var(--font-paragraph-emphasis-size);
56
58
  font-weight: var(--font-paragraph-emphasis-weight);
@@ -79,9 +79,10 @@
79
79
  font-weight: var(--font-paragraph-sm-weight);
80
80
  line-height: var(--font-paragraph-sm-line-height);
81
81
  color: var(--color-text-tertiary);
82
- white-space: nowrap;
83
- overflow: hidden;
84
- text-overflow: ellipsis;
82
+ /* The value is what the card is for (an email, a number), so it wraps
83
+ rather than ending in an ellipsis, breaking inside a long address
84
+ when it must. */
85
+ overflow-wrap: anywhere;
85
86
  }
86
87
 
87
88
  /* Actions */
@@ -172,4 +172,24 @@
172
172
  margin-inline-start: var(--gap-050);
173
173
  }
174
174
 
175
+ /* Loading: every day an empty cell, the whole grid pulsing in place of the
176
+ mount sweep. */
177
+
178
+ .ds-contribution-graph__grid--loading {
179
+ /* ds-allow(motion): the pulse needs a symmetric in-out curve and no
180
+ --motion-ease-* token provides one; the duration is tokenized. */
181
+ animation: ds-contribution-graph-pulse var(--motion-duration-loop-shimmer) ease-in-out infinite alternate;
182
+ }
183
+
184
+ .ds-contribution-graph__grid--loading .ds-contribution-graph__cell {
185
+ background-color: var(--color-bg-container-secondary);
186
+ animation: none;
187
+ }
188
+
189
+ @keyframes ds-contribution-graph-pulse {
190
+ to {
191
+ opacity: 0.5;
192
+ }
193
+ }
194
+
175
195
  } /* @layer rift.components */
@@ -66,6 +66,10 @@ type ContributionGraphOwnProps = {
66
66
  cellLabel?: (count: number, date: Date) => string;
67
67
  /** Additional CSS classes */
68
68
  className?: string;
69
+ /** Draws the grid with every day empty, pulsing, while the activity is being fetched: the weeks `days` covers, or half a year when it is empty. */
70
+ loading?: boolean;
71
+ /** Accessible name announced while `loading`. */
72
+ loadingLabel?: string;
69
73
  };
70
74
  export interface ContributionGraphProps extends ContributionGraphOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof ContributionGraphOwnProps | 'children'> {
71
75
  }
@@ -39,6 +39,7 @@ const buildMonthLabels = (weeks, monthNames) => {
39
39
  }
40
40
  return labels;
41
41
  };
42
+ const LOADING_WEEKS = Array.from({ length: 26 }, () => Array.from({ length: 7 }, () => null));
42
43
  const ContributionGraph = React.forwardRef(({
43
44
  days,
44
45
  title,
@@ -56,10 +57,13 @@ const ContributionGraph = React.forwardRef(({
56
57
  monthLabels: monthLabelsProp,
57
58
  cellLabel: cellLabelProp,
58
59
  className = "",
60
+ loading = false,
61
+ loadingLabel = "Loading",
59
62
  ...rest
60
63
  }, ref) => {
61
- const weeks = buildWeeks(days, weekStartsOn ?? weekStartOf(locale));
62
- const monthLabels = buildMonthLabels(weeks, monthsOr(monthLabelsProp, locale));
64
+ const builtWeeks = buildWeeks(days, weekStartsOn ?? weekStartOf(locale));
65
+ const weeks = loading && builtWeeks.length === 0 ? LOADING_WEEKS : builtWeeks;
66
+ const monthLabels = loading ? [] : buildMonthLabels(weeks, monthsOr(monthLabelsProp, locale));
63
67
  const cellLabel = cellLabelProp ?? cellLabelFor(locale);
64
68
  const chartClass = "ds-chart";
65
69
  const classes = [
@@ -96,17 +100,18 @@ const ContributionGraph = React.forwardRef(({
96
100
  /* @__PURE__ */ jsx(
97
101
  "div",
98
102
  {
99
- className: "ds-contribution-graph__grid",
103
+ className: `ds-contribution-graph__grid${loading ? " ds-contribution-graph__grid--loading" : ""}`,
100
104
  style: { gridTemplateColumns: columnTemplate },
101
- role: "img",
102
- "aria-label": gridLabel ?? caption ?? "Contribution activity",
105
+ role: loading ? "status" : "img",
106
+ "aria-busy": loading || void 0,
107
+ "aria-label": loading ? loadingLabel : gridLabel ?? caption ?? "Contribution activity",
103
108
  children: weeks.map((week, weekIndex) => /* @__PURE__ */ jsx(
104
109
  "div",
105
110
  {
106
111
  className: "ds-contribution-graph__week",
107
112
  style: { "--ds-contribution-week": weekIndex },
108
113
  children: week.map(
109
- (day, dayIndex) => day ? /* @__PURE__ */ jsx(
114
+ (day, dayIndex) => loading ? /* @__PURE__ */ jsx("div", { className: "ds-contribution-graph__cell ds-contribution-graph__cell--level-0" }, dayIndex) : day ? /* @__PURE__ */ jsx(
110
115
  "div",
111
116
  {
112
117
  className: `ds-contribution-graph__cell ds-contribution-graph__cell--level-${day.level}`,
@@ -170,7 +170,7 @@
170
170
  columns; the panel clips its own body instead. */
171
171
  .ds-data-table__grid--fixed
172
172
  .ds-table__body
173
- .ds-table__cell:not(.ds-data-table__cell--pinned-edge, .ds-data-table__detail-cell),
173
+ .ds-table__cell:not(.ds-data-table__cell--pinned-edge, .ds-data-table__detail-cell, .ds-data-table__group-cell),
174
174
  .ds-data-table__grid--fixed .ds-data-table__cell--pinned-edge > .ds-table__cell-content {
175
175
  overflow: hidden;
176
176
  }
@@ -208,7 +208,7 @@
208
208
  --ds-dt-tint: var(--color-table-row-hover-bg);
209
209
  }
210
210
 
211
- .ds-table--striped .ds-table__body .ds-table__row:nth-child(even) > .ds-data-table__cell--pinned {
211
+ .ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))) > .ds-data-table__cell--pinned {
212
212
  --ds-dt-tint: var(--color-table-row-stripe-bg);
213
213
  }
214
214
 
@@ -1047,12 +1047,25 @@
1047
1047
  }
1048
1048
 
1049
1049
  /* The group's label runs past its first column over the empty cells beside
1050
- it, so a long value is never clipped to one column's width. */
1050
+ it, so a long value is never clipped to one column's width: the cell is
1051
+ left out of the fixed grid's clip above, and while the cell beside it is
1052
+ empty the label keeps its full width rather than shrinking to an
1053
+ ellipsis. A pinned group cell still clips (nothing may spill out from
1054
+ under a pinned edge), and beside a group total the value gives way. */
1051
1055
  .ds-data-table__group-cell,
1052
1056
  .ds-data-table__group-cell > .ds-table__cell-content {
1053
1057
  overflow: visible;
1054
1058
  }
1055
1059
 
1060
+ .ds-data-table__grid--fixed .ds-data-table__group-cell.ds-data-table__cell--pinned:not(.ds-data-table__cell--pinned-edge) {
1061
+ overflow: hidden;
1062
+ }
1063
+
1064
+ .ds-data-table__group-cell:not(.ds-data-table__cell--pinned):has(+ .ds-table__cell:empty) .ds-data-table__group-value {
1065
+ flex-shrink: 0;
1066
+ overflow: visible;
1067
+ }
1068
+
1056
1069
  .ds-data-table__group-label {
1057
1070
  display: flex;
1058
1071
  align-items: center;
@@ -1384,7 +1397,7 @@
1384
1397
  .ds-data-table__banner {
1385
1398
  margin-block-end: var(--gap-300);
1386
1399
  /* Banner is a page-wide strip; over a table it takes the frame's corner. */
1387
- border-radius: var(--radius-300);
1400
+ border-radius: var(--radius-600);
1388
1401
  }
1389
1402
 
1390
1403
  /* ============================================
@@ -1399,6 +1412,17 @@
1399
1412
  its own tint.
1400
1413
  ============================================ */
1401
1414
 
1415
+ /* A side with a pinned column takes no scroll cue: the fade would wash
1416
+ the column that is holding still, and its scrolling-edge shadow already
1417
+ says something is under it. */
1418
+ .ds-table__wrapper:has(> .ds-table > .ds-table__head .ds-data-table__cell--pinned-start) {
1419
+ --ds-table-cue-start: 0px;
1420
+ }
1421
+
1422
+ .ds-table__wrapper:has(> .ds-table > .ds-table__head .ds-data-table__cell--pinned-end) {
1423
+ --ds-table-cue-end: 0px;
1424
+ }
1425
+
1402
1426
  .ds-table__wrapper.ds-data-table__frame--frameless {
1403
1427
  margin-inline: calc(-1 * var(--padding-400));
1404
1428
  border: 0;
@@ -14,7 +14,14 @@ export interface DataTableColumn<R extends DataTableRow = DataTableRow> {
14
14
  header: React.ReactNode;
15
15
  /** Whether clicking this header sorts by the column. */
16
16
  sortable?: boolean;
17
- /** Optional column width (CSS value like '200px', '30%', 'auto'). */
17
+ /**
18
+ * The column's width, as any CSS width: `'200px'`, `'12rem'`, `'30%'`,
19
+ * `'auto'`. A table with a resizable or pinned column works in pixels: a
20
+ * pixel or rem width is taken as written, and any other value is laid out
21
+ * by the browser once and measured, so a percentage holds the share it had
22
+ * on that first layout. Either way the column is never narrower than its
23
+ * header's controls need (`minWidth` sets that floor yourself).
24
+ */
18
25
  width?: string;
19
26
  /** Text alignment for cells in this column. `start` and `end` follow the reading direction (a typed column defaults to its type's: `end` for numbers, money and progress, `start` for text); `left` and `right` are screen sides. */
20
27
  align?: 'start' | 'center' | 'end' | 'left' | 'right';
@@ -457,7 +464,14 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
457
464
  searchable?: boolean;
458
465
  /** Placeholder for the search field. */
459
466
  searchPlaceholder?: string;
460
- /** Slot beside the search field for consumer-owned filter controls. */
467
+ /**
468
+ * The table's own control bar, drawn in the frame's head beside the
469
+ * search field. Pass `<TableToolbar />` for the standard one (search,
470
+ * filters as chips, the Columns panel, the density switch and the result
471
+ * count, reading and setting this table's state with no props), so the
472
+ * controls sit in the table rather than in a row above it; any other node
473
+ * is a slot for controls of your own.
474
+ */
461
475
  toolbar?: React.ReactNode;
462
476
  /**
463
477
  * The table's density, and the controls' with it: `default` rows with the
@@ -715,6 +715,11 @@ function DataTable({
715
715
  tableEl.querySelectorAll("thead th[data-col]").forEach((th) => {
716
716
  const key = th.dataset.col;
717
717
  if (next[key] !== void 0 || declaredPixels(byKey.get(key)?.width) !== void 0) return;
718
+ const rems = byKey.get(key)?.width?.trim().match(/^(\d+(?:\.\d+)?)rem$/);
719
+ if (rems) {
720
+ next[key] = Math.round(Number(rems[1]) * parseFloat(getComputedStyle(document.documentElement).fontSize));
721
+ return;
722
+ }
718
723
  const natural = Math.round(th.getBoundingClientRect().width);
719
724
  const truncates = (byKey.get(key)?.cellText ?? cellText) === "truncate";
720
725
  next[key] = truncates ? Math.min(natural, TRUNCATE_START_WIDTH) : natural;
@@ -113,7 +113,9 @@
113
113
  ERROR STATE
114
114
  ============================================ */
115
115
 
116
- .ds-date-input--error .ds-date-input__field {
116
+ /* The hover rule above is more specific, so the error border names it too. */
117
+ .ds-date-input--error .ds-date-input__field,
118
+ .ds-date-input--error .ds-date-input__field:hover:not(:focus):not(:disabled) {
117
119
  border-color: var(--color-status-error-border);
118
120
  }
119
121
 
@@ -22,6 +22,22 @@
22
22
  box-sizing: border-box;
23
23
  }
24
24
 
25
+ /* Bare: a Popover, Panel or Dialog around it already draws the surface,
26
+ so the picker gives up its own frame and sits flush in theirs. */
27
+ .ds-date-picker--bare {
28
+ padding: 0;
29
+ border: none;
30
+ border-radius: 0;
31
+ background-color: transparent;
32
+ }
33
+
34
+ /* Pending: no value, no `today`, and the device's date not yet read. The
35
+ month holds its place unseen for that one paint, so no wrong month shows. */
36
+ .ds-date-picker--pending .ds-date-picker__month-year,
37
+ .ds-date-picker--pending .ds-date-picker__grid {
38
+ visibility: hidden;
39
+ }
40
+
25
41
  /* ============================================
26
42
  HEADER
27
43
  ============================================ */
@@ -57,6 +57,19 @@ type DatePickerOwnProps = {
57
57
  * `de-DE`.
58
58
  */
59
59
  weekStartsOn?: Weekday;
60
+ /**
61
+ * The date the calendar treats as today, as `YYYY-MM-DD`: it carries the today ring and
62
+ * picks the month shown first when no `value` is set. Pass it to pin today
63
+ * for a demo, a test, a time zone the device is not in, or a server render.
64
+ * Unset, today is the device's date, read in the browser only: a server
65
+ * render reads no clock and draws no today ring, and the browser adds it.
66
+ */
67
+ today?: string;
68
+ /**
69
+ * Drops the picker's own frame (border, fill, radius and padding), for a
70
+ * surface that already draws one: a Popover, a Panel, a Dialog.
71
+ */
72
+ bare?: boolean;
60
73
  /** Additional CSS classes */
61
74
  className?: string;
62
75
  };
@@ -6,6 +6,7 @@ import "../../fonts/material-symbols.css";
6
6
  import { useLocale } from "../../behaviors/LocaleProvider.js";
7
7
  import { weekStartOf, rotateWeek, isEnglish, weekdayHeadersIn, weekdayNamesIn } from "../../behaviors/locale.js";
8
8
  import { MonthGrid } from "./MonthGrid.js";
9
+ import { useToday, PLACEHOLDER_MONTH } from "./today.js";
9
10
  import { parseDate, monthLabelIn, dayLabelIn, weekdaysOr, EN_DAYS, formatDate, visuallyHidden, isSameDay, keyMove } from "./calendar.js";
10
11
  const DatePicker = React.forwardRef(
11
12
  ({
@@ -24,6 +25,8 @@ const DatePicker = React.forwardRef(
24
25
  weekdayNames,
25
26
  locale: localeProp,
26
27
  weekStartsOn,
28
+ today: todayProp,
29
+ bare = false,
27
30
  className = "",
28
31
  ...rest
29
32
  }, ref) => {
@@ -43,14 +46,14 @@ const DatePicker = React.forwardRef(
43
46
  weekdaysOr(weekdayNames, weekdayNamesIn(locale, "long")),
44
47
  weekStart
45
48
  );
46
- const today = useMemo(() => /* @__PURE__ */ new Date(), []);
47
- const todayStart = new Date(today.getFullYear(), today.getMonth(), today.getDate());
48
- const [viewMonth, setViewMonth] = useState(
49
- selectedDate ? selectedDate.getMonth() : today.getMonth()
50
- );
51
- const [viewYear, setViewYear] = useState(
52
- selectedDate ? selectedDate.getFullYear() : today.getFullYear()
53
- );
49
+ const today = useToday(todayProp);
50
+ const todayStart = today ? new Date(today.getFullYear(), today.getMonth(), today.getDate()) : null;
51
+ const [turned, setTurned] = useState(null);
52
+ const anchor = selectedDate ?? today;
53
+ const pending = turned === null && anchor === null;
54
+ const viewMonth = turned?.month ?? anchor?.getMonth() ?? PLACEHOLDER_MONTH.getMonth();
55
+ const viewYear = turned?.year ?? anchor?.getFullYear() ?? PLACEHOLDER_MONTH.getFullYear();
56
+ const setView = (month, year) => setTurned({ month, year });
54
57
  const [focusedDate, setFocusedDate] = useState(null);
55
58
  const pendingFocus = useRef(false);
56
59
  const gridRef = useRef(null);
@@ -65,24 +68,18 @@ const DatePicker = React.forwardRef(
65
68
  baseClass,
66
69
  `${baseClass}--${size}`,
67
70
  disabled ? `${baseClass}--disabled` : "",
71
+ bare ? `${baseClass}--bare` : "",
72
+ pending ? `${baseClass}--pending` : "",
68
73
  className
69
74
  ].filter(Boolean).join(" ");
70
75
  const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
71
76
  const goToPrevMonth = () => {
72
- if (viewMonth === 0) {
73
- setViewMonth(11);
74
- setViewYear(viewYear - 1);
75
- } else {
76
- setViewMonth(viewMonth - 1);
77
- }
77
+ if (viewMonth === 0) setView(11, viewYear - 1);
78
+ else setView(viewMonth - 1, viewYear);
78
79
  };
79
80
  const goToNextMonth = () => {
80
- if (viewMonth === 11) {
81
- setViewMonth(0);
82
- setViewYear(viewYear + 1);
83
- } else {
84
- setViewMonth(viewMonth + 1);
85
- }
81
+ if (viewMonth === 11) setView(0, viewYear + 1);
82
+ else setView(viewMonth + 1, viewYear);
86
83
  };
87
84
  const isDateDisabled = (date) => {
88
85
  if (disabled) return true;
@@ -93,10 +90,7 @@ const DatePicker = React.forwardRef(
93
90
  };
94
91
  const isInView = (date) => date.getMonth() === viewMonth && date.getFullYear() === viewYear;
95
92
  const moveFocusTo = (date) => {
96
- if (!isInView(date)) {
97
- setViewMonth(date.getMonth());
98
- setViewYear(date.getFullYear());
99
- }
93
+ if (!isInView(date)) setView(date.getMonth(), date.getFullYear());
100
94
  setFocusedDate(date);
101
95
  pendingFocus.current = true;
102
96
  };
@@ -123,7 +117,7 @@ const DatePicker = React.forwardRef(
123
117
  let tabStop = [focusedDate, selectedDate, todayStart].find(
124
118
  (date) => date !== null && isInView(date) && !isDateDisabled(date)
125
119
  ) ?? null;
126
- for (let d = 1; !tabStop && d <= daysInMonth; d++) {
120
+ for (let d = 1; !pending && !tabStop && d <= daysInMonth; d++) {
127
121
  const date = new Date(viewYear, viewMonth, d);
128
122
  if (!isDateDisabled(date)) tabStop = date;
129
123
  }
@@ -153,7 +147,7 @@ const DatePicker = React.forwardRef(
153
147
  }
154
148
  )
155
149
  ] }),
156
- /* @__PURE__ */ jsx("span", { "aria-live": "polite", style: visuallyHidden, children: monthTitle }),
150
+ /* @__PURE__ */ jsx("span", { "aria-live": "polite", style: visuallyHidden, children: turned ? monthTitle : "" }),
157
151
  /* @__PURE__ */ jsx(
158
152
  MonthGrid,
159
153
  {
@@ -169,7 +163,7 @@ const DatePicker = React.forwardRef(
169
163
  today,
170
164
  dayState: (cell) => {
171
165
  const isSelected = Boolean(selectedDate && isSameDay(cell.date, selectedDate));
172
- const isToday = isSameDay(cell.date, today);
166
+ const isToday = today !== null && isSameDay(cell.date, today);
173
167
  return {
174
168
  className: [
175
169
  !cell.inMonth ? `${baseClass}__cell--outside` : "",
@@ -32,8 +32,8 @@ export type MonthGridProps = {
32
32
  label: string;
33
33
  /** The day numbers' format. */
34
34
  dayNumber: Intl.NumberFormat;
35
- /** Today, for `aria-current="date"` and its ring. */
36
- today: Date;
35
+ /** Today, for `aria-current="date"` and its ring; null while it is not yet known, which marks no day. */
36
+ today: Date | null;
37
37
  /** The state of each day. */
38
38
  dayState: (cell: MonthCell) => DayState;
39
39
  /** A day was pressed. */
@@ -30,7 +30,7 @@ function MonthGrid({
30
30
  if (hideOutside && !cell.inMonth)
31
31
  return /* @__PURE__ */ jsx("div", { className: `${baseClass}__gridcell`, role: "gridcell" }, formatDate(cell.date));
32
32
  const state = dayState(cell);
33
- const isToday = isSameDay(cell.date, today);
33
+ const isToday = today !== null && isSameDay(cell.date, today);
34
34
  return /* @__PURE__ */ jsx(
35
35
  "div",
36
36
  {
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Today, for the date pickers. Internal, beside calendar.ts.
3
+ *
4
+ * A calendar never reads the clock while it prerenders: a host's `today`
5
+ * wins, and without one the device's date is read in the browser only,
6
+ * through `useSyncExternalStore` with a null server snapshot (EventCalendar's
7
+ * rule). So a server render and the hydration that follows it know no today,
8
+ * draw no today ring and agree with each other; the browser then resolves
9
+ * the date and the ring appears. A prerender has nothing unstable in it,
10
+ * which a framework that checks for one (Next's cache components) requires.
11
+ */
12
+ /** The month a calendar holds its place with, hidden, until its own is known. */
13
+ export declare const PLACEHOLDER_MONTH: Date;
14
+ /** The host's `today` (`YYYY-MM-DD`), else the device's date once the browser has it, else null. */
15
+ export declare function useToday(pinned: string | undefined): Date | null;
@@ -0,0 +1,17 @@
1
+ import { useSyncExternalStore, useMemo } from "react";
2
+ import { parseDate, formatDate } from "./calendar.js";
3
+ const PLACEHOLDER_MONTH = new Date(2e3, 0, 1);
4
+ const subscribeNothing = () => () => {
5
+ };
6
+ const deviceDay = () => formatDate(/* @__PURE__ */ new Date());
7
+ const noDay = () => null;
8
+ function useToday(pinned) {
9
+ const device = useSyncExternalStore(subscribeNothing, pinned ? noDay : deviceDay, noDay);
10
+ const deviceDate = useMemo(() => parseDate(device), [device]);
11
+ const pinnedDate = useMemo(() => parseDate(pinned), [pinned]);
12
+ return pinnedDate ?? deviceDate;
13
+ }
14
+ export {
15
+ PLACEHOLDER_MONTH,
16
+ useToday
17
+ };
@@ -69,6 +69,19 @@ type DateRangePickerOwnProps = {
69
69
  locale?: string;
70
70
  /** The first column of the grid, 0 (Sunday) to 6 (Saturday). Defaults to the first day of the week in `locale`. */
71
71
  weekStartsOn?: Weekday;
72
+ /**
73
+ * The date the calendar treats as today, as `YYYY-MM-DD`: it carries the today ring and
74
+ * picks the month shown first when no range is set. Pass it to pin today
75
+ * for a demo, a test, a time zone the device is not in, or a server render.
76
+ * Unset, today is the device's date, read in the browser only: a server
77
+ * render reads no clock and draws no today ring, and the browser adds it.
78
+ */
79
+ today?: string;
80
+ /**
81
+ * Drops the picker's own frame (border, fill, radius and padding), for a
82
+ * surface that already draws one: a Popover, a Panel, a Dialog.
83
+ */
84
+ bare?: boolean;
72
85
  /** Additional CSS classes */
73
86
  className?: string;
74
87
  };
@@ -82,5 +95,5 @@ export interface DateRangePickerProps extends DateRangePickerOwnProps, Omit<Reac
82
95
  * DatePicker: arrows, Home and End, Page Up and Page Down move, Enter or
83
96
  * Space chooses.
84
97
  */
85
- export declare function DateRangePicker({ value: valueProp, defaultValue, onValueChange, months, min, max, isDateDisabled: isDateDisabledProp, minLength, maxLength, presets, presetsLabel, size, disabled, name, previousLabel, nextLabel, monthLabel: monthLabelProp, dayLabel: dayLabelProp, rangeStartLabel, rangeEndLabel, inRangeLabel, weekdayLabels, weekdayNames, locale: localeProp, weekStartsOn, className, onPointerLeave, ref, ...rest }: DateRangePickerProps): React.JSX.Element;
98
+ export declare function DateRangePicker({ value: valueProp, defaultValue, onValueChange, months, min, max, isDateDisabled: isDateDisabledProp, minLength, maxLength, presets, presetsLabel, size, disabled, name, previousLabel, nextLabel, monthLabel: monthLabelProp, dayLabel: dayLabelProp, rangeStartLabel, rangeEndLabel, inRangeLabel, weekdayLabels, weekdayNames, locale: localeProp, weekStartsOn, today: todayProp, bare, className, onPointerLeave, ref, ...rest }: DateRangePickerProps): React.JSX.Element;
86
99
  export {};
@@ -4,6 +4,7 @@ import { useState, useMemo, useRef, useEffect } from "react";
4
4
  import { useLocale } from "../../behaviors/LocaleProvider.js";
5
5
  import { weekStartOf, rotateWeek, isEnglish, weekdayHeadersIn, weekdayNamesIn } from "../../behaviors/locale.js";
6
6
  import { MonthGrid } from "../DatePicker/MonthGrid.js";
7
+ import { useToday, PLACEHOLDER_MONTH } from "../DatePicker/today.js";
7
8
  import { parseDate, monthLabelIn, fullDateIn, weekdaysOr, EN_DAYS, formatDate, isSameDay, visuallyHidden, addMonths, keyMove, daysBetween } from "../DatePicker/calendar.js";
8
9
  import { Chip } from "../Chip/Chip.js";
9
10
  import "../DatePicker/DatePicker.css";
@@ -36,6 +37,8 @@ function DateRangePicker({
36
37
  weekdayNames,
37
38
  locale: localeProp,
38
39
  weekStartsOn,
40
+ today: todayProp,
41
+ bare = false,
39
42
  className = "",
40
43
  onPointerLeave,
41
44
  ref,
@@ -58,9 +61,14 @@ function DateRangePicker({
58
61
  weekStart
59
62
  );
60
63
  const weekdayFullNames = rotateWeek(weekdaysOr(weekdayNames, weekdayNamesIn(locale, "long")), weekStart);
61
- const today = useMemo(() => /* @__PURE__ */ new Date(), []);
62
- const initial = start ?? today;
63
- const [view, setView] = useState({ year: initial.getFullYear(), month: initial.getMonth() });
64
+ const today = useToday(todayProp);
65
+ const [turned, setView] = useState(null);
66
+ const anchor = start ?? today;
67
+ const pending = turned === null && anchor === null;
68
+ const view = turned ?? {
69
+ year: (anchor ?? PLACEHOLDER_MONTH).getFullYear(),
70
+ month: (anchor ?? PLACEHOLDER_MONTH).getMonth()
71
+ };
64
72
  const [focusedDate, setFocusedDate] = useState(null);
65
73
  const [hoverDate, setHoverDate] = useState(null);
66
74
  const pendingFocus = useRef(false);
@@ -74,7 +82,7 @@ function DateRangePicker({
74
82
  if (!pendingFocus.current || !focusedDate) return;
75
83
  pendingFocus.current = false;
76
84
  rootRef.current?.querySelector(`[data-date="${formatDate(focusedDate)}"]`)?.focus();
77
- }, [focusedDate, view]);
85
+ }, [focusedDate, view.year, view.month]);
78
86
  const shown = Array.from({ length: months }, (_, i) => {
79
87
  const first = new Date(view.year, view.month + i, 1);
80
88
  return { year: first.getFullYear(), month: first.getMonth() };
@@ -101,6 +109,7 @@ function DateRangePicker({
101
109
  return false;
102
110
  };
103
111
  const commit = (next) => {
112
+ if (!turned) setView(view);
104
113
  if (!controlled) setUncontrolled(next);
105
114
  onValueChange?.(next);
106
115
  };
@@ -159,7 +168,7 @@ function DateRangePicker({
159
168
  let tabStop = [focusedDate, start, today].find(
160
169
  (date) => date !== null && isInView(date) && !isDayDisabled(date)
161
170
  ) ?? null;
162
- for (let d = new Date(firstShown); !tabStop && d <= lastShown; d = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)) {
171
+ for (let d = new Date(firstShown); !pending && !tabStop && d <= lastShown; d = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)) {
163
172
  if (!isDayDisabled(d)) tabStop = d;
164
173
  }
165
174
  const activePreset = presets?.findIndex((p) => p.range.start === range.start && p.range.end === range.end) ?? -1;
@@ -177,6 +186,8 @@ function DateRangePicker({
177
186
  baseClass,
178
187
  `${baseClass}--${size}`,
179
188
  disabled ? `${baseClass}--disabled` : "",
189
+ bare ? `${baseClass}--bare` : "",
190
+ pending ? `${baseClass}--pending` : "",
180
191
  className
181
192
  ].filter(Boolean).join(" ");
182
193
  const turn = (by) => {
@@ -248,7 +259,7 @@ function DateRangePicker({
248
259
  const position = positionOf(cell.date);
249
260
  const chosenEnd = position === "start" || position === "end" || position === "start-end";
250
261
  const inSpan = Boolean(start && spanEnd && cell.date > start && cell.date < spanEnd);
251
- const isToday = isSameDay(cell.date, today);
262
+ const isToday = today !== null && isSameDay(cell.date, today);
252
263
  const dayDisabled = isDayDisabled(cell.date);
253
264
  return {
254
265
  className: [
@@ -280,7 +291,7 @@ function DateRangePicker({
280
291
  }
281
292
  )
282
293
  ] }, `${year}-${month}`)) }),
283
- /* @__PURE__ */ jsx("span", { "aria-live": "polite", style: visuallyHidden, children: titles.join(", ") }),
294
+ /* @__PURE__ */ jsx("span", { "aria-live": "polite", style: visuallyHidden, children: turned ? titles.join(", ") : "" }),
284
295
  name && /* @__PURE__ */ jsxs(Fragment, { children: [
285
296
  /* @__PURE__ */ jsx("input", { type: "hidden", name: `${name}[start]`, value: range.start ?? "", disabled }),
286
297
  /* @__PURE__ */ jsx("input", { type: "hidden", name: `${name}[end]`, value: range.end ?? "", disabled })
@@ -215,4 +215,15 @@
215
215
  }
216
216
  }
217
217
 
218
+ /* Loading: a placeholder line where each value goes, in a box one text line
219
+ tall, so the list keeps its height when the values land. */
220
+
221
+ .ds-description-list__details--loading {
222
+ min-height: 1lh;
223
+ }
224
+
225
+ .ds-description-list__details--loading > .ds-skeleton {
226
+ width: 60%;
227
+ }
228
+
218
229
  } /* @layer rift.components */
@@ -40,6 +40,10 @@ type DescriptionListOwnProps = {
40
40
  copiedLabel?: string;
41
41
  /** Called after a value is put on the clipboard, so a host can confirm it or count it. Only reaches a list rendered from a client component. */
42
42
  onValueCopy?: (value: string) => void;
43
+ /** Holds a placeholder line in place of every value while they are being fetched. The terms stay, and copy buttons and actions wait. */
44
+ loading?: boolean;
45
+ /** Accessible name announced while `loading`. */
46
+ loadingLabel?: string;
43
47
  /** Additional CSS classes. */
44
48
  className?: string;
45
49
  };
@@ -51,7 +55,7 @@ export interface DescriptionListProps extends DescriptionListOwnProps, Omit<Reac
51
55
  * narrow, or in a grid; values can be copied or carry a trailing action, and
52
56
  * an empty value says so in words. Server-renderable.
53
57
  */
54
- export declare function DescriptionList({ items, children, layout, columns, dividers, size, termWidth, align, emptyValue, copyLabel, copiedLabel, onValueCopy, className, style, ref, ...rest }: DescriptionListProps): React.JSX.Element;
58
+ export declare function DescriptionList({ items, children, layout, columns, dividers, size, termWidth, align, emptyValue, copyLabel, copiedLabel, onValueCopy, loading, loadingLabel, className, style, ref, ...rest }: DescriptionListProps): React.JSX.Element;
55
59
  /** Props owned by DescriptionListItem itself; everything else falls through to the entry's wrapper `<div>`. */
56
60
  type DescriptionListItemOwnProps = Omit<DescriptionListEntry, 'id'> & {
57
61
  /** The value, as children. `details` wins when both are set. */