@react-fabric/core 1.0.0-beta.61 → 1.0.0-beta.63
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/css/components/_animations.css +7 -11
- package/css/components/_avatar.css +5 -5
- package/css/components/_badge.css +2 -1
- package/css/components/_breadcrumbs.css +7 -5
- package/css/components/_button.css +49 -9
- package/css/components/_card.css +9 -17
- package/css/components/_chip.css +0 -4
- package/css/components/_dropdown.css +1 -0
- package/css/components/_flyout.css +1 -1
- package/css/components/_media.css +2 -14
- package/css/components/_menu.css +1 -1
- package/css/components/_modal.css +3 -3
- package/css/components/_progress.css +1 -1
- package/css/components/_stepper.css +2 -1
- package/css/components/_tabPanel.css +4 -4
- package/css/core/_aside.css +3 -3
- package/css/core/_errorboundary.css +2 -10
- package/css/core/_page.css +1 -1
- package/css/core/_responsive.css +8 -0
- package/css/core/_theme.css +1 -1
- package/css/core/_viewport.css +1 -5
- package/css/reset/_reset.css +42 -43
- package/css/reset/_theme.css +214 -201
- package/css/styles.css +5 -0
- package/css/theme/_colors.css +14 -0
- package/css/theme/_utilities.css +103 -225
- package/css/theme/index.css +4 -6
- package/dist/cjs/components/actionLabel/ActionLabel.js +1 -1
- package/dist/cjs/components/animations/Animations.js +7 -7
- package/dist/cjs/components/avatar/Avatar.js +1 -1
- package/dist/cjs/components/avatar/AvatarGroup.js +1 -1
- package/dist/cjs/components/badge/Badge.js +5 -27
- package/dist/cjs/components/breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/cjs/components/button/Button.js +8 -6
- package/dist/cjs/components/button/ButtonGroup.js +1 -1
- package/dist/cjs/components/button/ConfirmButton.js +7 -6
- package/dist/cjs/components/button/ToggleButtonGroup.js +1 -1
- package/dist/cjs/components/callout/Callout.js +8 -7
- package/dist/cjs/components/card/Card.js +3 -3
- package/dist/cjs/components/card/CardCover.js +1 -1
- package/dist/cjs/components/card/FlipContent.js +2 -2
- package/dist/cjs/components/chip/Chip.js +8 -7
- package/dist/cjs/components/collapsable/Collapsable.js +4 -3
- package/dist/cjs/components/divider/Divider.js +2 -2
- package/dist/cjs/components/dropdown/Dropdown.js +28 -14
- package/dist/cjs/components/empty/EmptyContent.js +1 -1
- package/dist/cjs/components/icon/Icon.js +26 -40
- package/dist/cjs/components/media/Media.js +13 -13
- package/dist/cjs/components/menu/ContextMenu.js +23 -13
- package/dist/cjs/components/menu/Menu.js +19 -14
- package/dist/cjs/components/menu/MenuItem.js +5 -4
- package/dist/cjs/components/meter/Meter.js +1 -1
- package/dist/cjs/components/navigator/Navigator.js +6 -6
- package/dist/cjs/components/panel/Panel.js +6 -4
- package/dist/cjs/components/panel/PanelGroup.js +3 -3
- package/dist/cjs/components/panel/PanelStack.js +5 -5
- package/dist/cjs/components/progress/ProgressBar.js +2 -2
- package/dist/cjs/components/progress/ProgressCircle.js +2 -2
- package/dist/cjs/components/tabpanel/Tab.js +6 -4
- package/dist/cjs/components/tabpanel/TabPanel.js +7 -6
- package/dist/cjs/context/Global.js +2 -55
- package/dist/cjs/context/NotificationCenter.js +38 -39
- package/dist/cjs/context/context.js +59 -0
- package/dist/cjs/core/aside/Aside.js +9 -7
- package/dist/cjs/core/boundary/ErrorBoundary.js +2 -4
- package/dist/cjs/core/page/Page.js +4 -1
- package/dist/cjs/core/responsive/Responsive.js +3 -2
- package/dist/cjs/core/theme/ThemeProvider.js +5 -4
- package/dist/cjs/core/viewport/Viewport.js +1 -1
- package/dist/cjs/hooks/useContextMenu.js +103 -0
- package/dist/cjs/hooks/useIsDark.js +6 -4
- package/dist/cjs/hooks/useNavigator.js +11 -10
- package/dist/cjs/hooks/useOverlayService.js +27 -38
- package/dist/cjs/hooks/usePropToggle.js +2 -2
- package/dist/cjs/hooks/useResize.js +8 -6
- package/dist/cjs/hooks/useResizeObserver.js +5 -5
- package/dist/cjs/hooks/useStepper.js +2 -6
- package/dist/cjs/hotkeys/HotKey.js +2 -2
- package/dist/cjs/hotkeys/HotKeyWrapper.js +8 -13
- package/dist/cjs/hotkeys/commons.js +1 -1
- package/dist/cjs/hotkeys/context.js +36 -0
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/cjs/index.js +10 -5
- package/dist/cjs/overlays/alert/Alert.js +6 -5
- package/dist/cjs/overlays/flyout/Flyout.js +8 -6
- package/dist/cjs/overlays/message/Message.js +5 -5
- package/dist/cjs/overlays/modal/Modal.js +5 -3
- package/dist/cjs/overlays/toast/Toast.js +4 -4
- package/dist/cjs/overlays/tooltip/Tooltip.js +2 -16
- package/dist/cjs/typography/Abbr.js +4 -5
- package/dist/cjs/typography/Anchor.js +2 -2
- package/dist/cjs/typography/Copy.js +2 -2
- package/dist/cjs/typography/Mark.js +2 -4
- package/dist/cjs/typography/Text.js +4 -4
- package/dist/cjs/typography/Title.js +2 -2
- package/dist/cjs/utils/cloneElement.js +4 -4
- package/dist/cjs/utils/getBadgeProps.js +51 -0
- package/dist/cjs/utils/getIconProps.js +42 -0
- package/dist/cjs/utils/getTooltipProps.js +45 -0
- package/dist/esm/components/actionLabel/ActionLabel.js +1 -1
- package/dist/esm/components/animations/Animations.js +7 -7
- package/dist/esm/components/avatar/Avatar.js +1 -1
- package/dist/esm/components/avatar/AvatarGroup.js +1 -1
- package/dist/esm/components/badge/Badge.js +7 -28
- package/dist/esm/components/breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/esm/components/button/Button.js +9 -7
- package/dist/esm/components/button/ButtonGroup.js +3 -3
- package/dist/esm/components/button/ConfirmButton.js +8 -7
- package/dist/esm/components/button/ToggleButtonGroup.js +3 -3
- package/dist/esm/components/callout/Callout.js +8 -7
- package/dist/esm/components/card/Card.js +4 -4
- package/dist/esm/components/card/CardCover.js +1 -1
- package/dist/esm/components/card/FlipContent.js +2 -2
- package/dist/esm/components/chip/Chip.js +9 -8
- package/dist/esm/components/collapsable/Collapsable.js +4 -3
- package/dist/esm/components/divider/Divider.js +2 -2
- package/dist/esm/components/dropdown/Dropdown.js +30 -16
- package/dist/esm/components/empty/EmptyContent.js +1 -1
- package/dist/esm/components/icon/Icon.js +28 -41
- package/dist/esm/components/media/Media.js +13 -13
- package/dist/esm/components/menu/ContextMenu.js +24 -14
- package/dist/esm/components/menu/Menu.js +22 -17
- package/dist/esm/components/menu/MenuItem.js +6 -5
- package/dist/esm/components/meter/Meter.js +1 -1
- package/dist/esm/components/navigator/Navigator.js +7 -7
- package/dist/esm/components/panel/Panel.js +6 -4
- package/dist/esm/components/panel/PanelGroup.js +4 -4
- package/dist/esm/components/panel/PanelStack.js +6 -6
- package/dist/esm/components/progress/ProgressBar.js +2 -2
- package/dist/esm/components/progress/ProgressCircle.js +2 -2
- package/dist/esm/components/tabpanel/Tab.js +6 -4
- package/dist/esm/components/tabpanel/TabPanel.js +8 -7
- package/dist/esm/context/Global.js +3 -52
- package/dist/esm/context/NotificationCenter.js +38 -39
- package/dist/esm/context/context.js +56 -0
- package/dist/esm/core/aside/Aside.js +10 -8
- package/dist/esm/core/boundary/ErrorBoundary.js +1 -3
- package/dist/esm/core/page/Page.js +4 -1
- package/dist/esm/core/responsive/Responsive.js +3 -2
- package/dist/esm/core/theme/ThemeProvider.js +4 -3
- package/dist/esm/core/viewport/Viewport.js +1 -1
- package/dist/esm/hooks/useContextMenu.js +103 -0
- package/dist/esm/hooks/useIsDark.js +7 -5
- package/dist/esm/hooks/useNavigator.js +12 -11
- package/dist/esm/hooks/useOverlayService.js +28 -39
- package/dist/esm/hooks/usePropToggle.js +3 -3
- package/dist/esm/hooks/useResize.js +9 -7
- package/dist/esm/hooks/useResizeObserver.js +6 -6
- package/dist/esm/hooks/useStepper.js +2 -6
- package/dist/esm/hotkeys/HotKey.js +1 -1
- package/dist/esm/hotkeys/HotKeyWrapper.js +9 -12
- package/dist/esm/hotkeys/commons.js +1 -1
- package/dist/esm/hotkeys/context.js +35 -0
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/index.js +8 -4
- package/dist/esm/overlays/alert/Alert.js +7 -6
- package/dist/esm/overlays/flyout/Flyout.js +9 -7
- package/dist/esm/overlays/message/Message.js +6 -6
- package/dist/esm/overlays/modal/Modal.js +6 -4
- package/dist/esm/overlays/toast/Toast.js +5 -5
- package/dist/esm/overlays/tooltip/Tooltip.js +4 -17
- package/dist/esm/typography/Abbr.js +4 -5
- package/dist/esm/typography/Anchor.js +2 -2
- package/dist/esm/typography/Copy.js +3 -3
- package/dist/esm/typography/Mark.js +2 -4
- package/dist/esm/typography/Text.js +5 -5
- package/dist/esm/typography/Title.js +2 -2
- package/dist/esm/utils/cloneElement.js +4 -4
- package/dist/esm/utils/getBadgeProps.js +51 -0
- package/dist/esm/utils/getIconProps.js +42 -0
- package/dist/esm/utils/getTooltipProps.js +45 -0
- package/dist/types/components/actionLabel/ActionLabel.d.ts +1 -1
- package/dist/types/components/animations/Animations.d.ts +6 -6
- package/dist/types/components/avatar/Avatar.d.ts +1 -1
- package/dist/types/components/avatar/AvatarGroup.d.ts +1 -1
- package/dist/types/components/badge/Badge.d.ts +2 -10
- package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/types/components/button/Button.d.ts +1 -1
- package/dist/types/components/button/ButtonGroup.d.ts +1 -1
- package/dist/types/components/button/ConfirmButton.d.ts +1 -1
- package/dist/types/components/button/ToggleButtonGroup.d.ts +1 -1
- package/dist/types/components/callout/Callout.d.ts +7 -3
- package/dist/types/components/card/Card.d.ts +2 -2
- package/dist/types/components/card/CardCover.d.ts +1 -1
- package/dist/types/components/card/FlipContent.d.ts +1 -1
- package/dist/types/components/chip/Chip.d.ts +1 -1
- package/dist/types/components/collapsable/Collapsable.d.ts +1 -1
- package/dist/types/components/divider/Divider.d.ts +1 -1
- package/dist/types/components/dropdown/Dropdown.d.ts +7 -3
- package/dist/types/components/dropdown/DropdownTool.d.ts +1 -1
- package/dist/types/components/empty/EmptyContent.d.ts +3 -3
- package/dist/types/components/icon/Icon.d.ts +3 -4
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/media/Media.d.ts +2 -2
- package/dist/types/components/menu/ContextMenu.d.ts +1 -1
- package/dist/types/components/menu/Menu.d.ts +1 -1
- package/dist/types/components/menu/types.d.ts +6 -1
- package/dist/types/components/meter/Meter.d.ts +1 -1
- package/dist/types/components/navigator/Navigator.d.ts +7 -1
- package/dist/types/components/panel/Panel.d.ts +2 -2
- package/dist/types/components/panel/PanelGroup.d.ts +1 -1
- package/dist/types/components/panel/PanelStack.d.ts +1 -1
- package/dist/types/components/progress/ProgressBar.d.ts +1 -1
- package/dist/types/components/progress/ProgressCircle.d.ts +1 -1
- package/dist/types/components/tabpanel/Tab.d.ts +1 -1
- package/dist/types/components/tabpanel/TabPanel.d.ts +1 -1
- package/dist/types/context/Global.d.ts +0 -82
- package/dist/types/context/context.d.ts +85 -0
- package/dist/types/core/aside/Aside.d.ts +2 -2
- package/dist/types/core/responsive/Responsive.d.ts +5 -1
- package/dist/types/core/theme/ThemeProvider.d.ts +2 -2
- package/dist/types/hooks/useContextMenu.d.ts +10 -0
- package/dist/types/hooks/useOverlayService.d.ts +3 -5
- package/dist/types/hotkeys/HotKeyWrapper.d.ts +0 -9
- package/dist/types/hotkeys/context.d.ts +9 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/overlays/alert/Alert.d.ts +2 -2
- package/dist/types/overlays/flyout/Flyout.d.ts +2 -2
- package/dist/types/overlays/message/Message.d.ts +2 -2
- package/dist/types/overlays/modal/Modal.d.ts +2 -2
- package/dist/types/overlays/toast/Toast.d.ts +2 -2
- package/dist/types/overlays/tooltip/Tooltip.d.ts +0 -3
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/typography/Abbr.d.ts +4 -8
- package/dist/types/typography/Anchor.d.ts +1 -1
- package/dist/types/typography/Copy.d.ts +1 -1
- package/dist/types/typography/Mark.d.ts +2 -2
- package/dist/types/typography/Text.d.ts +1 -1
- package/dist/types/typography/Title.d.ts +1 -1
- package/dist/types/utils/getBadgeProps.d.ts +9 -0
- package/dist/types/utils/getIconProps.d.ts +2 -0
- package/dist/types/utils/getTooltipProps.d.ts +4 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/package.json +14 -15
- package/src/components/actionLabel/ActionLabel.tsx +1 -1
- package/src/components/animations/Animations.tsx +6 -6
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/avatar/AvatarGroup.tsx +1 -1
- package/src/components/badge/Badge.tsx +8 -46
- package/src/components/breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/button/Button.tsx +24 -52
- package/src/components/button/ButtonGroup.tsx +1 -1
- package/src/components/button/ConfirmButton.tsx +23 -20
- package/src/components/button/ToggleButtonGroup.tsx +1 -1
- package/src/components/callout/Callout.tsx +14 -19
- package/src/components/card/Card.tsx +9 -11
- package/src/components/card/CardCover.tsx +1 -1
- package/src/components/card/FlipContent.tsx +2 -2
- package/src/components/chip/Chip.tsx +16 -33
- package/src/components/collapsable/Collapsable.tsx +2 -2
- package/src/components/divider/Divider.tsx +1 -1
- package/src/components/dropdown/Dropdown.tsx +60 -73
- package/src/components/dropdown/DropdownTool.tsx +1 -1
- package/src/components/empty/EmptyContent.tsx +3 -3
- package/src/components/icon/Icon.tsx +27 -54
- package/src/components/index.ts +5 -4
- package/src/components/media/Media.tsx +3 -3
- package/src/components/menu/ContextMenu.tsx +30 -30
- package/src/components/menu/Menu.tsx +35 -63
- package/src/components/menu/MenuItem.tsx +9 -28
- package/src/components/menu/types.ts +6 -1
- package/src/components/meter/Meter.tsx +1 -1
- package/src/components/navigator/Navigator.tsx +13 -11
- package/src/components/panel/Panel.tsx +13 -54
- package/src/components/panel/PanelGroup.tsx +3 -4
- package/src/components/panel/PanelStack.tsx +20 -25
- package/src/components/progress/ProgressBar.tsx +2 -2
- package/src/components/progress/ProgressCircle.tsx +2 -2
- package/src/components/tabpanel/Tab.tsx +9 -28
- package/src/components/tabpanel/TabPanel.tsx +13 -15
- package/src/context/Global.tsx +18 -125
- package/src/context/NotificationCenter.tsx +0 -1
- package/src/context/context.ts +100 -0
- package/src/core/aside/Aside.tsx +18 -55
- package/src/core/boundary/ErrorBoundary.tsx +8 -37
- package/src/core/page/Page.tsx +3 -5
- package/src/core/responsive/Responsive.tsx +10 -34
- package/src/core/theme/ThemeProvider.tsx +5 -8
- package/src/core/viewport/Viewport.tsx +1 -1
- package/src/hooks/useContextMenu.tsx +131 -0
- package/src/hooks/useIsDark.ts +7 -5
- package/src/hooks/useNavigator.tsx +8 -12
- package/src/hooks/useOverlayService.tsx +22 -17
- package/src/hooks/usePropToggle.ts +3 -3
- package/src/hooks/useResize.ts +14 -17
- package/src/hooks/useResizeObserver.ts +21 -21
- package/src/hooks/useStepper.tsx +1 -1
- package/src/hotkeys/HotKey.tsx +1 -1
- package/src/hotkeys/HotKeyWrapper.tsx +81 -105
- package/src/hotkeys/commons.ts +2 -0
- package/src/hotkeys/context.ts +32 -0
- package/src/i18n/index.ts +2 -2
- package/src/index.ts +4 -7
- package/src/overlays/alert/Alert.tsx +12 -16
- package/src/overlays/flyout/Flyout.tsx +32 -69
- package/src/overlays/message/Message.tsx +11 -15
- package/src/overlays/modal/Modal.tsx +23 -57
- package/src/overlays/toast/Toast.tsx +16 -15
- package/src/overlays/tooltip/Tooltip.tsx +6 -29
- package/src/types/global.d.ts +12 -0
- package/src/types/index.ts +2 -2
- package/src/typography/Abbr.tsx +11 -39
- package/src/typography/Anchor.tsx +1 -1
- package/src/typography/Copy.tsx +4 -4
- package/src/typography/Mark.tsx +2 -3
- package/src/typography/Text.tsx +8 -6
- package/src/typography/Title.tsx +1 -1
- package/src/utils/getBadgeProps.ts +45 -0
- package/src/utils/getIconProps.ts +35 -0
- package/src/utils/getTooltipProps.ts +38 -0
- package/src/utils/index.ts +3 -0
- /package/dist/cjs/i18n/{ar.json.js → ar/core.json.js} +0 -0
- /package/dist/cjs/i18n/{en.json.js → en/core.json.js} +0 -0
- /package/dist/esm/i18n/{ar.json.js → ar/core.json.js} +0 -0
- /package/dist/esm/i18n/{en.json.js → en/core.json.js} +0 -0
- /package/src/i18n/{ar.json → ar/core.json} +0 -0
- /package/src/i18n/{en.json → en/core.json} +0 -0
|
@@ -39,7 +39,7 @@ export interface Props extends CssProp, AriaProps, RefProp, TestProps {
|
|
|
39
39
|
/**
|
|
40
40
|
* svg path / webfont className / 1-4 letter text
|
|
41
41
|
*/
|
|
42
|
-
icon: string |
|
|
42
|
+
icon: string | React.ReactElement;
|
|
43
43
|
/**
|
|
44
44
|
* icon image source URL, if failed to load then shows icon
|
|
45
45
|
*/
|
|
@@ -81,29 +81,8 @@ export interface Props extends CssProp, AriaProps, RefProp, TestProps {
|
|
|
81
81
|
|
|
82
82
|
export type IconProps =
|
|
83
83
|
| string
|
|
84
|
-
|
|
|
85
|
-
| Pick<
|
|
86
|
-
Props,
|
|
87
|
-
| "icon"
|
|
88
|
-
| "iconSrc"
|
|
89
|
-
| "bg"
|
|
90
|
-
| "color"
|
|
91
|
-
| "size"
|
|
92
|
-
| "rtlFlip"
|
|
93
|
-
| "viewBox"
|
|
94
|
-
| "rounded"
|
|
95
|
-
| "animate"
|
|
96
|
-
>;
|
|
97
|
-
|
|
98
|
-
export const getIconProps = (props: IconProps): Props => {
|
|
99
|
-
if (typeof props === "string") {
|
|
100
|
-
return { icon: props };
|
|
101
|
-
}
|
|
102
|
-
if (isValidElement(props)) {
|
|
103
|
-
return { icon: props };
|
|
104
|
-
}
|
|
105
|
-
return props as unknown as Props;
|
|
106
|
-
};
|
|
84
|
+
| React.ReactElement
|
|
85
|
+
| Pick<Props, "icon" | "iconSrc" | "bg" | "color" | "size" | "rtlFlip" | "viewBox" | "rounded" | "animate">;
|
|
107
86
|
|
|
108
87
|
const SvgTextSize = ["", ".875em", ".525em", ".35em", ".25em"];
|
|
109
88
|
const SizeMap: KeyValue<string> = {
|
|
@@ -123,7 +102,7 @@ const SizeMap: KeyValue<string> = {
|
|
|
123
102
|
* These include `bg`, `color`, `size`, `rtlFlip`, `animate`, and `rounded`.
|
|
124
103
|
*
|
|
125
104
|
* @param {IconProps} props - The properties for the Icon component.
|
|
126
|
-
* @returns {
|
|
105
|
+
* @returns {React.ReactElement} The rendered Icon component.
|
|
127
106
|
*
|
|
128
107
|
* @example
|
|
129
108
|
* ```jsx
|
|
@@ -191,29 +170,29 @@ export const Icon = ({
|
|
|
191
170
|
/** ***************** render icon *******************/
|
|
192
171
|
const iconEl = useMemo(() => {
|
|
193
172
|
if (isValidElement(icon)) return icon;
|
|
194
|
-
if (
|
|
195
|
-
|
|
173
|
+
if (isString(icon)) {
|
|
174
|
+
return isSvg ? (
|
|
175
|
+
<svg viewBox={viewBox}>
|
|
176
|
+
<path fill="currentColor" d={icon.toString()} />
|
|
177
|
+
</svg>
|
|
178
|
+
) : icon?.toString().length <= 4 ? (
|
|
179
|
+
<svg role="img">
|
|
180
|
+
<text
|
|
181
|
+
x="50%"
|
|
182
|
+
y="50%"
|
|
183
|
+
dy=".1em"
|
|
184
|
+
dominantBaseline="middle"
|
|
185
|
+
textAnchor="middle"
|
|
186
|
+
style={{ fontSize: SvgTextSize[icon.length] }}
|
|
187
|
+
>
|
|
188
|
+
{icon}
|
|
189
|
+
</text>
|
|
190
|
+
</svg>
|
|
191
|
+
) : (
|
|
192
|
+
<i className={`${icon}`} />
|
|
193
|
+
);
|
|
196
194
|
}
|
|
197
|
-
|
|
198
|
-
<svg viewBox={viewBox}>
|
|
199
|
-
<path fill="currentColor" d={icon.toString()} />
|
|
200
|
-
</svg>
|
|
201
|
-
) : icon?.toString().length <= 4 ? (
|
|
202
|
-
<svg role="img">
|
|
203
|
-
<text
|
|
204
|
-
x="50%"
|
|
205
|
-
y="50%"
|
|
206
|
-
dy=".1em"
|
|
207
|
-
dominantBaseline="middle"
|
|
208
|
-
textAnchor="middle"
|
|
209
|
-
style={{ fontSize: SvgTextSize[icon.length] }}
|
|
210
|
-
>
|
|
211
|
-
{icon}
|
|
212
|
-
</text>
|
|
213
|
-
</svg>
|
|
214
|
-
) : (
|
|
215
|
-
<i className={`${icon}`} />
|
|
216
|
-
);
|
|
195
|
+
throw Error("Invalid icon expected string");
|
|
217
196
|
}, [icon, isSvg, viewBox]);
|
|
218
197
|
|
|
219
198
|
return (
|
|
@@ -241,13 +220,7 @@ export const Icon = ({
|
|
|
241
220
|
data-clickable={!!onClick}
|
|
242
221
|
data-inner-clickable={!!onClick}
|
|
243
222
|
>
|
|
244
|
-
{iconSrc && !imageFailed && (
|
|
245
|
-
<img
|
|
246
|
-
src={iconSrc}
|
|
247
|
-
alt="fallback icon"
|
|
248
|
-
onError={() => setImageFailed(true)}
|
|
249
|
-
/>
|
|
250
|
-
)}
|
|
223
|
+
{iconSrc && !imageFailed && <img src={iconSrc} alt="fallback icon" onError={() => setImageFailed(true)} />}
|
|
251
224
|
{(!iconSrc || imageFailed) && iconEl}
|
|
252
225
|
</dfn>
|
|
253
226
|
);
|
package/src/components/index.ts
CHANGED
|
@@ -23,15 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
export { ActionLabel } from "./actionLabel/ActionLabel";
|
|
25
25
|
export {
|
|
26
|
-
LoadingBars,
|
|
27
26
|
AnimationIndicator,
|
|
28
|
-
|
|
27
|
+
AnimationLoader,
|
|
28
|
+
LoadingBars,
|
|
29
29
|
LoadingLine,
|
|
30
|
+
LoadingSpinner,
|
|
30
31
|
Skeleton,
|
|
31
32
|
} from "./animations/Animations";
|
|
32
33
|
export { Avatar } from "./avatar/Avatar";
|
|
33
34
|
export { AvatarGroup } from "./avatar/AvatarGroup";
|
|
34
|
-
export { Badge
|
|
35
|
+
export { Badge } from "./badge/Badge";
|
|
35
36
|
export { Breadcrumbs } from "./breadcrumbs/Breadcrumbs";
|
|
36
37
|
export { Button } from "./button/Button";
|
|
37
38
|
export { ButtonGroup } from "./button/ButtonGroup";
|
|
@@ -47,7 +48,7 @@ export { Divider } from "./divider/Divider";
|
|
|
47
48
|
export { Dropdown, DropdownDismiss } from "./dropdown/Dropdown";
|
|
48
49
|
export { DropdownTool } from "./dropdown/DropdownTool";
|
|
49
50
|
export { EmptyContent } from "./empty/EmptyContent";
|
|
50
|
-
export { Icon
|
|
51
|
+
export { Icon } from "./icon/Icon";
|
|
51
52
|
export { Image, Video } from "./media/Media";
|
|
52
53
|
export { ContextMenu } from "./menu/ContextMenu";
|
|
53
54
|
export { Menu } from "./menu/Menu";
|
|
@@ -89,7 +89,7 @@ const loadIndicator = (
|
|
|
89
89
|
* It automatically adjusts the display based on the provided fit property, allowing for different styles such as cover, contain, or fill.
|
|
90
90
|
*
|
|
91
91
|
* @param {ImageProps | VideoProps} props - The properties for the Media component.
|
|
92
|
-
* @returns {
|
|
92
|
+
* @returns {React.ReactElement} The rendered Media component.
|
|
93
93
|
*
|
|
94
94
|
* @example
|
|
95
95
|
* ```jsx
|
|
@@ -174,7 +174,7 @@ export const Image = ({
|
|
|
174
174
|
* It also includes a reel decoration for a more engaging visual presentation.
|
|
175
175
|
*
|
|
176
176
|
* @param {VideoProps} props - The properties for the Video component.
|
|
177
|
-
* @returns {
|
|
177
|
+
* @returns {React.ReactElement} The rendered Video component.
|
|
178
178
|
*
|
|
179
179
|
* @example
|
|
180
180
|
* ```jsx
|
|
@@ -264,7 +264,7 @@ export const Video = ({
|
|
|
264
264
|
data-inner-clickable
|
|
265
265
|
className={classNames(
|
|
266
266
|
"fabric-mediaControls",
|
|
267
|
-
"absolute bottom-6
|
|
267
|
+
"absolute bottom-6 inset-e-6 rounded-full flex flex-col",
|
|
268
268
|
)}
|
|
269
269
|
>
|
|
270
270
|
<Button
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
+
FloatingFocusManager,
|
|
26
|
+
FloatingOverlay,
|
|
25
27
|
FloatingPortal,
|
|
26
28
|
autoUpdate,
|
|
27
29
|
flip,
|
|
@@ -48,7 +50,7 @@ export interface ContextMenuProps extends ChildrenProp {
|
|
|
48
50
|
* This component is useful for creating custom context menus that can be triggered by right-clicking on elements.
|
|
49
51
|
*
|
|
50
52
|
* @param {ContextMenuProps} props - The properties for the ContextMenu component.
|
|
51
|
-
* @returns {
|
|
53
|
+
* @returns {React.ReactElement} The rendered ContextMenu component.
|
|
52
54
|
*
|
|
53
55
|
* @example
|
|
54
56
|
* ```jsx
|
|
@@ -114,45 +116,43 @@ export const ContextMenu = ({ children, menu, disabled }: ContextMenuProps) => {
|
|
|
114
116
|
if (el && !disabled) {
|
|
115
117
|
el?.parentElement?.addEventListener("contextmenu", handleClick.current);
|
|
116
118
|
return () => {
|
|
117
|
-
el?.parentElement?.removeEventListener(
|
|
118
|
-
"contextmenu",
|
|
119
|
-
handleClick.current,
|
|
120
|
-
);
|
|
119
|
+
el?.parentElement?.removeEventListener("contextmenu", handleClick.current);
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
}, [disabled]);
|
|
124
123
|
|
|
125
124
|
const tryClosing = useRef((e: React.MouseEvent) => {
|
|
126
|
-
if ((e.target as HTMLElement)?.closest("[data-dropdown-dismiss='
|
|
127
|
-
setTimeout(() => setIsOpen(false), 50);
|
|
125
|
+
if (!(e.target as HTMLElement)?.closest("[data-dropdown-dismiss='false']")) setTimeout(() => setIsOpen(false), 50);
|
|
128
126
|
});
|
|
129
127
|
|
|
130
128
|
return (
|
|
131
|
-
<div
|
|
132
|
-
className="contents"
|
|
133
|
-
ref={wrapperRef}
|
|
134
|
-
onMouseUpCapture={tryClosing.current}
|
|
135
|
-
>
|
|
129
|
+
<div className="contents" ref={wrapperRef}>
|
|
136
130
|
{children}
|
|
137
131
|
{isOpen && (
|
|
138
|
-
<FloatingPortal
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
132
|
+
<FloatingPortal root={refs.domReference.current?.closest<HTMLElement>(".theme-base") ?? undefined}>
|
|
133
|
+
<FloatingOverlay
|
|
134
|
+
lockScroll
|
|
135
|
+
style={{
|
|
136
|
+
zIndex: "var(--z-overlay-mask)",
|
|
137
|
+
position: "absolute",
|
|
138
|
+
overflow: "hidden",
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<FloatingFocusManager context={context}>
|
|
142
|
+
{cloneElement(menu as AnyObject, {
|
|
143
|
+
...getFloatingProps(),
|
|
144
|
+
style: {
|
|
145
|
+
...floatingStyles,
|
|
146
|
+
borderRadius: "var(--rounding)",
|
|
147
|
+
zIndex: "var(--z-popover)",
|
|
148
|
+
fontSize: "0.875rem",
|
|
149
|
+
},
|
|
150
|
+
className: "bg-default outline rounded-capped shadow-lg",
|
|
151
|
+
ref: refs.setFloating,
|
|
152
|
+
onMouseUp: tryClosing.current,
|
|
153
|
+
})}
|
|
154
|
+
</FloatingFocusManager>
|
|
155
|
+
</FloatingOverlay>
|
|
156
156
|
</FloatingPortal>
|
|
157
157
|
)}
|
|
158
158
|
</div>
|
|
@@ -47,14 +47,7 @@ import {
|
|
|
47
47
|
} from "@floating-ui/react";
|
|
48
48
|
import { mergeRefs } from "@react-fabric/utilities";
|
|
49
49
|
import classNames from "classnames";
|
|
50
|
-
import {
|
|
51
|
-
cloneElement,
|
|
52
|
-
Fragment,
|
|
53
|
-
useCallback,
|
|
54
|
-
useEffect,
|
|
55
|
-
useRef,
|
|
56
|
-
useState,
|
|
57
|
-
} from "react";
|
|
50
|
+
import { cloneElement, Fragment, useEffect, useEffectEvent, useRef, useState } from "react";
|
|
58
51
|
import { HotKeyWrapper } from "../../hotkeys/HotKeyWrapper";
|
|
59
52
|
import { cloneChildren, nodeCheck } from "../../utils";
|
|
60
53
|
import { MenuItem } from "./MenuItem";
|
|
@@ -71,6 +64,11 @@ const MenuComponent = ({
|
|
|
71
64
|
trigger = "hover",
|
|
72
65
|
// @ts-expect-error ignore
|
|
73
66
|
ref,
|
|
67
|
+
// @ts-expect-error ignore
|
|
68
|
+
onMouseUp,
|
|
69
|
+
// @ts-expect-error ignore
|
|
70
|
+
onMouseDown,
|
|
71
|
+
forDropdown,
|
|
74
72
|
...rest
|
|
75
73
|
}: Partial<MenuProps>) => {
|
|
76
74
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -83,22 +81,17 @@ const MenuComponent = ({
|
|
|
83
81
|
const nodeId = useFloatingNodeId();
|
|
84
82
|
const parentId = useFloatingParentNodeId();
|
|
85
83
|
|
|
86
|
-
const isNested = parentId !== null;
|
|
84
|
+
const isNested = parentId !== null && !forDropdown;
|
|
87
85
|
|
|
88
86
|
const { floatingStyles, refs, context } = useFloating<HTMLButtonElement>({
|
|
89
|
-
nodeId
|
|
87
|
+
nodeId: `menu-${nodeId}`,
|
|
90
88
|
open: !isNested || isOpen,
|
|
91
89
|
onOpenChange(open, event, reason) {
|
|
92
90
|
isNested && setIsOpen(open);
|
|
93
|
-
if (reason === "outside-press" && trigger === "click")
|
|
94
|
-
tree?.events.emit("close");
|
|
91
|
+
if (reason === "outside-press" && trigger === "click") tree?.events.emit("close");
|
|
95
92
|
},
|
|
96
93
|
placement: isNested ? "right-start" : "bottom-start",
|
|
97
|
-
middleware: [
|
|
98
|
-
offset({ mainAxis: isNested ? 0 : 4, alignmentAxis: isNested ? -4 : 0 }),
|
|
99
|
-
flip(),
|
|
100
|
-
shift(),
|
|
101
|
-
],
|
|
94
|
+
middleware: [offset({ mainAxis: isNested ? 0 : 4, alignmentAxis: isNested ? -4 : 0 }), flip(), shift()],
|
|
102
95
|
whileElementsMounted: autoUpdate,
|
|
103
96
|
});
|
|
104
97
|
|
|
@@ -126,9 +119,14 @@ const MenuComponent = ({
|
|
|
126
119
|
activeIndex,
|
|
127
120
|
});
|
|
128
121
|
|
|
129
|
-
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions(
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
|
|
123
|
+
click,
|
|
124
|
+
hover,
|
|
125
|
+
role,
|
|
126
|
+
dismiss,
|
|
127
|
+
listNavigation,
|
|
128
|
+
typeahead,
|
|
129
|
+
]);
|
|
132
130
|
|
|
133
131
|
// Event emitter allows you to communicate across tree components.
|
|
134
132
|
// This effect closes all menus when an item gets clicked anywhere
|
|
@@ -163,33 +161,22 @@ const MenuComponent = ({
|
|
|
163
161
|
}
|
|
164
162
|
}, [tree, isOpen, nodeId, parentId]);
|
|
165
163
|
|
|
166
|
-
const handleClick =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
[onClick],
|
|
174
|
-
);
|
|
164
|
+
const handleClick = useEffectEvent((e: React.MouseEvent) => {
|
|
165
|
+
const el = e.target as HTMLElement;
|
|
166
|
+
if (el.dataset.id) {
|
|
167
|
+
onClick?.(el.dataset.id as AnyObject);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
175
170
|
|
|
176
171
|
const Wrapper = isNested ? FloatingPortal : Fragment;
|
|
177
172
|
const wrapperProps = isNested
|
|
178
173
|
? {
|
|
179
|
-
root:
|
|
180
|
-
refs.domReference.current?.closest<HTMLElement>(".theme-base") ??
|
|
181
|
-
undefined,
|
|
174
|
+
root: refs.domReference.current?.closest<HTMLElement>(".theme-base") ?? undefined,
|
|
182
175
|
}
|
|
183
176
|
: {};
|
|
184
177
|
|
|
185
178
|
useEffect(() => {
|
|
186
|
-
setTimeout(
|
|
187
|
-
() =>
|
|
188
|
-
refs.floating.current
|
|
189
|
-
?.querySelector(`[data-active="true"]`)
|
|
190
|
-
?.scrollIntoView({ block: "nearest" }),
|
|
191
|
-
100,
|
|
192
|
-
);
|
|
179
|
+
setTimeout(() => refs.floating.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({ block: "nearest" }), 100);
|
|
193
180
|
}, [isOpen]);
|
|
194
181
|
|
|
195
182
|
useEffect(() => {
|
|
@@ -226,23 +213,19 @@ const MenuComponent = ({
|
|
|
226
213
|
<Wrapper {...wrapperProps}>
|
|
227
214
|
{isNested && <FloatingOverlay />}
|
|
228
215
|
<HotKeyWrapper>
|
|
229
|
-
<FloatingFocusManager
|
|
230
|
-
context={context}
|
|
231
|
-
modal={!isNested}
|
|
232
|
-
initialFocus={isNested ? -1 : 0}
|
|
233
|
-
returnFocus={!isNested}
|
|
234
|
-
>
|
|
216
|
+
<FloatingFocusManager context={context} closeOnFocusOut initialFocus={isNested ? -1 : 0} returnFocus={!isNested}>
|
|
235
217
|
<div
|
|
236
218
|
className={classNames(
|
|
237
219
|
menuClassName,
|
|
238
|
-
"flex flex-col
|
|
239
|
-
isNested &&
|
|
240
|
-
"outline shadow-lg rounded-capped max-h-96 overflow-auto scroll-thin z-(--z-popover)",
|
|
220
|
+
"flex flex-col p-1 menu-list",
|
|
221
|
+
isNested && "outline shadow-lg rounded-capped max-h-96 overflow-auto scroll-thin z-(--z-popover)",
|
|
241
222
|
)}
|
|
242
223
|
autoFocus
|
|
243
224
|
ref={mergeRefs(isNested ? refs.setFloating : ref)}
|
|
244
225
|
{...getFloatingProps({
|
|
245
226
|
onClick: isNested ? undefined : handleClick,
|
|
227
|
+
onMouseDown,
|
|
228
|
+
onMouseUp,
|
|
246
229
|
})}
|
|
247
230
|
// @ts-expect-error ignore
|
|
248
231
|
{...{ style: !isNested ? rest.style : floatingStyles }}
|
|
@@ -255,8 +238,7 @@ const MenuComponent = ({
|
|
|
255
238
|
? {
|
|
256
239
|
minimal: !isNested && minimal,
|
|
257
240
|
"data-focus": activeIndex === index,
|
|
258
|
-
ref: (el: HTMLElement) =>
|
|
259
|
-
(elementsRef.current[index] = el),
|
|
241
|
+
ref: (el: HTMLElement) => (elementsRef.current[index] = el),
|
|
260
242
|
...getItemProps({
|
|
261
243
|
onClick: child.props.onClick,
|
|
262
244
|
tabIndex: activeIndex === index ? 0 : -1,
|
|
@@ -282,7 +264,7 @@ const MenuComponent = ({
|
|
|
282
264
|
* It can be nested within other menus to create complex menu structures.
|
|
283
265
|
*
|
|
284
266
|
* @param {MenuProps} props - The properties for the Menu component.
|
|
285
|
-
* @returns {
|
|
267
|
+
* @returns {React.ReactElement} The rendered Menu component.
|
|
286
268
|
*
|
|
287
269
|
* @example
|
|
288
270
|
* ```jsx
|
|
@@ -309,23 +291,13 @@ export const Menu = (props: MenuProps) => {
|
|
|
309
291
|
const tree = useFloatingTree();
|
|
310
292
|
|
|
311
293
|
if (tree) {
|
|
312
|
-
return (
|
|
313
|
-
<MenuComponent
|
|
314
|
-
{...(props as AnyObject)}
|
|
315
|
-
className=""
|
|
316
|
-
menuClassName={props.className}
|
|
317
|
-
/>
|
|
318
|
-
);
|
|
294
|
+
return <MenuComponent {...(props as AnyObject)} className="" menuClassName={props.className} />;
|
|
319
295
|
}
|
|
320
296
|
|
|
321
297
|
if (parentId === null) {
|
|
322
298
|
return (
|
|
323
299
|
<FloatingTree>
|
|
324
|
-
<MenuComponent
|
|
325
|
-
{...(props as AnyObject)}
|
|
326
|
-
className=""
|
|
327
|
-
menuClassName={props.className}
|
|
328
|
-
/>
|
|
300
|
+
<MenuComponent {...(props as AnyObject)} className="" menuClassName={props.className} />
|
|
329
301
|
</FloatingTree>
|
|
330
302
|
);
|
|
331
303
|
}
|
|
@@ -29,8 +29,9 @@ import { HotKey } from "../../hotkeys/HotKey";
|
|
|
29
29
|
import { HotKeyLabel } from "../../hotkeys/HotKeyLabel";
|
|
30
30
|
import { Tooltip } from "../../overlays";
|
|
31
31
|
import { type PolymorphicProps } from "../../types";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
32
|
+
import { getBadgeProps, getIconProps } from "../../utils";
|
|
33
|
+
import { Badge } from "../badge/Badge";
|
|
34
|
+
import { Icon } from "../icon/Icon";
|
|
34
35
|
import { type MenuItemProps } from "./types";
|
|
35
36
|
|
|
36
37
|
/**
|
|
@@ -92,23 +93,13 @@ export const MenuItem = <Tag extends React.ElementType = "button">({
|
|
|
92
93
|
if (minimal && !path) {
|
|
93
94
|
path = iconToken(label);
|
|
94
95
|
}
|
|
95
|
-
return (
|
|
96
|
-
<Icon
|
|
97
|
-
className={classNames("fabric-menuIcon", minimal && "minimal")}
|
|
98
|
-
{...getIconProps(path ?? "")}
|
|
99
|
-
/>
|
|
100
|
-
);
|
|
96
|
+
return <Icon className={classNames("fabric-menuIcon", minimal && "minimal")} {...getIconProps(path ?? "")} />;
|
|
101
97
|
}, [icon, minimal, label]);
|
|
102
98
|
|
|
103
99
|
const Wrapper = useCallback(
|
|
104
100
|
({ children, ...rest }: AnyObject) => {
|
|
105
101
|
return minimal ? (
|
|
106
|
-
<Tooltip
|
|
107
|
-
content={label}
|
|
108
|
-
placement="right"
|
|
109
|
-
disabled={childOpen}
|
|
110
|
-
{...rest}
|
|
111
|
-
>
|
|
102
|
+
<Tooltip content={label} placement="right" disabled={childOpen} {...rest}>
|
|
112
103
|
{children}
|
|
113
104
|
</Tooltip>
|
|
114
105
|
) : (
|
|
@@ -122,9 +113,7 @@ export const MenuItem = <Tag extends React.ElementType = "button">({
|
|
|
122
113
|
return (
|
|
123
114
|
<div className="flex flex-nowrap text-start items-center">
|
|
124
115
|
{iconEl}
|
|
125
|
-
{!minimal &&
|
|
126
|
-
<label className="flex-1 pe-4 py-[0.375em] truncate">{label}</label>
|
|
127
|
-
)}
|
|
116
|
+
{!minimal && <label className="flex-1 pe-4 py-[0.375em] truncate">{label}</label>}
|
|
128
117
|
{appendLabel && (
|
|
129
118
|
<span
|
|
130
119
|
className={classNames(
|
|
@@ -138,16 +127,10 @@ export const MenuItem = <Tag extends React.ElementType = "button">({
|
|
|
138
127
|
</span>
|
|
139
128
|
)}
|
|
140
129
|
{badge && (
|
|
141
|
-
<Badge
|
|
142
|
-
{...badgeProps}
|
|
143
|
-
placement={minimal ? "end" : ""}
|
|
144
|
-
className={classNames("me-1", badgeProps.className)}
|
|
145
|
-
/>
|
|
130
|
+
<Badge {...badgeProps} placement={minimal ? "end" : ""} className={classNames("me-1", badgeProps.className)} />
|
|
146
131
|
)}
|
|
147
132
|
{hotKey && <HotKeyLabel keyCombo={hotKey} />}
|
|
148
|
-
{!minimal && altIcon &&
|
|
149
|
-
<Icon className="text-muted px-1" icon={altIcon} rtlFlip />
|
|
150
|
-
)}
|
|
133
|
+
{!minimal && altIcon && <Icon className="text-muted px-1" icon={altIcon} rtlFlip />}
|
|
151
134
|
</div>
|
|
152
135
|
);
|
|
153
136
|
}, [iconEl, minimal, appendLabel, label, badge, badgeProps, hotKey, active]);
|
|
@@ -177,9 +160,7 @@ export const MenuItem = <Tag extends React.ElementType = "button">({
|
|
|
177
160
|
}}
|
|
178
161
|
{...(minimal ? {} : aria)}
|
|
179
162
|
>
|
|
180
|
-
{hotKey && (
|
|
181
|
-
<HotKey keyCombo={hotKey} handler={() => elRef.current?.click?.()} />
|
|
182
|
-
)}
|
|
163
|
+
{!disabled && hotKey && <HotKey keyCombo={hotKey} handler={() => elRef.current?.click?.()} />}
|
|
183
164
|
{menuLabel}
|
|
184
165
|
</E>
|
|
185
166
|
</Wrapper>
|
|
@@ -45,7 +45,7 @@ export interface MenuItemProps extends CssProp, AriaProps, TestProps {
|
|
|
45
45
|
/**
|
|
46
46
|
* append label badge text
|
|
47
47
|
*/
|
|
48
|
-
appendLabel?: string | false;
|
|
48
|
+
appendLabel?: React.ReactElement | string | number | false;
|
|
49
49
|
/**
|
|
50
50
|
* menu color
|
|
51
51
|
*/
|
|
@@ -83,6 +83,10 @@ export interface MenuItemProps extends CssProp, AriaProps, TestProps {
|
|
|
83
83
|
export interface MenuRootProps extends CssProp {
|
|
84
84
|
label?: never;
|
|
85
85
|
minimal?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* use this create a dropdown button within menu-item
|
|
88
|
+
*/
|
|
89
|
+
forDropdown?: boolean;
|
|
86
90
|
menuClassName?: never;
|
|
87
91
|
onClick?: (id: string) => CallbackReturn;
|
|
88
92
|
}
|
|
@@ -91,6 +95,7 @@ export interface MenuInnerProps extends MenuItemProps {
|
|
|
91
95
|
label: string;
|
|
92
96
|
minimal?: never;
|
|
93
97
|
trigger?: "hover" | "click";
|
|
98
|
+
forDropdown?: boolean;
|
|
94
99
|
/**
|
|
95
100
|
* floating menu className
|
|
96
101
|
*/
|
|
@@ -45,7 +45,7 @@ export interface MeterProps extends CssProp, AriaProps, TestProps {
|
|
|
45
45
|
* The component can also display a label showing the percentage value.
|
|
46
46
|
*
|
|
47
47
|
* @param {MeterProps} props - The properties for the Meter component.
|
|
48
|
-
* @returns {
|
|
48
|
+
* @returns {React.ReactElement} The rendered Meter component.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```jsx
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { isEmpty } from "@react-fabric/utilities";
|
|
24
25
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
26
|
+
import { useEffectEvent } from "react";
|
|
26
27
|
import { HotKey } from "../../hotkeys/HotKey";
|
|
27
28
|
import {
|
|
28
29
|
type AriaProps,
|
|
@@ -33,15 +34,18 @@ import {
|
|
|
33
34
|
type TestProps,
|
|
34
35
|
} from "../../types";
|
|
35
36
|
import { Icon } from "../icon/Icon";
|
|
36
|
-
import { isEmpty } from "@react-fabric/utilities";
|
|
37
37
|
|
|
38
38
|
export interface NavigatorProps
|
|
39
|
-
extends CssProp,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
extends CssProp, AriaProps, TestProps, Partial<ChildProp> {
|
|
40
|
+
/**
|
|
41
|
+
* item list length (ignore to enable infinite navigation)
|
|
42
|
+
*/
|
|
43
43
|
length?: number;
|
|
44
|
+
/**
|
|
45
|
+
* current item index (ignore to enable infinite navigation)
|
|
46
|
+
*/
|
|
44
47
|
current?: number;
|
|
48
|
+
|
|
45
49
|
disableKeyHandlers?: boolean;
|
|
46
50
|
/**
|
|
47
51
|
* navigator button color
|
|
@@ -58,7 +62,7 @@ export interface NavigatorProps
|
|
|
58
62
|
* It includes previous and next buttons, and supports keyboard navigation.
|
|
59
63
|
*
|
|
60
64
|
* @param {NavigatorProps} props - The properties for the Navigator component.
|
|
61
|
-
* @returns {
|
|
65
|
+
* @returns {React.ReactElement} The rendered Navigator component.
|
|
62
66
|
*
|
|
63
67
|
* @example
|
|
64
68
|
* ```jsx
|
|
@@ -85,13 +89,11 @@ export const Navigator = ({
|
|
|
85
89
|
disableKeyHandlers,
|
|
86
90
|
...aria
|
|
87
91
|
}: NavigatorProps) => {
|
|
88
|
-
const navPrev =
|
|
92
|
+
const navPrev = useEffectEvent(
|
|
89
93
|
() => (isEmpty(current) || current !== 0) && onNavigate(-1),
|
|
90
|
-
[onNavigate, current],
|
|
91
94
|
);
|
|
92
|
-
const navNext =
|
|
95
|
+
const navNext = useEffectEvent(
|
|
93
96
|
() => (isEmpty(current) || current + 1 < (length ?? 0)) && onNavigate(+1),
|
|
94
|
-
[onNavigate, current, length],
|
|
95
97
|
);
|
|
96
98
|
return (
|
|
97
99
|
<div
|