frontile 0.18.1 → 0.18.3

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 (151) 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/close-button.d.ts +2 -2
  5. package/declarations/components/buttons/close-button.d.ts.map +1 -1
  6. package/declarations/components/collections/calendar/calendar.d.ts +7 -1
  7. package/declarations/components/collections/calendar/calendar.d.ts.map +1 -1
  8. package/declarations/components/collections/calendar/header.d.ts +2 -0
  9. package/declarations/components/collections/calendar/header.d.ts.map +1 -1
  10. package/declarations/components/collections/calendar/types.d.ts +15 -0
  11. package/declarations/components/collections/calendar/types.d.ts.map +1 -1
  12. package/declarations/components/collections/calendar/year-grid.d.ts +2 -0
  13. package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
  14. package/declarations/components/collections/listbox/item.d.ts +2 -2
  15. package/declarations/components/collections/listbox/item.d.ts.map +1 -1
  16. package/declarations/components/collections/simple-table/column.d.ts +6 -0
  17. package/declarations/components/collections/simple-table/column.d.ts.map +1 -1
  18. package/declarations/components/collections/simple-table/footer.d.ts +2 -1
  19. package/declarations/components/collections/simple-table/footer.d.ts.map +1 -1
  20. package/declarations/components/collections/simple-table/header.d.ts +2 -1
  21. package/declarations/components/collections/simple-table/header.d.ts.map +1 -1
  22. package/declarations/components/collections/simple-table/index.d.ts +1 -1
  23. package/declarations/components/collections/simple-table/index.d.ts.map +1 -1
  24. package/declarations/components/collections/table/checkbox.d.ts +1 -1
  25. package/declarations/components/collections/table/checkbox.d.ts.map +1 -1
  26. package/declarations/components/collections/table/column-visibility.d.ts +2 -2
  27. package/declarations/components/collections/table/column-visibility.d.ts.map +1 -1
  28. package/declarations/components/collections/table/table.d.ts +9 -7
  29. package/declarations/components/collections/table/table.d.ts.map +1 -1
  30. package/declarations/components/forms/checkbox.d.ts +2 -2
  31. package/declarations/components/forms/checkbox.d.ts.map +1 -1
  32. package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -1
  33. package/declarations/components/forms/date-input/date-input.d.ts +5 -2
  34. package/declarations/components/forms/date-input/date-input.d.ts.map +1 -1
  35. package/declarations/components/forms/date-input/segment-group.d.ts +2 -0
  36. package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
  37. package/declarations/components/forms/date-input/segments.d.ts +30 -4
  38. package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
  39. package/declarations/components/forms/date-input/types.d.ts +60 -5
  40. package/declarations/components/forms/date-input/types.d.ts.map +1 -1
  41. package/declarations/components/forms/date-picker/date-picker.d.ts +19 -2
  42. package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
  43. package/declarations/components/forms/date-picker/end-content.d.ts +3 -1
  44. package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
  45. package/declarations/components/forms/date-picker/types.d.ts +42 -4
  46. package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
  47. package/declarations/components/forms/date-picker/value.d.ts +21 -5
  48. package/declarations/components/forms/date-picker/value.d.ts.map +1 -1
  49. package/declarations/components/forms/field.d.ts +4 -5
  50. package/declarations/components/forms/field.d.ts.map +1 -1
  51. package/declarations/components/forms/form.d.ts +5 -5
  52. package/declarations/components/forms/form.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 +4 -4
  56. package/declarations/components/forms/input.d.ts.map +1 -1
  57. package/declarations/components/forms/native-select.d.ts +2 -2
  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/textarea.d.ts +3 -3
  62. package/declarations/components/forms/textarea.d.ts.map +1 -1
  63. package/declarations/components/navigation/pagination/pagination.d.ts +32 -1
  64. package/declarations/components/navigation/pagination/pagination.d.ts.map +1 -1
  65. package/declarations/components/overlays/overlay.d.ts +4 -4
  66. package/declarations/components/overlays/overlay.d.ts.map +1 -1
  67. package/declarations/components/utilities/avatar.d.ts +1 -1
  68. package/declarations/components/utilities/avatar.d.ts.map +1 -1
  69. package/declarations/components/utilities/collapsible.d.ts +16 -0
  70. package/declarations/components/utilities/collapsible.d.ts.map +1 -1
  71. package/declarations/utils/forms-utils-index.d.ts +1 -1
  72. package/declarations/utils/forms-utils-index.d.ts.map +1 -1
  73. package/declarations/utils/nested-data.d.ts +17 -0
  74. package/declarations/utils/nested-data.d.ts.map +1 -1
  75. package/dist/components/buttons/close-button.js +5 -12
  76. package/dist/components/buttons/close-button.js.map +1 -1
  77. package/dist/components/collections/calendar/calendar.js +13 -1
  78. package/dist/components/collections/calendar/calendar.js.map +1 -1
  79. package/dist/components/collections/calendar/header.js +1 -1
  80. package/dist/components/collections/calendar/header.js.map +1 -1
  81. package/dist/components/collections/calendar/year-grid.js +1 -1
  82. package/dist/components/collections/calendar/year-grid.js.map +1 -1
  83. package/dist/components/collections/listbox/item.js +4 -11
  84. package/dist/components/collections/listbox/item.js.map +1 -1
  85. package/dist/components/collections/simple-table/column.js +2 -2
  86. package/dist/components/collections/simple-table/column.js.map +1 -1
  87. package/dist/components/collections/simple-table/footer.js +1 -1
  88. package/dist/components/collections/simple-table/footer.js.map +1 -1
  89. package/dist/components/collections/simple-table/header.js +1 -1
  90. package/dist/components/collections/simple-table/header.js.map +1 -1
  91. package/dist/components/collections/simple-table/index.js +1 -1
  92. package/dist/components/collections/simple-table/index.js.map +1 -1
  93. package/dist/components/collections/table/checkbox.js +2 -7
  94. package/dist/components/collections/table/checkbox.js.map +1 -1
  95. package/dist/components/collections/table/column-visibility.js +2 -7
  96. package/dist/components/collections/table/column-visibility.js.map +1 -1
  97. package/dist/components/forms/checkbox.js +4 -12
  98. package/dist/components/forms/checkbox.js.map +1 -1
  99. package/dist/components/forms/date-input/clipboard.js +74 -5
  100. package/dist/components/forms/date-input/clipboard.js.map +1 -1
  101. package/dist/components/forms/date-input/date-input.js +24 -5
  102. package/dist/components/forms/date-input/date-input.js.map +1 -1
  103. package/dist/components/forms/date-input/segment-group.js +26 -5
  104. package/dist/components/forms/date-input/segment-group.js.map +1 -1
  105. package/dist/components/forms/date-input/segments.js +203 -20
  106. package/dist/components/forms/date-input/segments.js.map +1 -1
  107. package/dist/components/forms/date-input.js +1 -1
  108. package/dist/components/forms/date-picker/date-picker.js +76 -11
  109. package/dist/components/forms/date-picker/date-picker.js.map +1 -1
  110. package/dist/components/forms/date-picker/end-content.js +1 -3
  111. package/dist/components/forms/date-picker/end-content.js.map +1 -1
  112. package/dist/components/forms/date-picker/value.js +44 -6
  113. package/dist/components/forms/date-picker/value.js.map +1 -1
  114. package/dist/components/forms/field.js +8 -19
  115. package/dist/components/forms/field.js.map +1 -1
  116. package/dist/components/forms/form.js +11 -27
  117. package/dist/components/forms/form.js.map +1 -1
  118. package/dist/components/forms/index.js +3 -3
  119. package/dist/components/forms/input-otp.js +10 -26
  120. package/dist/components/forms/input-otp.js.map +1 -1
  121. package/dist/components/forms/input.js +9 -22
  122. package/dist/components/forms/input.js.map +1 -1
  123. package/dist/components/forms/native-select.js +5 -12
  124. package/dist/components/forms/native-select.js.map +1 -1
  125. package/dist/components/forms/radio.js +4 -12
  126. package/dist/components/forms/radio.js.map +1 -1
  127. package/dist/components/forms/textarea.js +6 -17
  128. package/dist/components/forms/textarea.js.map +1 -1
  129. package/dist/components/navigation/pagination/pagination.js +18 -2
  130. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  131. package/dist/components/notifications/index.js +1 -1
  132. package/dist/components/overlays/overlay.js +8 -21
  133. package/dist/components/overlays/overlay.js.map +1 -1
  134. package/dist/components/utilities/avatar.js +3 -7
  135. package/dist/components/utilities/avatar.js.map +1 -1
  136. package/dist/components/utilities/collapsible.js +47 -3
  137. package/dist/components/utilities/collapsible.js.map +1 -1
  138. package/dist/forms.js +3 -3
  139. package/dist/index.js +4 -4
  140. package/dist/{manager-jDaRVZ5o.js → manager-Dge4r8Vn.js} +9 -19
  141. package/dist/manager-Dge4r8Vn.js.map +1 -0
  142. package/dist/notifications.js +1 -1
  143. package/dist/services/notifications.js +1 -1
  144. package/dist/test-support.js +400 -365
  145. package/dist/test-support.js.map +1 -1
  146. package/dist/utils/forms-utils-index.js +1 -1
  147. package/dist/utils/forms-utils-index.js.map +1 -1
  148. package/dist/utils/nested-data.js +28 -1
  149. package/dist/utils/nested-data.js.map +1 -1
  150. package/package.json +10 -10
  151. package/dist/manager-jDaRVZ5o.js.map +0 -1
