@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
|
@@ -26,8 +26,8 @@ import classNames from "classnames";
|
|
|
26
26
|
import {
|
|
27
27
|
Fragment,
|
|
28
28
|
isValidElement,
|
|
29
|
-
useCallback,
|
|
30
29
|
useEffect,
|
|
30
|
+
useEffectEvent,
|
|
31
31
|
useMemo,
|
|
32
32
|
useRef,
|
|
33
33
|
useState,
|
|
@@ -50,10 +50,10 @@ import {
|
|
|
50
50
|
type TestProps,
|
|
51
51
|
type TooltipType,
|
|
52
52
|
} from "../../types";
|
|
53
|
-
import { getColor } from "../../utils";
|
|
53
|
+
import { getBadgeProps, getColor, getIconProps } from "../../utils";
|
|
54
54
|
import { AnimationIndicator } from "../animations/Animations";
|
|
55
|
-
import { Badge
|
|
56
|
-
import {
|
|
55
|
+
import { Badge } from "../badge/Badge";
|
|
56
|
+
import { Icon, type IconProps } from "../icon/Icon";
|
|
57
57
|
|
|
58
58
|
export interface BaseProps extends CssProp, AriaProps, RefProp, TestProps {
|
|
59
59
|
/**
|
|
@@ -153,9 +153,7 @@ type ButtonTypeProps =
|
|
|
153
153
|
| { children: string | React.ReactElement; "aria-label"?: string }
|
|
154
154
|
| { children?: never; "aria-label": string };
|
|
155
155
|
|
|
156
|
-
export type ButtonProps<Tag extends React.ElementType = "button"> = BaseProps &
|
|
157
|
-
ButtonTypeProps &
|
|
158
|
-
PolymorphicProps<Tag>;
|
|
156
|
+
export type ButtonProps<Tag extends React.ElementType = "button"> = BaseProps & ButtonTypeProps & PolymorphicProps<Tag>;
|
|
159
157
|
|
|
160
158
|
/**
|
|
161
159
|
* A versatile button component that supports various styles, icons, and actions.
|
|
@@ -164,7 +162,7 @@ export type ButtonProps<Tag extends React.ElementType = "button"> = BaseProps &
|
|
|
164
162
|
* It also includes features like after action tooltips, badges, and keyboard shortcuts.
|
|
165
163
|
*
|
|
166
164
|
* @param {ButtonProps} props - The properties for the Button component.
|
|
167
|
-
* @returns {
|
|
165
|
+
* @returns {React.ReactElement} The rendered Button component.
|
|
168
166
|
*
|
|
169
167
|
* @example
|
|
170
168
|
* ```jsx
|
|
@@ -217,28 +215,18 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
217
215
|
const [actionDone, setActionDone] = useState(false);
|
|
218
216
|
|
|
219
217
|
// Handle click events
|
|
220
|
-
const clickHandler =
|
|
221
|
-
(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
[
|
|
234
|
-
onClick,
|
|
235
|
-
disabled,
|
|
236
|
-
preventDefault,
|
|
237
|
-
actionMessage,
|
|
238
|
-
showActionDoneEvent,
|
|
239
|
-
stopPropagation,
|
|
240
|
-
],
|
|
241
|
-
);
|
|
218
|
+
const clickHandler = useEffectEvent((e: React.MouseEvent) => {
|
|
219
|
+
setBusy(true);
|
|
220
|
+
preventDefault && e.preventDefault();
|
|
221
|
+
stopPropagation && e.stopPropagation();
|
|
222
|
+
const ret = onClick?.(e);
|
|
223
|
+
void Promise.resolve(ret).then((b) => {
|
|
224
|
+
setBusy(false);
|
|
225
|
+
if (b !== false && actionMessage && showActionDoneEvent === "click") {
|
|
226
|
+
setActionDone(true);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
242
230
|
|
|
243
231
|
/** ***************** reset done state on timeout *******************/
|
|
244
232
|
useEffect(() => {
|
|
@@ -255,10 +243,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
255
243
|
"ActionButton done handler",
|
|
256
244
|
);
|
|
257
245
|
|
|
258
|
-
const TooltipWrapper = useMemo(
|
|
259
|
-
() => (actionMessage ? Tooltip : Fragment),
|
|
260
|
-
[actionMessage, actionDone],
|
|
261
|
-
);
|
|
246
|
+
const TooltipWrapper = useMemo(() => (actionMessage ? Tooltip : Fragment), [actionMessage, actionDone]);
|
|
262
247
|
const tooltipProps = useMemo(() => {
|
|
263
248
|
if (actionDone && actionMessage) {
|
|
264
249
|
return {
|
|
@@ -292,9 +277,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
292
277
|
data-loading={busy || loading}
|
|
293
278
|
data-disabled={disabled}
|
|
294
279
|
>
|
|
295
|
-
{!disabled && hotKey &&
|
|
296
|
-
<HotKey keyCombo={hotKey} handler={hotKeyHandler.current} />
|
|
297
|
-
)}
|
|
280
|
+
{!disabled && hotKey && <HotKey keyCombo={hotKey} handler={hotKeyHandler.current} />}
|
|
298
281
|
<TooltipWrapper {...tooltipProps}>
|
|
299
282
|
<E
|
|
300
283
|
ref={mergeRefs(ref, refEl)}
|
|
@@ -317,29 +300,16 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
317
300
|
data-variant={variant}
|
|
318
301
|
{...aria}
|
|
319
302
|
>
|
|
320
|
-
{icon && (
|
|
321
|
-
|
|
322
|
-
className={"fabric-buttonIcon"}
|
|
323
|
-
data-align={iconAlign}
|
|
324
|
-
{...getIconProps(icon)}
|
|
325
|
-
/>
|
|
326
|
-
)}
|
|
327
|
-
{isValidElement(children) && (
|
|
328
|
-
<div className={"fabric-buttonChild"}>{children}</div>
|
|
329
|
-
)}
|
|
303
|
+
{icon && <Icon className={"fabric-buttonIcon"} data-align={iconAlign} {...getIconProps(icon)} />}
|
|
304
|
+
{isValidElement(children) && <div className={"fabric-buttonChild"}>{children}</div>}
|
|
330
305
|
{isString(children) && (
|
|
331
|
-
<label
|
|
332
|
-
className={classNames("fabric-buttonLabel", "truncate")}
|
|
333
|
-
data-colored-icon={isObject(icon) && "bg" in icon}
|
|
334
|
-
>
|
|
306
|
+
<label className={classNames("fabric-buttonLabel", "truncate")} data-colored-icon={isObject(icon) && "bg" in icon}>
|
|
335
307
|
{children}
|
|
336
308
|
</label>
|
|
337
309
|
)}
|
|
338
310
|
{!isNil(badge) && <Badge {...badgeProps} />}
|
|
339
311
|
{hotKey && children && <HotKeyLabel keyCombo={hotKey} />}
|
|
340
|
-
{altIcon &&
|
|
341
|
-
<Icon className={"fabric-altIcon"} icon={altIcon} rtlFlip />
|
|
342
|
-
)}
|
|
312
|
+
{altIcon && <Icon className={"fabric-altIcon"} icon={altIcon} rtlFlip />}
|
|
343
313
|
</E>
|
|
344
314
|
</TooltipWrapper>
|
|
345
315
|
{actionDone && (
|
|
@@ -78,7 +78,7 @@ export interface ButtonGroupProps
|
|
|
78
78
|
* such as toolbars, action groups, or navigation buttons.
|
|
79
79
|
*
|
|
80
80
|
* @param {ButtonGroupProps} props - The properties for the ButtonGroup component.
|
|
81
|
-
* @returns {
|
|
81
|
+
* @returns {React.ReactElement} The rendered ButtonGroup component.
|
|
82
82
|
*
|
|
83
83
|
* @example
|
|
84
84
|
* ```jsx
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
Fragment,
|
|
43
43
|
useCallback,
|
|
44
44
|
useEffect,
|
|
45
|
+
useEffectEvent,
|
|
45
46
|
useMemo,
|
|
46
47
|
useRef,
|
|
47
48
|
useState,
|
|
@@ -87,7 +88,7 @@ export type ConfirmButtonProps = ExtendedProps & ButtonProps;
|
|
|
87
88
|
* It also supports custom placement of the dialog, and can display an action message when the action is completed.
|
|
88
89
|
*
|
|
89
90
|
* @param {ConfirmButtonProps} props - The properties for the ConfirmButton component.
|
|
90
|
-
* @returns {
|
|
91
|
+
* @returns {React.ReactElement} The rendered ConfirmButton component.
|
|
91
92
|
*
|
|
92
93
|
* @example
|
|
93
94
|
* ```jsx
|
|
@@ -123,21 +124,18 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
123
124
|
const [busy, setBusy] = useState(false);
|
|
124
125
|
const [actionDone, setActionDone] = useState(false);
|
|
125
126
|
|
|
126
|
-
const clickHandler =
|
|
127
|
-
(e
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
[onClick, actionMessage, showActionDoneEvent],
|
|
140
|
-
);
|
|
127
|
+
const clickHandler = useEffectEvent((e: boolean) => {
|
|
128
|
+
setBusy(e);
|
|
129
|
+
const ret = onClick?.(e);
|
|
130
|
+
if (e) {
|
|
131
|
+
void Promise.resolve(ret).then((b) => {
|
|
132
|
+
setBusy(false);
|
|
133
|
+
if (b !== false && actionMessage && showActionDoneEvent === "click") {
|
|
134
|
+
setActionDone(true);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
141
139
|
useEffect(() => {
|
|
142
140
|
if (actionDone) {
|
|
143
141
|
const timer = setTimeout(() => setActionDone(false), 2000);
|
|
@@ -200,12 +198,17 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
200
198
|
data-dropdown-open={isOpen}
|
|
201
199
|
/>
|
|
202
200
|
{isOpen && (
|
|
203
|
-
<FloatingPortal
|
|
204
|
-
|
|
201
|
+
<FloatingPortal
|
|
202
|
+
root={
|
|
203
|
+
refs.domReference.current?.closest<HTMLElement>(".theme-base") ??
|
|
204
|
+
undefined
|
|
205
|
+
}
|
|
206
|
+
>
|
|
207
|
+
<FloatingFocusManager context={context}>
|
|
205
208
|
<div
|
|
206
209
|
data-color={color}
|
|
207
210
|
className={classNames(
|
|
208
|
-
"select-none not-italic rounded-capped shadow-lg outline outline-muted bg-
|
|
211
|
+
"select-none not-italic rounded-capped shadow-lg outline outline-muted bg-default",
|
|
209
212
|
)}
|
|
210
213
|
ref={refs.setFloating}
|
|
211
214
|
style={{
|
|
@@ -244,7 +247,7 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
244
247
|
ref={arrowRef}
|
|
245
248
|
context={context}
|
|
246
249
|
strokeWidth={0.5}
|
|
247
|
-
className="fill-
|
|
250
|
+
className="fill-default stroke-muted"
|
|
248
251
|
/>
|
|
249
252
|
</div>
|
|
250
253
|
</FloatingFocusManager>
|
|
@@ -99,7 +99,7 @@ export type ToggleButtonGroupProps<T> = BaseProps &
|
|
|
99
99
|
* such as toggle switches, selection groups, or multi-select options.
|
|
100
100
|
*
|
|
101
101
|
* @param {ToggleButtonGroupProps} props - The properties for the ToggleButtonGroup component.
|
|
102
|
-
* @returns {
|
|
102
|
+
* @returns {React.ReactElement} The rendered ToggleButtonGroup component.
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
105
|
* ```jsx
|
|
@@ -22,28 +22,22 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
26
|
-
type AriaProps,
|
|
27
|
-
type ChildrenProp,
|
|
28
|
-
type ColorState,
|
|
29
|
-
type CssProp,
|
|
30
|
-
type TestProps,
|
|
31
|
-
} from "../../types";
|
|
25
|
+
import { type AriaProps, type ChildrenProp, type ColorState, type CssProp, type TestProps } from "../../types";
|
|
32
26
|
import { Icon } from "../icon/Icon";
|
|
33
27
|
|
|
34
|
-
export interface CalloutProps
|
|
35
|
-
extends AriaProps,
|
|
36
|
-
ChildrenProp,
|
|
37
|
-
CssProp,
|
|
38
|
-
TestProps {
|
|
28
|
+
export interface CalloutProps extends AriaProps, ChildrenProp, CssProp, TestProps {
|
|
39
29
|
/**
|
|
40
30
|
* callout color
|
|
41
31
|
*/
|
|
42
|
-
color?: ColorState | "
|
|
32
|
+
color?: ColorState | "dimmed";
|
|
43
33
|
/**
|
|
44
34
|
* legend title
|
|
45
35
|
*/
|
|
46
36
|
legend?: string | React.ReactElement;
|
|
37
|
+
/**
|
|
38
|
+
* legend class name
|
|
39
|
+
*/
|
|
40
|
+
legendClassName?: string;
|
|
47
41
|
/**
|
|
48
42
|
* callout icon
|
|
49
43
|
*/
|
|
@@ -64,9 +58,9 @@ export interface CalloutProps
|
|
|
64
58
|
|
|
65
59
|
// colors for different callout types
|
|
66
60
|
const colors = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
muted: "bg-
|
|
61
|
+
default: "bg-default text-tint-900 border-tint-100",
|
|
62
|
+
dimmed: "bg-dimmed text-dimmed border-tint-200",
|
|
63
|
+
muted: "bg-muted text-muted border-tint-200",
|
|
70
64
|
primary: "bg-primary-50/50 text-primary-800 border-primary-300",
|
|
71
65
|
accent: "bg-accent-50/50 text-accent-800 border-accent-300",
|
|
72
66
|
info: "bg-info-50/50 text-info-800 border-info-300",
|
|
@@ -83,7 +77,7 @@ const colors = {
|
|
|
83
77
|
* such as alerts, notifications, or important messages.
|
|
84
78
|
*
|
|
85
79
|
* @param {CalloutProps} props - The properties for the Callout component.
|
|
86
|
-
* @returns {
|
|
80
|
+
* @returns {React.ReactElement} The rendered Callout component.
|
|
87
81
|
*
|
|
88
82
|
* @example
|
|
89
83
|
* ```jsx
|
|
@@ -105,6 +99,7 @@ export const Callout = ({
|
|
|
105
99
|
children,
|
|
106
100
|
color = "default",
|
|
107
101
|
legend,
|
|
102
|
+
legendClassName,
|
|
108
103
|
title,
|
|
109
104
|
icon,
|
|
110
105
|
border,
|
|
@@ -115,7 +110,7 @@ export const Callout = ({
|
|
|
115
110
|
return (
|
|
116
111
|
<fieldset
|
|
117
112
|
className={classNames(
|
|
118
|
-
"block rounded-capped border max-w-full relative overflow-hidden
|
|
113
|
+
"block rounded-capped border max-w-full relative overflow-hidden",
|
|
119
114
|
colors[color],
|
|
120
115
|
className,
|
|
121
116
|
border === "dashed" && "border-dashed",
|
|
@@ -124,7 +119,7 @@ export const Callout = ({
|
|
|
124
119
|
{...aria}
|
|
125
120
|
>
|
|
126
121
|
{legend && (
|
|
127
|
-
<legend className="px-2 mx-4 font-medium" data-ref="calloutLegend">
|
|
122
|
+
<legend className={classNames("px-2 mx-4 font-medium", legendClassName)} data-ref="calloutLegend">
|
|
128
123
|
{legend}
|
|
129
124
|
</legend>
|
|
130
125
|
)}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
25
|
import {
|
|
26
26
|
Children,
|
|
27
|
-
|
|
27
|
+
useEffectEvent,
|
|
28
28
|
useMemo,
|
|
29
29
|
type DragEvent,
|
|
30
30
|
type MouseEventHandler,
|
|
@@ -37,17 +37,18 @@ import {
|
|
|
37
37
|
type HeadFootProps,
|
|
38
38
|
} from "../../core/headfoot/HeadFoot";
|
|
39
39
|
import {
|
|
40
|
-
type PolymorphicProps,
|
|
41
40
|
type AriaProps,
|
|
42
41
|
type ChildrenProp,
|
|
43
42
|
type CssProp,
|
|
43
|
+
type PolymorphicProps,
|
|
44
44
|
type RefProp,
|
|
45
45
|
type TestProps,
|
|
46
46
|
} from "../../types";
|
|
47
47
|
import { nodeCheck } from "../../utils";
|
|
48
48
|
|
|
49
49
|
interface BaseProps
|
|
50
|
-
extends
|
|
50
|
+
extends
|
|
51
|
+
CssProp,
|
|
51
52
|
AriaProps,
|
|
52
53
|
TestProps,
|
|
53
54
|
RefProp<HTMLDivElement>,
|
|
@@ -106,7 +107,7 @@ export type CardProps<Tag extends React.ElementType = "div"> = BaseProps &
|
|
|
106
107
|
* It can be styled with custom CSS classes and supports features like selection indication and drag-and-drop functionality.
|
|
107
108
|
*
|
|
108
109
|
* @param {CardProps} props - The properties for the Card component.
|
|
109
|
-
* @returns {
|
|
110
|
+
* @returns {React.ReactElement} The rendered Card component.
|
|
110
111
|
*
|
|
111
112
|
* @example
|
|
112
113
|
* ```jsx
|
|
@@ -161,13 +162,10 @@ export const Card = <Tag extends React.ElementType = "div">({
|
|
|
161
162
|
);
|
|
162
163
|
}, [children]);
|
|
163
164
|
|
|
164
|
-
const handleDragStart =
|
|
165
|
-
(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
[onDragStart, dragKey, dragData],
|
|
170
|
-
);
|
|
165
|
+
const handleDragStart = useEffectEvent((event: DragEvent) => {
|
|
166
|
+
dragKey && event.dataTransfer?.setData(dragKey, JSON.stringify(dragData));
|
|
167
|
+
dragKey && onDragStart?.(event, dragKey, dragData);
|
|
168
|
+
});
|
|
171
169
|
|
|
172
170
|
const E = as ?? "div";
|
|
173
171
|
return (
|
|
@@ -54,7 +54,7 @@ const scheme = {
|
|
|
54
54
|
* It can be used to create visually appealing card layouts with media content.
|
|
55
55
|
*
|
|
56
56
|
* @param {CardCoverProps} props - The properties for the CardCover component.
|
|
57
|
-
* @returns {
|
|
57
|
+
* @returns {React.ReactElement} The rendered CardCover component.
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* ```jsx
|
|
@@ -48,7 +48,7 @@ export interface Props extends ChildrenProp, RefProp<FlipContentRef> {
|
|
|
48
48
|
* The `flipCard` method can be called to toggle the visibility of the back content.
|
|
49
49
|
*
|
|
50
50
|
* @param {Props} props - The properties for the FlipContent component.
|
|
51
|
-
* @returns {
|
|
51
|
+
* @returns {React.ReactElement} The rendered FlipContent component.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
54
|
* ```jsx
|
|
@@ -80,7 +80,7 @@ export const FlipContent = ({ ref, children }: Props) => {
|
|
|
80
80
|
cloneElement(child, {
|
|
81
81
|
className: classNames(
|
|
82
82
|
child.props?.className ?? "",
|
|
83
|
-
idx === 0 ? "bg-
|
|
83
|
+
idx === 0 ? "bg-content relative" : "bg-content absolute inset-0",
|
|
84
84
|
),
|
|
85
85
|
"data-card-flip-face": idx === 0 ? "front" : "back",
|
|
86
86
|
} as AnyObject),
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
25
|
+
import { useEffectEvent, type ReactElement } from "react";
|
|
26
26
|
import { useMemoDebugger } from "../../hooks/useEffectDebugger";
|
|
27
27
|
import {
|
|
28
28
|
type AriaProps,
|
|
@@ -35,15 +35,10 @@ import {
|
|
|
35
35
|
type SizeType,
|
|
36
36
|
type TestProps,
|
|
37
37
|
} from "../../types";
|
|
38
|
-
import { getColor } from "../../utils";
|
|
39
|
-
import {
|
|
38
|
+
import { getColor, getIconProps } from "../../utils";
|
|
39
|
+
import { Icon, type IconProps } from "../icon/Icon";
|
|
40
40
|
|
|
41
|
-
export interface ChipProps
|
|
42
|
-
extends CssProp,
|
|
43
|
-
AriaProps,
|
|
44
|
-
TestProps,
|
|
45
|
-
ChildProp<string | ReactElement>,
|
|
46
|
-
RefProp<HTMLDivElement> {
|
|
41
|
+
export interface ChipProps extends CssProp, AriaProps, TestProps, ChildProp<string | ReactElement>, RefProp<HTMLDivElement> {
|
|
47
42
|
/**
|
|
48
43
|
* chip size
|
|
49
44
|
*/
|
|
@@ -107,7 +102,7 @@ const SizeMap: KeyValue<string> = {
|
|
|
107
102
|
* It can also include an icon and a remove button, making it versatile for different use cases.
|
|
108
103
|
*
|
|
109
104
|
* @param {ChipProps} props - The properties for the Chip component.
|
|
110
|
-
* @returns {
|
|
105
|
+
* @returns {React.ReactElement} The rendered Chip component.
|
|
111
106
|
*
|
|
112
107
|
* @example
|
|
113
108
|
* ```jsx
|
|
@@ -155,22 +150,16 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
155
150
|
"Chip styles",
|
|
156
151
|
);
|
|
157
152
|
|
|
158
|
-
const clickHandler =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
[onClick, preventDefault, stopPropagation],
|
|
165
|
-
);
|
|
153
|
+
const clickHandler = useEffectEvent((e: React.MouseEvent) => {
|
|
154
|
+
preventDefault && e.preventDefault();
|
|
155
|
+
stopPropagation && e.stopPropagation();
|
|
156
|
+
onClick?.(e);
|
|
157
|
+
});
|
|
166
158
|
|
|
167
|
-
const removeHandler =
|
|
168
|
-
(e
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
[onRemove, stopPropagation],
|
|
173
|
-
);
|
|
159
|
+
const removeHandler = useEffectEvent((e: React.MouseEvent) => {
|
|
160
|
+
if (stopPropagation) e.stopPropagation();
|
|
161
|
+
onRemove?.(e);
|
|
162
|
+
});
|
|
174
163
|
|
|
175
164
|
const E = as ?? "div";
|
|
176
165
|
return (
|
|
@@ -201,10 +190,7 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
201
190
|
/>
|
|
202
191
|
)}
|
|
203
192
|
{children && (
|
|
204
|
-
<label
|
|
205
|
-
data-ref="chipLabel"
|
|
206
|
-
className={classNames("fabric-chipLabel", "truncate flex-1")}
|
|
207
|
-
>
|
|
193
|
+
<label data-ref="chipLabel" className={classNames("fabric-chipLabel", "truncate flex-1")}>
|
|
208
194
|
{children}
|
|
209
195
|
</label>
|
|
210
196
|
)}
|
|
@@ -213,10 +199,7 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
213
199
|
role="none"
|
|
214
200
|
data-ref="chipRemove"
|
|
215
201
|
data-inner-cliackable
|
|
216
|
-
className={classNames(
|
|
217
|
-
"fabric-chipRemove",
|
|
218
|
-
"cursor-pointer pe-1 opacity-65 hover:opacity-90",
|
|
219
|
-
)}
|
|
202
|
+
className={classNames("fabric-chipRemove", "cursor-pointer pe-1 opacity-65 hover:opacity-90")}
|
|
220
203
|
onClick={removeHandler}
|
|
221
204
|
>
|
|
222
205
|
×
|
|
@@ -101,7 +101,7 @@ export interface CollapsableProps
|
|
|
101
101
|
* This component is ideal for creating accordions, expandable panels, or sections that can be toggled by the user.
|
|
102
102
|
*
|
|
103
103
|
* @param {CollapsableProps} props - The properties for the Collapsable component.
|
|
104
|
-
* @returns {
|
|
104
|
+
* @returns {React.ReactElement} The rendered Collapsable component.
|
|
105
105
|
*
|
|
106
106
|
* @example
|
|
107
107
|
* ```jsx
|
|
@@ -167,7 +167,7 @@ export const Collapsable = ({
|
|
|
167
167
|
"fabric-collapsableHead",
|
|
168
168
|
"flex gap-1 flex-nowrap py-2 font-medium cursor-pointer items-center select-none hover:opacity-70",
|
|
169
169
|
headerClassName,
|
|
170
|
-
stickyHeader && "bg-
|
|
170
|
+
stickyHeader && "bg-default sticky top-0 py-1 z-10",
|
|
171
171
|
iconAlign === "end" ? "flex-row-reverse" : "flex-row",
|
|
172
172
|
)}
|
|
173
173
|
onClick={() => !disabled && setOpenState(!openState)}
|
|
@@ -61,7 +61,7 @@ export interface DividerProps extends CssProp, Partial<ChildProp> {
|
|
|
61
61
|
* styles, and alignment options.
|
|
62
62
|
*
|
|
63
63
|
* @param {DividerProps} props - The properties for the Divider component.
|
|
64
|
-
* @returns {
|
|
64
|
+
* @returns {React.ReactElement} The rendered Divider component.
|
|
65
65
|
*
|
|
66
66
|
* @example
|
|
67
67
|
* ```jsx
|