@box-kite/react 2.2.5 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.claude/rules/box-kite-rules.md +3 -1
  2. package/.claude/skills/box-kite/SKILL.md +3 -1
  3. package/.claude/skills/box-kite/references/components.md +34 -0
  4. package/.cursor/rules/box-kite.mdc +3 -1
  5. package/AGENTS.md +3 -1
  6. package/BOX_AI_CONTEXT.md +95 -5
  7. package/BOX_KITE_AI_CONTEXT.md +95 -5
  8. package/box.cjs +1 -1
  9. package/box.mjs +7 -7
  10. package/catalog.cjs +1 -1
  11. package/catalog.mjs +521 -0
  12. package/client.cjs +1 -1
  13. package/client.mjs +94 -106
  14. package/components/calendar.cjs +1 -0
  15. package/components/calendar.d.ts +77 -0
  16. package/components/calendar.mjs +483 -0
  17. package/components/dataGrid/components/dataGridBooleanValue.d.ts +11 -0
  18. package/components/dataGrid/components/dataGridDateParts.d.ts +40 -0
  19. package/components/dataGrid/components/dataGridDateValue.d.ts +14 -0
  20. package/components/dataGrid/contracts/dataGridContract.d.ts +38 -11
  21. package/components/dataGrid/models/columnModel.d.ts +3 -1
  22. package/components/dataGrid/models/editModel.d.ts +3 -1
  23. package/components/dataGrid/models/localeText.d.ts +4 -0
  24. package/components/dataGrid/useDateParts.d.ts +17 -0
  25. package/components/dataGrid.cjs +3 -3
  26. package/components/dataGrid.mjs +797 -664
  27. package/components/dateField.cjs +1 -0
  28. package/components/dateField.d.ts +78 -0
  29. package/components/dateField.mjs +313 -0
  30. package/components/datePicker.cjs +1 -0
  31. package/components/datePicker.d.ts +120 -0
  32. package/components/datePicker.mjs +529 -0
  33. package/components/dateTime.cjs +1 -0
  34. package/components/dateTime.d.ts +23 -0
  35. package/components/dateTime.mjs +34 -0
  36. package/components/dialog.cjs +1 -1
  37. package/components/dialog.mjs +87 -75
  38. package/components/overlay.cjs +1 -1
  39. package/components/overlay.mjs +1 -1
  40. package/components/semantics.d.ts +29 -29
  41. package/components/timeZoneSelect.cjs +1 -0
  42. package/components/timeZoneSelect.d.ts +52 -0
  43. package/components/timeZoneSelect.mjs +74 -0
  44. package/components/toaster.cjs +1 -1
  45. package/components/toaster.mjs +1 -1
  46. package/dataGridDateParts.cjs +1 -0
  47. package/dataGridDateParts.mjs +223 -0
  48. package/dataGridList.cjs +1 -1
  49. package/dataGridList.mjs +328 -365
  50. package/dataGridListLayout.cjs +1 -0
  51. package/dataGridListLayout.mjs +49 -0
  52. package/date-environment.cjs +1 -0
  53. package/date-environment.mjs +29 -0
  54. package/date-input.cjs +1 -0
  55. package/date-input.mjs +346 -0
  56. package/date-math.cjs +1 -0
  57. package/date-math.mjs +317 -0
  58. package/date.cjs +1 -0
  59. package/date.d.ts +40 -0
  60. package/date.mjs +4 -0
  61. package/dates.cjs +1 -0
  62. package/dates.mjs +689 -0
  63. package/docs/components.md +6 -1
  64. package/package.json +118 -26
  65. package/react/boxComponent.d.ts +1 -1
  66. package/react/date/dateChange.d.ts +18 -0
  67. package/react/date/dateEnvironment.d.ts +34 -0
  68. package/react-shared.cjs +1 -1
  69. package/react-shared.mjs +1 -1
  70. package/ssg.cjs +1 -1
  71. package/ssg.mjs +1 -1
  72. package/utils/date/calendar.d.ts +44 -0
  73. package/utils/date/calendarModel.d.ts +46 -0
  74. package/utils/date/dateTime.d.ts +144 -0
  75. package/utils/date/fieldModel.d.ts +74 -0
  76. package/utils/date/format.d.ts +39 -0
  77. package/utils/date/iso.d.ts +40 -0
  78. package/utils/date/locale.d.ts +17 -0
  79. package/utils/date/parse.d.ts +20 -0
  80. package/utils/date/settings.d.ts +26 -0
  81. package/utils/date/value.d.ts +43 -0
  82. package/utils/date/zoneOptions.d.ts +19 -0
  83. package/utils/date/zones.d.ts +32 -0
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../identity.cjs"),a=require("../dates.cjs"),o=require("../date-math.cjs"),s=require("../date-input.cjs"),c=require("../date-environment.cjs");let l=require("react"),u=require("react/jsx-runtime");var d=`data-segment`;function f(e,f){let{type:p=`date`,value:ee,defaultValue:m=null,onValueChange:te,zone:h,locale:ne,hourCycle:re,granularity:g=`minute`,min:_,max:v,isDateUnavailable:y,disabled:b=!1,readOnly:x=!1,required:S=!1,invalid:ie,name:C,label:w,labelledBy:ae,describedBy:T,placeholderValue:oe,disambiguation:E,showZone:se,end:ce,autoFocus:le,emptyText:ue=`Empty`,tabIndex:de=0,props:fe,...D}=e,O=c.n({locale:ne,zone:h===`none`?void 0:h}),{locale:k}=O,A=p===`datetime`&&h!==`none`?O.zone:null,j=re??a.b(k),M=(0,l.useMemo)(()=>({type:p,locale:k,hourCycle:j,granularity:g}),[p,k,j,g]),N=(0,l.useMemo)(()=>s.o(M),[M]),P=`${p}|${k}|${j}|${g}|${A}`,[F,pe]=r.i({value:ee,defaultValue:m,onChange:(e,t)=>te?.(e,{...t,...o.x(e,A??O.zone)})}),[I,L]=(0,l.useState)(()=>({draft:s.n(F,M,A),source:F,key:P})),R=I.draft;if(I.source!==F||I.key!==P){let e=s.f(I.draft,N,M,{zone:A,disambiguation:E}),t={draft:I.key===P&&e===F?I.draft:s.n(F,M,A),source:F,key:P};L(t),R=t.draft}let[z,B]=(0,l.useState)(null),V=(0,l.useRef)(null),H=(0,l.useRef)(null),U=i.t(`date-field`),me=w===void 0?void 0:`${U}-label`,W=(0,l.useMemo)(()=>s.n(oe??`${o.N(O.zone)}T00:00:00`,{...M,type:M.type===`date`?`date`:`datetime`},null),[oe,O.zone,M]),G=(e,t,n)=>{let r=s.f(e,N,M,{zone:A,disambiguation:E});L({draft:e,source:r,key:P}),pe(r,{reason:t,event:n})},K=r.o({draft:R,editing:z,commit:G}),q=()=>Array.from(V.current?.querySelectorAll(`[${d}]`)??[]),J=e=>{let t=q();t[Math.max(0,Math.min(e,t.length-1))]?.focus()},Y=e=>q().indexOf(e),X=(e,t,n,r)=>{let{draft:i,editing:a}=K.current,o=a?.type===t?a.buffer:``;if(t===`dayPeriod`){let t=s.d(i,n,k);t&&(K.current.commit(t,`keyboard`,r),J(Y(e)+1));return}if(!/^\d$/.test(n)){/^[^\p{L}\p{N}]$/u.test(n)&&i[t]!==void 0&&J(Y(e)+1);return}let c=s.u(i,t,o,n,M);B({type:t,buffer:c.advance?``:c.buffer}),K.current.commit(c.draft,`keyboard`,r),c.advance&&J(Y(e)+1)},he=r.a(e=>{let n=e.target.closest(`[${d}]`);if(!n||b||e.defaultPrevented)return;let r=n.getAttribute(d),i=Y(n),a=t.d(n),{key:o}=e,c=K.current.draft,l=t=>{e.preventDefault(),!x&&(B({type:r,buffer:``}),G(t,`keyboard`,e))};if(o===`ArrowUp`||o===`ArrowDown`)return l(s.c(c,r,o===`ArrowUp`?1:-1,M,W));if(o===`PageUp`||o===`PageDown`)return l(s.c(c,r,(o===`PageUp`?1:-1)*s.t[r],M,W));if(o===`Home`||o===`End`){let e=s.i(r,c,M);return l({...c,[r]:o===`Home`?e.min:e.max})}if(o===`ArrowLeft`||o===`ArrowRight`){e.preventDefault(),J(i+(o===`ArrowRight`===a?-1:1));return}if(o===`Backspace`||o===`Delete`){if(e.preventDefault(),x)return;let t=K.current.editing?.type===r?K.current.editing.buffer:``;if(t.length>1){let n=t.slice(0,-1);B({type:r,buffer:n}),G({...c,[r]:Number(n)},`keyboard`,e)}else c[r]===void 0?o===`Backspace`&&J(i-1):(B({type:r,buffer:``}),G({...c,[r]:void 0},`keyboard`,e));return}if(o===`Enter`){e.preventDefault(),H.current?.form?.requestSubmit();return}o===`Unidentified`||o===`Process`||e.ctrlKey||e.metaKey||e.altKey||o.length!==1||(e.preventDefault(),x||X(n,r,o,e))});(0,l.useEffect)(()=>{let e=V.current;if(!e)return;let t=e=>{let t=e.target?.closest(`[${d}]`);if(!t||(e.preventDefault(),b||x))return;let n=t.getAttribute(d);if(e.inputType.startsWith(`delete`)){t.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Backspace`,bubbles:!0,cancelable:!0}));return}for(let r of e.data??``)X(t,n,r,e)};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)});let ge=r.a(e=>{if(e.preventDefault(),b||x)return;let t=p===`datetime`?A?`instant`:`datetime`:p,n=s.m(e.clipboardData.getData(`text`),{locale:k,kind:t,zone:A??O.zone});n&&G(s.n(n,M,A),`paste`,e)});(0,l.useEffect)(()=>{let e=H.current?.form;if(!e)return;let t=e=>K.current.commit(s.n(m,M,A),`reset`,e);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}),(0,l.useEffect)(()=>{le&&J(0)},[]);let _e=F!==null&&(_!=null&&o.i(F,_)<0||v!=null&&o.i(F,v)>0),Z=F!==null&&p!==`time`&&y?o.O(F,{zone:A??O.zone}):null,Q=ie??(_e||Z!==null&&y(Z)),ve=p===`time`?[]:a.x(k),ye=typeof w==`string`?w:void 0,be=s.r(N)[0],$=p===`datetime`&&A&&(se??A!==O.readerZone)?a.s(A,{locale:k,style:`short`,at:F??void 0}):null;return(0,u.jsxs)(u.Fragment,{children:[w!==void 0&&(0,u.jsx)(n.default,{component:`dateField.label`,display:`block`,mb:1.5,fontSize:14,id:me,props:{onClick:()=>J(0)},children:w}),(0,u.jsxs)(n.default,{ref:e=>{V.current=e,typeof f==`function`?f(e):f&&(f.current=e)},component:`dateField`,display:`inline-flex`,ai:`center`,position:`relative`,cursor:`text`,css:{fontVariantNumeric:`tabular-nums`,unicodeBidi:`isolate`},...D,variant:[D.variant,{disabled:b,invalid:Q}],id:U,props:{role:`group`,"aria-labelledby":[me,ae].filter(Boolean).join(` `)||void 0,"aria-describedby":T,"aria-disabled":b||void 0,"aria-invalid":Q||void 0,...fe,onKeyDown:he,onPaste:ge,onPointerDown:e=>{if(e.target!==e.currentTarget||b)return;e.preventDefault();let t=s.r(N).findIndex(e=>K.current.draft[e]===void 0);J(t===-1?0:t)}},children:[N.map((e,t)=>{if(e.type===`literal`)return(0,u.jsx)(n.default,{component:`dateField.literal`,whiteSpace:`pre`,props:{"aria-hidden":!0},children:e.text},t);let r=e.type,i=s.i(r,R,M),o=R[r],c=o===void 0,l=z?.type===r?z.buffer:``,f=s.a(r,R,l,k),p=c?ue:r===`month`?`${o} – ${ve[o-1]}`:r===`dayPeriod`?f:String(o);return(0,u.jsx)(n.default,{component:`dateField.segment`,display:`inline-block`,px:.5,borderRadius:1,textAlign:`end`,whiteSpace:`nowrap`,variant:{placeholder:c,disabled:b},id:`${U}-${r}`,props:{[d]:r,role:`spinbutton`,tabIndex:b?-1:de,contentEditable:!b&&!x,suppressContentEditableWarning:!0,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,inputMode:r===`dayPeriod`?`text`:`numeric`,enterKeyHint:`next`,"aria-label":ye?`${a.y(r,k)}, ${ye}`:a.y(r,k),"aria-valuemin":i.min,"aria-valuemax":i.max,"aria-valuenow":o??W[r]??i.min,"aria-valuetext":p,"aria-readonly":x||void 0,"aria-disabled":b||void 0,"aria-invalid":Q||void 0,"aria-describedby":r===be?T:void 0,onFocus:()=>B({type:r,buffer:``}),onBlur:()=>B(null)},children:f},t)}),$&&(0,u.jsx)(n.default,{component:`dateField.zone`,ms:2,fontSize:13,whiteSpace:`nowrap`,children:$}),ce,C!==void 0||S?(0,u.jsx)(l.Fragment,{children:S?(0,u.jsx)(n.default,{tag:`input`,ref:H,component:`dateField.validation`,required:!0,disabled:b,props:{type:`text`,name:C,value:F??``,tabIndex:-1,"aria-hidden":!0,onChange:()=>{},onFocus:()=>J(0)}}):(0,u.jsx)(`input`,{ref:H,type:`hidden`,name:C,value:F??``,disabled:b})}):null]})]})}var p=e.f(f,`DateField`);exports.default=p;
@@ -0,0 +1,78 @@
1
+ import { RefAttributes } from 'react';
2
+ import { BoxProps } from '../box';
3
+ import { ChangeHandler } from '../react/a11y/useControllableState';
4
+ import { DateChangeDetails, DateChangeReason } from '../react/date/dateChange';
5
+ import { ComponentsAndVariants } from '@box-kite/core/types';
6
+ import { FieldGranularity, FieldType } from '../utils/date/fieldModel';
7
+ import { Disambiguation, ZoneInput } from '../utils/date/zones';
8
+ export type { DateChangeDetails, DateChangeHandler, DateChangeReason } from '../react/date/dateChange';
9
+ export type DateFieldType = FieldType;
10
+ export type DateFieldGranularity = FieldGranularity;
11
+ type DateFieldBoxProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'div', TKey>, 'onChange' | 'disabled' | 'required' | 'invalid' | 'placeholder' | 'defaultValue' | 'readOnly'>;
12
+ export interface DateFieldProps<TKey extends keyof ComponentsAndVariants = 'dateField'> extends DateFieldBoxProps<TKey> {
13
+ /** What it edits: a day (`'date'`, default), a time of day (`'time'`), or both (`'datetime'`). */
14
+ type?: DateFieldType;
15
+ /**
16
+ * Controlled value, an ISO string of the field's kind: `2026-10-19`, `14:30:00`, or for a date-time an
17
+ * instant with its offset (`2026-10-19T14:30:00+03:00`), `…Z` in UTC, or a wall clock with `zone="none"`.
18
+ * `null` is empty. Any spelling `parse` reads is accepted; what comes back is canonical.
19
+ */
20
+ value?: string | null;
21
+ /** The value it starts with when the field owns its state. */
22
+ defaultValue?: string | null;
23
+ /**
24
+ * Fires with the new value — `null` while a segment is empty — and its readings: `utc`, the reader's
25
+ * `local` wall clock, a `Date`, the epoch, and why it changed.
26
+ */
27
+ onValueChange?: ChangeHandler<string | null, DateChangeReason, DateChangeDetails>;
28
+ /**
29
+ * Whose wall clock a date-time is typed on. Default `'local'`, the reader's; `'utc'`, any IANA zone or
30
+ * `+03:00` for another; `'none'` for a wall clock with no zone at all (an alarm, a timetable). A date and a
31
+ * time have no zone, so this only says what "today" is for them.
32
+ */
33
+ zone?: ZoneInput | 'none';
34
+ /** The language the segments are ordered and named in. Default the reader's. */
35
+ locale?: string;
36
+ /** A 12- or 24-hour clock. Default the locale's. */
37
+ hourCycle?: 12 | 24;
38
+ /** Whether a time is edited to the minute (default) or the second. */
39
+ granularity?: DateFieldGranularity;
40
+ /** The earliest value that is valid. A value before it is kept and marked `aria-invalid`. */
41
+ min?: string | null;
42
+ /** The latest value that is valid. */
43
+ max?: string | null;
44
+ /** Days nobody can choose — a weekend, a holiday. Handed the `YYYY-MM-DD` day. */
45
+ isDateUnavailable?: (date: string) => boolean;
46
+ /** Not editable and not focusable, and read out as such. */
47
+ disabled?: boolean;
48
+ /** Focusable and read out, but not editable. */
49
+ readOnly?: boolean;
50
+ /** The form is not valid until it is filled in — the browser's own check, announced and translated for free. */
51
+ required?: boolean;
52
+ /** Marks the value invalid whatever the bounds say. Default: invalid when out of bounds or unavailable. */
53
+ invalid?: boolean;
54
+ /** What the value posts under in a form: the canonical string, or nothing while empty. */
55
+ name?: string;
56
+ /** The field's visible name, rendered above it. A group of segments is not named by its contents. */
57
+ label?: React.ReactNode;
58
+ /** Names the field after an element already on the page, instead of `label`. */
59
+ labelledBy?: string;
60
+ /** An element that describes the field — a hint, an error. */
61
+ describedBy?: string;
62
+ /** What an empty segment starts from on an arrow key. Default today, at midnight. */
63
+ placeholderValue?: string;
64
+ /** What a wall-clock time a zone skips or repeats means. Default `'compatible'`. */
65
+ disambiguation?: Disambiguation;
66
+ /** Whether a date-time names its zone after the time. Default: when the zone is not the reader's own. */
67
+ showZone?: boolean;
68
+ /** Something inside the field, after the segments — a picker's button. */
69
+ end?: React.ReactNode;
70
+ /** Focus the first segment on mount. */
71
+ autoFocus?: boolean;
72
+ /** What an empty segment is read out as. Default `'Empty'`. */
73
+ emptyText?: string;
74
+ /** Every segment's tab index. Default `0`; `-1` keeps the field out of the page's tab order, which a grid cell wants. */
75
+ tabIndex?: number;
76
+ }
77
+ declare const _default: <TKey extends keyof ComponentsAndVariants = "dateField">(props: DateFieldProps<TKey> & RefAttributes<HTMLDivElement>) => React.ReactNode;
78
+ export default _default;
@@ -0,0 +1,313 @@
1
+ "use client";
2
+ import { f as e } from "../react-shared.mjs";
3
+ import { d as t } from "../platform.mjs";
4
+ import n from "../box.mjs";
5
+ import { a as r, i, o as a } from "../behavior.mjs";
6
+ import { t as o } from "../identity.mjs";
7
+ import { b as s, s as c, x as ee, y as te } from "../dates.mjs";
8
+ import { N as ne, O as re, i as ie, x as ae } from "../date-math.mjs";
9
+ import { a as oe, c as l, d as se, f as u, i as d, m as ce, n as f, o as le, r as ue, t as de, u as fe } from "../date-input.mjs";
10
+ import { n as pe } from "../date-environment.mjs";
11
+ import { Fragment as me, useEffect as p, useMemo as m, useRef as he, useState as ge } from "react";
12
+ import { Fragment as _e, jsx as h, jsxs as ve } from "react/jsx-runtime";
13
+ //#region src/components/dateField.tsx
14
+ var g = "data-segment";
15
+ function _(e, _) {
16
+ let { type: v = "date", value: ye, defaultValue: be = null, onValueChange: xe, zone: y, locale: Se, hourCycle: Ce, granularity: b = "minute", min: x, max: S, isDateUnavailable: C, disabled: w = !1, readOnly: T = !1, required: E = !1, invalid: we, name: D, label: O, labelledBy: Te, describedBy: k, placeholderValue: A, disambiguation: j, showZone: Ee, end: De, autoFocus: Oe, emptyText: ke = "Empty", tabIndex: Ae = 0, props: je, ...M } = e, N = pe({
17
+ locale: Se,
18
+ zone: y === "none" ? void 0 : y
19
+ }), { locale: P } = N, F = v === "datetime" && y !== "none" ? N.zone : null, I = Ce ?? s(P), L = m(() => ({
20
+ type: v,
21
+ locale: P,
22
+ hourCycle: I,
23
+ granularity: b
24
+ }), [
25
+ v,
26
+ P,
27
+ I,
28
+ b
29
+ ]), R = m(() => le(L), [L]), z = `${v}|${P}|${I}|${b}|${F}`, [B, Me] = i({
30
+ value: ye,
31
+ defaultValue: be,
32
+ onChange: (e, t) => xe?.(e, {
33
+ ...t,
34
+ ...ae(e, F ?? N.zone)
35
+ })
36
+ }), [V, Ne] = ge(() => ({
37
+ draft: f(B, L, F),
38
+ source: B,
39
+ key: z
40
+ })), H = V.draft;
41
+ if (V.source !== B || V.key !== z) {
42
+ let e = u(V.draft, R, L, {
43
+ zone: F,
44
+ disambiguation: j
45
+ }), t = {
46
+ draft: V.key === z && e === B ? V.draft : f(B, L, F),
47
+ source: B,
48
+ key: z
49
+ };
50
+ Ne(t), H = t.draft;
51
+ }
52
+ let [U, W] = ge(null), G = he(null), K = he(null), q = o("date-field"), Pe = O === void 0 ? void 0 : `${q}-label`, J = m(() => f(A ?? `${ne(N.zone)}T00:00:00`, {
53
+ ...L,
54
+ type: L.type === "date" ? "date" : "datetime"
55
+ }, null), [
56
+ A,
57
+ N.zone,
58
+ L
59
+ ]), Y = (e, t, n) => {
60
+ let r = u(e, R, L, {
61
+ zone: F,
62
+ disambiguation: j
63
+ });
64
+ Ne({
65
+ draft: e,
66
+ source: r,
67
+ key: z
68
+ }), Me(r, {
69
+ reason: t,
70
+ event: n
71
+ });
72
+ }, X = a({
73
+ draft: H,
74
+ editing: U,
75
+ commit: Y
76
+ }), Fe = () => Array.from(G.current?.querySelectorAll(`[${g}]`) ?? []), Z = (e) => {
77
+ let t = Fe();
78
+ t[Math.max(0, Math.min(e, t.length - 1))]?.focus();
79
+ }, Q = (e) => Fe().indexOf(e), Ie = (e, t, n, r) => {
80
+ let { draft: i, editing: a } = X.current, o = a?.type === t ? a.buffer : "";
81
+ if (t === "dayPeriod") {
82
+ let t = se(i, n, P);
83
+ t && (X.current.commit(t, "keyboard", r), Z(Q(e) + 1));
84
+ return;
85
+ }
86
+ if (!/^\d$/.test(n)) {
87
+ /^[^\p{L}\p{N}]$/u.test(n) && i[t] !== void 0 && Z(Q(e) + 1);
88
+ return;
89
+ }
90
+ let s = fe(i, t, o, n, L);
91
+ W({
92
+ type: t,
93
+ buffer: s.advance ? "" : s.buffer
94
+ }), X.current.commit(s.draft, "keyboard", r), s.advance && Z(Q(e) + 1);
95
+ }, Le = r((e) => {
96
+ let n = e.target.closest(`[${g}]`);
97
+ if (!n || w || e.defaultPrevented) return;
98
+ let r = n.getAttribute(g), i = Q(n), a = t(n), { key: o } = e, s = X.current.draft, c = (t) => {
99
+ e.preventDefault(), !T && (W({
100
+ type: r,
101
+ buffer: ""
102
+ }), Y(t, "keyboard", e));
103
+ };
104
+ if (o === "ArrowUp" || o === "ArrowDown") return c(l(s, r, o === "ArrowUp" ? 1 : -1, L, J));
105
+ if (o === "PageUp" || o === "PageDown") return c(l(s, r, (o === "PageUp" ? 1 : -1) * de[r], L, J));
106
+ if (o === "Home" || o === "End") {
107
+ let e = d(r, s, L);
108
+ return c({
109
+ ...s,
110
+ [r]: o === "Home" ? e.min : e.max
111
+ });
112
+ }
113
+ if (o === "ArrowLeft" || o === "ArrowRight") {
114
+ e.preventDefault(), Z(i + (o === "ArrowRight" === a ? -1 : 1));
115
+ return;
116
+ }
117
+ if (o === "Backspace" || o === "Delete") {
118
+ if (e.preventDefault(), T) return;
119
+ let t = X.current.editing?.type === r ? X.current.editing.buffer : "";
120
+ if (t.length > 1) {
121
+ let n = t.slice(0, -1);
122
+ W({
123
+ type: r,
124
+ buffer: n
125
+ }), Y({
126
+ ...s,
127
+ [r]: Number(n)
128
+ }, "keyboard", e);
129
+ } else s[r] === void 0 ? o === "Backspace" && Z(i - 1) : (W({
130
+ type: r,
131
+ buffer: ""
132
+ }), Y({
133
+ ...s,
134
+ [r]: void 0
135
+ }, "keyboard", e));
136
+ return;
137
+ }
138
+ if (o === "Enter") {
139
+ e.preventDefault(), K.current?.form?.requestSubmit();
140
+ return;
141
+ }
142
+ o === "Unidentified" || o === "Process" || e.ctrlKey || e.metaKey || e.altKey || o.length !== 1 || (e.preventDefault(), T || Ie(n, r, o, e));
143
+ });
144
+ p(() => {
145
+ let e = G.current;
146
+ if (!e) return;
147
+ let t = (e) => {
148
+ let t = e.target?.closest(`[${g}]`);
149
+ if (!t || (e.preventDefault(), w || T)) return;
150
+ let n = t.getAttribute(g);
151
+ if (e.inputType.startsWith("delete")) {
152
+ t.dispatchEvent(new KeyboardEvent("keydown", {
153
+ key: "Backspace",
154
+ bubbles: !0,
155
+ cancelable: !0
156
+ }));
157
+ return;
158
+ }
159
+ for (let r of e.data ?? "") Ie(t, n, r, e);
160
+ };
161
+ return e.addEventListener("beforeinput", t), () => e.removeEventListener("beforeinput", t);
162
+ });
163
+ let Re = r((e) => {
164
+ if (e.preventDefault(), w || T) return;
165
+ let t = v === "datetime" ? F ? "instant" : "datetime" : v, n = ce(e.clipboardData.getData("text"), {
166
+ locale: P,
167
+ kind: t,
168
+ zone: F ?? N.zone
169
+ });
170
+ n && Y(f(n, L, F), "paste", e);
171
+ });
172
+ p(() => {
173
+ let e = K.current?.form;
174
+ if (!e) return;
175
+ let t = (e) => X.current.commit(f(be, L, F), "reset", e);
176
+ return e.addEventListener("reset", t), () => e.removeEventListener("reset", t);
177
+ }), p(() => {
178
+ Oe && Z(0);
179
+ }, []);
180
+ let ze = B !== null && (x != null && ie(B, x) < 0 || S != null && ie(B, S) > 0), Be = B !== null && v !== "time" && C ? re(B, { zone: F ?? N.zone }) : null, $ = we ?? (ze || Be !== null && C(Be)), Ve = v === "time" ? [] : ee(P), He = typeof O == "string" ? O : void 0, Ue = ue(R)[0], We = v === "datetime" && F && (Ee ?? F !== N.readerZone) ? c(F, {
181
+ locale: P,
182
+ style: "short",
183
+ at: B ?? void 0
184
+ }) : null;
185
+ return /* @__PURE__ */ ve(_e, { children: [O !== void 0 && /* @__PURE__ */ h(n, {
186
+ component: "dateField.label",
187
+ display: "block",
188
+ mb: 1.5,
189
+ fontSize: 14,
190
+ id: Pe,
191
+ props: { onClick: () => Z(0) },
192
+ children: O
193
+ }), /* @__PURE__ */ ve(n, {
194
+ ref: (e) => {
195
+ G.current = e, typeof _ == "function" ? _(e) : _ && (_.current = e);
196
+ },
197
+ component: "dateField",
198
+ display: "inline-flex",
199
+ ai: "center",
200
+ position: "relative",
201
+ cursor: "text",
202
+ css: {
203
+ fontVariantNumeric: "tabular-nums",
204
+ unicodeBidi: "isolate"
205
+ },
206
+ ...M,
207
+ variant: [M.variant, {
208
+ disabled: w,
209
+ invalid: $
210
+ }],
211
+ id: q,
212
+ props: {
213
+ role: "group",
214
+ "aria-labelledby": [Pe, Te].filter(Boolean).join(" ") || void 0,
215
+ "aria-describedby": k,
216
+ "aria-disabled": w || void 0,
217
+ "aria-invalid": $ || void 0,
218
+ ...je,
219
+ onKeyDown: Le,
220
+ onPaste: Re,
221
+ onPointerDown: (e) => {
222
+ if (e.target !== e.currentTarget || w) return;
223
+ e.preventDefault();
224
+ let t = ue(R).findIndex((e) => X.current.draft[e] === void 0);
225
+ Z(t === -1 ? 0 : t);
226
+ }
227
+ },
228
+ children: [
229
+ R.map((e, t) => {
230
+ if (e.type === "literal") return /* @__PURE__ */ h(n, {
231
+ component: "dateField.literal",
232
+ whiteSpace: "pre",
233
+ props: { "aria-hidden": !0 },
234
+ children: e.text
235
+ }, t);
236
+ let r = e.type, i = d(r, H, L), a = H[r], o = a === void 0, s = U?.type === r ? U.buffer : "", c = oe(r, H, s, P), ee = o ? ke : r === "month" ? `${a} – ${Ve[a - 1]}` : r === "dayPeriod" ? c : String(a);
237
+ return /* @__PURE__ */ h(n, {
238
+ component: "dateField.segment",
239
+ display: "inline-block",
240
+ px: .5,
241
+ borderRadius: 1,
242
+ textAlign: "end",
243
+ whiteSpace: "nowrap",
244
+ variant: {
245
+ placeholder: o,
246
+ disabled: w
247
+ },
248
+ id: `${q}-${r}`,
249
+ props: {
250
+ [g]: r,
251
+ role: "spinbutton",
252
+ tabIndex: w ? -1 : Ae,
253
+ contentEditable: !w && !T,
254
+ suppressContentEditableWarning: !0,
255
+ spellCheck: !1,
256
+ autoCorrect: "off",
257
+ autoCapitalize: "off",
258
+ inputMode: r === "dayPeriod" ? "text" : "numeric",
259
+ enterKeyHint: "next",
260
+ "aria-label": He ? `${te(r, P)}, ${He}` : te(r, P),
261
+ "aria-valuemin": i.min,
262
+ "aria-valuemax": i.max,
263
+ "aria-valuenow": a ?? J[r] ?? i.min,
264
+ "aria-valuetext": ee,
265
+ "aria-readonly": T || void 0,
266
+ "aria-disabled": w || void 0,
267
+ "aria-invalid": $ || void 0,
268
+ "aria-describedby": r === Ue ? k : void 0,
269
+ onFocus: () => W({
270
+ type: r,
271
+ buffer: ""
272
+ }),
273
+ onBlur: () => W(null)
274
+ },
275
+ children: c
276
+ }, t);
277
+ }),
278
+ We && /* @__PURE__ */ h(n, {
279
+ component: "dateField.zone",
280
+ ms: 2,
281
+ fontSize: 13,
282
+ whiteSpace: "nowrap",
283
+ children: We
284
+ }),
285
+ De,
286
+ D !== void 0 || E ? /* @__PURE__ */ h(me, { children: E ? /* @__PURE__ */ h(n, {
287
+ tag: "input",
288
+ ref: K,
289
+ component: "dateField.validation",
290
+ required: !0,
291
+ disabled: w,
292
+ props: {
293
+ type: "text",
294
+ name: D,
295
+ value: B ?? "",
296
+ tabIndex: -1,
297
+ "aria-hidden": !0,
298
+ onChange: () => {},
299
+ onFocus: () => Z(0)
300
+ }
301
+ }) : /* @__PURE__ */ h("input", {
302
+ ref: K,
303
+ type: "hidden",
304
+ name: D,
305
+ value: B ?? "",
306
+ disabled: w
307
+ }) }) : null
308
+ ]
309
+ })] });
310
+ }
311
+ var v = e(_, "DateField");
312
+ //#endregion
313
+ export { v as default };
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../box.cjs"),n=require("../behavior.cjs"),r=require("../placement.cjs"),i=require("../dates.cjs"),a=require("../date-math.cjs"),o=require("../date-input.cjs"),s=require("./svg.cjs"),c=require("../date-environment.cjs"),l=require("./calendar.cjs"),u=require("../layer.cjs"),d=require("./overlay.cjs"),f=require("./dateField.cjs");let p=require("react"),m=require("react/jsx-runtime");function h(){return(0,m.jsx)(s.Svg,{viewBox:`0 0 16 16`,width:`1rem`,height:`1rem`,props:{fill:`none`},children:(0,m.jsx)(s.Path,{d:`M3 3.5h10a1 1 0 0 1 1 1V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5a1 1 0 0 1 1-1ZM2 7h12M5.5 2v3M10.5 2v3`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`})})}function g(){return(0,m.jsx)(s.Svg,{viewBox:`0 0 16 16`,width:`1rem`,height:`1rem`,props:{fill:`none`},children:(0,m.jsx)(s.Path,{d:`M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12ZM8 5v3l2 1.5`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`})})}function _(){return(0,m.jsx)(s.Svg,{viewBox:`0 0 16 16`,width:`0.875rem`,height:`0.875rem`,props:{fill:`none`},children:(0,m.jsx)(s.Path,{d:`m4.5 4.5 7 7m0-7-7 7`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`})})}function v(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function y(e){let[i,a]=(0,p.useState)(null),o=e.ref,s=(0,p.useCallback)(e=>{a(e),v(o,e)},[o]),c=e=>{if(!e||e.contains(document.activeElement)&&document.activeElement!==e)return;let t=[`[data-date][tabindex="0"]`,`[role="option"][tabindex="0"]`,`button:not([disabled])`].map(t=>e.querySelector(t)).find(Boolean),n=e.querySelector(`[role="listbox"]`),r=n?.querySelector(`[role="option"][tabindex="0"]`);n&&r&&(n.scrollTop=r.offsetTop-n.clientHeight/2+r.offsetHeight/2),(t??e).focus({preventScroll:!0})},l=n.a(e=>c(e)),{platform:f,isOpen:h,id:g,setPanel:_,setOpen:y,trigger:b,triggerElement:x,panelElement:S}=u.t({haspopup:`dialog`,idPrefix:`date-picker`,open:e.open,defaultOpen:e.defaultOpen,onOpenChange:e.onOpenChange,onOpened:l,onClosing:(e,t)=>{e&&t?.focus()}}),C=r.t({side:e.side,align:e.align,offset:1,flip:!0,anchor:i});return(0,p.useEffect)(()=>{h&&c(S)},[h,S]),{attachTrigger:b.ref,triggerAttributes:b.props,closeOnChoice:e=>{x?.focus(),y(!1,{reason:`select`,event:e})},id:g,attachField:s,panel:n=>{let r={role:`dialog`,"aria-label":e.label,tabIndex:-1};return f?(0,m.jsx)(t.default,{ref:_,component:`popover`,variant:{topLayer:!0},p:3,...C.layerProps,id:g,props:{popover:`auto`,...r},children:h?n:null}):h&&(0,m.jsx)(d.default,{contentRef:_,anchor:i,side:e.side,align:e.align,offset:1,component:`popover`,p:3,id:g,props:r,children:n})}}}function b(e){let{value:r,step:a,locale:s,hourCycle:c,onSelect:l,label:u}=e,d=(0,p.useMemo)(()=>o.l(a),[a]),f=o.s(r,a),h=Math.max(0,f?d.indexOf(f):d.indexOf(`09:00:00`)),g=n.t({count:d.length,defaultActiveIndex:h,loop:!1,onSelect:(e,t)=>l(d[e],t)});return(0,m.jsx)(t.default,{component:`datePicker.times`,position:`relative`,display:`flex`,d:`column`,gap:.5,maxHeight:72,overflowY:`auto`,ps:2,bs:1,props:{role:`listbox`,"aria-label":u,onKeyDown:g.onKeyDown},children:d.map((e,n)=>(0,m.jsx)(t.default,{component:`datePicker.time`,variant:{selected:e===f},px:3,py:1.5,borderRadius:2,fontSize:14,textAlign:`start`,whiteSpace:`nowrap`,css:{fontVariantNumeric:`tabular-nums`},props:{role:`option`,"aria-selected":e===f,...g.itemProps(n),onClick:t=>l(e,t)},children:i.t(e,{locale:s,hour:`numeric`,minute:`2-digit`,hourCycle:c===void 0?void 0:c===12?`h12`:`h23`})},e))})}function x(e){return(0,m.jsx)(t.default,{component:`datePicker.presets`,display:`flex`,d:`column`,gap:.5,pe:2,be:1,props:{role:`group`},children:e.presets.map(n=>(0,m.jsx)(t.default,{tag:`button`,component:`datePicker.preset`,variant:{selected:e.isSelected(n.value)},px:3,py:1.5,borderRadius:2,fontSize:14,textAlign:`start`,whiteSpace:`nowrap`,props:{type:`button`,onClick:t=>e.onSelect(n.value,t)},children:n.label},n.label))})}function S(e,r){let{type:o=`date`,value:s,defaultValue:u=null,onValueChange:d,zone:p,locale:v,hourCycle:S,granularity:C,disambiguation:w,min:T,max:E,isDateUnavailable:D,disabled:O=!1,readOnly:k=!1,required:ee,invalid:te,name:ne,label:A,labelledBy:re,describedBy:ie,open:j,defaultOpen:ae,onOpenChange:oe,closeOnSelect:M=!0,firstDayOfWeek:se,weekNumbers:ce,side:le=`bottom`,align:N=`start`,clearable:ue=!1,triggerLabel:P,clearLabel:F=`Clear`,tabIndex:I,step:L=30,defaultTime:de=`00:00`,presets:R,showZone:fe,...z}=e,B=c.n({locale:v,zone:p===`none`?void 0:p}),{locale:V}=B,H=o===`datetime`&&p!==`none`?B.zone:null,U=H??B.zone,[W,G]=n.i({value:s,defaultValue:u,onChange:(e,t)=>d?.(e,{...t,...a.x(e,U)})}),K=P??(o===`time`?`Choose time`:`Choose date`),q=typeof A==`string`?A:K,{attachTrigger:pe,triggerAttributes:J,closeOnChoice:Y,attachField:X,panel:Z}=y({ref:r,open:j,defaultOpen:ae,onOpenChange:oe,side:le,align:N,label:q}),Q=W&&o!==`time`?a.O(W,{zone:U}):null,me=W&&o!==`date`?a.A(W,{zone:U}):null,he=W?i.t(W,{locale:V,zone:U,...o===`date`?{dateStyle:`medium`}:o===`time`?{timeStyle:`short`}:{dateStyle:`medium`,timeStyle:`short`}}):``,$=Y,ge=(e,t)=>a.r(e,t,H?{zone:H,disambiguation:w}:{}),_e=(e,t)=>{e&&(o===`date`?(G(e,{reason:`select`,event:t}),M&&$(t)):G(ge(e,me??de),{reason:`select`,event:t}))},ve=(e,t)=>{G(o===`time`?e:ge(Q??a.N(U),e),{reason:`select`,event:t}),M&&$(t)},ye=(0,m.jsx)(t.default,{tag:`button`,ref:pe,component:`datePicker.trigger`,display:`inline-flex`,ai:`center`,jc:`center`,width:7,height:7,ms:2,me:-1.5,borderRadius:1.5,disabled:O||k,props:{type:`button`,"aria-label":he?`${K}, ${he}`:K,tabIndex:I,...J},children:o===`time`?(0,m.jsx)(g,{}):(0,m.jsx)(h,{})}),be=ue&&W&&!O&&!k&&(0,m.jsx)(t.default,{tag:`button`,component:`datePicker.clear`,display:`inline-flex`,ai:`center`,jc:`center`,width:6,height:6,ms:1,borderRadius:999,props:{type:`button`,"aria-label":F,tabIndex:I,onClick:e=>G(null,{reason:`clear`,event:e})},children:(0,m.jsx)(_,{})});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(f.default,{ref:X,...z,type:o,value:W,onValueChange:(e,t)=>G(e,{reason:t.reason,event:t.event}),zone:p,locale:v,hourCycle:S,granularity:C,disambiguation:w,min:T,max:E,isDateUnavailable:D,disabled:O,readOnly:k,required:ee,invalid:te,name:ne,label:A,labelledBy:re,describedBy:ie,showZone:fe,tabIndex:I,end:(0,m.jsxs)(m.Fragment,{children:[be,ye]})}),Z((0,m.jsxs)(t.default,{display:`flex`,gap:3,ai:`stretch`,children:[R&&R.length>0&&(0,m.jsx)(x,{presets:R,isSelected:e=>W!==null&&a.i(e,W,{zone:U})===0,onSelect:(e,t)=>{G(e,{reason:`preset`,event:t}),M&&$(t)}}),o!==`time`&&(0,m.jsx)(l.default,{value:Q,onValueChange:(e,t)=>_e(e,t.event),min:T?a.O(T,{zone:U}):void 0,max:E?a.O(E,{zone:U}):void 0,isDateUnavailable:D,locale:v,zone:p===`none`?void 0:p,firstDayOfWeek:se,weekNumbers:ce}),o!==`date`&&(0,m.jsx)(b,{value:me,step:L,locale:V,hourCycle:S,label:o===`time`?q:`Time`,onSelect:ve})]}))]})}function C(e,r){let{value:o,defaultValue:s=null,onValueChange:u,locale:d,min:g,max:v,isDateUnavailable:b,disabled:S=!1,readOnly:C=!1,required:w,invalid:T,startName:E,endName:D,label:O,labelledBy:k,describedBy:ee,startLabel:te=`Start date`,endLabel:ne=`End date`,open:A,defaultOpen:re,onOpenChange:ie,closeOnSelect:j=!0,firstDayOfWeek:ae,weekNumbers:oe,months:M=2,side:se=`bottom`,align:ce=`start`,clearable:le=!1,triggerLabel:N=`Choose dates`,clearLabel:ue=`Clear`,tabIndex:P,presets:F,props:I,...L}=e,{locale:de}=c.n({locale:d}),[R,fe]=n.i({value:o,defaultValue:s,onChange:u}),[z,B]=(0,p.useState)({start:R?.start??null,end:R?.end??null,source:R}),{start:V,end:H}=z;z.source!==R&&(V=R?.start??null,H=R?.end??null,B({start:V,end:H,source:R}));let{attachTrigger:U,triggerAttributes:W,closeOnChoice:G,id:K,attachField:q,panel:pe}=y({ref:r,open:A,defaultOpen:re,onOpenChange:ie,side:se,align:ce,label:typeof O==`string`?O:N}),J=R?i.n(R.start,R.end,{locale:de}):``,Y=V!==null&&H!==null&&a.i(V,H)>0,X=(e,t,n,r)=>{let i=e&&t&&a.i(e,t)<=0?{start:e,end:t}:null;B({start:e,end:t,source:i}),fe(i,{reason:n,event:r})},Z=G,Q={locale:d,min:g,max:v,isDateUnavailable:b,disabled:S,readOnly:C,required:w,component:`datePicker.part`,px:0,py:0,tabIndex:P};return(0,m.jsxs)(m.Fragment,{children:[O!==void 0&&(0,m.jsx)(t.default,{component:`dateField.label`,display:`block`,mb:1.5,fontSize:14,id:`${K}-label`,children:O}),(0,m.jsxs)(t.default,{ref:q,component:`dateField`,display:`inline-flex`,ai:`center`,gap:2,px:3,py:2,...L,variant:[L.variant,{disabled:S,invalid:T??Y}],props:{role:`group`,"aria-labelledby":[O===void 0?void 0:`${K}-label`,k].filter(Boolean).join(` `)||void 0,"aria-invalid":(T??Y)||void 0,"aria-describedby":ee,...I},children:[(0,m.jsx)(f.default,{...Q,value:V,onValueChange:(e,t)=>X(e,H,t.reason,t.event),name:E,props:{"aria-label":te},invalid:T??Y}),(0,m.jsx)(t.default,{component:`dateField.literal`,props:{"aria-hidden":!0},children:`–`}),(0,m.jsx)(f.default,{...Q,value:H,onValueChange:(e,t)=>X(V,e,t.reason,t.event),name:D,props:{"aria-label":ne},invalid:T??Y}),le&&R&&!S&&!C&&(0,m.jsx)(t.default,{tag:`button`,component:`datePicker.clear`,display:`inline-flex`,ai:`center`,jc:`center`,width:6,height:6,borderRadius:999,props:{type:`button`,"aria-label":ue,tabIndex:P,onClick:e=>X(null,null,`clear`,e)},children:(0,m.jsx)(_,{})}),(0,m.jsx)(t.default,{tag:`button`,ref:U,component:`datePicker.trigger`,display:`inline-flex`,ai:`center`,jc:`center`,width:7,height:7,me:-1.5,borderRadius:1.5,disabled:S||C,props:{type:`button`,"aria-label":J?`${N}, ${J}`:N,tabIndex:P,...W},children:(0,m.jsx)(h,{})})]}),pe((0,m.jsxs)(t.default,{display:`flex`,gap:3,ai:`stretch`,children:[F&&F.length>0&&(0,m.jsx)(x,{presets:F,isSelected:e=>R!==null&&e.start===R.start&&e.end===R.end,onSelect:(e,t)=>{X(e.start,e.end,`preset`,t),j&&Z(t)}}),(0,m.jsx)(l.default,{mode:`range`,months:M,value:R,defaultFocusedDate:V??void 0,onValueChange:(e,t)=>{X(e?.start??null,e?.end??null,`select`,t.event),j&&e&&t.event&&Z(t.event)},min:g,max:v,isDateUnavailable:b,locale:d,firstDayOfWeek:ae,weekNumbers:oe})]}))]})}var w=e.f(S,`DatePicker`),T=e.f(C,`DateRangePicker`);exports.DateRangePicker=T,exports.default=w;
@@ -0,0 +1,120 @@
1
+ import { RefAttributes } from 'react';
2
+ import { BoxProps } from '../box';
3
+ import { ChangeHandler } from '../react/a11y/useControllableState';
4
+ import { DateChangeDetails, DateChangeReason } from '../react/date/dateChange';
5
+ import { PopoverReason } from '../react/popover/usePopoverLayer';
6
+ import { ComponentsAndVariants } from '@box-kite/core/types';
7
+ import { AnchorAlign, AnchorSide } from '../utils/anchor/anchorUtils';
8
+ import { FieldGranularity } from '../utils/date/fieldModel';
9
+ import { Disambiguation, ZoneInput } from '../utils/date/zones';
10
+ import { DateRange } from './calendar';
11
+ export type { DateRange } from './calendar';
12
+ export type { DateChangeDetails, DateChangeHandler, DateChangeReason } from '../react/date/dateChange';
13
+ /** Why the panel opened or closed: the layer's four, and `select` — a value was chosen and closed it. */
14
+ export type DatePickerOpenReason = PopoverReason | 'select';
15
+ /** A shortcut beside the calendar: a label and the value it sets. */
16
+ export interface DatePreset<TValue = string> {
17
+ label: string;
18
+ value: TValue;
19
+ }
20
+ type PickerBoxProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'div', TKey>, 'onChange' | 'disabled' | 'required' | 'invalid' | 'placeholder' | 'defaultValue' | 'readOnly' | 'open' | 'flip'>;
21
+ interface SharedProps<TKey extends keyof ComponentsAndVariants> extends PickerBoxProps<TKey> {
22
+ /** The language of the field, the calendar and the times. Default the reader's. */
23
+ locale?: string;
24
+ /** The earliest value that is valid, and the first day the calendar offers. */
25
+ min?: string | null;
26
+ /** The latest. */
27
+ max?: string | null;
28
+ /** Days nobody can choose. */
29
+ isDateUnavailable?: (date: string) => boolean;
30
+ /** Not editable, not focusable and not openable. */
31
+ disabled?: boolean;
32
+ /** Focusable and read out, but not editable, and the button does not open. */
33
+ readOnly?: boolean;
34
+ /** The form is not valid until it is filled in — the browser's own check. */
35
+ required?: boolean;
36
+ /** Marks the value invalid whatever the bounds say. Default: invalid when out of bounds or unavailable. */
37
+ invalid?: boolean;
38
+ /** The picker's visible name, above the field. */
39
+ label?: React.ReactNode;
40
+ /** Names the field after an element already on the page, instead of `label`. */
41
+ labelledBy?: string;
42
+ /** An element that describes the field — a hint, an error. */
43
+ describedBy?: string;
44
+ /** Whether the panel is open. Controlled. */
45
+ open?: boolean;
46
+ /** Whether it starts open, when the picker owns that itself. */
47
+ defaultOpen?: boolean;
48
+ /** Fires with the new state and why — the layer's four reasons, and `'select'` when choosing closed it. */
49
+ onOpenChange?: ChangeHandler<boolean, DatePickerOpenReason>;
50
+ /** Whether choosing closes the panel. Default `true`; a date-time closes once its time is chosen. */
51
+ closeOnSelect?: boolean;
52
+ /** The day the week starts on, 0 for Sunday. Default the locale's. */
53
+ firstDayOfWeek?: number;
54
+ /** ISO week numbers down the calendar's side. */
55
+ weekNumbers?: boolean;
56
+ /** Which side of the field the panel opens on. Default `'bottom'`. */
57
+ side?: AnchorSide;
58
+ /** Which of the field's edges it lines up with. Default `'start'`. */
59
+ align?: AnchorAlign;
60
+ /** A button inside the field that empties it. */
61
+ clearable?: boolean;
62
+ /** The calendar button's name. Default `'Choose date'`, or `'Choose time'`. */
63
+ triggerLabel?: string;
64
+ /** The clear button's name. Default `'Clear'`. */
65
+ clearLabel?: string;
66
+ /** Every segment's and button's tab index. Default `0`; `-1` keeps the picker out of the page's tab order, which a grid cell wants. */
67
+ tabIndex?: number;
68
+ }
69
+ export interface DatePickerProps<TKey extends keyof ComponentsAndVariants = 'dateField'> extends SharedProps<TKey> {
70
+ /** A day (`'date'`, default), a time of day (`'time'`), or both (`'datetime'`). */
71
+ type?: 'date' | 'time' | 'datetime';
72
+ /** Controlled value, an ISO string of the picker's kind — see `DateField`. */
73
+ value?: string | null;
74
+ /** The value it starts with when the picker owns its state. */
75
+ defaultValue?: string | null;
76
+ /** Fires with the value and its readings — `utc`, the reader's `local` wall clock, a `Date`. */
77
+ onValueChange?: ChangeHandler<string | null, DateChangeReason, DateChangeDetails>;
78
+ /** Whose wall clock a date-time is on. Default `'local'`; `'none'` for no zone at all. */
79
+ zone?: ZoneInput | 'none';
80
+ /** A 12- or 24-hour clock, in the field and the list of times. Default the locale's. */
81
+ hourCycle?: 12 | 24;
82
+ /** Whether a time is edited to the minute (default) or the second. */
83
+ granularity?: FieldGranularity;
84
+ /** What a wall-clock time a zone skips or repeats means. Default `'compatible'`. */
85
+ disambiguation?: Disambiguation;
86
+ /** What the value posts under in a form. */
87
+ name?: string;
88
+ /** Minutes between the times the list offers. Default 30. */
89
+ step?: number;
90
+ /** The time a day picked before any time takes. Default `'00:00'`. */
91
+ defaultTime?: string;
92
+ /** Shortcuts beside the calendar — `{ label: 'Today', value: today() }`. */
93
+ presets?: readonly DatePreset[];
94
+ /** Whether a date-time names its zone after the time. Default: when the zone is not the reader's own. */
95
+ showZone?: boolean;
96
+ }
97
+ export interface DateRangePickerProps<TKey extends keyof ComponentsAndVariants = 'dateField'> extends SharedProps<TKey> {
98
+ /** Controlled value: both ends, `YYYY-MM-DD`, or `null`. */
99
+ value?: DateRange | null;
100
+ /** The span it starts with when the picker owns its value. */
101
+ defaultValue?: DateRange | null;
102
+ /** Fires once both ends are filled in and in order, and with `null` when either is emptied. */
103
+ onValueChange?: ChangeHandler<DateRange | null, DateChangeReason>;
104
+ /** What the start posts under in a form. */
105
+ startName?: string;
106
+ /** What the end posts under. */
107
+ endName?: string;
108
+ /** The names a screen reader gives the two fields. Default `'Start date'` and `'End date'`. */
109
+ startLabel?: string;
110
+ /** The end field's name. Default `'End date'`. */
111
+ endLabel?: string;
112
+ /** Months side by side in the panel. Default 2. */
113
+ months?: 1 | 2 | 3;
114
+ /** Shortcuts beside the calendar — `{ label: 'This week', value: { start, end } }`. */
115
+ presets?: readonly DatePreset<DateRange>[];
116
+ }
117
+ declare const DateRangePicker: <TKey extends keyof ComponentsAndVariants = "dateField">(props: DateRangePickerProps<TKey> & RefAttributes<HTMLDivElement>) => React.ReactNode;
118
+ export { DateRangePicker };
119
+ declare const _default: <TKey extends keyof ComponentsAndVariants = "dateField">(props: DatePickerProps<TKey> & RefAttributes<HTMLDivElement>) => React.ReactNode;
120
+ export default _default;