frontile 0.18.0 → 0.18.2

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 (155) hide show
  1. package/declarations/-private/get-config.d.ts.map +1 -1
  2. package/declarations/-private/timer.d.ts +3 -3
  3. package/declarations/-private/timer.d.ts.map +1 -1
  4. package/declarations/components/buttons/chip.d.ts +1 -1
  5. package/declarations/components/buttons/chip.d.ts.map +1 -1
  6. package/declarations/components/buttons/close-button.d.ts +2 -2
  7. package/declarations/components/buttons/close-button.d.ts.map +1 -1
  8. package/declarations/components/collections/listbox/item.d.ts +2 -2
  9. package/declarations/components/collections/listbox/item.d.ts.map +1 -1
  10. package/declarations/components/collections/simple-table/column.d.ts +6 -0
  11. package/declarations/components/collections/simple-table/column.d.ts.map +1 -1
  12. package/declarations/components/collections/simple-table/footer.d.ts +2 -1
  13. package/declarations/components/collections/simple-table/footer.d.ts.map +1 -1
  14. package/declarations/components/collections/simple-table/header.d.ts +2 -1
  15. package/declarations/components/collections/simple-table/header.d.ts.map +1 -1
  16. package/declarations/components/collections/simple-table/index.d.ts +1 -1
  17. package/declarations/components/collections/simple-table/index.d.ts.map +1 -1
  18. package/declarations/components/collections/table/checkbox.d.ts +1 -1
  19. package/declarations/components/collections/table/checkbox.d.ts.map +1 -1
  20. package/declarations/components/collections/table/column-visibility.d.ts +2 -2
  21. package/declarations/components/collections/table/column-visibility.d.ts.map +1 -1
  22. package/declarations/components/collections/table/table.d.ts +9 -7
  23. package/declarations/components/collections/table/table.d.ts.map +1 -1
  24. package/declarations/components/forms/autocomplete.d.ts +12 -12
  25. package/declarations/components/forms/checkbox.d.ts +2 -2
  26. package/declarations/components/forms/checkbox.d.ts.map +1 -1
  27. package/declarations/components/forms/date-input/clipboard.d.ts +34 -0
  28. package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -0
  29. package/declarations/components/forms/date-input/date-input.d.ts +93 -0
  30. package/declarations/components/forms/date-input/date-input.d.ts.map +1 -0
  31. package/declarations/components/forms/date-input/segment-group.d.ts +132 -0
  32. package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -0
  33. package/declarations/components/forms/date-input/segments.d.ts +163 -0
  34. package/declarations/components/forms/date-input/segments.d.ts.map +1 -0
  35. package/declarations/components/forms/date-input/types.d.ts +175 -0
  36. package/declarations/components/forms/date-input/types.d.ts.map +1 -0
  37. package/declarations/components/forms/date-input.d.ts +6 -0
  38. package/declarations/components/forms/date-input.d.ts.map +1 -0
  39. package/declarations/components/forms/date-picker/date-picker.d.ts +263 -15
  40. package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
  41. package/declarations/components/forms/date-picker/end-content.d.ts +33 -3
  42. package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
  43. package/declarations/components/forms/date-picker/types.d.ts +45 -2
  44. package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
  45. package/declarations/components/forms/date-picker/value.d.ts +21 -5
  46. package/declarations/components/forms/date-picker/value.d.ts.map +1 -1
  47. package/declarations/components/forms/field.d.ts +7 -5
  48. package/declarations/components/forms/field.d.ts.map +1 -1
  49. package/declarations/components/forms/form.d.ts +5 -5
  50. package/declarations/components/forms/form.d.ts.map +1 -1
  51. package/declarations/components/forms/index.d.ts +1 -0
  52. package/declarations/components/forms/index.d.ts.map +1 -1
  53. package/declarations/components/forms/input-otp.d.ts +5 -5
  54. package/declarations/components/forms/input-otp.d.ts.map +1 -1
  55. package/declarations/components/forms/input.d.ts +15 -15
  56. package/declarations/components/forms/input.d.ts.map +1 -1
  57. package/declarations/components/forms/native-select.d.ts +10 -10
  58. package/declarations/components/forms/native-select.d.ts.map +1 -1
  59. package/declarations/components/forms/radio.d.ts +2 -2
  60. package/declarations/components/forms/radio.d.ts.map +1 -1
  61. package/declarations/components/forms/select/select.d.ts +16 -16
  62. package/declarations/components/forms/textarea.d.ts +10 -10
  63. package/declarations/components/forms/textarea.d.ts.map +1 -1
  64. package/declarations/components/navigation/pagination/pagination.d.ts +32 -1
  65. package/declarations/components/navigation/pagination/pagination.d.ts.map +1 -1
  66. package/declarations/components/overlays/overlay.d.ts +4 -4
  67. package/declarations/components/overlays/overlay.d.ts.map +1 -1
  68. package/declarations/components/utilities/avatar.d.ts +35 -2
  69. package/declarations/components/utilities/avatar.d.ts.map +1 -1
  70. package/declarations/components/utilities/collapsible.d.ts +16 -0
  71. package/declarations/components/utilities/collapsible.d.ts.map +1 -1
  72. package/declarations/test-support.d.ts +30 -0
  73. package/declarations/test-support.d.ts.map +1 -1
  74. package/declarations/utils/forms-utils-index.d.ts +1 -1
  75. package/declarations/utils/forms-utils-index.d.ts.map +1 -1
  76. package/declarations/utils/nested-data.d.ts +17 -0
  77. package/declarations/utils/nested-data.d.ts.map +1 -1
  78. package/dist/components/buttons/chip.js.map +1 -1
  79. package/dist/components/buttons/close-button.js +5 -12
  80. package/dist/components/buttons/close-button.js.map +1 -1
  81. package/dist/components/collections/listbox/item.js +4 -11
  82. package/dist/components/collections/listbox/item.js.map +1 -1
  83. package/dist/components/collections/simple-table/column.js +2 -2
  84. package/dist/components/collections/simple-table/column.js.map +1 -1
  85. package/dist/components/collections/simple-table/footer.js +1 -1
  86. package/dist/components/collections/simple-table/footer.js.map +1 -1
  87. package/dist/components/collections/simple-table/header.js +1 -1
  88. package/dist/components/collections/simple-table/header.js.map +1 -1
  89. package/dist/components/collections/simple-table/index.js +1 -1
  90. package/dist/components/collections/simple-table/index.js.map +1 -1
  91. package/dist/components/collections/table/checkbox.js +2 -7
  92. package/dist/components/collections/table/checkbox.js.map +1 -1
  93. package/dist/components/collections/table/column-visibility.js +2 -7
  94. package/dist/components/collections/table/column-visibility.js.map +1 -1
  95. package/dist/components/forms/checkbox.js +4 -12
  96. package/dist/components/forms/checkbox.js.map +1 -1
  97. package/dist/components/forms/date-input/clipboard.js +231 -0
  98. package/dist/components/forms/date-input/clipboard.js.map +1 -0
  99. package/dist/components/forms/date-input/date-input.js +204 -0
  100. package/dist/components/forms/date-input/date-input.js.map +1 -0
  101. package/dist/components/forms/date-input/segment-group.js +292 -0
  102. package/dist/components/forms/date-input/segment-group.js.map +1 -0
  103. package/dist/components/forms/date-input/segments.js +562 -0
  104. package/dist/components/forms/date-input/segments.js.map +1 -0
  105. package/dist/components/forms/date-input/types.js +2 -0
  106. package/dist/components/forms/date-input/types.js.map +1 -0
  107. package/dist/components/forms/date-input.js +4 -0
  108. package/dist/components/forms/date-input.js.map +1 -0
  109. package/dist/components/forms/date-picker/date-picker.js +361 -20
  110. package/dist/components/forms/date-picker/date-picker.js.map +1 -1
  111. package/dist/components/forms/date-picker/end-content.js +17 -4
  112. package/dist/components/forms/date-picker/end-content.js.map +1 -1
  113. package/dist/components/forms/date-picker/value.js +44 -6
  114. package/dist/components/forms/date-picker/value.js.map +1 -1
  115. package/dist/components/forms/field.js +12 -20
  116. package/dist/components/forms/field.js.map +1 -1
  117. package/dist/components/forms/form.js +11 -27
  118. package/dist/components/forms/form.js.map +1 -1
  119. package/dist/components/forms/index.js +5 -2
  120. package/dist/components/forms/index.js.map +1 -1
  121. package/dist/components/forms/input-otp.js +10 -26
  122. package/dist/components/forms/input-otp.js.map +1 -1
  123. package/dist/components/forms/input.js +9 -22
  124. package/dist/components/forms/input.js.map +1 -1
  125. package/dist/components/forms/native-select.js +5 -12
  126. package/dist/components/forms/native-select.js.map +1 -1
  127. package/dist/components/forms/radio.js +4 -12
  128. package/dist/components/forms/radio.js.map +1 -1
  129. package/dist/components/forms/textarea.js +6 -17
  130. package/dist/components/forms/textarea.js.map +1 -1
  131. package/dist/components/navigation/pagination/pagination.js +18 -2
  132. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  133. package/dist/components/notifications/index.js +1 -1
  134. package/dist/components/overlays/overlay.js +8 -21
  135. package/dist/components/overlays/overlay.js.map +1 -1
  136. package/dist/components/utilities/avatar.js +26 -5
  137. package/dist/components/utilities/avatar.js.map +1 -1
  138. package/dist/components/utilities/collapsible.js +47 -3
  139. package/dist/components/utilities/collapsible.js.map +1 -1
  140. package/dist/forms.js +5 -2
  141. package/dist/forms.js.map +1 -1
  142. package/dist/index.js +6 -3
  143. package/dist/index.js.map +1 -1
  144. package/dist/{manager-jDaRVZ5o.js → manager-Dge4r8Vn.js} +9 -19
  145. package/dist/manager-Dge4r8Vn.js.map +1 -0
  146. package/dist/notifications.js +1 -1
  147. package/dist/services/notifications.js +1 -1
  148. package/dist/test-support.js +903 -389
  149. package/dist/test-support.js.map +1 -1
  150. package/dist/utils/forms-utils-index.js +1 -1
  151. package/dist/utils/forms-utils-index.js.map +1 -1
  152. package/dist/utils/nested-data.js +28 -1
  153. package/dist/utils/nested-data.js.map +1 -1
  154. package/package.json +10 -10
  155. package/dist/manager-jDaRVZ5o.js.map +0 -1