@@ -30,12 +30,56 @@ const BOUNDS = {
30
30
  max: 9999,
31
31
  width: 4,
32
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
33
72
  }
34
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
+ }
35
79
  function isSegment(part) {
36
80
  return part.kind === 'segment';
37
81
  }
38
- function emptySegment(type) {
82
+ function emptySegment(type, overrides = {}) {
39
83
  const {
40
84
  min,
41
85
  max,
@@ -51,10 +95,41 @@ function emptySegment(type) {
51
95
  width,
52
96
  placeholder,
53
97
  buffer: '',
54
- isCommitted: false
98
+ isCommitted: false,
99
+ ...overrides
55
100
  };
56
101
  }
57
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
+
58
133
  /**
59
134
  * Derives the segments and their separators from the locale, so `mm/dd/yyyy`,
60
135
  * `dd/mm/yyyy` and `yyyy年mm月dd日` all fall out of `Intl` rather than being
@@ -64,24 +139,62 @@ function emptySegment(type) {
64
139
  * representation, so that part becomes a numeric month segment anyway. The
65
140
  * component warns; this function stays pure.
66
141
  */
67
- function buildParts(locale, formatOptions = DEFAULT_FORMAT) {
68
- const formatter = new Intl.DateTimeFormat(locale, formatOptions);
142
+ function buildParts(locale, formatOptions = DEFAULT_FORMAT, time = {}) {
143
+ const formatter = new Intl.DateTimeFormat(locale, withTime(formatOptions, time));
69
144
  // A reference date, only ever used to make the formatter emit its parts.
70
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';
71
149
  const out = [];
72
150
  for (const part of parts) {
73
151
  if (part.type === 'year' || part.type === 'month' || part.type === 'day') {
74
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
+ }));
75
166
  } else if (part.type === 'literal') {
76
167
  out.push({
77
168
  kind: 'literal',
78
169
  text: part.value
79
170
  });
80
171
  }
81
- // Everything else -- era, weekday, relatedYear -- is dropped: day
82
- // granularity has no segment for it.
172
+ // Everything else -- era, weekday, relatedYear -- is dropped: there is no
173
+ // segment for it.
83
174
  }
84
- return out;
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
+ });
85
198
  }
