@orbitcommerce/constellation-docs 0.0.0-stage → 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/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +8260 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-CNbBbErC.js +129 -0
- package/dist/pages/_figures-data-BDmScEny.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_overlays-specimens-Dpn6oiyH.js +310 -0
- package/dist/pages/alert-BD4e6QTh.js +769 -0
- package/dist/pages/app-shell-KbA-nRqZ.js +1479 -0
- package/dist/pages/area-chart-B91dLcGo.js +562 -0
- package/dist/pages/avatar-DPPHXJAu.js +713 -0
- package/dist/pages/badge-C9JR0thI.js +729 -0
- package/dist/pages/button-D3V912P4.js +518 -0
- package/dist/pages/calendar-DSDZ9nRH.js +630 -0
- package/dist/pages/card-DUggbis3.js +659 -0
- package/dist/pages/checkbox-DwimQaK3.js +365 -0
- package/dist/pages/colour-BwuO8xAv.js +1498 -0
- package/dist/pages/command-palette-xAD7fOg6.js +1243 -0
- package/dist/pages/date-picker-BYSa816m.js +1421 -0
- package/dist/pages/delta-CtAo0eIM.js +574 -0
- package/dist/pages/dialog-BRAf4LMh.js +1451 -0
- package/dist/pages/docs-BNOb7AqR.js +515 -0
- package/dist/pages/empty-state-C-mLrXW2.js +417 -0
- package/dist/pages/figure-tabs-CoPFzzKz.js +460 -0
- package/dist/pages/home-dashboard-CFQwDtC9.js +959 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/icon-button-C9eSVPPW.js +861 -0
- package/dist/pages/icons-sxkTs5Ob.js +473 -0
- package/dist/pages/input-KF9Gkawf.js +1093 -0
- package/dist/pages/installation-DpsX8G_n.js +445 -0
- package/dist/pages/kbd-cNfDoikz.js +544 -0
- package/dist/pages/live-globe-ClvLn9Lb.js +571 -0
- package/dist/pages/logo-BfGF1Pq9.js +571 -0
- package/dist/pages/menu-by2sgQ09.js +1618 -0
- package/dist/pages/motion-BvTGc2Dk.js +855 -0
- package/dist/pages/orbit-spinner-Dil1Z3Oy.js +332 -0
- package/dist/pages/overview-BPEbZQ6g.js +130 -0
- package/dist/pages/pagination-BBUnGvv5.js +249 -0
- package/dist/pages/popover-Db1gLDpb.js +1136 -0
- package/dist/pages/principles-CeAIOIdt.js +483 -0
- package/dist/pages/radio-group-CkdBWWfG.js +1077 -0
- package/dist/pages/registry-CroHzK9I.js +244 -0
- package/dist/pages/release-Dvo684UJ.js +13 -0
- package/dist/pages/rolling-number-qmvH84Mq.js +529 -0
- package/dist/pages/search-field-BN7MWGQ4.js +693 -0
- package/dist/pages/segmented-control-CTbIpRBW.js +777 -0
- package/dist/pages/select-DguELoRR.js +1429 -0
- package/dist/pages/separator-CPZub9pv.js +351 -0
- package/dist/pages/shape-DKvA0YKr.js +627 -0
- package/dist/pages/skeleton-DLuBhP46.js +561 -0
- package/dist/pages/sparkline-DMMYGbHn.js +668 -0
- package/dist/pages/switch-B-Qe4kcT.js +517 -0
- package/dist/pages/table-AMoODng4.js +607 -0
- package/dist/pages/tabs-B4M-usCV.js +1455 -0
- package/dist/pages/textarea-fTuUZRQb.js +693 -0
- package/dist/pages/toast-CKP03zjy.js +1176 -0
- package/dist/pages/tooltip-CBYil3kt.js +697 -0
- package/dist/pages/typography-PCbg8Bhg.js +735 -0
- package/manifest.json +3125 -0
- package/package.json +35 -4
|
@@ -0,0 +1,1421 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-BNOb7AqR.js";
|
|
4
|
+
import { t as Playground } from "./Playground-CNbBbErC.js";
|
|
5
|
+
import { c as SpecimenFrame, s as PopoverSheet } from "./_overlays-specimens-Dpn6oiyH.js";
|
|
6
|
+
import { useMemo, useRef, useState } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Button, Calendar, DatePicker, DateRangePicker, Field, Input, dateRangePresets, fromISODate, toISODate } from "@orbitcommerce/constellation";
|
|
9
|
+
import { CheckCircleIcon } from "@orbitcommerce/constellation/icons";
|
|
10
|
+
//#region src/pages/components/date-picker.tsx
|
|
11
|
+
function startOfToday() {
|
|
12
|
+
const now = /* @__PURE__ */ new Date();
|
|
13
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
14
|
+
}
|
|
15
|
+
var addDays = (date, days) => new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
|
|
16
|
+
var at = (date, hours, minutes = 0) => new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours, minutes);
|
|
17
|
+
/** The next day we deliver on (not a Sunday), at least `after` days away. */
|
|
18
|
+
function nextDeliveryDay(from, after = 1) {
|
|
19
|
+
let day = addDays(from, after);
|
|
20
|
+
while (day.getDay() === 0) day = addDays(day, 1);
|
|
21
|
+
return day;
|
|
22
|
+
}
|
|
23
|
+
var WITH_WEEKDAY = {
|
|
24
|
+
weekday: "short",
|
|
25
|
+
day: "numeric",
|
|
26
|
+
month: "short",
|
|
27
|
+
year: "numeric"
|
|
28
|
+
};
|
|
29
|
+
var shortDate = new Intl.DateTimeFormat("en-GB", {
|
|
30
|
+
day: "numeric",
|
|
31
|
+
month: "short",
|
|
32
|
+
year: "numeric"
|
|
33
|
+
});
|
|
34
|
+
var weekdayDate = new Intl.DateTimeFormat("en-GB", WITH_WEEKDAY);
|
|
35
|
+
function FieldStill({ text, size = "md", width }) {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: "o-input o-date-field",
|
|
38
|
+
"data-size": size,
|
|
39
|
+
"data-state": "open",
|
|
40
|
+
style: { width },
|
|
41
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
42
|
+
className: "o-date-field__trigger",
|
|
43
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
44
|
+
className: "o-input__icon",
|
|
45
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
46
|
+
viewBox: "0 0 16 16",
|
|
47
|
+
fill: "none",
|
|
48
|
+
stroke: "currentColor",
|
|
49
|
+
strokeWidth: 1.5,
|
|
50
|
+
strokeLinecap: "round",
|
|
51
|
+
strokeLinejoin: "round",
|
|
52
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
53
|
+
x: "2.25",
|
|
54
|
+
y: "3.25",
|
|
55
|
+
width: "11.5",
|
|
56
|
+
height: "10.5",
|
|
57
|
+
rx: "2.5"
|
|
58
|
+
}), /* @__PURE__ */ jsx("path", { d: "M2.25 6.75h11.5M5.5 1.75v2.75M10.5 1.75v2.75" })]
|
|
59
|
+
})
|
|
60
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
61
|
+
className: "o-date-field__value",
|
|
62
|
+
children: text
|
|
63
|
+
})]
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function DatePickerStill() {
|
|
68
|
+
const today = startOfToday();
|
|
69
|
+
const chosen = nextDeliveryDay(today, 6);
|
|
70
|
+
return /* @__PURE__ */ jsxs(SpecimenFrame, {
|
|
71
|
+
className: "date-picker-still",
|
|
72
|
+
children: [/* @__PURE__ */ jsx(FieldStill, {
|
|
73
|
+
text: weekdayDate.format(chosen),
|
|
74
|
+
width: 276
|
|
75
|
+
}), /* @__PURE__ */ jsx(PopoverSheet, {
|
|
76
|
+
padding: "sm",
|
|
77
|
+
children: /* @__PURE__ */ jsx(Calendar, {
|
|
78
|
+
defaultValue: chosen,
|
|
79
|
+
today,
|
|
80
|
+
minValue: addDays(today, 1),
|
|
81
|
+
disabled: { dayOfWeek: [0] }
|
|
82
|
+
})
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function RangeSheetStill() {
|
|
87
|
+
const today = startOfToday();
|
|
88
|
+
const range = dateRangePresets[2].range(today);
|
|
89
|
+
return /* @__PURE__ */ jsxs(SpecimenFrame, {
|
|
90
|
+
className: "date-picker-still",
|
|
91
|
+
children: [/* @__PURE__ */ jsx(FieldStill, {
|
|
92
|
+
text: "Last 30 days",
|
|
93
|
+
width: 260
|
|
94
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
95
|
+
className: "o-popover o-date-range",
|
|
96
|
+
"data-padding": "none",
|
|
97
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
98
|
+
className: "o-date-range__presets",
|
|
99
|
+
children: dateRangePresets.map((preset) => /* @__PURE__ */ jsxs("span", {
|
|
100
|
+
className: "o-date-range__preset",
|
|
101
|
+
"aria-pressed": preset.id === "last-30-days",
|
|
102
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "o-date-range__preset-label",
|
|
104
|
+
children: preset.label
|
|
105
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
106
|
+
className: "o-date-range__check",
|
|
107
|
+
viewBox: "0 0 16 16",
|
|
108
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
109
|
+
pathLength: 1,
|
|
110
|
+
d: "M3.6 8.4l2.9 2.9 5.9-6.6"
|
|
111
|
+
})
|
|
112
|
+
})]
|
|
113
|
+
}, preset.id))
|
|
114
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
115
|
+
className: "o-date-range__calendar",
|
|
116
|
+
children: /* @__PURE__ */ jsx(Calendar, {
|
|
117
|
+
mode: "range",
|
|
118
|
+
numberOfMonths: 2,
|
|
119
|
+
defaultValue: range,
|
|
120
|
+
today,
|
|
121
|
+
maxValue: today
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function Preview() {
|
|
128
|
+
const today = startOfToday();
|
|
129
|
+
const chosen = nextDeliveryDay(today, 6);
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: "date-picker-preview",
|
|
132
|
+
children: [/* @__PURE__ */ jsx(FieldStill, {
|
|
133
|
+
text: shortDate.format(chosen),
|
|
134
|
+
size: "sm"
|
|
135
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: "date-picker-preview__sheet",
|
|
137
|
+
children: /* @__PURE__ */ jsx(PopoverSheet, {
|
|
138
|
+
padding: "sm",
|
|
139
|
+
children: /* @__PURE__ */ jsx(Calendar, {
|
|
140
|
+
defaultValue: chosen,
|
|
141
|
+
today
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
var quote = (v) => String(v).replace(/"/g, """);
|
|
148
|
+
var PLAYGROUND = [
|
|
149
|
+
{
|
|
150
|
+
prop: "aria-label",
|
|
151
|
+
type: "text",
|
|
152
|
+
default: "Delivery date",
|
|
153
|
+
toAttr: (v) => `aria-label="${quote(v)}"`
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
prop: "placeholder",
|
|
157
|
+
type: "text",
|
|
158
|
+
default: "Choose a date",
|
|
159
|
+
toAttr: (v) => v && v !== "Choose a date" ? `placeholder="${quote(v)}"` : null
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
prop: "size",
|
|
163
|
+
type: "select",
|
|
164
|
+
options: [
|
|
165
|
+
"sm",
|
|
166
|
+
"md",
|
|
167
|
+
"lg"
|
|
168
|
+
],
|
|
169
|
+
default: "md"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
prop: "granularity",
|
|
173
|
+
type: "select",
|
|
174
|
+
options: ["day", "minute"],
|
|
175
|
+
default: "day"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
prop: "hourCycle",
|
|
179
|
+
type: "select",
|
|
180
|
+
options: ["24", "12"],
|
|
181
|
+
default: "24",
|
|
182
|
+
toAttr: (v) => v === "12" ? "hourCycle={12}" : null
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
prop: "clearable",
|
|
186
|
+
type: "boolean",
|
|
187
|
+
default: true
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
prop: "invalid",
|
|
191
|
+
type: "boolean",
|
|
192
|
+
default: false
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
prop: "readOnly",
|
|
196
|
+
type: "boolean",
|
|
197
|
+
default: false
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
prop: "disabled",
|
|
201
|
+
type: "boolean",
|
|
202
|
+
default: false
|
|
203
|
+
}
|
|
204
|
+
];
|
|
205
|
+
function BookDelivery() {
|
|
206
|
+
const tomorrow = useMemo(() => addDays(startOfToday(), 1), []);
|
|
207
|
+
const [date, setDate] = useState(null);
|
|
208
|
+
const [error, setError] = useState();
|
|
209
|
+
const [booked, setBooked] = useState(null);
|
|
210
|
+
const ref = useRef(null);
|
|
211
|
+
const submit = (event) => {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
if (!date) {
|
|
214
|
+
setError("Choose a delivery date");
|
|
215
|
+
setBooked(null);
|
|
216
|
+
ref.current?.focus();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
setError(void 0);
|
|
220
|
+
setBooked(date);
|
|
221
|
+
};
|
|
222
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
223
|
+
noValidate: true,
|
|
224
|
+
onSubmit: submit,
|
|
225
|
+
className: "date-picker-form",
|
|
226
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
227
|
+
label: "Delivery date",
|
|
228
|
+
hint: "We deliver Monday to Saturday, from tomorrow.",
|
|
229
|
+
error,
|
|
230
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
231
|
+
ref,
|
|
232
|
+
value: date,
|
|
233
|
+
onChange: (next) => {
|
|
234
|
+
setDate(next);
|
|
235
|
+
setError(void 0);
|
|
236
|
+
setBooked(null);
|
|
237
|
+
},
|
|
238
|
+
minValue: tomorrow,
|
|
239
|
+
disabledDays: { dayOfWeek: [0] },
|
|
240
|
+
format: WITH_WEEKDAY
|
|
241
|
+
})
|
|
242
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
243
|
+
className: "date-picker-form__footer",
|
|
244
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
245
|
+
role: "status",
|
|
246
|
+
className: "date-picker-status",
|
|
247
|
+
children: booked ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
248
|
+
/* @__PURE__ */ jsx(CheckCircleIcon, {
|
|
249
|
+
weight: "fill",
|
|
250
|
+
"aria-hidden": "true"
|
|
251
|
+
}),
|
|
252
|
+
"Order #1042 arrives ",
|
|
253
|
+
weekdayDate.format(booked)
|
|
254
|
+
] }) : null
|
|
255
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
256
|
+
type: "submit",
|
|
257
|
+
variant: "primary",
|
|
258
|
+
children: "Book delivery"
|
|
259
|
+
})]
|
|
260
|
+
})]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function HoldUntil() {
|
|
264
|
+
const tomorrow = useMemo(() => addDays(startOfToday(), 1), []);
|
|
265
|
+
const [date, setDate] = useState(() => addDays(tomorrow, 4));
|
|
266
|
+
return /* @__PURE__ */ jsx("div", {
|
|
267
|
+
className: "date-picker-stack",
|
|
268
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
269
|
+
label: "Hold until (optional)",
|
|
270
|
+
hint: date ? `Order #1042 is released on ${weekdayDate.format(date)}.` : "Held until you release it.",
|
|
271
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
272
|
+
clearable: true,
|
|
273
|
+
value: date,
|
|
274
|
+
onChange: setDate,
|
|
275
|
+
minValue: tomorrow
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function PublishAt({ hourCycle = 24 }) {
|
|
281
|
+
const [value, setValue] = useState(() => at(addDays(startOfToday(), 1), 9));
|
|
282
|
+
const now = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
283
|
+
return /* @__PURE__ */ jsx("div", {
|
|
284
|
+
className: "date-picker-stack",
|
|
285
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
286
|
+
label: hourCycle === 12 ? "Send the email at" : "Publish on",
|
|
287
|
+
hint: hourCycle === 12 ? "The Autumn sale email goes to 1,284 subscribers." : "The Arden ergonomic chair goes live on your store at this time.",
|
|
288
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
289
|
+
granularity: "minute",
|
|
290
|
+
hourCycle,
|
|
291
|
+
value,
|
|
292
|
+
onChange: setValue,
|
|
293
|
+
minValue: now
|
|
294
|
+
})
|
|
295
|
+
})
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function DiscountDates() {
|
|
299
|
+
const today = useMemo(() => startOfToday(), []);
|
|
300
|
+
const [starts, setStarts] = useState(() => at(addDays(today, 3), 9));
|
|
301
|
+
const [ends, setEnds] = useState(() => at(addDays(today, 17), 23, 59));
|
|
302
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
303
|
+
className: "date-picker-discount",
|
|
304
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
305
|
+
className: "date-picker-discount__code",
|
|
306
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
307
|
+
className: "date-picker-discount__name",
|
|
308
|
+
children: "AUTUMN20"
|
|
309
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
310
|
+
className: "date-picker-discount__meta",
|
|
311
|
+
children: "20% off everything in Home office"
|
|
312
|
+
})]
|
|
313
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
314
|
+
className: "date-picker-pair",
|
|
315
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
316
|
+
label: "Starts",
|
|
317
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
318
|
+
granularity: "minute",
|
|
319
|
+
value: starts,
|
|
320
|
+
onChange: setStarts,
|
|
321
|
+
minValue: today
|
|
322
|
+
})
|
|
323
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
324
|
+
label: "Ends (optional)",
|
|
325
|
+
hint: "Leave it empty to run until you end it.",
|
|
326
|
+
error: starts && ends && ends <= starts ? "End it after it starts, or leave it empty" : void 0,
|
|
327
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
328
|
+
granularity: "minute",
|
|
329
|
+
clearable: true,
|
|
330
|
+
value: ends,
|
|
331
|
+
onChange: setEnds,
|
|
332
|
+
minValue: starts ?? today
|
|
333
|
+
})
|
|
334
|
+
})]
|
|
335
|
+
})]
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function BannerDates() {
|
|
339
|
+
const today = useMemo(() => startOfToday(), []);
|
|
340
|
+
const [range, setRange] = useState(() => ({
|
|
341
|
+
from: addDays(today, 7),
|
|
342
|
+
to: addDays(today, 20)
|
|
343
|
+
}));
|
|
344
|
+
const days = range ? Math.round((range.to.getTime() - range.from.getTime()) / 864e5) + 1 : 0;
|
|
345
|
+
return /* @__PURE__ */ jsx("div", {
|
|
346
|
+
className: "date-picker-stack",
|
|
347
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
348
|
+
label: "Show the banner",
|
|
349
|
+
hint: range ? `Free delivery banner, on the storefront for ${days} ${days === 1 ? "day" : "days"}.` : "Pick the first and the last day.",
|
|
350
|
+
children: /* @__PURE__ */ jsx(DateRangePicker, {
|
|
351
|
+
clearable: true,
|
|
352
|
+
value: range,
|
|
353
|
+
onChange: setRange,
|
|
354
|
+
minValue: today
|
|
355
|
+
})
|
|
356
|
+
})
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function SalesReport({ presets = true }) {
|
|
360
|
+
const today = useMemo(() => startOfToday(), []);
|
|
361
|
+
const [range, setRange] = useState(() => dateRangePresets[2].range(today));
|
|
362
|
+
const [preset, setPreset] = useState("last-30-days");
|
|
363
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
364
|
+
className: "date-picker-report",
|
|
365
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
366
|
+
className: "date-picker-report__bar",
|
|
367
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
368
|
+
className: "date-picker-report__title",
|
|
369
|
+
children: "Sales"
|
|
370
|
+
}), /* @__PURE__ */ jsx(DateRangePicker, {
|
|
371
|
+
"aria-label": "Report dates",
|
|
372
|
+
presets,
|
|
373
|
+
maxValue: today,
|
|
374
|
+
value: range,
|
|
375
|
+
onChange: (next, id) => {
|
|
376
|
+
setRange(next);
|
|
377
|
+
setPreset(id);
|
|
378
|
+
},
|
|
379
|
+
className: "date-picker-report__range"
|
|
380
|
+
})]
|
|
381
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
382
|
+
className: "date-picker-report__meta",
|
|
383
|
+
"aria-live": "polite",
|
|
384
|
+
children: [
|
|
385
|
+
range ? `${shortDate.format(range.from)} to ${shortDate.format(range.to)}` : "No dates",
|
|
386
|
+
" · ",
|
|
387
|
+
preset ? /* @__PURE__ */ jsxs(Fragment$1, { children: ["preset ", /* @__PURE__ */ jsx("code", { children: preset })] }) : "picked on the calendar"
|
|
388
|
+
]
|
|
389
|
+
})]
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
var day = (offset) => (today) => addDays(today, offset);
|
|
393
|
+
var ANALYTICS_PRESETS = [
|
|
394
|
+
{
|
|
395
|
+
id: "today",
|
|
396
|
+
label: "Today",
|
|
397
|
+
range: (today) => ({
|
|
398
|
+
from: today,
|
|
399
|
+
to: today
|
|
400
|
+
})
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
id: "yesterday",
|
|
404
|
+
label: "Yesterday",
|
|
405
|
+
range: (today) => ({
|
|
406
|
+
from: day(-1)(today),
|
|
407
|
+
to: day(-1)(today)
|
|
408
|
+
})
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
id: "last-7-days",
|
|
412
|
+
label: "Last 7 days",
|
|
413
|
+
range: (today) => ({
|
|
414
|
+
from: day(-6)(today),
|
|
415
|
+
to: today
|
|
416
|
+
})
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
id: "last-30-days",
|
|
420
|
+
label: "Last 30 days",
|
|
421
|
+
range: (today) => ({
|
|
422
|
+
from: day(-29)(today),
|
|
423
|
+
to: today
|
|
424
|
+
})
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
id: "last-90-days",
|
|
428
|
+
label: "Last 90 days",
|
|
429
|
+
range: (today) => ({
|
|
430
|
+
from: day(-89)(today),
|
|
431
|
+
to: today
|
|
432
|
+
})
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
id: "last-365-days",
|
|
436
|
+
label: "Last 365 days",
|
|
437
|
+
range: (today) => ({
|
|
438
|
+
from: day(-364)(today),
|
|
439
|
+
to: today
|
|
440
|
+
})
|
|
441
|
+
}
|
|
442
|
+
];
|
|
443
|
+
function NativeSwap() {
|
|
444
|
+
const [holdUntil, setHoldUntil] = useState("");
|
|
445
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
446
|
+
className: "date-picker-stack",
|
|
447
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
448
|
+
label: "Hold until (optional)",
|
|
449
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
450
|
+
clearable: true,
|
|
451
|
+
value: fromISODate(holdUntil),
|
|
452
|
+
onChange: (date) => setHoldUntil(date ? toISODate(date) : "")
|
|
453
|
+
})
|
|
454
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
455
|
+
className: "date-picker-report__meta",
|
|
456
|
+
children: ["Stored as ", /* @__PURE__ */ jsx("code", { children: holdUntil ? `'${holdUntil}'` : "''" })]
|
|
457
|
+
})]
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
function Stage({ children }) {
|
|
461
|
+
return /* @__PURE__ */ jsx("div", {
|
|
462
|
+
className: "date-picker-stage",
|
|
463
|
+
children
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
function Page() {
|
|
467
|
+
const today = startOfToday();
|
|
468
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
469
|
+
title: "Date picker",
|
|
470
|
+
status: "new",
|
|
471
|
+
importNames: [
|
|
472
|
+
"DatePicker",
|
|
473
|
+
"DateRangePicker",
|
|
474
|
+
"toISODate",
|
|
475
|
+
"fromISODate"
|
|
476
|
+
],
|
|
477
|
+
lead: "A field that opens a calendar: one day (and a time, if it matters) with DatePicker, or a first and last day with DateRangePicker. It looks and sizes exactly like Input, so dates sit in forms beside everything else.",
|
|
478
|
+
children: [
|
|
479
|
+
/* @__PURE__ */ jsx(Section, {
|
|
480
|
+
id: "playground",
|
|
481
|
+
title: "Playground",
|
|
482
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
483
|
+
"Change the props, then open the calendar with a click, or with Enter or Space once the field has focus. A day pick closes it; with ",
|
|
484
|
+
/* @__PURE__ */ jsx("code", { children: "granularity=\"minute\"" }),
|
|
485
|
+
" it stays open for the time."
|
|
486
|
+
] }),
|
|
487
|
+
children: /* @__PURE__ */ jsx(Playground, {
|
|
488
|
+
clientOnly: true,
|
|
489
|
+
component: "DatePicker",
|
|
490
|
+
controls: PLAYGROUND,
|
|
491
|
+
render: (v) => /* @__PURE__ */ jsx(Stage, { children: /* @__PURE__ */ jsx(DatePicker, {
|
|
492
|
+
"aria-label": String(v["aria-label"]),
|
|
493
|
+
placeholder: String(v.placeholder) || void 0,
|
|
494
|
+
size: v.size,
|
|
495
|
+
granularity: v.granularity,
|
|
496
|
+
hourCycle: v.hourCycle === "12" ? 12 : 24,
|
|
497
|
+
clearable: Boolean(v.clearable),
|
|
498
|
+
invalid: Boolean(v.invalid),
|
|
499
|
+
readOnly: Boolean(v.readOnly),
|
|
500
|
+
disabled: Boolean(v.disabled)
|
|
501
|
+
}) })
|
|
502
|
+
})
|
|
503
|
+
}),
|
|
504
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
505
|
+
id: "picking-a-day",
|
|
506
|
+
title: "Picking a day",
|
|
507
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
508
|
+
"Put the picker in a ",
|
|
509
|
+
/* @__PURE__ */ jsx("code", { children: "Field" }),
|
|
510
|
+
" for its label, hint and error, as with any input. Here a delivery can be booked from tomorrow, on any day but Sunday: ",
|
|
511
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
512
|
+
" rules out the past (and the months before it cannot even be reached), and ",
|
|
513
|
+
/* @__PURE__ */ jsx("code", { children: "disabledDays" }),
|
|
514
|
+
" rules out Sundays. ",
|
|
515
|
+
/* @__PURE__ */ jsx("code", { children: "format" }),
|
|
516
|
+
" adds the weekday to the field, because for a delivery the day of the week matters."
|
|
517
|
+
] }), /* @__PURE__ */ jsx("p", { children: "Press Book delivery with no date to see the error, and focus come back to the field." })] }),
|
|
518
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
519
|
+
clientOnly: true,
|
|
520
|
+
code: `
|
|
521
|
+
const [date, setDate] = useState<Date | null>(null)
|
|
522
|
+
|
|
523
|
+
<Field label="Delivery date" hint="We deliver Monday to Saturday, from tomorrow." error={error}>
|
|
524
|
+
<DatePicker
|
|
525
|
+
value={date}
|
|
526
|
+
onChange={setDate}
|
|
527
|
+
minValue={tomorrow}
|
|
528
|
+
disabledDays={{ dayOfWeek: [0] }}
|
|
529
|
+
format={{ weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' }}
|
|
530
|
+
/>
|
|
531
|
+
</Field>`,
|
|
532
|
+
children: /* @__PURE__ */ jsx(BookDelivery, {})
|
|
533
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
534
|
+
columns: ["Part", "What it does"],
|
|
535
|
+
rows: [
|
|
536
|
+
["Field", "The Input's well: same edge, halo, heights and error look. While the calendar is open it keeps its teal edge, so the two read as one."],
|
|
537
|
+
["Calendar glyph", "Quiet slate, firming up while the field has focus. Clicking anywhere on the field opens the calendar."],
|
|
538
|
+
["Date", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
539
|
+
"Formatted with Intl in British English: ",
|
|
540
|
+
/* @__PURE__ */ jsx("code", { children: "2 Oct 2026" }),
|
|
541
|
+
" by default, the placeholder in quiet slate until then."
|
|
542
|
+
] })],
|
|
543
|
+
["Clear button", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
544
|
+
"With ",
|
|
545
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
546
|
+
", a small round button pops in at the end once there is a date."
|
|
547
|
+
] })],
|
|
548
|
+
["Calendar", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
549
|
+
"On the Popover's sheet, growing out of the field. See ",
|
|
550
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
551
|
+
to: "/components/calendar",
|
|
552
|
+
children: "Calendar"
|
|
553
|
+
}),
|
|
554
|
+
" for the grid itself."
|
|
555
|
+
] })]
|
|
556
|
+
]
|
|
557
|
+
})]
|
|
558
|
+
}),
|
|
559
|
+
/* @__PURE__ */ jsx(Section, {
|
|
560
|
+
id: "sizes",
|
|
561
|
+
title: "Sizes",
|
|
562
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
563
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
564
|
+
" 30px, ",
|
|
565
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
566
|
+
" 36px (default) and ",
|
|
567
|
+
/* @__PURE__ */ jsx("code", { children: "lg" }),
|
|
568
|
+
" 44px: the heights of Input and Button, so a date, a text field and a button share a line exactly."
|
|
569
|
+
] }),
|
|
570
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
571
|
+
clientOnly: true,
|
|
572
|
+
code: `
|
|
573
|
+
<Input size="sm" aria-label="Postcode" defaultValue="LS1 4AP" />
|
|
574
|
+
<DatePicker size="sm" aria-label="Delivery date" defaultValue={deliveryDay} />
|
|
575
|
+
<Button size="sm">Book</Button>
|
|
576
|
+
|
|
577
|
+
{/* md (default) and lg follow the same pattern */}`,
|
|
578
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
579
|
+
className: "date-picker-sizes",
|
|
580
|
+
children: [
|
|
581
|
+
"sm",
|
|
582
|
+
"md",
|
|
583
|
+
"lg"
|
|
584
|
+
].map((size) => /* @__PURE__ */ jsxs("div", {
|
|
585
|
+
className: "date-picker-sizes__row",
|
|
586
|
+
children: [
|
|
587
|
+
/* @__PURE__ */ jsx(Input, {
|
|
588
|
+
size,
|
|
589
|
+
"aria-label": "Postcode",
|
|
590
|
+
defaultValue: "LS1 4AP",
|
|
591
|
+
className: "date-picker-sizes__postcode"
|
|
592
|
+
}),
|
|
593
|
+
/* @__PURE__ */ jsx(DatePicker, {
|
|
594
|
+
size,
|
|
595
|
+
"aria-label": "Delivery date",
|
|
596
|
+
defaultValue: nextDeliveryDay(today, 3)
|
|
597
|
+
}),
|
|
598
|
+
/* @__PURE__ */ jsx(Button, {
|
|
599
|
+
size,
|
|
600
|
+
children: "Book"
|
|
601
|
+
})
|
|
602
|
+
]
|
|
603
|
+
}, size))
|
|
604
|
+
})
|
|
605
|
+
})
|
|
606
|
+
}),
|
|
607
|
+
/* @__PURE__ */ jsx(Section, {
|
|
608
|
+
id: "states",
|
|
609
|
+
title: "States",
|
|
610
|
+
description: /* @__PURE__ */ jsx("p", { children: "Hover firms the edge; focus turns it teal with a soft halo (Tab into a field to see it). An error swaps the teal for red. Read-only shows the date in the well and will not open; disabled dims it and Tab skips it." }),
|
|
611
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
612
|
+
clientOnly: true,
|
|
613
|
+
align: "fill",
|
|
614
|
+
caption: "Empty, filled, invalid, read-only and disabled.",
|
|
615
|
+
code: `
|
|
616
|
+
<Field label="Delivery date">
|
|
617
|
+
<DatePicker />
|
|
618
|
+
</Field>
|
|
619
|
+
<Field label="Delivery date">
|
|
620
|
+
<DatePicker defaultValue={deliveryDay} />
|
|
621
|
+
</Field>
|
|
622
|
+
<Field label="Delivery date" error="Choose a day from tomorrow onwards">
|
|
623
|
+
<DatePicker defaultValue={yesterday} minValue={tomorrow} />
|
|
624
|
+
</Field>
|
|
625
|
+
<Field label="Order placed" hint="Set when the order came in">
|
|
626
|
+
<DatePicker readOnly value={placedAt} />
|
|
627
|
+
</Field>
|
|
628
|
+
<Field label="Sale ends" hint="Turn on Put on sale to set an end date">
|
|
629
|
+
<DatePicker disabled />
|
|
630
|
+
</Field>`,
|
|
631
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
632
|
+
className: "date-picker-grid",
|
|
633
|
+
children: [
|
|
634
|
+
/* @__PURE__ */ jsx(Field, {
|
|
635
|
+
label: "Delivery date",
|
|
636
|
+
children: /* @__PURE__ */ jsx(DatePicker, {})
|
|
637
|
+
}),
|
|
638
|
+
/* @__PURE__ */ jsx(Field, {
|
|
639
|
+
label: "Delivery date",
|
|
640
|
+
children: /* @__PURE__ */ jsx(DatePicker, { defaultValue: nextDeliveryDay(today, 3) })
|
|
641
|
+
}),
|
|
642
|
+
/* @__PURE__ */ jsx(Field, {
|
|
643
|
+
label: "Delivery date",
|
|
644
|
+
error: "Choose a day from tomorrow onwards",
|
|
645
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
646
|
+
defaultValue: addDays(today, -1),
|
|
647
|
+
minValue: addDays(today, 1)
|
|
648
|
+
})
|
|
649
|
+
}),
|
|
650
|
+
/* @__PURE__ */ jsx(Field, {
|
|
651
|
+
label: "Order placed",
|
|
652
|
+
hint: "Set when the order came in",
|
|
653
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
654
|
+
readOnly: true,
|
|
655
|
+
value: addDays(today, -2)
|
|
656
|
+
})
|
|
657
|
+
}),
|
|
658
|
+
/* @__PURE__ */ jsx(Field, {
|
|
659
|
+
label: "Sale ends",
|
|
660
|
+
hint: "Turn on Put on sale to set an end date",
|
|
661
|
+
children: /* @__PURE__ */ jsx(DatePicker, { disabled: true })
|
|
662
|
+
})
|
|
663
|
+
]
|
|
664
|
+
})
|
|
665
|
+
})
|
|
666
|
+
}),
|
|
667
|
+
/* @__PURE__ */ jsx(Section, {
|
|
668
|
+
id: "clearing",
|
|
669
|
+
title: "Clearing",
|
|
670
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
671
|
+
"An optional date needs a way back to none. ",
|
|
672
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
673
|
+
" adds a round clear button at the end of the field once there is a date, and Backspace or Delete on the field clears it too. The button stays out of the Tab order, as the search field's does. A required date leaves it off."
|
|
674
|
+
] }),
|
|
675
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
676
|
+
clientOnly: true,
|
|
677
|
+
code: `
|
|
678
|
+
<Field label="Hold until (optional)" hint="Order #1042 is released on that day.">
|
|
679
|
+
<DatePicker clearable value={date} onChange={setDate} minValue={tomorrow} />
|
|
680
|
+
</Field>`,
|
|
681
|
+
children: /* @__PURE__ */ jsx(HoldUntil, {})
|
|
682
|
+
})
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
685
|
+
id: "time",
|
|
686
|
+
title: "Date and time",
|
|
687
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "granularity=\"minute\"" }), " adds a time row under the calendar: hours and minutes on a 24-hour clock, as UK shops expect. Picking a day keeps the calendar open so the time can follow. Click into the hours and type \"9\": it can only mean 09, so focus moves on to the minutes. The arrow keys step either part, and Enter closes."] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
688
|
+
"Picking a new day always keeps the time the value had, even without a time row, so moving a 16:30 deadline to Friday leaves it at 16:30. With a time, ",
|
|
689
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
690
|
+
" and ",
|
|
691
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
692
|
+
" hold to the minute."
|
|
693
|
+
] })] }),
|
|
694
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
695
|
+
clientOnly: true,
|
|
696
|
+
code: `
|
|
697
|
+
<Field label="Publish on" hint="The Arden ergonomic chair goes live on your store at this time.">
|
|
698
|
+
<DatePicker granularity="minute" value={publishAt} onChange={setPublishAt} minValue={new Date()} />
|
|
699
|
+
</Field>`,
|
|
700
|
+
children: /* @__PURE__ */ jsx(PublishAt, {})
|
|
701
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
702
|
+
title: "12-hour clock",
|
|
703
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
704
|
+
/* @__PURE__ */ jsxs("code", { children: ["hourCycle=", "{12}"] }),
|
|
705
|
+
" shows the hours 1 to 12 with an AM and PM switch beside them, and the field reads ",
|
|
706
|
+
/* @__PURE__ */ jsx("code", { children: "9:00 am" }),
|
|
707
|
+
". Keep the default 24-hour clock unless the people using it expect otherwise."
|
|
708
|
+
] }),
|
|
709
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
710
|
+
clientOnly: true,
|
|
711
|
+
code: `
|
|
712
|
+
<DatePicker granularity="minute" hourCycle={12} value={sendAt} onChange={setSendAt} minValue={new Date()} />`,
|
|
713
|
+
children: /* @__PURE__ */ jsx(PublishAt, { hourCycle: 12 })
|
|
714
|
+
})
|
|
715
|
+
})]
|
|
716
|
+
}),
|
|
717
|
+
/* @__PURE__ */ jsx(Section, {
|
|
718
|
+
id: "start-and-end",
|
|
719
|
+
title: "A start and an end",
|
|
720
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
721
|
+
"When the two ends each have a time, or the end is optional, as with a discount, use two pickers and let the start bound the end: ",
|
|
722
|
+
/* @__PURE__ */ jsxs("code", { children: ["minValue=", "{starts}"] }),
|
|
723
|
+
" on the end keeps it from being picked before the start. Move the start past the end to see the error."
|
|
724
|
+
] }),
|
|
725
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
726
|
+
clientOnly: true,
|
|
727
|
+
align: "fill",
|
|
728
|
+
code: `
|
|
729
|
+
<Field label="Starts">
|
|
730
|
+
<DatePicker granularity="minute" value={starts} onChange={setStarts} minValue={today} />
|
|
731
|
+
</Field>
|
|
732
|
+
<Field label="Ends (optional)" hint="Leave it empty to run until you end it." error={error}>
|
|
733
|
+
<DatePicker granularity="minute" clearable value={ends} onChange={setEnds} minValue={starts ?? today} />
|
|
734
|
+
</Field>`,
|
|
735
|
+
children: /* @__PURE__ */ jsx(DiscountDates, {})
|
|
736
|
+
})
|
|
737
|
+
}),
|
|
738
|
+
/* @__PURE__ */ jsx(Section, {
|
|
739
|
+
id: "ranges",
|
|
740
|
+
title: "Date ranges",
|
|
741
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "DateRangePicker" }), " picks a run of whole days: the first click starts the range, the second ends it and closes the calendar. While the end is being picked, a fainter wash follows the pointer (or focus) to a teal ring. Picking an earlier day second simply swaps the ends. Two months sit side by side on screens 768px and wider, one below."] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
742
|
+
"The value is ",
|
|
743
|
+
/* @__PURE__ */ jsx("code", { children: "{ from, to }" }),
|
|
744
|
+
", both local midnight and both included, and the field reads",
|
|
745
|
+
" ",
|
|
746
|
+
/* @__PURE__ */ jsx("code", { children: "2 Oct 2026 to 9 Oct 2026" }),
|
|
747
|
+
"."
|
|
748
|
+
] })] }),
|
|
749
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
750
|
+
clientOnly: true,
|
|
751
|
+
code: `
|
|
752
|
+
const [range, setRange] = useState<DateRange | null>({ from: nextWeek, to: inThreeWeeks })
|
|
753
|
+
|
|
754
|
+
<Field label="Show the banner" hint="Free delivery banner, on the storefront for 14 days.">
|
|
755
|
+
<DateRangePicker clearable value={range} onChange={setRange} minValue={today} />
|
|
756
|
+
</Field>`,
|
|
757
|
+
children: /* @__PURE__ */ jsx(BannerDates, {})
|
|
758
|
+
})
|
|
759
|
+
}),
|
|
760
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
761
|
+
id: "presets",
|
|
762
|
+
title: "Presets",
|
|
763
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "presets" }), " adds a column of ready-made ranges on the left, as reports need: Today, Last 7 days, Last 30 days, This month and Last month. Picking one applies it at once. When the range matches a preset, the field names it (\"Last 30 days\") and the preset carries a teal check; any other range shows its dates."] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
764
|
+
/* @__PURE__ */ jsx("code", { children: "onChange" }),
|
|
765
|
+
" gets the preset's ",
|
|
766
|
+
/* @__PURE__ */ jsx("code", { children: "id" }),
|
|
767
|
+
" as a second argument, so a report can keep \"Last 30 days\" rolling forward day by day rather than freezing the dates. On phones the presets become a row of chips above one month."
|
|
768
|
+
] })] }),
|
|
769
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
770
|
+
clientOnly: true,
|
|
771
|
+
align: "fill",
|
|
772
|
+
code: `
|
|
773
|
+
<DateRangePicker
|
|
774
|
+
aria-label="Report dates"
|
|
775
|
+
presets
|
|
776
|
+
maxValue={today}
|
|
777
|
+
value={range}
|
|
778
|
+
onChange={(next, preset) => {
|
|
779
|
+
setRange(next)
|
|
780
|
+
setPreset(preset) // 'last-30-days', or undefined for a range picked on the calendar
|
|
781
|
+
}}
|
|
782
|
+
/>`,
|
|
783
|
+
children: /* @__PURE__ */ jsx(SalesReport, {})
|
|
784
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
785
|
+
title: "Your own presets",
|
|
786
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
787
|
+
"Pass a list of ",
|
|
788
|
+
/* @__PURE__ */ jsx("code", { children: "{ id, label, range }" }),
|
|
789
|
+
", where ",
|
|
790
|
+
/* @__PURE__ */ jsx("code", { children: "range(today)" }),
|
|
791
|
+
" returns the dates. These match the analytics pages. Presets that would cross ",
|
|
792
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
793
|
+
" or ",
|
|
794
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
795
|
+
" are shown but cannot be picked."
|
|
796
|
+
] }),
|
|
797
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
798
|
+
clientOnly: true,
|
|
799
|
+
align: "fill",
|
|
800
|
+
code: `
|
|
801
|
+
const presets: DateRangePreset[] = [
|
|
802
|
+
{ id: 'today', label: 'Today', range: (today) => ({ from: today, to: today }) },
|
|
803
|
+
{ id: 'yesterday', label: 'Yesterday', range: (today) => ({ from: addDays(today, -1), to: addDays(today, -1) }) },
|
|
804
|
+
{ id: 'last-7-days', label: 'Last 7 days', range: (today) => ({ from: addDays(today, -6), to: today }) },
|
|
805
|
+
{ id: 'last-30-days', label: 'Last 30 days', range: (today) => ({ from: addDays(today, -29), to: today }) },
|
|
806
|
+
{ id: 'last-90-days', label: 'Last 90 days', range: (today) => ({ from: addDays(today, -89), to: today }) },
|
|
807
|
+
{ id: 'last-365-days', label: 'Last 365 days', range: (today) => ({ from: addDays(today, -364), to: today }) },
|
|
808
|
+
]
|
|
809
|
+
|
|
810
|
+
<DateRangePicker aria-label="Report dates" presets={presets} maxValue={today} value={range} onChange={…} />`,
|
|
811
|
+
children: /* @__PURE__ */ jsx(SalesReport, { presets: ANALYTICS_PRESETS })
|
|
812
|
+
})
|
|
813
|
+
})]
|
|
814
|
+
}),
|
|
815
|
+
/* @__PURE__ */ jsx(Section, {
|
|
816
|
+
id: "limits",
|
|
817
|
+
title: "Limits and unavailable days",
|
|
818
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
819
|
+
"Both pickers take the same limits. Unavailable days stay visible, in mist, so the month keeps its shape, and cannot be picked or focused. The ",
|
|
820
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
821
|
+
to: "/components/calendar#unavailable",
|
|
822
|
+
children: "Calendar"
|
|
823
|
+
}),
|
|
824
|
+
" page lists every way to describe them."
|
|
825
|
+
] }),
|
|
826
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
827
|
+
columns: [
|
|
828
|
+
"Prop",
|
|
829
|
+
"Rules out",
|
|
830
|
+
"For example"
|
|
831
|
+
],
|
|
832
|
+
rows: [
|
|
833
|
+
[
|
|
834
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
835
|
+
"Every day before it. Months before it cannot be reached.",
|
|
836
|
+
"Delivery from tomorrow; a discount end no earlier than its start."
|
|
837
|
+
],
|
|
838
|
+
[
|
|
839
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
840
|
+
"Every day after it. Months after it cannot be reached.",
|
|
841
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
842
|
+
"Reports up to today: ",
|
|
843
|
+
/* @__PURE__ */ jsxs("code", { children: ["maxValue=", "{today}"] }),
|
|
844
|
+
"."
|
|
845
|
+
] })
|
|
846
|
+
],
|
|
847
|
+
[
|
|
848
|
+
/* @__PURE__ */ jsx("code", { children: "disabledDays" }),
|
|
849
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
850
|
+
"Any day matching: a date, dates, ",
|
|
851
|
+
/* @__PURE__ */ jsx("code", { children: "{ dayOfWeek }" }),
|
|
852
|
+
", a range, or a function."
|
|
853
|
+
] }),
|
|
854
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
855
|
+
"Sundays: ",
|
|
856
|
+
/* @__PURE__ */ jsx("code", { children: "{ dayOfWeek: [0] }" }),
|
|
857
|
+
". Bank holidays: ",
|
|
858
|
+
/* @__PURE__ */ jsx("code", { children: "(date) => isBankHoliday(date)" }),
|
|
859
|
+
"."
|
|
860
|
+
] })
|
|
861
|
+
]
|
|
862
|
+
]
|
|
863
|
+
})
|
|
864
|
+
}),
|
|
865
|
+
/* @__PURE__ */ jsx(Section, {
|
|
866
|
+
id: "keyboard",
|
|
867
|
+
title: "Keyboard",
|
|
868
|
+
description: /* @__PURE__ */ jsx("p", { children: "Everything works from the keyboard: open, move, pick and close, and focus always lands somewhere useful." }),
|
|
869
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
870
|
+
columns: [
|
|
871
|
+
"Where",
|
|
872
|
+
"Key",
|
|
873
|
+
"What it does"
|
|
874
|
+
],
|
|
875
|
+
rows: [
|
|
876
|
+
[
|
|
877
|
+
"Field",
|
|
878
|
+
"Enter, Space, Down arrow",
|
|
879
|
+
"Opens the calendar, with focus on the chosen day (or today, or the first day that can be picked)."
|
|
880
|
+
],
|
|
881
|
+
[
|
|
882
|
+
"Field",
|
|
883
|
+
"Backspace, Delete",
|
|
884
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
885
|
+
"Clears the date, when the picker is ",
|
|
886
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
887
|
+
"."
|
|
888
|
+
] })
|
|
889
|
+
],
|
|
890
|
+
[
|
|
891
|
+
"Calendar",
|
|
892
|
+
"Arrow keys",
|
|
893
|
+
"Move a day, or a week up and down, into the next month when they run off the edge."
|
|
894
|
+
],
|
|
895
|
+
[
|
|
896
|
+
"Calendar",
|
|
897
|
+
"Page Up, Page Down",
|
|
898
|
+
"Move a month. With Shift, a year."
|
|
899
|
+
],
|
|
900
|
+
[
|
|
901
|
+
"Calendar",
|
|
902
|
+
"Home, End",
|
|
903
|
+
"Move to the start or the end of the week."
|
|
904
|
+
],
|
|
905
|
+
[
|
|
906
|
+
"Calendar",
|
|
907
|
+
"Enter, Space",
|
|
908
|
+
"Pick the day. A single day closes the calendar; a range closes on its second day."
|
|
909
|
+
],
|
|
910
|
+
[
|
|
911
|
+
"Time",
|
|
912
|
+
"Digits, Up and Down arrows",
|
|
913
|
+
"Type the hours and minutes, or step them round the clock."
|
|
914
|
+
],
|
|
915
|
+
[
|
|
916
|
+
"Time",
|
|
917
|
+
"Enter",
|
|
918
|
+
"Closes the calendar."
|
|
919
|
+
],
|
|
920
|
+
[
|
|
921
|
+
"Anywhere inside",
|
|
922
|
+
"Tab, Shift Tab",
|
|
923
|
+
"Move between the presets, the month buttons, the grid and the time, and round again: focus stays inside while it is open."
|
|
924
|
+
],
|
|
925
|
+
[
|
|
926
|
+
"Anywhere inside",
|
|
927
|
+
"Escape",
|
|
928
|
+
"Closes the calendar and returns focus to the field. A range with only its first day picked is dropped."
|
|
929
|
+
]
|
|
930
|
+
]
|
|
931
|
+
})
|
|
932
|
+
}),
|
|
933
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
934
|
+
id: "native",
|
|
935
|
+
title: "Replacing a native date field",
|
|
936
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
937
|
+
"The pickers take and give a ",
|
|
938
|
+
/* @__PURE__ */ jsx("code", { children: "Date" }),
|
|
939
|
+
". A native ",
|
|
940
|
+
/* @__PURE__ */ jsx("code", { children: "<input type=\"date\">" }),
|
|
941
|
+
" holds a string,",
|
|
942
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DD" }),
|
|
943
|
+
", and ",
|
|
944
|
+
/* @__PURE__ */ jsx("code", { children: "new Date()" }),
|
|
945
|
+
" reads that as midnight UTC, which is still the day before anywhere west of Greenwich. Convert at the edge with the helpers, which read and write the local day and never shift it."
|
|
946
|
+
] }), /* @__PURE__ */ jsx("p", { children: "Pick a day, then clear it, and watch the stored string." })] }),
|
|
947
|
+
children: [
|
|
948
|
+
/* @__PURE__ */ jsx(Example, {
|
|
949
|
+
clientOnly: true,
|
|
950
|
+
code: `
|
|
951
|
+
import { DatePicker, toISODate, fromISODate } from '@orbitcommerce/constellation'
|
|
952
|
+
|
|
953
|
+
// Before
|
|
954
|
+
<input type="date" value={holdUntil} onChange={(e) => setHoldUntil(e.target.value)} />
|
|
955
|
+
|
|
956
|
+
// After: the state is still 'YYYY-MM-DD' (or '' for none)
|
|
957
|
+
<DatePicker
|
|
958
|
+
clearable
|
|
959
|
+
value={fromISODate(holdUntil)}
|
|
960
|
+
onChange={(date) => setHoldUntil(date ? toISODate(date) : '')}
|
|
961
|
+
/>`,
|
|
962
|
+
children: /* @__PURE__ */ jsx(NativeSwap, {})
|
|
963
|
+
}),
|
|
964
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
965
|
+
columns: ["Native", "DatePicker"],
|
|
966
|
+
rows: [
|
|
967
|
+
[/* @__PURE__ */ jsx("code", { children: "type=\"date\"" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
968
|
+
"DatePicker. The value is a ",
|
|
969
|
+
/* @__PURE__ */ jsx("code", { children: "Date" }),
|
|
970
|
+
" at local midnight."
|
|
971
|
+
] })],
|
|
972
|
+
[/* @__PURE__ */ jsx("code", { children: "type=\"datetime-local\"" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
973
|
+
/* @__PURE__ */ jsx("code", { children: "granularity=\"minute\"" }),
|
|
974
|
+
", with ",
|
|
975
|
+
/* @__PURE__ */ jsx("code", { children: "toISODateTime" }),
|
|
976
|
+
" for the ",
|
|
977
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DDTHH:mm" }),
|
|
978
|
+
" string."
|
|
979
|
+
] })],
|
|
980
|
+
[/* @__PURE__ */ jsx("code", { children: "value" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
981
|
+
/* @__PURE__ */ jsxs("code", { children: ["value=", "{fromISODate(text)}"] }),
|
|
982
|
+
". Empty or invalid text reads as ",
|
|
983
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
984
|
+
"."
|
|
985
|
+
] })],
|
|
986
|
+
[/* @__PURE__ */ jsx("code", { children: "onChange" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
987
|
+
/* @__PURE__ */ jsx("code", { children: "onChange={(date) => set(date ? toISODate(date) : '')}" }),
|
|
988
|
+
". Called with a ",
|
|
989
|
+
/* @__PURE__ */ jsx("code", { children: "Date" }),
|
|
990
|
+
", or ",
|
|
991
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
992
|
+
" when cleared."
|
|
993
|
+
] })],
|
|
994
|
+
[/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
995
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
996
|
+
", ",
|
|
997
|
+
/* @__PURE__ */ jsx("code", { children: "max" })
|
|
998
|
+
] }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
999
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
1000
|
+
", ",
|
|
1001
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
1002
|
+
" (pass ",
|
|
1003
|
+
/* @__PURE__ */ jsx("code", { children: "fromISODate(min)" }),
|
|
1004
|
+
")."
|
|
1005
|
+
] })],
|
|
1006
|
+
[/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1007
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
1008
|
+
", ",
|
|
1009
|
+
/* @__PURE__ */ jsx("code", { children: "readOnly" })
|
|
1010
|
+
] }), "The same."],
|
|
1011
|
+
[/* @__PURE__ */ jsx("code", { children: "required" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1012
|
+
"Leave ",
|
|
1013
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
1014
|
+
" off and check on submit, showing ",
|
|
1015
|
+
/* @__PURE__ */ jsx("code", { children: "error" }),
|
|
1016
|
+
" on the Field."
|
|
1017
|
+
] })],
|
|
1018
|
+
[/* @__PURE__ */ jsx("code", { children: "name" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1019
|
+
"The same: submits ",
|
|
1020
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DD" }),
|
|
1021
|
+
" (or ",
|
|
1022
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DDTHH:mm" }),
|
|
1023
|
+
") with the form."
|
|
1024
|
+
] })],
|
|
1025
|
+
["Two date fields for a range", "One DateRangePicker, unless each end needs its own time or the end is optional."]
|
|
1026
|
+
]
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1029
|
+
columns: ["Helper", "Does"],
|
|
1030
|
+
rows: [
|
|
1031
|
+
[/* @__PURE__ */ jsx("code", { children: "toISODate(date)" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("code", { children: "'2026-10-02'" }), ": the local calendar day, as a date input holds it."] })],
|
|
1032
|
+
[/* @__PURE__ */ jsx("code", { children: "toISODateTime(date)" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("code", { children: "'2026-10-02T09:30'" }), ": local time, as a datetime-local input holds it."] })],
|
|
1033
|
+
[/* @__PURE__ */ jsx("code", { children: "fromISODate(text)" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1034
|
+
"Reads both of those as local time, and a full timestamp with a zone (",
|
|
1035
|
+
/* @__PURE__ */ jsx("code", { children: "…Z" }),
|
|
1036
|
+
", ",
|
|
1037
|
+
/* @__PURE__ */ jsx("code", { children: "+01:00" }),
|
|
1038
|
+
") as the instant it is. Empty, malformed or impossible dates give ",
|
|
1039
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
1040
|
+
"."
|
|
1041
|
+
] })]
|
|
1042
|
+
]
|
|
1043
|
+
}),
|
|
1044
|
+
/* @__PURE__ */ jsx(Fragment$1, {})
|
|
1045
|
+
]
|
|
1046
|
+
}),
|
|
1047
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1048
|
+
id: "both-themes",
|
|
1049
|
+
title: "In both themes",
|
|
1050
|
+
description: /* @__PURE__ */ jsx("p", { children: "Held open for review, light beside dark: the field keeps its teal edge while the calendar is open, and the sheet is white in light and graphite in dark. The pickers on the rest of this page are live." }),
|
|
1051
|
+
children: [/* @__PURE__ */ jsx(ThemePair, {
|
|
1052
|
+
clientOnly: true,
|
|
1053
|
+
align: "start",
|
|
1054
|
+
children: /* @__PURE__ */ jsx(DatePickerStill, {})
|
|
1055
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1056
|
+
className: "overlays-stack",
|
|
1057
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
1058
|
+
clientOnly: true,
|
|
1059
|
+
align: "start",
|
|
1060
|
+
caption: "The range sheet with presets, two months wide.",
|
|
1061
|
+
children: /* @__PURE__ */ jsx(RangeSheetStill, {})
|
|
1062
|
+
})
|
|
1063
|
+
})]
|
|
1064
|
+
}),
|
|
1065
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1066
|
+
id: "guidelines",
|
|
1067
|
+
title: "Guidelines",
|
|
1068
|
+
children: [
|
|
1069
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
1070
|
+
clientOnly: true,
|
|
1071
|
+
do: {
|
|
1072
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1073
|
+
className: "date-picker-dodont",
|
|
1074
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
1075
|
+
label: "Delivery date",
|
|
1076
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
1077
|
+
defaultValue: nextDeliveryDay(today, 3),
|
|
1078
|
+
format: WITH_WEEKDAY
|
|
1079
|
+
})
|
|
1080
|
+
})
|
|
1081
|
+
}),
|
|
1082
|
+
caption: "A date in the next few weeks, where seeing the days around it helps: deliveries, launches, deadlines."
|
|
1083
|
+
},
|
|
1084
|
+
dont: {
|
|
1085
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1086
|
+
className: "date-picker-dodont",
|
|
1087
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
1088
|
+
label: "Date of birth",
|
|
1089
|
+
children: /* @__PURE__ */ jsx(DatePicker, { defaultValue: new Date(1986, 4, 14) })
|
|
1090
|
+
})
|
|
1091
|
+
}),
|
|
1092
|
+
caption: "A date people know by heart, decades away. Paging back month by month is slow: ask for day, month and year in three short inputs."
|
|
1093
|
+
}
|
|
1094
|
+
}),
|
|
1095
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
1096
|
+
clientOnly: true,
|
|
1097
|
+
do: {
|
|
1098
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1099
|
+
className: "date-picker-dodont",
|
|
1100
|
+
children: /* @__PURE__ */ jsx(DateRangePicker, {
|
|
1101
|
+
"aria-label": "Report dates",
|
|
1102
|
+
presets: true,
|
|
1103
|
+
maxValue: today,
|
|
1104
|
+
defaultValue: dateRangePresets[1].range(today)
|
|
1105
|
+
})
|
|
1106
|
+
}),
|
|
1107
|
+
caption: "One range picker, with presets, for the dates of a report."
|
|
1108
|
+
},
|
|
1109
|
+
dont: {
|
|
1110
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1111
|
+
className: "date-picker-dodont date-picker-dodont--pair",
|
|
1112
|
+
children: [/* @__PURE__ */ jsx(DatePicker, {
|
|
1113
|
+
"aria-label": "From",
|
|
1114
|
+
defaultValue: addDays(today, -6),
|
|
1115
|
+
size: "sm"
|
|
1116
|
+
}), /* @__PURE__ */ jsx(DatePicker, {
|
|
1117
|
+
"aria-label": "To",
|
|
1118
|
+
defaultValue: today,
|
|
1119
|
+
size: "sm"
|
|
1120
|
+
})]
|
|
1121
|
+
}),
|
|
1122
|
+
caption: "Two separate pickers for one range: the ends can cross, and every common range takes four clicks."
|
|
1123
|
+
}
|
|
1124
|
+
}),
|
|
1125
|
+
/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1126
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1127
|
+
"Label the field with what the date is for (\"Delivery date\", \"Publish on\"), never just \"Date\". End an optional one's label with \"(optional)\" and make it ",
|
|
1128
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
1129
|
+
"."
|
|
1130
|
+
] }),
|
|
1131
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1132
|
+
"Rule out what cannot be picked with ",
|
|
1133
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
1134
|
+
", ",
|
|
1135
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
1136
|
+
" and ",
|
|
1137
|
+
/* @__PURE__ */ jsx("code", { children: "disabledDays" }),
|
|
1138
|
+
", then say why in the hint (\"We deliver Monday to Saturday\")."
|
|
1139
|
+
] }),
|
|
1140
|
+
"Add the weekday to the format when the day of the week matters to the decision, as it does for deliveries and bookings.",
|
|
1141
|
+
"Keep the 24-hour clock and day, month, year order: they are what UK merchants read without thinking.",
|
|
1142
|
+
"Use a SegmentedControl, not a picker, for a handful of fixed periods that change a view in place (Today, 7 days, 30 days)."
|
|
1143
|
+
] })
|
|
1144
|
+
]
|
|
1145
|
+
}),
|
|
1146
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1147
|
+
id: "accessibility",
|
|
1148
|
+
title: "Accessibility",
|
|
1149
|
+
children: [/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1150
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1151
|
+
"The field is a button with ",
|
|
1152
|
+
/* @__PURE__ */ jsx("code", { children: "aria-haspopup=\"dialog\"" }),
|
|
1153
|
+
" and ",
|
|
1154
|
+
/* @__PURE__ */ jsx("code", { children: "aria-expanded" }),
|
|
1155
|
+
", named by the Field's label and the date together (\"Delivery date, Fri, 9 Oct 2026\") through",
|
|
1156
|
+
" ",
|
|
1157
|
+
/* @__PURE__ */ jsx("code", { children: "aria-labelledby" }),
|
|
1158
|
+
", so the current value is always read. Without a Field, give it an",
|
|
1159
|
+
" ",
|
|
1160
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
1161
|
+
"."
|
|
1162
|
+
] }),
|
|
1163
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1164
|
+
"Hints and errors are linked with ",
|
|
1165
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
1166
|
+
", and an error sets ",
|
|
1167
|
+
/* @__PURE__ */ jsx("code", { children: "aria-invalid" }),
|
|
1168
|
+
"."
|
|
1169
|
+
] }),
|
|
1170
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1171
|
+
"The calendar opens in a dialog named after the field. It is a ",
|
|
1172
|
+
/* @__PURE__ */ jsx("code", { children: "grid" }),
|
|
1173
|
+
" of day buttons, each read in full (\"Today, Friday, 2 October 2026, selected\"); the month caption is a polite live region, so moving month is announced."
|
|
1174
|
+
] }),
|
|
1175
|
+
"Focus moves to the chosen day when the calendar opens, stays inside while it is open, and goes back to the field when it closes.",
|
|
1176
|
+
"Unavailable days are disabled buttons: they cannot be focused or picked, and are skipped by the arrow keys.",
|
|
1177
|
+
"The time parts are spin buttons named Hours and Minutes, with their value and range.",
|
|
1178
|
+
"With reduced motion, the sheet fades in without growing, the chosen-day disc appears without settling, and months swap without sliding."
|
|
1179
|
+
] }), /* @__PURE__ */ jsx(Note, {
|
|
1180
|
+
title: "Typing a date",
|
|
1181
|
+
children: "The pickers have no typed entry: the calendar is the way in, by pointer or keyboard. For a date people already know, such as a date of birth or a date printed on an invoice, three short Inputs for day, month and year are quicker and just as accessible."
|
|
1182
|
+
})]
|
|
1183
|
+
}),
|
|
1184
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1185
|
+
id: "props",
|
|
1186
|
+
title: "Props",
|
|
1187
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1188
|
+
"Both pickers forward every other button attribute, and the ",
|
|
1189
|
+
/* @__PURE__ */ jsx("code", { children: "ref" }),
|
|
1190
|
+
", to the field's button.",
|
|
1191
|
+
" ",
|
|
1192
|
+
/* @__PURE__ */ jsx("code", { children: "className" }),
|
|
1193
|
+
" and ",
|
|
1194
|
+
/* @__PURE__ */ jsx("code", { children: "style" }),
|
|
1195
|
+
" go to the well around it."
|
|
1196
|
+
] }),
|
|
1197
|
+
children: [
|
|
1198
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1199
|
+
title: "DatePicker",
|
|
1200
|
+
rows: [
|
|
1201
|
+
{
|
|
1202
|
+
name: "value",
|
|
1203
|
+
type: "Date | null",
|
|
1204
|
+
description: "Controlled value: a local date, with a time when granularity is minute."
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
name: "defaultValue",
|
|
1208
|
+
type: "Date | null",
|
|
1209
|
+
description: "Starting value when uncontrolled."
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: "onChange",
|
|
1213
|
+
type: "(value: Date | null) => void",
|
|
1214
|
+
description: "A day picked, a time changed or the field cleared. Never on mount."
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "granularity",
|
|
1218
|
+
type: "'day' | 'minute'",
|
|
1219
|
+
default: "'day'",
|
|
1220
|
+
description: "Minute adds hours and minutes under the calendar."
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
name: "hourCycle",
|
|
1224
|
+
type: "12 | 24",
|
|
1225
|
+
default: "24",
|
|
1226
|
+
description: "The clock for the time and the field."
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "size",
|
|
1230
|
+
type: "'sm' | 'md' | 'lg'",
|
|
1231
|
+
default: "'md'",
|
|
1232
|
+
description: "30, 36 or 44px: the same heights as Input and Button."
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
name: "placeholder",
|
|
1236
|
+
type: "string",
|
|
1237
|
+
default: "'Choose a date'",
|
|
1238
|
+
description: "Shown while there is no date ('Choose a date and time' with a time)."
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "clearable",
|
|
1242
|
+
type: "boolean",
|
|
1243
|
+
default: "false",
|
|
1244
|
+
description: "A clear button, and Backspace or Delete, while there is a date."
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
name: "minValue",
|
|
1248
|
+
type: "Date | null",
|
|
1249
|
+
description: "The earliest day (and time, with a time) that can be picked."
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
name: "maxValue",
|
|
1253
|
+
type: "Date | null",
|
|
1254
|
+
description: "The latest day (and time) that can be picked."
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
name: "disabledDays",
|
|
1258
|
+
type: "CalendarMatcher | CalendarMatcher[]",
|
|
1259
|
+
description: "Days that cannot be picked: Sundays, bank holidays, sold-out days."
|
|
1260
|
+
},
|
|
1261
|
+
{
|
|
1262
|
+
name: "format",
|
|
1263
|
+
type: "Intl.DateTimeFormatOptions",
|
|
1264
|
+
description: "How the field shows the date. Defaults to 2 Oct 2026, and 2 Oct 2026, 09:30 with a time."
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
name: "locale",
|
|
1268
|
+
type: "string",
|
|
1269
|
+
default: "'en-GB'",
|
|
1270
|
+
description: "Locale for the field, the month and day names, and the first day of the week."
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
name: "weekStartsOn",
|
|
1274
|
+
type: "0 to 6",
|
|
1275
|
+
description: "First column of the week, 0 for Sunday. Defaults to the locale's: Monday in en-GB."
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
name: "invalid",
|
|
1279
|
+
type: "boolean",
|
|
1280
|
+
description: "Red edge and aria-invalid. Inside a Field, follows the Field's error."
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
name: "readOnly",
|
|
1284
|
+
type: "boolean",
|
|
1285
|
+
description: "Shows the date in the well but will not open."
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
name: "disabled",
|
|
1289
|
+
type: "boolean",
|
|
1290
|
+
description: "Dims the field; Tab skips it."
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
name: "closeOnSelect",
|
|
1294
|
+
type: "boolean",
|
|
1295
|
+
default: "true",
|
|
1296
|
+
description: "Close when a day is picked. False by default with a time."
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
name: "name",
|
|
1300
|
+
type: "string",
|
|
1301
|
+
description: "Submits YYYY-MM-DD (or YYYY-MM-DDTHH:mm) with a form."
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
name: "open, defaultOpen, onOpenChange",
|
|
1305
|
+
type: "boolean, boolean, (open) => void",
|
|
1306
|
+
description: "Control the calendar yourself."
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
name: "modal",
|
|
1310
|
+
type: "boolean",
|
|
1311
|
+
default: "true",
|
|
1312
|
+
description: "Keep focus and the pointer inside the calendar while it is open."
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
name: "align, side",
|
|
1316
|
+
type: "'start' | 'center' | 'end', 'bottom' | 'top' | …",
|
|
1317
|
+
default: "'start', 'bottom'",
|
|
1318
|
+
description: "Where the calendar opens. It flips when there is no room."
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
name: "container",
|
|
1322
|
+
type: "HTMLElement | null",
|
|
1323
|
+
default: "document.body",
|
|
1324
|
+
description: "Where the calendar is portalled."
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
name: "today",
|
|
1328
|
+
type: "Date",
|
|
1329
|
+
description: "The day treated as today. Defaults to now."
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
name: "labels",
|
|
1333
|
+
type: "Partial<DatePickerLabels>",
|
|
1334
|
+
description: "Translations: clear, time, hours, minutes, dayPeriod, previousMonth, nextMonth, today, selected."
|
|
1335
|
+
}
|
|
1336
|
+
]
|
|
1337
|
+
}),
|
|
1338
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1339
|
+
title: "DateRangePicker (where it differs)",
|
|
1340
|
+
rows: [
|
|
1341
|
+
{
|
|
1342
|
+
name: "value",
|
|
1343
|
+
type: "DateRange | null",
|
|
1344
|
+
description: "Controlled range: { from, to }, both local midnight and both included."
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
name: "defaultValue",
|
|
1348
|
+
type: "DateRange | null",
|
|
1349
|
+
description: "Starting range when uncontrolled."
|
|
1350
|
+
},
|
|
1351
|
+
{
|
|
1352
|
+
name: "onChange",
|
|
1353
|
+
type: "(value: DateRange | null, preset?: string) => void",
|
|
1354
|
+
description: "Once a range is complete, a preset is picked (with its id), or the field is cleared."
|
|
1355
|
+
},
|
|
1356
|
+
{
|
|
1357
|
+
name: "presets",
|
|
1358
|
+
type: "boolean | DateRangePreset[]",
|
|
1359
|
+
default: "false",
|
|
1360
|
+
description: "True for dateRangePresets (Today, Last 7 days, Last 30 days, This month, Last month), or your own list."
|
|
1361
|
+
},
|
|
1362
|
+
{
|
|
1363
|
+
name: "numberOfMonths",
|
|
1364
|
+
type: "number",
|
|
1365
|
+
description: "Months side by side. Defaults to two from 768px wide, one below."
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
name: "placeholder",
|
|
1369
|
+
type: "string",
|
|
1370
|
+
default: "'Choose dates'",
|
|
1371
|
+
description: "Shown while there is no range."
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
name: "labels",
|
|
1375
|
+
type: "Partial<DateRangePickerLabels>",
|
|
1376
|
+
description: "Translations: clear, to (between the dates), presets, and the calendar labels."
|
|
1377
|
+
}
|
|
1378
|
+
]
|
|
1379
|
+
}),
|
|
1380
|
+
/* @__PURE__ */ jsxs("p", {
|
|
1381
|
+
className: "doc-section__description",
|
|
1382
|
+
children: [
|
|
1383
|
+
"DateRangePicker has no time and no ",
|
|
1384
|
+
/* @__PURE__ */ jsx("code", { children: "granularity" }),
|
|
1385
|
+
", ",
|
|
1386
|
+
/* @__PURE__ */ jsx("code", { children: "hourCycle" }),
|
|
1387
|
+
" or ",
|
|
1388
|
+
/* @__PURE__ */ jsx("code", { children: "name" }),
|
|
1389
|
+
"; the rest is the same as DatePicker."
|
|
1390
|
+
]
|
|
1391
|
+
}),
|
|
1392
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1393
|
+
title: "DateRangePreset",
|
|
1394
|
+
rows: [
|
|
1395
|
+
{
|
|
1396
|
+
name: "id",
|
|
1397
|
+
type: "string",
|
|
1398
|
+
required: true,
|
|
1399
|
+
description: "Passed to onChange when the preset is picked."
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
name: "label",
|
|
1403
|
+
type: "string",
|
|
1404
|
+
required: true,
|
|
1405
|
+
description: "Shown in the list, and in the field when the range matches."
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
name: "range",
|
|
1409
|
+
type: "(today: Date) => DateRange",
|
|
1410
|
+
required: true,
|
|
1411
|
+
description: "The dates for a given today (local midnight)."
|
|
1412
|
+
}
|
|
1413
|
+
]
|
|
1414
|
+
})
|
|
1415
|
+
]
|
|
1416
|
+
})
|
|
1417
|
+
]
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
//#endregion
|
|
1421
|
+
export { Page, Preview };
|