@kanso-labs/kanso-ui 0.47.4 → 0.48.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.
- package/dist/button/hooks.js +35 -1
- package/dist/button/hooks.js.map +1 -1
- package/dist/button/index.js +78 -65
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/styles.js +5 -5
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/styles.js +1 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/context.js +6 -0
- package/dist/collection/context.js.map +1 -0
- package/dist/collection/styles.js +29 -6
- package/dist/collection/styles.js.map +1 -1
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.js +7 -0
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/checkbox/index.js +10 -7
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +2 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip-group/index.js +69 -66
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/color-swatch-picker/index.js +1 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/combo-box/index.js +5 -1
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/drop-zone/styles.js +11 -11
- package/dist/components/drop-zone/styles.js.map +1 -1
- package/dist/components/fab-menu/index.js +3 -3
- package/dist/components/fab-menu/index.js.map +1 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.js +58 -11
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.js +82 -103
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/navigation-rail/index.js +4 -4
- package/dist/components/navigation-rail/index.js.map +1 -1
- package/dist/components/number-field/index.js +3 -3
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.js +3 -3
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/radio-group/index.js +12 -11
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.js +4 -4
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/select/index.js +5 -1
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/sheet/index.js +1 -1
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/snackbar/index.js +3 -3
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/split-button/index.js +53 -41
- package/dist/components/split-button/index.js.map +1 -1
- package/dist/components/table/index.js +58 -45
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tabs/index.js +81 -30
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/time-picker/index.js +5 -5
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/tree/index.js +78 -21
- package/dist/components/tree/index.js.map +1 -1
- package/dist/field/index.js +103 -104
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +1 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/hooks/useScrollEdges.js +73 -0
- package/dist/hooks/useScrollEdges.js.map +1 -0
- package/dist/navigation/styles.js +5 -5
- package/dist/navigation/styles.js.map +1 -1
- package/dist/row/styles.js +7 -7
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/color.js +16 -16
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/focus.js +4 -4
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles/overlay.js +3 -3
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles/scroll-fade.js +33 -0
- package/dist/styles/scroll-fade.js.map +1 -0
- package/dist/styles.css +61 -20
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","useSyncExternalStore","RACToastQueue","RACToastRegion","useBottomEdgeClearance","useRipple","mergeStatefulStyles","MESSAGE_MS","MINIMUM_MS","UNTIL_CLOSED","EXIT_MS","_temp","krVfgx","kGO01o","styles","action","kgeoSG","kGOzcv","kpsdNU","kEoFBp","kMwMTN","kMv6JI","kGuDYH","k63SB2","kb6lSQ","kLWn49","kAzted","k8WAf4","kg3NbH","$$css","close","kZKoxP","kzqmXN","kmVPX3","control","kGNEyG","kWkggS","kaIpWk","kMzoRj","kB7OPa","kkrTdU","k1xSpc","kmuXW","kjj79g","kjBf7l","kInvED","k3XXqK","kMeerF","kVAEAm","controlFocused","controlHovered","controlPressed","region","kXwgrk","kOIVth","kkqhue","kLKAdn","kE3dHu","kpe85a","kfzvcC","kY2c9j","risen","clearance","val","undefined","label","onPress","message","showCloseButton","onClose","timeout","className","closeLabel","queue","SnackbarQueue","style","FadingToastQueue","fading","Set","onClosing","key","constructor","maxVisibleToasts","add","setTimeout","delete","listener","isFading","has","subscribeToFading","rac","Map","toasts","options","clear","readableTimeout","set","keys","get","actionPress","closeToast","controlClassName","state","isFocusVisible","isHovered","isPressed","props","Math","max","Snackbar","t0","$","T0","t1","t2","t3","snackbarContent","t4","SnackbarButton","children","ripple","handlers","surface","toast","SnackbarControls","SnackbarToast","content","useFading","Symbol","for","0","1","t5","_temp2","Queue","RACButton","RACToastContent","RACToast"],"sources":["../../../src/components/snackbar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { FocusableElement, ToastRegionProps as RACToastRegionProps, ToastRegionRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useSyncExternalStore } from 'react';\nimport { Button as RACButton, UNSTABLE_Toast as RACToast, UNSTABLE_ToastContent as RACToastContent, UNSTABLE_ToastQueue as RACToastQueue, UNSTABLE_ToastRegion as RACToastRegion, Text } from 'react-aria-components';\nimport { CloseGlyph } from '../../glyphs';\nimport { useBottomEdgeClearance } from '../../hooks/useBottomEdge';\nimport { useRipple } from '../../hooks/useRipple';\nimport '../../styles/layers.stylex';\nimport { layers } from '../../styles/layers.stylex';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, sizing, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// The snackbar page's brief message at the bottom of the screen, with an\n// optional action beside it and an optional close button after that. The\n// page's container is the inverse surface at a 4dp corner and elevation 3,\n// its supporting text is body-medium in inverse on surface, its action label\n// is inverse primary, and its close icon takes the supporting text's colour.\n// The measurements are the page's too: 8dp of margin from the edges of the\n// screen, 8dp of padding inside the container with another 8dp either side\n// of the message, 14dp above and below on a single line, and between 320 and\n// 576dp wide above the page's 600dp breakpoint — full width below it.\n//\n// One at a time. The page shows a single snackbar and replaces it rather\n// than stacking, so a message added while another is up closes that one —\n// its `onClose` runs — and takes its place. Nothing waits behind it: React\n// Aria's queue, left to itself, kept every message and showed the one it had\n// replaced again once the newer closed, so an Undo could come back long after\n// the thing it undid.\n//\n// React Aria's toast is the behaviour: the region is a landmark that holds\n// the message, moves focus into it for a keyboard, and pauses every timer\n// while it is hovered or focused, so a message never expires while it is\n// being read or acted on.\n//\n// Three things are decided here rather than taken from React Aria or from\n// the page.\n//\n// **The queue is ours, not React Aria's.** React Aria's toast is still\n// `UNSTABLE_`, and `SnackbarQueue` is what keeps that name out of a\n// consumer's code — an upstream rename is this file rather than every call\n// site. It wraps their queue, defaults it to one visible message, and takes\n// the message and its options as one call.\n//\n// **The action and the close button are drawn here rather than through\n// Button and IconButton.** The page colours them inverse primary and inverse\n// on surface, which no variant of either carries, and a colour pushed in\n// from outside through `className` is the merge hazard AGENTS.md describes:\n// StyleX decides between two atomic classes by their order in the compiled\n// stylesheet, not by the order they are applied. Both are React Aria's\n// `Button` with the same ripple and the same state layers, over\n// `currentColor` so each takes the colour the snackbar gives it.\n//\n// **There is no `container` prop.** Every other overlay here takes one,\n// because React Aria's `Modal` and `Popover` accept a portal container, and\n// `src/components/portal-container.test.tsx` is what keeps that true.\n// Its toast region does not: it reads a portal provider that\n// `react-aria-components` does not export, so the region always lands at the\n// end of `<body>`. An app that scopes its StyleX theme to a subtree has to\n// put the theme on `:root` for the snackbar to be drawn in it.\n\n// How long a message is shown when the call site names no `timeout`. The\n// specs page gives no duration, so these come from the snackbar's guidelines\n// and accessibility pages.\n//\n// A message alone leaves after five seconds. The pages allow four to ten, and\n// React Aria's toast docs set five as the least a reader should be given.\n//\n// A call site's own `timeout` is held to the pages' four. A shorter one is\n// lengthened to that, since a message gone in a second cannot be read, and the\n// web gives a reader no setting to slow it down with — the same reason the\n// paragraph below gives. `0` is left alone: it is no timer at all.\n//\n// A message with an action stays until the action is taken or something\n// closes it, as the pages ask of every actionable snackbar. No timer can know\n// how long a reader needs to act: a screen reader user hears the message\n// first and has to reach the region before the action is any use, and the\n// pause while the region is hovered or focused only starts once they have.\n// Android's snackbar can keep shorter defaults because the platform lengthens\n// them from each user's accessibility settings, and the web has no such\n// setting to read.\nconst MESSAGE_MS = 5000;\nconst MINIMUM_MS = 4000;\nconst UNTIL_CLOSED = 0;\n\n// How long a closing snackbar takes to fade, and so how long it stays in the\n// document once something has closed it: `durationShort2`, the token the fade\n// below runs for. A theme that lengthens that token has its fade cut short\n// here, since the queue cannot read a duration out of the stylesheet.\nconst EXIT_MS = 150;\n\n// Below the page's 600dp breakpoint the snackbar runs the width of the\n// screen; above it, it takes between 320 and 576.\nconst WIDE = '@media (min-width: 600px)';\n\n// The page's own is a fade, in and out. It rises a little as it arrives too,\n// which is what the page draws and what says the message came from the edge\n// of the screen rather than appearing over it. It leaves by the fade alone,\n// and quicker than it came, on the curve for something going away: once it is\n// closed there is nothing left on it to read.\nconst rise = \"x15b941j-B\";\nconst fadeOut = \"x1jn504y-B\";\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)';\n\n// The least press area the action keeps, as Button's medium size does. A\n// literal rather than a token, for the reason Button's `TARGET_SIZE` gives: a\n// consumer resizing their controls should not shrink a floor the page states.\nconst TARGET_SIZE = '48px';\nconst _temp = {\n krVfgx: \"xiicpxy\",\n kGO01o: \"xqf7pud\",\n \"$$css\": true\n};\nconst styles = {\n action: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"xun2zgk\",\n kpsdNU: \"xm4btww\",\n kEoFBp: \"x1hmns74\",\n kMwMTN: \"x16bex6i\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kAzted: \"x1cio8j0\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n close: {\n kZKoxP: \"xbg5kjn\",\n kMwMTN: \"x1girmi0\",\n kzqmXN: \"xoqf9c6\",\n kmVPX3: \"x1717udv\",\n $$css: true\n },\n control: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kjj79g: \"xl56j7k\",\n kjBf7l: \"x14ytart\",\n kInvED: \"xr2mjdv\",\n k3XXqK: \"x9v5kkp x1t137rt\",\n kMeerF: \"x1de99jn\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n controlFocused: {\n kWkggS: \"x1mbb5iu\",\n $$css: true\n },\n controlHovered: {\n kWkggS: \"x930l3l\",\n $$css: true\n },\n controlPressed: {\n kWkggS: \"xsykwg8\",\n $$css: true\n },\n region: {\n kGNEyG: \"x6s0dn4\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n kOIVth: \"x126z3so\",\n krVfgx: \"x1ey2m1c\",\n kkqhue: \"x17y0mx6\",\n k3XXqK: \"x1t137rt\",\n kGO01o: \"x1u7mh7p\",\n kLKAdn: \"xi7mcox\",\n kE3dHu: \"xbpsoft\",\n kpe85a: \"xq5vm52\",\n kfzvcC: \"x47corl\",\n kVAEAm: \"xixxii4\",\n kY2c9j: \"x1bk8fjm\",\n $$css: true\n },\n risen: (clearance: string) => [_temp, {\n \"--x-insetBlockEnd\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(clearance)\n }]\n};\ntype SnackbarAction = {\n /** What the action says. The page gives it a single word where it can. */\n label: string;\n /** Run when the action is pressed, just before the snackbar closes. */\n onPress: () => void;\n};\n\n/** What a snackbar carries: its message, and what may sit beside it. */\ntype SnackbarMessage = {\n action: SnackbarAction | undefined;\n message: ReactNode;\n showCloseButton: boolean;\n};\ntype SnackbarOptions = {\n /**\n * A single action shown after the message. Pressing it runs `onPress` and\n * closes the snackbar, which is what the page draws.\n */\n action?: SnackbarAction;\n /**\n * Run when the snackbar closes, however it was closed: by its timer, its\n * action or close button, `close`, `clear`, or a newer message added in its\n * place. It runs as the snackbar starts to fade out, not once it has gone.\n */\n onClose?: () => void;\n /**\n * Whether a close button is shown at the end. The page draws one for a\n * message a reader may want out of the way before it expires.\n *\n * Named for what it draws rather than `isDismissable`, which on `Sheet`,\n * `Dialog` and React Aria's modals is whether a press outside them closes\n * them — a snackbar has no outside to press.\n * @default false\n */\n showCloseButton?: boolean;\n /**\n * How long the snackbar is shown, in milliseconds. Defaults to five seconds\n * for a message alone. A message with an action defaults to `0` and stays\n * until the action is taken or something closes it, as Material Design asks\n * of an actionable snackbar, since a reader may need longer to reach the\n * action than any timer allows. The timer is paused while the region is\n * hovered or focused, so a message never expires while it is being read.\n *\n * A timer shorter than four seconds, the least Material Design allows, is\n * lengthened to four, since a message gone sooner cannot be read.\n *\n * `0` is the page's indefinite length: the snackbar stays until something\n * closes it. Give one of those an action or `showCloseButton`, or there is no\n * way to be rid of it.\n */\n timeout?: number;\n};\ntype SnackbarProps = {\n /**\n * What a screen reader calls the region holding the snackbar. Left out,\n * React Aria names the region itself: a count of the messages it holds, in\n * the reader's own locale — \"1 notification.\" in English, and one of some\n * thirty languages otherwise. Pass a name only to replace that, and pass a\n * translated one, since whatever is passed is read as written.\n */\n 'aria-label'?: string;\n /** A function may compute the class from the region's render state. */\n className?: RACToastRegionProps<SnackbarMessage>['className'];\n /**\n * What a screen reader calls the button that dismisses a snackbar. It sits\n * here rather than on a message's own options because it does not vary by\n * message, so putting it there would make every `add` call repeat it. Left\n * out, React Aria names it in the reader's locale — \"Close\" in English.\n */\n closeLabel?: string;\n /** The queue the region shows messages from. */\n queue: SnackbarQueue;\n /** A function may compute the style from the region's render state. */\n style?: RACToastRegionProps<SnackbarMessage>['style'];\n} & Omit<RACToastRegionProps<SnackbarMessage>, 'aria-label' | 'children' | 'className' | 'queue' | 'style'>;\n\n// One entry of the queue, as React Aria hands it to the region's render\n// function. Taken from its render state rather than imported from\n// `react-stately`, which this package does not depend on.\ntype SnackbarToastItem = ToastRegionRenderProps<SnackbarMessage>['visibleToasts'][number];\n\n/**\n * React Aria's queue, made to keep a closing snackbar on screen while it\n * fades. React Aria drops a toast from its list the moment it closes, and the\n * region unmounts with its last toast, so a closing strip has no state of its\n * own to be drawn in. Every close reaches `close` here — React Aria's timer and\n * its close button call it on the queue they were handed, as `SnackbarQueue`\n * does — so this one override covers all of them: the strip is marked as\n * fading, and React Aria closes it once the fade has run.\n */\nclass FadingToastQueue extends RACToastQueue<SnackbarMessage> {\n // The strips fading out.\n readonly #fading = new Set<string>();\n readonly #listeners = new Set<() => void>();\n\n // Run as a strip starts to close — see `SnackbarQueue`.\n readonly #onClosing: (key: string) => void;\n constructor(onClosing: (key: string) => void) {\n // One at a time, which is what the page shows. React Aria shows the\n // newest, so a message added while another is up or fading takes its\n // place at once, and the older one runs out its fade unseen.\n super({\n maxVisibleToasts: 1\n });\n this.#onClosing = onClosing;\n }\n\n /** Starts a toast fading, and closes it once the fade has run. */\n override close(key: string) {\n this.#onClosing(key);\n this.#fading.add(key);\n setTimeout(() => {\n this.#fading.delete(key);\n super.close(key);\n }, EXIT_MS);\n for (const listener of this.#listeners) {\n listener();\n }\n }\n\n /** Whether a toast is fading out. */\n isFading(key: string) {\n return this.#fading.has(key);\n }\n\n /** Calls `listener` whenever a toast starts to fade. */\n subscribeToFading(listener: () => void) {\n this.#listeners.add(listener);\n return () => {\n this.#listeners.delete(listener);\n };\n }\n}\n\n/**\n * The queue a snackbar is shown from. Make one where the app can reach it —\n * a module of its own is the usual place — mount `Snackbar` once with it,\n * and call `add` from anywhere.\n *\n * ```ts\n * const messages = new Snackbar.Queue()\n * messages.add('Label', { action: { label: 'Undo', onPress: undo } })\n * ```\n *\n * It wraps React Aria's toast queue rather than exposing it, which is what\n * keeps that API's `UNSTABLE_` name out of a consumer's code.\n */\nclass SnackbarQueue {\n /**\n * React Aria's queue, which `Snackbar` subscribes to. Not part of the\n * package's API — read it and an upstream release may break the call site.\n */\n readonly rac: RACToastQueue<SnackbarMessage>;\n\n // The snackbars not yet closed, each with its `onClose`, which `add` and\n // `clear` close. Kept here because React Aria keeps its own list private,\n // and its own `clear` empties that list without running a single `onClose`.\n readonly #open = new Map<string, (() => void) | undefined>();\n\n // `rac` as the class it is, which `rac` itself is not declared as so that\n // the subclass stays out of the package's API.\n readonly #toasts: FadingToastQueue;\n constructor() {\n this.#toasts = new FadingToastQueue(key => {\n this.#closing(key);\n });\n this.rac = this.#toasts;\n }\n\n /**\n * Shows a message in place of the one on screen, and returns the key that\n * closes it. The message it replaces is closed, so its `onClose` runs, and\n * it does not come back.\n */\n add(message: ReactNode, options: SnackbarOptions = {}) {\n const {\n action,\n onClose,\n showCloseButton = false,\n timeout\n } = options;\n this.clear();\n const key = this.#toasts.add({\n action,\n message,\n showCloseButton\n }, {\n timeout: readableTimeout(timeout ?? (action === undefined ? MESSAGE_MS : UNTIL_CLOSED))\n });\n this.#open.set(key, onClose);\n return key;\n }\n\n /** Closes the snackbar on screen, running its `onClose`. */\n clear() {\n // Each close runs that message's `onClose`, which deletes its own key\n // from the map — the entry being visited, which a Map allows.\n for (const key of this.#open.keys()) {\n this.#toasts.close(key);\n }\n }\n\n /** Closes one snackbar, by the key `add` returned. */\n close(key: string) {\n this.#toasts.close(key);\n }\n\n // A snackbar starting to close, however it was closed — its timer runs\n // inside React Aria's queue, past this one — leaves the open map and runs\n // its `onClose` on the way out.\n #closing(key: string) {\n const onClose = this.#open.get(key);\n if (this.#open.delete(key)) {\n onClose?.();\n }\n }\n}\n\n// The three handlers the snackbar hands to something below it, each built by\n// a call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\nfunction actionPress(action: SnackbarAction, close: () => void) {\n return () => {\n action.onPress();\n close();\n };\n}\nfunction closeToast(queue: SnackbarQueue, key: string) {\n return () => {\n queue.close(key);\n };\n}\n\n// A control's classes, from its own render state — see `controlFocused`.\nfunction controlClassName(style: stylex.StyleXStyles) {\n return (state: {\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n }) => stylex.props(styles.control, style, state.isHovered && styles.controlHovered, state.isFocusVisible && styles.controlFocused, state.isPressed && styles.controlPressed).className ?? '';\n}\n\n// A timer the reader has time to read by — see the durations at the top of\n// this file. Only a timer is held to the minimum: React Aria runs none for `0`\n// or below, which keep the message until something closes it.\nfunction readableTimeout(timeout: number) {\n return timeout > UNTIL_CLOSED ? Math.max(timeout, MINIMUM_MS) : timeout;\n}\n\n/**\n * A brief message at the bottom of the screen, with an optional action. Mount\n * one of these with a `Snackbar.Queue`, and call the queue's `add` to show a\n * message from anywhere.\n *\n * ```tsx\n * const messages = new Snackbar.Queue()\n *\n * <Snackbar queue={messages} />\n * ```\n *\n * The region is portalled to the end of `<body>` and renders nothing while\n * the queue is empty. It is one region rather than one per message, so mount\n * it once, near the root.\n *\n * The call site's `className` and `style` land on that region, which is the\n * element a layout positions.\n *\n * While a full-screen `Dialog` or a `Sheet` with a footer is open, the region\n * rises to sit above those actions rather than over them, since they share\n * the bottom edge of the window and the snackbar is drawn above both.\n *\n * While a `Dialog` or a `Sheet` is open, Tab stays inside it and never\n * reaches the snackbar. F6 does: React Aria moves focus between landmarks\n * with it, so it lands on the region, Tab then reaches the message and its\n * action, and tabbing on past the last of them leads back into the dialog. A\n * message with an action stays until it is answered, so a keyboard user has\n * the time that route takes.\n */\nfunction Snackbar({\n closeLabel,\n queue,\n ...props\n}: RefAttributes<HTMLDivElement> & SnackbarProps) {\n const clearance = useBottomEdgeClearance();\n return <RACToastRegion<SnackbarMessage> queue={queue.rac} {...props} {...mergeStatefulStyles(stylex.props(styles.region, clearance > 0 && styles.risen(`${clearance}px`)), props)}>\n {snackbarContent(queue, closeLabel)}\n </RACToastRegion>;\n}\n\n/**\n * One of the snackbar's two controls. React Aria's `Button` rather than the\n * library's, for the colour reason in the comment at the top of this file;\n * the ripple and the state layers are the same ones every other control\n * here draws, over `currentColor`.\n */\nfunction SnackbarButton({\n children,\n style,\n ...props\n}: {\n 'aria-label'?: string;\n children: ReactNode;\n onPress?: () => void;\n slot?: string;\n style: stylex.StyleXStyles;\n}) {\n const ripple = useRipple<FocusableElement>();\n return <RACButton {...ripple.handlers} {...props} className={controlClassName(style)}>\n {children}\n {ripple.surface}\n </RACButton>;\n}\nfunction snackbarContent(queue: SnackbarQueue, closeLabel: string | undefined) {\n return ({\n toast\n }: {\n toast: SnackbarToastItem;\n }) => <SnackbarToast close={closeToast(queue, toast.key)} closeLabel={closeLabel} queue={queue} toast={toast} />;\n}\n\n/**\n * The action, the close button, or nothing, after the message — together, so\n * they move beneath it together.\n */\nfunction SnackbarControls({\n action,\n close,\n closeLabel,\n fading,\n showCloseButton\n}: {\n action: SnackbarAction | undefined;\n close: () => void;\n closeLabel: string | undefined;\n fading: boolean;\n showCloseButton: boolean;\n}) {\n if (action === undefined && !showCloseButton) {\n return null;\n }\n return <div className=\"x6s0dn4 x9f619 x78zum5 x2lah0s xvc5jky\">\n {action === undefined ? null :\n // Nothing on a fading strip answers a press: its action has already\n // run, and an Undo pressed twice would undo twice.\n <SnackbarButton onPress={fading ? undefined : actionPress(action, close)} style={styles.action}>\n {action.label}\n </SnackbarButton>}\n {showCloseButton ? <SnackbarButton aria-label={closeLabel} slot=\"close\" style={styles.close}>\n <CloseGlyph className=\"xxk0z11 xvy4d1p\" />\n </SnackbarButton> : null}\n </div>;\n}\n\n/** One snackbar: its message, then whatever sits after it. */\nfunction SnackbarToast({\n close,\n closeLabel,\n queue,\n toast\n}: {\n close: () => void;\n closeLabel: string | undefined;\n queue: SnackbarQueue;\n toast: SnackbarToastItem;\n}) {\n const {\n action,\n message,\n showCloseButton\n } = toast.content;\n const fading = useFading(queue, toast.key);\n return <RACToast toast={toast} {...{\n 0: {\n className: \"x6s0dn4 x1n1nwrg x1u6grsq x1dwmuk9 x16dv9tl x1c5gpgi x1w1tqly x1tfhd1 xx61lck x13rsnn2 x1udv5rz x9f619 x78zum5 x1a02dak xh8yej3 x1x1rfll xlx31pv x1dry9sr xeuugli xuq8xha x1ulcdur xr2mjdv x9v5kkp x1t137rt x1de99jn xt970qd xn60lsn x67bb7w\"\n },\n 1: {\n className: \"x6s0dn4 x1c5gpgi x1w1tqly x1tfhd1 xx61lck x13rsnn2 x1udv5rz x9f619 x78zum5 x1a02dak xh8yej3 x1x1rfll xlx31pv x1dry9sr xeuugli xuq8xha x1ulcdur xr2mjdv x9v5kkp x1t137rt x1de99jn xt970qd xn60lsn x1vhuh8u x1u6grsq x10e4vud xxp0q0x xi22y15 x47corl\"\n }\n }[!!fading << 0]}>\n <RACToastContent className=\"x9f619 x1girmi0 x4pfjvb x1iyjqo2 xpo2rfv x193rfdd x1hews6w xkjl1po xn43zvd xv61bfh xz158ff xeuugli xj0a0fe xxlmvz2\">\n <Text slot=\"title\">{message}</Text>\n </RACToastContent>\n <SnackbarControls action={action} close={close} closeLabel={closeLabel} fading={fading} showCloseButton={showCloseButton} />\n </RACToast>;\n}\n\n/**\n * Whether a snackbar is fading out of its queue. `rac` is always the queue\n * that fades, but is declared as React Aria's, so it is narrowed back here.\n */\nfunction useFading(queue: SnackbarQueue, key: string) {\n const toasts = queue.rac instanceof FadingToastQueue ? queue.rac : undefined;\n return useSyncExternalStore(listener => toasts?.subscribeToFading(listener) ?? (() => {}), () => toasts?.isFading(key) ?? false);\n}\nSnackbar.Queue = SnackbarQueue;\n\n// The queue is reached as `Snackbar.Queue` rather than exported beside the\n// component: this file would otherwise export something that is not a\n// component, which is what turns fast refresh off for it.\nexport type { SnackbarAction, SnackbarMessage, SnackbarOptions, SnackbarProps, SnackbarQueue, ToastRegionRenderProps as SnackbarRegionRenderProps };\nexport default Snackbar;"],"mappings":";;;;;;;;;;;AAoFA,MAAMQ,aAAa;AACnB,MAAMC,aAAa;AACnB,MAAMC,eAAe;AAMrB,MAAMC,UAAU;AAwBhB,MAAMC,QAAQ;CACZC,QAAQ;CACRC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,SAAS;CACbC,QAAQ;EACNC,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,OAAO;EACLC,QAAQ;EACRX,QAAQ;EACRY,QAAQ;EACRC,QAAQ;EACRJ,OAAO;CACT;CACAK,SAAS;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRnB,OAAO;CACT;CACAoB,gBAAgB;EACdb,QAAQ;EACRP,OAAO;CACT;CACAqB,gBAAgB;EACdd,QAAQ;EACRP,OAAO;CACT;CACAsB,gBAAgB;EACdf,QAAQ;EACRP,OAAO;CACT;CACAuB,QAAQ;EACNjB,QAAQ;EACRI,QAAQ;EACRE,QAAQ;EACRY,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,EAAA,OAAA/B,OAAA+B,EAAA,OAAAnB,QAAA;EAAEqB,WAAMrB,QAAML,SAAWP,GAAY,KAA7B;EAA8B+B,EAAA,KAAA/B;EAAA+B,EAAA,KAAAnB;EAAAmB,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAxH9G,qBAAqB6G,IAA+DG,EAAoC;AAAC;AAFlI,SAAAoB,SAAA,CAAA;AAIAxB,SAASyB,QAAQ5D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","useSyncExternalStore","RACToastQueue","RACToastRegion","useBottomEdgeClearance","useRipple","mergeStatefulStyles","MESSAGE_MS","MINIMUM_MS","UNTIL_CLOSED","EXIT_MS","_temp","krVfgx","kGO01o","styles","action","kgeoSG","kGOzcv","kpsdNU","kEoFBp","kMwMTN","kMv6JI","kGuDYH","k63SB2","kb6lSQ","kLWn49","kAzted","k8WAf4","kg3NbH","$$css","close","kZKoxP","kzqmXN","kmVPX3","control","kGNEyG","kWkggS","kaIpWk","kMzoRj","kB7OPa","kkrTdU","k1xSpc","kmuXW","kjj79g","kjBf7l","kInvED","k3XXqK","kMeerF","kVAEAm","controlFocused","controlHovered","controlPressed","region","kXwgrk","kOIVth","kkqhue","kLKAdn","kE3dHu","kpe85a","kfzvcC","kY2c9j","risen","clearance","val","undefined","label","onPress","message","showCloseButton","onClose","timeout","className","closeLabel","queue","SnackbarQueue","style","FadingToastQueue","fading","Set","onClosing","key","constructor","maxVisibleToasts","add","setTimeout","delete","listener","isFading","has","subscribeToFading","rac","Map","toasts","options","clear","readableTimeout","set","keys","get","actionPress","closeToast","controlClassName","state","isFocusVisible","isHovered","isPressed","props","Math","max","Snackbar","t0","$","T0","t1","t2","t3","snackbarContent","t4","SnackbarButton","children","ripple","handlers","surface","toast","SnackbarControls","SnackbarToast","content","useFading","Symbol","for","0","1","t5","_temp2","Queue","RACButton","RACToastContent","RACToast"],"sources":["../../../src/components/snackbar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { FocusableElement, ToastRegionProps as RACToastRegionProps, ToastRegionRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useSyncExternalStore } from 'react';\nimport { Button as RACButton, UNSTABLE_Toast as RACToast, UNSTABLE_ToastContent as RACToastContent, UNSTABLE_ToastQueue as RACToastQueue, UNSTABLE_ToastRegion as RACToastRegion, Text } from 'react-aria-components';\nimport { CloseGlyph } from '../../glyphs';\nimport { useBottomEdgeClearance } from '../../hooks/useBottomEdge';\nimport { useRipple } from '../../hooks/useRipple';\nimport '../../styles/layers.stylex';\nimport { layers } from '../../styles/layers.stylex';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, shadows, sizing, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// The snackbar page's brief message at the bottom of the screen, with an\n// optional action beside it and an optional close button after that. The\n// page's container is the inverse surface at a 4dp corner and elevation 3,\n// its supporting text is body-medium in inverse on surface, its action label\n// is inverse primary, and its close icon takes the supporting text's colour.\n// The measurements are the page's too: 8dp of margin from the edges of the\n// screen, 8dp of padding inside the container with another 8dp either side\n// of the message, 14dp above and below on a single line, and between 320 and\n// 576dp wide above the page's 600dp breakpoint — full width below it.\n//\n// One at a time. The page shows a single snackbar and replaces it rather\n// than stacking, so a message added while another is up closes that one —\n// its `onClose` runs — and takes its place. Nothing waits behind it: React\n// Aria's queue, left to itself, kept every message and showed the one it had\n// replaced again once the newer closed, so an Undo could come back long after\n// the thing it undid.\n//\n// React Aria's toast is the behaviour: the region is a landmark that holds\n// the message, moves focus into it for a keyboard, and pauses every timer\n// while it is hovered or focused, so a message never expires while it is\n// being read or acted on.\n//\n// Three things are decided here rather than taken from React Aria or from\n// the page.\n//\n// **The queue is ours, not React Aria's.** React Aria's toast is still\n// `UNSTABLE_`, and `SnackbarQueue` is what keeps that name out of a\n// consumer's code — an upstream rename is this file rather than every call\n// site. It wraps their queue, defaults it to one visible message, and takes\n// the message and its options as one call.\n//\n// **The action and the close button are drawn here rather than through\n// Button and IconButton.** The page colours them inverse primary and inverse\n// on surface, which no variant of either carries, and a colour pushed in\n// from outside through `className` is the merge hazard AGENTS.md describes:\n// StyleX decides between two atomic classes by their order in the compiled\n// stylesheet, not by the order they are applied. Both are React Aria's\n// `Button` with the same ripple and the same state layers, over\n// `currentColor` so each takes the colour the snackbar gives it.\n//\n// **There is no `container` prop.** Every other overlay here takes one,\n// because React Aria's `Modal` and `Popover` accept a portal container, and\n// `src/components/portal-container.test.tsx` is what keeps that true.\n// Its toast region does not: it reads a portal provider that\n// `react-aria-components` does not export, so the region always lands at the\n// end of `<body>`. An app that scopes its StyleX theme to a subtree has to\n// put the theme on `:root` for the snackbar to be drawn in it.\n\n// How long a message is shown when the call site names no `timeout`. The\n// specs page gives no duration, so these come from the snackbar's guidelines\n// and accessibility pages.\n//\n// A message alone leaves after five seconds. The pages allow four to ten, and\n// React Aria's toast docs set five as the least a reader should be given.\n//\n// A call site's own `timeout` is held to the pages' four. A shorter one is\n// lengthened to that, since a message gone in a second cannot be read, and the\n// web gives a reader no setting to slow it down with — the same reason the\n// paragraph below gives. `0` is left alone: it is no timer at all.\n//\n// A message with an action stays until the action is taken or something\n// closes it, as the pages ask of every actionable snackbar. No timer can know\n// how long a reader needs to act: a screen reader user hears the message\n// first and has to reach the region before the action is any use, and the\n// pause while the region is hovered or focused only starts once they have.\n// Android's snackbar can keep shorter defaults because the platform lengthens\n// them from each user's accessibility settings, and the web has no such\n// setting to read.\nconst MESSAGE_MS = 5000;\nconst MINIMUM_MS = 4000;\nconst UNTIL_CLOSED = 0;\n\n// How long a closing snackbar takes to fade, and so how long it stays in the\n// document once something has closed it: `durationShort2`, the token the fade\n// below runs for. A theme that lengthens that token has its fade cut short\n// here, since the queue cannot read a duration out of the stylesheet.\nconst EXIT_MS = 150;\n\n// Below the page's 600dp breakpoint the snackbar runs the width of the\n// screen; above it, it takes between 320 and 576.\nconst WIDE = '@media (min-width: 600px)';\n\n// The page's own is a fade, in and out. It rises a little as it arrives too,\n// which is what the page draws and what says the message came from the edge\n// of the screen rather than appearing over it. It leaves by the fade alone,\n// and quicker than it came, on the curve for something going away: once it is\n// closed there is nothing left on it to read.\nconst rise = \"x15b941j-B\";\nconst fadeOut = \"x1jn504y-B\";\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)';\n\n// The least press area the action keeps, as Button's medium size does. A\n// literal rather than a token, for the reason Button's `TARGET_SIZE` gives: a\n// consumer resizing their controls should not shrink a floor the page states.\nconst TARGET_SIZE = '48px';\nconst _temp = {\n krVfgx: \"xiicpxy\",\n kGO01o: \"xqf7pud\",\n \"$$css\": true\n};\nconst styles = {\n action: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"xun2zgk\",\n kpsdNU: \"xm4btww\",\n kEoFBp: \"x1hmns74\",\n kMwMTN: \"x16bex6i\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n kAzted: \"x1cio8j0\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n close: {\n kZKoxP: \"xbg5kjn\",\n kMwMTN: \"x1girmi0\",\n kzqmXN: \"xoqf9c6\",\n kmVPX3: \"x1717udv\",\n $$css: true\n },\n control: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kjj79g: \"xl56j7k\",\n kjBf7l: \"x14ytart\",\n kInvED: \"xr2mjdv\",\n k3XXqK: \"x9v5kkp x1t137rt\",\n kMeerF: \"x1s780dp\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n controlFocused: {\n kWkggS: \"x1mbb5iu\",\n $$css: true\n },\n controlHovered: {\n kWkggS: \"x930l3l\",\n $$css: true\n },\n controlPressed: {\n kWkggS: \"xsykwg8\",\n $$css: true\n },\n region: {\n kGNEyG: \"x6s0dn4\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXwgrk: \"xdt5ytf\",\n kOIVth: \"x126z3so\",\n krVfgx: \"x1ey2m1c\",\n kkqhue: \"x17y0mx6\",\n k3XXqK: \"x1t137rt\",\n kGO01o: \"x1u7mh7p\",\n kLKAdn: \"xi7mcox\",\n kE3dHu: \"xbpsoft\",\n kpe85a: \"xq5vm52\",\n kfzvcC: \"x47corl\",\n kVAEAm: \"xixxii4\",\n kY2c9j: \"x1bk8fjm\",\n $$css: true\n },\n risen: (clearance: string) => [_temp, {\n \"--x-insetBlockEnd\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(clearance)\n }]\n};\ntype SnackbarAction = {\n /** What the action says. The page gives it a single word where it can. */\n label: string;\n /** Run when the action is pressed, just before the snackbar closes. */\n onPress: () => void;\n};\n\n/** What a snackbar carries: its message, and what may sit beside it. */\ntype SnackbarMessage = {\n action: SnackbarAction | undefined;\n message: ReactNode;\n showCloseButton: boolean;\n};\ntype SnackbarOptions = {\n /**\n * A single action shown after the message. Pressing it runs `onPress` and\n * closes the snackbar, which is what the page draws.\n */\n action?: SnackbarAction;\n /**\n * Run when the snackbar closes, however it was closed: by its timer, its\n * action or close button, `close`, `clear`, or a newer message added in its\n * place. It runs as the snackbar starts to fade out, not once it has gone.\n */\n onClose?: () => void;\n /**\n * Whether a close button is shown at the end. The page draws one for a\n * message a reader may want out of the way before it expires.\n *\n * Named for what it draws rather than `isDismissable`, which on `Sheet`,\n * `Dialog` and React Aria's modals is whether a press outside them closes\n * them — a snackbar has no outside to press.\n * @default false\n */\n showCloseButton?: boolean;\n /**\n * How long the snackbar is shown, in milliseconds. Defaults to five seconds\n * for a message alone. A message with an action defaults to `0` and stays\n * until the action is taken or something closes it, as Material Design asks\n * of an actionable snackbar, since a reader may need longer to reach the\n * action than any timer allows. The timer is paused while the region is\n * hovered or focused, so a message never expires while it is being read.\n *\n * A timer shorter than four seconds, the least Material Design allows, is\n * lengthened to four, since a message gone sooner cannot be read.\n *\n * `0` is the page's indefinite length: the snackbar stays until something\n * closes it. Give one of those an action or `showCloseButton`, or there is no\n * way to be rid of it.\n */\n timeout?: number;\n};\ntype SnackbarProps = {\n /**\n * What a screen reader calls the region holding the snackbar. Left out,\n * React Aria names the region itself: a count of the messages it holds, in\n * the reader's own locale — \"1 notification.\" in English, and one of some\n * thirty languages otherwise. Pass a name only to replace that, and pass a\n * translated one, since whatever is passed is read as written.\n */\n 'aria-label'?: string;\n /** A function may compute the class from the region's render state. */\n className?: RACToastRegionProps<SnackbarMessage>['className'];\n /**\n * What a screen reader calls the button that dismisses a snackbar. It sits\n * here rather than on a message's own options because it does not vary by\n * message, so putting it there would make every `add` call repeat it. Left\n * out, React Aria names it in the reader's locale — \"Close\" in English.\n */\n closeLabel?: string;\n /** The queue the region shows messages from. */\n queue: SnackbarQueue;\n /** A function may compute the style from the region's render state. */\n style?: RACToastRegionProps<SnackbarMessage>['style'];\n} & Omit<RACToastRegionProps<SnackbarMessage>, 'aria-label' | 'children' | 'className' | 'queue' | 'style'>;\n\n// One entry of the queue, as React Aria hands it to the region's render\n// function. Taken from its render state rather than imported from\n// `react-stately`, which this package does not depend on.\ntype SnackbarToastItem = ToastRegionRenderProps<SnackbarMessage>['visibleToasts'][number];\n\n/**\n * React Aria's queue, made to keep a closing snackbar on screen while it\n * fades. React Aria drops a toast from its list the moment it closes, and the\n * region unmounts with its last toast, so a closing strip has no state of its\n * own to be drawn in. Every close reaches `close` here — React Aria's timer and\n * its close button call it on the queue they were handed, as `SnackbarQueue`\n * does — so this one override covers all of them: the strip is marked as\n * fading, and React Aria closes it once the fade has run.\n */\nclass FadingToastQueue extends RACToastQueue<SnackbarMessage> {\n // The strips fading out.\n readonly #fading = new Set<string>();\n readonly #listeners = new Set<() => void>();\n\n // Run as a strip starts to close — see `SnackbarQueue`.\n readonly #onClosing: (key: string) => void;\n constructor(onClosing: (key: string) => void) {\n // One at a time, which is what the page shows. React Aria shows the\n // newest, so a message added while another is up or fading takes its\n // place at once, and the older one runs out its fade unseen.\n super({\n maxVisibleToasts: 1\n });\n this.#onClosing = onClosing;\n }\n\n /** Starts a toast fading, and closes it once the fade has run. */\n override close(key: string) {\n this.#onClosing(key);\n this.#fading.add(key);\n setTimeout(() => {\n this.#fading.delete(key);\n super.close(key);\n }, EXIT_MS);\n for (const listener of this.#listeners) {\n listener();\n }\n }\n\n /** Whether a toast is fading out. */\n isFading(key: string) {\n return this.#fading.has(key);\n }\n\n /** Calls `listener` whenever a toast starts to fade. */\n subscribeToFading(listener: () => void) {\n this.#listeners.add(listener);\n return () => {\n this.#listeners.delete(listener);\n };\n }\n}\n\n/**\n * The queue a snackbar is shown from. Make one where the app can reach it —\n * a module of its own is the usual place — mount `Snackbar` once with it,\n * and call `add` from anywhere.\n *\n * ```ts\n * const messages = new Snackbar.Queue()\n * messages.add('Label', { action: { label: 'Undo', onPress: undo } })\n * ```\n *\n * It wraps React Aria's toast queue rather than exposing it, which is what\n * keeps that API's `UNSTABLE_` name out of a consumer's code.\n */\nclass SnackbarQueue {\n /**\n * React Aria's queue, which `Snackbar` subscribes to. Not part of the\n * package's API — read it and an upstream release may break the call site.\n */\n readonly rac: RACToastQueue<SnackbarMessage>;\n\n // The snackbars not yet closed, each with its `onClose`, which `add` and\n // `clear` close. Kept here because React Aria keeps its own list private,\n // and its own `clear` empties that list without running a single `onClose`.\n readonly #open = new Map<string, (() => void) | undefined>();\n\n // `rac` as the class it is, which `rac` itself is not declared as so that\n // the subclass stays out of the package's API.\n readonly #toasts: FadingToastQueue;\n constructor() {\n this.#toasts = new FadingToastQueue(key => {\n this.#closing(key);\n });\n this.rac = this.#toasts;\n }\n\n /**\n * Shows a message in place of the one on screen, and returns the key that\n * closes it. The message it replaces is closed, so its `onClose` runs, and\n * it does not come back.\n */\n add(message: ReactNode, options: SnackbarOptions = {}) {\n const {\n action,\n onClose,\n showCloseButton = false,\n timeout\n } = options;\n this.clear();\n const key = this.#toasts.add({\n action,\n message,\n showCloseButton\n }, {\n timeout: readableTimeout(timeout ?? (action === undefined ? MESSAGE_MS : UNTIL_CLOSED))\n });\n this.#open.set(key, onClose);\n return key;\n }\n\n /** Closes the snackbar on screen, running its `onClose`. */\n clear() {\n // Each close runs that message's `onClose`, which deletes its own key\n // from the map — the entry being visited, which a Map allows.\n for (const key of this.#open.keys()) {\n this.#toasts.close(key);\n }\n }\n\n /** Closes one snackbar, by the key `add` returned. */\n close(key: string) {\n this.#toasts.close(key);\n }\n\n // A snackbar starting to close, however it was closed — its timer runs\n // inside React Aria's queue, past this one — leaves the open map and runs\n // its `onClose` on the way out.\n #closing(key: string) {\n const onClose = this.#open.get(key);\n if (this.#open.delete(key)) {\n onClose?.();\n }\n }\n}\n\n// The three handlers the snackbar hands to something below it, each built by\n// a call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\nfunction actionPress(action: SnackbarAction, close: () => void) {\n return () => {\n action.onPress();\n close();\n };\n}\nfunction closeToast(queue: SnackbarQueue, key: string) {\n return () => {\n queue.close(key);\n };\n}\n\n// A control's classes, from its own render state — see `controlFocused`.\nfunction controlClassName(style: stylex.StyleXStyles) {\n return (state: {\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n }) => stylex.props(styles.control, style, state.isHovered && styles.controlHovered, state.isFocusVisible && styles.controlFocused, state.isPressed && styles.controlPressed).className ?? '';\n}\n\n// A timer the reader has time to read by — see the durations at the top of\n// this file. Only a timer is held to the minimum: React Aria runs none for `0`\n// or below, which keep the message until something closes it.\nfunction readableTimeout(timeout: number) {\n return timeout > UNTIL_CLOSED ? Math.max(timeout, MINIMUM_MS) : timeout;\n}\n\n/**\n * A brief message at the bottom of the screen, with an optional action. Mount\n * one of these with a `Snackbar.Queue`, and call the queue's `add` to show a\n * message from anywhere.\n *\n * ```tsx\n * const messages = new Snackbar.Queue()\n *\n * <Snackbar queue={messages} />\n * ```\n *\n * The region is portalled to the end of `<body>` and renders nothing while\n * the queue is empty. It is one region rather than one per message, so mount\n * it once, near the root.\n *\n * The call site's `className` and `style` land on that region, which is the\n * element a layout positions.\n *\n * While a full-screen `Dialog` or a `Sheet` with a footer is open, the region\n * rises to sit above those actions rather than over them, since they share\n * the bottom edge of the window and the snackbar is drawn above both.\n *\n * While a `Dialog` or a `Sheet` is open, Tab stays inside it and never\n * reaches the snackbar. F6 does: React Aria moves focus between landmarks\n * with it, so it lands on the region, Tab then reaches the message and its\n * action, and tabbing on past the last of them leads back into the dialog. A\n * message with an action stays until it is answered, so a keyboard user has\n * the time that route takes.\n */\nfunction Snackbar({\n closeLabel,\n queue,\n ...props\n}: RefAttributes<HTMLDivElement> & SnackbarProps) {\n const clearance = useBottomEdgeClearance();\n return <RACToastRegion<SnackbarMessage> queue={queue.rac} {...props} {...mergeStatefulStyles(stylex.props(styles.region, clearance > 0 && styles.risen(`${clearance}px`)), props)}>\n {snackbarContent(queue, closeLabel)}\n </RACToastRegion>;\n}\n\n/**\n * One of the snackbar's two controls. React Aria's `Button` rather than the\n * library's, for the colour reason in the comment at the top of this file;\n * the ripple and the state layers are the same ones every other control\n * here draws, over `currentColor`.\n */\nfunction SnackbarButton({\n children,\n style,\n ...props\n}: {\n 'aria-label'?: string;\n children: ReactNode;\n onPress?: () => void;\n slot?: string;\n style: stylex.StyleXStyles;\n}) {\n const ripple = useRipple<FocusableElement>();\n return <RACButton {...ripple.handlers} {...props} className={controlClassName(style)}>\n {children}\n {ripple.surface}\n </RACButton>;\n}\nfunction snackbarContent(queue: SnackbarQueue, closeLabel: string | undefined) {\n return ({\n toast\n }: {\n toast: SnackbarToastItem;\n }) => <SnackbarToast close={closeToast(queue, toast.key)} closeLabel={closeLabel} queue={queue} toast={toast} />;\n}\n\n/**\n * The action, the close button, or nothing, after the message — together, so\n * they move beneath it together.\n */\nfunction SnackbarControls({\n action,\n close,\n closeLabel,\n fading,\n showCloseButton\n}: {\n action: SnackbarAction | undefined;\n close: () => void;\n closeLabel: string | undefined;\n fading: boolean;\n showCloseButton: boolean;\n}) {\n if (action === undefined && !showCloseButton) {\n return null;\n }\n return <div className=\"x6s0dn4 x9f619 x78zum5 x2lah0s xvc5jky\">\n {action === undefined ? null :\n // Nothing on a fading strip answers a press: its action has already\n // run, and an Undo pressed twice would undo twice.\n <SnackbarButton onPress={fading ? undefined : actionPress(action, close)} style={styles.action}>\n {action.label}\n </SnackbarButton>}\n {showCloseButton ? <SnackbarButton aria-label={closeLabel} slot=\"close\" style={styles.close}>\n <CloseGlyph className=\"xxk0z11 xvy4d1p\" />\n </SnackbarButton> : null}\n </div>;\n}\n\n/** One snackbar: its message, then whatever sits after it. */\nfunction SnackbarToast({\n close,\n closeLabel,\n queue,\n toast\n}: {\n close: () => void;\n closeLabel: string | undefined;\n queue: SnackbarQueue;\n toast: SnackbarToastItem;\n}) {\n const {\n action,\n message,\n showCloseButton\n } = toast.content;\n const fading = useFading(queue, toast.key);\n return <RACToast toast={toast} {...{\n 0: {\n className: \"x6s0dn4 x1n1nwrg x1u6grsq x1dwmuk9 x16dv9tl x1c5gpgi x1w1tqly x1tfhd1 xx61lck x13rsnn2 x1udv5rz x9f619 x78zum5 x1a02dak xh8yej3 x1x1rfll xlx31pv x1dry9sr xeuugli xuq8xha x1ulcdur xr2mjdv x9v5kkp x1t137rt x1s780dp xt970qd xn60lsn x67bb7w\"\n },\n 1: {\n className: \"x6s0dn4 x1c5gpgi x1w1tqly x1tfhd1 xx61lck x13rsnn2 x1udv5rz x9f619 x78zum5 x1a02dak xh8yej3 x1x1rfll xlx31pv x1dry9sr xeuugli xuq8xha x1ulcdur xr2mjdv x9v5kkp x1t137rt x1s780dp xt970qd xn60lsn x1vhuh8u x1u6grsq x10e4vud xxp0q0x xi22y15 x47corl\"\n }\n }[!!fading << 0]}>\n <RACToastContent className=\"x9f619 x1girmi0 x4pfjvb x1iyjqo2 xpo2rfv x193rfdd x1hews6w xkjl1po xn43zvd xv61bfh xz158ff xeuugli xj0a0fe xxlmvz2\">\n <Text slot=\"title\">{message}</Text>\n </RACToastContent>\n <SnackbarControls action={action} close={close} closeLabel={closeLabel} fading={fading} showCloseButton={showCloseButton} />\n </RACToast>;\n}\n\n/**\n * Whether a snackbar is fading out of its queue. `rac` is always the queue\n * that fades, but is declared as React Aria's, so it is narrowed back here.\n */\nfunction useFading(queue: SnackbarQueue, key: string) {\n const toasts = queue.rac instanceof FadingToastQueue ? queue.rac : undefined;\n return useSyncExternalStore(listener => toasts?.subscribeToFading(listener) ?? (() => {}), () => toasts?.isFading(key) ?? false);\n}\nSnackbar.Queue = SnackbarQueue;\n\n// The queue is reached as `Snackbar.Queue` rather than exported beside the\n// component: this file would otherwise export something that is not a\n// component, which is what turns fast refresh off for it.\nexport type { SnackbarAction, SnackbarMessage, SnackbarOptions, SnackbarProps, SnackbarQueue, ToastRegionRenderProps as SnackbarRegionRenderProps };\nexport default Snackbar;"],"mappings":";;;;;;;;;;;AAoFA,MAAMQ,aAAa;AACnB,MAAMC,aAAa;AACnB,MAAMC,eAAe;AAMrB,MAAMC,UAAU;AAwBhB,MAAMC,QAAQ;CACZC,QAAQ;CACRC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,SAAS;CACbC,QAAQ;EACNC,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,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AAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAM;EAAAN,EAAA,MAAAY;EAAAZ,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,OAZNqB;AAYM;;;;;AAOf,SAAAL,UAAAtD,OAAAO,KAAA;CAAA,MAAA+B,IAAAhH,EAAA,CAAA;CACE,MAAA6F,SAAenB,MAAKiB,eAAgBd,mBAAmBH,MAAKiB,MAA7C1B,KAAAA;CAA8D,IAAA8C;CAAA,IAAAC,EAAA,OAAAnB,QAAA;EACjDkB,MAAAxB,aAAYM,QAAMH,kBAAoBH,QAAsB,KAAhD+C;EAAiDtB,EAAA,KAAAnB;EAAAmB,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,IAAAE;CAAA,IAAAF,EAAA,OAAA/B,OAAA+B,EAAA,OAAAnB,QAAA;EAAEqB,WAAMrB,QAAML,SAAWP,GAAY,KAA7B;EAA8B+B,EAAA,KAAA/B;EAAA+B,EAAA,KAAAnB;EAAAmB,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAxH9G,qBAAqB6G,IAA+DG,EAAoC;AAAC;AAFlI,SAAAoB,SAAA,CAAA;AAIAxB,SAASyB,QAAQ5D"}
|
|
@@ -254,7 +254,7 @@ function SplitButtonAction(props) {
|
|
|
254
254
|
* of alternatives its children describe.
|
|
255
255
|
*/
|
|
256
256
|
function SplitButtonMenu(t0) {
|
|
257
|
-
const $ = c(
|
|
257
|
+
const $ = c(26);
|
|
258
258
|
const { "aria-label": label, children, container, defaultOpen: t1, isDisabled, isOpen, onAction, onOpenChange } = t0;
|
|
259
259
|
const defaultOpen = t1 === void 0 ? false : t1;
|
|
260
260
|
const { size, variant } = useContext(SplitButtonContext);
|
|
@@ -281,62 +281,74 @@ function SplitButtonMenu(t0) {
|
|
|
281
281
|
const item = t3;
|
|
282
282
|
let t4;
|
|
283
283
|
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
284
|
-
t4 =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
284
|
+
t4 = {
|
|
285
|
+
0: { className: "x12w9bfk x7p49u4 xkzkux9 x11xpdln xpc4ca7" },
|
|
286
|
+
1: { className: "x12w9bfk xkzkux9 x11xpdln xpc4ca7 x19jd1h0" }
|
|
287
|
+
};
|
|
288
288
|
$[6] = t4;
|
|
289
289
|
} else t4 = $[6];
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
const t5 = t4[!!open << 0];
|
|
291
|
+
let t6;
|
|
292
|
+
if ($[7] !== t5) {
|
|
293
|
+
t6 = /* @__PURE__ */ jsx(ChevronDownGlyph, {
|
|
294
|
+
height: "1em",
|
|
295
|
+
width: "1em",
|
|
296
|
+
...t5
|
|
297
|
+
});
|
|
298
|
+
$[7] = t5;
|
|
299
|
+
$[8] = t6;
|
|
300
|
+
} else t6 = $[8];
|
|
301
|
+
let t7;
|
|
302
|
+
if ($[9] !== isDisabled || $[10] !== label || $[11] !== t6 || $[12] !== variant) {
|
|
303
|
+
t7 = /* @__PURE__ */ jsx(Button$1, {
|
|
293
304
|
"aria-label": label,
|
|
294
305
|
isDisabled,
|
|
295
306
|
variant,
|
|
296
|
-
children:
|
|
307
|
+
children: t6
|
|
297
308
|
});
|
|
298
|
-
$[
|
|
299
|
-
$[
|
|
300
|
-
$[
|
|
301
|
-
$[
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
309
|
+
$[9] = isDisabled;
|
|
310
|
+
$[10] = label;
|
|
311
|
+
$[11] = t6;
|
|
312
|
+
$[12] = variant;
|
|
313
|
+
$[13] = t7;
|
|
314
|
+
} else t7 = $[13];
|
|
315
|
+
let t8;
|
|
316
|
+
if ($[14] !== item || $[15] !== t7) {
|
|
317
|
+
t8 = /* @__PURE__ */ jsx(ButtonGroupItemContext, {
|
|
306
318
|
value: item,
|
|
307
|
-
children:
|
|
319
|
+
children: t7
|
|
308
320
|
});
|
|
309
|
-
$[
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
312
|
-
} else
|
|
313
|
-
let
|
|
314
|
-
if ($[
|
|
315
|
-
|
|
321
|
+
$[14] = item;
|
|
322
|
+
$[15] = t7;
|
|
323
|
+
$[16] = t8;
|
|
324
|
+
} else t8 = $[16];
|
|
325
|
+
let t9;
|
|
326
|
+
if ($[17] !== children || $[18] !== container || $[19] !== onAction) {
|
|
327
|
+
t9 = /* @__PURE__ */ jsx(Menu$1.Content, {
|
|
316
328
|
align: "end",
|
|
317
329
|
container,
|
|
318
330
|
onAction,
|
|
319
331
|
children
|
|
320
332
|
});
|
|
321
|
-
$[
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
$[
|
|
325
|
-
} else
|
|
326
|
-
let
|
|
327
|
-
if ($[
|
|
328
|
-
|
|
333
|
+
$[17] = children;
|
|
334
|
+
$[18] = container;
|
|
335
|
+
$[19] = onAction;
|
|
336
|
+
$[20] = t9;
|
|
337
|
+
} else t9 = $[20];
|
|
338
|
+
let t10;
|
|
339
|
+
if ($[21] !== changeOpen || $[22] !== open || $[23] !== t8 || $[24] !== t9) {
|
|
340
|
+
t10 = /* @__PURE__ */ jsxs(Menu$1, {
|
|
329
341
|
isOpen: open,
|
|
330
342
|
onOpenChange: changeOpen,
|
|
331
|
-
children: [
|
|
343
|
+
children: [t8, t9]
|
|
332
344
|
});
|
|
333
|
-
$[
|
|
334
|
-
$[
|
|
335
|
-
$[
|
|
336
|
-
$[
|
|
337
|
-
$[
|
|
338
|
-
} else
|
|
339
|
-
return
|
|
345
|
+
$[21] = changeOpen;
|
|
346
|
+
$[22] = open;
|
|
347
|
+
$[23] = t8;
|
|
348
|
+
$[24] = t9;
|
|
349
|
+
$[25] = t10;
|
|
350
|
+
} else t10 = $[25];
|
|
351
|
+
return t10;
|
|
340
352
|
}
|
|
341
353
|
function trailingItem(size, isOpen) {
|
|
342
354
|
const padding = TRAILING_PADDING[size];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","createContext","useContext","useState","mergeStyles","radii","sizing","Menu","corners","shape","start","end","undefined","kT0f0o","$$css","kVL7Gh","kfmiAY","krdFHd","val","leading","lg","kwRFfy","kZCmMZ","md","xl","xs","xxl","chevron","kGuDYH","trailing","padding","TRAILING_PADDING","CLOSED_OFFSET","INNER","sm","ROUND","controlLg","controlSm","controlXl","controlXs","controlXxl","INNER_ACTIVE","children","container","defaultOpen","isDisabled","isOpen","onAction","onOpenChange","className","size","style","variant","SplitButtonContext","isActive","state","isHovered","isFocusVisible","isPressed","leadingItem","shift","styles","SplitButton","t0","$","label","ref","t1","t2","t3","context","t4","t5","t6","SplitButtonAction","props","item","SplitButtonMenu","ownOpen","setOwnOpen","open","next","changeOpen","trailingItem","Symbol","for","t7","t8","offset","Action","RACGroup","Button","Menu"],"sources":["../../../src/components/split-button/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { Key } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useCallback, useContext, useMemo, useState } from 'react';\nimport { Group as RACGroup } from 'react-aria-components';\nimport type { ButtonState } from '../../button';\nimport type { ButtonGroupItem, GroupSize } from '../../button/context';\nimport type { ButtonProps, ButtonSize } from '../button';\nimport { ButtonGroupItemContext } from '../../button/context';\nimport { ChevronDownGlyph } from '../../glyphs';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\nimport Button from '../button';\nimport Menu from '../menu';\n\n// The split button page's split button: an action and the menu of\n// alternatives beside it, drawn as two Buttons 2dp apart — the page calls it\n// a special connected button group. The outer ends keep the button's round,\n// and the two edges that meet take the inner corner the size gives them,\n// 4dp up to the page's M, 8dp at L and 12dp at XL, opening out to 8dp, 12dp\n// and 20dp while either half is hovered, focused or pressed. The values are\n// the page's size token sets, read from Material Design's own split button\n// tokens; the 20dp corner, and the paddings that are not steps of the\n// spacing scale, are written out.\n//\n// **The leading half is a Button**, with an icon, a label or both, and the\n// page's own padding either side of what it holds — 12dp and 10dp at XS, for\n// instance, where a lone Button takes 16dp on both.\n//\n// **The trailing half is the menu's trigger**: a Button holding the down\n// chevron at the size's icon size, 22dp up to 50dp, with the menu below its\n// end edge. The chevron sits a pixel or more toward the start while the menu\n// is closed — the page's optical centring, 1dp to 6dp by size — and centres\n// once it opens, when the inner corners round off entirely. The page keeps\n// the colours as they are while the menu is open and lays the pressed state\n// layer over them, which is what React Aria's report of the trigger as\n// pressed for as long as its menu is open already draws.\n//\n// Both halves take the variant the root names, out of Button's four with a\n// container — the page gives text no split button.\n\n// Each half's corners on each side, set from the half and its state.\nconst corners = {\n shape: (start: string, end: string) => [end !== undefined && {\n kT0f0o: end != null ? \"x1wsjk4f\" : \"\",\n $$css: true\n }, start !== undefined && {\n kVL7Gh: start != null ? \"x1oq9ryg\" : \"\",\n $$css: true\n }, end !== undefined && {\n kfmiAY: end != null ? \"xbsomw4\" : \"\",\n $$css: true\n }, start !== undefined && {\n krdFHd: start != null ? \"x6pmj1i\" : \"\",\n $$css: true\n }, {\n \"--x-borderEndEndRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-borderEndStartRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start),\n \"--x-borderStartEndRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-borderStartStartRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\n\n// The leading half's padding either side of what it holds.\nconst leading = {\n lg: {\n kwRFfy: \"xdndrey\",\n kZCmMZ: \"x1kdgbu8\",\n $$css: true\n },\n md: {\n kwRFfy: \"xk163s\",\n kZCmMZ: \"x10rdx38\",\n $$css: true\n },\n xl: {\n kwRFfy: \"x15zmtp0\",\n kZCmMZ: \"x1oiqv2n\",\n $$css: true\n },\n xs: {\n kwRFfy: \"x2vl965\",\n kZCmMZ: \"xwde665\",\n $$css: true\n },\n xxl: {\n kwRFfy: \"xli2wwf\",\n kZCmMZ: \"x7vhb2i\",\n $$css: true\n }\n};\n\n// The trailing half's chevron, at the size's icon size.\nconst chevron = {\n lg: {\n kGuDYH: \"x1ewwscv\",\n $$css: true\n },\n md: {\n kGuDYH: \"x1i1m3gp\",\n $$css: true\n },\n xl: {\n kGuDYH: \"x155jak9\",\n $$css: true\n },\n xs: {\n kGuDYH: \"x1i1m3gp\",\n $$css: true\n },\n xxl: {\n kGuDYH: \"xermeyz\",\n $$css: true\n }\n};\n\n// The trailing half's padding: centred once the menu is open, and moved\n// toward the start by the page's offset while it is closed.\nconst trailing = {\n padding: (start: string, end: string) => [end !== undefined && {\n kwRFfy: end != null ? \"x120eax6\" : \"\",\n $$css: true\n }, start !== undefined && {\n kZCmMZ: start != null ? \"xnvo3vl\" : \"\",\n $$css: true\n }, {\n \"--x-paddingInlineEnd\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-paddingInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\n\n// The trailing half's padding either side of the chevron, and how far the\n// chevron sits toward the start while the menu is closed.\nconst TRAILING_PADDING = {\n lg: 15,\n md: 13,\n xl: 29,\n xs: 13,\n xxl: 43\n};\nconst CLOSED_OFFSET = {\n lg: 2,\n md: 1,\n xl: 3,\n xs: 1,\n xxl: 6\n};\n\n// The corner where the halves meet, at rest and while a half is hovered,\n// focused or pressed.\nconst INNER = {\n lg: radii.xs,\n md: radii.xs,\n xl: radii.sm,\n xs: radii.xs,\n xxl: radii.md\n};\n\n// The round end at each size: half the button's height. Not the pill's\n// 9999px: CSS scales every corner of a box down together when two on one\n// side add up to more than the side is long, so a 9999px end beside an 8px\n// inner corner shrank the inner one to nothing. Half the height fits as\n// written. A label that wraps makes a button taller than this, and its ends\n// a little less than round.\nconst ROUND = {\n lg: `calc(${sizing.controlLg} / 2)`,\n md: `calc(${sizing.controlSm} / 2)`,\n xl: `calc(${sizing.controlXl} / 2)`,\n xs: `calc(${sizing.controlXs} / 2)`,\n xxl: `calc(${sizing.controlXxl} / 2)`\n};\nconst INNER_ACTIVE = {\n lg: radii.md,\n md: radii.md,\n xl: '20px',\n xs: radii.sm,\n xxl: '20px'\n};\n\n// Omitted form by form: ButtonProps is a union of the plain, link and toggle\n// forms, and an Omit of the whole union keeps only the keys all three share,\n// which would let a link's and a toggle's props back together.\ntype SplitButtonActionProps = (ButtonProps extends infer Props ? Props extends unknown ? Omit<Props, 'shape' | 'size' | 'variant'> : never : never) & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\ntype SplitButtonMenuProps = {\n /** What the menu offers, in words: the trailing half is an icon alone. */\n 'aria-label': string;\n /** The menu's items, as `Menu.Item`s and the rest of Menu's parts. */\n children: ReactNode;\n /**\n * Where the menu is portalled to. Defaults to the container of the\n * `ThemeScope` around it, or to the end of `<body>` where there is none. A\n * subtree themed through the `themeScope` class has no container of its own,\n * so point this inside it, or it renders outside and keeps the page's tokens.\n */\n container?: Element;\n /**\n * Whether the menu starts open, when it keeps its own state.\n * @default false\n */\n defaultOpen?: boolean;\n /** Whether the trailing half can be pressed. */\n isDisabled?: boolean;\n /** Whether the menu is open, when the call site holds the state. */\n isOpen?: boolean;\n /** Called with an item's `id` when it is chosen. */\n onAction?: (key: Key) => void;\n /** Called when the menu opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n};\ntype SplitButtonProps = RefAttributes<HTMLDivElement> & {\n /** What the pair is, in words, for the group around the two halves. */\n 'aria-label'?: string;\n /** The two halves: a `SplitButton.Action`, then a `SplitButton.Menu`. */\n children: ReactNode;\n /** The class for the group around the two halves. */\n className?: string;\n /**\n * The size both halves take, as Button's: `xs` to `xxl`.\n * @default 'md'\n */\n size?: ButtonSize;\n /** The style for the group around the two halves. */\n style?: CSSProperties;\n /**\n * The colour style both halves take: Button's four with a container.\n * @default 'filled'\n */\n variant?: SplitButtonVariant;\n};\ntype SplitButtonVariant = 'elevated' | 'filled' | 'outlined' | 'tonal';\n\n// What the root hands its two halves.\nconst SplitButtonContext = createContext<{\n size: GroupSize;\n variant: SplitButtonVariant;\n}>({\n size: 'md',\n variant: 'filled'\n});\n\n// Whether a half shows the corner it opens out to: while it is hovered,\n// focused or pressed.\nfunction isActive(state: ButtonState) {\n return state.isHovered || state.isFocusVisible || state.isPressed;\n}\n\n// The leading half's part: its padding, its round start and the inner\n// corner at its end.\nfunction leadingItem(size: GroupSize): ButtonGroupItem {\n return {\n shift: 0,\n size,\n styles: (state: ButtonState) => [leading[size], corners.shape(ROUND[size], isActive(state) ? INNER_ACTIVE[size] : INNER[size])]\n };\n}\n\n/**\n * An action and a menu of alternatives beside it, drawn as one control.\n *\n * ```tsx\n * <SplitButton>\n * <SplitButton.Action onPress={save}>Label</SplitButton.Action>\n * <SplitButton.Menu aria-label=\"More options\">\n * <Menu.Item id=\"first\">First item</Menu.Item>\n * </SplitButton.Menu>\n * </SplitButton>\n * ```\n *\n * The call site's `className`, `style` and `ref` land on the group around\n * the two halves.\n */\nfunction SplitButton({\n 'aria-label': label,\n children,\n className,\n ref,\n size = 'md',\n style,\n variant = 'filled'\n}: SplitButtonProps) {\n const context = useMemo(() => ({\n size,\n variant\n }), [size, variant]);\n return <SplitButtonContext value={context}>\n <RACGroup aria-label={label} ref={ref} {...mergeStyles({\n className: \"x6s0dn4 x9f619 x3nfvp2 x14qo01y\"\n }, {\n className,\n style\n })}>\n {children}\n </RACGroup>\n </SplitButtonContext>;\n}\n\n/**\n * The split button's leading half: a Button, with an icon, a label or both,\n * in the root's size and variant.\n */\nfunction SplitButtonAction(props: SplitButtonActionProps) {\n const {\n size,\n variant\n } = useContext(SplitButtonContext);\n const item = useMemo(() => leadingItem(size), [size]);\n return <ButtonGroupItemContext value={item}>\n <Button {...props} variant={variant} />\n </ButtonGroupItemContext>;\n}\n\n/**\n * The split button's trailing half: the down chevron, which opens the menu\n * of alternatives its children describe.\n */\nfunction SplitButtonMenu({\n 'aria-label': label,\n children,\n container,\n defaultOpen = false,\n isDisabled,\n isOpen,\n onAction,\n onOpenChange\n}: SplitButtonMenuProps) {\n const {\n size,\n variant\n } = useContext(SplitButtonContext);\n const [ownOpen, setOwnOpen] = useState(defaultOpen);\n const open = isOpen ?? ownOpen;\n const changeOpen = useCallback((next: boolean) => {\n if (isOpen === undefined) {\n setOwnOpen(next);\n }\n onOpenChange?.(next);\n }, [isOpen, onOpenChange]);\n const item = useMemo(() => trailingItem(size, open), [size, open]);\n return <Menu isOpen={open} onOpenChange={changeOpen}>\n <ButtonGroupItemContext value={item}>\n <Button aria-label={label} isDisabled={isDisabled} variant={variant}>\n <ChevronDownGlyph height=\"1em\" width=\"1em\" />\n </Button>\n </ButtonGroupItemContext>\n <Menu.Content align=\"end\" container={container} onAction={onAction}>\n {children}\n </Menu.Content>\n </Menu>;\n}\n\n// The trailing half's part: its chevron and padding, the inner corner at its\n// start, and its round end — and while the menu is open, the chevron centred\n// and the inner corner rounded off.\nfunction trailingItem(size: GroupSize, isOpen: boolean): ButtonGroupItem {\n const padding = TRAILING_PADDING[size];\n const offset = isOpen ? 0 : CLOSED_OFFSET[size];\n return {\n shift: 0,\n size,\n styles: (state: ButtonState) => [chevron[size], trailing.padding(`${padding - offset}px`, `${padding + offset}px`), corners.shape(isOpen ? ROUND[size] : isActive(state) ? INNER_ACTIVE[size] : INNER[size], ROUND[size])]\n };\n}\nSplitButton.Action = SplitButtonAction;\nSplitButton.Menu = SplitButtonMenu;\nexport type { SplitButtonActionProps, SplitButtonMenuProps, SplitButtonProps, SplitButtonVariant };\nexport { SplitButtonAction, SplitButtonMenu };\nexport default SplitButton;"],"mappings":";;;;;;;;;;;;AA6CA,MAAMQ,UAAU,EACdC,QAAQC,OAAeC,QAAgB;CAACA,QAAQC,KAAAA,KAAa;EAC3DC,QAAQF,OAAO,OAAO,aAAa;EACnCG,OAAO;CACT;CAAGJ,UAAUE,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Context","useContext","useState","mergeStyles","radii","sizing","Menu","corners","shape","start","end","undefined","kT0f0o","$$css","kVL7Gh","kfmiAY","krdFHd","val","leading","lg","kwRFfy","kZCmMZ","md","xl","xs","xxl","chevron","kGuDYH","trailing","padding","TRAILING_PADDING","CLOSED_OFFSET","INNER","sm","ROUND","controlLg","controlSm","controlXl","controlXs","controlXxl","INNER_ACTIVE","children","container","defaultOpen","isDisabled","isOpen","onAction","onOpenChange","className","size","style","variant","SplitButtonContext","isActive","state","isHovered","isFocusVisible","isPressed","leadingItem","shift","styles","SplitButton","t0","$","label","ref","t1","t2","t3","context","t4","t5","t6","SplitButtonAction","props","item","SplitButtonMenu","ownOpen","setOwnOpen","open","next","changeOpen","trailingItem","Symbol","for","0","1","t7","t8","t9","t10","offset","Action","RACGroup","Button","Menu"],"sources":["../../../src/components/split-button/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { Key } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useCallback, useContext, useMemo, useState } from 'react';\nimport { Group as RACGroup } from 'react-aria-components';\nimport type { ButtonState } from '../../button';\nimport type { ButtonGroupItem, GroupSize } from '../../button/context';\nimport type { ButtonProps, ButtonSize } from '../button';\nimport { ButtonGroupItemContext } from '../../button/context';\nimport { ChevronDownGlyph } from '../../glyphs';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { motion, radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\nimport Button from '../button';\nimport Menu from '../menu';\n\n// The split button page's split button: an action and the menu of\n// alternatives beside it, drawn as two Buttons 2dp apart — the page calls it\n// a special connected button group. The outer ends keep the button's round,\n// and the two edges that meet take the inner corner the size gives them,\n// 4dp up to the page's M, 8dp at L and 12dp at XL, opening out to 8dp, 12dp\n// and 20dp while either half is hovered, focused or pressed. The values are\n// the page's size token sets, read from Material Design's own split button\n// tokens; the 20dp corner, and the paddings that are not steps of the\n// spacing scale, are written out.\n//\n// **The leading half is a Button**, with an icon, a label or both, and the\n// page's own padding either side of what it holds — 12dp and 10dp at XS, for\n// instance, where a lone Button takes 16dp on both.\n//\n// **The trailing half is the menu's trigger**: a Button holding the down\n// chevron at the size's icon size, 22dp up to 50dp, with the menu below its\n// end edge. The chevron sits a pixel or more toward the start while the menu\n// is closed — the page's optical centring, 1dp to 6dp by size — and centres\n// once it opens, when the inner corners round off entirely.\n//\n// **The trailing half is selected while its menu is open**, as the page\n// draws it: the inner corners round off and the chevron turns 180° to point\n// up, turning back as the menu closes. Both are read from the menu's open\n// state, which the half is handed, rather than from React Aria's report of\n// the trigger as pressed for as long as its menu is open — a Button draws\n// nothing for that report (see src/button). The turn takes the standard\n// easing on the short step the surface it opens arrives on, as Select's\n// chevron does, and happens at once for a reader who asks for reduced\n// motion. \"Selected\" is the picture alone: the button announces the open\n// menu through `aria-expanded`, and no `aria-pressed` beside it, which would\n// make it a toggle.\n//\n// The page keeps the colours as\n// they are while it is open and lays the pressed state layer over them; here\n// the colours stay at rest with no layer over them, and the hover layer\n// still answers the pointer, as every overlay trigger in the library does —\n// a Button draws its pressed layer and corner for a press alone, not for the\n// open menu React Aria also reports as pressed (see src/button). The\n// difference from the page is a state layer's 10% over the container.\n//\n// Both halves take the variant the root names, out of Button's four with a\n// container — the page gives text no split button.\n\n// Each half's corners on each side, set from the half and its state.\nconst corners = {\n shape: (start: string, end: string) => [end !== undefined && {\n kT0f0o: end != null ? \"x1wsjk4f\" : \"\",\n $$css: true\n }, start !== undefined && {\n kVL7Gh: start != null ? \"x1oq9ryg\" : \"\",\n $$css: true\n }, end !== undefined && {\n kfmiAY: end != null ? \"xbsomw4\" : \"\",\n $$css: true\n }, start !== undefined && {\n krdFHd: start != null ? \"x6pmj1i\" : \"\",\n $$css: true\n }, {\n \"--x-borderEndEndRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-borderEndStartRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start),\n \"--x-borderStartEndRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-borderStartStartRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\n\n// The leading half's padding either side of what it holds.\nconst leading = {\n lg: {\n kwRFfy: \"xdndrey\",\n kZCmMZ: \"x1kdgbu8\",\n $$css: true\n },\n md: {\n kwRFfy: \"xk163s\",\n kZCmMZ: \"x10rdx38\",\n $$css: true\n },\n xl: {\n kwRFfy: \"x15zmtp0\",\n kZCmMZ: \"x1oiqv2n\",\n $$css: true\n },\n xs: {\n kwRFfy: \"x2vl965\",\n kZCmMZ: \"xwde665\",\n $$css: true\n },\n xxl: {\n kwRFfy: \"xli2wwf\",\n kZCmMZ: \"x7vhb2i\",\n $$css: true\n }\n};\n\n// The trailing half's chevron, at the size's icon size.\nconst chevron = {\n lg: {\n kGuDYH: \"x1ewwscv\",\n $$css: true\n },\n md: {\n kGuDYH: \"x1i1m3gp\",\n $$css: true\n },\n xl: {\n kGuDYH: \"x155jak9\",\n $$css: true\n },\n xs: {\n kGuDYH: \"x1i1m3gp\",\n $$css: true\n },\n xxl: {\n kGuDYH: \"xermeyz\",\n $$css: true\n }\n};\n\n// The trailing half's padding: centred once the menu is open, and moved\n// toward the start by the page's offset while it is closed.\nconst trailing = {\n padding: (start: string, end: string) => [end !== undefined && {\n kwRFfy: end != null ? \"x120eax6\" : \"\",\n $$css: true\n }, start !== undefined && {\n kZCmMZ: start != null ? \"xnvo3vl\" : \"\",\n $$css: true\n }, {\n \"--x-paddingInlineEnd\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-paddingInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\n\n// The trailing half's padding either side of the chevron, and how far the\n// chevron sits toward the start while the menu is closed.\nconst TRAILING_PADDING = {\n lg: 15,\n md: 13,\n xl: 29,\n xs: 13,\n xxl: 43\n};\nconst CLOSED_OFFSET = {\n lg: 2,\n md: 1,\n xl: 3,\n xs: 1,\n xxl: 6\n};\n\n// The corner where the halves meet, at rest and while a half is hovered,\n// focused or pressed.\nconst INNER = {\n lg: radii.xs,\n md: radii.xs,\n xl: radii.sm,\n xs: radii.xs,\n xxl: radii.md\n};\n\n// The round end at each size: half the button's height. Not the pill's\n// 9999px: CSS scales every corner of a box down together when two on one\n// side add up to more than the side is long, so a 9999px end beside an 8px\n// inner corner shrank the inner one to nothing. Half the height fits as\n// written. A label that wraps makes a button taller than this, and its ends\n// a little less than round.\nconst ROUND = {\n lg: `calc(${sizing.controlLg} / 2)`,\n md: `calc(${sizing.controlSm} / 2)`,\n xl: `calc(${sizing.controlXl} / 2)`,\n xs: `calc(${sizing.controlXs} / 2)`,\n xxl: `calc(${sizing.controlXxl} / 2)`\n};\nconst INNER_ACTIVE = {\n lg: radii.md,\n md: radii.md,\n xl: '20px',\n xs: radii.sm,\n xxl: '20px'\n};\n\n// Omitted form by form: ButtonProps is a union of the plain, link and toggle\n// forms, and an Omit of the whole union keeps only the keys all three share,\n// which would let a link's and a toggle's props back together.\ntype SplitButtonActionProps = (ButtonProps extends infer Props ? Props extends unknown ? Omit<Props, 'shape' | 'size' | 'variant'> : never : never) & RefAttributes<HTMLAnchorElement | HTMLButtonElement>;\ntype SplitButtonMenuProps = {\n /** What the menu offers, in words: the trailing half is an icon alone. */\n 'aria-label': string;\n /** The menu's items, as `Menu.Item`s and the rest of Menu's parts. */\n children: ReactNode;\n /**\n * Where the menu is portalled to. Defaults to the container of the\n * `ThemeScope` around it, or to the end of `<body>` where there is none. A\n * subtree themed through the `themeScope` class has no container of its own,\n * so point this inside it, or it renders outside and keeps the page's tokens.\n */\n container?: Element;\n /**\n * Whether the menu starts open, when it keeps its own state.\n * @default false\n */\n defaultOpen?: boolean;\n /** Whether the trailing half can be pressed. */\n isDisabled?: boolean;\n /** Whether the menu is open, when the call site holds the state. */\n isOpen?: boolean;\n /** Called with an item's `id` when it is chosen. */\n onAction?: (key: Key) => void;\n /** Called when the menu opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n};\ntype SplitButtonProps = RefAttributes<HTMLDivElement> & {\n /** What the pair is, in words, for the group around the two halves. */\n 'aria-label'?: string;\n /** The two halves: a `SplitButton.Action`, then a `SplitButton.Menu`. */\n children: ReactNode;\n /** The class for the group around the two halves. */\n className?: string;\n /**\n * The size both halves take, as Button's: `xs` to `xxl`.\n * @default 'md'\n */\n size?: ButtonSize;\n /** The style for the group around the two halves. */\n style?: CSSProperties;\n /**\n * The colour style both halves take: Button's four with a container.\n * @default 'filled'\n */\n variant?: SplitButtonVariant;\n};\ntype SplitButtonVariant = 'elevated' | 'filled' | 'outlined' | 'tonal';\n\n// What the root hands its two halves.\nconst SplitButtonContext = createContext<{\n size: GroupSize;\n variant: SplitButtonVariant;\n}>({\n size: 'md',\n variant: 'filled'\n});\n\n// Whether a half shows the corner it opens out to: while it is hovered,\n// focused or pressed.\nfunction isActive(state: ButtonState) {\n return state.isHovered || state.isFocusVisible || state.isPressed;\n}\n\n// The leading half's part: its padding, its round start and the inner\n// corner at its end.\nfunction leadingItem(size: GroupSize): ButtonGroupItem {\n return {\n shift: 0,\n size,\n styles: (state: ButtonState) => [leading[size], corners.shape(ROUND[size], isActive(state) ? INNER_ACTIVE[size] : INNER[size])]\n };\n}\n\n/**\n * An action and a menu of alternatives beside it, drawn as one control.\n *\n * ```tsx\n * <SplitButton>\n * <SplitButton.Action onPress={save}>Label</SplitButton.Action>\n * <SplitButton.Menu aria-label=\"More options\">\n * <Menu.Item id=\"first\">First item</Menu.Item>\n * </SplitButton.Menu>\n * </SplitButton>\n * ```\n *\n * The call site's `className`, `style` and `ref` land on the group around\n * the two halves.\n */\nfunction SplitButton({\n 'aria-label': label,\n children,\n className,\n ref,\n size = 'md',\n style,\n variant = 'filled'\n}: SplitButtonProps) {\n const context = useMemo(() => ({\n size,\n variant\n }), [size, variant]);\n return <SplitButtonContext value={context}>\n <RACGroup aria-label={label} ref={ref} {...mergeStyles({\n className: \"x6s0dn4 x9f619 x3nfvp2 x14qo01y\"\n }, {\n className,\n style\n })}>\n {children}\n </RACGroup>\n </SplitButtonContext>;\n}\n\n/**\n * The split button's leading half: a Button, with an icon, a label or both,\n * in the root's size and variant.\n */\nfunction SplitButtonAction(props: SplitButtonActionProps) {\n const {\n size,\n variant\n } = useContext(SplitButtonContext);\n const item = useMemo(() => leadingItem(size), [size]);\n return <ButtonGroupItemContext value={item}>\n <Button {...props} variant={variant} />\n </ButtonGroupItemContext>;\n}\n\n/**\n * The split button's trailing half: the down chevron, which opens the menu\n * of alternatives its children describe.\n */\nfunction SplitButtonMenu({\n 'aria-label': label,\n children,\n container,\n defaultOpen = false,\n isDisabled,\n isOpen,\n onAction,\n onOpenChange\n}: SplitButtonMenuProps) {\n const {\n size,\n variant\n } = useContext(SplitButtonContext);\n const [ownOpen, setOwnOpen] = useState(defaultOpen);\n const open = isOpen ?? ownOpen;\n const changeOpen = useCallback((next: boolean) => {\n if (isOpen === undefined) {\n setOwnOpen(next);\n }\n onOpenChange?.(next);\n }, [isOpen, onOpenChange]);\n const item = useMemo(() => trailingItem(size, open), [size, open]);\n return <Menu isOpen={open} onOpenChange={changeOpen}>\n <ButtonGroupItemContext value={item}>\n <Button aria-label={label} isDisabled={isDisabled} variant={variant}>\n <ChevronDownGlyph height=\"1em\" width=\"1em\" {...{\n 0: {\n className: \"x12w9bfk x7p49u4 xkzkux9 x11xpdln xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xkzkux9 x11xpdln xpc4ca7 x19jd1h0\"\n }\n }[!!open << 0]} />\n </Button>\n </ButtonGroupItemContext>\n <Menu.Content align=\"end\" container={container} onAction={onAction}>\n {children}\n </Menu.Content>\n </Menu>;\n}\n\n// The trailing half's part: its chevron and padding, the inner corner at its\n// start, and its round end — and while the menu is open, the chevron centred\n// and the inner corner rounded off.\nfunction trailingItem(size: GroupSize, isOpen: boolean): ButtonGroupItem {\n const padding = TRAILING_PADDING[size];\n const offset = isOpen ? 0 : CLOSED_OFFSET[size];\n return {\n shift: 0,\n size,\n styles: (state: ButtonState) => [chevron[size], trailing.padding(`${padding - offset}px`, `${padding + offset}px`), corners.shape(isOpen ? ROUND[size] : isActive(state) ? INNER_ACTIVE[size] : INNER[size], ROUND[size])]\n };\n}\nSplitButton.Action = SplitButtonAction;\nSplitButton.Menu = SplitButtonMenu;\nexport type { SplitButtonActionProps, SplitButtonMenuProps, SplitButtonProps, SplitButtonVariant };\nexport { SplitButtonAction, SplitButtonMenu };\nexport default SplitButton;"],"mappings":";;;;;;;;;;;;AA8DA,MAAMQ,UAAU,EACdC,QAAQC,OAAeC,QAAgB;CAACA,QAAQC,KAAAA,KAAa;EAC3DC,QAAQF,OAAO,OAAO,aAAa;EACnCG,OAAO;CACT;CAAGJ,UAAUE,KAAAA,KAAa;EACxBG,QAAQL,SAAS,OAAO,aAAa;EACrCI,OAAO;CACT;CAAGH,QAAQC,KAAAA,KAAa;EACtBI,QAAQL,OAAO,OAAO,YAAY;EAClCG,OAAO;CACT;CAAGJ,UAAUE,KAAAA,KAAa;EACxBK,QAAQP,SAAS,OAAO,YAAY;EACpCI,OAAO;CACT;CAAG;EACD,4BAA2BI,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO,OAAOA,MAAMN,KAAAA,EAAAA,CAAWD,GAAG;EAC3G,8BAA6BO,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO,OAAOA,MAAMN,KAAAA,EAAAA,CAAWF,KAAK;EAC/G,8BAA6BQ,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO,OAAOA,MAAMN,KAAAA,EAAAA,CAAWD,GAAG;EAC7G,gCAA+BO,QAAO,OAAOA,QAAQ,WAAWA,MAAM,OAAOA,OAAO,OAAOA,MAAMN,KAAAA,EAAAA,CAAWF,KAAK;CACnH;AAAC,EACH;AAGA,MAAMS,UAAU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OAAAA,KAAA1B,EAAA;CAAA,IAAA2B;CAAA,IAAA3B,EAAA,QAAAkB,cAAAlB,EAAA,QAAAgB,QAAAhB,EAAA,QAAAyB,MAAAzB,EAAA,QAAA0B,IAAA;EAfZC,MAAA,qBAACK,QAAD;GAAchB,QAAAA;GAAoBE,cAAAA;GAAlC,UAAA,CACHO,IAYAC,EAbQ;;EAgBH1B,EAAA,MAAAkB;EAAAlB,EAAA,MAAAgB;EAAAhB,EAAA,MAAAyB;EAAAzB,EAAA,MAAA0B;EAAA1B,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,OAhBF2B;AAgBE;AAMX,SAASR,aAAajC,MAAiBJ,QAAkC;CACvE,MAAMhB,UAAUC,iBAAiBmB;CACjC,MAAM0C,SAAS9C,SAAS,IAAId,cAAckB;CAC1C,OAAO;EACLU,OAAO;EACPV;EACAW,SAASN,UAAuB;GAAC5B,QAAQuB;GAAOrB,SAASC,QAAQ,GAAGA,UAAU8D,OAAM,KAAM,GAAG9D,UAAU8D,OAAM,GAAI;GAAGpF,QAAQC,MAAMqC,SAASX,MAAMe,QAAQI,SAASC,KAAK,IAAId,aAAaS,QAAQjB,MAAMiB,OAAOf,MAAMe,KAAK;EAAC;CAC3N;AACF;AACAY,YAAY+B,SAASnB;AACrBZ,YAAYvD,OAAOsE"}
|
|
@@ -3,9 +3,11 @@ import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
|
3
3
|
import { CollectionLoadMore } from "../../collection/index.js";
|
|
4
4
|
import { collectionStyles } from "../../collection/styles.js";
|
|
5
5
|
import { ArrowDownwardGlyph, ArrowUpwardGlyph } from "../../glyphs/index.js";
|
|
6
|
+
import { useScrollEdges } from "../../hooks/useScrollEdges.js";
|
|
6
7
|
import { mergeRefs } from "../../render/ref.js";
|
|
7
8
|
import { rowStyles as rowStyles$1 } from "../../row/styles.js";
|
|
8
9
|
import { mergeStatefulStyles, mergeStyles } from "../../styles/merge.js";
|
|
10
|
+
import { scrollFadeOf } from "../../styles/scroll-fade.js";
|
|
9
11
|
import Checkbox from "../checkbox/index.js";
|
|
10
12
|
import { c } from "react/compiler-runtime";
|
|
11
13
|
import { createContext, useContext, useLayoutEffect, useState } from "react";
|
|
@@ -31,10 +33,10 @@ const styles = {
|
|
|
31
33
|
$$css: true
|
|
32
34
|
},
|
|
33
35
|
focus: {
|
|
34
|
-
kjBf7l: "
|
|
35
|
-
kInvED: "
|
|
36
|
+
kjBf7l: "xat36cu x1v8yhc2",
|
|
37
|
+
kInvED: "x1v57pqu",
|
|
36
38
|
k3XXqK: "x9v5kkp x1t137rt",
|
|
37
|
-
kMeerF: "
|
|
39
|
+
kMeerF: "x1s780dp",
|
|
38
40
|
$$css: true
|
|
39
41
|
},
|
|
40
42
|
header: {
|
|
@@ -62,6 +64,13 @@ const styles = {
|
|
|
62
64
|
kkrTdU: "x1ypdohk",
|
|
63
65
|
$$css: true
|
|
64
66
|
},
|
|
67
|
+
resizableContainer: {
|
|
68
|
+
kB7OPa: "x9f619",
|
|
69
|
+
kzqmXN: "xh8yej3",
|
|
70
|
+
kHjlTd: "x1h4wwuj",
|
|
71
|
+
kXHlph: "xw2csxc",
|
|
72
|
+
$$css: true
|
|
73
|
+
},
|
|
65
74
|
row: {
|
|
66
75
|
kZKoxP: "xdd8jsf",
|
|
67
76
|
kLZC3w: "x12smttz",
|
|
@@ -178,8 +187,8 @@ function measureColumns(table) {
|
|
|
178
187
|
for (const [element, css] of held) element.style.cssText = css;
|
|
179
188
|
return widths;
|
|
180
189
|
}
|
|
181
|
-
function resizableContainerClassName() {
|
|
182
|
-
return
|
|
190
|
+
function resizableContainerClassName(edges) {
|
|
191
|
+
return props(styles.resizableContainer, scrollFadeOf(edges)).className ?? "";
|
|
183
192
|
}
|
|
184
193
|
function resizerRule(state) {
|
|
185
194
|
return /* @__PURE__ */ jsx("span", { ...{
|
|
@@ -225,7 +234,7 @@ function sortArrowFor(direction) {
|
|
|
225
234
|
* element a layout positions.
|
|
226
235
|
*/
|
|
227
236
|
function Table(t0) {
|
|
228
|
-
const $ = c(
|
|
237
|
+
const $ = c(42);
|
|
229
238
|
let onResize;
|
|
230
239
|
let onResizeEnd;
|
|
231
240
|
let props;
|
|
@@ -267,6 +276,8 @@ function Table(t0) {
|
|
|
267
276
|
} else t3 = $[11];
|
|
268
277
|
const ref = t3;
|
|
269
278
|
const minWidths = useColumnMinWidths(resizable ? element : null);
|
|
279
|
+
const [container, setContainer] = useState(null);
|
|
280
|
+
const edges = useScrollEdges(resizable ? container : null);
|
|
270
281
|
let t4;
|
|
271
282
|
if ($[12] !== props) {
|
|
272
283
|
t4 = mergeStatefulStyles(tableClasses, props);
|
|
@@ -287,79 +298,81 @@ function Table(t0) {
|
|
|
287
298
|
} else t5 = $[17];
|
|
288
299
|
const table = t5;
|
|
289
300
|
let t6;
|
|
290
|
-
if ($[18] !==
|
|
301
|
+
if ($[18] !== edges || $[19] !== onResize || $[20] !== onResizeEnd || $[21] !== resizable || $[22] !== table) {
|
|
291
302
|
t6 = resizable ? /* @__PURE__ */ jsx(ResizableTableContainer, {
|
|
292
|
-
className: resizableContainerClassName(),
|
|
303
|
+
className: resizableContainerClassName(edges),
|
|
293
304
|
onResize,
|
|
294
305
|
onResizeEnd,
|
|
306
|
+
ref: setContainer,
|
|
295
307
|
children: table
|
|
296
308
|
}) : table;
|
|
297
|
-
$[18] =
|
|
298
|
-
$[19] =
|
|
299
|
-
$[20] =
|
|
300
|
-
$[21] =
|
|
301
|
-
$[22] =
|
|
302
|
-
|
|
309
|
+
$[18] = edges;
|
|
310
|
+
$[19] = onResize;
|
|
311
|
+
$[20] = onResizeEnd;
|
|
312
|
+
$[21] = resizable;
|
|
313
|
+
$[22] = table;
|
|
314
|
+
$[23] = t6;
|
|
315
|
+
} else t6 = $[23];
|
|
303
316
|
let t7;
|
|
304
|
-
if ($[
|
|
317
|
+
if ($[24] !== minWidths || $[25] !== t6) {
|
|
305
318
|
t7 = /* @__PURE__ */ jsx(ColumnMinWidthsContext, {
|
|
306
319
|
value: minWidths,
|
|
307
320
|
children: t6
|
|
308
321
|
});
|
|
309
|
-
$[
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
312
|
-
} else t7 = $[
|
|
322
|
+
$[24] = minWidths;
|
|
323
|
+
$[25] = t6;
|
|
324
|
+
$[26] = t7;
|
|
325
|
+
} else t7 = $[26];
|
|
313
326
|
let t8;
|
|
314
|
-
if ($[
|
|
327
|
+
if ($[27] !== stickyHeader || $[28] !== t7) {
|
|
315
328
|
t8 = /* @__PURE__ */ jsx(StickyHeaderContext, {
|
|
316
329
|
value: stickyHeader,
|
|
317
330
|
children: t7
|
|
318
331
|
});
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[
|
|
322
|
-
} else t8 = $[
|
|
332
|
+
$[27] = stickyHeader;
|
|
333
|
+
$[28] = t7;
|
|
334
|
+
$[29] = t8;
|
|
335
|
+
} else t8 = $[29];
|
|
323
336
|
let t9;
|
|
324
|
-
if ($[
|
|
337
|
+
if ($[30] !== resizable || $[31] !== t8) {
|
|
325
338
|
t9 = /* @__PURE__ */ jsx(ResizableContext, {
|
|
326
339
|
value: resizable,
|
|
327
340
|
children: t8
|
|
328
341
|
});
|
|
329
|
-
$[
|
|
330
|
-
$[
|
|
331
|
-
$[
|
|
332
|
-
} else t9 = $[
|
|
342
|
+
$[30] = resizable;
|
|
343
|
+
$[31] = t8;
|
|
344
|
+
$[32] = t9;
|
|
345
|
+
} else t9 = $[32];
|
|
333
346
|
let t10;
|
|
334
|
-
if ($[
|
|
347
|
+
if ($[33] !== resizeLabel || $[34] !== t9) {
|
|
335
348
|
t10 = /* @__PURE__ */ jsx(ResizeLabelContext, {
|
|
336
349
|
value: resizeLabel,
|
|
337
350
|
children: t9
|
|
338
351
|
});
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
} else t10 = $[
|
|
352
|
+
$[33] = resizeLabel;
|
|
353
|
+
$[34] = t9;
|
|
354
|
+
$[35] = t10;
|
|
355
|
+
} else t10 = $[35];
|
|
343
356
|
let t11;
|
|
344
|
-
if ($[
|
|
357
|
+
if ($[36] !== selectLabel || $[37] !== t10) {
|
|
345
358
|
t11 = /* @__PURE__ */ jsx(SelectLabelContext, {
|
|
346
359
|
value: selectLabel,
|
|
347
360
|
children: t10
|
|
348
361
|
});
|
|
349
|
-
$[
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
} else t11 = $[
|
|
362
|
+
$[36] = selectLabel;
|
|
363
|
+
$[37] = t10;
|
|
364
|
+
$[38] = t11;
|
|
365
|
+
} else t11 = $[38];
|
|
353
366
|
let t12;
|
|
354
|
-
if ($[
|
|
367
|
+
if ($[39] !== selectAllLabel || $[40] !== t11) {
|
|
355
368
|
t12 = /* @__PURE__ */ jsx(SelectAllLabelContext, {
|
|
356
369
|
value: selectAllLabel,
|
|
357
370
|
children: t11
|
|
358
371
|
});
|
|
359
|
-
$[
|
|
360
|
-
$[
|
|
361
|
-
$[
|
|
362
|
-
} else t12 = $[
|
|
372
|
+
$[39] = selectAllLabel;
|
|
373
|
+
$[40] = t11;
|
|
374
|
+
$[41] = t12;
|
|
375
|
+
} else t12 = $[41];
|
|
363
376
|
return t12;
|
|
364
377
|
}
|
|
365
378
|
/**
|
|
@@ -439,7 +452,7 @@ function TableCell(t0) {
|
|
|
439
452
|
return t5;
|
|
440
453
|
}
|
|
441
454
|
function tableClasses(state) {
|
|
442
|
-
return props(styles.table, state.isDropTarget && collectionStyles.dropTarget);
|
|
455
|
+
return props(styles.table, state.isFocusVisible && collectionStyles.focusVisible, state.isDropTarget && collectionStyles.dropTarget);
|
|
443
456
|
}
|
|
444
457
|
/**
|
|
445
458
|
* One column. `allowsSorting` is React Aria's and makes the header cell
|