@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.
Files changed (77) hide show
  1. package/css/components/_icon.css +3 -3
  2. package/dist/cjs/components/avatar/Avatar.js +1 -0
  3. package/dist/cjs/components/badge/Badge.js +2 -10
  4. package/dist/cjs/components/button/Button.js +4 -11
  5. package/dist/cjs/components/chip/Chip.js +5 -12
  6. package/dist/cjs/components/icon/Icon.js +28 -3
  7. package/dist/cjs/components/menu/MenuItem.js +5 -12
  8. package/dist/cjs/components/panel/Panel.js +4 -13
  9. package/dist/cjs/components/tabpanel/Tab.js +3 -12
  10. package/dist/cjs/core/aside/Aside.js +2 -11
  11. package/dist/cjs/core/headfoot/HeadFoot.js +4 -2
  12. package/dist/cjs/core/page/Page.js +4 -13
  13. package/dist/cjs/index.js +1 -0
  14. package/dist/cjs/overlays/alert/Alert.js +3 -1
  15. package/dist/cjs/overlays/flyout/Flyout.js +4 -11
  16. package/dist/cjs/overlays/message/Message.js +2 -0
  17. package/dist/cjs/overlays/modal/Modal.js +4 -11
  18. package/dist/cjs/overlays/toast/Toast.js +3 -1
  19. package/dist/cjs/types/icons.js +2 -1
  20. package/dist/esm/components/avatar/Avatar.js +1 -0
  21. package/dist/esm/components/badge/Badge.js +3 -11
  22. package/dist/esm/components/button/Button.js +6 -13
  23. package/dist/esm/components/chip/Chip.js +6 -13
  24. package/dist/esm/components/icon/Icon.js +30 -6
  25. package/dist/esm/components/menu/MenuItem.js +6 -13
  26. package/dist/esm/components/panel/Panel.js +5 -14
  27. package/dist/esm/components/tabpanel/Tab.js +4 -13
  28. package/dist/esm/core/aside/Aside.js +3 -12
  29. package/dist/esm/core/headfoot/HeadFoot.js +4 -2
  30. package/dist/esm/core/page/Page.js +5 -14
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/overlays/alert/Alert.js +3 -1
  33. package/dist/esm/overlays/flyout/Flyout.js +5 -12
  34. package/dist/esm/overlays/message/Message.js +2 -0
  35. package/dist/esm/overlays/modal/Modal.js +5 -12
  36. package/dist/esm/overlays/toast/Toast.js +3 -1
  37. package/dist/esm/types/icons.js +2 -1
  38. package/dist/types/components/badge/Badge.d.ts +8 -3
  39. package/dist/types/components/button/Button.d.ts +8 -3
  40. package/dist/types/components/chip/Chip.d.ts +8 -3
  41. package/dist/types/components/icon/Icon.d.ts +10 -4
  42. package/dist/types/components/index.d.ts +1 -1
  43. package/dist/types/components/menu/MenuItem.d.ts +1 -1
  44. package/dist/types/components/menu/types.d.ts +7 -2
  45. package/dist/types/components/panel/Panel.d.ts +8 -5
  46. package/dist/types/components/tabpanel/Tab.d.ts +8 -5
  47. package/dist/types/core/aside/Aside.d.ts +8 -5
  48. package/dist/types/core/page/Page.d.ts +8 -5
  49. package/dist/types/overlays/alert/Alert.d.ts +15 -3
  50. package/dist/types/overlays/flyout/Flyout.d.ts +5 -5
  51. package/dist/types/overlays/message/Message.d.ts +15 -3
  52. package/dist/types/overlays/modal/Modal.d.ts +5 -5
  53. package/dist/types/overlays/toast/Toast.d.ts +15 -3
  54. package/dist/types/types/icons.d.ts +2 -1
  55. package/dist/types/types/index.d.ts +0 -18
  56. package/package.json +14 -14
  57. package/src/components/avatar/Avatar.tsx +1 -1
  58. package/src/components/badge/Badge.tsx +7 -13
  59. package/src/components/button/Button.tsx +10 -18
  60. package/src/components/chip/Chip.tsx +7 -11
  61. package/src/components/icon/Icon.tsx +43 -6
  62. package/src/components/index.ts +1 -1
  63. package/src/components/menu/MenuItem.tsx +4 -9
  64. package/src/components/menu/types.ts +6 -6
  65. package/src/components/panel/Panel.tsx +7 -13
  66. package/src/components/tabpanel/Tab.tsx +6 -17
  67. package/src/core/aside/Aside.tsx +7 -13
  68. package/src/core/headfoot/HeadFoot.tsx +2 -2
  69. package/src/core/page/Page.tsx +8 -23
  70. package/src/overlays/alert/Alert.tsx +24 -5
  71. package/src/overlays/flyout/Flyout.tsx +5 -21
  72. package/src/overlays/message/Message.tsx +18 -3
  73. package/src/overlays/modal/Modal.tsx +5 -21
  74. package/src/overlays/toast/Toast.tsx +23 -4
  75. package/src/types/global.d.ts +8 -0
  76. package/src/types/icons.ts +3 -1
  77. package/src/types/index.ts +0 -19
