@quickbuilder.io/date-pickers 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +167 -2
- package/dist/DatePickersLocalization-DAGwd4hM.d.mts +200 -0
- package/dist/DatePickersLocalization-DAGwd4hM.d.ts +200 -0
- package/dist/chunk-SIFVGHXY.mjs +108 -0
- package/dist/chunk-SIFVGHXY.mjs.map +1 -0
- package/dist/chunk-XMJPY2BR.js +120 -0
- package/dist/chunk-XMJPY2BR.js.map +1 -0
- package/dist/index.d.mts +588 -0
- package/dist/index.d.ts +588 -0
- package/dist/index.js +951 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +893 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react-native.d.mts +654 -0
- package/dist/react-native.d.ts +654 -0
- package/dist/react-native.js +1761 -0
- package/dist/react-native.js.map +1 -0
- package/dist/react-native.mjs +1721 -0
- package/dist/react-native.mjs.map +1 -0
- package/dist/react.d.mts +531 -0
- package/dist/react.d.ts +531 -0
- package/dist/react.js +1885 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +1794 -0
- package/dist/react.mjs.map +1 -0
- package/dist/runtime.d.mts +3 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +37 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.mjs +4 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +140 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Quick Builder contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,168 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @quickbuilder.io/date-pickers
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Date, time, and date-time fields and calendars for React and React Native. Includes framework-neutral utilities for timezone conversion, validation, and persistence.
|
|
4
|
+
|
|
5
|
+
~~~sh
|
|
6
|
+
npm install @quickbuilder.io/date-pickers
|
|
7
|
+
~~~
|
|
8
|
+
|
|
9
|
+
| Import | Use |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `@quickbuilder.io/date-pickers` | Timezone conversion and persisted picker values |
|
|
12
|
+
| `@quickbuilder.io/date-pickers/react` | Web pickers, localization, and date adapters |
|
|
13
|
+
| `@quickbuilder.io/date-pickers/react-native` | Native pickers, localization, and date adapters |
|
|
14
|
+
|
|
15
|
+
Install the matching React peer dependencies for your platform. The neutral entry can run on Node.js without React. Range pickers are available through `@quickbuilder.io/date-pickers-pro`.
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
The pickers share validation and localization across platforms and use each platform's Quick Builder design-system components.
|
|
20
|
+
|
|
21
|
+
The implementation composes:
|
|
22
|
+
|
|
23
|
+
- `DatePicker` from `@quickbuilder.io/design-system/react`
|
|
24
|
+
- `TimeInput` from `@quickbuilder.io/design-system/react`
|
|
25
|
+
- `Calendar` from `@quickbuilder.io/design-system/react`
|
|
26
|
+
- Input, Dropdown, Popover and Button for a single combined date-time field
|
|
27
|
+
|
|
28
|
+
### Date and time fields
|
|
29
|
+
|
|
30
|
+
On the web, press Enter or leave the date field to accept typed text. Choosing a calendar day applies it immediately. A malformed or unavailable date stays editable, blocks native form submission and preserves the last accepted value. Clearing the field emits `null`. The calendar and typed input use the same inclusive bounds, disabled-day predicate and picker-local day for past/future checks. An uncontrolled field restores its default on form reset. Use `slots.calendar` to customize the calendar and `slotProps.calendar` for its presentation. The field owns the selection and month navigation.
|
|
31
|
+
|
|
32
|
+
`TimePicker` applies its bounds and past/future checks to the clock time in the picker timezone at minute precision. Invalid times report the failed constraint and display an associated error. Date and time fields accept a provider timezone on web and native. Supply valid adapter values for bounds and a supported locale for display.
|
|
33
|
+
|
|
34
|
+
## Single-input date and time
|
|
35
|
+
|
|
36
|
+
DateTimePicker has one editable, labelled input and one selection panel. It composes the design-system Input, Calendar, Dropdown, Button and Popover. All colors, spacing, focus rings, disabled states and overlay motion follow the active design-system provider.
|
|
37
|
+
|
|
38
|
+
~~~tsx
|
|
39
|
+
import { DateTimePicker } from '@quickbuilder.io/date-pickers/react';
|
|
40
|
+
|
|
41
|
+
<DateTimePicker
|
|
42
|
+
label="Appointment"
|
|
43
|
+
value={appointment}
|
|
44
|
+
onChange={setAppointment}
|
|
45
|
+
timezone="America/New_York"
|
|
46
|
+
minutesStep={15}
|
|
47
|
+
minDateTime={earliestAppointment}
|
|
48
|
+
required
|
|
49
|
+
/>
|
|
50
|
+
~~~
|
|
51
|
+
|
|
52
|
+
Type the localized numeric date and time, then press Enter or leave the field to commit. Arrow Down or the calendar button opens the panel. Date and time selections are drafts until Apply; Cancel, Escape, Tab out, or an outside click dismisses the draft. Clear removes the whole value. Calendar navigation and time selection retain their owned keyboard behavior. The panel fits narrow viewports and stays in the provider's theme.
|
|
53
|
+
|
|
54
|
+
Controlled value and uncontrolled defaultValue accept adapter values or null. referenceDate controls the initial calendar/time of an empty field. A native form reset restores the uncontrolled default; controlled forms reset their own state. Native FormData contains localized text. Persist the adapter value from onChange instead. The field has minute precision; changed values have zero seconds and milliseconds.
|
|
55
|
+
|
|
56
|
+
Validation applies equally to typing and picking:
|
|
57
|
+
- minDate/maxDate bound calendar days; minTime/maxTime bound daily times.
|
|
58
|
+
- minDateTime/maxDateTime bound actual instants, including boundary-day times.
|
|
59
|
+
- disablePast/disableFuture compare with the current instant.
|
|
60
|
+
- shouldDisableDate/shouldDisableTime receive timezone-local display dates.
|
|
61
|
+
- minutesStep defaults to 1 and must be a positive divisor of 60.
|
|
62
|
+
- Invalid text remains editable, displays an associated error and blocks native form submission. It never replaces the accepted value.
|
|
63
|
+
- onError reports DateTimePickerValidationError codes; validationMessage translates the inline message. onChange reports accepted values (or null on clear); onAccept runs for Apply.
|
|
64
|
+
- Invalid configuration throws instead of silently changing a supplied constraint.
|
|
65
|
+
|
|
66
|
+
Locale and calendar-system parsing use the same public design-system calendar contract. hour12 defaults to the locale. Timezone values use provider/system defaults or an explicit IANA zone. Skipped daylight-saving times are rejected. Repeated times are rejected by default; disambiguation="earlier" or "later" selects an explicit occurrence. No vendor date runtime is loaded.
|
|
67
|
+
|
|
68
|
+
disabled, readOnly and status="loading" prevent picker mutation. open/defaultOpen/onOpenChange control panel visibility. Input sizing, borders, labels, helper text, required, form and name use the existing design-system Input props. localeText translates panel labels.
|
|
69
|
+
|
|
70
|
+
The single-input API replaces orientation, timeLabel, timePickerProps and the two-field datePicker/timePicker slots. Consumers use direct constraint props and localeText.timeLabel. There is one implementation; DateTimeRangePicker composes it for both endpoints.
|
|
71
|
+
|
|
72
|
+
## Localization and adapters
|
|
73
|
+
|
|
74
|
+
`DatePickersLocalizationProvider` owns package-level localization for picker components. It accepts:
|
|
75
|
+
|
|
76
|
+
- `adapterLocale` for locale-aware design-system formatting and parsing
|
|
77
|
+
- `localeText` for translatable picker labels
|
|
78
|
+
- `dateAdapter` for non-native date value types
|
|
79
|
+
- `dateLibInstance` and `timezone` for explicit caller-supplied adapter interoperability
|
|
80
|
+
|
|
81
|
+
The core package ships the owned `AdapterNativeDate`, typed interoperability bridges for Day.js, date-fns, Luxon, and Moment value shapes, and a typed adapter contract for custom date values. Quick Builder does not declare, install, import, dynamically load, or fall back to those vendor libraries. An application that deliberately interoperates with an existing vendor date value may pass its own runtime through `dateLibInstance`; the Quick Builder application itself uses the owned native adapter.
|
|
82
|
+
|
|
83
|
+
Timezone-aware rendering and value conversion are implemented for `UTC`, `system`, `default`, and IANA zones such as `America/New_York`. Picker controls receive timezone-local display dates, and changes are converted back to stored instants before `onChange` fires.
|
|
84
|
+
|
|
85
|
+
`getZonedCivilTimestamp(instant, timezone)` encodes the local calendar fields of an instant as UTC milliseconds for calendar arithmetic. Pass the result to `resolveZonedCivilTimestamp(timestamp, timezone, disambiguation)` to resolve those fields in the named timezone. A nonexistent clock returns `nonexistentTime`. A repeated clock follows the supplied `earlier`, `later`, or `reject` policy.
|
|
86
|
+
|
|
87
|
+
`addZonedCalendarDays(instant, days, timezone)` moves a known instant by whole calendar days in the specified IANA zone. Zero days preserves the selected instant, including its occurrence in a repeated hour. For other days the result contains either the matching instant or a `nonexistentTime` or `ambiguousTime` error.
|
|
88
|
+
|
|
89
|
+
Non-Gregorian calendar-system adapter bridges are implemented for:
|
|
90
|
+
|
|
91
|
+
- `AdapterDateFnsJalali`
|
|
92
|
+
- `AdapterMomentJalaali`
|
|
93
|
+
- `AdapterMomentHijri`
|
|
94
|
+
- `AdapterDayjsBuddhist`
|
|
95
|
+
|
|
96
|
+
The design-system `DatePicker`, `Calendar`, and `CalendarPanel` expose a `calendarSystem` contract for `gregory`, `jalali`, `hijri`, and `buddhist`. Field parsing, field formatting, month labels, year labels, weekdays, day numbers, date aria labels, visible month boundaries, outside-day detection, navigation, and month/year dropdown targets render through the matching calendar system while preserving Quick Builder styling and primitives.
|
|
97
|
+
|
|
98
|
+
## Exports
|
|
99
|
+
|
|
100
|
+
- `DatePicker`
|
|
101
|
+
- `TimePicker`
|
|
102
|
+
- `DateTimePicker`
|
|
103
|
+
- `DateCalendar`
|
|
104
|
+
- `DatePickersLocalizationProvider`
|
|
105
|
+
- `AdapterNativeDate`
|
|
106
|
+
- `AdapterDateFns`
|
|
107
|
+
- `AdapterDateFnsJalali`
|
|
108
|
+
- `AdapterDayjs`
|
|
109
|
+
- `AdapterDayjsBuddhist`
|
|
110
|
+
- `AdapterLuxon`
|
|
111
|
+
- `AdapterMoment`
|
|
112
|
+
- `AdapterMomentHijri`
|
|
113
|
+
- `AdapterMomentJalaali`
|
|
114
|
+
- `createDatePickerAdapter`
|
|
115
|
+
- calendar-system adapter utilities
|
|
116
|
+
- timezone conversion utilities, including framework-neutral `resolveDateTimeInstant(displayDate, timezone, disambiguation)` for strict civil-time resolution. It returns `nonexistentTime` for skipped clocks and `ambiguousTime` for repeated clocks with `reject`; use `earlier` or `later` explicitly to choose a repeated instant. Invalid dates, zones, and disambiguation options throw.
|
|
117
|
+
- `datePickerCapabilityFeatures`
|
|
118
|
+
- validation and date composition utilities
|
|
119
|
+
|
|
120
|
+
## Native adapter and contract
|
|
121
|
+
|
|
122
|
+
`@quickbuilder.io/date-pickers/react-native` exports DatePicker, TimePicker,
|
|
123
|
+
DateTimePicker, DateCalendar and DatePickersLocalizationProvider. The provider and
|
|
124
|
+
validation engine are shared with React; native controls compose the native DS.
|
|
125
|
+
The neutral support matrix declares React and React Native implemented, and
|
|
126
|
+
Vue, Preact, Qwik, Astro, Svelte, Solid and Web Components unsupported without
|
|
127
|
+
advertising adapter entrypoints for them.
|
|
128
|
+
Fields expose the native design-system `shape` (sharp/soft/rounded/pill), `size`
|
|
129
|
+
(tiny/small/medium/large), and `description` props. The calendar/clock action is
|
|
130
|
+
inside the Input surface. Fields inherit Form/FormField appearance and locking
|
|
131
|
+
through the public `useFormFieldState` contract, including the inline opener.
|
|
132
|
+
Values are controlled adapter values. Typed input and the selection panel share
|
|
133
|
+
constraints; invalid input stays visible, the confirmation action commits, dismissing
|
|
134
|
+
discards pending selection, and Clear emits null when permitted. Locale, calendar system, timezone, minute steps and
|
|
135
|
+
DST ambiguity use the owning codec, not an OS parser guess.
|
|
136
|
+
Minimum and maximum bounds must be valid and ordered, including daily times and absolute instants.
|
|
137
|
+
|
|
138
|
+
Native DatePicker additionally accepts `dateFormat="medium"` for a localized
|
|
139
|
+
abbreviated month (for example, Nov 3, 2026); `numeric` remains the default.
|
|
140
|
+
Typing, calendar selection, locale changes and validation use the same owned
|
|
141
|
+
calendar parser. TimePicker and DateTimePicker retain their numeric codec and
|
|
142
|
+
reject an explicit dateFormat.
|
|
143
|
+
|
|
144
|
+
Native DatePicker opens the owned floating BottomSheet with a selection header,
|
|
145
|
+
a fixed confirmation action, aligned short weekday labels, six week rows and a
|
|
146
|
+
compact circular selected day. Adjacent-month dates use subdued theme text;
|
|
147
|
+
disabled days remain blocked by the shared validation engine. Month arrows and
|
|
148
|
+
the month/year selector navigate without committing a value. `showLabel=false`
|
|
149
|
+
hides a standalone calendar's repeated visual heading inside a labeled panel.
|
|
150
|
+
`pickerTitle` and `confirmationLabel` accept nonempty localized labels for the
|
|
151
|
+
panel; business payment fields use “Select expiration date” and “Done”. Supply
|
|
152
|
+
`bottomInset` from the shell's safe-area owner to keep floating panels above the
|
|
153
|
+
system gesture bar; an explicit zero remains zero. Back,
|
|
154
|
+
backdrop and downward header drag cancel pending choices. Optional Clear is
|
|
155
|
+
shown only when `clearable` is set and the field is not required. Editable fields
|
|
156
|
+
can also clear an optional value through empty text. TimePicker and DateTimePicker
|
|
157
|
+
retain their date/time dialog and validation-gated confirmation controls.
|
|
158
|
+
|
|
159
|
+
The neutral root additionally exports serializePickerDate, serializePickerTime,
|
|
160
|
+
serializePickerDateTime and parseStoredPickerValue. These produce and validate an
|
|
161
|
+
explicit version-1 JSON union for a civil date (YYYY-MM-DD), time (HH:mm), or UTC
|
|
162
|
+
instant with an explicit display timezone. Local times require minute precision.
|
|
163
|
+
Civil date years use local calendar fields. Stored instants support UTC years 0001 through 9999.
|
|
164
|
+
Do not apply these records to existing stored fields without an explicit schema
|
|
165
|
+
change and migration; mobile form authoring remains gated until its binding uses
|
|
166
|
+
the chosen durable contract.
|
|
167
|
+
|
|
168
|
+
The `/runtime` export contains only host-free React state/providers. Browser and native adapters share its context; it imports no platform UI. Use `/react-native` for native UI and its matching provider exports. Package tests check shared context identity and runtime dependencies in both module formats.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SupportedLocale } from '@quickbuilder.io/design-system/calendar';
|
|
3
|
+
|
|
4
|
+
type DatePickerTimezone = "default" | "system" | "UTC" | string;
|
|
5
|
+
declare function resolvePickerTimezone(timezone: DatePickerTimezone | undefined, providerTimezone?: DatePickerTimezone): string | undefined;
|
|
6
|
+
declare function toTimezoneDisplayDate(value: Date | null, timezone: string | undefined): Date | null;
|
|
7
|
+
declare function fromTimezoneDisplayDate(value: Date | null, timezone: string | undefined): Date | null;
|
|
8
|
+
declare function getSystemTimezone(): string;
|
|
9
|
+
declare function assertSupportedTimezone(timezone: string): void;
|
|
10
|
+
/** UTC-encoded calendar fields in the named zone, for civil arithmetic only. */
|
|
11
|
+
declare function getZonedCivilTimestamp(value: Date, timezone: string): number;
|
|
12
|
+
/** Enumerate zone offsets around a transition, including half-hour transitions. */
|
|
13
|
+
declare function resolveDateTimeInstant(value: Date, timezone: string | undefined, disambiguation: "earlier" | "later" | "reject"): {
|
|
14
|
+
date: null;
|
|
15
|
+
error: "nonexistentTime";
|
|
16
|
+
} | {
|
|
17
|
+
date: null;
|
|
18
|
+
error: "ambiguousTime";
|
|
19
|
+
} | {
|
|
20
|
+
date: Date;
|
|
21
|
+
error: null;
|
|
22
|
+
};
|
|
23
|
+
/** Keep the local clock when adding calendar days to a known instant. */
|
|
24
|
+
declare function addZonedCalendarDays(value: Date, days: number, timezone: string): {
|
|
25
|
+
date: Date;
|
|
26
|
+
error: null;
|
|
27
|
+
} | {
|
|
28
|
+
date: null;
|
|
29
|
+
error: "nonexistentTime";
|
|
30
|
+
} | {
|
|
31
|
+
date: null;
|
|
32
|
+
error: "ambiguousTime";
|
|
33
|
+
};
|
|
34
|
+
/** Resolve UTC-encoded civil fields in their own zone, independently of the host clock. */
|
|
35
|
+
declare function resolveZonedCivilTimestamp(target: number, timezone: string, disambiguation: "earlier" | "later" | "reject"): {
|
|
36
|
+
date: Date;
|
|
37
|
+
error: null;
|
|
38
|
+
} | {
|
|
39
|
+
date: null;
|
|
40
|
+
error: "nonexistentTime";
|
|
41
|
+
} | {
|
|
42
|
+
date: null;
|
|
43
|
+
error: "ambiguousTime";
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
interface DatePickerAdapterRuntimeOptions {
|
|
47
|
+
dateLibInstance?: unknown;
|
|
48
|
+
locale?: SupportedLocale | string;
|
|
49
|
+
timezone?: DatePickerTimezone;
|
|
50
|
+
}
|
|
51
|
+
interface DayjsDateValue {
|
|
52
|
+
format: (format?: string) => string;
|
|
53
|
+
isValid: () => boolean;
|
|
54
|
+
toDate: () => Date;
|
|
55
|
+
valueOf?: () => number;
|
|
56
|
+
}
|
|
57
|
+
interface DayjsFactory {
|
|
58
|
+
(value?: unknown, format?: string): DayjsDateValue;
|
|
59
|
+
}
|
|
60
|
+
interface DateFnsRuntime {
|
|
61
|
+
format?: (date: Date, format: string, options?: unknown) => string;
|
|
62
|
+
isValid?: (date: unknown) => boolean;
|
|
63
|
+
parse?: (value: string, format: string, referenceDate: Date, options?: unknown) => Date;
|
|
64
|
+
}
|
|
65
|
+
interface LuxonDateTimeValue {
|
|
66
|
+
isValid: boolean;
|
|
67
|
+
setLocale?: (locale: string) => LuxonDateTimeValue;
|
|
68
|
+
setZone?: (timezone: string) => LuxonDateTimeValue;
|
|
69
|
+
toFormat: (format: string) => string;
|
|
70
|
+
toJSDate: () => Date;
|
|
71
|
+
toMillis?: () => number;
|
|
72
|
+
}
|
|
73
|
+
interface LuxonDateTimeConstructor {
|
|
74
|
+
fromFormat?: (value: string, format: string, options?: unknown) => LuxonDateTimeValue;
|
|
75
|
+
fromISO: (value: string, options?: unknown) => LuxonDateTimeValue;
|
|
76
|
+
fromJSDate: (value: Date, options?: unknown) => LuxonDateTimeValue;
|
|
77
|
+
}
|
|
78
|
+
interface MomentDateValue {
|
|
79
|
+
format: (format?: string) => string;
|
|
80
|
+
isValid: () => boolean;
|
|
81
|
+
toDate: () => Date;
|
|
82
|
+
valueOf?: () => number;
|
|
83
|
+
}
|
|
84
|
+
interface MomentFactory {
|
|
85
|
+
(value?: unknown, format?: string): MomentDateValue;
|
|
86
|
+
}
|
|
87
|
+
declare class AdapterDateFns implements DatePickerAdapter<Date> {
|
|
88
|
+
private readonly options;
|
|
89
|
+
adapterName: DatePickerAdapterName | string;
|
|
90
|
+
private readonly runtime;
|
|
91
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
92
|
+
format(value: Date, formatKey?: string): string;
|
|
93
|
+
fromJsDate(value: Date): Date;
|
|
94
|
+
isEqual(left: Date | null, right: Date | null): boolean;
|
|
95
|
+
isValid(value: unknown): value is Date;
|
|
96
|
+
parse(value: string, formatKey?: string): Date | null;
|
|
97
|
+
toJsDate(value: Date): Date;
|
|
98
|
+
}
|
|
99
|
+
declare class AdapterDayjs implements DatePickerAdapter<DayjsDateValue> {
|
|
100
|
+
private readonly options;
|
|
101
|
+
adapterName: DatePickerAdapterName | string;
|
|
102
|
+
private readonly dayjs;
|
|
103
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
104
|
+
format(value: DayjsDateValue, formatKey?: string): string;
|
|
105
|
+
fromJsDate(value: Date): DayjsDateValue;
|
|
106
|
+
isEqual(left: DayjsDateValue | null, right: DayjsDateValue | null): boolean;
|
|
107
|
+
isValid(value: unknown): value is DayjsDateValue;
|
|
108
|
+
parse(value: string, formatKey?: string): DayjsDateValue | null;
|
|
109
|
+
toJsDate(value: DayjsDateValue): Date;
|
|
110
|
+
}
|
|
111
|
+
declare class AdapterLuxon implements DatePickerAdapter<LuxonDateTimeValue> {
|
|
112
|
+
private readonly options;
|
|
113
|
+
adapterName: DatePickerAdapterName | string;
|
|
114
|
+
private readonly dateTime;
|
|
115
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
116
|
+
format(value: LuxonDateTimeValue, formatKey?: string): string;
|
|
117
|
+
fromJsDate(value: Date): LuxonDateTimeValue;
|
|
118
|
+
isEqual(left: LuxonDateTimeValue | null, right: LuxonDateTimeValue | null): boolean;
|
|
119
|
+
isValid(value: unknown): value is LuxonDateTimeValue;
|
|
120
|
+
parse(value: string, formatKey?: string): LuxonDateTimeValue | null;
|
|
121
|
+
toJsDate(value: LuxonDateTimeValue): Date;
|
|
122
|
+
}
|
|
123
|
+
declare class AdapterMoment implements DatePickerAdapter<MomentDateValue> {
|
|
124
|
+
private readonly options;
|
|
125
|
+
adapterName: DatePickerAdapterName | string;
|
|
126
|
+
private readonly moment;
|
|
127
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
128
|
+
format(value: MomentDateValue, formatKey?: string): string;
|
|
129
|
+
fromJsDate(value: Date): MomentDateValue;
|
|
130
|
+
isEqual(left: MomentDateValue | null, right: MomentDateValue | null): boolean;
|
|
131
|
+
isValid(value: unknown): value is MomentDateValue;
|
|
132
|
+
parse(value: string, formatKey?: string): MomentDateValue | null;
|
|
133
|
+
toJsDate(value: MomentDateValue): Date;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
type PickerValidDate = unknown;
|
|
137
|
+
type DatePickerAdapterName = 'custom' | 'date-fns' | 'date-fns-jalali' | 'dayjs' | 'dayjs-buddhist' | 'luxon' | 'moment' | 'moment-hijri' | 'moment-jalaali' | 'native';
|
|
138
|
+
interface DatePickerLocaleText {
|
|
139
|
+
cancelButtonLabel: string;
|
|
140
|
+
applyButtonLabel: string;
|
|
141
|
+
timeLabel: string;
|
|
142
|
+
hoursLabel: string;
|
|
143
|
+
minutesLabel: string;
|
|
144
|
+
dayPeriodLabel: string;
|
|
145
|
+
nowButtonLabel: string;
|
|
146
|
+
clearButtonLabel: string;
|
|
147
|
+
datePickerToolbarTitle: string;
|
|
148
|
+
dateTimePickerToolbarTitle: string;
|
|
149
|
+
end: string;
|
|
150
|
+
okButtonLabel: string;
|
|
151
|
+
start: string;
|
|
152
|
+
timePickerToolbarTitle: string;
|
|
153
|
+
}
|
|
154
|
+
interface DatePickerAdapter<TDate = Date> {
|
|
155
|
+
adapterName: DatePickerAdapterName | string;
|
|
156
|
+
format: (value: TDate, formatKey?: string) => string;
|
|
157
|
+
fromJsDate: (value: Date) => TDate;
|
|
158
|
+
isEqual: (left: TDate | null, right: TDate | null) => boolean;
|
|
159
|
+
isValid: (value: unknown) => value is TDate;
|
|
160
|
+
parse: (value: string, formatKey?: string) => TDate | null;
|
|
161
|
+
toJsDate: (value: TDate) => Date;
|
|
162
|
+
}
|
|
163
|
+
declare function toPickerDate<TDate>(adapter: DatePickerAdapter<TDate>, value: TDate, name: string): Date;
|
|
164
|
+
type DatePickerAdapterConstructor<TDate = Date> = new (options?: DatePickerAdapterRuntimeOptions) => DatePickerAdapter<TDate>;
|
|
165
|
+
interface DatePickersLocalizationContextValue<TDate = Date> {
|
|
166
|
+
adapter: DatePickerAdapter<TDate>;
|
|
167
|
+
adapterLocale: SupportedLocale | string;
|
|
168
|
+
localeText: DatePickerLocaleText;
|
|
169
|
+
timezone?: DatePickerTimezone;
|
|
170
|
+
}
|
|
171
|
+
declare const defaultDatePickerLocaleText: DatePickerLocaleText;
|
|
172
|
+
declare function resolveDatePickerLocaleText(localeText?: Partial<DatePickerLocaleText>): DatePickerLocaleText;
|
|
173
|
+
declare class AdapterNativeDate implements DatePickerAdapter<Date> {
|
|
174
|
+
private readonly options;
|
|
175
|
+
adapterName: "native";
|
|
176
|
+
constructor(options?: {
|
|
177
|
+
locale?: SupportedLocale | string;
|
|
178
|
+
timezone?: string;
|
|
179
|
+
});
|
|
180
|
+
format(value: Date, formatKey?: string): string;
|
|
181
|
+
fromJsDate(value: Date): Date;
|
|
182
|
+
isEqual(left: Date | null, right: Date | null): boolean;
|
|
183
|
+
isValid(value: unknown): value is Date;
|
|
184
|
+
parse(value: string): Date | null;
|
|
185
|
+
toJsDate(value: Date): Date;
|
|
186
|
+
}
|
|
187
|
+
declare function createDatePickerAdapter<TDate>(adapter: DatePickerAdapter<TDate>): DatePickerAdapter<TDate>;
|
|
188
|
+
|
|
189
|
+
interface DatePickersLocalizationProviderProps<TDate = Date> {
|
|
190
|
+
adapterLocale?: SupportedLocale | string;
|
|
191
|
+
children: React.ReactNode;
|
|
192
|
+
dateAdapter?: DatePickerAdapter<TDate> | DatePickerAdapterConstructor<TDate>;
|
|
193
|
+
dateLibInstance?: unknown;
|
|
194
|
+
localeText?: Partial<DatePickerLocaleText>;
|
|
195
|
+
timezone?: DatePickerTimezone;
|
|
196
|
+
}
|
|
197
|
+
declare function DatePickersLocalizationProvider<TDate = Date>({ adapterLocale, children, dateAdapter, dateLibInstance, localeText, timezone, }: DatePickersLocalizationProviderProps<TDate>): React.JSX.Element;
|
|
198
|
+
declare function useDatePickersLocalization<TDate = Date>(): DatePickersLocalizationContextValue<TDate>;
|
|
199
|
+
|
|
200
|
+
export { AdapterDateFns as A, resolvePickerTimezone as B, resolveZonedCivilTimestamp as C, type DatePickerAdapter as D, toPickerDate as E, toTimezoneDisplayDate as F, useDatePickersLocalization as G, type LuxonDateTimeConstructor as L, type MomentDateValue as M, type PickerValidDate as P, type DatePickerAdapterRuntimeOptions as a, AdapterDayjs as b, type DayjsDateValue as c, AdapterMoment as d, type DatePickerLocaleText as e, type DatePickerTimezone as f, AdapterLuxon as g, AdapterNativeDate as h, type DateFnsRuntime as i, type DatePickerAdapterConstructor as j, type DatePickerAdapterName as k, type DatePickersLocalizationContextValue as l, DatePickersLocalizationProvider as m, type DatePickersLocalizationProviderProps as n, type DayjsFactory as o, type LuxonDateTimeValue as p, type MomentFactory as q, addZonedCalendarDays as r, assertSupportedTimezone as s, createDatePickerAdapter as t, defaultDatePickerLocaleText as u, fromTimezoneDisplayDate as v, getSystemTimezone as w, getZonedCivilTimestamp as x, resolveDatePickerLocaleText as y, resolveDateTimeInstant as z };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SupportedLocale } from '@quickbuilder.io/design-system/calendar';
|
|
3
|
+
|
|
4
|
+
type DatePickerTimezone = "default" | "system" | "UTC" | string;
|
|
5
|
+
declare function resolvePickerTimezone(timezone: DatePickerTimezone | undefined, providerTimezone?: DatePickerTimezone): string | undefined;
|
|
6
|
+
declare function toTimezoneDisplayDate(value: Date | null, timezone: string | undefined): Date | null;
|
|
7
|
+
declare function fromTimezoneDisplayDate(value: Date | null, timezone: string | undefined): Date | null;
|
|
8
|
+
declare function getSystemTimezone(): string;
|
|
9
|
+
declare function assertSupportedTimezone(timezone: string): void;
|
|
10
|
+
/** UTC-encoded calendar fields in the named zone, for civil arithmetic only. */
|
|
11
|
+
declare function getZonedCivilTimestamp(value: Date, timezone: string): number;
|
|
12
|
+
/** Enumerate zone offsets around a transition, including half-hour transitions. */
|
|
13
|
+
declare function resolveDateTimeInstant(value: Date, timezone: string | undefined, disambiguation: "earlier" | "later" | "reject"): {
|
|
14
|
+
date: null;
|
|
15
|
+
error: "nonexistentTime";
|
|
16
|
+
} | {
|
|
17
|
+
date: null;
|
|
18
|
+
error: "ambiguousTime";
|
|
19
|
+
} | {
|
|
20
|
+
date: Date;
|
|
21
|
+
error: null;
|
|
22
|
+
};
|
|
23
|
+
/** Keep the local clock when adding calendar days to a known instant. */
|
|
24
|
+
declare function addZonedCalendarDays(value: Date, days: number, timezone: string): {
|
|
25
|
+
date: Date;
|
|
26
|
+
error: null;
|
|
27
|
+
} | {
|
|
28
|
+
date: null;
|
|
29
|
+
error: "nonexistentTime";
|
|
30
|
+
} | {
|
|
31
|
+
date: null;
|
|
32
|
+
error: "ambiguousTime";
|
|
33
|
+
};
|
|
34
|
+
/** Resolve UTC-encoded civil fields in their own zone, independently of the host clock. */
|
|
35
|
+
declare function resolveZonedCivilTimestamp(target: number, timezone: string, disambiguation: "earlier" | "later" | "reject"): {
|
|
36
|
+
date: Date;
|
|
37
|
+
error: null;
|
|
38
|
+
} | {
|
|
39
|
+
date: null;
|
|
40
|
+
error: "nonexistentTime";
|
|
41
|
+
} | {
|
|
42
|
+
date: null;
|
|
43
|
+
error: "ambiguousTime";
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
interface DatePickerAdapterRuntimeOptions {
|
|
47
|
+
dateLibInstance?: unknown;
|
|
48
|
+
locale?: SupportedLocale | string;
|
|
49
|
+
timezone?: DatePickerTimezone;
|
|
50
|
+
}
|
|
51
|
+
interface DayjsDateValue {
|
|
52
|
+
format: (format?: string) => string;
|
|
53
|
+
isValid: () => boolean;
|
|
54
|
+
toDate: () => Date;
|
|
55
|
+
valueOf?: () => number;
|
|
56
|
+
}
|
|
57
|
+
interface DayjsFactory {
|
|
58
|
+
(value?: unknown, format?: string): DayjsDateValue;
|
|
59
|
+
}
|
|
60
|
+
interface DateFnsRuntime {
|
|
61
|
+
format?: (date: Date, format: string, options?: unknown) => string;
|
|
62
|
+
isValid?: (date: unknown) => boolean;
|
|
63
|
+
parse?: (value: string, format: string, referenceDate: Date, options?: unknown) => Date;
|
|
64
|
+
}
|
|
65
|
+
interface LuxonDateTimeValue {
|
|
66
|
+
isValid: boolean;
|
|
67
|
+
setLocale?: (locale: string) => LuxonDateTimeValue;
|
|
68
|
+
setZone?: (timezone: string) => LuxonDateTimeValue;
|
|
69
|
+
toFormat: (format: string) => string;
|
|
70
|
+
toJSDate: () => Date;
|
|
71
|
+
toMillis?: () => number;
|
|
72
|
+
}
|
|
73
|
+
interface LuxonDateTimeConstructor {
|
|
74
|
+
fromFormat?: (value: string, format: string, options?: unknown) => LuxonDateTimeValue;
|
|
75
|
+
fromISO: (value: string, options?: unknown) => LuxonDateTimeValue;
|
|
76
|
+
fromJSDate: (value: Date, options?: unknown) => LuxonDateTimeValue;
|
|
77
|
+
}
|
|
78
|
+
interface MomentDateValue {
|
|
79
|
+
format: (format?: string) => string;
|
|
80
|
+
isValid: () => boolean;
|
|
81
|
+
toDate: () => Date;
|
|
82
|
+
valueOf?: () => number;
|
|
83
|
+
}
|
|
84
|
+
interface MomentFactory {
|
|
85
|
+
(value?: unknown, format?: string): MomentDateValue;
|
|
86
|
+
}
|
|
87
|
+
declare class AdapterDateFns implements DatePickerAdapter<Date> {
|
|
88
|
+
private readonly options;
|
|
89
|
+
adapterName: DatePickerAdapterName | string;
|
|
90
|
+
private readonly runtime;
|
|
91
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
92
|
+
format(value: Date, formatKey?: string): string;
|
|
93
|
+
fromJsDate(value: Date): Date;
|
|
94
|
+
isEqual(left: Date | null, right: Date | null): boolean;
|
|
95
|
+
isValid(value: unknown): value is Date;
|
|
96
|
+
parse(value: string, formatKey?: string): Date | null;
|
|
97
|
+
toJsDate(value: Date): Date;
|
|
98
|
+
}
|
|
99
|
+
declare class AdapterDayjs implements DatePickerAdapter<DayjsDateValue> {
|
|
100
|
+
private readonly options;
|
|
101
|
+
adapterName: DatePickerAdapterName | string;
|
|
102
|
+
private readonly dayjs;
|
|
103
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
104
|
+
format(value: DayjsDateValue, formatKey?: string): string;
|
|
105
|
+
fromJsDate(value: Date): DayjsDateValue;
|
|
106
|
+
isEqual(left: DayjsDateValue | null, right: DayjsDateValue | null): boolean;
|
|
107
|
+
isValid(value: unknown): value is DayjsDateValue;
|
|
108
|
+
parse(value: string, formatKey?: string): DayjsDateValue | null;
|
|
109
|
+
toJsDate(value: DayjsDateValue): Date;
|
|
110
|
+
}
|
|
111
|
+
declare class AdapterLuxon implements DatePickerAdapter<LuxonDateTimeValue> {
|
|
112
|
+
private readonly options;
|
|
113
|
+
adapterName: DatePickerAdapterName | string;
|
|
114
|
+
private readonly dateTime;
|
|
115
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
116
|
+
format(value: LuxonDateTimeValue, formatKey?: string): string;
|
|
117
|
+
fromJsDate(value: Date): LuxonDateTimeValue;
|
|
118
|
+
isEqual(left: LuxonDateTimeValue | null, right: LuxonDateTimeValue | null): boolean;
|
|
119
|
+
isValid(value: unknown): value is LuxonDateTimeValue;
|
|
120
|
+
parse(value: string, formatKey?: string): LuxonDateTimeValue | null;
|
|
121
|
+
toJsDate(value: LuxonDateTimeValue): Date;
|
|
122
|
+
}
|
|
123
|
+
declare class AdapterMoment implements DatePickerAdapter<MomentDateValue> {
|
|
124
|
+
private readonly options;
|
|
125
|
+
adapterName: DatePickerAdapterName | string;
|
|
126
|
+
private readonly moment;
|
|
127
|
+
constructor(options?: DatePickerAdapterRuntimeOptions);
|
|
128
|
+
format(value: MomentDateValue, formatKey?: string): string;
|
|
129
|
+
fromJsDate(value: Date): MomentDateValue;
|
|
130
|
+
isEqual(left: MomentDateValue | null, right: MomentDateValue | null): boolean;
|
|
131
|
+
isValid(value: unknown): value is MomentDateValue;
|
|
132
|
+
parse(value: string, formatKey?: string): MomentDateValue | null;
|
|
133
|
+
toJsDate(value: MomentDateValue): Date;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
type PickerValidDate = unknown;
|
|
137
|
+
type DatePickerAdapterName = 'custom' | 'date-fns' | 'date-fns-jalali' | 'dayjs' | 'dayjs-buddhist' | 'luxon' | 'moment' | 'moment-hijri' | 'moment-jalaali' | 'native';
|
|
138
|
+
interface DatePickerLocaleText {
|
|
139
|
+
cancelButtonLabel: string;
|
|
140
|
+
applyButtonLabel: string;
|
|
141
|
+
timeLabel: string;
|
|
142
|
+
hoursLabel: string;
|
|
143
|
+
minutesLabel: string;
|
|
144
|
+
dayPeriodLabel: string;
|
|
145
|
+
nowButtonLabel: string;
|
|
146
|
+
clearButtonLabel: string;
|
|
147
|
+
datePickerToolbarTitle: string;
|
|
148
|
+
dateTimePickerToolbarTitle: string;
|
|
149
|
+
end: string;
|
|
150
|
+
okButtonLabel: string;
|
|
151
|
+
start: string;
|
|
152
|
+
timePickerToolbarTitle: string;
|
|
153
|
+
}
|
|
154
|
+
interface DatePickerAdapter<TDate = Date> {
|
|
155
|
+
adapterName: DatePickerAdapterName | string;
|
|
156
|
+
format: (value: TDate, formatKey?: string) => string;
|
|
157
|
+
fromJsDate: (value: Date) => TDate;
|
|
158
|
+
isEqual: (left: TDate | null, right: TDate | null) => boolean;
|
|
159
|
+
isValid: (value: unknown) => value is TDate;
|
|
160
|
+
parse: (value: string, formatKey?: string) => TDate | null;
|
|
161
|
+
toJsDate: (value: TDate) => Date;
|
|
162
|
+
}
|
|
163
|
+
declare function toPickerDate<TDate>(adapter: DatePickerAdapter<TDate>, value: TDate, name: string): Date;
|
|
164
|
+
type DatePickerAdapterConstructor<TDate = Date> = new (options?: DatePickerAdapterRuntimeOptions) => DatePickerAdapter<TDate>;
|
|
165
|
+
interface DatePickersLocalizationContextValue<TDate = Date> {
|
|
166
|
+
adapter: DatePickerAdapter<TDate>;
|
|
167
|
+
adapterLocale: SupportedLocale | string;
|
|
168
|
+
localeText: DatePickerLocaleText;
|
|
169
|
+
timezone?: DatePickerTimezone;
|
|
170
|
+
}
|
|
171
|
+
declare const defaultDatePickerLocaleText: DatePickerLocaleText;
|
|
172
|
+
declare function resolveDatePickerLocaleText(localeText?: Partial<DatePickerLocaleText>): DatePickerLocaleText;
|
|
173
|
+
declare class AdapterNativeDate implements DatePickerAdapter<Date> {
|
|
174
|
+
private readonly options;
|
|
175
|
+
adapterName: "native";
|
|
176
|
+
constructor(options?: {
|
|
177
|
+
locale?: SupportedLocale | string;
|
|
178
|
+
timezone?: string;
|
|
179
|
+
});
|
|
180
|
+
format(value: Date, formatKey?: string): string;
|
|
181
|
+
fromJsDate(value: Date): Date;
|
|
182
|
+
isEqual(left: Date | null, right: Date | null): boolean;
|
|
183
|
+
isValid(value: unknown): value is Date;
|
|
184
|
+
parse(value: string): Date | null;
|
|
185
|
+
toJsDate(value: Date): Date;
|
|
186
|
+
}
|
|
187
|
+
declare function createDatePickerAdapter<TDate>(adapter: DatePickerAdapter<TDate>): DatePickerAdapter<TDate>;
|
|
188
|
+
|
|
189
|
+
interface DatePickersLocalizationProviderProps<TDate = Date> {
|
|
190
|
+
adapterLocale?: SupportedLocale | string;
|
|
191
|
+
children: React.ReactNode;
|
|
192
|
+
dateAdapter?: DatePickerAdapter<TDate> | DatePickerAdapterConstructor<TDate>;
|
|
193
|
+
dateLibInstance?: unknown;
|
|
194
|
+
localeText?: Partial<DatePickerLocaleText>;
|
|
195
|
+
timezone?: DatePickerTimezone;
|
|
196
|
+
}
|
|
197
|
+
declare function DatePickersLocalizationProvider<TDate = Date>({ adapterLocale, children, dateAdapter, dateLibInstance, localeText, timezone, }: DatePickersLocalizationProviderProps<TDate>): React.JSX.Element;
|
|
198
|
+
declare function useDatePickersLocalization<TDate = Date>(): DatePickersLocalizationContextValue<TDate>;
|
|
199
|
+
|
|
200
|
+
export { AdapterDateFns as A, resolvePickerTimezone as B, resolveZonedCivilTimestamp as C, type DatePickerAdapter as D, toPickerDate as E, toTimezoneDisplayDate as F, useDatePickersLocalization as G, type LuxonDateTimeConstructor as L, type MomentDateValue as M, type PickerValidDate as P, type DatePickerAdapterRuntimeOptions as a, AdapterDayjs as b, type DayjsDateValue as c, AdapterMoment as d, type DatePickerLocaleText as e, type DatePickerTimezone as f, AdapterLuxon as g, AdapterNativeDate as h, type DateFnsRuntime as i, type DatePickerAdapterConstructor as j, type DatePickerAdapterName as k, type DatePickersLocalizationContextValue as l, DatePickersLocalizationProvider as m, type DatePickersLocalizationProviderProps as n, type DayjsFactory as o, type LuxonDateTimeValue as p, type MomentFactory as q, addZonedCalendarDays as r, assertSupportedTimezone as s, createDatePickerAdapter as t, defaultDatePickerLocaleText as u, fromTimezoneDisplayDate as v, getSystemTimezone as w, getZonedCivilTimestamp as x, resolveDatePickerLocaleText as y, resolveDateTimeInstant as z };
|