react-aria-components 1.5.0 → 1.7.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/README.md +1 -1
- package/dist/Autocomplete.main.js +91 -0
- package/dist/Autocomplete.main.js.map +1 -0
- package/dist/Autocomplete.mjs +79 -0
- package/dist/Autocomplete.module.js +79 -0
- package/dist/Autocomplete.module.js.map +1 -0
- package/dist/Breadcrumbs.main.js +2 -5
- package/dist/Breadcrumbs.main.js.map +1 -1
- package/dist/Breadcrumbs.mjs +3 -6
- package/dist/Breadcrumbs.module.js +3 -6
- package/dist/Breadcrumbs.module.js.map +1 -1
- package/dist/Button.main.js +5 -5
- package/dist/Button.main.js.map +1 -1
- package/dist/Button.mjs +5 -5
- package/dist/Button.module.js +5 -5
- package/dist/Button.module.js.map +1 -1
- package/dist/Calendar.main.js +29 -28
- package/dist/Calendar.main.js.map +1 -1
- package/dist/Calendar.mjs +30 -29
- package/dist/Calendar.module.js +30 -29
- package/dist/Calendar.module.js.map +1 -1
- package/dist/Checkbox.main.js +6 -13
- package/dist/Checkbox.main.js.map +1 -1
- package/dist/Checkbox.mjs +7 -14
- package/dist/Checkbox.module.js +7 -14
- package/dist/Checkbox.module.js.map +1 -1
- package/dist/Collection.main.js.map +1 -1
- package/dist/Collection.module.js.map +1 -1
- package/dist/ColorArea.main.js +6 -9
- package/dist/ColorArea.main.js.map +1 -1
- package/dist/ColorArea.mjs +5 -8
- package/dist/ColorArea.module.js +5 -8
- package/dist/ColorArea.module.js.map +1 -1
- package/dist/ColorField.main.js +10 -15
- package/dist/ColorField.main.js.map +1 -1
- package/dist/ColorField.mjs +6 -11
- package/dist/ColorField.module.js +6 -11
- package/dist/ColorField.module.js.map +1 -1
- package/dist/ColorPicker.main.js +2 -2
- package/dist/ColorPicker.main.js.map +1 -1
- package/dist/ColorPicker.mjs +1 -1
- package/dist/ColorPicker.module.js +1 -1
- package/dist/ColorPicker.module.js.map +1 -1
- package/dist/ColorSlider.main.js +7 -12
- package/dist/ColorSlider.main.js.map +1 -1
- package/dist/ColorSlider.mjs +5 -10
- package/dist/ColorSlider.module.js +5 -10
- package/dist/ColorSlider.module.js.map +1 -1
- package/dist/ColorSwatch.main.js +4 -7
- package/dist/ColorSwatch.main.js.map +1 -1
- package/dist/ColorSwatch.mjs +3 -6
- package/dist/ColorSwatch.module.js +3 -6
- package/dist/ColorSwatch.module.js.map +1 -1
- package/dist/ColorSwatchPicker.main.js +7 -11
- package/dist/ColorSwatchPicker.main.js.map +1 -1
- package/dist/ColorSwatchPicker.mjs +6 -10
- package/dist/ColorSwatchPicker.module.js +6 -10
- package/dist/ColorSwatchPicker.module.js.map +1 -1
- package/dist/ColorThumb.main.js +4 -11
- package/dist/ColorThumb.main.js.map +1 -1
- package/dist/ColorThumb.mjs +4 -11
- package/dist/ColorThumb.module.js +4 -11
- package/dist/ColorThumb.module.js.map +1 -1
- package/dist/ColorWheel.main.js +9 -15
- package/dist/ColorWheel.main.js.map +1 -1
- package/dist/ColorWheel.mjs +8 -14
- package/dist/ColorWheel.module.js +8 -14
- package/dist/ColorWheel.module.js.map +1 -1
- package/dist/ComboBox.main.js +3 -6
- package/dist/ComboBox.main.js.map +1 -1
- package/dist/ComboBox.mjs +4 -7
- package/dist/ComboBox.module.js +4 -7
- package/dist/ComboBox.module.js.map +1 -1
- package/dist/DateField.main.js +12 -26
- package/dist/DateField.main.js.map +1 -1
- package/dist/DateField.mjs +13 -27
- package/dist/DateField.module.js +13 -27
- package/dist/DateField.module.js.map +1 -1
- package/dist/DatePicker.main.js +6 -13
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +7 -14
- package/dist/DatePicker.module.js +7 -14
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/Dialog.main.js +4 -6
- package/dist/Dialog.main.js.map +1 -1
- package/dist/Dialog.mjs +5 -7
- package/dist/Dialog.module.js +5 -7
- package/dist/Dialog.module.js.map +1 -1
- package/dist/Disclosure.main.js +11 -23
- package/dist/Disclosure.main.js.map +1 -1
- package/dist/Disclosure.mjs +8 -20
- package/dist/Disclosure.module.js +8 -20
- package/dist/Disclosure.module.js.map +1 -1
- package/dist/DragAndDrop.main.js +2 -5
- package/dist/DragAndDrop.main.js.map +1 -1
- package/dist/DragAndDrop.mjs +3 -6
- package/dist/DragAndDrop.module.js +3 -6
- package/dist/DragAndDrop.module.js.map +1 -1
- package/dist/DropZone.main.js +3 -8
- package/dist/DropZone.main.js.map +1 -1
- package/dist/DropZone.mjs +4 -9
- package/dist/DropZone.module.js +4 -9
- package/dist/DropZone.module.js.map +1 -1
- package/dist/FieldError.main.js +2 -5
- package/dist/FieldError.main.js.map +1 -1
- package/dist/FieldError.mjs +3 -6
- package/dist/FieldError.module.js +3 -6
- package/dist/FieldError.module.js.map +1 -1
- package/dist/FileTrigger.main.js +2 -5
- package/dist/FileTrigger.main.js.map +1 -1
- package/dist/FileTrigger.mjs +2 -5
- package/dist/FileTrigger.module.js +2 -5
- package/dist/FileTrigger.module.js.map +1 -1
- package/dist/Form.main.js +2 -6
- package/dist/Form.main.js.map +1 -1
- package/dist/Form.mjs +2 -6
- package/dist/Form.module.js +2 -6
- package/dist/Form.module.js.map +1 -1
- package/dist/GridList.main.js +2 -6
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +3 -7
- package/dist/GridList.module.js +3 -7
- package/dist/GridList.module.js.map +1 -1
- package/dist/Group.main.js +2 -5
- package/dist/Group.main.js.map +1 -1
- package/dist/Group.mjs +2 -5
- package/dist/Group.module.js +2 -5
- package/dist/Group.module.js.map +1 -1
- package/dist/Heading.main.js +2 -3
- package/dist/Heading.main.js.map +1 -1
- package/dist/Heading.mjs +2 -3
- package/dist/Heading.module.js +2 -3
- package/dist/Heading.module.js.map +1 -1
- package/dist/Input.main.js +2 -5
- package/dist/Input.main.js.map +1 -1
- package/dist/Input.mjs +2 -5
- package/dist/Input.module.js +2 -5
- package/dist/Input.module.js.map +1 -1
- package/dist/Keyboard.main.js +2 -3
- package/dist/Keyboard.main.js.map +1 -1
- package/dist/Keyboard.mjs +2 -3
- package/dist/Keyboard.module.js +2 -3
- package/dist/Keyboard.module.js.map +1 -1
- package/dist/Label.main.js +2 -3
- package/dist/Label.main.js.map +1 -1
- package/dist/Label.mjs +2 -3
- package/dist/Label.module.js +2 -3
- package/dist/Label.module.js.map +1 -1
- package/dist/Link.main.js +2 -6
- package/dist/Link.main.js.map +1 -1
- package/dist/Link.mjs +2 -6
- package/dist/Link.module.js +2 -6
- package/dist/Link.module.js.map +1 -1
- package/dist/ListBox.main.js +23 -11
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +27 -15
- package/dist/ListBox.module.js +27 -15
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Menu.main.js +56 -33
- package/dist/Menu.main.js.map +1 -1
- package/dist/Menu.mjs +58 -35
- package/dist/Menu.module.js +58 -35
- package/dist/Menu.module.js.map +1 -1
- package/dist/Meter.main.js +3 -6
- package/dist/Meter.main.js.map +1 -1
- package/dist/Meter.mjs +3 -6
- package/dist/Meter.module.js +3 -6
- package/dist/Meter.module.js.map +1 -1
- package/dist/Modal.main.js +7 -10
- package/dist/Modal.main.js.map +1 -1
- package/dist/Modal.mjs +10 -13
- package/dist/Modal.module.js +10 -13
- package/dist/Modal.module.js.map +1 -1
- package/dist/NumberField.main.js +6 -7
- package/dist/NumberField.main.js.map +1 -1
- package/dist/NumberField.mjs +7 -8
- package/dist/NumberField.module.js +7 -8
- package/dist/NumberField.module.js.map +1 -1
- package/dist/OverlayArrow.main.js +2 -6
- package/dist/OverlayArrow.main.js.map +1 -1
- package/dist/OverlayArrow.mjs +2 -6
- package/dist/OverlayArrow.module.js +2 -6
- package/dist/OverlayArrow.module.js.map +1 -1
- package/dist/Popover.main.js +71 -22
- package/dist/Popover.main.js.map +1 -1
- package/dist/Popover.mjs +75 -26
- package/dist/Popover.module.js +75 -26
- package/dist/Popover.module.js.map +1 -1
- package/dist/ProgressBar.main.js +3 -7
- package/dist/ProgressBar.main.js.map +1 -1
- package/dist/ProgressBar.mjs +3 -7
- package/dist/ProgressBar.module.js +3 -7
- package/dist/ProgressBar.module.js.map +1 -1
- package/dist/RadioGroup.main.js +5 -11
- package/dist/RadioGroup.main.js.map +1 -1
- package/dist/RadioGroup.mjs +5 -11
- package/dist/RadioGroup.module.js +5 -11
- package/dist/RadioGroup.module.js.map +1 -1
- package/dist/SearchField.main.js +9 -9
- package/dist/SearchField.main.js.map +1 -1
- package/dist/SearchField.mjs +11 -11
- package/dist/SearchField.module.js +11 -11
- package/dist/SearchField.module.js.map +1 -1
- package/dist/Select.main.js +9 -14
- package/dist/Select.main.js.map +1 -1
- package/dist/Select.mjs +10 -15
- package/dist/Select.module.js +10 -15
- package/dist/Select.module.js.map +1 -1
- package/dist/Slider.main.js +10 -22
- package/dist/Slider.main.js.map +1 -1
- package/dist/Slider.mjs +11 -23
- package/dist/Slider.module.js +11 -23
- package/dist/Slider.module.js.map +1 -1
- package/dist/Switch.main.js +2 -5
- package/dist/Switch.main.js.map +1 -1
- package/dist/Switch.mjs +2 -5
- package/dist/Switch.module.js +2 -5
- package/dist/Switch.module.js.map +1 -1
- package/dist/Table.main.js +21 -18
- package/dist/Table.main.js.map +1 -1
- package/dist/Table.mjs +22 -19
- package/dist/Table.module.js +22 -19
- package/dist/Table.module.js.map +1 -1
- package/dist/TableLayout.main.js.map +1 -1
- package/dist/TableLayout.module.js.map +1 -1
- package/dist/Tabs.main.js +12 -19
- package/dist/Tabs.main.js.map +1 -1
- package/dist/Tabs.mjs +15 -22
- package/dist/Tabs.module.js +15 -22
- package/dist/Tabs.module.js.map +1 -1
- package/dist/TagGroup.main.js +5 -11
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +6 -12
- package/dist/TagGroup.module.js +6 -12
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/Text.main.js +2 -3
- package/dist/Text.main.js.map +1 -1
- package/dist/Text.mjs +2 -3
- package/dist/Text.module.js +2 -3
- package/dist/Text.module.js.map +1 -1
- package/dist/TextArea.main.js +2 -5
- package/dist/TextArea.main.js.map +1 -1
- package/dist/TextArea.mjs +2 -5
- package/dist/TextArea.module.js +2 -5
- package/dist/TextArea.module.js.map +1 -1
- package/dist/TextField.main.js +12 -10
- package/dist/TextField.main.js.map +1 -1
- package/dist/TextField.mjs +14 -12
- package/dist/TextField.module.js +14 -12
- package/dist/TextField.module.js.map +1 -1
- package/dist/Toast.main.js +148 -0
- package/dist/Toast.main.js.map +1 -0
- package/dist/Toast.mjs +137 -0
- package/dist/Toast.module.js +137 -0
- package/dist/Toast.module.js.map +1 -0
- package/dist/ToggleButton.main.js +2 -5
- package/dist/ToggleButton.main.js.map +1 -1
- package/dist/ToggleButton.mjs +3 -6
- package/dist/ToggleButton.module.js +3 -6
- package/dist/ToggleButton.module.js.map +1 -1
- package/dist/ToggleButtonGroup.main.js +2 -5
- package/dist/ToggleButtonGroup.main.js.map +1 -1
- package/dist/ToggleButtonGroup.mjs +2 -5
- package/dist/ToggleButtonGroup.module.js +2 -5
- package/dist/ToggleButtonGroup.module.js.map +1 -1
- package/dist/Toolbar.main.js +2 -6
- package/dist/Toolbar.main.js.map +1 -1
- package/dist/Toolbar.mjs +2 -6
- package/dist/Toolbar.module.js +2 -6
- package/dist/Toolbar.module.js.map +1 -1
- package/dist/Tooltip.main.js +4 -7
- package/dist/Tooltip.main.js.map +1 -1
- package/dist/Tooltip.mjs +7 -10
- package/dist/Tooltip.module.js +7 -10
- package/dist/Tooltip.module.js.map +1 -1
- package/dist/Tree.main.js +39 -39
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +36 -36
- package/dist/Tree.module.js +36 -36
- package/dist/Tree.module.js.map +1 -1
- package/dist/Virtualizer.main.js +4 -1
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +4 -1
- package/dist/Virtualizer.module.js +4 -1
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/import.mjs +10 -6
- package/dist/main.js +34 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +10 -6
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +369 -259
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.main.js +9 -68
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +10 -67
- package/dist/utils.module.js +10 -67
- package/dist/utils.module.js.map +1 -1
- package/i18n/ar-AE.js +1 -1
- package/i18n/ar-AE.mjs +1 -1
- package/i18n/bg-BG.js +1 -1
- package/i18n/bg-BG.mjs +1 -1
- package/i18n/cs-CZ.js +1 -1
- package/i18n/cs-CZ.mjs +1 -1
- package/i18n/da-DK.js +1 -1
- package/i18n/da-DK.mjs +1 -1
- package/i18n/de-DE.js +1 -1
- package/i18n/de-DE.mjs +1 -1
- package/i18n/el-GR.js +1 -1
- package/i18n/el-GR.mjs +1 -1
- package/i18n/en-US.js +1 -1
- package/i18n/en-US.mjs +1 -1
- package/i18n/es-ES.js +1 -1
- package/i18n/es-ES.mjs +1 -1
- package/i18n/et-EE.js +1 -1
- package/i18n/et-EE.mjs +1 -1
- package/i18n/fi-FI.js +1 -1
- package/i18n/fi-FI.mjs +1 -1
- package/i18n/fr-FR.js +1 -1
- package/i18n/fr-FR.mjs +1 -1
- package/i18n/he-IL.js +1 -1
- package/i18n/he-IL.mjs +1 -1
- package/i18n/hr-HR.js +1 -1
- package/i18n/hr-HR.mjs +1 -1
- package/i18n/hu-HU.js +1 -1
- package/i18n/hu-HU.mjs +1 -1
- package/i18n/index.js +1 -1
- package/i18n/index.mjs +1 -1
- package/i18n/it-IT.js +1 -1
- package/i18n/it-IT.mjs +1 -1
- package/i18n/ja-JP.js +1 -1
- package/i18n/ja-JP.mjs +1 -1
- package/i18n/ko-KR.js +1 -1
- package/i18n/ko-KR.mjs +1 -1
- package/i18n/lt-LT.js +1 -1
- package/i18n/lt-LT.mjs +1 -1
- package/i18n/lv-LV.js +1 -1
- package/i18n/lv-LV.mjs +1 -1
- package/i18n/nb-NO.js +1 -1
- package/i18n/nb-NO.mjs +1 -1
- package/i18n/nl-NL.js +1 -1
- package/i18n/nl-NL.mjs +1 -1
- package/i18n/pl-PL.js +1 -1
- package/i18n/pl-PL.mjs +1 -1
- package/i18n/pt-BR.js +1 -1
- package/i18n/pt-BR.mjs +1 -1
- package/i18n/pt-PT.js +1 -1
- package/i18n/pt-PT.mjs +1 -1
- package/i18n/ro-RO.js +1 -1
- package/i18n/ro-RO.mjs +1 -1
- package/i18n/ru-RU.js +1 -1
- package/i18n/ru-RU.mjs +1 -1
- package/i18n/sk-SK.js +1 -1
- package/i18n/sk-SK.mjs +1 -1
- package/i18n/sl-SI.js +1 -1
- package/i18n/sl-SI.mjs +1 -1
- package/i18n/sr-SP.js +1 -1
- package/i18n/sr-SP.mjs +1 -1
- package/i18n/sv-SE.js +1 -1
- package/i18n/sv-SE.mjs +1 -1
- package/i18n/tr-TR.js +1 -1
- package/i18n/tr-TR.mjs +1 -1
- package/i18n/uk-UA.js +1 -1
- package/i18n/uk-UA.mjs +1 -1
- package/i18n/zh-CN.js +1 -1
- package/i18n/zh-CN.mjs +1 -1
- package/i18n/zh-TW.js +1 -1
- package/i18n/zh-TW.mjs +1 -1
- package/package.json +26 -29
- package/src/Autocomplete.tsx +75 -0
- package/src/Breadcrumbs.tsx +5 -8
- package/src/Button.tsx +8 -8
- package/src/Calendar.tsx +35 -39
- package/src/Checkbox.tsx +14 -18
- package/src/Collection.tsx +2 -2
- package/src/ColorArea.tsx +7 -11
- package/src/ColorField.tsx +13 -14
- package/src/ColorPicker.tsx +1 -2
- package/src/ColorSlider.tsx +10 -13
- package/src/ColorSwatch.tsx +7 -10
- package/src/ColorSwatchPicker.tsx +8 -14
- package/src/ColorThumb.tsx +7 -12
- package/src/ColorWheel.tsx +12 -18
- package/src/ComboBox.tsx +8 -9
- package/src/DateField.tsx +29 -36
- package/src/DatePicker.tsx +15 -17
- package/src/Dialog.tsx +11 -10
- package/src/Disclosure.tsx +18 -28
- package/src/DragAndDrop.tsx +5 -8
- package/src/DropZone.tsx +6 -10
- package/src/FieldError.tsx +5 -8
- package/src/FileTrigger.tsx +5 -8
- package/src/Form.tsx +6 -9
- package/src/GridList.tsx +11 -9
- package/src/Group.tsx +6 -8
- package/src/Heading.tsx +2 -5
- package/src/Input.tsx +5 -8
- package/src/Keyboard.tsx +2 -5
- package/src/Label.tsx +2 -5
- package/src/Link.tsx +6 -9
- package/src/ListBox.tsx +19 -16
- package/src/Menu.tsx +71 -42
- package/src/Meter.tsx +8 -9
- package/src/Modal.tsx +7 -10
- package/src/NumberField.tsx +16 -10
- package/src/OverlayArrow.tsx +6 -9
- package/src/Popover.tsx +84 -35
- package/src/ProgressBar.tsx +9 -10
- package/src/RadioGroup.tsx +13 -17
- package/src/SearchField.tsx +14 -14
- package/src/Select.tsx +17 -19
- package/src/Slider.tsx +26 -34
- package/src/Switch.tsx +5 -8
- package/src/Table.tsx +45 -34
- package/src/TableLayout.ts +1 -1
- package/src/Tabs.tsx +24 -28
- package/src/TagGroup.tsx +11 -15
- package/src/Text.tsx +2 -5
- package/src/TextArea.tsx +5 -7
- package/src/TextField.tsx +16 -16
- package/src/Toast.tsx +184 -0
- package/src/ToggleButton.tsx +5 -8
- package/src/ToggleButtonGroup.tsx +5 -8
- package/src/Toolbar.tsx +6 -9
- package/src/Tooltip.tsx +7 -10
- package/src/Tree.tsx +72 -57
- package/src/Virtualizer.tsx +18 -3
- package/src/index.ts +17 -15
- package/src/utils.tsx +8 -81
package/src/GridList.tsx
CHANGED
|
@@ -57,6 +57,11 @@ export interface GridListRenderProps {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export interface GridListProps<T> extends Omit<AriaGridListProps<T>, 'children'>, CollectionProps<T>, StyleRenderProps<GridListRenderProps>, SlotProps, ScrollableProps<HTMLDivElement> {
|
|
60
|
+
/**
|
|
61
|
+
* Whether typeahead navigation is disabled.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
disallowTypeAhead?: boolean,
|
|
60
65
|
/** How multiple selection should behave in the collection. */
|
|
61
66
|
selectionBehavior?: SelectionBehavior,
|
|
62
67
|
/** The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the GridList. */
|
|
@@ -73,7 +78,11 @@ export interface GridListProps<T> extends Omit<AriaGridListProps<T>, 'children'>
|
|
|
73
78
|
|
|
74
79
|
export const GridListContext = createContext<ContextValue<GridListProps<any>, HTMLDivElement>>(null);
|
|
75
80
|
|
|
76
|
-
|
|
81
|
+
/**
|
|
82
|
+
* A grid list displays a list of interactive items, with support for keyboard navigation,
|
|
83
|
+
* single or multiple selection, and row actions.
|
|
84
|
+
*/
|
|
85
|
+
export const GridList = /*#__PURE__*/ (forwardRef as forwardRefType)(function GridList<T extends object>(props: GridListProps<T>, ref: ForwardedRef<HTMLDivElement>) {
|
|
77
86
|
// Render the portal first so that we have the collection by the time we render the DOM in SSR.
|
|
78
87
|
[props, ref] = useContextProps(props, ref, GridListContext);
|
|
79
88
|
|
|
@@ -82,7 +91,7 @@ function GridList<T extends object>(props: GridListProps<T>, ref: ForwardedRef<H
|
|
|
82
91
|
{collection => <GridListInner props={props} collection={collection} gridListRef={ref} />}
|
|
83
92
|
</CollectionBuilder>
|
|
84
93
|
);
|
|
85
|
-
}
|
|
94
|
+
});
|
|
86
95
|
|
|
87
96
|
interface GridListInnerProps<T extends object> {
|
|
88
97
|
props: GridListProps<T>,
|
|
@@ -243,13 +252,6 @@ function GridListInner<T extends object>({props, collection, gridListRef: ref}:
|
|
|
243
252
|
);
|
|
244
253
|
}
|
|
245
254
|
|
|
246
|
-
/**
|
|
247
|
-
* A grid list displays a list of interactive items, with support for keyboard navigation,
|
|
248
|
-
* single or multiple selection, and row actions.
|
|
249
|
-
*/
|
|
250
|
-
const _GridList = /*#__PURE__*/ (forwardRef as forwardRefType)(GridList);
|
|
251
|
-
export {_GridList as GridList};
|
|
252
|
-
|
|
253
255
|
export interface GridListItemRenderProps extends ItemRenderProps {}
|
|
254
256
|
|
|
255
257
|
export interface GridListItemProps<T = object> extends RenderProps<GridListItemRenderProps>, LinkDOMProps, HoverEvents {
|
package/src/Group.tsx
CHANGED
|
@@ -60,7 +60,10 @@ export interface GroupProps extends AriaLabelingProps, Omit<HTMLAttributes<HTMLE
|
|
|
60
60
|
|
|
61
61
|
export const GroupContext = createContext<ContextValue<GroupProps, HTMLDivElement>>({});
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* A group represents a set of related UI controls, and supports interactive states for styling.
|
|
65
|
+
*/
|
|
66
|
+
export const Group = /*#__PURE__*/ (forwardRef as forwardRefType)(function Group(props: GroupProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
64
67
|
[props, ref] = useContextProps(props, ref, GroupContext);
|
|
65
68
|
let {isDisabled, isInvalid, onHoverStart, onHoverChange, onHoverEnd, ...otherProps} = props;
|
|
66
69
|
|
|
@@ -71,6 +74,7 @@ function Group(props: GroupProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
71
74
|
|
|
72
75
|
isDisabled ??= !!props['aria-disabled'] && props['aria-disabled'] !== 'false';
|
|
73
76
|
isInvalid ??= !!props['aria-invalid'] && props['aria-invalid'] !== 'false';
|
|
77
|
+
|
|
74
78
|
let renderProps = useRenderProps({
|
|
75
79
|
...props,
|
|
76
80
|
values: {isHovered, isFocusWithin: isFocused, isFocusVisible, isDisabled, isInvalid},
|
|
@@ -92,10 +96,4 @@ function Group(props: GroupProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
92
96
|
{renderProps.children}
|
|
93
97
|
</div>
|
|
94
98
|
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* A group represents a set of related UI controls, and supports interactive states for styling.
|
|
99
|
-
*/
|
|
100
|
-
const _Group = /*#__PURE__*/ (forwardRef as forwardRefType)(Group);
|
|
101
|
-
export {_Group as Group};
|
|
99
|
+
});
|
package/src/Heading.tsx
CHANGED
|
@@ -18,7 +18,7 @@ export interface HeadingProps extends HTMLAttributes<HTMLElement> {
|
|
|
18
18
|
level?: number
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function Heading(props: HeadingProps, ref: ForwardedRef<HTMLHeadingElement>) {
|
|
21
|
+
export const Heading = forwardRef(function Heading(props: HeadingProps, ref: ForwardedRef<HTMLHeadingElement>) {
|
|
22
22
|
[props, ref] = useContextProps(props, ref, HeadingContext);
|
|
23
23
|
let {children, level = 3, className, ...domProps} = props;
|
|
24
24
|
let Element = `h${level}` as ElementType;
|
|
@@ -28,7 +28,4 @@ function Heading(props: HeadingProps, ref: ForwardedRef<HTMLHeadingElement>) {
|
|
|
28
28
|
{children}
|
|
29
29
|
</Element>
|
|
30
30
|
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const _Heading = forwardRef(Heading);
|
|
34
|
-
export {_Heading as Heading};
|
|
31
|
+
});
|
package/src/Input.tsx
CHANGED
|
@@ -53,7 +53,10 @@ let filterHoverProps = (props: InputProps) => {
|
|
|
53
53
|
return otherProps;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* An input allows a user to input text.
|
|
58
|
+
*/
|
|
59
|
+
export const Input = /*#__PURE__*/ createHideableComponent(function Input(props: InputProps, ref: ForwardedRef<HTMLInputElement>) {
|
|
57
60
|
[props, ref] = useContextProps(props, ref, InputContext);
|
|
58
61
|
|
|
59
62
|
let {hoverProps, isHovered} = useHover(props);
|
|
@@ -86,10 +89,4 @@ function Input(props: InputProps, ref: ForwardedRef<HTMLInputElement>) {
|
|
|
86
89
|
data-focus-visible={isFocusVisible || undefined}
|
|
87
90
|
data-invalid={isInvalid || undefined} />
|
|
88
91
|
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* An input allows a user to input text.
|
|
93
|
-
*/
|
|
94
|
-
const _Input = /*#__PURE__*/ createHideableComponent(Input);
|
|
95
|
-
export {_Input as Input};
|
|
92
|
+
});
|
package/src/Keyboard.tsx
CHANGED
|
@@ -15,10 +15,7 @@ import React, {createContext, ForwardedRef, forwardRef, HTMLAttributes} from 're
|
|
|
15
15
|
|
|
16
16
|
export const KeyboardContext = createContext<ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>>({});
|
|
17
17
|
|
|
18
|
-
function Keyboard(props: HTMLAttributes<HTMLElement>, ref: ForwardedRef<HTMLElement>) {
|
|
18
|
+
export const Keyboard = forwardRef(function Keyboard(props: HTMLAttributes<HTMLElement>, ref: ForwardedRef<HTMLElement>) {
|
|
19
19
|
[props, ref] = useContextProps(props, ref, KeyboardContext);
|
|
20
20
|
return <kbd dir="ltr" {...props} ref={ref} />;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const _Keyboard = forwardRef(Keyboard);
|
|
24
|
-
export {_Keyboard as Keyboard};
|
|
21
|
+
});
|
package/src/Label.tsx
CHANGED
|
@@ -20,12 +20,9 @@ export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
|
20
20
|
|
|
21
21
|
export const LabelContext = createContext<ContextValue<LabelProps, HTMLLabelElement>>({});
|
|
22
22
|
|
|
23
|
-
function Label(props: LabelProps, ref: ForwardedRef<HTMLLabelElement>) {
|
|
23
|
+
export const Label = /*#__PURE__*/ createHideableComponent(function Label(props: LabelProps, ref: ForwardedRef<HTMLLabelElement>) {
|
|
24
24
|
[props, ref] = useContextProps(props, ref, LabelContext);
|
|
25
25
|
let {elementType: ElementType = 'label', ...labelProps} = props;
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
return <ElementType className="react-aria-Label" {...labelProps} ref={ref} />;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const _Label = /*#__PURE__*/ createHideableComponent(Label);
|
|
31
|
-
export {_Label as Label};
|
|
28
|
+
});
|
package/src/Link.tsx
CHANGED
|
@@ -52,7 +52,11 @@ export interface LinkRenderProps {
|
|
|
52
52
|
|
|
53
53
|
export const LinkContext = createContext<ContextValue<LinkProps, HTMLAnchorElement>>(null);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* A link allows a user to navigate to another page or resource within a web page
|
|
57
|
+
* or application.
|
|
58
|
+
*/
|
|
59
|
+
export const Link = /*#__PURE__*/ (forwardRef as forwardRefType)(function Link(props: LinkProps, ref: ForwardedRef<HTMLAnchorElement>) {
|
|
56
60
|
[props, ref] = useContextProps(props, ref, LinkContext);
|
|
57
61
|
|
|
58
62
|
let ElementType: ElementType = props.href && !props.isDisabled ? 'a' : 'span';
|
|
@@ -88,11 +92,4 @@ function Link(props: LinkProps, ref: ForwardedRef<HTMLAnchorElement>) {
|
|
|
88
92
|
{renderProps.children}
|
|
89
93
|
</ElementType>
|
|
90
94
|
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* A link allows a user to navigate to another page or resource within a web page
|
|
95
|
-
* or application.
|
|
96
|
-
*/
|
|
97
|
-
const _Link = /*#__PURE__*/ (forwardRef as forwardRefType)(Link);
|
|
98
|
-
export {_Link as Link};
|
|
95
|
+
});
|
package/src/ListBox.tsx
CHANGED
|
@@ -13,16 +13,17 @@
|
|
|
13
13
|
import {AriaListBoxOptions, AriaListBoxProps, DraggableItemResult, DragPreviewRenderer, DroppableCollectionResult, DroppableItemResult, FocusScope, ListKeyboardDelegate, mergeProps, useCollator, useFocusRing, useHover, useListBox, useListBoxSection, useLocale, useOption} from 'react-aria';
|
|
14
14
|
import {Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';
|
|
15
15
|
import {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps} from './Collection';
|
|
16
|
-
import {ContextValue, Provider, RenderProps, ScrollableProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';
|
|
16
|
+
import {ContextValue, DEFAULT_SLOT, Provider, RenderProps, ScrollableProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';
|
|
17
17
|
import {DragAndDropContext, DropIndicatorContext, DropIndicatorProps, useDndPersistedKeys, useRenderDropIndicator} from './DragAndDrop';
|
|
18
18
|
import {DragAndDropHooks} from './useDragAndDrop';
|
|
19
|
-
import {DraggableCollectionState, DroppableCollectionState, ListState, Node, Orientation, SelectionBehavior, useListState} from 'react-stately';
|
|
20
|
-
import {filterDOMProps, useObjectRef} from '@react-aria/utils';
|
|
19
|
+
import {DraggableCollectionState, DroppableCollectionState, ListState, Node, Orientation, SelectionBehavior, UNSTABLE_useFilteredListState, useListState} from 'react-stately';
|
|
20
|
+
import {filterDOMProps, mergeRefs, useObjectRef} from '@react-aria/utils';
|
|
21
21
|
import {forwardRefType, HoverEvents, Key, LinkDOMProps, RefObject} from '@react-types/shared';
|
|
22
22
|
import {HeaderContext} from './Header';
|
|
23
23
|
import React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';
|
|
24
24
|
import {SeparatorContext} from './Separator';
|
|
25
25
|
import {TextContext} from './Text';
|
|
26
|
+
import {UNSTABLE_InternalAutocompleteContext} from './Autocomplete';
|
|
26
27
|
|
|
27
28
|
export interface ListBoxRenderProps {
|
|
28
29
|
/**
|
|
@@ -79,7 +80,10 @@ export interface ListBoxProps<T> extends Omit<AriaListBoxProps<T>, 'children' |
|
|
|
79
80
|
export const ListBoxContext = createContext<ContextValue<ListBoxProps<any>, HTMLDivElement>>(null);
|
|
80
81
|
export const ListStateContext = createContext<ListState<any> | null>(null);
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
/**
|
|
84
|
+
* A listbox displays a list of options and allows a user to select one or more of them.
|
|
85
|
+
*/
|
|
86
|
+
export const ListBox = /*#__PURE__*/ (forwardRef as forwardRefType)(function ListBox<T extends object>(props: ListBoxProps<T>, ref: ForwardedRef<HTMLDivElement>) {
|
|
83
87
|
[props, ref] = useContextProps(props, ref, ListBoxContext);
|
|
84
88
|
let state = useContext(ListStateContext);
|
|
85
89
|
|
|
@@ -98,7 +102,7 @@ function ListBox<T extends object>(props: ListBoxProps<T>, ref: ForwardedRef<HTM
|
|
|
98
102
|
{collection => <StandaloneListBox props={props} listBoxRef={ref} collection={collection} />}
|
|
99
103
|
</CollectionBuilder>
|
|
100
104
|
);
|
|
101
|
-
}
|
|
105
|
+
});
|
|
102
106
|
|
|
103
107
|
function StandaloneListBox({props, listBoxRef, collection}) {
|
|
104
108
|
props = {...props, collection, children: null, items: null};
|
|
@@ -107,20 +111,19 @@ function StandaloneListBox({props, listBoxRef, collection}) {
|
|
|
107
111
|
return <ListBoxInner state={state} props={props} listBoxRef={listBoxRef} />;
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
/**
|
|
111
|
-
* A listbox displays a list of options and allows a user to select one or more of them.
|
|
112
|
-
*/
|
|
113
|
-
const _ListBox = /*#__PURE__*/ (forwardRef as forwardRefType)(ListBox);
|
|
114
|
-
export {_ListBox as ListBox};
|
|
115
|
-
|
|
116
114
|
interface ListBoxInnerProps<T> {
|
|
117
115
|
state: ListState<T>,
|
|
118
116
|
props: ListBoxProps<T> & AriaListBoxOptions<T>,
|
|
119
117
|
listBoxRef: RefObject<HTMLDivElement | null>
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
function ListBoxInner<T extends object>({state, props, listBoxRef}: ListBoxInnerProps<T>) {
|
|
120
|
+
function ListBoxInner<T extends object>({state: inputState, props, listBoxRef}: ListBoxInnerProps<T>) {
|
|
121
|
+
let {filter, collectionProps, collectionRef} = useContext(UNSTABLE_InternalAutocompleteContext) || {};
|
|
122
|
+
props = useMemo(() => collectionProps ? ({...props, ...collectionProps}) : props, [props, collectionProps]);
|
|
123
123
|
let {dragAndDropHooks, layout = 'stack', orientation = 'vertical'} = props;
|
|
124
|
+
// Memoed so that useAutocomplete callback ref is properly only called once on mount and not everytime a rerender happens
|
|
125
|
+
listBoxRef = useObjectRef(useMemo(() => mergeRefs(listBoxRef, collectionRef !== undefined ? collectionRef as RefObject<HTMLDivElement> : null), [collectionRef, listBoxRef]));
|
|
126
|
+
let state = UNSTABLE_useFilteredListState(inputState, filter);
|
|
124
127
|
let {collection, selectionManager} = state;
|
|
125
128
|
let isListDraggable = !!dragAndDropHooks?.useDraggableCollectionState;
|
|
126
129
|
let isListDroppable = !!dragAndDropHooks?.useDroppableCollectionState;
|
|
@@ -246,7 +249,7 @@ function ListBoxInner<T extends object>({state, props, listBoxRef}: ListBoxInner
|
|
|
246
249
|
[DragAndDropContext, {dragAndDropHooks, dragState, dropState}],
|
|
247
250
|
[SeparatorContext, {elementType: 'div'}],
|
|
248
251
|
[DropIndicatorContext, {render: ListBoxDropIndicatorWrapper}],
|
|
249
|
-
[SectionContext, {name: 'ListBoxSection', render:
|
|
252
|
+
[SectionContext, {name: 'ListBoxSection', render: ListBoxSectionInner}]
|
|
250
253
|
]}>
|
|
251
254
|
<CollectionRoot
|
|
252
255
|
collection={collection}
|
|
@@ -263,7 +266,7 @@ function ListBoxInner<T extends object>({state, props, listBoxRef}: ListBoxInner
|
|
|
263
266
|
|
|
264
267
|
export interface ListBoxSectionProps<T> extends SectionProps<T> {}
|
|
265
268
|
|
|
266
|
-
function
|
|
269
|
+
function ListBoxSectionInner<T extends object>(props: ListBoxSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-ListBoxSection') {
|
|
267
270
|
let state = useContext(ListStateContext)!;
|
|
268
271
|
let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;
|
|
269
272
|
let {CollectionBranch} = useContext(CollectionRendererContext);
|
|
@@ -298,8 +301,7 @@ function ListBoxSection<T extends object>(props: ListBoxSectionProps<T>, ref: Fo
|
|
|
298
301
|
/**
|
|
299
302
|
* A ListBoxSection represents a section within a ListBox.
|
|
300
303
|
*/
|
|
301
|
-
const
|
|
302
|
-
export {_ListBoxSection as ListBoxSection};
|
|
304
|
+
export const ListBoxSection = /*#__PURE__*/ createBranchComponent('section', ListBoxSectionInner);
|
|
303
305
|
|
|
304
306
|
export interface ListBoxItemRenderProps extends ItemRenderProps {}
|
|
305
307
|
|
|
@@ -397,6 +399,7 @@ export const ListBoxItem = /*#__PURE__*/ createLeafComponent('item', function Li
|
|
|
397
399
|
values={[
|
|
398
400
|
[TextContext, {
|
|
399
401
|
slots: {
|
|
402
|
+
[DEFAULT_SLOT]: labelProps,
|
|
400
403
|
label: labelProps,
|
|
401
404
|
description: descriptionProps
|
|
402
405
|
}
|
package/src/Menu.tsx
CHANGED
|
@@ -10,20 +10,19 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import {MenuTriggerProps as BaseMenuTriggerProps, Collection as ICollection, Node, TreeState, useMenuTriggerState, useTreeState} from 'react-stately';
|
|
16
|
-
import {Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';
|
|
13
|
+
import {AriaMenuProps, FocusScope, mergeProps, useHover, useMenu, useMenuItem, useMenuSection, useMenuTrigger, useSubmenuTrigger} from 'react-aria';
|
|
14
|
+
import {BaseCollection, Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';
|
|
15
|
+
import {MenuTriggerProps as BaseMenuTriggerProps, Collection as ICollection, Node, RootMenuTriggerState, TreeState, useMenuTriggerState, useSubmenuTriggerState, useTreeState} from 'react-stately';
|
|
17
16
|
import {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps, usePersistedKeys} from './Collection';
|
|
18
|
-
import {ContextValue, Provider, RenderProps, ScrollableProps, SlotProps,
|
|
19
|
-
import {filterDOMProps, useObjectRef, useResizeObserver} from '@react-aria/utils';
|
|
17
|
+
import {ContextValue, DEFAULT_SLOT, Provider, RenderProps, ScrollableProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';
|
|
18
|
+
import {filterDOMProps, mergeRefs, useObjectRef, useResizeObserver} from '@react-aria/utils';
|
|
20
19
|
import {FocusStrategy, forwardRefType, HoverEvents, Key, LinkDOMProps, MultipleSelection} from '@react-types/shared';
|
|
21
20
|
import {HeaderContext} from './Header';
|
|
22
21
|
import {KeyboardContext} from './Keyboard';
|
|
23
22
|
import {MultipleSelectionState, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';
|
|
24
23
|
import {OverlayTriggerStateContext} from './Dialog';
|
|
25
24
|
import {PopoverContext} from './Popover';
|
|
26
|
-
import {PressResponder
|
|
25
|
+
import {PressResponder} from '@react-aria/interactions';
|
|
27
26
|
import React, {
|
|
28
27
|
createContext,
|
|
29
28
|
ForwardedRef,
|
|
@@ -33,13 +32,13 @@ import React, {
|
|
|
33
32
|
RefObject,
|
|
34
33
|
useCallback,
|
|
35
34
|
useContext,
|
|
35
|
+
useMemo,
|
|
36
36
|
useRef,
|
|
37
37
|
useState
|
|
38
38
|
} from 'react';
|
|
39
|
-
import {RootMenuTriggerState, useSubmenuTriggerState} from '@react-stately/menu';
|
|
40
39
|
import {SeparatorContext} from './Separator';
|
|
41
40
|
import {TextContext} from './Text';
|
|
42
|
-
import {
|
|
41
|
+
import {UNSTABLE_InternalAutocompleteContext} from './Autocomplete';
|
|
43
42
|
|
|
44
43
|
export const MenuContext = createContext<ContextValue<MenuProps<any>, HTMLDivElement>>(null);
|
|
45
44
|
export const MenuStateContext = createContext<TreeState<any> | null>(null);
|
|
@@ -69,7 +68,6 @@ export function MenuTrigger(props: MenuTriggerProps) {
|
|
|
69
68
|
ref: ref,
|
|
70
69
|
onResize: onResize
|
|
71
70
|
});
|
|
72
|
-
|
|
73
71
|
let scrollRef = useRef(null);
|
|
74
72
|
|
|
75
73
|
return (
|
|
@@ -83,7 +81,8 @@ export function MenuTrigger(props: MenuTriggerProps) {
|
|
|
83
81
|
triggerRef: ref,
|
|
84
82
|
scrollRef,
|
|
85
83
|
placement: 'bottom start',
|
|
86
|
-
style: {'--trigger-width': buttonWidth} as React.CSSProperties
|
|
84
|
+
style: {'--trigger-width': buttonWidth} as React.CSSProperties,
|
|
85
|
+
'aria-labelledby': menuProps['aria-labelledby']
|
|
87
86
|
}]
|
|
88
87
|
]}>
|
|
89
88
|
<PressResponder {...menuTriggerProps} ref={ref} isPressed={state.isOpen}>
|
|
@@ -105,7 +104,7 @@ export interface SubmenuTriggerProps {
|
|
|
105
104
|
delay?: number
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
const SubmenuTriggerContext = createContext<{parentMenuRef: RefObject<HTMLElement | null
|
|
107
|
+
const SubmenuTriggerContext = createContext<{parentMenuRef: RefObject<HTMLElement | null>, shouldUseVirtualFocus?: boolean} | null>(null);
|
|
109
108
|
|
|
110
109
|
/**
|
|
111
110
|
* A submenu trigger is used to wrap a submenu's trigger item and the submenu itself.
|
|
@@ -119,11 +118,12 @@ export const SubmenuTrigger = /*#__PURE__*/ createBranchComponent('submenutrigg
|
|
|
119
118
|
let submenuTriggerState = useSubmenuTriggerState({triggerKey: item.key}, rootMenuTriggerState);
|
|
120
119
|
let submenuRef = useRef<HTMLDivElement>(null);
|
|
121
120
|
let itemRef = useObjectRef(ref);
|
|
122
|
-
let {parentMenuRef} = useContext(SubmenuTriggerContext)!;
|
|
121
|
+
let {parentMenuRef, shouldUseVirtualFocus} = useContext(SubmenuTriggerContext)!;
|
|
123
122
|
let {submenuTriggerProps, submenuProps, popoverProps} = useSubmenuTrigger({
|
|
124
123
|
parentMenuRef,
|
|
125
124
|
submenuRef,
|
|
126
|
-
delay: props.delay
|
|
125
|
+
delay: props.delay,
|
|
126
|
+
shouldUseVirtualFocus
|
|
127
127
|
}, submenuTriggerState, itemRef);
|
|
128
128
|
|
|
129
129
|
return (
|
|
@@ -137,9 +137,7 @@ export const SubmenuTrigger = /*#__PURE__*/ createBranchComponent('submenutrigg
|
|
|
137
137
|
trigger: 'SubmenuTrigger',
|
|
138
138
|
triggerRef: itemRef,
|
|
139
139
|
placement: 'end top',
|
|
140
|
-
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
'data-react-aria-top-layer': true,
|
|
140
|
+
'aria-labelledby': submenuProps['aria-labelledby'],
|
|
143
141
|
...popoverProps
|
|
144
142
|
}]
|
|
145
143
|
]}>
|
|
@@ -149,41 +147,72 @@ export const SubmenuTrigger = /*#__PURE__*/ createBranchComponent('submenutrigg
|
|
|
149
147
|
);
|
|
150
148
|
}, props => props.children[0]);
|
|
151
149
|
|
|
152
|
-
export interface
|
|
150
|
+
export interface MenuRenderProps {
|
|
151
|
+
/**
|
|
152
|
+
* Whether the menu has no items and should display its empty state.
|
|
153
|
+
* @selector [data-empty]
|
|
154
|
+
*/
|
|
155
|
+
isEmpty: boolean
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children'>, CollectionProps<T>, StyleRenderProps<MenuRenderProps>, SlotProps, ScrollableProps<HTMLDivElement> {
|
|
159
|
+
/** Provides content to display when there are no items in the list. */
|
|
160
|
+
renderEmptyState?: () => ReactNode
|
|
161
|
+
}
|
|
153
162
|
|
|
154
|
-
|
|
163
|
+
/**
|
|
164
|
+
* A menu displays a list of actions or options that a user can choose.
|
|
165
|
+
*/
|
|
166
|
+
export const Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(function Menu<T extends object>(props: MenuProps<T>, ref: ForwardedRef<HTMLDivElement>) {
|
|
155
167
|
[props, ref] = useContextProps(props, ref, MenuContext);
|
|
156
168
|
|
|
157
169
|
// Delay rendering the actual menu until we have the collection so that auto focus works properly.
|
|
158
170
|
return (
|
|
159
171
|
<CollectionBuilder content={<Collection {...props} />}>
|
|
160
|
-
{collection =>
|
|
172
|
+
{collection => <MenuInner props={props} collection={collection} menuRef={ref} />}
|
|
161
173
|
</CollectionBuilder>
|
|
162
174
|
);
|
|
163
|
-
}
|
|
175
|
+
});
|
|
164
176
|
|
|
165
177
|
interface MenuInnerProps<T> {
|
|
166
178
|
props: MenuProps<T>,
|
|
167
|
-
collection:
|
|
179
|
+
collection: BaseCollection<object>,
|
|
168
180
|
menuRef: RefObject<HTMLDivElement | null>
|
|
169
181
|
}
|
|
170
182
|
|
|
171
183
|
function MenuInner<T extends object>({props, collection, menuRef: ref}: MenuInnerProps<T>) {
|
|
184
|
+
let {filter, collectionProps: autocompleteMenuProps, collectionRef} = useContext(UNSTABLE_InternalAutocompleteContext) || {};
|
|
185
|
+
// Memoed so that useAutocomplete callback ref is properly only called once on mount and not everytime a rerender happens
|
|
186
|
+
ref = useObjectRef(useMemo(() => mergeRefs(ref, collectionRef !== undefined ? collectionRef as RefObject<HTMLDivElement> : null), [collectionRef, ref]));
|
|
187
|
+
let filteredCollection = useMemo(() => filter ? collection.UNSTABLE_filter(filter) : collection, [collection, filter]);
|
|
172
188
|
let state = useTreeState({
|
|
173
189
|
...props,
|
|
174
|
-
collection
|
|
190
|
+
collection: filteredCollection as ICollection<Node<object>>,
|
|
175
191
|
children: undefined
|
|
176
192
|
});
|
|
177
193
|
let triggerState = useContext(RootMenuTriggerStateContext);
|
|
178
194
|
let {isVirtualized, CollectionRoot} = useContext(CollectionRendererContext);
|
|
179
|
-
let {menuProps} = useMenu({...props, isVirtualized, onClose: props.onClose || triggerState?.close}, state, ref);
|
|
195
|
+
let {menuProps} = useMenu({...props, ...autocompleteMenuProps, isVirtualized, onClose: props.onClose || triggerState?.close}, state, ref);
|
|
180
196
|
let renderProps = useRenderProps({
|
|
181
197
|
defaultClassName: 'react-aria-Menu',
|
|
182
198
|
className: props.className,
|
|
183
199
|
style: props.style,
|
|
184
|
-
values: {
|
|
200
|
+
values: {
|
|
201
|
+
isEmpty: state.collection.size === 0
|
|
202
|
+
}
|
|
185
203
|
});
|
|
186
204
|
|
|
205
|
+
let emptyState: ReactElement | null = null;
|
|
206
|
+
if (state.collection.size === 0 && props.renderEmptyState) {
|
|
207
|
+
emptyState = (
|
|
208
|
+
<div
|
|
209
|
+
role="menuitem"
|
|
210
|
+
style={{display: 'contents'}}>
|
|
211
|
+
{props.renderEmptyState()}
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
187
216
|
return (
|
|
188
217
|
<FocusScope>
|
|
189
218
|
<div
|
|
@@ -192,32 +221,33 @@ function MenuInner<T extends object>({props, collection, menuRef: ref}: MenuInne
|
|
|
192
221
|
{...renderProps}
|
|
193
222
|
ref={ref}
|
|
194
223
|
slot={props.slot || undefined}
|
|
224
|
+
data-empty={state.collection.size === 0 || undefined}
|
|
195
225
|
onScroll={props.onScroll}>
|
|
196
226
|
<Provider
|
|
197
227
|
values={[
|
|
198
228
|
[MenuStateContext, state],
|
|
199
229
|
[SeparatorContext, {elementType: 'div'}],
|
|
200
|
-
[SectionContext, {name: 'MenuSection', render:
|
|
201
|
-
[SubmenuTriggerContext, {parentMenuRef: ref}],
|
|
230
|
+
[SectionContext, {name: 'MenuSection', render: MenuSectionInner}],
|
|
231
|
+
[SubmenuTriggerContext, {parentMenuRef: ref, shouldUseVirtualFocus: autocompleteMenuProps?.shouldUseVirtualFocus}],
|
|
202
232
|
[MenuItemContext, null],
|
|
203
|
-
[
|
|
233
|
+
[UNSTABLE_InternalAutocompleteContext, null],
|
|
234
|
+
[SelectionManagerContext, state.selectionManager],
|
|
235
|
+
/* Ensure root MenuTriggerState is defined, in case Menu is rendered outside a MenuTrigger. */
|
|
236
|
+
/* We assume the context can never change between defined and undefined. */
|
|
237
|
+
/* eslint-disable-next-line react-hooks/rules-of-hooks */
|
|
238
|
+
[RootMenuTriggerStateContext, triggerState ?? useMenuTriggerState({})]
|
|
204
239
|
]}>
|
|
205
240
|
<CollectionRoot
|
|
206
|
-
collection={collection}
|
|
241
|
+
collection={state.collection}
|
|
207
242
|
persistedKeys={usePersistedKeys(state.selectionManager.focusedKey)}
|
|
208
243
|
scrollRef={ref} />
|
|
209
244
|
</Provider>
|
|
245
|
+
{emptyState}
|
|
210
246
|
</div>
|
|
211
247
|
</FocusScope>
|
|
212
248
|
);
|
|
213
249
|
}
|
|
214
250
|
|
|
215
|
-
/**
|
|
216
|
-
* A menu displays a list of actions or options that a user can choose.
|
|
217
|
-
*/
|
|
218
|
-
const _Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(Menu);
|
|
219
|
-
export {_Menu as Menu};
|
|
220
|
-
|
|
221
251
|
export interface MenuSectionProps<T> extends SectionProps<T>, MultipleSelection {}
|
|
222
252
|
|
|
223
253
|
// A subclass of SelectionManager that forwards focus-related properties to the parent,
|
|
@@ -251,7 +281,7 @@ class GroupSelectionManager extends SelectionManager {
|
|
|
251
281
|
}
|
|
252
282
|
}
|
|
253
283
|
|
|
254
|
-
function
|
|
284
|
+
function MenuSectionInner<T extends object>(props: MenuSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-MenuSection') {
|
|
255
285
|
let state = useContext(MenuStateContext)!;
|
|
256
286
|
let {CollectionBranch} = useContext(CollectionRendererContext);
|
|
257
287
|
let [headingRef, heading] = useSlot();
|
|
@@ -290,8 +320,7 @@ function MenuSection<T extends object>(props: MenuSectionProps<T>, ref: Forwarde
|
|
|
290
320
|
/**
|
|
291
321
|
* A MenuSection represents a section within a Menu.
|
|
292
322
|
*/
|
|
293
|
-
const
|
|
294
|
-
export {_MenuSection as MenuSection};
|
|
323
|
+
export const MenuSection = /*#__PURE__*/ createBranchComponent('section', MenuSectionInner);
|
|
295
324
|
|
|
296
325
|
export interface MenuItemRenderProps extends ItemRenderProps {
|
|
297
326
|
/**
|
|
@@ -342,7 +371,6 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI
|
|
|
342
371
|
selectionManager
|
|
343
372
|
}, state, ref);
|
|
344
373
|
|
|
345
|
-
let {isFocusVisible, focusProps} = useFocusRing();
|
|
346
374
|
let {hoverProps, isHovered} = useHover({
|
|
347
375
|
isDisabled: states.isDisabled
|
|
348
376
|
});
|
|
@@ -354,7 +382,7 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI
|
|
|
354
382
|
values: {
|
|
355
383
|
...states,
|
|
356
384
|
isHovered,
|
|
357
|
-
isFocusVisible,
|
|
385
|
+
isFocusVisible: states.isFocusVisible,
|
|
358
386
|
selectionMode: selectionManager.selectionMode,
|
|
359
387
|
selectionBehavior: selectionManager.selectionBehavior,
|
|
360
388
|
hasSubmenu: !!props['aria-haspopup'],
|
|
@@ -366,13 +394,13 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI
|
|
|
366
394
|
|
|
367
395
|
return (
|
|
368
396
|
<ElementType
|
|
369
|
-
{...mergeProps(menuItemProps,
|
|
397
|
+
{...mergeProps(menuItemProps, hoverProps)}
|
|
370
398
|
{...renderProps}
|
|
371
399
|
ref={ref}
|
|
372
400
|
data-disabled={states.isDisabled || undefined}
|
|
373
401
|
data-hovered={isHovered || undefined}
|
|
374
402
|
data-focused={states.isFocused || undefined}
|
|
375
|
-
data-focus-visible={isFocusVisible || undefined}
|
|
403
|
+
data-focus-visible={states.isFocusVisible || undefined}
|
|
376
404
|
data-pressed={states.isPressed || undefined}
|
|
377
405
|
data-selected={states.isSelected || undefined}
|
|
378
406
|
data-selection-mode={selectionManager.selectionMode === 'none' ? undefined : selectionManager.selectionMode}
|
|
@@ -382,6 +410,7 @@ export const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuI
|
|
|
382
410
|
values={[
|
|
383
411
|
[TextContext, {
|
|
384
412
|
slots: {
|
|
413
|
+
[DEFAULT_SLOT]: labelProps,
|
|
385
414
|
label: labelProps,
|
|
386
415
|
description: descriptionProps
|
|
387
416
|
}
|
package/src/Meter.tsx
CHANGED
|
@@ -33,7 +33,10 @@ export interface MeterRenderProps {
|
|
|
33
33
|
|
|
34
34
|
export const MeterContext = createContext<ContextValue<MeterProps, HTMLDivElement>>(null);
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* A meter represents a quantity within a known range, or a fractional value.
|
|
38
|
+
*/
|
|
39
|
+
export const Meter = /*#__PURE__*/ (forwardRef as forwardRefType)(function Meter(props: MeterProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
37
40
|
[props, ref] = useContextProps(props, ref, MeterContext);
|
|
38
41
|
let {
|
|
39
42
|
value = 0,
|
|
@@ -42,7 +45,9 @@ function Meter(props: MeterProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
42
45
|
} = props;
|
|
43
46
|
value = clamp(value, minValue, maxValue);
|
|
44
47
|
|
|
45
|
-
let [labelRef, label] = useSlot(
|
|
48
|
+
let [labelRef, label] = useSlot(
|
|
49
|
+
!props['aria-label'] && !props['aria-labelledby']
|
|
50
|
+
);
|
|
46
51
|
let {
|
|
47
52
|
meterProps,
|
|
48
53
|
labelProps
|
|
@@ -67,10 +72,4 @@ function Meter(props: MeterProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
67
72
|
</LabelContext.Provider>
|
|
68
73
|
</div>
|
|
69
74
|
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A meter represents a quantity within a known range, or a fractional value.
|
|
74
|
-
*/
|
|
75
|
-
const _Meter = /*#__PURE__*/ (forwardRef as forwardRefType)(Meter);
|
|
76
|
-
export {_Meter as Meter};
|
|
75
|
+
});
|
package/src/Modal.tsx
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {AriaModalOverlayProps, DismissButton, Overlay, useIsSSR, useModalOverlay} from 'react-aria';
|
|
14
|
-
import {ContextValue, Provider, RenderProps, SlotProps, useContextProps,
|
|
14
|
+
import {ContextValue, Provider, RenderProps, SlotProps, useContextProps, useRenderProps} from './utils';
|
|
15
15
|
import {DOMAttributes, forwardRefType, RefObject} from '@react-types/shared';
|
|
16
|
-
import {filterDOMProps, mergeProps, mergeRefs, useObjectRef, useViewportSize} from '@react-aria/utils';
|
|
16
|
+
import {filterDOMProps, mergeProps, mergeRefs, useEnterAnimation, useExitAnimation, useObjectRef, useViewportSize} from '@react-aria/utils';
|
|
17
17
|
import {OverlayTriggerProps, OverlayTriggerState, useOverlayTriggerState} from 'react-stately';
|
|
18
18
|
import {OverlayTriggerStateContext} from './Dialog';
|
|
19
19
|
import React, {createContext, ForwardedRef, forwardRef, useContext, useMemo, useRef} from 'react';
|
|
@@ -61,7 +61,10 @@ export interface ModalRenderProps {
|
|
|
61
61
|
state: OverlayTriggerState
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* A modal is an overlay element which blocks interaction with elements outside it.
|
|
66
|
+
*/
|
|
67
|
+
export const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
65
68
|
let ctx = useContext(InternalModalContext);
|
|
66
69
|
|
|
67
70
|
if (ctx) {
|
|
@@ -98,7 +101,7 @@ function Modal(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
98
101
|
</ModalContent>
|
|
99
102
|
</ModalOverlay>
|
|
100
103
|
);
|
|
101
|
-
}
|
|
104
|
+
});
|
|
102
105
|
|
|
103
106
|
interface ModalOverlayInnerProps extends ModalOverlayProps {
|
|
104
107
|
overlayRef: RefObject<HTMLDivElement | null>,
|
|
@@ -107,12 +110,6 @@ interface ModalOverlayInnerProps extends ModalOverlayProps {
|
|
|
107
110
|
isExiting: boolean
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
/**
|
|
111
|
-
* A modal is an overlay element which blocks interaction with elements outside it.
|
|
112
|
-
*/
|
|
113
|
-
const _Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(Modal);
|
|
114
|
-
export {_Modal as Modal};
|
|
115
|
-
|
|
116
113
|
function ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
117
114
|
[props, ref] = useContextProps(props, ref, ModalContext);
|
|
118
115
|
let contextState = useContext(OverlayTriggerStateContext);
|