86
199
 
87
200
  /**
@@ -124,10 +237,13 @@ function bufferValue(segment, buffer) {
124
237
  * to the day, while typing `1` waits to see whether `12` is coming.
125
238
  */
126
239
  function applyDigit(segment, digit) {
127
- if (!/^\d$/.test(digit)) return {
128
- segment,
129
- isFull: false
130
- };
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
+ }
131
247
  let buffer = segment.buffer + digit;
132
248
  let value = bufferValue(segment, buffer);
133
249
 
@@ -201,6 +317,24 @@ function withValue(segment, value) {
201
317
  };
202
318
  }
203
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
+
204
338
  /** Clears both the value and the digits behind it. */
205
339
  function clearSegment(segment) {
206
340
  return {
@@ -224,11 +358,36 @@ function deleteDigit(segment) {
224
358
  };
225
359
  }
226
360
 
227
- /** The unit of `placeholderValue` this segment seeds from when empty. */
228
- function seedFrom(type, placeholderValue) {
229
- if (type === 'year') return placeholderValue.getFullYear();
230
- if (type === 'month') return placeholderValue.getMonth() + 1;
231
- return placeholderValue.getDate();
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
+ }
232
391
  }
233
392
 
234
393
  /**
@@ -238,7 +397,7 @@ function seedFrom(type, placeholderValue) {
238
397
  */
