@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
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}
|
|
@@ -66,7 +66,7 @@ export interface AnchorProps extends ChildrenProp, CssProp, RefProp, AriaProps {
|
|
|
66
66
|
*
|
|
67
67
|
* @param {AnchorProps} props - The properties for the Anchor component.
|
|
68
68
|
* @param {Tag} as - The HTML element type to render as (default is "a").
|
|
69
|
-
* @returns {
|
|
69
|
+
* @returns {React.ReactElement} - A styled anchor element with the specified properties.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```jsx
|
package/src/typography/Copy.tsx
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
25
|
+
import { useEffectEvent } from "react";
|
|
26
26
|
import { useTranslation } from "react-i18next";
|
|
27
27
|
import { Button } from "../components/button/Button";
|
|
28
28
|
import { Tooltip } from "../overlays/tooltip/Tooltip";
|
|
@@ -34,7 +34,7 @@ import { type CssProp, type SizeType } from "../types";
|
|
|
34
34
|
* The button displays a tooltip feedback when the text is successfully copied.
|
|
35
35
|
*
|
|
36
36
|
* @param {CopyProps} props - The properties for the Copy component.
|
|
37
|
-
* @returns {
|
|
37
|
+
* @returns {React.ReactElement} The rendered Copy component.
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```jsx
|
|
@@ -55,9 +55,9 @@ export const Copy = ({ text, size, className }: CopyProps) => {
|
|
|
55
55
|
const { t } = useTranslation("core");
|
|
56
56
|
|
|
57
57
|
/** ***************** handle copy *******************/
|
|
58
|
-
const doCopy =
|
|
58
|
+
const doCopy = useEffectEvent(() => {
|
|
59
59
|
void navigator.clipboard.writeText(text);
|
|
60
|
-
}
|
|
60
|
+
});
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
63
|
<Tooltip content={t("action.copy")}>
|
package/src/typography/Mark.tsx
CHANGED
|
@@ -56,7 +56,7 @@ export interface MarkProps extends ChildProp<string> {
|
|
|
56
56
|
/**
|
|
57
57
|
* renderer callback
|
|
58
58
|
*/
|
|
59
|
-
renderer?: (part: string[]) =>
|
|
59
|
+
renderer?: (part: string[]) => React.ReactElement;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -67,7 +67,7 @@ export interface MarkProps extends ChildProp<string> {
|
|
|
67
67
|
* allowing for greater flexibility in how the text is presented.
|
|
68
68
|
*
|
|
69
69
|
* @param {MarkProps} props - The properties for the Mark component.
|
|
70
|
-
* @returns {
|
|
70
|
+
* @returns {React.ReactElement} The rendered Mark component.
|
|
71
71
|
*
|
|
72
72
|
* @example
|
|
73
73
|
* <Mark
|
|
@@ -96,7 +96,6 @@ export const Mark = ({ children, mark, renderer }: MarkProps) => {
|
|
|
96
96
|
|
|
97
97
|
/** ***************** tokenize text with abbr list *******************/
|
|
98
98
|
const inner = useMemoDebugger(
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
100
99
|
() => {
|
|
101
100
|
if (isString(children)) {
|
|
102
101
|
if (!isEmpty(mark)) {
|
package/src/typography/Text.tsx
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { isNumber } from "@react-fabric/utilities";
|
|
25
25
|
import classNames from "classnames";
|
|
26
|
-
import {
|
|
26
|
+
import { useEffectEvent, useRef, useState } from "react";
|
|
27
27
|
import { useTranslation } from "react-i18next";
|
|
28
28
|
import {
|
|
29
29
|
useLayoutEffectDebugger,
|
|
@@ -80,7 +80,7 @@ export interface TextProps extends ChildrenProp, CssProp, AriaProps, TestProps {
|
|
|
80
80
|
* It leverages the ResizeObserver API to detect changes in the text container's size and adjust the line clamping accordingly.
|
|
81
81
|
*
|
|
82
82
|
* @param {TextProps} props - The properties for the Text component.
|
|
83
|
-
* @returns {
|
|
83
|
+
* @returns {React.ReactElement} The rendered Text component.
|
|
84
84
|
*
|
|
85
85
|
* @example
|
|
86
86
|
* ```jsx
|
|
@@ -119,7 +119,7 @@ export const Text = ({
|
|
|
119
119
|
const [showMore, toggleShowMore, refShowMore] = usePropToggle(false);
|
|
120
120
|
|
|
121
121
|
/** ***************** check text height if clip enabled *******************/
|
|
122
|
-
const checkHeight =
|
|
122
|
+
const checkHeight = useEffectEvent(() => {
|
|
123
123
|
const el = refContainer.current as HTMLElement;
|
|
124
124
|
if (el && isNumber(clamp) && clamp > 0 && !refShowMore.current) {
|
|
125
125
|
setClipped(
|
|
@@ -127,7 +127,7 @@ export const Text = ({
|
|
|
127
127
|
el.offsetHeight,
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
|
-
}
|
|
130
|
+
});
|
|
131
131
|
|
|
132
132
|
/** ***************** observe element resize to recalculate height *******************/
|
|
133
133
|
useLayoutEffectDebugger(
|
|
@@ -179,13 +179,15 @@ export const Text = ({
|
|
|
179
179
|
<div
|
|
180
180
|
ref={refContainer}
|
|
181
181
|
style={
|
|
182
|
-
{
|
|
182
|
+
{
|
|
183
|
+
"--text-clamp": showMore ? "unset" : (clamp ?? "unset"),
|
|
184
|
+
} as AnyObject
|
|
183
185
|
}
|
|
184
186
|
>
|
|
185
187
|
<div
|
|
186
188
|
className={classNames(
|
|
187
189
|
"fabric-text",
|
|
188
|
-
"mixed-lang px-
|
|
190
|
+
"mixed-lang px-0.5 whitespace-pre-wrap",
|
|
189
191
|
family && `font-${family}`,
|
|
190
192
|
clamp && "line-clamp-1",
|
|
191
193
|
)}
|
package/src/typography/Title.tsx
CHANGED
|
@@ -71,7 +71,7 @@ export interface TitleProps extends ChildrenProp, CssProp, AriaProps {
|
|
|
71
71
|
* This component is useful for creating headings or titles in a consistent style across an application.
|
|
72
72
|
*
|
|
73
73
|
* @param {TitleProps} props - The properties for the Title component.
|
|
74
|
-
* @returns {
|
|
74
|
+
* @returns {React.ReactElement} The rendered Title component.
|
|
75
75
|
*
|
|
76
76
|
* @example
|
|
77
77
|
* ```jsx
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2026 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { isObject } from "@react-fabric/utilities";
|
|
25
|
+
import { isValidElement } from "react";
|
|
26
|
+
import { BadgeType } from "../types";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Utility function to get badge properties from a badge value or object.
|
|
30
|
+
* It checks if the badge is an object and returns its properties,
|
|
31
|
+
*
|
|
32
|
+
* @param {string | number | BadgeType} badge - The badge value or object.
|
|
33
|
+
* @returns {AnyObject} An object containing badge properties.
|
|
34
|
+
*/
|
|
35
|
+
export const getBadgeProps = (badge?: string | number | BadgeType): AnyObject => {
|
|
36
|
+
if (isObject(badge) && !isValidElement(badge)) {
|
|
37
|
+
return Object.assign({ forButton: true, placement: "" }, badge);
|
|
38
|
+
} else {
|
|
39
|
+
return {
|
|
40
|
+
value: badge,
|
|
41
|
+
forButton: true,
|
|
42
|
+
placement: "",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2026 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { isValidElement } from "react";
|
|
25
|
+
import { IconProps, Props } from "../components/icon/Icon";
|
|
26
|
+
|
|
27
|
+
export const getIconProps = (props: IconProps): Props => {
|
|
28
|
+
if (typeof props === "string") {
|
|
29
|
+
return { icon: props };
|
|
30
|
+
}
|
|
31
|
+
if (isValidElement(props)) {
|
|
32
|
+
return { icon: props };
|
|
33
|
+
}
|
|
34
|
+
return props as unknown as Props;
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2026 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { isObject, isString } from "@react-fabric/utilities";
|
|
25
|
+
import { isValidElement } from "react";
|
|
26
|
+
import { TooltipType } from "../types";
|
|
27
|
+
|
|
28
|
+
export const getTooltipProps = (
|
|
29
|
+
tooltip?: string | TooltipType,
|
|
30
|
+
innerRef?: AnyObject,
|
|
31
|
+
): (TooltipType & { ref: AnyObject }) | undefined => {
|
|
32
|
+
if (isString(tooltip) || isValidElement(tooltip)) {
|
|
33
|
+
return { ref: innerRef, placement: "top", content: tooltip };
|
|
34
|
+
}
|
|
35
|
+
if (isObject(tooltip)) {
|
|
36
|
+
return Object.assign({ ref: innerRef, placement: "top" }, tooltip);
|
|
37
|
+
}
|
|
38
|
+
};
|
package/src/utils/index.ts
CHANGED