react-aria-components 1.12.2 → 1.13.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/Autocomplete.main.js +3 -3
- package/dist/Autocomplete.main.js.map +1 -1
- package/dist/Autocomplete.mjs +3 -3
- package/dist/Autocomplete.module.js +3 -3
- package/dist/Autocomplete.module.js.map +1 -1
- package/dist/Button.main.js +5 -11
- package/dist/Button.main.js.map +1 -1
- package/dist/Button.mjs +5 -11
- package/dist/Button.module.js +5 -11
- package/dist/Button.module.js.map +1 -1
- package/dist/DateField.main.js +12 -8
- package/dist/DateField.main.js.map +1 -1
- package/dist/DateField.mjs +12 -8
- package/dist/DateField.module.js +12 -8
- package/dist/DateField.module.js.map +1 -1
- package/dist/DatePicker.main.js +6 -2
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +6 -2
- package/dist/DatePicker.module.js +6 -2
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/GridList.main.js +24 -21
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +25 -23
- package/dist/GridList.module.js +25 -23
- package/dist/GridList.module.js.map +1 -1
- package/dist/Group.main.js +3 -2
- package/dist/Group.main.js.map +1 -1
- package/dist/Group.mjs +3 -2
- package/dist/Group.module.js +3 -2
- package/dist/Group.module.js.map +1 -1
- package/dist/Input.main.js.map +1 -1
- package/dist/Input.module.js.map +1 -1
- package/dist/ListBox.main.js +14 -4
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +14 -4
- package/dist/ListBox.module.js +14 -4
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Menu.main.js +16 -6
- package/dist/Menu.main.js.map +1 -1
- package/dist/Menu.mjs +16 -6
- package/dist/Menu.module.js +16 -6
- package/dist/Menu.module.js.map +1 -1
- package/dist/Modal.main.js +9 -1
- package/dist/Modal.main.js.map +1 -1
- package/dist/Modal.mjs +10 -2
- package/dist/Modal.module.js +10 -2
- package/dist/Modal.module.js.map +1 -1
- package/dist/NumberField.main.js +2 -1
- package/dist/NumberField.main.js.map +1 -1
- package/dist/NumberField.mjs +2 -1
- package/dist/NumberField.module.js +2 -1
- package/dist/NumberField.module.js.map +1 -1
- package/dist/ProgressBar.main.js.map +1 -1
- package/dist/ProgressBar.module.js.map +1 -1
- package/dist/RSPContexts.main.js +4 -0
- package/dist/RSPContexts.main.js.map +1 -1
- package/dist/RSPContexts.mjs +3 -1
- package/dist/RSPContexts.module.js +3 -1
- package/dist/RSPContexts.module.js.map +1 -1
- package/dist/RadioGroup.main.js +10 -2
- package/dist/RadioGroup.main.js.map +1 -1
- package/dist/RadioGroup.mjs +10 -2
- package/dist/RadioGroup.module.js +10 -2
- package/dist/RadioGroup.module.js.map +1 -1
- package/dist/SearchField.main.js +2 -2
- package/dist/SearchField.main.js.map +1 -1
- package/dist/SearchField.mjs +2 -2
- package/dist/SearchField.module.js +2 -2
- package/dist/SearchField.module.js.map +1 -1
- package/dist/Select.main.js +62 -22
- package/dist/Select.main.js.map +1 -1
- package/dist/Select.mjs +65 -25
- package/dist/Select.module.js +65 -25
- package/dist/Select.module.js.map +1 -1
- package/dist/SelectionIndicator.main.js +45 -0
- package/dist/SelectionIndicator.main.js.map +1 -0
- package/dist/SelectionIndicator.mjs +35 -0
- package/dist/SelectionIndicator.module.js +35 -0
- package/dist/SelectionIndicator.module.js.map +1 -0
- package/dist/SharedElementTransition.main.js +139 -0
- package/dist/SharedElementTransition.main.js.map +1 -0
- package/dist/SharedElementTransition.mjs +129 -0
- package/dist/SharedElementTransition.module.js +129 -0
- package/dist/SharedElementTransition.module.js.map +1 -0
- package/dist/Table.main.js +16 -11
- package/dist/Table.main.js.map +1 -1
- package/dist/Table.mjs +17 -12
- package/dist/Table.module.js +17 -12
- package/dist/Table.module.js.map +1 -1
- package/dist/Tabs.main.js +11 -3
- package/dist/Tabs.main.js.map +1 -1
- package/dist/Tabs.mjs +11 -3
- package/dist/Tabs.module.js +11 -3
- package/dist/Tabs.module.js.map +1 -1
- package/dist/TagGroup.main.js +28 -16
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +28 -16
- package/dist/TagGroup.module.js +28 -16
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/TextField.main.js +2 -2
- package/dist/TextField.main.js.map +1 -1
- package/dist/TextField.mjs +2 -2
- package/dist/TextField.module.js +2 -2
- package/dist/TextField.module.js.map +1 -1
- package/dist/ToggleButton.main.js +7 -1
- package/dist/ToggleButton.main.js.map +1 -1
- package/dist/ToggleButton.mjs +7 -1
- package/dist/ToggleButton.module.js +7 -1
- package/dist/ToggleButton.module.js.map +1 -1
- package/dist/ToggleButtonGroup.main.js +3 -1
- package/dist/ToggleButtonGroup.main.js.map +1 -1
- package/dist/ToggleButtonGroup.mjs +3 -1
- package/dist/ToggleButtonGroup.module.js +3 -1
- package/dist/ToggleButtonGroup.module.js.map +1 -1
- package/dist/Tree.main.js +16 -4
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +16 -4
- package/dist/Tree.module.js +16 -4
- package/dist/Tree.module.js.map +1 -1
- package/dist/import.mjs +10 -4
- package/dist/main.js +18 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +10 -4
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +99 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +23 -23
- package/src/Autocomplete.tsx +1 -1
- package/src/Button.tsx +9 -11
- package/src/DateField.tsx +21 -12
- package/src/DatePicker.tsx +11 -2
- package/src/GridList.tsx +32 -33
- package/src/Group.tsx +5 -2
- package/src/Input.tsx +7 -1
- package/src/ListBox.tsx +12 -7
- package/src/Menu.tsx +11 -6
- package/src/Modal.tsx +11 -2
- package/src/NumberField.tsx +1 -1
- package/src/ProgressBar.tsx +1 -1
- package/src/RSPContexts.ts +19 -0
- package/src/RadioGroup.tsx +8 -2
- package/src/SearchField.tsx +1 -1
- package/src/Select.tsx +75 -34
- package/src/SelectionIndicator.tsx +40 -0
- package/src/SharedElementTransition.tsx +185 -0
- package/src/Table.tsx +17 -16
- package/src/Tabs.tsx +8 -2
- package/src/TagGroup.tsx +31 -24
- package/src/TextField.tsx +1 -1
- package/src/ToggleButton.tsx +6 -1
- package/src/ToggleButtonGroup.tsx +4 -1
- package/src/Tree.tsx +16 -9
- package/src/index.ts +10 -3
- package/src/utils.tsx +1 -1
- package/dist/context.main.js +0 -25
- package/dist/context.main.js.map +0 -1
- package/dist/context.mjs +0 -19
- package/dist/context.module.js +0 -19
- package/dist/context.module.js.map +0 -1
- package/src/context.tsx +0 -34
package/dist/Select.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA8DM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAkD;AACpF,MAAM,0DAAqB,CAAA,GAAA,0BAAY,EAA+B;AAKtE,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,OAA8B,KAAqB,EAAE,GAAiC;IAChK,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,oBAAM,EAAE,IACpB,OAAO,aAAa,aAChB,SAAS;YACT,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACE,UACH;QAAC;QAAU;QAAY;QAAW;KAAW;IAEhD,qBACE,0DAAC,CAAA,GAAA,6CAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,0DAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAi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Y;YACZ,WAAW;YACX,gBAAgB;YAChB,YAAY;YACZ,eAAe;YACf,mBAAmB;QACrB;IACF;IAEA,IAAI,kBAAkB,CAAA,GAAA,4CAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;QAI7C,MAGD,2BACA;IANlB,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,CAAA,OAAA,qBAAA,sBAAA,WAAY,yBAAZ,kBAAA,OAA2B,gBAAgB,MAAM,CAAC;QACnE,kBAAkB;QAClB,QAAQ;YACN,cAAc,CAAA,6BAAA,sBAAA,MAAM,YAAY,cAAlB,0CAAA,oBAAoB,KAAK,cAAzB,uCAAA,4BAAkC;YAChD,cAAc,CAAA,iCAAA,uBAAA,MAAM,YAAY,cAAlB,2CAAA,qBAAoB,SAAS,cAA7B,2CAAA,gCAAiC;YAC/C,eAAe,CAAC;QAClB;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC;QAAK,KAAK;QAAM,GAAG,QAAQ;QAAG,GAAG,WAAW;QAAE,oBAAkB,CAAC,gBAAgB;qBAEhF,0DAAC,CAAA,GAAA,qCAAU,EAAE,QAAQ;QAAC,OAAO;OAC1B,YAAY,QAAQ;AAI7B","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, useFocusRing, useLocalizedStringFormatter, useSelect} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, Node, SelectState, useSelectState} from 'react-stately';\nimport {CollectionBuilder} from '@react-aria/collections';\nimport {ContextValue, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps, mergeProps, useResizeObserver} from '@react-aria/utils';\nimport {FormContext} from './Form';\nimport {forwardRefType, 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 {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {TextContext} from './Text';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the select is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the select is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the select is currently open.\n * @selector [data-open]\n */\n isOpen: boolean,\n /**\n * Whether the select is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the select is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport interface SelectProps<T extends object = {}> extends Omit<AriaSelectProps<T>, 'children' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior' | 'items'>, RACValidation, RenderProps<SelectRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * Temporary text that occupies the select when it is empty.\n * @default 'Select an item' (localized)\n */\n placeholder?: string\n}\n\nexport const SelectContext = createContext<ContextValue<SelectProps<any>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown> | 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__*/ (forwardRef as forwardRefType)(function Select<T extends object = {}>(props: SelectProps<T>, 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 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 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 extends object> {\n props: SelectProps<T>,\n selectRef: ForwardedRef<HTMLDivElement>,\n collection: Collection<Node<T>>\n}\n\nfunction SelectInner<T extends object>({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(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect({\n ...removeDataAttributes(props),\n label,\n validationBehavior\n }, state, buttonRef);\n\n // Make menu width match input + button\n let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (buttonRef.current) {\n setButtonWidth(buttonRef.current.offsetWidth + 'px');\n }\n }, [buttonRef]);\n\n useResizeObserver({\n ref: buttonRef,\n onResize: onResize\n });\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(() => ({\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 }), [state.isOpen, state.isFocused, isFocusVisible, props.isDisabled, validation.isInvalid, props.isRequired]);\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 [ButtonContext, {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}],\n [OverlayTriggerStateContext, state],\n [PopoverContext, {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n style: {'--trigger-width': buttonWidth} as React.CSSProperties,\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n <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\n {...hiddenSelectProps}\n autoComplete={props.autoComplete} />\n </div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean,\n /** The object value of the currently selected item. */\n selectedItem: T | null,\n /** The textValue of the currently selected item. */\n selectedText: string | null\n}\n\nexport interface SelectValueProps<T extends object> extends Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>, RenderProps<SelectValueRenderProps<T>> {}\n\nexport const SelectValueContext = 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__*/ (forwardRef as forwardRefType)(function SelectValue<T extends object>(props: SelectValueProps<T>, ref: ForwardedRef<HTMLSpanElement>) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)!;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let selectedItem = state.selectedKey != null\n ? state.collection.getItem(state.selectedKey)\n : null;\n let rendered = selectedItem?.props.children;\n if (typeof rendered === 'function') {\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\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 let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: rendered ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: state.selectedItem?.value as T ?? null,\n selectedText: state.selectedItem?.textValue ?? null,\n isPlaceholder: !selectedItem\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <span ref={ref} {...DOMProps} {...renderProps} data-placeholder={!selectedItem || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>\n {renderProps.children}\n </TextContext.Provider>\n </span>\n );\n});\n"],"names":[],"version":3,"file":"Select.main.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,KAAK,KAAK;qBAEnG,0DAAC,CAAA,GAAA,qCAAU,EAAE,QAAQ;QAAC,OAAO;OAC1B,YAAY,QAAQ;AAI7B","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, useFocusRing, useListFormatter, useLocalizedStringFormatter, useSelect} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, Node, SelectState, useSelectState} from 'react-stately';\nimport {CollectionBuilder, createHideableComponent} from '@react-aria/collections';\nimport {ContextValue, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps, mergeProps, useResizeObserver} from '@react-aria/utils';\nimport {FormContext} from './Form';\nimport {forwardRefType, 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 {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {createContext, ForwardedRef, forwardRef, Fragment, HTMLAttributes, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {TextContext} from './Text';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the select is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the select is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the select is currently open.\n * @selector [data-open]\n */\n isOpen: boolean,\n /**\n * Whether the select is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the select is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport interface SelectProps<T extends object = {}, M extends SelectionMode = 'single'> extends Omit<AriaSelectProps<T, M>, 'children' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior' | 'items'>, RACValidation, RenderProps<SelectRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * Temporary text that occupies the select when it is empty.\n * @default 'Select an item' (localized)\n */\n placeholder?: string\n}\n\nexport const SelectContext = 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__*/ (forwardRef as forwardRefType)(function Select<T extends object = {}, M extends SelectionMode = 'single'>(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 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 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 extends object> {\n props: SelectProps<T, SelectionMode>,\n selectRef: ForwardedRef<HTMLDivElement>,\n collection: Collection<Node<T>>\n}\n\nfunction SelectInner<T extends object>({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(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect({\n ...removeDataAttributes(props),\n label,\n validationBehavior\n }, state, buttonRef);\n\n // Make menu width match input + button\n let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (buttonRef.current) {\n setButtonWidth(buttonRef.current.offsetWidth + 'px');\n }\n }, [buttonRef]);\n\n useResizeObserver({\n ref: buttonRef,\n onResize: onResize\n });\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(() => ({\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 }), [state.isOpen, state.isFocused, isFocusVisible, props.isDisabled, validation.isInvalid, props.isRequired]);\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 [ButtonContext, {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}],\n [OverlayTriggerStateContext, state],\n [PopoverContext, {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n style: {'--trigger-width': buttonWidth} as React.CSSProperties,\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n <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\n {...hiddenSelectProps}\n autoComplete={props.autoComplete} />\n </div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean,\n /**\n * The object value of the first selected item.\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 extends object> extends Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>, RenderProps<SelectValueRenderProps<T>> {}\n\nexport const SelectValueContext = 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 extends object>(props: SelectValueProps<T>, ref: ForwardedRef<HTMLSpanElement>) {\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(() => state.selectedItems.map(item => item?.textValue), [state.selectedItems]);\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(() => (\n selectionMode === 'single' \n ? textValue[0] ?? '' \n : formatter.format(textValue)\n ), [selectionMode, formatter, textValue]);\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(() => state.selectedItems.map(item => item.value as T ?? null), [state.selectedItems]),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <span ref={ref} {...DOMProps} {...renderProps} data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>\n {renderProps.children}\n </TextContext.Provider>\n </span>\n );\n});\n"],"names":[],"version":3,"file":"Select.main.js.map"}
|
package/dist/Select.mjs
CHANGED
|
@@ -8,11 +8,11 @@ import {ListBoxContext as $eed445e0843c11d0$export$7ff8f37d2d81a48d, ListStateCo
|
|
|
8
8
|
import {OverlayTriggerStateContext as $de32f1b87079253c$export$d2f961adcb0afbe} from "./Dialog.mjs";
|
|
9
9
|
import {PopoverContext as $07b14b47974efb58$export$9b9a0cd73afb7ca4} from "./Popover.mjs";
|
|
10
10
|
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.mjs";
|
|
11
|
-
import {useFocusRing as $akiWb$useFocusRing, useSelect as $akiWb$useSelect, HiddenSelect as $akiWb$HiddenSelect, useLocalizedStringFormatter as $akiWb$useLocalizedStringFormatter} from "react-aria";
|
|
11
|
+
import {useFocusRing as $akiWb$useFocusRing, useSelect as $akiWb$useSelect, HiddenSelect as $akiWb$HiddenSelect, useListFormatter as $akiWb$useListFormatter, useLocalizedStringFormatter as $akiWb$useLocalizedStringFormatter} from "react-aria";
|
|
12
12
|
import {useSelectState as $akiWb$useSelectState} from "react-stately";
|
|
13
|
-
import {CollectionBuilder as $akiWb$CollectionBuilder} from "@react-aria/collections";
|
|
13
|
+
import {CollectionBuilder as $akiWb$CollectionBuilder, createHideableComponent as $akiWb$createHideableComponent} from "@react-aria/collections";
|
|
14
14
|
import {useResizeObserver as $akiWb$useResizeObserver, filterDOMProps as $akiWb$filterDOMProps, mergeProps as $akiWb$mergeProps} from "@react-aria/utils";
|
|
15
|
-
import $akiWb$react, {createContext as $akiWb$createContext, forwardRef as $akiWb$forwardRef, useMemo as $akiWb$useMemo, useRef as $akiWb$useRef, useState as $akiWb$useState, useCallback as $akiWb$useCallback, useContext as $akiWb$useContext} from "react";
|
|
15
|
+
import $akiWb$react, {createContext as $akiWb$createContext, forwardRef as $akiWb$forwardRef, useMemo as $akiWb$useMemo, useRef as $akiWb$useRef, useState as $akiWb$useState, useCallback as $akiWb$useCallback, useContext as $akiWb$useContext, Fragment as $akiWb$Fragment} from "react";
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
function $parcel$interopDefault(a) {
|
|
@@ -224,37 +224,77 @@ function $82d7e5349645de74$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
224
224
|
})));
|
|
225
225
|
}
|
|
226
226
|
const $82d7e5349645de74$export$f8f745c04421623f = /*#__PURE__*/ (0, $akiWb$createContext)(null);
|
|
227
|
-
const $82d7e5349645de74$export$e288731fd71264f0 = /*#__PURE__*/ (0, $akiWb$
|
|
228
|
-
var
|
|
227
|
+
const $82d7e5349645de74$export$e288731fd71264f0 = /*#__PURE__*/ (0, $akiWb$createHideableComponent)(function SelectValue(props, ref) {
|
|
228
|
+
var _state_selectedItems_;
|
|
229
229
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $82d7e5349645de74$export$f8f745c04421623f);
|
|
230
230
|
let state = (0, $akiWb$useContext)($82d7e5349645de74$export$ef445b55be0601bd);
|
|
231
231
|
let { placeholder: placeholder } = (0, $64fa3d84918910a7$export$fabf2dc03a41866e)($82d7e5349645de74$export$7540cee5be7dc19b);
|
|
232
|
-
let
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
let rendered = state.selectedItems.map((item)=>{
|
|
233
|
+
var _item_props;
|
|
234
|
+
let rendered = (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.children;
|
|
235
235
|
// If the selected item has a function as a child, we need to call it to render to React.JSX.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
236
|
+
if (typeof rendered === 'function') {
|
|
237
|
+
let fn = rendered;
|
|
238
|
+
rendered = fn({
|
|
239
|
+
isHovered: false,
|
|
240
|
+
isPressed: false,
|
|
241
|
+
isSelected: false,
|
|
242
|
+
isFocused: false,
|
|
243
|
+
isFocusVisible: false,
|
|
244
|
+
isDisabled: false,
|
|
245
|
+
selectionMode: 'single',
|
|
246
|
+
selectionBehavior: 'toggle'
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return rendered;
|
|
250
|
+
});
|
|
251
|
+
let formatter = (0, $akiWb$useListFormatter)();
|
|
252
|
+
let textValue = (0, $akiWb$useMemo)(()=>state.selectedItems.map((item)=>item === null || item === void 0 ? void 0 : item.textValue), [
|
|
253
|
+
state.selectedItems
|
|
254
|
+
]);
|
|
255
|
+
let selectionMode = state.selectionManager.selectionMode;
|
|
256
|
+
let selectedText = (0, $akiWb$useMemo)(()=>{
|
|
257
|
+
var _textValue_;
|
|
258
|
+
return selectionMode === 'single' ? (_textValue_ = textValue[0]) !== null && _textValue_ !== void 0 ? _textValue_ : '' : formatter.format(textValue);
|
|
259
|
+
}, [
|
|
260
|
+
selectionMode,
|
|
261
|
+
formatter,
|
|
262
|
+
textValue
|
|
263
|
+
]);
|
|
264
|
+
let defaultChildren = (0, $akiWb$useMemo)(()=>{
|
|
265
|
+
if (selectionMode === 'single') return rendered[0];
|
|
266
|
+
let parts = formatter.formatToParts(textValue);
|
|
267
|
+
if (parts.length === 0) return null;
|
|
268
|
+
let index = 0;
|
|
269
|
+
return parts.map((part)=>{
|
|
270
|
+
if (part.type === 'element') return /*#__PURE__*/ (0, $akiWb$react).createElement((0, $akiWb$Fragment), {
|
|
271
|
+
key: index
|
|
272
|
+
}, rendered[index++]);
|
|
273
|
+
else return part.value;
|
|
246
274
|
});
|
|
247
|
-
}
|
|
275
|
+
}, [
|
|
276
|
+
selectionMode,
|
|
277
|
+
formatter,
|
|
278
|
+
textValue,
|
|
279
|
+
rendered
|
|
280
|
+
]);
|
|
248
281
|
let stringFormatter = (0, $akiWb$useLocalizedStringFormatter)((0, ($parcel$interopDefault($akiWb$intlStringsmodulejs))), 'react-aria-components');
|
|
249
|
-
var _ref,
|
|
282
|
+
var _ref, _state_selectedItems__value;
|
|
250
283
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
251
284
|
...props,
|
|
252
|
-
defaultChildren: (_ref =
|
|
285
|
+
defaultChildren: (_ref = defaultChildren !== null && defaultChildren !== void 0 ? defaultChildren : placeholder) !== null && _ref !== void 0 ? _ref : stringFormatter.format('selectPlaceholder'),
|
|
253
286
|
defaultClassName: 'react-aria-SelectValue',
|
|
254
287
|
values: {
|
|
255
|
-
selectedItem: (
|
|
256
|
-
|
|
257
|
-
|
|
288
|
+
selectedItem: (_state_selectedItems__value = (_state_selectedItems_ = state.selectedItems[0]) === null || _state_selectedItems_ === void 0 ? void 0 : _state_selectedItems_.value) !== null && _state_selectedItems__value !== void 0 ? _state_selectedItems__value : null,
|
|
289
|
+
selectedItems: (0, $akiWb$useMemo)(()=>state.selectedItems.map((item)=>{
|
|
290
|
+
var _item_value;
|
|
291
|
+
return (_item_value = item.value) !== null && _item_value !== void 0 ? _item_value : null;
|
|
292
|
+
}), [
|
|
293
|
+
state.selectedItems
|
|
294
|
+
]),
|
|
295
|
+
selectedText: selectedText,
|
|
296
|
+
isPlaceholder: state.selectedItems.length === 0,
|
|
297
|
+
state: state
|
|
258
298
|
}
|
|
259
299
|
});
|
|
260
300
|
let DOMProps = (0, $akiWb$filterDOMProps)(props, {
|
|
@@ -264,7 +304,7 @@ const $82d7e5349645de74$export$e288731fd71264f0 = /*#__PURE__*/ (0, $akiWb$forwa
|
|
|
264
304
|
ref: ref,
|
|
265
305
|
...DOMProps,
|
|
266
306
|
...renderProps,
|
|
267
|
-
"data-placeholder":
|
|
307
|
+
"data-placeholder": state.selectedItems.length === 0 || undefined
|
|
268
308
|
}, /*#__PURE__*/ (0, $akiWb$react).createElement((0, $514c0188e459b4c0$export$9afb8bc826b033ea).Provider, {
|
|
269
309
|
value: undefined
|
|
270
310
|
}, renderProps.children));
|
package/dist/Select.module.js
CHANGED
|
@@ -8,11 +8,11 @@ import {ListBoxContext as $eed445e0843c11d0$export$7ff8f37d2d81a48d, ListStateCo
|
|
|
8
8
|
import {OverlayTriggerStateContext as $de32f1b87079253c$export$d2f961adcb0afbe} from "./Dialog.module.js";
|
|
9
9
|
import {PopoverContext as $07b14b47974efb58$export$9b9a0cd73afb7ca4} from "./Popover.module.js";
|
|
10
10
|
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.module.js";
|
|
11
|
-
import {useFocusRing as $akiWb$useFocusRing, useSelect as $akiWb$useSelect, HiddenSelect as $akiWb$HiddenSelect, useLocalizedStringFormatter as $akiWb$useLocalizedStringFormatter} from "react-aria";
|
|
11
|
+
import {useFocusRing as $akiWb$useFocusRing, useSelect as $akiWb$useSelect, HiddenSelect as $akiWb$HiddenSelect, useListFormatter as $akiWb$useListFormatter, useLocalizedStringFormatter as $akiWb$useLocalizedStringFormatter} from "react-aria";
|
|
12
12
|
import {useSelectState as $akiWb$useSelectState} from "react-stately";
|
|
13
|
-
import {CollectionBuilder as $akiWb$CollectionBuilder} from "@react-aria/collections";
|
|
13
|
+
import {CollectionBuilder as $akiWb$CollectionBuilder, createHideableComponent as $akiWb$createHideableComponent} from "@react-aria/collections";
|
|
14
14
|
import {useResizeObserver as $akiWb$useResizeObserver, filterDOMProps as $akiWb$filterDOMProps, mergeProps as $akiWb$mergeProps} from "@react-aria/utils";
|
|
15
|
-
import $akiWb$react, {createContext as $akiWb$createContext, forwardRef as $akiWb$forwardRef, useMemo as $akiWb$useMemo, useRef as $akiWb$useRef, useState as $akiWb$useState, useCallback as $akiWb$useCallback, useContext as $akiWb$useContext} from "react";
|
|
15
|
+
import $akiWb$react, {createContext as $akiWb$createContext, forwardRef as $akiWb$forwardRef, useMemo as $akiWb$useMemo, useRef as $akiWb$useRef, useState as $akiWb$useState, useCallback as $akiWb$useCallback, useContext as $akiWb$useContext, Fragment as $akiWb$Fragment} from "react";
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
function $parcel$interopDefault(a) {
|
|
@@ -224,37 +224,77 @@ function $82d7e5349645de74$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
224
224
|
})));
|
|
225
225
|
}
|
|
226
226
|
const $82d7e5349645de74$export$f8f745c04421623f = /*#__PURE__*/ (0, $akiWb$createContext)(null);
|
|
227
|
-
const $82d7e5349645de74$export$e288731fd71264f0 = /*#__PURE__*/ (0, $akiWb$
|
|
228
|
-
var
|
|
227
|
+
const $82d7e5349645de74$export$e288731fd71264f0 = /*#__PURE__*/ (0, $akiWb$createHideableComponent)(function SelectValue(props, ref) {
|
|
228
|
+
var _state_selectedItems_;
|
|
229
229
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $82d7e5349645de74$export$f8f745c04421623f);
|
|
230
230
|
let state = (0, $akiWb$useContext)($82d7e5349645de74$export$ef445b55be0601bd);
|
|
231
231
|
let { placeholder: placeholder } = (0, $64fa3d84918910a7$export$fabf2dc03a41866e)($82d7e5349645de74$export$7540cee5be7dc19b);
|
|
232
|
-
let
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
let rendered = state.selectedItems.map((item)=>{
|
|
233
|
+
var _item_props;
|
|
234
|
+
let rendered = (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.children;
|
|
235
235
|
// If the selected item has a function as a child, we need to call it to render to React.JSX.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
236
|
+
if (typeof rendered === 'function') {
|
|
237
|
+
let fn = rendered;
|
|
238
|
+
rendered = fn({
|
|
239
|
+
isHovered: false,
|
|
240
|
+
isPressed: false,
|
|
241
|
+
isSelected: false,
|
|
242
|
+
isFocused: false,
|
|
243
|
+
isFocusVisible: false,
|
|
244
|
+
isDisabled: false,
|
|
245
|
+
selectionMode: 'single',
|
|
246
|
+
selectionBehavior: 'toggle'
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return rendered;
|
|
250
|
+
});
|
|
251
|
+
let formatter = (0, $akiWb$useListFormatter)();
|
|
252
|
+
let textValue = (0, $akiWb$useMemo)(()=>state.selectedItems.map((item)=>item === null || item === void 0 ? void 0 : item.textValue), [
|
|
253
|
+
state.selectedItems
|
|
254
|
+
]);
|
|
255
|
+
let selectionMode = state.selectionManager.selectionMode;
|
|
256
|
+
let selectedText = (0, $akiWb$useMemo)(()=>{
|
|
257
|
+
var _textValue_;
|
|
258
|
+
return selectionMode === 'single' ? (_textValue_ = textValue[0]) !== null && _textValue_ !== void 0 ? _textValue_ : '' : formatter.format(textValue);
|
|
259
|
+
}, [
|
|
260
|
+
selectionMode,
|
|
261
|
+
formatter,
|
|
262
|
+
textValue
|
|
263
|
+
]);
|
|
264
|
+
let defaultChildren = (0, $akiWb$useMemo)(()=>{
|
|
265
|
+
if (selectionMode === 'single') return rendered[0];
|
|
266
|
+
let parts = formatter.formatToParts(textValue);
|
|
267
|
+
if (parts.length === 0) return null;
|
|
268
|
+
let index = 0;
|
|
269
|
+
return parts.map((part)=>{
|
|
270
|
+
if (part.type === 'element') return /*#__PURE__*/ (0, $akiWb$react).createElement((0, $akiWb$Fragment), {
|
|
271
|
+
key: index
|
|
272
|
+
}, rendered[index++]);
|
|
273
|
+
else return part.value;
|
|
246
274
|
});
|
|
247
|
-
}
|
|
275
|
+
}, [
|
|
276
|
+
selectionMode,
|
|
277
|
+
formatter,
|
|
278
|
+
textValue,
|
|
279
|
+
rendered
|
|
280
|
+
]);
|
|
248
281
|
let stringFormatter = (0, $akiWb$useLocalizedStringFormatter)((0, ($parcel$interopDefault($akiWb$intlStringsmodulejs))), 'react-aria-components');
|
|
249
|
-
var _ref,
|
|
282
|
+
var _ref, _state_selectedItems__value;
|
|
250
283
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
251
284
|
...props,
|
|
252
|
-
defaultChildren: (_ref =
|
|
285
|
+
defaultChildren: (_ref = defaultChildren !== null && defaultChildren !== void 0 ? defaultChildren : placeholder) !== null && _ref !== void 0 ? _ref : stringFormatter.format('selectPlaceholder'),
|
|
253
286
|
defaultClassName: 'react-aria-SelectValue',
|
|
254
287
|
values: {
|
|
255
|
-
selectedItem: (
|
|
256
|
-
|
|
257
|
-
|
|
288
|
+
selectedItem: (_state_selectedItems__value = (_state_selectedItems_ = state.selectedItems[0]) === null || _state_selectedItems_ === void 0 ? void 0 : _state_selectedItems_.value) !== null && _state_selectedItems__value !== void 0 ? _state_selectedItems__value : null,
|
|
289
|
+
selectedItems: (0, $akiWb$useMemo)(()=>state.selectedItems.map((item)=>{
|
|
290
|
+
var _item_value;
|
|
291
|
+
return (_item_value = item.value) !== null && _item_value !== void 0 ? _item_value : null;
|
|
292
|
+
}), [
|
|
293
|
+
state.selectedItems
|
|
294
|
+
]),
|
|
295
|
+
selectedText: selectedText,
|
|
296
|
+
isPlaceholder: state.selectedItems.length === 0,
|
|
297
|
+
state: state
|
|
258
298
|
}
|
|
259
299
|
});
|
|
260
300
|
let DOMProps = (0, $akiWb$filterDOMProps)(props, {
|
|
@@ -264,7 +304,7 @@ const $82d7e5349645de74$export$e288731fd71264f0 = /*#__PURE__*/ (0, $akiWb$forwa
|
|
|
264
304
|
ref: ref,
|
|
265
305
|
...DOMProps,
|
|
266
306
|
...renderProps,
|
|
267
|
-
"data-placeholder":
|
|
307
|
+
"data-placeholder": state.selectedItems.length === 0 || undefined
|
|
268
308
|
}, /*#__PURE__*/ (0, $akiWb$react).createElement((0, $514c0188e459b4c0$export$9afb8bc826b033ea).Provider, {
|
|
269
309
|
value: undefined
|
|
270
310
|
}, renderProps.children));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA8DM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAAkD;AACpF,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA+B;AAKtE,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,OAA8B,KAAqB,EAAE,GAAiC;IAChK,CAAC,OAAO,IAAI,GAA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AAQ;QAAC,OAAO;OAC1B,YAAY,QAAQ;AAI7B","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, useFocusRing, useLocalizedStringFormatter, useSelect} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, Node, SelectState, useSelectState} from 'react-stately';\nimport {CollectionBuilder} from '@react-aria/collections';\nimport {ContextValue, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps, mergeProps, useResizeObserver} from '@react-aria/utils';\nimport {FormContext} from './Form';\nimport {forwardRefType, 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 {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {TextContext} from './Text';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the select is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the select is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the select is currently open.\n * @selector [data-open]\n */\n isOpen: boolean,\n /**\n * Whether the select is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the select is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport interface SelectProps<T extends object = {}> extends Omit<AriaSelectProps<T>, 'children' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior' | 'items'>, RACValidation, RenderProps<SelectRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * Temporary text that occupies the select when it is empty.\n * @default 'Select an item' (localized)\n */\n placeholder?: string\n}\n\nexport const SelectContext = createContext<ContextValue<SelectProps<any>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown> | 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__*/ (forwardRef as forwardRefType)(function Select<T extends object = {}>(props: SelectProps<T>, 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 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 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 extends object> {\n props: SelectProps<T>,\n selectRef: ForwardedRef<HTMLDivElement>,\n collection: Collection<Node<T>>\n}\n\nfunction SelectInner<T extends object>({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(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect({\n ...removeDataAttributes(props),\n label,\n validationBehavior\n }, state, buttonRef);\n\n // Make menu width match input + button\n let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (buttonRef.current) {\n setButtonWidth(buttonRef.current.offsetWidth + 'px');\n }\n }, [buttonRef]);\n\n useResizeObserver({\n ref: buttonRef,\n onResize: onResize\n });\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(() => ({\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 }), [state.isOpen, state.isFocused, isFocusVisible, props.isDisabled, validation.isInvalid, props.isRequired]);\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 [ButtonContext, {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}],\n [OverlayTriggerStateContext, state],\n [PopoverContext, {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n style: {'--trigger-width': buttonWidth} as React.CSSProperties,\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n <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\n {...hiddenSelectProps}\n autoComplete={props.autoComplete} />\n </div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean,\n /** The object value of the currently selected item. */\n selectedItem: T | null,\n /** The textValue of the currently selected item. */\n selectedText: string | null\n}\n\nexport interface SelectValueProps<T extends object> extends Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>, RenderProps<SelectValueRenderProps<T>> {}\n\nexport const SelectValueContext = 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__*/ (forwardRef as forwardRefType)(function SelectValue<T extends object>(props: SelectValueProps<T>, ref: ForwardedRef<HTMLSpanElement>) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)!;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let selectedItem = state.selectedKey != null\n ? state.collection.getItem(state.selectedKey)\n : null;\n let rendered = selectedItem?.props.children;\n if (typeof rendered === 'function') {\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\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 let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: rendered ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: state.selectedItem?.value as T ?? null,\n selectedText: state.selectedItem?.textValue ?? null,\n isPlaceholder: !selectedItem\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <span ref={ref} {...DOMProps} {...renderProps} data-placeholder={!selectedItem || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>\n {renderProps.children}\n </TextContext.Provider>\n </span>\n );\n});\n"],"names":[],"version":3,"file":"Select.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAgEM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAAiE;AACnG,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,OAAkE,KAAwB,EAAE,GAAiC;IACvM,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,EAAE,IACpB,OAAO,aAAa,aAChB,SAAS;YACT,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACE,UACH;QAAC;QAAU;QAAY;QAAW;KAAW;IAEhD,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;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7B,yCAAA,8BAAsC;YACpD,eAAe,CAAA,GAAA,cAAM,EAAE,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;wBAAQ;2BAAA,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAmB;oBAAO;gBAAC,MAAM,aAAa;aAAC;0BAC5G;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC;QAAK,KAAK;QAAM,GAAG,QAAQ;QAAG,GAAG,WAAW;QAAE,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEnG,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAC1B,YAAY,QAAQ;AAI7B","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, useFocusRing, useListFormatter, useLocalizedStringFormatter, useSelect} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, Node, SelectState, useSelectState} from 'react-stately';\nimport {CollectionBuilder, createHideableComponent} from '@react-aria/collections';\nimport {ContextValue, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps, mergeProps, useResizeObserver} from '@react-aria/utils';\nimport {FormContext} from './Form';\nimport {forwardRefType, 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 {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {createContext, ForwardedRef, forwardRef, Fragment, HTMLAttributes, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {TextContext} from './Text';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the select is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the select is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the select is currently open.\n * @selector [data-open]\n */\n isOpen: boolean,\n /**\n * Whether the select is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the select is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport interface SelectProps<T extends object = {}, M extends SelectionMode = 'single'> extends Omit<AriaSelectProps<T, M>, 'children' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior' | 'items'>, RACValidation, RenderProps<SelectRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * Temporary text that occupies the select when it is empty.\n * @default 'Select an item' (localized)\n */\n placeholder?: string\n}\n\nexport const SelectContext = 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__*/ (forwardRef as forwardRefType)(function Select<T extends object = {}, M extends SelectionMode = 'single'>(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 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 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 extends object> {\n props: SelectProps<T, SelectionMode>,\n selectRef: ForwardedRef<HTMLDivElement>,\n collection: Collection<Node<T>>\n}\n\nfunction SelectInner<T extends object>({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(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect({\n ...removeDataAttributes(props),\n label,\n validationBehavior\n }, state, buttonRef);\n\n // Make menu width match input + button\n let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (buttonRef.current) {\n setButtonWidth(buttonRef.current.offsetWidth + 'px');\n }\n }, [buttonRef]);\n\n useResizeObserver({\n ref: buttonRef,\n onResize: onResize\n });\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(() => ({\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 }), [state.isOpen, state.isFocused, isFocusVisible, props.isDisabled, validation.isInvalid, props.isRequired]);\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 [ButtonContext, {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}],\n [OverlayTriggerStateContext, state],\n [PopoverContext, {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n style: {'--trigger-width': buttonWidth} as React.CSSProperties,\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n <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\n {...hiddenSelectProps}\n autoComplete={props.autoComplete} />\n </div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean,\n /**\n * The object value of the first selected item.\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 extends object> extends Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>, RenderProps<SelectValueRenderProps<T>> {}\n\nexport const SelectValueContext = 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 extends object>(props: SelectValueProps<T>, ref: ForwardedRef<HTMLSpanElement>) {\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(() => state.selectedItems.map(item => item?.textValue), [state.selectedItems]);\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(() => (\n selectionMode === 'single' \n ? textValue[0] ?? '' \n : formatter.format(textValue)\n ), [selectionMode, formatter, textValue]);\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(() => state.selectedItems.map(item => item.value as T ?? null), [state.selectedItems]),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <span ref={ref} {...DOMProps} {...renderProps} data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>\n {renderProps.children}\n </TextContext.Provider>\n </span>\n );\n});\n"],"names":[],"version":3,"file":"Select.module.js.map"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
2
|
+
var $2d10bc562fea46b3$exports = require("./SharedElementTransition.main.js");
|
|
3
|
+
var $lAR0I$react = require("react");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$interopDefault(a) {
|
|
7
|
+
return a && a.__esModule ? a.default : a;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function $parcel$export(e, n, v, s) {
|
|
11
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
$parcel$export(module.exports, "SelectionIndicatorContext", () => $54e872c96e6d295b$export$c9549807523555e0);
|
|
15
|
+
$parcel$export(module.exports, "SelectionIndicator", () => $54e872c96e6d295b$export$17f80983afe4e444);
|
|
16
|
+
/*
|
|
17
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
18
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
+
* governing permissions and limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const $54e872c96e6d295b$export$c9549807523555e0 = /*#__PURE__*/ (0, $lAR0I$react.createContext)({
|
|
30
|
+
isSelected: false
|
|
31
|
+
});
|
|
32
|
+
const $54e872c96e6d295b$export$17f80983afe4e444 = /*#__PURE__*/ (0, $lAR0I$react.forwardRef)(function SelectionIndicator(props, ref) {
|
|
33
|
+
[props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $54e872c96e6d295b$export$c9549807523555e0);
|
|
34
|
+
let { isSelected: isSelected, ...otherProps } = props;
|
|
35
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($lAR0I$react))).createElement((0, $2d10bc562fea46b3$exports.SharedElement), {
|
|
36
|
+
...otherProps,
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: props.className || 'react-aria-SelectionIndicator',
|
|
39
|
+
name: "SelectionIndicator",
|
|
40
|
+
isVisible: isSelected
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=SelectionIndicator.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAUM,MAAM,0DAA4B,CAAA,GAAA,0BAAY,EAAyD;IAC5G,YAAY;AACd;AAMO,MAAM,0DAAqB,CAAA,GAAA,uBAAS,EAAE,SAAS,mBAAmB,KAA8B,EAAE,GAAiC;IACxI,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,cAAC,UAAU,EAAE,GAAG,YAAW,GAAG;IAClC,qBACE,0DAAC,CAAA,GAAA,uCAAY;QACV,GAAG,UAAU;QACd,KAAK;QACL,WAAW,MAAM,SAAS,IAAI;QAC9B,MAAK;QACL,WAAW;;AAEjB","sources":["packages/react-aria-components/src/SelectionIndicator.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 {ContextValue, useContextProps} from './utils';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\nimport {SharedElement, SharedElementPropsBase} from './SharedElementTransition';\n\nexport interface SelectionIndicatorProps extends SharedElementPropsBase {\n isSelected?: boolean\n}\n\nexport const SelectionIndicatorContext = createContext<ContextValue<SelectionIndicatorProps, HTMLDivElement>>({\n isSelected: false\n});\n\n\n/**\n * An animated indicator of selection state within a group of items.\n */\nexport const SelectionIndicator = forwardRef(function SelectionIndicator(props: SelectionIndicatorProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectionIndicatorContext);\n let {isSelected, ...otherProps} = props;\n return (\n <SharedElement\n {...otherProps}\n ref={ref}\n className={props.className || 'react-aria-SelectionIndicator'}\n name=\"SelectionIndicator\"\n isVisible={isSelected} />\n );\n});\n"],"names":[],"version":3,"file":"SelectionIndicator.main.js.map"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415} from "./utils.mjs";
|
|
2
|
+
import {SharedElement as $c8a5a149f625efcf$export$c34620ff8881d89f} from "./SharedElementTransition.mjs";
|
|
3
|
+
import $4GgyL$react, {createContext as $4GgyL$createContext, forwardRef as $4GgyL$forwardRef} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const $1d5b8b8664671ef2$export$c9549807523555e0 = /*#__PURE__*/ (0, $4GgyL$createContext)({
|
|
19
|
+
isSelected: false
|
|
20
|
+
});
|
|
21
|
+
const $1d5b8b8664671ef2$export$17f80983afe4e444 = /*#__PURE__*/ (0, $4GgyL$forwardRef)(function SelectionIndicator(props, ref) {
|
|
22
|
+
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $1d5b8b8664671ef2$export$c9549807523555e0);
|
|
23
|
+
let { isSelected: isSelected, ...otherProps } = props;
|
|
24
|
+
return /*#__PURE__*/ (0, $4GgyL$react).createElement((0, $c8a5a149f625efcf$export$c34620ff8881d89f), {
|
|
25
|
+
...otherProps,
|
|
26
|
+
ref: ref,
|
|
27
|
+
className: props.className || 'react-aria-SelectionIndicator',
|
|
28
|
+
name: "SelectionIndicator",
|
|
29
|
+
isVisible: isSelected
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {$1d5b8b8664671ef2$export$c9549807523555e0 as SelectionIndicatorContext, $1d5b8b8664671ef2$export$17f80983afe4e444 as SelectionIndicator};
|
|
35
|
+
//# sourceMappingURL=SelectionIndicator.module.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415} from "./utils.module.js";
|
|
2
|
+
import {SharedElement as $c8a5a149f625efcf$export$c34620ff8881d89f} from "./SharedElementTransition.module.js";
|
|
3
|
+
import $4GgyL$react, {createContext as $4GgyL$createContext, forwardRef as $4GgyL$forwardRef} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const $1d5b8b8664671ef2$export$c9549807523555e0 = /*#__PURE__*/ (0, $4GgyL$createContext)({
|
|
19
|
+
isSelected: false
|
|
20
|
+
});
|
|
21
|
+
const $1d5b8b8664671ef2$export$17f80983afe4e444 = /*#__PURE__*/ (0, $4GgyL$forwardRef)(function SelectionIndicator(props, ref) {
|
|
22
|
+
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $1d5b8b8664671ef2$export$c9549807523555e0);
|
|
23
|
+
let { isSelected: isSelected, ...otherProps } = props;
|
|
24
|
+
return /*#__PURE__*/ (0, $4GgyL$react).createElement((0, $c8a5a149f625efcf$export$c34620ff8881d89f), {
|
|
25
|
+
...otherProps,
|
|
26
|
+
ref: ref,
|
|
27
|
+
className: props.className || 'react-aria-SelectionIndicator',
|
|
28
|
+
name: "SelectionIndicator",
|
|
29
|
+
isVisible: isSelected
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {$1d5b8b8664671ef2$export$c9549807523555e0 as SelectionIndicatorContext, $1d5b8b8664671ef2$export$17f80983afe4e444 as SelectionIndicator};
|
|
35
|
+
//# sourceMappingURL=SelectionIndicator.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAUM,MAAM,0DAA4B,CAAA,GAAA,oBAAY,EAAyD;IAC5G,YAAY;AACd;AAMO,MAAM,0DAAqB,CAAA,GAAA,iBAAS,EAAE,SAAS,mBAAmB,KAA8B,EAAE,GAAiC;IACxI,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,cAAC,UAAU,EAAE,GAAG,YAAW,GAAG;IAClC,qBACE,gCAAC,CAAA,GAAA,yCAAY;QACV,GAAG,UAAU;QACd,KAAK;QACL,WAAW,MAAM,SAAS,IAAI;QAC9B,MAAK;QACL,WAAW;;AAEjB","sources":["packages/react-aria-components/src/SelectionIndicator.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 {ContextValue, useContextProps} from './utils';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\nimport {SharedElement, SharedElementPropsBase} from './SharedElementTransition';\n\nexport interface SelectionIndicatorProps extends SharedElementPropsBase {\n isSelected?: boolean\n}\n\nexport const SelectionIndicatorContext = createContext<ContextValue<SelectionIndicatorProps, HTMLDivElement>>({\n isSelected: false\n});\n\n\n/**\n * An animated indicator of selection state within a group of items.\n */\nexport const SelectionIndicator = forwardRef(function SelectionIndicator(props: SelectionIndicatorProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectionIndicatorContext);\n let {isSelected, ...otherProps} = props;\n return (\n <SharedElement\n {...otherProps}\n ref={ref}\n className={props.className || 'react-aria-SelectionIndicator'}\n name=\"SelectionIndicator\"\n isVisible={isSelected} />\n );\n});\n"],"names":[],"version":3,"file":"SelectionIndicator.module.js.map"}
|