@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.
@@ -0,0 +1,1761 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/frameworks/react-native/index.ts
21
+ var react_native_exports = {};
22
+ __export(react_native_exports, {
23
+ AdapterDateFns: () => AdapterDateFns,
24
+ AdapterDateFnsJalali: () => AdapterDateFnsJalali,
25
+ AdapterDayjs: () => AdapterDayjs,
26
+ AdapterDayjsBuddhist: () => AdapterDayjsBuddhist,
27
+ AdapterLuxon: () => AdapterLuxon,
28
+ AdapterMoment: () => AdapterMoment,
29
+ AdapterMomentHijri: () => AdapterMomentHijri,
30
+ AdapterMomentJalaali: () => AdapterMomentJalaali,
31
+ AdapterNativeDate: () => AdapterNativeDate,
32
+ DateCalendar: () => DateCalendar,
33
+ DatePicker: () => DatePicker,
34
+ DatePickersLocalizationProvider: () => import_runtime4.DatePickersLocalizationProvider,
35
+ DateTimePicker: () => DateTimePicker,
36
+ TimePicker: () => TimePicker,
37
+ addCalendarDays: () => addCalendarDays2,
38
+ addZonedCalendarDays: () => addZonedCalendarDays,
39
+ assertSupportedTimezone: () => assertSupportedTimezone,
40
+ cloneDate: () => cloneDate2,
41
+ createDatePickerAdapter: () => createDatePickerAdapter,
42
+ datePickerCalendarSystemAdapters: () => datePickerCalendarSystemAdapters,
43
+ datePickerCapabilityFeatureIds: () => datePickerCapabilityFeatureIds,
44
+ datePickerCapabilityFeatures: () => datePickerCapabilityFeatures,
45
+ datePickersFrameworkAdapterSupport: () => datePickersFrameworkAdapterSupport,
46
+ datePickersPackageManifest: () => datePickersPackageManifest,
47
+ defaultDatePickerLocaleText: () => defaultDatePickerLocaleText,
48
+ formatDatePattern: () => formatDatePattern,
49
+ formatDateTime: () => formatDateTime,
50
+ formatRelativeTime: () => formatRelativeTime,
51
+ frameworkAdapterSupport: () => frameworkAdapterSupport,
52
+ fromTimezoneDisplayDate: () => fromTimezoneDisplayDate,
53
+ getDatePickerCalendarSystem: () => getDatePickerCalendarSystem,
54
+ getSystemTimezone: () => getSystemTimezone,
55
+ getZonedCivilTimestamp: () => getZonedCivilTimestamp,
56
+ isCalendarSystemAdapter: () => isCalendarSystemAdapter,
57
+ isDateThisWeek: () => isDateThisWeek,
58
+ isDateToday: () => isDateToday,
59
+ isDateYesterday: () => isDateYesterday,
60
+ isSameCalendarDay: () => isSameCalendarDay,
61
+ isValidDate: () => isValidDate,
62
+ mergeDateAndTime: () => mergeDateAndTime,
63
+ minutesFromDate: () => minutesFromDate,
64
+ packageManifest: () => packageManifest,
65
+ parseIsoDate: () => parseIsoDate,
66
+ parseStoredPickerValue: () => parseStoredPickerValue,
67
+ reactNativeFrameworkAdapter: () => reactNativeFrameworkAdapter,
68
+ resolveDatePickerLocale: () => resolveDatePickerLocale,
69
+ resolveDatePickerLocaleText: () => resolveDatePickerLocaleText,
70
+ resolveDateTimeInstant: () => resolveDateTimeInstant,
71
+ resolveDateValidationError: () => resolveDateValidationError,
72
+ resolvePickerTimezone: () => resolvePickerTimezone,
73
+ resolveTimeValidationError: () => resolveTimeValidationError,
74
+ resolveZonedCivilTimestamp: () => resolveZonedCivilTimestamp,
75
+ serializePickerDate: () => serializePickerDate,
76
+ serializePickerDateTime: () => serializePickerDateTime,
77
+ serializePickerTime: () => serializePickerTime,
78
+ shouldAllowDate: () => shouldAllowDate,
79
+ shouldAllowTime: () => shouldAllowTime,
80
+ startOfDay: () => startOfDay,
81
+ subtractCalendarDays: () => subtractCalendarDays,
82
+ supportsDatePickerCalendarSystem: () => supportsDatePickerCalendarSystem,
83
+ toDatePickerDate: () => toDatePickerDate,
84
+ toPickerDate: () => toPickerDate,
85
+ toTimezoneDisplayDate: () => toTimezoneDisplayDate,
86
+ useDatePickersLocalization: () => import_runtime4.useDatePickersLocalization
87
+ });
88
+ module.exports = __toCommonJS(react_native_exports);
89
+
90
+ // src/frameworks/react-native/PickerField.tsx
91
+ var import_react3 = require("react");
92
+ var import_react_native4 = require("@quickbuilder.io/design-system/react-native");
93
+ var import_calendar5 = require("@quickbuilder.io/design-system/calendar");
94
+ var import_runtime3 = require("@quickbuilder.io/date-pickers/runtime");
95
+
96
+ // src/DatePickersTimezone.ts
97
+ function resolvePickerTimezone(timezone, providerTimezone) {
98
+ const requestedTimezone = timezone ?? providerTimezone;
99
+ if (requestedTimezone === void 0) return void 0;
100
+ if (requestedTimezone === "default") {
101
+ if (providerTimezone === void 0 || providerTimezone === "default") return void 0;
102
+ return resolvePickerTimezone(providerTimezone);
103
+ }
104
+ if (requestedTimezone === "system") {
105
+ return getSystemTimezone();
106
+ }
107
+ if (requestedTimezone === "UTC") {
108
+ return "UTC";
109
+ }
110
+ assertSupportedTimezone(requestedTimezone);
111
+ return requestedTimezone;
112
+ }
113
+ function toTimezoneDisplayDate(value, timezone) {
114
+ if (value === null) return null;
115
+ if (timezone === void 0) return cloneDate(value);
116
+ const parts = getTimezoneParts(value, timezone);
117
+ const display = /* @__PURE__ */ new Date(0);
118
+ display.setFullYear(parts.year, parts.month - 1, parts.day);
119
+ display.setHours(parts.hour, parts.minute, parts.second, value.getMilliseconds());
120
+ return display;
121
+ }
122
+ function fromTimezoneDisplayDate(value, timezone) {
123
+ if (value === null) return null;
124
+ if (timezone === void 0) return cloneDate(value);
125
+ const utcGuess = civilStamp(value);
126
+ const firstOffset = getTimezoneOffsetMs(new Date(utcGuess), timezone);
127
+ const firstCandidate = new Date(utcGuess - firstOffset);
128
+ const secondOffset = getTimezoneOffsetMs(firstCandidate, timezone);
129
+ return new Date(utcGuess - secondOffset);
130
+ }
131
+ function getSystemTimezone() {
132
+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
133
+ if (!zone) throw new Error("The system timezone is unavailable.");
134
+ return zone;
135
+ }
136
+ function assertSupportedTimezone(timezone) {
137
+ getTimezoneFormatter(timezone);
138
+ }
139
+ var formatters = /* @__PURE__ */ new Map();
140
+ function getTimezoneFormatter(timezone) {
141
+ if (typeof timezone !== "string") throw new TypeError("Unsupported timezone. Supply an IANA timezone name.");
142
+ const cached = formatters.get(timezone);
143
+ if (cached) return cached;
144
+ try {
145
+ const formatter = new Intl.DateTimeFormat("en-US-u-ca-gregory", {
146
+ day: "2-digit",
147
+ hour: "2-digit",
148
+ hourCycle: "h23",
149
+ minute: "2-digit",
150
+ month: "2-digit",
151
+ second: "2-digit",
152
+ timeZone: timezone,
153
+ year: "numeric"
154
+ });
155
+ if (formatters.size >= 32) formatters.delete(formatters.keys().next().value);
156
+ formatters.set(timezone, formatter);
157
+ return formatter;
158
+ } catch {
159
+ throw new Error(
160
+ `Unsupported date picker timezone "${timezone}". Use "UTC", "system", "default", or a valid IANA timezone.`
161
+ );
162
+ }
163
+ }
164
+ function cloneDate(value) {
165
+ return new Date(value.getTime());
166
+ }
167
+ function getZonedCivilTimestamp(value, timezone) {
168
+ if (!Number.isFinite(value.getTime())) throw new RangeError("A valid instant is required.");
169
+ if (timezone === "UTC") return value.getTime();
170
+ const parts = getTimezoneParts(value, timezone);
171
+ const stamp = /* @__PURE__ */ new Date(0);
172
+ stamp.setUTCFullYear(parts.year, parts.month - 1, parts.day);
173
+ stamp.setUTCHours(parts.hour, parts.minute, parts.second, value.getMilliseconds());
174
+ return stamp.getTime();
175
+ }
176
+ function getTimezoneOffsetMs(value, timezone) {
177
+ return getZonedCivilTimestamp(value, timezone) - value.getTime();
178
+ }
179
+ function getTimezoneParts(value, timezone) {
180
+ const parts = getTimezoneFormatter(timezone).formatToParts(value);
181
+ const resolvedParts = Object.fromEntries(
182
+ parts.map((part) => [part.type, part.value])
183
+ );
184
+ return {
185
+ day: Number(resolvedParts.day),
186
+ hour: Number(resolvedParts.hour),
187
+ minute: Number(resolvedParts.minute),
188
+ month: Number(resolvedParts.month),
189
+ second: Number(resolvedParts.second),
190
+ year: Number(resolvedParts.year)
191
+ };
192
+ }
193
+ function civilStamp(date) {
194
+ const stamp = /* @__PURE__ */ new Date(0);
195
+ stamp.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate());
196
+ stamp.setUTCHours(
197
+ date.getHours(),
198
+ date.getMinutes(),
199
+ date.getSeconds(),
200
+ date.getMilliseconds()
201
+ );
202
+ return stamp.getTime();
203
+ }
204
+ function resolveDateTimeInstant(value, timezone, disambiguation) {
205
+ if (!Number.isFinite(value.getTime()))
206
+ throw new RangeError("Date-time resolution requires a valid date.");
207
+ if (timezone === void 0) {
208
+ assertDisambiguation(disambiguation);
209
+ return { date: new Date(value), error: null };
210
+ }
211
+ return resolveZonedCivilTimestamp(civilStamp(value), timezone, disambiguation);
212
+ }
213
+ function addZonedCalendarDays(value, days, timezone) {
214
+ if (!Number.isFinite(value.getTime()) || !Number.isSafeInteger(days))
215
+ throw new RangeError("Calendar-day addition requires a valid instant and an integer day count.");
216
+ assertSupportedTimezone(timezone);
217
+ if (days === 0) return { date: new Date(value), error: null };
218
+ const target = getZonedCivilTimestamp(value, timezone) + days * 864e5;
219
+ return resolveZonedCivilTimestamp(target, timezone, "reject");
220
+ }
221
+ function assertDisambiguation(disambiguation) {
222
+ if (!["earlier", "later", "reject"].includes(disambiguation))
223
+ throw new TypeError("Unsupported date-time disambiguation.");
224
+ }
225
+ function resolveZonedCivilTimestamp(target, timezone, disambiguation) {
226
+ if (!Number.isSafeInteger(target) || !Number.isFinite(new Date(target).getTime()))
227
+ throw new RangeError("A valid civil timestamp is required.");
228
+ assertDisambiguation(disambiguation);
229
+ if (timezone === "UTC") return { date: new Date(target), error: null };
230
+ const offsets = /* @__PURE__ */ new Set();
231
+ for (const hours of [-36, -12, 0, 12, 36]) {
232
+ const probe = new Date(target + hours * 36e5);
233
+ offsets.add(getTimezoneOffsetMs(probe, timezone));
234
+ }
235
+ const matches = [...offsets].filter((offset) => getTimezoneOffsetMs(new Date(target - offset), timezone) === offset).map((offset) => target - offset).sort((a, b) => a - b);
236
+ if (!matches.length) return { date: null, error: "nonexistentTime" };
237
+ if (matches.length > 1 && disambiguation === "reject")
238
+ return { date: null, error: "ambiguousTime" };
239
+ return {
240
+ date: new Date(
241
+ disambiguation === "later" ? matches[matches.length - 1] : matches[0]
242
+ ),
243
+ error: null
244
+ };
245
+ }
246
+
247
+ // src/DatePickersAdapters.ts
248
+ var AdapterDateFns = class {
249
+ constructor(options = {}) {
250
+ this.options = options;
251
+ this.adapterName = "date-fns";
252
+ this.runtime = isDateFnsRuntime(options.dateLibInstance) ? options.dateLibInstance : void 0;
253
+ }
254
+ format(value, formatKey = "short") {
255
+ if (!this.isValid(value)) return "";
256
+ const format = resolveUnicodeDateFormat(formatKey);
257
+ return this.runtime?.format ? this.runtime.format(value, format) : formatNativeDate(value, this.options.locale, resolvePickerTimezone(this.options.timezone), formatKey);
258
+ }
259
+ fromJsDate(value) {
260
+ return new Date(value.getTime());
261
+ }
262
+ isEqual(left, right) {
263
+ if (left === null || right === null) return left === right;
264
+ return left.getTime() === right.getTime();
265
+ }
266
+ isValid(value) {
267
+ if (!(value instanceof Date)) return false;
268
+ return this.runtime?.isValid ? this.runtime.isValid(value) : !Number.isNaN(value.getTime());
269
+ }
270
+ parse(value, formatKey = "short") {
271
+ const parsed = this.runtime?.parse ? this.runtime.parse(value, resolveUnicodeDateFormat(formatKey), /* @__PURE__ */ new Date()) : new Date(value);
272
+ return this.isValid(parsed) ? parsed : null;
273
+ }
274
+ toJsDate(value) {
275
+ return new Date(value.getTime());
276
+ }
277
+ };
278
+ var AdapterDayjs = class {
279
+ constructor(options = {}) {
280
+ this.options = options;
281
+ this.adapterName = "dayjs";
282
+ this.dayjs = requireDateLibInstance(options.dateLibInstance, "AdapterDayjs", "dayjs");
283
+ }
284
+ format(value, formatKey = "short") {
285
+ return this.isValid(value) ? value.format(resolveDayjsMomentFormat(formatKey)) : "";
286
+ }
287
+ fromJsDate(value) {
288
+ return this.dayjs(value);
289
+ }
290
+ isEqual(left, right) {
291
+ if (left === null || right === null) return left === right;
292
+ return getDateValueTime(left) === getDateValueTime(right);
293
+ }
294
+ isValid(value) {
295
+ return isDayjsLike(value) && value.isValid();
296
+ }
297
+ parse(value, formatKey = "short") {
298
+ const parsed = this.dayjs(value, resolveDayjsMomentFormat(formatKey));
299
+ return this.isValid(parsed) ? parsed : null;
300
+ }
301
+ toJsDate(value) {
302
+ return value.toDate();
303
+ }
304
+ };
305
+ var AdapterLuxon = class {
306
+ constructor(options = {}) {
307
+ this.options = options;
308
+ this.adapterName = "luxon";
309
+ this.dateTime = requireDateLibInstance(options.dateLibInstance, "AdapterLuxon", "luxon DateTime");
310
+ }
311
+ format(value, formatKey = "short") {
312
+ return this.isValid(value) ? withLuxonContext(value, this.options).toFormat(resolveLuxonFormat(formatKey)) : "";
313
+ }
314
+ fromJsDate(value) {
315
+ return this.dateTime.fromJSDate(value, getLuxonOptions(this.options));
316
+ }
317
+ isEqual(left, right) {
318
+ if (left === null || right === null) return left === right;
319
+ return getDateValueTime(left) === getDateValueTime(right);
320
+ }
321
+ isValid(value) {
322
+ return isLuxonLike(value) && value.isValid;
323
+ }
324
+ parse(value, formatKey = "short") {
325
+ const format = resolveLuxonFormat(formatKey);
326
+ const parsed = this.dateTime.fromFormat ? this.dateTime.fromFormat(value, format, getLuxonOptions(this.options)) : this.dateTime.fromISO(value, getLuxonOptions(this.options));
327
+ return this.isValid(parsed) ? parsed : null;
328
+ }
329
+ toJsDate(value) {
330
+ return value.toJSDate();
331
+ }
332
+ };
333
+ var AdapterMoment = class {
334
+ constructor(options = {}) {
335
+ this.options = options;
336
+ this.adapterName = "moment";
337
+ this.moment = requireDateLibInstance(options.dateLibInstance, "AdapterMoment", "moment");
338
+ }
339
+ format(value, formatKey = "short") {
340
+ return this.isValid(value) ? value.format(resolveDayjsMomentFormat(formatKey)) : "";
341
+ }
342
+ fromJsDate(value) {
343
+ return this.moment(value);
344
+ }
345
+ isEqual(left, right) {
346
+ if (left === null || right === null) return left === right;
347
+ return getDateValueTime(left) === getDateValueTime(right);
348
+ }
349
+ isValid(value) {
350
+ return isMomentLike(value) && value.isValid();
351
+ }
352
+ parse(value, formatKey = "short") {
353
+ const parsed = this.moment(value, resolveDayjsMomentFormat(formatKey));
354
+ return this.isValid(parsed) ? parsed : null;
355
+ }
356
+ toJsDate(value) {
357
+ return value.toDate();
358
+ }
359
+ };
360
+ function requireDateLibInstance(dateLibInstance, adapterName, libraryName) {
361
+ if (!dateLibInstance) {
362
+ throw new Error(`${adapterName} requires ${libraryName} to be passed through DatePickersLocalizationProvider dateLibInstance.`);
363
+ }
364
+ return dateLibInstance;
365
+ }
366
+ function isDateFnsRuntime(value) {
367
+ return typeof value === "object" && value !== null;
368
+ }
369
+ function isDayjsLike(value) {
370
+ return typeof value === "object" && value !== null && typeof value.format === "function" && typeof value.isValid === "function" && typeof value.toDate === "function";
371
+ }
372
+ function isMomentLike(value) {
373
+ return isDayjsLike(value);
374
+ }
375
+ function isLuxonLike(value) {
376
+ return typeof value === "object" && value !== null && typeof value.isValid === "boolean" && typeof value.toFormat === "function" && typeof value.toJSDate === "function";
377
+ }
378
+ function getDateValueTime(value) {
379
+ if (value.toMillis) return value.toMillis();
380
+ const primitiveValue = typeof value.valueOf === "function" ? value.valueOf() : void 0;
381
+ if (typeof primitiveValue === "number") return primitiveValue;
382
+ if (value.toDate) return value.toDate().getTime();
383
+ if (value.toJSDate) return value.toJSDate().getTime();
384
+ return Number.NaN;
385
+ }
386
+ function resolveDayjsMomentFormat(formatKey) {
387
+ if (formatKey === "short") return "L";
388
+ if (formatKey === "medium") return "ll";
389
+ if (formatKey === "long") return "LL";
390
+ return formatKey;
391
+ }
392
+ function resolveLuxonFormat(formatKey) {
393
+ if (formatKey === "short") return "D";
394
+ if (formatKey === "medium") return "DD";
395
+ if (formatKey === "long") return "DDD";
396
+ return formatKey;
397
+ }
398
+ function resolveUnicodeDateFormat(formatKey) {
399
+ if (formatKey === "short") return "P";
400
+ if (formatKey === "medium") return "PP";
401
+ if (formatKey === "long") return "PPP";
402
+ return formatKey;
403
+ }
404
+ function formatNativeDate(value, locale, timezone, formatKey) {
405
+ const dateStyle = formatKey === "long" ? "long" : formatKey === "medium" ? "medium" : "short";
406
+ return new Intl.DateTimeFormat(locale ?? "en", {
407
+ dateStyle,
408
+ timeZone: timezone
409
+ }).format(value);
410
+ }
411
+ function getLuxonOptions(options) {
412
+ return {
413
+ ...options.locale ? { locale: options.locale } : {},
414
+ ...resolvePickerTimezone(options.timezone) ? { zone: resolvePickerTimezone(options.timezone) } : {}
415
+ };
416
+ }
417
+ function withLuxonContext(value, options) {
418
+ let nextValue = value;
419
+ if (options.locale && nextValue.setLocale) {
420
+ nextValue = nextValue.setLocale(options.locale);
421
+ }
422
+ const resolvedTimezone = resolvePickerTimezone(options.timezone);
423
+ if (resolvedTimezone && nextValue.setZone) {
424
+ nextValue = nextValue.setZone(resolvedTimezone);
425
+ }
426
+ return nextValue;
427
+ }
428
+
429
+ // src/DatePickersCalendarSystems.ts
430
+ var datePickerCalendarSystemAdapters = [
431
+ {
432
+ adapterName: "date-fns-jalali",
433
+ calendarSystem: "jalali",
434
+ fieldEditing: "supported",
435
+ runtimePackage: "date-fns-jalali"
436
+ },
437
+ {
438
+ adapterName: "moment-jalaali",
439
+ calendarSystem: "jalali",
440
+ fieldEditing: "supported",
441
+ runtimePackage: "moment-jalaali"
442
+ },
443
+ {
444
+ adapterName: "moment-hijri",
445
+ calendarSystem: "hijri",
446
+ fieldEditing: "view-only-recommended",
447
+ runtimePackage: "moment-hijri"
448
+ },
449
+ {
450
+ adapterName: "dayjs-buddhist",
451
+ calendarSystem: "buddhist",
452
+ fieldEditing: "supported",
453
+ runtimePackage: "dayjs"
454
+ }
455
+ ];
456
+ var AdapterDateFnsJalali = class extends AdapterDateFns {
457
+ constructor(options = {}) {
458
+ requireCalendarRuntime(options.dateLibInstance, "AdapterDateFnsJalali", "date-fns-jalali");
459
+ super(options);
460
+ this.adapterName = "date-fns-jalali";
461
+ this.calendarSystem = "jalali";
462
+ this.fieldEditing = "supported";
463
+ }
464
+ };
465
+ var AdapterMomentJalaali = class extends AdapterMoment {
466
+ constructor(options = {}) {
467
+ super({
468
+ ...options,
469
+ dateLibInstance: requireCalendarRuntime(options.dateLibInstance, "AdapterMomentJalaali", "moment-jalaali")
470
+ });
471
+ this.adapterName = "moment-jalaali";
472
+ this.calendarSystem = "jalali";
473
+ this.fieldEditing = "supported";
474
+ }
475
+ format(value, formatKey = "short") {
476
+ return this.isValid(value) ? value.format(resolveMomentJalaaliFormat(formatKey)) : "";
477
+ }
478
+ parse(value, formatKey = "short") {
479
+ const parsed = this.createMomentValue(value, resolveMomentJalaaliFormat(formatKey));
480
+ return this.isValid(parsed) ? parsed : null;
481
+ }
482
+ createMomentValue(value, format) {
483
+ const factory = requireCalendarRuntime(
484
+ this.moment,
485
+ "AdapterMomentJalaali",
486
+ "moment-jalaali"
487
+ );
488
+ return factory(value, format);
489
+ }
490
+ };
491
+ var AdapterMomentHijri = class extends AdapterMoment {
492
+ constructor(options = {}) {
493
+ super({
494
+ ...options,
495
+ dateLibInstance: requireCalendarRuntime(options.dateLibInstance, "AdapterMomentHijri", "moment-hijri")
496
+ });
497
+ this.adapterName = "moment-hijri";
498
+ this.calendarSystem = "hijri";
499
+ this.fieldEditing = "view-only-recommended";
500
+ }
501
+ format(value, formatKey = "short") {
502
+ return this.isValid(value) ? value.format(resolveMomentHijriFormat(formatKey)) : "";
503
+ }
504
+ parse(value, formatKey = "short") {
505
+ const parsed = this.createMomentValue(value, resolveMomentHijriFormat(formatKey));
506
+ return this.isValid(parsed) ? parsed : null;
507
+ }
508
+ createMomentValue(value, format) {
509
+ const factory = requireCalendarRuntime(
510
+ this.moment,
511
+ "AdapterMomentHijri",
512
+ "moment-hijri"
513
+ );
514
+ return factory(value, format);
515
+ }
516
+ };
517
+ var AdapterDayjsBuddhist = class extends AdapterDayjs {
518
+ constructor(options = {}) {
519
+ super({
520
+ ...options,
521
+ dateLibInstance: requireCalendarRuntime(options.dateLibInstance, "AdapterDayjsBuddhist", "dayjs with buddhistEra plugin")
522
+ });
523
+ this.adapterName = "dayjs-buddhist";
524
+ this.calendarSystem = "buddhist";
525
+ this.fieldEditing = "supported";
526
+ }
527
+ format(value, formatKey = "short") {
528
+ return this.isValid(value) ? value.format(resolveDayjsBuddhistFormat(formatKey)) : "";
529
+ }
530
+ };
531
+ function isCalendarSystemAdapter(adapter) {
532
+ return typeof adapter.calendarSystem === "string";
533
+ }
534
+ function getDatePickerCalendarSystem(adapter) {
535
+ return isCalendarSystemAdapter(adapter) ? adapter.calendarSystem : "gregory";
536
+ }
537
+ function supportsDatePickerCalendarSystem(calendarSystem) {
538
+ return datePickerCalendarSystemAdapters.some((adapter) => adapter.calendarSystem === calendarSystem) || calendarSystem === "gregory";
539
+ }
540
+ function requireCalendarRuntime(dateLibInstance, adapterName, packageName) {
541
+ if (!dateLibInstance) {
542
+ throw new Error(`${adapterName} requires ${packageName} to be passed through DatePickersLocalizationProvider dateLibInstance.`);
543
+ }
544
+ return dateLibInstance;
545
+ }
546
+ function resolveMomentJalaaliFormat(formatKey) {
547
+ if (formatKey === "short") return "jYYYY/jMM/jDD";
548
+ if (formatKey === "medium") return "jD jMMM jYYYY";
549
+ if (formatKey === "long") return "jD jMMMM jYYYY";
550
+ return formatKey;
551
+ }
552
+ function resolveMomentHijriFormat(formatKey) {
553
+ if (formatKey === "short") return "iYYYY/iMM/iDD";
554
+ if (formatKey === "medium") return "iD iMMM iYYYY";
555
+ if (formatKey === "long") return "iD iMMMM iYYYY";
556
+ return formatKey;
557
+ }
558
+ function resolveDayjsBuddhistFormat(formatKey) {
559
+ if (formatKey === "short") return "BBBB/MM/DD";
560
+ if (formatKey === "medium") return "D MMM BBBB";
561
+ if (formatKey === "long") return "D MMMM BBBB";
562
+ return formatKey;
563
+ }
564
+
565
+ // src/DatePickersLocalization.ts
566
+ function toPickerDate(adapter, value, name) {
567
+ if (adapter.isValid(value)) {
568
+ const date = adapter.toJsDate(value);
569
+ if (date instanceof Date && Number.isFinite(date.getTime())) return date;
570
+ }
571
+ throw new TypeError(`${name} must be a valid adapter value.`);
572
+ }
573
+ var defaultDatePickerLocaleText = {
574
+ cancelButtonLabel: "Cancel",
575
+ applyButtonLabel: "Apply",
576
+ timeLabel: "Time",
577
+ hoursLabel: "Hours",
578
+ minutesLabel: "Minutes",
579
+ dayPeriodLabel: "AM or PM",
580
+ nowButtonLabel: "Now",
581
+ clearButtonLabel: "Clear",
582
+ datePickerToolbarTitle: "Select date",
583
+ dateTimePickerToolbarTitle: "Select date and time",
584
+ end: "End",
585
+ okButtonLabel: "OK",
586
+ start: "Start",
587
+ timePickerToolbarTitle: "Select time"
588
+ };
589
+ function resolveDatePickerLocaleText(localeText) {
590
+ return {
591
+ ...defaultDatePickerLocaleText,
592
+ ...localeText
593
+ };
594
+ }
595
+ var AdapterNativeDate = class {
596
+ constructor(options = {}) {
597
+ this.options = options;
598
+ this.adapterName = "native";
599
+ }
600
+ format(value, formatKey = "short") {
601
+ if (!this.isValid(value)) return "";
602
+ const locale = this.options.locale ?? "en";
603
+ const dateStyle = formatKey === "long" ? "long" : formatKey === "medium" ? "medium" : "short";
604
+ return new Intl.DateTimeFormat(locale, {
605
+ dateStyle,
606
+ timeZone: this.options.timezone
607
+ }).format(value);
608
+ }
609
+ fromJsDate(value) {
610
+ return new Date(value.getTime());
611
+ }
612
+ isEqual(left, right) {
613
+ if (left === null || right === null) return left === right;
614
+ return left.getTime() === right.getTime();
615
+ }
616
+ isValid(value) {
617
+ return value instanceof Date && !Number.isNaN(value.getTime());
618
+ }
619
+ parse(value) {
620
+ const parsed = new Date(value);
621
+ return this.isValid(parsed) ? parsed : null;
622
+ }
623
+ toJsDate(value) {
624
+ return new Date(value.getTime());
625
+ }
626
+ };
627
+ function createDatePickerAdapter(adapter) {
628
+ return adapter;
629
+ }
630
+
631
+ // src/DateTimePicker.utils.ts
632
+ var import_calendar2 = require("@quickbuilder.io/design-system/calendar");
633
+
634
+ // src/DatePickers.utils.ts
635
+ var import_calendar = require("@quickbuilder.io/design-system/calendar");
636
+ function resolveDatePickerLocale(requested) {
637
+ const supported = (0, import_calendar.normalizeLocale)(requested);
638
+ if (requested === supported) return supported;
639
+ const [canonical] = Intl.getCanonicalLocales(requested);
640
+ const locale = (0, import_calendar.normalizeLocale)(canonical);
641
+ if (locale !== canonical) throw new RangeError(`Unsupported date picker locale: ${requested}`);
642
+ return locale;
643
+ }
644
+ function cloneDate2(value) {
645
+ return new Date(value.getTime());
646
+ }
647
+ function isValidDate(value) {
648
+ return value instanceof Date && !Number.isNaN(value.getTime());
649
+ }
650
+ function startOfDay(value) {
651
+ const date = cloneDate2(value);
652
+ date.setHours(0, 0, 0, 0);
653
+ return date;
654
+ }
655
+ function mergeDateAndTime(dateValue, timeValue) {
656
+ if (!dateValue && !timeValue) return null;
657
+ const nextValue = cloneDate2(dateValue ?? timeValue ?? /* @__PURE__ */ new Date());
658
+ if (timeValue) {
659
+ nextValue.setHours(timeValue.getHours(), timeValue.getMinutes(), 0, 0);
660
+ }
661
+ return nextValue;
662
+ }
663
+ function resolveDateValidationError({
664
+ disableFuture = false,
665
+ disablePast = false,
666
+ maxDate,
667
+ minDate,
668
+ shouldDisableDate,
669
+ today = /* @__PURE__ */ new Date(),
670
+ value
671
+ }) {
672
+ if (value === null) return null;
673
+ if (!isValidDate(value)) return "invalidDate";
674
+ const comparableValue = startOfDay(value).getTime();
675
+ const todayStamp = startOfDay(today).getTime();
676
+ if (disablePast && comparableValue < todayStamp) return "disablePast";
677
+ if (disableFuture && comparableValue > todayStamp) return "disableFuture";
678
+ if (minDate && comparableValue < startOfDay(minDate).getTime()) return "minDate";
679
+ if (maxDate && comparableValue > startOfDay(maxDate).getTime()) return "maxDate";
680
+ if (shouldDisableDate?.(value)) return "shouldDisableDate";
681
+ return null;
682
+ }
683
+ function resolveTimeValidationError({
684
+ disableFuture = false,
685
+ disablePast = false,
686
+ maxTime,
687
+ minTime,
688
+ shouldDisableTime,
689
+ now = /* @__PURE__ */ new Date(),
690
+ value
691
+ }) {
692
+ if (value === null) return null;
693
+ if (!isValidDate(value)) return "invalidTime";
694
+ if (disablePast && minutesFromDate(value) < minutesFromDate(now)) return "disablePast";
695
+ if (disableFuture && minutesFromDate(value) > minutesFromDate(now)) return "disableFuture";
696
+ if (minTime && minutesFromDate(value) < minutesFromDate(minTime)) return "minTime";
697
+ if (maxTime && minutesFromDate(value) > minutesFromDate(maxTime)) return "maxTime";
698
+ if (shouldDisableTime?.(value)) return "shouldDisableTime";
699
+ return null;
700
+ }
701
+ function shouldAllowDate({
702
+ disableFuture,
703
+ disablePast,
704
+ maxDate,
705
+ minDate,
706
+ shouldDisableDate
707
+ }) {
708
+ return (date) => resolveDateValidationError({
709
+ disableFuture,
710
+ disablePast,
711
+ maxDate,
712
+ minDate,
713
+ shouldDisableDate,
714
+ value: date
715
+ }) === null;
716
+ }
717
+ function shouldAllowTime({
718
+ disableFuture,
719
+ disablePast,
720
+ maxTime,
721
+ minTime,
722
+ shouldDisableTime
723
+ }) {
724
+ return (time) => resolveTimeValidationError({
725
+ disableFuture,
726
+ disablePast,
727
+ maxTime,
728
+ minTime,
729
+ shouldDisableTime,
730
+ value: time
731
+ }) === null;
732
+ }
733
+ function minutesFromDate(value) {
734
+ return value.getHours() * 60 + value.getMinutes();
735
+ }
736
+
737
+ // src/DateTimePicker.utils.ts
738
+ var escapePattern = (text) => text.replace(/[.*+?^$()|[\]{}\\]/g, "\\$&");
739
+ var stripDirection = (text) => text.normalize("NFKC").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, "").trim();
740
+ function createDateTimeCodec(locale, calendarSystem, hour12) {
741
+ const dateFormat = new Intl.DateTimeFormat(
742
+ (0, import_calendar2.getCalendarSystemLocale)(locale, calendarSystem),
743
+ { year: "numeric", month: "2-digit", day: "2-digit" }
744
+ );
745
+ const timeFormat = new Intl.DateTimeFormat(locale, {
746
+ hour: "2-digit",
747
+ minute: "2-digit",
748
+ ...hour12 === void 0 ? {} : hour12 ? { hour12: true } : { hourCycle: "h23" }
749
+ });
750
+ const digits = new Intl.NumberFormat(locale, { useGrouping: false });
751
+ const normalize = (text) => {
752
+ let value = stripDirection(text).toLocaleLowerCase(locale);
753
+ for (let digit = 0; digit < 10; digit++)
754
+ value = value.split(digits.format(digit)).join(String(digit));
755
+ return value;
756
+ };
757
+ const periods = [0, 13].map(
758
+ (hour) => timeFormat.formatToParts(new Date(2026, 0, 1, hour)).find((part) => part.type === "dayPeriod")?.value ?? ""
759
+ );
760
+ const fields = [];
761
+ const pattern = timeFormat.formatToParts(new Date(2026, 0, 1, 13, 45)).map((part) => {
762
+ if (part.type === "hour" || part.type === "minute") {
763
+ fields.push(part.type);
764
+ return "(\\d{1,2})";
765
+ }
766
+ if (part.type === "dayPeriod") {
767
+ fields.push(part.type);
768
+ return "(" + periods.map((value) => escapePattern(normalize(value))).join("|") + ")";
769
+ }
770
+ if (/^\s+$/.test(part.value)) return "\\s*";
771
+ return escapePattern(normalize(part.value)).replace(/\s+/g, "\\s*");
772
+ }).join("");
773
+ const expression = new RegExp("^(.+?)[,\u060C]?\\s+" + pattern + "$", "u");
774
+ return {
775
+ format: (date) => date ? dateFormat.format(date) + ", " + timeFormat.format(date) : "",
776
+ formatTime: (date) => timeFormat.format(date),
777
+ parse: (text) => {
778
+ const match = normalize(text).match(expression);
779
+ if (!match) return null;
780
+ const date = (0, import_calendar2.parseDateInputForCalendarSystem)(
781
+ match[1].replace(/[,،]$/, ""),
782
+ locale,
783
+ calendarSystem,
784
+ true
785
+ );
786
+ if (!date) return null;
787
+ const values = Object.fromEntries(
788
+ fields.map((field, index) => [field, match[index + 2]])
789
+ );
790
+ let hour = Number(values.hour);
791
+ const minute = Number(values.minute);
792
+ if (minute > 59 || hour > 23) return null;
793
+ if (values.dayPeriod) {
794
+ if (hour < 1 || hour > 12) return null;
795
+ hour = hour % 12 + (values.dayPeriod === normalize(periods[1]) ? 12 : 0);
796
+ }
797
+ date.setHours(hour, minute, 0, 0);
798
+ return date.getHours() === hour && date.getMinutes() === minute ? date : null;
799
+ }
800
+ };
801
+ }
802
+ function assertOrderedPickerBounds(min, max, compareValue, name) {
803
+ if (min !== void 0 && !isValidDate(min) || max !== void 0 && !isValidDate(max))
804
+ throw new RangeError(`${name} must be valid dates.`);
805
+ if (min && max && compareValue(min) > compareValue(max))
806
+ throw new RangeError(`${name} must be ordered.`);
807
+ }
808
+ function assertDateBounds(minDate, maxDate) {
809
+ assertOrderedPickerBounds(
810
+ minDate,
811
+ maxDate,
812
+ (date) => startOfDay(date).getTime(),
813
+ "minDate/maxDate"
814
+ );
815
+ }
816
+ function assertDateTimeBounds(constraints) {
817
+ assertOrderedPickerBounds(
818
+ constraints.minDateTime,
819
+ constraints.maxDateTime,
820
+ (date) => date.getTime(),
821
+ "minDateTime/maxDateTime"
822
+ );
823
+ assertDateBounds(constraints.minDate, constraints.maxDate);
824
+ assertOrderedPickerBounds(
825
+ constraints.minTime,
826
+ constraints.maxTime,
827
+ minutesFromDate,
828
+ "minTime/maxTime"
829
+ );
830
+ }
831
+ function validateDateTime(display, instant, constraints) {
832
+ if (!display || !instant) return constraints.required ? "required" : null;
833
+ const dateError = resolveDateValidationError({
834
+ value: display,
835
+ minDate: constraints.minDate,
836
+ maxDate: constraints.maxDate,
837
+ shouldDisableDate: constraints.shouldDisableDate
838
+ });
839
+ if (dateError) return dateError;
840
+ if (constraints.minDateTime && instant < constraints.minDateTime)
841
+ return "minDateTime";
842
+ if (constraints.maxDateTime && instant > constraints.maxDateTime)
843
+ return "maxDateTime";
844
+ if (constraints.disablePast && instant.getTime() < Date.now())
845
+ return "disablePast";
846
+ if (constraints.disableFuture && instant.getTime() > Date.now())
847
+ return "disableFuture";
848
+ if (display.getMinutes() % constraints.minutesStep !== 0)
849
+ return "minutesStep";
850
+ return resolveTimeValidationError({
851
+ value: display,
852
+ minTime: constraints.minTime,
853
+ maxTime: constraints.maxTime,
854
+ shouldDisableTime: constraints.shouldDisableTime
855
+ });
856
+ }
857
+ var dateTimeValidationMessages = {
858
+ required: "Choose a date and time.",
859
+ invalidDate: "Enter a complete date and time in the displayed format.",
860
+ invalidTime: "Enter a valid time.",
861
+ minDate: "Choose a date on or after the earliest available date.",
862
+ maxDate: "Choose a date on or before the latest available date.",
863
+ minTime: "Choose a time at or after opening time.",
864
+ maxTime: "Choose a time at or before closing time.",
865
+ minDateTime: "Choose a date and time at or after the minimum.",
866
+ maxDateTime: "Choose a date and time at or before the maximum.",
867
+ disablePast: "Choose a future date and time.",
868
+ disableFuture: "Choose a past date and time.",
869
+ shouldDisableDate: "This date is unavailable. Choose another date.",
870
+ shouldDisableTime: "This time is unavailable. Choose another time.",
871
+ minutesStep: "Choose a time that matches the minute interval.",
872
+ nonexistentTime: "This local time does not exist because the clocks move forward. Choose another time.",
873
+ ambiguousTime: "This local time occurs twice because the clocks move back. Choose another time or set an explicit timezone policy."
874
+ };
875
+
876
+ // src/frameworks/react-native/PickerField.tsx
877
+ var import_lucide_line2 = require("@quickbuilder.io/icons/packs/lucide-line");
878
+
879
+ // src/frameworks/react-native/PickerField.parts.tsx
880
+ var import_react2 = require("react");
881
+ var import_react_native3 = require("@quickbuilder.io/design-system/react-native");
882
+ var import_runtime2 = require("@quickbuilder.io/date-pickers/runtime");
883
+
884
+ // src/frameworks/react-native/DateCalendar.tsx
885
+ var import_react = require("react");
886
+ var import_lucide_line = require("@quickbuilder.io/icons/packs/lucide-line");
887
+ var import_react_native2 = require("@quickbuilder.io/design-system/react-native");
888
+ var import_calendar4 = require("@quickbuilder.io/design-system/calendar");
889
+ var import_runtime = require("@quickbuilder.io/date-pickers/runtime");
890
+
891
+ // src/frameworks/react-native/DateCalendar.parts.tsx
892
+ var import_react_native = require("@quickbuilder.io/design-system/react-native");
893
+ var import_calendar3 = require("@quickbuilder.io/design-system/calendar");
894
+ var import_jsx_runtime = require("react/jsx-runtime");
895
+ function CalendarMonthSelection({
896
+ month,
897
+ calendarSystem,
898
+ calendarLocale,
899
+ locale,
900
+ blocked,
901
+ setMonth,
902
+ close
903
+ }) {
904
+ const parts = (0, import_calendar3.getCalendarSystemDateParts)(month, calendarSystem);
905
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.Box, { padding: "small", gap: "small", children: [
906
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
907
+ import_react_native.Dropdown,
908
+ {
909
+ label: "Month",
910
+ disabled: blocked,
911
+ value: String(parts.month),
912
+ options: Array.from({ length: 12 }, (_, index) => {
913
+ const date = (0, import_calendar3.addCalendarSystemMonths)(
914
+ month,
915
+ index - parts.month + 1,
916
+ calendarSystem
917
+ );
918
+ const option = (0, import_calendar3.getCalendarSystemDateParts)(date, calendarSystem);
919
+ return {
920
+ value: String(option.month),
921
+ label: new Intl.DateTimeFormat(calendarLocale, {
922
+ month: "long"
923
+ }).format(date)
924
+ };
925
+ }),
926
+ onChange: (value) => {
927
+ if (value) {
928
+ setMonth(
929
+ (0, import_calendar3.findCalendarSystemMonthStart)(
930
+ parts.year,
931
+ Number(value),
932
+ calendarSystem,
933
+ month
934
+ )
935
+ );
936
+ close();
937
+ }
938
+ }
939
+ }
940
+ ),
941
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
942
+ import_react_native.NumberInput,
943
+ {
944
+ label: "Year",
945
+ value: parts.year,
946
+ min: 1,
947
+ max: 9999,
948
+ precision: 0,
949
+ locale,
950
+ disabled: blocked,
951
+ onChange: (year) => {
952
+ if (year !== null)
953
+ setMonth(
954
+ (0, import_calendar3.findCalendarSystemMonthStart)(
955
+ year,
956
+ parts.month,
957
+ calendarSystem,
958
+ month
959
+ )
960
+ );
961
+ }
962
+ }
963
+ )
964
+ ] });
965
+ }
966
+
967
+ // src/frameworks/react-native/DateCalendar.tsx
968
+ var import_jsx_runtime2 = require("react/jsx-runtime");
969
+ function DateCalendar(rawProps) {
970
+ const theme = (0, import_react_native2.useNativeTheme)();
971
+ const [chooseMonth, setChooseMonth] = (0, import_react.useState)(false);
972
+ const field = (0, import_react_native2.useFormFieldState)(rawProps);
973
+ const props = { ...rawProps, ...field, label: rawProps.label };
974
+ assertDateBounds(props.minDate, props.maxDate);
975
+ const { adapter, adapterLocale } = (0, import_runtime.useDatePickersLocalization)();
976
+ const locale = resolveDatePickerLocale(props.locale ?? adapterLocale);
977
+ const calendarSystem = props.calendarSystem ?? getDatePickerCalendarSystem(adapter);
978
+ const selected = props.value === null ? null : adapter.toJsDate(props.value);
979
+ const [month, setMonth] = (0, import_react.useState)(
980
+ () => (0, import_calendar4.startOfCalendarSystemMonth)(selected ?? /* @__PURE__ */ new Date(), calendarSystem)
981
+ );
982
+ (0, import_react.useEffect)(() => {
983
+ if (selected)
984
+ setMonth((0, import_calendar4.startOfCalendarSystemMonth)(selected, calendarSystem));
985
+ }, [selected?.getTime(), calendarSystem]);
986
+ const firstDay = props.firstDayOfWeek ?? (0, import_calendar4.getDefaultFirstDayOfWeek)(locale);
987
+ const first = (0, import_calendar4.startOfCalendarSystemMonth)(month, calendarSystem);
988
+ const start = (0, import_calendar4.addCalendarDays)(first, -(first.getDay() - firstDay + 7) % 7);
989
+ const calendarLocale = (0, import_calendar4.getCalendarSystemLocale)(locale, calendarSystem);
990
+ const parts = (0, import_calendar4.getCalendarSystemDateParts)(month, calendarSystem);
991
+ const blocked = props.disabled || props.readOnly || props.loading;
992
+ if (props.loading)
993
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Loader, { accessibilityLabel: `Loading ${props.label}` });
994
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.Box, { gap: "small", children: [
995
+ props.showLabel !== false ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { accessibilityRole: "header", children: props.label }) : null,
996
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.Box, { direction: "row", style: { alignItems: "center" }, children: [
997
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
998
+ import_react_native2.IconButton,
999
+ {
1000
+ icon: { customIcon: import_lucide_line.chevronleftIcon, size: 18 },
1001
+ skin: "neutral",
1002
+ accessibilityLabel: "Previous month",
1003
+ disabled: blocked,
1004
+ onPress: () => setMonth((0, import_calendar4.addCalendarSystemMonths)(month, -1, calendarSystem))
1005
+ }
1006
+ ),
1007
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1008
+ import_react_native2.Button,
1009
+ {
1010
+ variant: "text",
1011
+ skin: "neutral",
1012
+ size: "small",
1013
+ style: { flex: 1 },
1014
+ disabled: blocked,
1015
+ suffixIcon: { customIcon: import_lucide_line.chevrondownIcon, size: 14 },
1016
+ onPress: () => setChooseMonth((open) => !open),
1017
+ children: new Intl.DateTimeFormat(calendarLocale, {
1018
+ year: "numeric",
1019
+ month: "long"
1020
+ }).format(month)
1021
+ }
1022
+ ),
1023
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1024
+ import_react_native2.IconButton,
1025
+ {
1026
+ icon: { customIcon: import_lucide_line.chevronrightIcon, size: 18 },
1027
+ skin: "neutral",
1028
+ accessibilityLabel: "Next month",
1029
+ disabled: blocked,
1030
+ onPress: () => setMonth((0, import_calendar4.addCalendarSystemMonths)(month, 1, calendarSystem))
1031
+ }
1032
+ )
1033
+ ] }),
1034
+ chooseMonth ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1035
+ CalendarMonthSelection,
1036
+ {
1037
+ month,
1038
+ calendarSystem,
1039
+ calendarLocale,
1040
+ locale,
1041
+ blocked,
1042
+ setMonth,
1043
+ close: () => setChooseMonth(false)
1044
+ }
1045
+ ) : null,
1046
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.Layout, { columns: 7, gap: "none", children: [
1047
+ Array.from({ length: 7 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Layout.Cell, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1048
+ import_react_native2.Text,
1049
+ {
1050
+ size: "tiny",
1051
+ weight: "semibold",
1052
+ style: {
1053
+ textAlign: "center",
1054
+ paddingVertical: theme.spacing.small
1055
+ },
1056
+ children: new Intl.DateTimeFormat(calendarLocale, {
1057
+ weekday: "short"
1058
+ }).format((0, import_calendar4.addCalendarDays)(start, index))
1059
+ }
1060
+ ) }, `weekday-${index}`)),
1061
+ Array.from({ length: 42 }, (_, index) => {
1062
+ const date = (0, import_calendar4.addCalendarDays)(start, index);
1063
+ const error = resolveDateValidationError({ ...props, value: date });
1064
+ const active = selected?.toDateString() === date.toDateString();
1065
+ const inMonth = (0, import_calendar4.getCalendarSystemDateParts)(date, calendarSystem).month === parts.month;
1066
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Layout.Cell, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1067
+ import_react_native2.Button,
1068
+ {
1069
+ size: "small",
1070
+ style: {
1071
+ paddingHorizontal: 0,
1072
+ paddingVertical: 0,
1073
+ width: "100%"
1074
+ },
1075
+ visualInset: 8,
1076
+ skin: active || inMonth ? "standard" : "muted",
1077
+ selected: active,
1078
+ variant: active ? "primary" : "text",
1079
+ disabled: blocked || Boolean(error),
1080
+ accessibilityLabel: `${new Intl.DateTimeFormat(calendarLocale, { dateStyle: "full" }).format(date)}${active ? ", selected" : ""}`,
1081
+ onPress: () => props.onChange(adapter.fromJsDate(date), {
1082
+ validationError: null
1083
+ }),
1084
+ children: new Intl.DateTimeFormat(calendarLocale, {
1085
+ day: "numeric"
1086
+ }).format(date)
1087
+ }
1088
+ ) }, date.toISOString());
1089
+ })
1090
+ ] })
1091
+ ] });
1092
+ }
1093
+
1094
+ // src/frameworks/react-native/PickerField.parts.tsx
1095
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1096
+ function NativePickerPanel({
1097
+ props,
1098
+ current,
1099
+ hour12,
1100
+ selection,
1101
+ setSelection,
1102
+ changeTime,
1103
+ trialError,
1104
+ commit
1105
+ }) {
1106
+ const [hourError, setHourError] = (0, import_react2.useState)();
1107
+ const [minuteError, setMinuteError] = (0, import_react2.useState)();
1108
+ const { adapter, localeText } = (0, import_runtime2.useDatePickersLocalization)();
1109
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native3.Box, { gap: "medium", padding: props.mode === "date" ? "small" : void 0, children: [
1110
+ props.mode !== "time" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1111
+ DateCalendar,
1112
+ {
1113
+ ...props,
1114
+ showLabel: false,
1115
+ value: adapter.fromJsDate(current),
1116
+ onChange: (value) => {
1117
+ if (value !== null) {
1118
+ const next = adapter.toJsDate(value);
1119
+ if (props.mode === "datetime")
1120
+ next.setHours(current.getHours(), current.getMinutes(), 0, 0);
1121
+ setSelection(next);
1122
+ }
1123
+ }
1124
+ }
1125
+ ) : null,
1126
+ props.mode !== "date" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native3.Box, { gap: "small", children: [
1127
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1128
+ import_react_native3.NumberInput,
1129
+ {
1130
+ required: true,
1131
+ requiredMessage: dateTimeValidationMessages.invalidTime,
1132
+ shape: props.shape,
1133
+ size: props.size,
1134
+ onError: setHourError,
1135
+ label: localeText.hoursLabel,
1136
+ precision: 0,
1137
+ min: hour12 ? 1 : 0,
1138
+ max: hour12 ? 12 : 23,
1139
+ value: hour12 ? current.getHours() % 12 || 12 : current.getHours(),
1140
+ onChange: (hour) => {
1141
+ if (hour !== null)
1142
+ changeTime(
1143
+ hour12 ? hour % 12 + (current.getHours() >= 12 ? 12 : 0) : hour,
1144
+ current.getMinutes()
1145
+ );
1146
+ }
1147
+ }
1148
+ ),
1149
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1150
+ import_react_native3.NumberInput,
1151
+ {
1152
+ required: true,
1153
+ requiredMessage: dateTimeValidationMessages.invalidTime,
1154
+ shape: props.shape,
1155
+ size: props.size,
1156
+ onError: setMinuteError,
1157
+ label: localeText.minutesLabel,
1158
+ precision: 0,
1159
+ min: 0,
1160
+ max: 59,
1161
+ value: current.getMinutes(),
1162
+ onChange: (minute) => {
1163
+ if (minute !== null) changeTime(current.getHours(), minute);
1164
+ }
1165
+ }
1166
+ ),
1167
+ hour12 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1168
+ import_react_native3.SegmentedToggle,
1169
+ {
1170
+ label: localeText.dayPeriodLabel,
1171
+ options: [
1172
+ { value: "am", label: "AM" },
1173
+ { value: "pm", label: "PM" }
1174
+ ],
1175
+ value: current.getHours() >= 12 ? "pm" : "am",
1176
+ onChange: (period) => changeTime(
1177
+ current.getHours() % 12 + (period === "pm" ? 12 : 0),
1178
+ current.getMinutes()
1179
+ )
1180
+ }
1181
+ ) : null
1182
+ ] }) : null,
1183
+ trialError ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.SectionHelper, { severity: "error", children: dateTimeValidationMessages[trialError] }) : null,
1184
+ props.mode !== "date" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1185
+ import_react_native3.Button,
1186
+ {
1187
+ disabled: Boolean(trialError || hourError || minuteError),
1188
+ onPress: () => commit(selection),
1189
+ children: props.confirmationLabel ?? localeText.applyButtonLabel
1190
+ }
1191
+ ) : null,
1192
+ props.clearable && !props.required ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Button, { variant: "text", size: "small", onPress: () => commit(null), children: localeText.clearButtonLabel }) : null
1193
+ ] });
1194
+ }
1195
+ function NativePickerSurface({
1196
+ props,
1197
+ open,
1198
+ blocked,
1199
+ trialError,
1200
+ onCancel,
1201
+ onConfirm,
1202
+ children
1203
+ }) {
1204
+ const { localeText } = (0, import_runtime2.useDatePickersLocalization)();
1205
+ const Surface = props.mode === "date" ? import_react_native3.BottomSheet : import_react_native3.Modal;
1206
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1207
+ Surface,
1208
+ {
1209
+ visible: open && !blocked,
1210
+ title: props.pickerTitle ?? props.label,
1211
+ bottomInset: props.bottomInset,
1212
+ floating: props.mode === "date",
1213
+ sheetHeader: props.mode === "date" ? "selection" : "default",
1214
+ closePlacement: props.mode === "date" ? "none" : "footer",
1215
+ footer: props.mode === "date" ? null : void 0,
1216
+ contentPadding: props.mode === "date" ? "none" : "medium",
1217
+ dismissOnBackdropPress: props.mode === "date",
1218
+ headerActions: props.mode === "date" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1219
+ import_react_native3.Button,
1220
+ {
1221
+ variant: "text",
1222
+ size: "small",
1223
+ disabled: Boolean(trialError),
1224
+ onPress: onConfirm,
1225
+ children: props.confirmationLabel ?? localeText.applyButtonLabel
1226
+ }
1227
+ ) : void 0,
1228
+ closeLabel: localeText.cancelButtonLabel,
1229
+ onRequestClose: onCancel,
1230
+ children
1231
+ }
1232
+ );
1233
+ }
1234
+
1235
+ // src/frameworks/react-native/PickerField.tsx
1236
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1237
+ function NativePickerField(rawProps) {
1238
+ const field = (0, import_react_native4.useFormFieldState)(rawProps);
1239
+ const props = { ...rawProps, ...field, label: rawProps.label };
1240
+ if ([props.pickerTitle, props.confirmationLabel].some(
1241
+ (text) => text !== void 0 && !text.trim()
1242
+ ))
1243
+ throw new Error("Native picker panel labels must not be empty");
1244
+ if (props.dateFormat !== void 0 && (props.mode !== "date" || !["numeric", "medium"].includes(props.dateFormat)))
1245
+ throw new Error(
1246
+ "Native dateFormat requires a DatePicker and a supported format"
1247
+ );
1248
+ const {
1249
+ adapter,
1250
+ adapterLocale,
1251
+ localeText,
1252
+ timezone: providerTimezone
1253
+ } = (0, import_runtime3.useDatePickersLocalization)();
1254
+ const locale = resolveDatePickerLocale(props.locale ?? adapterLocale);
1255
+ const calendarSystem = props.calendarSystem ?? getDatePickerCalendarSystem(adapter);
1256
+ const timezone = resolvePickerTimezone(props.timezone, providerTimezone) ?? (props.mode === "datetime" ? resolvePickerTimezone("system") : void 0);
1257
+ const hour12 = props.hour12 ?? new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hour12 ?? false;
1258
+ const codec = createDateTimeCodec(locale, calendarSystem, hour12);
1259
+ const step = props.minutesStep ?? 1;
1260
+ if (!Number.isInteger(step) || step <= 0 || 60 % step !== 0)
1261
+ throw new RangeError("minutesStep must divide 60");
1262
+ const dateFormat = new Intl.DateTimeFormat(
1263
+ (0, import_calendar5.getCalendarSystemLocale)(locale, calendarSystem),
1264
+ props.dateFormat === "medium" ? { year: "numeric", month: "short", day: "numeric" } : { year: "numeric", month: "2-digit", day: "2-digit" }
1265
+ );
1266
+ const stored = props.value === null ? null : toPickerDate(adapter, props.value, "value");
1267
+ const display = toTimezoneDisplayDate(stored, timezone);
1268
+ const constraints = {
1269
+ ...props,
1270
+ minutesStep: step,
1271
+ minDate: toTimezoneDisplayDate(props.minDate ?? null, timezone) ?? void 0,
1272
+ maxDate: toTimezoneDisplayDate(props.maxDate ?? null, timezone) ?? void 0,
1273
+ minTime: toTimezoneDisplayDate(props.minTime ?? null, timezone) ?? void 0,
1274
+ maxTime: toTimezoneDisplayDate(props.maxTime ?? null, timezone) ?? void 0,
1275
+ today: toTimezoneDisplayDate(/* @__PURE__ */ new Date(), timezone)
1276
+ };
1277
+ assertDateTimeBounds(constraints);
1278
+ const format = (date) => date ? props.mode === "date" ? dateFormat.format(date) : props.mode === "time" ? codec.formatTime(date) : codec.format(date) : "";
1279
+ const [open, setOpen] = (0, import_react3.useState)(false);
1280
+ const [draft, setDraft] = (0, import_react3.useState)(format(display));
1281
+ const [selection, setSelection] = (0, import_react3.useState)(display);
1282
+ const [error, setError] = (0, import_react3.useState)(
1283
+ null
1284
+ );
1285
+ const blocked = props.disabled || props.readOnly || props.loading;
1286
+ (0, import_react3.useEffect)(() => {
1287
+ setDraft(format(display));
1288
+ setSelection(display);
1289
+ setError(null);
1290
+ setOpen(false);
1291
+ }, [display?.getTime(), locale, calendarSystem, timezone, props.dateFormat]);
1292
+ function validateValue(date, instant) {
1293
+ if (date === null) return props.required ? "required" : null;
1294
+ if (props.mode === "date") return resolveDateValidationError({ ...constraints, value: date });
1295
+ if (props.mode === "time") return date.getMinutes() % step ? "minutesStep" : resolveTimeValidationError({ ...constraints, now: constraints.today, value: date });
1296
+ return validateDateTime(date, instant, constraints);
1297
+ }
1298
+ function validate(date) {
1299
+ const resolved = date ? resolveDateTimeInstant(date, timezone, props.disambiguation ?? "reject") : { date: null, error: null };
1300
+ return {
1301
+ date: resolved.date,
1302
+ error: resolved.error ?? validateValue(date, resolved.date)
1303
+ };
1304
+ }
1305
+ function commit(date) {
1306
+ if (blocked) return;
1307
+ const result = validate(date);
1308
+ setError(result.error);
1309
+ props.onError?.(result.error);
1310
+ if (result.error) return;
1311
+ props.onChange(result.date ? adapter.fromJsDate(result.date) : null, {
1312
+ validationError: null
1313
+ });
1314
+ setOpen(false);
1315
+ setDraft(format(date));
1316
+ }
1317
+ const current = selection ?? constraints.today;
1318
+ const changeTime = (hour, minute) => {
1319
+ const next = new Date(current);
1320
+ next.setHours(hour, minute, 0, 0);
1321
+ setSelection(next);
1322
+ setError(null);
1323
+ };
1324
+ const trial = validate(selection);
1325
+ const acceptedError = validateValue(display, stored);
1326
+ function edit(text) {
1327
+ if (blocked) return;
1328
+ setDraft(text);
1329
+ const date = !text.trim() ? null : props.mode === "date" ? (0, import_calendar5.parseDateInputForCalendarSystem)(
1330
+ text,
1331
+ locale,
1332
+ calendarSystem,
1333
+ true
1334
+ ) ?? null : codec.parse(
1335
+ props.mode === "time" ? `${dateFormat.format(display ?? constraints.today)}, ${text}` : text
1336
+ );
1337
+ const result = !date && text.trim() ? {
1338
+ date: null,
1339
+ error: props.mode === "time" ? "invalidTime" : "invalidDate"
1340
+ } : validate(date);
1341
+ setError(result.error);
1342
+ props.onError?.(result.error);
1343
+ if (!result.error)
1344
+ props.onChange(result.date ? adapter.fromJsDate(result.date) : null, {
1345
+ validationError: null
1346
+ });
1347
+ }
1348
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native4.Box, { gap: "small", children: [
1349
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1350
+ import_react_native4.Input,
1351
+ {
1352
+ label: props.label,
1353
+ shape: props.shape,
1354
+ size: props.size,
1355
+ description: props.description,
1356
+ required: props.required,
1357
+ suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1358
+ import_react_native4.IconButton,
1359
+ {
1360
+ skin: "neutral",
1361
+ icon: {
1362
+ customIcon: props.mode === "time" ? import_lucide_line2.clockIcon : import_lucide_line2.calendarIcon
1363
+ },
1364
+ accessibilityLabel: props.mode === "date" ? localeText.datePickerToolbarTitle : props.mode === "time" ? localeText.timePickerToolbarTitle : localeText.dateTimePickerToolbarTitle,
1365
+ disabled: blocked,
1366
+ shape: props.shape,
1367
+ onPress: () => {
1368
+ const reference = display ?? toTimezoneDisplayDate(/* @__PURE__ */ new Date(), timezone);
1369
+ reference.setSeconds(0, 0);
1370
+ setSelection(reference);
1371
+ setError(null);
1372
+ setOpen(true);
1373
+ }
1374
+ }
1375
+ ),
1376
+ value: draft,
1377
+ disabled: props.disabled,
1378
+ editable: !props.loading,
1379
+ readOnly: props.readOnly,
1380
+ onChangeText: edit,
1381
+ onSubmitEditing: () => {
1382
+ if (!error) setDraft(format(display));
1383
+ },
1384
+ error: props.error ?? (error ?? acceptedError ? dateTimeValidationMessages[error ?? acceptedError] : void 0)
1385
+ }
1386
+ ),
1387
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1388
+ NativePickerSurface,
1389
+ {
1390
+ props,
1391
+ open,
1392
+ blocked,
1393
+ trialError: trial.error,
1394
+ onConfirm: () => commit(selection),
1395
+ onCancel: () => {
1396
+ setOpen(false);
1397
+ setSelection(display);
1398
+ setError(null);
1399
+ },
1400
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1401
+ NativePickerPanel,
1402
+ {
1403
+ props: constraints,
1404
+ current,
1405
+ hour12,
1406
+ selection,
1407
+ setSelection,
1408
+ changeTime,
1409
+ trialError: trial.error,
1410
+ commit
1411
+ }
1412
+ )
1413
+ }
1414
+ )
1415
+ ] });
1416
+ }
1417
+
1418
+ // src/frameworks/react-native/DatePicker.tsx
1419
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1420
+ function DatePicker(props) {
1421
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NativePickerField, { ...props, mode: "date" });
1422
+ }
1423
+
1424
+ // src/frameworks/react-native/TimePicker.tsx
1425
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1426
+ function TimePicker(props) {
1427
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(NativePickerField, { ...props, mode: "time" });
1428
+ }
1429
+
1430
+ // src/frameworks/react-native/DateTimePicker.tsx
1431
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1432
+ function DateTimePicker(props) {
1433
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NativePickerField, { ...props, mode: "datetime" });
1434
+ }
1435
+
1436
+ // src/frameworks/react-native/index.ts
1437
+ var import_runtime4 = require("@quickbuilder.io/date-pickers/runtime");
1438
+
1439
+ // src/framework-adapter.ts
1440
+ var datePickersFrameworkAdapterSupport = Object.freeze([
1441
+ { framework: "react", entrypoint: "@quickbuilder.io/date-pickers/react", status: "implemented" },
1442
+ { framework: "vue", status: "unsupported" },
1443
+ { framework: "preact", status: "unsupported" },
1444
+ { framework: "qwik", status: "unsupported" },
1445
+ { framework: "astro", status: "unsupported" },
1446
+ { framework: "svelte", status: "unsupported" },
1447
+ { framework: "solid", status: "unsupported" },
1448
+ { framework: "web-components", status: "unsupported" },
1449
+ { framework: "react-native", status: "implemented", entrypoint: "@quickbuilder.io/date-pickers/react-native" }
1450
+ ]);
1451
+ var frameworkAdapterSupport = datePickersFrameworkAdapterSupport;
1452
+
1453
+ // src/DatePickers.capabilities.ts
1454
+ var datePickerCapabilityFeatures = [
1455
+ { id: "date-picker", label: "Date picker", category: "field", packageTier: "community", status: "implemented" },
1456
+ { id: "time-picker", label: "Time picker", category: "field", packageTier: "community", status: "implemented" },
1457
+ { id: "date-time-picker", label: "Date time picker", category: "field", packageTier: "community", status: "implemented" },
1458
+ { id: "date-calendar", label: "Date calendar", category: "view", packageTier: "community", status: "implemented" },
1459
+ { id: "controlled-state", label: "Controlled and uncontrolled values", category: "field", packageTier: "community", status: "implemented" },
1460
+ { id: "validation", label: "Date and time validation", category: "validation", packageTier: "community", status: "implemented" },
1461
+ { id: "localization", label: "Locale-aware formatting", category: "localization", packageTier: "community", status: "implemented" },
1462
+ { id: "localization-provider", label: "Localization provider", category: "localization", packageTier: "community", status: "implemented" },
1463
+ { id: "date-adapters", label: "Date adapter contract", category: "localization", packageTier: "community", status: "implemented" },
1464
+ { id: "date-adapter-bridges", label: "Day.js, date-fns, Luxon, and Moment adapter bridges", category: "localization", packageTier: "community", status: "implemented" },
1465
+ { id: "calendar-system-adapter-bridges", label: "Jalali, Hijri, and Buddhist adapter bridges", category: "localization", packageTier: "community", status: "implemented" },
1466
+ { id: "calendar-system-display-labels", label: "Calendar-system display labels", category: "localization", packageTier: "community", status: "implemented" },
1467
+ { id: "calendar-system-field-values", label: "Calendar-system field parsing and formatting", category: "localization", packageTier: "community", status: "implemented" },
1468
+ { id: "slots", label: "Slots and slot props", category: "customization", packageTier: "community", status: "implemented" },
1469
+ { id: "date-range-picker", label: "Date range picker", category: "field", packageTier: "pro", status: "implemented" },
1470
+ { id: "time-range-picker", label: "Time range picker", category: "field", packageTier: "pro", status: "implemented" },
1471
+ { id: "date-time-range-picker", label: "Date time range picker", category: "field", packageTier: "pro", status: "implemented" },
1472
+ { id: "range-shortcuts", label: "Range shortcuts", category: "customization", packageTier: "pro", status: "implemented" },
1473
+ { id: "timezone-values", label: "Timezone-aware rendering and value conversion", category: "localization", packageTier: "community", status: "implemented" },
1474
+ { id: "non-gregorian-calendar-grid", label: "Native non-Gregorian calendar grid rendering", category: "localization", packageTier: "community", status: "implemented" }
1475
+ ];
1476
+ var datePickerCapabilityFeatureIds = datePickerCapabilityFeatures.map((feature) => feature.id);
1477
+
1478
+ // src/DatePickersFormatting.ts
1479
+ var RELATIVE_THRESHOLDS = Object.freeze([
1480
+ { limit: 60, milliseconds: 1e3, unit: "second" },
1481
+ { limit: 60, milliseconds: 6e4, unit: "minute" },
1482
+ { limit: 24, milliseconds: 36e5, unit: "hour" },
1483
+ { limit: 7, milliseconds: 864e5, unit: "day" },
1484
+ { limit: 5, milliseconds: 6048e5, unit: "week" },
1485
+ { limit: 12, milliseconds: 2629746e3, unit: "month" },
1486
+ {
1487
+ limit: Number.POSITIVE_INFINITY,
1488
+ milliseconds: 31556952e3,
1489
+ unit: "year"
1490
+ }
1491
+ ]);
1492
+ function toDatePickerDate(value) {
1493
+ const date = value instanceof Date ? new Date(value.getTime()) : new Date(value);
1494
+ if (Number.isNaN(date.getTime())) {
1495
+ throw new RangeError(`Invalid date value "${String(value)}".`);
1496
+ }
1497
+ return date;
1498
+ }
1499
+ function formatDateTime(value, { locale = "en-US", ...options } = {}) {
1500
+ return new Intl.DateTimeFormat(
1501
+ locale,
1502
+ Object.keys(options).length > 0 ? options : { dateStyle: "medium" }
1503
+ ).format(toDatePickerDate(value));
1504
+ }
1505
+ function formatDatePattern(value, pattern, locale = "en-US") {
1506
+ const date = toDatePickerDate(value);
1507
+ if (pattern === "yyyy-MM-dd") {
1508
+ return [
1509
+ String(date.getFullYear()).padStart(4, "0"),
1510
+ String(date.getMonth() + 1).padStart(2, "0"),
1511
+ String(date.getDate()).padStart(2, "0")
1512
+ ].join("-");
1513
+ }
1514
+ const optionsByPattern = {
1515
+ PPpp: { dateStyle: "medium", timeStyle: "short" },
1516
+ EEE: { weekday: "short" },
1517
+ "EEEE, MMMM d, yyyy": {
1518
+ day: "numeric",
1519
+ month: "long",
1520
+ weekday: "long",
1521
+ year: "numeric"
1522
+ },
1523
+ "MMM d": { day: "numeric", month: "short" },
1524
+ "MMM d, h:mm a": {
1525
+ day: "numeric",
1526
+ hour: "numeric",
1527
+ hour12: true,
1528
+ minute: "2-digit",
1529
+ month: "short"
1530
+ },
1531
+ "MMM d, yyyy": { day: "numeric", month: "short", year: "numeric" },
1532
+ "MMMM d, yyyy": { day: "numeric", month: "long", year: "numeric" },
1533
+ "MMMM yyyy": { month: "long", year: "numeric" },
1534
+ d: { day: "numeric" },
1535
+ "h a": { hour: "numeric", hour12: true },
1536
+ "h:mm a": { hour: "numeric", hour12: true, minute: "2-digit" }
1537
+ };
1538
+ const options = optionsByPattern[pattern];
1539
+ if (!options) {
1540
+ throw new RangeError(
1541
+ `Unsupported Quick Builder date pattern "${pattern}".`
1542
+ );
1543
+ }
1544
+ return new Intl.DateTimeFormat(locale, options).format(date);
1545
+ }
1546
+ function formatRelativeTime(value, {
1547
+ addSuffix = true,
1548
+ locale = "en-US",
1549
+ now = Date.now(),
1550
+ numeric = "always"
1551
+ } = {}) {
1552
+ const difference = toDatePickerDate(value).getTime() - toDatePickerDate(now).getTime();
1553
+ const absoluteDifference = Math.abs(difference);
1554
+ const selected = RELATIVE_THRESHOLDS.find(
1555
+ ({ limit, milliseconds }) => absoluteDifference < limit * milliseconds
1556
+ ) ?? RELATIVE_THRESHOLDS[RELATIVE_THRESHOLDS.length - 1];
1557
+ const rawValue = difference / selected.milliseconds;
1558
+ const roundedValue = rawValue < 0 ? Math.ceil(rawValue) : Math.floor(rawValue);
1559
+ const displayValue = roundedValue === 0 && difference !== 0 ? difference < 0 ? -1 : 1 : roundedValue;
1560
+ if (addSuffix) {
1561
+ return new Intl.RelativeTimeFormat(locale, {
1562
+ numeric,
1563
+ style: "long"
1564
+ }).format(displayValue, selected.unit);
1565
+ }
1566
+ return new Intl.NumberFormat(locale, {
1567
+ style: "unit",
1568
+ unit: selected.unit,
1569
+ unitDisplay: "long"
1570
+ }).format(Math.abs(displayValue));
1571
+ }
1572
+ function parseIsoDate(value) {
1573
+ return toDatePickerDate(value);
1574
+ }
1575
+ function addCalendarDays2(value, amount) {
1576
+ const date = toDatePickerDate(value);
1577
+ date.setDate(date.getDate() + amount);
1578
+ return date;
1579
+ }
1580
+ function subtractCalendarDays(value, amount) {
1581
+ return addCalendarDays2(value, -amount);
1582
+ }
1583
+ function isSameCalendarDay(left, right) {
1584
+ const leftDate = toDatePickerDate(left);
1585
+ const rightDate = toDatePickerDate(right);
1586
+ return leftDate.getFullYear() === rightDate.getFullYear() && leftDate.getMonth() === rightDate.getMonth() && leftDate.getDate() === rightDate.getDate();
1587
+ }
1588
+ function isDateToday(value, now = Date.now()) {
1589
+ return isSameCalendarDay(value, now);
1590
+ }
1591
+ function isDateYesterday(value, now = Date.now()) {
1592
+ return isSameCalendarDay(value, addCalendarDays2(now, -1));
1593
+ }
1594
+ function isDateThisWeek(value, {
1595
+ now = Date.now(),
1596
+ weekStartsOn = 0
1597
+ } = {}) {
1598
+ if (!Number.isInteger(weekStartsOn) || weekStartsOn < 0 || weekStartsOn > 6) {
1599
+ throw new RangeError("weekStartsOn must be an integer from 0 through 6.");
1600
+ }
1601
+ const reference = toDatePickerDate(now);
1602
+ const start = new Date(
1603
+ reference.getFullYear(),
1604
+ reference.getMonth(),
1605
+ reference.getDate()
1606
+ );
1607
+ start.setDate(start.getDate() - (start.getDay() - weekStartsOn + 7) % 7);
1608
+ const end = addCalendarDays2(start, 7);
1609
+ const candidate = toDatePickerDate(value).getTime();
1610
+ return candidate >= start.getTime() && candidate < end.getTime();
1611
+ }
1612
+
1613
+ // src/DatePickers.storage.ts
1614
+ function assertDate(value, basis = "local") {
1615
+ if (!(value instanceof Date) || !Number.isFinite(value.getTime()))
1616
+ throw new TypeError("Invalid picker date");
1617
+ const year = basis === "utc" ? value.getUTCFullYear() : value.getFullYear();
1618
+ if (year < 1 || year > 9999) throw new TypeError("Invalid picker date");
1619
+ }
1620
+ var pad = (value, width = 2) => String(value).padStart(width, "0");
1621
+ function serializePickerDate(value) {
1622
+ assertDate(value);
1623
+ return {
1624
+ version: 1,
1625
+ kind: "date",
1626
+ date: `${pad(value.getFullYear(), 4)}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`
1627
+ };
1628
+ }
1629
+ function serializePickerTime(value) {
1630
+ assertDate(value);
1631
+ if (value.getSeconds() || value.getMilliseconds())
1632
+ throw new Error("Time picker storage requires minute precision");
1633
+ return {
1634
+ version: 1,
1635
+ kind: "time",
1636
+ time: `${pad(value.getHours())}:${pad(value.getMinutes())}`
1637
+ };
1638
+ }
1639
+ function serializePickerDateTime(value, timezone) {
1640
+ assertDate(value, "utc");
1641
+ if (!timezone || timezone === "system" || timezone === "default")
1642
+ throw new Error("Persist an explicit display timezone");
1643
+ assertSupportedTimezone(timezone);
1644
+ return {
1645
+ version: 1,
1646
+ kind: "dateTime",
1647
+ instant: value.toISOString(),
1648
+ timezone
1649
+ };
1650
+ }
1651
+ function parseStoredPickerValue(input) {
1652
+ if (!input || typeof input !== "object" || Array.isArray(input))
1653
+ throw new TypeError("Expected picker storage schema version 1");
1654
+ const value = Object.getOwnPropertyDescriptors(input);
1655
+ if (Object.values(value).some((property) => !("value" in property)))
1656
+ throw new TypeError("Picker storage must contain JSON values");
1657
+ const record = Object.fromEntries(
1658
+ Object.entries(value).map(([key, descriptor]) => [key, descriptor.value])
1659
+ );
1660
+ const fields = record.kind === "date" ? ["version", "kind", "date"] : record.kind === "time" ? ["version", "kind", "time"] : ["version", "kind", "instant", "timezone"];
1661
+ if (record.version !== 1 || Object.keys(record).length !== fields.length || Object.keys(record).some((key) => !fields.includes(key)))
1662
+ throw new TypeError("Invalid picker storage fields");
1663
+ if (record.kind === "date" && typeof record.date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(record.date)) {
1664
+ const [year, month, day] = record.date.split("-").map(Number);
1665
+ const date = /* @__PURE__ */ new Date(0);
1666
+ date.setUTCFullYear(year, month - 1, day);
1667
+ date.setUTCHours(0, 0, 0, 0);
1668
+ if (year >= 1 && date.toISOString().slice(0, 10) === record.date)
1669
+ return { version: 1, kind: "date", date: record.date };
1670
+ }
1671
+ if (record.kind === "time" && typeof record.time === "string" && /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(record.time))
1672
+ return { version: 1, kind: "time", time: record.time };
1673
+ if (record.kind === "dateTime" && typeof record.instant === "string" && typeof record.timezone === "string") {
1674
+ const date = new Date(record.instant);
1675
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(record.instant) && Number.isFinite(date.getTime()) && date.toISOString() === record.instant)
1676
+ return serializePickerDateTime(date, record.timezone);
1677
+ }
1678
+ throw new TypeError("Invalid stored picker value");
1679
+ }
1680
+
1681
+ // src/core.ts
1682
+ var datePickersPackageManifest = {
1683
+ packageName: "@quickbuilder.io/date-pickers",
1684
+ displayName: "Quick Builder Date Pickers",
1685
+ family: "date-pickers",
1686
+ tier: "community",
1687
+ designSystemDependency: "@quickbuilder.io/design-system",
1688
+ status: "implemented"
1689
+ };
1690
+ var packageManifest = datePickersPackageManifest;
1691
+
1692
+ // src/frameworks/react-native/index.ts
1693
+ var reactNativeFrameworkAdapter = Object.freeze({ apiVersion: 1, id: "quickbuilder-date-pickers-react-native", packageName: "@quickbuilder.io/date-pickers", framework: "react-native", entrypoint: "@quickbuilder.io/date-pickers/react-native", status: "implemented", capabilities: Object.freeze(["date-input", "time-input", "date-time-input", "calendar", "timezone-validation"]) });
1694
+ // Annotate the CommonJS export names for ESM import in node:
1695
+ 0 && (module.exports = {
1696
+ AdapterDateFns,
1697
+ AdapterDateFnsJalali,
1698
+ AdapterDayjs,
1699
+ AdapterDayjsBuddhist,
1700
+ AdapterLuxon,
1701
+ AdapterMoment,
1702
+ AdapterMomentHijri,
1703
+ AdapterMomentJalaali,
1704
+ AdapterNativeDate,
1705
+ DateCalendar,
1706
+ DatePicker,
1707
+ DatePickersLocalizationProvider,
1708
+ DateTimePicker,
1709
+ TimePicker,
1710
+ addCalendarDays,
1711
+ addZonedCalendarDays,
1712
+ assertSupportedTimezone,
1713
+ cloneDate,
1714
+ createDatePickerAdapter,
1715
+ datePickerCalendarSystemAdapters,
1716
+ datePickerCapabilityFeatureIds,
1717
+ datePickerCapabilityFeatures,
1718
+ datePickersFrameworkAdapterSupport,
1719
+ datePickersPackageManifest,
1720
+ defaultDatePickerLocaleText,
1721
+ formatDatePattern,
1722
+ formatDateTime,
1723
+ formatRelativeTime,
1724
+ frameworkAdapterSupport,
1725
+ fromTimezoneDisplayDate,
1726
+ getDatePickerCalendarSystem,
1727
+ getSystemTimezone,
1728
+ getZonedCivilTimestamp,
1729
+ isCalendarSystemAdapter,
1730
+ isDateThisWeek,
1731
+ isDateToday,
1732
+ isDateYesterday,
1733
+ isSameCalendarDay,
1734
+ isValidDate,
1735
+ mergeDateAndTime,
1736
+ minutesFromDate,
1737
+ packageManifest,
1738
+ parseIsoDate,
1739
+ parseStoredPickerValue,
1740
+ reactNativeFrameworkAdapter,
1741
+ resolveDatePickerLocale,
1742
+ resolveDatePickerLocaleText,
1743
+ resolveDateTimeInstant,
1744
+ resolveDateValidationError,
1745
+ resolvePickerTimezone,
1746
+ resolveTimeValidationError,
1747
+ resolveZonedCivilTimestamp,
1748
+ serializePickerDate,
1749
+ serializePickerDateTime,
1750
+ serializePickerTime,
1751
+ shouldAllowDate,
1752
+ shouldAllowTime,
1753
+ startOfDay,
1754
+ subtractCalendarDays,
1755
+ supportsDatePickerCalendarSystem,
1756
+ toDatePickerDate,
1757
+ toPickerDate,
1758
+ toTimezoneDisplayDate,
1759
+ useDatePickersLocalization
1760
+ });
1761
+ //# sourceMappingURL=react-native.js.map