@depup/react-aria-components 1.19.0-depup.27 → 1.20.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PreviewTrigger/package.json +5 -0
- package/README.md +2 -2
- package/TokenField/package.json +5 -0
- package/changes.json +1 -1
- package/dist/exports/GridList.cjs.map +1 -1
- package/dist/exports/GridList.js.map +1 -1
- package/dist/exports/GridList.mjs.map +1 -1
- package/dist/exports/PreviewTrigger.cjs +26 -0
- package/dist/exports/PreviewTrigger.cjs.map +1 -0
- package/dist/exports/PreviewTrigger.js +21 -0
- package/dist/exports/PreviewTrigger.js.map +1 -0
- package/dist/exports/PreviewTrigger.mjs +21 -0
- package/dist/exports/PreviewTrigger.mjs.map +1 -0
- package/dist/exports/TokenField.cjs +31 -0
- package/dist/exports/TokenField.cjs.map +1 -0
- package/dist/exports/TokenField.js +21 -0
- package/dist/exports/TokenField.js.map +1 -0
- package/dist/exports/TokenField.mjs +21 -0
- package/dist/exports/TokenField.mjs.map +1 -0
- package/dist/exports/Tree.cjs.map +1 -1
- package/dist/exports/Tree.js.map +1 -1
- package/dist/exports/Tree.mjs.map +1 -1
- package/dist/exports/index.cjs +12 -0
- package/dist/exports/index.cjs.map +1 -1
- package/dist/exports/index.js +7 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/index.mjs +7 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/private/Checkbox.cjs.map +1 -1
- package/dist/private/Checkbox.js.map +1 -1
- package/dist/private/Checkbox.mjs.map +1 -1
- package/dist/private/ComboBox.cjs +21 -2
- package/dist/private/ComboBox.cjs.map +1 -1
- package/dist/private/ComboBox.js +21 -2
- package/dist/private/ComboBox.js.map +1 -1
- package/dist/private/ComboBox.mjs +21 -2
- package/dist/private/ComboBox.mjs.map +1 -1
- package/dist/private/Dialog.cjs +15 -1
- package/dist/private/Dialog.cjs.map +1 -1
- package/dist/private/Dialog.js +15 -1
- package/dist/private/Dialog.js.map +1 -1
- package/dist/private/Dialog.mjs +15 -1
- package/dist/private/Dialog.mjs.map +1 -1
- package/dist/private/DragAndDrop.cjs +1 -0
- package/dist/private/DragAndDrop.cjs.map +1 -1
- package/dist/private/DragAndDrop.js +1 -0
- package/dist/private/DragAndDrop.js.map +1 -1
- package/dist/private/DragAndDrop.mjs +1 -0
- package/dist/private/DragAndDrop.mjs.map +1 -1
- package/dist/private/DropZone.cjs +5 -2
- package/dist/private/DropZone.cjs.map +1 -1
- package/dist/private/DropZone.js +5 -3
- package/dist/private/DropZone.js.map +1 -1
- package/dist/private/DropZone.mjs +5 -2
- package/dist/private/DropZone.mjs.map +1 -1
- package/dist/private/FileTrigger.cjs +1 -0
- package/dist/private/FileTrigger.cjs.map +1 -1
- package/dist/private/FileTrigger.js +1 -0
- package/dist/private/FileTrigger.js.map +1 -1
- package/dist/private/FileTrigger.mjs +1 -0
- package/dist/private/FileTrigger.mjs.map +1 -1
- package/dist/private/GridLayout.cjs +3 -1
- package/dist/private/GridLayout.cjs.map +1 -1
- package/dist/private/GridLayout.js +3 -1
- package/dist/private/GridLayout.js.map +1 -1
- package/dist/private/GridLayout.mjs +3 -1
- package/dist/private/GridLayout.mjs.map +1 -1
- package/dist/private/GridList.cjs +12 -1
- package/dist/private/GridList.cjs.map +1 -1
- package/dist/private/GridList.js +12 -1
- package/dist/private/GridList.js.map +1 -1
- package/dist/private/GridList.mjs +12 -1
- package/dist/private/GridList.mjs.map +1 -1
- package/dist/private/ListBox.cjs +9 -1
- package/dist/private/ListBox.cjs.map +1 -1
- package/dist/private/ListBox.js +9 -1
- package/dist/private/ListBox.js.map +1 -1
- package/dist/private/ListBox.mjs +9 -1
- package/dist/private/ListBox.mjs.map +1 -1
- package/dist/private/Menu.cjs +4 -2
- package/dist/private/Menu.cjs.map +1 -1
- package/dist/private/Menu.js +4 -2
- package/dist/private/Menu.js.map +1 -1
- package/dist/private/Menu.mjs +4 -2
- package/dist/private/Menu.mjs.map +1 -1
- package/dist/private/Meter.cjs +2 -1
- package/dist/private/Meter.cjs.map +1 -1
- package/dist/private/Meter.js +2 -1
- package/dist/private/Meter.js.map +1 -1
- package/dist/private/Meter.mjs +2 -1
- package/dist/private/Meter.mjs.map +1 -1
- package/dist/private/Modal.cjs +2 -0
- package/dist/private/Modal.cjs.map +1 -1
- package/dist/private/Modal.js +2 -0
- package/dist/private/Modal.js.map +1 -1
- package/dist/private/Modal.mjs +2 -0
- package/dist/private/Modal.mjs.map +1 -1
- package/dist/private/Popover.cjs +34 -9
- package/dist/private/Popover.cjs.map +1 -1
- package/dist/private/Popover.js +34 -9
- package/dist/private/Popover.js.map +1 -1
- package/dist/private/Popover.mjs +34 -9
- package/dist/private/Popover.mjs.map +1 -1
- package/dist/private/PreviewTrigger.cjs +88 -0
- package/dist/private/PreviewTrigger.cjs.map +1 -0
- package/dist/private/PreviewTrigger.js +80 -0
- package/dist/private/PreviewTrigger.js.map +1 -0
- package/dist/private/PreviewTrigger.mjs +79 -0
- package/dist/private/PreviewTrigger.mjs.map +1 -0
- package/dist/private/ProgressBar.cjs +6 -1
- package/dist/private/ProgressBar.cjs.map +1 -1
- package/dist/private/ProgressBar.js +6 -1
- package/dist/private/ProgressBar.js.map +1 -1
- package/dist/private/ProgressBar.mjs +6 -1
- package/dist/private/ProgressBar.mjs.map +1 -1
- package/dist/private/Select.cjs.map +1 -1
- package/dist/private/Select.js.map +1 -1
- package/dist/private/Select.mjs.map +1 -1
- package/dist/private/Table.cjs +26 -14
- package/dist/private/Table.cjs.map +1 -1
- package/dist/private/Table.js +26 -14
- package/dist/private/Table.js.map +1 -1
- package/dist/private/Table.mjs +26 -14
- package/dist/private/Table.mjs.map +1 -1
- package/dist/private/TableLayout.cjs +3 -1
- package/dist/private/TableLayout.cjs.map +1 -1
- package/dist/private/TableLayout.js +3 -1
- package/dist/private/TableLayout.js.map +1 -1
- package/dist/private/TableLayout.mjs +3 -1
- package/dist/private/TableLayout.mjs.map +1 -1
- package/dist/private/TagGroup.cjs +1 -0
- package/dist/private/TagGroup.cjs.map +1 -1
- package/dist/private/TagGroup.js +1 -0
- package/dist/private/TagGroup.js.map +1 -1
- package/dist/private/TagGroup.mjs +1 -0
- package/dist/private/TagGroup.mjs.map +1 -1
- package/dist/private/ToggleButton.cjs.map +1 -1
- package/dist/private/ToggleButton.js.map +1 -1
- package/dist/private/ToggleButton.mjs.map +1 -1
- package/dist/private/TokenField.cjs +207 -0
- package/dist/private/TokenField.cjs.map +1 -0
- package/dist/private/TokenField.js +197 -0
- package/dist/private/TokenField.js.map +1 -0
- package/dist/private/TokenField.mjs +195 -0
- package/dist/private/TokenField.mjs.map +1 -0
- package/dist/private/Tooltip.cjs +10 -2
- package/dist/private/Tooltip.cjs.map +1 -1
- package/dist/private/Tooltip.js +10 -2
- package/dist/private/Tooltip.js.map +1 -1
- package/dist/private/Tooltip.mjs +10 -2
- package/dist/private/Tooltip.mjs.map +1 -1
- package/dist/private/Tree.cjs +11 -1
- package/dist/private/Tree.cjs.map +1 -1
- package/dist/private/Tree.js +11 -1
- package/dist/private/Tree.js.map +1 -1
- package/dist/private/Tree.mjs +11 -1
- package/dist/private/Tree.mjs.map +1 -1
- package/dist/private/Virtualizer.cjs +18 -16
- package/dist/private/Virtualizer.cjs.map +1 -1
- package/dist/private/Virtualizer.js +18 -16
- package/dist/private/Virtualizer.js.map +1 -1
- package/dist/private/Virtualizer.mjs +18 -16
- package/dist/private/Virtualizer.mjs.map +1 -1
- package/dist/private/useDragAndDrop.cjs +7 -0
- package/dist/private/useDragAndDrop.cjs.map +1 -1
- package/dist/private/useDragAndDrop.js +7 -0
- package/dist/private/useDragAndDrop.js.map +1 -1
- package/dist/private/useDragAndDrop.mjs +7 -0
- package/dist/private/useDragAndDrop.mjs.map +1 -1
- package/dist/private/utils.cjs.map +1 -1
- package/dist/private/utils.js.map +1 -1
- package/dist/private/utils.mjs.map +1 -1
- package/dist/types/exports/GridList.d.ts +1 -1
- package/dist/types/exports/PreviewTrigger.d.ts +3 -0
- package/dist/types/exports/TokenField.d.ts +5 -0
- package/dist/types/exports/Tree.d.ts +1 -1
- package/dist/types/exports/index.d.ts +7 -2
- package/dist/types/src/ComboBox.d.ts +4 -1
- package/dist/types/src/GridList.d.ts +12 -1
- package/dist/types/src/ListBox.d.ts +1 -1
- package/dist/types/src/Popover.d.ts +7 -0
- package/dist/types/src/PreviewTrigger.d.ts +23 -0
- package/dist/types/src/Select.d.ts +1 -1
- package/dist/types/src/Table.d.ts +24 -0
- package/dist/types/src/TokenField.d.ts +111 -0
- package/dist/types/src/Tree.d.ts +7 -5
- package/dist/types/src/Virtualizer.d.ts +4 -0
- package/dist/types/src/utils.d.ts +19 -5
- package/i18n/ar-AE.js +1 -1
- package/i18n/ar-AE.mjs +1 -1
- package/i18n/bg-BG.js +1 -1
- package/i18n/bg-BG.mjs +1 -1
- package/i18n/cs-CZ.js +1 -1
- package/i18n/cs-CZ.mjs +1 -1
- package/i18n/da-DK.js +1 -1
- package/i18n/da-DK.mjs +1 -1
- package/i18n/de-DE.js +1 -1
- package/i18n/de-DE.mjs +1 -1
- package/i18n/el-GR.js +1 -1
- package/i18n/el-GR.mjs +1 -1
- package/i18n/en-US.js +1 -1
- package/i18n/en-US.mjs +1 -1
- package/i18n/es-ES.js +1 -1
- package/i18n/es-ES.mjs +1 -1
- package/i18n/et-EE.js +1 -1
- package/i18n/et-EE.mjs +1 -1
- package/i18n/fi-FI.js +1 -1
- package/i18n/fi-FI.mjs +1 -1
- package/i18n/fr-FR.js +1 -1
- package/i18n/fr-FR.mjs +1 -1
- package/i18n/he-IL.js +1 -1
- package/i18n/he-IL.mjs +1 -1
- package/i18n/hr-HR.js +1 -1
- package/i18n/hr-HR.mjs +1 -1
- package/i18n/hu-HU.js +1 -1
- package/i18n/hu-HU.mjs +1 -1
- package/i18n/it-IT.js +1 -1
- package/i18n/it-IT.mjs +1 -1
- package/i18n/ja-JP.js +1 -1
- package/i18n/ja-JP.mjs +1 -1
- package/i18n/ko-KR.js +1 -1
- package/i18n/ko-KR.mjs +1 -1
- package/i18n/lt-LT.js +1 -1
- package/i18n/lt-LT.mjs +1 -1
- package/i18n/lv-LV.js +1 -1
- package/i18n/lv-LV.mjs +1 -1
- package/i18n/nb-NO.js +1 -1
- package/i18n/nb-NO.mjs +1 -1
- package/i18n/nl-NL.js +1 -1
- package/i18n/nl-NL.mjs +1 -1
- package/i18n/pl-PL.js +1 -1
- package/i18n/pl-PL.mjs +1 -1
- package/i18n/pt-BR.js +1 -1
- package/i18n/pt-BR.mjs +1 -1
- package/i18n/pt-PT.js +1 -1
- package/i18n/pt-PT.mjs +1 -1
- package/i18n/ro-RO.js +1 -1
- package/i18n/ro-RO.mjs +1 -1
- package/i18n/ru-RU.js +1 -1
- package/i18n/ru-RU.mjs +1 -1
- package/i18n/sk-SK.js +1 -1
- package/i18n/sk-SK.mjs +1 -1
- package/i18n/sl-SI.js +1 -1
- package/i18n/sl-SI.mjs +1 -1
- package/i18n/sr-SP.js +1 -1
- package/i18n/sr-SP.mjs +1 -1
- package/i18n/sv-SE.js +1 -1
- package/i18n/sv-SE.mjs +1 -1
- package/i18n/tr-TR.js +1 -1
- package/i18n/tr-TR.mjs +1 -1
- package/i18n/uk-UA.js +1 -1
- package/i18n/uk-UA.mjs +1 -1
- package/i18n/zh-CN.js +1 -1
- package/i18n/zh-CN.mjs +1 -1
- package/i18n/zh-TW.js +1 -1
- package/i18n/zh-TW.mjs +1 -1
- package/package.json +32 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AA8PM,MAAM,0DAAkB,CAAA,GAAA,oBAAY,EAAiD;AACrF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DAA4B,CAAA,GAAA,oBAAY,EAA6B;AAK3E,MAAM,4CAA8B,AAAd,WAAW,GAAI,CAA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B,GAAG,KAAK;0BACR;QACA,QAAQ;wBACN;YACA,iBAAiB,mBAAmB;uBACpC;uBACA;uBACA;4BACA;wBACA;wBACA;uBACA;YACA,YAAY,cAAc;QAC5B;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,sBAAoB,mBAAmB;QACvC,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Checkbox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n AriaCheckboxGroupProps,\n useCheckboxGroup,\n useCheckboxGroupItem\n} from 'react-aria/useCheckboxGroup';\n\nimport {AriaCheckboxProps, CheckboxAria, useCheckbox} from 'react-aria/useCheckbox';\nimport {CheckboxGroupState, useCheckboxGroupState} from 'react-stately/useCheckboxGroupState';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useToggleState} from 'react-stately/useToggleState';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface CheckboxGroupProps\n extends\n Omit<\n AriaCheckboxGroupProps,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<CheckboxGroupRenderProps, 'div'>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxGroup'\n */\n className?: ClassNameOrFunction<CheckboxGroupRenderProps>;\n}\n\nexport interface CheckboxProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n HoverEvents,\n RACValidation,\n RenderProps<CheckboxRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Checkbox'\n */\n className?: ClassNameOrFunction<CheckboxRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxFieldProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<CheckboxFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxField'\n */\n className?: ClassNameOrFunction<CheckboxFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxButtonProps\n extends\n HoverEvents,\n RenderProps<CheckboxButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxButton'\n */\n className?: ClassNameOrFunction<CheckboxButtonRenderProps>;\n}\n\nexport interface CheckboxGroupRenderProps {\n /**\n * Whether the checkbox group is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox group is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox group is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the checkbox group is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * State of the checkbox group.\n */\n state: CheckboxGroupState;\n}\n\nexport interface CheckboxRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the checkbox is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the checkbox is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the checkbox is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxFieldRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxButtonRenderProps extends CheckboxRenderProps {}\n\nexport const CheckboxContext = createContext<ContextValue<CheckboxProps, HTMLLabelElement>>(null);\nexport const CheckboxFieldContext =\n createContext<ContextValue<CheckboxFieldProps, HTMLDivElement>>(null);\nexport const CheckboxGroupContext =\n createContext<ContextValue<CheckboxGroupProps, HTMLDivElement>>(null);\nexport const CheckboxGroupStateContext = createContext<CheckboxGroupState | null>(null);\n\n/**\n * A checkbox group allows a user to select multiple items from a list of options.\n */\nexport const CheckboxGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxGroup(\n props: CheckboxGroupProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, CheckboxGroupContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useCheckboxGroupState({\n ...props,\n validationBehavior\n });\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {groupProps, labelProps, descriptionProps, errorMessageProps, ...validation} =\n useCheckboxGroup(\n {\n ...props,\n label,\n validationBehavior\n },\n state\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly,\n isRequired: props.isRequired || false,\n isInvalid: state.isInvalid,\n state\n },\n defaultClassName: 'react-aria-CheckboxGroup'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-required={props.isRequired || undefined}\n data-invalid={state.isInvalid || undefined}\n data-disabled={props.isDisabled || undefined}>\n <Provider\n values={[\n [CheckboxGroupStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\ninterface InternalCheckboxContextValue extends CheckboxAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isIndeterminate?: boolean;\n isRequired?: boolean;\n}\n\nconst InternalCheckboxContext = createContext<InternalCheckboxContextValue | null>(null);\n\n/**\n * A checkbox allows a user to select an item, with support for validation and help text.\n */\nexport const CheckboxField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxFieldContext);\n let groupState = useContext(CheckboxGroupStateContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-CheckboxField',\n values: {\n isSelected,\n isIndeterminate: props.isIndeterminate || false,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={props.isIndeterminate || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [\n InternalCheckboxContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-CheckboxButton',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n // In a CheckboxGroup, validation is handled at the group level instead of repeated on each checkbox.\n [FieldErrorContext, groupState ? null : {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\nfunction useCheckboxAria(\n props: CheckboxProps | CheckboxFieldProps,\n userProvidedInputRef: RefObject<HTMLInputElement | null> | null\n): [CheckboxAria, RefObject<HTMLInputElement | null>] {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let groupState = useContext(CheckboxGroupStateContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let checkboxProps = {\n ...removeDataAttributes(props),\n children: typeof props.children === 'function' ? true : props.children,\n value: props.value!,\n validationBehavior\n };\n\n let aria = groupState\n ? // eslint-disable-next-line react-hooks/rules-of-hooks\n useCheckboxGroupItem(checkboxProps, groupState, inputRef)\n : // eslint-disable-next-line react-hooks/rules-of-hooks\n useCheckbox(checkboxProps, useToggleState(props), inputRef);\n return [aria, inputRef];\n}\n\n/**\n * A checkbox allows a user to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n *\n * @deprecated Use CheckboxField + CheckboxButton instead.\n */\nexport const Checkbox = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n\n return (\n <InternalCheckboxContext.Provider\n value={{\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Checkbox',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }}>\n <CheckboxButton {...props} ref={ref} />\n </InternalCheckboxContext.Provider>\n );\n});\n\n/**\n * A checkbox button is the clickable area of a checkbox, including the indicator and label.\n */\nexport const CheckboxButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxButton(\n props: CheckboxButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isIndeterminate,\n isRequired\n } = useContext(InternalCheckboxContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isIndeterminate: isIndeterminate || false,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={isIndeterminate || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Checkbox.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AA8PM,MAAM,0DAAkB,CAAA,GAAA,oBAAY,EAAiD;AACrF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DAA4B,CAAA,GAAA,oBAAY,EAA6B;AAK3E,MAAM,4CAA8B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,cACjF,KAAyB,EACzB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,G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O;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,sBAAoB,mBAAmB;QACvC,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Checkbox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n AriaCheckboxGroupProps,\n useCheckboxGroup,\n useCheckboxGroupItem\n} from 'react-aria/useCheckboxGroup';\n\nimport {AriaCheckboxProps, CheckboxAria, useCheckbox} from 'react-aria/useCheckbox';\nimport {CheckboxGroupState, useCheckboxGroupState} from 'react-stately/useCheckboxGroupState';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useToggleState} from 'react-stately/useToggleState';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface CheckboxGroupProps\n extends\n Omit<\n AriaCheckboxGroupProps,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<CheckboxGroupRenderProps, 'div'>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxGroup'\n */\n className?: ClassNameOrFunction<CheckboxGroupRenderProps>;\n}\n\nexport interface CheckboxProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n HoverEvents,\n RACValidation,\n RenderProps<CheckboxRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Checkbox'\n */\n className?: ClassNameOrFunction<CheckboxRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxFieldProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<CheckboxFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxField'\n */\n className?: ClassNameOrFunction<CheckboxFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxButtonProps\n extends\n HoverEvents,\n RenderProps<CheckboxButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxButton'\n */\n className?: ClassNameOrFunction<CheckboxButtonRenderProps>;\n}\n\nexport interface CheckboxGroupRenderProps {\n /**\n * Whether the checkbox group is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox group is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox group is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the checkbox group is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * State of the checkbox group.\n */\n state: CheckboxGroupState;\n}\n\nexport interface CheckboxRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the checkbox is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the checkbox is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the checkbox is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxFieldRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxButtonRenderProps extends CheckboxRenderProps {}\n\nexport const CheckboxContext = createContext<ContextValue<CheckboxProps, HTMLLabelElement>>(null);\nexport const CheckboxFieldContext =\n createContext<ContextValue<CheckboxFieldProps, HTMLDivElement>>(null);\nexport const CheckboxGroupContext =\n createContext<ContextValue<CheckboxGroupProps, HTMLDivElement>>(null);\nexport const CheckboxGroupStateContext = createContext<CheckboxGroupState | null>(null);\n\n/**\n * A checkbox group allows a user to select multiple items from a list of options.\n */\nexport const CheckboxGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxGroup(\n props: CheckboxGroupProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, CheckboxGroupContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useCheckboxGroupState({\n ...props,\n validationBehavior\n });\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {groupProps, labelProps, descriptionProps, errorMessageProps, ...validation} =\n useCheckboxGroup(\n {\n ...props,\n label,\n validationBehavior\n },\n state\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly,\n isRequired: props.isRequired || false,\n isInvalid: state.isInvalid,\n state\n },\n defaultClassName: 'react-aria-CheckboxGroup'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-required={props.isRequired || undefined}\n data-invalid={state.isInvalid || undefined}\n data-disabled={props.isDisabled || undefined}>\n <Provider\n values={[\n [CheckboxGroupStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\ninterface InternalCheckboxContextValue extends CheckboxAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isIndeterminate?: boolean;\n isRequired?: boolean;\n}\n\nconst InternalCheckboxContext = createContext<InternalCheckboxContextValue | null>(null);\n\n/**\n * A checkbox allows a user to select an item, with support for validation and help text.\n */\nexport const CheckboxField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxFieldContext);\n let groupState = useContext(CheckboxGroupStateContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-CheckboxField',\n values: {\n isSelected,\n isIndeterminate: props.isIndeterminate || false,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={props.isIndeterminate || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [\n InternalCheckboxContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-CheckboxButton',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n // In a CheckboxGroup, validation is handled at the group level instead of repeated on each checkbox.\n [FieldErrorContext, groupState ? null : {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\nfunction useCheckboxAria(\n props: CheckboxProps | CheckboxFieldProps,\n userProvidedInputRef: RefObject<HTMLInputElement | null> | null\n): [CheckboxAria, RefObject<HTMLInputElement | null>] {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let groupState = useContext(CheckboxGroupStateContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let checkboxProps = {\n ...removeDataAttributes(props),\n children: typeof props.children === 'function' ? true : props.children,\n value: props.value!,\n validationBehavior\n };\n\n let aria = groupState\n ? // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks\n useCheckboxGroupItem(checkboxProps, groupState, inputRef)\n : // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks\n useCheckbox(checkboxProps, useToggleState(props), inputRef);\n return [aria, inputRef];\n}\n\n/**\n * A checkbox allows a user to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n *\n * @deprecated Use CheckboxField + CheckboxButton instead.\n */\nexport const Checkbox = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n\n return (\n <InternalCheckboxContext.Provider\n value={{\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Checkbox',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }}>\n <CheckboxButton {...props} ref={ref} />\n </InternalCheckboxContext.Provider>\n );\n});\n\n/**\n * A checkbox button is the clickable area of a checkbox, including the indicator and label.\n */\nexport const CheckboxButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxButton(\n props: CheckboxButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isIndeterminate,\n isRequired\n } = useContext(InternalCheckboxContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isIndeterminate: isIndeterminate || false,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={isIndeterminate || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Checkbox.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AA8PM,MAAM,0DAAkB,CAAA,GAAA,oBAAY,EAAiD;AACrF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DAA4B,CAAA,GAAA,oBAAY,EAA6B;AAK3E,MAAM,4CAA8B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,cACjF,KAAyB,EACzB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,CAAA,GAAA,yCAAU,MAAM,CAAC;IACtF,IAAI,qBAAqB,MAAM,kBAAkB,IAAI,0BAA0B;IAC/E,IAAI,QAAQ,CAAA,GAAA,4BA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aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Checkbox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n AriaCheckboxGroupProps,\n useCheckboxGroup,\n useCheckboxGroupItem\n} from 'react-aria/useCheckboxGroup';\n\nimport {AriaCheckboxProps, CheckboxAria, useCheckbox} from 'react-aria/useCheckbox';\nimport {CheckboxGroupState, useCheckboxGroupState} from 'react-stately/useCheckboxGroupState';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useToggleState} from 'react-stately/useToggleState';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface CheckboxGroupProps\n extends\n Omit<\n AriaCheckboxGroupProps,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<CheckboxGroupRenderProps, 'div'>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxGroup'\n */\n className?: ClassNameOrFunction<CheckboxGroupRenderProps>;\n}\n\nexport interface CheckboxProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n HoverEvents,\n RACValidation,\n RenderProps<CheckboxRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Checkbox'\n */\n className?: ClassNameOrFunction<CheckboxRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxFieldProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<CheckboxFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxField'\n */\n className?: ClassNameOrFunction<CheckboxFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxButtonProps\n extends\n HoverEvents,\n RenderProps<CheckboxButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxButton'\n */\n className?: ClassNameOrFunction<CheckboxButtonRenderProps>;\n}\n\nexport interface CheckboxGroupRenderProps {\n /**\n * Whether the checkbox group is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox group is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox group is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the checkbox group is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * State of the checkbox group.\n */\n state: CheckboxGroupState;\n}\n\nexport interface CheckboxRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the checkbox is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the checkbox is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the checkbox is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxFieldRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxButtonRenderProps extends CheckboxRenderProps {}\n\nexport const CheckboxContext = createContext<ContextValue<CheckboxProps, HTMLLabelElement>>(null);\nexport const CheckboxFieldContext =\n createContext<ContextValue<CheckboxFieldProps, HTMLDivElement>>(null);\nexport const CheckboxGroupContext =\n createContext<ContextValue<CheckboxGroupProps, HTMLDivElement>>(null);\nexport const CheckboxGroupStateContext = createContext<CheckboxGroupState | null>(null);\n\n/**\n * A checkbox group allows a user to select multiple items from a list of options.\n */\nexport const CheckboxGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxGroup(\n props: CheckboxGroupProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, CheckboxGroupContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useCheckboxGroupState({\n ...props,\n validationBehavior\n });\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {groupProps, labelProps, descriptionProps, errorMessageProps, ...validation} =\n useCheckboxGroup(\n {\n ...props,\n label,\n validationBehavior\n },\n state\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly,\n isRequired: props.isRequired || false,\n isInvalid: state.isInvalid,\n state\n },\n defaultClassName: 'react-aria-CheckboxGroup'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-required={props.isRequired || undefined}\n data-invalid={state.isInvalid || undefined}\n data-disabled={props.isDisabled || undefined}>\n <Provider\n values={[\n [CheckboxGroupStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\ninterface InternalCheckboxContextValue extends CheckboxAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isIndeterminate?: boolean;\n isRequired?: boolean;\n}\n\nconst InternalCheckboxContext = createContext<InternalCheckboxContextValue | null>(null);\n\n/**\n * A checkbox allows a user to select an item, with support for validation and help text.\n */\nexport const CheckboxField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxFieldContext);\n let groupState = useContext(CheckboxGroupStateContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-CheckboxField',\n values: {\n isSelected,\n isIndeterminate: props.isIndeterminate || false,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={props.isIndeterminate || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [\n InternalCheckboxContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-CheckboxButton',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n // In a CheckboxGroup, validation is handled at the group level instead of repeated on each checkbox.\n [FieldErrorContext, groupState ? null : {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\nfunction useCheckboxAria(\n props: CheckboxProps | CheckboxFieldProps,\n userProvidedInputRef: RefObject<HTMLInputElement | null> | null\n): [CheckboxAria, RefObject<HTMLInputElement | null>] {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let groupState = useContext(CheckboxGroupStateContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let checkboxProps = {\n ...removeDataAttributes(props),\n children: typeof props.children === 'function' ? true : props.children,\n value: props.value!,\n validationBehavior\n };\n\n let aria = groupState\n ? // eslint-disable-next-line react-hooks/rules-of-hooks\n useCheckboxGroupItem(checkboxProps, groupState, inputRef)\n : // eslint-disable-next-line react-hooks/rules-of-hooks\n useCheckbox(checkboxProps, useToggleState(props), inputRef);\n return [aria, inputRef];\n}\n\n/**\n * A checkbox allows a user to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n *\n * @deprecated Use CheckboxField + CheckboxButton instead.\n */\nexport const Checkbox = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n\n return (\n <InternalCheckboxContext.Provider\n value={{\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Checkbox',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }}>\n <CheckboxButton {...props} ref={ref} />\n </InternalCheckboxContext.Provider>\n );\n});\n\n/**\n * A checkbox button is the clickable area of a checkbox, including the indicator and label.\n */\nexport const CheckboxButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxButton(\n props: CheckboxButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isIndeterminate,\n isRequired\n } = useContext(InternalCheckboxContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isIndeterminate: isIndeterminate || false,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={isIndeterminate || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Checkbox.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AA8PM,MAAM,0DAAkB,CAAA,GAAA,oBAAY,EAAiD;AACrF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAoD;AAC3D,MAAM,0DAA4B,CAAA,GAAA,oBAAY,EAA6B;AAK3E,MAAM,4CAA8B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,cACjF,KAAyB,EACzB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,CAAA,GAAA,yCAAU,MAAM,CAAC;IACtF,IAAI,qBAAqB,MAAM,kBAAkB,IAAI,0BAA0B;IAC/E,IAAI,QAAQ,CAAA,GAAA,4BAAoB,EAAE;QAChC,GAAG,KAAK;4BACR;IACF;IACA,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAC9E,CAAA,GAAA,uBAAe,EACb;QACE,GAAG,KAAK;eACR;4BACA;IACF,GACA;IAGJ,IAA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Checkbox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n AriaCheckboxGroupProps,\n useCheckboxGroup,\n useCheckboxGroupItem\n} from 'react-aria/useCheckboxGroup';\n\nimport {AriaCheckboxProps, CheckboxAria, useCheckbox} from 'react-aria/useCheckbox';\nimport {CheckboxGroupState, useCheckboxGroupState} from 'react-stately/useCheckboxGroupState';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useToggleState} from 'react-stately/useToggleState';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface CheckboxGroupProps\n extends\n Omit<\n AriaCheckboxGroupProps,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<CheckboxGroupRenderProps, 'div'>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxGroup'\n */\n className?: ClassNameOrFunction<CheckboxGroupRenderProps>;\n}\n\nexport interface CheckboxProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n HoverEvents,\n RACValidation,\n RenderProps<CheckboxRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Checkbox'\n */\n className?: ClassNameOrFunction<CheckboxRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxFieldProps\n extends\n Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<CheckboxFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxField'\n */\n className?: ClassNameOrFunction<CheckboxFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface CheckboxButtonProps\n extends\n HoverEvents,\n RenderProps<CheckboxButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-CheckboxButton'\n */\n className?: ClassNameOrFunction<CheckboxButtonRenderProps>;\n}\n\nexport interface CheckboxGroupRenderProps {\n /**\n * Whether the checkbox group is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox group is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox group is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the checkbox group is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * State of the checkbox group.\n */\n state: CheckboxGroupState;\n}\n\nexport interface CheckboxRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the checkbox is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the checkbox is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the checkbox is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxFieldRenderProps {\n /**\n * Whether the checkbox is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the checkbox is indeterminate.\n *\n * @selector [data-indeterminate]\n */\n isIndeterminate: boolean;\n /**\n * Whether the checkbox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the checkbox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the checkbox invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface CheckboxButtonRenderProps extends CheckboxRenderProps {}\n\nexport const CheckboxContext = createContext<ContextValue<CheckboxProps, HTMLLabelElement>>(null);\nexport const CheckboxFieldContext =\n createContext<ContextValue<CheckboxFieldProps, HTMLDivElement>>(null);\nexport const CheckboxGroupContext =\n createContext<ContextValue<CheckboxGroupProps, HTMLDivElement>>(null);\nexport const CheckboxGroupStateContext = createContext<CheckboxGroupState | null>(null);\n\n/**\n * A checkbox group allows a user to select multiple items from a list of options.\n */\nexport const CheckboxGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxGroup(\n props: CheckboxGroupProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, CheckboxGroupContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useCheckboxGroupState({\n ...props,\n validationBehavior\n });\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {groupProps, labelProps, descriptionProps, errorMessageProps, ...validation} =\n useCheckboxGroup(\n {\n ...props,\n label,\n validationBehavior\n },\n state\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly,\n isRequired: props.isRequired || false,\n isInvalid: state.isInvalid,\n state\n },\n defaultClassName: 'react-aria-CheckboxGroup'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-required={props.isRequired || undefined}\n data-invalid={state.isInvalid || undefined}\n data-disabled={props.isDisabled || undefined}>\n <Provider\n values={[\n [CheckboxGroupStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\ninterface InternalCheckboxContextValue extends CheckboxAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isIndeterminate?: boolean;\n isRequired?: boolean;\n}\n\nconst InternalCheckboxContext = createContext<InternalCheckboxContextValue | null>(null);\n\n/**\n * A checkbox allows a user to select an item, with support for validation and help text.\n */\nexport const CheckboxField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxFieldContext);\n let groupState = useContext(CheckboxGroupStateContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-CheckboxField',\n values: {\n isSelected,\n isIndeterminate: props.isIndeterminate || false,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={props.isIndeterminate || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [\n InternalCheckboxContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-CheckboxButton',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n // In a CheckboxGroup, validation is handled at the group level instead of repeated on each checkbox.\n [FieldErrorContext, groupState ? null : {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\nfunction useCheckboxAria(\n props: CheckboxProps | CheckboxFieldProps,\n userProvidedInputRef: RefObject<HTMLInputElement | null> | null\n): [CheckboxAria, RefObject<HTMLInputElement | null>] {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let groupState = useContext(CheckboxGroupStateContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let checkboxProps = {\n ...removeDataAttributes(props),\n children: typeof props.children === 'function' ? true : props.children,\n value: props.value!,\n validationBehavior\n };\n\n let aria = groupState\n ? // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks\n useCheckboxGroupItem(checkboxProps, groupState, inputRef)\n : // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks\n useCheckbox(checkboxProps, useToggleState(props), inputRef);\n return [aria, inputRef];\n}\n\n/**\n * A checkbox allows a user to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n *\n * @deprecated Use CheckboxField + CheckboxButton instead.\n */\nexport const Checkbox = /*#__PURE__*/ (forwardRef as forwardRefType)(function Checkbox(\n props: CheckboxProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, CheckboxContext);\n let [aria, inputRef] = useCheckboxAria(props, userProvidedInputRef);\n\n return (\n <InternalCheckboxContext.Provider\n value={{\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Checkbox',\n isIndeterminate: props.isIndeterminate,\n isRequired: props.isRequired\n }}>\n <CheckboxButton {...props} ref={ref} />\n </InternalCheckboxContext.Provider>\n );\n});\n\n/**\n * A checkbox button is the clickable area of a checkbox, including the indicator and label.\n */\nexport const CheckboxButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function CheckboxButton(\n props: CheckboxButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isIndeterminate,\n isRequired\n } = useContext(InternalCheckboxContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isIndeterminate: isIndeterminate || false,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-indeterminate={isIndeterminate || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Checkbox.mjs.map"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var $16c7f9b22cce3838$exports = require("./Button.cjs");
|
|
2
2
|
var $048d76b84370f141$exports = require("./utils.cjs");
|
|
3
3
|
var $862aa7df04d8fa76$exports = require("./FieldError.cjs");
|
|
4
|
+
var $433949643203e332$exports = require("./Autocomplete.cjs");
|
|
4
5
|
var $5adc12e2ce73be8f$exports = require("./Form.cjs");
|
|
5
6
|
var $f3068c15cd7dcac2$exports = require("./Group.cjs");
|
|
6
7
|
var $81dc1c05bf045ce0$exports = require("./Input.cjs");
|
|
@@ -63,6 +64,7 @@ $parcel$export(module.exports, "ComboBoxValue", function () { return $251f6141ad
|
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
|
|
67
|
+
|
|
66
68
|
const $251f6141ad6e692a$export$d414ccceff7063c3 = /*#__PURE__*/ (0, $3UK7x$react.createContext)(null);
|
|
67
69
|
const $251f6141ad6e692a$export$c02625b26074192c = /*#__PURE__*/ (0, $3UK7x$react.createContext)(null);
|
|
68
70
|
const $251f6141ad6e692a$export$72b9695b8216309a = /*#__PURE__*/ (0, $3UK7x$reactariaprivatecollectionsHidden.createHideableComponent)(function ComboBox(props, ref) {
|
|
@@ -101,6 +103,7 @@ const $251f6141ad6e692a$var$CLEAR_CONTEXTS = [
|
|
|
101
103
|
(0, $d5d46822336ca1e1$exports.LabelContext),
|
|
102
104
|
(0, $16c7f9b22cce3838$exports.ButtonContext),
|
|
103
105
|
(0, $81dc1c05bf045ce0$exports.InputContext),
|
|
106
|
+
(0, $433949643203e332$exports.FieldInputContext),
|
|
104
107
|
(0, $f3068c15cd7dcac2$exports.GroupContext),
|
|
105
108
|
(0, $cab7d9a238d19c33$exports.TextContext)
|
|
106
109
|
];
|
|
@@ -127,6 +130,7 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
|
|
|
127
130
|
let listBoxRef = (0, $3UK7x$react.useRef)(null);
|
|
128
131
|
let popoverRef = (0, $3UK7x$react.useRef)(null);
|
|
129
132
|
let [labelRef, label] = (0, $048d76b84370f141$exports.useSlot)(!props['aria-label'] && !props['aria-labelledby']);
|
|
133
|
+
let [labelElementType, setLabelElementType] = (0, $3UK7x$react.useState)('label');
|
|
130
134
|
let { buttonProps: buttonProps, inputProps: inputProps, listBoxProps: listBoxProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, valueProps: valueProps, ...validation } = (0, $3UK7x$reactariauseComboBox.useComboBox)({
|
|
131
135
|
...(0, $048d76b84370f141$exports.removeDataAttributes)(props),
|
|
132
136
|
label: label,
|
|
@@ -135,7 +139,8 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
|
|
|
135
139
|
listBoxRef: listBoxRef,
|
|
136
140
|
popoverRef: popoverRef,
|
|
137
141
|
name: formValue === 'text' ? name : undefined,
|
|
138
|
-
validationBehavior: validationBehavior
|
|
142
|
+
validationBehavior: validationBehavior,
|
|
143
|
+
labelElementType: labelElementType
|
|
139
144
|
}, state);
|
|
140
145
|
// Make menu width match input + button
|
|
141
146
|
// Left for backward compatibility in case a <Group> is not rendered.
|
|
@@ -162,7 +167,8 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
|
|
|
162
167
|
get current () {
|
|
163
168
|
return groupRef.current || inputRef.current;
|
|
164
169
|
}
|
|
165
|
-
}),
|
|
170
|
+
}), // oxlint-disable-next-line react/react-compiler
|
|
171
|
+
[
|
|
166
172
|
groupRef,
|
|
167
173
|
inputRef
|
|
168
174
|
]);
|
|
@@ -215,6 +221,7 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
|
|
|
215
221
|
(0, $d5d46822336ca1e1$exports.LabelContext),
|
|
216
222
|
{
|
|
217
223
|
...labelProps,
|
|
224
|
+
elementType: labelElementType,
|
|
218
225
|
ref: labelRef
|
|
219
226
|
}
|
|
220
227
|
],
|
|
@@ -233,6 +240,18 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
|
|
|
233
240
|
ref: inputRef
|
|
234
241
|
}
|
|
235
242
|
],
|
|
243
|
+
[
|
|
244
|
+
(0, $433949643203e332$exports.FieldInputContext),
|
|
245
|
+
{
|
|
246
|
+
...inputProps,
|
|
247
|
+
ref: (0, $3UK7x$react.useCallback)((el)=>{
|
|
248
|
+
inputRef.current = el; // TODO: figure out how to fix non-input element types in useComboBox/useTextField
|
|
249
|
+
if (el) setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');
|
|
250
|
+
}, []),
|
|
251
|
+
value: state.inputValue,
|
|
252
|
+
onChange: (v)=>state.setInputValue(v)
|
|
253
|
+
}
|
|
254
|
+
],
|
|
236
255
|
[
|
|
237
256
|
(0, $88595bf043e542ec$exports.OverlayTriggerStateContext),
|
|
238
257
|
state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAwHM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,0BAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,oBAAM,EAClB,kBACE,0DAAC,CAAA,GAAA,wCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,MAAM,KAAK,IAAI,MAAM,YAAY;YAAA;WACtE,OAAO,aAAa,aACjB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,iBAAiB;wBACjB;QACF,KACA,WAGR;QAAC;QAAU;QAAY;QAAW;QAAY;QAAY,MAAM,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AAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,eAAe,CAAA,GAAA,oBAAM,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,AAAC,KAAK,KAAK,IAAU,OAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, InputContext, GroupContext, TextContext];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n [groupRef, inputRef]\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AA4HM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,0BAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,oBAAM,EAClB,kBACE,0DAAC,CAAA,GAAA,wCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,MAAM,KAAK,IAAI,MAAM,YAAY;YAAA;WACtE,OAAO,aAAa,aACjB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,iBAAiB;wBACjB;QACF,KACA,WAGR;QAAC;QAAU;QAAY;QAAW;QAAY;QAAY,MAAM,KAAK;QAAE,MAAM,YAAY;KAAC;IAG5F,qBACE,0DAAC,CAAA,GAAA,mDAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,0DAAC;YAAc,OAAO;YAAO,YAAY;YAAY,aAAa;;AAGvF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IACrB,CAAA,GAAA,sCAAW;IACX,CAAA,GAAA,uCAAY;IACZ,CAAA,GAAA,sCAAW;IACX,CAAA,GAAA,2CAAgB;IAChB,CAAA,GAAA,sCAAW;IAC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CACd,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,MAAM,aAAa,IAAI,MAAM,CAAC,CAAA,IAAK,MAAM,MAE7E;QAAC;QAAW,MAAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,eAAe,CAAA,GAAA,oBAAM,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,AAAC,KAAK,KAAK,IAAU,OAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, FocusableElement, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /**\n * The filter function used to determine if an option should be included in the combo box list.\n * By default, a language-sensitive \"contains\" filter from `useFilter` is used.\n */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [\n LabelContext,\n ButtonContext,\n InputContext,\n FieldInputContext,\n GroupContext,\n TextContext\n];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let [labelElementType, setLabelElementType] = useState<'span' | 'label'>('label');\n\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior,\n labelElementType\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n // oxlint-disable-next-line react/react-compiler\n [groupRef, inputRef]\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, elementType: labelElementType, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [\n FieldInputContext,\n {\n ...inputProps,\n ref: useCallback((el: FocusableElement) => {\n inputRef.current = el as HTMLInputElement; // TODO: figure out how to fix non-input element types in useComboBox/useTextField\n if (el) {\n setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');\n }\n }, []),\n value: state.inputValue,\n onChange: v => state.setInputValue(v as string)\n } as any\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.cjs.map"}
|
package/dist/private/ComboBox.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {ButtonContext as $fc203795b9b363cd$export$24d547caef80ccd1} from "./Button.js";
|
|
2
2
|
import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, Provider as $b7b7a92703138c9b$export$2881499e37b75b9a, removeDataAttributes as $b7b7a92703138c9b$export$ef03459518577ad4, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3, useSlot as $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8, useSlottedContext as $b7b7a92703138c9b$export$fabf2dc03a41866e} from "./utils.js";
|
|
3
3
|
import {FieldErrorContext as $6567560e1d9cc847$export$ff05c3ac10437e03} from "./FieldError.js";
|
|
4
|
+
import {FieldInputContext as $8f09b710ef85b337$export$698f465ec27e93df} from "./Autocomplete.js";
|
|
4
5
|
import {FormContext as $c7332d4a2d191cd2$export$c24727297075ec6a} from "./Form.js";
|
|
5
6
|
import {GroupContext as $2e357e4f16c05be6$export$f9c6924e160136d1} from "./Group.js";
|
|
6
7
|
import {InputContext as $d8e7992b5f7739ce$export$37fb8590cf2c088c} from "./Input.js";
|
|
@@ -49,6 +50,7 @@ import {useResizeObserver as $feVgu$useResizeObserver} from "react-aria/private/
|
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
|
|
52
54
|
const $ddc2347ad81bd857$export$d414ccceff7063c3 = /*#__PURE__*/ (0, $feVgu$createContext)(null);
|
|
53
55
|
const $ddc2347ad81bd857$export$c02625b26074192c = /*#__PURE__*/ (0, $feVgu$createContext)(null);
|
|
54
56
|
const $ddc2347ad81bd857$export$72b9695b8216309a = /*#__PURE__*/ (0, $feVgu$createHideableComponent)(function ComboBox(props, ref) {
|
|
@@ -90,6 +92,7 @@ const $ddc2347ad81bd857$var$CLEAR_CONTEXTS = [
|
|
|
90
92
|
(0, $3e4839e5b30e7b17$export$75b6ee27786ba447),
|
|
91
93
|
(0, $fc203795b9b363cd$export$24d547caef80ccd1),
|
|
92
94
|
(0, $d8e7992b5f7739ce$export$37fb8590cf2c088c),
|
|
95
|
+
(0, $8f09b710ef85b337$export$698f465ec27e93df),
|
|
93
96
|
(0, $2e357e4f16c05be6$export$f9c6924e160136d1),
|
|
94
97
|
(0, $20d769b1e2b13352$export$9afb8bc826b033ea)
|
|
95
98
|
];
|
|
@@ -117,6 +120,7 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
|
|
|
117
120
|
let listBoxRef = (0, $feVgu$useRef)(null);
|
|
118
121
|
let popoverRef = (0, $feVgu$useRef)(null);
|
|
119
122
|
let [labelRef, label] = (0, $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
|
|
123
|
+
let [labelElementType, setLabelElementType] = (0, $feVgu$useState)('label');
|
|
120
124
|
let { buttonProps: buttonProps, inputProps: inputProps, listBoxProps: listBoxProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, valueProps: valueProps, ...validation } = (0, $feVgu$useComboBox)({
|
|
121
125
|
...(0, $b7b7a92703138c9b$export$ef03459518577ad4)(props),
|
|
122
126
|
label: label,
|
|
@@ -125,7 +129,8 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
|
|
|
125
129
|
listBoxRef: listBoxRef,
|
|
126
130
|
popoverRef: popoverRef,
|
|
127
131
|
name: formValue === 'text' ? name : undefined,
|
|
128
|
-
validationBehavior: validationBehavior
|
|
132
|
+
validationBehavior: validationBehavior,
|
|
133
|
+
labelElementType: labelElementType
|
|
129
134
|
}, state);
|
|
130
135
|
// Make menu width match input + button
|
|
131
136
|
// Left for backward compatibility in case a <Group> is not rendered.
|
|
@@ -153,7 +158,8 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
|
|
|
153
158
|
get current () {
|
|
154
159
|
return groupRef.current || inputRef.current;
|
|
155
160
|
}
|
|
156
|
-
}),
|
|
161
|
+
}), // oxlint-disable-next-line react/react-compiler
|
|
162
|
+
[
|
|
157
163
|
groupRef,
|
|
158
164
|
inputRef
|
|
159
165
|
]);
|
|
@@ -206,6 +212,7 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
|
|
|
206
212
|
(0, $3e4839e5b30e7b17$export$75b6ee27786ba447),
|
|
207
213
|
{
|
|
208
214
|
...labelProps,
|
|
215
|
+
elementType: labelElementType,
|
|
209
216
|
ref: labelRef
|
|
210
217
|
}
|
|
211
218
|
],
|
|
@@ -224,6 +231,18 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
|
|
|
224
231
|
ref: inputRef
|
|
225
232
|
}
|
|
226
233
|
],
|
|
234
|
+
[
|
|
235
|
+
(0, $8f09b710ef85b337$export$698f465ec27e93df),
|
|
236
|
+
{
|
|
237
|
+
...inputProps,
|
|
238
|
+
ref: (0, $feVgu$useCallback)((el)=>{
|
|
239
|
+
inputRef.current = el; // TODO: figure out how to fix non-input element types in useComboBox/useTextField
|
|
240
|
+
if (el) setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');
|
|
241
|
+
}, []),
|
|
242
|
+
value: state.inputValue,
|
|
243
|
+
onChange: (v)=>state.setInputValue(v)
|
|
244
|
+
}
|
|
245
|
+
],
|
|
227
246
|
[
|
|
228
247
|
(0, $acf8e70c2f419f18$export$d2f961adcb0afbe),
|
|
229
248
|
state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAwHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB;YAC0C;6BAAxC,gCAAC,CAAA,GAAA,yCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,CAAA,eAAA,MAAM,KAAK,cAAX,0BAAA,eAAe,MAAM,YAAY;YAAA;WACtE,OAAO,aAAa,aACjB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,iBAAiB;wBACjB;QACF,KACA;OAGR;QAAC;QAAU;QAAY;QAAW;QAAY;QAAY,MAAM,KAAK;QAAE,MAAM,YAAY;KAAC;IAG5F,qBACE,gCAAC,CAAA,GAAA,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BAAA,KAAM,SAAS,KAAI,IAAI,MAAM,CAAC,CAAA,IAAK,MAAM,MAE7E;QAAC;QAAW,MAAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,eAAe,CAAA,GAAA,cAAM,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;wBAAS;2BAAD,CAAC,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAoB;oBAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, InputContext, GroupContext, TextContext];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n [groupRef, inputRef]\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AA4HM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB;YAC0C;6BAAxC,gCAAC,CAAA,GAAA,yCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,CAAA,eAAA,MAAM,KAAK,cAAX,0BAAA,eAAe,MAAM,YAAY;YAAA;WACtE,OAAO,aAAa,aACjB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,iBAAiB;wBACjB;QACF,KACA;OAGR;QAAC;QAAU;QAAY;QAAW;QAAY;QAAY,MAAM,KAAK;QAAE,MAAM,YAAY;KAAC;IAG5F,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAc,OAAO;YAAO,YAAY;YAAY,aAAa;;AAGvF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IACrB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C1E,KAA4B,EAC5B,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,uBAAe;IAC/B,IAAI,eAAe,CAAA,GAAA,cAAM,EACvB,IACE,UAAU,MAAM,CACd,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,CAAA,iBAAA,2BAAA,KAAM,SAAS,KAAI,IAAI,MAAM,CAAC,CAAA,IAAK,MAAM,MAE7E;QAAC;QAAW,MAAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,eAAe,CAAA,GAAA,cAAM,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;wBAAS;2BAAD,CAAC,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAoB;oBAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, FocusableElement, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /**\n * The filter function used to determine if an option should be included in the combo box list.\n * By default, a language-sensitive \"contains\" filter from `useFilter` is used.\n */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [\n LabelContext,\n ButtonContext,\n InputContext,\n FieldInputContext,\n GroupContext,\n TextContext\n];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let [labelElementType, setLabelElementType] = useState<'span' | 'label'>('label');\n\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior,\n labelElementType\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n // oxlint-disable-next-line react/react-compiler\n [groupRef, inputRef]\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, elementType: labelElementType, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [\n FieldInputContext,\n {\n ...inputProps,\n ref: useCallback((el: FocusableElement) => {\n inputRef.current = el as HTMLInputElement; // TODO: figure out how to fix non-input element types in useComboBox/useTextField\n if (el) {\n setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');\n }\n }, []),\n value: state.inputValue,\n onChange: v => state.setInputValue(v as string)\n } as any\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.js.map"}
|