@kanso-labs/kanso-ui 0.40.5 → 0.40.7
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 +37 -1
- package/dist/button/hooks.js.map +1 -1
- package/dist/button/index.d.ts +57 -1
- package/dist/button/index.js +153 -96
- package/dist/button/index.js.map +1 -1
- package/dist/button/toggle.js +17 -0
- package/dist/button/toggle.js.map +1 -0
- package/dist/calendar/index.js +69 -58
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +29 -6
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/index.js +3 -4
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/styles.js +2 -6
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/empty.js +7 -0
- package/dist/collection/empty.js.map +1 -0
- package/dist/collection/index.js +125 -2
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/styles.js +14 -0
- package/dist/collection/styles.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +26 -23
- package/dist/components/app-bar/index.js +89 -72
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +6 -4
- package/dist/components/autocomplete/index.js +23 -14
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/button/index.d.ts +15 -35
- package/dist/components/button/index.js +102 -74
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +9 -3
- package/dist/components/calendar/index.js +51 -42
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/card/index.js +43 -27
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/carousel/index.js +1 -1
- package/dist/components/checkbox/index.d.ts +9 -0
- package/dist/components/checkbox/index.js +47 -35
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/chip/index.d.ts +9 -4
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.js +51 -37
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/copy-field/index.d.ts +28 -6
- package/dist/components/copy-field/index.js +140 -54
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +6 -2
- package/dist/components/currency/index.js +74 -46
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/dialog/index.js +13 -13
- package/dist/components/disclosure/index.js +1 -1
- package/dist/components/icon-button/index.d.ts +6 -31
- package/dist/components/icon-button/index.js +64 -52
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/list/index.js +2 -2
- package/dist/components/list-box/index.d.ts +14 -2
- package/dist/components/list-box/index.js +16 -8
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/list-item/index.js +1 -1
- package/dist/components/menu/index.d.ts +14 -1
- package/dist/components/menu/index.js +32 -17
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +12 -12
- package/dist/components/radio-group/index.d.ts +4 -0
- package/dist/components/radio-group/index.js +12 -12
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +9 -3
- package/dist/components/range-calendar/index.js +51 -42
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/search-view/index.js +1 -1
- package/dist/components/segmented-button/index.d.ts +5 -4
- package/dist/components/segmented-button/index.js +3 -3
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/sheet/index.js +12 -12
- package/dist/components/split-button/index.d.ts +1 -1
- package/dist/components/split-button/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +9 -2
- package/dist/components/switch/index.js +2 -2
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/table/index.js +3 -3
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/tree/index.js +8 -8
- package/dist/control/index.js +55 -17
- package/dist/control/index.js.map +1 -1
- package/dist/field/index.js +59 -51
- package/dist/field/index.js.map +1 -1
- package/dist/hooks/useAppBarScroll.d.ts +52 -0
- package/dist/hooks/useAppBarScroll.js +75 -0
- package/dist/hooks/useAppBarScroll.js.map +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +68 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/render/name.d.ts +22 -0
- package/dist/styles.css +83 -24
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","CheckboxButtonRenderProps","CheckboxFieldProps","RACCheckboxFieldProps","stylex","CheckboxButton","CheckboxField","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","IndeterminateGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","stateLayerOpacity","FORCED_COLORS","styles","box","k6CgDc","kGNEyG","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kjj79g","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","CheckboxProps","children","description","Omit","Ripple","ReturnType","HTMLSpanElement","Tone","buttonContent","ripple","state","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","handlers","props","disc","controlReadOnly","controlDisabled","ringVisible","surface","Checkbox","t0","$","validationBehavior","T0","t1","t2","field","t3","t4","t5","Symbol","for","messages","t6","t7","stylex.props","_c","props"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxButton, CheckboxField } from 'react-aria-components';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n kMwMTN: \"xrpadme x1bhcspo\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on xmnqt3w\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n error: {\n kWkggS: \"xyn212m\",\n $$css: true\n },\n marked: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"xwqhyid\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLSpanElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The ripple's handlers and surface go on the\n// control while the checkbox can change, and are left off while it cannot,\n// since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, ripple: Ripple) {\n return (state: CheckboxButtonRenderProps) => {\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...interactive ? ripple.handlers : {}} {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n {state.isIndeterminate ? <IndeterminateGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : state.isSelected ? <CheckGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : null}\n </span>\n {interactive ? ripple.surface : null}\n </span>\n <ControlLabel state={state}>{children}</ControlLabel>\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps & RefAttributes<HTMLDivElement>) {\n const ripple = useRipple<HTMLSpanElement>();\n const validationBehavior = useFieldValidationBehavior();\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n <CheckboxButton className=\"xjp7ctv\">\n {buttonContent(children, ripple)}\n </CheckboxButton>\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </CheckboxField>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;AA0CA,MAAMwB,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,WAAW;EACTf,QAAQ;EACRE,QAAQ;EACRY,OAAO;CACT;CACAE,mBAAmB;EACjBhB,QAAQ;EACRE,QAAQ;EACRK,QAAQ;EACRO,OAAO;CACT;CACAG,gBAAgB;EACdjB,QAAQ;EACRE,QAAQ;EACRK,QAAQ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CheckboxButtonRenderProps","CheckboxFieldProps","RACCheckboxFieldProps","stylex","useContext","CheckboxButton","CheckboxField","CheckboxGroupStateContext","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","IndeterminateGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","stateLayerOpacity","FORCED_COLORS","styles","box","k6CgDc","kGNEyG","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kjj79g","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","CheckboxProps","children","description","Omit","Ripple","ReturnType","HTMLSpanElement","Tone","buttonContent","ripple","inGroup","state","required","isRequired","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","handlers","props","disc","controlReadOnly","controlDisabled","ringVisible","surface","Checkbox","t0","$","validationBehavior","reachable","validate","undefined","name","T0","t1","t2","field","t3","t4","t5","Symbol","for","messages","t6","t7","stylex.props","_c","props"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CheckboxButton, CheckboxField, CheckboxGroupStateContext } from 'react-aria-components';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n kMwMTN: \"xrpadme x1bhcspo\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on xmnqt3w\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n error: {\n kWkggS: \"xyn212m\",\n $$css: true\n },\n marked: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"xwqhyid\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n *\n * A link or a button in it acts on its own, as in a native label: a press\n * or Enter on \"the terms\" in \"I agree to the terms\" follows the link and\n * leaves the checkbox as it was. A press anywhere else in the label\n * toggles it.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLSpanElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The ripple's handlers and surface go on the\n// control while the checkbox can change, and are left off while it cannot,\n// since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, ripple: Ripple, inGroup: boolean) {\n return (state: CheckboxButtonRenderProps) => {\n // A checkbox in a group is marked by the group's label rather than its\n // own: the group is what has to have a choice made in it.\n const required = state.isRequired && !inGroup;\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...interactive ? ripple.handlers : {}} {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n {state.isIndeterminate ? <IndeterminateGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : state.isSelected ? <CheckGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : null}\n </span>\n {interactive ? ripple.surface : null}\n </span>\n <ControlLabel isRequired={required} state={state}>\n {children}\n </ControlLabel>\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * `isRequired` ends the label in the asterisk every required field's label\n * ends in. Inside a `CheckboxGroup` the group's label carries it instead,\n * since the group is what must have a choice made in it.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps & RefAttributes<HTMLDivElement>) {\n const ripple = useRipple<HTMLSpanElement>();\n const validationBehavior = useFieldValidationBehavior();\n\n // Whether a message can ever reach this checkbox, which is what a form\n // keeps an empty line under a field for. One in a group cannot — the\n // group owns the one message and keeps its own line for it — and one on\n // its own can only where something can find it wanting: a requirement, a\n // check of its own, or a name a form's errors can be keyed by. Without\n // this every checkbox in a form sat a line taller than it draws, and a\n // group of them in a form gained a line after every item.\n const inGroup = useContext(CheckboxGroupStateContext) !== null;\n const reachable = !inGroup && (props.isRequired === true || props.validate !== undefined || props.name !== undefined);\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n <CheckboxButton className=\"xjp7ctv\">\n {buttonContent(children, ripple, inGroup)}\n </CheckboxButton>\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} inset={false} reserve={reachable} />\n </div>\n </CheckboxField>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;;AA2CA,MAAM0B,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;E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,SAAAA;GAAS,CAAA;EAClF,CAAA;EAAAF,EAAA,KAAAhC;EAAAgC,EAAA,MAAAvC;EAAAuC,EAAA,MAAAE;EAAAF,EAAA,MAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAAA,IAAAiB;CAAA,IAAAjB,EAAA,QAAAM,MAAAN,EAAA,QAAAR,WAAAQ,EAAA,QAAAO,MAAAP,EAAA,QAAAQ,MAAAR,EAAA,QAAAW,MAAAX,EAAA,QAAAgB,MAAAhB,EAAA,QAAAC,oBAAA;EANHgB,KAAA,qBAAC,IAAD;GAA0B,WAAAV;GAAwCN;GAAkB,GAAMT;GAAK,GAAMgB;GAArG,UAAA,CACHG,IAGAK,EAJiB;;EAOHhB,EAAA,MAAAM;EAAAN,EAAA,MAAAR;EAAAQ,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;EAAAR,EAAA,MAAAW;EAAAX,EAAA,MAAAgB;EAAAhB,EAAA,MAAAC;EAAAD,EAAA,MAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,OAPXiB;AAOW"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
3
3
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
4
|
-
import { groupStyles } from "../../field/styles.js";
|
|
5
4
|
import { invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
|
|
5
|
+
import { groupStyles } from "../../field/styles.js";
|
|
6
6
|
import { FieldLabel, FieldMessage } from "../../field/index.js";
|
|
7
7
|
import { c } from "react/compiler-runtime";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -3,8 +3,11 @@ import { ButtonProps, ToggleButtonProps } from "react-aria-components";
|
|
|
3
3
|
//#region src/components/chip/index.d.ts
|
|
4
4
|
/** An assist or suggestion chip: an action, drawn as a plain button. */
|
|
5
5
|
type ChipActionProps = Omit<ButtonProps, 'children' | 'isPending'> & {
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The chip's label. Required: the page draws no chip without one, and a
|
|
8
|
+
* chip with none is an empty button to a screen reader.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
8
11
|
/**
|
|
9
12
|
* Raises the chip off the page on a container of its own, at the page's
|
|
10
13
|
* elevation 1, in place of the outline.
|
|
@@ -29,9 +32,11 @@ type ChipFilterProps = Omit<ToggleButtonProps, 'children'> & {
|
|
|
29
32
|
* The chip's label. A node rather than React Aria's node-or-function,
|
|
30
33
|
* since the chip puts its own check before whatever this is and a function
|
|
31
34
|
* would be handed a `defaultChildren` the chip never rendered. ChipGroup's
|
|
32
|
-
* chip narrows it the same way, for the same reason.
|
|
35
|
+
* chip narrows it the same way, for the same reason. Required: the page
|
|
36
|
+
* draws no chip without one, and a chip with none is an empty button to a
|
|
37
|
+
* screen reader.
|
|
33
38
|
*/
|
|
34
|
-
children
|
|
39
|
+
children: ReactNode;
|
|
35
40
|
/**
|
|
36
41
|
* Raises the chip off the page on a container of its own, at the page's
|
|
37
42
|
* elevation 1, in place of the outline. A selected one keeps the
|
|
@@ -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 /** The chip's label. */\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.\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":";;;;;;;;;AA6GA,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,E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AAA2B,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({ 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,EAAA,OAAAM,mBAAAN,EAAA,OAAAO,iBAAAP,EAAA,OAAAQ,kBAAAR,EAAA,OAAAS,aAAA;EAICM,KAAA;GAAAb;GAAAC;GAAAG;GAAAC;GAAAC;GAAAC;EAOtE;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,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"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
3
3
|
import { mergeStatefulStyles, mergeStyles } from "../../styles/merge.js";
|
|
4
4
|
import { CloseGlyph } from "../../glyphs/index.js";
|
|
5
|
+
import { focus } from "../../styles/focus.js";
|
|
5
6
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
6
|
-
import { groupStyles } from "../../field/styles.js";
|
|
7
7
|
import { invalidFrom } from "../../field/root.js";
|
|
8
|
+
import { groupStyles } from "../../field/styles.js";
|
|
8
9
|
import { FieldLabel, FieldMessage } from "../../field/index.js";
|
|
9
10
|
import { chipStyles } from "../../chip/styles.js";
|
|
10
11
|
import { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from "../../chip/index.js";
|
|
@@ -14,6 +15,14 @@ import { createContext, useContext } from "react";
|
|
|
14
15
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
15
16
|
import { Button, Tag, TagGroup, TagList } from "react-aria-components";
|
|
16
17
|
//#region src/components/chip-group/index.tsx
|
|
18
|
+
const styles = { list: {
|
|
19
|
+
kB7OPa: "x9f619",
|
|
20
|
+
k1xSpc: "x78zum5",
|
|
21
|
+
kwnvtZ: "x1a02dak",
|
|
22
|
+
kOIVth: "x126z3so",
|
|
23
|
+
kAzted: "xlzjxrf",
|
|
24
|
+
$$css: true
|
|
25
|
+
} };
|
|
17
26
|
function chipContent(children, icon, removeLabel, surface) {
|
|
18
27
|
return (state) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
19
28
|
chipGlyph(state, icon),
|
|
@@ -52,7 +61,7 @@ const LABEL_STATE_INVALID = { isInvalid: true };
|
|
|
52
61
|
* which is the element a layout positions.
|
|
53
62
|
*/
|
|
54
63
|
function ChipGroup(t0) {
|
|
55
|
-
const $ = c(
|
|
64
|
+
const $ = c(33);
|
|
56
65
|
let T0;
|
|
57
66
|
let children;
|
|
58
67
|
let description;
|
|
@@ -115,59 +124,64 @@ function ChipGroup(t0) {
|
|
|
115
124
|
$[14] = t4;
|
|
116
125
|
} else t4 = $[14];
|
|
117
126
|
let t5;
|
|
118
|
-
if ($[15]
|
|
119
|
-
t5 =
|
|
127
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
128
|
+
t5 = props(styles.list, focus.ring);
|
|
129
|
+
$[15] = t5;
|
|
130
|
+
} else t5 = $[15];
|
|
131
|
+
let t6;
|
|
132
|
+
if ($[16] !== children || $[17] !== items || $[18] !== renderEmptyState) {
|
|
133
|
+
t6 = /* @__PURE__ */ jsx(TagList, {
|
|
120
134
|
items,
|
|
121
135
|
renderEmptyState,
|
|
122
|
-
|
|
136
|
+
...t5,
|
|
123
137
|
children
|
|
124
138
|
});
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
} else
|
|
130
|
-
let
|
|
131
|
-
if ($[
|
|
132
|
-
|
|
139
|
+
$[16] = children;
|
|
140
|
+
$[17] = items;
|
|
141
|
+
$[18] = renderEmptyState;
|
|
142
|
+
$[19] = t6;
|
|
143
|
+
} else t6 = $[19];
|
|
144
|
+
let t7;
|
|
145
|
+
if ($[20] !== removeLabel || $[21] !== t6) {
|
|
146
|
+
t7 = /* @__PURE__ */ jsx(RemoveLabelContext, {
|
|
133
147
|
value: removeLabel,
|
|
134
|
-
children:
|
|
148
|
+
children: t6
|
|
135
149
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[20] = t5;
|
|
150
|
+
$[20] = removeLabel;
|
|
138
151
|
$[21] = t6;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
$[22] = t7;
|
|
153
|
+
} else t7 = $[22];
|
|
154
|
+
let t8;
|
|
155
|
+
if ($[23] !== description || $[24] !== error) {
|
|
156
|
+
t8 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
143
157
|
description,
|
|
144
158
|
error,
|
|
145
159
|
inset: false
|
|
146
160
|
});
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
} else
|
|
151
|
-
let
|
|
152
|
-
if ($[
|
|
153
|
-
|
|
161
|
+
$[23] = description;
|
|
162
|
+
$[24] = error;
|
|
163
|
+
$[25] = t8;
|
|
164
|
+
} else t8 = $[25];
|
|
165
|
+
let t9;
|
|
166
|
+
if ($[26] !== T0 || $[27] !== t1 || $[28] !== t2 || $[29] !== t4 || $[30] !== t7 || $[31] !== t8) {
|
|
167
|
+
t9 = /* @__PURE__ */ jsxs(T0, {
|
|
154
168
|
...t1,
|
|
155
169
|
...t2,
|
|
156
170
|
children: [
|
|
157
171
|
t4,
|
|
158
|
-
|
|
159
|
-
|
|
172
|
+
t7,
|
|
173
|
+
t8
|
|
160
174
|
]
|
|
161
175
|
});
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
$[29] = t6;
|
|
176
|
+
$[26] = T0;
|
|
177
|
+
$[27] = t1;
|
|
178
|
+
$[28] = t2;
|
|
179
|
+
$[29] = t4;
|
|
167
180
|
$[30] = t7;
|
|
168
181
|
$[31] = t8;
|
|
169
|
-
|
|
170
|
-
|
|
182
|
+
$[32] = t9;
|
|
183
|
+
} else t9 = $[32];
|
|
184
|
+
return t9;
|
|
171
185
|
}
|
|
172
186
|
/**
|
|
173
187
|
* One chip. Give every chip an `id` — that is the key selection and removal
|
|
@@ -227,7 +241,7 @@ function ChipGroupChip(t0) {
|
|
|
227
241
|
return t6;
|
|
228
242
|
}
|
|
229
243
|
function groupChipPropsFor(state) {
|
|
230
|
-
return chipPropsFor(state
|
|
244
|
+
return chipPropsFor(state);
|
|
231
245
|
}
|
|
232
246
|
ChipGroup.Chip = ChipGroupChip;
|
|
233
247
|
//#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","mergeStatefulStyles","mergeStyles","spacing","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","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","ripple","textValue","handlers","groupChipPropsFor","inGroup","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 { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { 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\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} className=\"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\">\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`, with the touch target a\n// chip in a group takes instead.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n inGroup: true\n });\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;AAoHA,SAASoD,YAAYZ,UAAqBE,MAAiBQ,aAAiCG,SAAoB;CAC9G,QAAQC,UAA0B,qBAAA,YAAA,EAAA,UAAA;EAC7B/B,UAAU+B,OAAOZ,IAAI;EACrBlB,UAAUgB,QAAQ;EAClBc,MAAMC,kBAAkB,UAAU,CAACD,MAAME,aAAaH,UAAU;EAChEC,MAAMG,iBAAiB,oBAACqC,QAAD;GAAW,cAAY5C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AT,EAAA,OAAA3B,YAAA2B,EAAA,OAAAzB,QAAAyB,EAAA,OAAAjB,eAAAiB,EAAA,OAAAqB,OAAAnC,SAAA;EAC3IuB,KAAAxB,YAAYZ,UAAUE,MAAMQ,aAAasC,OAAMnC,OAAQ;EAACc,EAAA,KAAA3B;EAAA2B,EAAA,KAAAzB;EAAAyB,EAAA,KAAAjB;EAAAiB,EAAA,KAAAqB,OAAAnC;EAAAc,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,QAAAC,MAAAD,EAAA,QAAAT,SAAAS,EAAA,QAAAqB,OAAAE,YAAAvB,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,MAAAqB,OAAAE;EAAAvB,EAAA,MAAAM;EAAAN,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFJU;AAEI;AAKb,SAASc,kBAAkBrC,OAAuB;CAChD,OAAO7B,aAAa6B,OAAO,EACzBsC,SAAS,KACX,CAAC;AACH;AACA3B,UAAU4B,OAAOX"}
|
|
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;AAMA,MAAMC,qBAAqBzD,cAAkC0D,KAAAA,CAAS;AAGtE,MAAMC,oBAAoB,EACxBC,WAAW,MACb;AACA,MAAMC,sBAAsB,EAC1BD,WAAW,KACb;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAAE,UAAAC,IAAA;CAAA,MAAA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AAQ;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"}
|
|
@@ -13,6 +13,15 @@ type CopyFieldProps = {
|
|
|
13
13
|
* I18nProvider's locale — "Copy" in English.
|
|
14
14
|
*/
|
|
15
15
|
copyLabel?: string;
|
|
16
|
+
/**
|
|
17
|
+
* What the value is — "Repository URL", "Access token" — for a page with
|
|
18
|
+
* more than one field. It names the field as a group and joins the button's
|
|
19
|
+
* name, so a screen reader hears "Copy Repository URL" rather than one
|
|
20
|
+
* "Copy" after another; it is not shown. The value itself stays out of the
|
|
21
|
+
* button's name, since a token would be read aloud. Left out, the field is
|
|
22
|
+
* unnamed and its button is "Copy" alone, as it always was.
|
|
23
|
+
*/
|
|
24
|
+
label?: string;
|
|
16
25
|
/**
|
|
17
26
|
* Called with the value after it reaches the clipboard, never before.
|
|
18
27
|
*
|
|
@@ -24,9 +33,10 @@ type CopyFieldProps = {
|
|
|
24
33
|
*/
|
|
25
34
|
onCopied?: (value: string) => void;
|
|
26
35
|
/**
|
|
27
|
-
* Called when the write is refused, with whatever was thrown
|
|
28
|
-
*
|
|
29
|
-
*
|
|
36
|
+
* Called when the write is refused, with whatever was thrown, and the
|
|
37
|
+
* field's own fallback has not copied the value either. By then the value
|
|
38
|
+
* is selected and the field says so — see `selectedLabel` — so this is for
|
|
39
|
+
* an app that wants to say more, in a snackbar say.
|
|
30
40
|
*
|
|
31
41
|
* Takes the error where `onCopied` takes the value, because the value is
|
|
32
42
|
* the one thing the call site already has and the reason is the one thing
|
|
@@ -35,6 +45,15 @@ type CopyFieldProps = {
|
|
|
35
45
|
* permission is denied it is a `DOMException`.
|
|
36
46
|
*/
|
|
37
47
|
onCopyFailed?: (error: unknown) => void;
|
|
48
|
+
/**
|
|
49
|
+
* What is announced when the clipboard refused the write and the value has
|
|
50
|
+
* been selected for the reader to copy themselves. The button keeps saying
|
|
51
|
+
* `copyLabel`, since a label slot wide enough for this would double the
|
|
52
|
+
* button's width at rest; the selection itself is what shows. Left out, it
|
|
53
|
+
* is the phrase for it in the I18nProvider's locale — "Selected to copy"
|
|
54
|
+
* in English.
|
|
55
|
+
*/
|
|
56
|
+
selectedLabel?: string;
|
|
38
57
|
/** The text shown, and the text copied. */
|
|
39
58
|
value: string;
|
|
40
59
|
} & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
@@ -44,10 +63,13 @@ type CopyFieldProps = {
|
|
|
44
63
|
* on the button itself.
|
|
45
64
|
*
|
|
46
65
|
* A write refused — outside a secure context, or where the permission is
|
|
47
|
-
* denied —
|
|
48
|
-
*
|
|
66
|
+
* denied — does not leave the reader with nothing. The field selects the
|
|
67
|
+
* value and tries the older copy command, which some of those places still
|
|
68
|
+
* allow; failing that, the selection is left ready for the keyboard's own
|
|
69
|
+
* copy, the field announces so, and `onCopyFailed` is called. One click on
|
|
70
|
+
* the value selects exactly the value too.
|
|
49
71
|
*/
|
|
50
|
-
declare function CopyField({ copiedLabel: copiedLabelProp, copyLabel: copyLabelProp, onCopied, onCopyFailed, value, ...props }: CopyFieldProps & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
72
|
+
declare function CopyField({ copiedLabel: copiedLabelProp, copyLabel: copyLabelProp, label, onCopied, onCopyFailed, selectedLabel: selectedLabelProp, value, ...props }: CopyFieldProps & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
51
73
|
//#endregion
|
|
52
74
|
export { type CopyFieldProps, CopyField as default };
|
|
53
75
|
//# sourceMappingURL=index.d.ts.map
|