@@ -119,6 +119,7 @@ var Avatar = function Avatar(_ref) {
119
119
  if (fallbackIcon) {
120
120
  return isSvgPath(fallbackIcon) ? /*#__PURE__*/jsx("svg", {
121
121
  viewBox: viewBox,
122
+ className: "p-[0.125em]",
122
123
  children: /*#__PURE__*/jsx("path", {
123
124
  fill: "currentColor",
124
125
  d: fallbackIcon.toString()
@@ -5,10 +5,10 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
5
5
  import { isObject, isNil, isNumber, mergeRefs } from '@react-fabric/utilities';
6
6
  import classNames from 'classnames';
7
7
  import { isValidElement, useMemo, cloneElement } from 'react';
8
- import { Icon } from '../icon/Icon.js';
8
+ import { Icon, getIconProps } from '../icon/Icon.js';
9
9
  import { jsxs, jsx } from 'react/jsx-runtime';
10
10
 
11
- var _excluded = ["ref", "className", "value", "max", "ping", "block", "inline", "placement", "children", "forButton", "icon", "iconBg", "iconColor", "rtlFlip"];
11
+ var _excluded = ["ref", "className", "value", "max", "ping", "block", "inline", "placement", "children", "forButton", "icon"];
12
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
14
  /**
@@ -65,9 +65,6 @@ var Badge = function Badge(_ref) {
65
65
  _ref$forButton = _ref.forButton,
66
66
  forButton = _ref$forButton === void 0 ? false : _ref$forButton,
67
67
  icon = _ref.icon,
68
- iconBg = _ref.iconBg,
69
- iconColor = _ref.iconColor,
70
- rtlFlip = _ref.rtlFlip,
71
68
  rest = _objectWithoutProperties(_ref, _excluded);
72
69
  var label = useMemo(function () {
73
70
  if ( /*#__PURE__*/isValidElement(value)) {
@@ -99,12 +96,7 @@ var Badge = function Badge(_ref) {
99
96
  children: [label && /*#__PURE__*/jsx("span", {
100
97
  className: "p-1",
101
98
  children: label
102
- }), icon && /*#__PURE__*/jsx(Icon, {
103
- icon: icon,
104
- bg: iconBg,
105
- color: iconColor,
106
- rtlFlip: rtlFlip
107
- })]
99
+ }), icon && /*#__PURE__*/jsx(Icon, _objectSpread({}, getIconProps(icon)))]
108
100
  })]
109
101
  });
110
102
  };
@@ -3,7 +3,7 @@
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
- import { mergeRefs, isString, isNil } from '@react-fabric/utilities';
6
+ import { mergeRefs, isString, isObject, isNil } from '@react-fabric/utilities';
7
7
  import classNames from 'classnames';
8
8
  import { useRef, useState, useCallback, useEffect, useMemo, Fragment, isValidElement } from 'react';
9
9
  import { useEffectDebugger } from '../../hooks/useEffectDebugger.js';
@@ -14,9 +14,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
14
14
  import { getColor } from '../../utils/getColor.js';
15
15
  import { AnimationIndicator } from '../animations/Animations.js';
16
16
  import { getBadgeProps, Badge } from '../badge/Badge.js';
17
- import { Icon } from '../icon/Icon.js';
17
+ import { Icon, getIconProps } from '../icon/Icon.js';
18
18
 
