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.
- package/declarations/-private/get-config.d.ts.map +1 -1
- package/declarations/-private/timer.d.ts +3 -3
- package/declarations/-private/timer.d.ts.map +1 -1
- package/declarations/components/buttons/close-button.d.ts +2 -2
- package/declarations/components/buttons/close-button.d.ts.map +1 -1
- package/declarations/components/collections/calendar/calendar.d.ts +7 -1
- package/declarations/components/collections/calendar/calendar.d.ts.map +1 -1
- package/declarations/components/collections/calendar/header.d.ts +2 -0
- package/declarations/components/collections/calendar/header.d.ts.map +1 -1
- package/declarations/components/collections/calendar/types.d.ts +15 -0
- package/declarations/components/collections/calendar/types.d.ts.map +1 -1
- package/declarations/components/collections/calendar/year-grid.d.ts +2 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +2 -2
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/column.d.ts +6 -0
- package/declarations/components/collections/simple-table/column.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/footer.d.ts +2 -1
- package/declarations/components/collections/simple-table/footer.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/header.d.ts +2 -1
- package/declarations/components/collections/simple-table/header.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/index.d.ts +1 -1
- package/declarations/components/collections/simple-table/index.d.ts.map +1 -1
- package/declarations/components/collections/table/checkbox.d.ts +1 -1
- package/declarations/components/collections/table/checkbox.d.ts.map +1 -1
- package/declarations/components/collections/table/column-visibility.d.ts +2 -2
- package/declarations/components/collections/table/column-visibility.d.ts.map +1 -1
- package/declarations/components/collections/table/table.d.ts +9 -7
- package/declarations/components/collections/table/table.d.ts.map +1 -1
- package/declarations/components/forms/checkbox.d.ts +2 -2
- package/declarations/components/forms/checkbox.d.ts.map +1 -1
- package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -1
- package/declarations/components/forms/date-input/date-input.d.ts +5 -2
- package/declarations/components/forms/date-input/date-input.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segment-group.d.ts +2 -0
- package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segments.d.ts +30 -4
- package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
- package/declarations/components/forms/date-input/types.d.ts +60 -5
- package/declarations/components/forms/date-input/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +19 -2
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/end-content.d.ts +3 -1
- package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/types.d.ts +42 -4
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/value.d.ts +21 -5
- package/declarations/components/forms/date-picker/value.d.ts.map +1 -1
- package/declarations/components/forms/field.d.ts +4 -5
- package/declarations/components/forms/field.d.ts.map +1 -1
- package/declarations/components/forms/form.d.ts +5 -5
- package/declarations/components/forms/form.d.ts.map +1 -1
- package/declarations/components/forms/input-otp.d.ts +5 -5
- package/declarations/components/forms/input-otp.d.ts.map +1 -1
- package/declarations/components/forms/input.d.ts +4 -4
- package/declarations/components/forms/input.d.ts.map +1 -1
- package/declarations/components/forms/native-select.d.ts +2 -2
- package/declarations/components/forms/native-select.d.ts.map +1 -1
- package/declarations/components/forms/radio.d.ts +2 -2
- package/declarations/components/forms/radio.d.ts.map +1 -1
- package/declarations/components/forms/textarea.d.ts +3 -3
- package/declarations/components/forms/textarea.d.ts.map +1 -1
- package/declarations/components/navigation/pagination/pagination.d.ts +32 -1
- package/declarations/components/navigation/pagination/pagination.d.ts.map +1 -1
- package/declarations/components/overlays/overlay.d.ts +4 -4
- package/declarations/components/overlays/overlay.d.ts.map +1 -1
- package/declarations/components/utilities/avatar.d.ts +1 -1
- package/declarations/components/utilities/avatar.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +16 -0
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/utils/forms-utils-index.d.ts +1 -1
- package/declarations/utils/forms-utils-index.d.ts.map +1 -1
- package/declarations/utils/nested-data.d.ts +17 -0
- package/declarations/utils/nested-data.d.ts.map +1 -1
- package/dist/components/buttons/close-button.js +5 -12
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/collections/calendar/calendar.js +13 -1
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +1 -1
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/listbox/item.js +4 -11
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +2 -2
- package/dist/components/collections/simple-table/column.js.map +1 -1
- package/dist/components/collections/simple-table/footer.js +1 -1
- package/dist/components/collections/simple-table/footer.js.map +1 -1
- package/dist/components/collections/simple-table/header.js +1 -1
- package/dist/components/collections/simple-table/header.js.map +1 -1
- package/dist/components/collections/simple-table/index.js +1 -1
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +2 -7
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +2 -7
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/forms/checkbox.js +4 -12
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/date-input/clipboard.js +74 -5
- package/dist/components/forms/date-input/clipboard.js.map +1 -1
- package/dist/components/forms/date-input/date-input.js +24 -5
- package/dist/components/forms/date-input/date-input.js.map +1 -1
- package/dist/components/forms/date-input/segment-group.js +26 -5
- package/dist/components/forms/date-input/segment-group.js.map +1 -1
- package/dist/components/forms/date-input/segments.js +203 -20
- package/dist/components/forms/date-input/segments.js.map +1 -1
- package/dist/components/forms/date-input.js +1 -1
- package/dist/components/forms/date-picker/date-picker.js +76 -11
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -3
- package/dist/components/forms/date-picker/end-content.js.map +1 -1
- package/dist/components/forms/date-picker/value.js +44 -6
- package/dist/components/forms/date-picker/value.js.map +1 -1
- package/dist/components/forms/field.js +8 -19
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form.js +11 -27
- package/dist/components/forms/form.js.map +1 -1
- package/dist/components/forms/index.js +3 -3
- package/dist/components/forms/input-otp.js +10 -26
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +9 -22
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/native-select.js +5 -12
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio.js +4 -12
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/textarea.js +6 -17
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +18 -2
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/overlays/overlay.js +8 -21
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/utilities/avatar.js +3 -7
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/collapsible.js +47 -3
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/forms.js +3 -3
- package/dist/index.js +4 -4
- package/dist/{manager-jDaRVZ5o.js → manager-Dge4r8Vn.js} +9 -19
- package/dist/manager-Dge4r8Vn.js.map +1 -0
- package/dist/notifications.js +1 -1
- package/dist/services/notifications.js +1 -1
- package/dist/test-support.js +400 -365
- package/dist/test-support.js.map +1 -1
- package/dist/utils/forms-utils-index.js +1 -1
- package/dist/utils/forms-utils-index.js.map +1 -1
- package/dist/utils/nested-data.js +28 -1
- package/dist/utils/nested-data.js.map +1 -1
- package/package.json +10 -10
- package/dist/manager-jDaRVZ5o.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","sources":["../../../../src/components/forms/date-input/clipboard.ts"],"sourcesContent":["import {\n isSegment,\n resolveTwoDigitYear,\n displaySegment,\n withValue\n} from './segments';\nimport type { Part, Segment, SegmentType } from './types';\n\nconst ISO_DAY = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\n\n/** The digits destined for each segment, keyed by type. */\ntype Digits = Partial<Record<SegmentType, string>>;\n\n/**\n * Writes digit strings onto the segments they name.\n *\n * Digits stay *strings* all the way in, because a year's leading zeros carry\n * meaning: `0045` is the year 45, while `45` runs through the sliding window.\n * Passing numbers here would erase that distinction and make a pasted `0045`\n * resolve differently from a typed one.\n *\n * A segment no key names is left untouched, which is what lets a partial paste\n * fill what it can. Out of bounds refuses the *whole* paste rather than\n * clamping: clamping would turn a paste of `99/99/2026` into a plausible\n * looking date the user never meant. The day is the exception by design -- its\n * bound is 31 and the real length of the month is applied later, by `toDate`,\n * so a pasted 31st of February shortens to the 28th exactly as a typed one\n * does.\n */\nfunction fill(parts: Part[], digits: Digits): Part[] | null {\n let filled = 0;\n\n const next: Part[] = [];\n for (const part of parts) {\n if (!isSegment(part)) {\n next.push(part);\n continue;\n }\n\n const raw = digits[part.type];\n if (raw === undefined) {\n next.push(part);\n continue;\n }\n\n const value = part.type === 'year' ? resolveTwoDigitYear(raw) : Number(raw);\n if (Number.isNaN(value) || value < part.min || value > part.max) {\n return null;\n }\n\n filled++;\n // A paste is a finished answer for every segment it fills.\n next.push(withValue(part, value));\n }\n\n // Nothing landed anywhere -- treat that as a refusal rather than quietly\n // handing back an untouched field.\n return filled === 0 ? null : next;\n}\n\n/** Maps digit groups onto the segments in their rendered order. */\nfunction byPosition(segments: Segment[], groups: string[]): Digits | null {\n if (groups.length === 0 || groups.length > segments.length) return null;\n\n const digits: Digits = {};\n groups.forEach((group, i) => {\n const segment = segments[i];\n if (segment) digits[segment.type] = group;\n });\n return digits;\n}\n\n/**\n * Reads pasted text into the segments, trying each strategy in turn and\n * stopping at the first that works.\n *\n * Every strategy lands in `fill`, so all three share one bounds policy. There\n * is deliberately no `new Date(text)` fallback: it parses differently in every\n * engine, and a date field that silently guesses wrong is worse than one that\n * declines.\n */\nfunction parsePasted(text: string, parts: Part[]): Part[] | null {\n const trimmed = text.trim();\n if (trimmed === '') return null;\n\n // 1. ISO, which is unambiguous and so outranks the locale's own order.\n const iso = ISO_DAY.exec(trimmed);\n if (iso) {\n const [, year, month, day] = iso;\n return fill(parts, { year, month, day });\n }\n\n const segments = parts.filter(isSegment);\n\n // 2. A bare digit run, split by each segment's width. Checked before the\n // separated form, because an unseparated run also splits into a single\n // \"group\" and would otherwise be read as one enormous month.\n if (/^\\d+$/.test(trimmed)) {\n const widths: string[] = [];\n let at = 0;\n for (const segment of segments) {\n if (at >= trimmed.length) break;\n widths.push(trimmed.slice(at, at + segment.width));\n at += segment.width;\n }\n\n // It has to end on a segment boundary, otherwise there is no telling\n // where the last number was meant to stop.\n if (at !== trimmed.length) return null;\n\n const digits = byPosition(segments, widths);\n return digits ? fill(parts, digits) : null;\n }\n\n // 3. Separated numbers, mapped positionally onto the locale's order. Fewer\n // groups than segments is a partial date and fills a prefix of them.\n const groups = trimmed.split(/\\D+/).filter(Boolean);\n const digits = byPosition(segments, groups);\n if (digits) return fill(parts, digits);\n\n return null;\n}\n\n/**\n * The field as it reads on screen, literals included. Copying the display\n * rather than an ISO string means the text round-trips through `parsePasted`\n * and still reads naturally when pasted into a document.\n *\n * Delegates each segment to `displaySegment`, the same function the group\n * renders from, so a mid-entry year (buffer `26`, uncommitted) copies as\n * `26` rather than being padded to `0026` -- padding would claim digits the\n * user never typed and would contradict what is on screen.\n */\nfunction formatForClipboard(parts: Part[]): string {\n return parts\n .map((part) => (isSegment(part) ? displaySegment(part) : part.text))\n .join('');\n}\n\n/**\n * What separates the two halves of a pasted range.\n *\n * An en or em dash needs no surrounding space, because neither ever appears\n * inside a date. A plain hyphen does: it is the ISO separator, so splitting on\n * an unspaced one would tear `2026-01-20` into pieces. The same reasoning\n * applies to the words -- `\\s+` on both sides keeps \"to\" from matching inside\n * \"total\".\n */\nconst RANGE_SEPARATOR = /\\s*[\\u2013\\u2014]\\s*|\\s+(?:-|to|until|through)\\s+/i;\n\n/**\n * Splits pasted text into the two dates of a range, or returns `null` when it\n * does not read as two.\n *\n * Only the shape is decided here; neither half is parsed. The caller runs each\n * through {@link parsePasted} and keeps the result only when both halves are\n * dates -- so text that merely contains a dash falls through to the ordinary\n * single-date handling rather than being consumed.\n */\nfunction splitRange(text: string): [string, string] | null {\n const trimmed = text.trim();\n const match = RANGE_SEPARATOR.exec(trimmed);\n if (!match) return null;\n\n const start = trimmed.slice(0, match.index).trim();\n const end = trimmed.slice(match.index + match[0].length).trim();\n if (start === '' || end === '') return null;\n\n // Three halves is not a range, and guessing which two were meant would be\n // exactly the silent wrong guess this module declines to make elsewhere.\n if (RANGE_SEPARATOR.test(end)) return null;\n\n return [start, end];\n}\n\nexport { parsePasted, formatForClipboard, splitRange };\n"],"names":["ISO_DAY","fill","parts","digits","filled","next","part","isSegment","push","raw","type","undefined","value","resolveTwoDigitYear","Number","isNaN","min","max","withValue","byPosition","segments","groups","length","forEach","group","i","segment","parsePasted","text","trimmed","trim","iso","exec","year","month","day","filter","test","widths","at","slice","width","split","Boolean","formatForClipboard","map","displaySegment","join","RANGE_SEPARATOR","splitRange","match","start","index","end"],"mappings":";;AAQA,MAAMA,OAAO,GAAG,2BAA2B;;AAE3C;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,IAAIA,CAACC,KAAa,EAAEC,MAAc,EAAiB;EAC1D,IAAIC,MAAM,GAAG,CAAC;EAEd,MAAMC,IAAY,GAAG,EAAE;AACvB,EAAA,KAAK,MAAMC,IAAI,IAAIJ,KAAK,EAAE;AACxB,IAAA,IAAI,CAACK,SAAS,CAACD,IA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IAAIE,GAAG,KAAK,EAAE,EAAE,OAAO,IAAI;;AAE3C;AACA;EACA,IAAIL,eAAe,CAACX,IAAI,CAACgB,GAAG,CAAC,EAAE,OAAO,IAAI;AAE1C,EAAA,OAAO,CAACF,KAAK,EAAEE,GAAG,CAAC;AACrB;;"}
|
|
1
|
+
{"version":3,"file":"clipboard.js","sources":["../../../../src/components/forms/date-input/clipboard.ts"],"sourcesContent":["import {\n isSegment,\n resolveTwoDigitYear,\n displaySegment,\n withValue,\n findSegment,\n hourOnCycle\n} from './segments';\nimport type { Part, Segment, SegmentType } from './types';\n\nconst ISO_DAY = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst ISO_DATE_TIME =\n /^(\\d{4})-(\\d{2})-(\\d{2})[T ](\\d{2}):(\\d{2})(?::\\d{2}(?:\\.\\d+)?)?$/;\n\n/** The digits destined for each segment, keyed by type. */\ntype Digits = Partial<Record<SegmentType, string>>;\n\n/**\n * Writes digit strings onto the segments they name.\n *\n * Digits stay *strings* all the way in, because a year's leading zeros carry\n * meaning: `0045` is the year 45, while `45` runs through the sliding window.\n * Passing numbers here would erase that distinction and make a pasted `0045`\n * resolve differently from a typed one.\n *\n * A segment no key names is left untouched, which is what lets a partial paste\n * fill what it can. Out of bounds refuses the *whole* paste rather than\n * clamping: clamping would turn a paste of `99/99/2026` into a plausible\n * looking date the user never meant. The day is the exception by design -- its\n * bound is 31 and the real length of the month is applied later, by `toDate`,\n * so a pasted 31st of February shortens to the 28th exactly as a typed one\n * does.\n */\nfunction fill(parts: Part[], digits: Digits): Part[] | null {\n let filled = 0;\n\n const next: Part[] = [];\n for (const part of parts) {\n if (!isSegment(part)) {\n next.push(part);\n continue;\n }\n\n const raw = digits[part.type];\n if (raw === undefined) {\n next.push(part);\n continue;\n }\n\n const value = part.type === 'year' ? resolveTwoDigitYear(raw) : Number(raw);\n if (Number.isNaN(value) || value < part.min || value > part.max) {\n return null;\n }\n\n filled++;\n // A paste is a finished answer for every segment it fills.\n next.push(withValue(part, value));\n }\n\n // Nothing landed anywhere -- treat that as a refusal rather than quietly\n // handing back an untouched field.\n return filled === 0 ? null : next;\n}\n\n/**\n * The time segments' digits for a 0-23 hour and a minute, as this field's\n * hour cycle counts them. Segments the field does not have get nothing.\n */\nfunction clockDigits(parts: Part[], hours: number, minutes: number): Digits {\n const hour = findSegment(parts, 'hour');\n if (!hour) return {};\n\n return {\n hour: String(hourOnCycle(hours, hour.hourCycle ?? 'h23')),\n minute: String(minutes),\n dayPeriod: hours < 12 ? '0' : '1'\n };\n}\n\n/**\n * Which of a textual segment's labels the text names -- AM or PM -- as its\n * value, or `undefined`. Besides the locale's own labels, a Latin `am`/`pm`\n * (dotted or not) is understood, which is how most pasted times spell it.\n */\nfunction dayPeriodIn(text: string, segment: Segment): string | undefined {\n const lower = text.toLocaleLowerCase();\n const index = (segment.labels ?? []).findIndex(\n (label) => label !== '' && lower.includes(label.toLocaleLowerCase())\n );\n if (index !== -1) return String(index);\n\n const latin = /(?:^|[^a-z])([ap])\\.?\\s*m\\.?(?![a-z])/i.exec(text);\n if (latin) return latin[1]?.toLowerCase() === 'a' ? '0' : '1';\n\n return undefined;\n}\n\n/**\n * Settles AM/PM for a positional paste. The text's own AM/PM wins; failing\n * that, an hour past the 12-hour clock's end is read as a 24-hour one, so\n * `21:30` pasted into an en-US field lands as 9:30 PM rather than refused.\n */\nfunction withDayPeriod(text: string, parts: Part[], digits: Digits): Digits {\n const dayPeriod = findSegment(parts, 'dayPeriod');\n const hour = findSegment(parts, 'hour');\n if (!dayPeriod) return digits;\n\n const named = dayPeriodIn(text, dayPeriod);\n if (named !== undefined) return { ...digits, dayPeriod: named };\n\n const typed = digits.hour === undefined ? NaN : Number(digits.hour);\n if (hour && typed > hour.max && typed <= 23) {\n return {\n ...digits,\n hour: String(hourOnCycle(typed, hour.hourCycle ?? 'h12')),\n dayPeriod: '1'\n };\n }\n\n return digits;\n}\n\n/** Maps digit groups onto the segments in their rendered order. */\nfunction byPosition(segments: Segment[], groups: string[]): Digits | null {\n if (groups.length === 0 || groups.length > segments.length) return null;\n\n const digits: Digits = {};\n groups.forEach((group, i) => {\n const segment = segments[i];\n if (segment) digits[segment.type] = group;\n });\n return digits;\n}\n\n/**\n * Reads pasted text into the segments, trying each strategy in turn and\n * stopping at the first that works.\n *\n * Every strategy lands in `fill`, so all three share one bounds policy. There\n * is deliberately no `new Date(text)` fallback: it parses differently in every\n * engine, and a date field that silently guesses wrong is worse than one that\n * declines.\n */\nfunction parsePasted(text: string, parts: Part[]): Part[] | null {\n const trimmed = text.trim();\n if (trimmed === '') return null;\n\n // 1. ISO, which is unambiguous and so outranks the locale's own order. A\n // day alone fills the date and leaves any time as it was.\n const isoTime = ISO_DATE_TIME.exec(trimmed);\n if (isoTime) {\n const [, year, month, day, hours, minutes] = isoTime;\n if (Number(hours) > 23 || Number(minutes) > 59) return null;\n return fill(parts, {\n year,\n month,\n day,\n ...clockDigits(parts, Number(hours), Number(minutes))\n });\n }\n\n const iso = ISO_DAY.exec(trimmed);\n if (iso) {\n const [, year, month, day] = iso;\n return fill(parts, { year, month, day });\n }\n\n // Positional reading maps digits, so only the numeric segments take part;\n // AM/PM is read from the text's words afterwards.\n const segments = parts.filter(isSegment).filter((s) => !s.labels);\n\n // 2. A bare digit run, split by each segment's width. Checked before the\n // separated form, because an unseparated run also splits into a single\n // \"group\" and would otherwise be read as one enormous month.\n if (/^\\d+$/.test(trimmed)) {\n const widths: string[] = [];\n let at = 0;\n for (const segment of segments) {\n if (at >= trimmed.length) break;\n widths.push(trimmed.slice(at, at + segment.width));\n at += segment.width;\n }\n\n // It has to end on a segment boundary, otherwise there is no telling\n // where the last number was meant to stop.\n if (at !== trimmed.length) return null;\n\n const digits = byPosition(segments, widths);\n return digits ? fill(parts, withDayPeriod(trimmed, parts, digits)) : null;\n }\n\n // 3. Separated numbers, mapped positionally onto the locale's order. Fewer\n // groups than segments is a partial date and fills a prefix of them.\n const groups = trimmed.split(/\\D+/).filter(Boolean);\n const digits = byPosition(segments, groups);\n if (digits) return fill(parts, withDayPeriod(trimmed, parts, digits));\n\n return null;\n}\n\n/**\n * The field as it reads on screen, literals included. Copying the display\n * rather than an ISO string means the text round-trips through `parsePasted`\n * and still reads naturally when pasted into a document.\n *\n * Delegates each segment to `displaySegment`, the same function the group\n * renders from, so a mid-entry year (buffer `26`, uncommitted) copies as\n * `26` rather than being padded to `0026` -- padding would claim digits the\n * user never typed and would contradict what is on screen.\n */\nfunction formatForClipboard(parts: Part[]): string {\n return parts\n .map((part) => (isSegment(part) ? displaySegment(part) : part.text))\n .join('');\n}\n\n/**\n * What separates the two halves of a pasted range.\n *\n * An en or em dash needs no surrounding space, because neither ever appears\n * inside a date. A plain hyphen does: it is the ISO separator, so splitting on\n * an unspaced one would tear `2026-01-20` into pieces. The same reasoning\n * applies to the words -- `\\s+` on both sides keeps \"to\" from matching inside\n * \"total\".\n */\nconst RANGE_SEPARATOR = /\\s*[\\u2013\\u2014]\\s*|\\s+(?:-|to|until|through)\\s+/i;\n\n/**\n * Splits pasted text into the two dates of a range, or returns `null` when it\n * does not read as two.\n *\n * Only the shape is decided here; neither half is parsed. The caller runs each\n * through {@link parsePasted} and keeps the result only when both halves are\n * dates -- so text that merely contains a dash falls through to the ordinary\n * single-date handling rather than being consumed.\n */\nfunction splitRange(text: string): [string, string] | null {\n const trimmed = text.trim();\n const match = RANGE_SEPARATOR.exec(trimmed);\n if (!match) return null;\n\n const start = trimmed.slice(0, match.index).trim();\n const end = trimmed.slice(match.index + match[0].length).trim();\n if (start === '' || end === '') return null;\n\n // Three halves is not a range, and guessing which two were meant would be\n // exactly the silent wrong guess this module declines to make elsewhere.\n if (RANGE_SEPARATOR.test(end)) return null;\n\n return [start, end];\n}\n\nexport { parsePasted, formatForClipboard, splitRange };\n"],"names":["ISO_DAY","ISO_DATE_TIME","fill","parts","digits","filled","next","part","isSegment","push","raw","type","undefined","value","resolveTwoDigitYear","Number","isNaN","min","max","withValue","clockDigits","hours","minutes","hour","findSegment","String","hourOnCycle","hourCycle","minute","dayPeriod","dayPeriodIn","text","segment","lower","toLocaleLowerCase","index","labels","findIndex","label","includes","latin","exec","toLowerCase","withDayPeriod","named","typed","NaN","byPosition","segments","groups","length","forEach","group","i","parsePasted","trimmed","trim","isoTime","year","month","day","iso","filter","s","test","widths","at","slice","width","split","Boolean","formatForClipboard","map","displaySegment","join","RANGE_SEPARATOR","splitRange","match","start","end"],"mappings":";;AAUA,MAAMA,OAAO,GAAG,2BAA2B;AAC3C,MAAMC,aAAa,GACjB,mEAAmE;;AAErE;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,IAAIA,CAACC,KAAa,EAAEC,MAAc,EAAiB;EAC1D,IAAIC,MAAM,GAAG,CAAC;EAEd,MAAMC,IAAY,GAAG,EAAE;AACvB,EAAA,KAAK,MAAMC,IAAI,IAAIJ,KAAK,EAAE;AACxB,IAAA,IAAI,CAACK,SAAS,CAACD,IAAI,CAAC,EAAE;AACpBD,MAAAA,IAAI,CAACG,IAAI,CAACF,IAAI,CAAC;AACf,MAAA;AACF,IAAA;AAEA,IAAA,MAAMG,GAAG,GAAGN,MAAM,CAACG,IAAI,CAACI,IAAI,CAAC;IAC7B,IAAID,GAAG,KAAKE,SAAS,EAAE;AACrBN,MAAAA,IAAI,CAACG,IAAI,CAACF,IAAI,CAAC;AACf,MAAA;AACF,IAAA;AAEA,IAAA,MAAMM,KAAK,GAAGN,IAAI,CAACI,IAAI,KAAK,MAAM,GAAGG,mBAAmB,CAACJ,GAAG,CAAC,GAAGK,MAAM,CAACL,GAAG,CAAC;AAC3E,IAAA,IAAIK,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,IAAIA,KAAK,GAAGN,IAAI,CAACU,GAAG,IAAIJ,KAAK,GAAGN,IAAI,CAACW,GAAG,EAAE;AAC/D,MAAA,OAAO,IAAI;AACb,IAAA;AAEAb,IAAAA,MAAM,EAAE;AACR;IAC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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASmE,kBAAkBA,CAACpE,KAAa,EAAU;EACjD,OAAOA,KAAK,CACTqE,GAAG,CAAEjE,IAAI,IAAMC,SAAS,CAACD,IAAI,CAAC,GAAGkE,cAAc,CAAClE,IAAI,CAAC,GAAGA,IAAI,CAACwB,IAAK,CAAC,CACnE2C,IAAI,CAAC,EAAE,CAAC;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,oDAAoD;;AAE5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAC7C,IAAY,EAA2B;AACzD,EAAA,MAAMwB,OAAO,GAAGxB,IAAI,CAACyB,IAAI,EAAE;AAC3B,EAAA,MAAMqB,KAAK,GAAGF,eAAe,CAAClC,IAAI,CAACc,OAAO,CAAC;AAC3C,EAAA,IAAI,CAACsB,KAAK,EAAE,OAAO,IAAI;AAEvB,EAAA,MAAMC,KAAK,GAAGvB,OAAO,CAACY,KAAK,CAAC,CAAC,EAAEU,KAAK,CAAC1C,KAAK,CAAC,CAACqB,IAAI,EAAE;EAClD,MAAMuB,GAAG,GAAGxB,OAAO,CAACY,KAAK,CAACU,KAAK,CAAC1C,KAAK,GAAG0C,KAAK,CAAC,CAAC,CAAC,CAAC3B,MAAM,CAAC,CAACM,IAAI,EAAE;EAC/D,IAAIsB,KAAK,KAAK,EAAE,IAAIC,GAAG,KAAK,EAAE,EAAE,OAAO,IAAI;;AAE3C;AACA;EACA,IAAIJ,eAAe,CAACX,IAAI,CAACe,GAAG,CAAC,EAAE,OAAO,IAAI;AAE1C,EAAA,OAAO,CAACD,KAAK,EAAEC,GAAG,CAAC;AACrB;;"}
|
|
@@ -14,6 +14,9 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
14
14
|
import { setComponentTemplate } from '@ember/component';
|
|
15
15
|
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
16
16
|
|
|
17
|
+
const DEFAULT_LABELS = {
|
|
18
|
+
clear: 'Clear'
|
|
19
|
+
};
|
|
17
20
|
/**
|
|
18
21
|
* A date typed into segments rather than picked from a grid. `DatePicker`
|
|
19
22
|
* renders the same segments and adds a calendar.
|
|
@@ -41,7 +44,7 @@ class DateInput extends Component {
|
|
|
41
44
|
constructor(owner, args) {
|
|
42
45
|
super(owner, args);
|
|
43
46
|
const seed = args.defaultValue;
|
|
44
|
-
this.setParts(fromDate(buildParts(this.locale, this.formatOptions), seed === undefined ? null : parseDate(seed)));
|
|
47
|
+
this.setParts(fromDate(buildParts(this.locale, this.formatOptions, this.timeOptions), seed === undefined ? null : parseDate(seed)));
|
|
45
48
|
}
|
|
46
49
|
get parts() {
|
|
47
50
|
return this.trackedParts;
|
|
@@ -63,12 +66,22 @@ class DateInput extends Component {
|
|
|
63
66
|
id: 'frontile.date-input.textual-format'
|
|
64
67
|
});
|
|
65
68
|
}
|
|
69
|
+
/** The time segments the field adds to the date, if any. */
|
|
70
|
+
get timeOptions() {
|
|
71
|
+
return {
|
|
72
|
+
granularity: this.args.granularity,
|
|
73
|
+
hourCycle: this.args.hourCycle
|
|
74
|
+
};
|
|
75
|
+
}
|
|
66
76
|
/**
|
|
67
77
|
* The composed value, or null while any segment is empty.
|
|
68
78
|
*
|
|
69
79
|
* Cached because `wireValue`, `isOutOfRange` and the template all read it
|
|
70
80
|
* independently, and each `toDate` walks the parts three times over.
|
|
71
81
|
*/
|
|
82
|
+
static {
|
|
83
|
+
decorateMethodV2(this.prototype, "timeOptions", [cached]);
|
|
84
|
+
}
|
|
72
85
|
get value() {
|
|
73
86
|
return toDate(this.parts);
|
|
74
87
|
}
|
|
@@ -76,7 +89,7 @@ class DateInput extends Component {
|
|
|
76
89
|
decorateMethodV2(this.prototype, "value", [cached]);
|
|
77
90
|
}
|
|
78
91
|
get wireValue() {
|
|
79
|
-
return toWire(this.value);
|
|
92
|
+
return toWire(this.value, this.args.granularity);
|
|
80
93
|
}
|
|
81
94
|
get isEmpty() {
|
|
82
95
|
return this.parts.every(p => !isSegment(p) || p.value === null);
|
|
@@ -122,8 +135,8 @@ class DateInput extends Component {
|
|
|
122
135
|
* field without emptying it -- half-typed digits included, which is why
|
|
123
136
|
* this goes segment by segment rather than through the composed value.
|
|
124
137
|
*/
|
|
125
|
-
syncLocale = modifier((_, [locale, format]) => {
|
|
126
|
-
this.setParts(carryOver(buildParts(locale, format), this.#currentParts));
|
|
138
|
+
syncLocale = modifier((_, [locale, format, time]) => {
|
|
139
|
+
this.setParts(carryOver(buildParts(locale, format, time), this.#currentParts));
|
|
127
140
|
});
|
|
128
141
|
handlePartsChange = parts => {
|
|
129
142
|
const before = toDate(this.#currentParts);
|
|
@@ -149,6 +162,12 @@ class DateInput extends Component {
|
|
|
149
162
|
if (container && next instanceof Node && container.contains(next)) return;
|
|
150
163
|
this.args.onBlur?.();
|
|
151
164
|
};
|
|
165
|
+
get labels() {
|
|
166
|
+
return {
|
|
167
|
+
...DEFAULT_LABELS,
|
|
168
|
+
...this.args.labels
|
|
169
|
+
};
|
|
170
|
+
}
|
|
152
171
|
/**
|
|
153
172
|
* A disabled or read-only field never offers it: it carries no disabled
|
|
154
173
|
* state of its own and would be a live button clearing a field the user may
|
|
@@ -178,7 +197,7 @@ class DateInput extends Component {
|
|
|
178
197
|
decorateMethodV2(this.prototype, "classes", [cached]);
|
|
179
198
|
}
|
|
180
199
|
static {
|
|
181
|
-
setComponentTemplate(precompileTemplate("<div {{this.syncLocale this.locale this.formatOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} {{on \"focusout\" this.handleFocusOut}} class={{this.classes.base class=@classes.base}} data-component=\"date-input\" data-part=\"base\" ...attributes>\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{this.isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <div class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} />\n {{#if this.isClearable}}\n <div data-part=\"end-content\" class={{this.classes.endContent class=@classes.endContent}}>\n <CloseButton @title
|
|
200
|
+
setComponentTemplate(precompileTemplate("<div {{this.syncLocale this.locale this.formatOptions this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} {{on \"focusout\" this.handleFocusOut}} class={{this.classes.base class=@classes.base}} data-component=\"date-input\" data-part=\"base\" ...attributes>\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{this.isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <div class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} />\n {{#if this.isClearable}}\n <div data-part=\"end-content\" class={{this.classes.endContent class=@classes.endContent}}>\n <CloseButton @title={{this.labels.clear}} @variant=\"soft\" @size=\"xs\" @class={{this.classes.clearButton class=@classes.clearButton}} data-part=\"clear-button\" @onPress={{this.clear}} />\n </div>\n {{/if}}\n </div>\n </FormControl>\n</div>", {
|
|
182
201
|
strictMode: true,
|
|
183
202
|
scope: () => ({
|
|
184
203
|
on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-input.js","sources":["../../../../src/components/forms/date-input/date-input.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport { useStyles } from '@frontile/theme';\nimport { FormControl } from '../form-control';\nimport { CloseButton } from '../../buttons/close-button';\nimport { SegmentGroup } from './segment-group';\nimport {\n buildParts,\n toDate,\n fromDate,\n isSegment,\n carryOver,\n resolveSegmentFormat,\n hasDateChanged\n} from './segments';\nimport { parseDate, toWire } from '../date-picker/value';\nimport { ref } from '../../../utils/ref';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport type { Part, DateInputArgs, DateInputClasses } from './types';\n\ninterface DateInputSignature {\n Args: DateInputArgs;\n Element: HTMLDivElement;\n}\n\n/**\n * A date typed into segments rather than picked from a grid. `DatePicker`\n * renders the same segments and adds a calendar.\n */\nclass DateInput extends Component<DateInputSignature> {\n containerRef = ref<HTMLElement>();\n\n /**\n * The segments are the state, not the value: mid-entry they hold digits that\n * compose to no date at all, which no `Date` can represent.\n */\n @tracked private trackedParts: Part[] = [];\n\n /**\n * An untracked mirror of {@link parts}. The sync modifiers below need to\n * read the current segments in order to rebuild them, and reading the\n * tracked field inside a modifier would put it in that modifier's own\n * tracking frame -- which the same modifier then writes to, re-running\n * itself forever.\n */\n #currentParts: Part[] = [];\n\n constructor(owner: unknown, args: DateInputArgs) {\n super(owner as never, args);\n\n const seed = args.defaultValue;\n this.setParts(\n fromDate(\n buildParts(this.locale, this.formatOptions),\n seed === undefined ? null : parseDate(seed)\n )\n );\n }\n\n get parts(): Part[] {\n return this.trackedParts;\n }\n\n private setParts(parts: Part[]): void {\n this.#currentParts = parts;\n this.trackedParts = parts;\n }\n\n get locale(): string {\n return this.args.locale ?? navigator.language;\n }\n\n get formatOptions(): Intl.DateTimeFormatOptions | undefined {\n // A textual month has no numeric segment to type into, so it falls back\n // to a numeric one. `dateStyle: 'medium'` is the common way to hit this --\n // it is DatePicker's button-trigger default. Only the month is replaced:\n // the rest of the format is the consumer's and stands.\n return resolveSegmentFormat(this.args.formatOptions, {\n message:\n '<DateInput> needs numeric segments; ' +\n 'a textual @formatOptions month falls back to a numeric one.',\n id: 'frontile.date-input.textual-format'\n });\n }\n\n /**\n * The composed value, or null while any segment is empty.\n *\n * Cached because `wireValue`, `isOutOfRange` and the template all read it\n * independently, and each `toDate` walks the parts three times over.\n */\n @cached\n get value(): Date | null {\n return toDate(this.parts);\n }\n\n get wireValue(): string {\n return toWire(this.value);\n }\n\n get isEmpty(): boolean {\n return this.parts.every((p) => !isSegment(p) || p.value === null);\n }\n\n get placeholderValue(): Date {\n return this.args.placeholderValue ?? new Date();\n }\n\n /**\n * Whether the composed value is outside the allowed range. Never blocks a\n * keystroke -- typing toward 2020 passes through 2, 20 and 202 on the way,\n * and a field that refused those could not be typed into at all.\n */\n get isOutOfRange(): boolean {\n const value = this.value;\n if (!value) return false;\n\n if (this.args.minValue && value < this.args.minValue) return true;\n if (this.args.maxValue && value > this.args.maxValue) return true;\n return this.args.isDateUnavailable?.(value) ?? false;\n }\n\n get isInvalid(): boolean {\n return Boolean(this.args.isInvalid) || this.isOutOfRange;\n }\n\n /**\n * Pushes `@value` into the segments when the argument changes. `undefined`\n * is ignored, so a field bound by `Field` before the form holds anything for\n * it keeps what the user typed -- the rule `DatePicker` documents.\n */\n syncValue = modifier(\n (_: HTMLElement, [raw]: [Date | string | null | undefined]) => {\n if (raw === undefined) return;\n\n const parsed = parseDate(raw);\n\n // Ignore the echo of our own `@onChange`. A controlled consumer writes\n // back the value this field just reported, and rewriting the segments\n // from it would destroy a partial entry: backspacing one digit of the\n // year un-commits it, so the field composes `null`, reports `null`, and\n // is handed `null` straight back -- which `fromDate` would spend on\n // clearing every other segment too. One keystroke would empty the field.\n if (!hasDateChanged(toDate(this.#currentParts), parsed)) return;\n\n this.setParts(fromDate(this.#currentParts, parsed));\n }\n );\n\n /**\n * Rebuilds the segment order when the locale or format changes, carrying\n * each segment's own state across so switching en-US to en-GB reorders the\n * field without emptying it -- half-typed digits included, which is why\n * this goes segment by segment rather than through the composed value.\n */\n syncLocale = modifier(\n (\n _: HTMLElement,\n [locale, format]: [string, Intl.DateTimeFormatOptions | undefined]\n ) => {\n this.setParts(carryOver(buildParts(locale, format), this.#currentParts));\n }\n );\n\n handlePartsChange = (parts: Part[]): void => {\n const before = toDate(this.#currentParts);\n this.setParts(parts);\n const after = toDate(parts);\n\n // Only value transitions are reported. The four keystrokes that fill a\n // month and a day compose no date at all, and report nothing.\n if (hasDateChanged(before, after)) {\n this.args.onChange?.(after);\n triggerFormInputEvent(this.containerRef.current);\n }\n };\n\n /**\n * `@onBlur` means \"the user left the field\", not \"the user left a segment\",\n * so a move between segments is filtered out by asking whether focus landed\n * inside the container. `DatePicker` needs `ControlBlurTracker` for this\n * because its focus can legitimately be in a popover outside its own DOM;\n * this field has no popover, so containment is the whole question.\n */\n handleFocusOut = (event: FocusEvent): void => {\n const container = this.containerRef.current;\n const next = event.relatedTarget;\n\n if (container && next instanceof Node && container.contains(next)) return;\n\n this.args.onBlur?.();\n };\n\n /**\n * A disabled or read-only field never offers it: it carries no disabled\n * state of its own and would be a live button clearing a field the user may\n * not change.\n */\n get isClearable(): boolean {\n return (\n Boolean(this.args.isClearable) &&\n !this.isEmpty &&\n !this.args.isDisabled &&\n !this.args.isReadOnly\n );\n }\n\n /**\n * Clearing removes the clear button from the DOM (`isClearable` flips\n * false the instant the value is gone), so focus must be handed somewhere\n * explicitly or it falls to `<body>` and a keyboard user loses their place.\n */\n clear = (): void => {\n this.handlePartsChange(fromDate(this.#currentParts, null));\n this.containerRef.current\n ?.querySelector<HTMLElement>('[data-part=\"segment\"]')\n ?.focus();\n };\n\n @cached\n get classes(): DateInputClasses {\n const { dateInput } = useStyles();\n return dateInput({ size: this.args.inputSize });\n }\n\n <template>\n <div\n {{this.syncLocale this.locale this.formatOptions}}\n {{this.syncValue @value}}\n {{this.containerRef.setup}}\n {{on \"focusout\" this.handleFocusOut}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"date-input\"\n data-part=\"base\"\n ...attributes\n >\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{this.isInvalid}}\n @isDisabled={{@isDisabled}}\n as |c|\n >\n <div\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n {{! The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. }}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n >\n <SegmentGroup\n @parts={{this.parts}}\n @onPartsChange={{this.handlePartsChange}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{c.id}}\n @label={{@label}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n />\n {{#if this.isClearable}}\n <div\n data-part=\"end-content\"\n class={{this.classes.endContent class=@classes.endContent}}\n >\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-part=\"clear-button\"\n @onPress={{this.clear}}\n />\n </div>\n {{/if}}\n </div>\n </FormControl>\n </div>\n </template>\n}\n\nexport { DateInput, type DateInputSignature };\nexport default DateInput;\n"],"names":["DateInput","Component","containerRef","ref","g","prototype","tracked","i","constructor","owner","args","seed","defaultValue","setParts","fromDate","buildParts","locale","formatOptions","undefined","parseDate","parts","trackedParts","navigator","language","resolveSegmentFormat","message","id","value","toDate","n","cached","wireValue","toWire","isEmpty","every","p","isSegment","placeholderValue","Date","isOutOfRange","minValue","maxValue","isDateUnavailable","isInvalid","Boolean","syncValue","modifier","_","raw","parsed","hasDateChanged","syncLocale","format","carryOver","handlePartsChange","before","after","onChange","triggerFormInputEvent","current","handleFocusOut","event","container","next","relatedTarget","Node","contains","onBlur","isClearable","isDisabled","isReadOnly","clear","querySelector","focus","classes","dateInput","useStyles","size","inputSize","setComponentTemplate","precompileTemplate","strictMode","scope","on","FormControl","SegmentGroup","CloseButton"],"mappings":";;;;;;;;;;;;;;;;AA2BA;;;;AAIA,MAAMA,kBAAkBC,SAAA,CAAU;EAChCC,YAAA,GAAeC,KAAI;AAEnB;;;AAGC;AAHD,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAICC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAuC,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,aAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,cAAA,CAAA,EAAA,MAAA;AAE1C;;;;;;AAMC;EACD,aAAa,GAAW,EAAE;AAE1BC,EAAAA,WAAAA,CAAYC,KAAc,EAAEC,IAAmB,EAAE;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AKAC,KAAA,GAAQA,MAAQ;AACd,IAAA,IAAI,CAACjB,iBAAiB,CAACxC,QAAA,CAAS,IAAI,CAAC,aAAa,EAAE,IAAA,CAAA,CAAA;AACpD,IAAA,IAAI,CAACZ,YAAY,CAACyD,OAAO,EACrBa,cAA2B,uBAAA,CAAA,EAC3BC,KAAA,EAAA;EACN,CAAA;EAEA,IACIC,UAA4B;IAC9B,MAAM;AAAEC,MAAAA;KAAW,GAAGC,SAAA,EAAA;AACtB,IAAA,OAAOD,SAAA,CAAU;AAAEE,MAAAA,IAAA,EAAM,IAAI,CAACnE,IAAI,CAACoE;AAAU,KAAA,CAAA;AAC/C,EAAA;AAAA,EAAA;IAAAjD,gBAAA,CAAA,IAAA,CAAAxB,SAAA,EAAA,SAAA,EAAA,CAJCyB,MAAA,CAAA,CAAA;AAAA;AAMD,EAAA;IAAAiD,oBAAA,CAAAC,kBAAA,CAAA,gxDAAA,EAoEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,WAAA;QAAAC,YAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
1
|
+
{"version":3,"file":"date-input.js","sources":["../../../../src/components/forms/date-input/date-input.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport { useStyles } from '@frontile/theme';\nimport { FormControl } from '../form-control';\nimport { CloseButton } from '../../buttons/close-button';\nimport { SegmentGroup } from './segment-group';\nimport {\n buildParts,\n toDate,\n fromDate,\n isSegment,\n carryOver,\n resolveSegmentFormat,\n hasDateChanged\n} from './segments';\nimport { parseDate, toWire } from '../date-picker/value';\nimport { ref } from '../../../utils/ref';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport type {\n Part,\n DateInputArgs,\n DateInputClasses,\n DateInputLabels,\n TimeOptions\n} from './types';\n\nconst DEFAULT_LABELS: DateInputLabels = {\n clear: 'Clear'\n};\n\ninterface DateInputSignature {\n Args: DateInputArgs;\n Element: HTMLDivElement;\n}\n\n/**\n * A date typed into segments rather than picked from a grid. `DatePicker`\n * renders the same segments and adds a calendar.\n */\nclass DateInput extends Component<DateInputSignature> {\n containerRef = ref<HTMLElement>();\n\n /**\n * The segments are the state, not the value: mid-entry they hold digits that\n * compose to no date at all, which no `Date` can represent.\n */\n @tracked private trackedParts: Part[] = [];\n\n /**\n * An untracked mirror of {@link parts}. The sync modifiers below need to\n * read the current segments in order to rebuild them, and reading the\n * tracked field inside a modifier would put it in that modifier's own\n * tracking frame -- which the same modifier then writes to, re-running\n * itself forever.\n */\n #currentParts: Part[] = [];\n\n constructor(owner: unknown, args: DateInputArgs) {\n super(owner as never, args);\n\n const seed = args.defaultValue;\n this.setParts(\n fromDate(\n buildParts(this.locale, this.formatOptions, this.timeOptions),\n seed === undefined ? null : parseDate(seed)\n )\n );\n }\n\n get parts(): Part[] {\n return this.trackedParts;\n }\n\n private setParts(parts: Part[]): void {\n this.#currentParts = parts;\n this.trackedParts = parts;\n }\n\n get locale(): string {\n return this.args.locale ?? navigator.language;\n }\n\n get formatOptions(): Intl.DateTimeFormatOptions | undefined {\n // A textual month has no numeric segment to type into, so it falls back\n // to a numeric one. `dateStyle: 'medium'` is the common way to hit this --\n // it is DatePicker's button-trigger default. Only the month is replaced:\n // the rest of the format is the consumer's and stands.\n return resolveSegmentFormat(this.args.formatOptions, {\n message:\n '<DateInput> needs numeric segments; ' +\n 'a textual @formatOptions month falls back to a numeric one.',\n id: 'frontile.date-input.textual-format'\n });\n }\n\n /** The time segments the field adds to the date, if any. */\n @cached\n get timeOptions(): TimeOptions {\n return {\n granularity: this.args.granularity,\n hourCycle: this.args.hourCycle\n };\n }\n\n /**\n * The composed value, or null while any segment is empty.\n *\n * Cached because `wireValue`, `isOutOfRange` and the template all read it\n * independently, and each `toDate` walks the parts three times over.\n */\n @cached\n get value(): Date | null {\n return toDate(this.parts);\n }\n\n get wireValue(): string {\n return toWire(this.value, this.args.granularity);\n }\n\n get isEmpty(): boolean {\n return this.parts.every((p) => !isSegment(p) || p.value === null);\n }\n\n get placeholderValue(): Date {\n return this.args.placeholderValue ?? new Date();\n }\n\n /**\n * Whether the composed value is outside the allowed range. Never blocks a\n * keystroke -- typing toward 2020 passes through 2, 20 and 202 on the way,\n * and a field that refused those could not be typed into at all.\n */\n get isOutOfRange(): boolean {\n const value = this.value;\n if (!value) return false;\n\n if (this.args.minValue && value < this.args.minValue) return true;\n if (this.args.maxValue && value > this.args.maxValue) return true;\n return this.args.isDateUnavailable?.(value) ?? false;\n }\n\n get isInvalid(): boolean {\n return Boolean(this.args.isInvalid) || this.isOutOfRange;\n }\n\n /**\n * Pushes `@value` into the segments when the argument changes. `undefined`\n * is ignored, so a field bound by `Field` before the form holds anything for\n * it keeps what the user typed -- the rule `DatePicker` documents.\n */\n syncValue = modifier(\n (_: HTMLElement, [raw]: [Date | string | null | undefined]) => {\n if (raw === undefined) return;\n\n const parsed = parseDate(raw);\n\n // Ignore the echo of our own `@onChange`. A controlled consumer writes\n // back the value this field just reported, and rewriting the segments\n // from it would destroy a partial entry: backspacing one digit of the\n // year un-commits it, so the field composes `null`, reports `null`, and\n // is handed `null` straight back -- which `fromDate` would spend on\n // clearing every other segment too. One keystroke would empty the field.\n if (!hasDateChanged(toDate(this.#currentParts), parsed)) return;\n\n this.setParts(fromDate(this.#currentParts, parsed));\n }\n );\n\n /**\n * Rebuilds the segment order when the locale or format changes, carrying\n * each segment's own state across so switching en-US to en-GB reorders the\n * field without emptying it -- half-typed digits included, which is why\n * this goes segment by segment rather than through the composed value.\n */\n syncLocale = modifier(\n (\n _: HTMLElement,\n [locale, format, time]: [\n string,\n Intl.DateTimeFormatOptions | undefined,\n TimeOptions\n ]\n ) => {\n this.setParts(\n carryOver(buildParts(locale, format, time), this.#currentParts)\n );\n }\n );\n\n handlePartsChange = (parts: Part[]): void => {\n const before = toDate(this.#currentParts);\n this.setParts(parts);\n const after = toDate(parts);\n\n // Only value transitions are reported. The four keystrokes that fill a\n // month and a day compose no date at all, and report nothing.\n if (hasDateChanged(before, after)) {\n this.args.onChange?.(after);\n triggerFormInputEvent(this.containerRef.current);\n }\n };\n\n /**\n * `@onBlur` means \"the user left the field\", not \"the user left a segment\",\n * so a move between segments is filtered out by asking whether focus landed\n * inside the container. `DatePicker` needs `ControlBlurTracker` for this\n * because its focus can legitimately be in a popover outside its own DOM;\n * this field has no popover, so containment is the whole question.\n */\n handleFocusOut = (event: FocusEvent): void => {\n const container = this.containerRef.current;\n const next = event.relatedTarget;\n\n if (container && next instanceof Node && container.contains(next)) return;\n\n this.args.onBlur?.();\n };\n\n get labels(): DateInputLabels {\n return { ...DEFAULT_LABELS, ...this.args.labels };\n }\n\n /**\n * A disabled or read-only field never offers it: it carries no disabled\n * state of its own and would be a live button clearing a field the user may\n * not change.\n */\n get isClearable(): boolean {\n return (\n Boolean(this.args.isClearable) &&\n !this.isEmpty &&\n !this.args.isDisabled &&\n !this.args.isReadOnly\n );\n }\n\n /**\n * Clearing removes the clear button from the DOM (`isClearable` flips\n * false the instant the value is gone), so focus must be handed somewhere\n * explicitly or it falls to `<body>` and a keyboard user loses their place.\n */\n clear = (): void => {\n this.handlePartsChange(fromDate(this.#currentParts, null));\n this.containerRef.current\n ?.querySelector<HTMLElement>('[data-part=\"segment\"]')\n ?.focus();\n };\n\n @cached\n get classes(): DateInputClasses {\n const { dateInput } = useStyles();\n return dateInput({ size: this.args.inputSize });\n }\n\n <template>\n <div\n {{this.syncLocale this.locale this.formatOptions this.timeOptions}}\n {{this.syncValue @value}}\n {{this.containerRef.setup}}\n {{on \"focusout\" this.handleFocusOut}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"date-input\"\n data-part=\"base\"\n ...attributes\n >\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{this.isInvalid}}\n @isDisabled={{@isDisabled}}\n as |c|\n >\n <div\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n {{! The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. }}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n >\n <SegmentGroup\n @parts={{this.parts}}\n @onPartsChange={{this.handlePartsChange}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{c.id}}\n @label={{@label}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n />\n {{#if this.isClearable}}\n <div\n data-part=\"end-content\"\n class={{this.classes.endContent class=@classes.endContent}}\n >\n <CloseButton\n @title={{this.labels.clear}}\n @variant=\"soft\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-part=\"clear-button\"\n @onPress={{this.clear}}\n />\n </div>\n {{/if}}\n </div>\n </FormControl>\n </div>\n </template>\n}\n\nexport { DateInput, type DateInputSignature };\nexport default DateInput;\n"],"names":["DEFAULT_LABELS","clear","DateInput","Component","containerRef","ref","g","prototype","tracked","i","constructor","owner","args","seed","defaultValue","setParts","fromDate","buildParts","locale","formatOptions","timeOptions","undefined","parseDate","parts","trackedParts","navigator","language","resolveSegmentFormat","message","id","granularity","hourCycle","n","cached","value","toDate","wireValue","toWire","isEmpty","every","p","isSegment","placeholderValue","Date","isOutOfRange","minValue","maxValue","isDateUnavailable","isInvalid","Boolean","syncValue","modifier","_","raw","parsed","hasDateChanged","syncLocale","format","time","carryOver","handlePartsChange","before","after","onChange","triggerFormInputEvent","current","handleFocusOut","event","container","next","relatedTarget","Node","contains","onBlur","labels","isClearable","isDisabled","isReadOnly","querySelector","focus","classes","dateInput","useStyles","size","inputSize","setComponentTemplate","precompileTemplate","strictMode","scope","on","FormControl","SegmentGroup","CloseButton"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAMA,cAAgB,GAAkB;AACtCC,EAAAA,KAAA,EAAO;AACT,CAAA;AAOA;;;;AAIA,MAAMC,kBAAkBC,SAAA,CAAU;EAChCC,YAAA,GAAeC,KAAI;AAEnB;;;AAGC;AAHD,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAICC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAuC,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,aAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,cAAA,CAAA,EAAA,MAAA;AAE1C;;;;;;AAMC;EACD,aAAa,GAAW,EAAE;AAE1BC,EAAAA,WAAAA,CAAYC,KAAc,EAAEC,IAAmB,EAAE;AAC/C,IAAA,KAAK,CAACD,KAAA,EAAgBC,IAAA,CAAA;AAEtB,IAAA,MAAMC,IAAA,GAAOD,KAAKE,YAAY;AAC9B,IAAA,IAAI,CAACC,QAAQ,CACXC,QAAA,CACEC,WAAW,IAAI,CAACC,MAAM,EAAE,IAAI,CAACC,aAAa,EAAE,IAAI,CAACC,WAAW,GAC5DP,IAAA,KAASQ,SAAA,GAAY,OAAOC,SAAA,CAAUT,IAAA,CAAA,CAAA,CAAA;AAG5C,EAAA;EAEA,IAAIU,QAAgB;IAClB,OAAO,IAAI,CAACC,YAAY;AAC1B,EAAA;EAEQT,QAAAA,CAASQ,KAAa,EAAQ;AACpC,IAAA,IAAI,CAAC,aAAa,GAAGA,KAAA;IACrB,IAAI,CAACC,YAAY,GAAGD,KAAA;AACtB,EAAA;EAEA,IAAIL,MAAAA,GAAiB;IACn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,QAAA,CAAS,IAAI,CAAC,aAAa,EAAE,IAAA,CAAA,CAAA;AACpD,IAAA,IAAI,CAACZ,YAAY,CAAC6D,OAAO,EACrBa,cAA2B,uBAAA,CAAA,EAC3BC,KAAA,EAAA;EACN,CAAA;EAEA,IACIC,UAA4B;IAC9B,MAAM;AAAEC,MAAAA;KAAW,GAAGC,SAAA,EAAA;AACtB,IAAA,OAAOD,SAAA,CAAU;AAAEE,MAAAA,IAAA,EAAM,IAAI,CAACvE,IAAI,CAACwE;AAAU,KAAA,CAAA;AAC/C,EAAA;AAAA,EAAA;IAAApD,gBAAA,CAAA,IAAA,CAAAzB,SAAA,EAAA,SAAA,EAAA,CAJC0B,MAAA,CAAA,CAAA;AAAA;AAMD,EAAA;IAAAoD,oBAAA,CAAAC,kBAAA,CAAA,6yDAAA,EAoEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,WAAA;QAAAC,YAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { cached } from '@glimmer/tracking';
|
|
3
3
|
import { fn } from '@ember/helper';
|
|
4
4
|
import { on } from '@ember/modifier';
|
|
5
|
-
import { isSegment, displaySegment, step, deleteDigit, clearSegment, applyDigit, commitSegment } from './segments.js';
|
|
5
|
+
import { isSegment, displaySegment, step, deleteDigit, clearSegment, applyDigit, applyLetter, commitSegment } from './segments.js';
|
|
6
6
|
import { parsePasted, splitRange, formatForClipboard } from './clipboard.js';
|
|
7
7
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
8
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -11,13 +11,19 @@ import { a as decorateMethodV2 } from '../../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
|
11
11
|
const DEFAULT_LABELS = {
|
|
12
12
|
year: 'year',
|
|
13
13
|
month: 'month',
|
|
14
|
-
day: 'day'
|
|
14
|
+
day: 'day',
|
|
15
|
+
hour: 'hour',
|
|
16
|
+
minute: 'minute',
|
|
17
|
+
dayPeriod: 'AM/PM'
|
|
15
18
|
};
|
|
16
19
|
/** How much PageUp/PageDown moves, per segment. */
|
|
17
20
|
const PAGE_STEP = {
|
|
18
21
|
day: 7,
|
|
19
22
|
month: 3,
|
|
20
|
-
year: 10
|
|
23
|
+
year: 10,
|
|
24
|
+
hour: 2,
|
|
25
|
+
minute: 15,
|
|
26
|
+
dayPeriod: 1
|
|
21
27
|
};
|
|
22
28
|
/**
|
|
23
29
|
* Everything one rendered part needs, resolved to primitives.
|
|
@@ -57,6 +63,7 @@ class SegmentGroup extends Component {
|
|
|
57
63
|
}
|
|
58
64
|
valueTextFor = segment => {
|
|
59
65
|
if (segment.value === null) return undefined;
|
|
66
|
+
if (segment.labels) return segment.labels[segment.value];
|
|
60
67
|
if (segment.type !== 'month') return String(segment.value);
|
|
61
68
|
// Any year and day will do; only the month is read back out.
|
|
62
69
|
return this.monthNames.format(new Date(2026, segment.value - 1, 1));
|
|
@@ -68,7 +75,8 @@ class SegmentGroup extends Component {
|
|
|
68
75
|
index,
|
|
69
76
|
isSegment: false,
|
|
70
77
|
isEmpty: false,
|
|
71
|
-
text: part.text
|
|
78
|
+
text: part.text,
|
|
79
|
+
inputMode: 'numeric'
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
return {
|
|
@@ -78,6 +86,7 @@ class SegmentGroup extends Component {
|
|
|
78
86
|
type: part.type,
|
|
79
87
|
isEmpty: part.value === null,
|
|
80
88
|
label: this.labelFor(part.type),
|
|
89
|
+
inputMode: part.labels ? 'text' : 'numeric',
|
|
81
90
|
// `undefined` rather than `null`: an empty segment has no current
|
|
82
91
|
// value, and `aria-valuenow="null"` would be a value of sorts.
|
|
83
92
|
valueNow: part.value ?? undefined,
|
|
@@ -174,6 +183,8 @@ class SegmentGroup extends Component {
|
|
|
174
183
|
}
|
|
175
184
|
if (/^\d$/.test(key)) {
|
|
176
185
|
event.preventDefault();
|
|
186
|
+
// AM/PM has no digits to take.
|
|
187
|
+
if (part.labels) return;
|
|
177
188
|
const {
|
|
178
189
|
segment,
|
|
179
190
|
isFull
|
|
@@ -184,6 +195,16 @@ class SegmentGroup extends Component {
|
|
|
184
195
|
if (isFull) this.focusSibling(element, 1);
|
|
185
196
|
return;
|
|
186
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
|
+
}
|
|
187
208
|
// Everything else -- letters, symbols -- would otherwise be inserted into
|
|
188
209
|
// the contenteditable span as literal text.
|
|
189
210
|
if (key.length === 1 && !event.metaKey && !event.ctrlKey) {
|
|
@@ -257,7 +278,7 @@ class SegmentGroup extends Component {
|
|
|
257
278
|
this.args.onPartsChange(this.args.parts.map(p => isSegment(p) ? clearSegment(p) : p));
|
|
258
279
|
};
|
|
259
280
|
static {
|
|
260
|
-
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
|
|
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>", {
|
|
261
282
|
strictMode: true,
|
|
262
283
|
scope: () => ({
|
|
263
284
|
on,
|
|
@@ -1 +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 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};\n\n/** How much PageUp/PageDown moves, per segment. */\nconst PAGE_STEP: Record<SegmentType, number> = { day: 7, month: 3, year: 10 };\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 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.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 { index, isSegment: false, isEmpty: false, text: part.text };\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 // `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 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 // 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=\"numeric\"\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","PAGE_STEP","SegmentGroup","Component","isEditable","args","isDisabled","isReadOnly","labelFor","type","segmentLabels","monthNames","Intl","DateTimeFormat","locale","n","prototype","cached","valueTextFor","segment","value","undefined","String","format","Date","cells","parts","map","part","index","isSegment","isEmpty","text","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","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":";;;;;;;;;;AA4DA,MAAMA,cAA0C,GAAI;AAClDC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,KAAA,EAAO,OAAA;AACPC,EAAAA,GAAA,EAAK;AACP,CAAA;AAEA;AACA,MAAMC,SAAqC,GAAI;AAAED,EAAAA,GAAA,EAAK,CAAA;AAAGD,EAAAA,KAAA,EAAO,CAAA;AAAGD,EAAAA,IAAA,EAAM;AAAG,CAAA;AAE5E;;;;;;;;;AAsBA;;;;AAIA,MAAMI,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,IAAIZ,cAAc,CAACY,KAAK;AAEzD;;;;;AAKC;EACD,IACIE,UAAAA,GAAkC;IACpC,OAAO,IAAIC,KAAKC,cAAc,CAAC,IAAI,CAACR,IAAI,CAACS,MAAM,EAAE;AAAEf,MAAAA,KAAA,EAAO;AAAO,KAAA,CAAA;AACnE,EAAA;AAEA;;;AAGC;AAHD,EAAA;IAAAgB,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;EASDC,eAAgBC,OAAS,IAA4B;AACnD,IAAA,IAAIA,OAAA,CAAQC,KAAK,KAAK,IAAA,EAAM,OAAOC,SAAA;AACnC,IAAA,IAAIF,QAAQV,IAAI,KAAK,SAAS,OAAOa,MAAA,CAAOH,QAAQC,KAAK,CAAA;AAEzD;AACA,IAAA,OAAO,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ment-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;;;;;AAKC;EACD,IACIE,UAAAA,GAAkC;IACpC,OAAO,IAAIC,KAAKC,cAAc,CAAC,IAAI,CAACR,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