@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":"color-sURV5Irg.js","names":["hueOf"],"sources":["../src/color/color-value.ts","../src/color/convert-color.ts","../src/color/format-color.ts","../src/color/color-gradient.ts","../src/color/color-keys.ts","../src/color/color-wheel-geometry.ts","../src/color/parse-color.ts","../src/color/eye-dropper.ts"],"sourcesContent":["/** The color spaces of the color model (spec/color.md, \"The value\"). */\nexport type ColorSpace = \"rgb\" | \"hsl\" | \"hsb\";\n\n/** A color's channels: three per space, and the alpha every space has. */\nexport type ColorChannel =\n | \"red\"\n | \"green\"\n | \"blue\"\n | \"hue\"\n | \"saturation\"\n | \"lightness\"\n | \"brightness\"\n | \"alpha\";\n\n/** sRGB: `red`, `green`, `blue` from 0 to 255 (whole numbers), `alpha` from 0 to 1. */\nexport interface RgbColor {\n readonly space: \"rgb\";\n readonly red: number;\n readonly green: number;\n readonly blue: number;\n readonly alpha: number;\n}\n\n/** HSL: `hue` from 0 to 360 (degrees), `saturation` and `lightness` from 0 to 100 (percent). */\nexport interface HslColor {\n readonly space: \"hsl\";\n readonly hue: number;\n readonly saturation: number;\n readonly lightness: number;\n readonly alpha: number;\n}\n\n/** HSB (HSV): `hue` from 0 to 360, `saturation` and `brightness` from 0 to 100. */\nexport interface HsbColor {\n readonly space: \"hsb\";\n readonly hue: number;\n readonly saturation: number;\n readonly brightness: number;\n readonly alpha: number;\n}\n\n/**\n * An immutable color value (spec/color.md): a plain object in one space, which every function\n * of the model returns anew and never changes.\n */\nexport type Color = RgbColor | HslColor | HsbColor;\n\n/** A channel's bounds and steps (spec/color.md, \"Channels\"). */\nexport interface ColorChannelRange {\n min: number;\n max: number;\n /** The arrows' step. */\n step: number;\n /** Page Up / Page Down and Shift with an arrow. */\n largeStep: number;\n}\n\nconst RANGES: Record<ColorChannel, ColorChannelRange> = {\n red: { min: 0, max: 255, step: 1, largeStep: 17 },\n green: { min: 0, max: 255, step: 1, largeStep: 17 },\n blue: { min: 0, max: 255, step: 1, largeStep: 17 },\n hue: { min: 0, max: 360, step: 1, largeStep: 15 },\n saturation: { min: 0, max: 100, step: 1, largeStep: 10 },\n lightness: { min: 0, max: 100, step: 1, largeStep: 10 },\n brightness: { min: 0, max: 100, step: 1, largeStep: 10 },\n alpha: { min: 0, max: 1, step: 0.01, largeStep: 0.1 },\n};\n\nconst CHANNELS: Record<\n ColorSpace,\n readonly [ColorChannel, ColorChannel, ColorChannel]\n> = {\n rgb: [\"red\", \"green\", \"blue\"],\n hsl: [\"hue\", \"saturation\", \"lightness\"],\n hsb: [\"hue\", \"saturation\", \"brightness\"],\n};\n\n/** A channel's bounds and steps. */\nexport function colorChannelRange(channel: ColorChannel): ColorChannelRange {\n return { ...RANGES[channel] };\n}\n\n/** The three color channels of a space, in order (alpha, which every space has, aside). */\nexport function colorChannels(\n space: ColorSpace,\n): readonly [ColorChannel, ColorChannel, ColorChannel] {\n return CHANNELS[space];\n}\n\n/** Whether `channel` is one of `space`'s (alpha is every space's). */\nexport function hasColorChannel(\n space: ColorSpace,\n channel: ColorChannel,\n): boolean {\n return channel === \"alpha\" || CHANNELS[space].includes(channel);\n}\n\n/**\n * The space a control edits `channel` in (spec/color.md, \"Channels\"): `preferred` (the control's\n * `colorSpace`) when given, else the value's own space when it has the channel, else the\n * channel's own space (`red`, `green`, `blue`: rgb; `lightness`: hsl; `hue`, `saturation`,\n * `brightness`: hsb).\n */\nexport function colorSpaceFor(\n channel: ColorChannel,\n color: Color,\n preferred?: ColorSpace,\n): ColorSpace {\n if (preferred !== undefined) {\n return preferred;\n }\n if (hasColorChannel(color.space, channel)) {\n return color.space;\n }\n if (channel === \"red\" || channel === \"green\" || channel === \"blue\") {\n return \"rgb\";\n }\n return channel === \"lightness\" ? \"hsl\" : \"hsb\";\n}\n\n/** A channel's value. `channel` must be one of the color's space (else a `RangeError`). */\nexport function getColorChannel(color: Color, channel: ColorChannel): number {\n if (!hasColorChannel(color.space, channel)) {\n throw new RangeError(`a ${color.space} color has no ${channel}`);\n }\n return (color as unknown as Record<ColorChannel, number>)[channel];\n}\n\n/** `value` clamped to the channel's bounds. */\nexport function clampColorChannel(\n channel: ColorChannel,\n value: number,\n): number {\n const { min, max } = RANGES[channel];\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * A new color with `channel` set to `value`, clamped to its bounds. `channel` must be one of the\n * color's space (else a `RangeError`): convert the color first (`convertColor`).\n */\nexport function setColorChannel(\n color: Color,\n channel: ColorChannel,\n value: number,\n): Color {\n if (!hasColorChannel(color.space, channel)) {\n throw new RangeError(`a ${color.space} color has no ${channel}`);\n }\n return { ...color, [channel]: clampColorChannel(channel, value) } as Color;\n}\n\n/** Whether two colors are the same value: the same space and the same channels. */\nexport function isSameColor(\n a: Color | null | undefined,\n b: Color | null | undefined,\n): boolean {\n if (a === b) {\n return true;\n }\n if (a === null || a === undefined || b === null || b === undefined) {\n return false;\n }\n if (a.space !== b.space || a.alpha !== b.alpha) {\n return false;\n }\n return CHANNELS[a.space].every(\n (channel) =>\n getColorChannel(a, channel) === getColorChannel(b, channel),\n );\n}\n\n/** The space and the two channels of a ColorArea (spec/color-area.md, \"API\"). */\nexport interface ColorAreaChannels {\n space: ColorSpace;\n xChannel: ColorChannel;\n yChannel: ColorChannel;\n}\n\nconst AREA_DEFAULTS: Record<ColorSpace, readonly [ColorChannel, ColorChannel]> =\n {\n rgb: [\"red\", \"green\"],\n hsl: [\"saturation\", \"lightness\"],\n hsb: [\"saturation\", \"brightness\"],\n };\n\n/**\n * A ColorArea's space and channels: `colorSpace`, else the value's own space when it has both\n * given channels, else the space of the more specific channel (lightness: hsl; brightness: hsb;\n * red, green, blue: rgb; else hsb); the channels not given are the space's defaults (rgb: red and\n * green; hsl: saturation and lightness; hsb: saturation and brightness).\n */\nexport function colorAreaChannels(\n color: Color,\n options: {\n xChannel?: ColorChannel | undefined;\n yChannel?: ColorChannel | undefined;\n colorSpace?: ColorSpace | undefined;\n } = {},\n): ColorAreaChannels {\n const given = [options.xChannel, options.yChannel].filter(\n (channel): channel is ColorChannel => channel !== undefined,\n );\n let space = options.colorSpace;\n if (space === undefined) {\n if (given.every((channel) => CHANNELS[color.space].includes(channel))) {\n space = color.space;\n } else if (given.includes(\"lightness\")) {\n space = \"hsl\";\n } else if (given.includes(\"brightness\")) {\n space = \"hsb\";\n } else if (given.some((channel) => CHANNELS.rgb.includes(channel))) {\n space = \"rgb\";\n } else {\n space = \"hsb\";\n }\n }\n const [x, y] = AREA_DEFAULTS[space];\n const xChannel = options.xChannel ?? (options.yChannel === x ? y : x);\n const yChannel = options.yChannel ?? (xChannel === y ? x : y);\n return { space, xChannel, yChannel };\n}\n","import type {\n Color,\n ColorSpace,\n HsbColor,\n HslColor,\n RgbColor,\n} from \"./color-value.ts\";\n\n/**\n * The precision of a converted channel (spec/color.md, \"Precision\"): red, green and blue are\n * whole numbers (8 bits, what a hex string holds), hue, saturation, lightness and brightness keep\n * 2 decimals, alpha 4 (a hex string's 1/255 steps survive the round trip).\n */\nexport function roundTo(value: number, decimals: number): number {\n const factor = 10 ** decimals;\n // `+ 0` turns -0 into 0\n return Math.round(value * factor) / factor + 0;\n}\n\n/** A channel from 0 to 1 as a byte; the float noise of `0.5 - 0.4` (25.4999…) cut first. */\nfunction byte(value: number): number {\n return Math.round(Number((value * 255).toFixed(6)));\n}\n\nfunction rgbOf(\n red: number,\n green: number,\n blue: number,\n alpha: number,\n): RgbColor {\n return {\n space: \"rgb\",\n red: byte(red),\n green: byte(green),\n blue: byte(blue),\n alpha,\n };\n}\n\nfunction hslToRgb(color: HslColor): RgbColor {\n const s = color.saturation / 100;\n const l = color.lightness / 100;\n const amount = s * Math.min(l, 1 - l);\n const at = (n: number) => {\n const k = (n + color.hue / 30) % 12;\n return l - amount * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n };\n return rgbOf(at(0), at(8), at(4), color.alpha);\n}\n\nfunction hsbToRgb(color: HsbColor): RgbColor {\n const s = color.saturation / 100;\n const v = color.brightness / 100;\n const at = (n: number) => {\n const k = (n + color.hue / 60) % 6;\n return v - v * s * Math.max(0, Math.min(k, 4 - k, 1));\n };\n return rgbOf(at(5), at(3), at(1), color.alpha);\n}\n\n/** The hue (degrees), the largest and the smallest of an rgb color's channels (0 to 1). */\nfunction hueOf(color: RgbColor): { hue: number; max: number; min: number } {\n const r = color.red / 255;\n const g = color.green / 255;\n const b = color.blue / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let hue = 0;\n if (delta !== 0) {\n if (max === r) {\n hue = ((g - b) / delta) % 6;\n } else if (max === g) {\n hue = (b - r) / delta + 2;\n } else {\n hue = (r - g) / delta + 4;\n }\n hue *= 60;\n if (hue < 0) {\n hue += 360;\n }\n }\n return { hue: roundTo(hue, 2) % 360, max, min };\n}\n\nfunction rgbToHsl(color: RgbColor): HslColor {\n const { hue, max, min } = hueOf(color);\n const l = (max + min) / 2;\n const delta = max - min;\n const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n return {\n space: \"hsl\",\n hue,\n saturation: roundTo(s * 100, 2),\n lightness: roundTo(l * 100, 2),\n alpha: color.alpha,\n };\n}\n\nfunction rgbToHsb(color: RgbColor): HsbColor {\n const { hue, max, min } = hueOf(color);\n const s = max === 0 ? 0 : (max - min) / max;\n return {\n space: \"hsb\",\n hue,\n saturation: roundTo(s * 100, 2),\n brightness: roundTo(max * 100, 2),\n alpha: color.alpha,\n };\n}\n\nfunction hslToHsb(color: HslColor): HsbColor {\n const s = color.saturation / 100;\n const l = color.lightness / 100;\n const v = l + s * Math.min(l, 1 - l);\n return {\n space: \"hsb\",\n hue: color.hue,\n saturation: roundTo(v === 0 ? 0 : 2 * (1 - l / v) * 100, 2),\n brightness: roundTo(v * 100, 2),\n alpha: color.alpha,\n };\n}\n\nfunction hsbToHsl(color: HsbColor): HslColor {\n const s = color.saturation / 100;\n const v = color.brightness / 100;\n const l = v * (1 - s / 2);\n const lowest = Math.min(l, 1 - l);\n return {\n space: \"hsl\",\n hue: color.hue,\n saturation: roundTo(lowest === 0 ? 0 : ((v - l) / lowest) * 100, 2),\n lightness: roundTo(l * 100, 2),\n alpha: color.alpha,\n };\n}\n\n/**\n * `color` in `space` (spec/color.md, \"Conversion\"): the same object when it already is in it;\n * hsl and hsb convert directly (the hue kept), the others through rgb. Each converted channel is\n * rounded to its precision.\n */\nexport function convertColor(color: Color, space: ColorSpace): Color {\n if (color.space === space) {\n return color;\n }\n if (color.space === \"hsl\" && space === \"hsb\") {\n return hslToHsb(color);\n }\n if (color.space === \"hsb\" && space === \"hsl\") {\n return hsbToHsl(color);\n }\n const rgb =\n color.space === \"rgb\"\n ? color\n : color.space === \"hsl\"\n ? hslToRgb(color)\n : hsbToRgb(color);\n if (space === \"rgb\") {\n return rgb;\n }\n return space === \"hsl\" ? rgbToHsl(rgb) : rgbToHsb(rgb);\n}\n","import {\n type Color,\n type ColorChannel,\n getColorChannel,\n} from \"./color-value.ts\";\nimport { convertColor, roundTo } from \"./convert-color.ts\";\n\n/**\n * How `formatColor` writes a color (spec/color.md, \"Formatting\"). `hex` writes `#rrggbb`, and\n * `#rrggbbaa` when the alpha is below 1 (nothing is lost); `hexa` always the eight digits; `css`\n * the color's own function (`rgb()`, `hsl()`; hsb, which CSS has not, as `hsl()`), with its alpha\n * when below 1.\n */\nexport type ColorFormat =\n | \"hex\"\n | \"hexa\"\n | \"rgb\"\n | \"rgba\"\n | \"hsl\"\n | \"hsla\"\n | \"hsb\"\n | \"hsba\"\n | \"css\";\n\nfunction hexByte(value: number): string {\n return Math.round(value).toString(16).padStart(2, \"0\");\n}\n\nfunction number(value: number): string {\n return String(roundTo(value, 2));\n}\n\n/** `color` as text, lower-case hex or a CSS function with commas (`rgb(255, 0, 0)`). */\nexport function formatColor(color: Color, format: ColorFormat = \"css\"): string {\n if (format === \"css\") {\n if (color.space === \"rgb\") {\n return formatColor(color, color.alpha < 1 ? \"rgba\" : \"rgb\");\n }\n return formatColor(color, color.alpha < 1 ? \"hsla\" : \"hsl\");\n }\n if (format === \"hex\" || format === \"hexa\") {\n const rgb = convertColor(color, \"rgb\") as Extract<\n Color,\n { space: \"rgb\" }\n >;\n const digits = `#${hexByte(rgb.red)}${hexByte(rgb.green)}${hexByte(rgb.blue)}`;\n return format === \"hexa\" || rgb.alpha < 1\n ? `${digits}${hexByte(rgb.alpha * 255)}`\n : digits;\n }\n const space = format.replace(/a$/, \"\") as \"rgb\" | \"hsl\" | \"hsb\";\n const converted = convertColor(color, space);\n const alpha = format.endsWith(\"a\")\n ? `, ${String(roundTo(converted.alpha, 4))}`\n : \"\";\n if (converted.space === \"rgb\") {\n return `${format}(${converted.red}, ${converted.green}, ${converted.blue}${alpha})`;\n }\n const last =\n converted.space === \"hsl\" ? converted.lightness : converted.brightness;\n return `${format}(${number(converted.hue)}, ${number(converted.saturation)}%, ${number(last)}%${alpha})`;\n}\n\n/**\n * The `Intl.NumberFormat` options a channel's value is written with (spec/color.md, \"Channel\n * text\"), and the scale its value is multiplied by first: hue in degrees (`unit: \"degree\"`),\n * saturation, lightness, brightness and alpha as percents, red, green and blue as whole numbers.\n * The digits follow the channel's step.\n */\nexport function colorChannelFormat(channel: ColorChannel): {\n format: Intl.NumberFormatOptions;\n scale: number;\n} {\n switch (channel) {\n case \"hue\":\n return {\n format: {\n style: \"unit\",\n unit: \"degree\",\n unitDisplay: \"narrow\",\n maximumFractionDigits: 0,\n },\n scale: 1,\n };\n case \"saturation\":\n case \"lightness\":\n case \"brightness\":\n return {\n format: { style: \"percent\", maximumFractionDigits: 0 },\n scale: 0.01,\n };\n case \"alpha\":\n return {\n format: { style: \"percent\", maximumFractionDigits: 0 },\n scale: 1,\n };\n default:\n return { format: { maximumFractionDigits: 0 }, scale: 1 };\n }\n}\n\n/**\n * A channel's value as text for `locale` (BCP 47; default: the runtime's), through `Intl`: `\"120°\"`,\n * `\"50%\"` (`\"50 %\"` in de-DE), `\"128\"`. A value given wins over the color's.\n */\nexport function formatColorChannel(\n color: Color,\n channel: ColorChannel,\n locale?: string,\n value: number = getColorChannel(color, channel),\n): string {\n const { format, scale } = colorChannelFormat(channel);\n return new Intl.NumberFormat(locale, format).format(value * scale);\n}\n","import {\n type Color,\n type ColorChannel,\n colorChannelRange,\n colorChannels,\n hasColorChannel,\n setColorChannel,\n} from \"./color-value.ts\";\nimport { formatColor } from \"./format-color.ts\";\n\n/** A CSS gradient direction: a slider's from its `min` to its `max`. */\nexport type ColorGradientDirection =\n | \"to right\"\n | \"to left\"\n | \"to top\"\n | \"to bottom\";\n\n/** The hue's stops: the primaries and secondaries, every 60°, where the hue ramp turns. */\nconst HUE_STOPS = [0, 60, 120, 180, 240, 300, 360];\n\nfunction stops(colors: readonly Color[]): string {\n return colors.map((color) => formatColor(color, \"css\")).join(\", \");\n}\n\n/** The colors along `channel`, the color's other channels kept, as linear stops. */\nfunction channelStops(color: Color, channel: ColorChannel): Color[] {\n if (channel === \"hue\") {\n return HUE_STOPS.map((hue) => setColorChannel(color, \"hue\", hue));\n }\n const { min, max } = colorChannelRange(channel);\n // a lightness ramp turns at 50% (black, the color, white)\n const values = channel === \"lightness\" ? [min, 50, max] : [min, max];\n return values.map((value) => setColorChannel(color, channel, value));\n}\n\n/**\n * The CSS `linear-gradient` of a slider's track (spec/color.md, \"Gradients\"): `channel` from its\n * `min` to its `max` along `direction`, the color's other channels kept, except the hue track,\n * which shows every hue at full saturation (and, in hsb, full brightness; in hsl, 50% lightness).\n * Every stop is a linear ramp in sRGB, so the gradient is exact. The alpha track keeps the\n * color's other channels, opaque at its end.\n */\nexport function colorChannelGradient(\n color: Color,\n channel: ColorChannel,\n direction: ColorGradientDirection = \"to right\",\n): string {\n if (!hasColorChannel(color.space, channel)) {\n throw new RangeError(`a ${color.space} color has no ${channel}`);\n }\n let base: Color =\n channel === \"alpha\" ? color : setColorChannel(color, \"alpha\", 1);\n if (channel === \"hue\") {\n base =\n base.space === \"hsl\"\n ? { ...base, saturation: 100, lightness: 50 }\n : base.space === \"hsb\"\n ? { ...base, saturation: 100, brightness: 100 }\n : base;\n }\n return `linear-gradient(${direction}, ${stops(channelStops(base, channel))})`;\n}\n\n/** A ColorArea's background: its layers, and how they blend (`screen` for two rgb channels). */\nexport interface ColorAreaBackground {\n backgroundImage: string;\n backgroundBlendMode: \"normal\" | \"screen\";\n}\n\nfunction gradient(direction: string, colors: readonly string[]): string {\n return `linear-gradient(${direction}, ${colors.join(\", \")})`;\n}\n\n/**\n * A ColorArea's background (spec/color.md, \"Gradients\"): two gradient layers that give, at every\n * point, the color with `xChannel` and `yChannel` at that point and its third channel kept, exactly\n * (sRGB compositing): two rgb channels add up through `screen`; a lightness or brightness axis is\n * a black (and white) layer over the other channel's ramp; a saturation axis beside a hue axis\n * fades the hue ramp to gray. `x` runs from the inline start (`rtl`: from the right), `y` from\n * the bottom. The channels are two different color channels of the color's space (no alpha).\n */\nexport function colorAreaBackground(\n color: Color,\n xChannel: ColorChannel,\n yChannel: ColorChannel,\n rtl = false,\n): ColorAreaBackground {\n const space = colorChannels(color.space);\n if (\n xChannel === yChannel ||\n !space.includes(xChannel) ||\n !space.includes(yChannel)\n ) {\n throw new RangeError(\n `${xChannel} and ${yChannel} are not two channels of a ${color.space} color`,\n );\n }\n const opaque = setColorChannel(color, \"alpha\", 1);\n const xDirection = rtl ? \"to left\" : \"to right\";\n if (opaque.space === \"rgb\") {\n const zero = { ...opaque, [xChannel]: 0, [yChannel]: 0 } as Color;\n const black: Color = {\n space: \"rgb\",\n red: 0,\n green: 0,\n blue: 0,\n alpha: 1,\n };\n const xMax = setColorChannel(zero, xChannel, 255);\n const yMax = setColorChannel(black, yChannel, 255);\n return {\n backgroundImage: [\n gradient(xDirection, [formatColor(zero), formatColor(xMax)]),\n gradient(\"to top\", [formatColor(black), formatColor(yMax)]),\n ].join(\", \"),\n backgroundBlendMode: \"screen\",\n };\n }\n // the axis that darkens (lightness, brightness), else the saturation beside a hue axis\n const shade =\n xChannel === \"lightness\" || xChannel === \"brightness\"\n ? \"x\"\n : yChannel === \"lightness\" || yChannel === \"brightness\"\n ? \"y\"\n : xChannel === \"saturation\"\n ? \"x\"\n : \"y\";\n const shadeChannel = shade === \"x\" ? xChannel : yChannel;\n const rampChannel = shade === \"x\" ? yChannel : xChannel;\n const shadeDirection = shade === \"x\" ? xDirection : \"to top\";\n const rampDirection = shade === \"x\" ? \"to top\" : xDirection;\n let overlay: string;\n let ramp: Color = opaque;\n if (shadeChannel === \"brightness\") {\n // hsb: a color at brightness b is the color at 100% mixed with black by 1 - b\n ramp = setColorChannel(opaque, \"brightness\", 100);\n overlay = gradient(shadeDirection, [\n \"rgb(0, 0, 0)\",\n \"rgba(0, 0, 0, 0)\",\n ]);\n } else if (shadeChannel === \"lightness\") {\n // hsl: the color at 50% lightness, mixed with black below 50% and with white above\n ramp = setColorChannel(opaque, \"lightness\", 50);\n overlay = gradient(shadeDirection, [\n \"rgb(0, 0, 0) 0%\",\n \"rgba(0, 0, 0, 0) 50%\",\n \"rgba(255, 255, 255, 0) 50%\",\n \"rgb(255, 255, 255) 100%\",\n ]);\n } else {\n // saturation beside hue: the full-saturation hue ramp, faded to the gray of 0% saturation\n ramp = setColorChannel(opaque, \"saturation\", 100);\n const gray = formatColor(setColorChannel(opaque, \"saturation\", 0));\n const clear = formatColor(\n setColorChannel(\n setColorChannel(opaque, \"saturation\", 0),\n \"alpha\",\n 0,\n ),\n );\n overlay = gradient(shadeDirection, [gray, clear]);\n }\n const rampStops =\n rampChannel === \"hue\"\n ? channelStops(ramp, \"hue\")\n : [\n setColorChannel(ramp, rampChannel, 0),\n setColorChannel(ramp, rampChannel, 100),\n ];\n return {\n backgroundImage: [\n overlay,\n `linear-gradient(${rampDirection}, ${stops(rampStops)})`,\n ].join(\", \"),\n backgroundBlendMode: \"normal\",\n };\n}\n\n/**\n * A ColorWheel's track (spec/color.md, \"Gradients\"): every hue at full saturation, from 0° at the\n * top, clockwise (the `conic-gradient`'s own start and direction).\n */\nexport function colorWheelGradient(): string {\n const hues: Color[] = HUE_STOPS.map((hue) => ({\n space: \"hsl\",\n hue,\n saturation: 100,\n lightness: 50,\n alpha: 1,\n }));\n return `conic-gradient(${stops(hues)})`;\n}\n","import type { ColorChannelRange } from \"./color-value.ts\";\n\nexport interface ColorAreaKeyOptions {\n x: number;\n y: number;\n xRange: ColorChannelRange;\n yRange: ColorChannelRange;\n rtl: boolean;\n}\n\n/**\n * The axis and value a key moves a ColorArea's thumb to (spec/color-area.md, \"Keyboard\"), before\n * snapping and clamping; `null` when the key does not move it. ArrowLeft and ArrowRight move `x`\n * (swapped in RTL), ArrowUp and ArrowDown `y`, with Shift by the large step; Page Up and Page\n * Down move `y` by its large step; Home and End set `x` to its `min` and `max`.\n */\nexport function colorAreaKeyTarget(\n key: string,\n shiftKey: boolean,\n options: ColorAreaKeyOptions,\n): { axis: \"x\" | \"y\"; value: number } | null {\n const { x, y, xRange, yRange } = options;\n const xAmount = shiftKey ? xRange.largeStep : xRange.step;\n const yAmount = shiftKey ? yRange.largeStep : yRange.step;\n const right = options.rtl ? -1 : 1;\n switch (key) {\n case \"ArrowRight\":\n return { axis: \"x\", value: x + right * xAmount };\n case \"ArrowLeft\":\n return { axis: \"x\", value: x - right * xAmount };\n case \"ArrowUp\":\n return { axis: \"y\", value: y + yAmount };\n case \"ArrowDown\":\n return { axis: \"y\", value: y - yAmount };\n case \"PageUp\":\n return { axis: \"y\", value: y + yRange.largeStep };\n case \"PageDown\":\n return { axis: \"y\", value: y - yRange.largeStep };\n case \"Home\":\n return { axis: \"x\", value: xRange.min };\n case \"End\":\n return { axis: \"x\", value: xRange.max };\n default:\n return null;\n }\n}\n\n/** `hue` turned into `[0, 360)`, with the hue's step precision (whole degrees by default). */\nexport function wrapHue(hue: number, step = 1): number {\n const decimals = (String(step).split(\".\")[1] ?? \"\").length;\n const snapped = Math.round(hue / step) * step;\n return Number((((snapped % 360) + 360) % 360).toFixed(decimals));\n}\n\n/**\n * The hue a key moves a ColorWheel to (spec/color-wheel.md, \"Keyboard\"), wrapped into `[0, 360)`;\n * `null` when the key does not move it. ArrowRight and ArrowUp increase it by `step` (Shift: by\n * `largeStep`), ArrowLeft and ArrowDown decrease it; Page Up and Page Down by `largeStep`; Home\n * sets 0 and End the last step before 360.\n */\nexport function colorWheelKeyTarget(\n key: string,\n shiftKey: boolean,\n hue: number,\n step = 1,\n largeStep = 15,\n): number | null {\n const amount = shiftKey ? largeStep : step;\n switch (key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n return wrapHue(hue + amount, step);\n case \"ArrowLeft\":\n case \"ArrowDown\":\n return wrapHue(hue - amount, step);\n case \"PageUp\":\n return wrapHue(hue + largeStep, step);\n case \"PageDown\":\n return wrapHue(hue - largeStep, step);\n case \"Home\":\n return 0;\n case \"End\":\n return wrapHue(360 - step, step);\n default:\n return null;\n }\n}\n","/** A box and a point, as `getBoundingClientRect()` and a pointer event give them. */\ninterface Box {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/**\n * The hue at a point of a ColorWheel (spec/color-wheel.md, \"Pointer\"): its angle around the box's\n * centre, 0° at the top, clockwise, in `[0, 360)`.\n */\nexport function hueAtPoint(box: Box, point: { x: number; y: number }): number {\n const dx = point.x - (box.left + box.width / 2);\n const dy = point.y - (box.top + box.height / 2);\n const degrees = (Math.atan2(dx, -dy) * 180) / Math.PI;\n return (degrees + 360) % 360;\n}\n\n/** Whether a point lies on a ColorWheel's ring: between the inner and the outer radius (px). */\nexport function isOnColorWheel(\n box: Box,\n point: { x: number; y: number },\n innerRadius: number,\n outerRadius: number,\n): boolean {\n const dx = point.x - (box.left + box.width / 2);\n const dy = point.y - (box.top + box.height / 2);\n const distance = Math.hypot(dx, dy);\n return distance >= innerRadius && distance <= outerRadius;\n}\n\n/**\n * Where a ColorWheel's thumb sits for `hue`: its offset (px) from the wheel's centre, on the\n * circle of `radius` (the ring's middle), 0° at the top, clockwise.\n */\nexport function colorWheelThumbOffset(\n hue: number,\n radius: number,\n): { x: number; y: number } {\n const radians = (hue * Math.PI) / 180;\n const round = (value: number) => Math.round(value * 100) / 100 + 0;\n return {\n x: round(radius * Math.sin(radians)),\n y: round(-radius * Math.cos(radians)),\n };\n}\n","import { type Color, clampColorChannel } from \"./color-value.ts\";\nimport { roundTo } from \"./convert-color.ts\";\n\nconst HEX = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst FUNCTION = /^(rgba?|hsla?|hsba?)\\(\\s*([^()]*?)\\s*\\)$/i;\nconst NUMBER = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?$/i;\n\nfunction parseHex(digits: string): Color {\n const full =\n digits.length <= 4\n ? [...digits].map((digit) => digit + digit).join(\"\")\n : digits;\n const byte = (index: number) =>\n Number.parseInt(full.slice(index * 2, index * 2 + 2), 16);\n return {\n space: \"rgb\",\n red: byte(0),\n green: byte(1),\n blue: byte(2),\n alpha: full.length === 8 ? roundTo(byte(3) / 255, 4) : 1,\n };\n}\n\n/** A number, with the suffix it may carry (`%`, `deg`), or `null`. */\nfunction numberOf(text: string, suffix: \"%\" | \"deg\" | \"\"): number | null {\n let body = text;\n if (suffix !== \"\" && body.toLowerCase().endsWith(suffix)) {\n body = body.slice(0, -suffix.length);\n }\n return NUMBER.test(body) ? Number(body) : null;\n}\n\n/** An alpha: a number from 0 to 1, or a percent. */\nfunction alphaOf(text: string | undefined): number | null {\n if (text === undefined) {\n return 1;\n }\n const value = text.endsWith(\"%\")\n ? (numberOf(text, \"%\") ?? Number.NaN) / 100\n : numberOf(text, \"\");\n return value === null || Number.isNaN(value)\n ? null\n : roundTo(clampColorChannel(\"alpha\", value), 4);\n}\n\n/** The arguments of `rgb(…)`, `hsl(…)` or `hsb(…)`: commas, or spaces with a `/` before alpha. */\nfunction argumentsOf(body: string): string[] | null {\n if (body.includes(\",\")) {\n const parts = body.split(\",\").map((part) => part.trim());\n return parts.length === 3 || parts.length === 4 ? parts : null;\n }\n const [channels = \"\", alpha, ...rest] = body.split(\"/\");\n if (rest.length > 0) {\n return null;\n }\n const parts = channels.trim().split(/\\s+/);\n if (parts.length !== 3) {\n return null;\n }\n return alpha === undefined ? parts : [...parts, alpha.trim()];\n}\n\n/** A hue in degrees, turned into `[0, 360)`. */\nfunction hueOf(text: string): number | null {\n const value = numberOf(text, \"deg\");\n return value === null ? null : roundTo(((value % 360) + 360) % 360, 2);\n}\n\nfunction parseFunction(name: string, body: string): Color | null {\n const parts = argumentsOf(body);\n if (parts === null) {\n return null;\n }\n const [first = \"\", second = \"\", third = \"\", fourth] = parts;\n const alpha = alphaOf(fourth);\n if (alpha === null) {\n return null;\n }\n const space = name.toLowerCase().replace(/a$/, \"\");\n if (space === \"rgb\") {\n const channels = [first, second, third].map((part) => {\n const value = numberOf(part, \"\");\n return value === null\n ? null\n : Math.round(clampColorChannel(\"red\", value));\n });\n const [red, green, blue] = channels;\n if (red == null || green == null || blue == null) {\n return null;\n }\n return { space: \"rgb\", red, green, blue, alpha };\n }\n const hue = hueOf(first);\n const saturation = numberOf(second, \"%\");\n const last = numberOf(third, \"%\");\n if (hue === null || saturation === null || last === null) {\n return null;\n }\n const percent = (value: number) =>\n roundTo(clampColorChannel(\"saturation\", value), 2);\n return space === \"hsl\"\n ? {\n space: \"hsl\",\n hue,\n saturation: percent(saturation),\n lightness: percent(last),\n alpha,\n }\n : {\n space: \"hsb\",\n hue,\n saturation: percent(saturation),\n brightness: percent(last),\n alpha,\n };\n}\n\n/**\n * A color from its text (spec/color.md, \"Parsing\"): hex (`#rgb`, `#rgba`, `#rrggbb`,\n * `#rrggbbaa`, the `#` optional), `rgb()` / `rgba()`, `hsl()` / `hsla()` and `hsb()` / `hsba()`\n * with commas or spaces (`/` before the alpha); `null` when it is none of them. A color given is\n * returned as it is, so a component can take a `Color` or a string.\n */\nexport function parseColor(value: string | Color): Color | null {\n if (typeof value !== \"string\") {\n return value;\n }\n const text = value.trim();\n const hex = HEX.exec(text);\n if (hex !== null) {\n return parseHex(hex[1] as string);\n }\n const call = FUNCTION.exec(text);\n if (call === null) {\n return null;\n }\n return parseFunction(call[1] as string, call[2] as string);\n}\n","import type { Color } from \"./color-value.ts\";\nimport { parseColor } from \"./parse-color.ts\";\n\n/** The EyeDropper API of a window (Chromium's; not in every browser, spec/color-picker.md). */\ninterface EyeDropperConstructor {\n new (): {\n open(options?: { signal?: AbortSignal }): Promise<{ sRGBHex: string }>;\n };\n}\n\nfunction eyeDropperOf(element: Element): EyeDropperConstructor | undefined {\n const view = element.ownerDocument.defaultView as\n | (Window & { EyeDropper?: unknown })\n | null;\n const api = view?.EyeDropper;\n return typeof api === \"function\"\n ? (api as EyeDropperConstructor)\n : undefined;\n}\n\n/** Whether `element`'s window has the EyeDropper API (spec/color-picker.md, \"EyeDropperTrigger\"). */\nexport function supportsEyeDropper(element: Element): boolean {\n return eyeDropperOf(element) !== undefined;\n}\n\n/**\n * Opens the browser's eyedropper from `element`'s window and resolves with the color the user\n * picked (an opaque rgb color), or `null` when the user cancelled it (Escape), the browser refused\n * it or has no EyeDropper API. It never rejects: a cancelled pick is no error for a picker.\n */\nexport async function openEyeDropper(\n element: Element,\n signal?: AbortSignal,\n): Promise<Color | null> {\n const EyeDropper = eyeDropperOf(element);\n if (EyeDropper === undefined) {\n return null;\n }\n try {\n const result = await new EyeDropper().open(\n signal === undefined ? undefined : { signal },\n );\n return parseColor(result.sRGBHex);\n } catch {\n return null;\n }\n}\n"],"mappings":";AAyDA,MAAM,SAAkD;CACpD,KAAK;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CAChD,OAAO;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CAClD,MAAM;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CACjD,KAAK;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CAChD,YAAY;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CACvD,WAAW;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CACtD,YAAY;EAAE,KAAK;EAAG,KAAK;EAAK,MAAM;EAAG,WAAW;CAAG;CACvD,OAAO;EAAE,KAAK;EAAG,KAAK;EAAG,MAAM;EAAM,WAAW;CAAI;AACxD;AAEA,MAAM,WAGF;CACA,KAAK;EAAC;EAAO;EAAS;CAAM;CAC5B,KAAK;EAAC;EAAO;EAAc;CA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;;AAQA,SAAgB,WAAW,OAAqC;CAC5D,IAAI,OAAO,UAAU,UACjB,OAAO;CAEX,MAAM,OAAO,MAAM,KAAK;CACxB,MAAM,MAAM,IAAI,KAAK,IAAI;CACzB,IAAI,QAAQ,MACR,OAAO,SAAS,IAAI,EAAY;CAEpC,MAAM,OAAO,SAAS,KAAK,IAAI;CAC/B,IAAI,SAAS,MACT,OAAO;CAEX,OAAO,cAAc,KAAK,IAAc,KAAK,EAAY;AAC7D;;AC/HA,SAAS,aAAa,SAAqD;CAIvE,MAAM,MAHO,QAAQ,cAAc,aAGjB;CAClB,OAAO,OAAO,QAAQ,aACf,MACD,KAAA;AACV;;AAGA,SAAgB,mBAAmB,SAA2B;CAC1D,OAAO,aAAa,OAAO,MAAM,KAAA;AACrC;;;;;;AAOA,eAAsB,eAClB,SACA,QACqB;CACrB,MAAM,aAAa,aAAa,OAAO;CACvC,IAAI,eAAe,KAAA,GACf,OAAO;CAEX,IAAI;EAIA,OAAO,YAAW,MAHG,IAAI,WAAW,CAAC,CAAC,KAClC,WAAW,KAAA,IAAY,KAAA,IAAY,EAAE,OAAO,CAChD,EACkB,CAAO,OAAO;CACpC,QAAQ;EACJ,OAAO;CACX;AACJ"}
@@ -0,0 +1,2 @@
1
+ import { A as colorAreaChannels, C as ColorChannel, D as HslColor, E as HsbColor, F as hasColorChannel, I as isSameColor, L as setColorChannel, M as colorChannels, N as colorSpaceFor, O as RgbColor, P as getColorChannel, S as ColorAreaChannels, T as ColorSpace, _ as ColorGradientDirection, a as formatColorChannel, b as colorWheelGradient, c as convertColor, d as isOnColorWheel, f as ColorAreaKeyOptions, g as ColorAreaBackground, h as wrapHue, i as formatColor, j as colorChannelRange, k as clampColorChannel, l as colorWheelThumbOffset, m as colorWheelKeyTarget, n as ColorFormat, o as openEyeDropper, p as colorAreaKeyTarget, r as colorChannelFormat, s as supportsEyeDropper, t as parseColor, u as hueAtPoint, v as colorAreaBackground, w as ColorChannelRange, x as Color, y as colorChannelGradient } from "./index-CWFRduRd.js";
2
+ export { type Color, type ColorAreaBackground, type ColorAreaChannels, type ColorAreaKeyOptions, type ColorChannel, type ColorChannelRange, type ColorFormat, type ColorGradientDirection, type ColorSpace, type HsbColor, type HslColor, type RgbColor, clampColorChannel, colorAreaBackground, colorAreaChannels, colorAreaKeyTarget, colorChannelFormat, colorChannelGradient, colorChannelRange, colorChannels, colorSpaceFor, colorWheelGradient, colorWheelKeyTarget, colorWheelThumbOffset, convertColor, formatColor, formatColorChannel, getColorChannel, hasColorChannel, hueAtPoint, isOnColorWheel, isSameColor, openEyeDropper, parseColor, setColorChannel, supportsEyeDropper, wrapHue };
package/dist/color.js ADDED
@@ -0,0 +1 @@
1
+ export { _ as clampColorChannel, u as colorAreaBackground, v as colorAreaChannels, s as colorAreaKeyTarget, p as colorChannelFormat, d as colorChannelGradient, y as colorChannelRange, b as colorChannels, x as colorSpaceFor, f as colorWheelGradient, c as colorWheelKeyTarget, i as colorWheelThumbOffset, g as convertColor, m as formatColor, h as formatColorChannel, S as getColorChannel, C as hasColorChannel, a as hueAtPoint, o as isOnColorWheel, w as isSameColor, t as openEyeDropper, r as parseColor, T as setColorChannel, n as supportsEyeDropper, l as wrapHue } from "./color-sURV5Irg.js";
@@ -0,0 +1,104 @@
1
+ import { n as stepIndex } from "./list-navigation-CbWv4DK5.js";
2
+ // src/command/command-key-target.ts
3
+ /**
4
+ * The index of the item a key highlights among `count` shown items, from `current` (-1: none):
5
+ * ArrowDown / ArrowUp the next / previous (wrapping with `loop`), Home / End the first / last;
6
+ * `null` for any other key (and Home / End with Shift, which stay native).
7
+ */
8
+ function commandKeyTarget(event, current, count, loop = true) {
9
+ if (event.altKey || event.ctrlKey || event.metaKey) return null;
10
+ switch (event.key) {
11
+ case "ArrowDown": return stepIndex(count, current, 1, { loop });
12
+ case "ArrowUp": return stepIndex(count, current, -1, { loop });
13
+ case "Home": return event.shiftKey ? null : count > 0 ? 0 : -1;
14
+ case "End": return event.shiftKey ? null : count - 1;
15
+ default: return null;
16
+ }
17
+ }
18
+ // src/command/command-score.ts
19
+ /** A keyword's match ranks just under the same match on the value. */
20
+ const KEYWORD_WEIGHT = .95;
21
+ const WORD_SEPARATORS = /[\s\-_/.:]+/;
22
+ /** Case- and accent-insensitive text: NFD, the combining marks removed, lower case. */
23
+ function fold(text) {
24
+ return text.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
25
+ }
26
+ function words(text) {
27
+ return text.split(WORD_SEPARATORS).filter((word) => word !== "");
28
+ }
29
+ /** Every word of the search starts a word of the text, in order. */
30
+ function wordPrefixes(text, search) {
31
+ let from = 0;
32
+ for (const part of search) {
33
+ let found = -1;
34
+ for (let index = from; index < text.length; index += 1) if (text[index]?.startsWith(part)) {
35
+ found = index;
36
+ break;
37
+ }
38
+ if (found === -1) return false;
39
+ from = found + 1;
40
+ }
41
+ return true;
42
+ }
43
+ /** The score of one text (already folded) for the search (folded, trimmed, not empty). */
44
+ function textScore(text, search) {
45
+ if (text === search) return 1;
46
+ if (text.startsWith(search)) return .9;
47
+ const textWords = words(text);
48
+ if (textWords.some((word) => word.startsWith(search))) return .8;
49
+ const searchWords = words(search);
50
+ if (searchWords.length > 1 && wordPrefixes(textWords, searchWords)) return .7;
51
+ return text.includes(search) ? .6 : 0;
52
+ }
53
+ /**
54
+ * The default scorer: the whole text `1`, a prefix `0.9`, a word's prefix `0.8`, every search
55
+ * word starting a word in order `0.7`, a substring `0.6`, else `0`; a keyword's score is
56
+ * `0.95` of the same match on the value. An empty search scores `1`.
57
+ */
58
+ function commandScore(value, search, keywords = []) {
59
+ const query = fold(search.trim());
60
+ if (query === "") return 1;
61
+ let best = textScore(fold(value), query);
62
+ for (const keyword of keywords) {
63
+ if (best === 1) break;
64
+ best = Math.max(best, textScore(fold(keyword), query) * KEYWORD_WEIGHT);
65
+ }
66
+ return best;
67
+ }
68
+ /** An item's score as a Command shows it: forced items and an empty search or no filter, `1`. */
69
+ function commandItemScore(value, search, keywords, filter, forceMount = false) {
70
+ const query = search.trim();
71
+ if (forceMount || filter === null || query === "") return 1;
72
+ return filter(value, query, keywords);
73
+ }
74
+ /** The entries matching the search, in order, with their scores. */
75
+ function commandMatches(entries, search, filter) {
76
+ const matching = [];
77
+ const scores = [];
78
+ for (const entry of entries) {
79
+ const score = commandItemScore(entry.value, search, entry.keywords ?? [], filter);
80
+ if (score > 0) {
81
+ matching.push(entry);
82
+ scores.push(score);
83
+ }
84
+ }
85
+ return {
86
+ entries: matching,
87
+ scores
88
+ };
89
+ }
90
+ /** The index of the best-scoring enabled entry (the first among equals), or `-1`. */
91
+ function bestMatch(scores, disabled = () => false) {
92
+ let best = -1;
93
+ let bestScore = 0;
94
+ scores.forEach((score, index) => {
95
+ if (score > bestScore && !disabled(index)) {
96
+ best = index;
97
+ bestScore = score;
98
+ }
99
+ });
100
+ return best;
101
+ }
102
+ export { commandKeyTarget as a, commandScore as i, commandItemScore as n, commandMatches as r, bestMatch as t };
103
+
104
+ //# sourceMappingURL=command-DueCXi65.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-DueCXi65.js","names":[],"sources":["../src/command/command-key-target.ts","../src/command/command-score.ts"],"sourcesContent":["// A command palette's keys over its shown items (spec/command.md, \"Keyboard\"). Pure.\n\nimport { stepIndex } from \"../collection/list-navigation.ts\";\n\n/**\n * The index of the item a key highlights among `count` shown items, from `current` (-1: none):\n * ArrowDown / ArrowUp the next / previous (wrapping with `loop`), Home / End the first / last;\n * `null` for any other key (and Home / End with Shift, which stay native).\n */\nexport function commandKeyTarget(\n event: Pick<\n KeyboardEvent,\n \"key\" | \"shiftKey\" | \"altKey\" | \"ctrlKey\" | \"metaKey\"\n >,\n current: number,\n count: number,\n loop = true,\n): number | null {\n if (event.altKey || event.ctrlKey || event.metaKey) {\n return null;\n }\n switch (event.key) {\n case \"ArrowDown\":\n return stepIndex(count, current, 1, { loop });\n case \"ArrowUp\":\n return stepIndex(count, current, -1, { loop });\n case \"Home\":\n return event.shiftKey ? null : count > 0 ? 0 : -1;\n case \"End\":\n return event.shiftKey ? null : count - 1;\n default:\n return null;\n }\n}\n","// A command palette's scorer (spec/command.md, \"The scorer\"): how well an item's text matches\n// the typed text, from 0 (no match) to 1. Pure.\n\n/** An item's score for the typed text: `0` hides it. */\nexport type CommandFilter = (\n value: string,\n search: string,\n keywords: readonly string[],\n) => number;\n\n/** A keyword's match ranks just under the same match on the value. */\nconst KEYWORD_WEIGHT = 0.95;\n\nconst WORD_SEPARATORS = /[\\s\\-_/.:]+/;\n\n/** Case- and accent-insensitive text: NFD, the combining marks removed, lower case. */\nfunction fold(text: string): string {\n return text.normalize(\"NFD\").replace(/\\p{M}/gu, \"\").toLowerCase();\n}\n\nfunction words(text: string): string[] {\n return text.split(WORD_SEPARATORS).filter((word) => word !== \"\");\n}\n\n/** Every word of the search starts a word of the text, in order. */\nfunction wordPrefixes(text: readonly string[], search: readonly string[]) {\n let from = 0;\n for (const part of search) {\n let found = -1;\n for (let index = from; index < text.length; index += 1) {\n if (text[index]?.startsWith(part)) {\n found = index;\n break;\n }\n }\n if (found === -1) {\n return false;\n }\n from = found + 1;\n }\n return true;\n}\n\n/** The score of one text (already folded) for the search (folded, trimmed, not empty). */\nfunction textScore(text: string, search: string): number {\n if (text === search) {\n return 1;\n }\n if (text.startsWith(search)) {\n return 0.9;\n }\n const textWords = words(text);\n if (textWords.some((word) => word.startsWith(search))) {\n return 0.8;\n }\n const searchWords = words(search);\n if (searchWords.length > 1 && wordPrefixes(textWords, searchWords)) {\n return 0.7;\n }\n return text.includes(search) ? 0.6 : 0;\n}\n\n/**\n * The default scorer: the whole text `1`, a prefix `0.9`, a word's prefix `0.8`, every search\n * word starting a word in order `0.7`, a substring `0.6`, else `0`; a keyword's score is\n * `0.95` of the same match on the value. An empty search scores `1`.\n */\nexport function commandScore(\n value: string,\n search: string,\n keywords: readonly string[] = [],\n): number {\n const query = fold(search.trim());\n if (query === \"\") {\n return 1;\n }\n let best = textScore(fold(value), query);\n for (const keyword of keywords) {\n if (best === 1) {\n break;\n }\n best = Math.max(best, textScore(fold(keyword), query) * KEYWORD_WEIGHT);\n }\n return best;\n}\n\n/** An item's score as a Command shows it: forced items and an empty search or no filter, `1`. */\nexport function commandItemScore(\n value: string,\n search: string,\n keywords: readonly string[],\n filter: CommandFilter | null,\n forceMount = false,\n): number {\n const query = search.trim();\n if (forceMount || filter === null || query === \"\") {\n return 1;\n }\n return filter(value, query, keywords);\n}\n\n/** An entry of a list the toolkit filters (a virtual Command list's `items`). */\nexport interface CommandEntry {\n value: string;\n keywords?: readonly string[];\n disabled?: boolean;\n}\n\nexport interface CommandMatches<Entry> {\n /** The matching entries, in their order. */\n entries: Entry[];\n /** Each matching entry's score. */\n scores: number[];\n}\n\n/** The entries matching the search, in order, with their scores. */\nexport function commandMatches<Entry extends CommandEntry>(\n entries: readonly Entry[],\n search: string,\n filter: CommandFilter | null,\n): CommandMatches<Entry> {\n const matching: Entry[] = [];\n const scores: number[] = [];\n for (const entry of entries) {\n const score = commandItemScore(\n entry.value,\n search,\n entry.keywords ?? [],\n filter,\n );\n if (score > 0) {\n matching.push(entry);\n scores.push(score);\n }\n }\n return { entries: matching, scores };\n}\n\n/** The index of the best-scoring enabled entry (the first among equals), or `-1`. */\nexport function bestMatch(\n scores: readonly number[],\n disabled: (index: number) => boolean = () => false,\n): number {\n let best = -1;\n let bestScore = 0;\n scores.forEach((score, index) => {\n if (score > bestScore && !disabled(index)) {\n best = index;\n bestScore = score;\n }\n });\n return best;\n}\n"],"mappings":";;;;;;;AASA,SAAgB,iBACZ,OAIA,SACA,OACA,OAAO,MACM;CACb,IAAI,MAAM,UAAU,MAAM,WAAW,MAAM,SACvC,OAAO;CAEX,QAAQ,MAAM,KAAd;EACI,KAAK,aACD,OAAO,UAAU,OAAO,SAAS,GAAG,EAAE,KAAK,CAAC;EAChD,KAAK,WACD,OAAO,UAAU,OAAO,SAAS,IAAI,EAAE,KAAK,CAAC;EACjD,KAAK,QACD,OAAO,MAAM,WAAW,OAAO,QAAQ,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KAAK,IAAI,MAAM,UAAU,KAAK,OAAO,GAAG,KAAK,IAAI,cAAc;CAC1E;CACA,OAAO;AACX;;AAGA,SAAgB,iBACZ,OACA,QACA,UACA,QACA,aAAa,OACP;CACN,MAAM,QAAQ,OAAO,KAAK;CAC1B,IAAI,cAAc,WAAW,QAAQ,UAAU,IAC3C,OAAO;CAEX,OAAO,OAAO,OAAO,OAAO,QAAQ;AACxC;;AAiBA,SAAgB,eACZ,SACA,QACA,QACqB;CACrB,MAAM,WAAoB,CAAC;CAC3B,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,SAAS,SAAS;EACzB,MAAM,QAAQ,iBACV,MAAM,OACN,QACA,MAAM,YAAY,CAAC,GACnB,MACJ;EACA,IAAI,QAAQ,GAAG;GACX,SAAS,KAAK,KAAK;GACnB,OAAO,KAAK,KAAK;EACrB;CACJ;CACA,OAAO;EAAE,SAAS;EAAU;CAAO;AACvC;;AAGA,SAAgB,UACZ,QACA,iBAA6C,OACvC;CACN,IAAI,OAAO;CACX,IAAI,YAAY;CAChB,OAAO,SAAS,OAAO,UAAU;EAC7B,IAAI,QAAQ,aAAa,CAAC,SAAS,KAAK,GAAG;GACvC,OAAO;GACP,YAAY;EAChB;CACJ,CAAC;CACD,OAAO;AACX"}
@@ -0,0 +1,2 @@
1
+ import { a as commandItemScore, c as commandKeyTarget, i as bestMatch, n as CommandFilter, o as commandMatches, r as CommandMatches, s as commandScore, t as CommandEntry } from "./index-CkrHWyU_.js";
2
+ export { type CommandEntry, type CommandFilter, type CommandMatches, bestMatch, commandItemScore, commandKeyTarget, commandMatches, commandScore };
@@ -0,0 +1 @@
1
+ export { t as bestMatch, n as commandItemScore, a as commandKeyTarget, r as commandMatches, i as commandScore } from "./command-DueCXi65.js";
@@ -0,0 +1,215 @@
1
+ // src/date/plain-date.ts
2
+ /** Builds a date, normalizing overflow (`{ month: 13 }` is January of the next year). */
3
+ function plainDate(year, month, day) {
4
+ const date = new Date(Date.UTC(year, month - 1, day));
5
+ return {
6
+ year: date.getUTCFullYear(),
7
+ month: date.getUTCMonth() + 1,
8
+ day: date.getUTCDate()
9
+ };
10
+ }
11
+ /** The local date of `now` (the clock the page sees). */
12
+ function today(now = /* @__PURE__ */ new Date()) {
13
+ return {
14
+ year: now.getFullYear(),
15
+ month: now.getMonth() + 1,
16
+ day: now.getDate()
17
+ };
18
+ }
19
+ /** Negative when `a` is before `b`, positive when after, 0 when the same day. */
20
+ function compareDates(a, b) {
21
+ return a.year - b.year || a.month - b.month || a.day - b.day;
22
+ }
23
+ function isSameDate(a, b) {
24
+ return a != null && b != null && compareDates(a, b) === 0;
25
+ }
26
+ function isSameMonth(a, b) {
27
+ return a.year === b.year && a.month === b.month;
28
+ }
29
+ /** `2026-11-20` */
30
+ function toIsoDate(date) {
31
+ const pad = (value, size) => String(value).padStart(size, "0");
32
+ return `${pad(date.year, 4)}-${pad(date.month, 2)}-${pad(date.day, 2)}`;
33
+ }
34
+ /** Parses `YYYY-MM-DD`; `null` when the text is not a valid date. */
35
+ function fromIsoDate(text) {
36
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
37
+ if (match === null) return null;
38
+ const [year, month, day] = [
39
+ Number(match[1]),
40
+ Number(match[2]),
41
+ Number(match[3])
42
+ ];
43
+ const date = plainDate(year, month, day);
44
+ return date.month === month && date.day === day ? date : null;
45
+ }
46
+ /** A `Date` at local midnight of the day, for `Intl` formatting. */
47
+ function toLocalDate(date) {
48
+ return new Date(date.year, date.month - 1, date.day);
49
+ }
50
+ // src/date/date-math.ts
51
+ function daysInMonth(year, month) {
52
+ return new Date(Date.UTC(year, month, 0)).getUTCDate();
53
+ }
54
+ function addDays(date, days) {
55
+ return plainDate(date.year, date.month, date.day + days);
56
+ }
57
+ /** The same day `months` later, clamped to the target month's last day (Jan 31 + 1 = Feb 28). */
58
+ function addMonths(date, months) {
59
+ const first = plainDate(date.year, date.month + months, 1);
60
+ return {
61
+ ...first,
62
+ day: Math.min(date.day, daysInMonth(first.year, first.month))
63
+ };
64
+ }
65
+ function addYears(date, years) {
66
+ return addMonths(date, years * 12);
67
+ }
68
+ function startOfMonth(date) {
69
+ return {
70
+ year: date.year,
71
+ month: date.month,
72
+ day: 1
73
+ };
74
+ }
75
+ function endOfMonth(date) {
76
+ return {
77
+ year: date.year,
78
+ month: date.month,
79
+ day: daysInMonth(date.year, date.month)
80
+ };
81
+ }
82
+ /** 0 = Sunday … 6 = Saturday. */
83
+ function dayOfWeek(date) {
84
+ return new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay();
85
+ }
86
+ /** The first day of the date's week, given the locale's first day (0 = Sunday). */
87
+ function startOfWeek(date, firstDayOfWeek) {
88
+ return addDays(date, -((dayOfWeek(date) - firstDayOfWeek + 7) % 7));
89
+ }
90
+ function endOfWeek(date, firstDayOfWeek) {
91
+ return addDays(startOfWeek(date, firstDayOfWeek), 6);
92
+ }
93
+ /** Whether `date` is inside `[min, max]` (each bound optional). */
94
+ function isWithinBounds(date, min, max) {
95
+ return (min == null || compareDates(date, min) >= 0) && (max == null || compareDates(date, max) <= 0);
96
+ }
97
+ /** `date` moved into `[min, max]`. */
98
+ function clampDate(date, min, max) {
99
+ if (min != null && compareDates(date, min) < 0) return min;
100
+ if (max != null && compareDates(date, max) > 0) return max;
101
+ return date;
102
+ }
103
+ /** Whether `date` is in `[a, b]`, whatever the order of `a` and `b`. */
104
+ function isBetween(date, a, b) {
105
+ const [low, high] = compareDates(a, b) <= 0 ? [a, b] : [b, a];
106
+ return compareDates(date, low) >= 0 && compareDates(date, high) <= 0;
107
+ }
108
+ /** The difference in whole months from `a`'s month to `b`'s month. */
109
+ function monthsBetween(a, b) {
110
+ return (b.year - a.year) * 12 + (b.month - a.month);
111
+ }
112
+ // src/date/calendar-keys.ts
113
+ /**
114
+ * The date a key moves the focused date to in a calendar grid (spec/calendar.md, "Keyboard", the
115
+ * APG date grid), or `null` when the key does not move it.
116
+ */
117
+ function calendarKeyTarget(key, focused, { rtl, firstDayOfWeek, shiftKey }) {
118
+ switch (key) {
119
+ case "ArrowRight": return addDays(focused, rtl ? -1 : 1);
120
+ case "ArrowLeft": return addDays(focused, rtl ? 1 : -1);
121
+ case "ArrowDown": return addDays(focused, 7);
122
+ case "ArrowUp": return addDays(focused, -7);
123
+ case "Home": return startOfWeek(focused, firstDayOfWeek);
124
+ case "End": return endOfWeek(focused, firstDayOfWeek);
125
+ case "PageDown": return shiftKey ? addYears(focused, 1) : addMonths(focused, 1);
126
+ case "PageUp": return shiftKey ? addYears(focused, -1) : addMonths(focused, -1);
127
+ default: return null;
128
+ }
129
+ }
130
+ // src/date/locale-data.ts
131
+ const SUNDAY_REGIONS = /* @__PURE__ */ new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" "));
132
+ const SATURDAY_REGIONS = /* @__PURE__ */ new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
133
+ /** The locale's first day of the week, 0 = Sunday (spec/calendar.md, `firstDayOfWeek`). */
134
+ function firstDayOfWeek(locale) {
135
+ const intlLocale = new Intl.Locale(locale);
136
+ const info = intlLocale.getWeekInfo?.() ?? intlLocale.weekInfo;
137
+ if (info !== void 0) return info.firstDay % 7;
138
+ const region = intlLocale.maximize().region ?? "";
139
+ if (SUNDAY_REGIONS.has(region)) return 0;
140
+ return SATURDAY_REGIONS.has(region) ? 6 : 1;
141
+ }
142
+ /** The seven weekdays in the locale's order. */
143
+ function weekdays(locale, firstDay) {
144
+ const short = new Intl.DateTimeFormat(locale, { weekday: "short" });
145
+ const long = new Intl.DateTimeFormat(locale, { weekday: "long" });
146
+ const start = startOfWeek({
147
+ year: 2026,
148
+ month: 11,
149
+ day: 1
150
+ }, firstDay);
151
+ return Array.from({ length: 7 }, (_, offset) => {
152
+ const local = toLocalDate(addDays(start, offset));
153
+ return {
154
+ index: local.getDay(),
155
+ short: short.format(local),
156
+ long: long.format(local)
157
+ };
158
+ });
159
+ }
160
+ /** "November 2026" (`Intl` `month: "long", year: "numeric"`). */
161
+ function formatMonthYear(locale, date) {
162
+ return new Intl.DateTimeFormat(locale, {
163
+ month: "long",
164
+ year: "numeric"
165
+ }).format(toLocalDate(date));
166
+ }
167
+ /** "Friday, November 20, 2026" (`Intl` `dateStyle: "full"`). */
168
+ function formatFullDate(locale, date) {
169
+ return new Intl.DateTimeFormat(locale, { dateStyle: "full" }).format(toLocalDate(date));
170
+ }
171
+ /** "20" (`Intl` `day: "numeric"`). */
172
+ function formatDayNumber(locale, date) {
173
+ return new Intl.DateTimeFormat(locale, { day: "numeric" }).format(toLocalDate(date));
174
+ }
175
+ // src/date/month-grid.ts
176
+ /**
177
+ * The 6 weeks shown for a month (spec/calendar.md: always 6 rows, so the grid never changes
178
+ * height), starting on the locale's first day of the week.
179
+ */
180
+ function monthGrid(year, month, firstDayOfWeek) {
181
+ let cursor = startOfWeek({
182
+ year,
183
+ month,
184
+ day: 1
185
+ }, firstDayOfWeek);
186
+ const weeks = [];
187
+ for (let week = 0; week < 6; week++) {
188
+ const days = [];
189
+ for (let day = 0; day < 7; day++) {
190
+ days.push(cursor);
191
+ cursor = addDays(cursor, 1);
192
+ }
193
+ weeks.push(days);
194
+ }
195
+ return weeks;
196
+ }
197
+ // src/date/watch-document-language.ts
198
+ /**
199
+ * Calls `onChange` when the `lang` of `doc`'s document element changes (spec/calendar.md, "API":
200
+ * a calendar with no `locale` follows the document's language after mount, Epic #49). Returns the
201
+ * cleanup.
202
+ */
203
+ function watchDocumentLanguage(doc, onChange) {
204
+ const Observer = doc.defaultView?.MutationObserver;
205
+ if (Observer === void 0) return () => {};
206
+ const observer = new Observer(() => onChange());
207
+ observer.observe(doc.documentElement, {
208
+ attributes: true,
209
+ attributeFilter: ["lang"]
210
+ });
211
+ return () => observer.disconnect();
212
+ }
213
+ export { fromIsoDate as C, toIsoDate as D, plainDate as E, toLocalDate as O, compareDates as S, isSameMonth as T, isBetween as _, formatFullDate as a, startOfMonth as b, calendarKeyTarget as c, addYears as d, clampDate as f, endOfWeek as g, endOfMonth as h, formatDayNumber as i, today as k, addDays as l, daysInMonth as m, monthGrid as n, formatMonthYear as o, dayOfWeek as p, firstDayOfWeek as r, weekdays as s, watchDocumentLanguage as t, addMonths as u, isWithinBounds as v, isSameDate as w, startOfWeek as x, monthsBetween as y };
214
+
215
+ //# sourceMappingURL=date-CrbFSJKQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-CrbFSJKQ.js","names":[],"sources":["../src/date/plain-date.ts","../src/date/date-math.ts","../src/date/calendar-keys.ts","../src/date/locale-data.ts","../src/date/month-grid.ts","../src/date/watch-document-language.ts"],"sourcesContent":["/**\n * A calendar date with no time and no time zone (spec/calendar.md, \"Dates\"). `month` is 1–12.\n * Values are plain, immutable objects: every function returns a new one.\n */\nexport interface PlainDate {\n readonly year: number;\n readonly month: number;\n readonly day: number;\n}\n\n/** A range of dates, `start <= end`. */\nexport interface DateRange {\n readonly start: PlainDate;\n readonly end: PlainDate;\n}\n\n/** Builds a date, normalizing overflow (`{ month: 13 }` is January of the next year). */\nexport function plainDate(year: number, month: number, day: number): PlainDate {\n const date = new Date(Date.UTC(year, month - 1, day));\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n };\n}\n\n/** The local date of `now` (the clock the page sees). */\nexport function today(now: Date = new Date()): PlainDate {\n return {\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n };\n}\n\n/** Negative when `a` is before `b`, positive when after, 0 when the same day. */\nexport function compareDates(a: PlainDate, b: PlainDate): number {\n return a.year - b.year || a.month - b.month || a.day - b.day;\n}\n\nexport function isSameDate(\n a: PlainDate | null | undefined,\n b: PlainDate | null | undefined,\n): boolean {\n return a != null && b != null && compareDates(a, b) === 0;\n}\n\nexport function isSameMonth(a: PlainDate, b: PlainDate): boolean {\n return a.year === b.year && a.month === b.month;\n}\n\n/** `2026-11-20` */\nexport function toIsoDate(date: PlainDate): string {\n const pad = (value: number, size: number) =>\n String(value).padStart(size, \"0\");\n return `${pad(date.year, 4)}-${pad(date.month, 2)}-${pad(date.day, 2)}`;\n}\n\n/** Parses `YYYY-MM-DD`; `null` when the text is not a valid date. */\nexport function fromIsoDate(text: string): PlainDate | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(text);\n if (match === null) {\n return null;\n }\n const [year, month, day] = [\n Number(match[1]),\n Number(match[2]),\n Number(match[3]),\n ];\n const date = plainDate(year, month, day);\n return date.month === month && date.day === day ? date : null;\n}\n\n/** A `Date` at local midnight of the day, for `Intl` formatting. */\nexport function toLocalDate(date: PlainDate): Date {\n return new Date(date.year, date.month - 1, date.day);\n}\n","import { compareDates, type PlainDate, plainDate } from \"./plain-date.ts\";\n\nexport function daysInMonth(year: number, month: number): number {\n return new Date(Date.UTC(year, month, 0)).getUTCDate();\n}\n\nexport function addDays(date: PlainDate, days: number): PlainDate {\n return plainDate(date.year, date.month, date.day + days);\n}\n\n/** The same day `months` later, clamped to the target month's last day (Jan 31 + 1 = Feb 28). */\nexport function addMonths(date: PlainDate, months: number): PlainDate {\n const first = plainDate(date.year, date.month + months, 1);\n return {\n ...first,\n day: Math.min(date.day, daysInMonth(first.year, first.month)),\n };\n}\n\nexport function addYears(date: PlainDate, years: number): PlainDate {\n return addMonths(date, years * 12);\n}\n\nexport function startOfMonth(date: PlainDate): PlainDate {\n return { year: date.year, month: date.month, day: 1 };\n}\n\nexport function endOfMonth(date: PlainDate): PlainDate {\n return {\n year: date.year,\n month: date.month,\n day: daysInMonth(date.year, date.month),\n };\n}\n\n/** 0 = Sunday … 6 = Saturday. */\nexport function dayOfWeek(date: PlainDate): number {\n return new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay();\n}\n\n/** The first day of the date's week, given the locale's first day (0 = Sunday). */\nexport function startOfWeek(\n date: PlainDate,\n firstDayOfWeek: number,\n): PlainDate {\n return addDays(date, -((dayOfWeek(date) - firstDayOfWeek + 7) % 7));\n}\n\nexport function endOfWeek(date: PlainDate, firstDayOfWeek: number): PlainDate {\n return addDays(startOfWeek(date, firstDayOfWeek), 6);\n}\n\n/** Whether `date` is inside `[min, max]` (each bound optional). */\nexport function isWithinBounds(\n date: PlainDate,\n min?: PlainDate | null,\n max?: PlainDate | null,\n): boolean {\n return (\n (min == null || compareDates(date, min) >= 0) &&\n (max == null || compareDates(date, max) <= 0)\n );\n}\n\n/** `date` moved into `[min, max]`. */\nexport function clampDate(\n date: PlainDate,\n min?: PlainDate | null,\n max?: PlainDate | null,\n): PlainDate {\n if (min != null && compareDates(date, min) < 0) {\n return min;\n }\n if (max != null && compareDates(date, max) > 0) {\n return max;\n }\n return date;\n}\n\n/** Whether `date` is in `[a, b]`, whatever the order of `a` and `b`. */\nexport function isBetween(\n date: PlainDate,\n a: PlainDate,\n b: PlainDate,\n): boolean {\n const [low, high] = compareDates(a, b) <= 0 ? [a, b] : [b, a];\n return compareDates(date, low) >= 0 && compareDates(date, high) <= 0;\n}\n\n/** The difference in whole months from `a`'s month to `b`'s month. */\nexport function monthsBetween(a: PlainDate, b: PlainDate): number {\n return (b.year - a.year) * 12 + (b.month - a.month);\n}\n","import {\n addDays,\n addMonths,\n addYears,\n endOfWeek,\n startOfWeek,\n} from \"./date-math.ts\";\nimport type { PlainDate } from \"./plain-date.ts\";\n\nexport interface CalendarKeyOptions {\n rtl: boolean;\n firstDayOfWeek: number;\n shiftKey: boolean;\n}\n\n/**\n * The date a key moves the focused date to in a calendar grid (spec/calendar.md, \"Keyboard\", the\n * APG date grid), or `null` when the key does not move it.\n */\nexport function calendarKeyTarget(\n key: string,\n focused: PlainDate,\n { rtl, firstDayOfWeek, shiftKey }: CalendarKeyOptions,\n): PlainDate | null {\n switch (key) {\n case \"ArrowRight\":\n return addDays(focused, rtl ? -1 : 1);\n case \"ArrowLeft\":\n return addDays(focused, rtl ? 1 : -1);\n case \"ArrowDown\":\n return addDays(focused, 7);\n case \"ArrowUp\":\n return addDays(focused, -7);\n case \"Home\":\n return startOfWeek(focused, firstDayOfWeek);\n case \"End\":\n return endOfWeek(focused, firstDayOfWeek);\n case \"PageDown\":\n return shiftKey ? addYears(focused, 1) : addMonths(focused, 1);\n case \"PageUp\":\n return shiftKey ? addYears(focused, -1) : addMonths(focused, -1);\n default:\n return null;\n }\n}\n","import { addDays, startOfWeek } from \"./date-math.ts\";\nimport { type PlainDate, toLocalDate } from \"./plain-date.ts\";\n\nexport interface Weekday {\n /** 0 = Sunday … 6 = Saturday. */\n readonly index: number;\n /** `Intl` `weekday: \"short\"`. */\n readonly short: string;\n /** `Intl` `weekday: \"long\"`. */\n readonly long: string;\n}\n\n// Regions whose week starts on Sunday or Saturday (CLDR), for engines without Intl week info.\nconst SUNDAY_REGIONS = /* @__PURE__ */ new Set(\n \"AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW\".split(\n \" \",\n ),\n);\nconst SATURDAY_REGIONS = /* @__PURE__ */ new Set(\n \"AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY\".split(\" \"),\n);\n\ninterface LocaleWithWeekInfo extends Intl.Locale {\n getWeekInfo?: () => { firstDay: number };\n weekInfo?: { firstDay: number };\n}\n\n/** The locale's first day of the week, 0 = Sunday (spec/calendar.md, `firstDayOfWeek`). */\nexport function firstDayOfWeek(locale: string): number {\n const intlLocale = new Intl.Locale(locale) as LocaleWithWeekInfo;\n const info = intlLocale.getWeekInfo?.() ?? intlLocale.weekInfo;\n if (info !== undefined) {\n return info.firstDay % 7;\n }\n const region = intlLocale.maximize().region ?? \"\";\n if (SUNDAY_REGIONS.has(region)) {\n return 0;\n }\n return SATURDAY_REGIONS.has(region) ? 6 : 1;\n}\n\n/** The seven weekdays in the locale's order. */\nexport function weekdays(locale: string, firstDay: number): Weekday[] {\n const short = new Intl.DateTimeFormat(locale, { weekday: \"short\" });\n const long = new Intl.DateTimeFormat(locale, { weekday: \"long\" });\n // 2026-11-01 is a Sunday: any week works, the names only depend on the weekday\n const start = startOfWeek({ year: 2026, month: 11, day: 1 }, firstDay);\n return Array.from({ length: 7 }, (_, offset) => {\n const date = addDays(start, offset);\n const local = toLocalDate(date);\n return {\n index: local.getDay(),\n short: short.format(local),\n long: long.format(local),\n };\n });\n}\n\n/** \"November 2026\" (`Intl` `month: \"long\", year: \"numeric\"`). */\nexport function formatMonthYear(locale: string, date: PlainDate): string {\n return new Intl.DateTimeFormat(locale, {\n month: \"long\",\n year: \"numeric\",\n }).format(toLocalDate(date));\n}\n\n/** \"Friday, November 20, 2026\" (`Intl` `dateStyle: \"full\"`). */\nexport function formatFullDate(locale: string, date: PlainDate): string {\n return new Intl.DateTimeFormat(locale, { dateStyle: \"full\" }).format(\n toLocalDate(date),\n );\n}\n\n/** \"20\" (`Intl` `day: \"numeric\"`). */\nexport function formatDayNumber(locale: string, date: PlainDate): string {\n return new Intl.DateTimeFormat(locale, { day: \"numeric\" }).format(\n toLocalDate(date),\n );\n}\n","import { addDays, startOfWeek } from \"./date-math.ts\";\nimport type { PlainDate } from \"./plain-date.ts\";\n\n/**\n * The 6 weeks shown for a month (spec/calendar.md: always 6 rows, so the grid never changes\n * height), starting on the locale's first day of the week.\n */\nexport function monthGrid(\n year: number,\n month: number,\n firstDayOfWeek: number,\n): PlainDate[][] {\n let cursor = startOfWeek({ year, month, day: 1 }, firstDayOfWeek);\n const weeks: PlainDate[][] = [];\n for (let week = 0; week < 6; week++) {\n const days: PlainDate[] = [];\n for (let day = 0; day < 7; day++) {\n days.push(cursor);\n cursor = addDays(cursor, 1);\n }\n weeks.push(days);\n }\n return weeks;\n}\n","/**\n * Calls `onChange` when the `lang` of `doc`'s document element changes (spec/calendar.md, \"API\":\n * a calendar with no `locale` follows the document's language after mount, Epic #49). Returns the\n * cleanup.\n */\nexport function watchDocumentLanguage(\n doc: Document,\n onChange: () => void,\n): () => void {\n const Observer = doc.defaultView?.MutationObserver;\n if (Observer === undefined) {\n return () => {};\n }\n const observer = new Observer(() => onChange());\n observer.observe(doc.documentElement, {\n attributes: true,\n attributeFilter: [\"lang\"],\n });\n return () => observer.disconnect();\n}\n"],"mappings":";;AAiBA,SAAgB,UAAU,MAAc,OAAe,KAAwB;CAC3E,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;CACpD,OAAO;EACH,MAAM,KAAK,eAAe;EAC1B,OAAO,KAAK,YAAY,IAAI;EAC5B,KAAK,KAAK,WAAW;CACzB;AACJ;;AAGA,SAAgB,MAAM,sBAAY,IAAI,KAAK,GAAc;CACrD,OAAO;EACH,MAAM,IAAI,YAAY;EACtB,OAAO,IAAI,SAAS,IAAI;EACxB,KAAK,IAAI,QAAQ;CACrB;AACJ;;AAGA,SAAgB,aAAa,GAAc,GAAsB;CAC7D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE;AAC7D;AAEA,SAAgB,WACZ,GACA,GACO;CACP,OAAO,KAAK,QAAQ,KAAK,QAAQ,aAAa,GAAG,CAAC,MAAM;AAC5D;AAEA,SAAgB,YAAY,GAAc,GAAuB;CAC7D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE;AAC9C;;AAGA,SAAgB,UAAU,MAAyB;CAC/C,MAAM,OAAO,OAAe,SACxB,OAAO,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG;CACpC,OAAO,GAAG,IAAI,KAAK,MAAM,CAAC,EAAE,GAAG,IAAI,KAAK,OAAO,CAAC,EAAE,GAAG,IAAI,KAAK,KAAK,CAAC;AACxE;;AAGA,SAAgB,YAAY,MAAgC;CACxD,MAAM,QAAQ,4BAA4B,KAAK,IAAI;CACnD,IAAI,UAAU,MACV,OAA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CAAC,CAAC,OAC1D,YAAY,IAAI,CACpB;AACJ;;AAGA,SAAgB,gBAAgB,QAAgB,MAAyB;CACrE,OAAO,IAAI,KAAK,eAAe,QAAQ,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,OACvD,YAAY,IAAI,CACpB;AACJ;;;;;;ACvEA,SAAgB,UACZ,MACA,OACA,gBACa;CACb,IAAI,SAAS,YAAY;EAAE;EAAM;EAAO,KAAK;CAAE,GAAG,cAAc;CAChE,MAAM,QAAuB,CAAC;CAC9B,KAAK,IAAI,OAAO,GAAG,OAAO,GAAG,QAAQ;EACjC,MAAM,OAAoB,CAAC;EAC3B,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO;GAC9B,KAAK,KAAK,MAAM;GAChB,SAAS,QAAQ,QAAQ,CAAC;EAC9B;EACA,MAAM,KAAK,IAAI;CACnB;CACA,OAAO;AACX;;;;;;;AClBA,SAAgB,sBACZ,KACA,UACU;CACV,MAAM,WAAW,IAAI,aAAa;CAClC,IAAI,aAAa,KAAA,GACb,aAAa,CAAC;CAElB,MAAM,WAAW,IAAI,eAAe,SAAS,CAAC;CAC9C,SAAS,QAAQ,IAAI,iBAAiB;EAClC,YAAY;EACZ,iBAAiB,CAAC,MAAM;CAC5B,CAAC;CACD,aAAa,SAAS,WAAW;AACrC"}
package/dist/date.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { a as isSameDate, c as toIsoDate, i as fromIsoDate, l as toLocalDate, n as PlainDate, o as isSameMonth, r as compareDates, s as plainDate, t as DateRange, u as today } from "./plain-date-idQH1P6X.js";
2
+ import { n as calendarKeyTarget, t as CalendarKeyOptions } from "./calendar-keys-DGYpjLwv.js";
3
+ import { _ as isBetween, a as formatDayNumber, b as startOfMonth, c as weekdays, d as addYears, f as clampDate, g as endOfWeek, h as endOfMonth, i as firstDayOfWeek, l as addDays, m as daysInMonth, n as monthGrid, o as formatFullDate, p as dayOfWeek, r as Weekday, s as formatMonthYear, t as watchDocumentLanguage, u as addMonths, v as isWithinBounds, x as startOfWeek, y as monthsBetween } from "./index-B0rwIZw9.js";
4
+ export { type CalendarKeyOptions, type DateRange, type PlainDate, type Weekday, addDays, addMonths, addYears, calendarKeyTarget, clampDate, compareDates, dayOfWeek, daysInMonth, endOfMonth, endOfWeek, firstDayOfWeek, formatDayNumber, formatFullDate, formatMonthYear, fromIsoDate, isBetween, isSameDate, isSameMonth, isWithinBounds, monthGrid, monthsBetween, plainDate, startOfMonth, startOfWeek, toIsoDate, toLocalDate, today, watchDocumentLanguage, weekdays };
package/dist/date.js ADDED
@@ -0,0 +1 @@
1
+ export { l as addDays, u as addMonths, d as addYears, c as calendarKeyTarget, f as clampDate, S as compareDates, p as dayOfWeek, m as daysInMonth, h as endOfMonth, g as endOfWeek, r as firstDayOfWeek, i as formatDayNumber, a as formatFullDate, o as formatMonthYear, C as fromIsoDate, _ as isBetween, w as isSameDate, T as isSameMonth, v as isWithinBounds, n as monthGrid, y as monthsBetween, E as plainDate, b as startOfMonth, x as startOfWeek, D as toIsoDate, O as toLocalDate, k as today, t as watchDocumentLanguage, s as weekdays } from "./date-CrbFSJKQ.js";
@@ -0,0 +1,8 @@
1
+ type Direction = "ltr" | "rtl";
2
+ /**
3
+ * The reading direction for an element (spec/direction.md): the direction a DirectionProvider
4
+ * gives, when there is one around it (`provided`), else the element's computed `direction` (falls
5
+ * back to `ltr`).
6
+ */
7
+ declare function getDirection(element: Element, provided?: Direction | null): Direction;
8
+ export { getDirection as n, Direction as t };
@@ -0,0 +1,13 @@
1
+ // src/direction/direction.ts
2
+ /**
3
+ * The reading direction for an element (spec/direction.md): the direction a DirectionProvider
4
+ * gives, when there is one around it (`provided`), else the element's computed `direction` (falls
5
+ * back to `ltr`).
6
+ */
7
+ function getDirection(element, provided) {
8
+ if (provided === "ltr" || provided === "rtl") return provided;
9
+ return element.ownerDocument.defaultView?.getComputedStyle(element).direction === "rtl" ? "rtl" : "ltr";
10
+ }
11
+ export { getDirection as t };
12
+
13
+ //# sourceMappingURL=direction-DJDPvnxJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction-DJDPvnxJ.js","names":[],"sources":["../src/direction/direction.ts"],"sourcesContent":["export type Direction = \"ltr\" | \"rtl\";\n\n/**\n * The reading direction for an element (spec/direction.md): the direction a DirectionProvider\n * gives, when there is one around it (`provided`), else the element's computed `direction` (falls\n * back to `ltr`).\n */\nexport function getDirection(\n element: Element,\n provided?: Direction | null,\n): Direction {\n if (provided === \"ltr\" || provided === \"rtl\") {\n return provided;\n }\n const view = element.ownerDocument.defaultView;\n const value = view?.getComputedStyle(element).direction;\n return value === \"rtl\" ? \"rtl\" : \"ltr\";\n}\n"],"mappings":";;;;;;AAOA,SAAgB,aACZ,SACA,UACS;CACT,IAAI,aAAa,SAAS,aAAa,OACnC,OAAO;CAIX,OAFa,QAAQ,cAAc,aACf,iBAAiB,OAAO,CAAC,CAAC,cAC7B,QAAQ,QAAQ;AACrC"}
@@ -0,0 +1,2 @@
1
+ import { n as getDirection, t as Direction } from "./direction-CTnVLpmd.js";
2
+ export { type Direction, getDirection };
@@ -0,0 +1 @@
1
+ export { t as getDirection } from "./direction-DJDPvnxJ.js";
@@ -0,0 +1,41 @@
1
+ // src/pointer/drag-session.ts
2
+ /**
3
+ * A pointer drag from `event` (a `pointerdown` on `element`), with pointer capture (spec/slider.md,
4
+ * "Pointer"): `element` receives the pointer's moves until it is released. It holds no value;
5
+ * the framework turns each move into its state. Returns the cleanup, which also ends the drag.
6
+ */
7
+ function startDrag(element, event, options) {
8
+ const pointerId = event.pointerId;
9
+ let ended = false;
10
+ try {
11
+ element.setPointerCapture(pointerId);
12
+ } catch {}
13
+ const view = element.ownerDocument.defaultView ?? window;
14
+ const onMove = (move) => {
15
+ if (move.pointerId === pointerId) options.onMove(move);
16
+ };
17
+ const finish = (last) => {
18
+ if (ended) return;
19
+ ended = true;
20
+ view.removeEventListener("pointermove", onMove);
21
+ view.removeEventListener("pointerup", onUp);
22
+ view.removeEventListener("pointercancel", onUp);
23
+ element.removeEventListener("lostpointercapture", onLost);
24
+ try {
25
+ if (element.hasPointerCapture(pointerId)) element.releasePointerCapture(pointerId);
26
+ } catch {}
27
+ options.onEnd(last);
28
+ };
29
+ const onUp = (up) => {
30
+ if (up.pointerId === pointerId) finish(up);
31
+ };
32
+ const onLost = (lost) => finish(lost);
33
+ view.addEventListener("pointermove", onMove);
34
+ view.addEventListener("pointerup", onUp);
35
+ view.addEventListener("pointercancel", onUp);
36
+ element.addEventListener("lostpointercapture", onLost);
37
+ return () => finish(null);
38
+ }
39
+ export { startDrag as t };
40
+
41
+ //# sourceMappingURL=drag-session-CSr06B5v.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag-session-CSr06B5v.js","names":[],"sources":["../src/pointer/drag-session.ts"],"sourcesContent":["export interface DragSessionOptions {\n /** Every move of the dragging pointer, captured: outside the element and the window too. */\n onMove: (event: PointerEvent) => void;\n /** The drag ended: pointer up, cancel or a lost capture (`null` when `end()` stopped it). */\n onEnd: (event: PointerEvent | null) => void;\n}\n\n/**\n * A pointer drag from `event` (a `pointerdown` on `element`), with pointer capture (spec/slider.md,\n * \"Pointer\"): `element` receives the pointer's moves until it is released. It holds no value;\n * the framework turns each move into its state. Returns the cleanup, which also ends the drag.\n */\nexport function startDrag(\n element: Element,\n event: PointerEvent,\n options: DragSessionOptions,\n): () => void {\n const pointerId = event.pointerId;\n let ended = false;\n try {\n element.setPointerCapture(pointerId);\n } catch {\n // a synthetic event without an active pointer: the window listeners still follow it\n }\n const view = element.ownerDocument.defaultView ?? window;\n const onMove = (move: PointerEvent) => {\n if (move.pointerId === pointerId) {\n options.onMove(move);\n }\n };\n const finish = (last: PointerEvent | null) => {\n if (ended) {\n return;\n }\n ended = true;\n view.removeEventListener(\"pointermove\", onMove);\n view.removeEventListener(\"pointerup\", onUp);\n view.removeEventListener(\"pointercancel\", onUp);\n element.removeEventListener(\"lostpointercapture\", onLost);\n try {\n if (element.hasPointerCapture(pointerId)) {\n element.releasePointerCapture(pointerId);\n }\n } catch {\n // already released\n }\n options.onEnd(last);\n };\n const onUp = (up: PointerEvent) => {\n if (up.pointerId === pointerId) {\n finish(up);\n }\n };\n const onLost = (lost: Event) => finish(lost as PointerEvent);\n // the window hears the captured element's events as they bubble\n view.addEventListener(\"pointermove\", onMove);\n view.addEventListener(\"pointerup\", onUp);\n view.addEventListener(\"pointercancel\", onUp);\n element.addEventListener(\"lostpointercapture\", onLost);\n return () => finish(null);\n}\n"],"mappings":";;;;;;AAYA,SAAgB,UACZ,SACA,OACA,SACU;CACV,MAAM,YAAY,MAAM;CACxB,IAAI,QAAQ;CACZ,IAAI;EACA,QAAQ,kBAAkB,SAAS;CACvC,QAAQ,CAER;CACA,MAAM,OAAO,QAAQ,cAAc,eAAe;CAClD,MAAM,UAAU,SAAuB;EACnC,IAAI,KAAK,cAAc,WACnB,QAAQ,OAAO,IAAI;CAE3B;CACA,MAAM,UAAU,SAA8B;EAC1C,IAAI,OACA;EAEJ,QAAQ;EACR,KAAK,oBAAoB,eAAe,MAAM;EAC9C,KAAK,oBAAoB,aAAa,IAAI;EAC1C,KAAK,oBAAoB,iBAAiB,IAAI;EAC9C,QAAQ,oBAAoB,sBAAsB,MAAM;EACxD,IAAI;GACA,IAAI,QAAQ,kBAAkB,SAAS,GACnC,QAAQ,sBAAsB,SAAS;EAE/C,QAAQ,CAER;EACA,QAAQ,MAAM,IAAI;CACtB;CACA,MAAM,QAAQ,OAAqB;EAC/B,IAAI,GAAG,cAAc,WACjB,OAAO,EAAE;CAEjB;CACA,MAAM,UAAU,SAAgB,OAAO,IAAoB;CAE3D,KAAK,iBAAiB,eAAe,MAAM;CAC3C,KAAK,iBAAiB,aAAa,IAAI;CACvC,KAAK,iBAAiB,iBAAiB,IAAI;CAC3C,QAAQ,iBAAiB,sBAAsB,MAAM;CACrD,aAAa,OAAO,IAAI;AAC5B"}