@fragiola/primitives 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -2
  4. package/dist/async-list-Bv6ff5Oj.js +81 -0
  5. package/dist/async-list-Bv6ff5Oj.js.map +1 -0
  6. package/dist/async-list.d.ts +2 -0
  7. package/dist/async-list.js +1 -0
  8. package/dist/calendar-keys-DGYpjLwv.d.ts +12 -0
  9. package/dist/calendar-system-B5U5HcPQ.d.ts +415 -0
  10. package/dist/calendar-systems-Daa6Q_ca.js +659 -0
  11. package/dist/calendar-systems-Daa6Q_ca.js.map +1 -0
  12. package/dist/calendar-systems.d.ts +3 -0
  13. package/dist/calendar-systems.js +1 -0
  14. package/dist/carousel-LRbWqbAx.js +375 -0
  15. package/dist/carousel-LRbWqbAx.js.map +1 -0
  16. package/dist/carousel.d.ts +2 -0
  17. package/dist/carousel.js +1 -0
  18. package/dist/cascade-B155Xvvv.js +64 -0
  19. package/dist/cascade-B155Xvvv.js.map +1 -0
  20. package/dist/cascade.d.ts +2 -0
  21. package/dist/cascade.js +1 -0
  22. package/dist/clipboard-Cy2cbGEW.js +33 -0
  23. package/dist/clipboard-Cy2cbGEW.js.map +1 -0
  24. package/dist/clipboard.d.ts +2 -0
  25. package/dist/clipboard.js +1 -0
  26. package/dist/collection-Dbk-PB5S.js +609 -0
  27. package/dist/collection-Dbk-PB5S.js.map +1 -0
  28. package/dist/collection.d.ts +2 -0
  29. package/dist/collection.js +3 -0
  30. package/dist/color-sURV5Irg.js +699 -0
  31. package/dist/color-sURV5Irg.js.map +1 -0
  32. package/dist/color.d.ts +2 -0
  33. package/dist/color.js +1 -0
  34. package/dist/command-DueCXi65.js +104 -0
  35. package/dist/command-DueCXi65.js.map +1 -0
  36. package/dist/command.d.ts +2 -0
  37. package/dist/command.js +1 -0
  38. package/dist/date-CrbFSJKQ.js +215 -0
  39. package/dist/date-CrbFSJKQ.js.map +1 -0
  40. package/dist/date.d.ts +4 -0
  41. package/dist/date.js +1 -0
  42. package/dist/direction-CTnVLpmd.d.ts +8 -0
  43. package/dist/direction-DJDPvnxJ.js +13 -0
  44. package/dist/direction-DJDPvnxJ.js.map +1 -0
  45. package/dist/direction.d.ts +2 -0
  46. package/dist/direction.js +1 -0
  47. package/dist/drag-session-CSr06B5v.js +41 -0
  48. package/dist/drag-session-CSr06B5v.js.map +1 -0
  49. package/dist/file-DSLtfzbi.js +263 -0
  50. package/dist/file-DSLtfzbi.js.map +1 -0
  51. package/dist/file.d.ts +2 -0
  52. package/dist/file.js +1 -0
  53. package/dist/focus-BI-VvM0f.js +75 -0
  54. package/dist/focus-BI-VvM0f.js.map +1 -0
  55. package/dist/focus.d.ts +2 -0
  56. package/dist/focus.js +3 -0
  57. package/dist/form-DovwKtqz.js +501 -0
  58. package/dist/form-DovwKtqz.js.map +1 -0
  59. package/dist/form.d.ts +2 -0
  60. package/dist/form.js +1 -0
  61. package/dist/hover-BakyPYnC.js +62 -0
  62. package/dist/hover-BakyPYnC.js.map +1 -0
  63. package/dist/hover.d.ts +2 -0
  64. package/dist/hover.js +1 -0
  65. package/dist/id-B0Y8iZrc.js +13 -0
  66. package/dist/id-B0Y8iZrc.js.map +1 -0
  67. package/dist/id.d.ts +2 -0
  68. package/dist/id.js +1 -0
  69. package/dist/image-D4X_yRYw.js +44 -0
  70. package/dist/image-D4X_yRYw.js.map +1 -0
  71. package/dist/image.d.ts +2 -0
  72. package/dist/image.js +1 -0
  73. package/dist/index-B0rwIZw9.d.ts +51 -0
  74. package/dist/index-B4wF1isn.d.ts +128 -0
  75. package/dist/index-BHiBRE01.d.ts +20 -0
  76. package/dist/index-BNlMm-0u.d.ts +17 -0
  77. package/dist/index-BapNrjY9.d.ts +48 -0
  78. package/dist/index-Bd-tVb7C.d.ts +6 -0
  79. package/dist/index-BjE8nDiX.d.ts +125 -0
  80. package/dist/index-BpbT-FsX.d.ts +117 -0
  81. package/dist/index-CBgGcTeX.d.ts +37 -0
  82. package/dist/index-CGThV_Md.d.ts +100 -0
  83. package/dist/index-CMig3TXL.d.ts +28 -0
  84. package/dist/index-CWFRduRd.d.ts +212 -0
  85. package/dist/index-CkrHWyU_.d.ts +33 -0
  86. package/dist/index-Cwu6f7y1.d.ts +18 -0
  87. package/dist/index-D10LDdR6.d.ts +139 -0
  88. package/dist/index-D146vm21.d.ts +104 -0
  89. package/dist/index-DGKhEvNr.d.ts +107 -0
  90. package/dist/index-DbAu4s16.d.ts +48 -0
  91. package/dist/index-DdaCj6IO.d.ts +54 -0
  92. package/dist/index-DeHcNdjC.d.ts +68 -0
  93. package/dist/index-DeR4ncrW.d.ts +93 -0
  94. package/dist/index-HIksgK0e.d.ts +70 -0
  95. package/dist/index-IZB0mlZl.d.ts +71 -0
  96. package/dist/index-IfDZj87U.d.ts +28 -0
  97. package/dist/index-SrTuVBms.d.ts +75 -0
  98. package/dist/index-T9UcYvkf.d.ts +339 -0
  99. package/dist/index-fRTojAoR.d.ts +31 -0
  100. package/dist/index-fuLUke9n.d.ts +6 -0
  101. package/dist/index-l63esAck.d.ts +104 -0
  102. package/dist/index-raSUg9U7.d.ts +38 -0
  103. package/dist/index-twgzPKvZ.d.ts +278 -0
  104. package/dist/index-wBpjRykh.d.ts +125 -0
  105. package/dist/index.d.ts +39 -0
  106. package/dist/index.js +42 -0
  107. package/dist/inert-DlGToy3q.js +80 -0
  108. package/dist/inert-DlGToy3q.js.map +1 -0
  109. package/dist/inert.d.ts +2 -0
  110. package/dist/inert.js +1 -0
  111. package/dist/layer-stack-BEtzaFC1.js +118 -0
  112. package/dist/layer-stack-BEtzaFC1.js.map +1 -0
  113. package/dist/layers-C-N4rrZX.js +24 -0
  114. package/dist/layers-C-N4rrZX.js.map +1 -0
  115. package/dist/layers.d.ts +2 -0
  116. package/dist/layers.js +3 -0
  117. package/dist/list-navigation-CbWv4DK5.js +40 -0
  118. package/dist/list-navigation-CbWv4DK5.js.map +1 -0
  119. package/dist/month-year-BG5imFUq.js +108 -0
  120. package/dist/month-year-BG5imFUq.js.map +1 -0
  121. package/dist/month-year.d.ts +3 -0
  122. package/dist/month-year.js +1 -0
  123. package/dist/number-BFUio97d.js +316 -0
  124. package/dist/number-BFUio97d.js.map +1 -0
  125. package/dist/number.d.ts +2 -0
  126. package/dist/number.js +1 -0
  127. package/dist/overlay-BwPyiM3T.js +78 -0
  128. package/dist/overlay-BwPyiM3T.js.map +1 -0
  129. package/dist/overlay.d.ts +2 -0
  130. package/dist/overlay.js +1 -0
  131. package/dist/pagination-BkVzaIGP.js +51 -0
  132. package/dist/pagination-BkVzaIGP.js.map +1 -0
  133. package/dist/pagination.d.ts +2 -0
  134. package/dist/pagination.js +1 -0
  135. package/dist/plain-date-idQH1P6X.d.ts +29 -0
  136. package/dist/plain-date-time-B8PGahhe.d.ts +99 -0
  137. package/dist/pointer-CuDtD9XA.js +189 -0
  138. package/dist/pointer-CuDtD9XA.js.map +1 -0
  139. package/dist/pointer.d.ts +2 -0
  140. package/dist/pointer.js +3 -0
  141. package/dist/positioning-DDUQ75mB.js +148 -0
  142. package/dist/positioning-DDUQ75mB.js.map +1 -0
  143. package/dist/positioning.d.ts +2 -0
  144. package/dist/positioning.js +1 -0
  145. package/dist/presence-BhKDOmII.js +86 -0
  146. package/dist/presence-BhKDOmII.js.map +1 -0
  147. package/dist/presence.d.ts +2 -0
  148. package/dist/presence.js +1 -0
  149. package/dist/range-o0_GBhyY.js +158 -0
  150. package/dist/range-o0_GBhyY.js.map +1 -0
  151. package/dist/range.d.ts +2 -0
  152. package/dist/range.js +1 -0
  153. package/dist/scroll-area-BYNhv36t.js +447 -0
  154. package/dist/scroll-area-BYNhv36t.js.map +1 -0
  155. package/dist/scroll-area.d.ts +2 -0
  156. package/dist/scroll-area.js +1 -0
  157. package/dist/scroll-lock-JzRNOA1O.js +42 -0
  158. package/dist/scroll-lock-JzRNOA1O.js.map +1 -0
  159. package/dist/scroll-lock.d.ts +2 -0
  160. package/dist/scroll-lock.js +1 -0
  161. package/dist/segments-eRu5G_Bd.js +587 -0
  162. package/dist/segments-eRu5G_Bd.js.map +1 -0
  163. package/dist/segments.d.ts +3 -0
  164. package/dist/segments.js +1 -0
  165. package/dist/selection-Cor67w_V.js +287 -0
  166. package/dist/selection-Cor67w_V.js.map +1 -0
  167. package/dist/selection.d.ts +2 -0
  168. package/dist/selection.js +1 -0
  169. package/dist/swipe.d.ts +2 -0
  170. package/dist/swipe.js +1 -0
  171. package/dist/tabbable-BPiLssIv.js +35 -0
  172. package/dist/tabbable-BPiLssIv.js.map +1 -0
  173. package/dist/time-Ct6oq9kt.js +208 -0
  174. package/dist/time-Ct6oq9kt.js.map +1 -0
  175. package/dist/time-zone-DegkzwST.js +305 -0
  176. package/dist/time-zone-DegkzwST.js.map +1 -0
  177. package/dist/time-zone.d.ts +2 -0
  178. package/dist/time-zone.js +1 -0
  179. package/dist/time.d.ts +2 -0
  180. package/dist/time.js +1 -0
  181. package/dist/toast-BjRpJalM.js +400 -0
  182. package/dist/toast-BjRpJalM.js.map +1 -0
  183. package/dist/toast.d.ts +2 -0
  184. package/dist/toast.js +1 -0
  185. package/dist/unit-grid-DJy8lb5D.d.ts +21 -0
  186. package/dist/virtual-BlX1RuHD.js +306 -0
  187. package/dist/virtual-BlX1RuHD.js.map +1 -0
  188. package/dist/virtual.d.ts +2 -0
  189. package/dist/virtual.js +1 -0
  190. package/dist/watch-swipe-BIucfr9O.js +301 -0
  191. package/dist/watch-swipe-BIucfr9O.js.map +1 -0
  192. package/package.json +234 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segments-eRu5G_Bd.js","names":[],"sources":["../src/segments/segment-format.ts","../src/segments/segment-values.ts","../src/segments/date-segments.ts","../src/segments/segment-focus.ts","../src/segments/segment-typing.ts","../src/segments/segment-keys.ts"],"sourcesContent":["import type { CalendarSystem } from \"../calendar-systems/calendar-system.ts\";\nimport type { TimeZone } from \"../time-zone/time-zone.ts\";\nimport type { Disambiguation } from \"../time-zone/zoned-date-time.ts\";\n\n/** What a segment of a date or time field shows (spec/date-field.md, \"Segments\"). */\nexport type SegmentType =\n | \"era\"\n | \"year\"\n | \"month\"\n | \"day\"\n | \"hour\"\n | \"minute\"\n | \"second\"\n | \"dayPeriod\"\n | \"timeZoneName\"\n | \"literal\";\n\n/**\n * The segments the user edits; the others (`literal`, `timeZoneName`) are only shown, and an\n * `era` only in a calendar system of several eras (spec/calendar-systems.md, \"In the fields\").\n */\nexport type EditableSegmentType =\n | \"era\"\n | \"year\"\n | \"month\"\n | \"day\"\n | \"hour\"\n | \"minute\"\n | \"second\"\n | \"dayPeriod\";\n\n/** The smallest unit a field edits: `day` for a date alone, else the time down to it. */\nexport type SegmentGranularity = \"day\" | \"hour\" | \"minute\" | \"second\";\n\n/** What a field holds: a date (and, finer than `day`, its time) or a time alone. */\nexport type SegmentKind = \"date\" | \"time\";\n\n/** `Intl`'s hour cycles: 0–11, 1–12, 0–23, 1–24. */\nexport type HourCycle = \"h11\" | \"h12\" | \"h23\" | \"h24\";\n\nexport interface SegmentFormatOptions {\n /** BCP 47. */\n readonly locale: string;\n readonly kind: SegmentKind;\n /** Default: `day` for a date, `minute` for a time (a time's `day` reads as `minute`). */\n readonly granularity?: SegmentGranularity | undefined;\n /** `12` or `24` (the locale picks `h11` or `h12` for 12), or an exact cycle; default: the locale's. */\n readonly hourCycle?: 12 | 24 | HourCycle | undefined;\n /**\n * A calendar system (spec/calendar-systems.md): the segments show and edit its fields; values\n * stay ISO. Default: none (the ISO calendar, as the locale writes it).\n */\n readonly calendar?: CalendarSystem | undefined;\n /**\n * A time zone (spec/time-zones.md): the values are `ZonedDateTime`s in it, and a date and\n * time shows a `timeZoneName` segment unless `hideTimeZone`.\n */\n readonly timeZone?: TimeZone | undefined;\n readonly hideTimeZone?: boolean | undefined;\n /** How a wall time the zone skips or repeats resolves (default `compatible`). */\n readonly disambiguation?: Disambiguation | undefined;\n}\n\n/** One piece of the format, in the locale's order: a segment, or the literal text between. */\nexport interface SegmentPart {\n readonly type: SegmentType;\n /** The text of a `literal` (or `era`) part, as `Intl` writes it; `\"\"` for the others. */\n readonly literal: string;\n}\n\n/**\n * A field's format for a locale (from `Intl.DateTimeFormat#formatToParts`): the order of its\n * segments and the literals between them, its hour cycle, its digits and the texts `Intl` gives\n * for the day periods and the segments' names. Built once per locale and options.\n */\nexport interface SegmentFormat {\n readonly locale: string;\n readonly kind: SegmentKind;\n readonly granularity: SegmentGranularity;\n readonly parts: readonly SegmentPart[];\n /** The editable segments, in the locale's order. */\n readonly types: readonly EditableSegmentType[];\n /** `null` when the format has no hour. */\n readonly hourCycle: HourCycle | null;\n /** The locale's ten digits, 0 to 9 (`Intl`'s numbering system). */\n readonly digits: readonly string[];\n /** The day period texts, AM then PM (`[\"\", \"\"]` when the format has none). */\n readonly dayPeriods: readonly [string, string];\n /** Each segment's name, from `Intl.DisplayNames` (`dateTimeField`), when the engine has it. */\n readonly names: Readonly<Partial<Record<SegmentType, string>>>;\n /** Formats a UTC date in the field's segments (`timeZone: \"UTC\"`). */\n readonly formatter: Intl.DateTimeFormat;\n /** Formats a UTC date's month name (`month: \"long\"`), the month's `aria-valuetext`. */\n readonly monthNames: Intl.DateTimeFormat;\n /** The calendar system, when the field has one. */\n readonly calendar?: CalendarSystem | undefined;\n /** The eras' names (`era: \"short\"`), oldest first, when the era is editable. */\n readonly eras?: readonly string[] | undefined;\n /** The time zone, when the field holds zoned values. */\n readonly timeZone?: TimeZone | undefined;\n readonly disambiguation?: Disambiguation | undefined;\n}\n\nconst EDITABLE = /* @__PURE__ */ new Set<string>([\n \"year\",\n \"month\",\n \"day\",\n \"hour\",\n \"minute\",\n \"second\",\n \"dayPeriod\",\n]);\n\n/** A UTC `Date` of the fields, years 0–99 included (`Date.UTC` reads them as 19xx). */\nexport function utcDate(\n year: number,\n month: number,\n day: number,\n hour = 0,\n minute = 0,\n second = 0,\n): Date {\n const date = new Date(0);\n date.setUTCFullYear(year, month - 1, day);\n date.setUTCHours(hour, minute, second, 0);\n return date;\n}\n\nfunction formatOptions(\n kind: SegmentKind,\n granularity: SegmentGranularity,\n hourCycle: SegmentFormatOptions[\"hourCycle\"],\n): Intl.DateTimeFormatOptions {\n const options: Intl.DateTimeFormatOptions = { timeZone: \"UTC\" };\n if (kind === \"date\") {\n options.year = \"numeric\";\n options.month = \"numeric\";\n options.day = \"numeric\";\n }\n if (granularity !== \"day\") {\n options.hour = \"numeric\";\n if (granularity !== \"hour\") {\n options.minute = \"2-digit\";\n }\n if (granularity === \"second\") {\n options.second = \"2-digit\";\n }\n if (hourCycle === 12) {\n // the locale's 12-hour cycle: h12 (1–12), or h11 (0–11) where it writes that\n options.hour12 = true;\n } else if (hourCycle === 24) {\n options.hourCycle = \"h23\";\n } else if (hourCycle !== undefined) {\n options.hourCycle = hourCycle;\n }\n }\n return options;\n}\n\n/**\n * A literal with its spaces as one kind: engines write the space before a day period as U+0020,\n * U+00A0 or U+202F depending on their ICU (Node and Chromium differ), so a server render and its\n * hydration would disagree; the bidirectional marks stay.\n */\nfunction normalizeLiteral(text: string): string {\n return text.replace(/[\\u00a0\\u2007\\u202f]/g, \" \");\n}\n\nfunction partType(type: string): SegmentType {\n return EDITABLE.has(type) || type === \"era\" || type === \"timeZoneName\"\n ? (type as SegmentType)\n : \"literal\";\n}\n\n/** The ten digits of a locale's numbering system. */\nfunction localeDigits(locale: string, numberingSystem: string): string[] {\n const format = new Intl.NumberFormat(locale, {\n numberingSystem,\n useGrouping: false,\n });\n return Array.from({ length: 10 }, (_, digit) => format.format(digit));\n}\n\nfunction segmentNames(locale: string): Partial<Record<SegmentType, string>> {\n const Names = Intl.DisplayNames as typeof Intl.DisplayNames | undefined;\n if (Names === undefined) {\n return {};\n }\n try {\n const names = new Names(locale, { type: \"dateTimeField\" });\n const result: Partial<Record<SegmentType, string>> = {};\n for (const type of [\n \"era\",\n ...(EDITABLE as Set<EditableSegmentType>),\n \"timeZoneName\",\n ] as const) {\n const name = names.of(type);\n if (name !== undefined) {\n result[type] = name;\n }\n }\n return result;\n } catch {\n // an engine without the `dateTimeField` names: the consumer names the segments\n return {};\n }\n}\n\n/**\n * The format of a date or time field in a locale (spec/date-field.md, \"Segments\"): the parts of\n * `Intl.DateTimeFormat#formatToParts` for the field's segments, in the locale's order, with its\n * literals, hour cycle and digits.\n */\nexport function segmentFormat(options: SegmentFormatOptions): SegmentFormat {\n const { locale, kind, calendar, timeZone } = options;\n const granularity: SegmentGranularity =\n options.granularity === undefined ||\n (kind === \"time\" && options.granularity === \"day\")\n ? kind === \"time\"\n ? \"minute\"\n : \"day\"\n : options.granularity;\n // a calendar system's names and digits: the locale with its `-u-ca-`\n const intlLocale = calendar?.locale(locale) ?? locale;\n const intl = formatOptions(kind, granularity, options.hourCycle);\n // a time zone's name where the locale writes it (its hook, `/time-zone`)\n const formatter = new Intl.DateTimeFormat(\n intlLocale,\n timeZone?.segmentOptions(options, intl) ?? intl,\n );\n const resolved = formatter.resolvedOptions();\n // a sample whose fields are all two digits, and in the afternoon\n const parts: SegmentPart[] = [];\n for (const part of formatter.formatToParts(\n utcDate(2026, 11, 23, 14, 35, 45),\n )) {\n const type = partType(part.type);\n const previous = parts[parts.length - 1];\n if (type === \"literal\" && previous?.type === \"literal\") {\n parts[parts.length - 1] = {\n type,\n literal: previous.literal + normalizeLiteral(part.value),\n };\n continue;\n }\n parts.push({\n type,\n literal:\n type === \"literal\"\n ? normalizeLiteral(part.value)\n : type === \"era\"\n ? part.value\n : \"\",\n });\n }\n const types = parts\n .map((part) => part.type)\n .filter((type): type is EditableSegmentType => EDITABLE.has(type));\n const hasHour = types.includes(\"hour\");\n const period = (hour: number) =>\n formatter\n .formatToParts(utcDate(2026, 11, 23, hour))\n .find((part) => part.type === \"dayPeriod\")?.value ?? \"\";\n // the options' locale, kind, calendar, time zone and disambiguation, the rest resolved\n const format: SegmentFormat = {\n ...options,\n granularity,\n parts,\n types,\n hourCycle: hasHour ? (resolved.hourCycle ?? \"h23\") : null,\n digits: localeDigits(locale, resolved.numberingSystem),\n dayPeriods: types.includes(\"dayPeriod\")\n ? [period(0), period(12)]\n : [\"\", \"\"],\n names: segmentNames(locale),\n formatter,\n monthNames: new Intl.DateTimeFormat(intlLocale, {\n month: \"long\",\n timeZone: \"UTC\",\n }),\n };\n // the era and the system's fields are the calendar system's hooks (`/calendar-systems`)\n return calendar?.segmentFormat(format) ?? format;\n}\n","import type { PlainDate } from \"../date/plain-date.ts\";\nimport type { PlainDateTime } from \"../time/plain-date-time.ts\";\nimport type { PlainTime } from \"../time/plain-time.ts\";\nimport type {\n EditableSegmentType,\n HourCycle,\n SegmentFormat,\n} from \"./segment-format.ts\";\n\n/**\n * What the user has set of a field, segment by segment (spec/date-field.md, \"Editing\"): a\n * segment left out is a placeholder. `hour` is 0–23 whatever the hour cycle; `dayPeriod` (0 AM,\n * 1 PM) is kept only once the user set it (with an hour set, the hour's half of the day agrees\n * with it). A plain, immutable object: every function returns a new one.\n */\nexport type SegmentValues = {\n readonly [type in EditableSegmentType]?: number;\n};\n\n/** A segment's range, in the unit it shows (an hour in its cycle: 1–12 for `h12`). */\nexport interface SegmentRange {\n readonly min: number;\n readonly max: number;\n /** The most digits it is typed with (`0` for the day period, typed by a letter). */\n readonly digits: number;\n}\n\n/** The amount Page Up and Page Down step a segment by (spec/date-field.md, \"Keyboard\"). */\nexport const SEGMENT_PAGE_STEPS: Readonly<Record<EditableSegmentType, number>> =\n {\n era: 1,\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15,\n dayPeriod: 1,\n };\n\n/** The days of a month; a month with no year set counts as in a leap year (February has 29). */\nfunction monthDays(year: number | undefined, month: number): number {\n const date = new Date(0);\n date.setUTCFullYear(year ?? 2000, month, 0);\n return date.getUTCDate();\n}\n\nfunction hourRange(cycle: HourCycle | null): { min: number; max: number } {\n switch (cycle) {\n case \"h11\":\n return { min: 0, max: 11 };\n case \"h12\":\n return { min: 1, max: 12 };\n case \"h24\":\n return { min: 1, max: 24 };\n default:\n return { min: 0, max: 23 };\n }\n}\n\n/** The range of a segment, given what else is set (a day's maximum follows its month and year). */\nexport function segmentRange(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n): SegmentRange {\n // a calendar system's era, months and days are its hooks' (`/calendar-systems`)\n const system = format.calendar?.segmentRange(format, values, type);\n if (system) {\n return system;\n }\n switch (type) {\n case \"year\":\n return { min: 1, max: 9999, digits: 4 };\n case \"month\":\n return { min: 1, max: 12, digits: 2 };\n case \"day\":\n return {\n min: 1,\n max:\n values.month === undefined\n ? 31\n : monthDays(values.year, values.month),\n digits: 2,\n };\n case \"hour\":\n return { ...hourRange(format.hourCycle), digits: 2 };\n case \"minute\":\n case \"second\":\n return { min: 0, max: 59, digits: 2 };\n // an era is edited only in a calendar system (its hook gives the range)\n case \"era\":\n case \"dayPeriod\":\n return { min: 0, max: 1, digits: 0 };\n }\n}\n\n/** The half of the day the values are in: the set day period, else the hour's, else `fallback`. */\nfunction dayPeriodOf(values: SegmentValues, fallback = 0): number {\n if (values.dayPeriod !== undefined) {\n return values.dayPeriod;\n }\n return values.hour === undefined ? fallback : values.hour >= 12 ? 1 : 0;\n}\n\n/** The hour as its cycle shows it (`h12`: 0 → 12, 13 → 1). */\nexport function displayHour(hour: number, cycle: HourCycle | null): number {\n switch (cycle) {\n case \"h11\":\n return hour % 12;\n case \"h12\":\n return hour % 12 || 12;\n case \"h24\":\n return hour || 24;\n default:\n return hour;\n }\n}\n\n/** The 0–23 hour of a shown hour in its cycle and half of the day. */\nfunction hourOf(\n shown: number,\n cycle: HourCycle | null,\n period: number,\n): number {\n switch (cycle) {\n case \"h11\":\n case \"h12\":\n return (shown % 12) + (period === 1 ? 12 : 0);\n case \"h24\":\n return shown % 24;\n default:\n return shown;\n }\n}\n\n/** A segment's value in the unit it shows; `undefined` while it is a placeholder. */\nexport function shownValue(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n): number | undefined {\n if (type === \"hour\") {\n return values.hour === undefined\n ? undefined\n : displayHour(values.hour, format.hourCycle);\n }\n return values[type];\n}\n\n/**\n * Sets a segment to a value in the unit it shows (an hour in its cycle, kept in its half of the\n * day; a day period moves a set hour into its half), or clears it with `undefined`. A day past\n * its month's end is clamped into it.\n */\nexport function setSegment(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n shown: number | undefined,\n seed: SegmentValues = {},\n): SegmentValues {\n const next: { -readonly [key in EditableSegmentType]?: number } = {\n ...values,\n };\n if (shown === undefined) {\n delete next[type];\n return next;\n }\n if (type === \"hour\") {\n const period = format.types.includes(\"dayPeriod\")\n ? dayPeriodOf(values, dayPeriodOf(seed))\n : shown >= 12\n ? 1\n : 0;\n next.hour = hourOf(shown, format.hourCycle, period);\n return next;\n }\n if (type === \"dayPeriod\") {\n next.dayPeriod = shown;\n if (next.hour !== undefined) {\n next.hour = (next.hour % 12) + (shown === 1 ? 12 : 0);\n }\n return next;\n }\n next[type] = shown;\n if (type === \"month\" || type === \"year\" || type === \"era\") {\n // the month clamped into its year (a calendar system's: a Hebrew common year has 12),\n // then the day into its month\n for (const field of [\"month\", \"day\"] as const) {\n const { max } = segmentRange(format, next, field);\n if ((next[field] ?? 0) > max) {\n next[field] = max;\n }\n }\n }\n return next;\n}\n\n/**\n * Steps a segment by `amount`, wrapping within its range and carrying nothing into the others (an\n * hour of a 12-hour cycle stays in its half of the day; the day period toggles). A placeholder\n * takes the seed's value instead (the field's `placeholderValue`), with no step.\n */\nexport function stepSegment(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n amount: number,\n seed: SegmentValues = {},\n): SegmentValues {\n const current = shownValue(format, values, type);\n if (current === undefined) {\n if (type === \"dayPeriod\") {\n return setSegment(\n format,\n values,\n type,\n dayPeriodOf(values, dayPeriodOf(seed)),\n );\n }\n const seeded =\n type === \"hour\"\n ? displayHour(seed.hour ?? 0, format.hourCycle)\n : seed[type];\n const range = segmentRange(format, values, type);\n return setSegment(\n format,\n values,\n type,\n Math.min(Math.max(seeded ?? range.min, range.min), range.max),\n seed,\n );\n }\n const { min, max } = segmentRange(format, values, type);\n const size = max - min + 1;\n const next = ((((current - min + amount) % size) + size) % size) + min;\n return setSegment(format, values, type, next, seed);\n}\n\n/** Sets a segment to the edge of its range (Home: `min`, End: `max`). */\nexport function segmentToEdge(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n edge: \"min\" | \"max\",\n seed: SegmentValues = {},\n): SegmentValues {\n const range = segmentRange(format, values, type);\n return setSegment(format, values, type, range[edge], seed);\n}\n\n/** Whether every editable segment of the format is set. */\nexport function isSegmentsComplete(\n format: SegmentFormat,\n values: SegmentValues,\n): boolean {\n return format.types.every((type) => values[type] !== undefined);\n}\n\n/**\n * The segment values of a date, a time or a date and time (only the format's segments; a day\n * period follows the hour). `null` gives no value: every segment a placeholder.\n */\nexport function segmentValuesOf(\n format: SegmentFormat,\n input: Partial<PlainDateTime> | null | undefined,\n): SegmentValues {\n if (input == null) {\n return {};\n }\n // a zoned value from another zone shows in the field's (spec/time-zones.md), a date in its\n // calendar system's fields (their hooks)\n const wall = format.timeZone?.wallTime(input) ?? input;\n const value: Partial<PlainDateTime> & { era?: number } =\n format.calendar?.segmentValuesOf(format, wall) ?? wall;\n const result: { -readonly [key in EditableSegmentType]?: number } = {};\n for (const type of format.types) {\n if (type === \"dayPeriod\") {\n if (value.hour !== undefined) {\n result.dayPeriod = value.hour >= 12 ? 1 : 0;\n }\n continue;\n }\n const field = value[type];\n if (field !== undefined) {\n result[type] = field;\n }\n }\n return result;\n}\n\n/**\n * The date of complete values (`null` while a date segment is a placeholder); with a calendar\n * system's `format`, the ISO date of its fields (its hook).\n */\nexport function segmentsToDate(\n values: SegmentValues,\n format?: SegmentFormat,\n): PlainDate | null {\n if (format?.calendar) {\n return format.calendar.segmentsToDate(format, values);\n }\n const { year, month, day } = values;\n return year === undefined || month === undefined || day === undefined\n ? null\n : { year, month, day };\n}\n\n/** The time of values (the segments a format has not are 0); `null` with no hour. */\nexport function segmentsToTime(values: SegmentValues): PlainTime | null {\n return values.hour === undefined\n ? null\n : {\n hour: values.hour,\n minute: values.minute ?? 0,\n second: values.second ?? 0,\n millisecond: 0,\n };\n}\n\n/**\n * The date and time of values; `null` while the date or the hour is a placeholder. With a time\n * zone's `format`, a `ZonedDateTime` resolved with its `disambiguation` (`null` when `reject`\n * meets a wall time the zone skips or repeats).\n */\nexport function segmentsToDateTime(\n values: SegmentValues,\n format?: SegmentFormat,\n): PlainDateTime | null {\n const date = segmentsToDate(values, format);\n const time = segmentsToTime(values);\n return date === null || time === null\n ? null\n : format?.timeZone\n ? format.timeZone.segmentsToDateTime(format, date, time)\n : { ...date, ...time };\n}\n","import {\n type EditableSegmentType,\n type SegmentFormat,\n type SegmentType,\n utcDate,\n} from \"./segment-format.ts\";\nimport type { SegmentEdit } from \"./segment-typing.ts\";\nimport {\n type SegmentValues,\n segmentRange,\n shownValue,\n} from \"./segment-values.ts\";\n\n/** One segment as a field renders it (spec/date-field.md, \"Segments\"). */\nexport interface DateSegment {\n readonly type: SegmentType;\n /** Its place in the format: a stable key among the field's segments. */\n readonly index: number;\n /**\n * What it shows: its value as `Intl` writes it, the digits being typed, a placeholder (one\n * `–` per digit), or a literal's text.\n */\n readonly text: string;\n /** An editable segment (a `spinbutton`); literals and eras are not. */\n readonly editable: boolean;\n /** An editable segment with no value yet. */\n readonly placeholder: boolean;\n /** Its value in the unit it shows (`aria-valuenow`); `null` for a placeholder or a literal. */\n readonly value: number | null;\n readonly min: number | null;\n readonly max: number | null;\n /** `aria-valuetext`: its text, a month's name; `null` for a placeholder or a literal. */\n readonly valueText: string | null;\n /** Its name from `Intl.DisplayNames` (\"month\"), its default `aria-label`; `null` for none. */\n readonly label: string | null;\n}\n\n/** The text of a placeholder: one en dash per digit, two for a day period (no language). */\nexport const SEGMENT_PLACEHOLDER = \"–\";\n\nfunction editable(\n format: SegmentFormat,\n type: SegmentType,\n): type is EditableSegmentType {\n return (format.types as readonly SegmentType[]).includes(type);\n}\n\n/**\n * The values, completed where they are placeholders, as a UTC date `Intl` formats (a calendar\n * system's is its hook's): 2000 is a leap year, so a day set with no year keeps February 29.\n */\nfunction sampleDate(format: SegmentFormat, values: SegmentValues): Date {\n const year = values.year ?? 2000;\n const month = values.month ?? 1;\n const last = utcDate(year, month + 1, 0).getUTCDate();\n return (\n format.calendar?.segmentSample(format, values) ??\n utcDate(\n year,\n month,\n Math.min(values.day ?? 1, last),\n values.hour ?? (values.dayPeriod === 1 ? 12 : 0),\n values.minute ?? 0,\n values.second ?? 0,\n )\n );\n}\n\n/**\n * The segments of a field (spec/date-field.md, \"Segments\"): its format's parts in order, each\n * editable one with its text, value, range, value text and name, the literals with their text.\n * `edit` shows the digits being typed into a segment that is not set yet (`0` of a month).\n */\nexport function dateSegments(\n format: SegmentFormat,\n values: SegmentValues,\n edit: SegmentEdit | null = null,\n): DateSegment[] {\n const sample = sampleDate(format, values);\n const texts = new Map<string, string>();\n for (const part of format.formatter.formatToParts(sample)) {\n texts.set(part.type, part.value);\n }\n const local = (text: string) =>\n [...text]\n .map((digit) => format.digits[Number(digit)] ?? digit)\n .join(\"\");\n return format.parts.map((part, index): DateSegment => {\n const { type } = part;\n const label = format.names[type] ?? null;\n if (!editable(format, type)) {\n return {\n type,\n index,\n // the zone's name at the values' time (\"EST\", \"EDT\": its hook), else the literal\n text:\n format.timeZone?.segmentText(format, type, sample) ??\n part.literal,\n editable: false,\n placeholder: false,\n value: null,\n min: null,\n max: null,\n valueText: null,\n label,\n };\n }\n const range = segmentRange(format, values, type);\n const value =\n type === \"dayPeriod\"\n ? values.dayPeriod\n : shownValue(format, values, type);\n // a placeholder shows the digits being typed, else one dash per digit\n const typing = edit?.type === type && edit.text !== \"\";\n const text =\n value === undefined\n ? typing\n ? local((edit as SegmentEdit).text)\n : SEGMENT_PLACEHOLDER.repeat(Math.max(range.digits, 2))\n : type === \"dayPeriod\"\n ? (format.dayPeriods[value] ?? \"\")\n : (texts.get(type) ?? local(String(value)));\n return {\n type,\n index,\n text,\n editable: true,\n placeholder: value === undefined && !typing,\n value: value ?? null,\n min: range.min,\n max: range.max,\n // a month's name in the sample's year (a calendar system's can depend on it)\n valueText:\n value === undefined\n ? null\n : type === \"month\"\n ? format.monthNames.format(sample)\n : text,\n label,\n };\n });\n}\n","/** Where a key moves the focus among a field's segments (spec/date-field.md, \"Keyboard\"). */\nexport type SegmentMove = \"next\" | \"previous\" | \"left\" | \"right\" | \"first\";\n\n/**\n * The focusable segments of `groups` (default: the group `segment` sits in), in their order and\n * each group's document order.\n */\nfunction focusableSegments(\n segment: HTMLElement,\n groups: readonly Element[] | undefined,\n): HTMLElement[] {\n const own = segment.closest('[role=\"group\"]');\n const scopes = groups ?? (own === null ? [] : [own]);\n return scopes\n .flatMap((group) => [\n ...group.querySelectorAll<HTMLElement>('[role=\"spinbutton\"]'),\n ])\n .filter((element) => element.tabIndex >= 0);\n}\n\nfunction center(element: HTMLElement): number {\n const rect = element.getBoundingClientRect();\n return rect.left + rect.width / 2;\n}\n\n/**\n * The segment a move reaches from `segment`: `next` and `previous` in the locale's order (the\n * document's), `left` and `right` on screen, wherever the bidirectional text placed the segments\n * (a he-IL date reads left to right in a right-to-left page), `first` the group's first.\n * `null` when there is none that way. With no layout (every box empty), `right` is `next` and\n * `left` is `previous`. `groups` makes several groups one sequence (a range field's start and end,\n * spec/date-range-field.md \"Typing and keys\"); by default the moves stay in the segment's group.\n */\nexport function segmentTarget(\n segment: HTMLElement,\n move: SegmentMove,\n groups?: readonly Element[],\n): HTMLElement | null {\n const segments = focusableSegments(segment, groups);\n const index = segments.indexOf(segment);\n if (move === \"first\") {\n return segments[0] ?? null;\n }\n const laidOut = segments.some(\n (element) => element.getBoundingClientRect().width > 0,\n );\n if (move === \"next\" || move === \"previous\" || !laidOut) {\n const step = move === \"next\" || move === \"right\" ? 1 : -1;\n return index < 0 ? null : (segments[index + step] ?? null);\n }\n const from = center(segment);\n let best: HTMLElement | null = null;\n let distance = Number.POSITIVE_INFINITY;\n for (const candidate of segments) {\n const offset = center(candidate) - from;\n if (\n candidate !== segment &&\n Math.sign(offset) === (move === \"right\" ? 1 : -1) &&\n Math.abs(offset) < distance\n ) {\n best = candidate;\n distance = Math.abs(offset);\n }\n }\n return best;\n}\n\n/**\n * Focuses the first segment when its field's label is pressed (spec/date-field.md, \"In a Field\":\n * a label names a group, which no `for` can point at). A press the consumer prevented does\n * nothing. Returns the cleanup.\n */\nexport function focusOnLabelPress(\n label: HTMLElement,\n target: () => HTMLElement | null,\n): () => void {\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented) {\n return;\n }\n target()?.focus();\n };\n label.addEventListener(\"click\", onClick);\n return () => label.removeEventListener(\"click\", onClick);\n}\n","import type { EditableSegmentType, SegmentFormat } from \"./segment-format.ts\";\nimport {\n type SegmentValues,\n segmentRange,\n setSegment,\n shownValue,\n} from \"./segment-values.ts\";\n\n/**\n * The digits typed into the focused segment so far (ASCII), so the next digit continues them\n * (`1` then `2` is month 12). A field keeps it while the segment stays focused, and drops it on\n * blur, a step or a move.\n */\nexport interface SegmentEdit {\n readonly type: EditableSegmentType;\n readonly text: string;\n}\n\nexport interface SegmentTypeResult {\n readonly values: SegmentValues;\n /** What to keep for the next key; `null` once the segment is complete. */\n readonly edit: SegmentEdit | null;\n /** The segment is complete: focus moves on to the next one. */\n readonly advance: boolean;\n}\n\nexport interface SegmentEraseResult {\n readonly values: SegmentValues;\n readonly edit: SegmentEdit | null;\n /** The segment was already empty: focus moves back to the previous one. */\n readonly retreat: boolean;\n}\n\n// ASCII, Arabic-Indic and Extended Arabic-Indic digits read in every locale (as NumberField's)\nconst SHARED_DIGITS = [\"0123456789\", \"٠١٢٣٤٥٦٧٨٩\", \"۰۱۲۳۴۵۶۷۸۹\"];\n\n/** The digit a character is in the locale's numbering system or a shared one; `null` for none. */\nexport function segmentDigit(\n format: SegmentFormat,\n character: string,\n): number | null {\n for (const digits of SHARED_DIGITS) {\n const index = digits.indexOf(character);\n if (index >= 0 && character.length === 1) {\n return index;\n }\n }\n const index = format.digits.indexOf(character);\n return index >= 0 ? index : null;\n}\n\n/**\n * Types one character into a segment (spec/date-field.md, \"Typing\"). A digit continues the\n * segment's typed digits, or starts again when the number would leave the range; the segment is\n * set once the number is in range (`0` alone in a month waits for the next digit), and complete\n * (`advance`) when no further digit could fit: `4` in a month, `12`, or a year's fourth digit. A\n * day period takes a letter: the first letter of its AM or PM text. Anything else is refused\n * (`null`).\n */\nexport function typeSegment(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n character: string,\n edit: SegmentEdit | null,\n seed: SegmentValues = {},\n): SegmentTypeResult | null {\n // a letter: the first letters of a day period's text, or of an era's name\n const names = (\n { dayPeriod: format.dayPeriods, era: format.eras } as Partial<\n Record<EditableSegmentType, readonly string[]>\n >\n )[type];\n if (names) {\n const key = character.toLocaleLowerCase(format.locale);\n const index = names.findIndex(\n (text) =>\n text !== \"\" &&\n text.toLocaleLowerCase(format.locale).startsWith(key),\n );\n if (index < 0 || key.trim() === \"\") {\n return null;\n }\n return {\n values: setSegment(format, values, type, index, seed),\n edit: null,\n advance: true,\n };\n }\n const digit = segmentDigit(format, character);\n if (digit === null) {\n return null;\n }\n const range = segmentRange(format, values, type);\n let text = `${edit?.type === type ? edit.text : \"\"}${digit}`;\n if (text.length > range.digits || Number(text) > range.max) {\n text = String(digit);\n }\n const number = Number(text);\n const next =\n number >= range.min && number <= range.max\n ? setSegment(format, values, type, number, seed)\n : setSegment(format, values, type, undefined);\n const advance =\n text.length >= range.digits || Number(`${text}0`) > range.max;\n return {\n values: next,\n edit: advance ? null : { type, text },\n advance: advance && next[type] !== undefined,\n };\n}\n\n/**\n * Backspace (or Delete) in a segment: removes its last digit (a day period is cleared at once);\n * a segment left with no digit is a placeholder. An empty segment reports `retreat`.\n */\nexport function eraseSegment(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n edit: SegmentEdit | null,\n): SegmentEraseResult {\n if (type === \"dayPeriod\" || type === \"era\") {\n return values[type] === undefined\n ? { values, edit: null, retreat: true }\n : {\n values: setSegment(format, values, type, undefined),\n edit: null,\n retreat: false,\n };\n }\n const shown = shownValue(format, values, type);\n const current =\n edit?.type === type\n ? edit.text\n : shown === undefined\n ? \"\"\n : String(shown);\n if (current === \"\") {\n return { values, edit: null, retreat: true };\n }\n const text = current.slice(0, -1);\n if (text === \"\") {\n return {\n values: setSegment(format, values, type, undefined),\n edit: null,\n retreat: false,\n };\n }\n const range = segmentRange(format, values, type);\n const number = Number(text);\n return {\n values: setSegment(\n format,\n values,\n type,\n number >= range.min && number <= range.max ? number : undefined,\n ),\n edit: { type, text },\n retreat: false,\n };\n}\n","import type { SegmentMove } from \"./segment-focus.ts\";\nimport type { EditableSegmentType, SegmentFormat } from \"./segment-format.ts\";\nimport { eraseSegment, type SegmentEdit } from \"./segment-typing.ts\";\nimport {\n SEGMENT_PAGE_STEPS,\n type SegmentValues,\n segmentToEdge,\n stepSegment,\n} from \"./segment-values.ts\";\n\nexport interface SegmentKeyResult {\n /** `step` (the arrows, Page Up and Down, Home, End), `erase` (Backspace, Delete) or `move`. */\n readonly kind: \"step\" | \"erase\" | \"move\";\n readonly values: SegmentValues;\n readonly edit: SegmentEdit | null;\n /** Where the focus goes, if anywhere. */\n readonly move: SegmentMove | null;\n}\n\n/**\n * The effect of a key on a focused segment (spec/date-field.md, \"Keyboard\", the APG spinbutton):\n * ArrowUp / ArrowDown step by one, Page Up / Page Down by the segment's page step, both wrapping\n * within the segment; Home / End go to its minimum / maximum; ArrowLeft / ArrowRight move to the\n * segment on that side; Backspace and Delete erase a digit, or move back from an empty segment.\n * `null` for any other key. A read-only field only moves.\n */\nexport function segmentKeyDown(\n format: SegmentFormat,\n values: SegmentValues,\n type: EditableSegmentType,\n key: string,\n edit: SegmentEdit | null,\n options: {\n readonly seed?: SegmentValues;\n readonly readOnly?: boolean;\n } = {},\n): SegmentKeyResult | null {\n const { seed = {}, readOnly = false } = options;\n if (key === \"ArrowLeft\" || key === \"ArrowRight\") {\n return {\n kind: \"move\",\n values,\n edit: null,\n move: key === \"ArrowLeft\" ? \"left\" : \"right\",\n };\n }\n if (readOnly) {\n return null;\n }\n const step = (amount: number): SegmentKeyResult => ({\n kind: \"step\",\n values: stepSegment(format, values, type, amount, seed),\n edit: null,\n move: null,\n });\n const page = SEGMENT_PAGE_STEPS[type];\n switch (key) {\n case \"ArrowUp\":\n return step(1);\n case \"ArrowDown\":\n return step(-1);\n case \"PageUp\":\n return step(page);\n case \"PageDown\":\n return step(-page);\n case \"Home\":\n case \"End\":\n return {\n kind: \"step\",\n values: segmentToEdge(\n format,\n values,\n type,\n key === \"Home\" ? \"min\" : \"max\",\n seed,\n ),\n edit: null,\n move: null,\n };\n case \"Backspace\":\n case \"Delete\": {\n const result = eraseSegment(format, values, type, edit);\n return {\n kind: \"erase\",\n values: result.values,\n edit: result.edit,\n move: result.retreat ? \"previous\" : null,\n };\n }\n default:\n return null;\n }\n}\n"],"mappings":";AAuGA,MAAM,2BAA2B,IAAI,IAAY;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;;AAGD,SAAgB,QACZ,MACA,OACA,KACA,OAAO,GACP,SAAS,GACT,SAAS,GACL;CACJ,MAAM,uBAAO,IAAI,KAAK,CAAC;CACvB,KAAK,eAAe,MAAM,QAAQ,GAAG,GAAG;CACxC,KAAK,YAAY,MAAM,QAAQ,QAAQ,CAAC;CACxC,OAAO;AACX;AAEA,SAAS,cACL,MACA,aACA,WAC0B;CAC1B,MAAM,UAAsC,EAAE,UAAU,MAAM;CAC9D,IAAI,SAAS,QAAQ;EACjB,QAAQ,OAAO;EACf,QAAQ,QAAQ;EAChB,QAAQ,MAAM;CAClB;CACA,IAAI,gBAAgB,OAAO;EACvB,QAAQ,OAAO;EACf,IAAI,gBAAgB,QAChB,QAAQ,SAAS;EAErB,IAAI,gBAAgB,UAChB,QAAQ,SAA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,QAAQ,IAAI;EACtD,MAAM;EACN,MAAM;CACV;CACA,MAAM,OAAO,mBAAmB;CAChC,QAAQ,KAAR;EACI,KAAK,WACD,OAAO,KAAK,CAAC;EACjB,KAAK,aACD,OAAO,KAAK,EAAE;EAClB,KAAK,UACD,OAAO,KAAK,IAAI;EACpB,KAAK,YACD,OAAO,KAAK,CAAC,IAAI;EACrB,KAAK;EACL,KAAK,OACD,OAAO;GACH,MAAM;GACN,QAAQ,cACJ,QACA,QACA,MACA,QAAQ,SAAS,QAAQ,OACzB,IACJ;GACA,MAAM;GACN,MAAM;EACV;EACJ,KAAK;EACL,KAAK,UAAU;GACX,MAAM,SAAS,aAAa,QAAQ,QAAQ,MAAM,IAAI;GACtD,OAAO;IACH,MAAM;IACN,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,MAAM,OAAO,UAAU,aAAa;GACxC;EACJ;EACA,SACI,OAAO;CACf;AACJ"}
