@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","createContext","useContext","RACGridList","RACGridListItem","RACGridListLoadMoreItem","RACGridListSection","collectionStyles","containerClasses","rowItemStyles","textOf","useRipple","mergeStatefulStyles","mergeStyles","SelectLabelContext","undefined","RowsActContext","NESTED_CONTROL","label","selectionBehavior","selectLabel","children","leading","overline","supporting","trailing","header","itemContent","ripple","state","isDisabled","isSelected","selectionFor","landsOnControl","event","control","target","Element","closest","currentTarget","contains","List","t0","$","T0","T1","T2","props","t1","t2","t3","t4","t5","t6","rowsAct","selectionMode","onAction","dragAndDropHooks","useDraggableCollectionState","t7","t8","ListLoadMore","loading","ListRow","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","textValue","acts","href","handlers","startsRipple","surface","ListSection","section","own","Item","LoadMore","Section","RACGridListHeader"],"sources":["../../../src/components/list/index.tsx"],"sourcesContent":["'use client';\n\nimport type { PointerEvent, PointerEventHandler, ReactNode, RefAttributes } from 'react';\nimport type { GridListItemRenderProps, GridListItemProps as RACGridListItemProps, GridListLoadMoreItemProps as RACGridListLoadMoreItemProps, GridListProps as RACGridListProps, GridListSectionProps as RACGridListSectionProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { GridList as RACGridList, GridListHeader as RACGridListHeader, GridListItem as RACGridListItem, GridListLoadMoreItem as RACGridListLoadMoreItem, GridListSection as RACGridListSection } from 'react-aria-components';\nimport { CollectionLoadMore } from '../../collection';\nimport { collectionStyles, containerClasses, rowItemStyles } from '../../collection/styles';\nimport { textOf } from '../../collection/text';\nimport { useRipple } from '../../hooks/useRipple';\nimport { RowContent } from '../../row';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport Checkbox from '../checkbox';\n\n// The lists page's interactive list. Each row is the row every list here\n// draws — `src/row`, shared with ListItem and ListBox — so the 56dp floor,\n// the body-large headline, the body-medium supporting line, the state layers\n// and the disabled treatment are all that module's.\n//\n// ListItem is the static row: one row, on its own, presenting. This is the\n// collection that draws the same row and adds selection, keyboard navigation\n// between rows, sections and a load-more sentinel. A page with one row uses\n// ListItem; a page with a list of them uses this.\n//\n// It is ListBox's shape over a different React Aria primitive, and the\n// difference is what the primitive allows inside a row. A listbox option is\n// a leaf: a screen reader reads its text and nothing inside it can be\n// focused, so a row with a checkbox or a button in it is not an option. A\n// grid list's row is a row of cells, and its contents can be reached and\n// operated. That is what a list with a checkbox on every row needs, and it\n// is why this exists beside ListBox rather than instead of it.\n//\n// Three things are this component's own.\n//\n// **A selecting list draws a checkbox.** React Aria reports the selection\n// mode and behaviour on each row, so a list that toggles draws one without\n// the call site saying so on every item — and it is the library's Checkbox\n// rather than a glyph, so it looks like every other checkbox on the page.\n//\n// **The checkbox is drawn first, before whatever the row was given.** The\n// page draws it leading on a plain row and trailing beside an avatar; one\n// place, always the same, is what keeps a column of rows reading down.\n//\n// **Drag and drop passes straight through.** `dragAndDropHooks` is React\n// Aria's and is not wrapped, since what a list can be dropped on is the\n// page's business rather than the row's.\n\n// What each row's selection checkbox is called. A context rather than a prop\n// on the row, since it is the list's decision and repeating it on every row\n// is how the two drift. Undefined unless the list is given one, which\n// leaves the name React Aria gives in the reader's locale.\nconst SelectLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the list makes every row act on a press: it selects, it has an\n// `onAction` of its own, or its rows drag. A row given an `onAction` or an\n// `href` acts whatever this says. A context for the reason SelectLabelContext\n// is one: it is the list's to decide, and a row reads it rather than taking\n// it again as a prop.\nconst RowsActContext = createContext(false);\n\n// What a press inside a row leaves to the element it lands on: a control of\n// the row's own content, which answers the press itself. A label is in the\n// list because a native checkbox or radio is pressed through the label\n// around it. React Aria's own controls, this library's Switch and Checkbox\n// among them, stop the pointerdown of a press they take, so the row never\n// hears one.\nconst NESTED_CONTROL = 'a[href], button, input, label, select, textarea, [role=\"button\"], [role=\"checkbox\"], [role=\"link\"], [role=\"switch\"]';\ntype ListLoadMoreProps = Omit<RACGridListLoadMoreItemProps, 'children'> & {\n /**\n * What the row says while it is loading. Read by a screen reader; the ring\n * itself carries no text.\n * Left out, it is the word for it in the I18nProvider's locale — \"Loading\n * more\" in English.\n */\n label?: string;\n};\ntype ListProps<T extends object = object> = {\n /** A function may compute the class from the list's render state. */\n className?: RACGridListProps<T>['className'];\n /**\n * How a press selects. `toggle` draws a checkbox on every row, and a press\n * adds that row to the selection or takes it out. `replace` draws none, a\n * press makes that row the selection, and the arrow keys carry the\n * selection with the focus; where rows also take an action, a click\n * selects and a double click acts. Left out, a `single` list replaces and\n * any other toggles, since a single choice drawn as checkboxes unticks one\n * box whenever another is ticked.\n */\n selectionBehavior?: RACGridListProps<T>['selectionBehavior'];\n /**\n * What each row's selection checkbox is called, for a screen reader. The\n * row's own text is what names the row; this names the box inside it.\n * Left out, React Aria names it in the reader's locale — \"Select\" in\n * English.\n */\n selectLabel?: string;\n /** A function may compute the style from the list's render state. */\n style?: RACGridListProps<T>['style'];\n} & Omit<RACGridListProps<T>, 'className' | 'selectionBehavior' | 'style'>;\n\n// `Row` rather than `Item`, though the component is `List.Item`, because\n// `ListItemProps` is the standalone `ListItem` component's and both are\n// exported from the package. The two overlap on four props, so a call site\n// reaching for the obvious name got something that typechecked until it\n// passed `textValue`, and an error pointing at `onClick` rather than at the\n// name. `row` is what this file and `src/row` call the thing anyway.\ntype ListRowProps<T extends object = object> = {\n /** The row's headline — the one thing it is mostly about. */\n children?: ReactNode;\n /** A function may compute the class from the row's render state. */\n className?: RACGridListItemProps<T>['className'];\n /** Content before the headline: an avatar, an icon. */\n leading?: ReactNode;\n /**\n * A line above the headline, in the page's label-small and the same muted\n * role the supporting line takes — a category, a date, a status. Given\n * alongside `supporting` it makes the row the page's three-line item.\n */\n overline?: ReactNode;\n /** A function may compute the style from the row's render state. */\n style?: RACGridListItemProps<T>['style'];\n /** A second line under the headline, in the muted role. */\n supporting?: ReactNode;\n /** Content after the headline, such as an amount or a control. */\n trailing?: ReactNode;\n} & Omit<RACGridListItemProps<T>, 'children' | 'className' | 'style'>;\ntype ListSectionProps<T extends object = object> = Omit<RACGridListSectionProps<T>, 'children'> & {\n /**\n * The rows in the section. A section built from data puts React Aria's\n * `Collection` in here rather than a render function, since the header is\n * an element beside them.\n */\n children?: ReactNode;\n /**\n * The section's heading, rendered through React Aria's header so the\n * section is named by it. A section without one is a group with no name.\n */\n header?: ReactNode;\n};\n\n// What the row draws, from React Aria's render state. Built by a call rather\n// 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.\n//\n// The state decides two things: whether a selection checkbox is drawn, and\n// which colour the supporting line takes — the muted role holds only while\n// the row is drawn on the surface.\nfunction itemContent(children: ReactNode, leading: ReactNode, overline: ReactNode, supporting: ReactNode, trailing: ReactNode, selectLabel: string | undefined, ripple: ReactNode) {\n return (state: GridListItemRenderProps) => <>\n <RowContent isDisabled={state.isDisabled} isSelected={state.isSelected} leading={leading} overline={overline} selection={selectionFor(state, selectLabel)} supporting={supporting} trailing={trailing}>\n {children}\n </RowContent>\n {state.isDisabled ? null : ripple}\n </>;\n}\n\n// Whether a press on the row began on a control inside it rather than on the\n// row itself. `contains` answers false for no control at all, and true for\n// the row itself, which the second half rules out.\nfunction landsOnControl(event: PointerEvent<HTMLDivElement>) {\n const control = event.target instanceof Element ? event.target.closest(NESTED_CONTROL) : null;\n return event.currentTarget.contains(control) && control !== event.currentTarget;\n}\n\n/**\n * A list of rows one or more of which can be selected. Selection is React\n * Aria's: set `selectionMode` to `single` or `multiple`, and pass\n * `selectedKeys` with `onSelectionChange` to control it or\n * `defaultSelectedKeys` to let it keep its own. A list that only responds to\n * a press takes `onAction` on the row instead.\n *\n * A `multiple` list draws a checkbox on every row. A `single` one draws none\n * and marks the chosen row alone, since a checkbox promises a choice that\n * leaves the others standing; `selectionBehavior` overrides either.\n *\n * ListItem is the static row — one row, presenting, on its own. This is the\n * collection that draws the same row and adds selection, keyboard navigation\n * between rows, sections and a load-more sentinel.\n *\n * Composed from parts, since a row's slots take arbitrary content:\n * `List.Item`, `List.Section` and `List.LoadMore`. Name the list with\n * `aria-label` or `aria-labelledby` — nothing here labels it for you.\n *\n * ```tsx\n * const [selected, setSelected] = useState<Selection>(new Set(['first']))\n *\n * <List\n * aria-label=\"Label\"\n * onSelectionChange={setSelected}\n * selectedKeys={selected}\n * selectionMode=\"multiple\"\n * >\n * <List.Item\n * id=\"first\"\n * leading={<Avatar name=\"Ada Lovelace\" size=\"sm\" />}\n * supporting=\"Supporting line\"\n * trailing={<Currency value={1250} />}\n * >\n * First item\n * </List.Item>\n * <List.Item id=\"second\" textValue=\"Second item\">\n * <Text variant=\"bodyLarge\">Second item</Text>\n * </List.Item>\n * </List>\n * ```\n *\n * A row's `id` is what `selectedKeys` holds. A row whose children are not a\n * plain string takes a `textValue`, which is what typing a row's first\n * letters matches against.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n *\n * Inside a `Virtualizer` the list is its own scroll container, so its height\n * and `overflow-y: auto` go on the list, through `className` or `style`, and\n * not on an element around it. React Aria sizes a page of Page Up and Page\n * Down from the list's own box, so a list left to grow to its full height\n * inside a scrolling wrapper is one page long, and the keys jump from one\n * end of it to the other.\n */\nfunction List<T extends object>({\n selectionBehavior,\n selectLabel,\n ...props\n}: ListProps<T> & RefAttributes<HTMLDivElement>) {\n // React Aria's own reading of a draggable collection: hooks that can build\n // the drag state.\n const rowsAct = (props.selectionMode ?? 'none') !== 'none' || props.onAction !== undefined || props.dragAndDropHooks?.useDraggableCollectionState !== undefined;\n return <SelectLabelContext value={selectLabel}>\n <RowsActContext value={rowsAct}>\n <RACGridList {...props} {...mergeStatefulStyles(containerClasses, props)}\n // React Aria's own default is `toggle` in every mode. Read with `??`\n // rather than placed before the spread, so a wrapper forwarding an\n // unset prop still gets the default.\n selectionBehavior={selectionBehavior ?? (props.selectionMode === 'single' ? 'replace' : 'toggle')} />\n </RowsActContext>\n </SelectLabelContext>;\n}\n\n/**\n * The row the list shows while it is fetching more. React Aria calls\n * `onLoadMore` when this comes into view, and draws it only while\n * `isLoading`.\n */\nfunction ListLoadMore({\n label,\n ...props\n}: ListLoadMoreProps & RefAttributes<HTMLDivElement>) {\n return <RACGridListLoadMoreItem {...props} {...mergeStyles(stylex.props(collectionStyles.loading), props)}>\n <CollectionLoadMore diameter=\"24px\" label={label} />\n </RACGridListLoadMoreItem>;\n}\n\n/**\n * One row. Its slots are the row's: `leading`, the headline as children,\n * `supporting` under it, and `trailing`. Give every row an `id` — that is\n * the key selection is reported by.\n *\n * A list that selects with checkboxes draws one before whatever `leading`\n * holds, from the state React Aria reports rather than from a prop here.\n */\nfunction ListRow<T extends object = object>({\n children,\n leading,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n overline,\n supporting,\n textValue,\n trailing,\n ...props\n}: ListRowProps<T> & RefAttributes<HTMLDivElement>) {\n const selectLabel = useContext(SelectLabelContext);\n const acts = useContext(RowsActContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple ListItem draws, so a row looks the same pressed in a\n // list as on its own, and only on a row a press acts on, as ListItem draws\n // it only on an interactive one: a row that does nothing on a press should\n // not look as though it did. The call site's pointer handlers are handed to\n // the hook to merge, for the reason ListItem gives, apart from the press\n // itself, which `startsRipple` hands on. React Aria keeps a row's clicks\n // for its own press handling, so the press ends on the release.\n const ripple = useRipple<HTMLDivElement>(acts, {\n onContextMenu,\n onPointerCancel,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACGridListItem textValue={textValue ?? textOf(children)} {...ripple.handlers} onPointerDown={startsRipple(ripple.handlers.onPointerDown, onPointerDown)} {...props} {...mergeStatefulStyles(rowItemStyles(supporting, overline), props)}>\n {itemContent(children, leading, overline, supporting, trailing, selectLabel, ripple.surface)}\n </RACGridListItem>;\n}\n\n/**\n * A named group of rows. `header` names it, and is what a screen reader\n * reads before the rows inside.\n */\nfunction ListSection<T extends object = object>({\n children,\n header,\n ...props\n}: ListSectionProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACGridListSection {...props} {...mergeStyles(stylex.props(collectionStyles.section), props)}>\n {header === undefined ? null : <RACGridListHeader {...stylex.props(collectionStyles.header)}>\n {header}\n </RACGridListHeader>}\n {children}\n </RACGridListSection>;\n}\n\n// StyleX cannot target `[data-selected]` on the element it is styling, so a\n// row's state comes from the render state React Aria hands its className.\n// The order matters: `disabled` is applied last so its ground and colour\n// win over the selected container's. The state layers come from the render\n// state as well — see `focusVisible` in src/row/styles.ts — and React Aria\n// reports none of them on a disabled row, so nothing has to outrank them.\n//\n// A supporting line moves the row from the page's one-line container height\n// to its two-line one, which is a floor rather than something the row's own\n// box arrives at — see `twoLine` in `src/row/styles.ts`. Taken as an\n// argument rather than read from the render state, since React Aria reports\n// what a row is doing and not what it holds; the row is built by a call for\n// the same reason `itemContent` is.\n/**\n * The selection checkbox, while the list toggles. The row draws it ahead of\n * whatever `leading` holds.\n */\nfunction selectionFor(state: GridListItemRenderProps, selectLabel: string | undefined) {\n if (state.selectionBehavior !== 'toggle' || state.selectionMode === 'none') {\n return null;\n }\n return <Checkbox aria-label={selectLabel} slot=\"selection\" />;\n}\n\n// The row's press: the ripple's, unless it lands on a control inside the\n// row, which answers it itself — a trailing button pressed spread the row's\n// ripple across the whole row. The call site's own handler runs either way,\n// after the ripple's, as the hook orders the two. Built by a call rather than\n// written at the prop, for the reason `itemContent` gives.\nfunction startsRipple(ripple: PointerEventHandler<HTMLDivElement> | undefined, own: PointerEventHandler<HTMLDivElement> | undefined) {\n return (event: PointerEvent<HTMLDivElement>) => {\n if (!landsOnControl(event)) {\n ripple?.(event);\n }\n own?.(event);\n };\n}\nList.Item = ListRow;\nList.LoadMore = ListLoadMore;\nList.Section = ListSection;\nexport type { ListLoadMoreProps, ListProps, ListRowProps, ListSectionProps };\nexport { ListLoadMore, ListRow, ListSection };\nexport default List;"],"mappings":";;;;;;;;;;;;;;AAoDA,MAAMe,qBAAqBb,cAAkCc,KAAAA,CAAS;AAOtE,MAAMC,iBAAiBf,cAAc,KAAK;AAQ1C,MAAMgB,iBAAiB;AAkFvB,SAASU,YAAYN,UAAqBC,SAAoBC,UAAqBC,YAAuBC,UAAqBL,aAAiCQ,QAAmB;CACjL,QAAQC,UAAmC,qBAAA,YAAA,EAAA,UAAA,CACvC,oBAAC,YAAD;EAAY,YAAY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ridList","RACGridListItem","RACGridListLoadMoreItem","RACGridListSection","collectionStyles","containerClasses","rowItemStyles","textOf","useRipple","mergeStatefulStyles","mergeStyles","SelectLabelContext","undefined","RowsActContext","NESTED_CONTROL","children","isDisabled","isSelected","leading","overline","ripple","selectLabel","showsCheckbox","supporting","trailing","label","selectionBehavior","header","checkboxFor","shows","itemContent","state","ItemContent","t0","$","t1","t2","t3","t4","landsOnControl","event","control","target","Element","closest","currentTarget","contains","List","T0","T1","T2","props","t5","t6","rowsAct","selectionMode","onAction","dragAndDropHooks","useDraggableCollectionState","t7","t8","ListLoadMore","loading","ListRow","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","textValue","acts","href","handlers","startsRipple","surface","ListSection","section","own","Item","LoadMore","Section","RACGridListHeader"],"sources":["../../../src/components/list/index.tsx"],"sourcesContent":["'use client';\n\nimport type { PointerEvent, PointerEventHandler, ReactNode, RefAttributes } from 'react';\nimport type { GridListItemRenderProps, GridListItemProps as RACGridListItemProps, GridListLoadMoreItemProps as RACGridListLoadMoreItemProps, GridListProps as RACGridListProps, GridListSectionProps as RACGridListSectionProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { GridList as RACGridList, GridListHeader as RACGridListHeader, GridListItem as RACGridListItem, GridListLoadMoreItem as RACGridListLoadMoreItem, GridListSection as RACGridListSection } from 'react-aria-components';\nimport { CollectionLoadMore } from '../../collection';\nimport { collectionStyles, containerClasses, rowItemStyles } from '../../collection/styles';\nimport { textOf } from '../../collection/text';\nimport { useRipple } from '../../hooks/useRipple';\nimport { RowContent } from '../../row';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport Checkbox from '../checkbox';\n\n// The lists page's interactive list. Each row is the row every list here\n// draws — `src/row`, shared with ListItem and ListBox — so the 56dp floor,\n// the body-large headline, the body-medium supporting line, the state layers\n// and the disabled treatment are all that module's.\n//\n// ListItem is the static row: one row, on its own, presenting. This is the\n// collection that draws the same row and adds selection, keyboard navigation\n// between rows, sections and a load-more sentinel. A page with one row uses\n// ListItem; a page with a list of them uses this.\n//\n// It is ListBox's shape over a different React Aria primitive, and the\n// difference is what the primitive allows inside a row. A listbox option is\n// a leaf: a screen reader reads its text and nothing inside it can be\n// focused, so a row with a checkbox or a button in it is not an option. A\n// grid list's row is a row of cells, and its contents can be reached and\n// operated. That is what a list with a checkbox on every row needs, and it\n// is why this exists beside ListBox rather than instead of it.\n//\n// Three things are this component's own.\n//\n// **A selecting list draws a checkbox.** React Aria reports the selection\n// mode and behaviour on each row, so a list that toggles draws one without\n// the call site saying so on every item — and it is the library's Checkbox\n// rather than a glyph, so it looks like every other checkbox on the page.\n//\n// **The checkbox is drawn first, before whatever the row was given.** The\n// page draws it leading on a plain row and trailing beside an avatar; one\n// place, always the same, is what keeps a column of rows reading down.\n//\n// **Drag and drop passes straight through.** `dragAndDropHooks` is React\n// Aria's and is not wrapped, since what a list can be dropped on is the\n// page's business rather than the row's.\n\n// What each row's selection checkbox is called. A context rather than a prop\n// on the row, since it is the list's decision and repeating it on every row\n// is how the two drift. Undefined unless the list is given one, which\n// leaves the name React Aria gives in the reader's locale.\nconst SelectLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the list makes every row act on a press: it selects, it has an\n// `onAction` of its own, or its rows drag. A row given an `onAction` or an\n// `href` acts whatever this says. A context for the reason SelectLabelContext\n// is one: it is the list's to decide, and a row reads it rather than taking\n// it again as a prop.\nconst RowsActContext = createContext(false);\n\n// What a press inside a row leaves to the element it lands on: a control of\n// the row's own content, which answers the press itself. A label is in the\n// list because a native checkbox or radio is pressed through the label\n// around it. React Aria's own controls, this library's Switch and Checkbox\n// among them, stop the pointerdown of a press they take, so the row never\n// hears one.\nconst NESTED_CONTROL = 'a[href], button, input, label, select, textarea, [role=\"button\"], [role=\"checkbox\"], [role=\"link\"], [role=\"switch\"]';\n\n// What `ItemContent` draws a row from: the flags it reads off React Aria's\n// render state, and the row's own slots.\ninterface ItemContentProps {\n children: ReactNode;\n isDisabled: boolean;\n isSelected: boolean;\n leading: ReactNode;\n overline: ReactNode;\n ripple: ReactNode;\n selectLabel: string | undefined;\n /** Whether the row draws its selection checkbox — see `showsCheckbox`. */\n showsCheckbox: boolean;\n supporting: ReactNode;\n trailing: ReactNode;\n}\ntype ListLoadMoreProps = Omit<RACGridListLoadMoreItemProps, 'children'> & {\n /**\n * What the row says while it is loading. Read by a screen reader; the ring\n * itself carries no text.\n * Left out, it is the word for it in the I18nProvider's locale — \"Loading\n * more\" in English.\n */\n label?: string;\n};\ntype ListProps<T extends object = object> = {\n /** A function may compute the class from the list's render state. */\n className?: RACGridListProps<T>['className'];\n /**\n * How a press selects. `toggle` draws a checkbox on every row, and a press\n * adds that row to the selection or takes it out. `replace` draws none, a\n * press makes that row the selection, and the arrow keys carry the\n * selection with the focus; where rows also take an action, a click\n * selects and a double click acts. Left out, a `single` list replaces and\n * any other toggles, since a single choice drawn as checkboxes unticks one\n * box whenever another is ticked.\n */\n selectionBehavior?: RACGridListProps<T>['selectionBehavior'];\n /**\n * What each row's selection checkbox is called, for a screen reader. The\n * row's own text is what names the row; this names the box inside it.\n * Left out, React Aria names it in the reader's locale — \"Select\" in\n * English.\n */\n selectLabel?: string;\n /** A function may compute the style from the list's render state. */\n style?: RACGridListProps<T>['style'];\n} & Omit<RACGridListProps<T>, 'className' | 'selectionBehavior' | 'style'>;\n\n// `Row` rather than `Item`, though the component is `List.Item`, because\n// `ListItemProps` is the standalone `ListItem` component's and both are\n// exported from the package. The two overlap on four props, so a call site\n// reaching for the obvious name got something that typechecked until it\n// passed `textValue`, and an error pointing at `onClick` rather than at the\n// name. `row` is what this file and `src/row` call the thing anyway.\ntype ListRowProps<T extends object = object> = {\n /** The row's headline — the one thing it is mostly about. */\n children?: ReactNode;\n /** A function may compute the class from the row's render state. */\n className?: RACGridListItemProps<T>['className'];\n /** Content before the headline: an avatar, an icon. */\n leading?: ReactNode;\n /**\n * A line above the headline, in the page's label-small and the same muted\n * role the supporting line takes — a category, a date, a status. Given\n * alongside `supporting` it makes the row the page's three-line item.\n */\n overline?: ReactNode;\n /** A function may compute the style from the row's render state. */\n style?: RACGridListItemProps<T>['style'];\n /** A second line under the headline, in the muted role. */\n supporting?: ReactNode;\n /** Content after the headline, such as an amount or a control. */\n trailing?: ReactNode;\n} & Omit<RACGridListItemProps<T>, 'children' | 'className' | 'style'>;\ntype ListSectionProps<T extends object = object> = Omit<RACGridListSectionProps<T>, 'children'> & {\n /**\n * The rows in the section. A section built from data puts React Aria's\n * `Collection` in here rather than a render function, since the header is\n * an element beside them.\n */\n children?: ReactNode;\n /**\n * The section's heading, rendered through React Aria's header so the\n * section is named by it. A section without one is a group with no name.\n */\n header?: ReactNode;\n};\n\n// The checkbox itself, or nothing. Written as a call rather than inline at\n// the prop, which is what react-perf's jsx-no-jsx-as-prop is after; the\n// React Compiler memoises the result on its inputs, which are flags here\n// rather than the render state, so it holds across a row's renders.\nfunction checkboxFor(shows: boolean, selectLabel: string | undefined) {\n return shows ? <Checkbox aria-label={selectLabel} slot=\"selection\" /> : null;\n}\n\n// What the row draws, from React Aria's render state. Built by a call rather\n// than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\n//\n// The state decides two things: whether a selection checkbox is drawn, and\n// which colour the supporting line takes — the muted role holds only while\n// the row is drawn on the surface. It is read here and handed on as those\n// flags, to a component, rather than turned into the row's elements in this\n// function: React Aria calls it on every render of every row, and the\n// compiler memoises a component's elements but not a plain function's, so an\n// element built here is a new one each time and re-renders the row under it.\n// A selection change re-renders every row of the list, and every row's\n// checkbox went with it; built from the flags, a row whose own flags held\n// keeps the content it drew.\nfunction itemContent(children: ReactNode, leading: ReactNode, overline: ReactNode, supporting: ReactNode, trailing: ReactNode, selectLabel: string | undefined, ripple: ReactNode) {\n return (state: GridListItemRenderProps) => <ItemContent isDisabled={state.isDisabled} isSelected={state.isSelected} leading={leading} overline={overline} ripple={ripple} selectLabel={selectLabel} showsCheckbox={showsCheckbox(state)} supporting={supporting} trailing={trailing}>\n {children}\n </ItemContent>;\n}\n\n/** A row's content and its ripple, from the flags `itemContent` reads. */\nfunction ItemContent({\n children,\n isDisabled,\n isSelected,\n leading,\n overline,\n ripple,\n selectLabel,\n showsCheckbox: shows,\n supporting,\n trailing\n}: ItemContentProps) {\n return <>\n <RowContent isDisabled={isDisabled} isSelected={isSelected} leading={leading} overline={overline} selection={checkboxFor(shows, selectLabel)} supporting={supporting} trailing={trailing}>\n {children}\n </RowContent>\n {isDisabled ? null : ripple}\n </>;\n}\n\n// Whether a press on the row began on a control inside it rather than on the\n// row itself. `contains` answers false for no control at all, and true for\n// the row itself, which the second half rules out.\nfunction landsOnControl(event: PointerEvent<HTMLDivElement>) {\n const control = event.target instanceof Element ? event.target.closest(NESTED_CONTROL) : null;\n return event.currentTarget.contains(control) && control !== event.currentTarget;\n}\n\n/**\n * A list of rows one or more of which can be selected. Selection is React\n * Aria's: set `selectionMode` to `single` or `multiple`, and pass\n * `selectedKeys` with `onSelectionChange` to control it or\n * `defaultSelectedKeys` to let it keep its own. A list that only responds to\n * a press takes `onAction` on the row instead.\n *\n * A `multiple` list draws a checkbox on every row. A `single` one draws none\n * and marks the chosen row alone, since a checkbox promises a choice that\n * leaves the others standing; `selectionBehavior` overrides either.\n *\n * ListItem is the static row — one row, presenting, on its own. This is the\n * collection that draws the same row and adds selection, keyboard navigation\n * between rows, sections and a load-more sentinel.\n *\n * Composed from parts, since a row's slots take arbitrary content:\n * `List.Item`, `List.Section` and `List.LoadMore`. Name the list with\n * `aria-label` or `aria-labelledby` — nothing here labels it for you.\n *\n * ```tsx\n * const [selected, setSelected] = useState<Selection>(new Set(['first']))\n *\n * <List\n * aria-label=\"Label\"\n * onSelectionChange={setSelected}\n * selectedKeys={selected}\n * selectionMode=\"multiple\"\n * >\n * <List.Item\n * id=\"first\"\n * leading={<Avatar name=\"Ada Lovelace\" size=\"sm\" />}\n * supporting=\"Supporting line\"\n * trailing={<Currency value={1250} />}\n * >\n * First item\n * </List.Item>\n * <List.Item id=\"second\" textValue=\"Second item\">\n * <Text variant=\"bodyLarge\">Second item</Text>\n * </List.Item>\n * </List>\n * ```\n *\n * A row's `id` is what `selectedKeys` holds. A row whose children are not a\n * plain string takes a `textValue`, which is what typing a row's first\n * letters matches against.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n *\n * Inside a `Virtualizer` the list is its own scroll container, so its height\n * and `overflow-y: auto` go on the list, through `className` or `style`, and\n * not on an element around it. React Aria sizes a page of Page Up and Page\n * Down from the list's own box, so a list left to grow to its full height\n * inside a scrolling wrapper is one page long, and the keys jump from one\n * end of it to the other.\n */\nfunction List<T extends object>({\n selectionBehavior,\n selectLabel,\n ...props\n}: ListProps<T> & RefAttributes<HTMLDivElement>) {\n // React Aria's own reading of a draggable collection: hooks that can build\n // the drag state.\n const rowsAct = (props.selectionMode ?? 'none') !== 'none' || props.onAction !== undefined || props.dragAndDropHooks?.useDraggableCollectionState !== undefined;\n return <SelectLabelContext value={selectLabel}>\n <RowsActContext value={rowsAct}>\n <RACGridList {...props} {...mergeStatefulStyles(containerClasses, props)}\n // React Aria's own default is `toggle` in every mode. Read with `??`\n // rather than placed before the spread, so a wrapper forwarding an\n // unset prop still gets the default.\n selectionBehavior={selectionBehavior ?? (props.selectionMode === 'single' ? 'replace' : 'toggle')} />\n </RowsActContext>\n </SelectLabelContext>;\n}\n\n/**\n * The row the list shows while it is fetching more. React Aria calls\n * `onLoadMore` when this comes into view, and draws it only while\n * `isLoading`.\n */\nfunction ListLoadMore({\n label,\n ...props\n}: ListLoadMoreProps & RefAttributes<HTMLDivElement>) {\n return <RACGridListLoadMoreItem {...props} {...mergeStyles(stylex.props(collectionStyles.loading), props)}>\n <CollectionLoadMore diameter=\"24px\" label={label} />\n </RACGridListLoadMoreItem>;\n}\n\n/**\n * One row. Its slots are the row's: `leading`, the headline as children,\n * `supporting` under it, and `trailing`. Give every row an `id` — that is\n * the key selection is reported by.\n *\n * A list that selects with checkboxes draws one before whatever `leading`\n * holds, from the state React Aria reports rather than from a prop here.\n */\nfunction ListRow<T extends object = object>({\n children,\n leading,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n overline,\n supporting,\n textValue,\n trailing,\n ...props\n}: ListRowProps<T> & RefAttributes<HTMLDivElement>) {\n const selectLabel = useContext(SelectLabelContext);\n const acts = useContext(RowsActContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple ListItem draws, so a row looks the same pressed in a\n // list as on its own, and only on a row a press acts on, as ListItem draws\n // it only on an interactive one: a row that does nothing on a press should\n // not look as though it did. The call site's pointer handlers are handed to\n // the hook to merge, for the reason ListItem gives, apart from the press\n // itself, which `startsRipple` hands on. React Aria keeps a row's clicks\n // for its own press handling, so the press ends on the release.\n const ripple = useRipple<HTMLDivElement>(acts, {\n onContextMenu,\n onPointerCancel,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACGridListItem textValue={textValue ?? textOf(children)} {...ripple.handlers} onPointerDown={startsRipple(ripple.handlers.onPointerDown, onPointerDown)} {...props} {...mergeStatefulStyles(rowItemStyles(supporting, overline), props)}>\n {itemContent(children, leading, overline, supporting, trailing, selectLabel, ripple.surface)}\n </RACGridListItem>;\n}\n\n/**\n * A named group of rows. `header` names it, and is what a screen reader\n * reads before the rows inside.\n */\nfunction ListSection<T extends object = object>({\n children,\n header,\n ...props\n}: ListSectionProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACGridListSection {...props} {...mergeStyles(stylex.props(collectionStyles.section), props)}>\n {header === undefined ? null : <RACGridListHeader {...stylex.props(collectionStyles.header)}>\n {header}\n </RACGridListHeader>}\n {children}\n </RACGridListSection>;\n}\n\n// StyleX cannot target `[data-selected]` on the element it is styling, so a\n// row's state comes from the render state React Aria hands its className.\n// The order matters: `disabled` is applied last so its ground and colour\n// win over the selected container's. The state layers come from the render\n// state as well — see `focusVisible` in src/row/styles.ts — and React Aria\n// reports none of them on a disabled row, so nothing has to outrank them.\n//\n// A supporting line moves the row from the page's one-line container height\n// to its two-line one, which is a floor rather than something the row's own\n// box arrives at — see `twoLine` in `src/row/styles.ts`. Taken as an\n// argument rather than read from the render state, since React Aria reports\n// what a row is doing and not what it holds; the row is built by a call for\n// the same reason `itemContent` is.\n/**\n * Whether the row draws the selection checkbox, which it does while the list\n * toggles. The row draws it ahead of whatever `leading` holds.\n */\nfunction showsCheckbox(state: GridListItemRenderProps) {\n return state.selectionBehavior === 'toggle' && state.selectionMode !== 'none';\n}\n\n// The row's press: the ripple's, unless it lands on a control inside the\n// row, which answers it itself — a trailing button pressed spread the row's\n// ripple across the whole row. The call site's own handler runs either way,\n// after the ripple's, as the hook orders the two. Built by a call rather than\n// written at the prop, for the reason `itemContent` gives.\nfunction startsRipple(ripple: PointerEventHandler<HTMLDivElement> | undefined, own: PointerEventHandler<HTMLDivElement> | undefined) {\n return (event: PointerEvent<HTMLDivElement>) => {\n if (!landsOnControl(event)) {\n ripple?.(event);\n }\n own?.(event);\n };\n}\nList.Item = ListRow;\nList.LoadMore = ListLoadMore;\nList.Section = ListSection;\nexport type { ListLoadMoreProps, ListProps, ListRowProps, ListSectionProps };\nexport { ListLoadMore, ListRow, ListSection };\nexport default List;"],"mappings":";;;;;;;;;;;;;;AAoDA,MAAMe,qBAAqBb,cAAkCc,KAAAA,CAAS;AAOtE,MAAMC,iBAAiBf,cAAc,KAAK;AAQ1C,MAAMgB,iBAAiB;AA8FvB,SAASc,YAAYC,OAAgBR,aAAiC;CACpE,OAAOQ,QAAQ,oBAAC,UAAD;EAAU,cAAYR;EAAa,MAAK;CAAW,CAAA,IAAM;AAC1E;AAgBA,SAASS,YAAYf,UAAqBG,SAAoBC,UAAqBI,YAAuBC,UAAqBH,aAAiCD,QAAmB;CACjL,QAAQW,UAAmC,oBAAC,aAAD;EAAa,YAAYA,MAAMf;EAAY,YAAYe,MAAMd;EAAqBC;EAAmBC;EAAkBC;EAAqBC;EAAa,eAAeC,cAAcS,KAAK;EAAeR;E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;EAC/FU,KAAAV,WAAWf,KAAAA,IAAX,OAA8B,oBAACqE,gBAAD;GAAkB,GAAKpF,MAAaO,iBAAgBuB,MAAO;GACrFA,UAAAA;EAD4C,CAAA;EAE3BO,EAAA,KAAAP;EAAAO,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAc,MAAAd,EAAA,OAAAnB,YAAAmB,EAAA,QAAAC,MAAAD,EAAA,QAAAE,MAAAF,EAAA,QAAAG,IAAA;EAHnBC,KAAA,qBAAC,IAAD;GAAmB,GAAKa;GAAK,GAAMf;GAAnC,UAAA,CACFC,IAGAtB,QAJqB;;EAKHmB,EAAA,KAAAc;EAAAd,EAAA,KAAAnB;EAAAmB,EAAA,MAAAC;EAAAD,EAAA,MAAAE;EAAAF,EAAA,MAAAG;EAAAH,EAAA,MAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OALhBI;AAKgB;;;;;AAoBzB,SAAShB,cAAcS,OAAgC;CACrD,OAAOA,MAAML,sBAAsB,YAAYK,MAAMwB,kBAAkB;AACzE;AAOA,SAASkB,aAAarD,QAAyDyD,KAAsD;CACnI,QAAQrC,UAAwC;EAC9C,IAAI,CAACD,eAAeC,KAAK,GACvBpB,SAASoB,KAAK;EAEhBqC,MAAMrC,KAAK;CACb;AACF;AACAO,KAAK+B,OAAOf;AACZhB,KAAKgC,WAAWlB;AAChBd,KAAKiC,UAAUL"}
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
3
3
|
import { CollectionEmpty, CollectionLoadMore } from "../../collection/index.js";
|
|
4
|
+
import { OptionRowContext } from "../../collection/context.js";
|
|
4
5
|
import { collectionStyles, containerClasses, rowItemStyles } from "../../collection/styles.js";
|
|
5
6
|
import { textOf } from "../../collection/text.js";
|
|
6
7
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
7
8
|
import { RowContent } from "../../row/index.js";
|
|
8
9
|
import { mergeStatefulStyles, mergeStyles } from "../../styles/merge.js";
|
|
9
10
|
import { c } from "react/compiler-runtime";
|
|
10
|
-
import {
|
|
11
|
+
import { useContext } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
13
|
import { Header, ListBox as ListBox$1, ListBoxItem as ListBoxItem$1, ListBoxLoadMoreItem, ListBoxSection as ListBoxSection$1 } from "react-aria-components";
|
|
12
14
|
// src/components/list-box/index.tsx
|
|
15
|
+
function EmptyRow() {
|
|
16
|
+
const $ = c(2);
|
|
17
|
+
const t0 = useContext(OptionRowContext);
|
|
18
|
+
let t1;
|
|
19
|
+
if ($[0] !== t0) {
|
|
20
|
+
t1 = /* @__PURE__ */ jsx(CollectionEmpty, { variant: t0 });
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = t1;
|
|
23
|
+
} else t1 = $[1];
|
|
24
|
+
return t1;
|
|
25
|
+
}
|
|
13
26
|
function emptyState() {
|
|
14
|
-
return /* @__PURE__ */ jsx(
|
|
27
|
+
return /* @__PURE__ */ jsx(EmptyRow, {});
|
|
15
28
|
}
|
|
16
|
-
function itemContent(children, leading, overline, supporting, trailing, ripple) {
|
|
17
|
-
return (state) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RowContent, {
|
|
29
|
+
function itemContent(children, leading, overline, supporting, trailing, ripple, variant) {
|
|
30
|
+
return (state) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RowContent, {
|
|
18
31
|
isDisabled: state.isDisabled,
|
|
19
32
|
isSelected: state.isSelected,
|
|
20
33
|
leading,
|
|
21
34
|
overline,
|
|
22
35
|
supporting,
|
|
23
36
|
trailing,
|
|
37
|
+
variant,
|
|
24
38
|
children
|
|
25
39
|
}), state.isDisabled ? null : ripple] });
|
|
26
40
|
}
|
|
@@ -69,8 +83,9 @@ function ListBox(props) {
|
|
|
69
83
|
* the key selection is reported by.
|
|
70
84
|
*/
|
|
71
85
|
function ListBoxItem(t0) {
|
|
72
|
-
const $ = c(
|
|
86
|
+
const $ = c(24);
|
|
73
87
|
const { children, leading, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, overline, supporting, textValue, trailing, ...props } = t0;
|
|
88
|
+
const variant = useContext(OptionRowContext);
|
|
74
89
|
let t1;
|
|
75
90
|
if ($[0] !== onContextMenu || $[1] !== onPointerCancel || $[2] !== onPointerDown || $[3] !== onPointerLeave || $[4] !== onPointerUp) {
|
|
76
91
|
t1 = {
|
|
@@ -97,20 +112,21 @@ function ListBoxItem(t0) {
|
|
|
97
112
|
$[8] = t2;
|
|
98
113
|
} else t2 = $[8];
|
|
99
114
|
const t3 = ripple.handlers;
|
|
100
|
-
const t4 = mergeStatefulStyles(rowItemStyles(supporting, overline), props);
|
|
115
|
+
const t4 = mergeStatefulStyles(rowItemStyles(supporting, overline, void 0, variant), props);
|
|
101
116
|
let t5;
|
|
102
|
-
if ($[9] !== children || $[10] !== leading || $[11] !== overline || $[12] !== ripple.surface || $[13] !== supporting || $[14] !== trailing) {
|
|
103
|
-
t5 = itemContent(children, leading, overline, supporting, trailing, ripple.surface);
|
|
117
|
+
if ($[9] !== children || $[10] !== leading || $[11] !== overline || $[12] !== ripple.surface || $[13] !== supporting || $[14] !== trailing || $[15] !== variant) {
|
|
118
|
+
t5 = itemContent(children, leading, overline, supporting, trailing, ripple.surface, variant);
|
|
104
119
|
$[9] = children;
|
|
105
120
|
$[10] = leading;
|
|
106
121
|
$[11] = overline;
|
|
107
122
|
$[12] = ripple.surface;
|
|
108
123
|
$[13] = supporting;
|
|
109
124
|
$[14] = trailing;
|
|
110
|
-
$[15] =
|
|
111
|
-
|
|
125
|
+
$[15] = variant;
|
|
126
|
+
$[16] = t5;
|
|
127
|
+
} else t5 = $[16];
|
|
112
128
|
let t6;
|
|
113
|
-
if ($[
|
|
129
|
+
if ($[17] !== T0 || $[18] !== props || $[19] !== ripple.handlers || $[20] !== t2 || $[21] !== t4 || $[22] !== t5) {
|
|
114
130
|
t6 = /* @__PURE__ */ jsx(T0, {
|
|
115
131
|
textValue: t2,
|
|
116
132
|
...t3,
|
|
@@ -118,14 +134,14 @@ function ListBoxItem(t0) {
|
|
|
118
134
|
...t4,
|
|
119
135
|
children: t5
|
|
120
136
|
});
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
} else t6 = $[
|
|
137
|
+
$[17] = T0;
|
|
138
|
+
$[18] = props;
|
|
139
|
+
$[19] = ripple.handlers;
|
|
140
|
+
$[20] = t2;
|
|
141
|
+
$[21] = t4;
|
|
142
|
+
$[22] = t5;
|
|
143
|
+
$[23] = t6;
|
|
144
|
+
} else t6 = $[23];
|
|
129
145
|
return t6;
|
|
130
146
|
}
|
|
131
147
|
/**
|
|
@@ -134,107 +150,70 @@ function ListBoxItem(t0) {
|
|
|
134
150
|
* `isLoading` — so a list that pages as it scrolls needs nothing else.
|
|
135
151
|
*/
|
|
136
152
|
function ListBoxLoadMore(t0) {
|
|
137
|
-
const $ = c(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
const $ = c(7);
|
|
154
|
+
const { label, ...props$1 } = t0;
|
|
155
|
+
const variant = useContext(OptionRowContext);
|
|
156
|
+
const T0 = ListBoxLoadMoreItem;
|
|
157
|
+
const t1 = mergeStyles(props(collectionStyles.loading, variant === "menu" && collectionStyles.loadingMenu), props$1);
|
|
141
158
|
let t2;
|
|
142
|
-
if ($[0] !==
|
|
143
|
-
|
|
144
|
-
label = t3;
|
|
145
|
-
T0 = ListBoxLoadMoreItem;
|
|
146
|
-
t1 = props$1;
|
|
147
|
-
t2 = mergeStyles(props(collectionStyles.loading), props$1);
|
|
148
|
-
$[0] = t0;
|
|
149
|
-
$[1] = T0;
|
|
150
|
-
$[2] = label;
|
|
151
|
-
$[3] = t1;
|
|
152
|
-
$[4] = t2;
|
|
153
|
-
} else {
|
|
154
|
-
T0 = $[1];
|
|
155
|
-
label = $[2];
|
|
156
|
-
t1 = $[3];
|
|
157
|
-
t2 = $[4];
|
|
158
|
-
}
|
|
159
|
-
let t3;
|
|
160
|
-
if ($[5] !== label) {
|
|
161
|
-
t3 = /* @__PURE__ */ jsx(CollectionLoadMore, {
|
|
159
|
+
if ($[0] !== label) {
|
|
160
|
+
t2 = /* @__PURE__ */ jsx(CollectionLoadMore, {
|
|
162
161
|
diameter: "24px",
|
|
163
162
|
label
|
|
164
163
|
});
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
167
|
-
} else
|
|
168
|
-
let
|
|
169
|
-
if ($[
|
|
170
|
-
|
|
164
|
+
$[0] = label;
|
|
165
|
+
$[1] = t2;
|
|
166
|
+
} else t2 = $[1];
|
|
167
|
+
let t3;
|
|
168
|
+
if ($[2] !== T0 || $[3] !== props$1 || $[4] !== t1 || $[5] !== t2) {
|
|
169
|
+
t3 = /* @__PURE__ */ jsx(T0, {
|
|
170
|
+
...props$1,
|
|
171
171
|
...t1,
|
|
172
|
-
|
|
173
|
-
children: t3
|
|
172
|
+
children: t2
|
|
174
173
|
});
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
} else
|
|
181
|
-
return
|
|
174
|
+
$[2] = T0;
|
|
175
|
+
$[3] = props$1;
|
|
176
|
+
$[4] = t1;
|
|
177
|
+
$[5] = t2;
|
|
178
|
+
$[6] = t3;
|
|
179
|
+
} else t3 = $[6];
|
|
180
|
+
return t3;
|
|
182
181
|
}
|
|
183
182
|
/**
|
|
184
183
|
* A named group of options. `header` names it, and is what a screen reader
|
|
185
184
|
* reads before the options inside.
|
|
186
185
|
*/
|
|
187
186
|
function ListBoxSection(t0) {
|
|
188
|
-
const $ = c(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
const $ = c(9);
|
|
188
|
+
const { children, header, ...props$2 } = t0;
|
|
189
|
+
const variant = useContext(OptionRowContext);
|
|
190
|
+
const T0 = ListBoxSection$1;
|
|
191
|
+
const t1 = mergeStyles(props(collectionStyles.section), props$2);
|
|
193
192
|
let t2;
|
|
194
|
-
if ($[0] !==
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
header = t4;
|
|
198
|
-
T0 = ListBoxSection$1;
|
|
199
|
-
t1 = props$2;
|
|
200
|
-
t2 = mergeStyles(props(collectionStyles.section), props$2);
|
|
201
|
-
$[0] = t0;
|
|
202
|
-
$[1] = T0;
|
|
203
|
-
$[2] = children;
|
|
204
|
-
$[3] = header;
|
|
205
|
-
$[4] = t1;
|
|
206
|
-
$[5] = t2;
|
|
207
|
-
} else {
|
|
208
|
-
T0 = $[1];
|
|
209
|
-
children = $[2];
|
|
210
|
-
header = $[3];
|
|
211
|
-
t1 = $[4];
|
|
212
|
-
t2 = $[5];
|
|
213
|
-
}
|
|
214
|
-
let t3;
|
|
215
|
-
if ($[6] !== header) {
|
|
216
|
-
t3 = header === void 0 ? null : /* @__PURE__ */ jsx(Header, {
|
|
217
|
-
...props(collectionStyles.header),
|
|
193
|
+
if ($[0] !== header || $[1] !== variant) {
|
|
194
|
+
t2 = header === void 0 ? null : /* @__PURE__ */ jsx(Header, {
|
|
195
|
+
...props(collectionStyles.header, variant === "menu" && collectionStyles.headerMenu),
|
|
218
196
|
children: header
|
|
219
197
|
});
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
198
|
+
$[0] = header;
|
|
199
|
+
$[1] = variant;
|
|
200
|
+
$[2] = t2;
|
|
201
|
+
} else t2 = $[2];
|
|
202
|
+
let t3;
|
|
203
|
+
if ($[3] !== T0 || $[4] !== children || $[5] !== props$2 || $[6] !== t1 || $[7] !== t2) {
|
|
204
|
+
t3 = /* @__PURE__ */ jsxs(T0, {
|
|
205
|
+
...props$2,
|
|
226
206
|
...t1,
|
|
227
|
-
|
|
228
|
-
children: [t3, children]
|
|
207
|
+
children: [t2, children]
|
|
229
208
|
});
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
} else
|
|
237
|
-
return
|
|
209
|
+
$[3] = T0;
|
|
210
|
+
$[4] = children;
|
|
211
|
+
$[5] = props$2;
|
|
212
|
+
$[6] = t1;
|
|
213
|
+
$[7] = t2;
|
|
214
|
+
$[8] = t3;
|
|
215
|
+
} else t3 = $[8];
|
|
216
|
+
return t3;
|
|
238
217
|
}
|
|
239
218
|
ListBox.Item = ListBoxItem;
|
|
240
219
|
ListBox.LoadMore = ListBoxLoadMore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","ListBox","ListBoxItem","RACListBoxItem","RACListBoxLoadMoreItem","ListBoxSection","RACListBoxSection","collectionStyles","containerClasses","rowItemStyles","textOf","useRipple","mergeStatefulStyles","mergeStyles","children","leading","overline","supporting","trailing","label","header","emptyState","itemContent","ripple","state","isDisabled","isSelected","props","$","t0","t1","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","textValue","T0","t2","t3","handlers","t4","t5","surface","t6","ListBoxLoadMore","loading","section","undefined","Item","LoadMore","Section","RACListBox"],"sources":["../../../src/components/list-box/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ListBoxItemRenderProps, ListBoxItemProps as RACListBoxItemProps, ListBoxLoadMoreItemProps as RACListBoxLoadMoreItemProps, ListBoxProps as RACListBoxProps, ListBoxSectionProps as RACListBoxSectionProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Header, ListBox as RACListBox, ListBoxItem as RACListBoxItem, ListBoxLoadMoreItem as RACListBoxLoadMoreItem, ListBoxSection as RACListBoxSection } from 'react-aria-components';\nimport { CollectionEmpty, CollectionLoadMore } from '../../collection';\nimport { collectionStyles, containerClasses, rowItemStyles } from '../../collection/styles';\nimport { textOf } from '../../collection/text';\nimport { useRipple } from '../../hooks/useRipple';\nimport { RowContent } from '../../row';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\n\n// The lists page's selectable list. Each option is the row every list here\n// draws — `src/row`, shared with ListItem and with every collection the\n// coverage plan adds after this one — so the 56dp floor, the body-large\n// headline, the body-medium supporting line, the state layers and the\n// disabled treatment are all that module's and none of them is written\n// again. What is here is the container around those rows, the section and\n// its header, and the row the list shows while it is fetching more.\n//\n// The container takes the page's 8dp above and below its rows and no\n// background of its own, which is what lets the same list sit on the page\n// and inside a popover without knowing which it is in. Select, ComboBox and\n// Autocomplete are each a field plus one of these in an overlay, so that is\n// not a detail — it is the reason the container is transparent.\n//\n// A selected option takes primary container and on primary container, the\n// page's selected state, through the row module's `list` variant. The page\n// also draws a checkbox in the trailing slot on a list that selects more\n// than one; that is left to the call site rather than added by the option,\n// since which of the two affordances a list wants is the list's decision and\n// the slot is already there for it.\n//\n// Three things are worth knowing about how this maps onto React Aria.\n//\n// **The option's styles are a function of its render state.** StyleX cannot\n// target `[data-selected]` on the element it is styling, so selection,\n// disabled and the rest are read from the state React Aria hands the\n// `className` function — the same mechanism Tabs and Chip use, wrapped in\n// `mergeStatefulStyles` so a call site's own `className` survives.\n//\n// **A section's heading is React Aria's `Header`**, which is what points the\n// section's `aria-labelledby` at it. The lists page names no subhead in its\n// anatomy, so the type is title-small in on surface variant at the row's own\n// 16dp inline padding, which is what the page's own guidance draws.\n//\n// **The load-more row is a sentinel, not a button.** React Aria's\n// `ListBoxLoadMoreItem` calls `onLoadMore` when it comes into view and\n// renders whatever it is given while `isLoading`; ours renders the ring, so\n// a list that fetches as it scrolls says so with the same indicator every\n// other pending state in the library uses.\n\ntype ListBoxItemProps<T extends object = object> = {\n /** The option's headline — the one thing it is mostly about. */\n children?: ReactNode;\n /** A function may compute the class from the option's render state. */\n className?: RACListBoxItemProps<T>['className'];\n /** Content before the headline: an avatar, an icon, a checkbox. */\n leading?: ReactNode;\n /**\n * A line above the headline, in the page's label-small and the same muted\n * role the supporting line takes — a category, a date, a status. Given\n * alongside `supporting` it makes the row the page's three-line item.\n */\n overline?: ReactNode;\n /** A function may compute the style from the option's render state. */\n style?: RACListBoxItemProps<T>['style'];\n /** A second line under the headline, in the muted role. */\n supporting?: ReactNode;\n /** Content after the headline, such as an amount or a control. */\n trailing?: ReactNode;\n} & Omit<RACListBoxItemProps<T>, 'children' | 'className' | 'style'>;\ntype ListBoxLoadMoreProps = Omit<RACListBoxLoadMoreItemProps, 'children'> & {\n /**\n * What the row says while it is loading. Read by a screen reader; the ring\n * itself carries no text.\n * Left out, it is the word for it in the I18nProvider's locale — \"Loading\n * more\" in English.\n */\n label?: string;\n};\ntype ListBoxProps<T extends object = object> = {\n /** A function may compute the class from the list's render state. */\n className?: RACListBoxProps<T>['className'];\n /**\n * What the list shows when nothing is in it — after a search that matched\n * nothing, usually. Left out, it is a muted row saying \"No results\" in the\n * I18nProvider's locale, which an `Autocomplete` around the list also\n * announces. One of the call site's own replaces the announcement as well\n * as the row, so what it says to a screen reader is the call site's too.\n */\n renderEmptyState?: RACListBoxProps<T>['renderEmptyState'];\n /** A function may compute the style from the list's render state. */\n style?: RACListBoxProps<T>['style'];\n} & Omit<RACListBoxProps<T>, 'className' | 'renderEmptyState' | 'style'>;\ntype ListBoxSectionProps<T extends object = object> = Omit<RACListBoxSectionProps<T>, 'children'> & {\n /**\n * The options in the section. A section built from data puts React Aria's\n * `Collection` in here rather than a render function, since the header is\n * an element beside them.\n */\n children?: ReactNode;\n /**\n * The section's heading, rendered through React Aria's header so the\n * section is named by it. A section without one is a group with no name.\n */\n header?: ReactNode;\n};\n\n// The default empty state, at module scope so every list hands React Aria\n// the same function.\nfunction emptyState() {\n return <CollectionEmpty variant=\"list\" />;\n}\n\n// What the option draws, from React Aria's render state. Built by a call\n// 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\n// on its inputs.\n//\n// It reads the render state for one thing: which colour the supporting line\n// takes. The muted role the page gives it holds only on the surface — over a\n// selected row's container it is a second colour family, and on a disabled\n// row it stays at full strength while the headline above it fades. The row\n// module decides; this hands it the two flags.\nfunction itemContent(children: ReactNode, leading: ReactNode, overline: ReactNode, supporting: ReactNode, trailing: ReactNode, ripple: ReactNode) {\n return (state: ListBoxItemRenderProps) => <>\n <RowContent isDisabled={state.isDisabled} isSelected={state.isSelected} leading={leading} overline={overline} supporting={supporting} trailing={trailing}>\n {children}\n </RowContent>\n {state.isDisabled ? null : ripple}\n </>;\n}\n\n// StyleX cannot target `[data-selected]` on the element it is styling, so an\n// option's state comes from the render state React Aria hands its className.\n// The order matters: `disabled` is applied last so its ground and colour\n// win over the selected container's. The state layers come from the render\n// state as well — see `focusVisible` in src/row/styles.ts — and React Aria\n// reports none of them on a disabled option, so nothing has to outrank them.\n//\n// A supporting line moves the option from the page's one-line container\n// height to its two-line one, which is a floor rather than something the\n// row's own box arrives at — see `twoLine` in `src/row/styles.ts`. Taken as\n// an argument rather than read from the render state, since React Aria\n// reports what an option is doing and not what it holds; the row is built by\n// a call for the same reason `itemContent` is.\n/**\n * A list of options one or more of which can be selected. Selection is React\n * Aria's: set `selectionMode` to `single` or `multiple`, and pass\n * `selectedKeys` with `onSelectionChange` to control it or\n * `defaultSelectedKeys` to let it keep its own. A list that only responds to\n * a press takes `onAction` on the option instead.\n *\n * Composed from parts, since an option's slots take arbitrary content:\n * `ListBox.Item`, `ListBox.Section` and `ListBox.LoadMore`. Name the list\n * with `aria-label` or `aria-labelledby` — nothing here labels it for you.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n *\n * A list with nothing in it shows a muted \"No results\" row in place of its\n * options, which is what a search that matches nothing leaves; pass\n * `renderEmptyState` to draw something else.\n */\nfunction ListBox<T extends object>(props: ListBoxProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACListBox renderEmptyState={emptyState} {...props} {...mergeStatefulStyles(containerClasses, props)} />;\n}\n\n/**\n * One option. Its slots are the row's: `leading`, the headline as children,\n * `supporting` under it, and `trailing`. Give every option an `id` — that is\n * the key selection is reported by.\n */\nfunction ListBoxItem<T extends object = object>({\n children,\n leading,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n overline,\n supporting,\n textValue,\n trailing,\n ...props\n}: ListBoxItemProps<T> & RefAttributes<HTMLDivElement>) {\n // The press ripple List's rows draw — see ListItem there.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACListBoxItem textValue={textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(rowItemStyles(supporting, overline), props)}>\n {itemContent(children, leading, overline, supporting, trailing, ripple.surface)}\n </RACListBoxItem>;\n}\n\n/**\n * The row the list shows while it is fetching more. React Aria calls\n * `onLoadMore` when this comes into view, and draws it only while\n * `isLoading` — so a list that pages as it scrolls needs nothing else.\n */\nfunction ListBoxLoadMore({\n label,\n ...props\n}: ListBoxLoadMoreProps & RefAttributes<HTMLDivElement>) {\n return <RACListBoxLoadMoreItem {...props} {...mergeStyles(stylex.props(collectionStyles.loading), props)}>\n <CollectionLoadMore diameter=\"24px\" label={label} />\n </RACListBoxLoadMoreItem>;\n}\n\n/**\n * A named group of options. `header` names it, and is what a screen reader\n * reads before the options inside.\n */\nfunction ListBoxSection<T extends object = object>({\n children,\n header,\n ...props\n}: ListBoxSectionProps<T> & RefAttributes<HTMLElement>) {\n return <RACListBoxSection {...props} {...mergeStyles(stylex.props(collectionStyles.section), props)}>\n {header === undefined ? null : <Header {...stylex.props(collectionStyles.header)}>{header}</Header>}\n {children}\n </RACListBoxSection>;\n}\nListBox.Item = ListBoxItem;\nListBox.LoadMore = ListBoxLoadMore;\nListBox.Section = ListBoxSection;\nexport type { ListBoxItemProps, ListBoxLoadMoreProps, ListBoxProps, ListBoxSectionProps };\nexport { ListBoxItem, ListBoxLoadMore, ListBoxSection };\nexport default ListBox;"],"mappings":";;;;;;;;;;;;AAgHA,SAASsB,aAAa;CACpB,OAAO,oBAAC,iBAAD,EAAiB,SAAQ,OAAM,CAAA;AACxC;AAYA,SAASC,YAAYR,UAAqBC,SAAoBC,UAAqBC,YAAuBC,UAAqBK,QAAmB;CAChJ,QAAQC,UAAkC,qBAAA,UAAA,EAAA,UAAA,CACtC,oBAAC,YAAD;EAAY,YAAYA,MAAMC;EAAY,YAAYD,MAAME;EAAqBX;EAAmBC;EAAsBC;EAAsBC;EAC7IJ;CACS,CAAA,GACXU,MAAMC,aAAa,OAAOF,MAC7B,EAAA,CAAA;AACJ;;;;;;;;;;;;;;;;;;;AAiCA,SAAAtB,QAAA0B,OAAA;CAAA,MAAAC,IAAA7B,EAAA,CAAA;CAAA,IAAA8B;CAAA,IAAAD,EAAA,OAAAD,OAAA;EACkEE,KAAAjB,oBAAoBJ,kBAAkBmB,KAAK;EAACC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,IAAAE;CAAA,IAAAF,EAAA,OAAAD,SAAAC,EAAA,OAAAC,IAAA;EAArGC,KAAA,oBAACsB,WAAD;GAA8B/B,kBAAAA;GAAU,GAAMM;GAAK,GAAME;EAA4C,CAAA;EAAID,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAzGE;AAAyG;;;;;;AAQlH,SAAA5B,YAAA2B,IAAA;CAAA,MAAAD,IAAA7B,EAAA,EAAA;CAAgD,MAAA,EAAAe,UAAAC,SAAAgB,eAAAC,iBAAAC,eAAAC,gBAAAC,aAAAnB,UAAAC,YAAAmB,WAAAlB,UAAA,GAAAS,UAAAE;CAaM,IAAAC;CAAA,IAAAF,EAAA,OAAAG,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,EAAA,MAAAE;EAAAF,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAHfa;AAGe;AAExBxC,QAAQgD,OAAO/C;AACfD,QAAQiD,WAAWL;AACnB5C,QAAQkD,UAAU9C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","useContext","ListBox","ListBoxItem","RACListBoxItem","RACListBoxLoadMoreItem","ListBoxSection","RACListBoxSection","OptionRowContext","collectionStyles","containerClasses","rowItemStyles","textOf","useRipple","mergeStatefulStyles","mergeStyles","children","leading","overline","supporting","trailing","label","header","EmptyRow","$","t0","t1","emptyState","itemContent","ripple","variant","state","isDisabled","isSelected","props","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","textValue","T0","t2","t3","handlers","t4","undefined","t5","surface","t6","ListBoxLoadMore","loading","loadingMenu","section","headerMenu","Item","LoadMore","Section","RACListBox"],"sources":["../../../src/components/list-box/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ListBoxItemRenderProps, ListBoxItemProps as RACListBoxItemProps, ListBoxLoadMoreItemProps as RACListBoxLoadMoreItemProps, ListBoxProps as RACListBoxProps, ListBoxSectionProps as RACListBoxSectionProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { Header, ListBox as RACListBox, ListBoxItem as RACListBoxItem, ListBoxLoadMoreItem as RACListBoxLoadMoreItem, ListBoxSection as RACListBoxSection } from 'react-aria-components';\nimport { CollectionEmpty, CollectionLoadMore } from '../../collection';\nimport { OptionRowContext } from '../../collection/context';\nimport { collectionStyles, containerClasses, rowItemStyles } from '../../collection/styles';\nimport { textOf } from '../../collection/text';\nimport { useRipple } from '../../hooks/useRipple';\nimport { RowContent } from '../../row';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\n\n// The lists page's selectable list. Each option is the row every list here\n// draws — `src/row`, shared with ListItem and with every collection the\n// coverage plan adds after this one — so the 56dp floor, the body-large\n// headline, the body-medium supporting line, the state layers and the\n// disabled treatment are all that module's and none of them is written\n// again. What is here is the container around those rows, the section and\n// its header, and the row the list shows while it is fetching more.\n//\n// The container takes the page's 8dp above and below its rows and no\n// background of its own, which is what lets the same list sit on the page\n// and inside a popover without knowing which it is in. Select, ComboBox and\n// Autocomplete are each a field plus one of these in an overlay, so that is\n// not a detail — it is the reason the container is transparent.\n//\n// A selected option takes primary container and on primary container, the\n// page's selected state, through the row module's `list` variant. The page\n// also draws a checkbox in the trailing slot on a list that selects more\n// than one; that is left to the call site rather than added by the option,\n// since which of the two affordances a list wants is the list's decision and\n// the slot is already there for it.\n//\n// **Inside a Select's or a ComboBox's popup the options are menu rows.**\n// Material Design draws an exposed dropdown menu, which is what those two\n// are, as a menu: 48dp rows at the menu's 12dp inset and icon gap, a\n// label-large label, and the menu's selected container. Each provides\n// `OptionRowContext` around its list, and the option, the section's header,\n// the empty row and the load-more row read it. A ListBox anywhere else keeps\n// the lists page's row.\n//\n// Three things are worth knowing about how this maps onto React Aria.\n//\n// **The option's styles are a function of its render state.** StyleX cannot\n// target `[data-selected]` on the element it is styling, so selection,\n// disabled and the rest are read from the state React Aria hands the\n// `className` function — the same mechanism Tabs and Chip use, wrapped in\n// `mergeStatefulStyles` so a call site's own `className` survives.\n//\n// **A section's heading is React Aria's `Header`**, which is what points the\n// section's `aria-labelledby` at it. The lists page names no subhead in its\n// anatomy, so the type is title-small in on surface variant at the row's own\n// 16dp inline padding, which is what the page's own guidance draws. Drawn as\n// a menu, it takes the menu's 12dp instead, so it lines up with the options\n// under it, as Menu's own section heading does.\n//\n// **The load-more row is a sentinel, not a button.** React Aria's\n// `ListBoxLoadMoreItem` calls `onLoadMore` when it comes into view and\n// renders whatever it is given while `isLoading`; ours renders the ring, so\n// a list that fetches as it scrolls says so with the same indicator every\n// other pending state in the library uses.\n\ntype ListBoxItemProps<T extends object = object> = {\n /** The option's headline — the one thing it is mostly about. */\n children?: ReactNode;\n /** A function may compute the class from the option's render state. */\n className?: RACListBoxItemProps<T>['className'];\n /** Content before the headline: an avatar, an icon, a checkbox. */\n leading?: ReactNode;\n /**\n * A line above the headline, in the page's label-small and the same muted\n * role the supporting line takes — a category, a date, a status. Given\n * alongside `supporting` it makes the row the page's three-line item.\n */\n overline?: ReactNode;\n /** A function may compute the style from the option's render state. */\n style?: RACListBoxItemProps<T>['style'];\n /** A second line under the headline, in the muted role. */\n supporting?: ReactNode;\n /** Content after the headline, such as an amount or a control. */\n trailing?: ReactNode;\n} & Omit<RACListBoxItemProps<T>, 'children' | 'className' | 'style'>;\ntype ListBoxLoadMoreProps = Omit<RACListBoxLoadMoreItemProps, 'children'> & {\n /**\n * What the row says while it is loading. Read by a screen reader; the ring\n * itself carries no text.\n * Left out, it is the word for it in the I18nProvider's locale — \"Loading\n * more\" in English.\n */\n label?: string;\n};\ntype ListBoxProps<T extends object = object> = {\n /** A function may compute the class from the list's render state. */\n className?: RACListBoxProps<T>['className'];\n /**\n * What the list shows when nothing is in it — after a search that matched\n * nothing, usually. Left out, it is a muted row saying \"No results\" in the\n * I18nProvider's locale, which an `Autocomplete` around the list also\n * announces. One of the call site's own replaces the announcement as well\n * as the row, so what it says to a screen reader is the call site's too.\n */\n renderEmptyState?: RACListBoxProps<T>['renderEmptyState'];\n /** A function may compute the style from the list's render state. */\n style?: RACListBoxProps<T>['style'];\n} & Omit<RACListBoxProps<T>, 'className' | 'renderEmptyState' | 'style'>;\ntype ListBoxSectionProps<T extends object = object> = Omit<RACListBoxSectionProps<T>, 'children'> & {\n /**\n * The options in the section. A section built from data puts React Aria's\n * `Collection` in here rather than a render function, since the header is\n * an element beside them.\n */\n children?: ReactNode;\n /**\n * The section's heading, rendered through React Aria's header so the\n * section is named by it. A section without one is a group with no name.\n */\n header?: ReactNode;\n};\nfunction EmptyRow() {\n return <CollectionEmpty variant={useContext(OptionRowContext)} />;\n}\n\n// The default empty state, at module scope so every list hands React Aria\n// the same function. A component rather than the element itself, so it reads\n// which row the list draws — a menu row inside a Select's or a ComboBox's\n// popup.\nfunction emptyState() {\n return <EmptyRow />;\n}\n\n// What the option draws, from React Aria's render state. Built by a call\n// 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\n// on its inputs.\n//\n// It reads the render state for one thing: which colour the supporting line\n// takes. The muted role the page gives it holds only on the surface — over a\n// selected row's container it is a second colour family, and on a disabled\n// row it stays at full strength while the headline above it fades. The row\n// module decides; this hands it the two flags.\nfunction itemContent(children: ReactNode, leading: ReactNode, overline: ReactNode, supporting: ReactNode, trailing: ReactNode, ripple: ReactNode, variant: 'list' | 'menu') {\n return (state: ListBoxItemRenderProps) => <>\n <RowContent isDisabled={state.isDisabled} isSelected={state.isSelected} leading={leading} overline={overline} supporting={supporting} trailing={trailing} variant={variant}>\n {children}\n </RowContent>\n {state.isDisabled ? null : ripple}\n </>;\n}\n\n// StyleX cannot target `[data-selected]` on the element it is styling, so an\n// option's state comes from the render state React Aria hands its className.\n// The order matters: `disabled` is applied last so its ground and colour\n// win over the selected container's. The state layers come from the render\n// state as well — see `focusVisible` in src/row/styles.ts — and React Aria\n// reports none of them on a disabled option, so nothing has to outrank them.\n//\n// A supporting line moves the option from the page's one-line container\n// height to its two-line one, which is a floor rather than something the\n// row's own box arrives at — see `twoLine` in `src/row/styles.ts`. Taken as\n// an argument rather than read from the render state, since React Aria\n// reports what an option is doing and not what it holds; the row is built by\n// a call for the same reason `itemContent` is.\n/**\n * A list of options one or more of which can be selected. Selection is React\n * Aria's: set `selectionMode` to `single` or `multiple`, and pass\n * `selectedKeys` with `onSelectionChange` to control it or\n * `defaultSelectedKeys` to let it keep its own. A list that only responds to\n * a press takes `onAction` on the option instead.\n *\n * Composed from parts, since an option's slots take arbitrary content:\n * `ListBox.Item`, `ListBox.Section` and `ListBox.LoadMore`. Name the list\n * with `aria-label` or `aria-labelledby` — nothing here labels it for you.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n *\n * A list with nothing in it shows a muted \"No results\" row in place of its\n * options, which is what a search that matches nothing leaves; pass\n * `renderEmptyState` to draw something else.\n */\nfunction ListBox<T extends object>(props: ListBoxProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACListBox renderEmptyState={emptyState} {...props} {...mergeStatefulStyles(containerClasses, props)} />;\n}\n\n/**\n * One option. Its slots are the row's: `leading`, the headline as children,\n * `supporting` under it, and `trailing`. Give every option an `id` — that is\n * the key selection is reported by.\n */\nfunction ListBoxItem<T extends object = object>({\n children,\n leading,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n overline,\n supporting,\n textValue,\n trailing,\n ...props\n}: ListBoxItemProps<T> & RefAttributes<HTMLDivElement>) {\n const variant = useContext(OptionRowContext);\n // The press ripple List's rows draw — see ListItem there.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACListBoxItem textValue={textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(rowItemStyles(supporting, overline, undefined, variant), props)}>\n {itemContent(children, leading, overline, supporting, trailing, ripple.surface, variant)}\n </RACListBoxItem>;\n}\n\n/**\n * The row the list shows while it is fetching more. React Aria calls\n * `onLoadMore` when this comes into view, and draws it only while\n * `isLoading` — so a list that pages as it scrolls needs nothing else.\n */\nfunction ListBoxLoadMore({\n label,\n ...props\n}: ListBoxLoadMoreProps & RefAttributes<HTMLDivElement>) {\n const variant = useContext(OptionRowContext);\n return <RACListBoxLoadMoreItem {...props} {...mergeStyles(stylex.props(collectionStyles.loading, variant === 'menu' && collectionStyles.loadingMenu), props)}>\n <CollectionLoadMore diameter=\"24px\" label={label} />\n </RACListBoxLoadMoreItem>;\n}\n\n/**\n * A named group of options. `header` names it, and is what a screen reader\n * reads before the options inside.\n */\nfunction ListBoxSection<T extends object = object>({\n children,\n header,\n ...props\n}: ListBoxSectionProps<T> & RefAttributes<HTMLElement>) {\n const variant = useContext(OptionRowContext);\n return <RACListBoxSection {...props} {...mergeStyles(stylex.props(collectionStyles.section), props)}>\n {header === undefined ? null : <Header {...stylex.props(collectionStyles.header, variant === 'menu' && collectionStyles.headerMenu)}>\n {header}\n </Header>}\n {children}\n </RACListBoxSection>;\n}\nListBox.Item = ListBoxItem;\nListBox.LoadMore = ListBoxLoadMore;\nListBox.Section = ListBoxSection;\nexport type { ListBoxItemProps, ListBoxLoadMoreProps, ListBoxProps, ListBoxSectionProps };\nexport { ListBoxItem, ListBoxLoadMore, ListBoxSection };\nexport default ListBox;"],"mappings":";;;;;;;;;;;;;;AAyHA,SAAAwB,WAAA;CAAA,MAAAC,IAAAzB,EAAA,CAAA;CACmC,MAAA0B,KAAAxB,WAAWO,gBAAgB;CAAC,IAAAkB;CAAA,IAAAF,EAAA,OAAAC,IAAA;EAAtDC,KAAA,oBAAC,iBAAD,EAA0B,SAAAD,GAA4B,CAAA;EAAID,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAA1DE;AAA0D;AAOnE,SAASC,aAAa;CACpB,OAAO,oBAAC,UAAD,CAAS,CAAA;AAClB;AAYA,SAASC,YAAYZ,UAAqBC,SAAoBC,UAAqBC,YAAuBC,UAAqBS,QAAmBC,SAA0B;CAC1K,QAAQC,UAAkC,qBAAA,YAAA,EAAA,UAAA,CACtC,oBAAC,YAAD;EAAY,YAAYA,MAAMC;EAAY,YAAYD,MAAME;EAAqBhB;EAAmBC;EAAsBC;EAAsBC;EAAmBU;EAChKd;CACS,CAAA,GACXe,MAAMC,aAAa,OAAOH,MAC7B,EAAA,CAAA;AACJ;;;;;;;;;;;;;;;;;;;AAiCA,SAAA3B,QAAAgC,OAAA;CAAA,MAAAV,IAAAzB,EAAA,CAAA;CAAA,IAAA0B;CAAA,IAAAD,EAAA,OAAAU,OAAA;EACkET,KAAAX,oBAAoBJ,kBAAkBwB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AA,OAAAU,WAAAV,EAAA,OAAAE,MAAAF,EAAA,OAAAkB,IAAA;EAHRC,KAAA,qBAAC,IAAD;GAAkB,GAAKT;GAAK,GAAMR;GAAlC,UAAA,CACFgB,IAGA1B,QAJoB;;EAKHQ,EAAA,KAAAiB;EAAAjB,EAAA,KAAAR;EAAAQ,EAAA,KAAAU;EAAAV,EAAA,KAAAE;EAAAF,EAAA,KAAAkB;EAAAlB,EAAA,KAAAmB;CAAA,OAAAA,KAAAnB,EAAA;CAAA,OALfmB;AAKe;AAExBzC,QAAQqD,OAAOpD;AACfD,QAAQsD,WAAWN;AACnBhD,QAAQuD,UAAUnD"}
|
|
@@ -16,12 +16,12 @@ const styles = { destinations: {
|
|
|
16
16
|
kXwgrk: "xdt5ytf",
|
|
17
17
|
kzQI83: "x1iyjqo2",
|
|
18
18
|
kmuXW: "xs83m0k",
|
|
19
|
-
kqGvvJ: "
|
|
20
|
-
kUOVxO: "
|
|
19
|
+
kqGvvJ: "x15zwqr x196bl58",
|
|
20
|
+
kUOVxO: "x13jr4wj x1knonev",
|
|
21
21
|
kAzted: "x2lwn1j",
|
|
22
22
|
kORKVm: "x1odjw0f",
|
|
23
|
-
k8WAf4: "
|
|
24
|
-
kg3NbH: "
|
|
23
|
+
k8WAf4: "xifx94n x1flqomg",
|
|
24
|
+
kg3NbH: "xm9j1uf x1snzwe2",
|
|
25
25
|
$$css: true
|
|
26
26
|
} };
|
|
27
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","useRender","mergeStyles","styles","destinations","kGNEyG","kSGwAc","kB7OPa","k1xSpc","kCS8Yb","kXwgrk","kzQI83","kmuXW","kqGvvJ","kUOVxO","kAzted","kORKVm","k8WAf4","kg3NbH","$$css","header","isExpanded","selectedRoute","NavigationRail","t0","$","children","context","render","t1","t2","t3","t4","t5","t6","t7","t8","props","undefined","t9","t10","form","0","className","1","defaultTagName","rail","NavigationRailItem","Item"],"sources":["../../../src/components/navigation-rail/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useMemo } from 'react';\nimport type { NavigationItemProps } from '../../navigation';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { NavigationItem, NavigationList } from '../../navigation';\nimport { NavigationContext } from '../../navigation/context';\nimport { useRender } from '../../render/useRender';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, spacing } from '../../tokens/design.tokens.stylex';\n\n// The navigation rail page's rail, in both its forms: collapsed, a 96dp\n// column of vertical destinations down the leading edge of a medium or wider\n// window, and expanded, between 220dp and 360dp with each destination the\n// page's 56dp horizontal pill. The expanded rail is what the page has\n// replace the navigation drawer, so an app's top-level destinations reach\n// every window size between this and NavigationBar. Both forms are on the\n// surface role, with their contents 44dp from the top: the first destination,\n// or a header when the rail has one — a menu button that expands it, say —\n// with the first destination 40dp under it. The destinations are\n// `src/navigation`'s, shared with NavigationBar, which holds their values.\n//\n// A collapsed destination's label stays on one line in the 88dp under its\n// indicator, about thirteen characters of label medium. A longer one is cut\n// short with an ellipsis and shows its full text in the browser's tooltip on\n// hover — see `src/navigation`. Once the reader has enlarged their text, by\n// a text-only zoom or a minimum font size, the label takes further lines\n// instead and its destination grows to hold them, since that text no longer\n// fits the lengths around it — see src/hooks/useEnlargedText.ts. The expanded\n// rail's labels sit beside their icons, with the rest of the rail's 360dp at\n// most.\n//\n// The rail is a `<nav>`, and a page usually has more than one navigation\n// landmark, so name it with `aria-label`.\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.\nconst FORCED_COLORS = '@media (forced-colors: active)';\n\n// How far a destination's focus ring reaches past it: the 2dp offset and\n// the 2dp ring, and 2dp more under forced colours, where the ring is twice\n// as heavy — see `ringWeight` in src/navigation/styles.ts. The destinations\n// scroll, and a scroll container clips what overflows it, so the block they\n// scroll in is padded by this much and pulled back out by as much, which\n// leaves every destination where it was and every ring whole.\nconst RING_REACH = {\n default: '4px',\n [FORCED_COLORS]: '6px'\n};\nconst RING_PULL = {\n default: '-4px',\n [FORCED_COLORS]: '-6px'\n};\nconst styles = {\n destinations: {\n kGNEyG: \"x6s0dn4\",\n kSGwAc: \"xkh2ocl\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kCS8Yb: \"xdl72j9\",\n kXwgrk: \"xdt5ytf\",\n kzQI83: \"x1iyjqo2\",\n kmuXW: \"xs83m0k\",\n kqGvvJ: \"x1k49i25 x1n2n1b5\",\n kUOVxO: \"xr6ywxm x1g55pzu\",\n kAzted: \"x2lwn1j\",\n kORKVm: \"x1odjw0f\",\n k8WAf4: \"x12ulsxz xf989l1\",\n kg3NbH: \"xfn1xvj x1rsxkid\",\n $$css: true\n }\n};\ntype NavigationRailProps = RenderComponentProps<'nav'> & {\n /**\n * What the rail draws above its destinations: a menu button that expands\n * it, or a floating action button.\n */\n header?: ReactNode;\n /**\n * Whether the rail is in its expanded form, each destination a pill with\n * its label beside the icon, rather than collapsed with the label under it.\n * @default false\n */\n isExpanded?: boolean;\n /**\n * The route of the current destination, matched exactly against each\n * destination's `href`. The match carries `aria-current=\"page\"` and the\n * active indicator. For a route nested under a destination, which no\n * `href` matches whole, mark that destination with its own `isCurrent`.\n */\n selectedRoute?: string;\n};\n\n/**\n * The column of top-level destinations a medium or wider window keeps at its\n * leading edge, collapsed or, with `isExpanded`, expanded. Each destination\n * is a link, so it routes through React Aria's `RouterProvider` when the app\n * has one.\n *\n * ```tsx\n * <NavigationRail aria-label=\"Label\" selectedRoute=\"/first\">\n * <NavigationRail.Item href=\"/first\" icon={<FirstIcon />}>\n * First item\n * </NavigationRail.Item>\n * <NavigationRail.Item href=\"/second\" icon={<SecondIcon />}>\n * Second item\n * </NavigationRail.Item>\n * </NavigationRail>\n * ```\n *\n * The call site's `className` and `style` land on the `<nav>`.\n */\nfunction NavigationRail({\n children,\n header,\n isExpanded = false,\n render,\n selectedRoute,\n ...props\n}: NavigationRailProps) {\n const context = useMemo(() => ({\n form: isExpanded ? 'expanded' as const : 'collapsed' as const,\n selectedRoute\n }), [isExpanded, selectedRoute]);\n const rail = useRender({\n defaultTagName: 'nav',\n props: {\n ...props,\n ...mergeStyles({\n 0: {\n className: \"x6s0dn4 x14s9m32 x5yr21d x9f619 x78zum5 xdt5ytf x2lah0s x8i8c5o xlaft8j xzoy561 x13oubkp\"\n },\n 1: {\n className: \"x6s0dn4 x14s9m32 x5yr21d x9f619 x78zum5 xdt5ytf x2lah0s x8i8c5o xlaft8j xeq5yr9 xxc7z9f x12rczxh x17qtykl\"\n }\n }[!!isExpanded << 0], props),\n children: <>\n {header === undefined ? null : <div {...{\n 0: {\n className: \"x6s0dn4 x9f619 x78zum5 xdt5ytf xqa3g7y\"\n },\n 1: {\n className: \"x9f619 x78zum5 xdt5ytf x1cy8zhl xkh2ocl x1mgj515 xdxifnh\"\n }\n }[!!isExpanded << 0]}>\n {header}\n </div>}\n <NavigationList layout={styles.destinations}>\n {children}\n </NavigationList>\n </>\n },\n render\n });\n return <NavigationContext value={context}>{rail}</NavigationContext>;\n}\n\n/**\n * One destination of a navigation rail — an icon, a label and, when it is the\n * current one, the active indicator. See `NavigationRail`.\n *\n * Defined here rather than re-exported from `src/navigation`: a re-export\n * let the build hand the package entry that module directly, past this\n * module's client directive, and a server component importing it got the\n * component itself rather than a reference to a client one.\n */\nfunction NavigationRailItem(props: NavigationItemProps & RefAttributes<HTMLAnchorElement>) {\n return <NavigationItem {...props} />;\n}\nNavigationRail.Item = NavigationRailItem;\nexport type { NavigationItemProps as NavigationRailItemProps, NavigationRailProps };\nexport { NavigationRailItem };\nexport default NavigationRail;"],"mappings":";;;;;;;;;AAwDA,MAAMG,SAAS,EACbC,cAAc;CACZC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;CACPC,QAAQ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GAAAM,gBACLd;GAAKM,OACdD;GAyBNR;EAEH;EAACH,EAAA,MAAAG;EAAAH,EAAA,MAAAM;EAAAN,EAAA,MAAAW;EAAAX,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CA7BD,MAAAqB,OAAa7C,GAAUsC,EA6BtB;CAAE,IAAAC;CAAA,IAAAf,EAAA,QAAAE,WAAAF,EAAA,QAAAqB,MAAA;EACIN,MAAA,oBAAC,mBAAD;GAA0Bb,OAAAA;GAAUmB,UAAAA;EAAlB,CAAA;EAA2CrB,EAAA,MAAAE;EAAAF,EAAA,MAAAqB;EAAArB,EAAA,MAAAe;CAAA,OAAAA,MAAAf,EAAA;CAAA,OAA7De;AAA6D;;;;;;;;;;AAYtE,SAAAO,mBAAAV,OAAA;CAAA,MAAAZ,IAAAzB,EAAA,CAAA;CAAA,IAAAwB;CAAA,IAAAC,EAAA,OAAAY,OAAA;EACSb,KAAA,oBAAC,gBAAD,EAAe,GAAKa,MAAK,CAAA;EAAIZ,EAAA,KAAAY;EAAAZ,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,OAA7BD;AAA6B;AAEtCD,eAAeyB,OAAOD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","useRender","mergeStyles","styles","destinations","kGNEyG","kSGwAc","kB7OPa","k1xSpc","kCS8Yb","kXwgrk","kzQI83","kmuXW","kqGvvJ","kUOVxO","kAzted","kORKVm","k8WAf4","kg3NbH","$$css","header","isExpanded","selectedRoute","NavigationRail","t0","$","children","context","render","t1","t2","t3","t4","t5","t6","t7","t8","props","undefined","t9","t10","form","0","className","1","defaultTagName","rail","NavigationRailItem","Item"],"sources":["../../../src/components/navigation-rail/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useMemo } from 'react';\nimport type { NavigationItemProps } from '../../navigation';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { NavigationItem, NavigationList } from '../../navigation';\nimport { NavigationContext } from '../../navigation/context';\nimport { useRender } from '../../render/useRender';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, spacing } from '../../tokens/design.tokens.stylex';\n\n// The navigation rail page's rail, in both its forms: collapsed, a 96dp\n// column of vertical destinations down the leading edge of a medium or wider\n// window, and expanded, between 220dp and 360dp with each destination the\n// page's 56dp horizontal pill. The expanded rail is what the page has\n// replace the navigation drawer, so an app's top-level destinations reach\n// every window size between this and NavigationBar. Both forms are on the\n// surface role, with their contents 44dp from the top: the first destination,\n// or a header when the rail has one — a menu button that expands it, say —\n// with the first destination 40dp under it. The destinations are\n// `src/navigation`'s, shared with NavigationBar, which holds their values.\n//\n// A collapsed destination's label stays on one line in the 88dp under its\n// indicator, about thirteen characters of label medium. A longer one is cut\n// short with an ellipsis and shows its full text in the browser's tooltip on\n// hover — see `src/navigation`. Once the reader has enlarged their text, by\n// a text-only zoom or a minimum font size, the label takes further lines\n// instead and its destination grows to hold them, since that text no longer\n// fits the lengths around it — see src/hooks/useEnlargedText.ts. The expanded\n// rail's labels sit beside their icons, with the rest of the rail's 360dp at\n// most.\n//\n// The rail is a `<nav>`, and a page usually has more than one navigation\n// landmark, so name it with `aria-label`.\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.\nconst FORCED_COLORS = '@media (forced-colors: active)';\n\n// How far a destination's focus ring reaches past it: the 2dp offset and\n// the 3dp ring, and 3dp more under forced colours, where the ring is twice\n// as heavy — see `ringWeight` in src/navigation/styles.ts. The destinations\n// scroll, and a scroll container clips what overflows it, so the block they\n// scroll in is padded by this much and pulled back out by as much, which\n// leaves every destination where it was and every ring whole.\nconst RING_REACH = {\n default: '5px',\n [FORCED_COLORS]: '8px'\n};\nconst RING_PULL = {\n default: '-5px',\n [FORCED_COLORS]: '-8px'\n};\nconst styles = {\n destinations: {\n kGNEyG: \"x6s0dn4\",\n kSGwAc: \"xkh2ocl\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kCS8Yb: \"xdl72j9\",\n kXwgrk: \"xdt5ytf\",\n kzQI83: \"x1iyjqo2\",\n kmuXW: \"xs83m0k\",\n kqGvvJ: \"x15zwqr x196bl58\",\n kUOVxO: \"x13jr4wj x1knonev\",\n kAzted: \"x2lwn1j\",\n kORKVm: \"x1odjw0f\",\n k8WAf4: \"xifx94n x1flqomg\",\n kg3NbH: \"xm9j1uf x1snzwe2\",\n $$css: true\n }\n};\ntype NavigationRailProps = RenderComponentProps<'nav'> & {\n /**\n * What the rail draws above its destinations: a menu button that expands\n * it, or a floating action button.\n */\n header?: ReactNode;\n /**\n * Whether the rail is in its expanded form, each destination a pill with\n * its label beside the icon, rather than collapsed with the label under it.\n * @default false\n */\n isExpanded?: boolean;\n /**\n * The route of the current destination, matched exactly against each\n * destination's `href`. The match carries `aria-current=\"page\"` and the\n * active indicator. For a route nested under a destination, which no\n * `href` matches whole, mark that destination with its own `isCurrent`.\n */\n selectedRoute?: string;\n};\n\n/**\n * The column of top-level destinations a medium or wider window keeps at its\n * leading edge, collapsed or, with `isExpanded`, expanded. Each destination\n * is a link, so it routes through React Aria's `RouterProvider` when the app\n * has one.\n *\n * ```tsx\n * <NavigationRail aria-label=\"Label\" selectedRoute=\"/first\">\n * <NavigationRail.Item href=\"/first\" icon={<FirstIcon />}>\n * First item\n * </NavigationRail.Item>\n * <NavigationRail.Item href=\"/second\" icon={<SecondIcon />}>\n * Second item\n * </NavigationRail.Item>\n * </NavigationRail>\n * ```\n *\n * The call site's `className` and `style` land on the `<nav>`.\n */\nfunction NavigationRail({\n children,\n header,\n isExpanded = false,\n render,\n selectedRoute,\n ...props\n}: NavigationRailProps) {\n const context = useMemo(() => ({\n form: isExpanded ? 'expanded' as const : 'collapsed' as const,\n selectedRoute\n }), [isExpanded, selectedRoute]);\n const rail = useRender({\n defaultTagName: 'nav',\n props: {\n ...props,\n ...mergeStyles({\n 0: {\n className: \"x6s0dn4 x14s9m32 x5yr21d x9f619 x78zum5 xdt5ytf x2lah0s x8i8c5o xlaft8j xzoy561 x13oubkp\"\n },\n 1: {\n className: \"x6s0dn4 x14s9m32 x5yr21d x9f619 x78zum5 xdt5ytf x2lah0s x8i8c5o xlaft8j xeq5yr9 xxc7z9f x12rczxh x17qtykl\"\n }\n }[!!isExpanded << 0], props),\n children: <>\n {header === undefined ? null : <div {...{\n 0: {\n className: \"x6s0dn4 x9f619 x78zum5 xdt5ytf xqa3g7y\"\n },\n 1: {\n className: \"x9f619 x78zum5 xdt5ytf x1cy8zhl xkh2ocl x1mgj515 xdxifnh\"\n }\n }[!!isExpanded << 0]}>\n {header}\n </div>}\n <NavigationList layout={styles.destinations}>\n {children}\n </NavigationList>\n </>\n },\n render\n });\n return <NavigationContext value={context}>{rail}</NavigationContext>;\n}\n\n/**\n * One destination of a navigation rail — an icon, a label and, when it is the\n * current one, the active indicator. See `NavigationRail`.\n *\n * Defined here rather than re-exported from `src/navigation`: a re-export\n * let the build hand the package entry that module directly, past this\n * module's client directive, and a server component importing it got the\n * component itself rather than a reference to a client one.\n */\nfunction NavigationRailItem(props: NavigationItemProps & RefAttributes<HTMLAnchorElement>) {\n return <NavigationItem {...props} />;\n}\nNavigationRail.Item = NavigationRailItem;\nexport type { NavigationItemProps as NavigationRailItemProps, NavigationRailProps };\nexport { NavigationRailItem };\nexport default NavigationRail;"],"mappings":";;;;;;;;;AAwDA,MAAMG,SAAS,EACbC,cAAc;CACZC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;CACPC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;;;;;;;;;;;;;;;;;;;;AAyCA,SAAAI,eAAAC,IAAA;CAAA,MAAAC,IAAAzB,EAAA,EAAA;CAAA,IAAA0B;CAAA,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