@panneau/fields 5.0.0-alpha.15 → 5.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +53 -3
  2. package/dist/address/AddressField.css +44 -0
  3. package/dist/address/AddressField.d.ts +37 -0
  4. package/dist/address/AddressField.d.ts.map +1 -0
  5. package/dist/address/AddressField.js +411 -0
  6. package/dist/address/AddressField.js.map +1 -0
  7. package/dist/address/AddressField.module.js +22 -0
  8. package/dist/address/AddressField.module.js.map +1 -0
  9. package/dist/address/address.d.ts +23 -0
  10. package/dist/address/address.d.ts.map +1 -0
  11. package/dist/address/address.js +58 -0
  12. package/dist/address/address.js.map +1 -0
  13. package/dist/address/index.d.ts +3 -0
  14. package/dist/address/index.d.ts.map +1 -0
  15. package/dist/address/index.js +3 -0
  16. package/dist/color/ColorField.css +9 -0
  17. package/dist/color/ColorField.d.ts +10 -3
  18. package/dist/color/ColorField.d.ts.map +1 -1
  19. package/dist/color/ColorField.js +341 -81
  20. package/dist/color/ColorField.js.map +1 -1
  21. package/dist/color/ColorField.module.js +4 -2
  22. package/dist/color/ColorField.module.js.map +1 -1
  23. package/dist/color/index.d.ts +1 -0
  24. package/dist/color/index.d.ts.map +1 -1
  25. package/dist/color/index.js +3 -1
  26. package/dist/color/palette.d.ts +23 -0
  27. package/dist/color/palette.d.ts.map +1 -0
  28. package/dist/color/palette.js +34 -0
  29. package/dist/color/palette.js.map +1 -0
  30. package/dist/country/CountryField.css +42 -0
  31. package/dist/country/CountryField.d.ts +19 -4
  32. package/dist/country/CountryField.d.ts.map +1 -1
  33. package/dist/country/CountryField.js +355 -82
  34. package/dist/country/CountryField.js.map +1 -1
  35. package/dist/country/CountryField.module.js +20 -0
  36. package/dist/country/CountryField.module.js.map +1 -0
  37. package/dist/country/index.d.ts +1 -1
  38. package/dist/country/index.d.ts.map +1 -1
  39. package/dist/daterange/DateRangeField.css +9 -0
  40. package/dist/daterange/DateRangeField.d.ts +31 -0
  41. package/dist/daterange/DateRangeField.d.ts.map +1 -0
  42. package/dist/daterange/DateRangeField.js +372 -0
  43. package/dist/daterange/DateRangeField.js.map +1 -0
  44. package/dist/daterange/DateRangeField.module.js +12 -0
  45. package/dist/daterange/DateRangeField.module.js.map +1 -0
  46. package/dist/daterange/index.d.ts +3 -0
  47. package/dist/daterange/index.d.ts.map +1 -0
  48. package/dist/daterange/index.js +3 -0
  49. package/dist/daterange/range.d.ts +61 -0
  50. package/dist/daterange/range.d.ts.map +1 -0
  51. package/dist/daterange/range.js +119 -0
  52. package/dist/daterange/range.js.map +1 -0
  53. package/dist/duration/DurationField.css +1 -1
  54. package/dist/duration/DurationField.d.ts +54 -13
  55. package/dist/duration/DurationField.d.ts.map +1 -1
  56. package/dist/duration/DurationField.js +205 -159
  57. package/dist/duration/DurationField.js.map +1 -1
  58. package/dist/duration/DurationField.module.js.map +1 -1
  59. package/dist/duration/index.d.ts +1 -1
  60. package/dist/duration/index.d.ts.map +1 -1
  61. package/dist/duration/index.js +1 -1
  62. package/dist/embed/EmbedField.d.ts +11 -2
  63. package/dist/embed/EmbedField.d.ts.map +1 -1
  64. package/dist/embed/EmbedField.js +179 -116
  65. package/dist/embed/EmbedField.js.map +1 -1
  66. package/dist/link/LinkField.css +12 -0
  67. package/dist/link/LinkField.d.ts +38 -0
  68. package/dist/link/LinkField.d.ts.map +1 -0
  69. package/dist/link/LinkField.js +742 -0
  70. package/dist/link/LinkField.js.map +1 -0
  71. package/dist/link/LinkField.module.js +8 -0
  72. package/dist/link/LinkField.module.js.map +1 -0
  73. package/dist/link/index.d.ts +3 -0
  74. package/dist/link/index.d.ts.map +1 -0
  75. package/dist/link/index.js +3 -0
  76. package/dist/link/link.d.ts +30 -0
  77. package/dist/link/link.d.ts.map +1 -0
  78. package/dist/link/link.js +63 -0
  79. package/dist/link/link.js.map +1 -0
  80. package/dist/link/pages.d.ts +17 -0
  81. package/dist/link/pages.d.ts.map +1 -0
  82. package/dist/link/pages.js +104 -0
  83. package/dist/link/pages.js.map +1 -0
  84. package/dist/location/LocationField.d.ts.map +1 -1
  85. package/dist/location/LocationField.js +9 -85
  86. package/dist/location/LocationField.js.map +1 -1
  87. package/dist/location/nominatim.d.ts +8 -2
  88. package/dist/location/nominatim.d.ts.map +1 -1
  89. package/dist/location/nominatim.js +32 -3
  90. package/dist/location/nominatim.js.map +1 -1
  91. package/dist/location/search.d.ts +10 -0
  92. package/dist/location/search.d.ts.map +1 -0
  93. package/dist/location/search.js +83 -0
  94. package/dist/location/search.js.map +1 -0
  95. package/dist/location/types.d.ts +8 -2
  96. package/dist/location/types.d.ts.map +1 -1
  97. package/dist/money/MoneyField.d.ts +28 -0
  98. package/dist/money/MoneyField.d.ts.map +1 -0
  99. package/dist/money/MoneyField.js +269 -0
  100. package/dist/money/MoneyField.js.map +1 -0
  101. package/dist/money/index.d.ts +3 -0
  102. package/dist/money/index.d.ts.map +1 -0
  103. package/dist/money/index.js +3 -0
  104. package/dist/money/money.d.ts +27 -0
  105. package/dist/money/money.d.ts.map +1 -0
  106. package/dist/money/money.js +56 -0
  107. package/dist/money/money.js.map +1 -0
  108. package/dist/region/RegionField.js +1 -1
  109. package/dist/shared/builtIn.d.ts +3 -1
  110. package/dist/shared/builtIn.d.ts.map +1 -1
  111. package/dist/shared/builtIn.js +18 -8
  112. package/dist/shared/builtIn.js.map +1 -1
  113. package/dist/shared/dates.js +2 -2
  114. package/dist/shared/dates.js.map +1 -1
  115. package/dist/shared/flow.d.ts.map +1 -1
  116. package/dist/shared/flow.js +1 -0
  117. package/dist/shared/flow.js.map +1 -1
  118. package/dist/shared/part.d.ts +26 -0
  119. package/dist/shared/part.d.ts.map +1 -0
  120. package/dist/shared/part.js +64 -0
  121. package/dist/shared/part.js.map +1 -0
  122. package/dist/tel/TelField.css +25 -0
  123. package/dist/tel/TelField.d.ts +14 -2
  124. package/dist/tel/TelField.d.ts.map +1 -1
  125. package/dist/tel/TelField.js +246 -145
  126. package/dist/tel/TelField.js.map +1 -1
  127. package/dist/tel/TelField.module.js +12 -0
  128. package/dist/tel/TelField.module.js.map +1 -0
  129. package/dist/tel/index.d.ts +1 -1
  130. package/dist/tel/index.d.ts.map +1 -1
  131. package/dist/tel/index.js +2 -2
  132. package/dist/tel/phone.d.ts +28 -0
  133. package/dist/tel/phone.d.ts.map +1 -1
  134. package/dist/tel/phone.js +48 -1
  135. package/dist/tel/phone.js.map +1 -1
  136. package/dist/url/UrlField.d.ts.map +1 -1
  137. package/dist/url/UrlField.js +1 -1
  138. package/dist/url/UrlField.js.map +1 -1
  139. package/package.json +24 -4
