@react-spectrum/s2 0.7.0 → 0.8.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/ActionBar.cjs.map +1 -1
- package/dist/ActionBar.css.map +1 -1
- package/dist/ActionBar.mjs.map +1 -1
- package/dist/ActionButton.cjs +26 -7
- package/dist/ActionButton.cjs.map +1 -1
- package/dist/ActionButton.css +74 -18
- package/dist/ActionButton.css.map +1 -1
- package/dist/ActionButton.mjs +26 -7
- package/dist/ActionButton.mjs.map +1 -1
- package/dist/Add.cjs.map +1 -1
- package/dist/Add.mjs.map +1 -1
- package/dist/Asterisk.cjs.map +1 -1
- package/dist/Asterisk.mjs.map +1 -1
- package/dist/Breadcrumbs.cjs.map +1 -1
- package/dist/Breadcrumbs.css.map +1 -1
- package/dist/Breadcrumbs.mjs.map +1 -1
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs.map +1 -1
- package/dist/ButtonGroup.cjs +3 -2
- package/dist/ButtonGroup.cjs.map +1 -1
- package/dist/ButtonGroup.css.map +1 -1
- package/dist/ButtonGroup.mjs +3 -2
- package/dist/ButtonGroup.mjs.map +1 -1
- package/dist/Card.cjs +1 -1
- package/dist/Card.cjs.map +1 -1
- package/dist/Card.css.map +1 -1
- package/dist/Card.mjs +1 -1
- package/dist/Card.mjs.map +1 -1
- package/dist/CenterBaseline.cjs.map +1 -1
- package/dist/CenterBaseline.css.map +1 -1
- package/dist/CenterBaseline.mjs.map +1 -1
- package/dist/Checkmark.cjs.map +1 -1
- package/dist/Checkmark.mjs.map +1 -1
- package/dist/Chevron.cjs.map +1 -1
- package/dist/Chevron.mjs.map +1 -1
- package/dist/ColorHandle.cjs.map +1 -1
- package/dist/ColorHandle.css.map +1 -1
- package/dist/ColorHandle.mjs.map +1 -1
- package/dist/ColorSwatchPicker.cjs +2 -2
- package/dist/ColorSwatchPicker.cjs.map +1 -1
- package/dist/ColorSwatchPicker.css.map +1 -1
- package/dist/ColorSwatchPicker.mjs +2 -2
- package/dist/ColorSwatchPicker.mjs.map +1 -1
- package/dist/ComboBox.cjs.map +1 -1
- package/dist/ComboBox.css.map +1 -1
- package/dist/ComboBox.mjs.map +1 -1
- package/dist/Content.cjs +6 -6
- package/dist/Content.cjs.map +1 -1
- package/dist/Content.mjs +6 -6
- package/dist/Content.mjs.map +1 -1
- package/dist/Cross.cjs.map +1 -1
- package/dist/Cross.mjs.map +1 -1
- package/dist/Dash.cjs.map +1 -1
- package/dist/Dash.mjs.map +1 -1
- package/dist/DialogContainer.cjs.map +1 -1
- package/dist/DialogContainer.mjs.map +1 -1
- package/dist/DialogTrigger.cjs.map +1 -1
- package/dist/DialogTrigger.mjs.map +1 -1
- package/dist/Disclosure.cjs +24 -21
- package/dist/Disclosure.cjs.map +1 -1
- package/dist/Disclosure.css +12 -20
- package/dist/Disclosure.css.map +1 -1
- package/dist/Disclosure.mjs +24 -21
- package/dist/Disclosure.mjs.map +1 -1
- package/dist/Divider.cjs +6 -0
- package/dist/Divider.cjs.map +1 -1
- package/dist/Divider.css +8 -0
- package/dist/Divider.css.map +1 -1
- package/dist/Divider.mjs +6 -0
- package/dist/Divider.mjs.map +1 -1
- package/dist/Field.cjs.map +1 -1
- package/dist/Field.css.map +1 -1
- package/dist/Field.mjs.map +1 -1
- package/dist/Image.cjs +1 -1
- package/dist/Image.cjs.map +1 -1
- package/dist/Image.css.map +1 -1
- package/dist/Image.mjs +1 -1
- package/dist/Image.mjs.map +1 -1
- package/dist/ImageCoordinator.cjs.map +1 -1
- package/dist/ImageCoordinator.mjs.map +1 -1
- package/dist/Link.cjs.map +1 -1
- package/dist/Link.css.map +1 -1
- package/dist/Link.mjs.map +1 -1
- package/dist/LinkOut.cjs.map +1 -1
- package/dist/LinkOut.mjs.map +1 -1
- package/dist/Menu.cjs.map +1 -1
- package/dist/Menu.css.map +1 -1
- package/dist/Menu.mjs.map +1 -1
- package/dist/NotificationBadge.cjs +163 -0
- package/dist/NotificationBadge.cjs.map +1 -0
- package/dist/NotificationBadge.css +227 -0
- package/dist/NotificationBadge.css.map +1 -0
- package/dist/NotificationBadge.mjs +157 -0
- package/dist/NotificationBadge.mjs.map +1 -0
- package/dist/Picker.cjs.map +1 -1
- package/dist/Picker.css.map +1 -1
- package/dist/Picker.mjs.map +1 -1
- package/dist/Provider.cjs.map +1 -1
- package/dist/Provider.css.map +1 -1
- package/dist/Provider.mjs.map +1 -1
- package/dist/Slider.cjs.map +1 -1
- package/dist/Slider.css.map +1 -1
- package/dist/Slider.mjs.map +1 -1
- package/dist/StatusLight.cjs +2 -2
- package/dist/StatusLight.cjs.map +1 -1
- package/dist/StatusLight.css.map +1 -1
- package/dist/StatusLight.mjs +2 -2
- package/dist/StatusLight.mjs.map +1 -1
- package/dist/Tabs.cjs +1 -0
- package/dist/Tabs.cjs.map +1 -1
- package/dist/Tabs.css.map +1 -1
- package/dist/Tabs.mjs +1 -0
- package/dist/Tabs.mjs.map +1 -1
- package/dist/TabsPicker.cjs.map +1 -1
- package/dist/TabsPicker.css.map +1 -1
- package/dist/TabsPicker.mjs.map +1 -1
- package/dist/Toast.cjs +557 -0
- package/dist/Toast.cjs.map +1 -0
- package/dist/Toast.css +461 -0
- package/dist/Toast.css.map +1 -0
- package/dist/Toast.mjs +551 -0
- package/dist/Toast.mjs.map +1 -0
- package/dist/Toast_module.cjs +70 -0
- package/dist/Toast_module.cjs.map +1 -0
- package/dist/Toast_module.css +119 -0
- package/dist/Toast_module.css.map +1 -0
- package/dist/Toast_module.mjs +72 -0
- package/dist/Toast_module.mjs.map +1 -0
- package/dist/ToggleButton.cjs.map +1 -1
- package/dist/ToggleButton.css.map +1 -1
- package/dist/ToggleButton.mjs.map +1 -1
- package/dist/Tooltip.cjs.map +1 -1
- package/dist/Tooltip.css.map +1 -1
- package/dist/Tooltip.mjs.map +1 -1
- package/dist/TreeView.cjs.map +1 -1
- package/dist/TreeView.css.map +1 -1
- package/dist/TreeView.mjs.map +1 -1
- package/dist/ar-AE.cjs +6 -1
- package/dist/ar-AE.cjs.map +1 -1
- package/dist/ar-AE.mjs +6 -1
- package/dist/ar-AE.mjs.map +1 -1
- package/dist/bg-BG.cjs +6 -1
- package/dist/bg-BG.cjs.map +1 -1
- package/dist/bg-BG.mjs +6 -1
- package/dist/bg-BG.mjs.map +1 -1
- package/dist/cs-CZ.cjs +10 -2
- package/dist/cs-CZ.cjs.map +1 -1
- package/dist/cs-CZ.mjs +10 -2
- package/dist/cs-CZ.mjs.map +1 -1
- package/dist/da-DK.cjs +8 -3
- package/dist/da-DK.cjs.map +1 -1
- package/dist/da-DK.mjs +8 -3
- package/dist/da-DK.mjs.map +1 -1
- package/dist/de-DE.cjs +7 -3
- package/dist/de-DE.cjs.map +1 -1
- package/dist/de-DE.mjs +7 -3
- package/dist/de-DE.mjs.map +1 -1
- package/dist/el-GR.cjs +6 -1
- package/dist/el-GR.cjs.map +1 -1
- package/dist/el-GR.mjs +6 -1
- package/dist/el-GR.mjs.map +1 -1
- package/dist/en-US.cjs +6 -1
- package/dist/en-US.cjs.map +1 -1
- package/dist/en-US.mjs +6 -1
- package/dist/en-US.mjs.map +1 -1
- package/dist/es-ES.cjs +10 -6
- package/dist/es-ES.cjs.map +1 -1
- package/dist/es-ES.mjs +10 -6
- package/dist/es-ES.mjs.map +1 -1
- package/dist/et-EE.cjs +6 -1
- package/dist/et-EE.cjs.map +1 -1
- package/dist/et-EE.mjs +6 -1
- package/dist/et-EE.mjs.map +1 -1
- package/dist/fi-FI.cjs +7 -2
- package/dist/fi-FI.cjs.map +1 -1
- package/dist/fi-FI.mjs +7 -2
- package/dist/fi-FI.mjs.map +1 -1
- package/dist/fr-FR.cjs +7 -3
- package/dist/fr-FR.cjs.map +1 -1
- package/dist/fr-FR.mjs +7 -3
- package/dist/fr-FR.mjs.map +1 -1
- package/dist/he-IL.cjs +9 -5
- package/dist/he-IL.cjs.map +1 -1
- package/dist/he-IL.mjs +9 -5
- package/dist/he-IL.mjs.map +1 -1
- package/dist/hr-HR.cjs +11 -3
- package/dist/hr-HR.cjs.map +1 -1
- package/dist/hr-HR.mjs +11 -3
- package/dist/hr-HR.mjs.map +1 -1
- package/dist/hu-HU.cjs +6 -1
- package/dist/hu-HU.cjs.map +1 -1
- package/dist/hu-HU.mjs +6 -1
- package/dist/hu-HU.mjs.map +1 -1
- package/dist/it-IT.cjs +6 -2
- package/dist/it-IT.cjs.map +1 -1
- package/dist/it-IT.mjs +6 -2
- package/dist/it-IT.mjs.map +1 -1
- package/dist/ja-JP.cjs +7 -2
- package/dist/ja-JP.cjs.map +1 -1
- package/dist/ja-JP.mjs +7 -2
- package/dist/ja-JP.mjs.map +1 -1
- package/dist/ko-KR.cjs +8 -3
- package/dist/ko-KR.cjs.map +1 -1
- package/dist/ko-KR.mjs +8 -3
- package/dist/ko-KR.mjs.map +1 -1
- package/dist/lt-LT.cjs +8 -3
- package/dist/lt-LT.cjs.map +1 -1
- package/dist/lt-LT.mjs +8 -3
- package/dist/lt-LT.mjs.map +1 -1
- package/dist/lv-LV.cjs +9 -4
- package/dist/lv-LV.cjs.map +1 -1
- package/dist/lv-LV.mjs +9 -4
- package/dist/lv-LV.mjs.map +1 -1
- package/dist/main.cjs +9 -0
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +6 -2
- package/dist/module.mjs.map +1 -1
- package/dist/nb-NO.cjs +12 -4
- package/dist/nb-NO.cjs.map +1 -1
- package/dist/nb-NO.mjs +12 -4
- package/dist/nb-NO.mjs.map +1 -1
- package/dist/nl-NL.cjs +6 -1
- package/dist/nl-NL.cjs.map +1 -1
- package/dist/nl-NL.mjs +6 -1
- package/dist/nl-NL.mjs.map +1 -1
- package/dist/pl-PL.cjs +11 -3
- package/dist/pl-PL.cjs.map +1 -1
- package/dist/pl-PL.mjs +11 -3
- package/dist/pl-PL.mjs.map +1 -1
- package/dist/pressScale.cjs.map +1 -1
- package/dist/pressScale.mjs.map +1 -1
- package/dist/pt-BR.cjs +6 -1
- package/dist/pt-BR.cjs.map +1 -1
- package/dist/pt-BR.mjs +6 -1
- package/dist/pt-BR.mjs.map +1 -1
- package/dist/pt-PT.cjs +6 -1
- package/dist/pt-PT.cjs.map +1 -1
- package/dist/pt-PT.mjs +6 -1
- package/dist/pt-PT.mjs.map +1 -1
- package/dist/ro-RO.cjs +8 -4
- package/dist/ro-RO.cjs.map +1 -1
- package/dist/ro-RO.mjs +8 -4
- package/dist/ro-RO.mjs.map +1 -1
- package/dist/ru-RU.cjs +11 -3
- package/dist/ru-RU.cjs.map +1 -1
- package/dist/ru-RU.mjs +11 -3
- package/dist/ru-RU.mjs.map +1 -1
- package/dist/sk-SK.cjs +10 -2
- package/dist/sk-SK.cjs.map +1 -1
- package/dist/sk-SK.mjs +10 -2
- package/dist/sk-SK.mjs.map +1 -1
- package/dist/sl-SI.cjs +11 -3
- package/dist/sl-SI.cjs.map +1 -1
- package/dist/sl-SI.mjs +11 -3
- package/dist/sl-SI.mjs.map +1 -1
- package/dist/sr-SP.cjs +10 -2
- package/dist/sr-SP.cjs.map +1 -1
- package/dist/sr-SP.mjs +10 -2
- package/dist/sr-SP.mjs.map +1 -1
- package/dist/sv-SE.cjs +6 -2
- package/dist/sv-SE.cjs.map +1 -1
- package/dist/sv-SE.mjs +6 -2
- package/dist/sv-SE.mjs.map +1 -1
- package/dist/tr-TR.cjs +7 -2
- package/dist/tr-TR.cjs.map +1 -1
- package/dist/tr-TR.mjs +7 -2
- package/dist/tr-TR.mjs.map +1 -1
- package/dist/types.d.ts +97 -29
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.cjs +10 -2
- package/dist/uk-UA.cjs.map +1 -1
- package/dist/uk-UA.mjs +10 -2
- package/dist/uk-UA.mjs.map +1 -1
- package/dist/zh-CN.cjs +6 -1
- package/dist/zh-CN.cjs.map +1 -1
- package/dist/zh-CN.mjs +6 -1
- package/dist/zh-CN.mjs.map +1 -1
- package/dist/zh-TW.cjs +6 -1
- package/dist/zh-TW.cjs.map +1 -1
- package/dist/zh-TW.mjs +6 -1
- package/dist/zh-TW.mjs.map +1 -1
- package/icons/Skeleton.cjs.map +1 -1
- package/icons/Skeleton.css.map +1 -1
- package/icons/Skeleton.mjs.map +1 -1
- package/package.json +21 -19
- package/src/ActionBar.tsx +9 -2
- package/src/ActionButton.tsx +38 -3
- package/src/Breadcrumbs.tsx +1 -1
- package/src/Button.tsx +2 -2
- package/src/ButtonGroup.tsx +4 -2
- package/src/Calendar.tsx +2 -1
- package/src/Card.tsx +1 -1
- package/src/CenterBaseline.tsx +1 -1
- package/src/ColorHandle.tsx +2 -2
- package/src/ColorSwatchPicker.tsx +2 -1
- package/src/ComboBox.tsx +2 -2
- package/src/Content.tsx +6 -6
- package/src/DateField.tsx +1 -1
- package/src/DatePicker.tsx +1 -1
- package/src/DateRangePicker.tsx +1 -1
- package/src/DialogContainer.tsx +2 -2
- package/src/DialogTrigger.tsx +2 -1
- package/src/Disclosure.tsx +18 -24
- package/src/Divider.tsx +2 -0
- package/src/Field.tsx +2 -2
- package/src/Image.tsx +1 -1
- package/src/ImageCoordinator.tsx +3 -3
- package/src/Link.tsx +1 -1
- package/src/ListBox.tsx +3 -2
- package/src/Menu.tsx +5 -5
- package/src/NotificationBadge.tsx +172 -0
- package/src/Picker.tsx +2 -2
- package/src/Provider.tsx +1 -1
- package/src/RangeCalendar.tsx +2 -1
- package/src/Skeleton.tsx +4 -4
- package/src/Slider.tsx +1 -1
- package/src/StatusLight.tsx +2 -2
- package/src/Tabs.tsx +4 -3
- package/src/TabsPicker.tsx +1 -1
- package/src/TimeField.tsx +1 -1
- package/src/Toast.module.css +153 -0
- package/src/Toast.tsx +579 -0
- package/src/ToggleButton.tsx +1 -1
- package/src/Toolbar.tsx +2 -1
- package/src/Tooltip.tsx +2 -2
- package/src/TreeView.tsx +2 -2
- package/src/index.ts +6 -1
- package/src/page.macro.ts +3 -3
- package/src/pressScale.ts +1 -1
- package/src/style-utils.ts +2 -2
- package/style/dist/main.cjs +18 -18
- package/style/dist/module.mjs +9 -9
- package/style/dist/spectrum-theme.cjs +191 -191
- package/style/dist/spectrum-theme.cjs.map +1 -1
- package/style/dist/spectrum-theme.mjs +183 -183
- package/style/dist/spectrum-theme.mjs.map +1 -1
- package/style/dist/style-macro.cjs +74 -74
- package/style/dist/style-macro.cjs.map +1 -1
- package/style/dist/style-macro.mjs +68 -68
- package/style/dist/style-macro.mjs.map +1 -1
- package/style/dist/types.d.ts +4 -4
- package/style/dist/types.d.ts.map +1 -1
- package/style/spectrum-theme.ts +5 -5
- package/style/style-macro.ts +3 -3
- package/style/tokens.ts +22 -6
package/src/ButtonGroup.tsx
CHANGED
|
@@ -14,13 +14,13 @@ import {ButtonContext, LinkButtonContext} from './Button';
|
|
|
14
14
|
import {ContextValue, Provider, SlotProps} from 'react-aria-components';
|
|
15
15
|
import {createContext, forwardRef, ReactNode, useCallback, useRef} from 'react';
|
|
16
16
|
import {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';
|
|
17
|
+
import {filterDOMProps, useLayoutEffect, useValueEffect} from '@react-aria/utils';
|
|
17
18
|
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
18
19
|
import {style} from '../style' with {type: 'macro'};
|
|
19
20
|
import {
|
|
20
21
|
useDOMRef,
|
|
21
22
|
useResizeObserver
|
|
22
23
|
} from '@react-spectrum/utils';
|
|
23
|
-
import {useLayoutEffect, useValueEffect} from '@react-aria/utils';
|
|
24
24
|
import {useSpectrumContextProps} from './useSpectrumContextProps';
|
|
25
25
|
|
|
26
26
|
interface ButtonGroupStyleProps {
|
|
@@ -112,7 +112,8 @@ export const ButtonGroup = forwardRef(function ButtonGroup(props: ButtonGroupPro
|
|
|
112
112
|
orientation = 'horizontal',
|
|
113
113
|
align = 'start',
|
|
114
114
|
children,
|
|
115
|
-
isDisabled
|
|
115
|
+
isDisabled,
|
|
116
|
+
...otherProps
|
|
116
117
|
} = props;
|
|
117
118
|
|
|
118
119
|
let [hasOverflow, setHasOverflow] = useValueEffect(false);
|
|
@@ -165,6 +166,7 @@ export const ButtonGroup = forwardRef(function ButtonGroup(props: ButtonGroupPro
|
|
|
165
166
|
let context = {styles: style({flexShrink: 0}), size, isDisabled};
|
|
166
167
|
return (
|
|
167
168
|
<div
|
|
169
|
+
{...filterDOMProps(otherProps)}
|
|
168
170
|
ref={domRef}
|
|
169
171
|
style={props.UNSAFE_style}
|
|
170
172
|
className={(props.UNSAFE_className || '') + buttongroup({
|
package/src/Calendar.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
Heading,
|
|
21
21
|
Text
|
|
22
22
|
} from 'react-aria-components';
|
|
23
|
+
import {ReactNode} from 'react';
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
export interface CalendarProps<T extends DateValue>
|
|
@@ -29,7 +30,7 @@ export interface CalendarProps<T extends DateValue>
|
|
|
29
30
|
|
|
30
31
|
export function Calendar<T extends DateValue>(
|
|
31
32
|
{errorMessage, ...props}: CalendarProps<T>
|
|
32
|
-
) {
|
|
33
|
+
): ReactNode {
|
|
33
34
|
return (
|
|
34
35
|
<AriaCalendar {...props}>
|
|
35
36
|
<header>
|
package/src/Card.tsx
CHANGED
|
@@ -501,7 +501,7 @@ export interface CardPreviewProps extends UnsafeStyles, DOMProps {
|
|
|
501
501
|
|
|
502
502
|
export const CardPreview = forwardRef(function CardPreview(props: CardPreviewProps, ref: DOMRef<HTMLDivElement>) {
|
|
503
503
|
let {size, isQuiet, isHovered, isFocusVisible, isSelected, isPressed, isCheckboxSelection} = useContext(InternalCardContext);
|
|
504
|
-
let {UNSAFE_className, UNSAFE_style} = props;
|
|
504
|
+
let {UNSAFE_className = '', UNSAFE_style} = props;
|
|
505
505
|
let domRef = useDOMRef(ref);
|
|
506
506
|
return (
|
|
507
507
|
<div
|
package/src/CenterBaseline.tsx
CHANGED
package/src/ColorHandle.tsx
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {cloneElement, JSX, RefObject, useState} from 'react';
|
|
13
|
+
import {cloneElement, JSX, ReactNode, RefObject, useState} from 'react';
|
|
14
14
|
import {ColorThumb} from 'react-aria-components';
|
|
15
15
|
import {createPortal} from 'react-dom';
|
|
16
16
|
import {keyframes} from '../style/style-macro' with {type: 'macro'};
|
|
@@ -28,7 +28,7 @@ interface ColorHandleProps {
|
|
|
28
28
|
getPosition: () => {x: number, y: number}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function ColorHandle({containerRef, getPosition}: ColorHandleProps) {
|
|
31
|
+
export function ColorHandle({containerRef, getPosition}: ColorHandleProps): ReactNode {
|
|
32
32
|
return (
|
|
33
33
|
<ColorThumb
|
|
34
34
|
className={style({
|
|
@@ -50,6 +50,7 @@ export const ColorSwatchPicker = forwardRef(function ColorSwatchPicker(props: Co
|
|
|
50
50
|
density = 'regular',
|
|
51
51
|
size = 'M',
|
|
52
52
|
rounding = 'none',
|
|
53
|
+
UNSAFE_className = '',
|
|
53
54
|
...otherProps
|
|
54
55
|
} = props;
|
|
55
56
|
let domRef = useDOMRef(ref);
|
|
@@ -58,7 +59,7 @@ export const ColorSwatchPicker = forwardRef(function ColorSwatchPicker(props: Co
|
|
|
58
59
|
<AriaColorSwatchPicker
|
|
59
60
|
{...otherProps}
|
|
60
61
|
ref={domRef}
|
|
61
|
-
className={
|
|
62
|
+
className={UNSAFE_className + style({
|
|
62
63
|
display: 'flex',
|
|
63
64
|
flexWrap: 'wrap',
|
|
64
65
|
gap: {
|
package/src/ComboBox.tsx
CHANGED
|
@@ -338,7 +338,7 @@ const checkmarkIconSize = {
|
|
|
338
338
|
XL: 'XL'
|
|
339
339
|
} as const;
|
|
340
340
|
|
|
341
|
-
export function ComboBoxItem(props: ComboBoxItemProps) {
|
|
341
|
+
export function ComboBoxItem(props: ComboBoxItemProps): ReactNode {
|
|
342
342
|
let ref = useRef(null);
|
|
343
343
|
let isLink = props.href != null;
|
|
344
344
|
let {size} = useContext(InternalComboboxContext);
|
|
@@ -378,7 +378,7 @@ export function ComboBoxItem(props: ComboBoxItemProps) {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
export interface ComboBoxSectionProps<T extends object> extends SectionProps<T> {}
|
|
381
|
-
export function ComboBoxSection<T extends object>(props: ComboBoxSectionProps<T>) {
|
|
381
|
+
export function ComboBoxSection<T extends object>(props: ComboBoxSectionProps<T>): ReactNode {
|
|
382
382
|
let {size} = useContext(InternalComboboxContext);
|
|
383
383
|
return (
|
|
384
384
|
<>
|
package/src/Content.tsx
CHANGED
|
@@ -37,7 +37,7 @@ export const Heading = forwardRef(// Wrapper around RAC Heading to unmount when
|
|
|
37
37
|
function Heading(props: HeadingProps, ref: DOMRef<HTMLHeadingElement>) {
|
|
38
38
|
[props, ref] = useSpectrumContextProps(props, ref, HeadingContext);
|
|
39
39
|
let domRef = useDOMRef(ref);
|
|
40
|
-
let {UNSAFE_className = '', UNSAFE_style, styles, isHidden, slot, ...otherProps} = props;
|
|
40
|
+
let {UNSAFE_className = '', UNSAFE_style, styles = '', isHidden, slot, ...otherProps} = props;
|
|
41
41
|
if (isHidden) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
@@ -57,7 +57,7 @@ export const HeaderContext = createContext<ContextValue<Partial<ContentProps>, D
|
|
|
57
57
|
export const Header = forwardRef(function Header(props: ContentProps, ref: DOMRef) {
|
|
58
58
|
[props, ref] = useSpectrumContextProps(props, ref, HeaderContext);
|
|
59
59
|
let domRef = useDOMRef(ref);
|
|
60
|
-
let {UNSAFE_className = '', UNSAFE_style, styles, isHidden, slot, ...otherProps} = props;
|
|
60
|
+
let {UNSAFE_className = '', UNSAFE_style, styles = '', isHidden, slot, ...otherProps} = props;
|
|
61
61
|
if (isHidden) {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
@@ -77,7 +77,7 @@ export const ContentContext = createContext<ContextValue<Partial<ContentProps>,
|
|
|
77
77
|
export const Content = forwardRef(function Content(props: ContentProps, ref: DOMRef<HTMLDivElement>) {
|
|
78
78
|
[props, ref] = useSpectrumContextProps(props, ref, ContentContext);
|
|
79
79
|
let domRef = useDOMRef(ref);
|
|
80
|
-
let {UNSAFE_className = '', UNSAFE_style, styles, isHidden, slot, ...otherProps} = props;
|
|
80
|
+
let {UNSAFE_className = '', UNSAFE_style, styles = '', isHidden, slot, ...otherProps} = props;
|
|
81
81
|
if (isHidden) {
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
@@ -96,7 +96,7 @@ export const TextContext = createContext<ContextValue<Partial<ContentProps>, DOM
|
|
|
96
96
|
export const Text = forwardRef(function Text(props: ContentProps, ref: DOMRef) {
|
|
97
97
|
[props, ref] = useSpectrumContextProps(props, ref, TextContext);
|
|
98
98
|
let domRef = useDOMRef(ref);
|
|
99
|
-
let {UNSAFE_className = '', UNSAFE_style, styles, isHidden, slot, children, ...otherProps} = props;
|
|
99
|
+
let {UNSAFE_className = '', UNSAFE_style, styles = '', isHidden, slot, children, ...otherProps} = props;
|
|
100
100
|
let racContext = useContext(RACTextContext);
|
|
101
101
|
let isSkeleton = useIsSkeleton();
|
|
102
102
|
[children, UNSAFE_style] = useSkeletonText(children, UNSAFE_style);
|
|
@@ -130,7 +130,7 @@ export const KeyboardContext = createContext<ContextValue<Partial<ContentProps>,
|
|
|
130
130
|
export const Keyboard = forwardRef(function Keyboard(props: ContentProps, ref: DOMRef) {
|
|
131
131
|
[props, ref] = useSpectrumContextProps(props, ref, KeyboardContext);
|
|
132
132
|
let domRef = useDOMRef(ref);
|
|
133
|
-
let {UNSAFE_className = '', UNSAFE_style, styles, isHidden, slot, ...otherProps} = props;
|
|
133
|
+
let {UNSAFE_className = '', UNSAFE_style, styles = '', isHidden, slot, ...otherProps} = props;
|
|
134
134
|
if (isHidden) {
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
@@ -149,7 +149,7 @@ export const FooterContext = createContext<ContextValue<Partial<ContentProps>, D
|
|
|
149
149
|
export const Footer = forwardRef(function Footer(props: ContentProps, ref: DOMRef) {
|
|
150
150
|
[props, ref] = useSpectrumContextProps(props, ref, FooterContext);
|
|
151
151
|
let domRef = useDOMRef(ref);
|
|
152
|
-
let {UNSAFE_className = '', UNSAFE_style, styles, isHidden, slot, ...otherProps} = props;
|
|
152
|
+
let {UNSAFE_className = '', UNSAFE_style, styles = '', isHidden, slot, ...otherProps} = props;
|
|
153
153
|
if (isHidden) {
|
|
154
154
|
return null;
|
|
155
155
|
}
|
package/src/DateField.tsx
CHANGED
|
@@ -31,7 +31,7 @@ export interface DateFieldProps<T extends DateValue>
|
|
|
31
31
|
|
|
32
32
|
export function DateField<T extends DateValue>(
|
|
33
33
|
{label, description, errorMessage, ...props}: DateFieldProps<T>
|
|
34
|
-
) {
|
|
34
|
+
): ReactNode {
|
|
35
35
|
return (
|
|
36
36
|
<AriaDateField {...props}>
|
|
37
37
|
<Label>{label}</Label>
|
package/src/DatePicker.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export interface DatePickerProps<T extends DateValue>
|
|
|
38
38
|
|
|
39
39
|
export function DatePicker<T extends DateValue>(
|
|
40
40
|
{label, description, errorMessage, ...props}: DatePickerProps<T>
|
|
41
|
-
) {
|
|
41
|
+
): ReactNode {
|
|
42
42
|
return (
|
|
43
43
|
<AriaDatePicker {...props}>
|
|
44
44
|
<Label>{label}</Label>
|
package/src/DateRangePicker.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export interface DateRangePickerProps<T extends DateValue>
|
|
|
38
38
|
|
|
39
39
|
export function DateRangePicker<T extends DateValue>(
|
|
40
40
|
{label, description, errorMessage, ...props}: DateRangePickerProps<T>
|
|
41
|
-
) {
|
|
41
|
+
): ReactNode {
|
|
42
42
|
return (
|
|
43
43
|
<AriaDateRangePicker {...props}>
|
|
44
44
|
<Label>{label}</Label>
|
package/src/DialogContainer.tsx
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {ModalContext, useSlottedContext} from 'react-aria-components';
|
|
14
|
-
import React, {ReactElement, useState} from 'react';
|
|
14
|
+
import React, {ReactElement, ReactNode, useState} from 'react';
|
|
15
15
|
import {SpectrumDialogContainerProps} from '@react-types/dialog';
|
|
16
16
|
|
|
17
17
|
export interface DialogContainerProps extends Omit<SpectrumDialogContainerProps, 'type' | 'isDismissable' | 'isKeyboardDismissDisabled'> {}
|
|
@@ -21,7 +21,7 @@ export interface DialogContainerProps extends Omit<SpectrumDialogContainerProps,
|
|
|
21
21
|
* it in a modal. Useful in cases where there is no trigger element
|
|
22
22
|
* or when the trigger unmounts while the dialog is open.
|
|
23
23
|
*/
|
|
24
|
-
export function DialogContainer(props: DialogContainerProps) {
|
|
24
|
+
export function DialogContainer(props: DialogContainerProps): ReactNode {
|
|
25
25
|
let {
|
|
26
26
|
children,
|
|
27
27
|
onDismiss
|
package/src/DialogTrigger.tsx
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {DialogTrigger as AriaDialogTrigger, DialogTriggerProps as AriaDialogTriggerProps} from 'react-aria-components';
|
|
14
14
|
import {PressResponder} from '@react-aria/interactions';
|
|
15
|
+
import {ReactNode} from 'react';
|
|
15
16
|
|
|
16
17
|
export interface DialogTriggerProps extends AriaDialogTriggerProps {}
|
|
17
18
|
|
|
@@ -20,7 +21,7 @@ export interface DialogTriggerProps extends AriaDialogTriggerProps {}
|
|
|
20
21
|
* open state with the trigger's press state. Additionally, it allows you to customize the type and
|
|
21
22
|
* positioning of the Dialog.
|
|
22
23
|
*/
|
|
23
|
-
export function DialogTrigger(props: DialogTriggerProps) {
|
|
24
|
+
export function DialogTrigger(props: DialogTriggerProps): ReactNode {
|
|
24
25
|
return (
|
|
25
26
|
<AriaDialogTrigger {...props}>
|
|
26
27
|
{/* RAC sets isPressed via PressResponder when the dialog is open.
|
package/src/Disclosure.tsx
CHANGED
|
@@ -130,10 +130,10 @@ const buttonStyles = style({
|
|
|
130
130
|
fontWeight: 'bold',
|
|
131
131
|
fontSize: {
|
|
132
132
|
size: {
|
|
133
|
-
S: '
|
|
134
|
-
M: '
|
|
135
|
-
L: '
|
|
136
|
-
XL: '
|
|
133
|
+
S: 'title-sm',
|
|
134
|
+
M: 'title',
|
|
135
|
+
L: 'title-lg',
|
|
136
|
+
XL: 'title-xl'
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
lineHeight: 'ui',
|
|
@@ -147,32 +147,32 @@ const buttonStyles = style({
|
|
|
147
147
|
// compact is equivalent to 'control', but other densities have more padding.
|
|
148
148
|
size: {
|
|
149
149
|
S: {
|
|
150
|
+
density: {
|
|
151
|
+
compact: 18,
|
|
152
|
+
regular: 24,
|
|
153
|
+
spacious: 32
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
M: {
|
|
150
157
|
density: {
|
|
151
158
|
compact: 24,
|
|
152
159
|
regular: 32,
|
|
153
160
|
spacious: 40
|
|
154
161
|
}
|
|
155
162
|
},
|
|
156
|
-
|
|
163
|
+
L: {
|
|
157
164
|
density: {
|
|
158
165
|
compact: 32,
|
|
159
166
|
regular: 40,
|
|
160
167
|
spacious: 48
|
|
161
168
|
}
|
|
162
169
|
},
|
|
163
|
-
|
|
170
|
+
XL: {
|
|
164
171
|
density: {
|
|
165
172
|
compact: 40,
|
|
166
173
|
regular: 48,
|
|
167
174
|
spacious: 56
|
|
168
175
|
}
|
|
169
|
-
},
|
|
170
|
-
XL: {
|
|
171
|
-
density: {
|
|
172
|
-
compact: 48,
|
|
173
|
-
regular: 56,
|
|
174
|
-
spacious: 64
|
|
175
|
-
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
},
|
|
@@ -219,18 +219,12 @@ function DisclosureHeaderWithForwardRef(props: DisclosureHeaderProps, ref: DOMRe
|
|
|
219
219
|
let domRef = useDOMRef(ref);
|
|
220
220
|
let {size, isQuiet, density} = useSlottedContext(DisclosureContext)!;
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
S: 'XS',
|
|
224
|
-
M: 'S',
|
|
225
|
-
L: 'M',
|
|
226
|
-
XL: 'L'
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
// maps to one size smaller in the compact density to ensure there is space between the top and bottom of the action button and container
|
|
222
|
+
// Shift button size down by 2 for compact density, 1 for regular/spacious to ensure there is space between the top and bottom of the action button and container
|
|
230
223
|
let newSize : 'XS' | 'S' | 'M' | 'L' | 'XL' | undefined = size;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
const sizes = ['XS', 'S', 'M', 'L', 'XL'];
|
|
225
|
+
const currentIndex = sizes.indexOf(size ?? 'M');
|
|
226
|
+
const shift = density === 'compact' ? 2 : 1;
|
|
227
|
+
newSize = sizes[Math.max(0, currentIndex - shift)] as 'XS' | 'S' | 'M' | 'L' | 'XL';
|
|
234
228
|
|
|
235
229
|
return (
|
|
236
230
|
<Provider
|
package/src/Divider.tsx
CHANGED
package/src/Field.tsx
CHANGED
|
@@ -276,7 +276,7 @@ const helpTextStyles = style({
|
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
|
|
279
|
-
export function HelpText(props: HelpTextProps & {descriptionRef?: DOMRef<HTMLDivElement>, errorRef?: DOMRef<HTMLDivElement>}) {
|
|
279
|
+
export function HelpText(props: HelpTextProps & {descriptionRef?: DOMRef<HTMLDivElement>, errorRef?: DOMRef<HTMLDivElement>}): ReactNode {
|
|
280
280
|
let domDescriptionRef = useDOMRef(props.descriptionRef || null);
|
|
281
281
|
let domErrorRef = useDOMRef(props.errorRef || null);
|
|
282
282
|
|
|
@@ -308,7 +308,7 @@ export function HelpText(props: HelpTextProps & {descriptionRef?: DOMRef<HTMLDiv
|
|
|
308
308
|
);
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
export function FieldErrorIcon(props: {isDisabled?: boolean}) {
|
|
311
|
+
export function FieldErrorIcon(props: {isDisabled?: boolean}): ReactNode {
|
|
312
312
|
return (
|
|
313
313
|
<Provider
|
|
314
314
|
values={[
|
package/src/Image.tsx
CHANGED
|
@@ -207,7 +207,7 @@ export const Image = forwardRef(function Image(props: ImageProps, domRef: Forwar
|
|
|
207
207
|
animation(domRef.current);
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
if (props.alt == null) {
|
|
210
|
+
if (props.alt == null && process.env.NODE_ENV !== 'production') {
|
|
211
211
|
console.warn(
|
|
212
212
|
'The `alt` prop was not provided to an image. ' +
|
|
213
213
|
'Add `alt` text for screen readers, or set `alt=""` prop to indicate that the image ' +
|
package/src/ImageCoordinator.tsx
CHANGED
|
@@ -44,7 +44,7 @@ interface State {
|
|
|
44
44
|
loaded: Map<string, boolean>
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
type Action =
|
|
47
|
+
type Action =
|
|
48
48
|
| {type: 'register', url: string}
|
|
49
49
|
| {type: 'unregister', url: string}
|
|
50
50
|
| {type: 'load', url: string}
|
|
@@ -120,7 +120,7 @@ function isAllLoaded(loaded: Map<string, boolean>) {
|
|
|
120
120
|
* An ImageCoordinator coordinates loading behavior for a group of images.
|
|
121
121
|
* Images within an ImageCoordinator are revealed together once all of them have loaded.
|
|
122
122
|
*/
|
|
123
|
-
export function ImageCoordinator(props: ImageCoordinatorProps) {
|
|
123
|
+
export function ImageCoordinator(props: ImageCoordinatorProps): ReactNode {
|
|
124
124
|
// If we are already inside another ImageCoordinator, just pass
|
|
125
125
|
// through children and coordinate loading at the root.
|
|
126
126
|
let ctx = useContext(props.group || DefaultImageGroup);
|
|
@@ -139,7 +139,7 @@ function ImageCoordinatorRoot(props: ImageCoordinatorProps) {
|
|
|
139
139
|
loadStartTime: 0,
|
|
140
140
|
loaded: new Map()
|
|
141
141
|
});
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
let register = useCallback((url: string) => dispatch({type: 'register', url}), []);
|
|
144
144
|
let unregister = useCallback((url: string) => dispatch({type: 'unregister', url}), []);
|
|
145
145
|
let load = useCallback((url: string) => dispatch({type: 'load', url}), []);
|
package/src/Link.tsx
CHANGED
|
@@ -34,7 +34,7 @@ interface LinkStyleProps {
|
|
|
34
34
|
isQuiet?: boolean
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export interface LinkProps extends Omit<RACLinkProps, 'isDisabled' | 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, LinkStyleProps {
|
|
37
|
+
export interface LinkProps extends Omit<RACLinkProps, 'isDisabled' | 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' | 'onClick'>, StyleProps, LinkStyleProps {
|
|
38
38
|
children: ReactNode
|
|
39
39
|
}
|
|
40
40
|
|
package/src/ListBox.tsx
CHANGED
|
@@ -16,11 +16,12 @@ import {
|
|
|
16
16
|
ListBoxItemProps,
|
|
17
17
|
ListBoxProps
|
|
18
18
|
} from 'react-aria-components';
|
|
19
|
+
import {ReactNode} from 'react';
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
export function ListBox<T extends object>(
|
|
22
23
|
{children, ...props}: ListBoxProps<T>
|
|
23
|
-
) {
|
|
24
|
+
): ReactNode {
|
|
24
25
|
return (
|
|
25
26
|
<AriaListBox {...props}>
|
|
26
27
|
{children}
|
|
@@ -28,6 +29,6 @@ export function ListBox<T extends object>(
|
|
|
28
29
|
);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function ListBoxItem(props: ListBoxItemProps) {
|
|
32
|
+
export function ListBoxItem(props: ListBoxItemProps): ReactNode {
|
|
32
33
|
return <AriaListBoxItem {...props} />;
|
|
33
34
|
}
|
package/src/Menu.tsx
CHANGED
|
@@ -406,7 +406,7 @@ export const Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(function Menu<T
|
|
|
406
406
|
return content;
|
|
407
407
|
});
|
|
408
408
|
|
|
409
|
-
export function Divider(props: SeparatorProps) {
|
|
409
|
+
export function Divider(props: SeparatorProps): ReactNode {
|
|
410
410
|
return (
|
|
411
411
|
<Separator
|
|
412
412
|
{...props}
|
|
@@ -429,7 +429,7 @@ export function Divider(props: SeparatorProps) {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
export interface MenuSectionProps<T extends object> extends AriaMenuSectionProps<T> {}
|
|
432
|
-
export function MenuSection<T extends object>(props: MenuSectionProps<T>) {
|
|
432
|
+
export function MenuSection<T extends object>(props: MenuSectionProps<T>): ReactNode {
|
|
433
433
|
// remember, context doesn't work if it's around Section nor inside
|
|
434
434
|
let {size} = useContext(InternalMenuContext);
|
|
435
435
|
return (
|
|
@@ -465,7 +465,7 @@ const linkIconSize = {
|
|
|
465
465
|
XL: 'XL'
|
|
466
466
|
} as const;
|
|
467
467
|
|
|
468
|
-
export function MenuItem(props: MenuItemProps) {
|
|
468
|
+
export function MenuItem(props: MenuItemProps): ReactNode {
|
|
469
469
|
let ref = useRef(null);
|
|
470
470
|
let isLink = props.href != null;
|
|
471
471
|
let isLinkOut = isLink && props.target === '_blank';
|
|
@@ -548,7 +548,7 @@ export function MenuItem(props: MenuItemProps) {
|
|
|
548
548
|
* The MenuTrigger serves as a wrapper around a Menu and its associated trigger,
|
|
549
549
|
* linking the Menu's open state with the trigger's press state.
|
|
550
550
|
*/
|
|
551
|
-
function MenuTrigger(props: MenuTriggerProps) {
|
|
551
|
+
function MenuTrigger(props: MenuTriggerProps): ReactNode {
|
|
552
552
|
// RAC sets isPressed via PressResponder when the menu is open.
|
|
553
553
|
// We don't want press scaling to appear to get "stuck", so override this.
|
|
554
554
|
// For mouse interactions, menus open on press start. When the popover underlay appears
|
|
@@ -591,6 +591,6 @@ export {MenuTrigger, SubmenuTrigger};
|
|
|
591
591
|
// This is purely so that storybook generates the types for both Menu and MenuTrigger
|
|
592
592
|
interface ICombined<T extends object> extends MenuProps<T>, Omit<MenuTriggerProps, 'children'> {}
|
|
593
593
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
594
|
-
export function CombinedMenu<T extends object>(props: ICombined<T>) {
|
|
594
|
+
export function CombinedMenu<T extends object>(props: ICombined<T>): ReactNode {
|
|
595
595
|
return <div />;
|
|
596
596
|
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {AriaLabelingProps, DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';
|
|
14
|
+
import {ContextValue, SlotProps} from 'react-aria-components';
|
|
15
|
+
import {filterDOMProps} from '@react-aria/utils';
|
|
16
|
+
import {fontRelative, style} from '../style' with {type: 'macro'};
|
|
17
|
+
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import intlMessages from '../intl/*.json';
|
|
20
|
+
import {NumberFormatter} from '@internationalized/number';
|
|
21
|
+
import React, {createContext, forwardRef} from 'react';
|
|
22
|
+
import {useDOMRef} from '@react-spectrum/utils';
|
|
23
|
+
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
24
|
+
import {useSpectrumContextProps} from './useSpectrumContextProps';
|
|
25
|
+
|
|
26
|
+
export interface NotificationBadgeStyleProps {
|
|
27
|
+
/**
|
|
28
|
+
* The size of the notification badge.
|
|
29
|
+
*
|
|
30
|
+
* @default 'S'
|
|
31
|
+
*/
|
|
32
|
+
size?: 'S' | 'M' | 'L' | 'XL'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface NotificationBadgeProps extends DOMProps, AriaLabelingProps, StyleProps, NotificationBadgeStyleProps, SlotProps {
|
|
36
|
+
/**
|
|
37
|
+
* The value to be displayed in the notification badge.
|
|
38
|
+
*/
|
|
39
|
+
value?: number | null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface NotificationBadgeContextProps extends Partial<NotificationBadgeProps> {
|
|
43
|
+
isDisabled?: boolean,
|
|
44
|
+
staticColor?: 'black' | 'white' | 'auto'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const NotificationBadgeContext = createContext<ContextValue<Partial<NotificationBadgeContextProps>, DOMRefValue<HTMLDivElement>>>(null);
|
|
48
|
+
|
|
49
|
+
const badge = style({
|
|
50
|
+
display: {
|
|
51
|
+
default: 'flex',
|
|
52
|
+
isDisabled: 'none'
|
|
53
|
+
},
|
|
54
|
+
font: 'control',
|
|
55
|
+
color: {
|
|
56
|
+
default: 'white',
|
|
57
|
+
isStaticColor: 'auto',
|
|
58
|
+
forcedColors: 'ButtonText'
|
|
59
|
+
},
|
|
60
|
+
fontSize: {
|
|
61
|
+
size: {
|
|
62
|
+
S: 'ui-xs',
|
|
63
|
+
M: 'ui-xs',
|
|
64
|
+
L: 'ui-sm',
|
|
65
|
+
XL: 'ui'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
borderStyle: {
|
|
69
|
+
forcedColors: 'solid'
|
|
70
|
+
},
|
|
71
|
+
borderWidth: {
|
|
72
|
+
forcedColors: '[1px]'
|
|
73
|
+
},
|
|
74
|
+
borderColor: {
|
|
75
|
+
forcedColors: 'ButtonBorder'
|
|
76
|
+
},
|
|
77
|
+
justifyContent: 'center',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
backgroundColor: {
|
|
80
|
+
default: 'accent',
|
|
81
|
+
isStaticColor: 'transparent-overlay-1000',
|
|
82
|
+
forcedColors: 'ButtonFace'
|
|
83
|
+
},
|
|
84
|
+
height: {
|
|
85
|
+
size: {
|
|
86
|
+
S: {
|
|
87
|
+
default: 12,
|
|
88
|
+
isIndicatorOnly: 8
|
|
89
|
+
},
|
|
90
|
+
M: {
|
|
91
|
+
default: fontRelative(18), // sort of arbitrary? tried to get as close to the figma designs as possible
|
|
92
|
+
isIndicatorOnly: 8
|
|
93
|
+
},
|
|
94
|
+
L: {
|
|
95
|
+
default: 16,
|
|
96
|
+
isIndicatorOnly: fontRelative(12)
|
|
97
|
+
},
|
|
98
|
+
XL: {
|
|
99
|
+
default: 18,
|
|
100
|
+
isIndicatorOnly: fontRelative(12)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
aspectRatio: {
|
|
105
|
+
isIndicatorOnly: 'square',
|
|
106
|
+
isSingleDigit: 'square'
|
|
107
|
+
},
|
|
108
|
+
width: 'max',
|
|
109
|
+
paddingX: {
|
|
110
|
+
isDoubleDigit: 'edge-to-text'
|
|
111
|
+
},
|
|
112
|
+
borderRadius: 'pill'
|
|
113
|
+
}, getAllowedOverrides());
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Notification badges are used to indicate new or pending activity .
|
|
117
|
+
*/
|
|
118
|
+
export const NotificationBadge = forwardRef(function Badge(props: NotificationBadgeProps, ref: DOMRef<HTMLDivElement>) {
|
|
119
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');
|
|
120
|
+
[props, ref] = useSpectrumContextProps(props, ref, NotificationBadgeContext);
|
|
121
|
+
let {
|
|
122
|
+
size = 'S',
|
|
123
|
+
value,
|
|
124
|
+
isDisabled = false,
|
|
125
|
+
staticColor,
|
|
126
|
+
...otherProps
|
|
127
|
+
} = props as NotificationBadgeContextProps;
|
|
128
|
+
let domRef = useDOMRef(ref);
|
|
129
|
+
let {locale} = useLocale();
|
|
130
|
+
let formattedValue = '';
|
|
131
|
+
|
|
132
|
+
let isIndicatorOnly = false;
|
|
133
|
+
let isSingleDigit = false;
|
|
134
|
+
let isDoubleDigit = false;
|
|
135
|
+
|
|
136
|
+
if (value == null) {
|
|
137
|
+
isIndicatorOnly = true;
|
|
138
|
+
} else if (value <= 0) {
|
|
139
|
+
throw new Error('Value cannot be negative or zero');
|
|
140
|
+
} else if (!Number.isInteger(value)) {
|
|
141
|
+
throw new Error('Value must be a positive integer');
|
|
142
|
+
} else {
|
|
143
|
+
formattedValue = new NumberFormatter(locale).format(Math.min(value, 99));
|
|
144
|
+
let length = Math.log(value <= 99 ? value : 99) * Math.LOG10E + 1 | 0; // for positive integers (https://stackoverflow.com/questions/14879691/get-number-of-digits-with-javascript)
|
|
145
|
+
if (length === 1) {
|
|
146
|
+
isSingleDigit = true;
|
|
147
|
+
} else if (length === 2) {
|
|
148
|
+
isDoubleDigit = true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (value > 99) {
|
|
152
|
+
formattedValue = stringFormatter.format('notificationbadge.plus', {notifications: formattedValue});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let ariaLabel = props['aria-label'] || undefined;
|
|
157
|
+
if (ariaLabel === undefined && isIndicatorOnly) {
|
|
158
|
+
ariaLabel = stringFormatter.format('notificationbadge.indicatorOnly');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<span
|
|
163
|
+
{...filterDOMProps(otherProps, {labelable: true})}
|
|
164
|
+
role={ariaLabel && 'img'}
|
|
165
|
+
aria-label={ariaLabel}
|
|
166
|
+
className={(props.UNSAFE_className || '') + badge({size, isIndicatorOnly, isSingleDigit, isDoubleDigit, isDisabled, isStaticColor: !!staticColor}, props.styles)}
|
|
167
|
+
style={props.UNSAFE_style}
|
|
168
|
+
ref={domRef}>
|
|
169
|
+
{formattedValue}
|
|
170
|
+
</span>
|
|
171
|
+
);
|
|
172
|
+
});
|
package/src/Picker.tsx
CHANGED
|
@@ -436,7 +436,7 @@ const checkmarkIconSize = {
|
|
|
436
436
|
XL: 'XL'
|
|
437
437
|
} as const;
|
|
438
438
|
|
|
439
|
-
export function PickerItem(props: PickerItemProps) {
|
|
439
|
+
export function PickerItem(props: PickerItemProps): ReactNode {
|
|
440
440
|
let ref = useRef(null);
|
|
441
441
|
let isLink = props.href != null;
|
|
442
442
|
let {size} = useContext(InternalPickerContext);
|
|
@@ -484,7 +484,7 @@ function DefaultProvider({context, value, children}: {context: React.Context<any
|
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
export interface PickerSectionProps<T extends object> extends SectionProps<T> {}
|
|
487
|
-
export function PickerSection<T extends object>(props: PickerSectionProps<T>) {
|
|
487
|
+
export function PickerSection<T extends object>(props: PickerSectionProps<T>): ReactNode {
|
|
488
488
|
let {size} = useContext(InternalPickerContext);
|
|
489
489
|
return (
|
|
490
490
|
<>
|