react-aria-components 1.14.0 → 1.15.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/Breadcrumbs.main.js +3 -2
- package/dist/Breadcrumbs.main.js.map +1 -1
- package/dist/Breadcrumbs.mjs +4 -3
- package/dist/Breadcrumbs.module.js +4 -3
- package/dist/Breadcrumbs.module.js.map +1 -1
- package/dist/Button.main.js +1 -1
- package/dist/Button.main.js.map +1 -1
- package/dist/Button.mjs +2 -2
- package/dist/Button.module.js +2 -2
- package/dist/Button.module.js.map +1 -1
- package/dist/Calendar.main.js +11 -7
- package/dist/Calendar.main.js.map +1 -1
- package/dist/Calendar.mjs +12 -8
- package/dist/Calendar.module.js +12 -8
- package/dist/Calendar.module.js.map +1 -1
- package/dist/Checkbox.main.js +2 -2
- package/dist/Checkbox.main.js.map +1 -1
- package/dist/Checkbox.mjs +3 -3
- package/dist/Checkbox.module.js +3 -3
- package/dist/Checkbox.module.js.map +1 -1
- package/dist/ColorArea.main.js +1 -1
- package/dist/ColorArea.main.js.map +1 -1
- package/dist/ColorArea.mjs +2 -2
- package/dist/ColorArea.module.js +2 -2
- package/dist/ColorArea.module.js.map +1 -1
- package/dist/ColorField.main.js +7 -3
- package/dist/ColorField.main.js.map +1 -1
- package/dist/ColorField.mjs +8 -4
- package/dist/ColorField.module.js +8 -4
- package/dist/ColorField.module.js.map +1 -1
- package/dist/ColorSlider.main.js +1 -1
- package/dist/ColorSlider.main.js.map +1 -1
- package/dist/ColorSlider.mjs +2 -2
- package/dist/ColorSlider.module.js +2 -2
- package/dist/ColorSlider.module.js.map +1 -1
- package/dist/ColorSwatch.main.js +1 -1
- package/dist/ColorSwatch.main.js.map +1 -1
- package/dist/ColorSwatch.mjs +2 -2
- package/dist/ColorSwatch.module.js +2 -2
- package/dist/ColorSwatch.module.js.map +1 -1
- package/dist/ColorSwatchPicker.main.js +2 -0
- package/dist/ColorSwatchPicker.main.js.map +1 -1
- package/dist/ColorSwatchPicker.mjs +2 -0
- package/dist/ColorSwatchPicker.module.js +2 -0
- package/dist/ColorSwatchPicker.module.js.map +1 -1
- package/dist/ColorThumb.main.js +1 -1
- package/dist/ColorThumb.main.js.map +1 -1
- package/dist/ColorThumb.mjs +2 -2
- package/dist/ColorThumb.module.js +2 -2
- package/dist/ColorThumb.module.js.map +1 -1
- package/dist/ColorWheel.main.js +2 -2
- package/dist/ColorWheel.main.js.map +1 -1
- package/dist/ColorWheel.mjs +3 -3
- package/dist/ColorWheel.module.js +3 -3
- package/dist/ColorWheel.module.js.map +1 -1
- package/dist/ComboBox.main.js +2 -2
- package/dist/ComboBox.main.js.map +1 -1
- package/dist/ComboBox.mjs +3 -3
- package/dist/ComboBox.module.js +3 -3
- package/dist/ComboBox.module.js.map +1 -1
- package/dist/DateField.main.js +3 -3
- package/dist/DateField.main.js.map +1 -1
- package/dist/DateField.mjs +4 -4
- package/dist/DateField.module.js +4 -4
- package/dist/DateField.module.js.map +1 -1
- package/dist/DatePicker.main.js +2 -2
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +3 -3
- package/dist/DatePicker.module.js +3 -3
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/Dialog.main.js +2 -1
- package/dist/Dialog.main.js.map +1 -1
- package/dist/Dialog.mjs +3 -2
- package/dist/Dialog.module.js +3 -2
- package/dist/Dialog.module.js.map +1 -1
- package/dist/Disclosure.main.js +3 -3
- package/dist/Disclosure.main.js.map +1 -1
- package/dist/Disclosure.mjs +4 -4
- package/dist/Disclosure.module.js +4 -4
- package/dist/Disclosure.module.js.map +1 -1
- package/dist/DropZone.main.js +2 -3
- package/dist/DropZone.main.js.map +1 -1
- package/dist/DropZone.mjs +4 -5
- package/dist/DropZone.module.js +4 -5
- package/dist/DropZone.module.js.map +1 -1
- package/dist/Form.main.js +1 -1
- package/dist/Form.main.js.map +1 -1
- package/dist/Form.mjs +2 -2
- package/dist/Form.module.js +2 -2
- package/dist/Form.module.js.map +1 -1
- package/dist/GridList.main.js +16 -13
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +17 -14
- package/dist/GridList.module.js +17 -14
- package/dist/GridList.module.js.map +1 -1
- package/dist/Group.main.js +1 -1
- package/dist/Group.main.js.map +1 -1
- package/dist/Group.mjs +2 -2
- package/dist/Group.module.js +2 -2
- package/dist/Group.module.js.map +1 -1
- package/dist/Header.main.js +1 -1
- package/dist/Header.main.js.map +1 -1
- package/dist/Header.mjs +2 -2
- package/dist/Header.module.js +2 -2
- package/dist/Header.module.js.map +1 -1
- package/dist/Heading.main.js +2 -2
- package/dist/Heading.main.js.map +1 -1
- package/dist/Heading.mjs +2 -2
- package/dist/Heading.module.js +2 -2
- package/dist/Heading.module.js.map +1 -1
- package/dist/HiddenDateInput.main.js +5 -1
- package/dist/HiddenDateInput.main.js.map +1 -1
- package/dist/HiddenDateInput.mjs +6 -2
- package/dist/HiddenDateInput.module.js +6 -2
- package/dist/HiddenDateInput.module.js.map +1 -1
- package/dist/Input.main.js +1 -1
- package/dist/Input.main.js.map +1 -1
- package/dist/Input.mjs +2 -2
- package/dist/Input.module.js +2 -2
- package/dist/Input.module.js.map +1 -1
- package/dist/Keyboard.main.js +1 -1
- package/dist/Keyboard.main.js.map +1 -1
- package/dist/Keyboard.mjs +2 -2
- package/dist/Keyboard.module.js +2 -2
- package/dist/Keyboard.module.js.map +1 -1
- package/dist/Label.main.js +2 -1
- package/dist/Label.main.js.map +1 -1
- package/dist/Label.mjs +3 -2
- package/dist/Label.module.js +3 -2
- package/dist/Label.module.js.map +1 -1
- package/dist/Link.main.js +3 -2
- package/dist/Link.main.js.map +1 -1
- package/dist/Link.mjs +4 -3
- package/dist/Link.module.js +4 -3
- package/dist/Link.module.js.map +1 -1
- package/dist/ListBox.main.js +13 -14
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +14 -15
- package/dist/ListBox.module.js +14 -15
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Menu.main.js +21 -8
- package/dist/Menu.main.js.map +1 -1
- package/dist/Menu.mjs +22 -9
- package/dist/Menu.module.js +22 -9
- package/dist/Menu.module.js.map +1 -1
- package/dist/Meter.main.js +1 -1
- package/dist/Meter.main.js.map +1 -1
- package/dist/Meter.mjs +2 -2
- package/dist/Meter.module.js +2 -2
- package/dist/Meter.module.js.map +1 -1
- package/dist/Modal.main.js +2 -2
- package/dist/Modal.main.js.map +1 -1
- package/dist/Modal.mjs +3 -3
- package/dist/Modal.module.js +3 -3
- package/dist/Modal.module.js.map +1 -1
- package/dist/NumberField.main.js +1 -1
- package/dist/NumberField.main.js.map +1 -1
- package/dist/NumberField.mjs +2 -2
- package/dist/NumberField.module.js +2 -2
- package/dist/NumberField.module.js.map +1 -1
- package/dist/OverlayArrow.main.js +1 -1
- package/dist/OverlayArrow.main.js.map +1 -1
- package/dist/OverlayArrow.mjs +2 -2
- package/dist/OverlayArrow.module.js +2 -2
- package/dist/OverlayArrow.module.js.map +1 -1
- package/dist/Popover.main.js +2 -2
- package/dist/Popover.main.js.map +1 -1
- package/dist/Popover.mjs +4 -4
- package/dist/Popover.module.js +4 -4
- package/dist/Popover.module.js.map +1 -1
- package/dist/ProgressBar.main.js +1 -1
- package/dist/ProgressBar.main.js.map +1 -1
- package/dist/ProgressBar.mjs +2 -2
- package/dist/ProgressBar.module.js +2 -2
- package/dist/ProgressBar.module.js.map +1 -1
- package/dist/RadioGroup.main.js +2 -2
- package/dist/RadioGroup.main.js.map +1 -1
- package/dist/RadioGroup.mjs +3 -3
- package/dist/RadioGroup.module.js +3 -3
- package/dist/RadioGroup.module.js.map +1 -1
- package/dist/SearchField.main.js +1 -1
- package/dist/SearchField.main.js.map +1 -1
- package/dist/SearchField.mjs +2 -2
- package/dist/SearchField.module.js +2 -2
- package/dist/SearchField.module.js.map +1 -1
- package/dist/Select.main.js +2 -2
- package/dist/Select.main.js.map +1 -1
- package/dist/Select.mjs +3 -3
- package/dist/Select.module.js +3 -3
- package/dist/Select.module.js.map +1 -1
- package/dist/Separator.main.js +3 -1
- package/dist/Separator.main.js.map +1 -1
- package/dist/Separator.mjs +4 -2
- package/dist/Separator.module.js +4 -2
- package/dist/Separator.module.js.map +1 -1
- package/dist/SharedElementTransition.main.js +3 -2
- package/dist/SharedElementTransition.main.js.map +1 -1
- package/dist/SharedElementTransition.mjs +4 -3
- package/dist/SharedElementTransition.module.js +4 -3
- package/dist/SharedElementTransition.module.js.map +1 -1
- package/dist/Slider.main.js +6 -5
- package/dist/Slider.main.js.map +1 -1
- package/dist/Slider.mjs +7 -6
- package/dist/Slider.module.js +7 -6
- package/dist/Slider.module.js.map +1 -1
- package/dist/Switch.main.js +1 -1
- package/dist/Switch.main.js.map +1 -1
- package/dist/Switch.mjs +2 -2
- package/dist/Switch.module.js +2 -2
- package/dist/Switch.module.js.map +1 -1
- package/dist/Table.main.js +30 -25
- package/dist/Table.main.js.map +1 -1
- package/dist/Table.mjs +31 -26
- package/dist/Table.module.js +31 -26
- package/dist/Table.module.js.map +1 -1
- package/dist/Tabs.main.js +13 -6
- package/dist/Tabs.main.js.map +1 -1
- package/dist/Tabs.mjs +14 -7
- package/dist/Tabs.module.js +14 -7
- package/dist/Tabs.module.js.map +1 -1
- package/dist/TagGroup.main.js +6 -5
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +7 -6
- package/dist/TagGroup.module.js +7 -6
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/Text.main.js +2 -1
- package/dist/Text.main.js.map +1 -1
- package/dist/Text.mjs +3 -2
- package/dist/Text.module.js +3 -2
- package/dist/Text.module.js.map +1 -1
- package/dist/TextArea.main.js +1 -1
- package/dist/TextArea.main.js.map +1 -1
- package/dist/TextArea.mjs +2 -2
- package/dist/TextArea.module.js +2 -2
- package/dist/TextArea.module.js.map +1 -1
- package/dist/TextField.main.js +1 -1
- package/dist/TextField.main.js.map +1 -1
- package/dist/TextField.mjs +2 -2
- package/dist/TextField.module.js +2 -2
- package/dist/TextField.module.js.map +1 -1
- package/dist/Toast.main.js +6 -4
- package/dist/Toast.main.js.map +1 -1
- package/dist/Toast.mjs +7 -5
- package/dist/Toast.module.js +7 -5
- package/dist/Toast.module.js.map +1 -1
- package/dist/ToggleButton.main.js +5 -2
- package/dist/ToggleButton.main.js.map +1 -1
- package/dist/ToggleButton.mjs +6 -3
- package/dist/ToggleButton.module.js +6 -3
- package/dist/ToggleButton.module.js.map +1 -1
- package/dist/ToggleButtonGroup.main.js +1 -1
- package/dist/ToggleButtonGroup.main.js.map +1 -1
- package/dist/ToggleButtonGroup.mjs +2 -2
- package/dist/ToggleButtonGroup.module.js +2 -2
- package/dist/ToggleButtonGroup.module.js.map +1 -1
- package/dist/Toolbar.main.js +1 -1
- package/dist/Toolbar.main.js.map +1 -1
- package/dist/Toolbar.mjs +2 -2
- package/dist/Toolbar.module.js +2 -2
- package/dist/Toolbar.module.js.map +1 -1
- package/dist/Tooltip.main.js +1 -1
- package/dist/Tooltip.main.js.map +1 -1
- package/dist/Tooltip.mjs +2 -2
- package/dist/Tooltip.module.js +2 -2
- package/dist/Tooltip.module.js.map +1 -1
- package/dist/Tree.main.js +6 -6
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +7 -7
- package/dist/Tree.module.js +7 -7
- package/dist/Tree.module.js.map +1 -1
- package/dist/types.d.ts +122 -63
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.main.js +41 -3
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +42 -5
- package/dist/utils.module.js +42 -5
- package/dist/utils.module.js.map +1 -1
- package/package.json +24 -24
- package/src/Breadcrumbs.tsx +9 -6
- package/src/Button.tsx +4 -3
- package/src/Calendar.tsx +26 -20
- package/src/Checkbox.tsx +7 -6
- package/src/ColorArea.tsx +3 -2
- package/src/ColorField.tsx +18 -3
- package/src/ColorSlider.tsx +2 -1
- package/src/ColorSwatch.tsx +2 -1
- package/src/ColorSwatchPicker.tsx +2 -0
- package/src/ColorThumb.tsx +3 -3
- package/src/ColorWheel.tsx +4 -3
- package/src/ComboBox.tsx +3 -2
- package/src/DateField.tsx +5 -4
- package/src/DatePicker.tsx +3 -2
- package/src/Dialog.tsx +5 -4
- package/src/Disclosure.tsx +7 -6
- package/src/DropZone.tsx +5 -5
- package/src/Form.tsx +4 -4
- package/src/GridList.tsx +30 -23
- package/src/Group.tsx +10 -9
- package/src/Header.tsx +7 -5
- package/src/Heading.tsx +4 -4
- package/src/HiddenDateInput.tsx +10 -3
- package/src/Input.tsx +3 -2
- package/src/Keyboard.tsx +4 -2
- package/src/Label.tsx +4 -3
- package/src/Link.tsx +15 -12
- package/src/ListBox.tsx +23 -22
- package/src/Menu.tsx +32 -17
- package/src/Meter.tsx +3 -2
- package/src/Modal.tsx +5 -4
- package/src/NumberField.tsx +2 -1
- package/src/OverlayArrow.tsx +3 -2
- package/src/Popover.tsx +5 -4
- package/src/ProgressBar.tsx +3 -2
- package/src/RadioGroup.tsx +6 -5
- package/src/SearchField.tsx +3 -2
- package/src/Select.tsx +6 -5
- package/src/Separator.tsx +8 -5
- package/src/SharedElementTransition.tsx +4 -3
- package/src/Slider.tsx +9 -7
- package/src/Switch.tsx +11 -10
- package/src/Table.tsx +47 -36
- package/src/Tabs.tsx +23 -18
- package/src/TagGroup.tsx +16 -13
- package/src/Text.tsx +4 -3
- package/src/TextArea.tsx +3 -2
- package/src/TextField.tsx +4 -3
- package/src/Toast.tsx +15 -11
- package/src/ToggleButton.tsx +5 -4
- package/src/ToggleButtonGroup.tsx +3 -2
- package/src/Toolbar.tsx +3 -2
- package/src/Tooltip.tsx +3 -2
- package/src/Tree.tsx +18 -17
- package/src/utils.tsx +97 -11
package/src/Toast.tsx
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
ClassNameOrFunction,
|
|
17
17
|
ContextValue,
|
|
18
18
|
DEFAULT_SLOT,
|
|
19
|
+
dom,
|
|
20
|
+
DOMRenderProps,
|
|
19
21
|
Provider,
|
|
20
22
|
RenderProps,
|
|
21
23
|
StyleRenderProps,
|
|
@@ -102,15 +104,15 @@ export const ToastRegion = /*#__PURE__*/ (forwardRef as forwardRefType)(function
|
|
|
102
104
|
|
|
103
105
|
let region = (
|
|
104
106
|
<ToastStateContext.Provider value={state}>
|
|
105
|
-
<div
|
|
107
|
+
<dom.div
|
|
106
108
|
{...mergeProps(DOMProps, renderProps, regionProps, focusProps, hoverProps)}
|
|
107
109
|
dir={direction}
|
|
108
110
|
ref={objectRef}
|
|
109
111
|
data-hovered={isHovered || undefined}
|
|
110
112
|
data-focused={isFocused || undefined}
|
|
111
113
|
data-focus-visible={isFocusVisible || undefined}>
|
|
112
|
-
{typeof props.children === 'function' ? <ToastList {...props} className={undefined} style={{display: 'contents'}}>{props.children}</ToastList> : props.children}
|
|
113
|
-
</div>
|
|
114
|
+
{typeof props.children === 'function' ? <ToastList {...props} render={undefined} className={undefined} style={{display: 'contents'}}>{props.children}</ToastList> : props.children}
|
|
115
|
+
</dom.div>
|
|
114
116
|
</ToastStateContext.Provider>
|
|
115
117
|
);
|
|
116
118
|
|
|
@@ -119,7 +121,7 @@ export const ToastRegion = /*#__PURE__*/ (forwardRef as forwardRefType)(function
|
|
|
119
121
|
: null;
|
|
120
122
|
});
|
|
121
123
|
|
|
122
|
-
export interface ToastListProps<T> extends Omit<ToastRegionProps<T>, 'queue' | 'children'
|
|
124
|
+
export interface ToastListProps<T> extends Omit<ToastRegionProps<T>, 'queue' | 'children' | 'render'>, DOMRenderProps<'ol', ToastRegionRenderProps<T>> {
|
|
123
125
|
/** A function to render each toast. */
|
|
124
126
|
children: (renderProps: {toast: QueuedToast<T>}) => ReactElement
|
|
125
127
|
}
|
|
@@ -140,13 +142,13 @@ export const ToastList = /*#__PURE__*/ (forwardRef as forwardRefType)(function T
|
|
|
140
142
|
});
|
|
141
143
|
|
|
142
144
|
return (
|
|
143
|
-
<ol {...hoverProps} {...renderProps} ref={ref}>
|
|
145
|
+
<dom.ol {...hoverProps} {...renderProps} ref={ref}>
|
|
144
146
|
{state.visibleToasts.map((toast) => (
|
|
145
147
|
<li key={toast.key} style={{display: 'contents'}}>
|
|
146
148
|
{props.children({toast})}
|
|
147
149
|
</li>
|
|
148
150
|
))}
|
|
149
|
-
</ol>
|
|
151
|
+
</dom.ol>
|
|
150
152
|
);
|
|
151
153
|
});
|
|
152
154
|
|
|
@@ -201,7 +203,7 @@ export const Toast = /*#__PURE__*/ (forwardRef as forwardRefType)(function Toast
|
|
|
201
203
|
let DOMProps = filterDOMProps(props, {global: true});
|
|
202
204
|
|
|
203
205
|
return (
|
|
204
|
-
<div
|
|
206
|
+
<dom.div
|
|
205
207
|
{...mergeProps(DOMProps, renderProps, toastProps, focusProps)}
|
|
206
208
|
ref={objectRef}
|
|
207
209
|
data-focused={isFocused || undefined}
|
|
@@ -225,20 +227,22 @@ export const Toast = /*#__PURE__*/ (forwardRef as forwardRefType)(function Toast
|
|
|
225
227
|
]}>
|
|
226
228
|
{renderProps.children}
|
|
227
229
|
</Provider>
|
|
228
|
-
</div>
|
|
230
|
+
</dom.div>
|
|
229
231
|
);
|
|
230
232
|
});
|
|
231
233
|
|
|
234
|
+
export interface ToastContentProps extends HTMLAttributes<HTMLElement>, DOMRenderProps<'div', undefined> {}
|
|
235
|
+
|
|
232
236
|
export const ToastContentContext = createContext<ContextValue<HTMLAttributes<HTMLElement>, HTMLDivElement>>({});
|
|
233
237
|
|
|
234
238
|
/**
|
|
235
239
|
* ToastContent wraps the main content of a toast notification.
|
|
236
240
|
*/
|
|
237
|
-
export const ToastContent = /*#__PURE__*/ forwardRef(function ToastContent(props:
|
|
241
|
+
export const ToastContent = /*#__PURE__*/ forwardRef(function ToastContent(props: ToastContentProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
238
242
|
[props, ref] = useContextProps(props, ref, ToastContentContext);
|
|
239
243
|
return (
|
|
240
|
-
<div className="react-aria-ToastContent" {...props} ref={ref}>
|
|
244
|
+
<dom.div render={props.render} className="react-aria-ToastContent" {...props} ref={ref}>
|
|
241
245
|
{props.children}
|
|
242
|
-
</div>
|
|
246
|
+
</dom.div>
|
|
243
247
|
);
|
|
244
248
|
});
|
package/src/ToggleButton.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {ButtonRenderProps} from './Button';
|
|
|
15
15
|
import {
|
|
16
16
|
ClassNameOrFunction,
|
|
17
17
|
ContextValue,
|
|
18
|
+
dom,
|
|
18
19
|
RenderProps,
|
|
19
20
|
SlotProps,
|
|
20
21
|
useContextProps,
|
|
@@ -39,7 +40,7 @@ export interface ToggleButtonRenderProps extends Omit<ButtonRenderProps, 'isPend
|
|
|
39
40
|
state: ToggleState
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
export interface ToggleButtonProps extends Omit<AriaToggleButtonProps, 'children' | 'elementType' | 'id'>, HoverEvents, SlotProps, RenderProps<ToggleButtonRenderProps>, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {
|
|
43
|
+
export interface ToggleButtonProps extends Omit<AriaToggleButtonProps, 'children' | 'elementType' | 'id'>, HoverEvents, SlotProps, RenderProps<ToggleButtonRenderProps, 'button'>, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {
|
|
43
44
|
/**
|
|
44
45
|
* 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.
|
|
45
46
|
* @default 'react-aria-ToggleButton'
|
|
@@ -71,7 +72,7 @@ export const ToggleButton = /*#__PURE__*/ (forwardRef as forwardRefType)(functio
|
|
|
71
72
|
: useToggleButton({...props, id: props.id != null ? String(props.id) : undefined}, state, ref);
|
|
72
73
|
|
|
73
74
|
let {focusProps, isFocused, isFocusVisible} = useFocusRing(props);
|
|
74
|
-
let {hoverProps, isHovered} = useHover(props);
|
|
75
|
+
let {hoverProps, isHovered} = useHover({...props, isDisabled});
|
|
75
76
|
let renderProps = useRenderProps({
|
|
76
77
|
...props,
|
|
77
78
|
id: undefined,
|
|
@@ -84,7 +85,7 @@ export const ToggleButton = /*#__PURE__*/ (forwardRef as forwardRefType)(functio
|
|
|
84
85
|
delete DOMProps.onClick;
|
|
85
86
|
|
|
86
87
|
return (
|
|
87
|
-
<button
|
|
88
|
+
<dom.button
|
|
88
89
|
{...mergeProps(DOMProps, renderProps, buttonProps, focusProps, hoverProps)}
|
|
89
90
|
ref={ref}
|
|
90
91
|
slot={props.slot || undefined}
|
|
@@ -97,6 +98,6 @@ export const ToggleButton = /*#__PURE__*/ (forwardRef as forwardRefType)(functio
|
|
|
97
98
|
<SelectionIndicatorContext.Provider value={{isSelected}}>
|
|
98
99
|
{renderProps.children}
|
|
99
100
|
</SelectionIndicatorContext.Provider>
|
|
100
|
-
</button>
|
|
101
|
+
</dom.button>
|
|
101
102
|
);
|
|
102
103
|
});
|
|
@@ -13,6 +13,7 @@ import {AriaToggleButtonGroupProps, useToggleButtonGroup} from 'react-aria';
|
|
|
13
13
|
import {
|
|
14
14
|
ClassNameOrFunction,
|
|
15
15
|
ContextValue,
|
|
16
|
+
dom,
|
|
16
17
|
RenderProps,
|
|
17
18
|
SlotProps,
|
|
18
19
|
useContextProps,
|
|
@@ -73,7 +74,7 @@ export const ToggleButtonGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(fu
|
|
|
73
74
|
let DOMProps = filterDOMProps(props, {global: true});
|
|
74
75
|
|
|
75
76
|
return (
|
|
76
|
-
<div
|
|
77
|
+
<dom.div
|
|
77
78
|
{...mergeProps(DOMProps, renderProps, groupProps)}
|
|
78
79
|
ref={ref}
|
|
79
80
|
slot={props.slot || undefined}
|
|
@@ -84,6 +85,6 @@ export const ToggleButtonGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(fu
|
|
|
84
85
|
{renderProps.children}
|
|
85
86
|
</SharedElementTransition>
|
|
86
87
|
</ToggleGroupStateContext.Provider>
|
|
87
|
-
</div>
|
|
88
|
+
</dom.div>
|
|
88
89
|
);
|
|
89
90
|
});
|
package/src/Toolbar.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import {AriaToolbarProps, useToolbar} from '@react-aria/toolbar';
|
|
|
14
14
|
import {
|
|
15
15
|
ClassNameOrFunction,
|
|
16
16
|
ContextValue,
|
|
17
|
+
dom,
|
|
17
18
|
RenderProps,
|
|
18
19
|
SlotProps,
|
|
19
20
|
useContextProps,
|
|
@@ -57,12 +58,12 @@ export const Toolbar = /*#__PURE__*/ (forwardRef as forwardRefType)(function Too
|
|
|
57
58
|
delete DOMProps.id;
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
|
-
<div
|
|
61
|
+
<dom.div
|
|
61
62
|
{...mergeProps(DOMProps, renderProps, toolbarProps)}
|
|
62
63
|
ref={ref}
|
|
63
64
|
slot={props.slot || undefined}
|
|
64
65
|
data-orientation={props.orientation || 'horizontal'}>
|
|
65
66
|
{renderProps.children}
|
|
66
|
-
</div>
|
|
67
|
+
</dom.div>
|
|
67
68
|
);
|
|
68
69
|
});
|
package/src/Tooltip.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {AriaPositionProps, mergeProps, OverlayContainer, Placement, PlacementAxi
|
|
|
15
15
|
import {
|
|
16
16
|
ClassNameOrFunction,
|
|
17
17
|
ContextValue,
|
|
18
|
+
dom,
|
|
18
19
|
Provider,
|
|
19
20
|
RenderProps,
|
|
20
21
|
useContextProps,
|
|
@@ -167,7 +168,7 @@ function TooltipInner(props: TooltipProps & {isExiting: boolean, tooltipRef: Ref
|
|
|
167
168
|
let DOMProps = filterDOMProps(props, {global: true});
|
|
168
169
|
|
|
169
170
|
return (
|
|
170
|
-
<div
|
|
171
|
+
<dom.div
|
|
171
172
|
{...mergeProps(DOMProps, renderProps, tooltipProps)}
|
|
172
173
|
ref={props.tooltipRef}
|
|
173
174
|
style={{
|
|
@@ -181,6 +182,6 @@ function TooltipInner(props: TooltipProps & {isExiting: boolean, tooltipRef: Ref
|
|
|
181
182
|
<OverlayArrowContext.Provider value={{...arrowProps, placement, ref: arrowRef}}>
|
|
182
183
|
{renderProps.children}
|
|
183
184
|
</OverlayArrowContext.Provider>
|
|
184
|
-
</div>
|
|
185
|
+
</dom.div>
|
|
185
186
|
);
|
|
186
187
|
}
|
package/src/Tree.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
ClassNameOrFunction,
|
|
19
19
|
ContextValue,
|
|
20
20
|
DEFAULT_SLOT,
|
|
21
|
+
dom,
|
|
21
22
|
Provider,
|
|
22
23
|
RenderProps,
|
|
23
24
|
SlotProps,
|
|
@@ -372,8 +373,8 @@ function TreeInner<T extends object>({props, collection, treeRef: ref}: TreeInne
|
|
|
372
373
|
};
|
|
373
374
|
|
|
374
375
|
let renderProps = useRenderProps({
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
...props,
|
|
377
|
+
children: undefined,
|
|
377
378
|
defaultClassName: 'react-aria-Tree',
|
|
378
379
|
values: renderValues
|
|
379
380
|
});
|
|
@@ -401,7 +402,7 @@ function TreeInner<T extends object>({props, collection, treeRef: ref}: TreeInne
|
|
|
401
402
|
return (
|
|
402
403
|
<>
|
|
403
404
|
<FocusScope>
|
|
404
|
-
<div
|
|
405
|
+
<dom.div
|
|
405
406
|
{...mergeProps(DOMProps, renderProps, gridProps, focusProps, droppableCollection?.collectionProps)}
|
|
406
407
|
ref={ref}
|
|
407
408
|
slot={props.slot || undefined}
|
|
@@ -427,7 +428,7 @@ function TreeInner<T extends object>({props, collection, treeRef: ref}: TreeInne
|
|
|
427
428
|
</SharedElementTransition>
|
|
428
429
|
</Provider>
|
|
429
430
|
{emptyState}
|
|
430
|
-
</div>
|
|
431
|
+
</dom.div>
|
|
431
432
|
</FocusScope>
|
|
432
433
|
{dragPreview}
|
|
433
434
|
</>
|
|
@@ -673,15 +674,15 @@ export const TreeItem = /*#__PURE__*/ createBranchComponent(TreeItemNode, <T ext
|
|
|
673
674
|
</div>
|
|
674
675
|
</div>
|
|
675
676
|
)}
|
|
676
|
-
<div
|
|
677
|
+
<dom.div
|
|
677
678
|
{...mergeProps(
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
679
|
+
DOMProps,
|
|
680
|
+
rowProps,
|
|
681
|
+
focusProps,
|
|
682
|
+
hoverProps,
|
|
683
|
+
focusWithinProps,
|
|
684
|
+
draggableItem?.dragProps
|
|
685
|
+
)}
|
|
685
686
|
{...renderProps}
|
|
686
687
|
ref={ref}
|
|
687
688
|
// TODO: missing selectionBehavior, hasAction and allowsSelection data attribute equivalents (available in renderProps). Do we want those?
|
|
@@ -732,7 +733,7 @@ export const TreeItem = /*#__PURE__*/ createBranchComponent(TreeItemNode, <T ext
|
|
|
732
733
|
{children}
|
|
733
734
|
</Provider>
|
|
734
735
|
</div>
|
|
735
|
-
</div>
|
|
736
|
+
</dom.div>
|
|
736
737
|
</>
|
|
737
738
|
);
|
|
738
739
|
});
|
|
@@ -811,7 +812,7 @@ export const TreeLoadMoreItem = createLeafComponent(LoaderNode, function TreeLoa
|
|
|
811
812
|
<div data-testid="loadMoreSentinel" ref={sentinelRef} style={{position: 'absolute', height: 1, width: 1}} />
|
|
812
813
|
</div>
|
|
813
814
|
{isLoading && renderProps.children && (
|
|
814
|
-
<div
|
|
815
|
+
<dom.div
|
|
815
816
|
ref={ref}
|
|
816
817
|
{...mergeProps(filterDOMProps(props as any), ariaProps)}
|
|
817
818
|
{...renderProps}
|
|
@@ -819,7 +820,7 @@ export const TreeLoadMoreItem = createLeafComponent(LoaderNode, function TreeLoa
|
|
|
819
820
|
<div {...gridCellProps} style={style}>
|
|
820
821
|
{renderProps.children}
|
|
821
822
|
</div>
|
|
822
|
-
</div>
|
|
823
|
+
</dom.div>
|
|
823
824
|
)}
|
|
824
825
|
</>
|
|
825
826
|
);
|
|
@@ -963,7 +964,7 @@ function TreeDropIndicator(props: TreeDropIndicatorProps, ref: ForwardedRef<HTML
|
|
|
963
964
|
});
|
|
964
965
|
|
|
965
966
|
return (
|
|
966
|
-
<div
|
|
967
|
+
<dom.div
|
|
967
968
|
{...renderProps}
|
|
968
969
|
role="row"
|
|
969
970
|
aria-level={level}
|
|
@@ -973,7 +974,7 @@ function TreeDropIndicator(props: TreeDropIndicatorProps, ref: ForwardedRef<HTML
|
|
|
973
974
|
<div {...visuallyHiddenProps} role="button" {...dropIndicatorProps} ref={buttonRef} />
|
|
974
975
|
{renderProps.children}
|
|
975
976
|
</div>
|
|
976
|
-
</div>
|
|
977
|
+
</dom.div>
|
|
977
978
|
);
|
|
978
979
|
}
|
|
979
980
|
|
package/src/utils.tsx
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {AriaLabelingProps, RefObject, DOMProps as SharedDOMProps} from '@react-types/shared';
|
|
14
14
|
import {mergeProps, mergeRefs, useLayoutEffect, useObjectRef} from '@react-aria/utils';
|
|
15
|
-
import React, {Context, CSSProperties, ForwardedRef, JSX, ReactNode, RefCallback, useCallback, useContext, useMemo, useRef, useState} from 'react';
|
|
15
|
+
import React, {AllHTMLAttributes, AnchorHTMLAttributes, Context, CSSProperties, DetailedHTMLProps, ForwardedRef, forwardRef, JSX, ReactElement, ReactNode, RefCallback, useCallback, useContext, useMemo, useRef, useState} from 'react';
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_SLOT = Symbol('default');
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ interface SlottedValue<T> {
|
|
|
20
20
|
slots?: Record<string | symbol, T>
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export type SlottedContextValue<T> = SlottedValue<T>
|
|
23
|
+
export type SlottedContextValue<T> = (SlottedValue<T> & T) | null | undefined;
|
|
24
24
|
export type ContextValue<T, E> = SlottedContextValue<WithRef<T, E>>;
|
|
25
25
|
|
|
26
26
|
type ProviderValue<T> = [Context<T>, T];
|
|
@@ -66,7 +66,7 @@ export interface DOMProps extends StyleProps, SharedDOMProps {
|
|
|
66
66
|
export type ClassNameOrFunction<T> = string | ((values: T & {defaultClassName: string | undefined}) => string);
|
|
67
67
|
type StyleOrFunction<T> = CSSProperties | ((values: T & {defaultStyle: CSSProperties}) => CSSProperties | undefined);
|
|
68
68
|
|
|
69
|
-
export interface StyleRenderProps<T> {
|
|
69
|
+
export interface StyleRenderProps<T, E extends keyof React.JSX.IntrinsicElements = 'div'> extends DOMRenderProps<E, T> {
|
|
70
70
|
/** 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. */
|
|
71
71
|
className?: ClassNameOrFunction<T>,
|
|
72
72
|
/** The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. */
|
|
@@ -75,26 +75,27 @@ export interface StyleRenderProps<T> {
|
|
|
75
75
|
|
|
76
76
|
export type ChildrenOrFunction<T> = ReactNode | ((values: T & {defaultChildren: ReactNode | undefined}) => ReactNode);
|
|
77
77
|
|
|
78
|
-
export interface RenderProps<T> extends StyleRenderProps<T> {
|
|
78
|
+
export interface RenderProps<T, E extends keyof React.JSX.IntrinsicElements = 'div'> extends StyleRenderProps<T, E> {
|
|
79
79
|
/** The children of the component. A function may be provided to alter the children based on component state. */
|
|
80
80
|
children?: ChildrenOrFunction<T>
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
interface RenderPropsHookOptions<T> extends RenderProps<T>, SharedDOMProps, AriaLabelingProps {
|
|
83
|
+
interface RenderPropsHookOptions<T, E extends keyof React.JSX.IntrinsicElements> extends RenderProps<T, E>, SharedDOMProps, AriaLabelingProps {
|
|
84
84
|
values: T,
|
|
85
85
|
defaultChildren?: ReactNode,
|
|
86
86
|
defaultClassName?: string,
|
|
87
87
|
defaultStyle?: CSSProperties
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
interface RenderPropsHookRetVal {
|
|
90
|
+
interface RenderPropsHookRetVal<T, E extends keyof React.JSX.IntrinsicElements> {
|
|
91
91
|
className?: string,
|
|
92
92
|
style?: CSSProperties,
|
|
93
93
|
children?: ReactNode,
|
|
94
|
-
'data-rac': string
|
|
94
|
+
'data-rac': string,
|
|
95
|
+
render?: DOMRenderFunction<E, T>
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
export function useRenderProps<T>(props: RenderPropsHookOptions<T>): RenderPropsHookRetVal {
|
|
98
|
+
export function useRenderProps<T, E extends keyof React.JSX.IntrinsicElements>(props: RenderPropsHookOptions<T, E>): RenderPropsHookRetVal<T, E> {
|
|
98
99
|
let {
|
|
99
100
|
className,
|
|
100
101
|
style,
|
|
@@ -102,7 +103,8 @@ export function useRenderProps<T>(props: RenderPropsHookOptions<T>): RenderProps
|
|
|
102
103
|
defaultClassName = undefined,
|
|
103
104
|
defaultChildren = undefined,
|
|
104
105
|
defaultStyle,
|
|
105
|
-
values
|
|
106
|
+
values,
|
|
107
|
+
render
|
|
106
108
|
} = props;
|
|
107
109
|
|
|
108
110
|
return useMemo(() => {
|
|
@@ -134,9 +136,10 @@ export function useRenderProps<T>(props: RenderPropsHookOptions<T>): RenderProps
|
|
|
134
136
|
className: computedClassName ?? defaultClassName,
|
|
135
137
|
style: (computedStyle || defaultStyle) ? {...defaultStyle, ...computedStyle} : undefined,
|
|
136
138
|
children: computedChildren ?? defaultChildren,
|
|
137
|
-
'data-rac': ''
|
|
139
|
+
'data-rac': '',
|
|
140
|
+
render: render ? (props => render(props, values)) : undefined
|
|
138
141
|
};
|
|
139
|
-
}, [className, style, children, defaultClassName, defaultChildren, defaultStyle, values]);
|
|
142
|
+
}, [className, style, children, defaultClassName, defaultChildren, defaultStyle, values, render]);
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
/**
|
|
@@ -262,3 +265,86 @@ export interface RACValidation {
|
|
|
262
265
|
*/
|
|
263
266
|
validationBehavior?: 'native' | 'aria'
|
|
264
267
|
}
|
|
268
|
+
|
|
269
|
+
export type DOMRenderFunction<E extends keyof React.JSX.IntrinsicElements, T> = (props: React.JSX.IntrinsicElements[E], renderProps: T) => ReactElement;
|
|
270
|
+
export interface DOMRenderProps<E extends keyof React.JSX.IntrinsicElements, T> {
|
|
271
|
+
/**
|
|
272
|
+
* Overrides the default DOM element with a custom render function.
|
|
273
|
+
* This allows rendering existing components with built-in styles and behaviors
|
|
274
|
+
* such as router links, animation libraries, and pre-styled components.
|
|
275
|
+
*
|
|
276
|
+
* Requirements:
|
|
277
|
+
*
|
|
278
|
+
* * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`).
|
|
279
|
+
* * Only a single root DOM element can be rendered (no fragments).
|
|
280
|
+
* * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
|
|
281
|
+
*/
|
|
282
|
+
render?: DOMRenderFunction<E, T>
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Makes `href` required in AnchorHTMLAttributes
|
|
286
|
+
type LinkWithRequiredHref = Required<Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>> & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;
|
|
287
|
+
|
|
288
|
+
// Same as DOMRenderProps but specific for the case where the element could be a 'a' or 'div' element.
|
|
289
|
+
export interface PossibleLinkDOMRenderProps<Fallback extends keyof React.JSX.IntrinsicElements, T> {
|
|
290
|
+
/**
|
|
291
|
+
* Overrides the default DOM element with a custom render function.
|
|
292
|
+
* This allows rendering existing components with built-in styles and behaviors
|
|
293
|
+
* such as router links, animation libraries, and pre-styled components.
|
|
294
|
+
*
|
|
295
|
+
* Note: You can check if `'href' in props` in order to tell whether to render an `<a>` element.
|
|
296
|
+
*
|
|
297
|
+
* Requirements:
|
|
298
|
+
*
|
|
299
|
+
* * You must render the expected element type (e.g. if `<a>` is expected, you cannot render a `<button>`).
|
|
300
|
+
* * Only a single root DOM element can be rendered (no fragments).
|
|
301
|
+
* * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
|
|
302
|
+
*/
|
|
303
|
+
render?: (props: DetailedHTMLProps<LinkWithRequiredHref, HTMLAnchorElement> | React.JSX.IntrinsicElements[Fallback], renderProps: T) => ReactElement
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function DOMElement(ElementType: string, props: DOMRenderProps<any, any> & AllHTMLAttributes<HTMLElement>, forwardedRef: ForwardedRef<HTMLElement>) {
|
|
307
|
+
let {render, ...otherProps} = props;
|
|
308
|
+
let elementRef = useRef<HTMLElement | null>(null);
|
|
309
|
+
let ref = useMemo(() => mergeRefs(forwardedRef, elementRef), [forwardedRef, elementRef]);
|
|
310
|
+
|
|
311
|
+
useLayoutEffect(() => {
|
|
312
|
+
if (process.env.NODE_ENV !== 'production' && render) {
|
|
313
|
+
if (!elementRef.current) {
|
|
314
|
+
console.warn('Ref was not connected to DOM element returned by custom `render` function. Did you forget to pass through or merge the `ref`?');
|
|
315
|
+
} else if (elementRef.current.localName !== ElementType) {
|
|
316
|
+
console.warn(`Unexpected DOM element returned by custom \`render\` function. Expected <${ElementType}>, got <${elementRef.current.localName}>. This may break the component behavior and accessibility.`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}, [ElementType, render]);
|
|
320
|
+
|
|
321
|
+
let domProps: any = {...otherProps, ref};
|
|
322
|
+
if (render) {
|
|
323
|
+
return render(domProps, undefined);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return <ElementType {...domProps} />;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
type DOMComponents = {
|
|
330
|
+
[E in keyof React.JSX.IntrinsicElements]: (props: DOMRenderProps<E, any> & React.JSX.IntrinsicElements[E]) => ReactElement
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const domComponentCache = {};
|
|
334
|
+
|
|
335
|
+
// Dynamically generates and caches components for each DOM element (e.g. `dom.button`).
|
|
336
|
+
export const dom = new Proxy({}, {
|
|
337
|
+
get(target, elementType) {
|
|
338
|
+
if (typeof elementType !== 'string') {
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
let res = domComponentCache[elementType];
|
|
343
|
+
if (!res) {
|
|
344
|
+
res = forwardRef(DOMElement.bind(null, elementType));
|
|
345
|
+
domComponentCache[elementType] = res;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return res;
|
|
349
|
+
}
|
|
350
|
+
}) as DOMComponents;
|