@kanso-labs/kanso-ui 0.45.21 → 0.45.23

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 (269) hide show
  1. package/dist/badge/index.js.map +1 -1
  2. package/dist/button/context.js.map +1 -1
  3. package/dist/button/group.js.map +1 -1
  4. package/dist/button/hooks.js.map +1 -1
  5. package/dist/button/index.d.ts +3 -4
  6. package/dist/button/index.js.map +1 -1
  7. package/dist/button/styles.js.map +1 -1
  8. package/dist/button/toggle.js.map +1 -1
  9. package/dist/calendar/index.js +119 -11
  10. package/dist/calendar/index.js.map +1 -1
  11. package/dist/calendar/styles.js +19 -1
  12. package/dist/calendar/styles.js.map +1 -1
  13. package/dist/carousel/arrangement.d.ts +1 -2
  14. package/dist/carousel/arrangement.js.map +1 -1
  15. package/dist/chip/index.js.map +1 -1
  16. package/dist/chip/label.js.map +1 -1
  17. package/dist/chip/styles.js.map +1 -1
  18. package/dist/collection/empty.js.map +1 -1
  19. package/dist/collection/index.js.map +1 -1
  20. package/dist/collection/styles.js.map +1 -1
  21. package/dist/collection/text.js.map +1 -1
  22. package/dist/color-scheme.d.ts +1 -2
  23. package/dist/color-scheme.js.map +1 -1
  24. package/dist/components/app-bar/index.d.ts +9 -4
  25. package/dist/components/app-bar/index.js +123 -73
  26. package/dist/components/app-bar/index.js.map +1 -1
  27. package/dist/components/autocomplete/index.d.ts +1 -2
  28. package/dist/components/autocomplete/index.js.map +1 -1
  29. package/dist/components/avatar/index.d.ts +1 -2
  30. package/dist/components/avatar/index.js.map +1 -1
  31. package/dist/components/badge/index.d.ts +1 -2
  32. package/dist/components/badge/index.js.map +1 -1
  33. package/dist/components/breadcrumbs/index.d.ts +1 -2
  34. package/dist/components/breadcrumbs/index.js.map +1 -1
  35. package/dist/components/button/index.d.ts +1 -2
  36. package/dist/components/button/index.js.map +1 -1
  37. package/dist/components/button-group/index.d.ts +1 -2
  38. package/dist/components/button-group/index.js.map +1 -1
  39. package/dist/components/calendar/index.d.ts +4 -5
  40. package/dist/components/calendar/index.js +8 -19
  41. package/dist/components/calendar/index.js.map +1 -1
  42. package/dist/components/card/index.d.ts +1 -2
  43. package/dist/components/card/index.js.map +1 -1
  44. package/dist/components/carousel/index.d.ts +22 -4
  45. package/dist/components/carousel/index.js +26 -14
  46. package/dist/components/carousel/index.js.map +1 -1
  47. package/dist/components/checkbox/index.d.ts +1 -2
  48. package/dist/components/checkbox/index.js.map +1 -1
  49. package/dist/components/checkbox-group/index.d.ts +1 -2
  50. package/dist/components/checkbox-group/index.js.map +1 -1
  51. package/dist/components/chip/index.d.ts +1 -2
  52. package/dist/components/chip/index.js.map +1 -1
  53. package/dist/components/chip-group/index.d.ts +1 -2
  54. package/dist/components/chip-group/index.js +3 -0
  55. package/dist/components/chip-group/index.js.map +1 -1
  56. package/dist/components/code/index.d.ts +1 -2
  57. package/dist/components/code/index.js.map +1 -1
  58. package/dist/components/color-area/index.d.ts +1 -2
  59. package/dist/components/color-area/index.js.map +1 -1
  60. package/dist/components/color-field/index.d.ts +1 -2
  61. package/dist/components/color-field/index.js.map +1 -1
  62. package/dist/components/color-picker/index.d.ts +1 -2
  63. package/dist/components/color-picker/index.js +64 -46
  64. package/dist/components/color-picker/index.js.map +1 -1
  65. package/dist/components/color-slider/index.d.ts +1 -2
  66. package/dist/components/color-slider/index.js.map +1 -1
  67. package/dist/components/color-swatch/index.d.ts +1 -2
  68. package/dist/components/color-swatch/index.js +20 -16
  69. package/dist/components/color-swatch/index.js.map +1 -1
  70. package/dist/components/color-swatch-picker/index.d.ts +1 -2
  71. package/dist/components/color-swatch-picker/index.js.map +1 -1
  72. package/dist/components/color-wheel/index.d.ts +1 -2
  73. package/dist/components/color-wheel/index.js.map +1 -1
  74. package/dist/components/combo-box/index.d.ts +1 -2
  75. package/dist/components/combo-box/index.js.map +1 -1
  76. package/dist/components/container/index.d.ts +1 -2
  77. package/dist/components/container/index.js.map +1 -1
  78. package/dist/components/copy-field/index.d.ts +1 -2
  79. package/dist/components/copy-field/index.js +1 -0
  80. package/dist/components/copy-field/index.js.map +1 -1
  81. package/dist/components/currency/index.d.ts +1 -2
  82. package/dist/components/currency/index.js.map +1 -1
  83. package/dist/components/date-field/index.d.ts +1 -2
  84. package/dist/components/date-field/index.js.map +1 -1
  85. package/dist/components/date-picker/index.d.ts +1 -2
  86. package/dist/components/date-picker/index.js.map +1 -1
  87. package/dist/components/date-range-picker/index.d.ts +1 -2
  88. package/dist/components/date-range-picker/index.js +165 -81
  89. package/dist/components/date-range-picker/index.js.map +1 -1
  90. package/dist/components/dialog/index.d.ts +1 -2
  91. package/dist/components/dialog/index.js.map +1 -1
  92. package/dist/components/disclosure/index.d.ts +1 -2
  93. package/dist/components/disclosure/index.js.map +1 -1
  94. package/dist/components/disclosure-group/index.d.ts +1 -2
  95. package/dist/components/disclosure-group/index.js.map +1 -1
  96. package/dist/components/drop-zone/index.d.ts +1 -2
  97. package/dist/components/drop-zone/index.js.map +1 -1
  98. package/dist/components/drop-zone/styles.js.map +1 -1
  99. package/dist/components/fab/index.d.ts +1 -2
  100. package/dist/components/fab/index.js.map +1 -1
  101. package/dist/components/fab-menu/index.d.ts +1 -2
  102. package/dist/components/fab-menu/index.js.map +1 -1
  103. package/dist/components/feed/index.d.ts +1 -2
  104. package/dist/components/feed/index.js.map +1 -1
  105. package/dist/components/form/index.d.ts +1 -2
  106. package/dist/components/form/index.js.map +1 -1
  107. package/dist/components/icon-button/index.d.ts +1 -2
  108. package/dist/components/icon-button/index.js.map +1 -1
  109. package/dist/components/index.d.ts +2 -2
  110. package/dist/components/keycap/index.d.ts +1 -2
  111. package/dist/components/keycap/index.js.map +1 -1
  112. package/dist/components/link/index.d.ts +1 -2
  113. package/dist/components/link/index.js.map +1 -1
  114. package/dist/components/list/index.d.ts +1 -2
  115. package/dist/components/list/index.js.map +1 -1
  116. package/dist/components/list-box/index.d.ts +1 -2
  117. package/dist/components/list-box/index.js.map +1 -1
  118. package/dist/components/list-detail/index.d.ts +1 -2
  119. package/dist/components/list-detail/index.js.map +1 -1
  120. package/dist/components/list-item/index.d.ts +1 -2
  121. package/dist/components/list-item/index.js.map +1 -1
  122. package/dist/components/loading-indicator/index.d.ts +1 -2
  123. package/dist/components/loading-indicator/index.js.map +1 -1
  124. package/dist/components/menu/index.d.ts +1 -2
  125. package/dist/components/menu/index.js.map +1 -1
  126. package/dist/components/meter/index.d.ts +1 -2
  127. package/dist/components/meter/index.js.map +1 -1
  128. package/dist/components/navigation-bar/index.d.ts +1 -2
  129. package/dist/components/navigation-bar/index.js.map +1 -1
  130. package/dist/components/navigation-rail/index.d.ts +1 -2
  131. package/dist/components/navigation-rail/index.js.map +1 -1
  132. package/dist/components/navigation-tree/index.d.ts +1 -2
  133. package/dist/components/navigation-tree/index.js.map +1 -1
  134. package/dist/components/number-field/index.d.ts +1 -2
  135. package/dist/components/number-field/index.js.map +1 -1
  136. package/dist/components/popover/index.d.ts +1 -2
  137. package/dist/components/popover/index.js +14 -4
  138. package/dist/components/popover/index.js.map +1 -1
  139. package/dist/components/product-icon/index.d.ts +1 -2
  140. package/dist/components/product-icon/index.js.map +1 -1
  141. package/dist/components/progress-indicator/index.d.ts +1 -2
  142. package/dist/components/progress-indicator/index.js.map +1 -1
  143. package/dist/components/radio-group/index.d.ts +1 -2
  144. package/dist/components/radio-group/index.js.map +1 -1
  145. package/dist/components/range-calendar/index.d.ts +1 -2
  146. package/dist/components/range-calendar/index.js +53 -80
  147. package/dist/components/range-calendar/index.js.map +1 -1
  148. package/dist/components/search-field/index.d.ts +1 -2
  149. package/dist/components/search-field/index.js.map +1 -1
  150. package/dist/components/search-view/index.d.ts +1 -2
  151. package/dist/components/search-view/index.js.map +1 -1
  152. package/dist/components/segmented-button/index.d.ts +1 -2
  153. package/dist/components/segmented-button/index.js +261 -145
  154. package/dist/components/segmented-button/index.js.map +1 -1
  155. package/dist/components/select/index.d.ts +1 -2
  156. package/dist/components/select/index.js.map +1 -1
  157. package/dist/components/separator/index.d.ts +1 -2
  158. package/dist/components/separator/index.js.map +1 -1
  159. package/dist/components/sheet/index.d.ts +1 -2
  160. package/dist/components/sheet/index.js +149 -82
  161. package/dist/components/sheet/index.js.map +1 -1
  162. package/dist/components/slider/index.d.ts +1 -2
  163. package/dist/components/slider/index.js.map +1 -1
  164. package/dist/components/snackbar/index.d.ts +1 -2
  165. package/dist/components/snackbar/index.js.map +1 -1
  166. package/dist/components/split-button/index.d.ts +1 -2
  167. package/dist/components/split-button/index.js.map +1 -1
  168. package/dist/components/stack/index.d.ts +1 -2
  169. package/dist/components/stack/index.js.map +1 -1
  170. package/dist/components/supporting-pane/index.d.ts +1 -2
  171. package/dist/components/supporting-pane/index.js.map +1 -1
  172. package/dist/components/switch/index.d.ts +1 -2
  173. package/dist/components/switch/index.js.map +1 -1
  174. package/dist/components/table/index.d.ts +1 -2
  175. package/dist/components/table/index.js +251 -123
  176. package/dist/components/table/index.js.map +1 -1
  177. package/dist/components/tabs/index.d.ts +1 -2
  178. package/dist/components/tabs/index.js.map +1 -1
  179. package/dist/components/tag/index.d.ts +1 -2
  180. package/dist/components/tag/index.js.map +1 -1
  181. package/dist/components/text/index.d.ts +1 -2
  182. package/dist/components/text/index.js.map +1 -1
  183. package/dist/components/text-area/index.d.ts +1 -2
  184. package/dist/components/text-area/index.js.map +1 -1
  185. package/dist/components/text-field/index.d.ts +1 -2
  186. package/dist/components/text-field/index.js.map +1 -1
  187. package/dist/components/time-field/index.d.ts +1 -2
  188. package/dist/components/time-field/index.js.map +1 -1
  189. package/dist/components/time-picker/index.d.ts +1 -2
  190. package/dist/components/time-picker/index.js.map +1 -1
  191. package/dist/components/token-field/index.d.ts +1 -2
  192. package/dist/components/token-field/index.js.map +1 -1
  193. package/dist/components/toolbar/index.d.ts +1 -2
  194. package/dist/components/toolbar/index.js.map +1 -1
  195. package/dist/components/tooltip/index.d.ts +1 -2
  196. package/dist/components/tooltip/index.js.map +1 -1
  197. package/dist/components/tree/index.d.ts +1 -2
  198. package/dist/components/tree/index.js.map +1 -1
  199. package/dist/control/index.js.map +1 -1
  200. package/dist/control/styles.js.map +1 -1
  201. package/dist/drag/hooks.d.ts +1 -2
  202. package/dist/drag/hooks.js.map +1 -1
  203. package/dist/drag/index.js.map +1 -1
  204. package/dist/drag/styles.js.map +1 -1
  205. package/dist/fab/styles.js.map +1 -1
  206. package/dist/field/index.d.ts +3 -4
  207. package/dist/field/index.js.map +1 -1
  208. package/dist/field/press.js.map +1 -1
  209. package/dist/field/root.js.map +1 -1
  210. package/dist/field/styles.js.map +1 -1
  211. package/dist/glyphs/index.js.map +1 -1
  212. package/dist/glyphs/styles.js.map +1 -1
  213. package/dist/hooks/useAppBarScroll.d.ts +1 -2
  214. package/dist/hooks/useAppBarScroll.js.map +1 -1
  215. package/dist/hooks/useBottomEdge.js.map +1 -1
  216. package/dist/hooks/useClippedTitle.js.map +1 -1
  217. package/dist/hooks/useImageLoadingStatus.js.map +1 -1
  218. package/dist/hooks/useRipple.js +3 -2
  219. package/dist/hooks/useRipple.js.map +1 -1
  220. package/dist/hooks/useScrollStop.js.map +1 -1
  221. package/dist/hooks/useToggleGroupDisabled.js.map +1 -1
  222. package/dist/i18n/index.js.map +1 -1
  223. package/dist/i18n/messages.js.map +1 -1
  224. package/dist/index.d.ts +2 -2
  225. package/dist/indicator/index.js.map +1 -1
  226. package/dist/indicator/styles.d.ts +1 -2
  227. package/dist/indicator/styles.js.map +1 -1
  228. package/dist/kanso-ui-core/defaults-DMH0HWCw.d.ts +1 -2
  229. package/dist/keycap/context.js.map +1 -1
  230. package/dist/layout.d.ts +1 -2
  231. package/dist/layout.js.map +1 -1
  232. package/dist/mark/index.js.map +1 -1
  233. package/dist/mark/initials.js.map +1 -1
  234. package/dist/mark/styles.js.map +1 -1
  235. package/dist/navigation/context.js.map +1 -1
  236. package/dist/navigation/index.d.ts +2 -3
  237. package/dist/navigation/index.js.map +1 -1
  238. package/dist/navigation/styles.js.map +1 -1
  239. package/dist/overlay/index.js.map +1 -1
  240. package/dist/render/aria.js.map +1 -1
  241. package/dist/render/content.js.map +1 -1
  242. package/dist/render/name.d.ts +1 -2
  243. package/dist/render/ref.js.map +1 -1
  244. package/dist/render/useRender.d.ts +1 -2
  245. package/dist/render/useRender.js.map +1 -1
  246. package/dist/row/index.js.map +1 -1
  247. package/dist/row/styles.js.map +1 -1
  248. package/dist/segments/index.js +2 -1
  249. package/dist/segments/index.js.map +1 -1
  250. package/dist/segments/styles.js +5 -1
  251. package/dist/segments/styles.js.map +1 -1
  252. package/dist/styles/chequer.js.map +1 -1
  253. package/dist/styles/color.js.map +1 -1
  254. package/dist/styles/focus.js.map +1 -1
  255. package/dist/styles/icon-button.js.map +1 -1
  256. package/dist/styles/merge.js.map +1 -1
  257. package/dist/styles/overlay.d.ts +2 -3
  258. package/dist/styles/overlay.js.map +1 -1
  259. package/dist/styles/picker.js.map +1 -1
  260. package/dist/styles/ripple.js.map +1 -1
  261. package/dist/styles/scheme.js.map +1 -1
  262. package/dist/styles.css +40 -8
  263. package/dist/swatch/index.js +19 -0
  264. package/dist/swatch/index.js.map +1 -0
  265. package/dist/theme-scope.d.ts +1 -2
  266. package/dist/theme-scope.js.map +1 -1
  267. package/dist/tokens/design.tokens.stylex.js.map +1 -1
  268. package/dist/tokens/values.js.map +1 -1
  269. package/package.json +16 -16
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","CalendarDate","ReactElement","RefAttributes","CalendarCellRenderProps","CalendarRenderProps","DateValue","CalendarProps","RACCalendarProps","isSameDay","stylex","useContext","CalendarStateContext","Calendar","RACCalendar","CalendarCell","RACCalendarCell","CalendarGrid","RACCalendarGrid","CalendarGridBody","RACCalendarGridBody","Text","RACText","CalendarFrame","CalendarGridHeader","monthOffsets","calendarStyles","dateLayers","invalidFrom","fieldChromeStyles","focus","mergeStatefulStyles","className","T","error","showMonthYearMenus","style","Omit","CalendarStates","isHeldWhileDisabled","isReadOnly","t0","$","T0","props","t1","t2","t3","t4","t5","t6","undefined","root","visibleDuration","months","isInvalid","map","_temp","message","messageError","offset","month","grid","gridCell","cellClassName","state","calendar","cell","ring","isToday","cellToday","isSelected","cellSelected","cellInvalid","cellReadOnly","isHovered","hoveredLayer","isPressed","pressedLayer","isUnavailable","cellUnavailable","isDisabled","cellDisabled","isOutsideMonth","cellSelectedDisabled","cellClassNameIn","DateCell","date","holds","value","held","some","entry","plainHovered","invalidHovered","selectedHovered","plainPressed","invalidPressed","selectedPressed","Calendar","_c","props","RACCalendar","stylex.props","RACText","RACCalendarGrid","CalendarGridHeader","RACCalendarGridBody","RACCalendarCell"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CalendarDate } from '@internationalized/date';\nimport type { ReactElement, RefAttributes } from 'react';\nimport type { CalendarCellRenderProps, CalendarRenderProps, DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport { isSameDay } from '@internationalized/date';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CalendarStateContext, Calendar as RACCalendar, CalendarCell as RACCalendarCell, CalendarGrid as RACCalendarGrid, CalendarGridBody as RACCalendarGridBody, Text as RACText } from 'react-aria-components';\nimport { CalendarFrame, CalendarGridHeader } from '../../calendar';\nimport { monthOffsets } from '../../calendar/months';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { invalidFrom } from '../../field/root';\nimport { fieldChromeStyles } from '../../field/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// The date pickers page's docked calendar: a month grid with a circle on the\n// selected date and an outline on today. Its values are that page's — a\n// 360dp container on the high surface container, 48dp date cells with a 40dp\n// state layer inside them, body-large for both the weekday row and the dates,\n// primary for the selected circle and for today's outline.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks — the most\n// any month occupies — so the calendar keeps its height as the month moves\n// and a shorter month leaves its last rows empty. `months` in\n// `src/calendar/styles.ts` is where the room is reserved.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was. The parts are in\n// `src/calendar`, shared with RangeCalendar.\n//\n// The calendar's own disabled, read-only and invalid states are drawn on its\n// dates, from React Aria's calendar state rather than each date's, since\n// that is the one place all three are known:\n//\n// - **Disabled** fades every date, the weekday row, the chevrons and the\n// menu buttons to the page's 38%, and keeps the date it holds as a\n// disabled filled circle — React Aria stops calling a disabled date\n// selected, which left the calendar looking empty.\n// - **Read-only** keeps every date at full strength, since it still reports\n// a value, but drops the pointer and the state layers from the dates, which\n// a press no longer changes. The chevrons and the menus still move the\n// month, so they keep theirs.\n// - **Invalid** draws the date held in the error container roles, and\n// `error` writes the reason under the months in the field's supporting\n// type and error colour. Each date React Aria marks invalid points\n// `aria-describedby` at it, so a screen reader hears why as well as that.\n//\n// Five things are this component's own.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year, which would need two names React Aria has no\n// message for — the library writes a word of its own only behind a prop that\n// can replace it, and it would take a pair on four components. The year list\n// reaches any year within a century of the one shown in one press, or any\n// the bounds allow where they are closer, and Shift with Page Up or Page\n// Down steps a year from the keyboard.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. The circle is the element, centred in a 48dp column and a 48dp\n// row — the pitch Compose lays its days at — and a transparent box reaching\n// the 4dp past it on every side makes the whole square the press target,\n// rather than a 48dp box with a 40dp box inside it. The chevrons and the\n// month and year menu buttons reach a 48dp target the same way.\n//\n// **It narrows to its container.** The page's docked calendar is 360dp, and\n// a compact window leaves 328dp between its margins, so the calendar is 360\n// at most and the columns share whatever is left below that. Under about\n// 304dp of content a column is narrower than its 40dp circle, and the\n// circles of neighbouring dates meet.\n//\n// **A date from the month either side is faded because it is disabled, not\n// because it is outside.** React Aria marks those cells `data-outside-month`\n// and disables them in the same breath, so a treatment keyed on the first\n// would never draw anything the second had not already drawn. The disabled\n// fade is the page's 38% either way.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and the\n// on-primary label. A selected today takes the fill, since a circle already\n// says where you are and two rings would say it twice.\n//\n// **The month is moved by IconButton's shape rather than by IconButton.**\n// React Aria wires `slot=\"previous\"` and `slot=\"next\"` on its own `Button`,\n// and IconButton renders React Aria's `Button` too — so nesting one inside\n// the slot would put two buttons where the page draws one. The chevrons take\n// the standard icon button's 40dp square and its state layer instead.\n\ntype CalendarProps<T extends DateValue = DateValue> = {\n /** A function may compute the class from the calendar's render state. */\n className?: RACCalendarProps<T>['className'];\n /**\n * The message shown under the months, which also marks the calendar\n * invalid: the date it holds turns to the error container colours, and\n * React Aria points that date's description at the message. `isInvalid`\n * on its own marks the date with no message.\n */\n error?: string;\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth: the year list runs a\n * century either side of the year shown, or to `minValue` and `maxValue`\n * where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown — the\n * menus name only the first, which would leave the others unlabelled.\n * @default false\n */\n showMonthYearMenus?: boolean;\n /** A function may compute the style from the calendar's render state. */\n style?: RACCalendarProps<T>['style'];\n} & Omit<RACCalendarProps<T>, 'children' | 'className' | 'style'>;\n\n/** What a date's classes read off the calendar around it. */\ntype CalendarStates = {\n /**\n * Whether this date is the one a disabled calendar holds, inside its\n * bounds. A copy of it in a neighbouring month's grid is told apart by\n * React Aria's own `isOutsideMonth`.\n */\n isHeldWhileDisabled: boolean;\n isReadOnly: boolean;\n};\n\n/**\n * A month calendar for picking a date. The value is React Aria's: pass\n * `value` with `onChange` to control it, or `defaultValue` to let it keep its\n * own, both as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { today, getLocalTimeZone } from '@kanso-labs/kanso-ui/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, `isDateUnavailable` rules individual\n * dates out, and `visibleDuration` of `{ months: 2 }` draws two months side\n * by side, stacked below the expanded breakpoint. Name it with `aria-label`\n * or `aria-labelledby`; React Aria composes the visible month into that name\n * itself.\n *\n * The call site's `className` and `style` land on the container, which is the\n * element a layout positions.\n */\nfunction Calendar<T extends DateValue>({\n error,\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> isInvalid={invalidFrom(error)} {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n {({\n isInvalid\n }: CalendarRenderProps) => <>\n <CalendarFrame months={props.visibleDuration?.months ?? 1} showMonthYearMenus={showMonthYearMenus}>\n <div {...stylex.props(calendarStyles.months)}>\n {monthOffsets(props.visibleDuration?.months ?? 1).map(offset => <div key={offset.months} {...stylex.props(calendarStyles.month)}>\n <RACCalendarGrid offset={offset} {...stylex.props(calendarStyles.grid)}>\n <CalendarGridHeader />\n <RACCalendarGridBody>{gridCell}</RACCalendarGridBody>\n </RACCalendarGrid>\n </div>)}\n </div>\n </CalendarFrame>\n {/*\n * Through React Aria's error slot, which gives it the id an\n * invalid date's `aria-describedby` names. Drawn only while the\n * calendar is invalid: React Aria looks for the element when\n * `isInvalid` changes, which is when this appears and goes.\n */}\n {isInvalid && error !== undefined ? <RACText slot=\"errorMessage\" {...stylex.props(fieldChromeStyles.message, fieldChromeStyles.messageError)}>\n {error}\n </RACText> : null}\n </>}\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state and the calendar's.\n// StyleX cannot target `[data-selected]` on the element it is styling, so the\n// state comes from what React Aria hands the className.\n//\n// The order matters. `selected` is applied after `today`, so a selected today\n// takes the fill rather than the outline — a circle already says where you\n// are, and two rings would say it twice — and `invalid` after `selected`,\n// which it repaints. The hover and pressed layers come next, over whichever\n// ground the date has, a press over a hover. A read-only calendar takes no\n// hover layer, and React Aria reports no press there to draw one for.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them; the date a disabled calendar\n// holds then puts its disabled circle back.\nfunction cellClassName(state: CalendarCellRenderProps, calendar: CalendarStates) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isSelected && state.isInvalid && calendarStyles.cellInvalid, calendar.isReadOnly && calendarStyles.cellReadOnly, !calendar.isReadOnly && state.isHovered && hoveredLayer(state), state.isPressed && pressedLayer(state), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled, calendar.isHeldWhileDisabled && !state.isOutsideMonth && calendarStyles.cellSelectedDisabled).className ?? '';\n}\n\n// The calendar's part of a date's classes, bound once per date. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\nfunction cellClassNameIn(calendar: CalendarStates) {\n return (state: CalendarCellRenderProps) => cellClassName(state, calendar);\n}\n\n/**\n * One date. React Aria's cell, with what its classes need from the calendar\n * read from React Aria's calendar state: whether it is read-only, and the\n * date it holds, which React Aria hides from the cell itself once the\n * calendar is disabled.\n *\n * Held means what React Aria would have called selected with the calendar\n * enabled: the value, inside the bounds, and in its own month's grid rather\n * than a neighbour's, which the classes check.\n */\nfunction DateCell({\n date\n}: {\n date: CalendarDate;\n}): ReactElement {\n const calendar = useContext(CalendarStateContext);\n const isHeldWhileDisabled = calendar !== null && calendar.isDisabled && !calendar.isInvalid(date) && holds(calendar.value, date);\n return <RACCalendarCell className={cellClassNameIn({\n isHeldWhileDisabled,\n isReadOnly: calendar?.isReadOnly ?? false\n })} date={date} />;\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <DateCell date={date} />;\n}\n\n// Whether a calendar's value includes a date: one date, or several where the\n// calendar takes more than one.\nfunction holds(value: CalendarDate | null | readonly (CalendarDate | null)[], date: CalendarDate) {\n const held = value !== null && 'length' in value ? value : [value];\n return held.some(entry => entry !== null && isSameDay(entry, date));\n}\nfunction hoveredLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainHovered;\n }\n return state.isInvalid ? dateLayers.invalidHovered : dateLayers.selectedHovered;\n}\nfunction pressedLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainPressed;\n }\n return state.isInvalid ? dateLayers.invalidPressed : dateLayers.selectedPressed;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyJA,SAAAc,WAAA4B,IAAA;CAAA,MAAAC,IAAA1C,EAAA,EAAA;CAAA,IAAA2C;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAuC,MAAA,EAAAP,OAAAc,IAAAb,oBAAAc,IAAA,GAAAC,OAAAT;EAAAP,QAAAc;EAAAJ,UAAAM;EAErCf,qBAAAc,OAAAE,KAAAA,IAAA,QAAAF;EAGQN,KAAA7B;EAAW,IAAA4B,EAAA,OAAAR,OAAA;GAAeW,KAAAjB,YAAYM,KAAK;GAACQ,EAAA,KAAAR;GAAAQ,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EAAME,KAAAA;EAAWG,KAAAhB,oBAAoBrB,MAAagB,eAAc0B,IAAK,GAAGR,OAAK;EAACF,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAR;EAAAQ,EAAA,KAAAE;EAAAF,EAAA,KAAAP;EAAAO,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAA;EAAAJ,KAAAD,EAAA;EAAAR,QAAAQ,EAAA;EAAAE,UAAAF,EAAA;EAAAP,qBAAAO,EAAA;EAAAG,KAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,E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KAAAwB;EAAAxB,EAAA,KAAA6C;EAAA7C,EAAA,KAAAC;EAAAD,EAAA,KAAAG;CAAA,OAAA;EAAAF,KAAAD,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAC,MAAAD,EAAA,OAAA6C,QAAA7C,EAAA,OAAAG,IAAA;EAHKC,KAAA,oBAAC,IAAD;GAA4B,WAAAD;GAGzB0C;EAAI,CAAA;EAAI7C,EAAA,KAAAC;EAAAD,EAAA,KAAA6C;EAAA7C,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAHXI;AAGW;AAEpB,SAASiB,SAASwB,MAAkC;CAClD,OAAO,oBAAC,UAAD,EAAgBA,KAAK,CAAA;AAC9B;AAIA,SAASC,MAAMC,OAA+DF,MAAoB;CAEhG,QADaE,UAAU,QAAQ,YAAYA,QAAQA,QAAQ,CAACA,KAAK,EAAA,CACrDE,MAAKC,UAASA,UAAU,QAAQnF,UAAUmF,OAAOL,IAAI,CAAC;AACpE;AACA,SAASX,aAAaX,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAO5C,WAAWkE;CAEpB,OAAO5B,MAAMV,YAAY5B,WAAWmE,iBAAiBnE,WAAWoE;AAClE;AACA,SAASjB,aAAab,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAO5C,WAAWqE;CAEpB,OAAO/B,MAAMV,YAAY5B,WAAWsE,iBAAiBtE,WAAWuE;AAClE"}
1
+ {"version":3,"file":"index.js","names":["_c","isSameDay","stylex","useContext","CalendarStateContext","Calendar","RACCalendar","RACCalendarCell","calendarStyles","dateLayers","invalidFrom","fieldChromeStyles","focus","mergeStatefulStyles","className","error","showMonthYearMenus","isHeldWhileDisabled","isReadOnly","t0","$","T0","props","t1","t2","t3","t4","t5","t6","undefined","root","visibleDuration","months","isInvalid","gridCell","message","messageError","cellClassName","state","calendar","cell","ring","isToday","cellToday","isSelected","cellSelected","cellInvalid","cellReadOnly","isHovered","hoveredLayer","isPressed","pressedLayer","isUnavailable","cellUnavailable","isDisabled","cellDisabled","isOutsideMonth","cellSelectedDisabled","cellClassNameIn","DateCell","date","holds","value","some","entry","plainHovered","invalidHovered","selectedHovered","plainPressed","invalidPressed","selectedPressed","RACText"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CalendarDate } from '@internationalized/date';\nimport type { ReactElement, RefAttributes } from 'react';\nimport type { CalendarCellRenderProps, CalendarRenderProps, DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport { isSameDay } from '@internationalized/date';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CalendarStateContext, Calendar as RACCalendar, CalendarCell as RACCalendarCell, Text as RACText } from 'react-aria-components';\nimport { CalendarFrame, CalendarMonths } from '../../calendar';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { invalidFrom } from '../../field/root';\nimport { fieldChromeStyles } from '../../field/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// The date pickers page's docked calendar: a month grid with a circle on the\n// selected date and an outline on today. Its values are that page's — a\n// 360dp container on the high surface container, 48dp date cells with a 40dp\n// state layer inside them, body-large for both the weekday row and the dates,\n// primary for the selected circle and for today's outline.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks — the most\n// any month occupies — so the calendar keeps its height as the month moves\n// and a shorter month leaves its last rows empty. `months` in\n// `src/calendar/styles.ts` is where the room is reserved.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was. The parts are in\n// `src/calendar`, shared with RangeCalendar.\n//\n// The calendar's own disabled, read-only and invalid states are drawn on its\n// dates, from React Aria's calendar state rather than each date's, since\n// that is the one place all three are known:\n//\n// - **Disabled** fades every date, the weekday row, the chevrons and the\n// menu buttons to the page's 38%, and keeps the date it holds as a\n// disabled filled circle — React Aria stops calling a disabled date\n// selected, which left the calendar looking empty.\n// - **Read-only** keeps every date at full strength, since it still reports\n// a value, but drops the pointer and the state layers from the dates, which\n// a press no longer changes. The chevrons and the menus still move the\n// month, so they keep theirs.\n// - **Invalid** draws the date held in the error container roles, and\n// `error` writes the reason under the months in the field's supporting\n// type and error colour. Each date React Aria marks invalid points\n// `aria-describedby` at it, so a screen reader hears why as well as that.\n//\n// Five things are this component's own.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year, which would need two names React Aria has no\n// message for — the library writes a word of its own only behind a prop that\n// can replace it, and it would take a pair on four components. The year list\n// reaches any year within a century of the one shown in one press, or any\n// the bounds allow where they are closer, and Shift with Page Up or Page\n// Down steps a year from the keyboard.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. The circle is the element, centred in a 48dp column and a 48dp\n// row — the pitch Compose lays its days at — and a transparent box reaching\n// the 4dp past it on every side makes the whole square the press target,\n// rather than a 48dp box with a 40dp box inside it. The chevrons and the\n// month and year menu buttons reach a 48dp target the same way.\n//\n// **It narrows to its container.** The page's docked calendar is 360dp, and\n// a compact window leaves 328dp between its margins, so the calendar is 360\n// at most and the columns share whatever is left below that. Under about\n// 304dp of content a column is narrower than its 40dp circle, and the\n// circles of neighbouring dates meet.\n//\n// **A date from the month either side is faded because it is disabled, not\n// because it is outside.** React Aria marks those cells `data-outside-month`\n// and disables them in the same breath, so a treatment keyed on the first\n// would never draw anything the second had not already drawn. The disabled\n// fade is the page's 38% either way.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and the\n// on-primary label. A selected today takes the fill, since a circle already\n// says where you are and two rings would say it twice.\n//\n// **The month is moved by IconButton's shape rather than by IconButton.**\n// React Aria wires `slot=\"previous\"` and `slot=\"next\"` on its own `Button`,\n// and IconButton renders React Aria's `Button` too — so nesting one inside\n// the slot would put two buttons where the page draws one. The chevrons take\n// the standard icon button's 40dp square and its state layer instead.\n\ntype CalendarProps<T extends DateValue = DateValue> = {\n /** A function may compute the class from the calendar's render state. */\n className?: RACCalendarProps<T>['className'];\n /**\n * The message shown under the months, which also marks the calendar\n * invalid: the date it holds turns to the error container colours, and\n * React Aria points that date's description at the message. `isInvalid`\n * on its own marks the date with no message.\n */\n error?: string;\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth: the year list runs a\n * century either side of the year shown, or to `minValue` and `maxValue`\n * where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown — the\n * menus name only the first, which would leave the others unlabelled.\n * @default false\n */\n showMonthYearMenus?: boolean;\n /** A function may compute the style from the calendar's render state. */\n style?: RACCalendarProps<T>['style'];\n} & Omit<RACCalendarProps<T>, 'children' | 'className' | 'style'>;\n\n/** What a date's classes read off the calendar around it. */\ntype CalendarStates = {\n /**\n * Whether this date is the one a disabled calendar holds, inside its\n * bounds. A copy of it in a neighbouring month's grid is told apart by\n * React Aria's own `isOutsideMonth`.\n */\n isHeldWhileDisabled: boolean;\n isReadOnly: boolean;\n};\n\n/**\n * A month calendar for picking a date. The value is React Aria's: pass\n * `value` with `onChange` to control it, or `defaultValue` to let it keep its\n * own, both as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { today, getLocalTimeZone } from '@kanso-labs/kanso-ui/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, `isDateUnavailable` rules individual\n * dates out, and `visibleDuration` of `{ months: 2 }` draws two months side\n * by side, stacked below the expanded breakpoint with each month named over\n * its grid. Name it with `aria-label` or `aria-labelledby`; React Aria\n * composes the visible month into that name itself.\n *\n * The call site's `className` and `style` land on the container, which is the\n * element a layout positions.\n */\nfunction Calendar<T extends DateValue>({\n error,\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> isInvalid={invalidFrom(error)} {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n {({\n isInvalid\n }: CalendarRenderProps) => <>\n <CalendarFrame months={props.visibleDuration?.months ?? 1} showMonthYearMenus={showMonthYearMenus}>\n <CalendarMonths months={props.visibleDuration?.months ?? 1}>\n {gridCell}\n </CalendarMonths>\n </CalendarFrame>\n {/*\n * Through React Aria's error slot, which gives it the id an\n * invalid date's `aria-describedby` names. Drawn only while the\n * calendar is invalid: React Aria looks for the element when\n * `isInvalid` changes, which is when this appears and goes.\n */}\n {isInvalid && error !== undefined ? <RACText slot=\"errorMessage\" {...stylex.props(fieldChromeStyles.message, fieldChromeStyles.messageError)}>\n {error}\n </RACText> : null}\n </>}\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state and the calendar's.\n// StyleX cannot target `[data-selected]` on the element it is styling, so the\n// state comes from what React Aria hands the className.\n//\n// The order matters. `selected` is applied after `today`, so a selected today\n// takes the fill rather than the outline — a circle already says where you\n// are, and two rings would say it twice — and `invalid` after `selected`,\n// which it repaints. The hover and pressed layers come next, over whichever\n// ground the date has, a press over a hover. A read-only calendar takes no\n// hover layer, and React Aria reports no press there to draw one for.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them; the date a disabled calendar\n// holds then puts its disabled circle back.\nfunction cellClassName(state: CalendarCellRenderProps, calendar: CalendarStates) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isSelected && state.isInvalid && calendarStyles.cellInvalid, calendar.isReadOnly && calendarStyles.cellReadOnly, !calendar.isReadOnly && state.isHovered && hoveredLayer(state), state.isPressed && pressedLayer(state), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled, calendar.isHeldWhileDisabled && !state.isOutsideMonth && calendarStyles.cellSelectedDisabled).className ?? '';\n}\n\n// The calendar's part of a date's classes, bound once per date. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\nfunction cellClassNameIn(calendar: CalendarStates) {\n return (state: CalendarCellRenderProps) => cellClassName(state, calendar);\n}\n\n/**\n * One date. React Aria's cell, with what its classes need from the calendar\n * read from React Aria's calendar state: whether it is read-only, and the\n * date it holds, which React Aria hides from the cell itself once the\n * calendar is disabled.\n *\n * Held means what React Aria would have called selected with the calendar\n * enabled: the value, inside the bounds, and in its own month's grid rather\n * than a neighbour's, which the classes check.\n */\nfunction DateCell({\n date\n}: {\n date: CalendarDate;\n}): ReactElement {\n const calendar = useContext(CalendarStateContext);\n const isHeldWhileDisabled = calendar !== null && calendar.isDisabled && !calendar.isInvalid(date) && holds(calendar.value, date);\n return <RACCalendarCell className={cellClassNameIn({\n isHeldWhileDisabled,\n isReadOnly: calendar?.isReadOnly ?? false\n })} date={date} />;\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <DateCell date={date} />;\n}\n\n// Whether a calendar's value includes a date: one date, or several where the\n// calendar takes more than one.\nfunction holds(value: CalendarDate | null | readonly (CalendarDate | null)[], date: CalendarDate) {\n const held = value !== null && 'length' in value ? value : [value];\n return held.some(entry => entry !== null && isSameDay(entry, date));\n}\nfunction hoveredLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainHovered;\n }\n return state.isInvalid ? dateLayers.invalidHovered : dateLayers.selectedHovered;\n}\nfunction pressedLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainPressed;\n }\n return state.isInvalid ? dateLayers.invalidPressed : dateLayers.selectedPressed;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJA,SAAAK,WAAAc,IAAA;CAAA,MA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iBzD,WAAW0D;AAClE;AACA,SAAShB,aAAab,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAOnC,WAAW2D;CAEpB,OAAO9B,MAAML,YAAYxB,WAAW4D,iBAAiB5D,WAAW6D;AAClE"}
@@ -54,5 +54,4 @@ type CardVariant = 'elevated' | 'filled' | 'outlined';
54
54
  * navigates.
55
55
  */
56
56
  declare function Card({ children, interactive, isDisabled, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, padding, render, variant, ...props }: CardProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
57
- export { type CardProps, type CardVariant, Card as default };
58
- //# sourceMappingURL=index.d.ts.map
57
+ export { type CardProps, type CardVariant, Card as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","MouseEvent","stylex","cloneElement","isValidElement","RenderComponentProps","useRipple","useRender","focus","mergeStyles","colors","motion","radii","shadows","spacing","stateLayerOpacity","FORCED_COLORS","styles","base","kaIpWk","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kVQacm","kHjlTd","kVAEAm","kybGjl","$$css","content","kAzted","disabled","kVAM5u","kkrTdU","disabledContent","kSiTet","disabledElevated","kWkggS","kGVxlE","disabledFilled","disabledOutlined","elevated","filled","interactive","kVVagm","kzqmXN","k9WMMc","kIyJzY","k1ekBW","kAMwcw","interactiveBoundary","ksu8eU","outlined","paddingDefault","kmVPX3","paddingNone","HOVER_CAPABLE","interactionStyles","focusColors","kjBf7l","CardProps","isDisabled","padding","variant","CardVariant","Card","t0","$","children","t1","t2","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","t3","render","t4","props","undefined","t5","t6","ripple","padded","t7","t8","type","t9","handlers","t10","disabledAttributes","t11","0","className","1","t12","surface","t13","ring","disabledStyles","t14","t15","withoutActivation","t16","defaultTagName","preventDefault","event","Record","href","tabIndex","_c","props","stylex.props"],"sources":["../../../src/components/card/index.tsx"],"sourcesContent":["'use client';\n\nimport type { MouseEvent } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { cloneElement, isValidElement } from 'react';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useRipple } from '../../hooks/useRipple';\nimport { useRender } from '../../render/useRender';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The three variants differ only in how they separate themselves from the\n// page: a shadow, a darker fill, or a border. Each therefore sits on a\n// different background, which is why the interaction styles below are keyed\n// by variant too — a state layer composites an 'on-color' over whatever the\n// container already is, so it cannot be written once for all three.\n//\n// color-mix() is inlined at each property rather than factored into a helper:\n// @stylexjs/babel-plugin only statically recognizes expressions written\n// directly as property values. Button's header comment records the same\n// constraint.\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n base: {\n kaIpWk: \"x62ce2h\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n k1xSpc: \"x1lliihq\",\n kVQacm: \"x7giv3\",\n kHjlTd: \"xj0a0fe\",\n kVAEAm: \"x1n2onr6\",\n kybGjl: \"x1hl2dhg\",\n $$css: true\n },\n content: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1lliihq\",\n kAzted: \"x1us19tq\",\n $$css: true\n },\n disabled: {\n kVAM5u: \"xmnqt3w\",\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n disabledContent: {\n kSiTet: \"x1ppv7y9\",\n $$css: true\n },\n disabledElevated: {\n kWkggS: \"x1jfv5e4\",\n kGVxlE: \"x1gnnqk1\",\n $$css: true\n },\n disabledFilled: {\n kWkggS: \"x6mg230\",\n $$css: true\n },\n disabledOutlined: {\n kVAM5u: \"x1y3ic1l xmnqt3w\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1rrhr5q\",\n $$css: true\n },\n interactive: {\n kkrTdU: \"x1ypdohk\",\n kVVagm: \"xln7xf2\",\n kzqmXN: \"xh8yej3\",\n k9WMMc: \"x1yc453h\",\n kIyJzY: \"x1iuyhda x12w9bfk\",\n k1ekBW: \"x106061f\",\n kAMwcw: \"x1g6yzlr\",\n $$css: true\n },\n interactiveBoundary: {\n kVAM5u: \"x1ylmb6m\",\n ksu8eU: \"xx61lck\",\n kMzoRj: \"xc342km x13rsnn2\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x14s9m32\",\n kVAM5u: \"x133yhug\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n $$css: true\n },\n paddingDefault: {\n kmVPX3: \"xgc26li\",\n $$css: true\n },\n paddingNone: {\n kmVPX3: \"x1717udv\",\n $$css: true\n }\n};\n\n// A pointer that can hover: a mouse or a trackpad, not a finger. An\n// interactive card is a plain element React Aria does not host, so it has no\n// `isHovered` to draw its hover layer from, and Chromium leaves `:hover` on\n// whatever a touch last tapped — a card tapped and then navigated back to\n// stayed lifted. Inside this query a touch screen draws no hover at all. A\n// touchscreen laptop still matches it for its trackpad, which is the limit of\n// asking the device rather than the event.\nconst HOVER_CAPABLE = '@media (hover: hover)';\n\n// The state layers, from pseudo-classes, since the card has no render state\n// to read — see `HOVER_CAPABLE`.\n// `:active` is written twice, bare for a touch and again inside the query.\n// StyleX orders a rule by the sum of its conditions, so a hover inside the\n// query would otherwise come after a bare press and win while both held.\n//\n// Each variant also lifts one level on hover and comes back down on a press,\n// to the container elevations the cards page gives: the elevated card from\n// level 1 to 2, and the filled and outlined cards from level 0 to 1.\nconst interactionStyles = {\n elevated: {\n kWkggS: \"xu5m21g x17zbzf9 x1ru19e0 x1vnz5z6\",\n kGVxlE: \"x1g60mc1 x14zlms8 xqmo4o3 x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1w49kxs x10l1pcx xt0lj0h x1rrhr5q\",\n kGVxlE: \"xpk4wdd x1xzfgx1 x1jblvwk\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x1jqfdmz x1ie1ydn x1dau0i7 x14s9m32\",\n kGVxlE: \"xpk4wdd x1xzfgx1 x1jblvwk\",\n $$css: true\n }\n};\n\n// The cards page's focus indicator, in secondary on the elevated and filled\n// cards and in on surface on the outlined one, where the shared ring takes\n// primary. Only the colour is the card's: the width, the offset and the\n// `:focus-visible` are the shared ring's, which this is applied over. Under\n// forced colours the mode repaints the outline in a system colour, as it does\n// every ring's.\nconst focusColors = {\n elevated: {\n kjBf7l: \"xat36cu\",\n $$css: true\n },\n filled: {\n kjBf7l: \"xat36cu\",\n $$css: true\n },\n outlined: {\n kjBf7l: \"xnzrtil\",\n $$css: true\n }\n};\n\n// Typed as the attributes a <div> accepts, because that is the surface every\n// element this can render shares. Anything element-specific — a button's\n// `type`, an anchor's `href` — would be wrong for the others, and does not\n// need to be here anyway: those are written on the element handed to\n// `render`, where TypeScript checks them against that element's own props.\ntype CardProps = {\n /**\n * Makes the card the thing you press: it ripples, lifts on hover, and takes\n * a focus ring. Renders a `<button>` unless `render` says otherwise. A\n * button holds phrasing content only, so its children are spans, which a\n * `Text` is, laid out through StyleX; for block content, `render` gives it\n * an anchor or another element. Leave it off for a card that merely holds\n * content, including one containing its own buttons.\n * @default false\n */\n interactive?: boolean;\n /**\n * Turns an interactive card off: it fades as the cards page draws a\n * disabled card, stops rippling and lifting, and takes no press. The\n * default `<button>` is disabled outright. An element of the call site's\n * own through `render` is marked `aria-disabled`, and an element handed in\n * directly loses its `href`, `tabIndex` and `onClick`, so a link card can\n * neither be followed nor focused. Has no effect on a card that is not\n * `interactive`, which cannot be pressed to begin with.\n * @default false\n */\n isDisabled?: boolean;\n /**\n * `none` removes the card's own padding, for a card whose children run to\n * its edges — a list of rows separated by rules.\n * @default 'default'\n */\n padding?: 'default' | 'none';\n /**\n * How the card separates itself from the page: `elevated` casts a shadow,\n * `filled` sits on a darker surface, `outlined` draws a border.\n * @default 'elevated'\n */\n variant?: CardVariant;\n} & RenderComponentProps<'div'>;\ntype CardVariant = 'elevated' | 'filled' | 'outlined';\n\n/**\n * A surface holding related content. `render` decides which element that\n * surface is, so a card that navigates can be a real `<a href>` — announced\n * as a link and opening in a new tab on a modifier click, which a `<button>`\n * with an onClick does neither of.\n *\n * ```tsx\n * <Card interactive render={<a href=\"#first\" />}>\n * <Text variant=\"titleMedium\">Headline</Text>\n * </Card>\n * ```\n *\n * `interactive` and `render` are separate axes. `interactive` says the card\n * is pressable and gives it the ripple, the hover lift, and a focus ring;\n * `render` says what it is. A pressable card with no `render` is a\n * `<button>`, which is the right default for one that acts rather than\n * navigates.\n */\nfunction Card({\n children,\n interactive = false,\n isDisabled = false,\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n padding = 'default',\n render,\n variant = 'elevated',\n ...props\n}: CardProps) {\n // The consumer's own pointer handlers are handed to useRipple to merge\n // rather than spread over its handlers afterwards, which is what Button\n // does and for the same reason: a plain spread means whichever object\n // comes last silently wins, so an onPointerDown on the call site would\n // replace the one driving the ripple and the card would stop rippling.\n const disabled = interactive && isDisabled;\n const ripple = useRipple(interactive && !disabled, {\n onClick: disabled ? undefined : onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n });\n const padded = padding === 'none' ? styles.paddingNone : styles.paddingDefault;\n return useRender({\n defaultTagName: interactive ? 'button' : 'div',\n props: {\n ...props,\n // Only when the default <button> is what renders. On an element the\n // call site chose, `type` is either meaningless or wrong — an <a>'s\n // `type` is a hint about the MIME type of what it links to — and that\n // element's own attributes are the call site's to write.\n ...(interactive && render === undefined ? {\n type: 'button'\n } : undefined),\n ...ripple.handlers,\n // After the ripple's handlers, whose click it replaces while disabled.\n ...disabledAttributes(disabled, render),\n children: <>\n {interactive ? <span {...{\n 0: {\n className: \"x9f619 x1lliihq x1us19tq\"\n },\n 1: {\n className: \"x9f619 x1lliihq x1us19tq x1ppv7y9\"\n }\n }[!!disabled << 0]}>\n {children}\n </span> : children}\n {ripple.surface}\n </>,\n ...mergeStyles(stylex.props(styles.base, styles[variant], padded, interactive && styles.interactive, interactive && variant !== 'outlined' && styles.interactiveBoundary, interactive && !disabled && focus.ring, interactive && !disabled && focusColors[variant], interactive && !disabled && interactionStyles[variant], disabled && styles.disabled, disabled && disabledStyles[variant]), props)\n },\n render: disabled ? withoutActivation(render) : render\n });\n}\nconst disabledStyles = {\n elevated: styles.disabledElevated,\n filled: styles.disabledFilled,\n outlined: styles.disabledOutlined\n};\n\n// How a disabled card says so, by the element it renders. The default\n// <button> takes the native `disabled`, which removes it from the tab order\n// and fires nothing on a press. Any other element has no such attribute, so\n// it is marked `aria-disabled` for assistive technology, and a click on it\n// has its default prevented, which is what would follow a link — the click\n// a function passed as `render` wires up is its own, and runs first.\nfunction disabledAttributes(disabled: boolean, render: CardProps['render']) {\n if (!disabled) {\n return undefined;\n }\n if (render === undefined) {\n return {\n disabled: true\n };\n }\n return {\n 'aria-disabled': true,\n onClick: preventDefault\n };\n}\nfunction preventDefault(event: MouseEvent) {\n event.preventDefault();\n}\n\n// An element handed in as `render`, without what would still activate it: an\n// element's own props win over the card's, so an <a href> stays a link the\n// card cannot switch off from outside. Without an `href` it is neither\n// followed nor focusable, and without its `tabIndex` it is not focusable\n// either. Its `onClick` is replaced rather than removed, since a key the\n// element carries wins even when its value is undefined, and would drop the\n// card's own prevented click along with it.\nfunction withoutActivation(render: CardProps['render']): CardProps['render'] {\n if (!isValidElement<Record<string, unknown>>(render)) {\n return render;\n }\n return cloneElement(render, {\n href: undefined,\n onClick: preventDefault,\n tabIndex: undefined\n });\n}\nexport type { CardProps, CardVariant };\nexport default Card;"],"mappings":";;;;;;;;;;AA4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BAAmB7D,UAAmB+C,QAA6B;CAC1E,IAAI,CAAC/C,UACH;CAEF,IAAI+C,WAAWG,KAAAA,GACb,OAAO,EACLlD,UAAU,KACZ;CAEF,OAAO;EACL,iBAAiB;EACjBwC,SAASoC;CACX;AACF;AACA,SAASA,eAAeC,OAAmB;CACzCA,MAAMD,eAAe;AACvB;AASA,SAASH,kBAAkB1B,QAAkD;CAC3E,IAAI,CAAC1E,eAAwC0E,MAAM,GACjD,OAAOA;CAET,OAAO3E,aAAa2E,QAAQ;EAC1BgC,MAAM7B,KAAAA;EACNV,SAASoC;EACTI,UAAU9B,KAAAA;CACZ,CAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","cloneElement","isValidElement","useRipple","useRender","focus","mergeStyles","styles","base","kaIpWk","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kVQacm","kHjlTd","kVAEAm","kybGjl","$$css","content","kAzted","disabled","kVAM5u","kkrTdU","disabledContent","kSiTet","disabledElevated","kWkggS","kGVxlE","disabledFilled","disabledOutlined","elevated","filled","interactive","kVVagm","kzqmXN","k9WMMc","kIyJzY","k1ekBW","kAMwcw","interactiveBoundary","ksu8eU","outlined","paddingDefault","kmVPX3","paddingNone","interactionStyles","focusColors","kjBf7l","isDisabled","padding","variant","Card","t0","$","children","t1","t2","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","t3","render","t4","props","undefined","t5","t6","ripple","padded","t7","t8","type","t9","handlers","t10","disabledAttributes","t11","0","className","1","t12","surface","t13","ring","disabledStyles","t14","t15","withoutActivation","t16","defaultTagName","preventDefault","event","href","tabIndex"],"sources":["../../../src/components/card/index.tsx"],"sourcesContent":["'use client';\n\nimport type { MouseEvent } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { cloneElement, isValidElement } from 'react';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useRipple } from '../../hooks/useRipple';\nimport { useRender } from '../../render/useRender';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The three variants differ only in how they separate themselves from the\n// page: a shadow, a darker fill, or a border. Each therefore sits on a\n// different background, which is why the interaction styles below are keyed\n// by variant too — a state layer composites an 'on-color' over whatever the\n// container already is, so it cannot be written once for all three.\n//\n// color-mix() is inlined at each property rather than factored into a helper:\n// @stylexjs/babel-plugin only statically recognizes expressions written\n// directly as property values. Button's header comment records the same\n// constraint.\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n base: {\n kaIpWk: \"x62ce2h\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n k1xSpc: \"x1lliihq\",\n kVQacm: \"x7giv3\",\n kHjlTd: \"xj0a0fe\",\n kVAEAm: \"x1n2onr6\",\n kybGjl: \"x1hl2dhg\",\n $$css: true\n },\n content: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1lliihq\",\n kAzted: \"x1us19tq\",\n $$css: true\n },\n disabled: {\n kVAM5u: \"xmnqt3w\",\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n disabledContent: {\n kSiTet: \"x1ppv7y9\",\n $$css: true\n },\n disabledElevated: {\n kWkggS: \"x1jfv5e4\",\n kGVxlE: \"x1gnnqk1\",\n $$css: true\n },\n disabledFilled: {\n kWkggS: \"x6mg230\",\n $$css: true\n },\n disabledOutlined: {\n kVAM5u: \"x1y3ic1l xmnqt3w\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1rrhr5q\",\n $$css: true\n },\n interactive: {\n kkrTdU: \"x1ypdohk\",\n kVVagm: \"xln7xf2\",\n kzqmXN: \"xh8yej3\",\n k9WMMc: \"x1yc453h\",\n kIyJzY: \"x1iuyhda x12w9bfk\",\n k1ekBW: \"x106061f\",\n kAMwcw: \"x1g6yzlr\",\n $$css: true\n },\n interactiveBoundary: {\n kVAM5u: \"x1ylmb6m\",\n ksu8eU: \"xx61lck\",\n kMzoRj: \"xc342km x13rsnn2\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x14s9m32\",\n kVAM5u: \"x133yhug\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n $$css: true\n },\n paddingDefault: {\n kmVPX3: \"xgc26li\",\n $$css: true\n },\n paddingNone: {\n kmVPX3: \"x1717udv\",\n $$css: true\n }\n};\n\n// A pointer that can hover: a mouse or a trackpad, not a finger. An\n// interactive card is a plain element React Aria does not host, so it has no\n// `isHovered` to draw its hover layer from, and Chromium leaves `:hover` on\n// whatever a touch last tapped — a card tapped and then navigated back to\n// stayed lifted. Inside this query a touch screen draws no hover at all. A\n// touchscreen laptop still matches it for its trackpad, which is the limit of\n// asking the device rather than the event.\nconst HOVER_CAPABLE = '@media (hover: hover)';\n\n// The state layers, from pseudo-classes, since the card has no render state\n// to read — see `HOVER_CAPABLE`.\n// `:active` is written twice, bare for a touch and again inside the query.\n// StyleX orders a rule by the sum of its conditions, so a hover inside the\n// query would otherwise come after a bare press and win while both held.\n//\n// Each variant also lifts one level on hover and comes back down on a press,\n// to the container elevations the cards page gives: the elevated card from\n// level 1 to 2, and the filled and outlined cards from level 0 to 1.\nconst interactionStyles = {\n elevated: {\n kWkggS: \"xu5m21g x17zbzf9 x1ru19e0 x1vnz5z6\",\n kGVxlE: \"x1g60mc1 x14zlms8 xqmo4o3 x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1w49kxs x10l1pcx xt0lj0h x1rrhr5q\",\n kGVxlE: \"xpk4wdd x1xzfgx1 x1jblvwk\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x1jqfdmz x1ie1ydn x1dau0i7 x14s9m32\",\n kGVxlE: \"xpk4wdd x1xzfgx1 x1jblvwk\",\n $$css: true\n }\n};\n\n// The cards page's focus indicator, in secondary on the elevated and filled\n// cards and in on surface on the outlined one, where the shared ring takes\n// primary. Only the colour is the card's: the width, the offset and the\n// `:focus-visible` are the shared ring's, which this is applied over. Under\n// forced colours the mode repaints the outline in a system colour, as it does\n// every ring's.\nconst focusColors = {\n elevated: {\n kjBf7l: \"xat36cu\",\n $$css: true\n },\n filled: {\n kjBf7l: \"xat36cu\",\n $$css: true\n },\n outlined: {\n kjBf7l: \"xnzrtil\",\n $$css: true\n }\n};\n\n// Typed as the attributes a <div> accepts, because that is the surface every\n// element this can render shares. Anything element-specific — a button's\n// `type`, an anchor's `href` — would be wrong for the others, and does not\n// need to be here anyway: those are written on the element handed to\n// `render`, where TypeScript checks them against that element's own props.\ntype CardProps = {\n /**\n * Makes the card the thing you press: it ripples, lifts on hover, and takes\n * a focus ring. Renders a `<button>` unless `render` says otherwise. A\n * button holds phrasing content only, so its children are spans, which a\n * `Text` is, laid out through StyleX; for block content, `render` gives it\n * an anchor or another element. Leave it off for a card that merely holds\n * content, including one containing its own buttons.\n * @default false\n */\n interactive?: boolean;\n /**\n * Turns an interactive card off: it fades as the cards page draws a\n * disabled card, stops rippling and lifting, and takes no press. The\n * default `<button>` is disabled outright. An element of the call site's\n * own through `render` is marked `aria-disabled`, and an element handed in\n * directly loses its `href`, `tabIndex` and `onClick`, so a link card can\n * neither be followed nor focused. Has no effect on a card that is not\n * `interactive`, which cannot be pressed to begin with.\n * @default false\n */\n isDisabled?: boolean;\n /**\n * `none` removes the card's own padding, for a card whose children run to\n * its edges — a list of rows separated by rules.\n * @default 'default'\n */\n padding?: 'default' | 'none';\n /**\n * How the card separates itself from the page: `elevated` casts a shadow,\n * `filled` sits on a darker surface, `outlined` draws a border.\n * @default 'elevated'\n */\n variant?: CardVariant;\n} & RenderComponentProps<'div'>;\ntype CardVariant = 'elevated' | 'filled' | 'outlined';\n\n/**\n * A surface holding related content. `render` decides which element that\n * surface is, so a card that navigates can be a real `<a href>` — announced\n * as a link and opening in a new tab on a modifier click, which a `<button>`\n * with an onClick does neither of.\n *\n * ```tsx\n * <Card interactive render={<a href=\"#first\" />}>\n * <Text variant=\"titleMedium\">Headline</Text>\n * </Card>\n * ```\n *\n * `interactive` and `render` are separate axes. `interactive` says the card\n * is pressable and gives it the ripple, the hover lift, and a focus ring;\n * `render` says what it is. A pressable card with no `render` is a\n * `<button>`, which is the right default for one that acts rather than\n * navigates.\n */\nfunction Card({\n children,\n interactive = false,\n isDisabled = false,\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n padding = 'default',\n render,\n variant = 'elevated',\n ...props\n}: CardProps) {\n // The consumer's own pointer handlers are handed to useRipple to merge\n // rather than spread over its handlers afterwards, which is what Button\n // does and for the same reason: a plain spread means whichever object\n // comes last silently wins, so an onPointerDown on the call site would\n // replace the one driving the ripple and the card would stop rippling.\n const disabled = interactive && isDisabled;\n const ripple = useRipple(interactive && !disabled, {\n onClick: disabled ? undefined : onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n });\n const padded = padding === 'none' ? styles.paddingNone : styles.paddingDefault;\n return useRender({\n defaultTagName: interactive ? 'button' : 'div',\n props: {\n ...props,\n // Only when the default <button> is what renders. On an element the\n // call site chose, `type` is either meaningless or wrong — an <a>'s\n // `type` is a hint about the MIME type of what it links to — and that\n // element's own attributes are the call site's to write.\n ...(interactive && render === undefined ? {\n type: 'button'\n } : undefined),\n ...ripple.handlers,\n // After the ripple's handlers, whose click it replaces while disabled.\n ...disabledAttributes(disabled, render),\n children: <>\n {interactive ? <span {...{\n 0: {\n className: \"x9f619 x1lliihq x1us19tq\"\n },\n 1: {\n className: \"x9f619 x1lliihq x1us19tq x1ppv7y9\"\n }\n }[!!disabled << 0]}>\n {children}\n </span> : children}\n {ripple.surface}\n </>,\n ...mergeStyles(stylex.props(styles.base, styles[variant], padded, interactive && styles.interactive, interactive && variant !== 'outlined' && styles.interactiveBoundary, interactive && !disabled && focus.ring, interactive && !disabled && focusColors[variant], interactive && !disabled && interactionStyles[variant], disabled && styles.disabled, disabled && disabledStyles[variant]), props)\n },\n render: disabled ? withoutActivation(render) : render\n });\n}\nconst disabledStyles = {\n elevated: styles.disabledElevated,\n filled: styles.disabledFilled,\n outlined: styles.disabledOutlined\n};\n\n// How a disabled card says so, by the element it renders. The default\n// <button> takes the native `disabled`, which removes it from the tab order\n// and fires nothing on a press. Any other element has no such attribute, so\n// it is marked `aria-disabled` for assistive technology, and a click on it\n// has its default prevented, which is what would follow a link — the click\n// a function passed as `render` wires up is its own, and runs first.\nfunction disabledAttributes(disabled: boolean, render: CardProps['render']) {\n if (!disabled) {\n return undefined;\n }\n if (render === undefined) {\n return {\n disabled: true\n };\n }\n return {\n 'aria-disabled': true,\n onClick: preventDefault\n };\n}\nfunction preventDefault(event: MouseEvent) {\n event.preventDefault();\n}\n\n// An element handed in as `render`, without what would still activate it: an\n// element's own props win over the card's, so an <a href> stays a link the\n// card cannot switch off from outside. Without an `href` it is neither\n// followed nor focusable, and without its `tabIndex` it is not focusable\n// either. Its `onClick` is replaced rather than removed, since a key the\n// element carries wins even when its value is undefined, and would drop the\n// card's own prevented click along with it.\nfunction withoutActivation(render: CardProps['render']): CardProps['render'] {\n if (!isValidElement<Record<string, unknown>>(render)) {\n return render;\n }\n return cloneElement(render, {\n href: undefined,\n onClick: preventDefault,\n tabIndex: undefined\n });\n}\nexport type { CardProps, CardVariant };\nexport default Card;"],"mappings":";;;;;;;;;;AA4BA,MAAMQ,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,SAAS;EACPR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B;CACzCA,MAAMD,eAAe;AACvB;AASA,SAASH,kBAAkB1B,QAAkD;CAC3E,IAAI,CAAC/D,eAAwC+D,MAAM,GACjD,OAAOA;CAET,OAAOhE,aAAagE,QAAQ;EAC1B+B,MAAM5B,KAAAA;EACNV,SAASoC;EACTG,UAAU7B,KAAAA;CACZ,CAAC;AACH"}
@@ -1,8 +1,27 @@
1
1
  import { CarouselLayout } from "../../carousel/arrangement.js";
2
2
  import { HTMLAttributes, ReactNode, RefAttributes } from "react";
3
3
  type CarouselItemProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
4
- /** What the item shows: usually an image, which the item masks. */
5
- children?: ReactNode;
4
+ /**
5
+ * What the item shows: usually an image, which the item masks. A function
6
+ * is handed how much of the item shows, every time that changes, so text
7
+ * the item has no room for can be hidden as the mask closes over it.
8
+ */
9
+ children?: ((state: CarouselItemRenderProps) => ReactNode) | ReactNode;
10
+ };
11
+ /** How much of a `Carousel.Item` shows, for children written as a function. */
12
+ type CarouselItemRenderProps = {
13
+ /**
14
+ * How much of `width` shows, in pixels. The mask takes the rest evenly
15
+ * from both sides, so `(width - visibleWidth) / 2` is cut off each. It is
16
+ * `width` for an item drawn large, and for every item of an uncontained
17
+ * carousel, which masks nothing.
18
+ */
19
+ visibleWidth: number;
20
+ /**
21
+ * The width the item is laid out at, in pixels: the large item's, which
22
+ * every item in the carousel shares.
23
+ */
24
+ width: number;
6
25
  };
7
26
  type CarouselProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
8
27
  /** The items: `Carousel.Item` for each. */
@@ -62,5 +81,4 @@ declare namespace Carousel {
62
81
  * The call site's `className` and `style` land on the item.
63
82
  */
64
83
  declare function CarouselItem({ children, ref, ...props }: CarouselItemProps & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
65
- export { CarouselItem, type CarouselItemProps, type CarouselLayout, type CarouselProps, Carousel as default };
66
- //# sourceMappingURL=index.d.ts.map
84
+ export { CarouselItem, type CarouselItemProps, type CarouselItemRenderProps, type CarouselLayout, type CarouselProps, Carousel as default };
@@ -336,7 +336,7 @@ function Carousel(t0) {
336
336
  * The call site's `className` and `style` land on the item.
337
337
  */
338
338
  function CarouselItem(t0) {
339
- const $ = c(11);
339
+ const $ = c(15);
340
340
  const { children, ref, ...props$1 } = t0;
341
341
  const messages = useMessages();
342
342
  const slot = useContext(SlotContext);
@@ -344,7 +344,8 @@ function CarouselItem(t0) {
344
344
  const index = slot?.index ?? 0;
345
345
  const large = slot?.large ?? 0;
346
346
  const placement = slot?.placement;
347
- const inset = placement === void 0 ? 0 : (large - placement.width) / 2;
347
+ const visibleWidth = placement === void 0 ? large : placement.width;
348
+ const inset = (large - visibleWidth) / 2;
348
349
  let t1;
349
350
  if ($[0] !== count || $[1] !== index || $[2] !== messages) {
350
351
  t1 = messages.slideLabel(index + 1, count);
@@ -357,25 +358,36 @@ function CarouselItem(t0) {
357
358
  const t3 = "group";
358
359
  const t4 = mergeStyles(props(styles.item, slot?.layout === "uncontained" && styles.itemUncontained, slot?.layout === "uncontained" && placed.uncontained(`${large}px`), placement !== void 0 && placed.item(`${large}px`, `${placement.left - inset - index * (large + 8)}px`, `inset(0 ${inset}px round ${radii.xl})`)), props$1);
359
360
  let t5;
360
- if ($[4] !== children || $[5] !== messages.slide || $[6] !== props$1 || $[7] !== ref || $[8] !== t1 || $[9] !== t4) {
361
- t5 = /* @__PURE__ */ jsx("div", {
361
+ if ($[4] !== children || $[5] !== large || $[6] !== visibleWidth) {
362
+ t5 = typeof children === "function" ? children({
363
+ visibleWidth,
364
+ width: large
365
+ }) : children;
366
+ $[4] = children;
367
+ $[5] = large;
368
+ $[6] = visibleWidth;
369
+ $[7] = t5;
370
+ } else t5 = $[7];
371
+ let t6;
372
+ if ($[8] !== messages.slide || $[9] !== props$1 || $[10] !== ref || $[11] !== t1 || $[12] !== t4 || $[13] !== t5) {
373
+ t6 = /* @__PURE__ */ jsx("div", {
362
374
  "aria-label": t1,
363
375
  "aria-roledescription": t2,
364
376
  ref,
365
377
  role: t3,
366
378
  ...props$1,
367
379
  ...t4,
368
- children
380
+ children: t5
369
381
  });
370
- $[4] = children;
371
- $[5] = messages.slide;
372
- $[6] = props$1;
373
- $[7] = ref;
374
- $[8] = t1;
375
- $[9] = t4;
376
- $[10] = t5;
377
- } else t5 = $[10];
378
- return t5;
382
+ $[8] = messages.slide;
383
+ $[9] = props$1;
384
+ $[10] = ref;
385
+ $[11] = t1;
386
+ $[12] = t4;
387
+ $[13] = t5;
388
+ $[14] = t6;
389
+ } else t6 = $[14];
390
+ return t6;
379
391
  }
380
392
  function restRevealing(index, { lastLarge, scrolled, step }) {
381
393
  const at = Math.round(scrolled / step);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","FocusEvent","HTMLAttributes","ReactNode","RefAttributes","stylex","Children","createContext","isValidElement","useCallback","useContext","useLayoutEffect","useRef","useState","CarouselLayout","Placement","arrange","GAP","placements","ChevronEndGlyph","useMessages","focus","mergeStyles","radii","spacing","IconButton","PADDING","DEFAULT_ITEM_SIZE","CarouselItemProps","Omit","HTMLDivElement","children","CarouselProps","HTMLElement","itemSize","label","layout","nextLabel","previousLabel","styles","item","kaIpWk","kB7OPa","kzQI83","kmuXW","kAzted","kVQacm","kVAEAm","$$css","itemUncontained","k5xd4v","marker","scroller","kOuLrU","k1xSpc","kXHlph","kORKVm","kvh3hx","k5wCbM","khEr5k","kc424l","scrollerUncontained","katHQp","_temp","kzqmXN","_temp2","_temp3","placed","inlineSize","shift","clip","kz4h6p","kLqNvP","undefined","val","uncontained","Slot","count","index","large","placement","SlotContext","Geometry","end","lastLarge","masked","scrolled","step","along","direction","offset","Math","round","min","max","Carousel","t0","$","t1","t2","ref","props","messages","scrollerRef","width","setWidth","setScrolled","items","toArray","filter","length","room","arrangement","steps","largeCount","position","drawn","t3","Symbol","for","current","clientWidth","abs","scrollLeft","measure","t4","t5","scroller_0","observer","ResizeObserver","observe","disconnect","t6","geometry","scrollAlong","previous","t7","geometry_0","next","t8","event","target","Node","Array","from","currentTarget","findIndex","child","contains","geometry_1","restRevealing","reveal","slots","map","_","index_0","t9","carousel","t10","className","t11","ring","t12","t13","0","1","t14","previousSlide","t15","t16","t17","t18","nextSlide","t19","t20","t21","t22","index_1","key","__0","rest","CarouselItem","slot","inset","slideLabel","slide","left","xl","at","sign","getComputedStyle","scrollTo","Item","_c","props","stylex.props"],"sources":["../../../src/components/carousel/index.tsx"],"sourcesContent":["'use client';\n\nimport type { FocusEvent, HTMLAttributes, ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { Children, createContext, isValidElement, useCallback, useContext, useLayoutEffect, useRef, useState } from 'react';\nimport type { CarouselLayout, Placement } from '../../carousel/arrangement';\nimport { arrange, GAP, placements } from '../../carousel/arrangement';\nimport { ChevronEndGlyph } from '../../glyphs';\nimport { useMessages } from '../../i18n';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, spacing } from '../../tokens/design.tokens.stylex';\nimport IconButton from '../icon-button';\n\n// The carousel page's carousel: a row of items that scrolls on and off the\n// screen, drawn in three of the page's layouts. Each has the page's 16dp of\n// padding at its ends and 8dp at its top and bottom, 8dp between items and a\n// 28dp corner on every item.\n//\n// - **Multi-browse**, the default, shows as many large items as fit at\n// `itemSize`, then a medium one and a small one, and fills its width\n// exactly; the large width gives way where the preferred one does not fit.\n// - **Hero** shows one large item and one small.\n// - **Uncontained** shows every item at `itemSize`, scrolling past the edge.\n//\n// **Items change size as they move**, as the page draws them. The first two\n// layouts come to rest one item apart, and between two rests every item's\n// place and width are interpolated, so an item shrinks as it leaves and\n// grows as it arrives; the last rests turn the arrangement round a slot at a\n// time, so every item is drawn large at one of them. The arithmetic is\n// `src/carousel/arrangement.ts`.\n// An item is laid out at the large width and masked down to the width it is\n// drawn at, centred, with the page's corner on the mask: what it holds is\n// cut at both sides rather than squeezed, as the page's masked items are.\n//\n// **The scrolling is the browser's.** A scroller holds the items' track,\n// which stays put while it scrolls, and a run of empty markers one item\n// apart after it, which is what gives the scroller its length and its rests:\n// each marker's end is a scroll-snap point, and a mark at the scroller's\n// start is the first. The position the scroller reports is what the items\n// are drawn from. Uncontained has no rests and no masks, so its items scroll\n// in the track themselves, snapping to their own starts.\n//\n// **It is the ARIA carousel pattern**, since React Aria has no carousel: a\n// region named by `label` and described as a carousel, each item a group\n// described as a slide and named by which of how many it is, and a previous\n// and a next button under it, at the end. Focus moving into an item that is\n// not drawn large scrolls the carousel to the nearest rest that draws it\n// large, and the scroller is a tab stop while it scrolls, so the arrow keys\n// move it too. Under reduced motion the scroller jumps rather than scrolling\n// smoothly.\n//\n// The page's large width is \"dynamic, or user-set\", and neither MDC-Android\n// nor Compose has a default for it; `itemSize`'s 240 is this component's own.\n// Uncontained keeps the 16dp at its end as well as its start, where the page\n// gives it a leading padding alone, so its last item does not end flush\n// against the edge.\n\n/** The page's 16dp at a carousel's ends. */\nconst PADDING = 16;\nconst DEFAULT_ITEM_SIZE = 240;\ntype CarouselItemProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** What the item shows: usually an image, which the item masks. */\n children?: ReactNode;\n};\ntype CarouselProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {\n /** The items: `Carousel.Item` for each. */\n children?: ReactNode;\n /**\n * The large item's preferred width, in pixels. Multi-browse lays out as\n * many as fit and narrows them where they do not; uncontained draws every\n * item at it; hero takes its large item's width from the carousel's.\n * @default 240\n */\n itemSize?: number;\n /**\n * What the carousel shows, for a screen reader. Required rather than\n * optional: a carousel is a region, and a region with no name is one a\n * screen reader cannot introduce.\n */\n label: string;\n /**\n * Which of the page's layouts the carousel draws.\n * @default 'multi-browse'\n */\n layout?: CarouselLayout;\n /**\n * What the next button is called. Left out, the library names it in the\n * reader's locale — \"Next slide\" in English.\n */\n nextLabel?: string;\n /**\n * What the previous button is called. Left out, the library names it in\n * the reader's locale — \"Previous slide\" in English.\n */\n previousLabel?: string;\n};\nconst styles = {\n item: {\n kaIpWk: \"x19pkqky\",\n kB7OPa: \"x9f619\",\n kzQI83: \"x1c4vz4f\",\n kmuXW: \"x2lah0s\",\n kAzted: \"x2lwn1j\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemUncontained: {\n k5xd4v: \"x1bhewko\",\n $$css: true\n },\n marker: {\n kmuXW: \"x2lah0s\",\n k5xd4v: \"x83psoy\",\n $$css: true\n },\n scroller: {\n kOuLrU: \"xfk6m8\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXHlph: \"xw2csxc\",\n kORKVm: \"x10wlt62\",\n kvh3hx: \"x7p5m3t\",\n kVAEAm: \"x1n2onr6\",\n k5wCbM: \"x1rohswg\",\n khEr5k: \"xkcv6ua xg83hb1\",\n kc424l: \"xhfbhpw\",\n $$css: true\n },\n scrollerUncontained: {\n katHQp: \"x7jkkja\",\n $$css: true\n }\n};\nconst _temp = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp2 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp3 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst placed = {\n item: (inlineSize: string, shift: string, clip: string) => [_temp, {\n kz4h6p: clip != null ? \"xx58lst\" : clip,\n kLqNvP: shift != null ? \"x1lxsm33\" : shift,\n $$css: true\n }, {\n \"--x-clipPath\": clip != null ? clip : undefined,\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize),\n \"--x-insetInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(shift)\n }],\n marker: (inlineSize: string) => [_temp2, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }],\n uncontained: (inlineSize: string) => [_temp3, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }]\n};\ntype Slot = {\n count: number;\n index: number;\n /** The width the item is laid out at. */\n large: number;\n layout: CarouselLayout;\n /** Where it is drawn, for a layout that masks. */\n placement: Placement | undefined;\n};\nconst SlotContext = createContext<null | Slot>(null);\n\n/** What the controls and focus scroll by, as numbers read off one render. */\ntype Geometry = {\n /** The offset of the last rest, or for uncontained how far it scrolls. */\n end: number;\n /** How many items past the first large one the last large one is. */\n lastLarge: number;\n masked: boolean;\n scrolled: number;\n /** The distance between two rests, or for uncontained between two items. */\n step: number;\n};\n\n// Where a press of previous or next scrolls to from `scrolled`: the rest\n// either side of the nearest one, or for uncontained an item's width along,\n// kept between the two ends.\nfunction along(direction: -1 | 1, {\n end,\n masked,\n scrolled,\n step\n}: Geometry): number {\n if (step <= 0) {\n return 0;\n }\n const offset = masked ? (Math.round(scrolled / step) + direction) * step : scrolled + direction * step;\n return Math.min(Math.max(offset, 0), end);\n}\n\n/**\n * A row of items that scrolls on and off the screen, in the carousel page's\n * multi-browse, hero or uncontained layout. Name it with `label`, and give it\n * a `Carousel.Item` for each item.\n *\n * ```tsx\n * <Carousel label=\"Label\">\n * <Carousel.Item><img alt=\"First item\" src=\"…\" /></Carousel.Item>\n * <Carousel.Item><img alt=\"Second item\" src=\"…\" /></Carousel.Item>\n * </Carousel>\n * ```\n *\n * The call site's `className` and `style` land on the carousel as a whole,\n * which is the element a layout positions.\n */\nfunction Carousel({\n children,\n itemSize = DEFAULT_ITEM_SIZE,\n label,\n layout = 'multi-browse',\n nextLabel,\n previousLabel,\n ref,\n ...props\n}: CarouselProps & RefAttributes<HTMLElement>) {\n const messages = useMessages();\n const scrollerRef = useRef<HTMLDivElement>(null);\n // The scroller's width and how far it has scrolled along the text:\n // everything drawn is drawn from these two.\n const [width, setWidth] = useState(0);\n const [scrolled, setScrolled] = useState(0);\n const items = Children.toArray(children).filter(isValidElement);\n const count = items.length;\n const room = Math.max(width - 2 * PADDING, 0);\n const arrangement = arrange(layout, room, itemSize, count);\n const masked = layout !== 'uncontained';\n // Read off the arrangement as arithmetic, so each is a number of its own\n // rather than a field of an object the calls below are handed.\n const step = arrangement.large + GAP;\n // The last rest, or how far the uncontained track runs past the scroller.\n const end = masked ? arrangement.steps * step : Math.max(count * step - GAP + 2 * PADDING - width, 0);\n const lastLarge = arrangement.largeCount - 1;\n const position = masked && step > 0 ? scrolled / step : 0;\n const drawn = masked ? placements(layout, arrangement, room, PADDING, count, position) : [];\n\n // Measured before the first paint, again on every scroll, and whenever\n // the scroller's width changes. A right-to-left scroller counts its offset\n // down from zero.\n const measure = useCallback(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return;\n }\n setWidth(scroller.clientWidth);\n setScrolled(Math.abs(scroller.scrollLeft));\n }, []);\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return undefined;\n }\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(scroller);\n return () => {\n observer.disconnect();\n };\n }, [measure]);\n const previous = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(-1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n const next = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n\n // Focus arriving in an item a masking layout is not drawing large.\n // Uncontained items are where they are drawn, so the browser's own\n // scrolling of focus into view is already right for them.\n const reveal = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const {\n target\n } = event;\n if (!masked || step <= 0 || !(target instanceof Node)) {\n return;\n }\n const index = Array.from(event.currentTarget.children).findIndex(child => child.contains(target));\n if (index < 0) {\n return;\n }\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n const offset = Math.min(restRevealing(index, geometry) * step, end);\n scrollAlong(scrollerRef.current, offset);\n }, [end, lastLarge, masked, scrolled, step]);\n const slots = items.map((_, index): Slot => ({\n count,\n index,\n large: arrangement.large,\n layout,\n placement: drawn[index]\n }));\n return <section aria-label={label} aria-roledescription={messages.carousel} ref={ref} {...props} {...mergeStyles({\n className: \"x9f619 x78zum5 xdt5ytf x126z3so xeuugli\"\n }, props)}>\n <div onScroll={measure} ref={scrollerRef}\n // A tab stop while there is anywhere to scroll, so the arrow keys\n // move it from rest to rest whatever its items hold. A scroll\n // container with nothing focusable inside is otherwise out of a\n // keyboard's reach, which axe's scrollable-region-focusable reports.\n // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- see above\n tabIndex={end > 0 ? 0 : undefined} {...stylex.props(styles.scroller, focus.ring, !masked && styles.scrollerUncontained)}>\n {masked ? <div aria-hidden=\"true\" className=\"xjm9jq1 x1i1rx1s x13vifvy x1o0tod x47corl x10l6tqk x1bhewko\" /> : null}\n <div onFocus={reveal} {...{\n 0: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz\"\n },\n 1: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz xh8yej3 x1o0tod x7giv3 x7wzq59\"\n }\n }[!!masked << 0]}>\n {items.map((item, index) => <SlotContext key={item.key ?? index} value={slots[index] ?? null}>\n {item}\n </SlotContext>)}\n </div>\n {masked ? Array.from({\n length: arrangement.steps\n }, (_, rest) => <div aria-hidden=\"true\" key={rest} {...stylex.props(styles.marker, placed.marker(`${step}px`))} />) : null}\n </div>\n <div className=\"x9f619 x78zum5 x126z3so x13a6bvl x790zyz\">\n <IconButton aria-label={previousLabel ?? messages.previousSlide} isDisabled={scrolled <= 0.5} onPress={previous}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x1pw7kks xpk2tj9\" />\n </IconButton>\n <IconButton aria-label={nextLabel ?? messages.nextSlide} isDisabled={scrolled >= end - 0.5} onPress={next}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x19axjrm x1c071of\" />\n </IconButton>\n </div>\n </section>;\n}\n\n/**\n * One item. It is named by which of how many it is — \"2 of 6\" — unless it is\n * given an `aria-label` of its own.\n *\n * The call site's `className` and `style` land on the item.\n */\nfunction CarouselItem({\n children,\n ref,\n ...props\n}: CarouselItemProps & RefAttributes<HTMLDivElement>) {\n const messages = useMessages();\n const slot = useContext(SlotContext);\n const count = slot?.count ?? 1;\n const index = slot?.index ?? 0;\n const large = slot?.large ?? 0;\n const placement = slot?.placement;\n const inset = placement === undefined ? 0 : (large - placement.width) / 2;\n return <div aria-label={messages.slideLabel(index + 1, count)} aria-roledescription={messages.slide} ref={ref}\n // The pattern's own role for a slide. Its suggested `fieldset` is a\n // form's grouping, with a legend and a border of its own.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- see above\n role=\"group\" {...props} {...mergeStyles(stylex.props(styles.item, slot?.layout === 'uncontained' && styles.itemUncontained, slot?.layout === 'uncontained' && placed.uncontained(`${large}px`), placement !== undefined && placed.item(`${large}px`, `${placement.left - inset - index * (large + GAP)}px`, `inset(0 ${inset}px round ${radii.xl})`)), props)}>\n {children}\n </div>;\n}\n\n// The nearest rest that draws the item at `index` large, from the rest\n// nearest `scrolled`: the one it starts, for an item before the large ones,\n// or the one it ends, for an item after them. At rest `s` the large items\n// are `s` to `s + lastLarge`.\nfunction restRevealing(index: number, {\n lastLarge,\n scrolled,\n step\n}: Geometry): number {\n const at = Math.round(scrolled / step);\n if (index < at) {\n return index;\n }\n if (index > at + lastLarge) {\n return index - lastLarge;\n }\n return at;\n}\n\n// Scrolls to an offset along the text, whichever way it runs: a\n// right-to-left scroller counts its offset down from zero.\nfunction scrollAlong(scroller: HTMLElement | null, offset: number) {\n if (scroller === null) {\n return;\n }\n const sign = getComputedStyle(scroller).direction === 'rtl' ? -1 : 1;\n scroller.scrollTo({\n left: sign * offset\n });\n}\nCarousel.Item = CarouselItem;\nexport type { CarouselItemProps, CarouselLayout, CarouselProps };\nexport { CarouselItem };\nexport default Carousel;"],"mappings":";;;;;;;;;;;;;;AA4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,YAAYlF,UAA8BsC,QAAgB;CACjE,IAAItC,aAAa,MACf;CAEF,MAAMyI,OAAOC,iBAAiB1I,QAAQ,CAAC,CAACqC,cAAc,QAAQ,KAAK;CACnErC,SAAS2I,SAAS,EAChBL,MAAMG,OAAOnG,OACf,CAAC;AACH;AACAK,SAASiG,OAAOX"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","Children","createContext","isValidElement","useContext","useLayoutEffect","useRef","useState","arrange","placements","useMessages","focus","mergeStyles","radii","PADDING","DEFAULT_ITEM_SIZE","children","visibleWidth","width","itemSize","label","layout","nextLabel","previousLabel","styles","item","kaIpWk","kB7OPa","kzQI83","kmuXW","kAzted","kVQacm","kVAEAm","$$css","itemUncontained","k5xd4v","marker","scroller","kOuLrU","k1xSpc","kXHlph","kORKVm","kvh3hx","k5wCbM","khEr5k","kc424l","scrollerUncontained","katHQp","_temp","kzqmXN","_temp2","_temp3","placed","inlineSize","shift","clip","kz4h6p","kLqNvP","undefined","val","uncontained","count","index","large","placement","SlotContext","end","lastLarge","masked","scrolled","step","along","direction","offset","Math","round","min","max","Carousel","t0","$","t1","t2","ref","props","messages","scrollerRef","setWidth","setScrolled","items","toArray","filter","length","room","arrangement","steps","largeCount","position","drawn","t3","Symbol","for","current","clientWidth","abs","scrollLeft","measure","t4","t5","scroller_0","observer","ResizeObserver","observe","disconnect","t6","geometry","scrollAlong","previous","t7","geometry_0","next","t8","event","target","Node","Array","from","currentTarget","findIndex","child","contains","restRevealing","reveal","slots","map","_","index_0","t9","carousel","t10","className","t11","ring","t12","t13","0","1","t14","previousSlide","t15","t16","t17","t18","nextSlide","t19","t20","t21","t22","index_1","key","__0","rest","CarouselItem","slot","inset","slideLabel","slide","left","xl","at","sign","getComputedStyle","scrollTo","Item"],"sources":["../../../src/components/carousel/index.tsx"],"sourcesContent":["'use client';\n\nimport type { FocusEvent, HTMLAttributes, ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { Children, createContext, isValidElement, useCallback, useContext, useLayoutEffect, useRef, useState } from 'react';\nimport type { CarouselLayout, Placement } from '../../carousel/arrangement';\nimport { arrange, GAP, placements } from '../../carousel/arrangement';\nimport { ChevronEndGlyph } from '../../glyphs';\nimport { useMessages } from '../../i18n';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, spacing } from '../../tokens/design.tokens.stylex';\nimport IconButton from '../icon-button';\n\n// The carousel page's carousel: a row of items that scrolls on and off the\n// screen, drawn in three of the page's layouts. Each has the page's 16dp of\n// padding at its ends and 8dp at its top and bottom, 8dp between items and a\n// 28dp corner on every item.\n//\n// - **Multi-browse**, the default, shows as many large items as fit at\n// `itemSize`, then a medium one and a small one, and fills its width\n// exactly; the large width gives way where the preferred one does not fit.\n// - **Hero** shows one large item and one small.\n// - **Uncontained** shows every item at `itemSize`, scrolling past the edge.\n//\n// **Items change size as they move**, as the page draws them. The first two\n// layouts come to rest one item apart, and between two rests every item's\n// place and width are interpolated, so an item shrinks as it leaves and\n// grows as it arrives; the last rests turn the arrangement round a slot at a\n// time, so every item is drawn large at one of them. The arithmetic is\n// `src/carousel/arrangement.ts`.\n// An item is laid out at the large width and masked down to the width it is\n// drawn at, centred, with the page's corner on the mask: what it holds is\n// cut at both sides rather than squeezed, as the page's masked items are.\n//\n// **What an item holds can see its mask.** The page shows an item's text\n// once the item is wide enough to hold it, and only what the item holds\n// knows where its text is, so `Carousel.Item` takes its children as a\n// function too, handed the width the item is laid out at and the width\n// that shows of it, as MDC-Android's masked items report their mask to a\n// listener. The text can then fade or hide as the mask closes over it.\n//\n// **The scrolling is the browser's.** A scroller holds the items' track,\n// which stays put while it scrolls, and a run of empty markers one item\n// apart after it, which is what gives the scroller its length and its rests:\n// each marker's end is a scroll-snap point, and a mark at the scroller's\n// start is the first. The position the scroller reports is what the items\n// are drawn from. Uncontained has no rests and no masks, so its items scroll\n// in the track themselves, snapping to their own starts.\n//\n// **It is the ARIA carousel pattern**, since React Aria has no carousel: a\n// region named by `label` and described as a carousel, each item a group\n// described as a slide and named by which of how many it is, and a previous\n// and a next button under it, at the end. Focus moving into an item that is\n// not drawn large scrolls the carousel to the nearest rest that draws it\n// large, and the scroller is a tab stop while it scrolls, so the arrow keys\n// move it too. Under reduced motion the scroller jumps rather than scrolling\n// smoothly.\n//\n// The page's large width is \"dynamic, or user-set\", and neither MDC-Android\n// nor Compose has a default for it; `itemSize`'s 240 is this component's own.\n// Uncontained keeps the 16dp at its end as well as its start, where the page\n// gives it a leading padding alone, so its last item does not end flush\n// against the edge.\n\n/** The page's 16dp at a carousel's ends. */\nconst PADDING = 16;\nconst DEFAULT_ITEM_SIZE = 240;\ntype CarouselItemProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /**\n * What the item shows: usually an image, which the item masks. A function\n * is handed how much of the item shows, every time that changes, so text\n * the item has no room for can be hidden as the mask closes over it.\n */\n children?: ((state: CarouselItemRenderProps) => ReactNode) | ReactNode;\n};\n\n/** How much of a `Carousel.Item` shows, for children written as a function. */\ntype CarouselItemRenderProps = {\n /**\n * How much of `width` shows, in pixels. The mask takes the rest evenly\n * from both sides, so `(width - visibleWidth) / 2` is cut off each. It is\n * `width` for an item drawn large, and for every item of an uncontained\n * carousel, which masks nothing.\n */\n visibleWidth: number;\n /**\n * The width the item is laid out at, in pixels: the large item's, which\n * every item in the carousel shares.\n */\n width: number;\n};\ntype CarouselProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {\n /** The items: `Carousel.Item` for each. */\n children?: ReactNode;\n /**\n * The large item's preferred width, in pixels. Multi-browse lays out as\n * many as fit and narrows them where they do not; uncontained draws every\n * item at it; hero takes its large item's width from the carousel's.\n * @default 240\n */\n itemSize?: number;\n /**\n * What the carousel shows, for a screen reader. Required rather than\n * optional: a carousel is a region, and a region with no name is one a\n * screen reader cannot introduce.\n */\n label: string;\n /**\n * Which of the page's layouts the carousel draws.\n * @default 'multi-browse'\n */\n layout?: CarouselLayout;\n /**\n * What the next button is called. Left out, the library names it in the\n * reader's locale — \"Next slide\" in English.\n */\n nextLabel?: string;\n /**\n * What the previous button is called. Left out, the library names it in\n * the reader's locale — \"Previous slide\" in English.\n */\n previousLabel?: string;\n};\nconst styles = {\n item: {\n kaIpWk: \"x19pkqky\",\n kB7OPa: \"x9f619\",\n kzQI83: \"x1c4vz4f\",\n kmuXW: \"x2lah0s\",\n kAzted: \"x2lwn1j\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemUncontained: {\n k5xd4v: \"x1bhewko\",\n $$css: true\n },\n marker: {\n kmuXW: \"x2lah0s\",\n k5xd4v: \"x83psoy\",\n $$css: true\n },\n scroller: {\n kOuLrU: \"xfk6m8\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXHlph: \"xw2csxc\",\n kORKVm: \"x10wlt62\",\n kvh3hx: \"x7p5m3t\",\n kVAEAm: \"x1n2onr6\",\n k5wCbM: \"x1rohswg\",\n khEr5k: \"xkcv6ua xg83hb1\",\n kc424l: \"xhfbhpw\",\n $$css: true\n },\n scrollerUncontained: {\n katHQp: \"x7jkkja\",\n $$css: true\n }\n};\nconst _temp = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp2 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp3 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst placed = {\n item: (inlineSize: string, shift: string, clip: string) => [_temp, {\n kz4h6p: clip != null ? \"xx58lst\" : clip,\n kLqNvP: shift != null ? \"x1lxsm33\" : shift,\n $$css: true\n }, {\n \"--x-clipPath\": clip != null ? clip : undefined,\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize),\n \"--x-insetInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(shift)\n }],\n marker: (inlineSize: string) => [_temp2, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }],\n uncontained: (inlineSize: string) => [_temp3, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }]\n};\ntype Slot = {\n count: number;\n index: number;\n /** The width the item is laid out at. */\n large: number;\n layout: CarouselLayout;\n /** Where it is drawn, for a layout that masks. */\n placement: Placement | undefined;\n};\nconst SlotContext = createContext<null | Slot>(null);\n\n/** What the controls and focus scroll by, as numbers read off one render. */\ntype Geometry = {\n /** The offset of the last rest, or for uncontained how far it scrolls. */\n end: number;\n /** How many items past the first large one the last large one is. */\n lastLarge: number;\n masked: boolean;\n scrolled: number;\n /** The distance between two rests, or for uncontained between two items. */\n step: number;\n};\n\n// Where a press of previous or next scrolls to from `scrolled`: the rest\n// either side of the nearest one, or for uncontained an item's width along,\n// kept between the two ends.\nfunction along(direction: -1 | 1, {\n end,\n masked,\n scrolled,\n step\n}: Geometry): number {\n if (step <= 0) {\n return 0;\n }\n const offset = masked ? (Math.round(scrolled / step) + direction) * step : scrolled + direction * step;\n return Math.min(Math.max(offset, 0), end);\n}\n\n/**\n * A row of items that scrolls on and off the screen, in the carousel page's\n * multi-browse, hero or uncontained layout. Name it with `label`, and give it\n * a `Carousel.Item` for each item.\n *\n * ```tsx\n * <Carousel label=\"Label\">\n * <Carousel.Item><img alt=\"First item\" src=\"…\" /></Carousel.Item>\n * <Carousel.Item><img alt=\"Second item\" src=\"…\" /></Carousel.Item>\n * </Carousel>\n * ```\n *\n * The call site's `className` and `style` land on the carousel as a whole,\n * which is the element a layout positions.\n */\nfunction Carousel({\n children,\n itemSize = DEFAULT_ITEM_SIZE,\n label,\n layout = 'multi-browse',\n nextLabel,\n previousLabel,\n ref,\n ...props\n}: CarouselProps & RefAttributes<HTMLElement>) {\n const messages = useMessages();\n const scrollerRef = useRef<HTMLDivElement>(null);\n // The scroller's width and how far it has scrolled along the text:\n // everything drawn is drawn from these two.\n const [width, setWidth] = useState(0);\n const [scrolled, setScrolled] = useState(0);\n const items = Children.toArray(children).filter(isValidElement);\n const count = items.length;\n const room = Math.max(width - 2 * PADDING, 0);\n const arrangement = arrange(layout, room, itemSize, count);\n const masked = layout !== 'uncontained';\n // Read off the arrangement as arithmetic, so each is a number of its own\n // rather than a field of an object the calls below are handed.\n const step = arrangement.large + GAP;\n // The last rest, or how far the uncontained track runs past the scroller.\n const end = masked ? arrangement.steps * step : Math.max(count * step - GAP + 2 * PADDING - width, 0);\n const lastLarge = arrangement.largeCount - 1;\n const position = masked && step > 0 ? scrolled / step : 0;\n const drawn = masked ? placements(layout, arrangement, room, PADDING, count, position) : [];\n\n // Measured before the first paint, again on every scroll, and whenever\n // the scroller's width changes. A right-to-left scroller counts its offset\n // down from zero.\n const measure = useCallback(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return;\n }\n setWidth(scroller.clientWidth);\n setScrolled(Math.abs(scroller.scrollLeft));\n }, []);\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return undefined;\n }\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(scroller);\n return () => {\n observer.disconnect();\n };\n }, [measure]);\n const previous = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(-1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n const next = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n\n // Focus arriving in an item a masking layout is not drawing large.\n // Uncontained items are where they are drawn, so the browser's own\n // scrolling of focus into view is already right for them.\n const reveal = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const {\n target\n } = event;\n if (!masked || step <= 0 || !(target instanceof Node)) {\n return;\n }\n const index = Array.from(event.currentTarget.children).findIndex(child => child.contains(target));\n if (index < 0) {\n return;\n }\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n const offset = Math.min(restRevealing(index, geometry) * step, end);\n scrollAlong(scrollerRef.current, offset);\n }, [end, lastLarge, masked, scrolled, step]);\n const slots = items.map((_, index): Slot => ({\n count,\n index,\n large: arrangement.large,\n layout,\n placement: drawn[index]\n }));\n return <section aria-label={label} aria-roledescription={messages.carousel} ref={ref} {...props} {...mergeStyles({\n className: \"x9f619 x78zum5 xdt5ytf x126z3so xeuugli\"\n }, props)}>\n <div onScroll={measure} ref={scrollerRef}\n // A tab stop while there is anywhere to scroll, so the arrow keys\n // move it from rest to rest whatever its items hold. A scroll\n // container with nothing focusable inside is otherwise out of a\n // keyboard's reach, which axe's scrollable-region-focusable reports.\n // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- see above\n tabIndex={end > 0 ? 0 : undefined} {...stylex.props(styles.scroller, focus.ring, !masked && styles.scrollerUncontained)}>\n {masked ? <div aria-hidden=\"true\" className=\"xjm9jq1 x1i1rx1s x13vifvy x1o0tod x47corl x10l6tqk x1bhewko\" /> : null}\n <div onFocus={reveal} {...{\n 0: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz\"\n },\n 1: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz xh8yej3 x1o0tod x7giv3 x7wzq59\"\n }\n }[!!masked << 0]}>\n {items.map((item, index) => <SlotContext key={item.key ?? index} value={slots[index] ?? null}>\n {item}\n </SlotContext>)}\n </div>\n {masked ? Array.from({\n length: arrangement.steps\n }, (_, rest) => <div aria-hidden=\"true\" key={rest} {...stylex.props(styles.marker, placed.marker(`${step}px`))} />) : null}\n </div>\n <div className=\"x9f619 x78zum5 x126z3so x13a6bvl x790zyz\">\n <IconButton aria-label={previousLabel ?? messages.previousSlide} isDisabled={scrolled <= 0.5} onPress={previous}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x1pw7kks xpk2tj9\" />\n </IconButton>\n <IconButton aria-label={nextLabel ?? messages.nextSlide} isDisabled={scrolled >= end - 0.5} onPress={next}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x19axjrm x1c071of\" />\n </IconButton>\n </div>\n </section>;\n}\n\n/**\n * One item. It is named by which of how many it is — \"2 of 6\" — unless it is\n * given an `aria-label` of its own.\n *\n * The call site's `className` and `style` land on the item.\n */\nfunction CarouselItem({\n children,\n ref,\n ...props\n}: CarouselItemProps & RefAttributes<HTMLDivElement>) {\n const messages = useMessages();\n const slot = useContext(SlotContext);\n const count = slot?.count ?? 1;\n const index = slot?.index ?? 0;\n const large = slot?.large ?? 0;\n const placement = slot?.placement;\n const visibleWidth = placement === undefined ? large : placement.width;\n const inset = (large - visibleWidth) / 2;\n return <div aria-label={messages.slideLabel(index + 1, count)} aria-roledescription={messages.slide} ref={ref}\n // The pattern's own role for a slide. Its suggested `fieldset` is a\n // form's grouping, with a legend and a border of its own.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- see above\n role=\"group\" {...props} {...mergeStyles(stylex.props(styles.item, slot?.layout === 'uncontained' && styles.itemUncontained, slot?.layout === 'uncontained' && placed.uncontained(`${large}px`), placement !== undefined && placed.item(`${large}px`, `${placement.left - inset - index * (large + GAP)}px`, `inset(0 ${inset}px round ${radii.xl})`)), props)}>\n {typeof children === 'function' ? children({\n visibleWidth,\n width: large\n }) : children}\n </div>;\n}\n\n// The nearest rest that draws the item at `index` large, from the rest\n// nearest `scrolled`: the one it starts, for an item before the large ones,\n// or the one it ends, for an item after them. At rest `s` the large items\n// are `s` to `s + lastLarge`.\nfunction restRevealing(index: number, {\n lastLarge,\n scrolled,\n step\n}: Geometry): number {\n const at = Math.round(scrolled / step);\n if (index < at) {\n return index;\n }\n if (index > at + lastLarge) {\n return index - lastLarge;\n }\n return at;\n}\n\n// Scrolls to an offset along the text, whichever way it runs: a\n// right-to-left scroller counts its offset down from zero.\nfunction scrollAlong(scroller: HTMLElement | null, offset: number) {\n if (scroller === null) {\n return;\n }\n const sign = getComputedStyle(scroller).direction === 'rtl' ? -1 : 1;\n scroller.scrollTo({\n left: sign * offset\n });\n}\nCarousel.Item = CarouselItem;\nexport type { CarouselItemProps, CarouselItemRenderProps, CarouselLayout, CarouselProps };\nexport { CarouselItem };\nexport default Carousel;"],"mappings":";;;;;;;;;;;;;;AAmEA,MAAMe,UAAU;AAChB,MAAMC,oBAAoB;AAyD1B,MAAMS,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,iBAAiB;EACfC,QAAQ;EACRF,OAAO;CACT;CACAG,QAAQ;EACNP,OAAO;EACPM,QAAQ;EACRF,OAAO;CACT;CACAI,UAAU;EACRC,QAAQ;EACRX,QAAQ;EACRY,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRV,QAAQ;EACRW,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRZ,OAAO;CACT;CACAa,qBAAqB;EACnBC,QAAQ;EACRd,OAAO;CACT;AACF;AACA,MAAMe,QAAQ;CACZC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,SAAS;CACbD,QAAQ;CACR,SAAS;AACX;AACA,MAAME,SAAS;CACbF,QAAQ;CACR,SAAS;AACX;AACA,MAAMG,SAAS;CACb3B,OAAO4B,YAAoBC,OAAeC,SAAiB;EAACP;EAAO;GACjEQ,QAAQD,QAAQ,OAAO,YAAYA;GACnCE,QAAQH,SAAS,OAAO,aAAaA;GACrCrB,OAAO;EACT;EAAG;GACD,gBAAgBsB,QAAQ,OAAOA,OAAOG,KAAAA;GACtC,oBAAmBC,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO,OAAOA,MAAMD,KAAAA,EAAAA,CAAWL,UAAU;GAC1G,0BAAyBM,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO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M,KAAA,oBAAA,OAAA;GAAiB,cAAAjC;GAA6D,wBAAAC;GAAqBC;GAIrG,MAAAgB;GAAO,GAAKf;GAAK,GAAMuB;GACvBC,UAAAA;EAIG,CAAA;EAAA5B,EAAA,KAAAK,SAAAiF;EAAAtF,EAAA,KAAAI;EAAAJ,EAAA,MAAAG;EAAAH,EAAA,MAAAC;EAAAD,EAAA,MAAA2B;EAAA3B,EAAA,MAAA4B;EAAA5B,EAAA,MAAAkC;CAAA,OAAAA,KAAAlC,EAAA;CAAA,OATDkC;AASC;AAOV,SAASiB,cAAcrE,OAAe,EACpCK,WACAE,UACAC,QACmB;CACnB,MAAMmG,KAAK/F,KAAKC,MAAMN,WAAWC,IAAI;CACrC,IAAIR,QAAQ2G,IACV,OAAO3G;CAET,IAAIA,QAAQ2G,KAAKtG,WACf,OAAOL,QAAQK;CAEjB,OAAOsG;AACT;AAIA,SAASrD,YAAY/E,UAA8BoC,QAAgB;CACjE,IAAIpC,aAAa,MACf;CAEF,MAAMqI,OAAOC,iBAAiBtI,QAAQ,CAAC,CAACmC,cAAc,QAAQ,KAAK;CACnEnC,SAASuI,SAAS,EAChBL,MAAMG,OAAOjG,OACf,CAAC;AACH;AACAK,SAAS+F,OAAOX"}
@@ -42,5 +42,4 @@ type CheckboxProps = {
42
42
  * which is the element a layout positions.
43
43
  */
44
44
  declare function Checkbox({ children, description, error, ...props }: CheckboxProps & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
45
- export { type CheckboxProps, Checkbox as default };
46
- //# sourceMappingURL=index.d.ts.map
45
+ export { type CheckboxProps, Checkbox as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","CheckboxButtonRenderProps","CheckboxFieldRenderProps","PressEvent","CheckboxFieldProps","RACCheckboxFieldProps","stylex","useContext","CheckboxButton","CheckboxField","CheckboxGroupStateContext","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","IndeterminateGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","stateLayerOpacity","FORCED_COLORS","styles","box","k6CgDc","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kVAEAm","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","CheckboxProps","children","description","Omit","Ripple","ReturnType","HTMLLabelElement","Tone","buttonContent","surface","inGroup","state","required","isRequired","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","props","disc","controlReadOnly","controlDisabled","ringVisible","className","Checkbox","t0","$","validationBehavior","group","reachable","validate","undefined","name","t1","Symbol","for","ripple","press","onPress","event","pointerType","play","t2","t3","field","t4","handlers","t5","t6","t7","fieldContent","button","reserve","messages","stylex.props","_c","props"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldRenderProps, PressEvent, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CheckboxButton, CheckboxField, CheckboxGroupStateContext } from 'react-aria-components';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\n//\n// A change of state moves together: the fill and the rule fade, and the glyph\n// fades and grows in or shrinks out with them, over the same duration and\n// curve. Both glyphs are always drawn, one over the other, so a box moving\n// between checked and indeterminate crosses from one to the other, and one\n// being cleared fades out the mark it had.\n//\n// The ripple answers every press: on the control, on the text beside it, or\n// from a key, and grows from the middle of the control whichever it is. The\n// text runs the width of the row, so a ripple following the pointer there\n// reached the control only as it finished growing. A key press ripples once\n// the key has activated the checkbox, as Button's does.\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x1lliihq\",\n kzqmXN: \"x1xp8n7a\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n kMwMTN: \"xrpadme x1bhcspo\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on xmnqt3w\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n error: {\n kWkggS: \"xyn212m\",\n $$css: true\n },\n marked: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"xwqhyid\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n *\n * A link or a button in it acts on its own, as in a native label: a press\n * or Enter on \"the terms\" in \"I agree to the terms\" follows the link and\n * leaves the checkbox as it was. A press anywhere else in the label\n * toggles it.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLLabelElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The ripple's surface goes on the control while\n// the checkbox can change, and is left off while it cannot, since a press\n// that changes nothing should not look like one. Its handlers are the\n// label's, in `Checkbox` below.\nfunction buttonContent(children: ReactNode, surface: Ripple['surface'], inGroup: boolean) {\n return (state: CheckboxButtonRenderProps) => {\n // A checkbox in a group is marked by the group's label rather than its\n // own: the group is what has to have a choice made in it.\n const required = state.isRequired && !inGroup;\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n <CheckGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!(state.isSelected && !state.isIndeterminate) << 0]} />\n <IndeterminateGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!state.isIndeterminate << 0]} />\n </span>\n {interactive ? surface : null}\n </span>\n <ControlLabel isRequired={required} state={state}>\n {children}\n </ControlLabel>\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * `isRequired` ends the label in the asterisk every required field's label\n * ends in. Inside a `CheckboxGroup` the group's label carries it instead,\n * since the group is what must have a choice made in it.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n\n // Whether a message can ever reach this checkbox, which is what a form\n // keeps an empty line under a field for. One in a group cannot — the\n // group owns the one message and keeps its own line for it — and one on\n // its own can only where something can find it wanting: a requirement, a\n // check of its own, or a name a form's errors can be keyed by. Without\n // this every checkbox in a form sat a line taller than it draws, and a\n // group of them in a form gained a line after every item.\n const group = useContext(CheckboxGroupStateContext);\n const inGroup = group !== null;\n const reachable = !inGroup && (props.isRequired === true || props.validate !== undefined || props.name !== undefined);\n\n // The ripple listens on the label, which hears a pointer on the control and\n // on the text alike, and grows from the middle of the control for both.\n // React Aria drops a click handler there, so a press ends on its release\n // instead. A key reaches the input rather than the label, so its press is\n // played once it activates the checkbox. React Aria reports that\n // activation twice, as the key and then as the click the browser makes of\n // it, and only the first plays. A checkbox that a press cannot change\n // listens for neither, as in `buttonContent`.\n const interactive = props.isDisabled !== true && props.isReadOnly !== true && group?.isDisabled !== true && group?.isReadOnly !== true;\n const ripple = useRipple<HTMLLabelElement>(interactive, {}, true, true);\n const press = {\n onPress: (event: PressEvent) => {\n if (event.pointerType === 'keyboard') {\n ripple.play();\n }\n props.onPress?.(event);\n }\n };\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...press} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n {fieldContent(<CheckboxButton {...ripple.handlers} className=\"xjp7ctv\">\n {buttonContent(children, ripple.surface, inGroup)}\n </CheckboxButton>, description, error, reachable)}\n </CheckboxField>;\n}\n\n// The button and the line under it, from the field's render state: the\n// description fades with a disabled checkbox, by itself or by its group, as\n// its label does. Built by a call for the same reason as `buttonContent`.\nfunction fieldContent(button: ReactNode, description: string | undefined, error: string | undefined, reserve: boolean) {\n return ({\n isDisabled\n }: CheckboxFieldRenderProps) => <>\n {button}\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} indent inset={false} isDisabled={isDisabled} reserve={reserve} />\n </div>\n </>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;;AAwDA,MAAM4B,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EAC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uB,EAAA,KAAAU,OAAAlC;EAAAwB,EAAA,KAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,IAAAsB;CAAA,IAAAtB,EAAA,OAAAU,OAAAU,YAAApB,EAAA,OAAAqB,IAAA;EADvCC,KAAA,oBAAC,gBAAD;GAAe,GAAKH;GAA2B,WAAA;GACxDE,UAAAA;EADwB,CAAA;EAEVrB,EAAA,KAAAU,OAAAU;EAAApB,EAAA,KAAAqB;EAAArB,EAAA,KAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,IAAAuB;CAAA,IAAAvB,EAAA,QAAA/B,eAAA+B,EAAA,QAAAtC,SAAAsC,EAAA,QAAAG,aAAAH,EAAA,QAAAsB,IAAA;EAFlBC,KAAAC,aAAaF,IAEOrD,aAAaP,OAAOyC,SAAS;EAACH,EAAA,MAAA/B;EAAA+B,EAAA,MAAAtC;EAAAsC,EAAA,MAAAG;EAAAH,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,OAHhD,oBAAC,eAAD;EAA0B,WAAAgB;EAAwCf;EAAkB,GAAMT;EAAK,GAAMmB;EAAK,GAAMM;EAClHM,UAAAA;CADgB,CAAA;AAIH;AAMpB,SAASC,aAAaC,QAAmBxD,aAAiCP,OAA2BgE,SAAkB;CACrH,QAAQ,EACN1C,iBAC8B,qBAAA,YAAA,EAAA,UAAA,CAC3ByC,QACD,oBAAC,OAAD;EAAK,GAAI5G,MAAaM,cAAcwG,QAAQ;EAC1C,UAAA,oBAAC,cAAD;GAA2B1D;GAAoBP;GAAO,QAAA;GAAO,OAAO;GAAmBsB;GAAqB0C;EAAQ,CAAA;CACjH,CAAA,CACP,EAAA,CAAA;AACJ"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","useContext","CheckboxGroupStateContext","controlStyles","invalidFrom","useFieldValidationBehavior","useRipple","focus","mergeStatefulStyles","styles","box","k6CgDc","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kVAEAm","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","children","description","buttonContent","surface","inGroup","state","required","isRequired","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","props","disc","controlReadOnly","controlDisabled","ringVisible","className","Checkbox","t0","$","validationBehavior","group","reachable","validate","undefined","name","t1","Symbol","for","ripple","press","onPress","event","pointerType","play","t2","t3","field","t4","handlers","t5","t6","t7","fieldContent","button","reserve","messages"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldRenderProps, PressEvent, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CheckboxButton, CheckboxField, CheckboxGroupStateContext } from 'react-aria-components';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\n//\n// A change of state moves together: the fill and the rule fade, and the glyph\n// fades and grows in or shrinks out with them, over the same duration and\n// curve. Both glyphs are always drawn, one over the other, so a box moving\n// between checked and indeterminate crosses from one to the other, and one\n// being cleared fades out the mark it had.\n//\n// The ripple answers every press: on the control, on the text beside it, or\n// from a key, and grows from the middle of the control whichever it is. The\n// text runs the width of the row, so a ripple following the pointer there\n// reached the control only as it finished growing. A key press ripples once\n// the key has activated the checkbox, as Button's does.\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x1lliihq\",\n kzqmXN: \"x1xp8n7a\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n kMwMTN: \"xrpadme x1bhcspo\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on xmnqt3w\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n error: {\n kWkggS: \"xyn212m\",\n $$css: true\n },\n marked: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"xwqhyid\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n *\n * A link or a button in it acts on its own, as in a native label: a press\n * or Enter on \"the terms\" in \"I agree to the terms\" follows the link and\n * leaves the checkbox as it was. A press anywhere else in the label\n * toggles it.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLLabelElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The ripple's surface goes on the control while\n// the checkbox can change, and is left off while it cannot, since a press\n// that changes nothing should not look like one. Its handlers are the\n// label's, in `Checkbox` below.\nfunction buttonContent(children: ReactNode, surface: Ripple['surface'], inGroup: boolean) {\n return (state: CheckboxButtonRenderProps) => {\n // A checkbox in a group is marked by the group's label rather than its\n // own: the group is what has to have a choice made in it.\n const required = state.isRequired && !inGroup;\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n <CheckGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!(state.isSelected && !state.isIndeterminate) << 0]} />\n <IndeterminateGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!state.isIndeterminate << 0]} />\n </span>\n {interactive ? surface : null}\n </span>\n <ControlLabel isRequired={required} state={state}>\n {children}\n </ControlLabel>\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * `isRequired` ends the label in the asterisk every required field's label\n * ends in. Inside a `CheckboxGroup` the group's label carries it instead,\n * since the group is what must have a choice made in it.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n\n // Whether a message can ever reach this checkbox, which is what a form\n // keeps an empty line under a field for. One in a group cannot — the\n // group owns the one message and keeps its own line for it — and one on\n // its own can only where something can find it wanting: a requirement, a\n // check of its own, or a name a form's errors can be keyed by. Without\n // this every checkbox in a form sat a line taller than it draws, and a\n // group of them in a form gained a line after every item.\n const group = useContext(CheckboxGroupStateContext);\n const inGroup = group !== null;\n const reachable = !inGroup && (props.isRequired === true || props.validate !== undefined || props.name !== undefined);\n\n // The ripple listens on the label, which hears a pointer on the control and\n // on the text alike, and grows from the middle of the control for both.\n // React Aria drops a click handler there, so a press ends on its release\n // instead. A key reaches the input rather than the label, so its press is\n // played once it activates the checkbox. React Aria reports that\n // activation twice, as the key and then as the click the browser makes of\n // it, and only the first plays. A checkbox that a press cannot change\n // listens for neither, as in `buttonContent`.\n const interactive = props.isDisabled !== true && props.isReadOnly !== true && group?.isDisabled !== true && group?.isReadOnly !== true;\n const ripple = useRipple<HTMLLabelElement>(interactive, {}, true, true);\n const press = {\n onPress: (event: PressEvent) => {\n if (event.pointerType === 'keyboard') {\n ripple.play();\n }\n props.onPress?.(event);\n }\n };\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...press} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n {fieldContent(<CheckboxButton {...ripple.handlers} className=\"xjp7ctv\">\n {buttonContent(children, ripple.surface, inGroup)}\n </CheckboxButton>, description, error, reachable)}\n </CheckboxField>;\n}\n\n// The button and the line under it, from the field's render state: the\n// description fades with a disabled checkbox, by itself or by its group, as\n// its label does. Built by a call for the same reason as `buttonContent`.\nfunction fieldContent(button: ReactNode, description: string | undefined, error: string | undefined, reserve: boolean) {\n return ({\n isDisabled\n }: CheckboxFieldRenderProps) => <>\n {button}\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} indent inset={false} isDisabled={isDisabled} reserve={reserve} />\n </div>\n </>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;;AAwDA,MAAMU,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,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gBAAD;GAAe,GAAKH;GAA2B,WAAA;GACxDE,UAAAA;EADwB,CAAA;EAEVrB,EAAA,KAAAU,OAAAU;EAAApB,EAAA,KAAAqB;EAAArB,EAAA,KAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,IAAAuB;CAAA,IAAAvB,EAAA,QAAA1B,eAAA0B,EAAA,QAAAhC,SAAAgC,EAAA,QAAAG,aAAAH,EAAA,QAAAsB,IAAA;EAFlBC,KAAAC,aAAaF,IAEOhD,aAAaN,OAAOmC,SAAS;EAACH,EAAA,MAAA1B;EAAA0B,EAAA,MAAAhC;EAAAgC,EAAA,MAAAG;EAAAH,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,OAHhD,oBAAC,eAAD;EAA0B,WAAAgB;EAAwCf;EAAkB,GAAMT;EAAK,GAAMmB;EAAK,GAAMM;EAClHM,UAAAA;CADgB,CAAA;AAIH;AAMpB,SAASC,aAAaC,QAAmBnD,aAAiCN,OAA2B0D,SAAkB;CACrH,QAAQ,EACN1C,iBAC8B,qBAAA,YAAA,EAAA,UAAA,CAC3ByC,QACD,oBAAC,OAAD;EAAK,GAAI5F,MAAaG,cAAc2F,QAAQ;EAC1C,UAAA,oBAAC,cAAD;GAA2BrD;GAAoBN;GAAO,QAAA;GAAO,OAAO;GAAmBgB;GAAqB0C;EAAQ,CAAA;CACjH,CAAA,CACP,EAAA,CAAA;AACJ"}
@@ -36,5 +36,4 @@ type CheckboxGroupProps$1 = {
36
36
  * which is the element a layout positions.
37
37
  */
38
38
  declare function CheckboxGroup$1({ children, description, error, label, ...props }: CheckboxGroupProps$1 & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
39
- export { type CheckboxGroupProps$1 as CheckboxGroupProps, CheckboxGroup$1 as default };
40
- //# sourceMappingURL=index.d.ts.map
39
+ export { type CheckboxGroupProps$1 as CheckboxGroupProps, CheckboxGroup$1 as default };