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,292 @@
1
+ import Component from '@glimmer/component';
2
+ import { cached } from '@glimmer/tracking';
3
+ import { fn } from '@ember/helper';
4
+ import { on } from '@ember/modifier';
5
+ import { isSegment, displaySegment, step, deleteDigit, clearSegment, applyDigit, applyLetter, commitSegment } from './segments.js';
6
+ import { parsePasted, splitRange, formatForClipboard } from './clipboard.js';
7
+ import { precompileTemplate } from '@ember/template-compilation';
8
+ import { setComponentTemplate } from '@ember/component';
9
+ import { a as decorateMethodV2 } from '../../../runtime--fcdnjmJ-BOdRhmsS.js';
10
+
11
+ const DEFAULT_LABELS = {
12
+ year: 'year',
13
+ month: 'month',
14
+ day: 'day',
15
+ hour: 'hour',
16
+ minute: 'minute',
17
+ dayPeriod: 'AM/PM'
18
+ };
19
+ /** How much PageUp/PageDown moves, per segment. */
20
+ const PAGE_STEP = {
21
+ day: 7,
22
+ month: 3,
23
+ year: 10,
24
+ hour: 2,
25
+ minute: 15,
26
+ dayPeriod: 1
27
+ };
28
+ /**
29
+ * Everything one rendered part needs, resolved to primitives.
30
+ *
31
+ * The template cannot narrow the `Part` union -- `eq` is unavailable and Glint
32
+ * does not carry a type predicate through `{{#if}}` -- so the narrowing happens
33
+ * here, in TypeScript, and the template only ever reads optional primitives.
34
+ * That keeps `part.type` off a `LiteralPart` without a cast anywhere.
35
+ */
36
+
37
+ /**
38
+ * One row of date segments. Private: `DateInput` and `DatePicker` both render
39
+ * it, and neither wants the other's `FormControl` wrapper.
40
+ */
41
+ class SegmentGroup extends Component {
42
+ get isEditable() {
43
+ return !this.args.isDisabled && !this.args.isReadOnly;
44
+ }
45
+ labelFor = type => this.args.segmentLabels?.[type] ?? DEFAULT_LABELS[type];
46
+ /**
47
+ * Built once per locale rather than inside {@link valueTextFor}: `cells`
48
+ * recomputes on every keystroke, and an `Intl` constructor is expensive
49
+ * enough that building one per keypress is the costliest thing this
50
+ * component would otherwise do.
51
+ */
52
+ get monthNames() {
53
+ return new Intl.DateTimeFormat(this.args.locale, {
54
+ month: 'long'
55
+ });
56
+ }
57
+ /**
58
+ * What a screen reader reads instead of the raw number. A month is read by
59
+ * name -- "January", not "1" -- which is the whole point of `aria-valuetext`.
60
+ */
61
+ static {
62
+ decorateMethodV2(this.prototype, "monthNames", [cached]);
63
+ }
64
+ valueTextFor = segment => {
65
+ if (segment.value === null) return undefined;
66
+ if (segment.labels) return segment.labels[segment.value];
67
+ if (segment.type !== 'month') return String(segment.value);
68
+ // Any year and day will do; only the month is read back out.
69
+ return this.monthNames.format(new Date(2026, segment.value - 1, 1));
70
+ };
71
+ get cells() {
72
+ return this.args.parts.map((part, index) => {
73
+ if (!isSegment(part)) {
74
+ return {
75
+ index,
76
+ isSegment: false,
77
+ isEmpty: false,
78
+ text: part.text,
79
+ inputMode: 'numeric'
80
+ };
81
+ }
82
+ return {
83
+ index,
84
+ isSegment: true,
85
+ text: displaySegment(part),
86
+ type: part.type,
87
+ isEmpty: part.value === null,
88
+ label: this.labelFor(part.type),
89
+ inputMode: part.labels ? 'text' : 'numeric',
90
+ // `undefined` rather than `null`: an empty segment has no current
91
+ // value, and `aria-valuenow="null"` would be a value of sorts.
92
+ valueNow: part.value ?? undefined,
93
+ valueMin: part.min,
94
+ valueMax: part.max,
95
+ valueText: this.valueTextFor(part)
96
+ };
97
+ });
98
+ }
99
+ /** The segment elements, in document order -- the focus order too. */
100
+ static {
101
+ decorateMethodV2(this.prototype, "cells", [cached]);
102
+ }
103
+ segmentElements(from) {
104
+ const group = from.closest('[data-part="group"]');
105
+ return group ? Array.from(group.querySelectorAll('[data-part="segment"]')) : [];
106
+ }
107
+ /**
108
+ * Left and right are *visual* directions, so in an RTL locale they run
109
+ * against document order: pressing the left arrow in `yyyy/mm/dd` laid out
110
+ * right-to-left should move to the segment drawn to the left, which is the
111
+ * later one in the DOM.
112
+ */
113
+ focusSibling(from, delta) {
114
+ const all = this.segmentElements(from);
115
+ const step = this.isRtl(from) ? -delta : delta;
116
+ const next = all[all.indexOf(from) + step];
117
+ next?.focus();
118
+ }
119
+ isRtl(from) {
120
+ const group = from.closest('[data-part="group"]') ?? from;
121
+ return getComputedStyle(group).direction === 'rtl';
122
+ }
123
+ focusEdge(from, edge) {
124
+ const all = this.segmentElements(from);
125
+ (edge === 'first' ? all[0] : all[all.length - 1])?.focus();
126
+ }
127
+ /** Replaces one segment by index and reports the new list. */
128
+ replace(index, segment) {
129
+ const next = this.args.parts.map((part, i) => i === index ? segment : part);
130
+ this.args.onPartsChange(next);
131
+ }
132
+ handleKeyDown = (index, event) => {
133
+ const part = this.args.parts[index];
134
+ if (!part || !isSegment(part)) return;
135
+ const element = event.target;
136
+ const {
137
+ key
138
+ } = event;
139
+ // Navigation works even when the field is read-only; editing does not.
140
+ if (key === 'ArrowRight') {
141
+ event.preventDefault();
142
+ this.focusSibling(element, 1);
143
+ return;
144
+ }
145
+ if (key === 'ArrowLeft') {
146
+ event.preventDefault();
147
+ this.focusSibling(element, -1);
148
+ return;
149
+ }
150
+ if (key === 'Home') {
151
+ event.preventDefault();
152
+ this.focusEdge(element, 'first');
153
+ return;
154
+ }
155
+ if (key === 'End') {
156
+ event.preventDefault();
157
+ this.focusEdge(element, 'last');
158
+ return;
159
+ }
160
+ if (!this.isEditable) return;
161
+ if (key === 'ArrowUp' || key === 'ArrowDown') {
162
+ event.preventDefault();
163
+ const delta = key === 'ArrowUp' ? 1 : -1;
164
+ this.replace(index, step(part, delta, this.args.placeholderValue));
165
+ return;
166
+ }
167
+ if (key === 'PageUp' || key === 'PageDown') {
168
+ event.preventDefault();
169
+ const magnitude = PAGE_STEP[part.type];
170
+ const delta = key === 'PageUp' ? magnitude : -magnitude;
171
+ this.replace(index, step(part, delta, this.args.placeholderValue));
172
+ return;
173
+ }
174
+ if (key === 'Backspace') {
175
+ event.preventDefault();
176
+ this.replace(index, deleteDigit(part));
177
+ return;
178
+ }
179
+ if (key === 'Delete') {
180
+ event.preventDefault();
181
+ this.replace(index, clearSegment(part));
182
+ return;
183
+ }
184
+ if (/^\d$/.test(key)) {
185
+ event.preventDefault();
186
+ // AM/PM has no digits to take.
187
+ if (part.labels) return;
188
+ const {
189
+ segment,
190
+ isFull
191
+ } = applyDigit(part, key);
192
+ this.replace(index, segment);
193
+ // Advancing before the DOM has caught up is safe: the segment elements
194
+ // are keyed by index and are updated, never re-created.
195
+ if (isFull) this.focusSibling(element, 1);
196
+ return;
197
+ }
198
+ if (part.labels && key.length === 1 && !event.metaKey && !event.ctrlKey) {
199
+ event.preventDefault();
200
+ const {
201
+ segment,
202
+ isFull
203
+ } = applyLetter(part, key);
204
+ if (segment !== part) this.replace(index, segment);
205
+ if (isFull) this.focusSibling(element, 1);
206
+ return;
207
+ }
208
+ // Everything else -- letters, symbols -- would otherwise be inserted into
209
+ // the contenteditable span as literal text.
210
+ if (key.length === 1 && !event.metaKey && !event.ctrlKey) {
211
+ event.preventDefault();
212
+ }
213
+ };
214
+ /**
215
+ * Leaving a segment finishes it: the digits in it stop being something the
216
+ * user is still typing and become their answer, which is what turns a typed
217
+ * `26` into 2026. Tab, arrow-key navigation and a click elsewhere all arrive
218
+ * here, because moving focus is the one thing they have in common.
219
+ */
220
+ handleFocusOut = index => {
221
+ if (!this.isEditable) return;
222
+ const part = this.args.parts[index];
223
+ if (!part || !isSegment(part) || part.isCommitted) return;
224
+ const committed = commitSegment(part);
225
+ // An empty segment commits to itself; reporting it would be churn.
226
+ if (committed !== part) this.replace(index, committed);
227
+ };
228
+ /**
229
+ * `contenteditable`'s hazard: anything not handled above arrives here and
230
+ * would be written into the span's DOM, desynchronising the display from the
231
+ * model. Every input type is refused; the model is the only writer.
232
+ */
233
+ handleBeforeInput = event => {
234
+ event.preventDefault();
235
+ };
236
+ /**
237
+ * Always `preventDefault`: the browser would otherwise write the pasted text
238
+ * into the contenteditable span, and the model would no longer describe what
239
+ * is on screen. Unparseable text is dropped silently -- a date field that
240
+ * guessed would be worse than one that declined.
241
+ */
242
+ handlePaste = event => {
243
+ event.preventDefault();
244
+ if (!this.isEditable) return;
245
+ const text = event.clipboardData?.getData('text/plain') ?? '';
246
+ const parsed = parsePasted(text, this.args.parts);
247
+ if (parsed) {
248
+ this.args.onPartsChange(parsed);
249
+ return;
250
+ }
251
+ this.tryRangePaste(text);
252
+ };
253
+ /**
254
+ * A second reading of text a single date could not be made of.
255
+ *
256
+ * Both halves are parsed against *this* group's parts, which is sound
257
+ * because the two groups of a range are built from the same locale and
258
+ * format and so have identical shape, and because a half only counts when
259
+ * it parses in full -- nothing of this group's own state survives into the
260
+ * list handed to the other one.
261
+ */
262
+ tryRangePaste(text) {
263
+ const onRangePaste = this.args.onRangePaste;
264
+ if (!onRangePaste) return;
265
+ const halves = splitRange(text);
266
+ if (!halves) return;
267
+ const start = parsePasted(halves[0], this.args.parts);
268
+ const end = parsePasted(halves[1], this.args.parts);
269
+ if (start && end) onRangePaste(start, end);
270
+ }
271
+ handleCopy = event => {
272
+ event.preventDefault();
273
+ event.clipboardData?.setData('text/plain', formatForClipboard(this.args.parts));
274
+ };
275
+ handleCut = event => {
276
+ this.handleCopy(event);
277
+ if (!this.isEditable) return;
278
+ this.args.onPartsChange(this.args.parts.map(p => isSegment(p) ? clearSegment(p) : p));
279
+ };
280
+ static {
281
+ setComponentTemplate(precompileTemplate("<div role=\"group\" data-part=\"group\" id={{@id}} aria-label={{@label}} aria-labelledby={{@labelledBy}} aria-describedby={{@describedBy}} aria-disabled={{if @isDisabled \"true\"}} {{!-- `role=\"group\"` supports neither aria-readonly nor aria-invalid --\n neither is global in ARIA 1.2, and ember-template-lint's\n no-unsupported-role-attributes is right to reject them here (its\n autofixer deletes them silently, which is how they went missing\n once already). Both live on the spinbuttons below instead, where\n the role does support them and where assistive technology actually\n lands. These data attributes carry the same state for styling and\n for tests. --}} data-readonly={{if @isReadOnly \"true\" \"false\"}} data-invalid={{if @isInvalid \"true\" \"false\"}} class={{@classes.group class=@userClasses.group}} {{on \"paste\" this.handlePaste}} {{on \"copy\" this.handleCopy}} {{on \"cut\" this.handleCut}} ...attributes>\n {{#each this.cells key=\"index\" as |cell|}}\n {{#if cell.isSegment}}\n <span role=\"spinbutton\" tabindex={{unless @isDisabled \"0\"}} contenteditable={{if this.isEditable \"true\" \"false\"}} inputmode={{cell.inputMode}} spellcheck=\"false\" autocorrect=\"off\" data-part=\"segment\" data-type={{cell.type}} data-placeholder={{if cell.isEmpty \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}} aria-readonly={{if @isReadOnly \"true\"}} aria-invalid={{if @isInvalid \"true\"}} aria-label={{cell.label}} aria-valuenow={{cell.valueNow}} aria-valuemin={{cell.valueMin}} aria-valuemax={{cell.valueMax}} aria-valuetext={{cell.valueText}} class={{@classes.segment class=@userClasses.segment}} {{on \"keydown\" (fn this.handleKeyDown cell.index)}} {{on \"focusout\" (fn this.handleFocusOut cell.index)}} {{on \"beforeinput\" this.handleBeforeInput}}>{{cell.text}}</span>\n {{else}}\n <span data-part=\"literal\" aria-hidden=\"true\" class={{@classes.literal class=@userClasses.literal}}>{{cell.text}}</span>\n {{/if}}\n {{/each}}\n</div>", {
282
+ strictMode: true,
283
+ scope: () => ({
284
+ on,
285
+ fn
286
+ })
287
+ }), this);
288
+ }
289
+ }
290
+
291
+ export { SegmentGroup, SegmentGroup as default };
292
+ //# sourceMappingURL=segment-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment-group.js","sources":["../../../../src/components/forms/date-input/segment-group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { fn } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport {\n isSegment,\n applyDigit,\n applyLetter,\n commitSegment,\n step,\n clearSegment,\n deleteDigit,\n displaySegment\n} from './segments';\nimport { parsePasted, formatForClipboard, splitRange } from './clipboard';\nimport type {\n Part,\n Segment,\n SegmentType,\n SegmentGroupClasses,\n SegmentGroupUserClasses\n} from './types';\n\ninterface SegmentGroupSignature {\n Args: {\n parts: Part[];\n /** Hands the whole list back; the group holds no state of its own. */\n onPartsChange: (parts: Part[]) => void;\n /**\n * Offered text that reads as two dates rather than one. Only `DatePicker`\n * in `@mode=\"range\"` supplies it, and only to its *start* group: pasting\n * a range into the end of a field and having it rewrite the start would\n * be surprising. Without it, such text is simply declined.\n */\n onRangePaste?: (start: Part[], end: Part[]) => void;\n locale: string;\n placeholderValue: Date;\n isDisabled?: boolean;\n isReadOnly?: boolean;\n isInvalid?: boolean;\n /** Rendered as the group's own id, so a `<label for>` can target it. */\n id?: string;\n /**\n * The field's name. A `role=\"group\"` is not a labelable element, so a\n * sibling `<label for>` does not name it on its own -- this does.\n */\n label?: string;\n labelledBy?: string;\n describedBy?: string;\n segmentLabels?: Partial<Record<SegmentType, string>>;\n /**\n * Only the three slots this group renders, so that `DateInput`'s\n * `dateInput` recipe and `DatePicker`'s `datePicker` recipe both satisfy\n * it. See {@link SegmentGroupClasses}.\n */\n classes: SegmentGroupClasses;\n userClasses?: SegmentGroupUserClasses;\n };\n Element: HTMLDivElement;\n}\n\nconst DEFAULT_LABELS: Record<SegmentType, string> = {\n year: 'year',\n month: 'month',\n day: 'day',\n hour: 'hour',\n minute: 'minute',\n dayPeriod: 'AM/PM'\n};\n\n/** How much PageUp/PageDown moves, per segment. */\nconst PAGE_STEP: Record<SegmentType, number> = {\n day: 7,\n month: 3,\n year: 10,\n hour: 2,\n minute: 15,\n dayPeriod: 1\n};\n\n/**\n * Everything one rendered part needs, resolved to primitives.\n *\n * The template cannot narrow the `Part` union -- `eq` is unavailable and Glint\n * does not carry a type predicate through `{{#if}}` -- so the narrowing happens\n * here, in TypeScript, and the template only ever reads optional primitives.\n * That keeps `part.type` off a `LiteralPart` without a cast anywhere.\n */\ninterface Cell {\n index: number;\n isSegment: boolean;\n /** The segment's display text, or the literal's text. */\n text: string;\n type?: SegmentType;\n isEmpty: boolean;\n label?: string;\n /** `text` for AM/PM, typed by letter; `numeric` for everything else. */\n inputMode: 'numeric' | 'text';\n valueNow?: number;\n valueMin?: number;\n valueMax?: number;\n valueText?: string;\n}\n\n/**\n * One row of date segments. Private: `DateInput` and `DatePicker` both render\n * it, and neither wants the other's `FormControl` wrapper.\n */\nclass SegmentGroup extends Component<SegmentGroupSignature> {\n get isEditable(): boolean {\n return !this.args.isDisabled && !this.args.isReadOnly;\n }\n\n labelFor = (type: SegmentType): string =>\n this.args.segmentLabels?.[type] ?? DEFAULT_LABELS[type];\n\n /**\n * Built once per locale rather than inside {@link valueTextFor}: `cells`\n * recomputes on every keystroke, and an `Intl` constructor is expensive\n * enough that building one per keypress is the costliest thing this\n * component would otherwise do.\n */\n @cached\n get monthNames(): Intl.DateTimeFormat {\n return new Intl.DateTimeFormat(this.args.locale, { month: 'long' });\n }\n\n /**\n * What a screen reader reads instead of the raw number. A month is read by\n * name -- \"January\", not \"1\" -- which is the whole point of `aria-valuetext`.\n */\n valueTextFor = (segment: Segment): string | undefined => {\n if (segment.value === null) return undefined;\n if (segment.labels) return segment.labels[segment.value];\n if (segment.type !== 'month') return String(segment.value);\n\n // Any year and day will do; only the month is read back out.\n return this.monthNames.format(new Date(2026, segment.value - 1, 1));\n };\n\n @cached\n get cells(): Cell[] {\n return this.args.parts.map((part, index) => {\n if (!isSegment(part)) {\n return {\n index,\n isSegment: false,\n isEmpty: false,\n text: part.text,\n inputMode: 'numeric'\n };\n }\n\n return {\n index,\n isSegment: true,\n text: displaySegment(part),\n type: part.type,\n isEmpty: part.value === null,\n label: this.labelFor(part.type),\n inputMode: part.labels ? 'text' : 'numeric',\n // `undefined` rather than `null`: an empty segment has no current\n // value, and `aria-valuenow=\"null\"` would be a value of sorts.\n valueNow: part.value ?? undefined,\n valueMin: part.min,\n valueMax: part.max,\n valueText: this.valueTextFor(part)\n };\n });\n }\n\n /** The segment elements, in document order -- the focus order too. */\n private segmentElements(from: HTMLElement): HTMLElement[] {\n const group = from.closest('[data-part=\"group\"]');\n return group\n ? Array.from(group.querySelectorAll<HTMLElement>('[data-part=\"segment\"]'))\n : [];\n }\n\n /**\n * Left and right are *visual* directions, so in an RTL locale they run\n * against document order: pressing the left arrow in `yyyy/mm/dd` laid out\n * right-to-left should move to the segment drawn to the left, which is the\n * later one in the DOM.\n */\n private focusSibling(from: HTMLElement, delta: number): void {\n const all = this.segmentElements(from);\n const step = this.isRtl(from) ? -delta : delta;\n const next = all[all.indexOf(from) + step];\n next?.focus();\n }\n\n private isRtl(from: HTMLElement): boolean {\n const group = from.closest<HTMLElement>('[data-part=\"group\"]') ?? from;\n return getComputedStyle(group).direction === 'rtl';\n }\n\n private focusEdge(from: HTMLElement, edge: 'first' | 'last'): void {\n const all = this.segmentElements(from);\n (edge === 'first' ? all[0] : all[all.length - 1])?.focus();\n }\n\n /** Replaces one segment by index and reports the new list. */\n private replace(index: number, segment: Segment): void {\n const next = this.args.parts.map((part, i) =>\n i === index ? segment : part\n );\n this.args.onPartsChange(next);\n }\n\n handleKeyDown = (index: number, event: KeyboardEvent): void => {\n const part = this.args.parts[index];\n if (!part || !isSegment(part)) return;\n\n const element = event.target as HTMLElement;\n const { key } = event;\n\n // Navigation works even when the field is read-only; editing does not.\n if (key === 'ArrowRight') {\n event.preventDefault();\n this.focusSibling(element, 1);\n return;\n }\n if (key === 'ArrowLeft') {\n event.preventDefault();\n this.focusSibling(element, -1);\n return;\n }\n if (key === 'Home') {\n event.preventDefault();\n this.focusEdge(element, 'first');\n return;\n }\n if (key === 'End') {\n event.preventDefault();\n this.focusEdge(element, 'last');\n return;\n }\n\n if (!this.isEditable) return;\n\n if (key === 'ArrowUp' || key === 'ArrowDown') {\n event.preventDefault();\n const delta = key === 'ArrowUp' ? 1 : -1;\n this.replace(index, step(part, delta, this.args.placeholderValue));\n return;\n }\n\n if (key === 'PageUp' || key === 'PageDown') {\n event.preventDefault();\n const magnitude = PAGE_STEP[part.type];\n const delta = key === 'PageUp' ? magnitude : -magnitude;\n this.replace(index, step(part, delta, this.args.placeholderValue));\n return;\n }\n\n if (key === 'Backspace') {\n event.preventDefault();\n this.replace(index, deleteDigit(part));\n return;\n }\n\n if (key === 'Delete') {\n event.preventDefault();\n this.replace(index, clearSegment(part));\n return;\n }\n\n if (/^\\d$/.test(key)) {\n event.preventDefault();\n // AM/PM has no digits to take.\n if (part.labels) return;\n const { segment, isFull } = applyDigit(part, key);\n this.replace(index, segment);\n // Advancing before the DOM has caught up is safe: the segment elements\n // are keyed by index and are updated, never re-created.\n if (isFull) this.focusSibling(element, 1);\n return;\n }\n\n if (part.labels && key.length === 1 && !event.metaKey && !event.ctrlKey) {\n event.preventDefault();\n const { segment, isFull } = applyLetter(part, key);\n if (segment !== part) this.replace(index, segment);\n if (isFull) this.focusSibling(element, 1);\n return;\n }\n\n // Everything else -- letters, symbols -- would otherwise be inserted into\n // the contenteditable span as literal text.\n if (key.length === 1 && !event.metaKey && !event.ctrlKey) {\n event.preventDefault();\n }\n };\n\n /**\n * Leaving a segment finishes it: the digits in it stop being something the\n * user is still typing and become their answer, which is what turns a typed\n * `26` into 2026. Tab, arrow-key navigation and a click elsewhere all arrive\n * here, because moving focus is the one thing they have in common.\n */\n handleFocusOut = (index: number): void => {\n if (!this.isEditable) return;\n\n const part = this.args.parts[index];\n if (!part || !isSegment(part) || part.isCommitted) return;\n\n const committed = commitSegment(part);\n // An empty segment commits to itself; reporting it would be churn.\n if (committed !== part) this.replace(index, committed);\n };\n\n /**\n * `contenteditable`'s hazard: anything not handled above arrives here and\n * would be written into the span's DOM, desynchronising the display from the\n * model. Every input type is refused; the model is the only writer.\n */\n handleBeforeInput = (event: Event): void => {\n event.preventDefault();\n };\n\n /**\n * Always `preventDefault`: the browser would otherwise write the pasted text\n * into the contenteditable span, and the model would no longer describe what\n * is on screen. Unparseable text is dropped silently -- a date field that\n * guessed would be worse than one that declined.\n */\n handlePaste = (event: ClipboardEvent): void => {\n event.preventDefault();\n if (!this.isEditable) return;\n\n const text = event.clipboardData?.getData('text/plain') ?? '';\n const parsed = parsePasted(text, this.args.parts);\n if (parsed) {\n this.args.onPartsChange(parsed);\n return;\n }\n\n this.tryRangePaste(text);\n };\n\n /**\n * A second reading of text a single date could not be made of.\n *\n * Both halves are parsed against *this* group's parts, which is sound\n * because the two groups of a range are built from the same locale and\n * format and so have identical shape, and because a half only counts when\n * it parses in full -- nothing of this group's own state survives into the\n * list handed to the other one.\n */\n private tryRangePaste(text: string): void {\n const onRangePaste = this.args.onRangePaste;\n if (!onRangePaste) return;\n\n const halves = splitRange(text);\n if (!halves) return;\n\n const start = parsePasted(halves[0], this.args.parts);\n const end = parsePasted(halves[1], this.args.parts);\n if (start && end) onRangePaste(start, end);\n }\n\n handleCopy = (event: ClipboardEvent): void => {\n event.preventDefault();\n event.clipboardData?.setData(\n 'text/plain',\n formatForClipboard(this.args.parts)\n );\n };\n\n handleCut = (event: ClipboardEvent): void => {\n this.handleCopy(event);\n if (!this.isEditable) return;\n\n this.args.onPartsChange(\n this.args.parts.map((p) => (isSegment(p) ? clearSegment(p) : p))\n );\n };\n\n <template>\n <div\n role=\"group\"\n data-part=\"group\"\n id={{@id}}\n aria-label={{@label}}\n aria-labelledby={{@labelledBy}}\n aria-describedby={{@describedBy}}\n aria-disabled={{if @isDisabled \"true\"}}\n {{! `role=\"group\"` supports neither aria-readonly nor aria-invalid --\n neither is global in ARIA 1.2, and ember-template-lint's\n no-unsupported-role-attributes is right to reject them here (its\n autofixer deletes them silently, which is how they went missing\n once already). Both live on the spinbuttons below instead, where\n the role does support them and where assistive technology actually\n lands. These data attributes carry the same state for styling and\n for tests. }}\n data-readonly={{if @isReadOnly \"true\" \"false\"}}\n data-invalid={{if @isInvalid \"true\" \"false\"}}\n class={{@classes.group class=@userClasses.group}}\n {{on \"paste\" this.handlePaste}}\n {{on \"copy\" this.handleCopy}}\n {{on \"cut\" this.handleCut}}\n ...attributes\n >\n {{#each this.cells key=\"index\" as |cell|}}\n {{#if cell.isSegment}}\n <span\n role=\"spinbutton\"\n tabindex={{unless @isDisabled \"0\"}}\n contenteditable={{if this.isEditable \"true\" \"false\"}}\n inputmode={{cell.inputMode}}\n spellcheck=\"false\"\n autocorrect=\"off\"\n data-part=\"segment\"\n data-type={{cell.type}}\n data-placeholder={{if cell.isEmpty \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n aria-readonly={{if @isReadOnly \"true\"}}\n aria-invalid={{if @isInvalid \"true\"}}\n aria-label={{cell.label}}\n aria-valuenow={{cell.valueNow}}\n aria-valuemin={{cell.valueMin}}\n aria-valuemax={{cell.valueMax}}\n aria-valuetext={{cell.valueText}}\n class={{@classes.segment class=@userClasses.segment}}\n {{on \"keydown\" (fn this.handleKeyDown cell.index)}}\n {{on \"focusout\" (fn this.handleFocusOut cell.index)}}\n {{on \"beforeinput\" this.handleBeforeInput}}\n >{{cell.text}}</span>\n {{else}}\n <span\n data-part=\"literal\"\n aria-hidden=\"true\"\n class={{@classes.literal class=@userClasses.literal}}\n >{{cell.text}}</span>\n {{/if}}\n {{/each}}\n </div>\n </template>\n}\n\nexport { SegmentGroup, type SegmentGroupSignature };\nexport default SegmentGroup;\n"],"names":["DEFAULT_LABELS","year","month","day","hour","minute","dayPeriod","PAGE_STEP","SegmentGroup","Component","isEditable","args","isDisabled","isReadOnly","labelFor","type","segmentLabels","monthNames","Intl","DateTimeFormat","locale","n","prototype","cached","valueTextFor","segment","value","undefined","labels","String","format","Date","cells","parts","map","part","index","isSegment","isEmpty","text","inputMode","displaySegment","label","valueNow","valueMin","min","valueMax","max","valueText","segmentElements","from","group","closest","Array","querySelectorAll","focusSibling","delta","all","step","isRtl","next","indexOf","focus","getComputedStyle","direction","focusEdge","edge","length","replace","i","onPartsChange","handleKeyDown","event","element","target","key","preventDefault","placeholderValue","magnitude","deleteDigit","clearSegment","test","isFull","applyDigit","metaKey","ctrlKey","applyLetter","handleFocusOut","isCommitted","committed","commitSegment","handleBeforeInput","handlePaste","clipboardData","getData","parsed","parsePasted","tryRangePaste","onRangePaste","halves","splitRange","start","end","handleCopy","setData","formatForClipboard","handleCut","p","setComponentTemplate","precompileTemplate","strictMode","scope","on","fn"],"mappings":";;;;;;;;;;AA6DA,MAAMA,cAA0C,GAAI;AAClDC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,KAAA,EAAO,OAAA;AACPC,EAAAA,GAAA,EAAK,KAAA;AACLC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,MAAA,EAAQ,QAAA;AACRC,EAAAA,SAAA,EAAW;AACb,CAAA;AAEA;AACA,MAAMC,SAAqC,GAAI;AAC7CJ,EAAAA,GAAA,EAAK,CAAA;AACLD,EAAAA,KAAA,EAAO,CAAA;AACPD,EAAAA,IAAA,EAAM,EAAA;AACNG,EAAAA,IAAA,EAAM,CAAA;AACNC,EAAAA,MAAA,EAAQ,EAAA;AACRC,EAAAA,SAAA,EAAW;AACb,CAAA;AAEA;;;;;;;;;AAwBA;;;;AAIA,MAAME,qBAAqBC,SAAA,CAAU;EACnC,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,CAAC,IAAI,CAACC,IAAI,CAACC,UAAU,IAAI,CAAC,IAAI,CAACD,IAAI,CAACE,UAAU;AACvD,EAAA;AAEAC,EAAAA,QAAA,GAAYC,IAAM,IAChB,IAAI,CAACJ,IAAI,CAACK,aAAa,GAAGD,IAAA,CAAK,IAAIf,cAAc,CAACe,KAAK;AAEzD;;;;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