@react-fabric/core 1.0.0-beta.62 → 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 +5 -5
- package/css/components/_button.css +48 -14
- 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 +1 -1
- 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/_viewport.css +1 -5
- package/css/reset/_reset.css +36 -41
- 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 +7 -5
- 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 +18 -16
- package/dist/cjs/components/empty/EmptyContent.js +1 -1
- package/dist/cjs/components/icon/Icon.js +2 -16
- 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 +16 -12
- package/dist/cjs/components/menu/MenuItem.js +4 -3
- package/dist/cjs/components/meter/Meter.js +1 -1
- package/dist/cjs/components/navigator/Navigator.js +5 -5
- 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 +4 -4
- 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 +2 -2
- 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 +2 -2
- package/dist/cjs/hooks/useOverlayService.js +10 -42
- 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/index.js +9 -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 +8 -6
- 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 +19 -17
- package/dist/esm/components/empty/EmptyContent.js +1 -1
- package/dist/esm/components/icon/Icon.js +4 -17
- 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 +19 -15
- package/dist/esm/components/menu/MenuItem.js +5 -4
- package/dist/esm/components/meter/Meter.js +1 -1
- package/dist/esm/components/navigator/Navigator.js +6 -6
- 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 +5 -5
- 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 +1 -1
- 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 +3 -3
- package/dist/esm/hooks/useOverlayService.js +8 -40
- 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/index.js +7 -3
- 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 +2 -2
- 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 +1 -1
- package/dist/types/components/meter/Meter.d.ts +1 -1
- package/dist/types/components/navigator/Navigator.d.ts +1 -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/hooks/useContextMenu.d.ts +10 -0
- 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 -54
- 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 +42 -72
- package/src/components/dropdown/DropdownTool.tsx +1 -1
- package/src/components/empty/EmptyContent.tsx +3 -3
- package/src/components/icon/Icon.tsx +5 -32
- package/src/components/index.ts +2 -2
- package/src/components/media/Media.tsx +3 -3
- package/src/components/menu/ContextMenu.tsx +30 -30
- package/src/components/menu/Menu.tsx +32 -61
- package/src/components/menu/MenuItem.tsx +9 -28
- package/src/components/menu/types.ts +1 -1
- package/src/components/meter/Meter.tsx +1 -1
- package/src/components/navigator/Navigator.tsx +5 -10
- 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 +11 -14
- 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 +2 -7
- 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 +12 -15
- package/src/hooks/useOverlayService.tsx +3 -11
- 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/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
|
@@ -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
|
-
{!disabled && 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?:
|
|
48
|
+
appendLabel?: React.ReactElement | string | number | false;
|
|
49
49
|
/**
|
|
50
50
|
* menu color
|
|
51
51
|
*/
|
|
@@ -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
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { isEmpty } from "@react-fabric/utilities";
|
|
25
25
|
import classNames from "classnames";
|
|
26
|
-
import {
|
|
26
|
+
import { useEffectEvent } from "react";
|
|
27
27
|
import { HotKey } from "../../hotkeys/HotKey";
|
|
28
28
|
import {
|
|
29
29
|
type AriaProps,
|
|
@@ -36,10 +36,7 @@ import {
|
|
|
36
36
|
import { Icon } from "../icon/Icon";
|
|
37
37
|
|
|
38
38
|
export interface NavigatorProps
|
|
39
|
-
extends CssProp,
|
|
40
|
-
AriaProps,
|
|
41
|
-
TestProps,
|
|
42
|
-
Partial<ChildProp> {
|
|
39
|
+
extends CssProp, AriaProps, TestProps, Partial<ChildProp> {
|
|
43
40
|
/**
|
|
44
41
|
* item list length (ignore to enable infinite navigation)
|
|
45
42
|
*/
|
|
@@ -65,7 +62,7 @@ export interface NavigatorProps
|
|
|
65
62
|
* It includes previous and next buttons, and supports keyboard navigation.
|
|
66
63
|
*
|
|
67
64
|
* @param {NavigatorProps} props - The properties for the Navigator component.
|
|
68
|
-
* @returns {
|
|
65
|
+
* @returns {React.ReactElement} The rendered Navigator component.
|
|
69
66
|
*
|
|
70
67
|
* @example
|
|
71
68
|
* ```jsx
|
|
@@ -92,13 +89,11 @@ export const Navigator = ({
|
|
|
92
89
|
disableKeyHandlers,
|
|
93
90
|
...aria
|
|
94
91
|
}: NavigatorProps) => {
|
|
95
|
-
const navPrev =
|
|
92
|
+
const navPrev = useEffectEvent(
|
|
96
93
|
() => (isEmpty(current) || current !== 0) && onNavigate(-1),
|
|
97
|
-
[onNavigate, current, length],
|
|
98
94
|
);
|
|
99
|
-
const navNext =
|
|
95
|
+
const navNext = useEffectEvent(
|
|
100
96
|
() => (isEmpty(current) || current + 1 < (length ?? 0)) && onNavigate(+1),
|
|
101
|
-
[onNavigate, current, length],
|
|
102
97
|
);
|
|
103
98
|
return (
|
|
104
99
|
<div
|
|
@@ -35,16 +35,12 @@ import {
|
|
|
35
35
|
type ExpandProps,
|
|
36
36
|
type TestProps,
|
|
37
37
|
} from "../../types";
|
|
38
|
+
import { getIconProps } from "../../utils";
|
|
38
39
|
import { LoadingLine } from "../animations/Animations";
|
|
39
|
-
import {
|
|
40
|
+
import { Icon, type IconProps } from "../icon/Icon";
|
|
40
41
|
|
|
41
42
|
export interface PanelProps
|
|
42
|
-
extends CssProp,
|
|
43
|
-
AriaProps,
|
|
44
|
-
TestProps,
|
|
45
|
-
ExpandProps,
|
|
46
|
-
CollapseProps,
|
|
47
|
-
ChildrenProp<HeadFootProps | ContentProps> {
|
|
43
|
+
extends CssProp, AriaProps, TestProps, ExpandProps, CollapseProps, ChildrenProp<HeadFootProps | ContentProps> {
|
|
48
44
|
/**
|
|
49
45
|
* panel id used by panel stack
|
|
50
46
|
*/
|
|
@@ -56,7 +52,7 @@ export interface PanelProps
|
|
|
56
52
|
/**
|
|
57
53
|
* header actions
|
|
58
54
|
*/
|
|
59
|
-
actions?:
|
|
55
|
+
actions?: React.ReactElement;
|
|
60
56
|
/**
|
|
61
57
|
* header css classname(s)
|
|
62
58
|
*/
|
|
@@ -112,7 +108,7 @@ export interface PanelProps
|
|
|
112
108
|
* It can be used in various applications where panels are needed, such as dashboards, settings pages, or content management systems.
|
|
113
109
|
*
|
|
114
110
|
* @param {PanelProps} props - The properties for the Panel component.
|
|
115
|
-
* @returns {
|
|
111
|
+
* @returns {React.ReactElement} The rendered Panel component.
|
|
116
112
|
*
|
|
117
113
|
* @example
|
|
118
114
|
* ```jsx
|
|
@@ -165,11 +161,7 @@ export const Panel = ({
|
|
|
165
161
|
onBack,
|
|
166
162
|
...aria
|
|
167
163
|
}: PanelProps) => {
|
|
168
|
-
const [collapsed, toggleCollapse] = usePropToggle(
|
|
169
|
-
_collapsed,
|
|
170
|
-
onCollapse,
|
|
171
|
-
panelId,
|
|
172
|
-
);
|
|
164
|
+
const [collapsed, toggleCollapse] = usePropToggle(_collapsed, onCollapse, panelId);
|
|
173
165
|
const [expanded, toggleExpand] = usePropToggle(_expanded, onExpand, panelId);
|
|
174
166
|
|
|
175
167
|
const hasTools = useMemo(() => {
|
|
@@ -205,11 +197,7 @@ export const Panel = ({
|
|
|
205
197
|
{expanded && <HotKey keyCombo="esc" handler={toggleExpand} />}
|
|
206
198
|
<header
|
|
207
199
|
role="none"
|
|
208
|
-
className={classNames(
|
|
209
|
-
"fabric-panelHeader",
|
|
210
|
-
headerClassName,
|
|
211
|
-
"flex flex-nowrap items-center area-head",
|
|
212
|
-
)}
|
|
200
|
+
className={classNames("fabric-panelHeader", headerClassName, "flex flex-nowrap items-center area-head")}
|
|
213
201
|
data-ref="panelHeader"
|
|
214
202
|
onClick={collapsable ? toggleCollapse : undefined}
|
|
215
203
|
>
|
|
@@ -222,37 +210,16 @@ export const Panel = ({
|
|
|
222
210
|
onClick={onBack}
|
|
223
211
|
/>
|
|
224
212
|
)}
|
|
225
|
-
{icon && (
|
|
226
|
-
|
|
227
|
-
className="p-2 text-md select-none pointer-events-none"
|
|
228
|
-
{...getIconProps(icon)}
|
|
229
|
-
/>
|
|
230
|
-
)}
|
|
231
|
-
<div
|
|
232
|
-
className={classNames(
|
|
233
|
-
titleClassName,
|
|
234
|
-
"flex-1 select-none truncate",
|
|
235
|
-
title && "py-1 first:px-2",
|
|
236
|
-
)}
|
|
237
|
-
>
|
|
238
|
-
{title}
|
|
239
|
-
</div>
|
|
213
|
+
{icon && <Icon className="p-2 text-md select-none pointer-events-none" {...getIconProps(icon)} />}
|
|
214
|
+
<div className={classNames(titleClassName, "flex-1 select-none truncate", title && "py-1 first:px-2")}>{title}</div>
|
|
240
215
|
<div className="px-1 leading-none">{actions}</div>
|
|
241
216
|
{hasTools && (
|
|
242
|
-
<div
|
|
243
|
-
role="none"
|
|
244
|
-
className="px-1 gap-px flex"
|
|
245
|
-
onClick={(e) => e.stopPropagation()}
|
|
246
|
-
>
|
|
217
|
+
<div role="none" className="px-1 gap-px flex" onClick={(e) => e.stopPropagation()}>
|
|
247
218
|
{expandable && (
|
|
248
219
|
<Icon
|
|
249
220
|
data-ref="panelExpand"
|
|
250
221
|
className={classNames("fabric-panelAction", "cursor-pointer")}
|
|
251
|
-
icon={
|
|
252
|
-
expanded
|
|
253
|
-
? "icon-[mdi--fullscreen-exit]"
|
|
254
|
-
: "icon-[mdi--fullscreen]"
|
|
255
|
-
}
|
|
222
|
+
icon={expanded ? "icon-[mdi--fullscreen-exit]" : "icon-[mdi--fullscreen]"}
|
|
256
223
|
onClick={toggleExpand}
|
|
257
224
|
/>
|
|
258
225
|
)}
|
|
@@ -260,9 +227,7 @@ export const Panel = ({
|
|
|
260
227
|
<Icon
|
|
261
228
|
data-ref="panelCollapse"
|
|
262
229
|
className={classNames("fabric-panelAction", "cursor-pointer")}
|
|
263
|
-
icon={
|
|
264
|
-
collapsed ? "icon-[mdi--plus-box]" : "icon-[mdi--minus-box]"
|
|
265
|
-
}
|
|
230
|
+
icon={collapsed ? "icon-[mdi--plus-box-outline]" : "icon-[mdi--minus-box-outline]"}
|
|
266
231
|
onClick={toggleCollapse}
|
|
267
232
|
/>
|
|
268
233
|
)}
|
|
@@ -278,13 +243,7 @@ export const Panel = ({
|
|
|
278
243
|
)}
|
|
279
244
|
</header>
|
|
280
245
|
{(!collapsed || expanded) && (
|
|
281
|
-
<div
|
|
282
|
-
data-ref="panelBody"
|
|
283
|
-
className={classNames(
|
|
284
|
-
"fabric-panelBody",
|
|
285
|
-
"area-content grid overflow-hidden",
|
|
286
|
-
)}
|
|
287
|
-
>
|
|
246
|
+
<div data-ref="panelBody" className={classNames("fabric-panelBody", "area-content grid overflow-hidden")}>
|
|
288
247
|
{loading && <LoadingLine />}
|
|
289
248
|
{children}
|
|
290
249
|
</div>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import { Children, cloneElement,
|
|
25
|
+
import { Children, cloneElement, useEffectEvent, useState } from "react";
|
|
26
26
|
import {
|
|
27
27
|
useEffectDebugger,
|
|
28
28
|
useMemoDebugger,
|
|
@@ -48,7 +48,7 @@ export interface PanelGroupProps extends ChildrenProp {
|
|
|
48
48
|
* It uses the `Panel` component to render each individual panel within the group.
|
|
49
49
|
*
|
|
50
50
|
* @param {PanelGroupProps} props - The properties for the PanelGroup component.
|
|
51
|
-
* @returns {
|
|
51
|
+
* @returns {React.ReactElement} The rendered PanelGroup component.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
54
|
* ```jsx
|
|
@@ -88,7 +88,7 @@ export const PanelGroup = ({
|
|
|
88
88
|
"PanelGroup setActive",
|
|
89
89
|
);
|
|
90
90
|
|
|
91
|
-
const changeExpanded =
|
|
91
|
+
const changeExpanded = useEffectEvent(
|
|
92
92
|
(collapsed: boolean, id: string, handler?: AnyObject) => {
|
|
93
93
|
if (!collapsed) {
|
|
94
94
|
setExpandedPanel(id);
|
|
@@ -97,7 +97,6 @@ export const PanelGroup = ({
|
|
|
97
97
|
handler?.(collapsed);
|
|
98
98
|
return id !== expandedPanel;
|
|
99
99
|
},
|
|
100
|
-
[onActiveChange, expandedPanel],
|
|
101
100
|
);
|
|
102
101
|
|
|
103
102
|
return (
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
Children,
|
|
26
26
|
cloneElement,
|
|
27
27
|
type MouseEvent,
|
|
28
|
-
useCallback,
|
|
29
28
|
useEffect,
|
|
29
|
+
useEffectEvent,
|
|
30
30
|
useMemo,
|
|
31
31
|
useRef,
|
|
32
32
|
useState,
|
|
@@ -60,7 +60,7 @@ export interface PanelStackProps extends CssProp, ChildrenProp {
|
|
|
60
60
|
* and it updates the active panel based on user interactions.
|
|
61
61
|
*
|
|
62
62
|
* @param {PanelStackProps} props - The properties for the PanelStack component.
|
|
63
|
-
* @returns {
|
|
63
|
+
* @returns {React.ReactElement} The rendered PanelStack component.
|
|
64
64
|
*
|
|
65
65
|
* @example
|
|
66
66
|
* ```jsx
|
|
@@ -112,40 +112,35 @@ export const PanelStack = ({
|
|
|
112
112
|
});
|
|
113
113
|
}, [onPanelChange, history]);
|
|
114
114
|
|
|
115
|
-
const goBack =
|
|
116
|
-
|
|
115
|
+
const goBack = useEffectEvent(() => {
|
|
117
116
|
if (onBack?.(history[0], history[1] ?? "root") !== false) {
|
|
118
117
|
setHistory(history.slice(1));
|
|
119
118
|
}
|
|
120
|
-
}
|
|
119
|
+
});
|
|
121
120
|
|
|
122
121
|
const currentPanel = useMemo<AnyObject>(
|
|
123
122
|
() => panels.get(history[0]) ?? panels.values().next().value,
|
|
124
123
|
[history, panels],
|
|
125
124
|
);
|
|
126
125
|
|
|
127
|
-
const checkMenuClick =
|
|
128
|
-
(e
|
|
129
|
-
|
|
130
|
-
if (panelKey) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (onBack?.(history[0], "root") !== false) {
|
|
136
|
-
setHistory([]);
|
|
137
|
-
}
|
|
138
|
-
} else if (panels.has(panelKey)) {
|
|
139
|
-
setHistory([panelKey, ...history]);
|
|
126
|
+
const checkMenuClick = useEffectEvent((e: MouseEvent) => {
|
|
127
|
+
const panelKey = (e.target as HTMLElement)?.dataset?.panel;
|
|
128
|
+
if (panelKey) {
|
|
129
|
+
if (panelKey === "back") {
|
|
130
|
+
goBack();
|
|
131
|
+
} else if (panelKey === "root") {
|
|
132
|
+
if (onBack?.(history[0], "root") !== false) {
|
|
133
|
+
setHistory([]);
|
|
140
134
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return false;
|
|
135
|
+
} else if (panels.has(panelKey)) {
|
|
136
|
+
setHistory([panelKey, ...history]);
|
|
144
137
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
});
|
|
149
144
|
|
|
150
145
|
return (
|
|
151
146
|
<div
|
|
@@ -67,7 +67,7 @@ const SizeMap: KeyValue = {
|
|
|
67
67
|
* The label can be customized or hidden based on the props provided.
|
|
68
68
|
*
|
|
69
69
|
* @param {ProgressProps} props - The properties for the ProgressBar component.
|
|
70
|
-
* @returns {
|
|
70
|
+
* @returns {React.ReactElement} The rendered ProgressBar component.
|
|
71
71
|
*
|
|
72
72
|
* @example
|
|
73
73
|
* ```jsx
|
|
@@ -107,7 +107,7 @@ export const ProgressBar = ({
|
|
|
107
107
|
<div
|
|
108
108
|
className={classNames(
|
|
109
109
|
"fabric-progressbar",
|
|
110
|
-
"block bg-
|
|
110
|
+
"block bg-tint-50 relative rounded font-bold overflow-hidden whitespace-nowrap",
|
|
111
111
|
)}
|
|
112
112
|
style={{
|
|
113
113
|
...progressVar,
|
|
@@ -56,7 +56,7 @@ const SizeMap: KeyValue = {
|
|
|
56
56
|
* The component is customizable with size and color props.
|
|
57
57
|
*
|
|
58
58
|
* @param {ProgressProps} props - The properties for the ProgressCircle component.
|
|
59
|
-
* @returns {
|
|
59
|
+
* @returns {React.ReactElement} - A circular progress indicator.
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
62
62
|
* ```jsx
|
|
@@ -100,7 +100,7 @@ export const ProgressCircle = ({
|
|
|
100
100
|
>
|
|
101
101
|
<svg
|
|
102
102
|
viewBox="0 0 100 100"
|
|
103
|
-
className={classNames("absolute inset-0 w-full h-full stroke-
|
|
103
|
+
className={classNames("absolute inset-0 w-full h-full stroke-tint-500")}
|
|
104
104
|
>
|
|
105
105
|
<circle
|
|
106
106
|
cx="50"
|
|
@@ -37,17 +37,12 @@ import {
|
|
|
37
37
|
type TestProps,
|
|
38
38
|
type TooltipProp,
|
|
39
39
|
} from "../../types";
|
|
40
|
-
import {
|
|
40
|
+
import { getBadgeProps, getIconProps } from "../../utils";
|
|
41
|
+
import { Badge } from "../badge/Badge";
|
|
41
42
|
import { DropdownTool } from "../dropdown/DropdownTool";
|
|
42
|
-
import {
|
|
43
|
+
import { Icon, type IconProps } from "../icon/Icon";
|
|
43
44
|
|
|
44
|
-
export interface TabProps
|
|
45
|
-
extends Partial<ChildrenProp>,
|
|
46
|
-
CssProp,
|
|
47
|
-
RefProp,
|
|
48
|
-
AriaProps,
|
|
49
|
-
TestProps,
|
|
50
|
-
TooltipProp {
|
|
45
|
+
export interface TabProps extends Partial<ChildrenProp>, CssProp, RefProp, AriaProps, TestProps, TooltipProp {
|
|
51
46
|
/**
|
|
52
47
|
* tab id
|
|
53
48
|
*/
|
|
@@ -100,7 +95,7 @@ export interface TabProps
|
|
|
100
95
|
* It also supports tooltips, active states, and click handling.
|
|
101
96
|
*
|
|
102
97
|
* @param {TabProps} props - The properties for the Tab component.
|
|
103
|
-
* @returns {
|
|
98
|
+
* @returns {React.ReactElement} The rendered Tab component.
|
|
104
99
|
*
|
|
105
100
|
* @example
|
|
106
101
|
* ```jsx
|
|
@@ -179,29 +174,15 @@ export const Tab = <Tag extends React.ElementType = "button">({
|
|
|
179
174
|
{...aria}
|
|
180
175
|
>
|
|
181
176
|
{icon && <Icon className="flex-content p-2" {...getIconProps(icon)} />}
|
|
182
|
-
{!minimal &&
|
|
183
|
-
<label className="flex-initial truncate text-center px-1 py-1">
|
|
184
|
-
{label}
|
|
185
|
-
</label>
|
|
186
|
-
)}
|
|
177
|
+
{!minimal && <label className="flex-initial truncate text-center px-1 py-1">{label}</label>}
|
|
187
178
|
{badge && (
|
|
188
|
-
<Badge
|
|
189
|
-
{...badgeProps}
|
|
190
|
-
placement={minimal ? "end" : ""}
|
|
191
|
-
className={classNames("me-1", badgeProps.className)}
|
|
192
|
-
/>
|
|
193
|
-
)}
|
|
194
|
-
{actions && active && (
|
|
195
|
-
<DropdownTool className="bg-tint-50/20 me-1 z-5">
|
|
196
|
-
{actions}
|
|
197
|
-
</DropdownTool>
|
|
179
|
+
<Badge {...badgeProps} placement={minimal ? "end" : ""} className={classNames("me-1", badgeProps.className)} />
|
|
198
180
|
)}
|
|
181
|
+
{actions && active && <DropdownTool className="bg-tint-50/20 me-1 z-5">{actions}</DropdownTool>}
|
|
199
182
|
{onClose && (
|
|
200
183
|
<span
|
|
201
184
|
role="none"
|
|
202
|
-
className={classNames(
|
|
203
|
-
"cursor-pointer me-1 opacity-65 hover:opacity-90 pointer-events-auto",
|
|
204
|
-
)}
|
|
185
|
+
className={classNames("cursor-pointer me-1 opacity-65 hover:opacity-90 pointer-events-auto")}
|
|
205
186
|
onClick={(e) => {
|
|
206
187
|
onClose?.();
|
|
207
188
|
e.stopPropagation();
|
|
@@ -26,8 +26,8 @@ import classNames from "classnames";
|
|
|
26
26
|
import {
|
|
27
27
|
Children,
|
|
28
28
|
cloneElement,
|
|
29
|
-
useCallback,
|
|
30
29
|
useEffect,
|
|
30
|
+
useEffectEvent,
|
|
31
31
|
useMemo,
|
|
32
32
|
useState,
|
|
33
33
|
} from "react";
|
|
@@ -101,7 +101,7 @@ export interface TabPanelProps extends ChildrenProp<typeof Tab> {
|
|
|
101
101
|
* It can be customized with different styles and behaviors to fit the needs of the application.
|
|
102
102
|
*
|
|
103
103
|
* @param {TabPanelProps} props - The properties for the TabPanel component.
|
|
104
|
-
* @returns {
|
|
104
|
+
* @returns {React.ReactElement} The rendered TabPanel component.
|
|
105
105
|
*
|
|
106
106
|
* @example
|
|
107
107
|
* ```jsx
|
|
@@ -162,23 +162,20 @@ export const TabPanel = ({
|
|
|
162
162
|
.children;
|
|
163
163
|
}, [tabs, active]);
|
|
164
164
|
|
|
165
|
-
const handleClick =
|
|
166
|
-
(id
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
[onBeforeChange, onChange, active],
|
|
175
|
-
);
|
|
165
|
+
const handleClick = useEffectEvent((id: string) => {
|
|
166
|
+
void Promise.resolve(onBeforeChange?.(id, active)).then((ret) => {
|
|
167
|
+
if (ret !== false) {
|
|
168
|
+
setActive(id);
|
|
169
|
+
onChange?.(id);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
176
173
|
|
|
177
174
|
return (
|
|
178
175
|
<div
|
|
179
176
|
className={classNames(
|
|
180
177
|
"fabric-tabPanel",
|
|
181
|
-
"area-content grid bg-
|
|
178
|
+
"area-content grid bg-default overflow-hidden",
|
|
182
179
|
)}
|
|
183
180
|
data-orientation={orientation}
|
|
184
181
|
data-variant={variant ?? "default"}
|