@@ -0,0 +1,9 @@
1
+ .panneau-date-range-field-field {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--panneau-space-2);
5
+ }
6
+
7
+ .panneau-date-range-field-time-zone {
8
+ max-width: 20rem;
9
+ }
@@ -0,0 +1,31 @@
1
+ import type { FieldEntryProps, FieldProps } from '../shared/types.js';
2
+ import { type DateRangeFieldValue } from './range.js';
3
+ export interface DateRangeFieldProps extends FieldProps<DateRangeFieldValue> {
4
+ /** The bounds are date-times. Without it, days. */
5
+ time?: boolean;
6
+ /** With `time`: an "All day" switch, whose ranges have days as bounds. */
7
+ allDay?: boolean;
8
+ /**
9
+ * The time zone the date-times are shown and typed in, when the value has none. Defaults to
10
+ * the browser's.
11
+ */
12
+ timeZone?: string | null;
13
+ /** With `time`: a menu of time zones, whose choice is kept in the value. */
14
+ chooseTimeZone?: boolean;
15
+ /** Defaults to the locale's. */
16
+ hourCycle?: 12 | 24;
17
+ controlClassName?: string;
18
+ }
19
+ /**
20
+ * A start and an end, checked together (decision 0053): days, or date-times with `time`, in one
21
+ * control with one calendar for both bounds. The value is `{ start, end }`, with `allDay` for an
22
+ * all-day range and the `timeZone` the user chose, or `null` once both bounds are empty.
23
+ *
24
+ * Date-times are shown and typed in the zone of the value, then `timeZone`, then the browser's,
25
+ * and written in UTC. A range typed halfway keeps its empty bound as `null`: the `daterange` rule
26
+ * refuses it unless that bound is open.
27
+ */
28
+ export declare function DateRangeField({ value, onChange, onBlur, time, allDay: offersAllDay, timeZone: fieldZone, chooseTimeZone, hourCycle, disabled, readOnly, required, ...props }: DateRangeFieldProps): import("react").JSX.Element;
29
+ /** The `daterange` type: settings `time`, `allDay`, `open`, `timeZone` and `chooseTimeZone`. */
30
+ export declare function DateRangeFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
31
+ //# sourceMappingURL=DateRangeField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangeField.d.ts","sourceRoot":"","sources":["../../src/daterange/DateRangeField.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EACH,KAAK,mBAAmB,EAI3B,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,mBAAoB,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IACxE,mDAAmD;IACnD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0EAA0E;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gCAAgC;IAChC,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAaD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAY,EACZ,MAAM,EAAE,YAAoB,EAC5B,QAAQ,EAAE,SAAS,EACnB,cAAsB,EACtB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,mBAAmB,+BA0IrB;AAED,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,+BAazD"}
@@ -0,0 +1,372 @@
1
+ import { getFieldProps } from "../shared/entry.js";
2
+ import { messages } from "../shared/messages.js";
3
+ import { CodeComboBox } from "../shared/CodeComboBox.js";
4
+ import { fromDateTime, toCalendarDate as toCalendarDate$1, toDateTime } from "../shared/dates.js";
5
+ import DateRangeField_module_default from "./DateRangeField.module.js";
6
+ import { getDateRangeSettings, getTimeZones, isDateRangeValue } from "./range.js";
7
+ import { c } from "react/compiler-runtime";
8
+ import { DateRangePicker, Switch, usePanneauIntl } from "@panneau/ui";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { getLocalTimeZone, now, toCalendarDate, toCalendarDateTime, toZoned } from "@internationalized/date";
11
+ //#region src/daterange/DateRangeField.tsx
12
+ /** A bound of the picker as a value: a day, or a date-time in UTC (or without an offset). */
13
+ function fromBound(bound, days) {
14
+ if (bound === null) return null;
15
+ if (days || !("hour" in bound)) return toCalendarDate(bound).toString();
16
+ return fromDateTime(bound);
17
+ }
18
+ /**
19
+ * A start and an end, checked together (decision 0053): days, or date-times with `time`, in one
20
+ * control with one calendar for both bounds. The value is `{ start, end }`, with `allDay` for an
21
+ * all-day range and the `timeZone` the user chose, or `null` once both bounds are empty.
22
+ *
23
+ * Date-times are shown and typed in the zone of the value, then `timeZone`, then the browser's,
24
+ * and written in UTC. A range typed halfway keeps its empty bound as `null`: the `daterange` rule
25
+ * refuses it unless that bound is open.
26
+ */
27
+ function DateRangeField(t0) {
28
+ const $ = c(86);
29
+ let disabled;
30
+ let fieldZone;
31
+ let hourCycle;
32
+ let onBlur;
33
+ let onChange;
34
+ let props;
35
+ let readOnly;
36
+ let required;
37
+ let t1;
38
+ let t2;
39
+ let t3;
40
+ let value;
41
+ if ($[0] !== t0) {
42
+ ({value, onChange, onBlur, time: t1, allDay: t2, timeZone: fieldZone, chooseTimeZone: t3, hourCycle, disabled, readOnly, required, ...props} = t0);
43
+ $[0] = t0;
44
+ $[1] = disabled;
45
+ $[2] = fieldZone;
46
+ $[3] = hourCycle;
47
+ $[4] = onBlur;
48
+ $[5] = onChange;
49
+ $[6] = props;
50
+ $[7] = readOnly;
51
+ $[8] = required;
52
+ $[9] = t1;
53
+ $[10] = t2;
54
+ $[11] = t3;
55
+ $[12] = value;
56
+ } else {
57
+ disabled = $[1];
58
+ fieldZone = $[2];
59
+ hourCycle = $[3];
60
+ onBlur = $[4];
61
+ onChange = $[5];
62
+ props = $[6];
63
+ readOnly = $[7];
64
+ required = $[8];
65
+ t1 = $[9];
66
+ t2 = $[10];
67
+ t3 = $[11];
68
+ value = $[12];
69
+ }
70
+ const time = t1 === void 0 ? false : t1;
71
+ const offersAllDay = t2 === void 0 ? false : t2;
72
+ const chooseTimeZone = t3 === void 0 ? false : t3;
73
+ const intl = usePanneauIntl();
74
+ const current = isDateRangeValue(value) ? value : null;
75
+ const isAllDay = time && offersAllDay && current?.allDay === true;
76
+ const days = !time || isAllDay;
77
+ let T0;
78
+ let allDaySwitch;
79
+ let changeZone;
80
+ let chosenZone;
81
+ let local;
82
+ let t10;
83
+ let t4;
84
+ let t5;
85
+ let t6;
86
+ let t7;
87
+ let t8;
88
+ let t9;
89
+ let zone;
90
+ if ($[13] !== chooseTimeZone || $[14] !== current || $[15] !== days || $[16] !== disabled || $[17] !== fieldZone || $[18] !== intl || $[19] !== isAllDay || $[20] !== offersAllDay || $[21] !== onBlur || $[22] !== onChange || $[23] !== props || $[24] !== readOnly || $[25] !== time) {
91
+ local = getLocalTimeZone();
92
+ zone = current?.timeZone ?? fieldZone ?? local;
93
+ chosenZone = chooseTimeZone ? current?.timeZone ?? fieldZone ?? local : null;
94
+ const toBound = (bound) => days ? toCalendarDate$1(bound) : toDateTime(bound, zone);
95
+ const emit = (next) => {
96
+ if (next.start === null && next.end === null) {
97
+ onChange?.(null);
98
+ return;
99
+ }
100
+ const nextZone = next.timeZone !== void 0 ? next.timeZone : chosenZone;
101
+ const nextAllDay = next.allDay ?? isAllDay;
102
+ onChange?.({
103
+ start: next.start,
104
+ end: next.end,
105
+ ...time && offersAllDay && nextAllDay ? { allDay: true } : {},
106
+ ...chooseTimeZone && nextZone !== null ? { timeZone: nextZone } : {}
107
+ });
108
+ };
109
+ const toggleAllDay = (on) => {
110
+ if (current === null) return;
111
+ const convert = (bound_0, edge) => {
112
+ if (bound_0 === null) return null;
113
+ if (on) {
114
+ const date = toDateTime(bound_0, zone);
115
+ return date !== null ? toCalendarDate(date).toString() : null;
116
+ }
117
+ const day = toCalendarDate$1(bound_0);
118
+ if (day === null) return null;
119
+ const zoned = toZoned(day, zone).set(edge === "start" ? {
120
+ hour: 9,
121
+ minute: 0
122
+ } : {
123
+ hour: 17,
124
+ minute: 0
125
+ });
126
+ return fromDateTime(zoned);
127
+ };
128
+ emit({
129
+ start: convert(current.start, "start"),
130
+ end: convert(current.end, "end"),
131
+ allDay: on
132
+ });
133
+ };
134
+ changeZone = (next_0) => {
135
+ if (next_0 === null || current === null || days) {
136
+ if (current !== null && next_0 !== null) emit({
137
+ start: current.start,
138
+ end: current.end,
139
+ timeZone: next_0
140
+ });
141
+ return;
142
+ }
143
+ const move = (bound_1) => {
144
+ const date_0 = toDateTime(bound_1, zone);
145
+ return date_0 !== null && "timeZone" in date_0 ? fromDateTime(toZoned(toCalendarDateTime(date_0), next_0)) : bound_1;
146
+ };
147
+ emit({
148
+ start: move(current.start),
149
+ end: move(current.end),
150
+ timeZone: next_0
151
+ });
152
+ };
153
+ let t11;
154
+ if ($[39] !== current || $[40] !== disabled || $[41] !== intl || $[42] !== isAllDay || $[43] !== offersAllDay || $[44] !== readOnly || $[45] !== time || $[46] !== toggleAllDay) {
155
+ t11 = time && offersAllDay ? /* @__PURE__ */ jsx(Switch, {
156
+ isSelected: isAllDay,
157
+ isDisabled: disabled === true || readOnly === true || current === null,
158
+ onChange: toggleAllDay,
159
+ children: intl.formatMessage(messages.allDay)
160
+ }) : void 0;
161
+ $[39] = current;
162
+ $[40] = disabled;
163
+ $[41] = intl;
164
+ $[42] = isAllDay;
165
+ $[43] = offersAllDay;
166
+ $[44] = readOnly;
167
+ $[45] = time;
168
+ $[46] = toggleAllDay;
169
+ $[47] = t11;
170
+ } else t11 = $[47];
171
+ allDaySwitch = t11;
172
+ t10 = DateRangeField_module_default.field;
173
+ T0 = DateRangePicker;
174
+ t4 = props;
175
+ if ($[48] !== current || $[49] !== toBound) {
176
+ t5 = current !== null ? {
177
+ start: toBound(current.start),
178
+ end: toBound(current.end)
179
+ } : null;
180
+ $[48] = current;
181
+ $[49] = toBound;
182
+ $[50] = t5;
183
+ } else t5 = $[50];
184
+ if ($[51] !== days || $[52] !== emit) {
185
+ t6 = (next_1) => emit({
186
+ start: fromBound(next_1.start, days),
187
+ end: fromBound(next_1.end, days)
188
+ });
189
+ $[51] = days;
190
+ $[52] = emit;
191
+ $[53] = t6;
192
+ } else t6 = $[53];
193
+ if ($[54] !== onBlur) {
194
+ t7 = onBlur !== void 0 ? { onBlur } : {};
195
+ $[54] = onBlur;
196
+ $[55] = t7;
197
+ } else t7 = $[55];
198
+ t8 = days ? "day" : "minute";
199
+ t9 = !days ? { placeholderValue: now(zone).set({
200
+ hour: 9,
201
+ minute: 0,
202
+ second: 0,
203
+ millisecond: 0
204
+ }) } : {};
205
+ $[13] = chooseTimeZone;
206
+ $[14] = current;
207
+ $[15] = days;
208
+ $[16] = disabled;
209
+ $[17] = fieldZone;
210
+ $[18] = intl;
211
+ $[19] = isAllDay;
212
+ $[20] = offersAllDay;
213
+ $[21] = onBlur;
214
+ $[22] = onChange;
215
+ $[23] = props;
216
+ $[24] = readOnly;
217
+ $[25] = time;
218
+ $[26] = T0;
219
+ $[27] = allDaySwitch;
220
+ $[28] = changeZone;
221
+ $[29] = chosenZone;
222
+ $[30] = local;
223
+ $[31] = t10;
224
+ $[32] = t4;
225
+ $[33] = t5;
226
+ $[34] = t6;
227
+ $[35] = t7;
228
+ $[36] = t8;
229
+ $[37] = t9;
230
+ $[38] = zone;
231
+ } else {
232
+ T0 = $[26];
233
+ allDaySwitch = $[27];
234
+ changeZone = $[28];
235
+ chosenZone = $[29];
236
+ local = $[30];
237
+ t10 = $[31];
238
+ t4 = $[32];
239
+ t5 = $[33];
240
+ t6 = $[34];
241
+ t7 = $[35];
242
+ t8 = $[36];
243
+ t9 = $[37];
244
+ zone = $[38];
245
+ }
246
+ let t11;
247
+ if ($[56] !== hourCycle) {
248
+ t11 = hourCycle !== void 0 ? { hourCycle } : {};
249
+ $[56] = hourCycle;
250
+ $[57] = t11;
251
+ } else t11 = $[57];
252
+ const t12 = zone === local;
253
+ let t13;
254
+ if ($[58] !== allDaySwitch) {
255
+ t13 = allDaySwitch !== void 0 ? { end: allDaySwitch } : {};
256
+ $[58] = allDaySwitch;
257
+ $[59] = t13;
258
+ } else t13 = $[59];
259
+ let t14;
260
+ if ($[60] !== T0 || $[61] !== disabled || $[62] !== readOnly || $[63] !== required || $[64] !== t11 || $[65] !== t12 || $[66] !== t13 || $[67] !== t4 || $[68] !== t5 || $[69] !== t6 || $[70] !== t7 || $[71] !== t8 || $[72] !== t9) {
261
+ t14 = /* @__PURE__ */ jsx(T0, {
262
+ ...t4,
263
+ value: t5,
264
+ onChange: t6,
265
+ ...t7,
266
+ granularity: t8,
267
+ ...t9,
268
+ ...t11,
269
+ hideTimeZone: t12,
270
+ ...t13,
271
+ isRequired: required,
272
+ isDisabled: disabled,
273
+ isReadOnly: readOnly
274
+ });
275
+ $[60] = T0;
276
+ $[61] = disabled;
277
+ $[62] = readOnly;
278
+ $[63] = required;
279
+ $[64] = t11;
280
+ $[65] = t12;
281
+ $[66] = t13;
282
+ $[67] = t4;
283
+ $[68] = t5;
284
+ $[69] = t6;
285
+ $[70] = t7;
286
+ $[71] = t8;
287
+ $[72] = t9;
288
+ $[73] = t14;
289
+ } else t14 = $[73];
290
+ let t15;
291
+ if ($[74] !== changeZone || $[75] !== chooseTimeZone || $[76] !== chosenZone || $[77] !== disabled || $[78] !== intl || $[79] !== readOnly || $[80] !== time) {
292
+ t15 = chooseTimeZone && time ? /* @__PURE__ */ jsx(CodeComboBox, {
293
+ label: intl.formatMessage(messages.timeZone),
294
+ choices: getTimeZones().map(_temp),
295
+ value: chosenZone,
296
+ onChange: changeZone,
297
+ disabled,
298
+ readOnly,
299
+ emptyMessage: intl.formatMessage(messages.noTimeZones),
300
+ className: DateRangeField_module_default.timeZone
301
+ }) : null;
302
+ $[74] = changeZone;
303
+ $[75] = chooseTimeZone;
304
+ $[76] = chosenZone;
305
+ $[77] = disabled;
306
+ $[78] = intl;
307
+ $[79] = readOnly;
308
+ $[80] = time;
309
+ $[81] = t15;
310
+ } else t15 = $[81];
311
+ let t16;
312
+ if ($[82] !== t10 || $[83] !== t14 || $[84] !== t15) {
313
+ t16 = /* @__PURE__ */ jsxs("div", {
314
+ className: t10,
315
+ children: [t14, t15]
316
+ });
317
+ $[82] = t10;
318
+ $[83] = t14;
319
+ $[84] = t15;
320
+ $[85] = t16;
321
+ } else t16 = $[85];
322
+ return t16;
323
+ }
324
+ /** The `daterange` type: settings `time`, `allDay`, `open`, `timeZone` and `chooseTimeZone`. */
325
+ function _temp(code) {
326
+ return {
327
+ code,
328
+ name: code.replaceAll("_", " ").replaceAll("/", " / ")
329
+ };
330
+ }
331
+ function DateRangeFieldEntry(props) {
332
+ const $ = c(12);
333
+ let t0;
334
+ if ($[0] !== props.field.settings) {
335
+ t0 = getDateRangeSettings(props.field.settings);
336
+ $[0] = props.field.settings;
337
+ $[1] = t0;
338
+ } else t0 = $[1];
339
+ const settings = t0;
340
+ let t1;
341
+ if ($[2] !== props) {
342
+ t1 = getFieldProps(props);
343
+ $[2] = props;
344
+ $[3] = t1;
345
+ } else t1 = $[3];
346
+ const t2 = isDateRangeValue(props.value) ? props.value : null;
347
+ let t3;
348
+ if ($[4] !== props.onChange || $[5] !== settings.allDay || $[6] !== settings.chooseTimeZone || $[7] !== settings.time || $[8] !== settings.timeZone || $[9] !== t1 || $[10] !== t2) {
349
+ t3 = /* @__PURE__ */ jsx(DateRangeField, {
350
+ ...t1,
351
+ value: t2,
352
+ onChange: props.onChange,
353
+ time: settings.time,
354
+ allDay: settings.allDay,
355
+ timeZone: settings.timeZone,
356
+ chooseTimeZone: settings.chooseTimeZone
357
+ });
358
+ $[4] = props.onChange;
359
+ $[5] = settings.allDay;
360
+ $[6] = settings.chooseTimeZone;
361
+ $[7] = settings.time;
362
+ $[8] = settings.timeZone;
363
+ $[9] = t1;
364
+ $[10] = t2;
365
+ $[11] = t3;
366
+ } else t3 = $[11];
367
+ return t3;
368
+ }
369
+ //#endregion
370
+ export { DateRangeField, DateRangeFieldEntry };
371
+
372
+ //# sourceMappingURL=DateRangeField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangeField.js","names":["DateValue","getLocalTimeZone","now","toCalendarDate","toCalendarDateTime","toZoned","DateRangePicker","Switch","usePanneauIntl","CodeComboBox","fromDateTime","parseDay","toDateTime","getFieldProps","messages","FieldEntryProps","FieldProps","styles","DateRangeFieldValue","getDateRangeSettings","getTimeZones","isDateRangeValue","DateRangeFieldProps","time","allDay","timeZone","chooseTimeZone","hourCycle","controlClassName","fromBound","bound","days","toString","DateRangeField","t0","$","_c","disabled","fieldZone","onBlur","onChange","props","readOnly","required","t1","t2","t3","value","undefined","offersAllDay","intl","current","isAllDay","T0","allDaySwitch","changeZone","chosenZone","local","t10","t4","t5","t6","t7","t8","t9","zone","toBound","emit","next","start","end","nextZone","nextAllDay","toggleAllDay","on","convert","bound_0","edge","date","day","zoned","set","hour","minute","next_0","move","bound_1","date_0","t11","formatMessage","field","next_1","placeholderValue","second","millisecond","t12","t13","t14","t15","map","_temp","noTimeZones","t16","code","name","replaceAll","DateRangeFieldEntry","settings","_c","parseDay","styles"],"sources":["../../src/daterange/DateRangeField.tsx"],"sourcesContent":["import {\n type DateValue,\n getLocalTimeZone,\n now,\n toCalendarDate,\n toCalendarDateTime,\n toZoned,\n} from '@internationalized/date';\n\nimport { DateRangePicker, Switch, usePanneauIntl } from '@panneau/ui';\n\nimport { CodeComboBox } from '../shared/CodeComboBox';\nimport { fromDateTime, toCalendarDate as parseDay, toDateTime } from '../shared/dates';\nimport { getFieldProps } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport styles from './DateRangeField.module.css';\nimport {\n type DateRangeFieldValue,\n getDateRangeSettings,\n getTimeZones,\n isDateRangeValue,\n} from './range';\n\nexport interface DateRangeFieldProps extends FieldProps<DateRangeFieldValue> {\n /** The bounds are date-times. Without it, days. */\n time?: boolean;\n /** With `time`: an \"All day\" switch, whose ranges have days as bounds. */\n allDay?: boolean;\n /**\n * The time zone the date-times are shown and typed in, when the value has none. Defaults to\n * the browser's.\n */\n timeZone?: string | null;\n /** With `time`: a menu of time zones, whose choice is kept in the value. */\n chooseTimeZone?: boolean;\n /** Defaults to the locale's. */\n hourCycle?: 12 | 24;\n controlClassName?: string;\n}\n\n/** A bound of the picker as a value: a day, or a date-time in UTC (or without an offset). */\nfunction fromBound(bound: DateValue | null, days: boolean): string | null {\n if (bound === null) {\n return null;\n }\n if (days || !('hour' in bound)) {\n return toCalendarDate(bound).toString();\n }\n return fromDateTime(bound);\n}\n\n/**\n * A start and an end, checked together (decision 0053): days, or date-times with `time`, in one\n * control with one calendar for both bounds. The value is `{ start, end }`, with `allDay` for an\n * all-day range and the `timeZone` the user chose, or `null` once both bounds are empty.\n *\n * Date-times are shown and typed in the zone of the value, then `timeZone`, then the browser's,\n * and written in UTC. A range typed halfway keeps its empty bound as `null`: the `daterange` rule\n * refuses it unless that bound is open.\n */\nexport function DateRangeField({\n value,\n onChange,\n onBlur,\n time = false,\n allDay: offersAllDay = false,\n timeZone: fieldZone,\n chooseTimeZone = false,\n hourCycle,\n disabled,\n readOnly,\n required,\n ...props\n}: DateRangeFieldProps) {\n const intl = usePanneauIntl();\n const current = isDateRangeValue(value) ? value : null;\n const isAllDay = time && offersAllDay && current?.allDay === true;\n const days = !time || isAllDay;\n const local = getLocalTimeZone();\n const zone = current?.timeZone ?? fieldZone ?? local;\n const chosenZone = chooseTimeZone ? (current?.timeZone ?? fieldZone ?? local) : null;\n\n const toBound = (bound: string | null | undefined): DateValue | null =>\n days ? parseDay(bound) : toDateTime(bound, zone);\n\n const emit = (next: {\n start: string | null;\n end: string | null;\n allDay?: boolean;\n timeZone?: string | null;\n }) => {\n if (next.start === null && next.end === null) {\n onChange?.(null);\n return;\n }\n const nextZone = next.timeZone !== undefined ? next.timeZone : chosenZone;\n const nextAllDay = next.allDay ?? isAllDay;\n onChange?.({\n start: next.start,\n end: next.end,\n ...(time && offersAllDay && nextAllDay ? { allDay: true } : {}),\n ...(chooseTimeZone && nextZone !== null ? { timeZone: nextZone } : {}),\n });\n };\n\n /** The bounds as date-times at the start and the end of their days, or as days. */\n const toggleAllDay = (on: boolean) => {\n if (current === null) {\n return;\n }\n const convert = (bound: string | null, edge: 'start' | 'end'): string | null => {\n if (bound === null) {\n return null;\n }\n if (on) {\n const date = toDateTime(bound, zone);\n return date !== null ? toCalendarDate(date).toString() : null;\n }\n const day = parseDay(bound);\n if (day === null) {\n return null;\n }\n const zoned = toZoned(day, zone).set(\n edge === 'start' ? { hour: 9, minute: 0 } : { hour: 17, minute: 0 },\n );\n return fromDateTime(zoned);\n };\n emit({\n start: convert(current.start, 'start'),\n end: convert(current.end, 'end'),\n allDay: on,\n });\n };\n\n /** The same wall-clock times in another zone: a range typed in the wrong zone, corrected. */\n const changeZone = (next: string | null) => {\n if (next === null || current === null || days) {\n if (current !== null && next !== null) {\n emit({ start: current.start, end: current.end, timeZone: next });\n }\n return;\n }\n const move = (bound: string | null) => {\n const date = toDateTime(bound, zone);\n return date !== null && 'timeZone' in date\n ? fromDateTime(toZoned(toCalendarDateTime(date), next))\n : bound;\n };\n emit({ start: move(current.start), end: move(current.end), timeZone: next });\n };\n\n const allDaySwitch =\n time && offersAllDay ? (\n <Switch\n isSelected={isAllDay}\n isDisabled={disabled === true || readOnly === true || current === null}\n onChange={toggleAllDay}\n >\n {intl.formatMessage(messages.allDay)}\n </Switch>\n ) : undefined;\n\n return (\n <div className={styles.field}>\n <DateRangePicker\n {...props}\n value={\n current !== null\n ? { start: toBound(current.start), end: toBound(current.end) }\n : null\n }\n onChange={(next) =>\n emit({ start: fromBound(next.start, days), end: fromBound(next.end, days) })\n }\n {...(onBlur !== undefined ? { onBlur } : {})}\n granularity={days ? 'day' : 'minute'}\n // Typed from empty, a date-time is in the zone of the field, and written in UTC.\n {...(!days\n ? {\n placeholderValue: now(zone).set({\n hour: 9,\n minute: 0,\n second: 0,\n millisecond: 0,\n }),\n }\n : {})}\n {...(hourCycle !== undefined ? { hourCycle } : {})}\n hideTimeZone={zone === local}\n {...(allDaySwitch !== undefined ? { end: allDaySwitch } : {})}\n isRequired={required}\n isDisabled={disabled}\n isReadOnly={readOnly}\n />\n {chooseTimeZone && time ? (\n <CodeComboBox\n label={intl.formatMessage(messages.timeZone)}\n choices={getTimeZones().map((code) => ({\n code,\n name: code.replaceAll('_', ' ').replaceAll('/', ' / '),\n }))}\n value={chosenZone}\n onChange={changeZone}\n disabled={disabled}\n readOnly={readOnly}\n emptyMessage={intl.formatMessage(messages.noTimeZones)}\n className={styles.timeZone}\n />\n ) : null}\n </div>\n );\n}\n\n/** The `daterange` type: settings `time`, `allDay`, `open`, `timeZone` and `chooseTimeZone`. */\nexport function DateRangeFieldEntry(props: FieldEntryProps) {\n const settings = getDateRangeSettings(props.field.settings);\n return (\n <DateRangeField\n {...getFieldProps(props)}\n value={isDateRangeValue(props.value) ? props.value : null}\n onChange={props.onChange}\n time={settings.time}\n allDay={settings.allDay}\n timeZone={settings.timeZone}\n chooseTimeZone={settings.chooseTimeZone}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AA0CA,SAAS6B,UAAUC,OAAyBC,MAA8B;CACtE,IAAID,UAAU,MACV,OAAO;CAEX,IAAIC,QAAQ,EAAE,UAAUD,QACpB,OAAO3B,eAAe2B,KAAK,CAAC,CAACE,SAAS;CAE1C,OAAOtB,aAAaoB,KAAK;AAC7B;;;;;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,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAA3D,MAAAwE,WAAiBzE;CAA2C,IAAAU;CAAA,IAAAT,EAAA,OAAAM,OAAA;EAGhDG,KAAA/B,cAAc4B,KAAK;EAACN,EAAA,KAAAM;EAAAN,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CACjB,MAAAU,KAAAxB,iBAAiBoB,MAAKM,KAA2B,IAAjBN,MAAKM,QAArC;CAAkD,IAAAD;CAAA,IAAAX,EAAA,OAAAM,MAAAD,YAAAL,EAAA,OAAAwE,SAAAnF,UAAAW,EAAA,OAAAwE,SAAAjF,kBAAAS,EAAA,OAAAwE,SAAApF,QAAAY,EAAA,OAAAwE,SAAAlF,YAAAU,EAAA,OAAAS,MAAAT,EAAA,QAAAU,IAAA;EAF7DC,KAAA,oBAAC,gBAAD;GAAe,GACPF;GACG,OAAAC;GACG,UAAAJ,MAAKD;GACT,MAAAmE,SAAQpF;GACN,QAAAoF,SAAQnF;GACN,UAAAmF,SAAQlF;GACF,gBAAAkF,SAAQjF;EAAe,CAAA;EACzCS,EAAA,KAAAM,MAAAD;EAAAL,EAAA,KAAAwE,SAAAnF;EAAAW,EAAA,KAAAwE,SAAAjF;EAAAS,EAAA,KAAAwE,SAAApF;EAAAY,EAAA,KAAAwE,SAAAlF;EAAAU,EAAA,KAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OARFW;AAQE"}
@@ -0,0 +1,12 @@
1
+ import "./DateRangeField.css";
2
+ //#region src/daterange/DateRangeField.module.css
3
+ var field = "panneau-date-range-field-field";
4
+ var timeZone = "panneau-date-range-field-time-zone";
5
+ var DateRangeField_module_default = {
6
+ field,
7
+ timeZone
8
+ };
9
+ //#endregion
10
+ export { DateRangeField_module_default as default, field, timeZone };
11
+
12
+ //# sourceMappingURL=DateRangeField.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangeField.module.js","names":[],"sources":["../../src/daterange/DateRangeField.module.css"],"sourcesContent":[".field {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-2);\n}\n\n.timeZone {\n max-width: 20rem;\n}\n"],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { DateRangeField, DateRangeFieldEntry, type DateRangeFieldProps } from './DateRangeField.js';
2
+ export { type DateRangeFieldValue, type DateRangeSettings, type FormattedDateRange, formatDateRange, getBoundDay, getDateRangeSettings, getRangeDays, getTimeZones, isDateRangeValue, isTimeZone, } from './range.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/daterange/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACb,MAAM,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { formatDateRange, getBoundDay, getDateRangeSettings, getRangeDays, getTimeZones, isDateRangeValue, isTimeZone } from "./range.js";
2
+ import { DateRangeField, DateRangeFieldEntry } from "./DateRangeField.js";
3
+ export { DateRangeField, DateRangeFieldEntry, formatDateRange, getBoundDay, getDateRangeSettings, getRangeDays, getTimeZones, isDateRangeValue, isTimeZone };
@@ -0,0 +1,61 @@
1
+ import type { DateRangeOpenBound } from '@panneau/protocol/runtime';
2
+ /**
3
+ * A `daterange` value as a field holds it (decision 0053): days (`2026-11-04`) or date-times with
4
+ * an offset, either `null` while it is empty, with `allDay` for an all-day range and the `timeZone`
5
+ * the user chose.
6
+ */
7
+ export interface DateRangeFieldValue {
8
+ start: string | null;
9
+ end: string | null;
10
+ allDay?: boolean;
11
+ timeZone?: string;
12
+ }
13
+ /** The settings of a `daterange` field, from its definition. */
14
+ export interface DateRangeSettings {
15
+ /** The bounds are date-times. */
16
+ time: boolean;
17
+ /** The field has an "All day" switch. */
18
+ allDay: boolean;
19
+ /** The bounds that can be `null`. */
20
+ open: DateRangeOpenBound | null;
21
+ /** The time zone the date-times are shown and typed in. */
22
+ timeZone: string | null;
23
+ /** The field has a menu of time zones, kept in the value. */
24
+ chooseTimeZone: boolean;
25
+ }
26
+ /** Whether a value is a `daterange` value: an object with a start and an end. */
27
+ export declare function isDateRangeValue(value: unknown): value is DateRangeFieldValue;
28
+ /** The settings of a `daterange` field (`settings.time`, `allDay`, `open`, `timeZone`…). */
29
+ export declare function getDateRangeSettings(settings: Record<string, unknown> | undefined): DateRangeSettings;
30
+ /** Whether a string is an IANA time zone that the browser knows (`America/Toronto`). */
31
+ export declare function isTimeZone(zone: string): boolean;
32
+ /** The time zones the browser knows, `UTC` first. */
33
+ export declare function getTimeZones(): string[];
34
+ /** The day of a bound: a day as it is, a date-time in the time zone. `null` when invalid. */
35
+ export declare function getBoundDay(bound: string | null | undefined, timeZone?: string): string | null;
36
+ /**
37
+ * The first and the last day of a range, in its time zone: the value's, the field's, or the
38
+ * browser's. A day bound is that day.
39
+ */
40
+ export declare function getRangeDays(value: unknown, fieldTimeZone?: string | null): {
41
+ first: string | null;
42
+ last: string | null;
43
+ };
44
+ /** A range in a locale: both bounds, or one of them for a range open at the other end. */
45
+ export type FormattedDateRange = {
46
+ kind: 'range';
47
+ text: string;
48
+ } | {
49
+ kind: 'from';
50
+ text: string;
51
+ } | {
52
+ kind: 'until';
53
+ text: string;
54
+ };
55
+ /**
56
+ * A range in the format of a locale, with `Intl.DateTimeFormat.formatRange`: `Nov 4 – 6, 2026`,
57
+ * `Nov 4, 2026, 7:30 – 9:00 PM`. Date-times show in the zone of the value, or the field's, with
58
+ * the zone's short name when it isn't the browser's. `null` for an empty or invalid value.
59
+ */
60
+ export declare function formatDateRange(value: unknown, locale: string, fieldTimeZone?: string | null): FormattedDateRange | null;
61
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/daterange/range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAC9B,iCAAiC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,qCAAqC;IACrC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,6DAA6D;IAC7D,cAAc,EAAE,OAAO,CAAC;CAC3B;AAOD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAS7E;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC9C,iBAAiB,CAUnB;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOhD;AAED,qDAAqD;AACrD,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAIvC;AAkBD,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS9F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC9B;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAM/C;AAED,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC9B,kBAAkB,GAAG,IAAI,CA4C3B"}
@@ -0,0 +1,119 @@
1
+ //#region src/daterange/range.ts
2
+ var DAY = /^\d{4}-\d{2}-\d{2}$/;
3
+ var isBound = (value) => value === null || value === void 0 || typeof value === "string";
4
+ /** Whether a value is a `daterange` value: an object with a start and an end. */
5
+ function isDateRangeValue(value) {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value) && ("start" in value || "end" in value) && isBound(value.start) && isBound(value.end);
7
+ }
8
+ /** The settings of a `daterange` field (`settings.time`, `allDay`, `open`, `timeZone`…). */
9
+ function getDateRangeSettings(settings) {
10
+ const open = settings?.open;
11
+ const timeZone = settings?.timeZone;
12
+ return {
13
+ time: settings?.time === true,
14
+ allDay: settings?.allDay === true && settings.time === true,
15
+ open: open === "start" || open === "end" || open === "both" ? open : null,
16
+ timeZone: typeof timeZone === "string" && isTimeZone(timeZone) ? timeZone : null,
17
+ chooseTimeZone: settings?.chooseTimeZone === true && settings.time === true
18
+ };
19
+ }
20
+ /** Whether a string is an IANA time zone that the browser knows (`America/Toronto`). */
21
+ function isTimeZone(zone) {
22
+ try {
23
+ new Intl.DateTimeFormat("en", { timeZone: zone });
24
+ return true;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+ /** The time zones the browser knows, `UTC` first. */
30
+ function getTimeZones() {
31
+ return ["UTC", ...(typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : []).filter((zone) => zone !== "UTC")];
32
+ }
33
+ function pad(value, length = 2) {
34
+ return String(value).padStart(length, "0");
35
+ }
36
+ /** The day of a date-time in a time zone (the browser's without one), as `2026-11-04`. */
37
+ function dayIn(date, timeZone) {
38
+ const parts = new Intl.DateTimeFormat("en-US", {
39
+ timeZone,
40
+ year: "numeric",
41
+ month: "numeric",
42
+ day: "numeric"
43
+ }).formatToParts(date);
44
+ const part = (type) => Number(parts.find((entry) => entry.type === type)?.value);
45
+ return `${pad(part("year"), 4)}-${pad(part("month"))}-${pad(part("day"))}`;
46
+ }
47
+ /** The day of a bound: a day as it is, a date-time in the time zone. `null` when invalid. */
48
+ function getBoundDay(bound, timeZone) {
49
+ if (bound === null || bound === void 0 || bound === "") return null;
50
+ if (DAY.test(bound)) return bound;
51
+ const date = new Date(bound);
52
+ return Number.isNaN(date.getTime()) ? null : dayIn(date, timeZone);
53
+ }
54
+ /**
55
+ * The first and the last day of a range, in its time zone: the value's, the field's, or the
56
+ * browser's. A day bound is that day.
57
+ */
58
+ function getRangeDays(value, fieldTimeZone) {
59
+ if (!isDateRangeValue(value)) return {
60
+ first: null,
61
+ last: null
62
+ };
63
+ const zone = value.timeZone ?? fieldTimeZone ?? void 0;
64
+ return {
65
+ first: getBoundDay(value.start, zone),
66
+ last: getBoundDay(value.end, zone)
67
+ };
68
+ }
69
+ /**
70
+ * A range in the format of a locale, with `Intl.DateTimeFormat.formatRange`: `Nov 4 – 6, 2026`,
71
+ * `Nov 4, 2026, 7:30 – 9:00 PM`. Date-times show in the zone of the value, or the field's, with
72
+ * the zone's short name when it isn't the browser's. `null` for an empty or invalid value.
73
+ */
74
+ function formatDateRange(value, locale, fieldTimeZone) {
75
+ if (!isDateRangeValue(value)) return null;
76
+ const bounds = [value.start, value.end].map((bound) => bound === null || bound === void 0 || bound === "" ? null : bound);
77
+ const days = bounds.every((bound) => bound === null || DAY.test(bound));
78
+ const toDate = (bound) => new Date(DAY.test(bound) ? `${bound}T00:00:00Z` : bound);
79
+ const local = Intl.DateTimeFormat().resolvedOptions().timeZone;
80
+ const zone = value.timeZone ?? fieldTimeZone ?? void 0;
81
+ const format = new Intl.DateTimeFormat(locale, {
82
+ year: "numeric",
83
+ month: "short",
84
+ day: "numeric",
85
+ ...days ? { timeZone: "UTC" } : {
86
+ hour: "numeric",
87
+ minute: "2-digit",
88
+ ...zone !== void 0 ? { timeZone: zone } : {},
89
+ ...zone !== void 0 && zone !== local ? { timeZoneName: "short" } : {}
90
+ }
91
+ });
92
+ const dates = bounds.map((bound) => bound !== null ? toDate(bound) : null);
93
+ if (dates.some((date) => date !== null && Number.isNaN(date.getTime()))) return null;
94
+ const [from, to] = dates;
95
+ if (from !== null && from !== void 0 && to !== null && to !== void 0) try {
96
+ return {
97
+ kind: "range",
98
+ text: format.formatRange(from, to)
99
+ };
100
+ } catch {
101
+ return {
102
+ kind: "range",
103
+ text: `${format.format(from)} – ${format.format(to)}`
104
+ };
105
+ }
106
+ if (from !== null && from !== void 0) return {
107
+ kind: "from",
108
+ text: format.format(from)
109
+ };
110
+ if (to !== null && to !== void 0) return {
111
+ kind: "until",
112
+ text: format.format(to)
113
+ };
114
+ return null;
115
+ }
116
+ //#endregion
117
+ export { formatDateRange, getBoundDay, getDateRangeSettings, getRangeDays, getTimeZones, isDateRangeValue, isTimeZone };
118
+
119
+ //# sourceMappingURL=range.js.map