@orbitcommerce/constellation-docs 0.0.0-stage → 1.2.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 +20787 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-Mk1yIWXb.js +129 -0
- package/dist/pages/_address-data-L9BR499w.js +161 -0
- package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
- package/dist/pages/_card-art-0be5ncyV.js +18 -0
- package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
- package/dist/pages/_figures-data-DaDvB7Nm.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/_overlays-specimens-bawR331Z.js +320 -0
- package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
- package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
- package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
- package/dist/pages/address-block-BZOOOPA9.js +368 -0
- package/dist/pages/address-fields-CwSqro3W.js +277 -0
- package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
- package/dist/pages/alert-D3i7xZTU.js +914 -0
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/app-shell-D4hdlHps.js +1558 -0
- package/dist/pages/area-chart-BEWFwiB2.js +718 -0
- package/dist/pages/avatar-BFEqQViw.js +895 -0
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/badge-0-PyMrih.js +1035 -0
- package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
- package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
- package/dist/pages/board-card-D2tZY_mU.js +415 -0
- package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
- package/dist/pages/button-DAyfssDY.js +715 -0
- package/dist/pages/calendar-Ds7KsgSI.js +682 -0
- package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
- package/dist/pages/card-CQEM1_wc.js +1567 -0
- package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
- package/dist/pages/chart-legend-B20AbakD.js +724 -0
- package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
- package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
- package/dist/pages/checklist-card-DEyykVFS.js +783 -0
- package/dist/pages/chip-Ck-o3Ui6.js +839 -0
- package/dist/pages/chip-list-k1LxXuCi.js +414 -0
- package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
- package/dist/pages/coachmark-Be2ghobT.js +366 -0
- package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
- package/dist/pages/collab-field-CfqqK7d2.js +696 -0
- package/dist/pages/color-field-CZpfcA-A.js +1127 -0
- package/dist/pages/colour-q2ntvI0w.js +1974 -0
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/command-palette-CJ7uBA04.js +1386 -0
- package/dist/pages/comment-box-CDSGYhr5.js +346 -0
- package/dist/pages/composer-D4B0NgpA.js +689 -0
- package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
- package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
- package/dist/pages/context-menu-F9DV30ia.js +487 -0
- package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
- package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
- package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
- package/dist/pages/date-input-GOW067EB.js +956 -0
- package/dist/pages/date-picker-GdBciR99.js +1569 -0
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/delta-CNAGv8JY.js +779 -0
- package/dist/pages/description-list-BPeXn1eW.js +1268 -0
- package/dist/pages/device-switcher-BCaN99c1.js +554 -0
- package/dist/pages/dialog-CRpkRC98.js +3164 -0
- package/dist/pages/docs-lM2UBSir.js +520 -0
- package/dist/pages/doodle-nzkqi2UI.js +201 -0
- package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
- package/dist/pages/drill-menu-cskH5mol.js +490 -0
- package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
- package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
- package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
- package/dist/pages/empty-state-4U2txFpI.js +1113 -0
- package/dist/pages/facet-filters-McbBeY9e.js +353 -0
- package/dist/pages/figure-D-HF5vCj.js +563 -0
- package/dist/pages/figure-strip-BB3mNl7D.js +1364 -0
- package/dist/pages/figure-tabs-QOeQMY6N.js +578 -0
- package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
- package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
- package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
- package/dist/pages/form-grid-BfWCVlie.js +692 -0
- package/dist/pages/gallery-BBk2EOri.js +453 -0
- package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
- package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
- package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
- package/dist/pages/heatmap-BohgIcNk.js +507 -0
- package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
- package/dist/pages/home-dashboard-CxPmvduE.js +962 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
- package/dist/pages/hosted-field-BLh-53AE.js +208 -0
- package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
- package/dist/pages/icon-button-Bu4Gj5sy.js +1200 -0
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/icons-CJ9Aar3d.js +736 -0
- package/dist/pages/image-cropper-NyougqLH.js +466 -0
- package/dist/pages/image-field-7knBv4mJ.js +567 -0
- package/dist/pages/import-result-CmTtGXW_.js +486 -0
- package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
- package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
- package/dist/pages/input-CzLCzfyx.js +2372 -0
- package/dist/pages/installation-C3UcpQJT.js +528 -0
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/kbd-UNj4zqxn.js +545 -0
- package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
- package/dist/pages/line-chart-CntWxeMF.js +1117 -0
- package/dist/pages/link-CXqvAg9z.js +689 -0
- package/dist/pages/link-picker-BMFGCC67.js +478 -0
- package/dist/pages/link-row-x8yaUuWc.js +595 -0
- package/dist/pages/live-globe-95ROMhGQ.js +715 -0
- package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
- package/dist/pages/loading-state-BNbCo51C.js +556 -0
- package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
- package/dist/pages/logo-B38rnzoq.js +571 -0
- package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
- package/dist/pages/markdown-Ied72vMT.js +237 -0
- package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
- package/dist/pages/media-banner-DkStCia0.js +233 -0
- package/dist/pages/menu-NrLYKqKp.js +2132 -0
- package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
- package/dist/pages/meta-line-D5p2TycR.js +371 -0
- package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
- package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
- package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
- package/dist/pages/motion-CrXtiBvA.js +865 -0
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/orbit-spinner-Dxv5qAhr.js +348 -0
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/overview-LA9XRhZc.js +130 -0
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/pagination-C1EgVtW4.js +294 -0
- package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
- package/dist/pages/password-field-DHEQKyUC.js +912 -0
- package/dist/pages/person-cell-BmjbADBz.js +564 -0
- package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
- package/dist/pages/plan-card-DRaA6RuB.js +621 -0
- package/dist/pages/plan-card-DtloWvMh.js +258 -0
- package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
- package/dist/pages/plan-grid-cfPVTB5V.js +251 -0
- package/dist/pages/point-list-BbPmZjsm.js +222 -0
- package/dist/pages/popover-C3Oar9D5.js +1198 -0
- package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
- package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
- package/dist/pages/price-CRBLoa9h.js +604 -0
- package/dist/pages/principles-pnDyfHpK.js +483 -0
- package/dist/pages/print-page-BkLv6bW8.js +513 -0
- package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
- package/dist/pages/progress-CP_awmo4.js +904 -0
- package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
- package/dist/pages/radio-group-C-4tg6FS.js +1639 -0
- package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
- package/dist/pages/rating-CweKN2SX.js +471 -0
- package/dist/pages/record-layout-DUP_X0RL.js +719 -0
- package/dist/pages/record-pager-y9D7JFgb.js +278 -0
- package/dist/pages/registry-BZg-xAbi.js +594 -0
- package/dist/pages/release-Cs6tl16C.js +16 -0
- package/dist/pages/repeater-BRZYKRQa.js +1351 -0
- package/dist/pages/reply-feedback-BDnHprla.js +192 -0
- package/dist/pages/reveal-BygENBbL.js +460 -0
- package/dist/pages/rich-text-DOFQZEpT.js +156 -0
- package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
- package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
- package/dist/pages/rolling-number-GR3Cyfpz.js +529 -0
- package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
- package/dist/pages/rule-list-DTCmIMpT.js +648 -0
- package/dist/pages/save-status-B5KkyMZP.js +378 -0
- package/dist/pages/schedule-YycI95O1.js +243 -0
- package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
- package/dist/pages/search-field-D1uG7R6A.js +693 -0
- package/dist/pages/search-menu-DMuXyUUW.js +580 -0
- package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
- package/dist/pages/section-rail-BtTCETS5.js +637 -0
- package/dist/pages/section-v2Pubup9.js +639 -0
- package/dist/pages/segmented-control-D-FB1K1T.js +1190 -0
- package/dist/pages/select-DZ43NpOm.js +1434 -0
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/separator-CFwqRvfO.js +428 -0
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/shape-DzniHAVT.js +627 -0
- package/dist/pages/share-list-D4wgBxKN.js +926 -0
- package/dist/pages/side-panel-CCtkrZjs.js +811 -0
- package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
- package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
- package/dist/pages/skip-link-BxznhSkz.js +252 -0
- package/dist/pages/slider-CAoPURKD.js +774 -0
- package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
- package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
- package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
- package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
- package/dist/pages/sparkline-D3aavCly.js +947 -0
- package/dist/pages/split-bar-DYgZnFID.js +414 -0
- package/dist/pages/split-button-Be08-VI-.js +335 -0
- package/dist/pages/split-pane-lSNZgTKt.js +523 -0
- package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
- package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
- package/dist/pages/status-dot-D99gAGsV.js +567 -0
- package/dist/pages/stepper-CxKTbEA-.js +1093 -0
- package/dist/pages/success-mark-CqFTOBEu.js +142 -0
- package/dist/pages/swatch-H_kNvHuC.js +565 -0
- package/dist/pages/switch-C93K6j9h.js +617 -0
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/tabs-Dh0mUsLw.js +1690 -0
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/textarea-CCM-SnGN.js +949 -0
- package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
- package/dist/pages/time-input-CA9-uZAa.js +442 -0
- package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
- package/dist/pages/timeline-BsMUTlpR.js +1798 -0
- package/dist/pages/toast-zXLRiMRT.js +1391 -0
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/tooltip-LHtCUkF-.js +826 -0
- package/dist/pages/translation-field-CTRXiF2N.js +251 -0
- package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
- package/dist/pages/tree-select-DU1qXHy_.js +492 -0
- package/dist/pages/tree-view-g_RjLtAb.js +739 -0
- package/dist/pages/typography-BSijtiRl.js +876 -0
- package/dist/pages/unit-input-Dml4fjmK.js +659 -0
- package/dist/pages/upload-rules-yozEzSah.js +419 -0
- package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
- package/dist/pages/value-change-CnubDKyO.js +489 -0
- package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
- package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
- package/dist/pages/working-status-CENemSsw.js +389 -0
- package/manifest.json +13001 -0
- package/package.json +35 -4
|
@@ -0,0 +1,1569 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section$1, 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-lM2UBSir.js";
|
|
4
|
+
import { t as Playground } from "./Playground-Mk1yIWXb.js";
|
|
5
|
+
import { c as SpecimenFrame, s as PopoverSheet } from "./_overlays-specimens-bawR331Z.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, dateFormatter, 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 = dateFormatter("en-GB", {
|
|
30
|
+
day: "numeric",
|
|
31
|
+
month: "short",
|
|
32
|
+
year: "numeric"
|
|
33
|
+
});
|
|
34
|
+
var weekdayDate = dateFormatter("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",
|
|
270
|
+
optional: true,
|
|
271
|
+
hint: date ? `Order #1042 is released on ${weekdayDate.format(date)}.` : "Held until you release it.",
|
|
272
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
273
|
+
clearable: true,
|
|
274
|
+
value: date,
|
|
275
|
+
onChange: setDate,
|
|
276
|
+
minValue: tomorrow
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function PublishAt({ hourCycle = 24 }) {
|
|
282
|
+
const [value, setValue] = useState(() => at(addDays(startOfToday(), 1), 9));
|
|
283
|
+
const now = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
284
|
+
return /* @__PURE__ */ jsx("div", {
|
|
285
|
+
className: "date-picker-stack",
|
|
286
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
287
|
+
label: hourCycle === 12 ? "Send the email at" : "Publish on",
|
|
288
|
+
hint: hourCycle === 12 ? "The Autumn sale email goes to 1,284 subscribers." : "The Arden ergonomic chair goes live on your store at this time.",
|
|
289
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
290
|
+
granularity: "minute",
|
|
291
|
+
hourCycle,
|
|
292
|
+
value,
|
|
293
|
+
onChange: setValue,
|
|
294
|
+
minValue: now
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function DiscountDates() {
|
|
300
|
+
const today = useMemo(() => startOfToday(), []);
|
|
301
|
+
const [starts, setStarts] = useState(() => at(addDays(today, 3), 9));
|
|
302
|
+
const [ends, setEnds] = useState(() => at(addDays(today, 17), 23, 59));
|
|
303
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
304
|
+
className: "date-picker-discount",
|
|
305
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
306
|
+
className: "date-picker-discount__code",
|
|
307
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
308
|
+
className: "date-picker-discount__name",
|
|
309
|
+
children: "AUTUMN20"
|
|
310
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
311
|
+
className: "date-picker-discount__meta",
|
|
312
|
+
children: "20% off everything in Home office"
|
|
313
|
+
})]
|
|
314
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
315
|
+
className: "date-picker-pair",
|
|
316
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
317
|
+
label: "Starts",
|
|
318
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
319
|
+
granularity: "minute",
|
|
320
|
+
value: starts,
|
|
321
|
+
onChange: setStarts,
|
|
322
|
+
minValue: today
|
|
323
|
+
})
|
|
324
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
325
|
+
label: "Ends",
|
|
326
|
+
optional: true,
|
|
327
|
+
hint: "Leave it empty to run until you end it.",
|
|
328
|
+
error: starts && ends && ends <= starts ? "End it after it starts, or leave it empty" : void 0,
|
|
329
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
330
|
+
granularity: "minute",
|
|
331
|
+
clearable: true,
|
|
332
|
+
value: ends,
|
|
333
|
+
onChange: setEnds,
|
|
334
|
+
minValue: starts ?? today
|
|
335
|
+
})
|
|
336
|
+
})]
|
|
337
|
+
})]
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
function BannerDates() {
|
|
341
|
+
const today = useMemo(() => startOfToday(), []);
|
|
342
|
+
const [range, setRange] = useState(() => ({
|
|
343
|
+
from: addDays(today, 7),
|
|
344
|
+
to: addDays(today, 20)
|
|
345
|
+
}));
|
|
346
|
+
const days = range ? Math.round((range.to.getTime() - range.from.getTime()) / 864e5) + 1 : 0;
|
|
347
|
+
return /* @__PURE__ */ jsx("div", {
|
|
348
|
+
className: "date-picker-stack",
|
|
349
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
350
|
+
label: "Show the banner",
|
|
351
|
+
hint: range ? `Free delivery banner, on the storefront for ${days} ${days === 1 ? "day" : "days"}.` : "Pick the first and the last day.",
|
|
352
|
+
children: /* @__PURE__ */ jsx(DateRangePicker, {
|
|
353
|
+
clearable: true,
|
|
354
|
+
value: range,
|
|
355
|
+
onChange: setRange,
|
|
356
|
+
minValue: today
|
|
357
|
+
})
|
|
358
|
+
})
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function SalesReport({ presets = true }) {
|
|
362
|
+
const today = useMemo(() => startOfToday(), []);
|
|
363
|
+
const [range, setRange] = useState(() => dateRangePresets[2].range(today));
|
|
364
|
+
const [preset, setPreset] = useState("last-30-days");
|
|
365
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
366
|
+
className: "date-picker-report",
|
|
367
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
368
|
+
className: "date-picker-report__bar",
|
|
369
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
370
|
+
className: "date-picker-report__title",
|
|
371
|
+
children: "Sales"
|
|
372
|
+
}), /* @__PURE__ */ jsx(DateRangePicker, {
|
|
373
|
+
"aria-label": "Report dates",
|
|
374
|
+
presets,
|
|
375
|
+
maxValue: today,
|
|
376
|
+
value: range,
|
|
377
|
+
onChange: (next, id) => {
|
|
378
|
+
setRange(next);
|
|
379
|
+
setPreset(id);
|
|
380
|
+
},
|
|
381
|
+
className: "date-picker-report__range"
|
|
382
|
+
})]
|
|
383
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
384
|
+
className: "date-picker-report__meta",
|
|
385
|
+
"aria-live": "polite",
|
|
386
|
+
children: [
|
|
387
|
+
range ? `${shortDate.format(range.from)} to ${shortDate.format(range.to)}` : "No dates",
|
|
388
|
+
" · ",
|
|
389
|
+
preset ? /* @__PURE__ */ jsxs(Fragment$1, { children: ["preset ", /* @__PURE__ */ jsx("code", { children: preset })] }) : "picked on the calendar"
|
|
390
|
+
]
|
|
391
|
+
})]
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
var day = (offset) => (today) => addDays(today, offset);
|
|
395
|
+
var ANALYTICS_PRESETS = [
|
|
396
|
+
{
|
|
397
|
+
id: "today",
|
|
398
|
+
label: "Today",
|
|
399
|
+
range: (today) => ({
|
|
400
|
+
from: today,
|
|
401
|
+
to: today
|
|
402
|
+
})
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
id: "yesterday",
|
|
406
|
+
label: "Yesterday",
|
|
407
|
+
range: (today) => ({
|
|
408
|
+
from: day(-1)(today),
|
|
409
|
+
to: day(-1)(today)
|
|
410
|
+
})
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
id: "last-7-days",
|
|
414
|
+
label: "Last 7 days",
|
|
415
|
+
range: (today) => ({
|
|
416
|
+
from: day(-6)(today),
|
|
417
|
+
to: today
|
|
418
|
+
})
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
id: "last-30-days",
|
|
422
|
+
label: "Last 30 days",
|
|
423
|
+
range: (today) => ({
|
|
424
|
+
from: day(-29)(today),
|
|
425
|
+
to: today
|
|
426
|
+
})
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
id: "last-90-days",
|
|
430
|
+
label: "Last 90 days",
|
|
431
|
+
range: (today) => ({
|
|
432
|
+
from: day(-89)(today),
|
|
433
|
+
to: today
|
|
434
|
+
})
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "last-365-days",
|
|
438
|
+
label: "Last 365 days",
|
|
439
|
+
range: (today) => ({
|
|
440
|
+
from: day(-364)(today),
|
|
441
|
+
to: today
|
|
442
|
+
})
|
|
443
|
+
}
|
|
444
|
+
];
|
|
445
|
+
/** A report's toolbar with the range as a pill: the presets first, Custom range for the calendars. */
|
|
446
|
+
function ReportMenu({ align = "start" }) {
|
|
447
|
+
const today = useMemo(() => startOfToday(), []);
|
|
448
|
+
const [range, setRange] = useState(() => ANALYTICS_PRESETS[3].range(today));
|
|
449
|
+
const [preset, setPreset] = useState("last-30-days");
|
|
450
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
451
|
+
className: "date-picker-report",
|
|
452
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
453
|
+
className: "date-picker-report__bar",
|
|
454
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
455
|
+
className: "date-picker-report__title",
|
|
456
|
+
children: "Analytics"
|
|
457
|
+
}), /* @__PURE__ */ jsx(DateRangePicker, {
|
|
458
|
+
trigger: "button",
|
|
459
|
+
size: "sm",
|
|
460
|
+
"aria-label": "Report dates",
|
|
461
|
+
presets: ANALYTICS_PRESETS,
|
|
462
|
+
maxValue: today,
|
|
463
|
+
align,
|
|
464
|
+
value: range,
|
|
465
|
+
onChange: (next, id) => {
|
|
466
|
+
setRange(next);
|
|
467
|
+
setPreset(id);
|
|
468
|
+
}
|
|
469
|
+
})]
|
|
470
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
471
|
+
className: "date-picker-report__meta",
|
|
472
|
+
"aria-live": "polite",
|
|
473
|
+
children: [
|
|
474
|
+
range ? `${shortDate.format(range.from)} to ${shortDate.format(range.to)}` : "No dates",
|
|
475
|
+
" · ",
|
|
476
|
+
preset ? /* @__PURE__ */ jsxs(Fragment$1, { children: ["preset ", /* @__PURE__ */ jsx("code", { children: preset })] }) : "a custom range"
|
|
477
|
+
]
|
|
478
|
+
})]
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function NativeSwap() {
|
|
482
|
+
const [holdUntil, setHoldUntil] = useState("");
|
|
483
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
484
|
+
className: "date-picker-stack",
|
|
485
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
486
|
+
label: "Hold until",
|
|
487
|
+
optional: true,
|
|
488
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
489
|
+
clearable: true,
|
|
490
|
+
value: fromISODate(holdUntil),
|
|
491
|
+
onChange: (date) => setHoldUntil(date ? toISODate(date) : "")
|
|
492
|
+
})
|
|
493
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
494
|
+
className: "date-picker-report__meta",
|
|
495
|
+
children: ["Stored as ", /* @__PURE__ */ jsx("code", { children: holdUntil ? `'${holdUntil}'` : "''" })]
|
|
496
|
+
})]
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function Stage({ children }) {
|
|
500
|
+
return /* @__PURE__ */ jsx("div", {
|
|
501
|
+
className: "date-picker-stage",
|
|
502
|
+
children
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
function Page() {
|
|
506
|
+
const today = startOfToday();
|
|
507
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
508
|
+
title: "Date picker",
|
|
509
|
+
status: "new",
|
|
510
|
+
importNames: [
|
|
511
|
+
"DatePicker",
|
|
512
|
+
"DateRangePicker",
|
|
513
|
+
"toISODate",
|
|
514
|
+
"fromISODate"
|
|
515
|
+
],
|
|
516
|
+
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.",
|
|
517
|
+
children: [
|
|
518
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
519
|
+
id: "playground",
|
|
520
|
+
title: "Playground",
|
|
521
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
522
|
+
"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 ",
|
|
523
|
+
/* @__PURE__ */ jsx("code", { children: "granularity=\"minute\"" }),
|
|
524
|
+
" it stays open for the time."
|
|
525
|
+
] }),
|
|
526
|
+
children: /* @__PURE__ */ jsx(Playground, {
|
|
527
|
+
clientOnly: true,
|
|
528
|
+
component: "DatePicker",
|
|
529
|
+
controls: PLAYGROUND,
|
|
530
|
+
render: (v) => /* @__PURE__ */ jsx(Stage, { children: /* @__PURE__ */ jsx(DatePicker, {
|
|
531
|
+
"aria-label": String(v["aria-label"]),
|
|
532
|
+
placeholder: String(v.placeholder) || void 0,
|
|
533
|
+
size: v.size,
|
|
534
|
+
granularity: v.granularity,
|
|
535
|
+
hourCycle: v.hourCycle === "12" ? 12 : 24,
|
|
536
|
+
clearable: Boolean(v.clearable),
|
|
537
|
+
invalid: Boolean(v.invalid),
|
|
538
|
+
readOnly: Boolean(v.readOnly),
|
|
539
|
+
disabled: Boolean(v.disabled)
|
|
540
|
+
}) })
|
|
541
|
+
})
|
|
542
|
+
}),
|
|
543
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
544
|
+
id: "picking-a-day",
|
|
545
|
+
title: "Picking a day",
|
|
546
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
547
|
+
"Put the picker in a ",
|
|
548
|
+
/* @__PURE__ */ jsx("code", { children: "Field" }),
|
|
549
|
+
" for its label, hint and error, as with any input. Here a delivery can be booked from tomorrow, on any day but Sunday: ",
|
|
550
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
551
|
+
" rules out the past (and the months before it cannot even be reached), and ",
|
|
552
|
+
/* @__PURE__ */ jsx("code", { children: "disabledDays" }),
|
|
553
|
+
" rules out Sundays. ",
|
|
554
|
+
/* @__PURE__ */ jsx("code", { children: "format" }),
|
|
555
|
+
" adds the weekday to the field, because for a delivery the day of the week matters."
|
|
556
|
+
] }), /* @__PURE__ */ jsx("p", { children: "Press Book delivery with no date to see the error, and focus come back to the field." })] }),
|
|
557
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
558
|
+
clientOnly: true,
|
|
559
|
+
code: `
|
|
560
|
+
const [date, setDate] = useState<Date | null>(null)
|
|
561
|
+
|
|
562
|
+
<Field label="Delivery date" hint="We deliver Monday to Saturday, from tomorrow." error={error}>
|
|
563
|
+
<DatePicker
|
|
564
|
+
value={date}
|
|
565
|
+
onChange={setDate}
|
|
566
|
+
minValue={tomorrow}
|
|
567
|
+
disabledDays={{ dayOfWeek: [0] }}
|
|
568
|
+
format={{ weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' }}
|
|
569
|
+
/>
|
|
570
|
+
</Field>`,
|
|
571
|
+
children: /* @__PURE__ */ jsx(BookDelivery, {})
|
|
572
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
573
|
+
columns: ["Part", "What it does"],
|
|
574
|
+
rows: [
|
|
575
|
+
["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."],
|
|
576
|
+
["Calendar glyph", "Quiet slate, firming up while the field has focus. Clicking anywhere on the field opens the calendar."],
|
|
577
|
+
["Date", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
578
|
+
"Formatted with Intl in British English: ",
|
|
579
|
+
/* @__PURE__ */ jsx("code", { children: "2 Oct 2026" }),
|
|
580
|
+
" by default, the placeholder in quiet slate until then."
|
|
581
|
+
] })],
|
|
582
|
+
["Clear button", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
583
|
+
"With ",
|
|
584
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
585
|
+
", a small round button pops in at the end once there is a date."
|
|
586
|
+
] })],
|
|
587
|
+
["Calendar", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
588
|
+
"On the Popover's sheet, growing out of the field. See ",
|
|
589
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
590
|
+
to: "/components/calendar",
|
|
591
|
+
children: "Calendar"
|
|
592
|
+
}),
|
|
593
|
+
" for the grid itself."
|
|
594
|
+
] })]
|
|
595
|
+
]
|
|
596
|
+
})]
|
|
597
|
+
}),
|
|
598
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
599
|
+
id: "sizes",
|
|
600
|
+
title: "Sizes",
|
|
601
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
602
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
603
|
+
" 30px, ",
|
|
604
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
605
|
+
" 36px (default) and ",
|
|
606
|
+
/* @__PURE__ */ jsx("code", { children: "lg" }),
|
|
607
|
+
" 44px: the heights of Input and Button, so a date, a text field and a button share a line exactly."
|
|
608
|
+
] }),
|
|
609
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
610
|
+
clientOnly: true,
|
|
611
|
+
code: `
|
|
612
|
+
<Input size="sm" aria-label="Postcode" defaultValue="LS1 4AP" />
|
|
613
|
+
<DatePicker size="sm" aria-label="Delivery date" defaultValue={deliveryDay} />
|
|
614
|
+
<Button size="sm">Book</Button>
|
|
615
|
+
|
|
616
|
+
{/* md (default) and lg follow the same pattern */}`,
|
|
617
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
618
|
+
className: "date-picker-sizes",
|
|
619
|
+
children: [
|
|
620
|
+
"sm",
|
|
621
|
+
"md",
|
|
622
|
+
"lg"
|
|
623
|
+
].map((size) => /* @__PURE__ */ jsxs("div", {
|
|
624
|
+
className: "date-picker-sizes__row",
|
|
625
|
+
children: [
|
|
626
|
+
/* @__PURE__ */ jsx(Input, {
|
|
627
|
+
size,
|
|
628
|
+
"aria-label": "Postcode",
|
|
629
|
+
defaultValue: "LS1 4AP",
|
|
630
|
+
className: "date-picker-sizes__postcode"
|
|
631
|
+
}),
|
|
632
|
+
/* @__PURE__ */ jsx(DatePicker, {
|
|
633
|
+
size,
|
|
634
|
+
"aria-label": "Delivery date",
|
|
635
|
+
defaultValue: nextDeliveryDay(today, 3)
|
|
636
|
+
}),
|
|
637
|
+
/* @__PURE__ */ jsx(Button, {
|
|
638
|
+
size,
|
|
639
|
+
children: "Book"
|
|
640
|
+
})
|
|
641
|
+
]
|
|
642
|
+
}, size))
|
|
643
|
+
})
|
|
644
|
+
})
|
|
645
|
+
}),
|
|
646
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
647
|
+
id: "states",
|
|
648
|
+
title: "States",
|
|
649
|
+
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." }),
|
|
650
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
651
|
+
clientOnly: true,
|
|
652
|
+
align: "fill",
|
|
653
|
+
caption: "Empty, filled, invalid, read-only and disabled.",
|
|
654
|
+
code: `
|
|
655
|
+
<Field label="Delivery date">
|
|
656
|
+
<DatePicker />
|
|
657
|
+
</Field>
|
|
658
|
+
<Field label="Delivery date">
|
|
659
|
+
<DatePicker defaultValue={deliveryDay} />
|
|
660
|
+
</Field>
|
|
661
|
+
<Field label="Delivery date" error="Choose a day from tomorrow onwards">
|
|
662
|
+
<DatePicker defaultValue={yesterday} minValue={tomorrow} />
|
|
663
|
+
</Field>
|
|
664
|
+
<Field label="Order placed" hint="Set when the order came in">
|
|
665
|
+
<DatePicker readOnly value={placedAt} />
|
|
666
|
+
</Field>
|
|
667
|
+
<Field label="Sale ends" hint="Turn on Put on sale to set an end date">
|
|
668
|
+
<DatePicker disabled />
|
|
669
|
+
</Field>`,
|
|
670
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
671
|
+
className: "date-picker-grid",
|
|
672
|
+
children: [
|
|
673
|
+
/* @__PURE__ */ jsx(Field, {
|
|
674
|
+
label: "Delivery date",
|
|
675
|
+
children: /* @__PURE__ */ jsx(DatePicker, {})
|
|
676
|
+
}),
|
|
677
|
+
/* @__PURE__ */ jsx(Field, {
|
|
678
|
+
label: "Delivery date",
|
|
679
|
+
children: /* @__PURE__ */ jsx(DatePicker, { defaultValue: nextDeliveryDay(today, 3) })
|
|
680
|
+
}),
|
|
681
|
+
/* @__PURE__ */ jsx(Field, {
|
|
682
|
+
label: "Delivery date",
|
|
683
|
+
error: "Choose a day from tomorrow onwards",
|
|
684
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
685
|
+
defaultValue: addDays(today, -1),
|
|
686
|
+
minValue: addDays(today, 1)
|
|
687
|
+
})
|
|
688
|
+
}),
|
|
689
|
+
/* @__PURE__ */ jsx(Field, {
|
|
690
|
+
label: "Order placed",
|
|
691
|
+
hint: "Set when the order came in",
|
|
692
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
693
|
+
readOnly: true,
|
|
694
|
+
value: addDays(today, -2)
|
|
695
|
+
})
|
|
696
|
+
}),
|
|
697
|
+
/* @__PURE__ */ jsx(Field, {
|
|
698
|
+
label: "Sale ends",
|
|
699
|
+
hint: "Turn on Put on sale to set an end date",
|
|
700
|
+
children: /* @__PURE__ */ jsx(DatePicker, { disabled: true })
|
|
701
|
+
})
|
|
702
|
+
]
|
|
703
|
+
})
|
|
704
|
+
})
|
|
705
|
+
}),
|
|
706
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
707
|
+
id: "clearing",
|
|
708
|
+
title: "Clearing",
|
|
709
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
710
|
+
"An optional date needs a way back to none. ",
|
|
711
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
712
|
+
" 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."
|
|
713
|
+
] }),
|
|
714
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
715
|
+
clientOnly: true,
|
|
716
|
+
code: `
|
|
717
|
+
<Field label="Hold until" optional hint="Order #1042 is released on that day.">
|
|
718
|
+
<DatePicker clearable value={date} onChange={setDate} minValue={tomorrow} />
|
|
719
|
+
</Field>`,
|
|
720
|
+
children: /* @__PURE__ */ jsx(HoldUntil, {})
|
|
721
|
+
})
|
|
722
|
+
}),
|
|
723
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
724
|
+
id: "time",
|
|
725
|
+
title: "Date and time",
|
|
726
|
+
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: [
|
|
727
|
+
"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, ",
|
|
728
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
729
|
+
" and ",
|
|
730
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
731
|
+
" hold to the minute."
|
|
732
|
+
] })] }),
|
|
733
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
734
|
+
clientOnly: true,
|
|
735
|
+
code: `
|
|
736
|
+
<Field label="Publish on" hint="The Arden ergonomic chair goes live on your store at this time.">
|
|
737
|
+
<DatePicker granularity="minute" value={publishAt} onChange={setPublishAt} minValue={new Date()} />
|
|
738
|
+
</Field>`,
|
|
739
|
+
children: /* @__PURE__ */ jsx(PublishAt, {})
|
|
740
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
741
|
+
title: "12-hour clock",
|
|
742
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
743
|
+
/* @__PURE__ */ jsxs("code", { children: ["hourCycle=", "{12}"] }),
|
|
744
|
+
" shows the hours 1 to 12 with an AM and PM switch beside them, and the field reads ",
|
|
745
|
+
/* @__PURE__ */ jsx("code", { children: "9:00 am" }),
|
|
746
|
+
". Keep the default 24-hour clock unless the people using it expect otherwise."
|
|
747
|
+
] }),
|
|
748
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
749
|
+
clientOnly: true,
|
|
750
|
+
code: `
|
|
751
|
+
<DatePicker granularity="minute" hourCycle={12} value={sendAt} onChange={setSendAt} minValue={new Date()} />`,
|
|
752
|
+
children: /* @__PURE__ */ jsx(PublishAt, { hourCycle: 12 })
|
|
753
|
+
})
|
|
754
|
+
})]
|
|
755
|
+
}),
|
|
756
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
757
|
+
id: "start-and-end",
|
|
758
|
+
title: "A start and an end",
|
|
759
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
760
|
+
"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: ",
|
|
761
|
+
/* @__PURE__ */ jsxs("code", { children: ["minValue=", "{starts}"] }),
|
|
762
|
+
" on the end keeps it from being picked before the start. Move the start past the end to see the error."
|
|
763
|
+
] }),
|
|
764
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
765
|
+
clientOnly: true,
|
|
766
|
+
align: "fill",
|
|
767
|
+
code: `
|
|
768
|
+
<Field label="Starts">
|
|
769
|
+
<DatePicker granularity="minute" value={starts} onChange={setStarts} minValue={today} />
|
|
770
|
+
</Field>
|
|
771
|
+
<Field label="Ends" optional hint="Leave it empty to run until you end it." error={error}>
|
|
772
|
+
<DatePicker granularity="minute" clearable value={ends} onChange={setEnds} minValue={starts ?? today} />
|
|
773
|
+
</Field>`,
|
|
774
|
+
children: /* @__PURE__ */ jsx(DiscountDates, {})
|
|
775
|
+
})
|
|
776
|
+
}),
|
|
777
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
778
|
+
id: "ranges",
|
|
779
|
+
title: "Date ranges",
|
|
780
|
+
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: [
|
|
781
|
+
"The value is ",
|
|
782
|
+
/* @__PURE__ */ jsx("code", { children: "{ from, to }" }),
|
|
783
|
+
", both local midnight and both included, and the field reads",
|
|
784
|
+
" ",
|
|
785
|
+
/* @__PURE__ */ jsx("code", { children: "2 Oct 2026 to 9 Oct 2026" }),
|
|
786
|
+
"."
|
|
787
|
+
] })] }),
|
|
788
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
789
|
+
clientOnly: true,
|
|
790
|
+
code: `
|
|
791
|
+
const [range, setRange] = useState<DateRange | null>({ from: nextWeek, to: inThreeWeeks })
|
|
792
|
+
|
|
793
|
+
<Field label="Show the banner" hint="Free delivery banner, on the storefront for 14 days.">
|
|
794
|
+
<DateRangePicker clearable value={range} onChange={setRange} minValue={today} />
|
|
795
|
+
</Field>`,
|
|
796
|
+
children: /* @__PURE__ */ jsx(BannerDates, {})
|
|
797
|
+
})
|
|
798
|
+
}),
|
|
799
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
800
|
+
id: "presets",
|
|
801
|
+
title: "Presets",
|
|
802
|
+
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: [
|
|
803
|
+
/* @__PURE__ */ jsx("code", { children: "onChange" }),
|
|
804
|
+
" gets the preset's ",
|
|
805
|
+
/* @__PURE__ */ jsx("code", { children: "id" }),
|
|
806
|
+
" 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 one row of chips above one month, which scrolls sideways, so the month keeps the room it needs."
|
|
807
|
+
] })] }),
|
|
808
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
809
|
+
clientOnly: true,
|
|
810
|
+
align: "fill",
|
|
811
|
+
code: `
|
|
812
|
+
<DateRangePicker
|
|
813
|
+
aria-label="Report dates"
|
|
814
|
+
presets
|
|
815
|
+
maxValue={today}
|
|
816
|
+
value={range}
|
|
817
|
+
onChange={(next, preset) => {
|
|
818
|
+
setRange(next)
|
|
819
|
+
setPreset(preset) // 'last-30-days', or undefined for a range picked on the calendar
|
|
820
|
+
}}
|
|
821
|
+
/>`,
|
|
822
|
+
children: /* @__PURE__ */ jsx(SalesReport, {})
|
|
823
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
824
|
+
title: "Your own presets",
|
|
825
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
826
|
+
"Pass a list of ",
|
|
827
|
+
/* @__PURE__ */ jsx("code", { children: "{ id, label, range }" }),
|
|
828
|
+
", where ",
|
|
829
|
+
/* @__PURE__ */ jsx("code", { children: "range(today)" }),
|
|
830
|
+
" returns the dates. These match the analytics pages. Presets that would cross ",
|
|
831
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
832
|
+
" or ",
|
|
833
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
834
|
+
" are shown but cannot be picked."
|
|
835
|
+
] }),
|
|
836
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
837
|
+
clientOnly: true,
|
|
838
|
+
align: "fill",
|
|
839
|
+
code: `
|
|
840
|
+
const presets: DateRangePreset[] = [
|
|
841
|
+
{ id: 'today', label: 'Today', range: (today) => ({ from: today, to: today }) },
|
|
842
|
+
{ id: 'yesterday', label: 'Yesterday', range: (today) => ({ from: addDays(today, -1), to: addDays(today, -1) }) },
|
|
843
|
+
{ id: 'last-7-days', label: 'Last 7 days', range: (today) => ({ from: addDays(today, -6), to: today }) },
|
|
844
|
+
{ id: 'last-30-days', label: 'Last 30 days', range: (today) => ({ from: addDays(today, -29), to: today }) },
|
|
845
|
+
{ id: 'last-90-days', label: 'Last 90 days', range: (today) => ({ from: addDays(today, -89), to: today }) },
|
|
846
|
+
{ id: 'last-365-days', label: 'Last 365 days', range: (today) => ({ from: addDays(today, -364), to: today }) },
|
|
847
|
+
]
|
|
848
|
+
|
|
849
|
+
<DateRangePicker aria-label="Report dates" presets={presets} maxValue={today} value={range} onChange={…} />`,
|
|
850
|
+
children: /* @__PURE__ */ jsx(SalesReport, { presets: ANALYTICS_PRESETS })
|
|
851
|
+
})
|
|
852
|
+
})]
|
|
853
|
+
}),
|
|
854
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
855
|
+
id: "range-menu",
|
|
856
|
+
title: "A range as a menu",
|
|
857
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
858
|
+
/* @__PURE__ */ jsx("code", { children: "trigger=\"button\"" }),
|
|
859
|
+
" makes the range a pill for a report's or a list's toolbar: a calendar glyph, the preset or the range, and a chevron. It opens a menu of ranges, presets first (the kit's, unless",
|
|
860
|
+
" ",
|
|
861
|
+
/* @__PURE__ */ jsx("code", { children: "presets" }),
|
|
862
|
+
" gives your own) with the current one ticked, and Custom range last. Only Custom range reveals the calendars, beside the ranges (under them on a phone), as a draft: what is picked so far is said under the months, Cancel puts it back and hands focus to Custom range, and Apply takes it."
|
|
863
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
864
|
+
"The arrows, Home and End move through the ranges; focus starts on the ticked one. Near the window's edge the menu flips above the pill, or scrolls within the window's height. ",
|
|
865
|
+
/* @__PURE__ */ jsx("code", { children: "size" }),
|
|
866
|
+
" is the Button's."
|
|
867
|
+
] })] }),
|
|
868
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
869
|
+
clientOnly: true,
|
|
870
|
+
align: "fill",
|
|
871
|
+
minHeight: 420,
|
|
872
|
+
code: `
|
|
873
|
+
<DateRangePicker
|
|
874
|
+
trigger="button"
|
|
875
|
+
size="sm"
|
|
876
|
+
align="end"
|
|
877
|
+
aria-label="Report dates"
|
|
878
|
+
presets={analyticsPresets}
|
|
879
|
+
maxValue={today}
|
|
880
|
+
value={range}
|
|
881
|
+
onChange={(next, preset) => {
|
|
882
|
+
setRange(next)
|
|
883
|
+
setPreset(preset) // undefined for a custom range
|
|
884
|
+
}}
|
|
885
|
+
/>`,
|
|
886
|
+
children: /* @__PURE__ */ jsx(ReportMenu, { align: "end" })
|
|
887
|
+
})
|
|
888
|
+
}),
|
|
889
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
890
|
+
id: "limits",
|
|
891
|
+
title: "Limits and unavailable days",
|
|
892
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
893
|
+
"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 ",
|
|
894
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
895
|
+
to: "/components/calendar#unavailable",
|
|
896
|
+
children: "Calendar"
|
|
897
|
+
}),
|
|
898
|
+
" page lists every way to describe them."
|
|
899
|
+
] }),
|
|
900
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
901
|
+
columns: [
|
|
902
|
+
"Prop",
|
|
903
|
+
"Rules out",
|
|
904
|
+
"For example"
|
|
905
|
+
],
|
|
906
|
+
rows: [
|
|
907
|
+
[
|
|
908
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
909
|
+
"Every day before it. Months before it cannot be reached.",
|
|
910
|
+
"Delivery from tomorrow; a discount end no earlier than its start."
|
|
911
|
+
],
|
|
912
|
+
[
|
|
913
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
914
|
+
"Every day after it. Months after it cannot be reached.",
|
|
915
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
916
|
+
"Reports up to today: ",
|
|
917
|
+
/* @__PURE__ */ jsxs("code", { children: ["maxValue=", "{today}"] }),
|
|
918
|
+
"."
|
|
919
|
+
] })
|
|
920
|
+
],
|
|
921
|
+
[
|
|
922
|
+
/* @__PURE__ */ jsx("code", { children: "disabledDays" }),
|
|
923
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
924
|
+
"Any day matching: a date, dates, ",
|
|
925
|
+
/* @__PURE__ */ jsx("code", { children: "{ dayOfWeek }" }),
|
|
926
|
+
", a range, or a function."
|
|
927
|
+
] }),
|
|
928
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
929
|
+
"Sundays: ",
|
|
930
|
+
/* @__PURE__ */ jsx("code", { children: "{ dayOfWeek: [0] }" }),
|
|
931
|
+
". Bank holidays: ",
|
|
932
|
+
/* @__PURE__ */ jsx("code", { children: "(date) => isBankHoliday(date)" }),
|
|
933
|
+
"."
|
|
934
|
+
] })
|
|
935
|
+
]
|
|
936
|
+
]
|
|
937
|
+
})
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
940
|
+
id: "keyboard",
|
|
941
|
+
title: "Keyboard",
|
|
942
|
+
description: /* @__PURE__ */ jsx("p", { children: "Everything works from the keyboard: open, move, pick and close, and focus always lands somewhere useful." }),
|
|
943
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
944
|
+
columns: [
|
|
945
|
+
"Where",
|
|
946
|
+
"Key",
|
|
947
|
+
"What it does"
|
|
948
|
+
],
|
|
949
|
+
rows: [
|
|
950
|
+
[
|
|
951
|
+
"Field",
|
|
952
|
+
"Enter, Space, Down arrow",
|
|
953
|
+
"Opens the calendar, with focus on the chosen day (or today, or the first day that can be picked)."
|
|
954
|
+
],
|
|
955
|
+
[
|
|
956
|
+
"Field",
|
|
957
|
+
"Backspace, Delete",
|
|
958
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
959
|
+
"Clears the date, when the picker is ",
|
|
960
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
961
|
+
". (A ",
|
|
962
|
+
/* @__PURE__ */ jsx("code", { children: "typed" }),
|
|
963
|
+
" field is edited as text.)"
|
|
964
|
+
] })
|
|
965
|
+
],
|
|
966
|
+
[
|
|
967
|
+
"Typed field",
|
|
968
|
+
"Digits, Enter, Down arrow",
|
|
969
|
+
/* @__PURE__ */ jsx(Fragment$1, { children: "Type the date; Enter reads it (and still submits a form); Down opens the calendar. Tab goes on to the calendar button." })
|
|
970
|
+
],
|
|
971
|
+
[
|
|
972
|
+
"Calendar",
|
|
973
|
+
"Arrow keys",
|
|
974
|
+
"Move a day, or a week up and down, into the next month when they run off the edge."
|
|
975
|
+
],
|
|
976
|
+
[
|
|
977
|
+
"Calendar",
|
|
978
|
+
"Page Up, Page Down",
|
|
979
|
+
"Move a month. With Shift, a year."
|
|
980
|
+
],
|
|
981
|
+
[
|
|
982
|
+
"Calendar caption",
|
|
983
|
+
"Tab, arrow keys",
|
|
984
|
+
/* @__PURE__ */ jsx(Fragment$1, { children: "With a month and a year to choose from, Tab reaches the two selects (named Month and Year), and the arrow keys or the list change them." })
|
|
985
|
+
],
|
|
986
|
+
[
|
|
987
|
+
"Calendar",
|
|
988
|
+
"Home, End",
|
|
989
|
+
"Move to the start or the end of the week."
|
|
990
|
+
],
|
|
991
|
+
[
|
|
992
|
+
"Calendar",
|
|
993
|
+
"Enter, Space",
|
|
994
|
+
"Pick the day. A single day closes the calendar; a range closes on its second day."
|
|
995
|
+
],
|
|
996
|
+
[
|
|
997
|
+
"Time",
|
|
998
|
+
"Digits, Up and Down arrows",
|
|
999
|
+
"Type the hours and minutes, or step them round the clock."
|
|
1000
|
+
],
|
|
1001
|
+
[
|
|
1002
|
+
"Time",
|
|
1003
|
+
"Enter",
|
|
1004
|
+
"Closes the calendar."
|
|
1005
|
+
],
|
|
1006
|
+
[
|
|
1007
|
+
"Anywhere inside",
|
|
1008
|
+
"Tab, Shift Tab",
|
|
1009
|
+
"Move between the presets, the month buttons, the grid and the time, and round again: focus stays inside while it is open."
|
|
1010
|
+
],
|
|
1011
|
+
[
|
|
1012
|
+
"Anywhere inside",
|
|
1013
|
+
"Escape",
|
|
1014
|
+
"Closes the calendar and returns focus to the field. A range with only its first day picked is dropped."
|
|
1015
|
+
]
|
|
1016
|
+
]
|
|
1017
|
+
})
|
|
1018
|
+
}),
|
|
1019
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1020
|
+
id: "native",
|
|
1021
|
+
title: "Replacing a native date field",
|
|
1022
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
1023
|
+
"The pickers take and give a ",
|
|
1024
|
+
/* @__PURE__ */ jsx("code", { children: "Date" }),
|
|
1025
|
+
". A native ",
|
|
1026
|
+
/* @__PURE__ */ jsx("code", { children: "<input type=\"date\">" }),
|
|
1027
|
+
" holds a string,",
|
|
1028
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DD" }),
|
|
1029
|
+
", and ",
|
|
1030
|
+
/* @__PURE__ */ jsx("code", { children: "new Date()" }),
|
|
1031
|
+
" 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."
|
|
1032
|
+
] }), /* @__PURE__ */ jsx("p", { children: "Pick a day, then clear it, and watch the stored string." })] }),
|
|
1033
|
+
children: [
|
|
1034
|
+
/* @__PURE__ */ jsxs(Note, {
|
|
1035
|
+
title: "Keeping the string?",
|
|
1036
|
+
children: [
|
|
1037
|
+
"If the page keeps the string, use ",
|
|
1038
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
1039
|
+
to: "/components/date-input",
|
|
1040
|
+
children: "DateInput"
|
|
1041
|
+
}),
|
|
1042
|
+
". It is this conversion in one component, with the same ",
|
|
1043
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
1044
|
+
" and ",
|
|
1045
|
+
/* @__PURE__ */ jsx("code", { children: "onChange" }),
|
|
1046
|
+
" as the native input, so nothing else in the page changes."
|
|
1047
|
+
]
|
|
1048
|
+
}),
|
|
1049
|
+
/* @__PURE__ */ jsx(Example, {
|
|
1050
|
+
clientOnly: true,
|
|
1051
|
+
code: `
|
|
1052
|
+
import { DatePicker, toISODate, fromISODate } from '@orbitcommerce/constellation'
|
|
1053
|
+
|
|
1054
|
+
// Before
|
|
1055
|
+
<input type="date" value={holdUntil} onChange={(e) => setHoldUntil(e.target.value)} />
|
|
1056
|
+
|
|
1057
|
+
// After: the state is still 'YYYY-MM-DD' (or '' for none)
|
|
1058
|
+
<DatePicker
|
|
1059
|
+
clearable
|
|
1060
|
+
value={fromISODate(holdUntil)}
|
|
1061
|
+
onChange={(date) => setHoldUntil(date ? toISODate(date) : '')}
|
|
1062
|
+
/>`,
|
|
1063
|
+
children: /* @__PURE__ */ jsx(NativeSwap, {})
|
|
1064
|
+
}),
|
|
1065
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1066
|
+
columns: ["Native", "DatePicker"],
|
|
1067
|
+
rows: [
|
|
1068
|
+
[/* @__PURE__ */ jsx("code", { children: "type=\"date\"" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1069
|
+
"DatePicker. The value is a ",
|
|
1070
|
+
/* @__PURE__ */ jsx("code", { children: "Date" }),
|
|
1071
|
+
" at local midnight."
|
|
1072
|
+
] })],
|
|
1073
|
+
[/* @__PURE__ */ jsx("code", { children: "type=\"datetime-local\"" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1074
|
+
/* @__PURE__ */ jsx("code", { children: "granularity=\"minute\"" }),
|
|
1075
|
+
", with ",
|
|
1076
|
+
/* @__PURE__ */ jsx("code", { children: "toISODateTime" }),
|
|
1077
|
+
" for the ",
|
|
1078
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DDTHH:mm" }),
|
|
1079
|
+
" string."
|
|
1080
|
+
] })],
|
|
1081
|
+
[/* @__PURE__ */ jsx("code", { children: "value" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1082
|
+
/* @__PURE__ */ jsxs("code", { children: ["value=", "{fromISODate(text)}"] }),
|
|
1083
|
+
". Empty or invalid text reads as ",
|
|
1084
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
1085
|
+
"."
|
|
1086
|
+
] })],
|
|
1087
|
+
[/* @__PURE__ */ jsx("code", { children: "onChange" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1088
|
+
/* @__PURE__ */ jsx("code", { children: "onChange={(date) => set(date ? toISODate(date) : '')}" }),
|
|
1089
|
+
". Called with a ",
|
|
1090
|
+
/* @__PURE__ */ jsx("code", { children: "Date" }),
|
|
1091
|
+
", or ",
|
|
1092
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
1093
|
+
" when cleared."
|
|
1094
|
+
] })],
|
|
1095
|
+
[/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1096
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
1097
|
+
", ",
|
|
1098
|
+
/* @__PURE__ */ jsx("code", { children: "max" })
|
|
1099
|
+
] }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1100
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
1101
|
+
", ",
|
|
1102
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
1103
|
+
" (pass ",
|
|
1104
|
+
/* @__PURE__ */ jsx("code", { children: "fromISODate(min)" }),
|
|
1105
|
+
")."
|
|
1106
|
+
] })],
|
|
1107
|
+
[/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1108
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
1109
|
+
", ",
|
|
1110
|
+
/* @__PURE__ */ jsx("code", { children: "readOnly" })
|
|
1111
|
+
] }), "The same."],
|
|
1112
|
+
[/* @__PURE__ */ jsx("code", { children: "required" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1113
|
+
"Leave ",
|
|
1114
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
1115
|
+
" off and check on submit, showing ",
|
|
1116
|
+
/* @__PURE__ */ jsx("code", { children: "error" }),
|
|
1117
|
+
" on the Field."
|
|
1118
|
+
] })],
|
|
1119
|
+
[/* @__PURE__ */ jsx("code", { children: "name" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1120
|
+
"The same: submits ",
|
|
1121
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DD" }),
|
|
1122
|
+
" (or ",
|
|
1123
|
+
/* @__PURE__ */ jsx("code", { children: "YYYY-MM-DDTHH:mm" }),
|
|
1124
|
+
") with the form."
|
|
1125
|
+
] })],
|
|
1126
|
+
["Two date fields for a range", "One DateRangePicker, unless each end needs its own time or the end is optional."]
|
|
1127
|
+
]
|
|
1128
|
+
}),
|
|
1129
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1130
|
+
columns: ["Helper", "Does"],
|
|
1131
|
+
rows: [
|
|
1132
|
+
[/* @__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."] })],
|
|
1133
|
+
[/* @__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."] })],
|
|
1134
|
+
[/* @__PURE__ */ jsx("code", { children: "fromISODate(text)" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1135
|
+
"Reads both of those as local time, and a full timestamp with a zone (",
|
|
1136
|
+
/* @__PURE__ */ jsx("code", { children: "…Z" }),
|
|
1137
|
+
", ",
|
|
1138
|
+
/* @__PURE__ */ jsx("code", { children: "+01:00" }),
|
|
1139
|
+
") as the instant it is. Empty, malformed or impossible dates give ",
|
|
1140
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
1141
|
+
"."
|
|
1142
|
+
] })]
|
|
1143
|
+
]
|
|
1144
|
+
}),
|
|
1145
|
+
/* @__PURE__ */ jsx(Fragment$1, {})
|
|
1146
|
+
]
|
|
1147
|
+
}),
|
|
1148
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1149
|
+
id: "both-themes",
|
|
1150
|
+
title: "In both themes",
|
|
1151
|
+
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." }),
|
|
1152
|
+
children: [/* @__PURE__ */ jsx(ThemePair, {
|
|
1153
|
+
clientOnly: true,
|
|
1154
|
+
align: "start",
|
|
1155
|
+
children: /* @__PURE__ */ jsx(DatePickerStill, {})
|
|
1156
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1157
|
+
className: "overlays-stack",
|
|
1158
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
1159
|
+
clientOnly: true,
|
|
1160
|
+
align: "start",
|
|
1161
|
+
caption: "The range sheet with presets, two months wide.",
|
|
1162
|
+
children: /* @__PURE__ */ jsx(RangeSheetStill, {})
|
|
1163
|
+
})
|
|
1164
|
+
})]
|
|
1165
|
+
}),
|
|
1166
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1167
|
+
id: "guidelines",
|
|
1168
|
+
title: "Guidelines",
|
|
1169
|
+
children: [
|
|
1170
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
1171
|
+
clientOnly: true,
|
|
1172
|
+
do: {
|
|
1173
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1174
|
+
className: "date-picker-dodont",
|
|
1175
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
1176
|
+
label: "Delivery date",
|
|
1177
|
+
children: /* @__PURE__ */ jsx(DatePicker, {
|
|
1178
|
+
defaultValue: nextDeliveryDay(today, 3),
|
|
1179
|
+
format: WITH_WEEKDAY
|
|
1180
|
+
})
|
|
1181
|
+
})
|
|
1182
|
+
}),
|
|
1183
|
+
caption: "A date in the next few weeks, where seeing the days around it helps: deliveries, launches, deadlines."
|
|
1184
|
+
},
|
|
1185
|
+
dont: {
|
|
1186
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1187
|
+
className: "date-picker-dodont",
|
|
1188
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
1189
|
+
label: "Date of birth",
|
|
1190
|
+
children: /* @__PURE__ */ jsx(DatePicker, { defaultValue: new Date(1986, 4, 14) })
|
|
1191
|
+
})
|
|
1192
|
+
}),
|
|
1193
|
+
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."
|
|
1194
|
+
}
|
|
1195
|
+
}),
|
|
1196
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
1197
|
+
clientOnly: true,
|
|
1198
|
+
do: {
|
|
1199
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1200
|
+
className: "date-picker-dodont",
|
|
1201
|
+
children: /* @__PURE__ */ jsx(DateRangePicker, {
|
|
1202
|
+
"aria-label": "Report dates",
|
|
1203
|
+
presets: true,
|
|
1204
|
+
maxValue: today,
|
|
1205
|
+
defaultValue: dateRangePresets[1].range(today)
|
|
1206
|
+
})
|
|
1207
|
+
}),
|
|
1208
|
+
caption: "One range picker, with presets, for the dates of a report."
|
|
1209
|
+
},
|
|
1210
|
+
dont: {
|
|
1211
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1212
|
+
className: "date-picker-dodont date-picker-dodont--pair",
|
|
1213
|
+
children: [/* @__PURE__ */ jsx(DatePicker, {
|
|
1214
|
+
"aria-label": "From",
|
|
1215
|
+
defaultValue: addDays(today, -6),
|
|
1216
|
+
size: "sm"
|
|
1217
|
+
}), /* @__PURE__ */ jsx(DatePicker, {
|
|
1218
|
+
"aria-label": "To",
|
|
1219
|
+
defaultValue: today,
|
|
1220
|
+
size: "sm"
|
|
1221
|
+
})]
|
|
1222
|
+
}),
|
|
1223
|
+
caption: "Two separate pickers for one range: the ends can cross, and every common range takes four clicks."
|
|
1224
|
+
}
|
|
1225
|
+
}),
|
|
1226
|
+
/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1227
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1228
|
+
"Label the field with what the date is for (\"Delivery date\", \"Publish on\"), never just \"Date\". Mark an optional one with ",
|
|
1229
|
+
/* @__PURE__ */ jsx("code", { children: "optional" }),
|
|
1230
|
+
" on its Field and make it ",
|
|
1231
|
+
/* @__PURE__ */ jsx("code", { children: "clearable" }),
|
|
1232
|
+
"."
|
|
1233
|
+
] }),
|
|
1234
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1235
|
+
"Rule out what cannot be picked with ",
|
|
1236
|
+
/* @__PURE__ */ jsx("code", { children: "minValue" }),
|
|
1237
|
+
", ",
|
|
1238
|
+
/* @__PURE__ */ jsx("code", { children: "maxValue" }),
|
|
1239
|
+
" and ",
|
|
1240
|
+
/* @__PURE__ */ jsx("code", { children: "disabledDays" }),
|
|
1241
|
+
", then say why in the hint (\"We deliver Monday to Saturday\")."
|
|
1242
|
+
] }),
|
|
1243
|
+
"Add the weekday to the format when the day of the week matters to the decision, as it does for deliveries and bookings.",
|
|
1244
|
+
"Keep the 24-hour clock and day, month, year order: they are what UK merchants read without thinking.",
|
|
1245
|
+
"Use a SegmentedControl, not a picker, for a handful of fixed periods that change a view in place (Today, 7 days, 30 days)."
|
|
1246
|
+
] })
|
|
1247
|
+
]
|
|
1248
|
+
}),
|
|
1249
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1250
|
+
id: "accessibility",
|
|
1251
|
+
title: "Accessibility",
|
|
1252
|
+
children: [/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1253
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1254
|
+
"The field is a button with ",
|
|
1255
|
+
/* @__PURE__ */ jsx("code", { children: "aria-haspopup=\"dialog\"" }),
|
|
1256
|
+
" and ",
|
|
1257
|
+
/* @__PURE__ */ jsx("code", { children: "aria-expanded" }),
|
|
1258
|
+
", named by the Field's label and the date together (\"Delivery date, Fri, 9 Oct 2026\") through",
|
|
1259
|
+
" ",
|
|
1260
|
+
/* @__PURE__ */ jsx("code", { children: "aria-labelledby" }),
|
|
1261
|
+
", so the current value is always read. Without a Field, give it an",
|
|
1262
|
+
" ",
|
|
1263
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
1264
|
+
"."
|
|
1265
|
+
] }),
|
|
1266
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1267
|
+
"Hints and errors are linked with ",
|
|
1268
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
1269
|
+
", and an error sets ",
|
|
1270
|
+
/* @__PURE__ */ jsx("code", { children: "aria-invalid" }),
|
|
1271
|
+
"."
|
|
1272
|
+
] }),
|
|
1273
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1274
|
+
"The calendar opens in a dialog named after the field. It is a ",
|
|
1275
|
+
/* @__PURE__ */ jsx("code", { children: "grid" }),
|
|
1276
|
+
" 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."
|
|
1277
|
+
] }),
|
|
1278
|
+
"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.",
|
|
1279
|
+
"Unavailable days are disabled buttons: they cannot be focused or picked, and are skipped by the arrow keys.",
|
|
1280
|
+
"The time parts are spin buttons named Hours and Minutes, with their value and range.",
|
|
1281
|
+
"With reduced motion, the sheet fades in without growing, the chosen-day disc appears without settling, and months swap without sliding."
|
|
1282
|
+
] }), /* @__PURE__ */ jsxs(Note, {
|
|
1283
|
+
title: "Typing a date",
|
|
1284
|
+
children: [
|
|
1285
|
+
"A picker is a button that opens the calendar. Add ",
|
|
1286
|
+
/* @__PURE__ */ jsx("code", { children: "typed" }),
|
|
1287
|
+
" and the field is a text input with a calendar button after it, taking the locale's numeric short date (",
|
|
1288
|
+
/* @__PURE__ */ jsx("code", { children: "25/12/2026" }),
|
|
1289
|
+
") and ",
|
|
1290
|
+
/* @__PURE__ */ jsx("code", { children: "2026-12-25" }),
|
|
1291
|
+
", and saying what is wrong with text that is not a date or not one that can be picked. It is for a date alone: with a time the field stays a button. The hint while it is empty is the shape in the locale's order,",
|
|
1292
|
+
" ",
|
|
1293
|
+
/* @__PURE__ */ jsx("code", { children: "dd/mm/yyyy" }),
|
|
1294
|
+
", from the words ",
|
|
1295
|
+
/* @__PURE__ */ jsx("code", { children: "labels.dayHint" }),
|
|
1296
|
+
", ",
|
|
1297
|
+
/* @__PURE__ */ jsx("code", { children: "monthHint" }),
|
|
1298
|
+
" and",
|
|
1299
|
+
" ",
|
|
1300
|
+
/* @__PURE__ */ jsx("code", { children: "yearHint" }),
|
|
1301
|
+
". ",
|
|
1302
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
1303
|
+
to: "/components/date-input#typing",
|
|
1304
|
+
children: "DateInput"
|
|
1305
|
+
}),
|
|
1306
|
+
" is typed by default, and its page has the rules in full."
|
|
1307
|
+
]
|
|
1308
|
+
})]
|
|
1309
|
+
}),
|
|
1310
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1311
|
+
id: "props",
|
|
1312
|
+
title: "Props",
|
|
1313
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1314
|
+
"Both pickers forward every other button attribute, and the ",
|
|
1315
|
+
/* @__PURE__ */ jsx("code", { children: "ref" }),
|
|
1316
|
+
", to the field's button (to the text input of a ",
|
|
1317
|
+
/* @__PURE__ */ jsx("code", { children: "typed" }),
|
|
1318
|
+
" DatePicker).",
|
|
1319
|
+
" ",
|
|
1320
|
+
/* @__PURE__ */ jsx("code", { children: "className" }),
|
|
1321
|
+
" and ",
|
|
1322
|
+
/* @__PURE__ */ jsx("code", { children: "style" }),
|
|
1323
|
+
" go to the well around it (to the element round the well and the sentence under it, for a ",
|
|
1324
|
+
/* @__PURE__ */ jsx("code", { children: "typed" }),
|
|
1325
|
+
" one, so it is one item in a flex row or a grid)."
|
|
1326
|
+
] }),
|
|
1327
|
+
children: [
|
|
1328
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1329
|
+
title: "DatePicker",
|
|
1330
|
+
rows: [
|
|
1331
|
+
{
|
|
1332
|
+
name: "value",
|
|
1333
|
+
type: "Date | null",
|
|
1334
|
+
description: "Controlled value: a local date, with a time when granularity is minute."
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
name: "defaultValue",
|
|
1338
|
+
type: "Date | null",
|
|
1339
|
+
description: "Starting value when uncontrolled."
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
name: "onChange",
|
|
1343
|
+
type: "(value: Date | null) => void",
|
|
1344
|
+
description: "A day picked, a time changed or the field cleared. Never on mount."
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
name: "granularity",
|
|
1348
|
+
type: "'day' | 'minute'",
|
|
1349
|
+
default: "'day'",
|
|
1350
|
+
description: "Minute adds hours and minutes under the calendar."
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
name: "hourCycle",
|
|
1354
|
+
type: "12 | 24",
|
|
1355
|
+
default: "24",
|
|
1356
|
+
description: "The clock for the time and the field."
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
name: "size",
|
|
1360
|
+
type: "'sm' | 'md' | 'lg'",
|
|
1361
|
+
default: "'md'",
|
|
1362
|
+
description: "30, 36 or 44px: the same heights as Input and Button."
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
name: "placeholder",
|
|
1366
|
+
type: "string",
|
|
1367
|
+
default: "'Choose a date'",
|
|
1368
|
+
description: "Shown while there is no date ('Choose a date and time' with a time)."
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
name: "clearable",
|
|
1372
|
+
type: "boolean",
|
|
1373
|
+
default: "false",
|
|
1374
|
+
description: "A clear button, and Backspace or Delete, while there is a date."
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
name: "minValue",
|
|
1378
|
+
type: "Date | null",
|
|
1379
|
+
description: "The earliest day (and time, with a time) that can be picked."
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
name: "maxValue",
|
|
1383
|
+
type: "Date | null",
|
|
1384
|
+
description: "The latest day (and time) that can be picked."
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
name: "disabledDays",
|
|
1388
|
+
type: "CalendarMatcher | CalendarMatcher[]",
|
|
1389
|
+
description: "Days that cannot be picked: Sundays, bank holidays, sold-out days."
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
name: "format",
|
|
1393
|
+
type: "Intl.DateTimeFormatOptions",
|
|
1394
|
+
description: "How the field shows the date. Defaults to 2 Oct 2026, and 2 Oct 2026, 09:30 with a time."
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
name: "locale",
|
|
1398
|
+
type: "string",
|
|
1399
|
+
default: "'en-GB'",
|
|
1400
|
+
description: "Locale for the field, the month and day names, and the first day of the week."
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
name: "weekStartsOn",
|
|
1404
|
+
type: "0 to 6",
|
|
1405
|
+
description: "First column of the week, 0 for Sunday. Defaults to the locale's: Monday in en-GB."
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
name: "invalid",
|
|
1409
|
+
type: "boolean",
|
|
1410
|
+
description: "Red edge and aria-invalid. Inside a Field, follows the Field's error."
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
name: "readOnly",
|
|
1414
|
+
type: "boolean",
|
|
1415
|
+
description: "Shows the date in the well but will not open."
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
name: "disabled",
|
|
1419
|
+
type: "boolean",
|
|
1420
|
+
description: "Dims the field; Tab skips it."
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
name: "closeOnSelect",
|
|
1424
|
+
type: "boolean",
|
|
1425
|
+
default: "true",
|
|
1426
|
+
description: "Close when a day is picked. False by default with a time."
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
name: "typed",
|
|
1430
|
+
type: "boolean",
|
|
1431
|
+
default: "false",
|
|
1432
|
+
description: "A text input you can type the locale's numeric short date into (or YYYY-MM-DD), with a calendar button beside it. Text that is not a date, or not one that can be picked, makes it invalid and says why under it; the value is then null. A day only: a field with a time stays a button. format does not apply."
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
name: "captionLayout",
|
|
1436
|
+
type: "'auto' | 'label' | 'dropdown' | 'dropdown-months' | 'dropdown-years'",
|
|
1437
|
+
default: "'label'",
|
|
1438
|
+
description: "The calendar's caption: the month's name between the arrows (label, as it has always been), or a month and a year to choose from (dropdown). Auto decides from the days that can be picked: the selects when they span more than a year (no limits is more than a year), the label when they do not. DateInput defaults to auto."
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
name: "name",
|
|
1442
|
+
type: "string",
|
|
1443
|
+
description: "Submits YYYY-MM-DD (or YYYY-MM-DDTHH:mm) with a form."
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
name: "open, defaultOpen, onOpenChange",
|
|
1447
|
+
type: "boolean, boolean, (open) => void",
|
|
1448
|
+
description: "Control the calendar yourself."
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
name: "modal",
|
|
1452
|
+
type: "boolean",
|
|
1453
|
+
default: "true",
|
|
1454
|
+
description: "Keep focus and the pointer inside the calendar while it is open."
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
name: "align, side",
|
|
1458
|
+
type: "'start' | 'center' | 'end', 'bottom' | 'top' | …",
|
|
1459
|
+
default: "'start', 'bottom'",
|
|
1460
|
+
description: "Where the calendar opens. It flips when there is no room."
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
name: "container",
|
|
1464
|
+
type: "HTMLElement | null",
|
|
1465
|
+
default: "document.body",
|
|
1466
|
+
description: "Where the calendar is portalled. Inside a dialog it opens in the dialog's layer; null keeps it on the page."
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
name: "today",
|
|
1470
|
+
type: "Date",
|
|
1471
|
+
description: "The day treated as today. Defaults to now."
|
|
1472
|
+
},
|
|
1473
|
+
{
|
|
1474
|
+
name: "labels",
|
|
1475
|
+
type: "Partial<DatePickerLabels>",
|
|
1476
|
+
description: "Translations: clear, time, hours, minutes, dayPeriod, previousMonth, nextMonth, today and selected, which a label object has always held; and, all optional with an English default, monthDropdown and yearDropdown, and for a typed field chooseDate (the calendar button), invalidDate(example), dateTooEarly(limit), dateTooLate(limit), dateUnavailable, and dayHint, monthHint and yearHint (the letters of its hint: dd, mm, yyyy)."
|
|
1477
|
+
}
|
|
1478
|
+
]
|
|
1479
|
+
}),
|
|
1480
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1481
|
+
title: "DateRangePicker (where it differs)",
|
|
1482
|
+
rows: [
|
|
1483
|
+
{
|
|
1484
|
+
name: "value",
|
|
1485
|
+
type: "DateRange | null",
|
|
1486
|
+
description: "Controlled range: { from, to }, both local midnight and both included."
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
name: "defaultValue",
|
|
1490
|
+
type: "DateRange | null",
|
|
1491
|
+
description: "Starting range when uncontrolled."
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
name: "onChange",
|
|
1495
|
+
type: "(value: DateRange | null, preset?: string) => void",
|
|
1496
|
+
description: "Once a range is complete, a preset is picked (with its id), or the field is cleared."
|
|
1497
|
+
},
|
|
1498
|
+
{
|
|
1499
|
+
name: "presets",
|
|
1500
|
+
type: "boolean | DateRangePreset[]",
|
|
1501
|
+
default: "false (the kit's with trigger=\"button\")",
|
|
1502
|
+
description: "True for dateRangePresets (Today, Last 7 days, Last 30 days, This month, Last month), or your own list."
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
name: "trigger",
|
|
1506
|
+
type: "'field' | 'button'",
|
|
1507
|
+
default: "'field'",
|
|
1508
|
+
description: "The Input's well, or a pill that opens a menu of ranges, Custom range revealing the calendars with Cancel and Apply."
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
name: "numberOfMonths",
|
|
1512
|
+
type: "number",
|
|
1513
|
+
description: "Months side by side. Defaults to two from 768px wide, one below."
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
name: "placeholder",
|
|
1517
|
+
type: "string",
|
|
1518
|
+
default: "'Choose dates'",
|
|
1519
|
+
description: "Shown while there is no range."
|
|
1520
|
+
},
|
|
1521
|
+
{
|
|
1522
|
+
name: "labels",
|
|
1523
|
+
type: "Partial<DateRangePickerLabels>",
|
|
1524
|
+
description: "Translations: clear, to (between the dates), presets, the calendar labels, and the menu's custom, apply, cancel, chooseStart and chooseEnd."
|
|
1525
|
+
}
|
|
1526
|
+
]
|
|
1527
|
+
}),
|
|
1528
|
+
/* @__PURE__ */ jsxs("p", {
|
|
1529
|
+
className: "doc-section__description",
|
|
1530
|
+
children: [
|
|
1531
|
+
"DateRangePicker has no time and no ",
|
|
1532
|
+
/* @__PURE__ */ jsx("code", { children: "granularity" }),
|
|
1533
|
+
", ",
|
|
1534
|
+
/* @__PURE__ */ jsx("code", { children: "hourCycle" }),
|
|
1535
|
+
" or ",
|
|
1536
|
+
/* @__PURE__ */ jsx("code", { children: "name" }),
|
|
1537
|
+
"; the rest is the same as DatePicker."
|
|
1538
|
+
]
|
|
1539
|
+
}),
|
|
1540
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1541
|
+
title: "DateRangePreset",
|
|
1542
|
+
rows: [
|
|
1543
|
+
{
|
|
1544
|
+
name: "id",
|
|
1545
|
+
type: "string",
|
|
1546
|
+
required: true,
|
|
1547
|
+
description: "Passed to onChange when the preset is picked."
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
name: "label",
|
|
1551
|
+
type: "string",
|
|
1552
|
+
required: true,
|
|
1553
|
+
description: "Shown in the list, and in the field when the range matches."
|
|
1554
|
+
},
|
|
1555
|
+
{
|
|
1556
|
+
name: "range",
|
|
1557
|
+
type: "(today: Date) => DateRange",
|
|
1558
|
+
required: true,
|
|
1559
|
+
description: "The dates for a given today (local midnight)."
|
|
1560
|
+
}
|
|
1561
|
+
]
|
|
1562
|
+
})
|
|
1563
|
+
]
|
|
1564
|
+
})
|
|
1565
|
+
]
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
//#endregion
|
|
1569
|
+
export { Page, Preview };
|