@react-fabric/core 1.0.0-beta.57 → 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/_icon.css +3 -3
- 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/index.js +1 -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/index.js +1 -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/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/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
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { isNil, isString, mergeRefs } from "@react-fabric/utilities";
|
|
24
|
+
import { isNil, isObject, isString, mergeRefs } from "@react-fabric/utilities";
|
|
25
25
|
import classNames from "classnames";
|
|
26
26
|
import {
|
|
27
27
|
Fragment,
|
|
@@ -39,12 +39,11 @@ import { HotKey } from "../../hotkeys/HotKey";
|
|
|
39
39
|
import { HotKeyLabel } from "../../hotkeys/HotKeyLabel";
|
|
40
40
|
import { Tooltip } from "../../overlays/tooltip/Tooltip";
|
|
41
41
|
import {
|
|
42
|
-
type ColorState,
|
|
43
42
|
type AriaProps,
|
|
44
43
|
type BadgeType,
|
|
45
44
|
type CallbackReturn,
|
|
45
|
+
type ColorState,
|
|
46
46
|
type CssProp,
|
|
47
|
-
type IconProps,
|
|
48
47
|
type PolymorphicProps,
|
|
49
48
|
type RefProp,
|
|
50
49
|
type SizeType,
|
|
@@ -54,14 +53,9 @@ import {
|
|
|
54
53
|
import { getColor } from "../../utils";
|
|
55
54
|
import { AnimationIndicator } from "../animations/Animations";
|
|
56
55
|
import { Badge, getBadgeProps } from "../badge/Badge";
|
|
57
|
-
import { Icon } from "../icon/Icon";
|
|
56
|
+
import { getIconProps, Icon, IconProps } from "../icon/Icon";
|
|
58
57
|
|
|
59
|
-
export interface BaseProps
|
|
60
|
-
extends CssProp,
|
|
61
|
-
AriaProps,
|
|
62
|
-
IconProps,
|
|
63
|
-
RefProp,
|
|
64
|
-
TestProps {
|
|
58
|
+
export interface BaseProps extends CssProp, AriaProps, RefProp, TestProps {
|
|
65
59
|
/**
|
|
66
60
|
* primary icon alignment
|
|
67
61
|
*/
|
|
@@ -78,6 +72,10 @@ export interface BaseProps
|
|
|
78
72
|
* button color
|
|
79
73
|
*/
|
|
80
74
|
color?: ColorState;
|
|
75
|
+
/**
|
|
76
|
+
* icon path or props
|
|
77
|
+
*/
|
|
78
|
+
icon?: IconProps;
|
|
81
79
|
/**
|
|
82
80
|
* button type
|
|
83
81
|
*/
|
|
@@ -191,11 +189,8 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
191
189
|
active,
|
|
192
190
|
color = "primary",
|
|
193
191
|
icon,
|
|
194
|
-
iconBg,
|
|
195
|
-
iconColor,
|
|
196
192
|
iconAlign = "start",
|
|
197
193
|
altIcon,
|
|
198
|
-
rtlFlip,
|
|
199
194
|
rounded,
|
|
200
195
|
size,
|
|
201
196
|
disabled,
|
|
@@ -323,11 +318,8 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
323
318
|
{icon && (
|
|
324
319
|
<Icon
|
|
325
320
|
className={"fabric-buttonIcon"}
|
|
326
|
-
icon={icon}
|
|
327
|
-
bg={iconBg}
|
|
328
|
-
color={iconColor}
|
|
329
|
-
rtlFlip={rtlFlip}
|
|
330
321
|
data-align={iconAlign}
|
|
322
|
+
{...getIconProps(icon)}
|
|
331
323
|
/>
|
|
332
324
|
)}
|
|
333
325
|
{isValidElement(children) && (
|
|
@@ -336,7 +328,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
336
328
|
{isString(children) && (
|
|
337
329
|
<label
|
|
338
330
|
className={classNames("fabric-buttonLabel", "truncate")}
|
|
339
|
-
data-colored-icon={
|
|
331
|
+
data-colored-icon={isObject(icon) && "bg" in icon}
|
|
340
332
|
>
|
|
341
333
|
{children}
|
|
342
334
|
</label>
|
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
type ChildProp,
|
|
30
30
|
type ColorType,
|
|
31
31
|
type CssProp,
|
|
32
|
-
type IconProps,
|
|
33
32
|
type PaletteType,
|
|
34
33
|
type PolymorphicProps,
|
|
35
34
|
type RefProp,
|
|
@@ -37,12 +36,11 @@ import {
|
|
|
37
36
|
type TestProps,
|
|
38
37
|
} from "../../types";
|
|
39
38
|
import { getColor } from "../../utils";
|
|
40
|
-
import { Icon } from "../icon/Icon";
|
|
39
|
+
import { getIconProps, Icon, IconProps } from "../icon/Icon";
|
|
41
40
|
|
|
42
41
|
export interface ChipProps
|
|
43
42
|
extends CssProp,
|
|
44
43
|
AriaProps,
|
|
45
|
-
IconProps,
|
|
46
44
|
TestProps,
|
|
47
45
|
ChildProp<string | ReactElement>,
|
|
48
46
|
RefProp<HTMLDivElement> {
|
|
@@ -62,6 +60,10 @@ export interface ChipProps
|
|
|
62
60
|
* full rounded edges
|
|
63
61
|
*/
|
|
64
62
|
rounded?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* icon path or props
|
|
65
|
+
*/
|
|
66
|
+
icon?: IconProps;
|
|
65
67
|
/**
|
|
66
68
|
* disabled state
|
|
67
69
|
*/
|
|
@@ -124,9 +126,6 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
124
126
|
color,
|
|
125
127
|
variant,
|
|
126
128
|
icon,
|
|
127
|
-
iconBg,
|
|
128
|
-
iconColor,
|
|
129
|
-
rtlFlip,
|
|
130
129
|
disabled,
|
|
131
130
|
onClick,
|
|
132
131
|
onIconClick,
|
|
@@ -197,17 +196,14 @@ export const Chip = <Tag extends React.ElementType = "div">({
|
|
|
197
196
|
<Icon
|
|
198
197
|
data-ref="chipIcon"
|
|
199
198
|
className={classNames("fabric-chipIcon", "m-1 flex-content")}
|
|
200
|
-
icon={icon}
|
|
201
|
-
bg={iconBg}
|
|
202
199
|
onClick={onIconClick}
|
|
203
|
-
|
|
204
|
-
rtlFlip={rtlFlip}
|
|
200
|
+
{...getIconProps(icon)}
|
|
205
201
|
/>
|
|
206
202
|
)}
|
|
207
203
|
{children && (
|
|
208
204
|
<label
|
|
209
205
|
data-ref="chipLabel"
|
|
210
|
-
className={classNames("fabric-chipLabel", "truncate")}
|
|
206
|
+
className={classNames("fabric-chipLabel", "truncate flex-1")}
|
|
211
207
|
>
|
|
212
208
|
{children}
|
|
213
209
|
</label>
|
|
@@ -23,23 +23,27 @@
|
|
|
23
23
|
|
|
24
24
|
import { isString, isSvgPath } from "@react-fabric/utilities";
|
|
25
25
|
import classNames from "classnames";
|
|
26
|
-
import { useMemo } from "react";
|
|
26
|
+
import { isValidElement, useEffect, useMemo, useState } from "react";
|
|
27
27
|
import {
|
|
28
|
-
type PaletteType,
|
|
29
28
|
type AriaProps,
|
|
30
29
|
type ColorType,
|
|
31
30
|
type CssProp,
|
|
31
|
+
type PaletteType,
|
|
32
32
|
type RefProp,
|
|
33
33
|
type SizeType,
|
|
34
34
|
type TestProps,
|
|
35
35
|
} from "../../types";
|
|
36
36
|
import { getColor } from "../../utils";
|
|
37
37
|
|
|
38
|
-
export interface
|
|
38
|
+
export interface Props extends CssProp, AriaProps, RefProp, TestProps {
|
|
39
39
|
/**
|
|
40
40
|
* svg path / webfont className / 1-4 letter text
|
|
41
41
|
*/
|
|
42
|
-
icon: string;
|
|
42
|
+
icon: string | JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* icon image source URL, if failed to load then shows icon
|
|
45
|
+
*/
|
|
46
|
+
iconSrc?: string;
|
|
43
47
|
/**
|
|
44
48
|
* background color (CSS color / tailwind color)
|
|
45
49
|
*/
|
|
@@ -75,6 +79,28 @@ export interface IconProps extends CssProp, AriaProps, RefProp, TestProps {
|
|
|
75
79
|
onClick?: React.MouseEventHandler;
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
export type IconProps =
|
|
83
|
+
| string
|
|
84
|
+
| Pick<
|
|
85
|
+
Props,
|
|
86
|
+
| "icon"
|
|
87
|
+
| "iconSrc"
|
|
88
|
+
| "bg"
|
|
89
|
+
| "color"
|
|
90
|
+
| "size"
|
|
91
|
+
| "rtlFlip"
|
|
92
|
+
| "viewBox"
|
|
93
|
+
| "rounded"
|
|
94
|
+
| "animate"
|
|
95
|
+
>;
|
|
96
|
+
|
|
97
|
+
export const getIconProps = (props: IconProps): Props => {
|
|
98
|
+
if (typeof props === "string") {
|
|
99
|
+
return { icon: props };
|
|
100
|
+
}
|
|
101
|
+
return props;
|
|
102
|
+
};
|
|
103
|
+
|
|
78
104
|
const SvgTextSize = ["", ".875em", ".525em", ".35em", ".25em"];
|
|
79
105
|
const SizeMap: KeyValue<string> = {
|
|
80
106
|
xs: "0.625rem",
|
|
@@ -116,6 +142,7 @@ const SizeMap: KeyValue<string> = {
|
|
|
116
142
|
export const Icon = ({
|
|
117
143
|
ref,
|
|
118
144
|
icon,
|
|
145
|
+
iconSrc,
|
|
119
146
|
bg,
|
|
120
147
|
color,
|
|
121
148
|
size = "",
|
|
@@ -127,7 +154,13 @@ export const Icon = ({
|
|
|
127
154
|
className,
|
|
128
155
|
onClick,
|
|
129
156
|
...rest
|
|
130
|
-
}:
|
|
157
|
+
}: Props) => {
|
|
158
|
+
const [imageFailed, setImageFailed] = useState(false);
|
|
159
|
+
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
setImageFailed(false);
|
|
162
|
+
}, [iconSrc]);
|
|
163
|
+
|
|
131
164
|
/** ***************** style map *******************/
|
|
132
165
|
const styles = useMemo(() => {
|
|
133
166
|
const s: KeyValue = {};
|
|
@@ -153,6 +186,7 @@ export const Icon = ({
|
|
|
153
186
|
|
|
154
187
|
/** ***************** render icon *******************/
|
|
155
188
|
const iconEl = useMemo(() => {
|
|
189
|
+
if (isValidElement(icon)) return icon;
|
|
156
190
|
if (!isString(icon)) {
|
|
157
191
|
throw Error("Invalid icon expected string");
|
|
158
192
|
}
|
|
@@ -203,7 +237,10 @@ export const Icon = ({
|
|
|
203
237
|
data-clickable={!!onClick}
|
|
204
238
|
data-inner-clickable={!!onClick}
|
|
205
239
|
>
|
|
206
|
-
{
|
|
240
|
+
{iconSrc && !imageFailed && (
|
|
241
|
+
<img src={iconSrc} onError={() => setImageFailed(true)} />
|
|
242
|
+
)}
|
|
243
|
+
{(!iconSrc || imageFailed) && iconEl}
|
|
207
244
|
</dfn>
|
|
208
245
|
);
|
|
209
246
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -47,7 +47,7 @@ export { Divider } from "./divider/Divider";
|
|
|
47
47
|
export { Dropdown, DropdownDismiss } from "./dropdown/Dropdown";
|
|
48
48
|
export { DropdownTool } from "./dropdown/DropdownTool";
|
|
49
49
|
export { EmptyContent } from "./empty/EmptyContent";
|
|
50
|
-
export { Icon } from "./icon/Icon";
|
|
50
|
+
export { Icon, getIconProps } from "./icon/Icon";
|
|
51
51
|
export { Image, Video } from "./media/Media";
|
|
52
52
|
export { ContextMenu } from "./menu/ContextMenu";
|
|
53
53
|
export { Menu } from "./menu/Menu";
|
|
@@ -30,8 +30,9 @@ import { HotKeyLabel } from "../../hotkeys/HotKeyLabel";
|
|
|
30
30
|
import { Tooltip } from "../../overlays";
|
|
31
31
|
import { type PolymorphicProps } from "../../types";
|
|
32
32
|
import { Badge, getBadgeProps } from "../badge/Badge";
|
|
33
|
-
import { Icon } from "../icon/Icon";
|
|
33
|
+
import { getIconProps, Icon } from "../icon/Icon";
|
|
34
34
|
import { type MenuItemProps } from "./types";
|
|
35
|
+
import { get } from "http";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* A menu item component that can be used in a dropdown or menu.
|
|
@@ -60,10 +61,7 @@ export const MenuItem = <Tag extends React.ElementType = "button">({
|
|
|
60
61
|
color = "primary",
|
|
61
62
|
className,
|
|
62
63
|
icon,
|
|
63
|
-
iconBg,
|
|
64
|
-
iconColor,
|
|
65
64
|
appendLabel,
|
|
66
|
-
rtlFlip,
|
|
67
65
|
altIcon,
|
|
68
66
|
id,
|
|
69
67
|
active,
|
|
@@ -98,13 +96,10 @@ export const MenuItem = <Tag extends React.ElementType = "button">({
|
|
|
98
96
|
return (
|
|
99
97
|
<Icon
|
|
100
98
|
className={classNames("fabric-menuIcon", minimal && "minimal")}
|
|
101
|
-
|
|
102
|
-
bg={iconBg}
|
|
103
|
-
color={iconColor}
|
|
104
|
-
rtlFlip={rtlFlip}
|
|
99
|
+
{...getIconProps(path ?? "")}
|
|
105
100
|
/>
|
|
106
101
|
);
|
|
107
|
-
}, [icon,
|
|
102
|
+
}, [icon, minimal, label]);
|
|
108
103
|
|
|
109
104
|
const Wrapper = useCallback(
|
|
110
105
|
({ children, ...rest }: AnyObject) => {
|
|
@@ -29,15 +29,11 @@ import {
|
|
|
29
29
|
type ChildrenProp,
|
|
30
30
|
type ColorState,
|
|
31
31
|
type CssProp,
|
|
32
|
-
type IconProps,
|
|
33
32
|
type TestProps,
|
|
34
33
|
} from "../../types";
|
|
34
|
+
import { IconProps } from "../icon/Icon";
|
|
35
35
|
|
|
36
|
-
export interface MenuItemProps
|
|
37
|
-
extends CssProp,
|
|
38
|
-
AriaProps,
|
|
39
|
-
TestProps,
|
|
40
|
-
IconProps {
|
|
36
|
+
export interface MenuItemProps extends CssProp, AriaProps, TestProps {
|
|
41
37
|
/**
|
|
42
38
|
* menu id passed via menu.onClick
|
|
43
39
|
*/
|
|
@@ -54,6 +50,10 @@ export interface MenuItemProps
|
|
|
54
50
|
* menu color
|
|
55
51
|
*/
|
|
56
52
|
color?: ColorState;
|
|
53
|
+
/**
|
|
54
|
+
* icon path or props
|
|
55
|
+
*/
|
|
56
|
+
icon?: IconProps;
|
|
57
57
|
/**
|
|
58
58
|
* item active
|
|
59
59
|
*/
|
|
@@ -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
|
)}
|
|
@@ -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) => {
|