@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.
Files changed (85) hide show
  1. package/css/components/_icon.css +3 -3
  2. package/css/components/_stepper.css +86 -0
  3. package/css/components/index.css +1 -0
  4. package/dist/cjs/components/avatar/Avatar.js +1 -0
  5. package/dist/cjs/components/badge/Badge.js +2 -10
  6. package/dist/cjs/components/button/Button.js +4 -11
  7. package/dist/cjs/components/chip/Chip.js +5 -12
  8. package/dist/cjs/components/icon/Icon.js +28 -3
  9. package/dist/cjs/components/menu/MenuItem.js +5 -12
  10. package/dist/cjs/components/panel/Panel.js +4 -13
  11. package/dist/cjs/components/tabpanel/Tab.js +3 -12
  12. package/dist/cjs/core/aside/Aside.js +2 -11
  13. package/dist/cjs/core/headfoot/HeadFoot.js +4 -2
  14. package/dist/cjs/core/page/Page.js +4 -13
  15. package/dist/cjs/hooks/useStepper.js +75 -0
  16. package/dist/cjs/index.js +3 -0
  17. package/dist/cjs/overlays/alert/Alert.js +3 -1
  18. package/dist/cjs/overlays/flyout/Flyout.js +4 -11
  19. package/dist/cjs/overlays/message/Message.js +2 -0
  20. package/dist/cjs/overlays/modal/Modal.js +4 -11
  21. package/dist/cjs/overlays/toast/Toast.js +3 -1
  22. package/dist/cjs/types/icons.js +2 -1
  23. package/dist/esm/components/avatar/Avatar.js +1 -0
  24. package/dist/esm/components/badge/Badge.js +3 -11
  25. package/dist/esm/components/button/Button.js +6 -13
  26. package/dist/esm/components/chip/Chip.js +6 -13
  27. package/dist/esm/components/icon/Icon.js +30 -6
  28. package/dist/esm/components/menu/MenuItem.js +6 -13
  29. package/dist/esm/components/panel/Panel.js +5 -14
  30. package/dist/esm/components/tabpanel/Tab.js +4 -13
  31. package/dist/esm/core/aside/Aside.js +3 -12
  32. package/dist/esm/core/headfoot/HeadFoot.js +4 -2
  33. package/dist/esm/core/page/Page.js +5 -14
  34. package/dist/esm/hooks/useStepper.js +75 -0
  35. package/dist/esm/index.js +2 -1
  36. package/dist/esm/overlays/alert/Alert.js +3 -1
  37. package/dist/esm/overlays/flyout/Flyout.js +5 -12
  38. package/dist/esm/overlays/message/Message.js +2 -0
  39. package/dist/esm/overlays/modal/Modal.js +5 -12
  40. package/dist/esm/overlays/toast/Toast.js +3 -1
  41. package/dist/esm/types/icons.js +2 -1
  42. package/dist/types/components/badge/Badge.d.ts +8 -3
  43. package/dist/types/components/button/Button.d.ts +8 -3
  44. package/dist/types/components/chip/Chip.d.ts +8 -3
  45. package/dist/types/components/icon/Icon.d.ts +10 -4
  46. package/dist/types/components/index.d.ts +1 -1
  47. package/dist/types/components/menu/MenuItem.d.ts +1 -1
  48. package/dist/types/components/menu/types.d.ts +7 -2
  49. package/dist/types/components/panel/Panel.d.ts +8 -5
  50. package/dist/types/components/tabpanel/Tab.d.ts +8 -5
  51. package/dist/types/core/aside/Aside.d.ts +8 -5
  52. package/dist/types/core/page/Page.d.ts +8 -5
  53. package/dist/types/hooks/useStepper.d.ts +15 -0
  54. package/dist/types/index.d.ts +1 -0
  55. package/dist/types/overlays/alert/Alert.d.ts +15 -3
  56. package/dist/types/overlays/flyout/Flyout.d.ts +5 -5
  57. package/dist/types/overlays/message/Message.d.ts +15 -3
  58. package/dist/types/overlays/modal/Modal.d.ts +5 -5
  59. package/dist/types/overlays/toast/Toast.d.ts +15 -3
  60. package/dist/types/types/icons.d.ts +2 -1
  61. package/dist/types/types/index.d.ts +0 -18
  62. package/package.json +14 -14
  63. package/src/components/avatar/Avatar.tsx +1 -1
  64. package/src/components/badge/Badge.tsx +7 -13
  65. package/src/components/button/Button.tsx +10 -18
  66. package/src/components/chip/Chip.tsx +7 -11
  67. package/src/components/icon/Icon.tsx +43 -6
  68. package/src/components/index.ts +1 -1
  69. package/src/components/menu/MenuItem.tsx +4 -9
  70. package/src/components/menu/types.ts +6 -6
  71. package/src/components/panel/Panel.tsx +7 -13
  72. package/src/components/tabpanel/Tab.tsx +6 -17
  73. package/src/core/aside/Aside.tsx +7 -13
  74. package/src/core/headfoot/HeadFoot.tsx +2 -2
  75. package/src/core/page/Page.tsx +8 -23
  76. package/src/hooks/useStepper.tsx +68 -0
  77. package/src/index.ts +1 -0
  78. package/src/overlays/alert/Alert.tsx +24 -5
  79. package/src/overlays/flyout/Flyout.tsx +5 -21
  80. package/src/overlays/message/Message.tsx +18 -3
  81. package/src/overlays/modal/Modal.tsx +5 -21
  82. package/src/overlays/toast/Toast.tsx +23 -4
  83. package/src/types/global.d.ts +8 -0
  84. package/src/types/icons.ts +3 -1
  85. package/src/types/index.ts +0 -19
