@kanso-labs/kanso-ui 0.36.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +2 -0
  2. package/dist/button/context.js +7 -0
  3. package/dist/button/context.js.map +1 -0
  4. package/dist/button/group.js +25 -0
  5. package/dist/button/group.js.map +1 -0
  6. package/dist/button/index.js +50 -37
  7. package/dist/button/index.js.map +1 -1
  8. package/dist/calendar/styles.js +2 -1
  9. package/dist/calendar/styles.js.map +1 -1
  10. package/dist/carousel/arrangement.d.ts +5 -0
  11. package/dist/carousel/arrangement.js +123 -0
  12. package/dist/carousel/arrangement.js.map +1 -0
  13. package/dist/chip/index.js +53 -15
  14. package/dist/chip/index.js.map +1 -1
  15. package/dist/chip/styles.js +48 -0
  16. package/dist/chip/styles.js.map +1 -1
  17. package/dist/collection/styles.js +21 -2
  18. package/dist/collection/styles.js.map +1 -1
  19. package/dist/components/badge/index.d.ts +3 -0
  20. package/dist/components/badge/index.js +7 -2
  21. package/dist/components/badge/index.js.map +1 -1
  22. package/dist/components/button/index.d.ts +1 -1
  23. package/dist/components/button/index.js +94 -111
  24. package/dist/components/button/index.js.map +1 -1
  25. package/dist/components/button-group/index.d.ts +54 -0
  26. package/dist/components/button-group/index.js +272 -0
  27. package/dist/components/button-group/index.js.map +1 -0
  28. package/dist/components/calendar/index.d.ts +3 -2
  29. package/dist/components/calendar/index.js +3 -2
  30. package/dist/components/calendar/index.js.map +1 -1
  31. package/dist/components/carousel/index.d.ts +68 -0
  32. package/dist/components/carousel/index.js +395 -0
  33. package/dist/components/carousel/index.js.map +1 -0
  34. package/dist/components/checkbox/index.js +15 -1
  35. package/dist/components/checkbox/index.js.map +1 -1
  36. package/dist/components/chip/index.d.ts +55 -8
  37. package/dist/components/chip/index.js +174 -57
  38. package/dist/components/chip/index.js.map +1 -1
  39. package/dist/components/chip-group/index.d.ts +13 -4
  40. package/dist/components/chip-group/index.js +52 -28
  41. package/dist/components/chip-group/index.js.map +1 -1
  42. package/dist/components/color-slider/index.js +82 -57
  43. package/dist/components/color-slider/index.js.map +1 -1
  44. package/dist/components/combo-box/index.d.ts +5 -3
  45. package/dist/components/combo-box/index.js.map +1 -1
  46. package/dist/components/date-picker/index.d.ts +9 -1
  47. package/dist/components/date-picker/index.js +26 -24
  48. package/dist/components/date-picker/index.js.map +1 -1
  49. package/dist/components/date-range-picker/index.d.ts +10 -1
  50. package/dist/components/date-range-picker/index.js +26 -24
  51. package/dist/components/date-range-picker/index.js.map +1 -1
  52. package/dist/components/icon-button/index.d.ts +1 -1
  53. package/dist/components/icon-button/index.js +119 -88
  54. package/dist/components/icon-button/index.js.map +1 -1
  55. package/dist/components/index.d.ts +9 -4
  56. package/dist/components/list/index.js +10 -10
  57. package/dist/components/list/index.js.map +1 -1
  58. package/dist/components/list-box/index.js +11 -11
  59. package/dist/components/list-box/index.js.map +1 -1
  60. package/dist/components/number-field/index.js +1 -1
  61. package/dist/components/radio-group/index.js +11 -1
  62. package/dist/components/radio-group/index.js.map +1 -1
  63. package/dist/components/search-field/index.js +1 -1
  64. package/dist/components/search-view/index.d.ts +79 -0
  65. package/dist/components/search-view/index.js +255 -0
  66. package/dist/components/search-view/index.js.map +1 -0
  67. package/dist/components/segmented-button/index.d.ts +1 -1
  68. package/dist/components/segmented-button/index.js +58 -29
  69. package/dist/components/segmented-button/index.js.map +1 -1
  70. package/dist/components/slider/index.d.ts +24 -3
  71. package/dist/components/slider/index.js +316 -87
  72. package/dist/components/slider/index.js.map +1 -1
  73. package/dist/components/split-button/index.d.ts +83 -0
  74. package/dist/components/split-button/index.js +341 -0
  75. package/dist/components/split-button/index.js.map +1 -0
  76. package/dist/components/switch/index.js +11 -1
  77. package/dist/components/switch/index.js.map +1 -1
  78. package/dist/components/table/index.js +19 -2
  79. package/dist/components/table/index.js.map +1 -1
  80. package/dist/components/tabs/index.d.ts +35 -4
  81. package/dist/components/tabs/index.js +333 -79
  82. package/dist/components/tabs/index.js.map +1 -1
  83. package/dist/components/tree/index.js +10 -10
  84. package/dist/components/tree/index.js.map +1 -1
  85. package/dist/drag/index.js.map +1 -1
  86. package/dist/glyphs/index.js +37 -1
  87. package/dist/glyphs/index.js.map +1 -1
  88. package/dist/hooks/useToggleGroupDisabled.js +24 -0
  89. package/dist/hooks/useToggleGroupDisabled.js.map +1 -0
  90. package/dist/i18n/index.js +10 -1
  91. package/dist/i18n/index.js.map +1 -1
  92. package/dist/i18n/messages.js +238 -34
  93. package/dist/i18n/messages.js.map +1 -1
  94. package/dist/index.d.ts +9 -4
  95. package/dist/index.js +6 -2
  96. package/dist/row/styles.js +15 -0
  97. package/dist/row/styles.js.map +1 -1
  98. package/dist/styles/color.js +18 -4
  99. package/dist/styles/color.js.map +1 -1
  100. package/dist/styles/picker.js +8 -0
  101. package/dist/styles/picker.js.map +1 -1
  102. package/dist/styles.css +493 -18
  103. package/dist/tokens/design.tokens.stylex.js +25 -1
  104. package/dist/tokens/design.tokens.stylex.js.map +1 -1
  105. package/package.json +3 -3
package/README.md CHANGED
@@ -302,9 +302,11 @@ the icon inherits it:
302
302
  | Slot | Size an `em` icon takes |
303
303
  | ------------------------------------------ | ---------------------------------------------------- |
304
304
  | `Button`'s `icon` | 20px, 20px, 24px, 32px and 40px across `xs` to `xxl` |
305
+ | `Chip`'s and `ChipGroup.Chip`'s `icon` | 18px |
305
306
  | `IconButton` | 20px, 24px, 24px, 32px and 40px across `xs` to `xxl` |
306
307
  | A field's `leadingIcon` and `trailingIcon` | 24px |
307
308
  | `SegmentedButton.Segment`'s `icon` | 18px |
309
+ | `Tabs.Tab`'s `icon` | 24px |
308
310
 
309
311
  **The `leading` and `trailing` slots on a row are different.** A list item, a
310
312
  menu item, a tree item and an app bar set no icon size, so an icon there takes
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react";
2
+ //#region src/button/context.ts
3
+ const ButtonGroupItemContext = createContext(null);
4
+ //#endregion
5
+ export { ButtonGroupItemContext };
6
+
7
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":["stylex","createContext","ButtonState","ButtonGroupItem","onPressEnd","onPressStart","width","shift","size","GroupSize","styles","state","StyleXStyles","ButtonGroupItemContext"],"sources":["../../src/button/context.ts"],"sourcesContent":["import type * as stylex from '@stylexjs/stylex';\nimport { createContext } from 'react';\nimport type { ButtonState } from '.';\n\n// What a group hands each Button or IconButton in it: ButtonGroup's two\n// variants and SplitButton's two halves. Apart from ./index.tsx so that file\n// exports components alone, which is what keeps fast refresh working for it.\n\ntype ButtonGroupItem = {\n /** Called as a press on the button ends, so the group lets go of it. */\n onPressEnd?: () => void;\n /**\n * Called as a press on the button starts, with its width, so a standard\n * group can widen it and narrow its neighbours.\n */\n onPressStart?: (width: number) => void;\n /**\n * How far the button's width moves while it or a neighbour is pressed, in\n * pixels: the pressed button's gain, or a neighbour's loss as a negative.\n * Zero at rest.\n */\n shift: number;\n /** The group's size, which a button takes unless it names its own. */\n size: GroupSize | undefined;\n /**\n * Styles the group lays over the button's own, from its render state: a\n * connected group's inner corners, a split button's paddings. Applied\n * after the button's own shape and before its disabled styles.\n */\n styles?: (state: ButtonState) => stylex.StyleXStyles[];\n};\n\n/** The five sizes Button and IconButton share. */\ntype GroupSize = 'lg' | 'md' | 'xl' | 'xs' | 'xxl';\nconst ButtonGroupItemContext = createContext<ButtonGroupItem | null>(null);\nexport type { ButtonGroupItem, GroupSize };\nexport { ButtonGroupItemContext };"],"mappings":";;AAkCA,MAAMa,yBAAyBZ,cAAsC,IAAI"}
@@ -0,0 +1,25 @@
1
+ //#region src/button/group.ts
2
+ /**
3
+ * The press handlers a button inside a group that tracks presses takes: its
4
+ * own, with the group told first. Empty anywhere else, which leaves the
5
+ * call site's own handlers on the button untouched.
6
+ */
7
+ function groupPressHandlers(group, onPressStart, onPressEnd) {
8
+ const start = group?.onPressStart;
9
+ if (start === void 0) return {};
10
+ const end = group?.onPressEnd;
11
+ return {
12
+ onPressEnd: (event) => {
13
+ end?.();
14
+ onPressEnd?.(event);
15
+ },
16
+ onPressStart: (event) => {
17
+ start(event.target.getBoundingClientRect().width);
18
+ onPressStart?.(event);
19
+ }
20
+ };
21
+ }
22
+ //#endregion
23
+ export { groupPressHandlers };
24
+
25
+ //# sourceMappingURL=group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.js","names":["PressEvent","ButtonGroupItem","groupPressHandlers","group","onPressStart","event","onPressEnd","start","undefined","end","target","getBoundingClientRect","width"],"sources":["../../src/button/group.ts"],"sourcesContent":["import type { PressEvent } from 'react-aria-components'\n\nimport type { ButtonGroupItem } from './context'\n\n// What a button in a standard ButtonGroup does about its own presses: tell\n// the group when one starts, with its width, and when it ends, so the group\n// can widen it and narrow its neighbours. Apart from ./index.tsx so that file\n// exports components alone, which is what keeps fast refresh working for it.\n\n/**\n * The press handlers a button inside a group that tracks presses takes: its\n * own, with the group told first. Empty anywhere else, which leaves the\n * call site's own handlers on the button untouched.\n */\nfunction groupPressHandlers(\n group: ButtonGroupItem | null,\n onPressStart: ((event: PressEvent) => void) | undefined,\n onPressEnd: ((event: PressEvent) => void) | undefined,\n) {\n const start = group?.onPressStart\n if (start === undefined) {\n return {}\n }\n const end = group?.onPressEnd\n\n return {\n onPressEnd: (event: PressEvent) => {\n end?.()\n onPressEnd?.(event)\n },\n onPressStart: (event: PressEvent) => {\n start(event.target.getBoundingClientRect().width)\n onPressStart?.(event)\n },\n }\n}\n\nexport { groupPressHandlers }\n"],"mappings":";;;;;;AAcA,SAASE,mBACPC,OACAC,cACAE,YACA;CACA,MAAMC,QAAQJ,OAAOC;CACrB,IAAIG,UAAUC,KAAAA,GACZ,OAAO,CAAC;CAEV,MAAMC,MAAMN,OAAOG;CAEnB,OAAO;EACLA,aAAaD,UAAsB;GACjCI,MAAM;GACNH,aAAaD,KAAK;EACpB;EACAD,eAAeC,UAAsB;GACnCE,MAAMF,MAAMK,OAAOC,sBAAsB,CAAC,CAACC,KAAK;GAChDR,eAAeC,KAAK;EACtB;CACF;AACF"}
@@ -2,6 +2,7 @@ import { props } from "../node_modules/@stylexjs/stylex/lib/es/stylex.js";
2
2
  import { mergeStatefulStyles } from "../styles/merge.js";
