@kanso-labs/kanso-ui 0.43.7 → 0.44.1
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/README.md +1 -0
- package/dist/calendar/index.js +34 -10
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +30 -0
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/index.js +27 -18
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/label.js +32 -0
- package/dist/chip/label.js.map +1 -0
- package/dist/chip/styles.js +32 -2
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/text.js +24 -3
- package/dist/collection/text.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +9 -5
- package/dist/components/app-bar/index.js +400 -170
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +8 -1
- package/dist/components/calendar/index.js +129 -73
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/checkbox/index.js +31 -31
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +4 -2
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +35 -5
- package/dist/components/chip-group/index.js +137 -97
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/copy-field/index.js +1 -1
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +64 -6
- package/dist/components/currency/index.js +117 -40
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/dialog/index.d.ts +3 -1
- package/dist/components/dialog/index.js +115 -81
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure-group/index.js +1 -1
- package/dist/components/disclosure-group/index.js.map +1 -1
- package/dist/components/icon-button/index.js +18 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/keycap/index.d.ts +3 -0
- package/dist/components/keycap/index.js +30 -44
- package/dist/components/keycap/index.js.map +1 -1
- package/dist/components/list/index.d.ts +16 -2
- package/dist/components/list/index.js +124 -69
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-detail/index.d.ts +11 -3
- package/dist/components/list-detail/index.js +13 -6
- package/dist/components/list-detail/index.js.map +1 -1
- package/dist/components/list-item/index.d.ts +16 -1
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +6 -2
- package/dist/components/menu/index.js +22 -15
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +4 -1
- package/dist/components/meter/index.js +6 -0
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/navigation-bar/index.d.ts +14 -4
- package/dist/components/navigation-bar/index.js +77 -50
- package/dist/components/navigation-bar/index.js.map +1 -1
- package/dist/components/navigation-rail/index.d.ts +3 -2
- package/dist/components/navigation-rail/index.js +59 -52
- package/dist/components/navigation-rail/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +4 -1
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +3 -2
- package/dist/components/number-field/index.js +91 -115
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +3 -1
- package/dist/components/popover/index.js +102 -100
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +4 -2
- package/dist/components/progress-indicator/index.js +4 -3
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/radio-group/index.js +34 -24
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +11 -1
- package/dist/components/search-field/index.js +32 -28
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +9 -2
- package/dist/components/segmented-button/index.js +1 -1
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/separator/index.d.ts +19 -7
- package/dist/components/separator/index.js +36 -13
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.js +29 -25
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +4 -1
- package/dist/components/snackbar/index.js +140 -55
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/stack/index.d.ts +6 -3
- package/dist/components/stack/index.js +48 -31
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +16 -6
- package/dist/components/switch/index.js +116 -62
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +10 -1
- package/dist/components/text-area/index.js +21 -19
- package/dist/components/text-area/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +16 -2
- package/dist/components/text-field/index.js +49 -43
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/tooltip/index.d.ts +3 -1
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tree/index.d.ts +15 -3
- package/dist/components/tree/index.js +41 -28
- package/dist/components/tree/index.js.map +1 -1
- package/dist/control/index.js +26 -23
- package/dist/control/index.js.map +1 -1
- package/dist/control/styles.js +7 -1
- package/dist/control/styles.js.map +1 -1
- package/dist/field/index.js +220 -193
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +64 -8
- package/dist/field/styles.js.map +1 -1
- package/dist/glyphs/index.js +37 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/hooks/useClippedTitle.js +44 -0
- package/dist/hooks/useClippedTitle.js.map +1 -0
- package/dist/hooks/useRipple.js +7 -6
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/hooks/useScrollStop.js +133 -0
- package/dist/hooks/useScrollStop.js.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +34 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/indicator/index.js +18 -16
- package/dist/indicator/index.js.map +1 -1
- package/dist/indicator/styles.js +3 -0
- package/dist/indicator/styles.js.map +1 -1
- package/dist/keycap/context.js +7 -0
- package/dist/keycap/context.js.map +1 -0
- package/dist/layout.d.ts +4 -1
- package/dist/layout.js +4 -1
- package/dist/layout.js.map +1 -1
- package/dist/navigation/index.d.ts +16 -2
- package/dist/navigation/index.js +145 -44
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/styles.js +79 -16
- package/dist/navigation/styles.js.map +1 -1
- package/dist/row/index.js +92 -89
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +26 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/overlay.d.ts +6 -2
- package/dist/styles/overlay.js +4 -1
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles.css +296 -38
- package/dist/theme-scope.d.ts +5 -1
- package/dist/theme-scope.js +100 -51
- package/dist/theme-scope.js.map +1 -1
- package/dist/tokens/design.tokens.stylex.js.map +1 -1
- package/package.json +21 -20
- package/dist/hooks/useScrollable.js +0 -69
- package/dist/hooks/useScrollable.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","ButtonRenderProps","FocusableElement","ButtonProps","RACButtonProps","ToggleButtonProps","RACToggleButtonProps","ToggleButtonRenderProps","Button","ToggleButton","ChipKind","chipGlyph","chipLabel","chipPropsFor","useRipple","ariaAttributesOf","buttonRenderer","toggleButtonRenderer","mergeStatefulStyles","ChipActionProps","Omit","children","elevated","icon","variant","ChipFilterProps","ChipProps","ChipVariant","ActionChip","t0","$","t1","onClick","onContextMenu","onKeyDown","onKeyUp","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","render","props","undefined","element","aria","t2","ripple","isDisabled","T0","t3","t4","handlers","t5","actionChipClasses","t6","surface","actionChipContent","t7","kind","state","isSelected","Chip","isAction","chipContent","FilterChip","filterChipClasses","t8","_c"],"sources":["../../../src/components/chip/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode, RefAttributes } from 'react'\nimport type {\n ButtonRenderProps,\n FocusableElement,\n ButtonProps as RACButtonProps,\n ToggleButtonProps as RACToggleButtonProps,\n ToggleButtonRenderProps,\n} from 'react-aria-components'\n\nimport { Button, ToggleButton } from 'react-aria-components'\n\nimport type { ChipKind } from '../../chip'\n\nimport { chipGlyph, chipLabel, chipPropsFor } from '../../chip'\nimport { useRipple } from '../../hooks/useRipple'\nimport {\n ariaAttributesOf,\n buttonRenderer,\n toggleButtonRenderer,\n} from '../../render/aria'\nimport { mergeStatefulStyles } from '../../styles/merge'\n\n// The pill, its containers, its check and its disabled treatment are the\n// chip module's in `src/chip`, shared with the chips a ChipGroup draws; what\n// is here is React Aria's button around them. Three of the chips page's four\n// chips are drawn here, and `variant` picks the button:\n//\n// - **A filter chip**, the default, is React Aria's `ToggleButton`: a\n// two-state button announced through `aria-pressed`, which takes the\n// secondary container and the check once selected.\n// - **An assist or suggestion chip** is React Aria's `Button`: an action, so\n// nothing is announced as pressed and nothing is ever selected. The two\n// differ in the label's role alone; see `src/chip/styles.ts`.\n//\n// The page's fourth, the input chip, is ChipGroup's removable chip, and a\n// token in a TokenField.\n//\n// Two of the call site's props go on the element through `src/render/aria`\n// rather than through that spread, as `Button` and `IconButton` do. React\n// Aria builds a button's attributes from an allowlist that holds only the\n// labelling `aria-*` and the state it manages itself, so any other one — a\n// shortcut, an owned element — is dropped before it reaches the DOM. And it\n// wraps a keyboard handler it is given so that the event stops there unless\n// the handler asks otherwise, which is its convention rather than the DOM's;\n// on the element the handler bubbles, so an Escape pressed on a chip inside\n// a dialog still reaches the dialog.\n//\n// A press ripples, as it does on every other pressable control here: the\n// chips page names the ripple as the pressed state, beside the layer.\n\n/** An assist or suggestion chip: an action, drawn as a plain button. */\ntype ChipActionProps = Omit<RACButtonProps, 'children' | 'isPending'> & {\n /**\n * The chip's label. Required: the page draws no chip without one, and a\n * chip with none is an empty button to a screen reader.\n */\n children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline.\n * @default false\n */\n elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode\n /**\n * `assist` for an action the chip's context suggests, and `suggestion`\n * for one the product generates. Either is an action rather than a\n * selection, so neither is ever selected.\n */\n variant: 'assist' | 'suggestion'\n}\n\n/** A filter chip: a two-state button, the default. */\ntype ChipFilterProps = Omit<RACToggleButtonProps, 'children'> & {\n /**\n * The chip's label. A node rather than React Aria's node-or-function,\n * since the chip puts its own check before whatever this is and a function\n * would be handed a `defaultChildren` the chip never rendered. ChipGroup's\n * chip narrows it the same way, for the same reason. Required: the page\n * draws no chip without one, and a chip with none is an empty button to a\n * screen reader.\n */\n children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline. A selected one keeps the\n * secondary container.\n * @default false\n */\n elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is selected, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode\n /**\n * A filter chip, a two-state button.\n * @default 'filter'\n */\n variant?: 'filter'\n}\n\ntype ChipProps = ChipActionProps | ChipFilterProps\n\n/** Which of the chips page's chips a Chip is. */\ntype ChipVariant = 'assist' | 'filter' | 'suggestion'\n\nfunction ActionChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n variant,\n ...props\n}: ChipActionProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled, as on the filter chip. `onClick` goes through the\n // ripple too: on a mouse press the ripple ends on the click, so a call\n // site's own handler spread beside it would leave it pressed.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <Button\n render={buttonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(actionChipClasses(variant, elevated), props)}\n >\n {actionChipContent(children, icon, ripple.surface)}\n </Button>\n )\n}\n\n// An action chip's classes: the unselected pill, which it always is.\nfunction actionChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ButtonRenderProps) =>\n chipPropsFor({ ...state, isSelected: false }, { elevated, kind })\n}\n\n// What an action chip draws: its icon, if any, then the label, and the\n// ripple over both. Built by a call for the reason `chipContent` is.\nfunction actionChipContent(\n children: ReactNode,\n icon: ReactNode,\n surface: ReactNode,\n) {\n return (state: ButtonRenderProps) => (\n <>\n {chipGlyph({ isDisabled: state.isDisabled, isSelected: false }, icon)}\n {chipLabel(children)}\n {surface}\n </>\n )\n}\n\n/**\n * A chip. By default a filter chip, which is a two-state button, so its\n * selected state is React Aria's `isSelected`: pass it with `onChange` to\n * control it, or `defaultSelected` to let it keep its own state. Selection is\n * announced through `aria-pressed` rather than a role of its own.\n *\n * `variant=\"assist\"` and `variant=\"suggestion\"` draw the page's two action\n * chips instead: plain buttons, pressed with `onPress`, never selected.\n */\nfunction Chip(props: ChipProps & RefAttributes<HTMLButtonElement>) {\n if (isAction(props)) {\n return <ActionChip {...props} />\n }\n return <FilterChip {...props} />\n}\n\n// What the chip draws, from React Aria's render state: the check while it is\n// selected or its icon while it is not, then the label, and the ripple over\n// both. Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs.\nfunction chipContent(children: ReactNode, icon: ReactNode, surface: ReactNode) {\n return (state: ToggleButtonRenderProps) => (\n <>\n {chipGlyph(state, icon)}\n {chipLabel(children)}\n {surface}\n </>\n )\n}\n\nfunction FilterChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n variant = 'filter',\n ...props\n}: ChipFilterProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled: React Aria still forwards pointer events to a\n // disabled element, and a press that changes nothing should not look like\n // one. Typed as Button's ripple is, since React Aria types a toggle\n // button's pointer events against a <div> rather than the <button> it\n // renders. `onClick` goes through it for the action chip's reason.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <ToggleButton\n render={toggleButtonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(filterChipClasses(variant, elevated), props)}\n >\n {chipContent(children, icon, ripple.surface)}\n </ToggleButton>\n )\n}\n\n// A filter chip's classes, from its render state.\nfunction filterChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ToggleButtonRenderProps) =>\n chipPropsFor(state, { elevated, kind })\n}\n\n// Whether a chip is one of the two action chips. A guard rather than a\n// comparison at the call, since TypeScript does not narrow the union through\n// React Aria's mapped prop types on `variant` alone.\nfunction isAction(props: ChipProps): props is ChipActionProps {\n return props.variant === 'assist' || props.variant === 'suggestion'\n}\n\nexport type { ChipActionProps, ChipFilterProps, ChipProps, ChipVariant }\n\nexport default Chip\n"],"mappings":";;;;;;;;;AAkHA,SAAA+B,WAAAC,IAAA;CAAA,MAAAC,IAAAhC,EAAA,EAAA;CAAoB,MAAA,EAAAuB,UAAAC,UAAAS,IAAAR,MAAAS,SAAAC,eAAAC,WAAAC,SAAAC,iBAAAC,eAAAC,gBAAAC,aAAAC,QAAAhB,SAAA,GAAAiB,UAAAZ;CAElB,MAAAP,WAAAS,OAAAW,KAAAA,IAAA,QAAAX;CAcA,MAAAY,UAAgB;EAAAC,MAAQ7B,iBAAiB0B,KAAK;EAACP;EAAAC;CAAqB;CAAC,IAAAU;CAAA,IAAAf,EAAA,OAAAE,WAAAF,EAAA,OAAAG,iBAAAH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QAAAwB,MAAAxB,EAAA,QAAA2B,IAAA;EAN9CS,KAAA,oBAAC,IAAD;GACU,QAAAhB;GAAqC,GACzCE;GAAe,GACfX;GAAK,GACLa;GAEHG,UAAAA;EANU,CAAA;EAOE3B,EAAA,MAAAkB;EAAAlB,EAAA,MAAAW;EAAAX,EAAA,MAAAgB,OAAAK;EAAArB,EAAA,MAAAoB;EAAApB,EAAA,MAAAwB;EAAAxB,EAAA,MAAA2B;EAAA3B,EAAA,MAAAoC;CAAA,OAAAA,KAAApC,EAAA;CAAA,OAPfoC;AAOe;AAKnB,SAASD,kBAAkBP,MAAgBpC,UAAmB;CAC5D,QAAQqC,UACN9C,aAAa8C,OAAO;EAAErC;EAAUoC;CAAK,CAAC;AAC1C;AAKA,SAASI,SAASrB,OAA4C;CAC5D,OAAOA,MAAMjB,YAAY,YAAYiB,MAAMjB,YAAY;AACzD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","ButtonRenderProps","FocusableElement","ButtonProps","RACButtonProps","ToggleButtonProps","RACToggleButtonProps","ToggleButtonRenderProps","Button","ToggleButton","ChipKind","chipGlyph","chipLabel","chipPropsFor","useRipple","ariaAttributesOf","buttonRenderer","toggleButtonRenderer","mergeStatefulStyles","ChipActionProps","Omit","children","elevated","icon","variant","ChipFilterProps","ChipProps","ChipVariant","ActionChip","t0","$","t1","onClick","onContextMenu","onKeyDown","onKeyUp","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","render","props","undefined","element","aria","t2","ripple","isDisabled","T0","t3","t4","handlers","t5","actionChipClasses","t6","surface","actionChipContent","t7","kind","state","isSelected","Chip","isAction","chipContent","FilterChip","filterChipClasses","t8","_c"],"sources":["../../../src/components/chip/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode, RefAttributes } from 'react'\nimport type {\n ButtonRenderProps,\n FocusableElement,\n ButtonProps as RACButtonProps,\n ToggleButtonProps as RACToggleButtonProps,\n ToggleButtonRenderProps,\n} from 'react-aria-components'\n\nimport { Button, ToggleButton } from 'react-aria-components'\n\nimport type { ChipKind } from '../../chip'\n\nimport { chipGlyph, chipLabel, chipPropsFor } from '../../chip'\nimport { useRipple } from '../../hooks/useRipple'\nimport {\n ariaAttributesOf,\n buttonRenderer,\n toggleButtonRenderer,\n} from '../../render/aria'\nimport { mergeStatefulStyles } from '../../styles/merge'\n\n// The pill, its containers, its check and its disabled treatment are the\n// chip module's in `src/chip`, shared with the chips a ChipGroup draws; what\n// is here is React Aria's button around them. Three of the chips page's four\n// chips are drawn here, and `variant` picks the button:\n//\n// - **A filter chip**, the default, is React Aria's `ToggleButton`: a\n// two-state button announced through `aria-pressed`, which takes the\n// secondary container and the check once selected.\n// - **An assist or suggestion chip** is React Aria's `Button`: an action, so\n// nothing is announced as pressed and nothing is ever selected. The two\n// differ in the label's role alone; see `src/chip/styles.ts`.\n//\n// The page's fourth, the input chip, is ChipGroup's removable chip, and a\n// token in a TokenField.\n//\n// Two of the call site's props go on the element through `src/render/aria`\n// rather than through that spread, as `Button` and `IconButton` do. React\n// Aria builds a button's attributes from an allowlist that holds only the\n// labelling `aria-*` and the state it manages itself, so any other one — a\n// shortcut, an owned element — is dropped before it reaches the DOM. And it\n// wraps a keyboard handler it is given so that the event stops there unless\n// the handler asks otherwise, which is its convention rather than the DOM's;\n// on the element the handler bubbles, so an Escape pressed on a chip inside\n// a dialog still reaches the dialog.\n//\n// A press ripples, as it does on every other pressable control here: the\n// chips page names the ripple as the pressed state, beside the layer.\n\n/** An assist or suggestion chip: an action, drawn as a plain button. */\ntype ChipActionProps = Omit<RACButtonProps, 'children' | 'isPending'> & {\n /**\n * The chip's label. Required: the page draws no chip without one, and a\n * chip with none is an empty button to a screen reader.\n */\n children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline.\n * @default false\n */\n elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode\n /**\n * `assist` for an action the chip's context suggests, and `suggestion`\n * for one the product generates. Either is an action rather than a\n * selection, so neither is ever selected.\n */\n variant: 'assist' | 'suggestion'\n}\n\n/** A filter chip: a two-state button, the default. */\ntype ChipFilterProps = Omit<RACToggleButtonProps, 'children'> & {\n /**\n * The chip's label. A node rather than React Aria's node-or-function,\n * since the chip puts its own check before whatever this is and a function\n * would be handed a `defaultChildren` the chip never rendered. ChipGroup's\n * chip narrows it the same way, for the same reason. Required: the page\n * draws no chip without one, and a chip with none is an empty button to a\n * screen reader.\n */\n children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline. A selected one keeps the\n * secondary container.\n * @default false\n */\n elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is selected, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode\n /**\n * A filter chip, a two-state button.\n * @default 'filter'\n */\n variant?: 'filter'\n}\n\ntype ChipProps = ChipActionProps | ChipFilterProps\n\n/** Which of the chips page's chips a Chip is. */\ntype ChipVariant = 'assist' | 'filter' | 'suggestion'\n\nfunction ActionChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n variant,\n ...props\n}: ChipActionProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled, as on the filter chip. `onClick` goes through the\n // ripple too: on a mouse press the ripple ends on the click, so a call\n // site's own handler spread beside it would leave it pressed.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <Button\n render={buttonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(actionChipClasses(variant, elevated), props)}\n >\n {actionChipContent(children, icon, ripple.surface)}\n </Button>\n )\n}\n\n// An action chip's classes: the unselected pill, which it always is.\nfunction actionChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ButtonRenderProps) =>\n chipPropsFor({ ...state, isSelected: false }, { elevated, kind })\n}\n\n// What an action chip draws: its icon, if any, then the label, and the\n// ripple over both. Built by a call for the reason `chipContent` is.\nfunction actionChipContent(\n children: ReactNode,\n icon: ReactNode,\n surface: ReactNode,\n) {\n return (state: ButtonRenderProps) => (\n <>\n {chipGlyph(\n { isDisabled: state.isDisabled, isSelected: false },\n icon,\n false,\n )}\n {chipLabel(children)}\n {surface}\n </>\n )\n}\n\n/**\n * A chip. By default a filter chip, which is a two-state button, so its\n * selected state is React Aria's `isSelected`: pass it with `onChange` to\n * control it, or `defaultSelected` to let it keep its own state. Selection is\n * announced through `aria-pressed` rather than a role of its own.\n *\n * `variant=\"assist\"` and `variant=\"suggestion\"` draw the page's two action\n * chips instead: plain buttons, pressed with `onPress`, never selected.\n */\nfunction Chip(props: ChipProps & RefAttributes<HTMLButtonElement>) {\n if (isAction(props)) {\n return <ActionChip {...props} />\n }\n return <FilterChip {...props} />\n}\n\n// What the chip draws, from React Aria's render state: the check while it is\n// selected or its icon while it is not, then the label, and the ripple over\n// both. Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs.\nfunction chipContent(children: ReactNode, icon: ReactNode, surface: ReactNode) {\n return (state: ToggleButtonRenderProps) => (\n <>\n {chipGlyph(state, icon)}\n {chipLabel(children)}\n {surface}\n </>\n )\n}\n\nfunction FilterChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n variant = 'filter',\n ...props\n}: ChipFilterProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled: React Aria still forwards pointer events to a\n // disabled element, and a press that changes nothing should not look like\n // one. Typed as Button's ripple is, since React Aria types a toggle\n // button's pointer events against a <div> rather than the <button> it\n // renders. `onClick` goes through it for the action chip's reason.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <ToggleButton\n render={toggleButtonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(filterChipClasses(variant, elevated), props)}\n >\n {chipContent(children, icon, ripple.surface)}\n </ToggleButton>\n )\n}\n\n// A filter chip's classes, from its render state.\nfunction filterChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ToggleButtonRenderProps) =>\n chipPropsFor(state, { elevated, kind })\n}\n\n// Whether a chip is one of the two action chips. A guard rather than a\n// comparison at the call, since TypeScript does not narrow the union through\n// React Aria's mapped prop types on `variant` alone.\nfunction isAction(props: ChipProps): props is ChipActionProps {\n return props.variant === 'assist' || props.variant === 'suggestion'\n}\n\nexport type { ChipActionProps, ChipFilterProps, ChipProps, ChipVariant }\n\nexport default Chip\n"],"mappings":";;;;;;;;;AAkHA,SAAA+B,WAAAC,IAAA;CAAA,MAAAC,IAAAhC,EAAA,EAAA;CAAoB,MAAA,EAAAuB,UAAAC,UAAAS,IAAAR,MAAAS,SAAAC,eAAAC,WAAAC,SAAAC,iBAAAC,eAAAC,gBAAAC,aAAAC,QAAAhB,SAAA,GAAAiB,UAAAZ;CAElB,MAAAP,WAAAS,OAAAW,KAAAA,IAAA,QAAAX;CAcA,MAAAY,UAAgB;EAAAC,MAAQ7B,iBAAiB0B,KAAK;EAACP;EAAAC;CAAqB;CAAC,IAAAU;CAAA,IAAAf,EAAA,OAAAE,WAAAF,EAAA,OAAAG,iBAAAH,EAAA,OAAAM,mBAAAN,EAAA,OAAAO,iBAAAP,EAAA,OAAAQ,kBAAAR,EAAA,OAAAS,aAAA;EAICM,KAAA;GAAAb;GAAAC;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ACLa;GAEHG,UAAAA;EANU,CAAA;EAOE3B,EAAA,MAAAkB;EAAAlB,EAAA,MAAAW;EAAAX,EAAA,MAAAgB,OAAAK;EAAArB,EAAA,MAAAoB;EAAApB,EAAA,MAAAwB;EAAAxB,EAAA,MAAA2B;EAAA3B,EAAA,MAAAoC;CAAA,OAAAA,KAAApC,EAAA;CAAA,OAPfoC;AAOe;AAKnB,SAASD,kBAAkBP,MAAgBpC,UAAmB;CAC5D,QAAQqC,UACN9C,aAAa8C,OAAO;EAAErC;EAAUoC;CAAK,CAAC;AAC1C;AAKA,SAASI,SAASrB,OAA4C;CAC5D,OAAOA,MAAMjB,YAAY,YAAYiB,MAAMjB,YAAY;AACzD"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ReactElement, ReactNode, RefAttributes } from "react";
|
|
2
2
|
import { TagGroupProps, TagListProps, TagProps } from "react-aria-components";
|
|
3
3
|
//#region src/components/chip-group/index.d.ts
|
|
4
|
-
type ChipGroupChipProps =
|
|
5
|
-
/**
|
|
4
|
+
type ChipGroupChipProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The chip's label. Text, numbers, or a mix of the two — `Label {3}` —
|
|
7
|
+
* also name the chip; a label holding an element needs `textValue`.
|
|
8
|
+
*/
|
|
6
9
|
children?: ReactNode;
|
|
7
10
|
/** A function may compute the class from the chip's render state. */
|
|
8
11
|
className?: TagProps['className'];
|
|
@@ -14,7 +17,15 @@ type ChipGroupChipProps = Omit<TagProps, 'children' | 'className' | 'style'> & {
|
|
|
14
17
|
icon?: ReactNode;
|
|
15
18
|
/** A function may compute the style from the chip's render state. */
|
|
16
19
|
style?: TagProps['style'];
|
|
17
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The chip's name as text, which is what a screen reader announces for
|
|
22
|
+
* its row. Read from the label when that is text or numbers, so it is
|
|
23
|
+
* needed only when the label holds an element — emphasis, a count in a
|
|
24
|
+
* badge — and React Aria warns in the console when such a chip has none.
|
|
25
|
+
* Given, it wins over the text read from the label.
|
|
26
|
+
*/
|
|
27
|
+
textValue?: string;
|
|
28
|
+
} & Omit<TagProps, 'children' | 'className' | 'style' | 'textValue'>;
|
|
18
29
|
type ChipGroupProps<T extends object = object> = {
|
|
19
30
|
/**
|
|
20
31
|
* The chips, each with an `id` of its own. With `items`, a function from an
|
|
@@ -36,6 +47,16 @@ type ChipGroupProps<T extends object = object> = {
|
|
|
36
47
|
* that space from the start; so does a permanent `description`.
|
|
37
48
|
*/
|
|
38
49
|
error?: string;
|
|
50
|
+
/**
|
|
51
|
+
* What Escape does on a chip. `none`, the default, keeps the selection and
|
|
52
|
+
* lets the key through to whatever is around the group, so a group in a
|
|
53
|
+
* Sheet, Dialog or Popover closes it on the first press. `clearSelection`
|
|
54
|
+
* empties the selection first, as React Aria's own default does, and lets
|
|
55
|
+
* a second press through.
|
|
56
|
+
*
|
|
57
|
+
* @default 'none'
|
|
58
|
+
*/
|
|
59
|
+
escapeKeyBehavior?: 'clearSelection' | 'none';
|
|
39
60
|
/**
|
|
40
61
|
* What the group is for. Required rather than optional: a set of chips
|
|
41
62
|
* with no name is a row a screen reader cannot introduce.
|
|
@@ -48,7 +69,7 @@ type ChipGroupProps<T extends object = object> = {
|
|
|
48
69
|
* Aria names it in the reader's locale — "Remove" in English.
|
|
49
70
|
*/
|
|
50
71
|
removeLabel?: string;
|
|
51
|
-
} & Omit<TagGroupProps, 'children'> & Pick<TagListProps<T>, 'items' | 'renderEmptyState'>;
|
|
72
|
+
} & Omit<TagGroupProps, 'children' | 'escapeKeyBehavior'> & Pick<TagListProps<T>, 'items' | 'renderEmptyState'>;
|
|
52
73
|
/**
|
|
53
74
|
* A labelled set of chips, one or more of which can be chosen, each of which
|
|
54
75
|
* can be removed. Selection is React Aria's: set `selectionMode` to `single`
|
|
@@ -64,13 +85,22 @@ type ChipGroupProps<T extends object = object> = {
|
|
|
64
85
|
* Give the group `onRemove` and each chip draws a close target. The arrow
|
|
65
86
|
* keys move between chips, so a set of many is one tab stop rather than many.
|
|
66
87
|
*
|
|
88
|
+
* A chip is never wider than its row, so a label with no room ends in an
|
|
89
|
+
* ellipsis rather than wrapping, and shows its full text in the browser's
|
|
90
|
+
* tooltip on hover.
|
|
91
|
+
*
|
|
92
|
+
* Escape on a chip keeps the selection and reaches whatever is around the
|
|
93
|
+
* group, so a group in a Sheet, Dialog or Popover closes it. Pass
|
|
94
|
+
* `escapeKeyBehavior="clearSelection"` for React Aria's own default, which
|
|
95
|
+
* empties the selection on the first press and lets the second through.
|
|
96
|
+
*
|
|
67
97
|
* A chip that toggles nothing else is Chip; this is for a set that shares a
|
|
68
98
|
* value.
|
|
69
99
|
*
|
|
70
100
|
* The call site's `className` and `style` land on the group as a whole,
|
|
71
101
|
* which is the element a layout positions.
|
|
72
102
|
*/
|
|
73
|
-
declare function ChipGroup<T extends object = object>({ children, description, error, items, label, removeLabel, renderEmptyState, ...props }: ChipGroupProps<T> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
103
|
+
declare function ChipGroup<T extends object = object>({ children, description, error, escapeKeyBehavior, items, label, removeLabel, renderEmptyState, ...props }: ChipGroupProps<T> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
74
104
|
declare namespace ChipGroup {
|
|
75
105
|
var Chip: typeof ChipGroupChip;
|
|
76
106
|
}
|
|
@@ -7,9 +7,9 @@ import { useRipple } from "../../hooks/useRipple.js";
|
|
|
7
7
|
import { invalidFrom } from "../../field/root.js";
|
|
8
8
|
import { groupStyles } from "../../field/styles.js";
|
|
9
9
|
import { FieldLabel, FieldMessage } from "../../field/index.js";
|
|
10
|
+
import { textOf } from "../../collection/text.js";
|
|
10
11
|
import { chipStyles } from "../../chip/styles.js";
|
|
11
12
|
import { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from "../../chip/index.js";
|
|
12
|
-
import { textOf } from "../../collection/text.js";
|
|
13
13
|
import { c } from "react/compiler-runtime";
|
|
14
14
|
import { createContext, useContext } from "react";
|
|
15
15
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -23,11 +23,14 @@ const styles = { list: {
|
|
|
23
23
|
kAzted: "xlzjxrf",
|
|
24
24
|
$$css: true
|
|
25
25
|
} };
|
|
26
|
-
function chipContent(children, icon, removeLabel, surface) {
|
|
26
|
+
function chipContent(children, icon, removeLabel, surface, acts) {
|
|
27
27
|
return (state) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
28
|
-
chipGlyph(state, icon),
|
|
28
|
+
chipGlyph(state, icon, state.selectionMode !== "none"),
|
|
29
29
|
chipLabel(children),
|
|
30
|
-
state.selectionMode !== "none" && !state.isDisabled ?
|
|
30
|
+
(acts || state.selectionMode !== "none") && !state.isDisabled ? /* @__PURE__ */ jsx("span", {
|
|
31
|
+
...props(chipStyles.surfaceCorners),
|
|
32
|
+
children: surface
|
|
33
|
+
}) : null,
|
|
31
34
|
state.allowsRemoving ? /* @__PURE__ */ jsx(Button, {
|
|
32
35
|
"aria-label": removeLabel,
|
|
33
36
|
className: chipRemoveClassName,
|
|
@@ -37,8 +40,12 @@ function chipContent(children, icon, removeLabel, surface) {
|
|
|
37
40
|
] });
|
|
38
41
|
}
|
|
39
42
|
const RemoveLabelContext = createContext(void 0);
|
|
43
|
+
const GroupActionContext = createContext(false);
|
|
40
44
|
const LABEL_STATE_VALID = { isInvalid: false };
|
|
41
45
|
const LABEL_STATE_INVALID = { isInvalid: true };
|
|
46
|
+
function actingChipPropsFor(state) {
|
|
47
|
+
return chipPropsFor(state);
|
|
48
|
+
}
|
|
42
49
|
/**
|
|
43
50
|
* A labelled set of chips, one or more of which can be chosen, each of which
|
|
44
51
|
* can be removed. Selection is React Aria's: set `selectionMode` to `single`
|
|
@@ -54,6 +61,15 @@ const LABEL_STATE_INVALID = { isInvalid: true };
|
|
|
54
61
|
* Give the group `onRemove` and each chip draws a close target. The arrow
|
|
55
62
|
* keys move between chips, so a set of many is one tab stop rather than many.
|
|
56
63
|
*
|
|
64
|
+
* A chip is never wider than its row, so a label with no room ends in an
|
|
65
|
+
* ellipsis rather than wrapping, and shows its full text in the browser's
|
|
66
|
+
* tooltip on hover.
|
|
67
|
+
*
|
|
68
|
+
* Escape on a chip keeps the selection and reaches whatever is around the
|
|
69
|
+
* group, so a group in a Sheet, Dialog or Popover closes it. Pass
|
|
70
|
+
* `escapeKeyBehavior="clearSelection"` for React Aria's own default, which
|
|
71
|
+
* empties the selection on the first press and lets the second through.
|
|
72
|
+
*
|
|
57
73
|
* A chip that toggles nothing else is Chip; this is for a set that shares a
|
|
58
74
|
* value.
|
|
59
75
|
*
|
|
@@ -61,7 +77,7 @@ const LABEL_STATE_INVALID = { isInvalid: true };
|
|
|
61
77
|
* which is the element a layout positions.
|
|
62
78
|
*/
|
|
63
79
|
function ChipGroup(t0) {
|
|
64
|
-
const $ = c(
|
|
80
|
+
const $ = c(39);
|
|
65
81
|
let T0;
|
|
66
82
|
let children;
|
|
67
83
|
let description;
|
|
@@ -69,23 +85,28 @@ function ChipGroup(t0) {
|
|
|
69
85
|
let invalid;
|
|
70
86
|
let items;
|
|
71
87
|
let label;
|
|
88
|
+
let props$1;
|
|
72
89
|
let removeLabel;
|
|
73
90
|
let renderEmptyState;
|
|
74
91
|
let t1;
|
|
75
92
|
let t2;
|
|
93
|
+
let t3;
|
|
76
94
|
if ($[0] !== t0) {
|
|
77
|
-
const { children:
|
|
78
|
-
children =
|
|
79
|
-
description =
|
|
80
|
-
error =
|
|
81
|
-
items =
|
|
82
|
-
label =
|
|
83
|
-
removeLabel =
|
|
84
|
-
renderEmptyState =
|
|
95
|
+
const { children: t4, description: t5, error: t6, escapeKeyBehavior: t7, items: t8, label: t9, removeLabel: t10, renderEmptyState: t11, ...t12 } = t0;
|
|
96
|
+
children = t4;
|
|
97
|
+
description = t5;
|
|
98
|
+
error = t6;
|
|
99
|
+
items = t8;
|
|
100
|
+
label = t9;
|
|
101
|
+
removeLabel = t10;
|
|
102
|
+
renderEmptyState = t11;
|
|
103
|
+
props$1 = t12;
|
|
104
|
+
const escapeKeyBehavior = t7 === void 0 ? "none" : t7;
|
|
85
105
|
invalid = invalidFrom(error);
|
|
86
106
|
T0 = TagGroup;
|
|
87
|
-
t1 =
|
|
88
|
-
t2 =
|
|
107
|
+
t1 = escapeKeyBehavior;
|
|
108
|
+
t2 = props$1;
|
|
109
|
+
t3 = mergeStyles(props(groupStyles.root), props$1);
|
|
89
110
|
$[0] = t0;
|
|
90
111
|
$[1] = T0;
|
|
91
112
|
$[2] = children;
|
|
@@ -94,10 +115,12 @@ function ChipGroup(t0) {
|
|
|
94
115
|
$[5] = invalid;
|
|
95
116
|
$[6] = items;
|
|
96
117
|
$[7] = label;
|
|
97
|
-
$[8] =
|
|
98
|
-
$[9] =
|
|
99
|
-
$[10] =
|
|
100
|
-
$[11] =
|
|
118
|
+
$[8] = props$1;
|
|
119
|
+
$[9] = removeLabel;
|
|
120
|
+
$[10] = renderEmptyState;
|
|
121
|
+
$[11] = t1;
|
|
122
|
+
$[12] = t2;
|
|
123
|
+
$[13] = t3;
|
|
101
124
|
} else {
|
|
102
125
|
T0 = $[1];
|
|
103
126
|
children = $[2];
|
|
@@ -106,91 +129,107 @@ function ChipGroup(t0) {
|
|
|
106
129
|
invalid = $[5];
|
|
107
130
|
items = $[6];
|
|
108
131
|
label = $[7];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
props$1 = $[8];
|
|
133
|
+
removeLabel = $[9];
|
|
134
|
+
renderEmptyState = $[10];
|
|
135
|
+
t1 = $[11];
|
|
136
|
+
t2 = $[12];
|
|
137
|
+
t3 = $[13];
|
|
113
138
|
}
|
|
114
|
-
const
|
|
115
|
-
let
|
|
116
|
-
if ($[
|
|
117
|
-
|
|
118
|
-
state:
|
|
139
|
+
const t4 = invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID;
|
|
140
|
+
let t5;
|
|
141
|
+
if ($[14] !== label || $[15] !== t4) {
|
|
142
|
+
t5 = /* @__PURE__ */ jsx(FieldLabel, {
|
|
143
|
+
state: t4,
|
|
119
144
|
variant: "group",
|
|
120
145
|
children: label
|
|
121
146
|
});
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
} else
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
$[14] = label;
|
|
148
|
+
$[15] = t4;
|
|
149
|
+
$[16] = t5;
|
|
150
|
+
} else t5 = $[16];
|
|
151
|
+
const t6 = props$1.onAction !== void 0;
|
|
152
|
+
let t7;
|
|
153
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
154
|
+
t7 = props(styles.list, focus.ring);
|
|
155
|
+
$[17] = t7;
|
|
156
|
+
} else t7 = $[17];
|
|
157
|
+
let t8;
|
|
158
|
+
if ($[18] !== children || $[19] !== items || $[20] !== renderEmptyState) {
|
|
159
|
+
t8 = /* @__PURE__ */ jsx(TagList, {
|
|
134
160
|
items,
|
|
135
161
|
renderEmptyState,
|
|
136
|
-
...
|
|
162
|
+
...t7,
|
|
137
163
|
children
|
|
138
164
|
});
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
} else
|
|
144
|
-
let
|
|
145
|
-
if ($[
|
|
146
|
-
|
|
165
|
+
$[18] = children;
|
|
166
|
+
$[19] = items;
|
|
167
|
+
$[20] = renderEmptyState;
|
|
168
|
+
$[21] = t8;
|
|
169
|
+
} else t8 = $[21];
|
|
170
|
+
let t9;
|
|
171
|
+
if ($[22] !== t6 || $[23] !== t8) {
|
|
172
|
+
t9 = /* @__PURE__ */ jsx(GroupActionContext, {
|
|
173
|
+
value: t6,
|
|
174
|
+
children: t8
|
|
175
|
+
});
|
|
176
|
+
$[22] = t6;
|
|
177
|
+
$[23] = t8;
|
|
178
|
+
$[24] = t9;
|
|
179
|
+
} else t9 = $[24];
|
|
180
|
+
let t10;
|
|
181
|
+
if ($[25] !== removeLabel || $[26] !== t9) {
|
|
182
|
+
t10 = /* @__PURE__ */ jsx(RemoveLabelContext, {
|
|
147
183
|
value: removeLabel,
|
|
148
|
-
children:
|
|
184
|
+
children: t9
|
|
149
185
|
});
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
} else
|
|
154
|
-
let
|
|
155
|
-
if ($[
|
|
156
|
-
|
|
186
|
+
$[25] = removeLabel;
|
|
187
|
+
$[26] = t9;
|
|
188
|
+
$[27] = t10;
|
|
189
|
+
} else t10 = $[27];
|
|
190
|
+
let t11;
|
|
191
|
+
if ($[28] !== description || $[29] !== error) {
|
|
192
|
+
t11 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
157
193
|
description,
|
|
158
194
|
error,
|
|
159
195
|
inset: false
|
|
160
196
|
});
|
|
161
|
-
$[
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
} else
|
|
165
|
-
let
|
|
166
|
-
if ($[
|
|
167
|
-
|
|
168
|
-
|
|
197
|
+
$[28] = description;
|
|
198
|
+
$[29] = error;
|
|
199
|
+
$[30] = t11;
|
|
200
|
+
} else t11 = $[30];
|
|
201
|
+
let t12;
|
|
202
|
+
if ($[31] !== T0 || $[32] !== t1 || $[33] !== t10 || $[34] !== t11 || $[35] !== t2 || $[36] !== t3 || $[37] !== t5) {
|
|
203
|
+
t12 = /* @__PURE__ */ jsxs(T0, {
|
|
204
|
+
escapeKeyBehavior: t1,
|
|
169
205
|
...t2,
|
|
206
|
+
...t3,
|
|
170
207
|
children: [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
208
|
+
t5,
|
|
209
|
+
t10,
|
|
210
|
+
t11
|
|
174
211
|
]
|
|
175
212
|
});
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
|
|
184
|
-
|
|
213
|
+
$[31] = T0;
|
|
214
|
+
$[32] = t1;
|
|
215
|
+
$[33] = t10;
|
|
216
|
+
$[34] = t11;
|
|
217
|
+
$[35] = t2;
|
|
218
|
+
$[36] = t3;
|
|
219
|
+
$[37] = t5;
|
|
220
|
+
$[38] = t12;
|
|
221
|
+
} else t12 = $[38];
|
|
222
|
+
return t12;
|
|
185
223
|
}
|
|
186
224
|
/**
|
|
187
225
|
* One chip. Give every chip an `id` — that is the key selection and removal
|
|
188
226
|
* are reported by.
|
|
189
227
|
*/
|
|
190
228
|
function ChipGroupChip(t0) {
|
|
191
|
-
const $ = c(
|
|
229
|
+
const $ = c(19);
|
|
192
230
|
const { children, icon, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, ...props } = t0;
|
|
193
231
|
const removeLabel = useContext(RemoveLabelContext);
|
|
232
|
+
const acts = useContext(GroupActionContext) || props.onAction !== void 0 || props.href !== void 0;
|
|
194
233
|
let t1;
|
|
195
234
|
if ($[0] !== onContextMenu || $[1] !== onPointerCancel || $[2] !== onPointerDown || $[3] !== onPointerLeave || $[4] !== onPointerUp) {
|
|
196
235
|
t1 = {
|
|
@@ -211,18 +250,19 @@ function ChipGroupChip(t0) {
|
|
|
211
250
|
const T0 = Tag;
|
|
212
251
|
const t2 = props.textValue ?? textOf(children);
|
|
213
252
|
const t3 = ripple.handlers;
|
|
214
|
-
const t4 = mergeStatefulStyles(groupChipPropsFor, props);
|
|
253
|
+
const t4 = mergeStatefulStyles(acts ? actingChipPropsFor : groupChipPropsFor, props);
|
|
215
254
|
let t5;
|
|
216
|
-
if ($[6] !==
|
|
217
|
-
t5 = chipContent(children, icon, removeLabel, ripple.surface);
|
|
218
|
-
$[6] =
|
|
219
|
-
$[7] =
|
|
220
|
-
$[8] =
|
|
221
|
-
$[9] =
|
|
222
|
-
$[10] =
|
|
223
|
-
|
|
255
|
+
if ($[6] !== acts || $[7] !== children || $[8] !== icon || $[9] !== removeLabel || $[10] !== ripple.surface) {
|
|
256
|
+
t5 = chipContent(children, icon, removeLabel, ripple.surface, acts);
|
|
257
|
+
$[6] = acts;
|
|
258
|
+
$[7] = children;
|
|
259
|
+
$[8] = icon;
|
|
260
|
+
$[9] = removeLabel;
|
|
261
|
+
$[10] = ripple.surface;
|
|
262
|
+
$[11] = t5;
|
|
263
|
+
} else t5 = $[11];
|
|
224
264
|
let t6;
|
|
225
|
-
if ($[
|
|
265
|
+
if ($[12] !== T0 || $[13] !== props || $[14] !== ripple.handlers || $[15] !== t2 || $[16] !== t4 || $[17] !== t5) {
|
|
226
266
|
t6 = /* @__PURE__ */ jsx(T0, {
|
|
227
267
|
textValue: t2,
|
|
228
268
|
...t3,
|
|
@@ -230,18 +270,18 @@ function ChipGroupChip(t0) {
|
|
|
230
270
|
...t4,
|
|
231
271
|
children: t5
|
|
232
272
|
});
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
} else t6 = $[
|
|
273
|
+
$[12] = T0;
|
|
274
|
+
$[13] = props;
|
|
275
|
+
$[14] = ripple.handlers;
|
|
276
|
+
$[15] = t2;
|
|
277
|
+
$[16] = t4;
|
|
278
|
+
$[17] = t5;
|
|
279
|
+
$[18] = t6;
|
|
280
|
+
} else t6 = $[18];
|
|
241
281
|
return t6;
|
|
242
282
|
}
|
|
243
283
|
function groupChipPropsFor(state) {
|
|
244
|
-
return chipPropsFor(state);
|
|
284
|
+
return chipPropsFor(state, { inert: state.selectionMode === "none" });
|
|
245
285
|
}
|
|
246
286
|
ChipGroup.Chip = ChipGroupChip;
|
|
247
287
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactElement","ReactNode","RefAttributes","TagGroupProps","RACTagGroupProps","TagListProps","RACTagListProps","TagProps","RACTagProps","TagRenderProps","stylex","createContext","useContext","Button","RACButton","Tag","RACTag","TagGroup","RACTagGroup","TagList","RACTagList","chipGlyph","chipLabel","chipPropsFor","chipRemoveClassName","chipStyles","textOf","FieldLabel","FieldMessage","invalidFrom","groupStyles","CloseGlyph","useRipple","focus","mergeStatefulStyles","mergeStyles","sizing","spacing","styles","list","kB7OPa","k1xSpc","kwnvtZ","kOIVth","kAzted","$$css","ChipGroupChipProps","Omit","children","className","icon","style","ChipGroupProps","item","T","description","error","label","removeLabel","Pick","chipContent","surface","state","selectionMode","isDisabled","allowsRemoving","props","removeGlyph","RemoveLabelContext","undefined","LABEL_STATE_VALID","isInvalid","LABEL_STATE_INVALID","ChipGroup","t0","$","T0","invalid","items","renderEmptyState","t1","t2","t3","t4","t5","t6","t7","t8","t9","root","Symbol","for","ring","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","ripple","textValue","handlers","groupChipPropsFor","Chip","RACButton","stylex.props","_c","props","RACTagGroup","RACTagList","RACTag"],"sources":["../../../src/components/chip-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, RefAttributes } from 'react';\nimport type { TagGroupProps as RACTagGroupProps, TagListProps as RACTagListProps, TagProps as RACTagProps, TagRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { Button as RACButton, Tag as RACTag, TagGroup as RACTagGroup, TagList as RACTagList } from 'react-aria-components';\nimport { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from '../../chip';\nimport { chipStyles } from '../../chip/styles';\nimport { textOf } from '../../collection/text';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { CloseGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The chips page's filter and input chips as a set: one or more chosen from a\n// row, each one removable. The pill is the chip module's in `src/chip`,\n// shared with the standalone Chip, so the two cannot drift; what is here is\n// the group around them.\n//\n// Three things it adds over a row of Chips.\n//\n// **It is a group, not a row of buttons.** React Aria's `TagGroup` names the\n// set, describes it, reports it invalid as a whole, and moves between its\n// chips with the arrow keys rather than making each one a tab stop — which\n// is what a set of a dozen filters needs. The label, the supporting line and\n// the error are the field chrome's, so a group reads like the fields beside\n// it, exactly as CheckboxGroup and RadioGroup do.\n//\n// **A chip can be removed.** Give the group `onRemove` and each chip draws\n// the page's trailing close target, an 18dp glyph in a target of its own so a\n// press there removes rather than toggles. Backspace and Delete remove the\n// focused chip too, which is React Aria's. A chosen chip's check sits at the\n// other end, so a chip that is both selected and removable carries one glyph\n// on each side of its label.\n//\n// **Selection is the group's, not each chip's.** `selectionMode` and\n// `selectedKeys` live on the group, so a set that chooses one of its chips\n// and a set that chooses several are the same component with a different\n// word. A chip on its own that toggles nothing else is still Chip.\n//\n// One thing is worth knowing about how this maps onto React Aria. A chip's\n// text value is read off its children and found only when they are a plain\n// string, and a chip here is always an element — the label sits beside a\n// close target. So a plain-string label is passed through as the text value,\n// which is what typeahead and a screen reader's announcement are made of;\n// see ListBox.Item, where the same thing bit.\n\nconst styles = {\n list: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kwnvtZ: \"x1a02dak\",\n kOIVth: \"x126z3so\",\n kAzted: \"xlzjxrf\",\n $$css: true\n }\n};\ntype ChipGroupChipProps = Omit<RACTagProps, 'children' | 'className' | 'style'> & {\n /** The chip's label. */\n children?: ReactNode;\n /** A function may compute the class from the chip's render state. */\n className?: RACTagProps['className'];\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is chosen, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode;\n /** A function may compute the style from the chip's render state. */\n style?: RACTagProps['style'];\n};\ntype ChipGroupProps<T extends object = object> = {\n /**\n * The chips, each with an `id` of its own. With `items`, a function from an\n * item to its chip, which React Aria calls for each item in turn.\n */\n children?: ((item: T) => ReactElement) | ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state — the message and `aria-invalid` both\n * follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * What the group is for. Required rather than optional: a set of chips\n * with no name is a row a screen reader cannot introduce.\n */\n label: string;\n /**\n * What the close target on each chip is called, for a screen reader. React\n * Aria adds the chip's own label after it, so this is the verb rather than\n * the whole phrase — \"Remove\" becomes \"Remove First item\". Left out, React\n * Aria names it in the reader's locale — \"Remove\" in English.\n */\n removeLabel?: string;\n} & Omit<RACTagGroupProps, 'children'> & Pick<RACTagListProps<T>, 'items' | 'renderEmptyState'>;\n\n// What the chip 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 check and the icon it replaces are the chip module's, so a chip in a\n// group and a chip on its own draw the same ones. The close target is drawn\n// only where the group allows removing, which React Aria reports rather than\n// the call site saying so on every chip.\n//\n// The ripple is drawn only on a chip a press does something to: one the\n// group lets be selected, and not disabled. A chip in a group that selects\n// nothing is a control only for its close target, and React Aria reports\n// neither hover nor press on it, so a ripple there would answer a press that\n// changes nothing.\nfunction chipContent(children: ReactNode, icon: ReactNode, removeLabel: string | undefined, surface: ReactNode) {\n return (state: TagRenderProps) => <>\n {chipGlyph(state, icon)}\n {chipLabel(children)}\n {state.selectionMode !== 'none' && !state.isDisabled ? surface : null}\n {state.allowsRemoving ? <RACButton aria-label={removeLabel} className={chipRemoveClassName} slot=\"remove\">\n <CloseGlyph {...stylex.props(chipStyles.removeGlyph)} />\n </RACButton> : null}\n </>;\n}\n\n// What each chip calls its close target. A context rather than a prop on the\n// chip, since it is the group's decision and repeating it on every chip is\n// how the two drift. Undefined unless the group is given one, which leaves\n// the name React Aria gives in the reader's locale.\nconst RemoveLabelContext = createContext<string | undefined>(undefined);\n\n// Hoisted so neither is a new object on every render.\nconst LABEL_STATE_VALID = {\n isInvalid: false\n};\nconst LABEL_STATE_INVALID = {\n isInvalid: true\n};\n\n/**\n * A labelled set of chips, one or more of which can be chosen, each of which\n * can be removed. Selection is React Aria's: set `selectionMode` to `single`\n * or `multiple` and pass `selectedKeys` with `onSelectionChange` to control\n * it, or `defaultSelectedKeys` to let it keep its own.\n *\n * ```tsx\n * <ChipGroup label=\"Label\" selectionMode=\"multiple\" onRemove={remove}>\n * <ChipGroup.Chip id=\"first\">First item</ChipGroup.Chip>\n * </ChipGroup>\n * ```\n *\n * Give the group `onRemove` and each chip draws a close target. The arrow\n * keys move between chips, so a set of many is one tab stop rather than many.\n *\n * A chip that toggles nothing else is Chip; this is for a set that shares a\n * value.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction ChipGroup<T extends object = object>({\n children,\n description,\n error,\n items,\n label,\n removeLabel,\n renderEmptyState,\n ...props\n}: ChipGroupProps<T> & RefAttributes<HTMLDivElement>) {\n const invalid = invalidFrom(error);\n return <RACTagGroup {...props} {...mergeStyles(stylex.props(groupStyles.root), props)}>\n {/* React Aria's tag group has no disabled state of its own — a chip is\n disabled through the group's `disabledKeys` — so the label follows\n validity alone. */}\n <FieldLabel state={invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID} variant=\"group\">\n {label}\n </FieldLabel>\n <RemoveLabelContext value={removeLabel}>\n <RACTagList<T> items={items} renderEmptyState={renderEmptyState} {...stylex.props(styles.list, focus.ring)}>\n {children}\n </RACTagList>\n </RemoveLabelContext>\n <FieldMessage description={description} error={error} inset={false} />\n </RACTagGroup>;\n}\n\n/**\n * One chip. Give every chip an `id` — that is the key selection and removal\n * are reported by.\n */\nfunction ChipGroupChip({\n children,\n icon,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n ...props\n}: ChipGroupChipProps & RefAttributes<HTMLDivElement>) {\n const removeLabel = useContext(RemoveLabelContext);\n // The press ripple a list's rows draw — see ListItem there. A chip in a\n // group is a collection row, whose clicks React Aria keeps for itself, so\n // the press ends when the pointer is released rather than on a click.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACTag textValue={props.textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(groupChipPropsFor, props)}>\n {chipContent(children, icon, removeLabel, ripple.surface)}\n </RACTag>;\n}\n\n// The pill a standalone Chip draws, from `src/chip`, touch target included:\n// every chip's reaches halfway across the gap its rows wrap at.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state);\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAqDA,MAAMwC,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AAiEA,SAASe,YAAYZ,UAAqBE,MAAiBQ,aAAiCG,SAAoB;CAC9G,QAAQC,UAA0B,qBAAA,YAAA,EAAA,UAAA;EAC7BzC,UAAUyC,OAAOZ,IAAI;EACrB5B,UAAU0B,QAAQ;EAClBc,MAAMC,kBAAkB,UAAU,CAACD,MAAME,aAAaH,UAAU;EAChEC,MAAMG,iBAAiB,oBAACuC,QAAD;GAAW,cAAY9C;GAAa,WAAWlC;GAAqB,MAAK;GAC7F,UAAA,oBAAC,YAAD,EAAY,GAAId,MAAae,WAAW0C,WAAW,EAAE,CAAA;EAC5C,CAAA,IAAI;CACnB,EAAA,CAAA;AACJ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pC,KAAK;CAAC,IAAAkB;CAAA,IAAAT,EAAA,OAAA3B,YAAA2B,EAAA,OAAAzB,QAAAyB,EAAA,OAAAjB,eAAAiB,EAAA,OAAAwB,OAAAtC,SAAA;EAC3IuB,KAAAxB,YAAYZ,UAAUE,MAAMQ,aAAayC,OAAMtC,OAAQ;EAACc,EAAA,KAAA3B;EAAA2B,EAAA,KAAAzB;EAAAyB,EAAA,KAAAjB;EAAAiB,EAAA,KAAAwB,OAAAtC;EAAAc,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,QAAAC,MAAAD,EAAA,QAAAT,SAAAS,EAAA,QAAAwB,OAAAE,YAAA1B,EAAA,QAAAM,MAAAN,EAAA,QAAAQ,MAAAR,EAAA,QAAAS,IAAA;EADtDC,KAAA,oBAAC,IAAD;GAAmB,WAAAJ;GAAmC,GAAMC;GAAe,GAAMhB;GAAK,GAAMiB;GAC9FC,UAAAA;EADS,CAAA;EAEHT,EAAA,MAAAC;EAAAD,EAAA,MAAAT;EAAAS,EAAA,MAAAwB,OAAAE;EAAA1B,EAAA,MAAAM;EAAAN,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFJU;AAEI;AAKb,SAASiB,kBAAkBxC,OAAuB;CAChD,OAAOvC,aAAauC,KAAK;AAC3B;AACAW,UAAU8B,OAAOV"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ReactElement","ReactNode","RefAttributes","TagGroupProps","RACTagGroupProps","TagListProps","RACTagListProps","TagProps","RACTagProps","TagRenderProps","stylex","createContext","useContext","Button","RACButton","Tag","RACTag","TagGroup","RACTagGroup","TagList","RACTagList","chipGlyph","chipLabel","chipPropsFor","chipRemoveClassName","chipStyles","textOf","FieldLabel","FieldMessage","invalidFrom","groupStyles","CloseGlyph","useRipple","focus","mergeStatefulStyles","mergeStyles","sizing","spacing","styles","list","kB7OPa","k1xSpc","kwnvtZ","kOIVth","kAzted","$$css","ChipGroupChipProps","children","className","icon","style","textValue","Omit","ChipGroupProps","item","T","description","error","escapeKeyBehavior","label","removeLabel","Pick","chipContent","surface","acts","state","selectionMode","isDisabled","props","surfaceCorners","allowsRemoving","removeGlyph","RemoveLabelContext","undefined","GroupActionContext","LABEL_STATE_VALID","isInvalid","LABEL_STATE_INVALID","actingChipPropsFor","ChipGroup","t0","$","T0","invalid","items","renderEmptyState","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","root","onAction","Symbol","for","ring","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","href","ripple","handlers","groupChipPropsFor","inert","Chip","stylex.props","RACButton","_c","props","RACTagGroup","RACTagList","RACTag"],"sources":["../../../src/components/chip-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, RefAttributes } from 'react';\nimport type { TagGroupProps as RACTagGroupProps, TagListProps as RACTagListProps, TagProps as RACTagProps, TagRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { Button as RACButton, Tag as RACTag, TagGroup as RACTagGroup, TagList as RACTagList } from 'react-aria-components';\nimport { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from '../../chip';\nimport { chipStyles } from '../../chip/styles';\nimport { textOf } from '../../collection/text';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { CloseGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The chips page's filter and input chips as a set: one or more chosen from a\n// row, each one removable. The pill is the chip module's in `src/chip`,\n// shared with the standalone Chip, so the two cannot drift; what is here is\n// the group around them.\n//\n// Three things it adds over a row of Chips.\n//\n// **It is a group, not a row of buttons.** React Aria's `TagGroup` names the\n// set, describes it, reports it invalid as a whole, and moves between its\n// chips with the arrow keys rather than making each one a tab stop — which\n// is what a set of a dozen filters needs. The label, the supporting line and\n// the error are the field chrome's, so a group reads like the fields beside\n// it, exactly as CheckboxGroup and RadioGroup do.\n//\n// **A chip can be removed.** Give the group `onRemove` and each chip draws\n// the page's trailing close target, an 18dp glyph in a target of its own so a\n// press there removes rather than toggles. Backspace and Delete remove the\n// focused chip too, which is React Aria's. A chosen chip's check sits at the\n// other end, so a chip that is both selected and removable carries one glyph\n// on each side of its label.\n//\n// **Selection is the group's, not each chip's.** `selectionMode` and\n// `selectedKeys` live on the group, so a set that chooses one of its chips\n// and a set that chooses several are the same component with a different\n// word. A chip on its own that toggles nothing else is still Chip.\n//\n// **Escape leaves the selection alone.** React Aria's collections clear the\n// selection on Escape and stop the key there, which suits a list whose\n// selection is what an action is about to act on. A set of chips holds a\n// value, as a checkbox group does, and usually sits in a Sheet, Dialog or\n// Popover, where Escape is what dismisses it: clearing it there wiped the\n// reader's filters and took a second press to close. So the group passes\n// React Aria's `escapeKeyBehavior` as `none` unless told `clearSelection`.\n//\n// **A chip a press does nothing to does not look pressable.** In a group\n// that selects nothing, a chip with no action of its own or the group's is\n// a control only for its close target. It draws the arrow cursor, no layer\n// and no ripple, and its close target keeps the pointer. A disabled chip's\n// close target takes the chip's `not-allowed` with it.\n//\n// One thing is worth knowing about how this maps onto React Aria. A chip's\n// text value is read off its children and found only when they are a plain\n// string, and a chip here is always an element — the label sits beside a\n// close target. So a plain-string label is passed through as the text value,\n// which is what typeahead and a screen reader's announcement are made of;\n// see ListBox.Item, where the same thing bit.\n\nconst styles = {\n list: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kwnvtZ: \"x1a02dak\",\n kOIVth: \"x126z3so\",\n kAzted: \"xlzjxrf\",\n $$css: true\n }\n};\ntype ChipGroupChipProps = {\n /**\n * The chip's label. Text, numbers, or a mix of the two — `Label {3}` —\n * also name the chip; a label holding an element needs `textValue`.\n */\n children?: ReactNode;\n /** A function may compute the class from the chip's render state. */\n className?: RACTagProps['className'];\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is chosen, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode;\n /** A function may compute the style from the chip's render state. */\n style?: RACTagProps['style'];\n /**\n * The chip's name as text, which is what a screen reader announces for\n * its row. Read from the label when that is text or numbers, so it is\n * needed only when the label holds an element — emphasis, a count in a\n * badge — and React Aria warns in the console when such a chip has none.\n * Given, it wins over the text read from the label.\n */\n textValue?: string;\n} & Omit<RACTagProps, 'children' | 'className' | 'style' | 'textValue'>;\ntype ChipGroupProps<T extends object = object> = {\n /**\n * The chips, each with an `id` of its own. With `items`, a function from an\n * item to its chip, which React Aria calls for each item in turn.\n */\n children?: ((item: T) => ReactElement) | ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state — the message and `aria-invalid` both\n * follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * What Escape does on a chip. `none`, the default, keeps the selection and\n * lets the key through to whatever is around the group, so a group in a\n * Sheet, Dialog or Popover closes it on the first press. `clearSelection`\n * empties the selection first, as React Aria's own default does, and lets\n * a second press through.\n *\n * @default 'none'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n /**\n * What the group is for. Required rather than optional: a set of chips\n * with no name is a row a screen reader cannot introduce.\n */\n label: string;\n /**\n * What the close target on each chip is called, for a screen reader. React\n * Aria adds the chip's own label after it, so this is the verb rather than\n * the whole phrase — \"Remove\" becomes \"Remove First item\". Left out, React\n * Aria names it in the reader's locale — \"Remove\" in English.\n */\n removeLabel?: string;\n} & Omit<RACTagGroupProps, 'children' | 'escapeKeyBehavior'> & Pick<RACTagListProps<T>, 'items' | 'renderEmptyState'>;\n\n// What the chip 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 check and the icon it replaces are the chip module's, so a chip in a\n// group and a chip on its own draw the same ones. The close target is drawn\n// only where the group allows removing, which React Aria reports rather than\n// the call site saying so on every chip.\n//\n// The ripple is drawn only on a chip a press does something to, and not\n// disabled: one the group lets be selected, or one with an action, its own\n// or the group's. Any other chip in a group that selects nothing is a\n// control only for its close target, and React Aria reports neither hover\n// nor press on it, so a ripple there would answer a press that changes\n// nothing. `acts` is the action half, which the render state does not carry.\n//\n// It sits in a box of its own carrying the chip's corner, since React Aria's\n// cell between the chip and this content would otherwise hand the ripple a\n// square one to inherit; see the header of src/chip/styles.ts.\nfunction chipContent(children: ReactNode, icon: ReactNode, removeLabel: string | undefined, surface: ReactNode, acts: boolean) {\n return (state: TagRenderProps) => <>\n {chipGlyph(state, icon, state.selectionMode !== 'none')}\n {chipLabel(children)}\n {(acts || state.selectionMode !== 'none') && !state.isDisabled ? <span {...stylex.props(chipStyles.surfaceCorners)}>{surface}</span> : null}\n {state.allowsRemoving ? <RACButton aria-label={removeLabel} className={chipRemoveClassName} slot=\"remove\">\n <CloseGlyph {...stylex.props(chipStyles.removeGlyph)} />\n </RACButton> : null}\n </>;\n}\n\n// What each chip calls its close target. A context rather than a prop on the\n// chip, since it is the group's decision and repeating it on every chip is\n// how the two drift. Undefined unless the group is given one, which leaves\n// the name React Aria gives in the reader's locale.\nconst RemoveLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the group was given `onAction`, which makes every chip in it\n// pressable whether or not it selects. A context for the reason the close\n// target's name is one.\nconst GroupActionContext = createContext(false);\n\n// Hoisted so neither is a new object on every render.\nconst LABEL_STATE_VALID = {\n isInvalid: false\n};\nconst LABEL_STATE_INVALID = {\n isInvalid: true\n};\n\n// The pill of a chip with an action, which a press always reaches.\nfunction actingChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state);\n}\n\n/**\n * A labelled set of chips, one or more of which can be chosen, each of which\n * can be removed. Selection is React Aria's: set `selectionMode` to `single`\n * or `multiple` and pass `selectedKeys` with `onSelectionChange` to control\n * it, or `defaultSelectedKeys` to let it keep its own.\n *\n * ```tsx\n * <ChipGroup label=\"Label\" selectionMode=\"multiple\" onRemove={remove}>\n * <ChipGroup.Chip id=\"first\">First item</ChipGroup.Chip>\n * </ChipGroup>\n * ```\n *\n * Give the group `onRemove` and each chip draws a close target. The arrow\n * keys move between chips, so a set of many is one tab stop rather than many.\n *\n * A chip is never wider than its row, so a label with no room ends in an\n * ellipsis rather than wrapping, and shows its full text in the browser's\n * tooltip on hover.\n *\n * Escape on a chip keeps the selection and reaches whatever is around the\n * group, so a group in a Sheet, Dialog or Popover closes it. Pass\n * `escapeKeyBehavior=\"clearSelection\"` for React Aria's own default, which\n * empties the selection on the first press and lets the second through.\n *\n * A chip that toggles nothing else is Chip; this is for a set that shares a\n * value.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction ChipGroup<T extends object = object>({\n children,\n description,\n error,\n escapeKeyBehavior = 'none',\n items,\n label,\n removeLabel,\n renderEmptyState,\n ...props\n}: ChipGroupProps<T> & RefAttributes<HTMLDivElement>) {\n const invalid = invalidFrom(error);\n return <RACTagGroup escapeKeyBehavior={escapeKeyBehavior} {...props} {...mergeStyles(stylex.props(groupStyles.root), props)}>\n {/* React Aria's tag group has no disabled state of its own — a chip is\n disabled through the group's `disabledKeys` — so the label follows\n validity alone. */}\n <FieldLabel state={invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID} variant=\"group\">\n {label}\n </FieldLabel>\n <RemoveLabelContext value={removeLabel}>\n <GroupActionContext value={props.onAction !== undefined}>\n <RACTagList<T> items={items} renderEmptyState={renderEmptyState} {...stylex.props(styles.list, focus.ring)}>\n {children}\n </RACTagList>\n </GroupActionContext>\n </RemoveLabelContext>\n <FieldMessage description={description} error={error} inset={false} />\n </RACTagGroup>;\n}\n\n/**\n * One chip. Give every chip an `id` — that is the key selection and removal\n * are reported by.\n */\nfunction ChipGroupChip({\n children,\n icon,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n ...props\n}: ChipGroupChipProps & RefAttributes<HTMLDivElement>) {\n const removeLabel = useContext(RemoveLabelContext);\n // An action of its own, a link or the group's makes a chip pressable even\n // in a group that selects nothing, as React Aria treats it.\n const acts = useContext(GroupActionContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple a list's rows draw — see ListItem there. A chip in a\n // group is a collection row, whose clicks React Aria keeps for itself, so\n // the press ends when the pointer is released rather than on a click.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACTag textValue={props.textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(acts ? actingChipPropsFor : groupChipPropsFor, props)}>\n {chipContent(children, icon, removeLabel, ripple.surface, acts)}\n </RACTag>;\n}\n\n// The pill a standalone Chip draws, from `src/chip`, touch target included:\n// every chip's reaches halfway across the gap its rows wrap at. Inert where\n// the group selects nothing and the chip has no action — see the header.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n inert: state.selectionMode === 'none'\n });\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,MAAMwC,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AA2FA,SAASiB,YAAYf,UAAqBE,MAAiBW,aAAiCG,SAAoBC,MAAe;CAC7H,QAAQC,UAA0B,q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ergeStyles({ className: "x6s0dn4 x14s9m32 x1fwvt7v x1xdvaa9 x1y0btm7 xmkeg23 x9f619 x78zum5 x126z3so x1cmllll xq7elwu xwde665" }, props);
|
|
98
98
|
let t5;
|
|
99
99
|
if ($[6] !== value) {
|
|
100
100
|
t5 = /* @__PURE__ */ jsx("span", {
|