@@ -12,6 +12,7 @@ export * from "./hooks/useNavigator";
12
12
  export * from "./hooks/useOverlayService";
13
13
  export * from "./hooks/useResize";
14
14
  export * from "./hooks/useResizeObserver";
15
+ export * from "./hooks/useStepper";
15
16
  export * from "./hooks/useStorage";
16
17
  export { HotKey } from "./hotkeys/HotKey";
17
18
  export { HotKeyLabel } from "./hotkeys/HotKeyLabel";
@@ -1,9 +1,21 @@
1
- import { type ColorState, type Elements, type IconProps } from "../../types";
2
- export interface AlertProps extends Omit<IconProps, "iconBg" | "iconColor"> {
1
+ import { type ColorState, type Elements } from "../../types";
2
+ export interface AlertProps {
3
3
  /**
4
4
  * toast type
5
5
  */
6
6
  type?: "alert" | "confirm" | "prompt";
7
+ /**
8
+ * svg path / webfont className / 1-4 letter text
9
+ */
10
+ icon: string;
11
+ /**
12
+ * icon image source URL, if failed to load then shows icon
13
+ */
14
+ iconSrc?: string;
15
+ /**
16
+ * flip icon in rtl
17
+ */
18
+ rtlFlip?: boolean;
7
19
  /**
8
20
  * toast title
9
21
  */
@@ -37,4 +49,4 @@ export interface AlertProps extends Omit<IconProps, "iconBg" | "iconColor"> {
37
49
  */
38
50
  defaultValue?: string;
39
51
  }
40
- export declare const Alert: ({ title, message, color, icon, rtlFlip, actions, onClose, type, okLabel, cancelLabel, placeholder, defaultValue, }: AlertProps) => import("react/jsx-runtime").JSX.Element;
52
+ export declare const Alert: ({ title, message, color, icon, iconSrc, rtlFlip, actions, onClose, type, okLabel, cancelLabel, placeholder, defaultValue, }: AlertProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
- import { type ElementType } from "react";
2
- import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type IconProps, type TestProps } from "../../types";
3
- export interface FlyoutProps extends AriaProps, TestProps, Omit<IconProps, "icon">, ChildrenProp {
4
- icon?: string | ElementType<IconProps>;
1
+ import { IconProps } from "../../components/icon/Icon";
2
+ import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type TestProps } from "../../types";
3
+ export interface FlyoutProps extends AriaProps, TestProps, ChildrenProp {
4
+ icon?: IconProps;
5
5
  /**
6
6
  * flyout alignment
7
7
  */
@@ -59,4 +59,4 @@ export interface FlyoutProps extends AriaProps, TestProps, Omit<IconProps, "icon
59
59
  */
60
60
  onBeforeClose?: (...args: AnyObject) => CallbackReturn;
61
61
  }
62
- export declare const Flyout: ({ icon, iconBg, iconColor, iconClassName, rtlFlip, title, actions, closeOnClick, headerClassName, onClose, onBeforeClose, children, loading, size, width, minWidth, root, hideMask, align, ...aria }: FlyoutProps) => import("react/jsx-runtime").JSX.Element;
62
+ export declare const Flyout: ({ icon, iconClassName, title, actions, closeOnClick, headerClassName, onClose, onBeforeClose, children, loading, size, width, minWidth, root, hideMask, align, ...aria }: FlyoutProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,17 @@
1
- import { type ColorState, type Elements, type IconProps } from "../../types";
2
- export interface MessageProps extends Omit<IconProps, "iconBg" | "iconColor"> {
1
+ import { type ColorState, type Elements } from "../../types";
2
+ export interface MessageProps {
3
+ /**
4
+ * svg path / webfont className / 1-4 letter text
5
+ */
6
+ icon: string;
7
+ /**
8
+ * icon image source URL, if failed to load then shows icon
9
+ */
10
+ iconSrc?: string;
11
+ /**
12
+ * flip icon in rtl
13
+ */
14
+ rtlFlip?: boolean;
3
15
  /**
4
16
  * message title
5
17
  */
@@ -17,4 +29,4 @@ export interface MessageProps extends Omit<IconProps, "iconBg" | "iconColor"> {
17
29
  */
18
30
  actions?: Elements<JSX.Element>;
19
31
  }
20
- export declare const Message: ({ title, message, color, icon, rtlFlip, actions, onClose, }: MessageProps) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const Message: ({ title, message, color, icon, iconSrc, rtlFlip, actions, onClose, }: MessageProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
- import { type ElementType } from "react";
2
- import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type IconProps, type TestProps } from "../../types";
3
- export interface ModalProps extends AriaProps, TestProps, Omit<IconProps, "icon">, ChildrenProp {
4
- icon?: string | ElementType<IconProps>;
1
+ import { IconProps } from "../../components/icon/Icon";
2
+ import { type AriaProps, type CallbackReturn, type ChildrenProp, type Elements, type TestProps } from "../../types";
3
+ export interface ModalProps extends AriaProps, TestProps, ChildrenProp {
4
+ icon?: IconProps;
5
5
  /**
6
6
  * header className
7
7
  */
@@ -59,4 +59,4 @@ export interface ModalProps extends AriaProps, TestProps, Omit<IconProps, "icon"
59
59
  */
60
60
  onBeforeClose?: (...args: AnyObject) => CallbackReturn;
61
61
  }
62
- export declare const Modal: ({ icon, iconBg, iconColor, iconClassName, rtlFlip, title, actions, headerClassName, onClose, onBeforeClose, children, loading, root, size, hideMask, width, height, minHeight, minWidth, ...aria }: ModalProps) => import("react/jsx-runtime").JSX.Element;
62
+ export declare const Modal: ({ icon, iconClassName, title, actions, headerClassName, onClose, onBeforeClose, children, loading, root, size, hideMask, width, height, minHeight, minWidth, ...aria }: ModalProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,21 @@
1
- import { type ColorState, type Elements, type IconProps } from "../../types";
2
- export interface ToastProps extends Omit<IconProps, "iconBg" | "iconColor"> {
1
+ import { type ColorState, type Elements } from "../../types";
2
+ export interface ToastProps {
3
3
  /**
4
4
  * toast type
5
5
  */
6
6
  type?: "alert" | "confirm";
7
+ /**
8
+ * svg path / webfont className / 1-4 letter text
9
+ */
10
+ icon: string;
11
+ /**
12
+ * icon image source URL, if failed to load then shows icon
13
+ */
14
+ iconSrc?: string;
15
+ /**
16
+ * flip icon in rtl
17
+ */
18
+ rtlFlip?: boolean;
7
19
  /**
8
20
  * toast title
9
21
  */
@@ -29,4 +41,4 @@ export interface ToastProps extends Omit<IconProps, "iconBg" | "iconColor"> {
29
41
  */
30
42
  cancelLabel?: string;
31
43
  }
32
- export declare const Toast: ({ title, message, color, icon, rtlFlip, actions, onClose, onCloseAll, type, okLabel, cancelLabel, }: ToastProps) => import("react/jsx-runtime").JSX.Element;
44
+ export declare const Toast: ({ title, message, color, icon, iconSrc, rtlFlip, actions, onClose, onCloseAll, type, okLabel, cancelLabel, }: ToastProps) => import("react/jsx-runtime").JSX.Element;
@@ -180,7 +180,7 @@ export declare namespace CoreIcons {
180
180
  const mediaAspect = "M19,12H17V15H14V17H19V12M7,9H10V7H5V12H7V9M21,3H3A2,2 0 0,0 1,5V19A2,2 0 0,0 3,21H21A2,2 0 0,0 23,19V5A2,2 0 0,0 21,3M21,19H3V5H21V19Z";
181
181
  const mediaZoomer = "M15 0.004c-4.97 0-9 4.030-9 9 0 1.52 0.38 2.95 1.046 4.206l-6.258 6.256 0.005 0.005c-0.489 0.481-0.794 1.147-0.794 1.887 0 1.462 1.185 2.647 2.647 2.647 0.739 0 1.406-0.304 1.886-0.794l-0.002-0.001 6.256-6.255c1.257 0.668 2.689 1.050 4.213 1.050 4.97 0 9-4.030 9-9s-4.030-9-9-9zM3.596 22.273c-0.241 0.25-0.576 0.407-0.95 0.407-0.731 0-1.324-0.592-1.324-1.323 0-0.373 0.157-0.707 0.407-0.95l-0.007-0.006 6.050-6.050c0.529 0.713 1.159 1.343 1.87 1.874l-6.047 6.047zM15 16.505c-4.142 0-7.5-3.359-7.5-7.5s3.358-7.5 7.5-7.5c4.141 0 7.5 3.358 7.5 7.5s-3.359 7.5-7.5 7.5zM15 3.754c0.206 0 0.375 0.168 0.375 0.375s-0.169 0.375-0.375 0.375c-2.486 0-4.5 2.015-4.5 4.5 0 0.207-0.168 0.375-0.375 0.375s-0.375-0.168-0.375-0.375c0-2.9 2.35-5.25 5.25-5.25z";
182
182
  const mediaOrient = "M7.34,6.41L0.86,12.9L7.35,19.38L13.84,12.9L7.34,6.41M3.69,12.9L7.35,9.24L11,12.9L7.34,16.56L3.69,12.9M19.36,6.64C17.61,4.88 15.3,4 13,4V0.76L8.76,5L13,9.24V6C14.79,6 16.58,6.68 17.95,8.05C20.68,10.78 20.68,15.22 17.95,17.95C16.58,19.32 14.79,20 13,20C12.03,20 11.06,19.79 10.16,19.39L8.67,20.88C10,21.62 11.5,22 13,22C15.3,22 17.61,21.12 19.36,19.36C22.88,15.85 22.88,10.15 19.36,6.64Z";
183
- const mediaCrop = "M7,17V1H5V5H1V7H5V17A2,2 0 0,0 7,19H17V23H19V19H23V17M17,15H19V7C19,5.89 18.1,5 17,5H9V7H17V15Z";
183
+ const mediaCrop = "M13,17H17V13H19V17H23V19H19V23H17V19H13V17M11,17V19H9V17H11M7,17V19H5V17H7M19,9V11H17V9H19M19,5V7H17V5H19M15,5V7H13V5H15M11,5V7H9V5H11M7,5V7H5V5H7M7,13V15H5V13H7M7,9V11H5V9H7Z";
184
184
  const mediaImage = "M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z";
185
185
  const mediaVideo = "M15,8V16H5V8H15M16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5V7A1,1 0 0,0 16,6Z";
186
186
  const mediaAudio = "M17.3,11C17.3,14 14.76,16.1 12,16.1C9.24,16.1 6.7,14 6.7,11H5C5,14.41 7.72,17.23 11,17.72V21H13V17.72C16.28,17.23 19,14.41 19,11M10.8,4.9C10.8,4.24 11.34,3.7 12,3.7C12.66,3.7 13.2,4.24 13.2,4.9L13.19,11.1C13.19,11.76 12.66,12.3 12,12.3C11.34,12.3 10.8,11.76 10.8,11.1M12,14A3,3 0 0,0 15,11V5A3,3 0 0,0 12,2A3,3 0 0,0 9,5V11A3,3 0 0,0 12,14Z";
@@ -202,6 +202,7 @@ export declare namespace CoreIcons {
202
202
  const mediaVolume3 = "M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z";
203
203
  const mediaComment = "M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M6,7H18V9H6V7M6,11H15V13H6V11Z";
204
204
  const mediaCommentAdd = "M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M11,6H13V9H16V11H13V14H11V11H8V9H11V6Z";
205
+ const mediaCapture = "M12,10L11.06,12.06L9,13L11.06,13.94L12,16L12.94,13.94L15,13L12.94,12.06L12,10M20,5H16.83L15,3H9L7.17,5H4A2,2 0 0,0 2,7V19A2,2 0 0,0 4,21H20A2,2 0 0,0 22,19V7A2,2 0 0,0 20,5M20,19H4V7H8.05L8.64,6.35L9.88,5H14.12L15.36,6.35L15.95,7H20V19M12,8A5,5 0 0,0 7,13A5,5 0 0,0 12,18A5,5 0 0,0 17,13A5,5 0 0,0 12,8M12,16A3,3 0 0,1 9,13A3,3 0 0,1 12,10A3,3 0 0,1 15,13A3,3 0 0,1 12,16Z";
205
206
  const mediaLightness = "M12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18M20,15.31L23.31,12L20,8.69V4H15.31L12,0.69L8.69,4H4V8.69L0.69,12L4,15.31V20H8.69L12,23.31L15.31,20H20V15.31Z";
206
207
  const mediaColor = "M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z";
207
208
  const mediaInvert = "M12,19.58V19.58C10.4,19.58 8.89,18.96 7.76,17.83C6.62,16.69 6,15.19 6,13.58C6,12 6.62,10.47 7.76,9.34L12,5.1M17.66,7.93L12,2.27V2.27L6.34,7.93C3.22,11.05 3.22,16.12 6.34,19.24C7.9,20.8 9.95,21.58 12,21.58C14.05,21.58 16.1,20.8 17.66,19.24C20.78,16.12 20.78,11.05 17.66,7.93Z";
@@ -84,24 +84,6 @@ export type PolymorphicProps<AsTag extends ReactTag> = Omit<PropsOf<AsTag>, "chi
84
84
  */
85
85
  as?: AsTag;
86
86
  };
87
- export interface IconProps {
88
- /**
89
- * svg path / image url
90
- */
91
- icon?: string;
92
- /**
93
- * flip icon in rtl
94
- */
95
- rtlFlip?: boolean;
96
- /**
97
- * icon background color
98
- */
99
- iconBg?: ColorType | PaletteType | string;
100
- /**
101
- * icon color
102
- */
103
- iconColor?: ColorType | PaletteType | string;
104
- }
105
87
  export interface CollapseProps {
106
88
  /**
107
89
  * Allow collapsing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/core",
3
- "version": "1.0.0-beta.57",
3
+ "version": "1.0.0-beta.59",
4
4
  "description": "RUF: Core package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -35,24 +35,24 @@
35
35
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
36
  },
37
37
  "dependencies": {
38
- "@floating-ui/react": "^0.27.12",
39
- "@react-fabric/utilities": "^1.0.0-beta.52",
40
- "@tailwindcss/postcss": "~4.1.8",
41
- "boring-avatars": "^1.11.2",
42
- "classnames": "^2.5.1",
43
- "color": "^4.2.3",
44
- "resize-observer-polyfill": "^1.5.1",
45
- "tailwindcss": "^4.1.8"
38
+ "@floating-ui/react": "~0.27.16",
39
+ "@react-fabric/utilities": "^1.0.0-beta.59",
40
+ "@tailwindcss/postcss": "~4.1.16",
41
+ "boring-avatars": "~1.11.2",
42
+ "classnames": "~2.5.1",
43
+ "color": "~5.0.2",
44
+ "resize-observer-polyfill": "~1.5.1",
45
+ "tailwindcss": "~4.1.16"
46
46
  },
47
47
  "peerDependencies": {
48
- "i18next": "^25.2.1",
49
- "react": "^19.0.0",
50
- "react-dom": "^19.0.0",
51
- "react-i18next": "^15.5.2"
48
+ "i18next": "~25.6.0",
49
+ "react": "~19.2.0",
50
+ "react-dom": "~19.2.0",
51
+ "react-i18next": "~16.2.1"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=18.12.0",
55
55
  "npm": ">=8.19.0"
56
56
  },
57
- "gitHead": "9b596a0a8d6cecaa8479f80c495b64fb42ce739f"
57
+ "gitHead": "74efd06c9c5ac629b6ef5cdc6d53ecb1c356f2eb"
58
58
  }
@@ -185,7 +185,7 @@ export const Avatar = ({
185
185
  const fallbackAvatar = useMemo(() => {
186
186
  if (fallbackIcon) {
187
187
  return isSvgPath(fallbackIcon) ? (
188
- <svg viewBox={viewBox}>
188
+ <svg viewBox={viewBox} className="p-[0.125em]">
189
189
  <path fill="currentColor" d={fallbackIcon.toString()} />
190
190
  </svg>
191
191
  ) : (
@@ -28,16 +28,11 @@ import {
28
28
  type BadgeType,
29
29
  type ChildProp,
30
30
  type CssProp,
31
- type IconProps,
32
31
  type RefProp,
33
32
  } from "../../types";
34
- import { Icon } from "../icon/Icon";
33
+ import { getIconProps, Icon, IconProps } from "../icon/Icon";
35
34
 
36
- export interface BadgeProps
37
- extends CssProp,
38
- RefProp,
39
- IconProps,
40
- Partial<ChildProp> {
35
+ export interface BadgeProps extends CssProp, RefProp, Partial<ChildProp> {
41
36
  /**
42
37
  * make wrapper a block element
43
38
  */
@@ -50,6 +45,10 @@ export interface BadgeProps
50
45
  * badge value
51
46
  */
52
47
  value?: number | string;
48
+ /**
49
+ * icon path or props
50
+ */
51
+ icon?: IconProps;
53
52
  /**
54
53
  * max value for number display
55
54
  */
@@ -124,9 +123,6 @@ export const Badge = ({
124
123
  // @ts-expect-error ignore
125
124
  forButton = false,
126
125
  icon,
127
- iconBg,
128
- iconColor,
129
- rtlFlip,
130
126
  ...rest
131
127
  }: BadgeProps) => {
132
128
  const label = useMemo(() => {
@@ -176,9 +172,7 @@ export const Badge = ({
176
172
  )}
177
173
  >
178
174
  {label && <span className="p-1">{label}</span>}
179
- {icon && (
180
- <Icon icon={icon} bg={iconBg} color={iconColor} rtlFlip={rtlFlip} />
181
- )}
175
+ {icon && <Icon {...getIconProps(icon)} />}
182
176
  </div>
183
177
  )}
184
178
  </div>
@@ -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={!!iconBg}
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
- color={iconColor}
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 IconProps extends CssProp, AriaProps, RefProp, TestProps {
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
- }: IconProps) => {
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
- {iconEl}
240
+ {iconSrc && !imageFailed && (
241
+ <img src={iconSrc} onError={() => setImageFailed(true)} />
242
+ )}
243
+ {(!iconSrc || imageFailed) && iconEl}
207
244
  </dfn>
208
245
  );
209
246
  };
@@ -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
- icon={path ?? ""}
102
- bg={iconBg}
103
- color={iconColor}
104
- rtlFlip={rtlFlip}
99
+ {...getIconProps(path ?? "")}
105
100
  />
106
101
  );
107
- }, [icon, iconBg, iconColor, rtlFlip, minimal, label]);
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
  */