3
3
  import { buttonRenderer, linkRenderer, toggleButtonRenderer } from "../render/aria.js";
4
4
  import ProgressIndicator from "../components/progress-indicator/index.js";
5
+ import { useToggleGroupDisabled } from "../hooks/useToggleGroupDisabled.js";
5
6
  import { useMessages } from "../i18n/index.js";
6
7
  import { useButtonBase } from "./hooks.js";
7
8
  import { buttonBaseStyles } from "./styles.js";
@@ -163,7 +164,7 @@ function buttonContent(children, pendingLabel, surface) {
163
164
  * as it does for the plain button.
164
165
  */
165
166
  function ToggleButtonBase(t0) {
166
- const $ = c(29);
167
+ const $ = c(32);
167
168
  let children;
168
169
  let classes;
169
170
  let defaultSelected;
@@ -193,56 +194,68 @@ function ToggleButtonBase(t0) {
193
194
  render = $[7];
194
195
  t1 = $[8];
195
196
  }
196
- const { disabled, element, props, ref, ripple } = useButtonBase(input, t1 === void 0 ? false : t1);
197
+ const isPending = t1 === void 0 ? false : t1;
198
+ const disabledByGroup = useToggleGroupDisabled(input.id);
197
199
  let t2;
198
- if ($[9] !== element || $[10] !== render) {
199
- t2 = toggleButtonRenderer(element, toggleRender(render));
200
- $[9] = element;
201
- $[10] = render;
200
+ if ($[9] !== disabledByGroup || $[10] !== input) {
201
+ t2 = disabledByGroup ? {
202
+ ...input,
203
+ isDisabled: true
204
+ } : input;
205
+ $[9] = disabledByGroup;
206
+ $[10] = input;
202
207
  $[11] = t2;
203
208
  } else t2 = $[11];
204
- const t3 = ripple.handlers;
205
- let t4;
206
- if ($[12] !== classes || $[13] !== props) {
207
- t4 = mergeStatefulStyles(classes, props);
208
- $[12] = classes;
209
- $[13] = props;
210
- $[14] = t4;
211
- } else t4 = $[14];
209
+ const { disabled, element, props, ref, ripple } = useButtonBase(t2, isPending);
210
+ let t3;
211
+ if ($[12] !== element || $[13] !== render) {
212
+ t3 = toggleButtonRenderer(element, toggleRender(render));
213
+ $[12] = element;
214
+ $[13] = render;
215
+ $[14] = t3;
216
+ } else t3 = $[14];
217
+ const t4 = ripple.handlers;
212
218
  let t5;
213
- if ($[15] !== children || $[16] !== ripple.surface) {
214
- t5 = toggleContent(children, ripple.surface);
215
- $[15] = children;
216
- $[16] = ripple.surface;
219
+ if ($[15] !== classes || $[16] !== props) {
220
+ t5 = mergeStatefulStyles(classes, props);
221
+ $[15] = classes;
222
+ $[16] = props;
217
223
  $[17] = t5;
218
224
  } else t5 = $[17];
219
225
  let t6;
220
- if ($[18] !== defaultSelected || $[19] !== disabled || $[20] !== isSelected || $[21] !== onChange || $[22] !== props || $[23] !== ref || $[24] !== ripple.handlers || $[25] !== t2 || $[26] !== t4 || $[27] !== t5) {
221
- t6 = /* @__PURE__ */ jsx(ToggleButton, {
226
+ if ($[18] !== children || $[19] !== ripple.surface) {
227
+ t6 = toggleContent(children, ripple.surface);
228
+ $[18] = children;
229
+ $[19] = ripple.surface;
230
+ $[20] = t6;
231
+ } else t6 = $[20];
232
+ let t7;
233
+ if ($[21] !== defaultSelected || $[22] !== disabled || $[23] !== isSelected || $[24] !== onChange || $[25] !== props || $[26] !== ref || $[27] !== ripple.handlers || $[28] !== t3 || $[29] !== t5 || $[30] !== t6) {
234
+ t7 = /* @__PURE__ */ jsx(ToggleButton, {
222
235
  defaultSelected,
223
236
  isDisabled: disabled,
224
237
  isSelected,
225
238
  onChange,
226
239
  ref,
227
- render: t2,
228
- ...t3,
229
- ...props,
240
+ render: t3,
230
241
  ...t4,
231
- children: t5
242
+ ...props,
243
+ ...t5,
244
+ children: t6
232
245
  });
233
- $[18] = defaultSelected;
234
- $[19] = disabled;
235
- $[20] = isSelected;
236
- $[21] = onChange;
237
- $[22] = props;
238
- $[23] = ref;
239
- $[24] = ripple.handlers;
240
- $[25] = t2;
241
- $[26] = t4;
242
- $[27] = t5;
243
- $[28] = t6;
244
- } else t6 = $[28];
245
- return t6;
246
+ $[21] = defaultSelected;
247
+ $[22] = disabled;
248
+ $[23] = isSelected;
249
+ $[24] = onChange;
250
+ $[25] = props;
251
+ $[26] = ref;
252
+ $[27] = ripple.handlers;
253
+ $[28] = t3;
254
+ $[29] = t5;
255
+ $[30] = t6;
256
+ $[31] = t7;
257
+ } else t7 = $[31];
258
+ return t7;
246
259
  }
247
260
  function toggleContent(children, surface) {
248
261
  return () => /* @__PURE__ */ jsxs(Fragment, { children: [children, surface] });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DOMAttributes","ReactNode","RefAttributes","ButtonRenderProps","ClassNameOrFunction","ButtonProps","RACButtonProps","ToggleButtonProps","RACToggleButtonProps","StyleOrFunction","stylex","Button","RACButton","Link","RACLink","ToggleButton","RACToggleButton","ProgressIndicator","useMessages","buttonRenderer","linkRenderer","toggleButtonRenderer","mergeStatefulStyles","useButtonBase","buttonBaseStyles","ButtonBaseProps","children","classes","state","ButtonState","ReturnType","props","className","disableRipple","href","pendingLabel","rel","style","target","ButtonDOMProps","HTMLAnchorElement","HTMLButtonElement","Omit","GlobalEventKey","Pick","HTMLElement","isSelected","Exclude","ToggleButtonBaseProps","defaultSelected","onChange","ButtonBase","t0","$","_c","input","render","t1","isPending","undefined","messages","disabled","element","ref","ripple","t2","styleProps","t3","t4","handlers","surface","t5","loading","t6","buttonContent","t7","label","labelPending","pending","ToggleButtonBase","toggleRender","toggleContent","_c","RACLink","RACButton","stylex.props","RACToggleButton"],"sources":["../../src/button/index.tsx"],"sourcesContent":["import type { DOMAttributes, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ClassNameOrFunction, ButtonProps as RACButtonProps, ToggleButtonProps as RACToggleButtonProps, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, Link as RACLink, ToggleButton as RACToggleButton } from 'react-aria-components';\nimport ProgressIndicator from '../components/progress-indicator';\nimport { useMessages } from '../i18n';\nimport { buttonRenderer, linkRenderer, toggleButtonRenderer } from '../render/aria';\nimport { mergeStatefulStyles } from '../styles/merge';\nimport { useButtonBase } from './hooks';\nimport { buttonBaseStyles } from './styles';\n\n// The press-button core Button and IconButton both render through. A button\n// is React Aria's `Button`, its `Link` once given `href`, or its\n// `ToggleButton` once it reports a state, and around each this adds what\n// React Aria leaves out: the ripple, the disabled state a parent's context\n// sets, the `aria-*` props and keyboard handlers it would drop or wrap, and\n// the ring drawn over the label while the button is pending. Each component\n// brings its own classes, as a function of the render state, and the call\n// site's `className` and `style` are merged over them.\n//\n// One module rather than a copy in each, since the copies had already drifted\n// once: IconButton read `ButtonContext` for a parent's disabled state and\n// Button did not. Not a component of the library's own and not exported from\n// the package; see `src/row` for the same arrangement around a list's row.\n\ntype ButtonBaseProps = {\n children?: ReactNode;\n /**\n * The component's own classes, from the render state. The call site's\n * `className` and `style` are merged over them.\n */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n disableRipple?: boolean;\n href?: string;\n pendingLabel?: string;\n rel?: string;\n style?: StyleOrFunction<ButtonState>;\n target?: string;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n// The props a button hands React Aria. React Aria types the global DOM events\n// — pointer, mouse, touch, wheel and the rest — against the element each\n// component renders, and a handler written for a <button> does not type-check\n// against an <a>. The keys are retyped against HTMLElement here so one set of\n// props serves both forms; the events React Aria defines itself (press,\n// focus, keyboard) keep its types, since it hands those its own event objects.\ntype ButtonDOMProps = Omit<RACButtonProps, 'children' | 'className' | 'style' | GlobalEventKey> & Pick<DOMAttributes<HTMLElement>, GlobalEventKey>;\n\n// The render state React Aria's three elements share. A className or style\n// function written against it serves the button, the link and the toggle\n// alike; `isPending` belongs to the button alone, and `isCurrent` to the\n// link, so neither is here. What the button draws while pending is decided\n// in `buttonContent`, which sees React Aria's own state rather than this one.\n//\n// `isSelected` is optional because only the toggle has one: React Aria hands\n// the button and the link a state without it and the toggle a state with\n// it, and a parameter type this wide accepts either.\ntype ButtonState = Pick<ButtonRenderProps, 'isDisabled' | 'isFocused' | 'isFocusVisible' | 'isHovered' | 'isPressed'> & {\n isSelected?: boolean;\n};\ntype GlobalEventKey = Exclude<keyof DOMAttributes<HTMLElement> & keyof RACButtonProps, 'onBlur' | 'onClick' | 'onFocus'>;\ntype ToggleButtonBaseProps = {\n children?: ReactNode;\n /** As for ButtonBase, handed `isSelected` as well. */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n defaultSelected?: boolean;\n disableRipple?: boolean;\n isSelected?: boolean;\n onChange?: (isSelected: boolean) => void;\n style?: StyleOrFunction<ButtonState>;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n/**\n * A button drawn with the classes a component hands it: React Aria's\n * `Button`, or its `Link` given `href`. See the header.\n */\nfunction ButtonBase({\n children,\n classes,\n href,\n isPending = false,\n pendingLabel,\n rel,\n render,\n target,\n ...input\n}: ButtonBaseProps) {\n const messages = useMessages();\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(input, isPending);\n const styleProps = mergeStatefulStyles(classes, props);\n if (href !== undefined) {\n return <RACLink href={href} isDisabled={disabled} ref={ref} rel={rel} render={linkRenderer(element)} target={target} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACLink>;\n }\n return <RACButton isDisabled={disabled} isPending={isPending} ref={ref} render={buttonRenderer(element, render)} {...ripple.handlers} {...props} {...styleProps}>\n {buttonContent(children, pendingLabel ?? messages.loading, ripple.surface)}\n </RACButton>;\n}\n\n// What the button draws: its label, hidden while the button is pending, with\n// the ring over it. The ring takes the button's own content colour rather\n// than the progress page's primary, which on a filled button is the fill\n// itself and so invisible. The label stays in the flow so the button keeps its\n// width, which is what stops a form jumping the moment it is submitted.\n// React Aria wants the progress bar in the accessibility tree as soon as the\n// button goes pending, so it is rendered from the render state rather than\n// after a delay.\n//\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\n// memoises the result on its inputs.\nfunction buttonContent(children: ReactNode, pendingLabel: string, surface: ReactNode) {\n return (state: ButtonRenderProps) => <>\n <span {...stylex.props(buttonBaseStyles.label, state.isPending && buttonBaseStyles.labelPending)}>\n {children}\n </span>\n {state.isPending ? <span {...stylex.props(buttonBaseStyles.pending)}>\n <ProgressIndicator aria-label={pendingLabel} isIndeterminate size=\"1em\" tone=\"inherit\" variant=\"circular\" />\n </span> : null}\n {surface}\n </>;\n}\n\n/**\n * A toggle drawn with the classes a component hands it: React Aria's\n * `ToggleButton`, which reports its state through `aria-pressed`. It is never\n * a link and never pending — React Aria's toggle takes neither, and neither\n * means anything for a control whose whole job is to report which of two\n * states it is in — so `isPending` reaches it only to keep the ripple off,\n * as it does for the plain button.\n */\nfunction ToggleButtonBase({\n children,\n classes,\n defaultSelected,\n isPending = false,\n isSelected,\n onChange,\n render,\n ...input\n}: ToggleButtonBaseProps) {\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(input, isPending);\n return <RACToggleButton defaultSelected={defaultSelected} isDisabled={disabled} isSelected={isSelected} onChange={onChange} ref={ref} render={toggleButtonRenderer(element, toggleRender(render))} {...ripple.handlers} {...props} {...mergeStatefulStyles(classes, props)}>\n {toggleContent(children, ripple.surface)}\n </RACToggleButton>;\n}\n\n// What a toggle draws: its label and the ripple. No pending ring — see\n// ToggleButtonBase. Built by a call for the reason `buttonContent` is.\nfunction toggleContent(children: ReactNode, surface: ReactNode) {\n return () => <>\n {children}\n {surface}\n </>;\n}\n\n// A call site's `render` is written for React Aria's button, whose render\n// state says whether it is pending; a toggle's says nothing of it, and a\n// toggle never is. So the toggle hands that function its own state with\n// `isPending` filled in, which is what lets one `render` prop serve a button\n// whichever element it turns out to be.\nfunction toggleRender(render: RACButtonProps['render']): RACToggleButtonProps['render'] {\n if (render === undefined) {\n return undefined;\n }\n return (props, state) => render(props, {\n ...state,\n isPending: false\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,CAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":["DOMAttributes","ReactNode","RefAttributes","ButtonRenderProps","ClassNameOrFunction","ButtonProps","RACButtonProps","ToggleButtonProps","RACToggleButtonProps","StyleOrFunction","stylex","Button","RACButton","Link","RACLink","ToggleButton","RACToggleButton","ProgressIndicator","useToggleGroupDisabled","useMessages","buttonRenderer","linkRenderer","toggleButtonRenderer","mergeStatefulStyles","useButtonBase","buttonBaseStyles","ButtonBaseProps","children","classes","state","ButtonState","ReturnType","props","className","disableRipple","href","pendingLabel","rel","style","target","ButtonDOMProps","HTMLAnchorElement","HTMLButtonElement","Omit","GlobalEventKey","Pick","HTMLElement","isSelected","Exclude","ToggleButtonBaseProps","defaultSelected","onChange","ButtonBase","t0","$","_c","input","render","t1","isPending","undefined","messages","disabled","element","ref","ripple","t2","styleProps","t3","t4","handlers","surface","t5","loading","t6","buttonContent","t7","label","labelPending","pending","ToggleButtonBase","disabledByGroup","id","isDisabled","toggleRender","toggleContent","_c","RACLink","RACButton","stylex.props","RACToggleButton"],"sources":["../../src/button/index.tsx"],"sourcesContent":["import type { DOMAttributes, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ClassNameOrFunction, ButtonProps as RACButtonProps, ToggleButtonProps as RACToggleButtonProps, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, Link as RACLink, ToggleButton as RACToggleButton } from 'react-aria-components';\nimport ProgressIndicator from '../components/progress-indicator';\nimport { useToggleGroupDisabled } from '../hooks/useToggleGroupDisabled';\nimport { useMessages } from '../i18n';\nimport { buttonRenderer, linkRenderer, toggleButtonRenderer } from '../render/aria';\nimport { mergeStatefulStyles } from '../styles/merge';\nimport { useButtonBase } from './hooks';\nimport { buttonBaseStyles } from './styles';\n\n// The press-button core Button and IconButton both render through. A button\n// is React Aria's `Button`, its `Link` once given `href`, or its\n// `ToggleButton` once it reports a state, and around each this adds what\n// React Aria leaves out: the ripple, the disabled state a parent's context\n// sets, the `aria-*` props and keyboard handlers it would drop or wrap, and\n// the ring drawn over the label while the button is pending. Each component\n// brings its own classes, as a function of the render state, and the call\n// site's `className` and `style` are merged over them.\n//\n// One module rather than a copy in each, since the copies had already drifted\n// once: IconButton read `ButtonContext` for a parent's disabled state and\n// Button did not. Not a component of the library's own and not exported from\n// the package; see `src/row` for the same arrangement around a list's row.\n\ntype ButtonBaseProps = {\n children?: ReactNode;\n /**\n * The component's own classes, from the render state. The call site's\n * `className` and `style` are merged over them.\n */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n disableRipple?: boolean;\n href?: string;\n pendingLabel?: string;\n rel?: string;\n style?: StyleOrFunction<ButtonState>;\n target?: string;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n// The props a button hands React Aria. React Aria types the global DOM events\n// — pointer, mouse, touch, wheel and the rest — against the element each\n// component renders, and a handler written for a <button> does not type-check\n// against an <a>. The keys are retyped against HTMLElement here so one set of\n// props serves both forms; the events React Aria defines itself (press,\n// focus, keyboard) keep its types, since it hands those its own event objects.\ntype ButtonDOMProps = Omit<RACButtonProps, 'children' | 'className' | 'style' | GlobalEventKey> & Pick<DOMAttributes<HTMLElement>, GlobalEventKey>;\n\n// The render state React Aria's three elements share. A className or style\n// function written against it serves the button, the link and the toggle\n// alike; `isPending` belongs to the button alone, and `isCurrent` to the\n// link, so neither is here. What the button draws while pending is decided\n// in `buttonContent`, which sees React Aria's own state rather than this one.\n//\n// `isSelected` is optional because only the toggle has one: React Aria hands\n// the button and the link a state without it and the toggle a state with\n// it, and a parameter type this wide accepts either.\ntype ButtonState = Pick<ButtonRenderProps, 'isDisabled' | 'isFocused' | 'isFocusVisible' | 'isHovered' | 'isPressed'> & {\n isSelected?: boolean;\n};\ntype GlobalEventKey = Exclude<keyof DOMAttributes<HTMLElement> & keyof RACButtonProps, 'onBlur' | 'onClick' | 'onFocus'>;\ntype ToggleButtonBaseProps = {\n children?: ReactNode;\n /** As for ButtonBase, handed `isSelected` as well. */\n classes: (state: ButtonState) => ReturnType<typeof stylex.props>;\n className?: ClassNameOrFunction<ButtonState>;\n defaultSelected?: boolean;\n disableRipple?: boolean;\n isSelected?: boolean;\n onChange?: (isSelected: boolean) => void;\n style?: StyleOrFunction<ButtonState>;\n} & ButtonDOMProps & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\n\n/**\n * A button drawn with the classes a component hands it: React Aria's\n * `Button`, or its `Link` given `href`. See the header.\n */\nfunction ButtonBase({\n children,\n classes,\n href,\n isPending = false,\n pendingLabel,\n rel,\n render,\n target,\n ...input\n}: ButtonBaseProps) {\n const messages = useMessages();\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(input, isPending);\n const styleProps = mergeStatefulStyles(classes, props);\n if (href !== undefined) {\n return <RACLink href={href} isDisabled={disabled} ref={ref} rel={rel} render={linkRenderer(element)} target={target} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACLink>;\n }\n return <RACButton isDisabled={disabled} isPending={isPending} ref={ref} render={buttonRenderer(element, render)} {...ripple.handlers} {...props} {...styleProps}>\n {buttonContent(children, pendingLabel ?? messages.loading, ripple.surface)}\n </RACButton>;\n}\n\n// What the button draws: its label, hidden while the button is pending, with\n// the ring over it. The ring takes the button's own content colour rather\n// than the progress page's primary, which on a filled button is the fill\n// itself and so invisible. The label stays in the flow so the button keeps its\n// width, which is what stops a form jumping the moment it is submitted.\n// React Aria wants the progress bar in the accessibility tree as soon as the\n// button goes pending, so it is rendered from the render state rather than\n// after a delay.\n//\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\n// memoises the result on its inputs.\nfunction buttonContent(children: ReactNode, pendingLabel: string, surface: ReactNode) {\n return (state: ButtonRenderProps) => <>\n <span {...stylex.props(buttonBaseStyles.label, state.isPending && buttonBaseStyles.labelPending)}>\n {children}\n </span>\n {state.isPending ? <span {...stylex.props(buttonBaseStyles.pending)}>\n <ProgressIndicator aria-label={pendingLabel} isIndeterminate size=\"1em\" tone=\"inherit\" variant=\"circular\" />\n </span> : null}\n {surface}\n </>;\n}\n\n/**\n * A toggle drawn with the classes a component hands it: React Aria's\n * `ToggleButton`, which reports its state through `aria-pressed`. It is never\n * a link and never pending — React Aria's toggle takes neither, and neither\n * means anything for a control whose whole job is to report which of two\n * states it is in — so `isPending` reaches it only to keep the ripple off,\n * as it does for the plain button.\n */\nfunction ToggleButtonBase({\n children,\n classes,\n defaultSelected,\n isPending = false,\n isSelected,\n onChange,\n render,\n ...input\n}: ToggleButtonBaseProps) {\n // A selecting ButtonGroup disables its toggles through React Aria's group\n // state, which no prop here carries, so the ripple would stay on in a\n // disabled group and answer a press with an animation. Handed on as the\n // toggle's own `isDisabled`, which is what React Aria makes of it anyway.\n const disabledByGroup = useToggleGroupDisabled(input.id);\n const {\n disabled,\n element,\n props,\n ref,\n ripple\n } = useButtonBase(disabledByGroup ? {\n ...input,\n isDisabled: true\n } : input, isPending);\n return <RACToggleButton defaultSelected={defaultSelected} isDisabled={disabled} isSelected={isSelected} onChange={onChange} ref={ref} render={toggleButtonRenderer(element, toggleRender(render))} {...ripple.handlers} {...props} {...mergeStatefulStyles(classes, props)}>\n {toggleContent(children, ripple.surface)}\n </RACToggleButton>;\n}\n\n// What a toggle draws: its label and the ripple. No pending ring — see\n// ToggleButtonBase. Built by a call for the reason `buttonContent` is.\nfunction toggleContent(children: ReactNode, surface: ReactNode) {\n return () => <>\n {children}\n {surface}\n </>;\n}\n\n// A call site's `render` is written for React Aria's button, whose render\n// state says whether it is pending; a toggle's says nothing of it, and a\n// toggle never is. So the toggle hands that function its own state with\n// `isPending` filled in, which is what lets one `render` prop serve a button\n// whichever element it turns out to be.\nfunction toggleRender(render: RACButtonProps['render']): RACToggleButtonProps['render'] {\n if (render === undefined) {\n return undefined;\n }\n return (props, state) => render(props, {\n ...state,\n isPending: false\n });\n}\nexport type { Button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B,EAAA;CAAA,OAFbsB;AAEa;AAKtB,SAASS,cAAc1D,UAAqB4C,SAAoB;CAC9D,aAAa,qBAAA,UAAA,EAAA,UAAA,CACR5C,UACA4C,OACH,EAAA,CAAA;AACJ;AAOA,SAASa,aAAa3B,QAAkE;CACtF,IAAIA,WAAWG,KAAAA,GACb;CAEF,QAAQ5B,OAAOH,UAAU4B,OAAOzB,OAAO;EACrC,GAAGH;EACH8B,WAAW;CACb,CAAC;AACH"}
@@ -212,8 +212,9 @@ const calendarStyles = {
212
212
  },
213
213
  months: {
214
214
  kGNEyG: "x7a106z",
215
- k1xSpc: "x78zum5",
215
+ k1xSpc: "x78zum5 x1yrkhk",
216
216
  kOIVth: "xj2l1yv",
217
+ kJBjZk: "x12n7ir1",
217
218
  kAzted: "x1fivsg2",
218
219
  $$css: true
219
220
  },
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","names":["stylex","colors","radii","sizing","spacing","stateLayerOpacity","typography","ROW_BLOCK_SIZE","WEEKS_HELD","FORCED_COLORS","calendarStyles","cell","kGNEyG","kWkggS","kZKoxP","kaIpWk","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kzqmXN","kjj79g","kb6lSQ","kLWn49","kUOVxO","$$css","cellDisabled","kAXs8y","cellInRange","kVAM5u","kjBf7l","cellRangeEnd","kT0f0o","kfmiAY","cellRangeStart","kVL7Gh","krdFHd","cellSelected","cellToday","ksu8eU","kMzoRj","cellUnavailable","kMnn75","chevron","chevronGlyph","k3aq6I","chevronGlyphPrevious","chevronHidden","k33iCy","grid","kLvRdT","kheTzg","header","kOIVth","kAzted","headerCell","headerGroup","heading","kogj98","k9WMMc","menuArrow","kmuXW","menuArrowExpanded","menuButton","kg3NbH","menuCheck","menuItem","k3XXqK","menuItemDisabled","menuItemFocused","kInvED","kMeerF","menuItemSelected","menuList","kLZC3w","kPef9Z","kEafiO","kORKVm","months","root","kXwgrk","k7Eaqz","kmVPX3","dateLayers","inRangeHovered","inRangePressed","plainHovered","plainPressed","selectedHovered","selectedPressed","menuLayers"],"sources":["../../src/calendar/styles.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport '../tokens/design.tokens.stylex';\nimport { colors, radii, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The styles Calendar and RangeCalendar both draw. Apart from either\n// component so the two cannot drift, and outside `src/components` because a\n// directory there is a public component with stories, a barrel entry and a\n// `styling.test.tsx` case — which shared styles are none of.\n//\n// The values are the date pickers page's docked calendar, named in\n// `src/components/calendar/index.tsx` along with the departures from it. What\n// is only a range's — the band between the two ends — takes its colours from\n// the modal date picker's range-selection tokens instead, since the docked\n// token set stops at the selected date; see `cellInRange`.\n//\n// Under forced colours a selected date and a range's band are fills, which\n// that mode paints in a system colour, so a calendar showed no selection and\n// no range there, only today's outline. Both take `Highlight` with\n// `HighlightText` over it, the pair the mode gives whatever is chosen, which\n// draws a range as one run from its first day to its last.\n//\n// They take the pair with `forced-color-adjust: none`. Left to adjust, the\n// mode lays a `Canvas` backplate behind every run of text, and a date in\n// `HighlightText` on that backplate is a blank box. With it off nothing is\n// forced on those cells, so they name a system colour for everything they\n// draw — the fill, the date, today's outline and the focus ring. A day ruled\n// out or disabled names none, so it hands itself back to the mode.\n\n// One row of the grid. The weekday row and every week of dates are the same\n// 40dp, so `cell`, `headerCell` and the room `months` reserves are all this\n// one number — a date resized without the reservation following it would put\n// the calendar's height back on its month.\nconst ROW_BLOCK_SIZE = '40px';\n\n// The weeks the grid holds room for, which is the most any month occupies: a\n// 31-day month beginning on the last day of a week runs one day, then four\n// whole weeks, then two days. February 2026 is the other end at four. Holding\n// six draws every month in the box the longest one fills.\nconst WEEKS_HELD = 6;\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 calendarStyles = {\n cell: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kzqmXN: \"x100vrsf\",\n kjj79g: \"xl56j7k\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n cellDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n $$css: true\n },\n cellInRange: {\n kWkggS: \"x15dekr4 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kaIpWk: \"x2u8bby\",\n kMwMTN: \"x1sawysd x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xrxpjvj\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellRangeEnd: {\n kT0f0o: \"x187kppt\",\n kfmiAY: \"x1fpsnkq\",\n $$css: true\n },\n cellRangeStart: {\n kVL7Gh: \"x17kgqx\",\n krdFHd: \"x1uni95s\",\n $$css: true\n },\n cellSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellToday: {\n kVAM5u: \"x1uajy3w\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n cellUnavailable: {\n kWkggS: \"xjbqb8w\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n kMnn75: \"x5lhwog\",\n $$css: true\n },\n chevron: {\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n chevronGlyph: {\n kZKoxP: \"xxk0z11\",\n kzqmXN: \"xvy4d1p\",\n k3aq6I: \"x19axjrm x1c071of\",\n $$css: true\n },\n chevronGlyphPrevious: {\n k3aq6I: \"xdg80k9 xpk2tj9\",\n $$css: true\n },\n chevronHidden: {\n k33iCy: \"xlshs6z\",\n $$css: true\n },\n grid: {\n kLvRdT: \"x1vathgz\",\n kheTzg: \"x1gukg7c\",\n kzqmXN: \"xh8yej3\",\n $$css: true\n },\n header: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"x126z3so\",\n kjj79g: \"x1qughib\",\n kAzted: \"x1ba4aug\",\n $$css: true\n },\n headerCell: {\n kZKoxP: \"x1vqgdyp\",\n kMwMTN: \"x139gbkf\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n $$css: true\n },\n headerGroup: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n $$css: true\n },\n heading: {\n kMwMTN: \"x1w5n3ug\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kogj98: \"x1ghz6dp\",\n k9WMMc: \"x2b8uid\",\n $$css: true\n },\n menuArrow: {\n kZKoxP: \"xmix8c7\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n menuArrowExpanded: {\n k3aq6I: \"x19jd1h0\",\n $$css: true\n },\n menuButton: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1rv7mn0\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"xzoy561\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n menuCheck: {\n kZKoxP: \"xxk0z11\",\n kMwMTN: \"x139gbkf\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n menuItem: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xbg5kjn\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kOIVth: \"xxj4525\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n k3XXqK: \"x1t137rt\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n menuItemDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n menuItemFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x2ssjo2\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n menuItemSelected: {\n kWkggS: \"xkrgufg\",\n $$css: true\n },\n menuList: {\n kZKoxP: \"x1mj9p22\",\n kLZC3w: \"x12smttz\",\n kPef9Z: \"x13fuv20\",\n kEafiO: \"x178xt8z\",\n kB7OPa: \"x9f619\",\n kUOVxO: \"xnx04jz\",\n k3XXqK: \"x1t137rt\",\n kORKVm: \"x1odjw0f\",\n $$css: true\n },\n months: {\n kGNEyG: \"x7a106z\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"xj2l1yv\",\n kAzted: \"x1fivsg2\",\n $$css: true\n },\n root: {\n kWkggS: \"xvkjz1l\",\n kaIpWk: \"xhpdng0\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n kOIVth: \"x1gka490\",\n kzqmXN: \"xeq5yr9\",\n k7Eaqz: \"x1gvwcb\",\n kmVPX3: \"xa36j16\",\n $$css: true\n }\n};\n\n// A date's hover and pressed layers, one pair per ground it sits on: nothing,\n// the range band, and the selected circle. From React Aria's render state rather than `:hover` and `:active`, for Button's\n// reasons — see its header: a hover layer stayed on after a tap, and no\n// pressed layer showed for a press made from the keyboard.\n// Each layer is written whole for its ground because StyleX replaces a\n// property whole, and the band and the circle keep their forced-colours\n// `Highlight` under the layer.\nconst dateLayers = {\n inRangeHovered: {\n kWkggS: \"x3zumxv x1jzqe4\",\n $$css: true\n },\n inRangePressed: {\n kWkggS: \"x1as5h4c x1jzqe4\",\n $$css: true\n },\n plainHovered: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n plainPressed: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n selectedHovered: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n }\n};\n\n// A list row's hover and pressed layers over the checked row's surface\n// variant. Over nothing a row takes a date's own pair, `dateLayers.plain*`,\n// since the page gives both the same on-surface layer.\nconst menuLayers = {\n selectedHovered: {\n kWkggS: \"xgw93rf\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x113d7pk\",\n $$css: true\n }\n};\nexport { calendarStyles, dateLayers, menuLayers };"],"mappings":";AA6CA,MAAMU,iBAAiB;CACrBC,MAAM;EACJC,QAAQ;EACRC,QAAQ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D,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACR/D,QAAQ;EACRW,QAAQ;EACR2C,QAAQ;EACRU,QAAQ;EACRpD,OAAO;CACT;CACAqD,QAAQ;EACNrE,QAAQ;EACRO,QAAQ;EACRqC,QAAQ;EACRC,QAAQ;EACR7B,OAAO;CACT;CACAsD,MAAM;EACJrE,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRE,QAAQ;EACRgE,QAAQ;EACR3B,QAAQ;EACRjC,QAAQ;EACR6D,QAAQ;EACRC,QAAQ;EACRzD,OAAO;CACT;AACF;AASA,MAAM0D,aAAa;CACjBC,gBAAgB;EACd1E,QAAQ;EACRe,OAAO;CACT;CACA4D,gBAAgB;EACd3E,QAAQ;EACRe,OAAO;CACT;CACA6D,cAAc;EACZ5E,QAAQ;EACRe,OAAO;CACT;CACA8D,cAAc;EACZ7E,QAAQ;EACRe,OAAO;CACT;CACA+D,iBAAiB;EACf9E,QAAQ;EACRe,OAAO;CACT;CACAgE,iBAAiB;EACf/E,QAAQ;EACRe,OAAO;CACT;AACF;AAKA,MAAMiE,aAAa;CACjBF,iBAAiB;EACf9E,QAAQ;EACRe,OAAO;CACT;CACAgE,iBAAiB;EACf/E,QAAQ;EACRe,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"styles.js","names":["stylex","colors","media","radii","sizing","spacing","stateLayerOpacity","typography","ROW_BLOCK_SIZE","WEEKS_HELD","FORCED_COLORS","calendarStyles","cell","kGNEyG","kWkggS","kZKoxP","kaIpWk","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kzqmXN","kjj79g","kb6lSQ","kLWn49","kUOVxO","$$css","cellDisabled","kAXs8y","cellInRange","kVAM5u","kjBf7l","cellRangeEnd","kT0f0o","kfmiAY","cellRangeStart","kVL7Gh","krdFHd","cellSelected","cellToday","ksu8eU","kMzoRj","cellUnavailable","kMnn75","chevron","chevronGlyph","k3aq6I","chevronGlyphPrevious","chevronHidden","k33iCy","grid","kLvRdT","kheTzg","header","kOIVth","kAzted","headerCell","headerGroup","heading","kogj98","k9WMMc","menuArrow","kmuXW","menuArrowExpanded","menuButton","kg3NbH","menuCheck","menuItem","k3XXqK","menuItemDisabled","menuItemFocused","kInvED","kMeerF","menuItemSelected","menuList","kLZC3w","kPef9Z","kEafiO","kORKVm","months","kJBjZk","root","kXwgrk","k7Eaqz","kmVPX3","dateLayers","inRangeHovered","inRangePressed","plainHovered","plainPressed","selectedHovered","selectedPressed","menuLayers"],"sources":["../../src/calendar/styles.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport '../tokens/design.tokens.stylex';\nimport { colors, media, radii, sizing, spacing, stateLayerOpacity, typography } from '../tokens/design.tokens.stylex';\n\n// The styles Calendar and RangeCalendar both draw. Apart from either\n// component so the two cannot drift, and outside `src/components` because a\n// directory there is a public component with stories, a barrel entry and a\n// `styling.test.tsx` case — which shared styles are none of.\n//\n// The values are the date pickers page's docked calendar, named in\n// `src/components/calendar/index.tsx` along with the departures from it. What\n// is only a range's — the band between the two ends — takes its colours from\n// the modal date picker's range-selection tokens instead, since the docked\n// token set stops at the selected date; see `cellInRange`.\n//\n// Under forced colours a selected date and a range's band are fills, which\n// that mode paints in a system colour, so a calendar showed no selection and\n// no range there, only today's outline. Both take `Highlight` with\n// `HighlightText` over it, the pair the mode gives whatever is chosen, which\n// draws a range as one run from its first day to its last.\n//\n// They take the pair with `forced-color-adjust: none`. Left to adjust, the\n// mode lays a `Canvas` backplate behind every run of text, and a date in\n// `HighlightText` on that backplate is a blank box. With it off nothing is\n// forced on those cells, so they name a system colour for everything they\n// draw — the fill, the date, today's outline and the focus ring. A day ruled\n// out or disabled names none, so it hands itself back to the mode.\n\n// One row of the grid. The weekday row and every week of dates are the same\n// 40dp, so `cell`, `headerCell` and the room `months` reserves are all this\n// one number — a date resized without the reservation following it would put\n// the calendar's height back on its month.\nconst ROW_BLOCK_SIZE = '40px';\n\n// The weeks the grid holds room for, which is the most any month occupies: a\n// 31-day month beginning on the last day of a week runs one day, then four\n// whole weeks, then two days. February 2026 is the other end at four. Holding\n// six draws every month in the box the longest one fills.\nconst WEEKS_HELD = 6;\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 calendarStyles = {\n cell: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kzqmXN: \"x100vrsf\",\n kjj79g: \"xl56j7k\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n cellDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n $$css: true\n },\n cellInRange: {\n kWkggS: \"x15dekr4 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kaIpWk: \"x2u8bby\",\n kMwMTN: \"x1sawysd x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xrxpjvj\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellRangeEnd: {\n kT0f0o: \"x187kppt\",\n kfmiAY: \"x1fpsnkq\",\n $$css: true\n },\n cellRangeStart: {\n kVL7Gh: \"x17kgqx\",\n krdFHd: \"x1uni95s\",\n $$css: true\n },\n cellSelected: {\n kWkggS: \"xnety89 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n kMwMTN: \"xwjo7ld x1k5gbb1\",\n kAXs8y: \"x1g12otp\",\n kjBf7l: \"xrgy624 x3teovq\",\n $$css: true\n },\n cellToday: {\n kVAM5u: \"x1uajy3w\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kMwMTN: \"x1mxwv8y\",\n $$css: true\n },\n cellUnavailable: {\n kWkggS: \"xjbqb8w\",\n kkrTdU: \"x1h6gzvc\",\n kAXs8y: \"xr5dkdi\",\n kMnn75: \"x5lhwog\",\n $$css: true\n },\n chevron: {\n kUOVxO: \"x34s64n\",\n $$css: true\n },\n chevronGlyph: {\n kZKoxP: \"xxk0z11\",\n kzqmXN: \"xvy4d1p\",\n k3aq6I: \"x19axjrm x1c071of\",\n $$css: true\n },\n chevronGlyphPrevious: {\n k3aq6I: \"xdg80k9 xpk2tj9\",\n $$css: true\n },\n chevronHidden: {\n k33iCy: \"xlshs6z\",\n $$css: true\n },\n grid: {\n kLvRdT: \"x1vathgz\",\n kheTzg: \"x1gukg7c\",\n kzqmXN: \"xh8yej3\",\n $$css: true\n },\n header: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n kOIVth: \"x126z3so\",\n kjj79g: \"x1qughib\",\n kAzted: \"x1ba4aug\",\n $$css: true\n },\n headerCell: {\n kZKoxP: \"x1vqgdyp\",\n kMwMTN: \"x139gbkf\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n $$css: true\n },\n headerGroup: {\n kGNEyG: \"x6s0dn4\",\n k1xSpc: \"x78zum5\",\n $$css: true\n },\n heading: {\n kMwMTN: \"x1w5n3ug\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kogj98: \"x1ghz6dp\",\n k9WMMc: \"x2b8uid\",\n $$css: true\n },\n menuArrow: {\n kZKoxP: \"xmix8c7\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x1xp8n7a\",\n $$css: true\n },\n menuArrowExpanded: {\n k3aq6I: \"x19jd1h0\",\n $$css: true\n },\n menuButton: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1rv7mn0\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"xzoy561\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n menuCheck: {\n kZKoxP: \"xxk0z11\",\n kMwMTN: \"x139gbkf\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n menuItem: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xbg5kjn\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kMv6JI: \"x16svsjw\",\n kGuDYH: \"x1848etk\",\n k63SB2: \"x1c52epr\",\n kOIVth: \"xxj4525\",\n kb6lSQ: \"x1qn8t5l\",\n kLWn49: \"xh7dzej\",\n k3XXqK: \"x1t137rt\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n menuItemDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x9w6zvh\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n menuItemFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x2ssjo2\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n menuItemSelected: {\n kWkggS: \"xkrgufg\",\n $$css: true\n },\n menuList: {\n kZKoxP: \"x1mj9p22\",\n kLZC3w: \"x12smttz\",\n kPef9Z: \"x13fuv20\",\n kEafiO: \"x178xt8z\",\n kB7OPa: \"x9f619\",\n kUOVxO: \"xnx04jz\",\n k3XXqK: \"x1t137rt\",\n kORKVm: \"x1odjw0f\",\n $$css: true\n },\n months: {\n kGNEyG: \"x7a106z\",\n k1xSpc: \"x78zum5 x1yrkhk\",\n kOIVth: \"xj2l1yv\",\n kJBjZk: \"x12n7ir1\",\n kAzted: \"x1fivsg2\",\n $$css: true\n },\n root: {\n kWkggS: \"xvkjz1l\",\n kaIpWk: \"xhpdng0\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n kOIVth: \"x1gka490\",\n kzqmXN: \"xeq5yr9\",\n k7Eaqz: \"x1gvwcb\",\n kmVPX3: \"xa36j16\",\n $$css: true\n }\n};\n\n// A date's hover and pressed layers, one pair per ground it sits on: nothing,\n// the range band, and the selected circle. From React Aria's render state rather than `:hover` and `:active`, for Button's\n// reasons — see its header: a hover layer stayed on after a tap, and no\n// pressed layer showed for a press made from the keyboard.\n// Each layer is written whole for its ground because StyleX replaces a\n// property whole, and the band and the circle keep their forced-colours\n// `Highlight` under the layer.\nconst dateLayers = {\n inRangeHovered: {\n kWkggS: \"x3zumxv x1jzqe4\",\n $$css: true\n },\n inRangePressed: {\n kWkggS: \"x1as5h4c x1jzqe4\",\n $$css: true\n },\n plainHovered: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n plainPressed: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n selectedHovered: {\n kWkggS: \"xo1ct44 x1jzqe4\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x7b25lv x1jzqe4\",\n $$css: true\n }\n};\n\n// A list row's hover and pressed layers over the checked row's surface\n// variant. Over nothing a row takes a date's own pair, `dateLayers.plain*`,\n// since the page gives both the same on-surface layer.\nconst menuLayers = {\n selectedHovered: {\n kWkggS: \"xgw93rf\",\n $$css: true\n },\n selectedPressed: {\n kWkggS: \"x113d7pk\",\n $$css: true\n }\n};\nexport { calendarStyles, dateLayers, menuLayers };"],"mappings":";AA6CA,MAAMW,iBAAiB;CACrBC,MAAM;EACJC,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,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,cAAc;EACZhB,QAAQ;EACRI,QAAQ;EACRC,QAAQ;EACRY,QAAQ;EACRF,OAAO;CACT;CACAG,aAAa;EACXlB,QAAQ;EACRmB,QAAQ;EACRjB,QAAQ;EACRE,QAAQ;EACRa,QAAQ;EACRP,QAAQ;EACRI,QAAQ;EACRM,QAAQ;EACRL,OAAO;CACT;CACAM,cAAc;EACZC,QAAQ;EACRC,QAAQ;EACRR,OAAO;CACT;CACAS,gBAAgB;EACdC,QAAQ;EACRC,QAAQ;EACRX,OAAO;CACT;CACAY,cAAc;EACZ3B,QAAQ;EACRmB,QAAQ;EACRf,QAAQ;EACRa,QAAQ;EACRG,QAAQ;EACRL,OAAO;CACT;CACAa,WAAW;EACTT,QAAQ;EACRU,QAAQ;EACRC,QAAQ;EACR1B,QAAQ;EACRW,OAAO;CACT;CACAgB,iBAAiB;EACf/B,QAAQ;EACRK,QAAQ;EACRY,QAAQ;EACRe,QAAQ;EACRjB,OAAO;CACT;CACAkB,SAAS;EACPnB,QAAQ;EACRC,OAAO;CACT;CACAmB,cAAc;EACZjC,QAAQ;EACRS,QAAQ;EACRyB,QAAQ;EACRpB,OAAO;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,QAAQ;EACRC,QAAQ;EACR4C,QAAQ;EACRH,QAAQ;EACRvC,OAAO;CACT;CACA2C,kBAAkB;EAChB1D,QAAQ;EACRI,QAAQ;EACRC,QAAQ;EACRU,OAAO;CACT;CACA4C,iBAAiB;EACfvC,QAAQ;EACRwC,QAAQ;EACRH,QAAQ;EACRI,QAAQ;EACR9C,OAAO;CACT;CACA+C,kBAAkB;EAChB9D,QAAQ;EACRe,OAAO;CACT;CACAgD,UAAU;EACR9D,QAAQ;EACR+D,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACR/D,QAAQ;EACRW,QAAQ;EACR2C,QAAQ;EACRU,QAAQ;EACRpD,OAAO;CACT;CACAqD,QAAQ;EACNrE,QAAQ;EACRO,QAAQ;EACRqC,QAAQ;EACR0B,QAAQ;EACRzB,QAAQ;EACR7B,OAAO;CACT;CACAuD,MAAM;EACJtE,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRE,QAAQ;EACRiE,QAAQ;EACR5B,QAAQ;EACRjC,QAAQ;EACR8D,QAAQ;EACRC,QAAQ;EACR1D,OAAO;CACT;AACF;AASA,MAAM2D,aAAa;CACjBC,gBAAgB;EACd3E,QAAQ;EACRe,OAAO;CACT;CACA6D,gBAAgB;EACd5E,QAAQ;EACRe,OAAO;CACT;CACA8D,cAAc;EACZ7E,QAAQ;EACRe,OAAO;CACT;CACA+D,cAAc;EACZ9E,QAAQ;EACRe,OAAO;CACT;CACAgE,iBAAiB;EACf/E,QAAQ;EACRe,OAAO;CACT;CACAiE,iBAAiB;EACfhF,QAAQ;EACRe,OAAO;CACT;AACF;AAKA,MAAMkE,aAAa;CACjBF,iBAAiB;EACf/E,QAAQ;EACRe,OAAO;CACT;CACAiE,iBAAiB;EACfhF,QAAQ;EACRe,OAAO;CACT;AACF"}
@@ -0,0 +1,5 @@
1
+ //#region src/carousel/arrangement.d.ts
2
+ type CarouselLayout = 'hero' | 'multi-browse' | 'uncontained';
3
+ //#endregion
4
+ export type { CarouselLayout };
5
+ //# sourceMappingURL=arrangement.d.ts.map
@@ -0,0 +1,123 @@
1
+ /** The page's small item: 40dp at the least and 56dp at the most. */
2
+ const SMALL_MAX = 56;
3
+ const SMALL_MIN = 40;
4
+ /**
5
+ * The sizes a layout draws its items at in a content box `room` wide, for
6
+ * `count` items and a preferred large width of `itemSize`.
7
+ */
8
+ function arrange(layout, room, itemSize, count) {
9
+ if (layout === "uncontained") return {
10
+ large: Math.min(itemSize, room),
11
+ largeCount: 0,
12
+ medium: 0,
13
+ small: 0,
14
+ steps: 0
15
+ };
16
+ const small = room >= 184 ? SMALL_MAX : SMALL_MIN;
17
+ if (layout === "hero") return withSteps({
18
+ large: Math.max(room - 8 - small, small),
19
+ largeCount: 1,
20
+ medium: 0,
21
+ small
22
+ }, count);
23
+ const fit = Math.floor((room - small - 8) / (itemSize + 8));
24
+ const most = Math.max(1, Math.min(fit, count - 2));
25
+ for (let largeCount = most; largeCount >= 1; largeCount--) {
26
+ const gaps = (largeCount + 1) * 8;
27
+ const medium = room - largeCount * itemSize - gaps - small;
28
+ if (medium >= small && medium <= itemSize) return withSteps({
29
+ large: itemSize,
30
+ largeCount,
31
+ medium,
32
+ small
33
+ }, count);
34
+ const large = (room - gaps - 1.5 * small) / (largeCount + .5);
35
+ if (large >= small) return withSteps({
36
+ large,
37
+ largeCount,
38
+ medium: (large + small) / 2,
39
+ small
40
+ }, count);
41
+ }
42
+ return arrange("hero", room, itemSize, count);
43
+ }
44
+ function filledOf(sizes, count) {
45
+ return Math.min(count, sizes.largeCount + trailingOf(sizes).length);
46
+ }
47
+ /**
48
+ * Where every item is drawn with the carousel `position` rests along: a
49
+ * whole number at a rest, and the fraction between two while it moves.
50
+ * `room` is the content box's width and `padding` the space on each side of
51
+ * it, which an item past the edge is drawn beyond.
52
+ */
53
+ function placements(layout, arrangement, room, padding, count, position) {
54
+ if (layout === "uncontained") return Array.from({ length: count }, (_, index) => ({
55
+ left: index * (arrangement.large + 8),
56
+ width: arrangement.large
57
+ }));
58
+ const clamped = Math.min(Math.max(position, 0), arrangement.steps);
59
+ const from = Math.floor(clamped);
60
+ const to = Math.min(from + 1, arrangement.steps);
61
+ const fraction = clamped - from;
62
+ const start = rest(arrangement, room, padding, count, from);
63
+ const end = rest(arrangement, room, padding, count, to);
64
+ return start.map((placement, index) => {
65
+ const next = end[index] ?? placement;
66
+ return {
67
+ left: placement.left + (next.left - placement.left) * fraction,
68
+ width: placement.width + (next.width - placement.width) * fraction
69
+ };
70
+ });
71
+ }
72
+ function rest(arrangement, room, padding, count, step) {
73
+ const { large, largeCount, small } = arrangement;
74
+ const filled = filledOf(arrangement, count);
75
+ const trailing = trailingOf(arrangement).slice(0, filled - largeCount);
76
+ const last = count - filled;
77
+ const turned = Math.max(0, step - last);
78
+ const kept = trailing.length - turned;
79
+ const sizes = [
80
+ ...Array.from({ length: turned }, (_, slot) => trailing[trailing.length - 1 - slot] ?? small),
81
+ ...Array.from({ length: Math.min(largeCount, filled) }, () => large),
82
+ ...trailing.slice(0, kept)
83
+ ];
84
+ const first = Math.min(step, last);
85
+ const lefts = [];
86
+ let cursor = 0;
87
+ for (const size of sizes) {
88
+ lefts.push(cursor);
89
+ cursor += size + 8;
90
+ }
91
+ const shift = turned > 0 ? room - (cursor - 8) : 0;
92
+ const away = small > 0 ? small : large;
93
+ return Array.from({ length: count }, (_, index) => {
94
+ const slot = index - first;
95
+ if (slot < 0) return {
96
+ left: -padding + slot * (away + 8),
97
+ width: away
98
+ };
99
+ if (slot >= sizes.length) return {
100
+ left: room + padding + 8 + (slot - sizes.length) * (away + 8),
101
+ width: away
102
+ };
103
+ return {
104
+ left: (lefts[slot] ?? 0) + shift,
105
+ width: sizes[slot] ?? away
106
+ };
107
+ });
108
+ }
109
+ function trailingOf({ medium, small }) {
110
+ return [medium, small].filter((size) => size > 0);
111
+ }
112
+ function withSteps(sizes, count) {
113
+ const filled = filledOf(sizes, count);
114
+ const turning = Math.max(0, filled - sizes.largeCount);
115
+ return {
116
+ ...sizes,
117
+ steps: count - filled + turning
118
+ };
119
+ }
120
+ //#endregion
121
+ export { arrange, placements };
122
+
123
+ //# sourceMappingURL=arrangement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrangement.js","names":["CarouselLayout","GAP","SMALL_MAX","SMALL_MIN","Arrangement","large","largeCount","medium","small","steps","Placement","left","width","arrange","layout","room","itemSize","count","Math","min","max","withSteps","fit","floor","most","gaps","sizes","filledOf","Omit","trailingOf","length","placements","arrangement","padding","position","Array","from","_","index","clamped","to","fraction","start","rest","end","map","placement","next","step","filled","trailing","slice","last","turned","kept","slot","first","lefts","cursor","size","push","shift","away","filter","turning"],"sources":["../../src/carousel/arrangement.ts"],"sourcesContent":["// The carousel page's layouts as numbers: which items are large, medium and\n// small at each place a carousel comes to rest, and where each is drawn as\n// it moves between two of them. Apart from the component so the arithmetic\n// can be tested without a browser laying anything out, and so the\n// component's file holds what it renders.\n//\n// The model is MDC-Android's keylines, simplified to what the page draws.\n// At rest a multi-browse carousel shows `largeCount` large items, one medium\n// and one small, filling the room exactly; a hero carousel one large and one\n// small. Each rest is one item further along than the last, and once the\n// last item has come into view the rests that remain turn the arrangement\n// round a slot at a time — small, the large ones, medium; then small,\n// medium, the large ones — so every item is drawn large at one rest at\n// least. At rest `s` the large items are always `s` to `s + largeCount - 1`.\n// Between two rests every item's place and width are interpolated, which is\n// what makes an item grow or shrink as it moves rather than jump. Items past\n// either edge are drawn small and out of sight, so they arrive at the size\n// of the slot they enter.\n//\n// Everything is in pixels along the inline axis of the carousel's content\n// box: 0 is its start edge, inside the leading padding.\n\ntype CarouselLayout = 'hero' | 'multi-browse' | 'uncontained'\n\n/** The page's 8dp between items. */\nconst GAP = 8\n\n/** The page's small item: 40dp at the least and 56dp at the most. */\nconst SMALL_MAX = 56\nconst SMALL_MIN = 40\n\ntype Arrangement = {\n /** The large item's width, which every item is laid out at. */\n large: number\n /** How many items are large at rest. */\n largeCount: number\n /** The medium item's width, or 0 for a layout without one. */\n medium: number\n /** The small item's width, or 0 for a layout without one. */\n small: number\n /** The last place the carousel comes to rest, counting from 0. */\n steps: number\n}\n\n/** Where an item is drawn: the start of what shows of it, and its width. */\ntype Placement = { left: number; width: number }\n\n/**\n * The sizes a layout draws its items at in a content box `room` wide, for\n * `count` items and a preferred large width of `itemSize`.\n */\nfunction arrange(\n layout: CarouselLayout,\n room: number,\n itemSize: number,\n count: number,\n): Arrangement {\n if (layout === 'uncontained') {\n const large = Math.min(itemSize, room)\n return { large, largeCount: 0, medium: 0, small: 0, steps: 0 }\n }\n\n // The small item at its largest unless the room is too narrow for it.\n const small = room >= 3 * SMALL_MAX + 2 * GAP ? SMALL_MAX : SMALL_MIN\n\n if (layout === 'hero') {\n const large = Math.max(room - GAP - small, small)\n return withSteps({ large, largeCount: 1, medium: 0, small }, count)\n }\n\n // As many items at the preferred width as fit beside a medium and a small\n // one, and no more than leave a medium and a small item to fill those two\n // slots, so a short run of items still fills the room rather than leaving\n // its last slots empty. Where what is left for the medium item is not\n // between the small and the large width, the large width gives way, to\n // whatever leaves the medium item halfway between the two.\n const fit = Math.floor((room - small - GAP) / (itemSize + GAP))\n const most = Math.max(1, Math.min(fit, count - 2))\n for (let largeCount = most; largeCount >= 1; largeCount--) {\n const gaps = (largeCount + 1) * GAP\n const medium = room - largeCount * itemSize - gaps - small\n if (medium >= small && medium <= itemSize) {\n return withSteps({ large: itemSize, largeCount, medium, small }, count)\n }\n const large = (room - gaps - 1.5 * small) / (largeCount + 0.5)\n if (large >= small) {\n const sizes = { large, largeCount, medium: (large + small) / 2, small }\n return withSteps(sizes, count)\n }\n }\n // Too narrow for three: one large item and one small, as a hero draws.\n return arrange('hero', room, itemSize, count)\n}\n\n// How many of the slots are filled: all of them, unless there are fewer\n// items, which leaves the last slots empty.\nfunction filledOf(sizes: Omit<Arrangement, 'steps'>, count: number) {\n return Math.min(count, sizes.largeCount + trailingOf(sizes).length)\n}\n\n/**\n * Where every item is drawn with the carousel `position` rests along: a\n * whole number at a rest, and the fraction between two while it moves.\n * `room` is the content box's width and `padding` the space on each side of\n * it, which an item past the edge is drawn beyond.\n */\nfunction placements(\n layout: CarouselLayout,\n arrangement: Arrangement,\n room: number,\n padding: number,\n count: number,\n position: number,\n): Placement[] {\n if (layout === 'uncontained') {\n return Array.from({ length: count }, (_, index) => ({\n left: index * (arrangement.large + GAP),\n width: arrangement.large,\n }))\n }\n\n const clamped = Math.min(Math.max(position, 0), arrangement.steps)\n const from = Math.floor(clamped)\n const to = Math.min(from + 1, arrangement.steps)\n const fraction = clamped - from\n const start = rest(arrangement, room, padding, count, from)\n const end = rest(arrangement, room, padding, count, to)\n\n return start.map((placement, index) => {\n const next = end[index] ?? placement\n return {\n left: placement.left + (next.left - placement.left) * fraction,\n width: placement.width + (next.width - placement.width) * fraction,\n }\n })\n}\n\n// Where every item is drawn at one rest.\nfunction rest(\n arrangement: Arrangement,\n room: number,\n padding: number,\n count: number,\n step: number,\n) {\n const { large, largeCount, small } = arrangement\n const filled = filledOf(arrangement, count)\n const trailing = trailingOf(arrangement).slice(0, filled - largeCount)\n // The last rest drawn from the start; past it, how many trailing slots\n // have turned round to the front, the last of them first.\n const last = count - filled\n const turned = Math.max(0, step - last)\n const kept = trailing.length - turned\n const sizes = [\n ...Array.from(\n { length: turned },\n (_, slot) => trailing[trailing.length - 1 - slot] ?? small,\n ),\n ...Array.from({ length: Math.min(largeCount, filled) }, () => large),\n ...trailing.slice(0, kept),\n ]\n // The item in the first slot. Once the arrangement turns, the slots hold\n // the last items, whichever way round they are drawn.\n const first = Math.min(step, last)\n\n // The slots, laid out from the start edge.\n const lefts: number[] = []\n let cursor = 0\n for (const size of sizes) {\n lefts.push(cursor)\n cursor += size + GAP\n }\n // A turned arrangement that does not fill the room is set against the end\n // edge instead, which is where its large items belong.\n const shift = turned > 0 ? room - (cursor - GAP) : 0\n const away = small > 0 ? small : large\n\n return Array.from({ length: count }, (_, index): Placement => {\n const slot = index - first\n if (slot < 0) {\n // Past the start edge, beyond the padding, a small item per place.\n return { left: -padding + slot * (away + GAP), width: away }\n }\n if (slot >= sizes.length) {\n // Past the end edge, likewise.\n return {\n left: room + padding + GAP + (slot - sizes.length) * (away + GAP),\n width: away,\n }\n }\n return { left: (lefts[slot] ?? 0) + shift, width: sizes[slot] ?? away }\n })\n}\n\n// The widths that follow the large ones at rest: medium then small, or the\n// small alone for a hero.\nfunction trailingOf({ medium, small }: Omit<Arrangement, 'steps'>) {\n return [medium, small].filter((size) => size > 0)\n}\n\n// A rest starts at each item while every slot after it is filled, and each\n// trailing slot turning round to the front is one rest more.\nfunction withSteps(\n sizes: Omit<Arrangement, 'steps'>,\n count: number,\n): Arrangement {\n const filled = filledOf(sizes, count)\n const turning = Math.max(0, filled - sizes.largeCount)\n return { ...sizes, steps: count - filled + turning }\n}\n\nexport type { Arrangement, CarouselLayout, Placement }\n\nexport { arrange, GAP, placements }\n"],"mappings":";AA4BA,MAAME,YAAY;AAClB,MAAMC,YAAY;;;;;AAsBlB,SAASU,QACPC,QACAC,MACAC,UACAC,OACa;CACb,IAAIH,WAAW,eAEb,OAAO;EAAET,OADKa,KAAKC,IAAIH,UAAUD,IACxBV;EAAOC,YAAY;EAAGC,QAAQ;EAAGC,OAAO;EAAGC,OAAO;CAAE;CAI/D,MAAMD,QAAQO,QAAQ,MAA0Bb,YAAYC;CAE5D,IAAIW,WAAW,QAEb,OAAOO,UAAU;EAAEhB,OADLa,KAAKE,IAAIL,OAAAA,IAAaP,OAAOA,KACxBH;EAAOC,YAAY;EAAGC,QAAQ;EAAGC;CAAM,GAAGS,KAAK;CASpE,MAAMK,MAAMJ,KAAKK,OAAOR,OAAOP,QAAAA,MAAgBQ,WAAAA,EAAe;CAC9D,MAAMQ,OAAON,KAAKE,IAAI,GAAGF,KAAKC,IAAIG,KAAKL,QAAQ,CAAC,CAAC;CACjD,KAAK,IAAIX,aAAakB,MAAMlB,cAAc,GAAGA,cAAc;EACzD,MAAMmB,QAAQnB,aAAa,KAAA;EAC3B,MAA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,QAEhB,OAAO;GACLnB,MAAMI,OAAOkB,UAAAA,KAAiBsB,OAAO7B,MAAMI,WAAWgC,OAAAA;GACtDlD,OAAOkD;EACT;EAEF,OAAO;GAAEnD,OAAO8C,MAAMF,SAAS,KAAKM;GAAOjD,OAAOc,MAAM6B,SAASO;EAAK;CACxE,CAAC;AACH;AAIA,SAASjC,WAAW,EAAEtB,QAAQC,SAAqC;CACjE,OAAO,CAACD,QAAQC,KAAK,CAAC,CAACuD,QAAQJ,SAASA,OAAO,CAAC;AAClD;AAIA,SAAStC,UACPK,OACAT,OACa;CACb,MAAMgC,SAAStB,SAASD,OAAOT,KAAK;CACpC,MAAM+C,UAAU9C,KAAKE,IAAI,GAAG6B,SAASvB,MAAMpB,UAAU;CACrD,OAAO;EAAE,GAAGoB;EAAOjB,OAAOQ,QAAQgC,SAASe;CAAQ;AACrD"}
@@ -5,10 +5,15 @@ import { chipLayers, chipStyles } from "./styles.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/chip/index.tsx
7
7
  /**
8
- * The check a selected chip draws before its label, and nothing at all while
9
- * it is not selected. Returns a node rather than letting the type be
10
- * inferred, since `ReactNode` is a union that includes a promise and an
11
- * inferred one has to be `async`.
8
+ * What a chip draws before its label: the check while it is selected, its own
9
+ * icon while it is not, and nothing for an unselected chip with no icon.
10
+ * Returns a node rather than letting the type be inferred, since `ReactNode`
11
+ * is a union that includes a promise and an inferred one has to be `async`.
12
+ *
13
+ * The check takes the icon's place rather than joining it, as the chips page
14
+ * draws a filter chip and as a segmented button's segments do. So a chip with
15
+ * an icon keeps its width when it is chosen, where one without grows by the
16
+ * slot.
12
17
  *
13
18
  * Shared rather than written at each of the two call sites: Chip and
14
19
  * ChipGroup's chip draw the same pill from `./styles`, and a check written
@@ -16,12 +21,16 @@ import { jsx } from "react/jsx-runtime";
16
21
  * library's own and not exported from the package; see `src/row` for the
17
22
  * same arrangement around a list's row.
18
23
  */
19
- function chipGlyph(isSelected) {
20
- if (!isSelected) return null;
21
- return /* @__PURE__ */ jsx("span", {
24
+ function chipGlyph(state, icon) {
25
+ if (state.isSelected) return /* @__PURE__ */ jsx("span", {
22
26
  ...props(chipStyles.glyph),
23
27
  children: /* @__PURE__ */ jsx(CheckGlyph, { ...props(chipStyles.glyphSvg) })
24
28
  });
29
+ if (icon === void 0 || icon === null) return null;
30
+ return /* @__PURE__ */ jsx("span", {
31
+ ...props(chipStyles.glyph, !state.isDisabled && chipStyles.icon),
32
+ children: icon
33
+ });
25
34
  }
26
35
  /**
27
36
  * The label a chip draws, in a span of its own so it can be cut short with an
@@ -35,22 +44,47 @@ function chipLabel(children) {
35
44
  children
36
45
  });
37
46
  }
47
+ const CONTAINERS = {
48
+ elevated: {
49
+ disabled: chipStyles.elevatedDisabled,
50
+ focused: chipLayers.elevatedFocused,
51
+ hovered: chipLayers.elevatedHovered,
52
+ pressed: chipLayers.elevatedPressed
53
+ },
54
+ selected: {
55
+ disabled: chipStyles.disabledSelected,
56
+ focused: chipLayers.selectedFocused,
57
+ hovered: chipLayers.selectedHovered,
58
+ pressed: chipLayers.selectedPressed
59
+ },
60
+ unselected: {
61
+ disabled: chipStyles.disabledUnselected,
62
+ focused: chipLayers.unselectedFocused,
63
+ hovered: chipLayers.unselectedHovered,
64
+ pressed: chipLayers.unselectedPressed
65
+ }
66
+ };
38
67
  /**
39
68
  * The pill's styles in the render state React Aria hands a chip's
40
- * `className`, for Chip's toggle button and ChipGroup's tag alike. StyleX
69
+ * `className`, for Chip's two buttons and ChipGroup's tag alike. StyleX
41
70
  * cannot target `[data-selected]` on the element it is styling, so the
42
71
  * container is chosen here rather than in CSS — which is also why an
43
72
  * uncontrolled chip styles itself without keeping a copy of its state.
44
73
  *
45
74
  * Shared for the reason `chipGlyph` is: the order is the precedence. The
46
- * hover and pressed layers come from the render state over the container, a
47
- * press over a hover, and disabled comes last so it wins over all of them,
48
- * since StyleX replaces a property whole. `inGroup` is a ChipGroup's
49
- * chip, whose touch target reaches only halfway across the gap to the next
50
- * row; see `targetInGroup` in `./styles`.
75
+ * hover, focus and pressed layers come from the render state over the
76
+ * container — focus over hover, and a press over both — and disabled comes
77
+ * last so it wins over all of them, since StyleX replaces a property whole.
78
+ *
79
+ * `elevated` raises the chip off the page on a container of its own, and
80
+ * `kind` names which of the page's chips it is, which decides the label's
81
+ * role. `inGroup` is a ChipGroup's chip, whose touch target reaches only
82
+ * halfway across the gap to the next row; see `targetInGroup` in `./styles`.
51
83
  */
52
- function chipPropsFor(state, inGroup = false) {
53
- return props(chipStyles.base, chipStyles.target, inGroup && chipStyles.targetInGroup, focus.ring, state.isSelected ? chipStyles.selected : chipStyles.unselected, state.isHovered && (state.isSelected ? chipLayers.selectedHovered : chipLayers.unselectedHovered), state.isPressed && (state.isSelected ? chipLayers.selectedPressed : chipLayers.unselectedPressed), state.isDisabled && chipStyles.disabled, state.isDisabled && (state.isSelected ? chipStyles.disabledSelected : chipStyles.disabledUnselected));
84
+ function chipPropsFor(state, { elevated = false, inGroup = false, kind = "filter" } = {}) {
85
+ const roles = CONTAINERS[containerOf(state.isSelected, elevated)];
86
+ const raised = elevated && !state.isDisabled;
87
+ return props(chipStyles.base, chipStyles.target, inGroup && chipStyles.targetInGroup, focus.ring, state.isSelected ? chipStyles.selected : chipStyles.unselected, elevated && !state.isSelected && chipStyles.elevated, kind === "assist" && chipStyles.assist, raised && chipStyles.raised, state.isHovered && roles.hovered, raised && state.isHovered && chipStyles.raisedHovered, state.isFocusVisible && roles.focused, state.isPressed && roles.pressed, state.isDisabled && chipStyles.disabled, state.isDisabled && roles.disabled);
54
88
  }
55
89
  /**
56
90
  * The close target's class, from its button's own render state, so its
@@ -61,6 +95,10 @@ function chipPropsFor(state, inGroup = false) {
61
95
  function chipRemoveClassName(state) {
62
96
  return props(chipStyles.remove, state.isHovered && chipLayers.removeHovered, state.isPressed && chipLayers.removePressed).className ?? "";
63
97
  }
98
+ function containerOf(isSelected, elevated) {
99
+ if (isSelected) return "selected";
100
+ return elevated ? "elevated" : "unselected";
101
+ }
64
102
  //#endregion
65
103
  export { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName };
66
104