react-aria-components 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/private/ColorSwatchPicker.cjs.map +1 -1
- package/dist/private/ColorSwatchPicker.js.map +1 -1
- package/dist/private/ColorSwatchPicker.mjs.map +1 -1
- package/dist/private/DropZone.cjs.map +1 -1
- package/dist/private/DropZone.js.map +1 -1
- package/dist/private/DropZone.mjs.map +1 -1
- package/dist/private/GridList.cjs +4 -3
- package/dist/private/GridList.cjs.map +1 -1
- package/dist/private/GridList.js +4 -3
- package/dist/private/GridList.js.map +1 -1
- package/dist/private/GridList.mjs +4 -3
- package/dist/private/GridList.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.map +1 -1
- package/dist/private/Table.js.map +1 -1
- package/dist/private/Table.mjs.map +1 -1
- package/dist/types/src/GridList.d.ts +7 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AA0HM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAA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AAA;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,IAAI;QACP,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.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 */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\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-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\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 isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\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 select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\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-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\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.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CA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AAA,sBAAwB,KAAK,cAA7B,yCAAA,8BAAuC;YACtD,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,IAAI;QACP,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.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 */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\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-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\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 isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\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 select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\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-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\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.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AA0HM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA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AC3D;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,IAAI;QACP,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.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 */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\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-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\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 isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\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 select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\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-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\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.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;w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AA,GAAA,yCAAE,EAAE,IAAI;QACP,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.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 */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\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-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\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 isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\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 select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\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-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\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.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.mjs.map"}
|