@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
|
@@ -32,18 +32,13 @@ import {
|
|
|
32
32
|
} from "@floating-ui/react";
|
|
33
33
|
import { isString } from "@react-fabric/utilities";
|
|
34
34
|
import classNames from "classnames";
|
|
35
|
-
import { isValidElement,
|
|
35
|
+
import { isValidElement, useEffect, useEffectEvent } from "react";
|
|
36
36
|
import { LoadingLine } from "../../components/animations/Animations";
|
|
37
|
-
import {
|
|
37
|
+
import { Icon, type IconProps } from "../../components/icon/Icon";
|
|
38
38
|
import { Header } from "../../core/headfoot/HeadFoot";
|
|
39
39
|
import { HotKeyWrapper } from "../../hotkeys/HotKeyWrapper";
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
type CallbackReturn,
|
|
43
|
-
type ChildrenProp,
|
|
44
|
-
type Elements,
|
|
45
|
-
type TestProps,
|
|
46
|
-
} from "../../types";
|
|
40
|
+
import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type TestProps } from "../../types";
|
|
41
|
+
import { getIconProps } from "../../utils";
|
|
47
42
|
|
|
48
43
|
export interface FlyoutProps extends AriaProps, TestProps, ChildrenProp {
|
|
49
44
|
icon?: IconProps;
|
|
@@ -66,11 +61,11 @@ export interface FlyoutProps extends AriaProps, TestProps, ChildrenProp {
|
|
|
66
61
|
/**
|
|
67
62
|
* modal title
|
|
68
63
|
*/
|
|
69
|
-
title?:
|
|
64
|
+
title?: React.ReactElement | string | false;
|
|
70
65
|
/**
|
|
71
66
|
* header actions
|
|
72
67
|
*/
|
|
73
|
-
actions?: Elements<
|
|
68
|
+
actions?: Elements<React.ReactElement>;
|
|
74
69
|
/**
|
|
75
70
|
* modal size
|
|
76
71
|
*/
|
|
@@ -140,28 +135,17 @@ export const Flyout = ({
|
|
|
140
135
|
// Merge all the interactions into prop getters
|
|
141
136
|
const { getFloatingProps } = useInteractions([dismiss, role]);
|
|
142
137
|
|
|
143
|
-
const handleClose =
|
|
144
|
-
(...args
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
setTimeout(
|
|
155
|
-
() =>
|
|
156
|
-
refs.floating.current
|
|
157
|
-
?.querySelector<HTMLElement>('[role="dialog"]')
|
|
158
|
-
?.focus(),
|
|
159
|
-
50,
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
[onBeforeClose, onClose],
|
|
164
|
-
);
|
|
138
|
+
const handleClose = useEffectEvent((...args: AnyObject) => {
|
|
139
|
+
void Promise.resolve(onBeforeClose?.(...args)).then((ret) => {
|
|
140
|
+
if (ret !== false) {
|
|
141
|
+
refs.floating.current && (refs.floating.current.dataset.show = "false");
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
onClose?.(...args);
|
|
144
|
+
}, 250);
|
|
145
|
+
}
|
|
146
|
+
ret === false && setTimeout(() => refs.floating.current?.querySelector<HTMLElement>('[role="dialog"]')?.focus(), 50);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
165
149
|
|
|
166
150
|
useEffect(() => {
|
|
167
151
|
setTimeout(() => {
|
|
@@ -169,19 +153,13 @@ export const Flyout = ({
|
|
|
169
153
|
}, 50);
|
|
170
154
|
}, []);
|
|
171
155
|
|
|
172
|
-
const tryClosing =
|
|
173
|
-
(e
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
handleClose();
|
|
180
|
-
}, 100);
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
[closeOnClick, handleClose],
|
|
184
|
-
);
|
|
156
|
+
const tryClosing = useEffectEvent((e: React.MouseEvent) => {
|
|
157
|
+
if (!!closeOnClick || (e.target as HTMLElement).closest("[data-flyout-dismiss='true']")) {
|
|
158
|
+
setTimeout(() => {
|
|
159
|
+
handleClose();
|
|
160
|
+
}, 100);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
185
163
|
|
|
186
164
|
return (
|
|
187
165
|
<FloatingPortal root={root}>
|
|
@@ -192,15 +170,15 @@ export const Flyout = ({
|
|
|
192
170
|
className="bg-tint-100/10 backdrop-blur-sm transition-all"
|
|
193
171
|
/>
|
|
194
172
|
)}
|
|
195
|
-
<FloatingFocusManager context={context}>
|
|
173
|
+
<FloatingFocusManager context={context} modal>
|
|
196
174
|
<div
|
|
197
175
|
data-align={align}
|
|
198
176
|
className={classNames(
|
|
199
177
|
"fabric-flyout",
|
|
200
178
|
"fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl",
|
|
201
|
-
align === "start" ? "
|
|
202
|
-
size === "sm" && "w-
|
|
203
|
-
size === "md" && "w-
|
|
179
|
+
align === "start" ? "inset-s-0" : "inset-e-0",
|
|
180
|
+
size === "sm" && "w-80",
|
|
181
|
+
size === "md" && "w-160",
|
|
204
182
|
size === "lg" && "w-[60vw]",
|
|
205
183
|
size === "xl" && "w-[80vw]",
|
|
206
184
|
)}
|
|
@@ -215,26 +193,14 @@ export const Flyout = ({
|
|
|
215
193
|
{...aria}
|
|
216
194
|
>
|
|
217
195
|
<HotKeyWrapper>
|
|
218
|
-
<Header
|
|
219
|
-
|
|
220
|
-
align="center"
|
|
221
|
-
className={classNames("fabric-flyoutHeader", headerClassName)}
|
|
222
|
-
>
|
|
223
|
-
{isString(icon) && (
|
|
224
|
-
<Icon
|
|
225
|
-
className={classNames(iconClassName, "p-1")}
|
|
226
|
-
{...getIconProps(icon)}
|
|
227
|
-
/>
|
|
228
|
-
)}
|
|
196
|
+
<Header flex align="center" className={classNames("fabric-flyoutHeader", headerClassName)}>
|
|
197
|
+
{isString(icon) && <Icon className={classNames(iconClassName, "p-1")} {...getIconProps(icon)} />}
|
|
229
198
|
{isValidElement(icon) && icon}
|
|
230
199
|
<label className="flex-1 truncate py-2 px-1">{title}</label>
|
|
231
200
|
{actions}
|
|
232
201
|
<Icon
|
|
233
202
|
data-ref="panelClose"
|
|
234
|
-
className={classNames(
|
|
235
|
-
"fabric-panelAction",
|
|
236
|
-
"cursor-pointer p-1 text-xl self-center",
|
|
237
|
-
)}
|
|
203
|
+
className={classNames("fabric-panelAction", "cursor-pointer p-1 text-xl self-center")}
|
|
238
204
|
icon="icon-[mdi--close]"
|
|
239
205
|
onClick={() => handleClose(false)}
|
|
240
206
|
/>
|
|
@@ -242,10 +208,7 @@ export const Flyout = ({
|
|
|
242
208
|
{loading && <LoadingLine />}
|
|
243
209
|
<div
|
|
244
210
|
role="dialog"
|
|
245
|
-
className={classNames(
|
|
246
|
-
"fabric-flyoutBody",
|
|
247
|
-
"flex-1 grid overflow-hidden",
|
|
248
|
-
)}
|
|
211
|
+
className={classNames("fabric-flyoutBody", "flex-1 grid overflow-hidden")}
|
|
249
212
|
{...({ tabIndex: 0 } as AnyObject)}
|
|
250
213
|
>
|
|
251
214
|
{children}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
25
|
+
import { useEffectEvent, useLayoutEffect, useRef } from "react";
|
|
26
26
|
import { Icon } from "../../components/icon/Icon";
|
|
27
27
|
import { type ColorState, type Elements } from "../../types";
|
|
28
28
|
import { getColor } from "../../utils";
|
|
@@ -47,7 +47,7 @@ export interface MessageProps {
|
|
|
47
47
|
/**
|
|
48
48
|
* message text
|
|
49
49
|
*/
|
|
50
|
-
message: string |
|
|
50
|
+
message: string | React.ReactElement;
|
|
51
51
|
/**
|
|
52
52
|
* theme color
|
|
53
53
|
*/
|
|
@@ -55,7 +55,7 @@ export interface MessageProps {
|
|
|
55
55
|
/**
|
|
56
56
|
* extra action button
|
|
57
57
|
*/
|
|
58
|
-
actions?: Elements<
|
|
58
|
+
actions?: Elements<React.ReactElement>;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export const Message = ({
|
|
@@ -67,19 +67,15 @@ export const Message = ({
|
|
|
67
67
|
rtlFlip,
|
|
68
68
|
actions,
|
|
69
69
|
// @ts-expect-error internal prop
|
|
70
|
-
// eslint-disable-next-line react/prop-types --- IGNORE ---
|
|
71
70
|
onClose,
|
|
72
71
|
}: MessageProps) => {
|
|
73
72
|
const elRef = useRef<HTMLDivElement>(null);
|
|
74
|
-
const handleClose =
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
[onClose],
|
|
82
|
-
);
|
|
73
|
+
const handleClose = useEffectEvent((ret?: AnyObject) => {
|
|
74
|
+
elRef.current && (elRef.current.dataset.show = "false");
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
onClose(ret);
|
|
77
|
+
}, 250);
|
|
78
|
+
});
|
|
83
79
|
useLayoutEffect(() => {
|
|
84
80
|
setTimeout(
|
|
85
81
|
() => elRef.current && (elRef.current.dataset.show = "true"),
|
|
@@ -91,7 +87,7 @@ export const Message = ({
|
|
|
91
87
|
<div
|
|
92
88
|
className={classNames(
|
|
93
89
|
"fabric-message",
|
|
94
|
-
"flex flex-nowrap gap-1 px-8 relative justify-center max-w-md pointer-events-auto rounded mb-2 select-none",
|
|
90
|
+
"flex flex-nowrap gap-1 px-8 relative justify-center items-center max-w-md pointer-events-auto rounded mb-2 select-none",
|
|
95
91
|
)}
|
|
96
92
|
style={{
|
|
97
93
|
backgroundColor: color
|
|
@@ -116,7 +112,7 @@ export const Message = ({
|
|
|
116
112
|
)}
|
|
117
113
|
<div
|
|
118
114
|
role="none"
|
|
119
|
-
className="cursor-pointer opacity-65 absolute
|
|
115
|
+
className="cursor-pointer opacity-65 absolute inset-e-1 hover:opacity-90"
|
|
120
116
|
onClick={() => handleClose()}
|
|
121
117
|
>
|
|
122
118
|
×
|
|
@@ -32,18 +32,13 @@ import {
|
|
|
32
32
|
} from "@floating-ui/react";
|
|
33
33
|
import { isString } from "@react-fabric/utilities";
|
|
34
34
|
import classNames from "classnames";
|
|
35
|
-
import { isValidElement,
|
|
35
|
+
import { isValidElement, useEffect, useEffectEvent } from "react";
|
|
36
36
|
import { LoadingLine } from "../../components/animations/Animations";
|
|
37
|
-
import {
|
|
37
|
+
import { Icon, type IconProps } from "../../components/icon/Icon";
|
|
38
38
|
import { Header } from "../../core/headfoot/HeadFoot";
|
|
39
39
|
import { HotKeyWrapper } from "../../hotkeys/HotKeyWrapper";
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
type CallbackReturn,
|
|
43
|
-
type ChildrenProp,
|
|
44
|
-
type Elements,
|
|
45
|
-
type TestProps,
|
|
46
|
-
} from "../../types";
|
|
40
|
+
import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type TestProps } from "../../types";
|
|
41
|
+
import { getIconProps } from "../../utils";
|
|
47
42
|
|
|
48
43
|
export interface ModalProps extends AriaProps, TestProps, ChildrenProp {
|
|
49
44
|
icon?: IconProps;
|
|
@@ -62,11 +57,11 @@ export interface ModalProps extends AriaProps, TestProps, ChildrenProp {
|
|
|
62
57
|
/**
|
|
63
58
|
* modal title
|
|
64
59
|
*/
|
|
65
|
-
title?:
|
|
60
|
+
title?: React.ReactElement | string | false;
|
|
66
61
|
/**
|
|
67
62
|
* header actions
|
|
68
63
|
*/
|
|
69
|
-
actions?: Elements<
|
|
64
|
+
actions?: Elements<React.ReactElement>;
|
|
70
65
|
/**
|
|
71
66
|
* modal size
|
|
72
67
|
*/
|
|
@@ -139,28 +134,17 @@ export const Modal = ({
|
|
|
139
134
|
// Merge all the interactions into prop getters
|
|
140
135
|
const { getFloatingProps } = useInteractions([dismiss, role]);
|
|
141
136
|
|
|
142
|
-
const handleClose =
|
|
143
|
-
(...args
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
setTimeout(
|
|
154
|
-
() =>
|
|
155
|
-
refs.floating.current
|
|
156
|
-
?.querySelector<HTMLElement>("[role='dialog']")
|
|
157
|
-
?.focus(),
|
|
158
|
-
50,
|
|
159
|
-
);
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
[onBeforeClose, onClose],
|
|
163
|
-
);
|
|
137
|
+
const handleClose = useEffectEvent((...args: AnyObject) => {
|
|
138
|
+
void Promise.resolve(onBeforeClose?.(...args)).then((ret) => {
|
|
139
|
+
if (ret !== false) {
|
|
140
|
+
refs.floating.current && (refs.floating.current.dataset.show = "false");
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
onClose?.(...args);
|
|
143
|
+
}, 250);
|
|
144
|
+
}
|
|
145
|
+
ret === false && setTimeout(() => refs.floating.current?.querySelector<HTMLElement>("[role='dialog']")?.focus(), 50);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
164
148
|
|
|
165
149
|
useEffect(() => {
|
|
166
150
|
setTimeout(() => {
|
|
@@ -177,12 +161,9 @@ export const Modal = ({
|
|
|
177
161
|
position: "absolute",
|
|
178
162
|
overflow: "hidden",
|
|
179
163
|
}}
|
|
180
|
-
className={classNames(
|
|
181
|
-
"grid place-items-center p-16",
|
|
182
|
-
!hideMask && "bg-tint-100/20 backdrop-blur-sm",
|
|
183
|
-
)}
|
|
164
|
+
className={classNames("grid place-items-center p-16", !hideMask && "bg-tint-100/20 backdrop-blur-sm")}
|
|
184
165
|
>
|
|
185
|
-
<FloatingFocusManager context={context}>
|
|
166
|
+
<FloatingFocusManager context={context} modal>
|
|
186
167
|
<dialog
|
|
187
168
|
className={classNames(
|
|
188
169
|
"fabric-modal",
|
|
@@ -205,26 +186,14 @@ export const Modal = ({
|
|
|
205
186
|
{...aria}
|
|
206
187
|
>
|
|
207
188
|
<HotKeyWrapper>
|
|
208
|
-
<Header
|
|
209
|
-
|
|
210
|
-
align="center"
|
|
211
|
-
className={classNames("fabric-modalHeader", headerClassName)}
|
|
212
|
-
>
|
|
213
|
-
{isString(icon) && (
|
|
214
|
-
<Icon
|
|
215
|
-
className={classNames(iconClassName, "p-1")}
|
|
216
|
-
{...getIconProps(icon)}
|
|
217
|
-
/>
|
|
218
|
-
)}
|
|
189
|
+
<Header flex align="center" className={classNames("fabric-modalHeader", headerClassName)}>
|
|
190
|
+
{isString(icon) && <Icon className={classNames(iconClassName, "p-1")} {...getIconProps(icon)} />}
|
|
219
191
|
{isValidElement(icon) && icon}
|
|
220
192
|
<label className="flex-1 truncate py-2 px-1">{title}</label>
|
|
221
193
|
{actions}
|
|
222
194
|
<Icon
|
|
223
195
|
data-ref="panelClose"
|
|
224
|
-
className={classNames(
|
|
225
|
-
"fabric-panelAction",
|
|
226
|
-
"cursor-pointer p-1 text-xl self-center",
|
|
227
|
-
)}
|
|
196
|
+
className={classNames("fabric-panelAction", "cursor-pointer p-1 text-xl self-center")}
|
|
228
197
|
icon="icon-[mdi--close]"
|
|
229
198
|
onClick={() => handleClose(false)}
|
|
230
199
|
/>
|
|
@@ -232,10 +201,7 @@ export const Modal = ({
|
|
|
232
201
|
{loading && <LoadingLine />}
|
|
233
202
|
<div
|
|
234
203
|
role="dialog"
|
|
235
|
-
className={classNames(
|
|
236
|
-
"fabric-modalBody",
|
|
237
|
-
"flex-1 grid overflow-hidden",
|
|
238
|
-
)}
|
|
204
|
+
className={classNames("fabric-modalBody", "flex-1 grid overflow-hidden")}
|
|
239
205
|
{...({ tabIndex: 0 } as AnyObject)}
|
|
240
206
|
>
|
|
241
207
|
{children}
|
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
Fragment,
|
|
27
|
+
useEffectEvent,
|
|
28
|
+
useLayoutEffect,
|
|
29
|
+
useMemo,
|
|
30
|
+
useRef,
|
|
31
|
+
} from "react";
|
|
26
32
|
import { useTranslation } from "react-i18next";
|
|
27
33
|
import { AnimationIndicator } from "../../components/animations/Animations";
|
|
28
34
|
import { Button } from "../../components/button/Button";
|
|
@@ -54,7 +60,7 @@ export interface ToastProps {
|
|
|
54
60
|
/**
|
|
55
61
|
* toast text
|
|
56
62
|
*/
|
|
57
|
-
message: string |
|
|
63
|
+
message: string | React.ReactElement;
|
|
58
64
|
/**
|
|
59
65
|
* theme color
|
|
60
66
|
*/
|
|
@@ -62,7 +68,7 @@ export interface ToastProps {
|
|
|
62
68
|
/**
|
|
63
69
|
* extra action button
|
|
64
70
|
*/
|
|
65
|
-
actions?: Elements<
|
|
71
|
+
actions?: Elements<React.ReactElement>;
|
|
66
72
|
/**
|
|
67
73
|
* ok label
|
|
68
74
|
*/
|
|
@@ -82,10 +88,8 @@ export const Toast = ({
|
|
|
82
88
|
rtlFlip,
|
|
83
89
|
actions,
|
|
84
90
|
// @ts-expect-error internal prop
|
|
85
|
-
// eslint-disable-next-line react/prop-types --- IGNORE ---
|
|
86
91
|
onClose,
|
|
87
92
|
// @ts-expect-error internal prop
|
|
88
|
-
// eslint-disable-next-line react/prop-types --- IGNORE ---
|
|
89
93
|
onCloseAll,
|
|
90
94
|
type,
|
|
91
95
|
okLabel,
|
|
@@ -122,15 +126,12 @@ export const Toast = ({
|
|
|
122
126
|
}, [color, type, icon, iconSrc, rtlFlip]);
|
|
123
127
|
|
|
124
128
|
const elRef = useRef<HTMLDivElement>(null);
|
|
125
|
-
const handleClose =
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
[onClose],
|
|
133
|
-
);
|
|
129
|
+
const handleClose = useEffectEvent((ret?: AnyObject) => {
|
|
130
|
+
elRef.current && (elRef.current.dataset.show = "false");
|
|
131
|
+
setTimeout(() => {
|
|
132
|
+
onClose(ret);
|
|
133
|
+
}, 250);
|
|
134
|
+
});
|
|
134
135
|
useLayoutEffect(() => {
|
|
135
136
|
setTimeout(
|
|
136
137
|
() => elRef.current && (elRef.current.dataset.show = "true"),
|
|
@@ -143,7 +144,7 @@ export const Toast = ({
|
|
|
143
144
|
role="alert"
|
|
144
145
|
className={classNames(
|
|
145
146
|
"fabric-toast",
|
|
146
|
-
"flex flex-nowrap max-w-sm bg-
|
|
147
|
+
"flex flex-nowrap max-w-sm bg-default min-w-72 border pointer-events-auto relative overflow-hidden rounded-capped mt-4 select-none",
|
|
147
148
|
)}
|
|
148
149
|
style={{
|
|
149
150
|
borderColor: getColor(color + "-300"),
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
useInteractions,
|
|
36
36
|
type Placement,
|
|
37
37
|
} from "@floating-ui/react";
|
|
38
|
-
import {
|
|
38
|
+
import { isString, mergeRefs } from "@react-fabric/utilities";
|
|
39
39
|
import classNames from "classnames";
|
|
40
40
|
import {
|
|
41
41
|
Fragment,
|
|
@@ -66,18 +66,6 @@ export interface TooltipProps extends TooltipType, RefProp {
|
|
|
66
66
|
children: ReactElement<KeyValue>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export const getTooltipProps = (
|
|
70
|
-
tooltip?: string | TooltipType,
|
|
71
|
-
innerRef?: AnyObject,
|
|
72
|
-
): (TooltipType & { ref: AnyObject }) | undefined => {
|
|
73
|
-
if (isString(tooltip) || isValidElement(tooltip)) {
|
|
74
|
-
return { ref: innerRef, placement: "top", content: tooltip };
|
|
75
|
-
}
|
|
76
|
-
if (isObject(tooltip)) {
|
|
77
|
-
return Object.assign({ ref: innerRef, placement: "top" }, tooltip);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
69
|
export const Tooltip = ({
|
|
82
70
|
ref,
|
|
83
71
|
children,
|
|
@@ -101,9 +89,7 @@ export const Tooltip = ({
|
|
|
101
89
|
const placement = useMemo<Placement>(() => {
|
|
102
90
|
if (isRtl)
|
|
103
91
|
return (
|
|
104
|
-
_placement?.includes("left")
|
|
105
|
-
? _placement.replace("left", "right")
|
|
106
|
-
: _placement?.replace("right", "left") ?? "top"
|
|
92
|
+
_placement?.includes("left") ? _placement.replace("left", "right") : (_placement?.replace("right", "left") ?? "top")
|
|
107
93
|
) as Placement;
|
|
108
94
|
|
|
109
95
|
return _placement ?? "top";
|
|
@@ -131,9 +117,7 @@ export const Tooltip = ({
|
|
|
131
117
|
handleClose: copyContent ? safePolygon({ buffer: 1 }) : undefined,
|
|
132
118
|
});
|
|
133
119
|
|
|
134
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
135
|
-
open ? undefined : hover,
|
|
136
|
-
]);
|
|
120
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([open ? undefined : hover]);
|
|
137
121
|
|
|
138
122
|
useEffect(() => {
|
|
139
123
|
context.update();
|
|
@@ -172,7 +156,7 @@ export const Tooltip = ({
|
|
|
172
156
|
...(open ? {} : getReferenceProps(rest)),
|
|
173
157
|
})}
|
|
174
158
|
{isOpen && content && (
|
|
175
|
-
<FloatingPortal>
|
|
159
|
+
<FloatingPortal root={refs.domReference.current?.closest<HTMLElement>(".theme-base") ?? undefined}>
|
|
176
160
|
<dfn
|
|
177
161
|
data-ref="tooltip"
|
|
178
162
|
className={classNames(
|
|
@@ -190,16 +174,9 @@ export const Tooltip = ({
|
|
|
190
174
|
{isValidElement(content) && content}
|
|
191
175
|
{isString(content) && (
|
|
192
176
|
<span
|
|
193
|
-
className={classNames(
|
|
194
|
-
"font-medium flex-1 break-all whitespace-pre-wrap mixed-lang",
|
|
195
|
-
!textColor && "contrast",
|
|
196
|
-
)}
|
|
177
|
+
className={classNames("font-medium flex-1 break-all whitespace-pre-wrap mixed-lang", !textColor && "contrast")}
|
|
197
178
|
style={{
|
|
198
|
-
color: textColor
|
|
199
|
-
? undefined
|
|
200
|
-
: color
|
|
201
|
-
? getColor(color)
|
|
202
|
-
: "var(--bg-color-muted)",
|
|
179
|
+
color: textColor ? undefined : color ? getColor(color) : "var(--bg-color-muted)",
|
|
203
180
|
}}
|
|
204
181
|
>
|
|
205
182
|
{content}
|
package/src/types/global.d.ts
CHANGED
|
@@ -53,6 +53,10 @@ declare module "*.jpeg" {
|
|
|
53
53
|
const content: any;
|
|
54
54
|
export default content;
|
|
55
55
|
}
|
|
56
|
+
declare module "*.webp" {
|
|
57
|
+
const content: any;
|
|
58
|
+
export default content;
|
|
59
|
+
}
|
|
56
60
|
declare module "*.svg" {
|
|
57
61
|
const content: any;
|
|
58
62
|
export default content;
|
|
@@ -69,6 +73,14 @@ declare module "*.css" {
|
|
|
69
73
|
const content: any;
|
|
70
74
|
export default content;
|
|
71
75
|
}
|
|
76
|
+
declare module "*.txt" {
|
|
77
|
+
const content: any;
|
|
78
|
+
export default content;
|
|
79
|
+
}
|
|
80
|
+
declare module "*.vtt" {
|
|
81
|
+
const content: any;
|
|
82
|
+
export default content;
|
|
83
|
+
}
|
|
72
84
|
|
|
73
85
|
interface HDate extends Date {
|
|
74
86
|
toGregorian: () => Date;
|
package/src/types/index.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/* istanbul ignore file */
|
|
24
24
|
|
|
25
25
|
import { type Placement } from "@floating-ui/react";
|
|
26
|
-
import { type JSXElementConstructor, type Ref } from "react";
|
|
26
|
+
import { type JSX, type JSXElementConstructor, type Ref } from "react";
|
|
27
27
|
|
|
28
28
|
export type ModalProps<P = unknown> = P & {
|
|
29
29
|
onClose: (...args: AnyObject) => void;
|
|
@@ -299,7 +299,7 @@ export interface TooltipType {
|
|
|
299
299
|
/**
|
|
300
300
|
* tooltip content
|
|
301
301
|
*/
|
|
302
|
-
content?: string |
|
|
302
|
+
content?: string | React.ReactElement;
|
|
303
303
|
/**
|
|
304
304
|
* tooltip color
|
|
305
305
|
*/
|
package/src/typography/Abbr.tsx
CHANGED
|
@@ -25,14 +25,9 @@ import { isEmpty, isString, tokenize } from "@react-fabric/utilities";
|
|
|
25
25
|
import classNames from "classnames";
|
|
26
26
|
import { Fragment, useCallback, useMemo } from "react";
|
|
27
27
|
import { useMemoDebugger } from "../hooks/useEffectDebugger";
|
|
28
|
-
import { Tooltip
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
type ColorType,
|
|
32
|
-
type CssProp,
|
|
33
|
-
type PaletteType,
|
|
34
|
-
} from "../types";
|
|
35
|
-
import { getColor } from "../utils";
|
|
28
|
+
import { Tooltip } from "../overlays/tooltip/Tooltip";
|
|
29
|
+
import { type ChildProp, type ColorType, type CssProp, type PaletteType } from "../types";
|
|
30
|
+
import { getColor, getTooltipProps } from "../utils";
|
|
36
31
|
|
|
37
32
|
interface AbbrTextProps {
|
|
38
33
|
children: string;
|
|
@@ -42,10 +37,7 @@ interface AbbrTextProps {
|
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
const AbbrText = ({ color, children, tooltip, content }: AbbrTextProps) => {
|
|
45
|
-
const TooltipWrapper = useMemo(
|
|
46
|
-
() => (tooltip ? Tooltip : Fragment),
|
|
47
|
-
[tooltip],
|
|
48
|
-
);
|
|
40
|
+
const TooltipWrapper = useMemo(() => (tooltip ? Tooltip : Fragment), [tooltip]);
|
|
49
41
|
const tooltipProps = useMemo(() => {
|
|
50
42
|
return tooltip ? { ...getTooltipProps(tooltip), copyContent: content } : {};
|
|
51
43
|
}, [tooltip, content]);
|
|
@@ -54,9 +46,7 @@ const AbbrText = ({ color, children, tooltip, content }: AbbrTextProps) => {
|
|
|
54
46
|
<TooltipWrapper {...tooltipProps}>
|
|
55
47
|
<abbr
|
|
56
48
|
className={classNames("fabric-abbr", "whitespace-nowrap")}
|
|
57
|
-
style={
|
|
58
|
-
color ? ({ "--abbr-color": getColor(color) } as AnyObject) : undefined
|
|
59
|
-
}
|
|
49
|
+
style={color ? ({ "--abbr-color": getColor(color) } as AnyObject) : undefined}
|
|
60
50
|
>
|
|
61
51
|
{children}
|
|
62
52
|
</abbr>
|
|
@@ -74,17 +64,11 @@ export interface AbbrProps extends ChildProp<string>, CssProp {
|
|
|
74
64
|
*
|
|
75
65
|
* [textPart, tooltip, color (class name or color string)]
|
|
76
66
|
*/
|
|
77
|
-
abbr: Array<
|
|
78
|
-
[
|
|
79
|
-
textPart: string,
|
|
80
|
-
tooltip: string,
|
|
81
|
-
color?: ColorType | PaletteType | string,
|
|
82
|
-
]
|
|
83
|
-
>;
|
|
67
|
+
abbr: Array<[textPart: string, tooltip: string, color?: ColorType | PaletteType | string]>;
|
|
84
68
|
/**
|
|
85
69
|
* renderer callback
|
|
86
70
|
*/
|
|
87
|
-
renderer?: (part: string[]) =>
|
|
71
|
+
renderer?: (part: string[]) => React.ReactElement;
|
|
88
72
|
}
|
|
89
73
|
|
|
90
74
|
/**
|
|
@@ -96,7 +80,7 @@ export interface AbbrProps extends ChildProp<string>, CssProp {
|
|
|
96
80
|
* while providing additional context through tooltips.
|
|
97
81
|
*
|
|
98
82
|
* @param {AbbrProps} props - The properties for the Abbr component.
|
|
99
|
-
* @returns {
|
|
83
|
+
* @returns {React.ReactElement} The rendered Abbr component.
|
|
100
84
|
*
|
|
101
85
|
* @example
|
|
102
86
|
* ```jsx
|
|
@@ -117,22 +101,12 @@ export interface AbbrProps extends ChildProp<string>, CssProp {
|
|
|
117
101
|
*
|
|
118
102
|
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/core-typography--abbr} for more details.
|
|
119
103
|
*/
|
|
120
|
-
export const Abbr = ({
|
|
121
|
-
children,
|
|
122
|
-
abbr,
|
|
123
|
-
className,
|
|
124
|
-
renderer,
|
|
125
|
-
copyContent = "text",
|
|
126
|
-
}: AbbrProps) => {
|
|
104
|
+
export const Abbr = ({ children, abbr, className, renderer, copyContent = "text" }: AbbrProps) => {
|
|
127
105
|
/** ***************** abbr text renderer *******************/
|
|
128
106
|
const abbrRender = useCallback(
|
|
129
107
|
(text: string, tooltip: string, color = "") => {
|
|
130
108
|
return (
|
|
131
|
-
<AbbrText
|
|
132
|
-
color={color}
|
|
133
|
-
tooltip={tooltip}
|
|
134
|
-
content={copyContent === "tooltip" ? tooltip : text}
|
|
135
|
-
>
|
|
109
|
+
<AbbrText color={color} tooltip={tooltip} content={copyContent === "tooltip" ? tooltip : text}>
|
|
136
110
|
{(renderer?.([text, tooltip, color]) ?? text) as string}
|
|
137
111
|
</AbbrText>
|
|
138
112
|
);
|
|
@@ -142,7 +116,6 @@ export const Abbr = ({
|
|
|
142
116
|
|
|
143
117
|
/** ***************** tokenize text with abbr list *******************/
|
|
144
118
|
const inner = useMemoDebugger(
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
146
119
|
() => {
|
|
147
120
|
if (isString(children)) {
|
|
148
121
|
if (!isEmpty(abbr)) {
|
|
@@ -163,8 +136,7 @@ export const Abbr = ({
|
|
|
163
136
|
return (
|
|
164
137
|
<Fragment>
|
|
165
138
|
{tokens.map(([start, text], i) => {
|
|
166
|
-
const { tooltip = "", color = "" } =
|
|
167
|
-
titles[text.toLowerCase()] ?? {};
|
|
139
|
+
const { tooltip = "", color = "" } = titles[text.toLowerCase()] ?? {};
|
|
168
140
|
return (
|
|
169
141
|
<Fragment key={i}>
|
|
170
142
|
{start}
|