@box-kite/react 2.2.4 → 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.
- package/.claude/rules/box-kite-rules.md +11 -1
- package/.claude/skills/box-kite/SKILL.md +11 -1
- package/.claude/skills/box-kite/references/components.md +83 -3
- package/.cursor/rules/box-kite.mdc +11 -1
- package/AGENTS.md +11 -1
- package/BOX_AI_CONTEXT.md +371 -25
- package/BOX_KITE_AI_CONTEXT.md +371 -25
- package/behavior.cjs +1 -1
- package/behavior.mjs +57 -57
- package/box.cjs +1 -1
- package/box.d.ts +5 -0
- package/box.mjs +15 -15
- package/catalog.cjs +1 -1
- package/catalog.mjs +906 -0
- package/client.cjs +1 -1
- package/client.mjs +94 -80
- package/components/calendar.cjs +1 -0
- package/components/calendar.d.ts +77 -0
- package/components/calendar.mjs +483 -0
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +1 -1
- package/components/dataGrid/components/dataGridBooleanValue.d.ts +11 -0
- package/components/dataGrid/components/dataGridDateParts.d.ts +40 -0
- package/components/dataGrid/components/dataGridDateValue.d.ts +14 -0
- package/components/dataGrid/components/dataGridList.d.ts +12 -0
- package/components/dataGrid/components/dataGridListAggregate.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilter.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilterSheet.d.ts +11 -0
- package/components/dataGrid/components/dataGridListFooter.d.ts +13 -0
- package/components/dataGrid/components/dataGridListGroup.d.ts +13 -0
- package/components/dataGrid/components/dataGridListItem.d.ts +21 -0
- package/components/dataGrid/components/dataGridListLayout.d.ts +20 -0
- package/components/dataGrid/components/dataGridListRecord.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSelectionBar.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSheet.d.ts +30 -0
- package/components/dataGrid/components/dataGridListSortSheet.d.ts +10 -0
- package/components/dataGrid/components/dataGridListToolbar.d.ts +10 -0
- package/components/dataGrid/components/dataGridListValue.d.ts +12 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +70 -11
- package/components/dataGrid/models/columnModel.d.ts +3 -1
- package/components/dataGrid/models/editModel.d.ts +3 -1
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/listModel.d.ts +129 -0
- package/components/dataGrid/models/localeText.d.ts +36 -0
- package/components/dataGrid/models/viewportModel.d.ts +0 -2
- package/components/dataGrid/useDateParts.d.ts +17 -0
- package/components/dataGrid/useListLayout.d.ts +13 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +1251 -854
- package/components/dateField.cjs +1 -0
- package/components/dateField.d.ts +78 -0
- package/components/dateField.mjs +313 -0
- package/components/datePicker.cjs +1 -0
- package/components/datePicker.d.ts +120 -0
- package/components/datePicker.mjs +529 -0
- package/components/dateTime.cjs +1 -0
- package/components/dateTime.d.ts +23 -0
- package/components/dateTime.mjs +34 -0
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +29 -29
- package/components/list/listItemParts.d.ts +9 -0
- package/components/list.cjs +1 -0
- package/components/list.d.ts +118 -0
- package/components/list.mjs +391 -0
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +25 -25
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +12 -12
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +1 -1
- package/components/sortableList.cjs +1 -0
- package/components/sortableList.d.ts +49 -0
- package/components/sortableList.mjs +384 -0
- package/components/swipeItem.cjs +1 -0
- package/components/swipeItem.d.ts +52 -0
- package/components/swipeItem.mjs +321 -0
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +1 -1
- package/components/timeZoneSelect.cjs +1 -0
- package/components/timeZoneSelect.d.ts +52 -0
- package/components/timeZoneSelect.mjs +74 -0
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +24 -24
- package/components/virtualList.cjs +1 -0
- package/components/virtualList.d.ts +32 -0
- package/components/virtualList.mjs +188 -0
- package/dataGridDateParts.cjs +1 -0
- package/dataGridDateParts.mjs +223 -0
- package/dataGridList.cjs +1 -0
- package/dataGridList.mjs +1314 -0
- package/dataGridListLayout.cjs +1 -0
- package/dataGridListLayout.mjs +49 -0
- package/date-environment.cjs +1 -0
- package/date-environment.mjs +29 -0
- package/date-input.cjs +1 -0
- package/date-input.mjs +346 -0
- package/date-math.cjs +1 -0
- package/date-math.mjs +317 -0
- package/date.cjs +1 -0
- package/date.d.ts +40 -0
- package/date.mjs +4 -0
- package/dates.cjs +1 -0
- package/dates.mjs +689 -0
- package/docs/components.md +10 -1
- package/icons/closeIcon.d.ts +2 -0
- package/icons/filterIcon.d.ts +2 -0
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/mcp/src/data.d.ts +2 -0
- package/package.json +178 -22
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +4 -1
- package/react/a11y/useControllableState.d.ts +2 -1
- package/react/boxComponent.d.ts +1 -1
- package/react/componentsContext.d.ts +4 -0
- package/react/componentsProvider.d.ts +10 -0
- package/react/date/dateChange.d.ts +18 -0
- package/react/date/dateEnvironment.d.ts +34 -0
- package/react/resolveStyles.d.ts +2 -1
- package/react/theme/theme.d.ts +6 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +6 -6
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +3 -1
- package/registry/designs/store/address-form.d.ts +11 -0
- package/registry/designs/store/cart-items.d.ts +10 -0
- package/registry/designs/store/cart-page.d.ts +4 -0
- package/registry/designs/store/checkout-page.d.ts +7 -0
- package/registry/designs/store/credit-card-form.d.ts +10 -0
- package/registry/designs/store/form-field.d.ts +19 -0
- package/registry/designs/store/order-summary.d.ts +18 -0
- package/registry/designs/store/product-art.d.ts +26 -0
- package/registry/designs/store/product-card.d.ts +11 -0
- package/registry/designs/store/product-gallery.d.ts +11 -0
- package/registry/designs/store/product-grid.d.ts +10 -0
- package/registry/designs/store/product-page.d.ts +5 -0
- package/registry/designs/store/quantity-stepper.d.ts +13 -0
- package/registry/designs/store/shipping-method.d.ts +14 -0
- package/registry/designs/store/store-data.d.ts +53 -0
- package/registry/designs/store/store-design.d.ts +63 -0
- package/registry/designs/store/store-shell.d.ts +12 -0
- package/registry/designs/store/storefront-page.d.ts +4 -0
- package/registry/designs/store/variant-picker.d.ts +15 -0
- package/rsc.cjs +1 -1
- package/rsc.d.ts +2 -0
- package/rsc.mjs +1 -1
- package/scrolling.cjs +1 -0
- package/scrolling.mjs +22 -0
- package/utils/date/calendar.d.ts +44 -0
- package/utils/date/calendarModel.d.ts +46 -0
- package/utils/date/dateTime.d.ts +144 -0
- package/utils/date/fieldModel.d.ts +74 -0
- package/utils/date/format.d.ts +39 -0
- package/utils/date/iso.d.ts +40 -0
- package/utils/date/locale.d.ts +17 -0
- package/utils/date/parse.d.ts +20 -0
- package/utils/date/settings.d.ts +26 -0
- package/utils/date/value.d.ts +43 -0
- package/utils/date/zoneOptions.d.ts +19 -0
- package/utils/date/zones.d.ts +32 -0
- package/utils/scroll/scrollUtils.d.ts +6 -0
- package/utils/sortable/sortableUtils.d.ts +25 -0
- package/utils/swipe/swipeUtils.d.ts +53 -0
- package/utils/virtual/measuredWindow.d.ts +28 -0
- package/utils/virtual/rowSearch.d.ts +11 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { DateKind } from './iso';
|
|
2
|
+
import { DateInput, ZoneOptions } from './value';
|
|
3
|
+
import { ZoneInput } from './zones';
|
|
4
|
+
/** An amount of time to move a value by. Years to days move the calendar; hours and below move the clock. */
|
|
5
|
+
export interface Duration {
|
|
6
|
+
years?: number;
|
|
7
|
+
months?: number;
|
|
8
|
+
weeks?: number;
|
|
9
|
+
days?: number;
|
|
10
|
+
hours?: number;
|
|
11
|
+
minutes?: number;
|
|
12
|
+
seconds?: number;
|
|
13
|
+
milliseconds?: number;
|
|
14
|
+
}
|
|
15
|
+
export type DateUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
|
16
|
+
export interface UnitOptions extends ZoneOptions {
|
|
17
|
+
/** Whose week `'week'` means — Monday-first in Moldova, Sunday-first in the US. Default the configured locale. */
|
|
18
|
+
locale?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Every reading of one value at once — what a date control hands its `onValueChange` beside the string. */
|
|
21
|
+
export interface DateTimeDetails {
|
|
22
|
+
/** The value itself, written canonically. */
|
|
23
|
+
value: string;
|
|
24
|
+
kind: DateKind;
|
|
25
|
+
/** The zone the wall-clock fields below are read in. */
|
|
26
|
+
zone: string;
|
|
27
|
+
/** The moment in UTC (`…Z`). A date is its midnight in `zone`; a time has none. */
|
|
28
|
+
utc: string | null;
|
|
29
|
+
/** The moment on `zone`'s wall clock, with its offset. */
|
|
30
|
+
zoned: string | null;
|
|
31
|
+
/** The same moment as the reader's own wall clock, with no zone: what a person in the browser sees. */
|
|
32
|
+
local: string | null;
|
|
33
|
+
/** `zone`'s offset at that moment, `+03:00`. */
|
|
34
|
+
offset: string | null;
|
|
35
|
+
/** A `Date` for the moment, for an API that wants one. */
|
|
36
|
+
date: Date | null;
|
|
37
|
+
/** Epoch milliseconds. */
|
|
38
|
+
epoch: number | null;
|
|
39
|
+
year: number;
|
|
40
|
+
month: number;
|
|
41
|
+
day: number;
|
|
42
|
+
hour: number;
|
|
43
|
+
minute: number;
|
|
44
|
+
second: number;
|
|
45
|
+
millisecond: number;
|
|
46
|
+
}
|
|
47
|
+
/** What kind a string is, or `null` when it is not a date value at all. */
|
|
48
|
+
export declare function kindOf(input: DateInput): DateKind | null;
|
|
49
|
+
/** Whether the input is a value — of `kind`, when one is named. */
|
|
50
|
+
export declare function isValid(input: DateInput, kind?: DateKind): boolean;
|
|
51
|
+
/** The input rewritten canonically, its kind kept: `2026-10-19 14:30` → `2026-10-19T14:30:00`. */
|
|
52
|
+
export declare function normalize(input: DateInput): string | null;
|
|
53
|
+
/** The moment in UTC: `2026-10-19T11:30:00Z`. A date-time is read on `zone`'s wall clock, a date as its midnight there. */
|
|
54
|
+
export declare function toUtc(input: DateInput, options?: Omit<ZoneOptions, 'zone'> & {
|
|
55
|
+
from?: ZoneInput;
|
|
56
|
+
}): string | null;
|
|
57
|
+
/** The moment on another zone's wall clock, with that zone's offset: `2026-10-19T07:30:00-04:00`. */
|
|
58
|
+
export declare function toZone(input: DateInput, zone: ZoneInput, options?: Omit<ZoneOptions, 'zone'> & {
|
|
59
|
+
from?: ZoneInput;
|
|
60
|
+
}): string | null;
|
|
61
|
+
/** The moment on the reader's wall clock, with its offset. On a server, "the reader" is `configureDates({ timeZone })` or the server. */
|
|
62
|
+
export declare function toLocal(input: DateInput, options?: Omit<ZoneOptions, 'zone'> & {
|
|
63
|
+
from?: ZoneInput;
|
|
64
|
+
}): string | null;
|
|
65
|
+
/** The day an input falls on in `zone`: `2026-10-19`. */
|
|
66
|
+
export declare function toPlainDate(input: DateInput, options?: ZoneOptions): string | null;
|
|
67
|
+
/** The wall-clock time an input shows in `zone`: `14:30:00`. */
|
|
68
|
+
export declare function toPlainTime(input: DateInput, options?: ZoneOptions): string | null;
|
|
69
|
+
/** The wall clock an input shows in `zone`, with no zone attached: `2026-10-19T14:30:00`. */
|
|
70
|
+
export declare function toPlainDateTime(input: DateInput, options?: ZoneOptions): string | null;
|
|
71
|
+
/** The instant an input names, on `zone`'s wall clock. A date-time is read there; a date is its midnight. */
|
|
72
|
+
export declare function toInstant(input: DateInput, options?: ZoneOptions): string | null;
|
|
73
|
+
/** Epoch milliseconds. */
|
|
74
|
+
export declare function toEpoch(input: DateInput, options?: ZoneOptions): number | null;
|
|
75
|
+
/** A `Date`, for an API that insists. A date is its midnight in `zone`, which is the one way a `Date` can hold a day. */
|
|
76
|
+
export declare function toDate(input: DateInput, options?: ZoneOptions): Date | null;
|
|
77
|
+
/** A `Date` or epoch milliseconds as a value of `kind` — by default the instant, in UTC. */
|
|
78
|
+
export declare function fromDate(date: Date | number, options?: ZoneOptions & {
|
|
79
|
+
kind?: DateKind;
|
|
80
|
+
}): string | null;
|
|
81
|
+
/** A date and a time put together: a date-time, or with `zone` the instant it names there. */
|
|
82
|
+
export declare function combine(date: DateInput, time: DateInput, options?: ZoneOptions): string | null;
|
|
83
|
+
/** Today's date in `zone`. Default the reader's. */
|
|
84
|
+
export declare function today(zone?: ZoneInput): string;
|
|
85
|
+
/** This moment on `zone`'s wall clock, with its offset — `now('utc')` is `…Z`. */
|
|
86
|
+
export declare function now(zone?: ZoneInput): string;
|
|
87
|
+
/** The time on `zone`'s wall clock. */
|
|
88
|
+
export declare function currentTime(zone?: ZoneInput): string;
|
|
89
|
+
/**
|
|
90
|
+
* Moves a value by a duration, keeping its kind. The calendar half (years to days) moves the wall clock, so a
|
|
91
|
+
* day later is the same time tomorrow across a DST change; the clock half (hours down) moves the instant. A
|
|
92
|
+
* date ignores the clock half, and a time wraps round midnight.
|
|
93
|
+
*/
|
|
94
|
+
export declare function add(input: DateInput, duration: Duration, options?: ZoneOptions): string | null;
|
|
95
|
+
export declare function subtract(input: DateInput, duration: Duration, options?: ZoneOptions): string | null;
|
|
96
|
+
/** The first moment of the unit a value is in — the 1st of its month, its week's first day in the locale, its hour. */
|
|
97
|
+
export declare function startOf(input: DateInput, unit: DateUnit, options?: UnitOptions): string | null;
|
|
98
|
+
/** The last moment of the unit — for a date, the last day; for anything with a clock, one millisecond before the next unit. */
|
|
99
|
+
export declare function endOf(input: DateInput, unit: DateUnit, options?: UnitOptions): string | null;
|
|
100
|
+
/**
|
|
101
|
+
* Below zero when `a` is earlier, above when later, `0` when equal. Two values of one zone-free kind compare
|
|
102
|
+
* on their wall clocks; anything else compares as instants, a zone-free side read in `zone`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function compare(a: DateInput, b: DateInput, options?: ZoneOptions): number;
|
|
105
|
+
export declare function isBefore(a: DateInput, b: DateInput, options?: ZoneOptions): boolean;
|
|
106
|
+
export declare function isAfter(a: DateInput, b: DateInput, options?: ZoneOptions): boolean;
|
|
107
|
+
/** Whether two inputs are the same moment — `…14:30+03:00` and `…11:30Z` are. */
|
|
108
|
+
export declare function isEqual(a: DateInput, b: DateInput, options?: ZoneOptions): boolean;
|
|
109
|
+
/** Whether two inputs fall in the same unit — the same day, the same week in the locale — on `zone`'s wall clock. */
|
|
110
|
+
export declare function isSame(a: DateInput, b: DateInput, unit: DateUnit, options?: UnitOptions): boolean;
|
|
111
|
+
/** Whether `input` is from `start` to `end`, both included. A missing end is open. */
|
|
112
|
+
export declare function isBetween(input: DateInput, start: DateInput, end: DateInput, options?: ZoneOptions): boolean;
|
|
113
|
+
/** The input, moved inside `[min, max]`. */
|
|
114
|
+
export declare function clamp(input: DateInput, min: DateInput, max: DateInput, options?: ZoneOptions): string | null;
|
|
115
|
+
/**
|
|
116
|
+
* How many whole units `a` is after `b` (negative when before). Months and years count on the calendar — 31
|
|
117
|
+
* January to 28 February is not yet a month — and days count calendar days between two dates.
|
|
118
|
+
*/
|
|
119
|
+
export declare function difference(a: DateInput, b: DateInput, unit: DateUnit, options?: ZoneOptions): number | null;
|
|
120
|
+
/** How many days the month a value falls in has. */
|
|
121
|
+
export declare function daysInMonthOf(input: DateInput, options?: ZoneOptions): number | null;
|
|
122
|
+
/**
|
|
123
|
+
* Every reading of a value at once: the canonical string, the UTC moment, the moment on `zone`'s wall clock
|
|
124
|
+
* and on the reader's, the offset, a `Date`, the epoch, and the wall-clock fields. `null` for a non-value.
|
|
125
|
+
*/
|
|
126
|
+
export declare function details(input: DateInput, options?: ZoneOptions): DateTimeDetails | null;
|
|
127
|
+
/** Minutes east of UTC that `zone` is at a moment (default now): `180` for Chisinau in summer, `-240` for New York. */
|
|
128
|
+
export declare function offsetOf(zone?: ZoneInput, at?: DateInput): number | null;
|
|
129
|
+
/** What a date control reports beside its value: the readings an app most often wants, all `null` for no value. */
|
|
130
|
+
export interface DateReadings {
|
|
131
|
+
/** The moment in UTC, `…Z`. A date is its midnight in the control's zone; a time has none. */
|
|
132
|
+
utc: string | null;
|
|
133
|
+
/** The moment on the reader's own wall clock, with no zone. */
|
|
134
|
+
local: string | null;
|
|
135
|
+
/** The moment on the control's zone's wall clock, with its offset. */
|
|
136
|
+
zoned: string | null;
|
|
137
|
+
date: Date | null;
|
|
138
|
+
epoch: number | null;
|
|
139
|
+
/** The zone the control reads and writes in. */
|
|
140
|
+
zone: string;
|
|
141
|
+
offset: string | null;
|
|
142
|
+
}
|
|
143
|
+
/** The readings for a value in a control's zone — what `onValueChange` hands over beside the string. */
|
|
144
|
+
export declare function readingsOf(value: string | null | undefined, zone?: ZoneInput): DateReadings;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Disambiguation } from './zones';
|
|
2
|
+
/** What a field edits: a day, a time of day, or both. */
|
|
3
|
+
export type FieldType = 'date' | 'time' | 'datetime';
|
|
4
|
+
/** How fine a time is edited. */
|
|
5
|
+
export type FieldGranularity = 'minute' | 'second';
|
|
6
|
+
/** A part of a field a person edits, one number at a time. */
|
|
7
|
+
export type SegmentType = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod';
|
|
8
|
+
export interface Segment {
|
|
9
|
+
type: SegmentType | 'literal';
|
|
10
|
+
/** What a literal reads — a `/`, a `.`, a `, `. */
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FieldConfig {
|
|
14
|
+
type: FieldType;
|
|
15
|
+
locale: string;
|
|
16
|
+
hourCycle: 12 | 24;
|
|
17
|
+
granularity: FieldGranularity;
|
|
18
|
+
}
|
|
19
|
+
/** A field part-way through being filled in: one number per segment, `dayPeriod` 0 for AM and 1 for PM. */
|
|
20
|
+
export type Draft = Partial<Record<SegmentType, number>>;
|
|
21
|
+
/**
|
|
22
|
+
* The segments in the order the locale writes them, with its own separators — `dd.mm.yyyy` in Moldova,
|
|
23
|
+
* `mm/dd/yyyy` in the US, `yyyy-mm-dd` in Sweden. Read off `formatToParts`, so no locale table ships, and on
|
|
24
|
+
* the Gregorian calendar with Latin digits whatever the locale's default, since the field edits numbers.
|
|
25
|
+
*/
|
|
26
|
+
export declare function segmentsFor(config: FieldConfig): Segment[];
|
|
27
|
+
/** The editable segments alone. */
|
|
28
|
+
export declare function editable(segments: readonly Segment[]): SegmentType[];
|
|
29
|
+
/** The values a segment takes. A day's top follows the month and year typed so far — 29 in a leap February. */
|
|
30
|
+
export declare function rangeOf(type: SegmentType, draft: Draft, config: FieldConfig): {
|
|
31
|
+
min: number;
|
|
32
|
+
max: number;
|
|
33
|
+
};
|
|
34
|
+
/** Up or down by `delta`, wrapping inside the segment's range the way a clock does. An empty segment takes its placeholder. */
|
|
35
|
+
export declare function step(draft: Draft, type: SegmentType, delta: number, config: FieldConfig, placeholder: Draft): Draft;
|
|
36
|
+
/** How far Page Up and Page Down move a segment. */
|
|
37
|
+
export declare const PAGE_STEP: Record<SegmentType, number>;
|
|
38
|
+
export interface Typed {
|
|
39
|
+
draft: Draft;
|
|
40
|
+
/** The digits typed into this segment so far, which a next digit appends to. */
|
|
41
|
+
buffer: string;
|
|
42
|
+
/** Whether no further digit could make sense here, so focus moves on. */
|
|
43
|
+
advance: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One digit typed into a segment. It appends while the number still fits the range and starts again when it
|
|
47
|
+
* would not, and focus moves on as soon as another digit could not fit — `4` in a month is April at once,
|
|
48
|
+
* `1` waits for a `0`, `1` or `2`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function typeDigit(draft: Draft, type: SegmentType, buffer: string, digit: string, config: FieldConfig): Typed;
|
|
51
|
+
/** A letter typed into the AM/PM segment: the first letter of either period in the locale, or `a`/`p`. */
|
|
52
|
+
export declare function typePeriod(draft: Draft, letter: string, locale: string): Draft | null;
|
|
53
|
+
/** What a segment shows: its number padded, the digits being typed, AM/PM, or its placeholder when empty. */
|
|
54
|
+
export declare function segmentText(type: SegmentType, draft: Draft, buffer: string, locale: string): string;
|
|
55
|
+
export interface FieldValueOptions {
|
|
56
|
+
/** The zone a date-time is an instant in; `null` keeps it a wall clock with no zone. */
|
|
57
|
+
zone: string | null;
|
|
58
|
+
disambiguation?: Disambiguation;
|
|
59
|
+
}
|
|
60
|
+
/** Whether every segment the field shows has a number. */
|
|
61
|
+
export declare function isComplete(draft: Draft, segments: readonly Segment[]): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The value a draft spells, or `null` while a segment is empty. A day past the month's end (31 typed before a
|
|
64
|
+
* February) is pulled back onto its last day, the way a calendar would read it.
|
|
65
|
+
*/
|
|
66
|
+
export declare function valueOf(draft: Draft, segments: readonly Segment[], config: FieldConfig, options: FieldValueOptions): string | null;
|
|
67
|
+
/** A value taken apart into a draft, on `zone`'s wall clock. Anything unreadable is an empty draft. */
|
|
68
|
+
export declare function draftOf(value: string | null | undefined, config: FieldConfig, zone: string | null): Draft;
|
|
69
|
+
/** The segments a draft keeps when the config changes shape — a 12-hour clock turned to 24 keeps the time. */
|
|
70
|
+
export declare function reshape(draft: Draft, from: FieldConfig, to: FieldConfig): Draft;
|
|
71
|
+
/** The times of a day every `step` minutes from midnight — what a time list offers. */
|
|
72
|
+
export declare function timeSlots(step: number): string[];
|
|
73
|
+
/** The slot a time falls in, so a list highlights 14:30 for 14:37 on a half-hour step. */
|
|
74
|
+
export declare function slotOf(time: string | null, step: number): string | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DateInput } from './value';
|
|
2
|
+
import { ZoneInput } from './zones';
|
|
3
|
+
/** What `Intl.DateTimeFormat` takes, less the zone, which is spelt `zone` here and accepts `'local'`. */
|
|
4
|
+
export interface FormatOptions extends Omit<Intl.DateTimeFormatOptions, 'timeZone'> {
|
|
5
|
+
/** A BCP 47 tag. Default: the configured locale, or the runtime's. */
|
|
6
|
+
locale?: string;
|
|
7
|
+
/** The wall clock an instant is shown on. Default `'local'`. A date, a time or a date-time has no zone, so this does nothing to one. */
|
|
8
|
+
zone?: ZoneInput;
|
|
9
|
+
}
|
|
10
|
+
/** One formatter per locale and option set: building one costs ~40µs and formatting with a cached one ~4µs. */
|
|
11
|
+
export declare function formatter(locale: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
12
|
+
/**
|
|
13
|
+
* A value in the reader's words: `19 Oct 2026`, `14:30`, `Oct 19, 2026, 2:30 PM`. Pass `dateStyle`/`timeStyle`
|
|
14
|
+
* or the component options (`month: 'long'`) for another shape; with none, the kind decides. Returns `''` for
|
|
15
|
+
* an input that is not a date at all, so a missing value renders as nothing.
|
|
16
|
+
*/
|
|
17
|
+
export declare function format(input: DateInput, options?: FormatOptions): string;
|
|
18
|
+
export declare function tidy(text: string): string;
|
|
19
|
+
/** The same, as parts — what a field builds its segments from. */
|
|
20
|
+
export declare function formatToParts(input: DateInput, options?: FormatOptions): Intl.DateTimeFormatPart[];
|
|
21
|
+
/** Two values as one range, `Oct 19 – 23, 2026`, with what they share written once. */
|
|
22
|
+
export declare function formatRange(start: DateInput, end: DateInput, options?: FormatOptions): string;
|
|
23
|
+
export interface RelativeOptions {
|
|
24
|
+
locale?: string;
|
|
25
|
+
/** What "now" is. Default the current moment; pass one a server rendered with, so the browser agrees with it. */
|
|
26
|
+
now?: DateInput;
|
|
27
|
+
zone?: ZoneInput;
|
|
28
|
+
/** `'auto'` (default) says `yesterday` and `in 2 days`; `'always'` says `1 day ago`. */
|
|
29
|
+
numeric?: 'auto' | 'always';
|
|
30
|
+
style?: 'long' | 'short' | 'narrow';
|
|
31
|
+
}
|
|
32
|
+
/** `3 minutes ago`, `tomorrow`, `in 2 weeks`. A date is counted in calendar days, so yesterday is yesterday at any hour. */
|
|
33
|
+
export declare function formatRelative(input: DateInput, options?: RelativeOptions): string;
|
|
34
|
+
/** What a zone is called at an instant: `Eastern European Summer Time`, `EEST`, `GMT+3`. */
|
|
35
|
+
export declare function zoneName(zone?: ZoneInput, options?: {
|
|
36
|
+
locale?: string;
|
|
37
|
+
style?: Intl.DateTimeFormatOptions['timeZoneName'];
|
|
38
|
+
at?: DateInput;
|
|
39
|
+
}): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DateTimeFields } from './calendar';
|
|
2
|
+
import { Disambiguation } from './zones';
|
|
3
|
+
/**
|
|
4
|
+
* The four things a date value can be, and the string each one is written as:
|
|
5
|
+
*
|
|
6
|
+
* - `date` — a day with no time and no zone: `2026-10-19`. A birthday, a due date.
|
|
7
|
+
* - `time` — a wall-clock time with no date: `14:30:00`. Opening hours.
|
|
8
|
+
* - `datetime` — a date and a time with no zone: `2026-10-19T14:30:00`. "Local" in the sense of *wherever you
|
|
9
|
+
* are* — an alarm, a train timetable. Temporal's `PlainDateTime`.
|
|
10
|
+
* - `instant` — one moment in time, written with the offset it was read in: `2026-10-19T14:30:00+03:00`, or
|
|
11
|
+
* `…Z` in UTC. Anything stored, compared across zones or sent to a server.
|
|
12
|
+
*/
|
|
13
|
+
export type DateKind = 'date' | 'time' | 'datetime' | 'instant';
|
|
14
|
+
/** A value taken apart: the wall clock as written, plus — for an instant — the offset and zone it was written in. */
|
|
15
|
+
export interface ParsedValue {
|
|
16
|
+
kind: DateKind;
|
|
17
|
+
fields: DateTimeFields;
|
|
18
|
+
/** Minutes east of UTC. Instants only. */
|
|
19
|
+
offset: number;
|
|
20
|
+
/** The IANA zone named in brackets (`…+03:00[Europe/Chisinau]`), when there was one. */
|
|
21
|
+
zone?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The epoch an instant names. */
|
|
24
|
+
export declare function epochOf(value: ParsedValue): number;
|
|
25
|
+
/**
|
|
26
|
+
* Reads an ISO 8601 / RFC 3339 / RFC 9557 string: a date, a time, a date-time, or one with an offset (`Z`,
|
|
27
|
+
* `+03:00`) and optionally a bracketed zone. `T` or a space between the halves, seconds and fractions
|
|
28
|
+
* optional, the basic form (`20261019T1430`) too. A bracketed zone with no offset is resolved in that zone.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseIso(input: string, disambiguation?: Disambiguation): ParsedValue | null;
|
|
31
|
+
export declare function dateText(fields: DateTimeFields): string;
|
|
32
|
+
/** Seconds always, milliseconds when there are any — Temporal's rule, so a value never changes length with its content. */
|
|
33
|
+
export declare function timeText(fields: DateTimeFields): string;
|
|
34
|
+
/** The canonical string for a value. An instant in UTC is written `Z`; in any other zone with its offset. */
|
|
35
|
+
export declare function toIso(value: ParsedValue, zoneSuffix?: boolean): string;
|
|
36
|
+
export declare function dateValue(fields: {
|
|
37
|
+
year: number;
|
|
38
|
+
month: number;
|
|
39
|
+
day: number;
|
|
40
|
+
}): ParsedValue;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Which day a week starts on and which days are the weekend. Days count from 0, Sunday, the way `Date#getDay` does. */
|
|
2
|
+
export interface WeekInfo {
|
|
3
|
+
firstDay: number;
|
|
4
|
+
weekend: readonly number[];
|
|
5
|
+
}
|
|
6
|
+
/** The locale's week, from `Intl.Locale#getWeekInfo` where the engine has it and from CLDR's table where it does not. */
|
|
7
|
+
export declare function weekInfo(locale?: string): WeekInfo;
|
|
8
|
+
/** Whether the locale reads the clock in 12 hours or 24. */
|
|
9
|
+
export declare function hourCycleOf(locale?: string): 12 | 24;
|
|
10
|
+
/** January first, in the locale's words. */
|
|
11
|
+
export declare function monthNames(locale?: string, style?: 'long' | 'short' | 'narrow'): string[];
|
|
12
|
+
/** Sunday first — rotate by `weekInfo().firstDay` for the order the locale reads a week in. */
|
|
13
|
+
export declare function weekdayNames(locale?: string, style?: 'long' | 'short' | 'narrow'): string[];
|
|
14
|
+
/** The locale's words for AM and PM. */
|
|
15
|
+
export declare function dayPeriodNames(locale?: string): [string, string];
|
|
16
|
+
/** What the locale calls a date field — `Jahr`, `месяц`, `hour` — for naming a segment to a screen reader. */
|
|
17
|
+
export declare function fieldName(field: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'timeZoneName', locale?: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DateKind } from './iso';
|
|
2
|
+
import { DateInput, ZoneOptions } from './value';
|
|
3
|
+
export interface ParseOptions extends ZoneOptions {
|
|
4
|
+
/** What to hand back. Default: whatever the input turned out to be — a date, a time, a date-time or an instant. */
|
|
5
|
+
kind?: DateKind;
|
|
6
|
+
/** Whose order `03/04/2026` is read in. Default the configured locale, or the runtime's. */
|
|
7
|
+
locale?: string;
|
|
8
|
+
/** What fills in a year the text leaves out, and the century of a two-digit one. Default today. */
|
|
9
|
+
reference?: DateInput;
|
|
10
|
+
}
|
|
11
|
+
type Order = ('year' | 'month' | 'day')[];
|
|
12
|
+
/** The order the locale writes a numeric date in: `day month year` in Moldova, `month day year` in the US. */
|
|
13
|
+
export declare function dateOrder(locale: string): Order;
|
|
14
|
+
/**
|
|
15
|
+
* Reads whatever a person or a system wrote down: ISO 8601 in any of its spellings, a `Date`, epoch
|
|
16
|
+
* milliseconds, an HTTP date, or text in the locale's own order (`19.10.2026 14:30`, `10/19/2026 2:30 PM`,
|
|
17
|
+
* `19 oct 2026`, `tomorrow`). Hands back the canonical string for `kind`, or `null`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parse(input: DateInput, options?: ParseOptions): string | null;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What the date layer falls back on when a call names no locale and no zone. */
|
|
2
|
+
export interface DateSettings {
|
|
3
|
+
/** A BCP 47 tag. Unset, the runtime's own default — the browser's language, or the server's. */
|
|
4
|
+
locale?: string;
|
|
5
|
+
/**
|
|
6
|
+
* The reader's IANA zone, when the runtime is not the reader. Unset, `'local'` means the runtime's own
|
|
7
|
+
* zone: the browser's in a browser and the server's on a server. A server that knows the reader's zone —
|
|
8
|
+
* from the cookie `zoneCookie()` writes — sets it here, or passes it to the call.
|
|
9
|
+
*/
|
|
10
|
+
timeZone?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Merges into what is set; `undefined` clears one key. Returns what was set before, so a test can put it back. */
|
|
13
|
+
export declare function configureDates(next: DateSettings): DateSettings;
|
|
14
|
+
export declare function dateSettings(): Readonly<DateSettings>;
|
|
15
|
+
/** The runtime's own IANA zone: the browser's, or the server's — `process.env.TZ`, which is UTC in most containers. */
|
|
16
|
+
export declare function systemZone(): string;
|
|
17
|
+
/** The reader's zone: the configured one, or the runtime's. */
|
|
18
|
+
export declare function localZone(): string;
|
|
19
|
+
export declare function systemLocale(): string;
|
|
20
|
+
export declare function defaultLocale(): string;
|
|
21
|
+
/** Forgets the runtime's zone and locale, for a test that changes `TZ` under a running process. */
|
|
22
|
+
export declare function resetSystemCaches(): void;
|
|
23
|
+
/** A `document.cookie` string carrying the browser's zone, so a server rendering the next request can read it. */
|
|
24
|
+
export declare function zoneCookie(zone?: string, name?: string): string;
|
|
25
|
+
/** The zone out of a `Cookie` header, or `undefined` — the server half of `zoneCookie()`. */
|
|
26
|
+
export declare function readZoneCookie(header: string | null | undefined, name?: string): string | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DateTimeFields } from './calendar';
|
|
2
|
+
import { DateKind, ParsedValue } from './iso';
|
|
3
|
+
import { Disambiguation, ZoneInput } from './zones';
|
|
4
|
+
/** Anything the date layer reads: an ISO string, a `Date`, or epoch milliseconds. `null` and `undefined` read as nothing. */
|
|
5
|
+
export type DateInput = string | number | Date | null | undefined;
|
|
6
|
+
export interface ZoneOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The zone a wall clock is read or written in. Default `'local'` — the reader's zone in a browser, and on
|
|
9
|
+
* a server the configured one (`configureDates({ timeZone })`) or the server's own.
|
|
10
|
+
*/
|
|
11
|
+
zone?: ZoneInput;
|
|
12
|
+
/** What a wall-clock time a zone skips or repeats means. Default `'compatible'`. */
|
|
13
|
+
disambiguation?: Disambiguation;
|
|
14
|
+
}
|
|
15
|
+
/** An instant re-expressed in `zone`: same moment, that zone's wall clock and offset. */
|
|
16
|
+
export declare function instantIn(epoch: number, zone: string): ParsedValue;
|
|
17
|
+
/**
|
|
18
|
+
* Takes any input apart. A string is ISO 8601 / RFC 3339 / RFC 9557, or — for what a server or a mail header
|
|
19
|
+
* writes (`Mon, 19 Oct 2026 14:30:00 GMT`) — whatever `Date.parse` reads, as long as it names its offset.
|
|
20
|
+
*/
|
|
21
|
+
export declare function read(input: DateInput, disambiguation?: Disambiguation): ParsedValue | null;
|
|
22
|
+
/** An instant written in UTC (`…Z`) with no zone named: the shape a `Date`, a server and JSON all write. */
|
|
23
|
+
export declare function utcInstant(epoch: number): ParsedValue;
|
|
24
|
+
/**
|
|
25
|
+
* The zone an instant is read in: the one asked for, the one it names in brackets, or the reader's. Its offset alone
|
|
26
|
+
* does not name a zone — `…Z` from a server is a moment, not a statement about where anybody is.
|
|
27
|
+
*/
|
|
28
|
+
export declare function zoneOf(value: ParsedValue, zone?: ZoneInput): string;
|
|
29
|
+
/** A result written the way its input was: `…Z` stays `…Z`, anything else takes the zone it was worked out in. */
|
|
30
|
+
export declare function written(source: ParsedValue, epoch: number, zone: string): ParsedValue;
|
|
31
|
+
/**
|
|
32
|
+
* A value as another kind, in `zone` — the one conversion everything else is written on. Returns `null` for a
|
|
33
|
+
* conversion with nothing to go on: a time has no date, so it has no instant either.
|
|
34
|
+
*/
|
|
35
|
+
export declare function convert(value: ParsedValue, kind: DateKind, options?: ZoneOptions): ParsedValue | null;
|
|
36
|
+
/** The canonical string for any input as `kind`, or `null`. */
|
|
37
|
+
export declare function as(input: DateInput, kind: DateKind, options?: ZoneOptions): string | null;
|
|
38
|
+
/** The epoch an input names — a date is its midnight and a date-time its wall clock, both in `zone`. */
|
|
39
|
+
export declare function epochFor(value: ParsedValue, options?: ZoneOptions): number | null;
|
|
40
|
+
/** The wall clock a value shows: its own fields, or for an instant the fields in `zone`. */
|
|
41
|
+
export declare function wallOf(value: ParsedValue, zone?: ZoneInput): DateTimeFields;
|
|
42
|
+
/** A value of the same kind built from a new wall clock, re-resolved in its zone when it is an instant. */
|
|
43
|
+
export declare function withWall(value: ParsedValue, fields: DateTimeFields, options?: ZoneOptions): ParsedValue;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** One zone as a list offers it. */
|
|
2
|
+
export interface ZoneOption {
|
|
3
|
+
/** The IANA name, `Europe/Chisinau` — the value. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The place, `Chisinau`, which is what people look for. */
|
|
6
|
+
city: string;
|
|
7
|
+
/** The part before the place, `Europe`. */
|
|
8
|
+
region: string;
|
|
9
|
+
/** Minutes east of UTC right now. */
|
|
10
|
+
offset: number;
|
|
11
|
+
/** `UTC+03:00`. */
|
|
12
|
+
offsetText: string;
|
|
13
|
+
/** The label a list shows and searches: `Chisinau (UTC+03:00)`. */
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
/** Every zone, or those given, with the offset each is at `at` — ordered west to east, then by place. */
|
|
17
|
+
export declare function zoneOptions(zones?: readonly string[], at?: number): ZoneOption[];
|
|
18
|
+
/** Matches a query against the place, the region, the IANA name and the offset, so `chis`, `europe` and `+3` all find Chisinau. */
|
|
19
|
+
export declare function matchZone(option: ZoneOption, query: string): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DateTimeFields } from './calendar';
|
|
2
|
+
/**
|
|
3
|
+
* Where a zone input points: `'local'` is the reader (`localZone()`), `'system'` the runtime, `'utc'` UTC,
|
|
4
|
+
* and anything else an IANA name (`'Europe/Chisinau'`) or a fixed offset (`'+03:00'`).
|
|
5
|
+
*/
|
|
6
|
+
export type ZoneInput = 'local' | 'system' | 'utc' | (string & {});
|
|
7
|
+
/**
|
|
8
|
+
* What to do with a wall-clock time a zone skips or repeats — Temporal's four answers. `'compatible'` takes
|
|
9
|
+
* the later reading of a skipped time and the earlier of a repeated one, which is what every OS does.
|
|
10
|
+
*/
|
|
11
|
+
export type Disambiguation = 'compatible' | 'earlier' | 'later' | 'reject';
|
|
12
|
+
/** Minutes east of UTC for a fixed offset (`'+03:00'`, `'-0530'`), or `undefined` for anything else. */
|
|
13
|
+
export declare function fixedOffset(zone: string): number | undefined;
|
|
14
|
+
/** `+03:00`, `-05:30`, `+00:00`. A historical offset carrying seconds keeps them. */
|
|
15
|
+
export declare function formatOffset(minutes: number): string;
|
|
16
|
+
/** The zone an input resolves to: `'UTC'`, a fixed offset in `+hh:mm` form, an IANA name — or `null` for nonsense. */
|
|
17
|
+
export declare function normalizeZone(zone: ZoneInput | undefined): string | null;
|
|
18
|
+
export declare function isValidZone(zone: string): boolean;
|
|
19
|
+
/** `normalizeZone`, with nonsense as an error rather than a `null` to forget about. */
|
|
20
|
+
export declare function requireZone(zone: ZoneInput | undefined): string;
|
|
21
|
+
/** Minutes east of UTC that `zone` is at `epoch` — `+180` for Chisinau in summer, `-240` for New York. */
|
|
22
|
+
export declare function offsetAt(zone: string, epoch: number): number;
|
|
23
|
+
/** The wall clock `zone` shows at `epoch`. */
|
|
24
|
+
export declare function wallAt(zone: string, epoch: number): DateTimeFields;
|
|
25
|
+
/**
|
|
26
|
+
* The instant a wall-clock time names in `zone`. A day either side of it brackets every offset the zone could
|
|
27
|
+
* be at, so the candidates are at most two: none in a spring-forward gap, two in a fall-back overlap.
|
|
28
|
+
* Returns `null` only for `'reject'` on a time that is skipped or repeated.
|
|
29
|
+
*/
|
|
30
|
+
export declare function wallToEpoch(fields: DateTimeFields, zone: string, disambiguation?: Disambiguation): number | null;
|
|
31
|
+
/** Every IANA zone the runtime knows, `UTC` first. */
|
|
32
|
+
export declare function timeZones(): readonly string[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElementLike } from '../dom/domUtils';
|
|
2
|
+
/**
|
|
3
|
+
* The element that scrolls `value` into view, or `null` for the page: the nearest ancestor that scrolls and has
|
|
4
|
+
* something to scroll. Both halves count — `overflow-x: hidden` alone computes `overflow-y` to `auto`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function scrollParentOf(value: ElementLike): HTMLElement | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Where an item sat when a drag began, relative to the list: its top edge and its height, in px. */
|
|
2
|
+
export interface SortableSlot {
|
|
3
|
+
top: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The model behind `<SortableList>`: which slot a dragged item is over, how far its neighbours step aside
|
|
8
|
+
* to make room, and the keyboard's moves. The slots are read once, when the drag starts, so every answer
|
|
9
|
+
* is about the layout the person is looking at rather than one that moves under the pointer.
|
|
10
|
+
*/
|
|
11
|
+
declare namespace SortableUtils {
|
|
12
|
+
/** How far a press on a handle travels before it is a drag rather than a press, in px. */
|
|
13
|
+
const SLOP = 4;
|
|
14
|
+
/** The index the held item would be dropped at, having travelled `travel` px from slot `from`. */
|
|
15
|
+
function targetIndex(slots: readonly SortableSlot[], from: number, travel: number): number;
|
|
16
|
+
/** What the held item takes up in the list: its height and the gap after it, which is what a neighbour steps by. */
|
|
17
|
+
function pitchOf(slots: readonly SortableSlot[], from: number): number;
|
|
18
|
+
/** How far the item at `index` steps aside while the item from `from` is held over `to`. */
|
|
19
|
+
function shiftOf(slots: readonly SortableSlot[], from: number, to: number, index: number): number;
|
|
20
|
+
/** `array` with the entry at `from` moved to `to`, everything between stepping along by one. A new array. */
|
|
21
|
+
function move<T>(array: readonly T[], from: number, to: number): T[];
|
|
22
|
+
/** Where a key moves the held item in a list of `count`, or `null` when the key is not a move. A vertical list, so the block axis. */
|
|
23
|
+
function keyTarget(key: string, index: number, count: number): number | null;
|
|
24
|
+
}
|
|
25
|
+
export default SortableUtils;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Which tray a swipe reveals: `start` sits under the inline start edge, so in a left-to-right page a swipe to the right shows it. */
|
|
2
|
+
export type SwipeSide = 'start' | 'end';
|
|
3
|
+
/** How wide each tray is when it is fully open, in px. `0` is a side with no actions, which a swipe cannot open. */
|
|
4
|
+
export interface SwipeTrays {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
/** Where a released swipe comes to rest: open on one side, closed, or carried through to the outermost action. */
|
|
9
|
+
export interface SwipeRest {
|
|
10
|
+
open: SwipeSide | null;
|
|
11
|
+
full: SwipeSide | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The model behind `<SwipeItem>`. Every offset here is **logical**: positive moves the content towards the
|
|
15
|
+
* inline end and reveals the `start` tray, so the arithmetic is the same in a right-to-left page and only
|
|
16
|
+
* the component turns it back into a physical translate. No DOM and no React — a swipe is numbers.
|
|
17
|
+
*/
|
|
18
|
+
declare namespace SwipeUtils {
|
|
19
|
+
/** How far a press travels before it is a gesture at all, in px — under it, a press is a tap. */
|
|
20
|
+
const SLOP = 8;
|
|
21
|
+
/** A release faster than this, in px per ms, is a flick: it goes the way it was going, however far it got. */
|
|
22
|
+
const FLICK = 0.4;
|
|
23
|
+
/** How much of the item a full swipe has to cross before letting go performs the outermost action. */
|
|
24
|
+
const FULL_RATIO = 0.6;
|
|
25
|
+
/**
|
|
26
|
+
* What a press is once it has moved past the slop: a swipe when it went more sideways than up or down,
|
|
27
|
+
* otherwise a scroll the page owns. `null` until then.
|
|
28
|
+
*/
|
|
29
|
+
function intent(dx: number, dy: number): 'swipe' | 'scroll' | null;
|
|
30
|
+
/** The offset for a press that started at `rest` and has travelled `travel` along the reading order. */
|
|
31
|
+
function offsetFor(rest: number, travel: number, trays: SwipeTrays, width: number, fullSwipe: boolean): number;
|
|
32
|
+
/** The side whose outermost action a release would perform, or `null` when it has not been carried far enough. */
|
|
33
|
+
function armed(offset: number, trays: SwipeTrays, width: number, fullSwipe: boolean): SwipeSide | null;
|
|
34
|
+
/**
|
|
35
|
+
* Where a release settles. A flick goes the way it was moving; otherwise a tray past half open opens and
|
|
36
|
+
* one short of it closes — the rule every platform swipe follows, because the eye judges halfway.
|
|
37
|
+
*/
|
|
38
|
+
function settle(offset: number, velocity: number, trays: SwipeTrays, width: number, fullSwipe: boolean): SwipeRest;
|
|
39
|
+
/** A pointer sample: when, in ms, and where along the line, in px. */
|
|
40
|
+
interface Sample {
|
|
41
|
+
t: number;
|
|
42
|
+
x: number;
|
|
43
|
+
}
|
|
44
|
+
/** How far back a release looks to judge its speed: the last tenth of a second is the flick, not the whole drag. */
|
|
45
|
+
const VELOCITY_WINDOW = 100;
|
|
46
|
+
/** The samples worth keeping once `next` arrives: those inside the window, and `next`. */
|
|
47
|
+
function track(samples: readonly Sample[], next: Sample): Sample[];
|
|
48
|
+
/** The speed along the line at release, in px per ms. Under a frame of samples is no measurement at all, so `0`. */
|
|
49
|
+
function velocity(samples: readonly Sample[]): number;
|
|
50
|
+
/** The offset a tray rests at: its whole width, towards the side it is on. */
|
|
51
|
+
function restOffset(open: SwipeSide | null, trays: SwipeTrays): number;
|
|
52
|
+
}
|
|
53
|
+
export default SwipeUtils;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VirtualWindow } from './virtualUtils';
|
|
2
|
+
/**
|
|
3
|
+
* Windowing for a list whose rows each have their own height — `<VirtualList>`'s, where `VirtualUtils` is the
|
|
4
|
+
* fixed pitch a listbox has. Its own module so neither consumer carries the other's arithmetic.
|
|
5
|
+
*/
|
|
6
|
+
declare namespace MeasuredWindow {
|
|
7
|
+
/** Rows either side of the screen when the caller names none. */
|
|
8
|
+
const DEFAULT_OVERSCAN = 4;
|
|
9
|
+
/** How far a focused row outside the window may be from it and still be kept rendered, so focus is not dropped. */
|
|
10
|
+
const PIN_REACH = 50;
|
|
11
|
+
/** Where each row of a list whose rows differ in height starts: `count + 1` entries, the last being the total. */
|
|
12
|
+
function offsetsOf(sizes: readonly number[]): number[];
|
|
13
|
+
/** What a row not yet drawn counts as: the mean of the rows that have been, or `fallback` before any has. */
|
|
14
|
+
function typicalSize(sizes: Iterable<number>, fallback: number): number;
|
|
15
|
+
interface MeasuredWindowOptions {
|
|
16
|
+
/** From `offsetsOf`. */
|
|
17
|
+
offsets: readonly number[];
|
|
18
|
+
/** The part of the list on screen, in px from the list's own top edge. Either end may be outside the list. */
|
|
19
|
+
viewStart: number;
|
|
20
|
+
viewEnd: number;
|
|
21
|
+
overscan?: number;
|
|
22
|
+
/** A row that has to stay rendered — the one focus is in — or `-1`. */
|
|
23
|
+
pin?: number;
|
|
24
|
+
}
|
|
25
|
+
/** The rows to render for a list whose rows each have their own height, and the space above and below them. */
|
|
26
|
+
function measuredWindow(options: MeasuredWindowOptions): VirtualWindow;
|
|
27
|
+
}
|
|
28
|
+
export default MeasuredWindow;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Where each row starts, ascending: an array, or a list that computes an entry when it is asked for one. */
|
|
2
|
+
export type RowTops = {
|
|
3
|
+
readonly length: number;
|
|
4
|
+
readonly [index: number]: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The row a point `y` falls in — the last of the first `count` rows that starts at or above it — clamped
|
|
8
|
+
* to the list. A binary search, since a scroll asks on every frame and a datasource grid lays out a million
|
|
9
|
+
* rows it never allocates. `DataGrid` and `VirtualList` both window through it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rowAt(tops: RowTops, y: number, count?: number): number;
|