@react-fabric/core 1.0.0-beta.55 → 1.0.0-beta.58
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/_card.css +8 -4
- package/css/components/_icon.css +3 -3
- package/css/components/_tabPanel.css +40 -0
- package/css/core/_aside.css +4 -6
- package/css/reset/_reset.css +14 -0
- package/dist/cjs/components/avatar/Avatar.js +9 -4
- package/dist/cjs/components/badge/Badge.js +2 -10
- package/dist/cjs/components/button/Button.js +7 -12
- package/dist/cjs/components/card/Card.js +18 -12
- package/dist/cjs/components/chip/Chip.js +9 -14
- package/dist/cjs/components/dropdown/Dropdown.js +1 -0
- package/dist/cjs/components/icon/Icon.js +37 -8
- 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 +4 -13
- package/dist/cjs/components/tabpanel/TabPanel.js +2 -1
- 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/index.js +1 -0
- package/dist/cjs/overlays/alert/Alert.js +3 -1
- package/dist/cjs/overlays/flyout/Flyout.js +6 -11
- package/dist/cjs/overlays/message/Message.js +2 -0
- package/dist/cjs/overlays/modal/Modal.js +6 -13
- package/dist/cjs/overlays/toast/Toast.js +3 -1
- package/dist/cjs/types/icons.js +2 -1
- package/dist/esm/components/avatar/Avatar.js +9 -4
- package/dist/esm/components/badge/Badge.js +3 -11
- package/dist/esm/components/button/Button.js +9 -14
- package/dist/esm/components/card/Card.js +18 -12
- package/dist/esm/components/chip/Chip.js +10 -15
- package/dist/esm/components/dropdown/Dropdown.js +1 -0
- package/dist/esm/components/icon/Icon.js +39 -11
- 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 +5 -14
- package/dist/esm/components/tabpanel/TabPanel.js +2 -1
- 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/index.js +1 -1
- package/dist/esm/overlays/alert/Alert.js +3 -1
- package/dist/esm/overlays/flyout/Flyout.js +7 -12
- package/dist/esm/overlays/message/Message.js +2 -0
- package/dist/esm/overlays/modal/Modal.js +7 -14
- package/dist/esm/overlays/toast/Toast.js +3 -1
- package/dist/esm/types/icons.js +2 -1
- package/dist/types/components/avatar/Avatar.d.ts +5 -1
- package/dist/types/components/badge/Badge.d.ts +8 -3
- package/dist/types/components/button/Button.d.ts +12 -3
- package/dist/types/components/card/Card.d.ts +5 -3
- package/dist/types/components/chip/Chip.d.ts +12 -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/components/tabpanel/TabPanel.d.ts +5 -1
- package/dist/types/core/aside/Aside.d.ts +8 -5
- package/dist/types/core/page/Page.d.ts +8 -5
- package/dist/types/overlays/alert/Alert.d.ts +15 -3
- package/dist/types/overlays/flyout/Flyout.d.ts +9 -5
- package/dist/types/overlays/message/Message.d.ts +15 -3
- package/dist/types/overlays/modal/Modal.d.ts +6 -6
- 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 +10 -2
- package/src/components/badge/Badge.tsx +7 -13
- package/src/components/button/Button.tsx +24 -19
- package/src/components/card/Card.tsx +29 -15
- package/src/components/chip/Chip.tsx +15 -13
- package/src/components/dropdown/Dropdown.tsx +1 -0
- package/src/components/icon/Icon.tsx +48 -7
- 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 +8 -19
- package/src/components/tabpanel/TabPanel.tsx +6 -0
- 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/overlays/alert/Alert.tsx +24 -5
- package/src/overlays/flyout/Flyout.tsx +11 -22
- package/src/overlays/message/Message.tsx +18 -3
- package/src/overlays/modal/Modal.tsx +8 -24
- 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,
|
|
@@ -174,22 +171,14 @@ export const Tab = <Tag extends React.ElementType = "button">({
|
|
|
174
171
|
active && activeClassName,
|
|
175
172
|
disabled && "text-tint-500 pointer-events-none",
|
|
176
173
|
tabFlex ? "flex-1" : "flex-initial max-w-36",
|
|
177
|
-
minimal ? "min-w-6 rounded" : "
|
|
178
|
-
"flex items-center justify-center
|
|
174
|
+
minimal ? "min-w-6 rounded" : "rounded-capped",
|
|
175
|
+
"flex items-center justify-center overflow-hidden cursor-pointer",
|
|
179
176
|
)}
|
|
180
177
|
onClick={() => !active && onClick?.(id)}
|
|
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}
|
|
@@ -52,6 +52,10 @@ export interface TabPanelProps extends ChildrenProp<typeof Tab> {
|
|
|
52
52
|
* tab button flex to fill tabs
|
|
53
53
|
*/
|
|
54
54
|
tabFlex?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* rotate tab sideways for start/end orientation
|
|
57
|
+
*/
|
|
58
|
+
tabRotate?: boolean;
|
|
55
59
|
/**
|
|
56
60
|
* tab button gap
|
|
57
61
|
*/
|
|
@@ -132,6 +136,7 @@ export const TabPanel = ({
|
|
|
132
136
|
tabFlex,
|
|
133
137
|
append,
|
|
134
138
|
prepend,
|
|
139
|
+
tabRotate,
|
|
135
140
|
gap,
|
|
136
141
|
onBeforeChange,
|
|
137
142
|
onChange,
|
|
@@ -182,6 +187,7 @@ export const TabPanel = ({
|
|
|
182
187
|
className={classNames(
|
|
183
188
|
"fabric-tabHeader",
|
|
184
189
|
headerClassName,
|
|
190
|
+
tabRotate && "tab-rotate",
|
|
185
191
|
justify && `justify-${justify}`,
|
|
186
192
|
["start", "end"].includes(orientation) && "flex-col",
|
|
187
193
|
"flex flex-nowrap overflow-hidden items-center",
|
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
|
)}
|
|
@@ -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
|
*/
|
|
@@ -94,6 +84,10 @@ export interface FlyoutProps
|
|
|
94
84
|
* minimum width
|
|
95
85
|
*/
|
|
96
86
|
minWidth?: string | number;
|
|
87
|
+
/**
|
|
88
|
+
* portal root element
|
|
89
|
+
*/
|
|
90
|
+
root?: HTMLElement;
|
|
97
91
|
/**
|
|
98
92
|
* hide backdrop mask
|
|
99
93
|
*/
|
|
@@ -114,10 +108,7 @@ export interface FlyoutProps
|
|
|
114
108
|
|
|
115
109
|
export const Flyout = ({
|
|
116
110
|
icon,
|
|
117
|
-
iconBg,
|
|
118
|
-
iconColor,
|
|
119
111
|
iconClassName,
|
|
120
|
-
rtlFlip,
|
|
121
112
|
title,
|
|
122
113
|
actions,
|
|
123
114
|
closeOnClick,
|
|
@@ -129,6 +120,7 @@ export const Flyout = ({
|
|
|
129
120
|
size,
|
|
130
121
|
width,
|
|
131
122
|
minWidth,
|
|
123
|
+
root,
|
|
132
124
|
hideMask,
|
|
133
125
|
align = "start",
|
|
134
126
|
...aria
|
|
@@ -193,7 +185,7 @@ export const Flyout = ({
|
|
|
193
185
|
);
|
|
194
186
|
|
|
195
187
|
return (
|
|
196
|
-
<FloatingPortal>
|
|
188
|
+
<FloatingPortal root={root}>
|
|
197
189
|
{!hideMask && (
|
|
198
190
|
<FloatingOverlay
|
|
199
191
|
lockScroll
|
|
@@ -231,11 +223,8 @@ export const Flyout = ({
|
|
|
231
223
|
>
|
|
232
224
|
{isString(icon) && (
|
|
233
225
|
<Icon
|
|
234
|
-
icon={icon}
|
|
235
|
-
bg={iconBg}
|
|
236
|
-
color={iconColor}
|
|
237
226
|
className={classNames(iconClassName, "p-1")}
|
|
238
|
-
|
|
227
|
+
{...getIconProps(icon)}
|
|
239
228
|
/>
|
|
240
229
|
)}
|
|
241
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
|
*/
|
|
@@ -105,7 +95,7 @@ export interface ModalProps
|
|
|
105
95
|
/**
|
|
106
96
|
* hide mask background
|
|
107
97
|
*/
|
|
108
|
-
|
|
98
|
+
hideMask?: boolean;
|
|
109
99
|
/**
|
|
110
100
|
* close handler
|
|
111
101
|
*/
|
|
@@ -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,
|
|
@@ -131,7 +118,7 @@ export const Modal = ({
|
|
|
131
118
|
loading,
|
|
132
119
|
root,
|
|
133
120
|
size,
|
|
134
|
-
|
|
121
|
+
hideMask,
|
|
135
122
|
width,
|
|
136
123
|
height,
|
|
137
124
|
minHeight,
|
|
@@ -193,7 +180,7 @@ export const Modal = ({
|
|
|
193
180
|
}}
|
|
194
181
|
className={classNames(
|
|
195
182
|
"grid place-items-center p-16",
|
|
196
|
-
!
|
|
183
|
+
!hideMask && "bg-tint-100/20 backdrop-blur-sm",
|
|
197
184
|
)}
|
|
198
185
|
>
|
|
199
186
|
<FloatingFocusManager context={context}>
|
|
@@ -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;
|