@@ -0,0 +1,3 @@
1
+ import { C as SegmentFormatOptions, D as SegmentType, E as SegmentPart, O as segmentFormat, S as SegmentFormat, T as SegmentKind, _ as setSegment, b as EditableSegmentType, c as SegmentValues, d as segmentRange, f as segmentToEdge, g as segmentsToTime, h as segmentsToDateTime, l as displayHour, m as segmentsToDate, o as SEGMENT_PAGE_STEPS, p as segmentValuesOf, s as SegmentRange, u as isSegmentsComplete, v as shownValue, w as SegmentGranularity, x as HourCycle, y as stepSegment } from "./calendar-system-B5U5HcPQ.js";
2
+ import { a as segmentTarget, c as dateSegments, d as SegmentTypeResult, f as eraseSegment, i as focusOnLabelPress, l as SegmentEdit, m as typeSegment, n as segmentKeyDown, o as DateSegment, p as segmentDigit, r as SegmentMove, s as SEGMENT_PLACEHOLDER, t as SegmentKeyResult, u as SegmentEraseResult } from "./index-DGKhEvNr.js";
3
+ export { type DateSegment, type EditableSegmentType, type HourCycle, SEGMENT_PAGE_STEPS, SEGMENT_PLACEHOLDER, type SegmentEdit, type SegmentEraseResult, type SegmentFormat, type SegmentFormatOptions, type SegmentGranularity, type SegmentKeyResult, type SegmentKind, type SegmentMove, type SegmentPart, type SegmentRange, type SegmentType, type SegmentTypeResult, type SegmentValues, dateSegments, displayHour, eraseSegment, focusOnLabelPress, isSegmentsComplete, segmentDigit, segmentFormat, segmentKeyDown, segmentRange, segmentTarget, segmentToEdge, segmentValuesOf, segmentsToDate, segmentsToDateTime, segmentsToTime, setSegment, shownValue, stepSegment, typeSegment };
@@ -0,0 +1 @@
1
+ export { l as SEGMENT_PAGE_STEPS, s as SEGMENT_PLACEHOLDER, c as dateSegments, u as displayHour, n as eraseSegment, a as focusOnLabelPress, d as isSegmentsComplete, r as segmentDigit, x as segmentFormat, t as segmentKeyDown, f as segmentRange, o as segmentTarget, p as segmentToEdge, m as segmentValuesOf, h as segmentsToDate, g as segmentsToDateTime, _ as segmentsToTime, v as setSegment, y as shownValue, b as stepSegment, i as typeSegment } from "./segments-eRu5G_Bd.js";
@@ -0,0 +1,287 @@
1
+ import { n as stepIndex, t as edgeIndex } from "./list-navigation-CbWv4DK5.js";
2
+ // src/selection/list-keys.ts
3
+ /** Where a plain focus move lands, or `null` for a key that moves nothing. */
4
+ function moveTarget(key, index, model, options) {
5
+ const vertical = options.orientation === "vertical";
6
+ const next = vertical ? "ArrowDown" : options.rtl ? "ArrowLeft" : "ArrowRight";
7
+ const previous = vertical ? "ArrowUp" : options.rtl ? "ArrowRight" : "ArrowLeft";
8
+ const count = model.size;
9
+ switch (key) {
10
+ case next:
11
+ case previous: return stepIndex(count, index, key === next ? 1 : -1, { loop: options.loop });
12
+ case "Home": return edgeIndex(count, "first");
13
+ case "End": return edgeIndex(count, "last");
14
+ case "PageDown":
15
+ case "PageUp": {
16
+ const delta = key === "PageDown" ? 1 : -1;
17
+ if (options.page !== void 0 && index !== -1) return options.page(index, delta);
18
+ return edgeIndex(count, delta === 1 ? "last" : "first");
19
+ }
20
+ default: return null;
21
+ }
22
+ }
23
+ /**
24
+ * What a key does in a listbox (spec/listbox.md, "Keyboard"), from the focused option `index`:
25
+ * `null` for a key it does not handle (Tab, Alt, the other orientation's arrows, a character no
26
+ * option starts with). A focus move (the arrows, Home, End, PageUp, PageDown, the typeahead)
27
+ * selects the option it lands on in the `replace` model, unless Ctrl (or Meta) is held; Shift with
28
+ * an arrow toggles the option it lands on (multiple); Space and Enter select (single), toggle
29
+ * (`toggle`) or replace (`replace`), Ctrl + Space toggles, Shift + Space selects the range from the
30
+ * anchor; Ctrl + Shift + Home / End the range from the focused option to the end, which it focuses;
31
+ * Ctrl + A selects all (multiple). Disabled options take focus; `applySelection` keeps them out.
32
+ */
33
+ function listKeyTarget(event, model, index, options) {
34
+ if (event.altKey || model.size === 0) return null;
35
+ const ctrl = event.ctrlKey || event.metaKey;
36
+ const multiple = options.mode === "multiple";
37
+ const focusedKey = model.nodes[index]?.key;
38
+ const key = event.key;
39
+ if (key === " " || key === "Enter") {
40
+ if (focusedKey === void 0 || options.mode === "none") return null;
41
+ if (multiple && event.shiftKey) return {
42
+ index,
43
+ selection: {
44
+ type: "range",
45
+ key: focusedKey
46
+ }
47
+ };
48
+ return {
49
+ index,
50
+ selection: {
51
+ type: multiple && (options.behavior === "toggle" || ctrl) ? "toggle" : "replace",
52
+ key: focusedKey
53
+ }
54
+ };
55
+ }
56
+ if (ctrl && !event.shiftKey && (key === "a" || key === "A")) return multiple ? {
57
+ index,
58
+ selection: { type: "all" }
59
+ } : null;
60
+ const target = moveTarget(key, index, model, options);
61
+ if (target === null || target === -1) {
62
+ if (key.length === 1 && !ctrl && options.typeahead !== void 0) {
63
+ const found = options.typeahead(key, index);
64
+ if (found === -1) return null;
65
+ return {
66
+ index: found,
67
+ selection: followFocus(found, model, options)
68
+ };
69
+ }
70
+ return null;
71
+ }
72
+ const targetKey = model.nodes[target]?.key;
73
+ if (targetKey === void 0) return null;
74
+ if (multiple && ctrl && event.shiftKey && (key === "Home" || key === "End")) return {
75
+ index: target,
76
+ selection: focusedKey === void 0 ? {
77
+ type: "range",
78
+ key: targetKey
79
+ } : {
80
+ type: "range",
81
+ key: targetKey,
82
+ from: focusedKey
83
+ }
84
+ };
85
+ if (ctrl && event.shiftKey && (key === "Home" || key === "End")) return {
86
+ index: target,
87
+ selection: followFocus(target, model, options)
88
+ };
89
+ if (event.shiftKey && multiple && key !== "Home" && key !== "End") return target === index ? {
90
+ index,
91
+ selection: null
92
+ } : {
93
+ index: target,
94
+ selection: {
95
+ type: "toggle",
96
+ key: targetKey
97
+ }
98
+ };
99
+ if (ctrl) return {
100
+ index: target,
101
+ selection: null
102
+ };
103
+ return {
104
+ index: target,
105
+ selection: followFocus(target, model, options)
106
+ };
107
+ }
108
+ /** The `replace` model's selection that follows a plain focus move, or none. */
109
+ function followFocus(index, model, options) {
110
+ const key = model.nodes[index]?.key;
111
+ if (key === void 0 || options.behavior !== "replace" || options.mode === "none") return null;
112
+ return {
113
+ type: "replace",
114
+ key
115
+ };
116
+ }
117
+ /** What a press on an option does (spec/listbox.md, "Pointer"), with its modifiers. */
118
+ function listPressSelection(key, event, options) {
119
+ if (options.mode === "none") return null;
120
+ if (options.mode === "single") return {
121
+ type: "replace",
122
+ key
123
+ };
124
+ if (event.shiftKey) return {
125
+ type: "range",
126
+ key
127
+ };
128
+ if (options.behavior === "toggle" || event.ctrlKey || event.metaKey) return {
129
+ type: "toggle",
130
+ key
131
+ };
132
+ return {
133
+ type: "replace",
134
+ key
135
+ };
136
+ }
137
+ // src/selection/list-model.ts
138
+ /** The list model of `nodes`, in their order; a repeated key keeps its first place. */
139
+ function createListModel(nodes) {
140
+ const indexes = /* @__PURE__ */ new Map();
141
+ const kept = [];
142
+ for (const node of nodes) if (!indexes.has(node.key)) {
143
+ indexes.set(node.key, kept.length);
144
+ kept.push(node);
145
+ }
146
+ return {
147
+ nodes: kept,
148
+ size: kept.length,
149
+ indexOf: (key) => key === null ? -1 : indexes.get(key) ?? -1,
150
+ isDisabled: (key) => {
151
+ const index = indexes.get(key);
152
+ return index !== void 0 && kept[index]?.disabled === true;
153
+ },
154
+ enabledKeys: kept.filter((node) => node.disabled !== true).map((node) => node.key),
155
+ labels: kept.map((node) => node.textValue)
156
+ };
157
+ }
158
+ // src/selection/page-target.ts
159
+ /**
160
+ * The option a page away from `current` (spec/listbox.md, "Keyboard": PageDown `1`, PageUp
161
+ * `-1`): the farthest option whose far edge is within the scroll container's visible size from
162
+ * the current option's near edge, along the orientation; the last (first) option when the list
163
+ * does not scroll. Measured on the elements (their bounding boxes), so it follows any layout.
164
+ */
165
+ function pageTarget(elements, current, delta, container, orientation = "vertical") {
166
+ const last = elements.length - 1;
167
+ const edge = delta === 1 ? last : 0;
168
+ const vertical = orientation === "vertical";
169
+ const visible = vertical ? container.clientHeight : container.clientWidth;
170
+ const total = vertical ? container.scrollHeight : container.scrollWidth;
171
+ const from = elements[current];
172
+ if (from === void 0 || total <= visible || visible === 0) return edge;
173
+ const start = from.getBoundingClientRect();
174
+ const origin = vertical ? delta === 1 ? start.top : start.bottom : delta === 1 ? start.left : start.right;
175
+ let target = current;
176
+ for (let index = current + delta; index >= 0 && index <= last; index += delta) {
177
+ const box = elements[index]?.getBoundingClientRect();
178
+ if (box === void 0) break;
179
+ const far = vertical ? delta === 1 ? box.bottom : box.top : delta === 1 ? box.right : box.left;
180
+ if (Math.abs(far - origin) > visible) break;
181
+ target = index;
182
+ }
183
+ return target === current ? Math.min(Math.max(current + delta, 0), last) : target;
184
+ }
185
+ // src/selection/row-target.ts
186
+ /**
187
+ * The option in the row above (`delta` -1) or below (`delta` 1) the option at `index`, in a list
188
+ * laid out in wrapping rows (spec/color-swatch-picker.md, "Keyboard"): measured on the rendered
189
+ * boxes, the nearest row on that side, and in it the option whose horizontal center is the closest
190
+ * to the current one's (the first of two as close). `index` itself when there is no row on that
191
+ * side (the arrows stop at the first and last rows), or -1 when `index` names no option.
192
+ */
193
+ function rowTarget(elements, index, delta) {
194
+ const current = elements[index];
195
+ if (current === void 0) return -1;
196
+ const from = current.getBoundingClientRect();
197
+ const center = (from.left + from.right) / 2;
198
+ const boxes = elements.map((element) => element.getBoundingClientRect());
199
+ const middle = (from.top + from.bottom) / 2;
200
+ let rowTop = null;
201
+ for (const box of boxes) {
202
+ if (!(delta === 1 ? box.top >= middle : box.bottom <= middle)) continue;
203
+ if (rowTop === null || (delta === 1 ? box.top < rowTop : box.top > rowTop)) rowTop = box.top;
204
+ }
205
+ if (rowTop === null) return index;
206
+ let target = index;
207
+ let distance = Number.POSITIVE_INFINITY;
208
+ boxes.forEach((box, candidate) => {
209
+ if (Math.abs(box.top - rowTop) >= (box.bottom - box.top) / 2) return;
210
+ const away = Math.abs((box.left + box.right) / 2 - center);
211
+ if (away < distance) {
212
+ distance = away;
213
+ target = candidate;
214
+ }
215
+ });
216
+ return target;
217
+ }
218
+ // src/selection/selection.ts
219
+ /** `keys` in the model's order; keys the model does not know stay at the end, in their order. */
220
+ function inModelOrder(model, keys) {
221
+ const unique = [...new Set(keys)];
222
+ return [...unique.filter((key) => model.indexOf(key) !== -1).sort((a, b) => model.indexOf(a) - model.indexOf(b)), ...unique.filter((key) => model.indexOf(key) === -1)];
223
+ }
224
+ /** The enabled keys from `a` to `b` (either way round), in order. */
225
+ function rangeKeys(model, a, b) {
226
+ const from = model.indexOf(a);
227
+ const to = model.indexOf(b);
228
+ if (from === -1 || to === -1) return [];
229
+ return model.nodes.slice(Math.min(from, to), Math.max(from, to) + 1).filter((node) => node.disabled !== true).map((node) => node.key);
230
+ }
231
+ /**
232
+ * The selection after `change` (spec/listbox.md, "Keyboard" and "Pointer"), or `state` itself
233
+ * when nothing changes. A disabled option is never selected: a change aimed at one does nothing,
234
+ * a range and `all` pass over them (a disabled option already selected, by a controlled value,
235
+ * stays). `single`: every change but `all` selects its option alone (the selected one stays
236
+ * selected). `multiple`: `toggle` flips an option and makes it the anchor; `replace` makes it the
237
+ * only one and the anchor; a `range` adds to the selection with `toggle`, replaces it with
238
+ * `replace`, and moves the anchor only when it starts `from` a given key; `all` selects every
239
+ * enabled option, or unselects them when they all are. `none`: nothing changes.
240
+ */
241
+ function applySelection(model, state, change, options) {
242
+ const { mode, behavior } = options;
243
+ if (mode === "none") return state;
244
+ if (change.type !== "all" && model.isDisabled(change.key)) return state;
245
+ if (mode === "single") {
246
+ if (change.type === "all") return state;
247
+ if (state.selected.length === 1 && state.selected[0] === change.key) return state;
248
+ return {
249
+ selected: [change.key],
250
+ anchor: change.key
251
+ };
252
+ }
253
+ switch (change.type) {
254
+ case "toggle": return {
255
+ selected: state.selected.includes(change.key) ? state.selected.filter((key) => key !== change.key) : inModelOrder(model, [...state.selected, change.key]),
256
+ anchor: change.key
257
+ };
258
+ case "replace": return {
259
+ selected: [change.key],
260
+ anchor: change.key
261
+ };
262
+ case "range": {
263
+ const anchor = state.anchor !== null && model.indexOf(state.anchor) !== -1 ? state.anchor : null;
264
+ const keys = rangeKeys(model, change.from ?? anchor ?? change.key, change.key);
265
+ return {
266
+ selected: inModelOrder(model, [...behavior === "replace" ? state.selected.filter((key) => model.isDisabled(key)) : state.selected, ...keys]),
267
+ anchor: change.from !== void 0 ? change.from : anchor ?? change.key
268
+ };
269
+ }
270
+ case "all": {
271
+ const enabled = model.enabledKeys;
272
+ const all = enabled.every((key) => state.selected.includes(key));
273
+ const others = state.selected.filter((key) => !enabled.includes(key));
274
+ return {
275
+ selected: all ? others : inModelOrder(model, [...others, ...enabled]),
276
+ anchor: state.anchor
277
+ };
278
+ }
279
+ }
280
+ }
281
+ /** Whether two selections hold the same keys in the same order. */
282
+ function sameSelection(a, b) {
283
+ return a.length === b.length && a.every((key, index) => b[index] === key);
284
+ }
285
+ export { pageTarget as a, listPressSelection as c, rowTarget as i, inModelOrder as n, createListModel as o, sameSelection as r, listKeyTarget as s, applySelection as t };
286
+
287
+ //# sourceMappingURL=selection-Cor67w_V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection-Cor67w_V.js","names":[],"sources":["../src/selection/list-keys.ts","../src/selection/list-model.ts","../src/selection/page-target.ts","../src/selection/row-target.ts","../src/selection/selection.ts"],"sourcesContent":["import { edgeIndex, stepIndex } from \"../collection/list-navigation.ts\";\nimport type { ListModel } from \"./list-model.ts\";\nimport type {\n SelectionBehavior,\n SelectionChange,\n SelectionMode,\n} from \"./selection.ts\";\n\n/** The keys of a listbox's key event that matter (a `KeyboardEvent`, or a framework's). */\nexport interface ListKeyEvent {\n key: string;\n shiftKey: boolean;\n ctrlKey: boolean;\n metaKey: boolean;\n altKey: boolean;\n}\n\nexport interface ListKeyOptions {\n orientation: \"horizontal\" | \"vertical\";\n rtl: boolean;\n /** Wrap from the last option to the first, and back (`loopFocus`). */\n loop: boolean;\n mode: SelectionMode;\n behavior: SelectionBehavior;\n /** The option a page away from `index` (PageDown `1`, PageUp `-1`); default: the last / first. */\n page?: (index: number, delta: 1 | -1) => number;\n /** The option the typeahead moves to for a printable character, or -1. */\n typeahead?: (character: string, index: number) => number;\n}\n\n/** What a key does: the option it focuses (`index`, maybe the focused one) and its selection change. */\nexport interface ListKeyResult {\n index: number;\n selection: SelectionChange | null;\n}\n\n/** Where a plain focus move lands, or `null` for a key that moves nothing. */\nfunction moveTarget(\n key: string,\n index: number,\n model: ListModel,\n options: ListKeyOptions,\n): number | null {\n const vertical = options.orientation === \"vertical\";\n const next = vertical\n ? \"ArrowDown\"\n : options.rtl\n ? \"ArrowLeft\"\n : \"ArrowRight\";\n const previous = vertical\n ? \"ArrowUp\"\n : options.rtl\n ? \"ArrowRight\"\n : \"ArrowLeft\";\n const count = model.size;\n switch (key) {\n case next:\n case previous:\n return stepIndex(count, index, key === next ? 1 : -1, {\n loop: options.loop,\n });\n case \"Home\":\n return edgeIndex(count, \"first\");\n case \"End\":\n return edgeIndex(count, \"last\");\n case \"PageDown\":\n case \"PageUp\": {\n const delta = key === \"PageDown\" ? 1 : -1;\n if (options.page !== undefined && index !== -1) {\n return options.page(index, delta);\n }\n return edgeIndex(count, delta === 1 ? \"last\" : \"first\");\n }\n default:\n return null;\n }\n}\n\n/**\n * What a key does in a listbox (spec/listbox.md, \"Keyboard\"), from the focused option `index`:\n * `null` for a key it does not handle (Tab, Alt, the other orientation's arrows, a character no\n * option starts with). A focus move (the arrows, Home, End, PageUp, PageDown, the typeahead)\n * selects the option it lands on in the `replace` model, unless Ctrl (or Meta) is held; Shift with\n * an arrow toggles the option it lands on (multiple); Space and Enter select (single), toggle\n * (`toggle`) or replace (`replace`), Ctrl + Space toggles, Shift + Space selects the range from the\n * anchor; Ctrl + Shift + Home / End the range from the focused option to the end, which it focuses;\n * Ctrl + A selects all (multiple). Disabled options take focus; `applySelection` keeps them out.\n */\nexport function listKeyTarget(\n event: ListKeyEvent,\n model: ListModel,\n index: number,\n options: ListKeyOptions,\n): ListKeyResult | null {\n if (event.altKey || model.size === 0) {\n return null;\n }\n const ctrl = event.ctrlKey || event.metaKey;\n const multiple = options.mode === \"multiple\";\n const focusedKey = model.nodes[index]?.key;\n const key = event.key;\n\n if (key === \" \" || key === \"Enter\") {\n if (focusedKey === undefined || options.mode === \"none\") {\n return null;\n }\n if (multiple && event.shiftKey) {\n return { index, selection: { type: \"range\", key: focusedKey } };\n }\n const toggles = multiple && (options.behavior === \"toggle\" || ctrl);\n return {\n index,\n selection: {\n type: toggles ? \"toggle\" : \"replace\",\n key: focusedKey,\n },\n };\n }\n if (ctrl && !event.shiftKey && (key === \"a\" || key === \"A\")) {\n return multiple ? { index, selection: { type: \"all\" } } : null;\n }\n const target = moveTarget(key, index, model, options);\n if (target === null || target === -1) {\n if (key.length === 1 && !ctrl && options.typeahead !== undefined) {\n const found = options.typeahead(key, index);\n if (found === -1) {\n return null;\n }\n return {\n index: found,\n selection: followFocus(found, model, options),\n };\n }\n return null;\n }\n const targetKey = model.nodes[target]?.key;\n if (targetKey === undefined) {\n return null;\n }\n if (\n multiple &&\n ctrl &&\n event.shiftKey &&\n (key === \"Home\" || key === \"End\")\n ) {\n return {\n index: target,\n selection:\n focusedKey === undefined\n ? { type: \"range\", key: targetKey }\n : { type: \"range\", key: targetKey, from: focusedKey },\n };\n }\n if (ctrl && event.shiftKey && (key === \"Home\" || key === \"End\")) {\n // single (or none): as Home / End\n return {\n index: target,\n selection: followFocus(target, model, options),\n };\n }\n if (event.shiftKey && multiple && key !== \"Home\" && key !== \"End\") {\n // the APG: Shift + an arrow moves to the next option and toggles it\n return target === index\n ? { index, selection: null }\n : { index: target, selection: { type: \"toggle\", key: targetKey } };\n }\n if (ctrl) {\n return { index: target, selection: null };\n }\n return { index: target, selection: followFocus(target, model, options) };\n}\n\n/** The `replace` model's selection that follows a plain focus move, or none. */\nfunction followFocus(\n index: number,\n model: ListModel,\n options: ListKeyOptions,\n): SelectionChange | null {\n const key = model.nodes[index]?.key;\n if (\n key === undefined ||\n options.behavior !== \"replace\" ||\n options.mode === \"none\"\n ) {\n return null;\n }\n return { type: \"replace\", key };\n}\n\n/** What a press on an option does (spec/listbox.md, \"Pointer\"), with its modifiers. */\nexport function listPressSelection(\n key: string,\n event: { shiftKey: boolean; ctrlKey: boolean; metaKey: boolean },\n options: { mode: SelectionMode; behavior: SelectionBehavior },\n): SelectionChange | null {\n if (options.mode === \"none\") {\n return null;\n }\n if (options.mode === \"single\") {\n return { type: \"replace\", key };\n }\n if (event.shiftKey) {\n return { type: \"range\", key };\n }\n if (options.behavior === \"toggle\" || event.ctrlKey || event.metaKey) {\n return { type: \"toggle\", key };\n }\n return { type: \"replace\", key };\n}\n","/** One option of a list collection (spec/listbox.md, \"The collections mechanism\"). */\nexport interface ListNode {\n /** The option's key: its value. */\n key: string;\n /** The text typeahead matches. */\n textValue: string;\n /** Takes focus, never the selection. */\n disabled?: boolean;\n}\n\n/**\n * The options of a list in order, with their indexes (spec/listbox.md): what the selection rules\n * and the key map read. Built from what a framework registered, in document order.\n */\nexport interface ListModel {\n readonly nodes: readonly ListNode[];\n readonly size: number;\n /** The index of `key`, or -1. */\n indexOf(key: string | null): number;\n /** Whether `key` names a disabled option (an unknown key is not disabled). */\n isDisabled(key: string): boolean;\n /** The keys of the enabled options, in order. */\n readonly enabledKeys: readonly string[];\n /** The labels, in order (the typeahead's input). */\n readonly labels: readonly string[];\n}\n\n/** The list model of `nodes`, in their order; a repeated key keeps its first place. */\nexport function createListModel(nodes: readonly ListNode[]): ListModel {\n const indexes = new Map<string, number>();\n const kept: ListNode[] = [];\n for (const node of nodes) {\n if (!indexes.has(node.key)) {\n indexes.set(node.key, kept.length);\n kept.push(node);\n }\n }\n return {\n nodes: kept,\n size: kept.length,\n indexOf: (key) => (key === null ? -1 : (indexes.get(key) ?? -1)),\n isDisabled: (key) => {\n const index = indexes.get(key);\n return index !== undefined && kept[index]?.disabled === true;\n },\n enabledKeys: kept\n .filter((node) => node.disabled !== true)\n .map((node) => node.key),\n labels: kept.map((node) => node.textValue),\n };\n}\n","/**\n * The option a page away from `current` (spec/listbox.md, \"Keyboard\": PageDown `1`, PageUp\n * `-1`): the farthest option whose far edge is within the scroll container's visible size from\n * the current option's near edge, along the orientation; the last (first) option when the list\n * does not scroll. Measured on the elements (their bounding boxes), so it follows any layout.\n */\nexport function pageTarget(\n elements: readonly HTMLElement[],\n current: number,\n delta: 1 | -1,\n container: HTMLElement,\n orientation: \"horizontal\" | \"vertical\" = \"vertical\",\n): number {\n const last = elements.length - 1;\n const edge = delta === 1 ? last : 0;\n const vertical = orientation === \"vertical\";\n const visible = vertical ? container.clientHeight : container.clientWidth;\n const total = vertical ? container.scrollHeight : container.scrollWidth;\n const from = elements[current];\n if (from === undefined || total <= visible || visible === 0) {\n return edge;\n }\n const start = from.getBoundingClientRect();\n const origin = vertical\n ? delta === 1\n ? start.top\n : start.bottom\n : delta === 1\n ? start.left\n : start.right;\n let target = current;\n for (\n let index = current + delta;\n index >= 0 && index <= last;\n index += delta\n ) {\n const box = elements[index]?.getBoundingClientRect();\n if (box === undefined) {\n break;\n }\n const far = vertical\n ? delta === 1\n ? box.bottom\n : box.top\n : delta === 1\n ? box.right\n : box.left;\n if (Math.abs(far - origin) > visible) {\n break;\n }\n target = index;\n }\n return target === current\n ? Math.min(Math.max(current + delta, 0), last)\n : target;\n}\n","/**\n * The option in the row above (`delta` -1) or below (`delta` 1) the option at `index`, in a list\n * laid out in wrapping rows (spec/color-swatch-picker.md, \"Keyboard\"): measured on the rendered\n * boxes, the nearest row on that side, and in it the option whose horizontal center is the closest\n * to the current one's (the first of two as close). `index` itself when there is no row on that\n * side (the arrows stop at the first and last rows), or -1 when `index` names no option.\n */\nexport function rowTarget(\n elements: readonly Element[],\n index: number,\n delta: 1 | -1,\n): number {\n const current = elements[index];\n if (current === undefined) {\n return -1;\n }\n const from = current.getBoundingClientRect();\n const center = (from.left + from.right) / 2;\n const boxes = elements.map((element) => element.getBoundingClientRect());\n // a box is in another row when it starts below the current one's middle (or ends above it)\n const middle = (from.top + from.bottom) / 2;\n let rowTop: number | null = null;\n for (const box of boxes) {\n const beyond = delta === 1 ? box.top >= middle : box.bottom <= middle;\n if (!beyond) {\n continue;\n }\n if (\n rowTop === null ||\n (delta === 1 ? box.top < rowTop : box.top > rowTop)\n ) {\n rowTop = box.top;\n }\n }\n if (rowTop === null) {\n return index;\n }\n let target = index;\n let distance = Number.POSITIVE_INFINITY;\n boxes.forEach((box, candidate) => {\n if (Math.abs(box.top - rowTop) >= (box.bottom - box.top) / 2) {\n return;\n }\n const away = Math.abs((box.left + box.right) / 2 - center);\n if (away < distance) {\n distance = away;\n target = candidate;\n }\n });\n return target;\n}\n","import type { ListModel } from \"./list-model.ts\";\n\n/** How many options a list selects (spec/listbox.md, \"API\"). */\nexport type SelectionMode = \"none\" | \"single\" | \"multiple\";\n\n/**\n * The APG's two multiple selection models (spec/listbox.md, \"Keyboard\"): `toggle`, the\n * recommended one (a move never selects, Space toggles); `replace`, the alternative one (the\n * selection follows the focus, Ctrl moves without selecting).\n */\nexport type SelectionBehavior = \"toggle\" | \"replace\";\n\n/** A list's selection: the selected keys, in the model's order, and the range anchor. */\nexport interface SelectionState {\n selected: readonly string[];\n /** The option the last toggle or replace selected: where a range starts. */\n anchor: string | null;\n}\n\n/**\n * A change of the selection: `toggle` one option, `replace` the selection with one option, select\n * the `range` from the anchor (or `from`) to `key`, or select `all` (none, when every enabled\n * option already is).\n */\nexport type SelectionChange =\n | { type: \"toggle\"; key: string }\n | { type: \"replace\"; key: string }\n | { type: \"range\"; key: string; from?: string }\n | { type: \"all\" };\n\nexport interface SelectionOptions {\n mode: SelectionMode;\n behavior: SelectionBehavior;\n}\n\n/** `keys` in the model's order; keys the model does not know stay at the end, in their order. */\nexport function inModelOrder(\n model: ListModel,\n keys: Iterable<string>,\n): string[] {\n const unique = [...new Set(keys)];\n const known = unique\n .filter((key) => model.indexOf(key) !== -1)\n .sort((a, b) => model.indexOf(a) - model.indexOf(b));\n return [...known, ...unique.filter((key) => model.indexOf(key) === -1)];\n}\n\n/** The enabled keys from `a` to `b` (either way round), in order. */\nfunction rangeKeys(model: ListModel, a: string, b: string): string[] {\n const from = model.indexOf(a);\n const to = model.indexOf(b);\n if (from === -1 || to === -1) {\n return [];\n }\n return model.nodes\n .slice(Math.min(from, to), Math.max(from, to) + 1)\n .filter((node) => node.disabled !== true)\n .map((node) => node.key);\n}\n\n/**\n * The selection after `change` (spec/listbox.md, \"Keyboard\" and \"Pointer\"), or `state` itself\n * when nothing changes. A disabled option is never selected: a change aimed at one does nothing,\n * a range and `all` pass over them (a disabled option already selected, by a controlled value,\n * stays). `single`: every change but `all` selects its option alone (the selected one stays\n * selected). `multiple`: `toggle` flips an option and makes it the anchor; `replace` makes it the\n * only one and the anchor; a `range` adds to the selection with `toggle`, replaces it with\n * `replace`, and moves the anchor only when it starts `from` a given key; `all` selects every\n * enabled option, or unselects them when they all are. `none`: nothing changes.\n */\nexport function applySelection(\n model: ListModel,\n state: SelectionState,\n change: SelectionChange,\n options: SelectionOptions,\n): SelectionState {\n const { mode, behavior } = options;\n if (mode === \"none\") {\n return state;\n }\n if (change.type !== \"all\" && model.isDisabled(change.key)) {\n return state;\n }\n if (mode === \"single\") {\n if (change.type === \"all\") {\n return state;\n }\n if (state.selected.length === 1 && state.selected[0] === change.key) {\n return state;\n }\n return { selected: [change.key], anchor: change.key };\n }\n switch (change.type) {\n case \"toggle\": {\n const selected = state.selected.includes(change.key)\n ? state.selected.filter((key) => key !== change.key)\n : inModelOrder(model, [...state.selected, change.key]);\n return { selected, anchor: change.key };\n }\n case \"replace\":\n return { selected: [change.key], anchor: change.key };\n case \"range\": {\n // an anchor the list no longer has (its option removed) is no anchor\n const anchor =\n state.anchor !== null && model.indexOf(state.anchor) !== -1\n ? state.anchor\n : null;\n const from = change.from ?? anchor ?? change.key;\n const keys = rangeKeys(model, from, change.key);\n const kept =\n behavior === \"replace\"\n ? state.selected.filter((key) => model.isDisabled(key))\n : state.selected;\n return {\n selected: inModelOrder(model, [...kept, ...keys]),\n anchor:\n change.from !== undefined\n ? change.from\n : (anchor ?? change.key),\n };\n }\n case \"all\": {\n const enabled = model.enabledKeys;\n const all = enabled.every((key) => state.selected.includes(key));\n const others = state.selected.filter(\n (key) => !enabled.includes(key),\n );\n return {\n selected: all\n ? others\n : inModelOrder(model, [...others, ...enabled]),\n anchor: state.anchor,\n };\n }\n }\n}\n\n/** Whether two selections hold the same keys in the same order. */\nexport function sameSelection(\n a: readonly string[],\n b: readonly string[],\n): boolean {\n return a.length === b.length && a.every((key, index) => b[index] === key);\n}\n"],"mappings":";;;AAqCA,SAAS,WACL,KACA,OACA,OACA,SACa;CACb,MAAM,WAAW,QAAQ,gBAAgB;CACzC,MAAM,OAAO,WACP,cACA,QAAQ,MACN,cACA;CACR,MAAM,WAAW,WACX,YACA,QAAQ,MACN,eACA;CACR,MAAM,QAAQ,MAAM;CACpB,QAAQ,KAAR;EACI,KAAK;EACL,KAAK,UACD,OAAO,UAAU,OAAO,OAAO,QAAQ,OAAO,IAAI,IAAI,EAClD,MAAM,QAAQ,KAClB,CAAC;EACL,KAAK,QACD,OAAO,UAAU,OAAO,OAAO;EACnC,KAAK,OACD,OAAO,UAAU,OAAO,MAAM;EAClC,KAAK;EACL,KAAK,UAAU;GACX,MAAM,QAAQ,QAAQ,aAAa,I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C,GAJ/B,aAAa,YACP,MAAM,SAAS,QAAQ,QAAQ,MAAM,WAAW,GAAG,CAAC,IACpD,MAAM,UAE4B,GAAG,IAAI,CAAC;IAChD,QACI,OAAO,SAAS,KAAA,IACV,OAAO,OACN,UAAU,OAAO;GAChC;EACJ;EACA,KAAK,OAAO;GACR,MAAM,UAAU,MAAM;GACtB,MAAM,MAAM,QAAQ,OAAO,QAAQ,MAAM,SAAS,SAAS,GAAG,CAAC;GAC/D,MAAM,SAAS,MAAM,SAAS,QACzB,QAAQ,CAAC,QAAQ,SAAS,GAAG,CAClC;GACA,OAAO;IACH,UAAU,MACJ,SACA,aAAa,OAAO,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC;IACjD,QAAQ,MAAM;GAClB;EACJ;CACJ;AACJ;;AAGA,SAAgB,cACZ,GACA,GACO;CACP,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,KAAK,UAAU,EAAE,WAAW,GAAG;AAC5E"}
@@ -0,0 +1,2 @@
1
+ import { _ as ListNode, a as ListKeyResult, c as SelectionBehavior, d as SelectionOptions, f as SelectionState, g as ListModel, h as sameSelection, i as ListKeyOptions, l as SelectionChange, m as inModelOrder, n as pageTarget, o as listKeyTarget, p as applySelection, r as ListKeyEvent, s as listPressSelection, t as rowTarget, u as SelectionMode, v as createListModel } from "./index-D10LDdR6.js";
2
+ export { type ListKeyEvent, type ListKeyOptions, type ListKeyResult, type ListModel, type ListNode, type SelectionBehavior, type SelectionChange, type SelectionMode, type SelectionOptions, type SelectionState, applySelection, createListModel, inModelOrder, listKeyTarget, listPressSelection, pageTarget, rowTarget, sameSelection };
@@ -0,0 +1 @@
1
+ export { t as applySelection, o as createListModel, n as inModelOrder, s as listKeyTarget, c as listPressSelection, a as pageTarget, i as rowTarget, r as sameSelection } from "./selection-Cor67w_V.js";
@@ -0,0 +1,2 @@
1
+ import { a as swipeDisplacement, c as swipeRelease, d as SwipeEnd, f as SwipeMovement, i as resolveSnapPoints, l as SWIPE_LOCK_DISTANCE, m as watchSwipe, n as SnapPoint, o as swipeMovement, p as SwipeOptions, r as SwipeOutcome, s as swipeProgress, t as ResolvedSnapPoint, u as SwipeDirection } from "./index-l63esAck.js";
2
+ export { type ResolvedSnapPoint, SWIPE_LOCK_DISTANCE, type SnapPoint, type SwipeDirection, type SwipeEnd, type SwipeMovement, type SwipeOptions, type SwipeOutcome, resolveSnapPoints, swipeDisplacement, swipeMovement, swipeProgress, swipeRelease, watchSwipe };
package/dist/swipe.js ADDED
@@ -0,0 +1 @@
1
+ export { t as SWIPE_LOCK_DISTANCE, i as resolveSnapPoints, a as swipeDisplacement, o as swipeMovement, s as swipeProgress, c as swipeRelease, n as watchSwipe } from "./watch-swipe-BIucfr9O.js";
@@ -0,0 +1,35 @@
1
+ // src/focus/tabbable.ts
2
+ const TABBABLE = [
3
+ "a[href]",
4
+ "area[href]",
5
+ "button:not([disabled])",
6
+ "input:not([disabled]):not([type='hidden'])",
7
+ "select:not([disabled])",
8
+ "textarea:not([disabled])",
9
+ "iframe",
10
+ "audio[controls]",
11
+ "video[controls]",
12
+ "[contenteditable]:not([contenteditable='false'])",
13
+ "[tabindex]"
14
+ ].join(",");
15
+ function isVisible(element) {
16
+ if (element.hidden || element.closest("[inert]") !== null) return false;
17
+ const style = element.ownerDocument.defaultView?.getComputedStyle(element);
18
+ return style?.visibility !== "hidden" && style?.display !== "none";
19
+ }
20
+ /** The elements of `container` that Tab reaches, in tab order (positive tabindex first). */
21
+ function getTabbables(container) {
22
+ const candidates = [...container.querySelectorAll(TABBABLE)].filter((element) => element.tabIndex >= 0 && isVisible(element));
23
+ return [...candidates.filter((element) => element.tabIndex > 0).sort((a, b) => a.tabIndex - b.tabIndex), ...candidates.filter((element) => element.tabIndex === 0)];
24
+ }
25
+ /** The first tabbable element of the document after `element` in tab order, outside `skip`. */
26
+ function nextTabbableAfter(element, skip = []) {
27
+ return getTabbables(element.ownerDocument.body).filter((candidate) => !skip.some((container) => container?.contains(candidate) === true)).find((candidate) => element.compareDocumentPosition(candidate) & Node.DOCUMENT_POSITION_FOLLOWING && !element.contains(candidate)) ?? null;
28
+ }
29
+ /** The last tabbable element of the document before `element` in tab order, outside `skip`. */
30
+ function previousTabbableBefore(element, skip = []) {
31
+ return getTabbables(element.ownerDocument.body).filter((candidate) => !skip.some((container) => container?.contains(candidate) === true)).filter((candidate) => element.compareDocumentPosition(candidate) & Node.DOCUMENT_POSITION_PRECEDING && !candidate.contains(element)).at(-1) ?? null;
32
+ }
33
+ export { nextTabbableAfter as n, previousTabbableBefore as r, getTabbables as t };
34
+
35
+ //# sourceMappingURL=tabbable-BPiLssIv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabbable-BPiLssIv.js","names":[],"sources":["../src/focus/tabbable.ts"],"sourcesContent":["const TABBABLE = [\n \"a[href]\",\n \"area[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled]):not([type='hidden'])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"iframe\",\n \"audio[controls]\",\n \"video[controls]\",\n \"[contenteditable]:not([contenteditable='false'])\",\n \"[tabindex]\",\n].join(\",\");\n\nfunction isVisible(element: HTMLElement): boolean {\n if (element.hidden || element.closest(\"[inert]\") !== null) {\n return false;\n }\n const view = element.ownerDocument.defaultView;\n const style = view?.getComputedStyle(element);\n return style?.visibility !== \"hidden\" && style?.display !== \"none\";\n}\n\n/** The elements of `container` that Tab reaches, in tab order (positive tabindex first). */\nexport function getTabbables(container: Element): HTMLElement[] {\n const candidates = [\n ...container.querySelectorAll<HTMLElement>(TABBABLE),\n ].filter((element) => element.tabIndex >= 0 && isVisible(element));\n const positive = candidates\n .filter((element) => element.tabIndex > 0)\n .sort((a, b) => a.tabIndex - b.tabIndex);\n return [\n ...positive,\n ...candidates.filter((element) => element.tabIndex === 0),\n ];\n}\n\n/** The first tabbable element of the document after `element` in tab order, outside `skip`. */\nexport function nextTabbableAfter(\n element: Element,\n skip: readonly (Element | null | undefined)[] = [],\n): HTMLElement | null {\n const all = getTabbables(element.ownerDocument.body).filter(\n (candidate) =>\n !skip.some((container) => container?.contains(candidate) === true),\n );\n return (\n all.find(\n (candidate) =>\n element.compareDocumentPosition(candidate) &\n Node.DOCUMENT_POSITION_FOLLOWING &&\n !element.contains(candidate),\n ) ?? null\n );\n}\n\n/** The last tabbable element of the document before `element` in tab order, outside `skip`. */\nexport function previousTabbableBefore(\n element: Element,\n skip: readonly (Element | null | undefined)[] = [],\n): HTMLElement | null {\n const all = getTabbables(element.ownerDocument.body).filter(\n (candidate) =>\n !skip.some((container) => container?.contains(candidate) === true),\n );\n return (\n all\n .filter(\n (candidate) =>\n element.compareDocumentPosition(candidate) &\n Node.DOCUMENT_POSITION_PRECEDING &&\n !candidate.contains(element),\n )\n .at(-1) ?? null\n );\n}\n"],"mappings":";AAAA,MAAM,WAAW;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC,CAAC,KAAK,GAAG;AAEV,SAAS,UAAU,SAA+B;CAC9C,IAAI,QAAQ,UAAU,QAAQ,QAAQ,SAAS,MAAM,MACjD,OAAO;CAGX,MAAM,QADO,QAAQ,cAAc,aACf,iBAAiB,OAAO;CAC5C,OAAO,OAAO,eAAe,YAAY,OAAO,YAAY;AAChE;;AAGA,SAAgB,aAAa,WAAmC;CAC5D,MAAM,aAAa,CACf,GAAG,UAAU,iBAA8B,QAAQ,CACvD,CAAC,CAAC,QAAQ,YAAY,QAAQ,YAAY,KAAK,UAAU,OAAO,CAAC;CAIjE,OAAO,CACH,GAJa,WACZ,QAAQ,YAAY,QAAQ,WAAW,CAAC,CAAC,CACzC,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,QAErB,GACV,GAAG,WAAW,QAAQ,YAAY,QAAQ,aAAa,CAAC,CAC5D;AACJ;;AAGA,SAAgB,kBACZ,SACA,OAAgD,CAAC,GAC/B;CAKlB,OAJY,aAAa,QAAQ,cAAc,IAAI,CAAC,CAAC,QAChD,cACG,CAA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