19
- var _excluded = ["as", "ref", "children", "className", "active", "color", "icon", "iconBg", "iconColor", "iconAlign", "altIcon", "rtlFlip", "rounded", "size", "disabled", "loading", "variant", "badge", "fullWidth", "spinOnHover", "onClick", "actionMessage", "preventDefault", "stopPropagation", "type", "hotKey", "showActionDone", "showActionDoneEvent", "tabIndex", "data-ref"];
19
+ var _excluded = ["as", "ref", "children", "className", "active", "color", "icon", "iconAlign", "altIcon", "rounded", "size", "disabled", "loading", "variant", "badge", "fullWidth", "spinOnHover", "onClick", "actionMessage", "preventDefault", "stopPropagation", "type", "hotKey", "showActionDone", "showActionDoneEvent", "tabIndex", "data-ref"];
20
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
22
  /**
@@ -52,12 +52,9 @@ var Button = function Button(_ref) {
52
52
  _ref$color = _ref.color,
53
53
  color = _ref$color === void 0 ? "primary" : _ref$color,
54
54
  icon = _ref.icon,
55
- iconBg = _ref.iconBg,
56
- iconColor = _ref.iconColor,
57
55
  _ref$iconAlign = _ref.iconAlign,
58
56
  iconAlign = _ref$iconAlign === void 0 ? "start" : _ref$iconAlign,
59
57
  altIcon = _ref.altIcon,
60
- rtlFlip = _ref.rtlFlip,
61
58
  rounded = _ref.rounded,
62
59
  size = _ref.size,
63
60
  disabled = _ref.disabled,
@@ -162,19 +159,15 @@ var Button = function Button(_ref) {
162
159
  "data-active": active,
163
160
  "data-variant": variant
164
161
  }, aria), {}, {
165
- children: [icon && /*#__PURE__*/jsx(Icon, {
162
+ children: [icon && /*#__PURE__*/jsx(Icon, _objectSpread({
166
163
  className: "fabric-buttonIcon",
167
- icon: icon,
168
- bg: iconBg,
169
- color: iconColor,
170
- rtlFlip: rtlFlip,
171
164
  "data-align": iconAlign
172
- }), /*#__PURE__*/isValidElement(children) && /*#__PURE__*/jsx("div", {
165
+ }, getIconProps(icon))), /*#__PURE__*/isValidElement(children) && /*#__PURE__*/jsx("div", {
173
166
  className: "fabric-buttonChild",
174
167
  children: children
175
168
  }), isString(children) && /*#__PURE__*/jsx("label", {
176
169
  className: classNames("fabric-buttonLabel", "truncate"),
177
- "data-colored-icon": !!iconBg,
170
+ "data-colored-icon": isObject(icon) && "bg" in icon,
178
171
  children: children
179
172
  }), !isNil(badge) && /*#__PURE__*/jsx(Badge, _objectSpread({}, badgeProps)), hotKey && children && /*#__PURE__*/jsx(HotKeyLabel, {
180
173
  keyCombo: hotKey
@@ -8,9 +8,9 @@ import { useMemoDebugger } from '../../hooks/useEffectDebugger.js';
8
8
  import { jsxs, jsx } from 'react/jsx-runtime';
9
9
  import { getColor } from '../../utils/getColor.js';
10
10
  import '@react-fabric/utilities';
11
- import { Icon } from '../icon/Icon.js';
11
+ import { Icon, getIconProps } from '../icon/Icon.js';
12
12
 
13
- var _excluded = ["ref", "children", "className", "size", "color", "variant", "icon", "iconBg", "iconColor", "rtlFlip", "disabled", "onClick", "onIconClick", "onRemove", "rounded", "preventDefault", "stopPropagation", "as"];
13
+ var _excluded = ["ref", "children", "className", "size", "color", "variant", "icon", "disabled", "onClick", "onIconClick", "onRemove", "rounded", "preventDefault", "stopPropagation", "as"];
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var SizeMap = {
@@ -49,9 +49,6 @@ var Chip = function Chip(_ref) {
49
49
  color = _ref.color,
50
50
  variant = _ref.variant,
51
51
  icon = _ref.icon,
52
- iconBg = _ref.iconBg,
53
- iconColor = _ref.iconColor,
54
- rtlFlip = _ref.rtlFlip,
55
52
  disabled = _ref.disabled,
56
53
  onClick = _ref.onClick,
57
54
  onIconClick = _ref.onIconClick,
@@ -95,17 +92,13 @@ var Chip = function Chip(_ref) {
95
92
  "data-inner-clickable": !!onClick,
96
93
  onClick: disabled ? undefined : clickHandler
97
94
  }, aria), {}, {
98
- children: [icon && /*#__PURE__*/jsx(Icon, {
95
+ children: [icon && /*#__PURE__*/jsx(Icon, _objectSpread({
99
96
  "data-ref": "chipIcon",
100
97
  className: classNames("fabric-chipIcon", "m-1 flex-content"),
101
- icon: icon,
102
- bg: iconBg,
103
- onClick: onIconClick,
104
- color: iconColor,
105
- rtlFlip: rtlFlip
106
- }), children && /*#__PURE__*/jsx("label", {
98
+ onClick: onIconClick
99
+ }, getIconProps(icon))), children && /*#__PURE__*/jsx("label", {
107
100
  "data-ref": "chipLabel",
108
- className: classNames("fabric-chipLabel", "truncate"),
101
+ className: classNames("fabric-chipLabel", "truncate flex-1"),
109
102
  children: children
110
103
  }), onRemove && /*#__PURE__*/jsx("span", {
111
104
  role: "none",
@@ -1,16 +1,25 @@
1
1
  'use client';
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
5
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
6
  import { isSvgPath, isString } from '@react-fabric/utilities';
6
7
  import classNames from 'classnames';
7
- import { useMemo } from 'react';
8
- import { jsx } from 'react/jsx-runtime';
8
+ import { useState, useEffect, useMemo, isValidElement } from 'react';
9
+ import { jsx, jsxs } from 'react/jsx-runtime';
9
10
  import { getColor } from '../../utils/getColor.js';
10
11
 
11
- var _excluded = ["ref", "icon", "bg", "color", "size", "rtlFlip", "animate", "rounded", "disabled", "viewBox", "className", "onClick"];
12
+ var _excluded = ["ref", "icon", "iconSrc", "bg", "color", "size", "rtlFlip", "animate", "rounded", "disabled", "viewBox", "className", "onClick"];
12
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ var getIconProps = function getIconProps(props) {
16
+ if (typeof props === "string") {
17
+ return {
18
+ icon: props
19
+ };
20
+ }
21
+ return props;
22
+ };
14
23
  var SvgTextSize = ["", ".875em", ".525em", ".35em", ".25em"];
15
24
  var SizeMap = {
16
25
  xs: "0.625rem",
@@ -52,6 +61,7 @@ var SizeMap = {
52
61
  var Icon = function Icon(_ref) {
53
62
  var ref = _ref.ref,
54
63
  icon = _ref.icon,
64
+ iconSrc = _ref.iconSrc,
55
65
  bg = _ref.bg,
56
66
  color = _ref.color,
57
67
  _ref$size = _ref.size,
@@ -65,6 +75,14 @@ var Icon = function Icon(_ref) {
65
75
  className = _ref.className,
66
76
  _onClick = _ref.onClick,
67
77
  rest = _objectWithoutProperties(_ref, _excluded);
78
+ var _useState = useState(false),
79
+ _useState2 = _slicedToArray(_useState, 2),
80
+ imageFailed = _useState2[0],
81
+ setImageFailed = _useState2[1];
82
+ useEffect(function () {
83
+ setImageFailed(false);
84
+ }, [iconSrc]);
85
+
68
86
  /** ***************** style map *******************/
69
87
  var styles = useMemo(function () {
70
88
  var s = {};
@@ -90,6 +108,7 @@ var Icon = function Icon(_ref) {
90
108
 
91
109
  /** ***************** render icon *******************/
92
110
  var iconEl = useMemo(function () {
111
+ if ( /*#__PURE__*/isValidElement(icon)) return icon;
93
112
  if (!isString(icon)) {
94
113
  throw Error("Invalid icon expected string");
95
114
  }
@@ -116,7 +135,7 @@ var Icon = function Icon(_ref) {
116
135
  className: "".concat(icon)
117
136
  });
118
137
  }, [icon, isSvg, viewBox]);
119
- return /*#__PURE__*/jsx("dfn", _objectSpread(_objectSpread({
138
+ return /*#__PURE__*/jsxs("dfn", _objectSpread(_objectSpread({
120
139
  "data-ref": "icon",
121
140
  ref: ref
122
141
  }, rest), {}, {
@@ -131,8 +150,13 @@ var Icon = function Icon(_ref) {
131
150
  style: styles,
132
151
  "data-clickable": !!_onClick,
133
152
  "data-inner-clickable": !!_onClick,
134
- children: iconEl
153
+ children: [iconSrc && !imageFailed && /*#__PURE__*/jsx("img", {
154
+ src: iconSrc,
155
+ onError: function onError() {
156
+ return setImageFailed(true);
157
+ }
158
+ }), (!iconSrc || imageFailed) && iconEl]
135
159
  }));
136
160
  };
137
161
 
138
- export { Icon };
162
+ export { Icon, getIconProps };
@@ -14,11 +14,11 @@ import '../../hooks/useEffectDebugger.js';
14
14
  import { jsx, jsxs } from 'react/jsx-runtime';
15
15
  import { Tooltip } from '../../overlays/tooltip/Tooltip.js';
16
16
  import { getBadgeProps, Badge } from '../badge/Badge.js';
17
- import { Icon } from '../icon/Icon.js';
17
+ import { Icon, getIconProps } from '../icon/Icon.js';
18
18
  import '../../types/icons.js';
19
19
  import '../../hotkeys/HotKeyWrapper.js';
20
20
 
21
- var _excluded = ["as", "label", "color", "className", "icon", "iconBg", "iconColor", "appendLabel", "rtlFlip", "altIcon", "id", "active", "disabled", "onClick", "badge", "hotKey", "tabIndex", "minimal", "data-open", "ref"],
21
+ var _excluded = ["as", "label", "color", "className", "icon", "appendLabel", "altIcon", "id", "active", "disabled", "onClick", "badge", "hotKey", "tabIndex", "minimal", "data-open", "ref"],
22
22
  _excluded2 = ["children"];
23
23
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
24
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -50,10 +50,7 @@ var MenuItem = function MenuItem(_ref) {
50
50
  color = _ref$color === void 0 ? "primary" : _ref$color,
51
51
  className = _ref.className,
52
52
  icon = _ref.icon,
53
- iconBg = _ref.iconBg,
54
- iconColor = _ref.iconColor,
55
53
  appendLabel = _ref.appendLabel,
56
- rtlFlip = _ref.rtlFlip,
57
54
  altIcon = _ref.altIcon,
58
55
  id = _ref.id,
59
56
  active = _ref.active,
@@ -82,14 +79,10 @@ var MenuItem = function MenuItem(_ref) {
82
79
  if (minimal && !path) {
83
80
  path = iconToken(label);
84
81
  }
85
- return /*#__PURE__*/jsx(Icon, {
86
- className: classNames("fabric-menuIcon", minimal && "minimal"),
87
- icon: (_path = path) !== null && _path !== void 0 ? _path : "",
88
- bg: iconBg,
89
- color: iconColor,
90
- rtlFlip: rtlFlip
91
- });
92
- }, [icon, iconBg, iconColor, rtlFlip, minimal, label]);
82
+ return /*#__PURE__*/jsx(Icon, _objectSpread({
83
+ className: classNames("fabric-menuIcon", minimal && "minimal")
84
+ }, getIconProps((_path = path) !== null && _path !== void 0 ? _path : "")));
85
+ }, [icon, minimal, label]);
93
86
  var Wrapper = useCallback(function (_ref2) {
94
87
  var children = _ref2.children,
95
88
  rest = _objectWithoutProperties(_ref2, _excluded2);
@@ -6,13 +6,13 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
6
6
  import classNames from 'classnames';
7
7
  import { useMemo } from 'react';
8
8
  import { usePropToggle } from '../../hooks/usePropToggle.js';
9
+ import { HotKey } from '../../hotkeys/HotKey.js';
9
10
  import { CoreIcons } from '../../types/icons.js';
10
11
  import { Loading } from '../animations/Animations.js';
11
- import { Icon } from '../icon/Icon.js';
12
- import { HotKey } from '../../hotkeys/HotKey.js';
12
+ import { Icon, getIconProps } from '../icon/Icon.js';
13
13
  import { jsxs, jsx } from 'react/jsx-runtime';
14
14
 
15
- var _excluded = ["children", "className", "titleClassName", "headerClassName", "title", "actions", "icon", "iconBg", "iconColor", "rtlFlip", "panelId", "height", "width", "minHeight", "minWidth", "maxHeight", "maxWidth", "loading", "expandable", "expanded", "onExpand", "collapsable", "collapsed", "onCollapse", "onClose", "onBack"];
15
+ var _excluded = ["children", "className", "titleClassName", "headerClassName", "title", "actions", "icon", "panelId", "height", "width", "minHeight", "minWidth", "maxHeight", "maxWidth", "loading", "expandable", "expanded", "onExpand", "collapsable", "collapsed", "onCollapse", "onClose", "onBack"];
16
16
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
18
  /**
@@ -31,8 +31,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
31
31
  * <Panel
32
32
  * title="Panel Title"
33
33
  * icon={CoreIcons.info}
34
- * iconBg="bg-blue-500"
35
- * iconColor="text-white"
36
34
  * actions={<button>Action</button>}
37
35
  * expandable
38
36
  * collapsable
@@ -60,9 +58,6 @@ var Panel = function Panel(_ref) {
60
58
  title = _ref.title,
61
59
  actions = _ref.actions,
62
60
  icon = _ref.icon,
63
- iconBg = _ref.iconBg,
64
- iconColor = _ref.iconColor,
65
- rtlFlip = _ref.rtlFlip,
66
61
  panelId = _ref.panelId,
67
62
  height = _ref.height,
68
63
  width = _ref.width,
@@ -121,13 +116,9 @@ var Panel = function Panel(_ref) {
121
116
  className: classNames("fabric-panelAction", "cursor-pointer"),
122
117
  icon: CoreIcons.chevronLeft,
123
118
  onClick: onBack
124
- }), icon && /*#__PURE__*/jsx(Icon, {
125
- icon: icon,
126
- bg: iconBg,
127
- color: iconColor,
128
- rtlFlip: rtlFlip,
119
+ }), icon && /*#__PURE__*/jsx(Icon, _objectSpread({
129
120
  className: "p-2 text-md select-none pointer-events-none"
130
- }), /*#__PURE__*/jsx("div", {
121
+ }, getIconProps(icon))), /*#__PURE__*/jsx("div", {
131
122
  className: classNames(titleClassName, "flex-1 select-none truncate", title && "py-1 first:px-2"),
132
123
  children: title
133
124
  }), /*#__PURE__*/jsx("div", {
@@ -13,11 +13,11 @@ import { jsx, jsxs } from 'react/jsx-runtime';
13
13
  import '../../hotkeys/HotKeyWrapper.js';
14
14
  import { Tooltip } from '../../overlays/tooltip/Tooltip.js';
15
15
  import { getBadgeProps, Badge } from '../badge/Badge.js';
16
- import { Icon } from '../icon/Icon.js';
16
+ import { Icon, getIconProps } from '../icon/Icon.js';
17
17
  import '../../types/icons.js';
18
18
  import { DropdownTool } from '../dropdown/DropdownTool.js';
19
19
 
20
- var _excluded = ["ref", "as", "id", "className", "label", "icon", "iconBg", "iconColor", "rtlFlip", "badge", "disabled", "onClose", "active", "onClick", "tabFlex", "color", "actions", "tooltip", "activeClassName"];
20
+ var _excluded = ["ref", "as", "id", "className", "label", "icon", "badge", "disabled", "onClose", "active", "onClick", "tabFlex", "color", "actions", "tooltip", "activeClassName"];
21
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
23
  /**
@@ -34,8 +34,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
34
34
  * id="tab1"
35
35
  * label="Tab 1"
36
36
  * icon="home"
37
- * iconBg="bg-blue-500"
38
- * iconColor="text-white"
39
37
  * badge="New"
40
38
  * onClick={(id) => console.log(`Tab clicked: ${id}`)}
41
39
  * onClose={() => console.log("Tab closed")}
@@ -58,9 +56,6 @@ var Tab = function Tab(_ref) {
58
56
  className = _ref.className,
59
57
  label = _ref.label,
60
58
  icon = _ref.icon,
61
- iconBg = _ref.iconBg,
62
- iconColor = _ref.iconColor,
63
- rtlFlip = _ref.rtlFlip,
64
59
  badge = _ref.badge,
65
60
  disabled = _ref.disabled,
66
61
  onClose = _ref.onClose,
@@ -98,13 +93,9 @@ var Tab = function Tab(_ref) {
98
93
  },
99
94
  ref: ref
100
95
  }, aria), {}, {
101
- children: [icon && /*#__PURE__*/jsx(Icon, {
102
- icon: icon,
103
- bg: iconBg,
104
- color: iconColor,
105
- rtlFlip: rtlFlip,
96
+ children: [icon && /*#__PURE__*/jsx(Icon, _objectSpread({
106
97
  className: "flex-content p-2"
107
- }), !minimal && /*#__PURE__*/jsx("label", {
98
+ }, getIconProps(icon))), !minimal && /*#__PURE__*/jsx("label", {
108
99
  className: "flex-initial truncate text-center px-1 py-1",
109
100
  children: label
110
101
  }), badge && /*#__PURE__*/jsx(Badge, _objectSpread(_objectSpread({}, badgeProps), {}, {
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import classNames from 'classnames';
6
6
  import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
7
7
  import { Loading } from '../../components/animations/Animations.js';
8
- import { Icon } from '../../components/icon/Icon.js';
8
+ import { Icon, getIconProps } from '../../components/icon/Icon.js';
9
9
  import { useLayoutEffectDebugger } from '../../hooks/useEffectDebugger.js';
10
10
  import { usePropToggle } from '../../hooks/usePropToggle.js';
11
11
  import { useResize } from '../../hooks/useResize.js';
@@ -28,8 +28,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
28
28
  * <Aside
29
29
  * title="Sidebar Title"
30
30
  * icon={CoreIcons.menu}
31
- * iconBg="bg-gray-200"
32
- * iconColor="text-gray-800"
33
31
  * rtlFlip={true}
34
32
  * className="custom-aside"
35
33
  * bodyClassName="custom-aside-body"
@@ -59,9 +57,6 @@ var Aside = function Aside(_ref) {
59
57
  var children = _ref.children,
60
58
  title = _ref.title,
61
59
  icon = _ref.icon,
62
- iconBg = _ref.iconBg,
63
- iconColor = _ref.iconColor,
64
- rtlFlip = _ref.rtlFlip,
65
60
  className = _ref.className,
66
61
  bodyClassName = _ref.bodyClassName,
67
62
  headerClassName = _ref.headerClassName,
@@ -160,13 +155,9 @@ var Aside = function Aside(_ref) {
160
155
  rtlFlip: true,
161
156
  onClick: toggleCollapse,
162
157
  "data-ref": "asideToggle"
163
- }), icon && /*#__PURE__*/jsx(Icon, {
164
- icon: icon,
165
- bg: iconBg,
166
- color: iconColor,
167
- rtlFlip: rtlFlip,
158
+ }), icon && /*#__PURE__*/jsx(Icon, _objectSpread({
168
159
  className: classNames("fabric-asideIcon", "p-1 text-lg select-none pointer-events-none")
169
- }), actions && /*#__PURE__*/jsx("div", {
160
+ }, getIconProps(icon))), actions && /*#__PURE__*/jsx("div", {
170
161
  className: "fabric-asideActions",
171
162
  children: actions
172
163
  })]
@@ -50,7 +50,8 @@ var HeadFoot = function HeadFoot(_ref) {
50
50
  var Header = function Header(props) {
51
51
  return /*#__PURE__*/jsx(HeadFoot, _objectSpread({
52
52
  as: "header",
53
- area: "head"
53
+ area: "head",
54
+ "data-ref": "header"
54
55
  }, props));
55
56
  };
56
57
 
@@ -78,7 +79,8 @@ var Header = function Header(props) {
78
79
  var Footer = function Footer(props) {
79
80
  return /*#__PURE__*/jsx(HeadFoot, _objectSpread({
80
81
  as: "footer",
81
- area: "foot"
82
+ area: "foot",
83
+ "data-ref": "footer"
82
84
  }, props));
83
85
  };
84
86
 
@@ -4,10 +4,10 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
5
  import classNames from 'classnames';
6
6
  import { Loading } from '../../components/animations/Animations.js';
7
- import { Icon } from '../../components/icon/Icon.js';
7
+ import { Icon, getIconProps } from '../../components/icon/Icon.js';
8
8
  import { jsxs, jsx } from 'react/jsx-runtime';
9
9
 
10
- var _excluded = ["ref", "children", "paper", "title", "titleClassName", "icon", "rtlFlip", "iconBg", "iconColor", "loading", "data-testid", "data-test-value"];
10
+ var _excluded = ["ref", "children", "paper", "title", "titleClassName", "icon", "loading", "data-testid", "data-test-value"];
11
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
13
  /**
@@ -24,8 +24,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
24
24
  * <Page
25
25
  * title="My Page"
26
26
  * icon="home"
27
- * iconBg="bg-blue-500"
28
- * iconColor="text-white"
29
27
  * loading={false}
30
28
  * paper={true}
31
29
  * data-testid="my-page"
@@ -45,9 +43,6 @@ var Page = function Page(_ref) {
45
43
  title = _ref.title,
46
44
  titleClassName = _ref.titleClassName,
47
45
  icon = _ref.icon,
48
- rtlFlip = _ref.rtlFlip,
49
- iconBg = _ref.iconBg,
50
- iconColor = _ref.iconColor,
51
46
  loading = _ref.loading,
52
47
  testId = _ref["data-testid"],
53
48
  testValue = _ref["data-test-value"],
@@ -62,13 +57,9 @@ var Page = function Page(_ref) {
62
57
  children: [title && /*#__PURE__*/jsxs("div", {
63
58
  "data-ref": "pageTitle",
64
59
  className: classNames("fabric-pageTitle", "select-none flex gap-1 items-center justify-center px-1 py-0.5 font-medium text-center", titleClassName),
65
- children: [icon && /*#__PURE__*/jsx(Icon, {
66
- icon: icon,
67
- size: "1.25em",
68
- rtlFlip: rtlFlip,
69
- bg: iconBg,
70
- color: iconColor
71
- }), title]
60
+ children: [icon && /*#__PURE__*/jsx(Icon, _objectSpread({
61
+ size: "1.25em"
62
+ }, getIconProps(icon))), title]
72
63
  }), loading && /*#__PURE__*/jsx(Loading, {}), children]
73
64
  }));
74
65
  };
package/dist/esm/index.js CHANGED
@@ -20,7 +20,7 @@ export { Divider } from './components/divider/Divider.js';
20
20
  export { Dropdown, DropdownDismiss } from './components/dropdown/Dropdown.js';
21
21
  export { DropdownTool } from './components/dropdown/DropdownTool.js';
22
22
  export { EmptyContent } from './components/empty/EmptyContent.js';
23
- export { Icon } from './components/icon/Icon.js';
23
+ export { Icon, getIconProps } from './components/icon/Icon.js';
24
24
  export { Image, Video } from './components/media/Media.js';
25
25
  export { ContextMenu } from './components/menu/ContextMenu.js';
26
26
  export { Menu } from './components/menu/Menu.js';
@@ -23,6 +23,7 @@ var Alert = function Alert(_ref) {
23
23
  _ref$color = _ref.color,
24
24
  color = _ref$color === void 0 ? "primary" : _ref$color,
25
25
  icon = _ref.icon,
26
+ iconSrc = _ref.iconSrc,
26
27
  rtlFlip = _ref.rtlFlip,
27
28
  actions = _ref.actions,
28
29
  onClose = _ref.onClose,
@@ -57,6 +58,7 @@ var Alert = function Alert(_ref) {
57
58
  var iconType = useMemo(function () {
58
59
  if (icon) return /*#__PURE__*/jsx(Icon, {
59
60
  icon: icon,
61
+ iconSrc: iconSrc,
60
62
  size: "md",
61
63
  rtlFlip: rtlFlip,
62
64
  color: "".concat(color, "-600")
@@ -83,7 +85,7 @@ var Alert = function Alert(_ref) {
83
85
  color: "".concat(color, "-600")
84
86
  });
85
87
  }
86
- }, [color, type, icon]);
88
+ }, [color, type, icon, iconSrc, rtlFlip]);
87
89
  var handleClose = useCallback(function (ret) {
88
90
  refs.floating.current && (refs.floating.current.dataset.show = "false");
89
91
  setTimeout(function () {
@@ -7,21 +7,18 @@ import { isString } from '@react-fabric/utilities';
7
7
  import classNames from 'classnames';
8
8
  import { useCallback, useEffect, isValidElement } from 'react';
9
9
  import { Loading } from '../../components/animations/Animations.js';
10
- import { Icon } from '../../components/icon/Icon.js';
10
+ import { Icon, getIconProps } from '../../components/icon/Icon.js';
11
11
  import { Header } from '../../core/headfoot/HeadFoot.js';
12
12
  import { HotKeyWrapper } from '../../hotkeys/HotKeyWrapper.js';
13
13
  import { CoreIcons } from '../../types/icons.js';
14
14
  import { jsxs, jsx } from 'react/jsx-runtime';
15
15
 
16
- var _excluded = ["icon", "iconBg", "iconColor", "iconClassName", "rtlFlip", "title", "actions", "closeOnClick", "headerClassName", "onClose", "onBeforeClose", "children", "loading", "size", "width", "minWidth", "root", "hideMask", "align"];
16
+ var _excluded = ["icon", "iconClassName", "title", "actions", "closeOnClick", "headerClassName", "onClose", "onBeforeClose", "children", "loading", "size", "width", "minWidth", "root", "hideMask", "align"];
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  var Flyout = function Flyout(_ref) {
20
20
  var icon = _ref.icon,
21
- iconBg = _ref.iconBg,
22
- iconColor = _ref.iconColor,
23
21
  iconClassName = _ref.iconClassName,
24
- rtlFlip = _ref.rtlFlip,
25
22
  title = _ref.title,
26
23
  actions = _ref.actions,
27
24
  closeOnClick = _ref.closeOnClick,
@@ -111,13 +108,9 @@ var Flyout = function Flyout(_ref) {
111
108
  flex: true,
112
109
  align: "center",
113
110
  className: classNames("fabric-flyoutHeader", headerClassName),
114
- children: [isString(icon) && /*#__PURE__*/jsx(Icon, {
115
- icon: icon,
116
- bg: iconBg,
117
- color: iconColor,
118
- className: classNames(iconClassName, "p-1"),
119
- rtlFlip: rtlFlip
120
- }), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
111
+ children: [isString(icon) && /*#__PURE__*/jsx(Icon, _objectSpread({
112
+ className: classNames(iconClassName, "p-1")
113
+ }, getIconProps(icon))), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
121
114
  className: "flex-1 truncate py-2 px-1",
122
115
  children: title
123
116
  }), actions, /*#__PURE__*/jsx(Icon, {
@@ -35,6 +35,7 @@ var Message = function Message(_ref) {
35
35
  message = _ref.message,
36
36
  color = _ref.color,
37
37
  icon = _ref.icon,
38
+ iconSrc = _ref.iconSrc,
38
39
  rtlFlip = _ref.rtlFlip,
39
40
  actions = _ref.actions,
40
41
  onClose = _ref.onClose;
@@ -59,6 +60,7 @@ var Message = function Message(_ref) {
59
60
  ref: elRef,
60
61
  children: [icon && /*#__PURE__*/jsx(Icon, {
61
62
  icon: icon,
63
+ iconSrc: iconSrc,
62
64
  size: "md",
63
65
  rtlFlip: rtlFlip
64
66
  }), title && /*#__PURE__*/jsx("div", {
@@ -7,21 +7,18 @@ import { isString } from '@react-fabric/utilities';
7
7
  import classNames from 'classnames';
8
8
  import { useCallback, useEffect, isValidElement } from 'react';
9
9
  import { Loading } from '../../components/animations/Animations.js';
10
- import { Icon } from '../../components/icon/Icon.js';
10
+ import { Icon, getIconProps } from '../../components/icon/Icon.js';
11
11
  import { Header } from '../../core/headfoot/HeadFoot.js';
12
12
  import { HotKeyWrapper } from '../../hotkeys/HotKeyWrapper.js';
13
13
  import { CoreIcons } from '../../types/icons.js';
14
14
  import { jsx, jsxs } from 'react/jsx-runtime';
15
15
 
16
- var _excluded = ["icon", "iconBg", "iconColor", "iconClassName", "rtlFlip", "title", "actions", "headerClassName", "onClose", "onBeforeClose", "children", "loading", "root", "size", "hideMask", "width", "height", "minHeight", "minWidth"];
16
+ var _excluded = ["icon", "iconClassName", "title", "actions", "headerClassName", "onClose", "onBeforeClose", "children", "loading", "root", "size", "hideMask", "width", "height", "minHeight", "minWidth"];
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  var Modal = function Modal(_ref) {
20
20
  var icon = _ref.icon,
21
- iconBg = _ref.iconBg,
22
- iconColor = _ref.iconColor,
23
21
  iconClassName = _ref.iconClassName,
24
- rtlFlip = _ref.rtlFlip,
25
22
  title = _ref.title,
26
23
  actions = _ref.actions,
27
24
  headerClassName = _ref.headerClassName,
@@ -103,13 +100,9 @@ var Modal = function Modal(_ref) {
103
100
  flex: true,
104
101
  align: "center",
105
102
  className: classNames("fabric-modalHeader", headerClassName),
106
- children: [isString(icon) && /*#__PURE__*/jsx(Icon, {
107
- icon: icon,
108
- bg: iconBg,
109
- color: iconColor,
110
- className: classNames(iconClassName, "p-1"),
111
- rtlFlip: rtlFlip
112
- }), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
103
+ children: [isString(icon) && /*#__PURE__*/jsx(Icon, _objectSpread({
104
+ className: classNames(iconClassName, "p-1")
105
+ }, getIconProps(icon))), /*#__PURE__*/isValidElement(icon) && icon, /*#__PURE__*/jsx("label", {
113
106
  className: "flex-1 truncate py-2 px-1",
114
107
  children: title
115
108
  }), actions, /*#__PURE__*/jsx(Icon, {