239
398
  function step(segment, delta, placeholderValue) {
240
399
  if (segment.value === null) {
241
- return withValue(segment, seedFrom(segment.type, placeholderValue));
400
+ return withValue(segment, seedFrom(segment, placeholderValue));
242
401
  }
243
402
  const span = segment.max - segment.min + 1;
244
403
  const offset = segment.value - segment.min + delta;
@@ -261,6 +420,7 @@ function step(segment, delta, placeholderValue) {
261
420
  */
262
421
  function displaySegment(segment) {
263
422
  if (segment.value === null) return segment.placeholder;
423
+ if (segment.labels) return segment.labels[segment.value] ?? '';
264
424
  const digits = segment.buffer;
265
425
  return segment.type === 'year' && !segment.isCommitted ? digits : digits.padStart(segment.width, '0');
266
426
  }
@@ -278,6 +438,27 @@ function isReady(segment) {
278
438
  return segment !== undefined && segment.value !== null && segment.isCommitted;
279
439
  }
280
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
+
281
462
  /**
282
463
  * The composed value, or `null` while any segment is still empty or still
283
464
  * being typed. The day is clamped to the chosen month's real length: a 31 left
@@ -291,8 +472,10 @@ function toDate(parts) {
291
472
 
292
473
  // Uncommitted counts as empty: half a year is not a date.
293
474
  if (!isReady(year) || !isReady(month) || !isReady(day)) return null;
475
+ const time = timeOf(parts);
476
+ if (!time) return null;
294
477
  const clamped = Math.min(day.value, daysInMonth(year.value, month.value));
295
- return new Date(year.value, month.value - 1, clamped);
478
+ return new Date(year.value, month.value - 1, clamped, time.hours, time.minutes);
296
479
  }
297
480
 
298
481
  /**
@@ -371,9 +554,9 @@ function fromDate(parts, date) {
371
554
  return parts.map(part => {
372
555
  if (!isSegment(part)) return part;
373
556
  if (!date) return clearSegment(part);
374
- return withValue(part, seedFrom(part.type, date));
557
+ return withValue(part, seedFrom(part, date));
375
558
  });
376
559
  }
377
560
 
378
- export { BOUNDS, DEFAULT_FORMAT, applyDigit, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, toDate, toNumericFormat, withValue };
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 };
379
562
  //# sourceMappingURL=segments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"segments.js","sources":["../../../../src/components/forms/date-input/segments.ts"],"sourcesContent":["import { warn } from '@ember/debug';\nimport type { Part, Segment, SegmentType } 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};\n\nfunction isSegment(part: Part): part is Segment {\n return part.kind === 'segment';\n}\n\nfunction emptySegment(type: SegmentType): 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 };\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): Part[] {\n const formatter = new Intl.DateTimeFormat(locale, formatOptions);\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\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 === 'literal') {\n out.push({ kind: 'literal', text: part.value });\n }\n // Everything else -- era, weekday, relatedYear -- is dropped: day\n // granularity has no segment for it.\n }\n\n return out;\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 if (!/^\\d$/.test(digit)) return { segment, isFull: false };\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/** 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/** The unit of `placeholderValue` this segment seeds from when empty. */\nfunction seedFrom(type: SegmentType, placeholderValue: Date): number {\n if (type === 'year') return placeholderValue.getFullYear();\n if (type === 'month') return placeholderValue.getMonth() + 1;\n return placeholderValue.getDate();\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.type, 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\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 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 clamped = Math.min(day.value, daysInMonth(year.value, month.value));\n return new Date(year.value, month.value - 1, clamped);\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.type, date));\n });\n}\n\nexport {\n buildParts,\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","isSegment","part","kind","emptySegment","type","value","buffer","isCommitted","buildParts","locale","formatOptions","formatter","Intl","DateTimeFormat","parts","formatToParts","Date","out","push","text","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","clearSegment","deleteDigit","slice","seedFrom","placeholderValue","getMonth","getDate","step","delta","span","offset","wrapped","displaySegment","findSegment","find","p","daysInMonth","isReady","undefined","toDate","clamped","carryOver","previous","map","was","hasTextualMonth","options","dateStyle","toNumericFormat","resolveSegmentFormat","given","warning","warn","message","id","hasDateChanged","before","after","getTime","fromDate","date"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAA0C,GAAG;AACjDC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,KAAK,EAAE,SAAS;AAChBC,EAAAA,GAAG,EAAE;AACP;AAEA,MAAMC,MAGL,GAAG;AACF;AACA;AACAD,EAAAA,GAAG,EAAE;AAAEE,IAAAA,GAAG,EAAE,CAAC;AAAEC,IAAAA,GAAG,EAAE,EAAE;AA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EAAE;GAAW;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASkF,oBAAoBA,CAC3BC,KAA6C,EAC7CC,OAAwC,EACA;EACxC,IAAI,CAACD,KAAK,IAAI,CAACL,eAAe,CAACK,KAAK,CAAC,EAAE,OAAOA,KAAK;AAEnDE,EAAAA,IAAI,CAACD,OAAO,CAACE,OAAO,EAAE,KAAK,EAAE;IAAEC,EAAE,EAAEH,OAAO,CAACG;AAAG,GAAC,CAAC;EAEhD,OAAON,eAAe,CAACE,KAAK,CAAC;AAC/B;;AAEA;AACA,SAASK,cAAcA,CAACC,MAAmB,EAAEC,KAAkB,EAAW;EACxE,IAAID,MAAM,KAAK,IAAI,IAAIC,KAAK,KAAK,IAAI,EAAE,OAAOD,MAAM,KAAKC,KAAK;EAC9D,OAAOD,MAAM,CAACE,OAAO,EAAE,KAAKD,KAAK,CAACC,OAAO,EAAE;AAC7C;;AAEA;AACA,SAASC,QAAQA,CAACvE,KAAa,EAAEwE,IAAiB,EAAU;AAC1D,EAAA,OAAOxE,KAAK,CAACuD,GAAG,CAAEpE,IAAI,IAAK;AACzB,IAAA,IAAI,CAACD,SAAS,CAACC,IAAI,CAAC,EAAE,OAAOA,IAAI;AACjC,IAAA,IAAI,CAACqF,IAAI,EAAE,OAAOxC,YAAY,CAAC7C,IAAI,CAAC;AAEpC,IAAA,OAAO0C,SAAS,CAAC1C,IAAI,EAAEgD,QAAQ,CAAChD,IAAI,CAACG,IAAI,EAAEkF,IAAI,CAAC,CAAC;AACnD,EAAA,CAAC,CAAC;AACJ;;"}
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,MAAMA,cAA0C,GAAG;AACjDC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,KAAK,EAAE,SAAS;AAChBC,EAAAA,GAAG,EAAE;AACP;AAEA,MAAMC,MAGL,GAAG;AACF;AACA;AACAD,EAAAA,GAAG,EAAE;AAAEE,IAAAA,GAAG,EAAE,CAAC;AAAEC,IAAAA,GAAG,EAAE,EAAE;AAAEC,IAAAA,KAAK,EAAE,CAAC;AAAEC,IAAAA,WAAW,EAAE;GAAM;AACrDN,EAAAA,KAAK,EAAE;AAAEG,IAAAA,GAAG,EAAE,CAAC;AAAEC,IAAAA,GAAG,EAAE,EAAE;AAAEC,IAAAA,KAAK,EAAE,CAAC;AAAEC,IAAAA,WAAW,EAAE;GAAM;AACvDP,EAAAA,IAAI,EAAE;AAAEI,IAAAA,GAAG,EAAE,CAAC;AAAEC,IAAAA,GAAG,EAAE,IAAI;AAAEC,IAAAA,KAAK,EAAE,CAAC;AAAEC,IAAAA,WAAW,EAAE;GAAQ;AAC1D;AACAC,EAAAA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ACK,KAAK,CAAC,EAAE,OAAOA,KAAK;AAEnDE,EAAAA,IAAI,CAACD,OAAO,CAACE,OAAO,EAAE,KAAK,EAAE;IAAEC,EAAE,EAAEH,OAAO,CAACG;AAAG,GAAC,CAAC;EAEhD,OAAON,eAAe,CAACE,KAAK,CAAC;AAC/B;;AAEA;AACA,SAASK,cAAcA,CAAChF,MAAmB,EAAEC,KAAkB,EAAW;EACxE,IAAID,MAAM,KAAK,IAAI,IAAIC,KAAK,KAAK,IAAI,EAAE,OAAOD,MAAM,KAAKC,KAAK;EAC9D,OAAOD,MAAM,CAACiF,OAAO,EAAE,KAAKhF,KAAK,CAACgF,OAAO,EAAE;AAC7C;;AAEA;AACA,SAASC,QAAQA,CAAC3F,KAAa,EAAEwD,IAAiB,EAAU;AAC1D,EAAA,OAAOxD,KAAK,CAACR,GAAG,CAAEjB,IAAI,IAAK;AACzB,IAAA,IAAI,CAACD,SAAS,CAACC,IAAI,CAAC,EAAE,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;;"}
@@ -1,4 +1,4 @@
1
- export { BOUNDS, DEFAULT_FORMAT, applyDigit, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, toDate, toNumericFormat, withValue } from './date-input/segments.js';
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
2
  export { formatForClipboard, parsePasted, splitRange } from './date-input/clipboard.js';
3
3
  export { DateInput, DateInput as default } from './date-input/date-input.js';
4
4
  //# sourceMappingURL=date-input.js.map