@react-fabric/core 1.0.0-beta.57 → 1.0.0-beta.59
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/_icon.css +3 -3
- package/css/components/_stepper.css +86 -0
- package/css/components/index.css +1 -0
- package/dist/cjs/components/avatar/Avatar.js +1 -0
- package/dist/cjs/components/badge/Badge.js +2 -10
- package/dist/cjs/components/button/Button.js +4 -11
- package/dist/cjs/components/chip/Chip.js +5 -12
- package/dist/cjs/components/icon/Icon.js +28 -3
- package/dist/cjs/components/menu/MenuItem.js +5 -12
- package/dist/cjs/components/panel/Panel.js +4 -13
- package/dist/cjs/components/tabpanel/Tab.js +3 -12
- package/dist/cjs/core/aside/Aside.js +2 -11
- package/dist/cjs/core/headfoot/HeadFoot.js +4 -2
- package/dist/cjs/core/page/Page.js +4 -13
- package/dist/cjs/hooks/useStepper.js +75 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/overlays/alert/Alert.js +3 -1
- package/dist/cjs/overlays/flyout/Flyout.js +4 -11
- package/dist/cjs/overlays/message/Message.js +2 -0
- package/dist/cjs/overlays/modal/Modal.js +4 -11
- package/dist/cjs/overlays/toast/Toast.js +3 -1
- package/dist/cjs/types/icons.js +2 -1
- package/dist/esm/components/avatar/Avatar.js +1 -0
- package/dist/esm/components/badge/Badge.js +3 -11
- package/dist/esm/components/button/Button.js +6 -13
- package/dist/esm/components/chip/Chip.js +6 -13
- package/dist/esm/components/icon/Icon.js +30 -6
- package/dist/esm/components/menu/MenuItem.js +6 -13
- package/dist/esm/components/panel/Panel.js +5 -14
- package/dist/esm/components/tabpanel/Tab.js +4 -13
- package/dist/esm/core/aside/Aside.js +3 -12
- package/dist/esm/core/headfoot/HeadFoot.js +4 -2
- package/dist/esm/core/page/Page.js +5 -14
- package/dist/esm/hooks/useStepper.js +75 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/overlays/alert/Alert.js +3 -1
- package/dist/esm/overlays/flyout/Flyout.js +5 -12
- package/dist/esm/overlays/message/Message.js +2 -0
- package/dist/esm/overlays/modal/Modal.js +5 -12
- package/dist/esm/overlays/toast/Toast.js +3 -1
- package/dist/esm/types/icons.js +2 -1
- package/dist/types/components/badge/Badge.d.ts +8 -3
- package/dist/types/components/button/Button.d.ts +8 -3
- package/dist/types/components/chip/Chip.d.ts +8 -3
- package/dist/types/components/icon/Icon.d.ts +10 -4
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/components/menu/MenuItem.d.ts +1 -1
- package/dist/types/components/menu/types.d.ts +7 -2
- package/dist/types/components/panel/Panel.d.ts +8 -5
- package/dist/types/components/tabpanel/Tab.d.ts +8 -5
- package/dist/types/core/aside/Aside.d.ts +8 -5
- package/dist/types/core/page/Page.d.ts +8 -5
- package/dist/types/hooks/useStepper.d.ts +15 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/overlays/alert/Alert.d.ts +15 -3
- package/dist/types/overlays/flyout/Flyout.d.ts +5 -5
- package/dist/types/overlays/message/Message.d.ts +15 -3
- package/dist/types/overlays/modal/Modal.d.ts +5 -5
- package/dist/types/overlays/toast/Toast.d.ts +15 -3
- package/dist/types/types/icons.d.ts +2 -1
- package/dist/types/types/index.d.ts +0 -18
- package/package.json +14 -14
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/badge/Badge.tsx +7 -13
- package/src/components/button/Button.tsx +10 -18
- package/src/components/chip/Chip.tsx +7 -11
- package/src/components/icon/Icon.tsx +43 -6
- package/src/components/index.ts +1 -1
- package/src/components/menu/MenuItem.tsx +4 -9
- package/src/components/menu/types.ts +6 -6
- package/src/components/panel/Panel.tsx +7 -13
- package/src/components/tabpanel/Tab.tsx +6 -17
- package/src/core/aside/Aside.tsx +7 -13
- package/src/core/headfoot/HeadFoot.tsx +2 -2
- package/src/core/page/Page.tsx +8 -23
- package/src/hooks/useStepper.tsx +68 -0
- package/src/index.ts +1 -0
- package/src/overlays/alert/Alert.tsx +24 -5
- package/src/overlays/flyout/Flyout.tsx +5 -21
- package/src/overlays/message/Message.tsx +18 -3
- package/src/overlays/modal/Modal.tsx +5 -21
- package/src/overlays/toast/Toast.tsx +23 -4
- package/src/types/global.d.ts +8 -0
- package/src/types/icons.ts +3 -1
- package/src/types/index.ts +0 -19
|
@@ -26,25 +26,23 @@ import { useMemo } from "react";
|
|
|
26
26
|
import { type ContentProps } from "../../core/content/Content";
|
|
27
27
|
import { type HeadFootProps } from "../../core/headfoot/HeadFoot";
|
|
28
28
|
import { usePropToggle } from "../../hooks/usePropToggle";
|
|
29
|
+
import { HotKey } from "../../hotkeys/HotKey";
|
|
29
30
|
import {
|
|
30
31
|
type AriaProps,
|
|
31
32
|
type ChildrenProp,
|
|
32
33
|
type CollapseProps,
|
|
33
34
|
type CssProp,
|
|
34
35
|
type ExpandProps,
|
|
35
|
-
type IconProps,
|
|
36
36
|
type TestProps,
|
|
37
37
|
} from "../../types";
|
|
38
38
|
import { CoreIcons } from "../../types/icons";
|
|
39
39
|
import { Loading } from "../animations/Animations";
|
|
40
|
-
import { Icon } from "../icon/Icon";
|
|
41
|
-
import { HotKey } from "../../hotkeys/HotKey";
|
|
40
|
+
import { getIconProps, Icon, IconProps } from "../icon/Icon";
|
|
42
41
|
|
|
43
42
|
export interface PanelProps
|
|
44
43
|
extends CssProp,
|
|
45
44
|
AriaProps,
|
|
46
45
|
TestProps,
|
|
47
|
-
IconProps,
|
|
48
46
|
ExpandProps,
|
|
49
47
|
CollapseProps,
|
|
50
48
|
ChildrenProp<HeadFootProps | ContentProps> {
|
|
@@ -68,6 +66,10 @@ export interface PanelProps
|
|
|
68
66
|
* title css classname(s)
|
|
69
67
|
*/
|
|
70
68
|
titleClassName?: string;
|
|
69
|
+
/**
|
|
70
|
+
* icon path or props
|
|
71
|
+
*/
|
|
72
|
+
icon?: IconProps;
|
|
71
73
|
/**
|
|
72
74
|
* loading state
|
|
73
75
|
*/
|
|
@@ -118,8 +120,6 @@ export interface PanelProps
|
|
|
118
120
|
* <Panel
|
|
119
121
|
* title="Panel Title"
|
|
120
122
|
* icon={CoreIcons.info}
|
|
121
|
-
* iconBg="bg-blue-500"
|
|
122
|
-
* iconColor="text-white"
|
|
123
123
|
* actions={<button>Action</button>}
|
|
124
124
|
* expandable
|
|
125
125
|
* collapsable
|
|
@@ -147,9 +147,6 @@ export const Panel = ({
|
|
|
147
147
|
title,
|
|
148
148
|
actions,
|
|
149
149
|
icon,
|
|
150
|
-
iconBg,
|
|
151
|
-
iconColor,
|
|
152
|
-
rtlFlip,
|
|
153
150
|
panelId,
|
|
154
151
|
height,
|
|
155
152
|
width,
|
|
@@ -227,11 +224,8 @@ export const Panel = ({
|
|
|
227
224
|
)}
|
|
228
225
|
{icon && (
|
|
229
226
|
<Icon
|
|
230
|
-
icon={icon}
|
|
231
|
-
bg={iconBg}
|
|
232
|
-
color={iconColor}
|
|
233
|
-
rtlFlip={rtlFlip}
|
|
234
227
|
className="p-2 text-md select-none pointer-events-none"
|
|
228
|
+
{...getIconProps(icon)}
|
|
235
229
|
/>
|
|
236
230
|
)}
|
|
237
231
|
<div
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
type ChildrenProp,
|
|
33
33
|
type ColorState,
|
|
34
34
|
type CssProp,
|
|
35
|
-
type IconProps,
|
|
36
35
|
type PolymorphicProps,
|
|
37
36
|
type RefProp,
|
|
38
37
|
type TestProps,
|
|
@@ -40,7 +39,7 @@ import {
|
|
|
40
39
|
} from "../../types";
|
|
41
40
|
import { Badge, getBadgeProps } from "../badge/Badge";
|
|
42
41
|
import { DropdownTool } from "../dropdown/DropdownTool";
|
|
43
|
-
import { Icon } from "../icon/Icon";
|
|
42
|
+
import { getIconProps, Icon, IconProps } from "../icon/Icon";
|
|
44
43
|
|
|
45
44
|
export interface TabProps
|
|
46
45
|
extends Partial<ChildrenProp>,
|
|
@@ -48,7 +47,6 @@ export interface TabProps
|
|
|
48
47
|
RefProp,
|
|
49
48
|
AriaProps,
|
|
50
49
|
TestProps,
|
|
51
|
-
IconProps,
|
|
52
50
|
TooltipProp {
|
|
53
51
|
/**
|
|
54
52
|
* tab id
|
|
@@ -62,6 +60,10 @@ export interface TabProps
|
|
|
62
60
|
* tab color
|
|
63
61
|
*/
|
|
64
62
|
color?: ColorState;
|
|
63
|
+
/**
|
|
64
|
+
* icon path or props
|
|
65
|
+
*/
|
|
66
|
+
icon?: IconProps;
|
|
65
67
|
/**
|
|
66
68
|
* tab badge
|
|
67
69
|
*/
|
|
@@ -106,8 +108,6 @@ export interface TabProps
|
|
|
106
108
|
* id="tab1"
|
|
107
109
|
* label="Tab 1"
|
|
108
110
|
* icon="home"
|
|
109
|
-
* iconBg="bg-blue-500"
|
|
110
|
-
* iconColor="text-white"
|
|
111
111
|
* badge="New"
|
|
112
112
|
* onClick={(id) => console.log(`Tab clicked: ${id}`)}
|
|
113
113
|
* onClose={() => console.log("Tab closed")}
|
|
@@ -130,9 +130,6 @@ export const Tab = <Tag extends React.ElementType = "button">({
|
|
|
130
130
|
className,
|
|
131
131
|
label,
|
|
132
132
|
icon,
|
|
133
|
-
iconBg,
|
|
134
|
-
iconColor,
|
|
135
|
-
rtlFlip,
|
|
136
133
|
badge,
|
|
137
134
|
disabled,
|
|
138
135
|
onClose,
|
|
@@ -181,15 +178,7 @@ export const Tab = <Tag extends React.ElementType = "button">({
|
|
|
181
178
|
ref={ref as AnyObject}
|
|
182
179
|
{...aria}
|
|
183
180
|
>
|
|
184
|
-
{icon && (
|
|
185
|
-
<Icon
|
|
186
|
-
icon={icon}
|
|
187
|
-
bg={iconBg}
|
|
188
|
-
color={iconColor}
|
|
189
|
-
rtlFlip={rtlFlip}
|
|
190
|
-
className="flex-content p-2"
|
|
191
|
-
/>
|
|
192
|
-
)}
|
|
181
|
+
{icon && <Icon className="flex-content p-2" {...getIconProps(icon)} />}
|
|
193
182
|
{!minimal && (
|
|
194
183
|
<label className="flex-initial truncate text-center px-1 py-1">
|
|
195
184
|
{label}
|
package/src/core/aside/Aside.tsx
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
type ReactNode,
|
|
32
32
|
} from "react";
|
|
33
33
|
import { Loading } from "../../components/animations/Animations";
|
|
34
|
-
import { Icon } from "../../components/icon/Icon";
|
|
34
|
+
import { getIconProps, Icon, IconProps } from "../../components/icon/Icon";
|
|
35
35
|
import { useLayoutEffectDebugger } from "../../hooks/useEffectDebugger";
|
|
36
36
|
import { usePropToggle } from "../../hooks/usePropToggle";
|
|
37
37
|
import { useResize } from "../../hooks/useResize";
|
|
@@ -40,15 +40,13 @@ import {
|
|
|
40
40
|
type CollapseProps,
|
|
41
41
|
type CssProp,
|
|
42
42
|
type Elements,
|
|
43
|
-
type IconProps,
|
|
44
43
|
type TestProps,
|
|
45
44
|
} from "../../types";
|
|
46
45
|
import { CoreIcons } from "../../types/icons";
|
|
47
46
|
import { ErrorBoundary } from "../boundary/ErrorBoundary";
|
|
48
47
|
|
|
49
48
|
export interface AsideProps
|
|
50
|
-
extends
|
|
51
|
-
ChildrenProp,
|
|
49
|
+
extends ChildrenProp,
|
|
52
50
|
CollapseProps,
|
|
53
51
|
CssProp,
|
|
54
52
|
TestProps {
|
|
@@ -60,6 +58,10 @@ export interface AsideProps
|
|
|
60
58
|
* align inline-end
|
|
61
59
|
*/
|
|
62
60
|
align?: "start" | "end";
|
|
61
|
+
/**
|
|
62
|
+
* icon path or props
|
|
63
|
+
*/
|
|
64
|
+
icon?: IconProps;
|
|
63
65
|
/**
|
|
64
66
|
* header actions
|
|
65
67
|
*/
|
|
@@ -117,8 +119,6 @@ export interface AsideProps
|
|
|
117
119
|
* <Aside
|
|
118
120
|
* title="Sidebar Title"
|
|
119
121
|
* icon={CoreIcons.menu}
|
|
120
|
-
* iconBg="bg-gray-200"
|
|
121
|
-
* iconColor="text-gray-800"
|
|
122
122
|
* rtlFlip={true}
|
|
123
123
|
* className="custom-aside"
|
|
124
124
|
* bodyClassName="custom-aside-body"
|
|
@@ -148,9 +148,6 @@ export const Aside = ({
|
|
|
148
148
|
children,
|
|
149
149
|
title,
|
|
150
150
|
icon,
|
|
151
|
-
iconBg,
|
|
152
|
-
iconColor,
|
|
153
|
-
rtlFlip,
|
|
154
151
|
className,
|
|
155
152
|
bodyClassName,
|
|
156
153
|
headerClassName,
|
|
@@ -272,14 +269,11 @@ export const Aside = ({
|
|
|
272
269
|
)}
|
|
273
270
|
{icon && (
|
|
274
271
|
<Icon
|
|
275
|
-
icon={icon}
|
|
276
|
-
bg={iconBg}
|
|
277
|
-
color={iconColor}
|
|
278
|
-
rtlFlip={rtlFlip}
|
|
279
272
|
className={classNames(
|
|
280
273
|
"fabric-asideIcon",
|
|
281
274
|
"p-1 text-lg select-none pointer-events-none",
|
|
282
275
|
)}
|
|
276
|
+
{...getIconProps(icon)}
|
|
283
277
|
/>
|
|
284
278
|
)}
|
|
285
279
|
{actions && <div className={"fabric-asideActions"}>{actions}</div>}
|
|
@@ -92,7 +92,7 @@ const HeadFoot = ({
|
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
export const Header = (props: HeadFootProps) => (
|
|
95
|
-
<HeadFoot as="header" area="head" {...props} />
|
|
95
|
+
<HeadFoot as="header" area="head" data-ref="header" {...props} />
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
/**
|
|
@@ -117,5 +117,5 @@ export const Header = (props: HeadFootProps) => (
|
|
|
117
117
|
* ```
|
|
118
118
|
*/
|
|
119
119
|
export const Footer = (props: HeadFootProps) => (
|
|
120
|
-
<HeadFoot as="footer" area="foot" {...props} />
|
|
120
|
+
<HeadFoot as="footer" area="foot" data-ref="footer" {...props} />
|
|
121
121
|
);
|
package/src/core/page/Page.tsx
CHANGED
|
@@ -23,17 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
25
|
import { Loading } from "../../components/animations/Animations";
|
|
26
|
-
import { Icon } from "../../components/icon/Icon";
|
|
27
|
-
import {
|
|
28
|
-
type ChildrenProp,
|
|
29
|
-
type IconProps,
|
|
30
|
-
type RefProp,
|
|
31
|
-
type TestProps,
|
|
32
|
-
} from "../../types";
|
|
26
|
+
import { getIconProps, Icon, IconProps } from "../../components/icon/Icon";
|
|
27
|
+
import { type ChildrenProp, type RefProp, type TestProps } from "../../types";
|
|
33
28
|
|
|
34
29
|
export interface PageProps
|
|
35
|
-
extends
|
|
36
|
-
ChildrenProp,
|
|
30
|
+
extends ChildrenProp,
|
|
37
31
|
TestProps,
|
|
38
32
|
RefProp<HTMLDivElement> {
|
|
39
33
|
/**
|
|
@@ -48,6 +42,10 @@ export interface PageProps
|
|
|
48
42
|
* paper style drop shadow
|
|
49
43
|
*/
|
|
50
44
|
paper?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* icon path or props
|
|
47
|
+
*/
|
|
48
|
+
icon?: IconProps;
|
|
51
49
|
/**
|
|
52
50
|
* loading indicator
|
|
53
51
|
*/
|
|
@@ -68,8 +66,6 @@ export interface PageProps
|
|
|
68
66
|
* <Page
|
|
69
67
|
* title="My Page"
|
|
70
68
|
* icon="home"
|
|
71
|
-
* iconBg="bg-blue-500"
|
|
72
|
-
* iconColor="text-white"
|
|
73
69
|
* loading={false}
|
|
74
70
|
* paper={true}
|
|
75
71
|
* data-testid="my-page"
|
|
@@ -89,9 +85,6 @@ export const Page = ({
|
|
|
89
85
|
title,
|
|
90
86
|
titleClassName,
|
|
91
87
|
icon,
|
|
92
|
-
rtlFlip,
|
|
93
|
-
iconBg,
|
|
94
|
-
iconColor,
|
|
95
88
|
loading,
|
|
96
89
|
"data-testid": testId,
|
|
97
90
|
"data-test-value": testValue,
|
|
@@ -119,15 +112,7 @@ export const Page = ({
|
|
|
119
112
|
titleClassName,
|
|
120
113
|
)}
|
|
121
114
|
>
|
|
122
|
-
{icon && (
|
|
123
|
-
<Icon
|
|
124
|
-
icon={icon}
|
|
125
|
-
size="1.25em"
|
|
126
|
-
rtlFlip={rtlFlip}
|
|
127
|
-
bg={iconBg}
|
|
128
|
-
color={iconColor}
|
|
129
|
-
/>
|
|
130
|
-
)}
|
|
115
|
+
{icon && <Icon size="1.25em" {...getIconProps(icon)} />}
|
|
131
116
|
{title}
|
|
132
117
|
</div>
|
|
133
118
|
)}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2025 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 { ReactNode, useMemo, useState } from "react";
|
|
25
|
+
import { Icon } from "../components";
|
|
26
|
+
|
|
27
|
+
export const useStepper = ({
|
|
28
|
+
steps,
|
|
29
|
+
activeStep: _initialActiveStep = 0,
|
|
30
|
+
}: {
|
|
31
|
+
steps: Array<{ label?: ReactNode; icon?: ReactNode }>;
|
|
32
|
+
activeStep?: number;
|
|
33
|
+
}) => {
|
|
34
|
+
const [activeStep, setActiveStep] = useState(_initialActiveStep);
|
|
35
|
+
const maxSteps = useMemo(() => steps.length - 1, [steps]);
|
|
36
|
+
|
|
37
|
+
const stepper = useMemo(() => {
|
|
38
|
+
return (
|
|
39
|
+
<div className="fabric-stepper bg-base flex-1 flex justify-center py-1 px-2 overflow-x-auto">
|
|
40
|
+
{steps.map((child: any, index) => (
|
|
41
|
+
<div
|
|
42
|
+
className="fabric-stepper--pill"
|
|
43
|
+
key={index}
|
|
44
|
+
data-state={
|
|
45
|
+
index === activeStep
|
|
46
|
+
? "active"
|
|
47
|
+
: index < activeStep
|
|
48
|
+
? "completed"
|
|
49
|
+
: undefined
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
{child.icon && <Icon icon={child.icon} />}
|
|
53
|
+
{child.label && <label>{child.label}</label>}
|
|
54
|
+
</div>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}, [steps]);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
stepper,
|
|
62
|
+
activeStep,
|
|
63
|
+
firstStep: activeStep === 0,
|
|
64
|
+
lastStep: activeStep === maxSteps,
|
|
65
|
+
next: () => setActiveStep((s) => Math.min(s + 1, maxSteps)),
|
|
66
|
+
prev: () => setActiveStep((s) => Math.max(s - 1, 0)),
|
|
67
|
+
};
|
|
68
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ export * from "./hooks/useNavigator";
|
|
|
36
36
|
export * from "./hooks/useOverlayService";
|
|
37
37
|
export * from "./hooks/useResize";
|
|
38
38
|
export * from "./hooks/useResizeObserver";
|
|
39
|
+
export * from "./hooks/useStepper";
|
|
39
40
|
export * from "./hooks/useStorage";
|
|
40
41
|
|
|
41
42
|
export { HotKey } from "./hotkeys/HotKey";
|
|
@@ -35,17 +35,29 @@ import { useCallback, useLayoutEffect, useMemo, useState } from "react";
|
|
|
35
35
|
import { useTranslation } from "react-i18next";
|
|
36
36
|
import { AnimationIndicator } from "../../components/animations/Animations";
|
|
37
37
|
import { Button } from "../../components/button/Button";
|
|
38
|
-
import { Icon } from "../../components/icon/Icon";
|
|
39
|
-
import { type ColorState, type Elements
|
|
38
|
+
import { Icon, IconProps } from "../../components/icon/Icon";
|
|
39
|
+
import { type ColorState, type Elements } from "../../types";
|
|
40
40
|
import { CoreIcons } from "../../types/icons";
|
|
41
41
|
import { Title } from "../../typography/Title";
|
|
42
42
|
import { getColor } from "../../utils";
|
|
43
43
|
|
|
44
|
-
export interface AlertProps
|
|
44
|
+
export interface AlertProps {
|
|
45
45
|
/**
|
|
46
46
|
* toast type
|
|
47
47
|
*/
|
|
48
48
|
type?: "alert" | "confirm" | "prompt";
|
|
49
|
+
/**
|
|
50
|
+
* svg path / webfont className / 1-4 letter text
|
|
51
|
+
*/
|
|
52
|
+
icon: string;
|
|
53
|
+
/**
|
|
54
|
+
* icon image source URL, if failed to load then shows icon
|
|
55
|
+
*/
|
|
56
|
+
iconSrc?: string;
|
|
57
|
+
/**
|
|
58
|
+
* flip icon in rtl
|
|
59
|
+
*/
|
|
60
|
+
rtlFlip?: boolean;
|
|
49
61
|
/**
|
|
50
62
|
* toast title
|
|
51
63
|
*/
|
|
@@ -85,6 +97,7 @@ export const Alert = ({
|
|
|
85
97
|
message,
|
|
86
98
|
color = "primary",
|
|
87
99
|
icon,
|
|
100
|
+
iconSrc,
|
|
88
101
|
rtlFlip,
|
|
89
102
|
actions,
|
|
90
103
|
// @ts-expect-error internal prop
|
|
@@ -115,7 +128,13 @@ export const Alert = ({
|
|
|
115
128
|
const iconType = useMemo(() => {
|
|
116
129
|
if (icon)
|
|
117
130
|
return (
|
|
118
|
-
<Icon
|
|
131
|
+
<Icon
|
|
132
|
+
icon={icon}
|
|
133
|
+
iconSrc={iconSrc}
|
|
134
|
+
size="md"
|
|
135
|
+
rtlFlip={rtlFlip}
|
|
136
|
+
color={`${color}-600`}
|
|
137
|
+
/>
|
|
119
138
|
);
|
|
120
139
|
switch (color) {
|
|
121
140
|
case "danger":
|
|
@@ -132,7 +151,7 @@ export const Alert = ({
|
|
|
132
151
|
/>
|
|
133
152
|
);
|
|
134
153
|
}
|
|
135
|
-
}, [color, type, icon]);
|
|
154
|
+
}, [color, type, icon, iconSrc, rtlFlip]);
|
|
136
155
|
|
|
137
156
|
const handleClose = useCallback(
|
|
138
157
|
(ret: AnyObject) => {
|
|
@@ -32,14 +32,9 @@ import {
|
|
|
32
32
|
} from "@floating-ui/react";
|
|
33
33
|
import { isString } from "@react-fabric/utilities";
|
|
34
34
|
import classNames from "classnames";
|
|
35
|
-
import {
|
|
36
|
-
isValidElement,
|
|
37
|
-
useCallback,
|
|
38
|
-
useEffect,
|
|
39
|
-
type ElementType,
|
|
40
|
-
} from "react";
|
|
35
|
+
import { isValidElement, useCallback, useEffect } from "react";
|
|
41
36
|
import { Loading } from "../../components/animations/Animations";
|
|
42
|
-
import { Icon } from "../../components/icon/Icon";
|
|
37
|
+
import { getIconProps, Icon, IconProps } from "../../components/icon/Icon";
|
|
43
38
|
import { Header } from "../../core/headfoot/HeadFoot";
|
|
44
39
|
import { HotKeyWrapper } from "../../hotkeys/HotKeyWrapper";
|
|
45
40
|
import {
|
|
@@ -47,17 +42,12 @@ import {
|
|
|
47
42
|
type CallbackReturn,
|
|
48
43
|
type ChildrenProp,
|
|
49
44
|
type Elements,
|
|
50
|
-
type IconProps,
|
|
51
45
|
type TestProps,
|
|
52
46
|
} from "../../types";
|
|
53
47
|
import { CoreIcons } from "../../types/icons";
|
|
54
48
|
|
|
55
|
-
export interface FlyoutProps
|
|
56
|
-
|
|
57
|
-
TestProps,
|
|
58
|
-
Omit<IconProps, "icon">,
|
|
59
|
-
ChildrenProp {
|
|
60
|
-
icon?: string | ElementType<IconProps>;
|
|
49
|
+
export interface FlyoutProps extends AriaProps, TestProps, ChildrenProp {
|
|
50
|
+
icon?: IconProps;
|
|
61
51
|
/**
|
|
62
52
|
* flyout alignment
|
|
63
53
|
*/
|
|
@@ -118,10 +108,7 @@ export interface FlyoutProps
|
|
|
118
108
|
|
|
119
109
|
export const Flyout = ({
|
|
120
110
|
icon,
|
|
121
|
-
iconBg,
|
|
122
|
-
iconColor,
|
|
123
111
|
iconClassName,
|
|
124
|
-
rtlFlip,
|
|
125
112
|
title,
|
|
126
113
|
actions,
|
|
127
114
|
closeOnClick,
|
|
@@ -236,11 +223,8 @@ export const Flyout = ({
|
|
|
236
223
|
>
|
|
237
224
|
{isString(icon) && (
|
|
238
225
|
<Icon
|
|
239
|
-
icon={icon}
|
|
240
|
-
bg={iconBg}
|
|
241
|
-
color={iconColor}
|
|
242
226
|
className={classNames(iconClassName, "p-1")}
|
|
243
|
-
|
|
227
|
+
{...getIconProps(icon)}
|
|
244
228
|
/>
|
|
245
229
|
)}
|
|
246
230
|
{isValidElement(icon) && icon}
|
|
@@ -24,10 +24,22 @@
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
25
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
26
26
|
import { Icon } from "../../components/icon/Icon";
|
|
27
|
-
import { type ColorState, type Elements
|
|
27
|
+
import { type ColorState, type Elements } from "../../types";
|
|
28
28
|
import { getColor } from "../../utils";
|
|
29
29
|
|
|
30
|
-
export interface MessageProps
|
|
30
|
+
export interface MessageProps {
|
|
31
|
+
/**
|
|
32
|
+
* svg path / webfont className / 1-4 letter text
|
|
33
|
+
*/
|
|
34
|
+
icon: string;
|
|
35
|
+
/**
|
|
36
|
+
* icon image source URL, if failed to load then shows icon
|
|
37
|
+
*/
|
|
38
|
+
iconSrc?: string;
|
|
39
|
+
/**
|
|
40
|
+
* flip icon in rtl
|
|
41
|
+
*/
|
|
42
|
+
rtlFlip?: boolean;
|
|
31
43
|
/**
|
|
32
44
|
* message title
|
|
33
45
|
*/
|
|
@@ -51,6 +63,7 @@ export const Message = ({
|
|
|
51
63
|
message,
|
|
52
64
|
color,
|
|
53
65
|
icon,
|
|
66
|
+
iconSrc,
|
|
54
67
|
rtlFlip,
|
|
55
68
|
actions,
|
|
56
69
|
// @ts-expect-error internal prop
|
|
@@ -87,7 +100,9 @@ export const Message = ({
|
|
|
87
100
|
}}
|
|
88
101
|
ref={elRef}
|
|
89
102
|
>
|
|
90
|
-
{icon &&
|
|
103
|
+
{icon && (
|
|
104
|
+
<Icon icon={icon} iconSrc={iconSrc} size="md" rtlFlip={rtlFlip} />
|
|
105
|
+
)}
|
|
91
106
|
{title && <div className="font-medium">{title}</div>}
|
|
92
107
|
<div className="truncate flex-initial">{message}</div>
|
|
93
108
|
{actions && (
|
|
@@ -32,14 +32,9 @@ import {
|
|
|
32
32
|
} from "@floating-ui/react";
|
|
33
33
|
import { isString } from "@react-fabric/utilities";
|
|
34
34
|
import classNames from "classnames";
|
|
35
|
-
import {
|
|
36
|
-
type ElementType,
|
|
37
|
-
isValidElement,
|
|
38
|
-
useCallback,
|
|
39
|
-
useEffect,
|
|
40
|
-
} from "react";
|
|
35
|
+
import { isValidElement, useCallback, useEffect } from "react";
|
|
41
36
|
import { Loading } from "../../components/animations/Animations";
|
|
42
|
-
import { Icon } from "../../components/icon/Icon";
|
|
37
|
+
import { getIconProps, Icon, IconProps } from "../../components/icon/Icon";
|
|
43
38
|
import { Header } from "../../core/headfoot/HeadFoot";
|
|
44
39
|
import { HotKeyWrapper } from "../../hotkeys/HotKeyWrapper";
|
|
45
40
|
import {
|
|
@@ -47,17 +42,12 @@ import {
|
|
|
47
42
|
type CallbackReturn,
|
|
48
43
|
type ChildrenProp,
|
|
49
44
|
type Elements,
|
|
50
|
-
type IconProps,
|
|
51
45
|
type TestProps,
|
|
52
46
|
} from "../../types";
|
|
53
47
|
import { CoreIcons } from "../../types/icons";
|
|
54
48
|
|
|
55
|
-
export interface ModalProps
|
|
56
|
-
|
|
57
|
-
TestProps,
|
|
58
|
-
Omit<IconProps, "icon">,
|
|
59
|
-
ChildrenProp {
|
|
60
|
-
icon?: string | ElementType<IconProps>;
|
|
49
|
+
export interface ModalProps extends AriaProps, TestProps, ChildrenProp {
|
|
50
|
+
icon?: IconProps;
|
|
61
51
|
/**
|
|
62
52
|
* header className
|
|
63
53
|
*/
|
|
@@ -118,10 +108,7 @@ export interface ModalProps
|
|
|
118
108
|
|
|
119
109
|
export const Modal = ({
|
|
120
110
|
icon,
|
|
121
|
-
iconBg,
|
|
122
|
-
iconColor,
|
|
123
111
|
iconClassName,
|
|
124
|
-
rtlFlip,
|
|
125
112
|
title,
|
|
126
113
|
actions,
|
|
127
114
|
headerClassName,
|
|
@@ -226,11 +213,8 @@ export const Modal = ({
|
|
|
226
213
|
>
|
|
227
214
|
{isString(icon) && (
|
|
228
215
|
<Icon
|
|
229
|
-
icon={icon}
|
|
230
|
-
bg={iconBg}
|
|
231
|
-
color={iconColor}
|
|
232
216
|
className={classNames(iconClassName, "p-1")}
|
|
233
|
-
|
|
217
|
+
{...getIconProps(icon)}
|
|
234
218
|
/>
|
|
235
219
|
)}
|
|
236
220
|
{isValidElement(icon) && icon}
|
|
@@ -27,15 +27,27 @@ import { useTranslation } from "react-i18next";
|
|
|
27
27
|
import { AnimationIndicator } from "../../components/animations/Animations";
|
|
28
28
|
import { Button } from "../../components/button/Button";
|
|
29
29
|
import { Icon } from "../../components/icon/Icon";
|
|
30
|
-
import { type ColorState, type Elements
|
|
30
|
+
import { type ColorState, type Elements } from "../../types";
|
|
31
31
|
import { CoreIcons } from "../../types/icons";
|
|
32
32
|
import { getColor } from "../../utils";
|
|
33
33
|
|
|
34
|
-
export interface ToastProps
|
|
34
|
+
export interface ToastProps {
|
|
35
35
|
/**
|
|
36
36
|
* toast type
|
|
37
37
|
*/
|
|
38
38
|
type?: "alert" | "confirm";
|
|
39
|
+
/**
|
|
40
|
+
* svg path / webfont className / 1-4 letter text
|
|
41
|
+
*/
|
|
42
|
+
icon: string;
|
|
43
|
+
/**
|
|
44
|
+
* icon image source URL, if failed to load then shows icon
|
|
45
|
+
*/
|
|
46
|
+
iconSrc?: string;
|
|
47
|
+
/**
|
|
48
|
+
* flip icon in rtl
|
|
49
|
+
*/
|
|
50
|
+
rtlFlip?: boolean;
|
|
39
51
|
/**
|
|
40
52
|
* toast title
|
|
41
53
|
*/
|
|
@@ -67,6 +79,7 @@ export const Toast = ({
|
|
|
67
79
|
message,
|
|
68
80
|
color = "primary",
|
|
69
81
|
icon,
|
|
82
|
+
iconSrc,
|
|
70
83
|
rtlFlip,
|
|
71
84
|
actions,
|
|
72
85
|
// @ts-expect-error internal prop
|
|
@@ -82,7 +95,13 @@ export const Toast = ({
|
|
|
82
95
|
const iconType = useMemo(() => {
|
|
83
96
|
if (icon)
|
|
84
97
|
return (
|
|
85
|
-
<Icon
|
|
98
|
+
<Icon
|
|
99
|
+
icon={icon}
|
|
100
|
+
iconSrc={iconSrc}
|
|
101
|
+
size="md"
|
|
102
|
+
rtlFlip={rtlFlip}
|
|
103
|
+
color={color + "-600"}
|
|
104
|
+
/>
|
|
86
105
|
);
|
|
87
106
|
switch (color) {
|
|
88
107
|
case "danger":
|
|
@@ -99,7 +118,7 @@ export const Toast = ({
|
|
|
99
118
|
/>
|
|
100
119
|
);
|
|
101
120
|
}
|
|
102
|
-
}, [color, type, icon]);
|
|
121
|
+
}, [color, type, icon, iconSrc, rtlFlip]);
|
|
103
122
|
|
|
104
123
|
const elRef = useRef<HTMLDivElement>(null);
|
|
105
124
|
const handleClose = useCallback(
|
package/src/types/global.d.ts
CHANGED
|
@@ -45,6 +45,14 @@ declare module "*.png" {
|
|
|
45
45
|
const content: any;
|
|
46
46
|
export default content;
|
|
47
47
|
}
|
|
48
|
+
declare module "*.jpg" {
|
|
49
|
+
const content: any;
|
|
50
|
+
export default content;
|
|
51
|
+
}
|
|
52
|
+
declare module "*.jpeg" {
|
|
53
|
+
const content: any;
|
|
54
|
+
export default content;
|
|
55
|
+
}
|
|
48
56
|
declare module "*.svg" {
|
|
49
57
|
const content: any;
|
|
50
58
|
export default content;
|