@@ -0,0 +1,562 @@
1
+ import { warn } from '@ember/debug';
2
+
3
+ /**
4
+ * The format an editable field uses when the consumer supplies none.
5
+ * Deliberately not `{ dateStyle: 'medium' }` -- DatePicker's button default --
6
+ * which renders a month name and has no numeric segment to type into.
7
+ */
8
+ const DEFAULT_FORMAT = {
9
+ year: 'numeric',
10
+ month: '2-digit',
11
+ day: '2-digit'
12
+ };
13
+ const BOUNDS = {
14
+ // Upper bound for the day is the widest any month gets; `toDate` clamps to
15
+ // the real length of the chosen month, which is not known segment-locally.
16
+ day: {
17
+ min: 1,
18
+ max: 31,
19
+ width: 2,
20
+ placeholder: 'dd'
21
+ },
22
+ month: {
23
+ min: 1,
24
+ max: 12,
25
+ width: 2,
26
+ placeholder: 'mm'
27
+ },
28
+ year: {
29
+ min: 1,
30
+ max: 9999,
31
+ width: 4,
32
+ placeholder: 'yyyy'
33
+ },
34
+ // A 24-hour clock's bounds; `hourBounds` gives the other cycles'.
35
+ hour: {
36
+ min: 0,
37
+ max: 23,
38
+ width: 2,
39
+ placeholder: 'hh'
40
+ },
41
+ minute: {
42
+ min: 0,
43
+ max: 59,
44
+ width: 2,
45
+ placeholder: 'mm'
46
+ },
47
+ // AM is 0 and PM is 1. Its placeholder is the locale's AM, set by
48
+ // `buildParts`, which is the only place the locale is known.
49
+ dayPeriod: {
50
+ min: 0,
51
+ max: 1,
52
+ width: 2,
53
+ placeholder: 'AM'
54
+ }
55
+ };
56
+ const HOUR_BOUNDS = {
57
+ h11: {
58
+ min: 0,
59
+ max: 11
60
+ },
61
+ h12: {
62
+ min: 1,
63
+ max: 12
64
+ },
65
+ h23: {
66
+ min: 0,
67
+ max: 23
68
+ },
69
+ h24: {
70
+ min: 1,
71
+ max: 24
72
+ }
73
+ };
74
+
75
+ /** Whether a cycle counts the hours twice a day, and so needs AM/PM. */
76
+ function isTwelveHour(cycle) {
77
+ return cycle === 'h11' || cycle === 'h12';
78
+ }
79
+ function isSegment(part) {
80
+ return part.kind === 'segment';
81
+ }
82
+ function emptySegment(type, overrides = {}) {
83
+ const {
84
+ min,
85
+ max,
86
+ width,
87
+ placeholder
88
+ } = BOUNDS[type];
89
+ return {
90
+ kind: 'segment',
91
+ type,
92
+ value: null,
93
+ min,
94
+ max,
95
+ width,
96
+ placeholder,
97
+ buffer: '',
98
+ isCommitted: false,
99
+ ...overrides
100
+ };
101
+ }
102
+
103
+ /**
104
+ * The format the segments are built from: the date format, plus the time
105
+ * fields a granularity asks for. Seconds are out of scope.
106
+ */
107
+ function withTime(format, {
108
+ granularity = 'day',
109
+ hourCycle
110
+ }) {
111
+ if (granularity === 'day') return format;
112
+ return {
113
+ ...format,
114
+ hour: '2-digit',
115
+ ...(granularity === 'minute' ? {
116
+ minute: '2-digit'
117
+ } : {}),
118
+ ...(hourCycle ? {
119
+ hourCycle: hourCycle === 12 ? 'h12' : 'h23'
120
+ } : {})
121
+ };
122
+ }
123
+
124
+ /** The locale's names for AM and PM, in that order. */
125
+ function dayPeriodLabels(locale) {
126
+ const formatter = new Intl.DateTimeFormat(locale, {
127
+ hour: 'numeric',
128
+ hourCycle: 'h12'
129
+ });
130
+ return [1, 13].map(hour => formatter.formatToParts(new Date(2026, 0, 20, hour)).find(p => p.type === 'dayPeriod')?.value ?? (hour < 12 ? 'AM' : 'PM'));
131
+ }
132
+
133
+ /**
134
+ * Derives the segments and their separators from the locale, so `mm/dd/yyyy`,
135
+ * `dd/mm/yyyy` and `yyyy年mm月dd日` all fall out of `Intl` rather than being
136
+ * hardcoded.
137
+ *
138
+ * A format producing a textual month ('Jan') has no editable numeric
139
+ * representation, so that part becomes a numeric month segment anyway. The
140
+ * component warns; this function stays pure.
141
+ */
142
+ function buildParts(locale, formatOptions = DEFAULT_FORMAT, time = {}) {
143
+ const formatter = new Intl.DateTimeFormat(locale, withTime(formatOptions, time));
144
+ // A reference date, only ever used to make the formatter emit its parts.
145
+ const parts = formatter.formatToParts(new Date(2026, 0, 20));
146
+ // `Intl` settles the cycle -- the locale's, or the one asked for -- and the
147
+ // hour's bounds, and whether there is an AM/PM at all, follow from it.
148
+ const hourCycle = formatter.resolvedOptions().hourCycle ?? 'h23';
149
+ const out = [];
150
+ for (const part of parts) {
151
+ if (part.type === 'year' || part.type === 'month' || part.type === 'day') {
152
+ out.push(emptySegment(part.type));
153
+ } else if (part.type === 'hour') {
154
+ out.push(emptySegment('hour', {
155
+ ...HOUR_BOUNDS[hourCycle],
156
+ hourCycle
157
+ }));
158
+ } else if (part.type === 'minute') {
159
+ out.push(emptySegment('minute'));
160
+ } else if (part.type === 'dayPeriod') {
161
+ const labels = dayPeriodLabels(locale);
162
+ out.push(emptySegment('dayPeriod', {
163
+ labels,
164
+ placeholder: labels[0]
165
+ }));
166
+ } else if (part.type === 'literal') {
167
+ out.push({
168
+ kind: 'literal',
169
+ text: part.value
170
+ });
171
+ }
172
+ // Everything else -- era, weekday, relatedYear -- is dropped: there is no
173
+ // segment for it.
174
+ }
175
+ return withoutDateTimeComma(out);
176
+ }
177
+ const DATE_TYPES = ['year', 'month', 'day'];
178
+
179
+ /**
180
+ * `Intl` joins the date and the time with a comma in many locales
181
+ * (`01/20/2026, 09:05 PM`), which reads like a sentence rather than a field.
182
+ * The separator between the last date segment and the first time one keeps
183
+ * whatever else the locale put there, minus the comma.
184
+ */
185
+ function withoutDateTimeComma(parts) {
186
+ return parts.map((part, i) => {
187
+ if (part.kind !== 'literal') return part;
188
+ const before = parts[i - 1];
189
+ const after = parts[i + 1];
190
+ const joinsDateAndTime = before?.kind === 'segment' && DATE_TYPES.includes(before.type) && after?.kind === 'segment' && !DATE_TYPES.includes(after.type);
191
+ if (!joinsDateAndTime) return part;
192
+ const text = part.text.replace(/[,،,]/g, '').replace(/\s+/g, ' ');
193
+ return {
194
+ kind: 'literal',
195
+ text: text.trim() === '' ? ' ' : text
196
+ };
197
+ });
198
+ }
199
+
200
+ /**
201
+ * A bare `yy` resolves into the hundred years running from 80 back to 19
202
+ * forward -- so a birth date reaches the past while a card expiry reaches the
203
+ * near future. Three or four digits are a year the user spelled out and are
204
+ * taken literally.
205
+ */
206
+ function resolveTwoDigitYear(digits, now = new Date()) {
207
+ const n = Number(digits);
208
+ if (digits.length > 2) return n;
209
+ const currentYear = now.getFullYear();
210
+ const start = currentYear - 80;
211
+ const century = Math.floor(start / 100) * 100;
212
+ const candidate = century + n;
213
+ return candidate < start ? candidate + 100 : candidate;
214
+ }
215
+
216
+ /**
217
+ * The numeric value a buffer represents, or null when it represents none.
218
+ *
219
+ * A buffer is always its literal number, including a year's: `26` is the year
220
+ * 26 here, not 2026. The two-digit window is applied once, by `commitSegment`,
221
+ * at the moment the user is finished with the segment -- applying it per
222
+ * keystroke would make the first digit of `2026` compose the year 2002 and
223
+ * push a date nobody typed out to `@onChange` and the calendar.
224
+ */
225
+ function bufferValue(segment, buffer) {
226
+ if (buffer === '') return null;
227
+ const n = Number(buffer);
228
+ return n < segment.min ? null : n;
229
+ }
230
+
231
+ /**
232
+ * Appends one typed digit.
233
+ *
234
+ * `isFull` is the signal to advance focus. It is true when the segment cannot
235
+ * take another digit -- either it has reached its width, or any further digit
236
+ * would exceed `max`. That is what makes typing `5` into a month jump straight
237
+ * to the day, while typing `1` waits to see whether `12` is coming.
238
+ */
239
+ function applyDigit(segment, digit) {
240
+ // A textual segment (AM/PM) is typed by letter; see `applyLetter`.
241
+ if (!/^\d$/.test(digit) || segment.labels) {
242
+ return {
243
+ segment,
244
+ isFull: false
245
+ };
246
+ }
247
+ let buffer = segment.buffer + digit;
248
+ let value = bufferValue(segment, buffer);
249
+
250
+ // The accumulated digits no longer fit the segment, so this keystroke starts
251
+ // a fresh entry instead of being discarded. Width is checked as well as the
252
+ // bound because leading zeros pile up without ever exceeding it: `00` then
253
+ // `1` in a month is the buffer `001`, which is still only January and would
254
+ // render three characters wide in a two-character segment.
255
+ if (buffer.length > segment.width || value !== null && value > segment.max) {
256
+ buffer = digit;
257
+ value = bufferValue(segment, buffer);
258
+ // A single digit that still overflows cannot be entered at all.
259
+ if (value !== null && value > segment.max) return {
260
+ segment,
261
+ isFull: false
262
+ };
263
+ }
264
+ const atWidth = buffer.length >= segment.width;
265
+ // Would any digit 0-9 appended here still fit? If not, there is nothing
266
+ // left to wait for. `bufferValue` returning null (below `min`) behaves like
267
+ // 0 here, same as the original non-null-assertion-based comparison did.
268
+ const extended = bufferValue(segment, buffer + '0') ?? 0;
269
+ const isFull = atWidth || extended > segment.max;
270
+
271
+ // A segment that can take no further digit is finished, so it commits here
272
+ // rather than waiting for focus to leave.
273
+ const next = {
274
+ ...segment,
275
+ buffer,
276
+ value,
277
+ isCommitted: isFull
278
+ };
279
+ return {
280
+ segment: next,
281
+ isFull
282
+ };
283
+ }
284
+
285
+ /**
286
+ * Marks a segment as the user's finished answer, expanding a one- or
287
+ * two-digit year through the sliding window on the way: typing `26` and
288
+ * moving on means 2026, while `0026` typed in full means the year 26.
289
+ *
290
+ * An empty segment has nothing to commit and stays uncommitted, so leaving a
291
+ * blank field does not invent a value for it.
292
+ */
293
+ function commitSegment(segment) {
294
+ if (segment.value === null) return segment;
295
+ if (segment.type === 'year' && segment.buffer.length > 0 && segment.buffer.length <= 2) {
296
+ return withValue(segment, resolveTwoDigitYear(segment.buffer));
297
+ }
298
+ return {
299
+ ...segment,
300
+ isCommitted: true
301
+ };
302
+ }
303
+
304
+ /**
305
+ * A segment holding `value` as a finished answer.
306
+ *
307
+ * The zero-padded buffer is the paired invariant of `displaySegment`, which
308
+ * reads the buffer back out -- so every path that sets a value goes through
309
+ * here rather than restating the padding and risking the two drifting.
310
+ */
311
+ function withValue(segment, value) {
312
+ return {
313
+ ...segment,
314
+ value,
315
+ buffer: String(value).padStart(segment.width, '0'),
316
+ isCommitted: true
317
+ };
318
+ }
319
+
320
+ /**
321
+ * Types into a textual segment: a letter picks the first label starting with
322
+ * it, so `a` and `p` set AM and PM in English. A letter that starts no label
323
+ * is ignored, and the segment is finished either way it is set.
324
+ */
325
+ function applyLetter(segment, key) {
326
+ const letter = key.toLocaleLowerCase();
327
+ const index = (segment.labels ?? []).findIndex(label => label.toLocaleLowerCase().startsWith(letter));
328
+ if (index === -1) return {
329
+ segment,
330
+ isFull: false
331
+ };
332
+ return {
333
+ segment: withValue(segment, index),
334
+ isFull: true
335
+ };
336
+ }
337
+
338
+ /** Clears both the value and the digits behind it. */
339
+ function clearSegment(segment) {
340
+ return {
341
+ ...segment,
342
+ value: null,
343
+ buffer: '',
344
+ isCommitted: false
345
+ };
346
+ }
347
+
348
+ /** Drops the last digit typed, for Backspace. */
349
+ function deleteDigit(segment) {
350
+ const buffer = segment.buffer.slice(0, -1);
351
+ // Un-commits: a year being backspaced through is being typed again, and the
352
+ // 202 it passes through must not compose a date.
353
+ return {
354
+ ...segment,
355
+ buffer,
356
+ value: bufferValue(segment, buffer),
357
+ isCommitted: false
358
+ };
359
+ }
360
+
361
+ /** A 0-23 hour as the given cycle counts it. */
362
+ function hourOnCycle(hours, cycle) {
363
+ if (cycle === 'h11') return hours % 12;
364
+ if (cycle === 'h12') return hours % 12 || 12;
365
+ if (cycle === 'h24') return hours || 24;
366
+ return hours;
367
+ }
368
+
369
+ /** The 0-23 hour an hour segment and an AM/PM (0 or 1) stand for. */
370
+ function hourOfDay(hour, cycle, dayPeriod) {
371
+ if (isTwelveHour(cycle)) return hour % 12 + (dayPeriod === 1 ? 12 : 0);
372
+ return hour % 24;
373
+ }
374
+
375
+ /** The unit of `date` this segment holds: what it seeds from, or is set to. */
376
+ function seedFrom(segment, date) {
377
+ switch (segment.type) {
378
+ case 'year':
379
+ return date.getFullYear();
380
+ case 'month':
381
+ return date.getMonth() + 1;
382
+ case 'day':
383
+ return date.getDate();
384
+ case 'hour':
385
+ return hourOnCycle(date.getHours(), segment.hourCycle ?? 'h23');
386
+ case 'minute':
387
+ return date.getMinutes();
388
+ case 'dayPeriod':
389
+ return date.getHours() < 12 ? 0 : 1;
390
+ }
391
+ }
392
+
393
+ /**
394
+ * Arrow and page keys. An empty segment does not step from zero -- it adopts
395
+ * `placeholderValue`, so ArrowUp on a blank year offers this year rather than
396
+ * the year 1.
397
+ */
398
+ function step(segment, delta, placeholderValue) {
399
+ if (segment.value === null) {
400
+ return withValue(segment, seedFrom(segment, placeholderValue));
401
+ }
402
+ const span = segment.max - segment.min + 1;
403
+ const offset = segment.value - segment.min + delta;
404
+ // Modulo twice: JavaScript's % keeps the sign of the dividend, so a
405
+ // decrement past the floor would otherwise land on a negative value.
406
+ const wrapped = (offset % span + span) % span;
407
+ return withValue(segment, wrapped + segment.min);
408
+ }
409
+
410
+ /**
411
+ * The segment's display text: the digits behind it, or its placeholder when
412
+ * empty. A year still being typed shows exactly what has been typed --
413
+ * `26` on the way to `2026` -- because padding it would claim digits the
414
+ * user has not entered. Every other segment, and a committed year, is padded
415
+ * to its full width.
416
+ *
417
+ * This is the single source of truth for "what does this segment read as
418
+ * right now" -- both the rendered cell text and `formatForClipboard` call
419
+ * it, so a mid-entry copy always matches what is on screen.
420
+ */
421
+ function displaySegment(segment) {
422
+ if (segment.value === null) return segment.placeholder;
423
+ if (segment.labels) return segment.labels[segment.value] ?? '';
424
+ const digits = segment.buffer;
425
+ return segment.type === 'year' && !segment.isCommitted ? digits : digits.padStart(segment.width, '0');
426
+ }
427
+ function findSegment(parts, type) {
428
+ return parts.find(p => isSegment(p) && p.type === type);
429
+ }
430
+
431
+ /** Days in a month, via the zeroth day of the next one. */
432
+ function daysInMonth(year, month) {
433
+ return new Date(year, month, 0).getDate();
434
+ }
435
+
436
+ /** A segment holding a finished value, as opposed to one mid-entry. */
437
+ function isReady(segment) {
438
+ return segment !== undefined && segment.value !== null && segment.isCommitted;
439
+ }
440
+
441
+ /**
442
+ * The time the time segments hold, as a 0-23 hour and a minute; midnight when
443
+ * there are none, and `null` while any of them is empty or still being typed.
444
+ */
445
+ function timeOf(parts) {
446
+ const hour = findSegment(parts, 'hour');
447
+ if (!hour) return {
448
+ hours: 0,
449
+ minutes: 0
450
+ };
451
+ const minute = findSegment(parts, 'minute');
452
+ const dayPeriod = findSegment(parts, 'dayPeriod');
453
+ if (!isReady(hour)) return null;
454
+ if (minute && !isReady(minute)) return null;
455
+ if (dayPeriod && !isReady(dayPeriod)) return null;
456
+ return {
457
+ hours: hourOfDay(hour.value, hour.hourCycle ?? 'h23', dayPeriod?.value ?? 0),
458
+ minutes: minute?.value ?? 0
459
+ };
460
+ }
461
+
462
+ /**
463
+ * The composed value, or `null` while any segment is still empty or still
464
+ * being typed. The day is clamped to the chosen month's real length: a 31 left
465
+ * over from January must resolve to the 28th in February, not roll forward
466
+ * into March the way the `Date` constructor would.
467
+ */
468
+ function toDate(parts) {
469
+ const year = findSegment(parts, 'year');
470
+ const month = findSegment(parts, 'month');
471
+ const day = findSegment(parts, 'day');
472
+
473
+ // Uncommitted counts as empty: half a year is not a date.
474
+ if (!isReady(year) || !isReady(month) || !isReady(day)) return null;
475
+ const time = timeOf(parts);
476
+ if (!time) return null;
477
+ const clamped = Math.min(day.value, daysInMonth(year.value, month.value));
478
+ return new Date(year.value, month.value - 1, clamped, time.hours, time.minutes);
479
+ }
480
+
481
+ /**
482
+ * Carries the segments' state onto a freshly built list, matching by type.
483
+ *
484
+ * Used when the locale or the format changes under a field that is already
485
+ * holding something. Going via `toDate` instead would discard a half-typed
486
+ * entry, because a partial entry composes no date -- and losing the user's
487
+ * digits to a locale switch is exactly the failure this component exists to
488
+ * avoid. A segment the new format has no place for is simply dropped.
489
+ */
490
+ function carryOver(next, previous) {
491
+ return next.map(part => {
492
+ if (!isSegment(part)) return part;
493
+ const was = findSegment(previous, part.type);
494
+ if (!was || was.value === null) return part;
495
+ return {
496
+ ...part,
497
+ value: was.value,
498
+ buffer: was.buffer,
499
+ isCommitted: was.isCommitted
500
+ };
501
+ });
502
+ }
503
+
504
+ /**
505
+ * Whether a format would render a month no one can type into -- either a
506
+ * textual month outright, or a `dateStyle` preset, which picks its own and
507
+ * cannot be reasoned about field by field.
508
+ */
509
+ function hasTextualMonth(options) {
510
+ return options.dateStyle !== undefined || options.month === 'long' || options.month === 'short' || options.month === 'narrow';
511
+ }
512
+
513
+ /**
514
+ * The nearest typeable format to the one asked for.
515
+ *
516
+ * A textual month is swapped for a numeric one and *everything else is left
517
+ * alone*: a format asking for month and day keeps exactly those two segments
518
+ * rather than growing a year the consumer never requested. A `dateStyle`
519
+ * preset names no fields at all, so there is nothing to preserve and the
520
+ * default numeric format stands in for the whole thing.
521
+ */
522
+ function toNumericFormat(options) {
523
+ if (options.dateStyle !== undefined) return DEFAULT_FORMAT;
524
+ return {
525
+ ...options,
526
+ month: 'numeric'
527
+ };
528
+ }
529
+
530
+ /**
531
+ * The format the segments should actually be built from, warning when that is
532
+ * not the one asked for.
533
+ *
534
+ * Both hosts need the identical policy and differ only in what they call
535
+ * themselves, so the message is passed in rather than the rule being written
536
+ * out twice and left to drift.
537
+ */
538
+ function resolveSegmentFormat(given, warning) {
539
+ if (!given || !hasTextualMonth(given)) return given;
540
+ warn(warning.message, false, {
541
+ id: warning.id
542
+ });
543
+ return toNumericFormat(given);
544
+ }
545
+
546
+ /** Whether two composed values differ -- `null` (no date) included. */
547
+ function hasDateChanged(before, after) {
548
+ if (before === null || after === null) return before !== after;
549
+ return before.getTime() !== after.getTime();
550
+ }
551
+
552
+ /** Writes a value across the segments, leaving literals untouched. */
553
+ function fromDate(parts, date) {
554
+ return parts.map(part => {
555
+ if (!isSegment(part)) return part;
556
+ if (!date) return clearSegment(part);
557
+ return withValue(part, seedFrom(part, date));
558
+ });
559
+ }
560
+
561
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue };
562
+ //# sourceMappingURL=segments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segments.js","sources":["../../../../src/components/forms/date-input/segments.ts"],"sourcesContent":["import { warn } from '@ember/debug';\nimport type {\n HourCycle,\n Part,\n Segment,\n SegmentType,\n TimeOptions\n} from './types';\n\n/**\n * The format an editable field uses when the consumer supplies none.\n * Deliberately not `{ dateStyle: 'medium' }` -- DatePicker's button default --\n * which renders a month name and has no numeric segment to type into.\n */\nconst DEFAULT_FORMAT: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit'\n};\n\nconst BOUNDS: Record<\n SegmentType,\n { min: number; max: number; width: number; placeholder: string }\n> = {\n // Upper bound for the day is the widest any month gets; `toDate` clamps to\n // the real length of the chosen month, which is not known segment-locally.\n day: { min: 1, max: 31, width: 2, placeholder: 'dd' },\n month: { min: 1, max: 12, width: 2, placeholder: 'mm' },\n year: { min: 1, max: 9999, width: 4, placeholder: 'yyyy' },\n // A 24-hour clock's bounds; `hourBounds` gives the other cycles'.\n hour: { min: 0, max: 23, width: 2, placeholder: 'hh' },\n minute: { min: 0, max: 59, width: 2, placeholder: 'mm' },\n // AM is 0 and PM is 1. Its placeholder is the locale's AM, set by\n // `buildParts`, which is the only place the locale is known.\n dayPeriod: { min: 0, max: 1, width: 2, placeholder: 'AM' }\n};\n\nconst HOUR_BOUNDS: Record<HourCycle, { min: number; max: number }> = {\n h11: { min: 0, max: 11 },\n h12: { min: 1, max: 12 },\n h23: { min: 0, max: 23 },\n h24: { min: 1, max: 24 }\n};\n\n/** Whether a cycle counts the hours twice a day, and so needs AM/PM. */\nfunction isTwelveHour(cycle: HourCycle): boolean {\n return cycle === 'h11' || cycle === 'h12';\n}\n\nfunction isSegment(part: Part): part is Segment {\n return part.kind === 'segment';\n}\n\nfunction emptySegment(\n type: SegmentType,\n overrides: Partial<Segment> = {}\n): Segment {\n const { min, max, width, placeholder } = BOUNDS[type];\n return {\n kind: 'segment',\n type,\n value: null,\n min,\n max,\n width,\n placeholder,\n buffer: '',\n isCommitted: false,\n ...overrides\n };\n}\n\n/**\n * The format the segments are built from: the date format, plus the time\n * fields a granularity asks for. Seconds are out of scope.\n */\nfunction withTime(\n format: Intl.DateTimeFormatOptions,\n { granularity = 'day', hourCycle }: TimeOptions\n): Intl.DateTimeFormatOptions {\n if (granularity === 'day') return format;\n\n return {\n ...format,\n hour: '2-digit',\n ...(granularity === 'minute' ? { minute: '2-digit' } : {}),\n ...(hourCycle ? { hourCycle: hourCycle === 12 ? 'h12' : 'h23' } : {})\n };\n}\n\n/** The locale's names for AM and PM, in that order. */\nfunction dayPeriodLabels(locale: string): string[] {\n const formatter = new Intl.DateTimeFormat(locale, {\n hour: 'numeric',\n hourCycle: 'h12'\n });\n return [1, 13].map(\n (hour) =>\n formatter\n .formatToParts(new Date(2026, 0, 20, hour))\n .find((p) => p.type === 'dayPeriod')?.value ?? (hour < 12 ? 'AM' : 'PM')\n );\n}\n\n/**\n * Derives the segments and their separators from the locale, so `mm/dd/yyyy`,\n * `dd/mm/yyyy` and `yyyy年mm月dd日` all fall out of `Intl` rather than being\n * hardcoded.\n *\n * A format producing a textual month ('Jan') has no editable numeric\n * representation, so that part becomes a numeric month segment anyway. The\n * component warns; this function stays pure.\n */\nfunction buildParts(\n locale: string,\n formatOptions: Intl.DateTimeFormatOptions = DEFAULT_FORMAT,\n time: TimeOptions = {}\n): Part[] {\n const formatter = new Intl.DateTimeFormat(\n locale,\n withTime(formatOptions, time)\n );\n // A reference date, only ever used to make the formatter emit its parts.\n const parts = formatter.formatToParts(new Date(2026, 0, 20));\n // `Intl` settles the cycle -- the locale's, or the one asked for -- and the\n // hour's bounds, and whether there is an AM/PM at all, follow from it.\n const hourCycle = formatter.resolvedOptions().hourCycle ?? 'h23';\n\n const out: Part[] = [];\n for (const part of parts) {\n if (part.type === 'year' || part.type === 'month' || part.type === 'day') {\n out.push(emptySegment(part.type));\n } else if (part.type === 'hour') {\n out.push(emptySegment('hour', { ...HOUR_BOUNDS[hourCycle], hourCycle }));\n } else if (part.type === 'minute') {\n out.push(emptySegment('minute'));\n } else if (part.type === 'dayPeriod') {\n const labels = dayPeriodLabels(locale);\n out.push(emptySegment('dayPeriod', { labels, placeholder: labels[0] }));\n } else if (part.type === 'literal') {\n out.push({ kind: 'literal', text: part.value });\n }\n // Everything else -- era, weekday, relatedYear -- is dropped: there is no\n // segment for it.\n }\n\n return withoutDateTimeComma(out);\n}\n\nconst DATE_TYPES: SegmentType[] = ['year', 'month', 'day'];\n\n/**\n * `Intl` joins the date and the time with a comma in many locales\n * (`01/20/2026, 09:05 PM`), which reads like a sentence rather than a field.\n * The separator between the last date segment and the first time one keeps\n * whatever else the locale put there, minus the comma.\n */\nfunction withoutDateTimeComma(parts: Part[]): Part[] {\n return parts.map((part, i) => {\n if (part.kind !== 'literal') return part;\n const before = parts[i - 1];\n const after = parts[i + 1];\n const joinsDateAndTime =\n before?.kind === 'segment' &&\n DATE_TYPES.includes(before.type) &&\n after?.kind === 'segment' &&\n !DATE_TYPES.includes(after.type);\n if (!joinsDateAndTime) return part;\n const text = part.text.replace(/[,،,]/g, '').replace(/\\s+/g, ' ');\n return { kind: 'literal', text: text.trim() === '' ? ' ' : text };\n });\n}\n\n/**\n * A bare `yy` resolves into the hundred years running from 80 back to 19\n * forward -- so a birth date reaches the past while a card expiry reaches the\n * near future. Three or four digits are a year the user spelled out and are\n * taken literally.\n */\nfunction resolveTwoDigitYear(digits: string, now: Date = new Date()): number {\n const n = Number(digits);\n if (digits.length > 2) return n;\n\n const currentYear = now.getFullYear();\n const start = currentYear - 80;\n const century = Math.floor(start / 100) * 100;\n const candidate = century + n;\n return candidate < start ? candidate + 100 : candidate;\n}\n\n/**\n * The numeric value a buffer represents, or null when it represents none.\n *\n * A buffer is always its literal number, including a year's: `26` is the year\n * 26 here, not 2026. The two-digit window is applied once, by `commitSegment`,\n * at the moment the user is finished with the segment -- applying it per\n * keystroke would make the first digit of `2026` compose the year 2002 and\n * push a date nobody typed out to `@onChange` and the calendar.\n */\nfunction bufferValue(segment: Segment, buffer: string): number | null {\n if (buffer === '') return null;\n const n = Number(buffer);\n return n < segment.min ? null : n;\n}\n\n/**\n * Appends one typed digit.\n *\n * `isFull` is the signal to advance focus. It is true when the segment cannot\n * take another digit -- either it has reached its width, or any further digit\n * would exceed `max`. That is what makes typing `5` into a month jump straight\n * to the day, while typing `1` waits to see whether `12` is coming.\n */\nfunction applyDigit(\n segment: Segment,\n digit: string\n): { segment: Segment; isFull: boolean } {\n // A textual segment (AM/PM) is typed by letter; see `applyLetter`.\n if (!/^\\d$/.test(digit) || segment.labels) {\n return { segment, isFull: false };\n }\n\n let buffer = segment.buffer + digit;\n let value = bufferValue(segment, buffer);\n\n // The accumulated digits no longer fit the segment, so this keystroke starts\n // a fresh entry instead of being discarded. Width is checked as well as the\n // bound because leading zeros pile up without ever exceeding it: `00` then\n // `1` in a month is the buffer `001`, which is still only January and would\n // render three characters wide in a two-character segment.\n if (\n buffer.length > segment.width ||\n (value !== null && value > segment.max)\n ) {\n buffer = digit;\n value = bufferValue(segment, buffer);\n // A single digit that still overflows cannot be entered at all.\n if (value !== null && value > segment.max)\n return { segment, isFull: false };\n }\n\n const atWidth = buffer.length >= segment.width;\n // Would any digit 0-9 appended here still fit? If not, there is nothing\n // left to wait for. `bufferValue` returning null (below `min`) behaves like\n // 0 here, same as the original non-null-assertion-based comparison did.\n const extended = bufferValue(segment, buffer + '0') ?? 0;\n const isFull = atWidth || extended > segment.max;\n\n // A segment that can take no further digit is finished, so it commits here\n // rather than waiting for focus to leave.\n const next: Segment = { ...segment, buffer, value, isCommitted: isFull };\n\n return { segment: next, isFull };\n}\n\n/**\n * Marks a segment as the user's finished answer, expanding a one- or\n * two-digit year through the sliding window on the way: typing `26` and\n * moving on means 2026, while `0026` typed in full means the year 26.\n *\n * An empty segment has nothing to commit and stays uncommitted, so leaving a\n * blank field does not invent a value for it.\n */\nfunction commitSegment(segment: Segment): Segment {\n if (segment.value === null) return segment;\n\n if (\n segment.type === 'year' &&\n segment.buffer.length > 0 &&\n segment.buffer.length <= 2\n ) {\n return withValue(segment, resolveTwoDigitYear(segment.buffer));\n }\n\n return { ...segment, isCommitted: true };\n}\n\n/**\n * A segment holding `value` as a finished answer.\n *\n * The zero-padded buffer is the paired invariant of `displaySegment`, which\n * reads the buffer back out -- so every path that sets a value goes through\n * here rather than restating the padding and risking the two drifting.\n */\nfunction withValue(segment: Segment, value: number): Segment {\n return {\n ...segment,\n value,\n buffer: String(value).padStart(segment.width, '0'),\n isCommitted: true\n };\n}\n\n/**\n * Types into a textual segment: a letter picks the first label starting with\n * it, so `a` and `p` set AM and PM in English. A letter that starts no label\n * is ignored, and the segment is finished either way it is set.\n */\nfunction applyLetter(\n segment: Segment,\n key: string\n): { segment: Segment; isFull: boolean } {\n const letter = key.toLocaleLowerCase();\n const index = (segment.labels ?? []).findIndex((label) =>\n label.toLocaleLowerCase().startsWith(letter)\n );\n if (index === -1) return { segment, isFull: false };\n\n return { segment: withValue(segment, index), isFull: true };\n}\n\n/** Clears both the value and the digits behind it. */\nfunction clearSegment(segment: Segment): Segment {\n return { ...segment, value: null, buffer: '', isCommitted: false };\n}\n\n/** Drops the last digit typed, for Backspace. */\nfunction deleteDigit(segment: Segment): Segment {\n const buffer = segment.buffer.slice(0, -1);\n // Un-commits: a year being backspaced through is being typed again, and the\n // 202 it passes through must not compose a date.\n return {\n ...segment,\n buffer,\n value: bufferValue(segment, buffer),\n isCommitted: false\n };\n}\n\n/** A 0-23 hour as the given cycle counts it. */\nfunction hourOnCycle(hours: number, cycle: HourCycle): number {\n if (cycle === 'h11') return hours % 12;\n if (cycle === 'h12') return hours % 12 || 12;\n if (cycle === 'h24') return hours || 24;\n return hours;\n}\n\n/** The 0-23 hour an hour segment and an AM/PM (0 or 1) stand for. */\nfunction hourOfDay(hour: number, cycle: HourCycle, dayPeriod: number): number {\n if (isTwelveHour(cycle)) return (hour % 12) + (dayPeriod === 1 ? 12 : 0);\n return hour % 24;\n}\n\n/** The unit of `date` this segment holds: what it seeds from, or is set to. */\nfunction seedFrom(segment: Segment, date: Date): number {\n switch (segment.type) {\n case 'year':\n return date.getFullYear();\n case 'month':\n return date.getMonth() + 1;\n case 'day':\n return date.getDate();\n case 'hour':\n return hourOnCycle(date.getHours(), segment.hourCycle ?? 'h23');\n case 'minute':\n return date.getMinutes();\n case 'dayPeriod':\n return date.getHours() < 12 ? 0 : 1;\n }\n}\n\n/**\n * Arrow and page keys. An empty segment does not step from zero -- it adopts\n * `placeholderValue`, so ArrowUp on a blank year offers this year rather than\n * the year 1.\n */\nfunction step(\n segment: Segment,\n delta: number,\n placeholderValue: Date\n): Segment {\n if (segment.value === null) {\n return withValue(segment, seedFrom(segment, placeholderValue));\n }\n\n const span = segment.max - segment.min + 1;\n const offset = segment.value - segment.min + delta;\n // Modulo twice: JavaScript's % keeps the sign of the dividend, so a\n // decrement past the floor would otherwise land on a negative value.\n const wrapped = ((offset % span) + span) % span;\n\n return withValue(segment, wrapped + segment.min);\n}\n\n/**\n * The segment's display text: the digits behind it, or its placeholder when\n * empty. A year still being typed shows exactly what has been typed --\n * `26` on the way to `2026` -- because padding it would claim digits the\n * user has not entered. Every other segment, and a committed year, is padded\n * to its full width.\n *\n * This is the single source of truth for \"what does this segment read as\n * right now\" -- both the rendered cell text and `formatForClipboard` call\n * it, so a mid-entry copy always matches what is on screen.\n */\nfunction displaySegment(segment: Segment): string {\n if (segment.value === null) return segment.placeholder;\n if (segment.labels) return segment.labels[segment.value] ?? '';\n\n const digits = segment.buffer;\n\n return segment.type === 'year' && !segment.isCommitted\n ? digits\n : digits.padStart(segment.width, '0');\n}\n\nfunction findSegment(parts: Part[], type: SegmentType): Segment | undefined {\n return parts.find((p): p is Segment => isSegment(p) && p.type === type);\n}\n\n/** Days in a month, via the zeroth day of the next one. */\nfunction daysInMonth(year: number, month: number): number {\n return new Date(year, month, 0).getDate();\n}\n\n/** A segment holding a finished value, as opposed to one mid-entry. */\nfunction isReady(\n segment: Segment | undefined\n): segment is Segment & { value: number } {\n return segment !== undefined && segment.value !== null && segment.isCommitted;\n}\n\n/**\n * The time the time segments hold, as a 0-23 hour and a minute; midnight when\n * there are none, and `null` while any of them is empty or still being typed.\n */\nfunction timeOf(parts: Part[]): { hours: number; minutes: number } | null {\n const hour = findSegment(parts, 'hour');\n if (!hour) return { hours: 0, minutes: 0 };\n\n const minute = findSegment(parts, 'minute');\n const dayPeriod = findSegment(parts, 'dayPeriod');\n if (!isReady(hour)) return null;\n if (minute && !isReady(minute)) return null;\n if (dayPeriod && !isReady(dayPeriod)) return null;\n\n return {\n hours: hourOfDay(\n hour.value,\n hour.hourCycle ?? 'h23',\n dayPeriod?.value ?? 0\n ),\n minutes: minute?.value ?? 0\n };\n}\n\n/**\n * The composed value, or `null` while any segment is still empty or still\n * being typed. The day is clamped to the chosen month's real length: a 31 left\n * over from January must resolve to the 28th in February, not roll forward\n * into March the way the `Date` constructor would.\n */\nfunction toDate(parts: Part[]): Date | null {\n const year = findSegment(parts, 'year');\n const month = findSegment(parts, 'month');\n const day = findSegment(parts, 'day');\n\n // Uncommitted counts as empty: half a year is not a date.\n if (!isReady(year) || !isReady(month) || !isReady(day)) return null;\n\n const time = timeOf(parts);\n if (!time) return null;\n\n const clamped = Math.min(day.value, daysInMonth(year.value, month.value));\n return new Date(\n year.value,\n month.value - 1,\n clamped,\n time.hours,\n time.minutes\n );\n}\n\n/**\n * Carries the segments' state onto a freshly built list, matching by type.\n *\n * Used when the locale or the format changes under a field that is already\n * holding something. Going via `toDate` instead would discard a half-typed\n * entry, because a partial entry composes no date -- and losing the user's\n * digits to a locale switch is exactly the failure this component exists to\n * avoid. A segment the new format has no place for is simply dropped.\n */\nfunction carryOver(next: Part[], previous: Part[]): Part[] {\n return next.map((part) => {\n if (!isSegment(part)) return part;\n\n const was = findSegment(previous, part.type);\n if (!was || was.value === null) return part;\n\n return {\n ...part,\n value: was.value,\n buffer: was.buffer,\n isCommitted: was.isCommitted\n };\n });\n}\n\n/**\n * Whether a format would render a month no one can type into -- either a\n * textual month outright, or a `dateStyle` preset, which picks its own and\n * cannot be reasoned about field by field.\n */\nfunction hasTextualMonth(options: Intl.DateTimeFormatOptions): boolean {\n return (\n options.dateStyle !== undefined ||\n options.month === 'long' ||\n options.month === 'short' ||\n options.month === 'narrow'\n );\n}\n\n/**\n * The nearest typeable format to the one asked for.\n *\n * A textual month is swapped for a numeric one and *everything else is left\n * alone*: a format asking for month and day keeps exactly those two segments\n * rather than growing a year the consumer never requested. A `dateStyle`\n * preset names no fields at all, so there is nothing to preserve and the\n * default numeric format stands in for the whole thing.\n */\nfunction toNumericFormat(\n options: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormatOptions {\n if (options.dateStyle !== undefined) return DEFAULT_FORMAT;\n return { ...options, month: 'numeric' };\n}\n\n/**\n * The format the segments should actually be built from, warning when that is\n * not the one asked for.\n *\n * Both hosts need the identical policy and differ only in what they call\n * themselves, so the message is passed in rather than the rule being written\n * out twice and left to drift.\n */\nfunction resolveSegmentFormat(\n given: Intl.DateTimeFormatOptions | undefined,\n warning: { message: string; id: string }\n): Intl.DateTimeFormatOptions | undefined {\n if (!given || !hasTextualMonth(given)) return given;\n\n warn(warning.message, false, { id: warning.id });\n\n return toNumericFormat(given);\n}\n\n/** Whether two composed values differ -- `null` (no date) included. */\nfunction hasDateChanged(before: Date | null, after: Date | null): boolean {\n if (before === null || after === null) return before !== after;\n return before.getTime() !== after.getTime();\n}\n\n/** Writes a value across the segments, leaving literals untouched. */\nfunction fromDate(parts: Part[], date: Date | null): Part[] {\n return parts.map((part) => {\n if (!isSegment(part)) return part;\n if (!date) return clearSegment(part);\n\n return withValue(part, seedFrom(part, date));\n });\n}\n\nexport {\n buildParts,\n withTime,\n applyLetter,\n timeOf,\n hourOnCycle,\n hourOfDay,\n isSegment,\n emptySegment,\n DEFAULT_FORMAT,\n BOUNDS,\n applyDigit,\n commitSegment,\n clearSegment,\n deleteDigit,\n step,\n toDate,\n fromDate,\n findSegment,\n resolveTwoDigitYear,\n daysInMonth,\n displaySegment,\n withValue,\n carryOver,\n hasTextualMonth,\n toNumericFormat,\n resolveSegmentFormat,\n hasDateChanged\n};\n"],"names":["DEFAULT_FORMAT","year","month","day","BOUNDS","min","max","width","placeholder","hour","minute","dayPeriod","HOUR_BOUNDS","h11","h12","h23","h24","isTwelveHour","cycle","isSegment","part","kind","emptySegment","type","overrides","value","buffer","isCommitted","withTime","format","granularity","hourCycle","dayPeriodLabels","locale","formatter","Intl","DateTimeFormat","map","formatToParts","Date","find","p","buildParts","formatOptions","time","parts","resolvedOptions","out","push","labels","text","withoutDateTimeComma","DATE_TYPES","i","before","after","joinsDateAndTime","includes","replace","trim","resolveTwoDigitYear","digits","now","n","Number","length","currentYear","getFullYear","start","century","Math","floor","candidate","bufferValue","segment","applyDigit","digit","test","isFull","atWidth","extended","next","commitSegment","withValue","String","padStart","applyLetter","key","letter","toLocaleLowerCase","index","findIndex","label","startsWith","clearSegment","deleteDigit","slice","hourOnCycle","hours","hourOfDay","seedFrom","date","getMonth","getDate","getHours","getMinutes","step","delta","placeholderValue","span","offset","wrapped","displaySegment","findSegment","daysInMonth","isReady","undefined","timeOf","minutes","toDate","clamped","carryOver","previous","was","hasTextualMonth","options","dateStyle","toNumericFormat","resolveSegmentFormat","given","warning","warn","message","id","hasDateChanged","getTime","fromDate"],"mappings":";;AASA;AACA;AACA;AACA;AACA;AACA,MAA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,OAAOA,IAAI;AACjC,IAAA,IAAI,CAACiF,IAAI,EAAE,OAAOP,YAAY,CAAC1E,IAAI,CAAC;IAEpC,OAAO+D,SAAS,CAAC/D,IAAI,EAAEgF,QAAQ,CAAChF,IAAI,EAAEiF,IAAI,CAAC,CAAC;AAC9C,EAAA,CAAC,CAAC;AACJ;;"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './date-input/segments.js';
2
+ export { formatForClipboard, parsePasted, splitRange } from './date-input/clipboard.js';
3
+ export { DateInput, DateInput as default } from './date-input/date-input.js';
4
+ //# sourceMappingURL=date-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}