react-aria-components 1.17.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/exports/Autocomplete.cjs.map +1 -1
- package/dist/exports/Autocomplete.js.map +1 -1
- package/dist/exports/Autocomplete.mjs.map +1 -1
- package/dist/exports/Calendar.cjs +3 -0
- package/dist/exports/Calendar.cjs.map +1 -1
- package/dist/exports/Calendar.js +2 -2
- package/dist/exports/Calendar.js.map +1 -1
- package/dist/exports/Calendar.mjs +2 -2
- package/dist/exports/Calendar.mjs.map +1 -1
- package/dist/exports/Checkbox.cjs +8 -0
- package/dist/exports/Checkbox.cjs.map +1 -1
- package/dist/exports/Checkbox.js +6 -2
- package/dist/exports/Checkbox.js.map +1 -1
- package/dist/exports/Checkbox.mjs +6 -2
- package/dist/exports/Checkbox.mjs.map +1 -1
- package/dist/exports/CheckboxGroup.cjs.map +1 -1
- package/dist/exports/CheckboxGroup.js.map +1 -1
- package/dist/exports/CheckboxGroup.mjs.map +1 -1
- package/dist/exports/CollectionBuilder.cjs.map +1 -1
- package/dist/exports/CollectionBuilder.js.map +1 -1
- package/dist/exports/CollectionBuilder.mjs.map +1 -1
- package/dist/exports/ColorArea.cjs.map +1 -1
- package/dist/exports/ColorArea.js.map +1 -1
- package/dist/exports/ColorArea.mjs.map +1 -1
- package/dist/exports/ColorField.cjs.map +1 -1
- package/dist/exports/ColorField.js.map +1 -1
- package/dist/exports/ColorField.mjs.map +1 -1
- package/dist/exports/ColorPicker.cjs.map +1 -1
- package/dist/exports/ColorPicker.js.map +1 -1
- package/dist/exports/ColorPicker.mjs.map +1 -1
- package/dist/exports/ColorSlider.cjs.map +1 -1
- package/dist/exports/ColorSlider.js.map +1 -1
- package/dist/exports/ColorSlider.mjs.map +1 -1
- package/dist/exports/ColorSwatch.cjs.map +1 -1
- package/dist/exports/ColorSwatch.js.map +1 -1
- package/dist/exports/ColorSwatch.mjs.map +1 -1
- package/dist/exports/ColorSwatchPicker.cjs.map +1 -1
- package/dist/exports/ColorSwatchPicker.js.map +1 -1
- package/dist/exports/ColorSwatchPicker.mjs.map +1 -1
- package/dist/exports/ColorThumb.cjs.map +1 -1
- package/dist/exports/ColorThumb.js.map +1 -1
- package/dist/exports/ColorThumb.mjs.map +1 -1
- package/dist/exports/ColorWheel.cjs.map +1 -1
- package/dist/exports/ColorWheel.js.map +1 -1
- package/dist/exports/ColorWheel.mjs.map +1 -1
- package/dist/exports/ComboBox.cjs.map +1 -1
- package/dist/exports/ComboBox.js.map +1 -1
- package/dist/exports/ComboBox.mjs.map +1 -1
- package/dist/exports/DateField.cjs.map +1 -1
- package/dist/exports/DateField.js.map +1 -1
- package/dist/exports/DateField.mjs.map +1 -1
- package/dist/exports/DatePicker.cjs.map +1 -1
- package/dist/exports/DatePicker.js.map +1 -1
- package/dist/exports/DatePicker.mjs.map +1 -1
- package/dist/exports/DateRangePicker.cjs.map +1 -1
- package/dist/exports/DateRangePicker.js.map +1 -1
- package/dist/exports/DateRangePicker.mjs.map +1 -1
- package/dist/exports/Disclosure.cjs.map +1 -1
- package/dist/exports/Disclosure.js.map +1 -1
- package/dist/exports/Disclosure.mjs.map +1 -1
- package/dist/exports/DisclosureGroup.cjs.map +1 -1
- package/dist/exports/DisclosureGroup.js.map +1 -1
- package/dist/exports/DisclosureGroup.mjs.map +1 -1
- package/dist/exports/GridList.cjs.map +1 -1
- package/dist/exports/GridList.js.map +1 -1
- package/dist/exports/GridList.mjs.map +1 -1
- package/dist/exports/ListBox.cjs.map +1 -1
- package/dist/exports/ListBox.js.map +1 -1
- package/dist/exports/ListBox.mjs.map +1 -1
- package/dist/exports/Menu.cjs.map +1 -1
- package/dist/exports/Menu.js.map +1 -1
- package/dist/exports/Menu.mjs.map +1 -1
- package/dist/exports/RadioGroup.cjs +3 -0
- package/dist/exports/RadioGroup.cjs.map +1 -1
- package/dist/exports/RadioGroup.js +2 -2
- package/dist/exports/RadioGroup.js.map +1 -1
- package/dist/exports/RadioGroup.mjs +2 -2
- package/dist/exports/RadioGroup.mjs.map +1 -1
- package/dist/exports/RangeCalendar.cjs +3 -0
- package/dist/exports/RangeCalendar.cjs.map +1 -1
- package/dist/exports/RangeCalendar.js +2 -2
- package/dist/exports/RangeCalendar.js.map +1 -1
- package/dist/exports/RangeCalendar.mjs +2 -2
- package/dist/exports/RangeCalendar.mjs.map +1 -1
- package/dist/exports/Select.cjs.map +1 -1
- package/dist/exports/Select.js.map +1 -1
- package/dist/exports/Select.mjs.map +1 -1
- package/dist/exports/SharedElementTransition.cjs.map +1 -1
- package/dist/exports/SharedElementTransition.js.map +1 -1
- package/dist/exports/SharedElementTransition.mjs.map +1 -1
- package/dist/exports/Slider.cjs +2 -0
- package/dist/exports/Slider.cjs.map +1 -1
- package/dist/exports/Slider.js +2 -2
- package/dist/exports/Slider.js.map +1 -1
- package/dist/exports/Slider.mjs +2 -2
- package/dist/exports/Slider.mjs.map +1 -1
- package/dist/exports/Switch.cjs +8 -0
- package/dist/exports/Switch.cjs.map +1 -1
- package/dist/exports/Switch.js +6 -2
- package/dist/exports/Switch.js.map +1 -1
- package/dist/exports/Switch.mjs +6 -2
- package/dist/exports/Switch.mjs.map +1 -1
- package/dist/exports/Table.cjs +1 -0
- package/dist/exports/Table.cjs.map +1 -1
- package/dist/exports/Table.js +2 -2
- package/dist/exports/Table.js.map +1 -1
- package/dist/exports/Table.mjs +2 -2
- package/dist/exports/Table.mjs.map +1 -1
- package/dist/exports/Tabs.cjs.map +1 -1
- package/dist/exports/Tabs.js.map +1 -1
- package/dist/exports/Tabs.mjs.map +1 -1
- package/dist/exports/TagGroup.cjs.map +1 -1
- package/dist/exports/TagGroup.js.map +1 -1
- package/dist/exports/TagGroup.mjs.map +1 -1
- package/dist/exports/TimeField.cjs.map +1 -1
- package/dist/exports/TimeField.js.map +1 -1
- package/dist/exports/TimeField.mjs.map +1 -1
- package/dist/exports/Toast.cjs.map +1 -1
- package/dist/exports/Toast.js.map +1 -1
- package/dist/exports/Toast.mjs.map +1 -1
- package/dist/exports/ToggleButtonGroup.cjs.map +1 -1
- package/dist/exports/ToggleButtonGroup.js.map +1 -1
- package/dist/exports/ToggleButtonGroup.mjs.map +1 -1
- package/dist/exports/Tree.cjs.map +1 -1
- package/dist/exports/Tree.js.map +1 -1
- package/dist/exports/Tree.mjs.map +1 -1
- package/dist/exports/Virtualizer.cjs.map +1 -1
- package/dist/exports/Virtualizer.js.map +1 -1
- package/dist/exports/Virtualizer.mjs.map +1 -1
- package/dist/exports/index.cjs +19 -1
- package/dist/exports/index.cjs.map +1 -1
- package/dist/exports/index.js +11 -8
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/index.mjs +11 -8
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/useAsyncList.cjs.map +1 -1
- package/dist/exports/useAsyncList.js.map +1 -1
- package/dist/exports/useAsyncList.mjs.map +1 -1
- package/dist/exports/useDragAndDrop.cjs.map +1 -1
- package/dist/exports/useDragAndDrop.js.map +1 -1
- package/dist/exports/useDragAndDrop.mjs.map +1 -1
- package/dist/exports/useDrop.cjs.map +1 -1
- package/dist/exports/useDrop.js.map +1 -1
- package/dist/exports/useDrop.mjs.map +1 -1
- package/dist/private/Autocomplete.cjs.map +1 -1
- package/dist/private/Autocomplete.js.map +1 -1
- package/dist/private/Autocomplete.mjs.map +1 -1
- package/dist/private/Breadcrumbs.cjs.map +1 -1
- package/dist/private/Breadcrumbs.js.map +1 -1
- package/dist/private/Breadcrumbs.mjs.map +1 -1
- package/dist/private/Button.cjs.map +1 -1
- package/dist/private/Button.js.map +1 -1
- package/dist/private/Button.mjs.map +1 -1
- package/dist/private/Calendar.cjs +34 -2
- package/dist/private/Calendar.cjs.map +1 -1
- package/dist/private/Calendar.js +34 -5
- package/dist/private/Calendar.js.map +1 -1
- package/dist/private/Calendar.mjs +34 -5
- package/dist/private/Calendar.mjs.map +1 -1
- package/dist/private/Checkbox.cjs +104 -17
- package/dist/private/Checkbox.cjs.map +1 -1
- package/dist/private/Checkbox.js +102 -18
- package/dist/private/Checkbox.js.map +1 -1
- package/dist/private/Checkbox.mjs +102 -18
- package/dist/private/Checkbox.mjs.map +1 -1
- package/dist/private/Collection.cjs.map +1 -1
- package/dist/private/Collection.js.map +1 -1
- package/dist/private/Collection.mjs.map +1 -1
- package/dist/private/ColorArea.cjs.map +1 -1
- package/dist/private/ColorArea.js.map +1 -1
- package/dist/private/ColorArea.mjs.map +1 -1
- package/dist/private/ColorField.cjs.map +1 -1
- package/dist/private/ColorField.js.map +1 -1
- package/dist/private/ColorField.mjs.map +1 -1
- package/dist/private/ColorPicker.cjs.map +1 -1
- package/dist/private/ColorPicker.js.map +1 -1
- package/dist/private/ColorPicker.mjs.map +1 -1
- package/dist/private/ColorSlider.cjs.map +1 -1
- package/dist/private/ColorSlider.js.map +1 -1
- package/dist/private/ColorSlider.mjs.map +1 -1
- package/dist/private/ColorSwatch.cjs.map +1 -1
- package/dist/private/ColorSwatch.js.map +1 -1
- package/dist/private/ColorSwatch.mjs.map +1 -1
- 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/ColorThumb.cjs.map +1 -1
- package/dist/private/ColorThumb.js.map +1 -1
- package/dist/private/ColorThumb.mjs.map +1 -1
- package/dist/private/ColorWheel.cjs.map +1 -1
- package/dist/private/ColorWheel.js.map +1 -1
- package/dist/private/ColorWheel.mjs.map +1 -1
- package/dist/private/ComboBox.cjs +15 -3
- package/dist/private/ComboBox.cjs.map +1 -1
- package/dist/private/ComboBox.js +16 -4
- package/dist/private/ComboBox.js.map +1 -1
- package/dist/private/ComboBox.mjs +16 -4
- package/dist/private/ComboBox.mjs.map +1 -1
- package/dist/private/DateField.cjs.map +1 -1
- package/dist/private/DateField.js.map +1 -1
- package/dist/private/DateField.mjs.map +1 -1
- package/dist/private/DatePicker.cjs +0 -26
- package/dist/private/DatePicker.cjs.map +1 -1
- package/dist/private/DatePicker.js +1 -27
- package/dist/private/DatePicker.js.map +1 -1
- package/dist/private/DatePicker.mjs +1 -27
- package/dist/private/DatePicker.mjs.map +1 -1
- package/dist/private/Dialog.cjs +1 -17
- package/dist/private/Dialog.cjs.map +1 -1
- package/dist/private/Dialog.js +2 -18
- package/dist/private/Dialog.js.map +1 -1
- package/dist/private/Dialog.mjs +2 -18
- package/dist/private/Dialog.mjs.map +1 -1
- package/dist/private/Disclosure.cjs.map +1 -1
- package/dist/private/Disclosure.js.map +1 -1
- package/dist/private/Disclosure.mjs.map +1 -1
- package/dist/private/DragAndDrop.cjs +3 -3
- package/dist/private/DragAndDrop.cjs.map +1 -1
- package/dist/private/DragAndDrop.js +3 -3
- package/dist/private/DragAndDrop.js.map +1 -1
- package/dist/private/DragAndDrop.mjs +3 -3
- package/dist/private/DragAndDrop.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/FieldError.cjs.map +1 -1
- package/dist/private/FieldError.js.map +1 -1
- package/dist/private/FieldError.mjs.map +1 -1
- package/dist/private/FileTrigger.cjs.map +1 -1
- package/dist/private/FileTrigger.js.map +1 -1
- package/dist/private/FileTrigger.mjs.map +1 -1
- package/dist/private/Form.cjs.map +1 -1
- package/dist/private/Form.js.map +1 -1
- package/dist/private/Form.mjs.map +1 -1
- package/dist/private/GridLayout.cjs +37 -0
- package/dist/private/GridLayout.cjs.map +1 -0
- package/dist/private/GridLayout.js +32 -0
- package/dist/private/GridLayout.js.map +1 -0
- package/dist/private/GridLayout.mjs +32 -0
- package/dist/private/GridLayout.mjs.map +1 -0
- package/dist/private/GridList.cjs +23 -5
- package/dist/private/GridList.cjs.map +1 -1
- package/dist/private/GridList.js +24 -6
- package/dist/private/GridList.js.map +1 -1
- package/dist/private/GridList.mjs +24 -6
- package/dist/private/GridList.mjs.map +1 -1
- package/dist/private/Group.cjs.map +1 -1
- package/dist/private/Group.js.map +1 -1
- package/dist/private/Group.mjs.map +1 -1
- package/dist/private/Header.cjs.map +1 -1
- package/dist/private/Header.js.map +1 -1
- package/dist/private/Header.mjs.map +1 -1
- package/dist/private/Heading.cjs.map +1 -1
- package/dist/private/Heading.js.map +1 -1
- package/dist/private/Heading.mjs.map +1 -1
- package/dist/private/HiddenDateInput.cjs +3 -3
- package/dist/private/HiddenDateInput.cjs.map +1 -1
- package/dist/private/HiddenDateInput.js +3 -3
- package/dist/private/HiddenDateInput.js.map +1 -1
- package/dist/private/HiddenDateInput.mjs +3 -3
- package/dist/private/HiddenDateInput.mjs.map +1 -1
- package/dist/private/Input.cjs.map +1 -1
- package/dist/private/Input.js.map +1 -1
- package/dist/private/Input.mjs.map +1 -1
- package/dist/private/Keyboard.cjs.map +1 -1
- package/dist/private/Keyboard.js.map +1 -1
- package/dist/private/Keyboard.mjs.map +1 -1
- package/dist/private/Label.cjs.map +1 -1
- package/dist/private/Label.js.map +1 -1
- package/dist/private/Label.mjs.map +1 -1
- package/dist/private/Link.cjs.map +1 -1
- package/dist/private/Link.js.map +1 -1
- package/dist/private/Link.mjs.map +1 -1
- package/dist/private/ListBox.cjs +6 -5
- package/dist/private/ListBox.cjs.map +1 -1
- package/dist/private/ListBox.js +6 -5
- package/dist/private/ListBox.js.map +1 -1
- package/dist/private/ListBox.mjs +6 -5
- package/dist/private/ListBox.mjs.map +1 -1
- package/dist/private/Menu.cjs +5 -15
- package/dist/private/Menu.cjs.map +1 -1
- package/dist/private/Menu.js +6 -16
- package/dist/private/Menu.js.map +1 -1
- package/dist/private/Menu.mjs +6 -16
- package/dist/private/Menu.mjs.map +1 -1
- package/dist/private/Meter.cjs.map +1 -1
- package/dist/private/Meter.js.map +1 -1
- package/dist/private/Meter.mjs.map +1 -1
- package/dist/private/Modal.cjs.map +1 -1
- package/dist/private/Modal.js.map +1 -1
- package/dist/private/Modal.mjs.map +1 -1
- package/dist/private/NumberField.cjs.map +1 -1
- package/dist/private/NumberField.js.map +1 -1
- package/dist/private/NumberField.mjs.map +1 -1
- package/dist/private/OverlayArrow.cjs.map +1 -1
- package/dist/private/OverlayArrow.js.map +1 -1
- package/dist/private/OverlayArrow.mjs.map +1 -1
- package/dist/private/Popover.cjs +17 -1
- package/dist/private/Popover.cjs.map +1 -1
- package/dist/private/Popover.js +19 -2
- package/dist/private/Popover.js.map +1 -1
- package/dist/private/Popover.mjs +18 -2
- package/dist/private/Popover.mjs.map +1 -1
- package/dist/private/ProgressBar.cjs.map +1 -1
- package/dist/private/ProgressBar.js.map +1 -1
- package/dist/private/ProgressBar.mjs.map +1 -1
- package/dist/private/RadioGroup.cjs +87 -7
- package/dist/private/RadioGroup.cjs.map +1 -1
- package/dist/private/RadioGroup.js +86 -9
- package/dist/private/RadioGroup.js.map +1 -1
- package/dist/private/RadioGroup.mjs +86 -9
- package/dist/private/RadioGroup.mjs.map +1 -1
- package/dist/private/SearchField.cjs.map +1 -1
- package/dist/private/SearchField.js.map +1 -1
- package/dist/private/SearchField.mjs.map +1 -1
- package/dist/private/Select.cjs +1 -17
- package/dist/private/Select.cjs.map +1 -1
- package/dist/private/Select.js +2 -18
- package/dist/private/Select.js.map +1 -1
- package/dist/private/Select.mjs +2 -18
- package/dist/private/Select.mjs.map +1 -1
- package/dist/private/SelectionIndicator.cjs.map +1 -1
- package/dist/private/SelectionIndicator.js.map +1 -1
- package/dist/private/SelectionIndicator.mjs.map +1 -1
- package/dist/private/Separator.cjs.map +1 -1
- package/dist/private/Separator.js.map +1 -1
- package/dist/private/Separator.mjs.map +1 -1
- package/dist/private/SharedElementTransition.cjs.map +1 -1
- package/dist/private/SharedElementTransition.js.map +1 -1
- package/dist/private/SharedElementTransition.mjs.map +1 -1
- package/dist/private/Slider.cjs +51 -1
- package/dist/private/Slider.cjs.map +1 -1
- package/dist/private/Slider.js +50 -2
- package/dist/private/Slider.js.map +1 -1
- package/dist/private/Slider.mjs +50 -2
- package/dist/private/Slider.mjs.map +1 -1
- package/dist/private/Switch.cjs +118 -4
- package/dist/private/Switch.cjs.map +1 -1
- package/dist/private/Switch.js +119 -7
- package/dist/private/Switch.js.map +1 -1
- package/dist/private/Switch.mjs +118 -7
- package/dist/private/Switch.mjs.map +1 -1
- package/dist/private/Table.cjs +115 -24
- package/dist/private/Table.cjs.map +1 -1
- package/dist/private/Table.js +116 -26
- package/dist/private/Table.js.map +1 -1
- package/dist/private/Table.mjs +116 -26
- package/dist/private/Table.mjs.map +1 -1
- package/dist/private/TableLayout.cjs.map +1 -1
- package/dist/private/TableLayout.js.map +1 -1
- package/dist/private/TableLayout.mjs.map +1 -1
- package/dist/private/Tabs.cjs +4 -3
- package/dist/private/Tabs.cjs.map +1 -1
- package/dist/private/Tabs.js +4 -3
- package/dist/private/Tabs.js.map +1 -1
- package/dist/private/Tabs.mjs +4 -3
- package/dist/private/Tabs.mjs.map +1 -1
- package/dist/private/TagGroup.cjs.map +1 -1
- package/dist/private/TagGroup.js.map +1 -1
- package/dist/private/TagGroup.mjs.map +1 -1
- package/dist/private/Text.cjs.map +1 -1
- package/dist/private/Text.js.map +1 -1
- package/dist/private/Text.mjs.map +1 -1
- package/dist/private/TextArea.cjs.map +1 -1
- package/dist/private/TextArea.js.map +1 -1
- package/dist/private/TextArea.mjs.map +1 -1
- package/dist/private/TextField.cjs.map +1 -1
- package/dist/private/TextField.js.map +1 -1
- package/dist/private/TextField.mjs.map +1 -1
- package/dist/private/Toast.cjs +2 -1
- package/dist/private/Toast.cjs.map +1 -1
- package/dist/private/Toast.js +2 -1
- package/dist/private/Toast.js.map +1 -1
- package/dist/private/Toast.mjs +2 -1
- package/dist/private/Toast.mjs.map +1 -1
- package/dist/private/ToggleButton.cjs.map +1 -1
- package/dist/private/ToggleButton.js.map +1 -1
- package/dist/private/ToggleButton.mjs.map +1 -1
- package/dist/private/ToggleButtonGroup.cjs.map +1 -1
- package/dist/private/ToggleButtonGroup.js.map +1 -1
- package/dist/private/ToggleButtonGroup.mjs.map +1 -1
- package/dist/private/Toolbar.cjs.map +1 -1
- package/dist/private/Toolbar.js.map +1 -1
- package/dist/private/Toolbar.mjs.map +1 -1
- package/dist/private/Tooltip.cjs.map +1 -1
- package/dist/private/Tooltip.js.map +1 -1
- package/dist/private/Tooltip.mjs.map +1 -1
- package/dist/private/Tree.cjs +18 -6
- package/dist/private/Tree.cjs.map +1 -1
- package/dist/private/Tree.js +19 -7
- package/dist/private/Tree.js.map +1 -1
- package/dist/private/Tree.mjs +19 -7
- package/dist/private/Tree.mjs.map +1 -1
- package/dist/private/TreeDropTargetDelegate.cjs +9 -4
- package/dist/private/TreeDropTargetDelegate.cjs.map +1 -1
- package/dist/private/TreeDropTargetDelegate.js +10 -4
- package/dist/private/TreeDropTargetDelegate.js.map +1 -1
- package/dist/private/TreeDropTargetDelegate.mjs +9 -4
- package/dist/private/TreeDropTargetDelegate.mjs.map +1 -1
- package/dist/private/Virtualizer.cjs.map +1 -1
- package/dist/private/Virtualizer.js.map +1 -1
- package/dist/private/Virtualizer.mjs.map +1 -1
- package/dist/private/useDragAndDrop.cjs.map +1 -1
- package/dist/private/useDragAndDrop.js.map +1 -1
- package/dist/private/useDragAndDrop.mjs.map +1 -1
- package/dist/private/utils.cjs.map +1 -1
- package/dist/private/utils.js.map +1 -1
- package/dist/private/utils.mjs.map +1 -1
- package/dist/types/exports/Calendar.d.ts +4 -3
- package/dist/types/exports/Checkbox.d.ts +7 -2
- package/dist/types/exports/RadioGroup.d.ts +2 -2
- package/dist/types/exports/RangeCalendar.d.ts +3 -2
- package/dist/types/exports/Slider.d.ts +2 -2
- package/dist/types/exports/Switch.d.ts +7 -2
- package/dist/types/exports/Table.d.ts +2 -2
- package/dist/types/exports/index.d.ts +15 -13
- package/dist/types/exports/useDragAndDrop.d.ts +1 -1
- package/dist/types/src/Autocomplete.d.ts +1 -1
- package/dist/types/src/Breadcrumbs.d.ts +13 -4
- package/dist/types/src/Button.d.ts +9 -1
- package/dist/types/src/Calendar.d.ts +93 -33
- package/dist/types/src/Checkbox.d.ts +93 -2
- package/dist/types/src/Collection.d.ts +17 -4
- package/dist/types/src/ColorArea.d.ts +6 -2
- package/dist/types/src/ColorField.d.ts +8 -1
- package/dist/types/src/ColorPicker.d.ts +4 -1
- package/dist/types/src/ColorSlider.d.ts +5 -1
- package/dist/types/src/ColorSwatch.d.ts +3 -1
- package/dist/types/src/ColorSwatchPicker.d.ts +7 -2
- package/dist/types/src/ColorThumb.d.ts +10 -2
- package/dist/types/src/ColorWheel.d.ts +7 -2
- package/dist/types/src/ComboBox.d.ts +24 -11
- package/dist/types/src/DateField.d.ts +29 -4
- package/dist/types/src/DatePicker.d.ts +15 -3
- package/dist/types/src/Dialog.d.ts +3 -1
- package/dist/types/src/Disclosure.d.ts +21 -5
- package/dist/types/src/DragAndDrop.d.ts +6 -2
- package/dist/types/src/DropZone.d.ts +8 -1
- package/dist/types/src/FieldError.d.ts +4 -1
- package/dist/types/src/FileTrigger.d.ts +2 -1
- package/dist/types/src/Form.d.ts +4 -1
- package/dist/types/src/GridLayout.d.ts +5 -0
- package/dist/types/src/GridList.d.ts +51 -13
- package/dist/types/src/Group.d.ts +9 -1
- package/dist/types/src/Heading.d.ts +12 -0
- package/dist/types/src/HiddenDateInput.d.ts +2 -1
- package/dist/types/src/Input.d.ts +8 -1
- package/dist/types/src/Link.d.ts +9 -1
- package/dist/types/src/ListBox.d.ts +35 -12
- package/dist/types/src/Menu.d.ts +22 -10
- package/dist/types/src/Meter.d.ts +4 -1
- package/dist/types/src/Modal.d.ts +9 -3
- package/dist/types/src/NumberField.d.ts +9 -2
- package/dist/types/src/OverlayArrow.d.ts +4 -1
- package/dist/types/src/Popover.d.ts +12 -3
- package/dist/types/src/ProgressBar.d.ts +5 -1
- package/dist/types/src/RadioGroup.d.ts +88 -2
- package/dist/types/src/SearchField.d.ts +8 -1
- package/dist/types/src/Select.d.ts +19 -6
- package/dist/types/src/SelectionIndicator.d.ts +7 -2
- package/dist/types/src/Separator.d.ts +5 -2
- package/dist/types/src/SharedElementTransition.d.ts +2 -0
- package/dist/types/src/Slider.d.ts +48 -4
- package/dist/types/src/Switch.d.ts +100 -3
- package/dist/types/src/Table.d.ts +138 -31
- package/dist/types/src/Tabs.d.ts +37 -12
- package/dist/types/src/TagGroup.d.ts +18 -7
- package/dist/types/src/TextArea.d.ts +3 -1
- package/dist/types/src/TextField.d.ts +7 -1
- package/dist/types/src/Toast.d.ts +13 -3
- package/dist/types/src/ToggleButton.d.ts +10 -3
- package/dist/types/src/ToggleButtonGroup.d.ts +7 -2
- package/dist/types/src/Toolbar.d.ts +6 -3
- package/dist/types/src/Tooltip.d.ts +13 -4
- package/dist/types/src/Tree.d.ts +52 -16
- package/dist/types/src/useDragAndDrop.d.ts +10 -4
- package/dist/types/src/utils.d.ts +109 -17
- package/package.json +9 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AAuIM,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AACvF,MAAM,0DAAe,CAAA,GAAA,oBAAY,EAAuD;AACxF,MAAM,0DAAyB,CAAA,GAAA,oBAAY,EAA0B;AAKrE,MAAM,4CAA2B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,WAAW,KAAsB,EAAE,GAAiC;IAClJ,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,CAAA,GAAA,yCAAU,MAAM,CAAC;IACtF,IAAI,qBAAqB,MAAM,kBAAkB,IAAI,0BAA0B;IAC/E,IAAI,QAAQ,CAAA,GAAA,yBAAiB,EAAE;QAC7B,GAAG,KAAK;4BACR;IACF;IAEA,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAC5B,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC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,CAAA,GAAA,yCAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,MAAM,UAAU,IAAI;QACnC,gBAAc,MAAM,SAAS,IAAI;QACjC,iBAAe,MAAM,UAAU,IAAI;qBACnC,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;uBAEtD,gCAAC,CAAA,GAAA,yCAAwB,EAAE,QAAQ;QAAC,OAAO;wBAAC;QAAU;OACnD,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/RadioGroup.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 {AriaRadioGroupProps, AriaRadioProps, useRadio, useRadioGroup} from 'react-aria/useRadioGroup';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents, Orientation} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {RadioGroupState, useRadioGroupState} from 'react-stately/useRadioGroupState';\nimport React, {createContext, ForwardedRef, forwardRef, useMemo} from 'react';\nimport {SelectionIndicatorContext} from './SelectionIndicator';\nimport {SharedElementTransition} from './SharedElementTransition';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface RadioGroupProps extends Omit<AriaRadioGroupProps, 'children' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior'>, RACValidation, RenderProps<RadioGroupRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-RadioGroup'\n */\n className?: ClassNameOrFunction<RadioGroupRenderProps>\n}\nexport interface RadioProps extends Omit<AriaRadioProps, 'children'>, HoverEvents, RenderProps<RadioRenderProps, 'label'>, SlotProps, Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-Radio'\n */\n className?: ClassNameOrFunction<RadioRenderProps>,\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\nexport interface RadioGroupRenderProps {\n /**\n * The orientation of the radio group.\n * @selector [data-orientation=\"horizontal | vertical\"]\n */\n orientation: Orientation,\n /**\n * Whether the radio group is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the radio group is read only.\n * @selector [data-readonly]\n */\n isReadOnly: boolean,\n /**\n * Whether the radio group is required.\n * @selector [data-required]\n */\n isRequired: boolean,\n /**\n * Whether the radio group is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * State of the radio group.\n */\n state: RadioGroupState\n}\n\nexport interface RadioRenderProps {\n /**\n * Whether the radio is selected.\n * @selector [data-selected]\n */\n isSelected: boolean,\n /**\n * Whether the radio is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean,\n /**\n * Whether the radio is currently in a pressed state.\n * @selector [data-pressed]\n */\n isPressed: boolean,\n /**\n * Whether the radio is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the radio is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the radio is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the radio is read only.\n * @selector [data-readonly]\n */\n isReadOnly: boolean,\n /**\n * Whether the radio is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the checkbox is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport const RadioGroupContext = createContext<ContextValue<RadioGroupProps, HTMLDivElement>>(null);\nexport const RadioContext = createContext<ContextValue<Partial<RadioProps>, HTMLLabelElement>>(null);\nexport const RadioGroupStateContext = createContext<RadioGroupState | null>(null);\n\n/**\n * A radio group allows a user to select a single item from a list of mutually exclusive options.\n */\nexport const RadioGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function RadioGroup(props: RadioGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, RadioGroupContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useRadioGroupState({\n ...props,\n validationBehavior\n });\n\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {radioGroupProps, labelProps, descriptionProps, errorMessageProps, ...validation} = useRadioGroup({\n ...props,\n label,\n validationBehavior\n }, state);\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n orientation: props.orientation || 'vertical',\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly,\n isRequired: state.isRequired,\n isInvalid: state.isInvalid,\n state\n },\n defaultClassName: 'react-aria-RadioGroup'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, radioGroupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-orientation={props.orientation || 'vertical'}\n data-invalid={state.isInvalid || undefined}\n data-disabled={state.isDisabled || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-required={state.isRequired || undefined}>\n <Provider\n values={[\n [RadioGroupStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n <SharedElementTransition>\n {renderProps.children}\n </SharedElementTransition>\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A radio represents an individual option within a radio group.\n */\nexport const Radio = /*#__PURE__*/ (forwardRef as forwardRefType)(function Radio(props: RadioProps, ref: ForwardedRef<HTMLLabelElement>) {\n let {\n inputRef: userProvidedInputRef = null,\n ...otherProps\n } = props;\n [props, ref] = useContextProps(otherProps, ref, RadioContext);\n let state = React.useContext(RadioGroupStateContext)!;\n let inputRef = useObjectRef(useMemo(() => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null), [userProvidedInputRef, props.inputRef]));\n let {labelProps, inputProps, isSelected, isDisabled, isPressed} = useRadio({\n ...removeDataAttributes<RadioProps>(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n }, state, inputRef);\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let interactionDisabled = isDisabled || state.isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: interactionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Radio',\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly: state.isReadOnly,\n isInvalid: state.isInvalid,\n isRequired: state.isRequired\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-invalid={state.isInvalid || undefined}\n data-required={state.isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n <SelectionIndicatorContext.Provider value={{isSelected}}>\n {renderProps.children}\n </SelectionIndicatorContext.Provider>\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"RadioGroup.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AAuPM,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AACvF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAuD;AAC9D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAA0D;AACjE,MAAM,0DAAyB,CAAA,GAAA,oBAAY,EAA0B;AAKrE,MAAM,4CAA2B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,WAC9E,KAAsB,EACtB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,CAAA,GAAA,yCAAU,MAAM,CAAC;IAC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,SAAS,IAAI;QACjC,iBAAe,MAAM,UAAU,IAAI;qBACnC,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/RadioGroup.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 {\n AriaRadioGroupProps,\n AriaRadioProps,\n RadioAria,\n useRadio,\n useRadioGroup\n} from 'react-aria/useRadioGroup';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents, Orientation} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {RadioGroupState, useRadioGroupState} from 'react-stately/useRadioGroupState';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo} from 'react';\nimport {SelectionIndicatorContext} from './SelectionIndicator';\nimport {SharedElementTransition} from './SharedElementTransition';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface RadioGroupProps\n extends\n Omit<\n AriaRadioGroupProps,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<RadioGroupRenderProps>,\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-RadioGroup'\n */\n className?: ClassNameOrFunction<RadioGroupRenderProps>;\n}\nexport interface RadioProps\n extends\n Omit<AriaRadioProps, 'children'>,\n HoverEvents,\n RenderProps<RadioRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Radio'\n */\n className?: ClassNameOrFunction<RadioRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface RadioFieldProps\n extends\n Omit<AriaRadioProps, 'children'>,\n RenderProps<RadioFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-RadioField'\n */\n className?: ClassNameOrFunction<RadioFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface RadioButtonProps\n extends\n HoverEvents,\n RenderProps<RadioButtonRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-RadioButton'\n */\n className?: ClassNameOrFunction<RadioButtonRenderProps>;\n}\n\nexport interface RadioGroupRenderProps {\n /**\n * The orientation of the radio group.\n *\n * @selector [data-orientation=\"horizontal | vertical\"]\n */\n orientation: Orientation;\n /**\n * Whether the radio group is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the radio group is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the radio group is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the radio group is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * State of the radio group.\n */\n state: RadioGroupState;\n}\n\nexport interface RadioRenderProps {\n /**\n * Whether the radio is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the radio is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the radio is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the radio is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the radio is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the radio is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the radio is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the radio is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface RadioFieldRenderProps {\n /**\n * Whether the radio is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the radio is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the radio is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the radio is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the checkbox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface RadioButtonRenderProps extends RadioRenderProps {}\n\nexport const RadioGroupContext = createContext<ContextValue<RadioGroupProps, HTMLDivElement>>(null);\nexport const RadioContext =\n createContext<ContextValue<Partial<RadioProps>, HTMLLabelElement>>(null);\nexport const RadioFieldContext =\n createContext<ContextValue<Partial<RadioFieldProps>, HTMLDivElement>>(null);\nexport const RadioGroupStateContext = createContext<RadioGroupState | null>(null);\n\n/**\n * A radio group allows a user to select a single item from a list of mutually exclusive options.\n */\nexport const RadioGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function RadioGroup(\n props: RadioGroupProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, RadioGroupContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useRadioGroupState({\n ...props,\n validationBehavior\n });\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {radioGroupProps, labelProps, descriptionProps, errorMessageProps, ...validation} =\n useRadioGroup(\n {\n ...props,\n label,\n validationBehavior\n },\n state\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n orientation: props.orientation || 'vertical',\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly,\n isRequired: state.isRequired,\n isInvalid: state.isInvalid,\n state\n },\n defaultClassName: 'react-aria-RadioGroup'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, radioGroupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-orientation={props.orientation || 'vertical'}\n data-invalid={state.isInvalid || undefined}\n data-disabled={state.isDisabled || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-required={state.isRequired || undefined}>\n <Provider\n values={[\n [RadioGroupStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <SharedElementTransition>{renderProps.children}</SharedElementTransition>\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A radio represents an individual option within a radio group.\n *\n * @deprecated Use RadioField + RadioButton instead.\n */\nexport const Radio = /*#__PURE__*/ (forwardRef as forwardRefType)(function Radio(\n props: RadioProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, RadioContext);\n let state = React.useContext(RadioGroupStateContext)!;\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let aria = useRadio(\n {\n ...removeDataAttributes<RadioProps>(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <InternalRadioContext.Provider\n value={{...aria, inputRef, defaultClassName: 'react-aria-Radio'}}>\n <RadioButton {...props} ref={ref} />\n </InternalRadioContext.Provider>\n );\n});\n\ninterface InternalRadioContextValue extends RadioAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n}\n\nconst InternalRadioContext = createContext<InternalRadioContextValue | null>(null);\n\n/**\n * A RadioField represents an individual option within a radio group, containing a RadioButton and\n * optional description.\n */\nexport const RadioField = /*#__PURE__*/ (forwardRef as forwardRefType)(function RadioField(\n props: RadioFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, RadioFieldContext);\n let state = React.useContext(RadioGroupStateContext)!;\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let aria = useRadio(\n {\n ...removeDataAttributes<RadioFieldProps>(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n let {descriptionProps, isSelected, isDisabled} = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-RadioField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly: state.isReadOnly,\n isInvalid: state.isInvalid,\n isRequired: state.isRequired\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-invalid={state.isInvalid || undefined}\n data-required={state.isRequired || undefined}>\n <Provider\n values={[\n [SelectionIndicatorContext, {isSelected}],\n [\n InternalRadioContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-RadioButton'\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps\n }\n }\n ]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A RadioButton is the clickable area of a radio, including the indicator and label.\n */\nexport const RadioButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function RadioButton(\n props: RadioButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {labelProps, inputProps, isSelected, isDisabled, isPressed, defaultClassName, inputRef} =\n useContext(InternalRadioContext)!;\n let state = React.useContext(RadioGroupStateContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let interactionDisabled = isDisabled || state.isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: interactionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly: state.isReadOnly,\n isInvalid: state.isInvalid,\n isRequired: state.isRequired\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={state.isReadOnly || undefined}\n data-invalid={state.isInvalid || undefined}\n data-required={state.isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"RadioGroup.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AA4FM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAkD;AAKzD,MAAM,4CAAc,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,YACxE,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE,CAAA,GAAA,qCAAU,MAAM,CAAC;IACtF,IAAI,qBAAqB,MAAM,kBAAkB,IAAI,0BAA0B;IAC/E,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAoB;IACxC,CAAC,OAAO,SAAoB,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,UA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AG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,uCAAY;gBAAG;aAAiB;YACjC;gBACE,CAAA,GAAA,qCAAU;gBACV;oBACE,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aACD;YACD;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YACxF;gBAAC,CAAA,GAAA,2CAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/SearchField.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 {AriaSearchFieldProps, useSearchField} from 'react-aria/useSearchField';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useRef} from 'react';\nimport {SearchFieldState, useSearchFieldState} from 'react-stately/useSearchFieldState';\nimport {TextContext} from './Text';\n\nexport interface SearchFieldRenderProps {\n /**\n * Whether the search field is empty.\n *\n * @selector [data-empty]\n */\n isEmpty: boolean;\n /**\n * Whether the search field is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the search field is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the search field is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the search field is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the search field.\n */\n state: SearchFieldState;\n}\n\nexport interface SearchFieldProps\n extends\n Omit<\n AriaSearchFieldProps,\n | 'label'\n | 'placeholder'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<SearchFieldRenderProps>,\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-SearchField'\n */\n className?: ClassNameOrFunction<SearchFieldRenderProps>;\n}\n\nexport const SearchFieldContext =\n createContext<ContextValue<SearchFieldProps, HTMLDivElement>>(null);\n\n/**\n * A search field allows a user to enter and clear a search query.\n */\nexport const SearchField = /*#__PURE__*/ createHideableComponent(function SearchField(\n props: SearchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SearchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useRef<HTMLInputElement>(null);\n [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let state = useSearchFieldState({\n ...props,\n validationBehavior\n });\n\n let {\n labelProps,\n inputProps,\n clearButtonProps,\n descriptionProps,\n errorMessageProps,\n ...validation\n } = useSearchField(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n inputRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isEmpty: state.value === '',\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false,\n state\n },\n defaultClassName: 'react-aria-SearchField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-empty={state.value === '' || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}],\n [InputContext, {...inputProps, ref: inputRef}],\n [ButtonContext, clearButtonProps],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [GroupContext, {isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"SearchField.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AA4FM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AAKzD,MAAM,4CAAc,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,YACxE,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,CAAA,GAAA,yCAAU,MAA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,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;qBACnC,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAY;gBAAG;aAAiB;YACjC;gBACE,CAAA,GAAA,yCAAU;gBACV;oBACE,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aACD;YACD;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YACxF;gBAAC,CAAA,GAAA,yCAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/SearchField.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 {AriaSearchFieldProps, useSearchField} from 'react-aria/useSearchField';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useRef} from 'react';\nimport {SearchFieldState, useSearchFieldState} from 'react-stately/useSearchFieldState';\nimport {TextContext} from './Text';\n\nexport interface SearchFieldRenderProps {\n /**\n * Whether the search field is empty.\n *\n * @selector [data-empty]\n */\n isEmpty: boolean;\n /**\n * Whether the search field is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the search field is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the search field is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the search field is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the search field.\n */\n state: SearchFieldState;\n}\n\nexport interface SearchFieldProps\n extends\n Omit<\n AriaSearchFieldProps,\n | 'label'\n | 'placeholder'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<SearchFieldRenderProps>,\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-SearchField'\n */\n className?: ClassNameOrFunction<SearchFieldRenderProps>;\n}\n\nexport const SearchFieldContext =\n createContext<ContextValue<SearchFieldProps, HTMLDivElement>>(null);\n\n/**\n * A search field allows a user to enter and clear a search query.\n */\nexport const SearchField = /*#__PURE__*/ createHideableComponent(function SearchField(\n props: SearchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SearchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useRef<HTMLInputElement>(null);\n [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let state = useSearchFieldState({\n ...props,\n validationBehavior\n });\n\n let {\n labelProps,\n inputProps,\n clearButtonProps,\n descriptionProps,\n errorMessageProps,\n ...validation\n } = useSearchField(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n inputRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isEmpty: state.value === '',\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false,\n state\n },\n defaultClassName: 'react-aria-SearchField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-empty={state.value === '' || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}],\n [InputContext, {...inputProps, ref: inputRef}],\n [ButtonContext, clearButtonProps],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [GroupContext, {isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"SearchField.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AA4FM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AAKzD,MAAM,4CAAc,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AQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,cAAY,MAAM,KAAK,KAAK,MAAM;QAClC,iBAAe,MAAM,UAAU,IAAI;QACnC,gBAAc,WAAW,SAAS,IAAI;QACtC,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;qBACnC,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAY;gBAAG;aAAiB;YACjC;gBACE,CAAA,GAAA,yCAAU;gBACV;oBACE,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aACD;YACD;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YACxF;gBAAC,CAAA,GAAA,yCAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/SearchField.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 {AriaSearchFieldProps, useSearchField} from 'react-aria/useSearchField';\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 {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useRef} from 'react';\nimport {SearchFieldState, useSearchFieldState} from 'react-stately/useSearchFieldState';\nimport {TextContext} from './Text';\n\nexport interface SearchFieldRenderProps {\n /**\n * Whether the search field is empty.\n *\n * @selector [data-empty]\n */\n isEmpty: boolean;\n /**\n * Whether the search field is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the search field is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the search field is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the search field is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the search field.\n */\n state: SearchFieldState;\n}\n\nexport interface SearchFieldProps\n extends\n Omit<\n AriaSearchFieldProps,\n | 'label'\n | 'placeholder'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<SearchFieldRenderProps>,\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-SearchField'\n */\n className?: ClassNameOrFunction<SearchFieldRenderProps>;\n}\n\nexport const SearchFieldContext =\n createContext<ContextValue<SearchFieldProps, HTMLDivElement>>(null);\n\n/**\n * A search field allows a user to enter and clear a search query.\n */\nexport const SearchField = /*#__PURE__*/ createHideableComponent(function SearchField(\n props: SearchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SearchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useRef<HTMLInputElement>(null);\n [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let state = useSearchFieldState({\n ...props,\n validationBehavior\n });\n\n let {\n labelProps,\n inputProps,\n clearButtonProps,\n descriptionProps,\n errorMessageProps,\n ...validation\n } = useSearchField(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n inputRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isEmpty: state.value === '',\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false,\n state\n },\n defaultClassName: 'react-aria-SearchField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-empty={state.value === '' || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}],\n [InputContext, {...inputProps, ref: inputRef}],\n [ButtonContext, clearButtonProps],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [GroupContext, {isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"SearchField.mjs.map"}
|
package/dist/private/Select.cjs
CHANGED
|
@@ -18,7 +18,6 @@ var $75P61$reactstatelyuseSelectState = require("react-stately/useSelectState");
|
|
|
18
18
|
var $75P61$reactariauseFocusRing = require("react-aria/useFocusRing");
|
|
19
19
|
var $75P61$reactariauseListFormatter = require("react-aria/useListFormatter");
|
|
20
20
|
var $75P61$reactariauseLocalizedStringFormatter = require("react-aria/useLocalizedStringFormatter");
|
|
21
|
-
var $75P61$reactariaprivateutilsuseResizeObserver = require("react-aria/private/utils/useResizeObserver");
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
function $parcel$interopDefault(a) {
|
|
@@ -64,10 +63,9 @@ $parcel$export(module.exports, "SelectValue", function () { return $4080fc4198ec
|
|
|
64
63
|
|
|
65
64
|
|
|
66
65
|
|
|
67
|
-
|
|
68
66
|
const $4080fc4198ecec34$export$7540cee5be7dc19b = /*#__PURE__*/ (0, $75P61$react.createContext)(null);
|
|
69
67
|
const $4080fc4198ecec34$export$ef445b55be0601bd = /*#__PURE__*/ (0, $75P61$react.createContext)(null);
|
|
70
|
-
const $4080fc4198ecec34$export$ef9b1a59e592288f = /*#__PURE__*/ (0, $75P61$
|
|
68
|
+
const $4080fc4198ecec34$export$ef9b1a59e592288f = /*#__PURE__*/ (0, $75P61$reactariaprivatecollectionsHidden.createHideableComponent)(function Select(props, ref) {
|
|
71
69
|
[props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $4080fc4198ecec34$export$7540cee5be7dc19b);
|
|
72
70
|
let { children: children, isDisabled: isDisabled = false, isInvalid: isInvalid = false, isRequired: isRequired = false } = props;
|
|
73
71
|
let content = (0, $75P61$react.useMemo)(()=>typeof children === 'function' ? children({
|
|
@@ -118,17 +116,6 @@ function $4080fc4198ecec34$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
118
116
|
label: label,
|
|
119
117
|
validationBehavior: validationBehavior
|
|
120
118
|
}, state, buttonRef);
|
|
121
|
-
// Make menu width match input + button
|
|
122
|
-
let [buttonWidth, setButtonWidth] = (0, $75P61$react.useState)(null);
|
|
123
|
-
let onResize = (0, $75P61$react.useCallback)(()=>{
|
|
124
|
-
if (buttonRef.current) setButtonWidth(buttonRef.current.offsetWidth + 'px');
|
|
125
|
-
}, [
|
|
126
|
-
buttonRef
|
|
127
|
-
]);
|
|
128
|
-
(0, $75P61$reactariaprivateutilsuseResizeObserver.useResizeObserver)({
|
|
129
|
-
ref: buttonRef,
|
|
130
|
-
onResize: onResize
|
|
131
|
-
});
|
|
132
119
|
// Only expose a subset of state to renderProps function to avoid infinite render loop
|
|
133
120
|
let renderPropsState = (0, $75P61$react.useMemo)(()=>({
|
|
134
121
|
isOpen: state.isOpen,
|
|
@@ -197,9 +184,6 @@ function $4080fc4198ecec34$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
197
184
|
triggerRef: buttonRef,
|
|
198
185
|
scrollRef: scrollRef,
|
|
199
186
|
placement: 'bottom start',
|
|
200
|
-
style: {
|
|
201
|
-
'--trigger-width': buttonWidth
|
|
202
|
-
},
|
|
203
187
|
'aria-labelledby': menuProps['aria-labelledby'],
|
|
204
188
|
clearContexts: $4080fc4198ecec34$var$CLEAR_CONTEXTS
|
|
205
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AA0FM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAiE;AACnG,MAAM,0DAAqB,CAAA,GAAA,0BAAY,EAA8C;AAKrF,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,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,oBAAM,EAAE,IACpB,OAAO,aAAa,aAChB,SAAS;YACT,QAAQ;wBAC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M,aAAa,CAAC,EAAE,EAAE,SAAc;YACpD,eAAe,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,KAAK,KAAK,IAAS,OAAO;gBAAC,MAAM,aAAa;aAAC;0BAC5G;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,IAAI;QAAC,KAAK;QAAM,GAAG,QAAQ;QAAG,GAAG,WAAW;QAAE,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEvG,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, 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 {forwardRefType, 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';\n// @ts-ignore\nimport {PopoverContext} from './Popover';\nimport React, {createContext, ForwardedRef, forwardRef, Fragment, HTMLAttributes, ReactNode, useCallback, useContext, useMemo, useRef, useState} 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';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\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 * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>,\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 <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\n {...hiddenSelectProps}\n autoComplete={props.autoComplete} />\n </dom.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>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>\n}\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 <dom.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 </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,0BAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAA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M,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,AAAC,KAAK,KAAK,IAAU,OAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,IAAI;QACP,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,0DAAC,CAAA,GAAA,qCAAU,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.cjs.map"}
|
package/dist/private/Select.js
CHANGED
|
@@ -13,12 +13,11 @@ import {CollectionBuilder as $2OPXg$CollectionBuilder} from "react-aria/Collecti
|
|
|
13
13
|
import {createHideableComponent as $2OPXg$createHideableComponent} from "react-aria/private/collections/Hidden";
|
|
14
14
|
import {filterDOMProps as $2OPXg$filterDOMProps} from "react-aria/filterDOMProps";
|
|
15
15
|
import {mergeProps as $2OPXg$mergeProps} from "react-aria/mergeProps";
|
|
16
|
-
import $2OPXg$react, {createContext as $2OPXg$createContext,
|
|
16
|
+
import $2OPXg$react, {createContext as $2OPXg$createContext, useMemo as $2OPXg$useMemo, useRef as $2OPXg$useRef, useContext as $2OPXg$useContext, Fragment as $2OPXg$Fragment} from "react";
|
|
17
17
|
import {useSelectState as $2OPXg$useSelectState} from "react-stately/useSelectState";
|
|
18
18
|
import {useFocusRing as $2OPXg$useFocusRing} from "react-aria/useFocusRing";
|
|
19
19
|
import {useListFormatter as $2OPXg$useListFormatter} from "react-aria/useListFormatter";
|
|
20
20
|
import {useLocalizedStringFormatter as $2OPXg$useLocalizedStringFormatter} from "react-aria/useLocalizedStringFormatter";
|
|
21
|
-
import {useResizeObserver as $2OPXg$useResizeObserver} from "react-aria/private/utils/useResizeObserver";
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
function $parcel$interopDefault(a) {
|
|
@@ -54,10 +53,9 @@ function $parcel$interopDefault(a) {
|
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
|
|
57
|
-
|
|
58
56
|
const $5ade0166931ef32f$export$7540cee5be7dc19b = /*#__PURE__*/ (0, $2OPXg$createContext)(null);
|
|
59
57
|
const $5ade0166931ef32f$export$ef445b55be0601bd = /*#__PURE__*/ (0, $2OPXg$createContext)(null);
|
|
60
|
-
const $5ade0166931ef32f$export$ef9b1a59e592288f = /*#__PURE__*/ (0, $2OPXg$
|
|
58
|
+
const $5ade0166931ef32f$export$ef9b1a59e592288f = /*#__PURE__*/ (0, $2OPXg$createHideableComponent)(function Select(props, ref) {
|
|
61
59
|
[props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(props, ref, $5ade0166931ef32f$export$7540cee5be7dc19b);
|
|
62
60
|
let { children: children, isDisabled: isDisabled = false, isInvalid: isInvalid = false, isRequired: isRequired = false } = props;
|
|
63
61
|
let content = (0, $2OPXg$useMemo)(()=>typeof children === 'function' ? children({
|
|
@@ -109,17 +107,6 @@ function $5ade0166931ef32f$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
109
107
|
label: label,
|
|
110
108
|
validationBehavior: validationBehavior
|
|
111
109
|
}, state, buttonRef);
|
|
112
|
-
// Make menu width match input + button
|
|
113
|
-
let [buttonWidth, setButtonWidth] = (0, $2OPXg$useState)(null);
|
|
114
|
-
let onResize = (0, $2OPXg$useCallback)(()=>{
|
|
115
|
-
if (buttonRef.current) setButtonWidth(buttonRef.current.offsetWidth + 'px');
|
|
116
|
-
}, [
|
|
117
|
-
buttonRef
|
|
118
|
-
]);
|
|
119
|
-
(0, $2OPXg$useResizeObserver)({
|
|
120
|
-
ref: buttonRef,
|
|
121
|
-
onResize: onResize
|
|
122
|
-
});
|
|
123
110
|
// Only expose a subset of state to renderProps function to avoid infinite render loop
|
|
124
111
|
let renderPropsState = (0, $2OPXg$useMemo)(()=>({
|
|
125
112
|
isOpen: state.isOpen,
|
|
@@ -188,9 +175,6 @@ function $5ade0166931ef32f$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
188
175
|
triggerRef: buttonRef,
|
|
189
176
|
scrollRef: scrollRef,
|
|
190
177
|
placement: 'bottom start',
|
|
191
|
-
style: {
|
|
192
|
-
'--trigger-width': buttonWidth
|
|
193
|
-
},
|
|
194
178
|
'aria-labelledby': menuProps['aria-labelledby'],
|
|
195
179
|
clearContexts: $5ade0166931ef32f$var$CLEAR_CONTEXTS
|
|
196
180
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AA0FM,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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AA,8CAAW,GAAG;QAI7C,MAGD;IALlB,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,CAAA,OAAA,4BAAA,6BAAA,kBAAmB,yBAAnB,kBAAA,OAAkC,gBAAgB,MAAM,CAAC;QAC1E,kBAAkB;QAClB,QAAQ;YACN,cAAc,CAAA,+BAAA,wBAAA,MAAM,aAAa,CAAC,EAAE,cAAtB,4CAAA,sBAAwB,KAAK,cAA7B,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,CAAA,GAAA,yCAAE,EAAE,IAAI;QAAC,KAAK;QAAM,GAAG,QAAQ;QAAG,GAAG,WAAW;QAAE,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEvG,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, 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 {forwardRefType, 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';\n// @ts-ignore\nimport {PopoverContext} from './Popover';\nimport React, {createContext, ForwardedRef, forwardRef, Fragment, HTMLAttributes, ReactNode, useCallback, useContext, useMemo, useRef, useState} 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';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\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 * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>,\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 <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\n {...hiddenSelectProps}\n autoComplete={props.autoComplete} />\n </dom.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>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>\n}\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 <dom.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 </Text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,KAAK,IAAI,KAAK,WAChB,qBAAO,gCAAC,CAAA,GAAA,eAAO;gBAAE,KAAK;eAAQ,QAAQ,CAAC,QAAQ;iBAE/C,OAAO,KAAK,KAAK;QAErB;IACF,GAAG;QAAC;QAAe;QAAW;QAAW;KAAS;IAElD,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;QAI7C,MAGA;IALnB,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,CAAA,OAAA,4BAAA,6BAAA,kBAAmB,yBAAnB,kBAAA,OAAkC,gBAAgB,MAAM,CAAC;QAC1E,kBAAkB;QAClB,QAAQ;YACN,cAAc,CAAC,+BAAA,wBAAA,MAAM,aAAa,CAAC,EAAE,cAAtB,4CAAA,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"}
|
package/dist/private/Select.mjs
CHANGED
|
@@ -13,12 +13,11 @@ import {CollectionBuilder as $2l4Cq$CollectionBuilder} from "react-aria/Collecti
|
|
|
13
13
|
import {createHideableComponent as $2l4Cq$createHideableComponent} from "react-aria/private/collections/Hidden";
|
|
14
14
|
import {filterDOMProps as $2l4Cq$filterDOMProps} from "react-aria/filterDOMProps";
|
|
15
15
|
import {mergeProps as $2l4Cq$mergeProps} from "react-aria/mergeProps";
|
|
16
|
-
import $2l4Cq$react, {createContext as $2l4Cq$createContext,
|
|
16
|
+
import $2l4Cq$react, {createContext as $2l4Cq$createContext, useMemo as $2l4Cq$useMemo, useRef as $2l4Cq$useRef, useContext as $2l4Cq$useContext, Fragment as $2l4Cq$Fragment} from "react";
|
|
17
17
|
import {useSelectState as $2l4Cq$useSelectState} from "react-stately/useSelectState";
|
|
18
18
|
import {useFocusRing as $2l4Cq$useFocusRing} from "react-aria/useFocusRing";
|
|
19
19
|
import {useListFormatter as $2l4Cq$useListFormatter} from "react-aria/useListFormatter";
|
|
20
20
|
import {useLocalizedStringFormatter as $2l4Cq$useLocalizedStringFormatter} from "react-aria/useLocalizedStringFormatter";
|
|
21
|
-
import {useResizeObserver as $2l4Cq$useResizeObserver} from "react-aria/private/utils/useResizeObserver";
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
function $parcel$interopDefault(a) {
|
|
@@ -54,10 +53,9 @@ function $parcel$interopDefault(a) {
|
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
|
|
57
|
-
|
|
58
56
|
const $c8bb816105474884$export$7540cee5be7dc19b = /*#__PURE__*/ (0, $2l4Cq$createContext)(null);
|
|
59
57
|
const $c8bb816105474884$export$ef445b55be0601bd = /*#__PURE__*/ (0, $2l4Cq$createContext)(null);
|
|
60
|
-
const $c8bb816105474884$export$ef9b1a59e592288f = /*#__PURE__*/ (0, $2l4Cq$
|
|
58
|
+
const $c8bb816105474884$export$ef9b1a59e592288f = /*#__PURE__*/ (0, $2l4Cq$createHideableComponent)(function Select(props, ref) {
|
|
61
59
|
[props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(props, ref, $c8bb816105474884$export$7540cee5be7dc19b);
|
|
62
60
|
let { children: children, isDisabled: isDisabled = false, isInvalid: isInvalid = false, isRequired: isRequired = false } = props;
|
|
63
61
|
let content = (0, $2l4Cq$useMemo)(()=>typeof children === 'function' ? children({
|
|
@@ -108,17 +106,6 @@ function $c8bb816105474884$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
108
106
|
label: label,
|
|
109
107
|
validationBehavior: validationBehavior
|
|
110
108
|
}, state, buttonRef);
|
|
111
|
-
// Make menu width match input + button
|
|
112
|
-
let [buttonWidth, setButtonWidth] = (0, $2l4Cq$useState)(null);
|
|
113
|
-
let onResize = (0, $2l4Cq$useCallback)(()=>{
|
|
114
|
-
if (buttonRef.current) setButtonWidth(buttonRef.current.offsetWidth + 'px');
|
|
115
|
-
}, [
|
|
116
|
-
buttonRef
|
|
117
|
-
]);
|
|
118
|
-
(0, $2l4Cq$useResizeObserver)({
|
|
119
|
-
ref: buttonRef,
|
|
120
|
-
onResize: onResize
|
|
121
|
-
});
|
|
122
109
|
// Only expose a subset of state to renderProps function to avoid infinite render loop
|
|
123
110
|
let renderPropsState = (0, $2l4Cq$useMemo)(()=>({
|
|
124
111
|
isOpen: state.isOpen,
|
|
@@ -187,9 +174,6 @@ function $c8bb816105474884$var$SelectInner({ props: props, selectRef: ref, colle
|
|
|
187
174
|
triggerRef: buttonRef,
|
|
188
175
|
scrollRef: scrollRef,
|
|
189
176
|
placement: 'bottom start',
|
|
190
|
-
style: {
|
|
191
|
-
'--trigger-width': buttonWidth
|
|
192
|
-
},
|
|
193
177
|
'aria-labelledby': menuProps['aria-labelledby'],
|
|
194
178
|
clearContexts: $c8bb816105474884$var$CLEAR_CONTEXTS
|
|
195
179
|
}
|