@react-fabric/core 1.0.0-beta.61 → 1.0.0-beta.62

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 (54) hide show
  1. package/css/components/_breadcrumbs.css +2 -0
  2. package/css/components/_button.css +8 -2
  3. package/css/components/_modal.css +2 -2
  4. package/css/core/_theme.css +1 -1
  5. package/css/reset/_reset.css +6 -2
  6. package/dist/cjs/components/button/Button.js +1 -1
  7. package/dist/cjs/components/dropdown/Dropdown.js +13 -1
  8. package/dist/cjs/components/icon/Icon.js +24 -24
  9. package/dist/cjs/components/menu/Menu.js +4 -3
  10. package/dist/cjs/components/menu/MenuItem.js +1 -1
  11. package/dist/cjs/components/navigator/Navigator.js +2 -2
  12. package/dist/cjs/components/tabpanel/TabPanel.js +3 -2
  13. package/dist/cjs/core/theme/ThemeProvider.js +3 -2
  14. package/dist/cjs/hooks/useNavigator.js +9 -8
  15. package/dist/cjs/hooks/useOverlayService.js +34 -13
  16. package/dist/cjs/i18n/index.js +4 -4
  17. package/dist/cjs/index.js +1 -0
  18. package/dist/esm/components/button/Button.js +1 -1
  19. package/dist/esm/components/dropdown/Dropdown.js +14 -2
  20. package/dist/esm/components/icon/Icon.js +24 -24
  21. package/dist/esm/components/menu/Menu.js +4 -3
  22. package/dist/esm/components/menu/MenuItem.js +1 -1
  23. package/dist/esm/components/navigator/Navigator.js +2 -2
  24. package/dist/esm/components/tabpanel/TabPanel.js +3 -2
  25. package/dist/esm/core/theme/ThemeProvider.js +3 -2
  26. package/dist/esm/hooks/useNavigator.js +10 -9
  27. package/dist/esm/hooks/useOverlayService.js +35 -14
  28. package/dist/esm/i18n/index.js +2 -2
  29. package/dist/esm/index.js +1 -1
  30. package/dist/types/components/index.d.ts +2 -2
  31. package/dist/types/components/menu/types.d.ts +6 -1
  32. package/dist/types/components/navigator/Navigator.d.ts +6 -0
  33. package/dist/types/core/theme/ThemeProvider.d.ts +2 -2
  34. package/dist/types/hooks/useOverlayService.d.ts +3 -5
  35. package/package.json +3 -3
  36. package/src/components/button/Button.tsx +3 -1
  37. package/src/components/dropdown/Dropdown.tsx +23 -6
  38. package/src/components/icon/Icon.tsx +22 -22
  39. package/src/components/index.ts +4 -3
  40. package/src/components/menu/Menu.tsx +3 -2
  41. package/src/components/menu/MenuItem.tsx +1 -1
  42. package/src/components/menu/types.ts +6 -1
  43. package/src/components/navigator/Navigator.tsx +9 -2
  44. package/src/components/tabpanel/TabPanel.tsx +2 -1
  45. package/src/core/theme/ThemeProvider.tsx +4 -2
  46. package/src/hooks/useNavigator.tsx +10 -11
  47. package/src/hooks/useOverlayService.tsx +29 -16
  48. package/src/i18n/index.ts +2 -2
  49. /package/dist/cjs/i18n/{ar.json.js → ar/core.json.js} +0 -0
  50. /package/dist/cjs/i18n/{en.json.js → en/core.json.js} +0 -0
  51. /package/dist/esm/i18n/{ar.json.js → ar/core.json.js} +0 -0
  52. /package/dist/esm/i18n/{en.json.js → en/core.json.js} +0 -0
  53. /package/src/i18n/{ar.json → ar/core.json} +0 -0
  54. /package/src/i18n/{en.json → en/core.json} +0 -0
@@ -54,6 +54,8 @@
54
54
 
55
55
  .fabric-breadcrumbs[data-variant="classic"] {
56
56
  & > .fabric-breadcrumbLink {
57
+ display: flex;
58
+ align-items: center;
57
59
  list-style: none;
58
60
 
59
61
  &::after {
@@ -23,7 +23,8 @@
23
23
 
24
24
  @layer components {
25
25
  .fabric-buttonWrapper {
26
- --color: var(--color-tint-700);
26
+ --color: var(--color-tint-600);
27
+ --color-muted: var(--color-tint-300);
27
28
 
28
29
  font-size: 1rem;
29
30
  border-radius: var(--rounding);
@@ -99,6 +100,11 @@
99
100
  flex: 0 1 1em;
100
101
  }
101
102
  }
103
+
104
+ [data-color-scheme="dark"] .fabric-buttonWrapper {
105
+ --color: var(--color-tint-500);
106
+ --color-muted: var(--color-tint-200);
107
+ }
102
108
  }
103
109
 
104
110
  @layer utilities {
@@ -157,7 +163,7 @@
157
163
  }
158
164
 
159
165
  &[data-color="muted"] {
160
- --color: var(--color-tint-300);
166
+ --color: var(--color-muted);
161
167
  }
162
168
 
163
169
  &[data-variant="outline"] {
@@ -26,8 +26,8 @@
26
26
  z-index: var(--z-overlay);
27
27
 
28
28
  width: 32rem;
29
- max-width: 100%;
30
- max-height: 100%;
29
+ max-width: calc(100vw - 8rem);
30
+ max-height: calc(100vh - 8rem);
31
31
  margin-top: -100%;
32
32
 
33
33
  opacity: 0;
@@ -24,7 +24,7 @@
24
24
  @layer components {
25
25
  .fabric-themeProvider {
26
26
  & > * {
27
- background-color: var(--bg-color-base);
27
+ background-color: var(--bg-color-content);
28
28
  }
29
29
  }
30
30
  }
@@ -78,6 +78,10 @@
78
78
  border-color: color-mix(in oklab, var(--fabric-bg) 65%, var(--color-tint));
79
79
  }
80
80
 
81
+ [class*="shadow"] {
82
+ --tw-shadow-color: var(--fabric-shadow);
83
+ }
84
+
81
85
  [class*="ring"] {
82
86
  --tw-ring-color: color-mix(
83
87
  in oklab,
@@ -223,7 +227,7 @@
223
227
  unicode-bidi: plaintext;
224
228
  }
225
229
 
226
- [dir="rtl"] {
230
+ [dir="rtl"] :not:where(:dir(ltr), [dir="ltr"]) {
227
231
  p,
228
232
  pre,
229
233
  h1,
@@ -233,7 +237,7 @@
233
237
  h5,
234
238
  h6,
235
239
  .mixed-lang {
236
- text-align: start;
240
+ text-align: right;
237
241
  }
238
242
  }
239
243
  }
@@ -142,7 +142,7 @@ var Button = function Button(_ref) {
142
142
  "data-size": size,
143
143
  "data-loading": busy || loading,
144
144
  "data-disabled": disabled,
145
- children: [hotKey && /*#__PURE__*/jsxRuntime.jsx(HotKey.HotKey, {
145
+ children: [!disabled && hotKey && /*#__PURE__*/jsxRuntime.jsx(HotKey.HotKey, {
146
146
  keyCombo: hotKey,
147
147
  handler: hotKeyHandler.current
148
148
  }), /*#__PURE__*/jsxRuntime.jsx(TooltipWrapper, _objectSpread(_objectSpread({}, tooltipProps), {}, {
@@ -32,6 +32,7 @@ var DropdownElement = function DropdownElement(_ref) {
32
32
  isOpen = _useState2[0],
33
33
  setIsOpen = _useState2[1];
34
34
  var tree = react.useFloatingTree();
35
+ var nodeId = react.useFloatingNodeId();
35
36
  var _useMemo = react$1.useMemo(function () {
36
37
  return react$1.Children.toArray(children);
37
38
  }, [children]),
@@ -39,6 +40,7 @@ var DropdownElement = function DropdownElement(_ref) {
39
40
  anchor = _useMemo2[0],
40
41
  panel = _useMemo2[1];
41
42
  var _useFloating = react.useFloating({
43
+ nodeId: "dropdown-".concat(nodeId),
42
44
  open: isOpen,
43
45
  onOpenChange: function onOpenChange(open, _, reason) {
44
46
  var _ref2;
@@ -80,6 +82,10 @@ var DropdownElement = function DropdownElement(_ref) {
80
82
  }
81
83
  return undefined;
82
84
  }, [refs, isOpen, fitToParent]);
85
+ var dismissDropdown = react$1.useCallback(function () {
86
+ setIsOpen(false);
87
+ onClose === null || onClose === void 0 || onClose();
88
+ }, []);
83
89
  var tryClosing = react$1.useCallback(function (e) {
84
90
  var _refs$floating$curren, _refs$floating$curren2;
85
91
  if (!((_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 && _refs$floating$curren.contains(e.target.closest("[data-dropdown-dismiss='false']"))) && (!!closeOnClick || (_refs$floating$curren2 = refs.floating.current) !== null && _refs$floating$curren2 !== void 0 && _refs$floating$curren2.contains(e.target.closest("[data-dropdown-dismiss='true']")))) {
@@ -139,7 +145,9 @@ var DropdownElement = function DropdownElement(_ref) {
139
145
  role: "none",
140
146
  className: classNames("fabric-dropdownBody", dropdownClassName, !plainDropdown && "shadow-lg bg-base ring-1 ring-tint-100", "rounded-capped overflow-auto scroll-thin grid max-h-[70vh]"),
141
147
  onMouseUpCapture: tryClosing,
142
- children: panel
148
+ children: /*#__PURE__*/react$1.cloneElement(panel, {
149
+ dismiss: dismissDropdown
150
+ })
143
151
  }), showArrow && /*#__PURE__*/jsxRuntime.jsx(react.FloatingArrow, {
144
152
  ref: arrowRef,
145
153
  context: context,
@@ -184,6 +192,10 @@ var DropdownElement = function DropdownElement(_ref) {
184
192
  * @see {@link https://floating-ui.com/docs/react} for more details on Floating UI.
185
193
  */
186
194
  var Dropdown = function Dropdown(props) {
195
+ var tree = react.useFloatingTree();
196
+ if (tree) {
197
+ return /*#__PURE__*/jsxRuntime.jsx(DropdownElement, _objectSpread({}, props));
198
+ }
187
199
  return /*#__PURE__*/jsxRuntime.jsx(react.FloatingTree, {
188
200
  children: /*#__PURE__*/jsxRuntime.jsx(DropdownElement, _objectSpread({}, props))
189
201
  });
@@ -114,31 +114,31 @@ var Icon = function Icon(_ref) {
114
114
  /** ***************** render icon *******************/
115
115
  var iconEl = react.useMemo(function () {
116
116
  if ( /*#__PURE__*/react.isValidElement(icon)) return icon;
117
- if (!utilities.isString(icon)) {
118
- throw Error("Invalid icon expected string");
117
+ if (utilities.isString(icon)) {
118
+ return isSvg ? /*#__PURE__*/jsxRuntime.jsx("svg", {
119
+ viewBox: viewBox,
120
+ children: /*#__PURE__*/jsxRuntime.jsx("path", {
121
+ fill: "currentColor",
122
+ d: icon.toString()
123
+ })
124
+ }) : (icon === null || icon === void 0 ? void 0 : icon.toString().length) <= 4 ? /*#__PURE__*/jsxRuntime.jsx("svg", {
125
+ role: "img",
126
+ children: /*#__PURE__*/jsxRuntime.jsx("text", {
127
+ x: "50%",
128
+ y: "50%",
129
+ dy: ".1em",
130
+ dominantBaseline: "middle",
131
+ textAnchor: "middle",
132
+ style: {
133
+ fontSize: SvgTextSize[icon.length]
134
+ },
135
+ children: icon
136
+ })
137
+ }) : /*#__PURE__*/jsxRuntime.jsx("i", {
138
+ className: "".concat(icon)
139
+ });
119
140
  }
120
- return isSvg ? /*#__PURE__*/jsxRuntime.jsx("svg", {
121
- viewBox: viewBox,
122
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
123
- fill: "currentColor",
124
- d: icon.toString()
125
- })
126
- }) : (icon === null || icon === void 0 ? void 0 : icon.toString().length) <= 4 ? /*#__PURE__*/jsxRuntime.jsx("svg", {
127
- role: "img",
128
- children: /*#__PURE__*/jsxRuntime.jsx("text", {
129
- x: "50%",
130
- y: "50%",
131
- dy: ".1em",
132
- dominantBaseline: "middle",
133
- textAnchor: "middle",
134
- style: {
135
- fontSize: SvgTextSize[icon.length]
136
- },
137
- children: icon
138
- })
139
- }) : /*#__PURE__*/jsxRuntime.jsx("i", {
140
- className: "".concat(icon)
141
- });
141
+ throw Error("Invalid icon expected string");
142
142
  }, [icon, isSvg, viewBox]);
143
143
  return /*#__PURE__*/jsxRuntime.jsxs("dfn", _objectSpread(_objectSpread({
144
144
  "data-ref": "icon",
@@ -13,7 +13,7 @@ var nodeCheck = require('../../utils/nodeCheck.js');
13
13
  var MenuItem = require('./MenuItem.js');
14
14
  var jsxRuntime = require('react/jsx-runtime');
15
15
 
16
- var _excluded = ["children", "minimal", "menuClassName", "onClick", "trigger", "ref"];
16
+ var _excluded = ["children", "minimal", "menuClassName", "onClick", "trigger", "ref", "forDropdown"];
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
  // FIXME: refactor menu implementation to differentiate between static and floating menus, implement context wrapper for each menu level
@@ -27,6 +27,7 @@ var MenuComponent = function MenuComponent(_ref) {
27
27
  _ref$trigger = _ref.trigger,
28
28
  trigger = _ref$trigger === void 0 ? "hover" : _ref$trigger,
29
29
  ref = _ref.ref,
30
+ forDropdown = _ref.forDropdown,
30
31
  rest = _objectWithoutProperties(_ref, _excluded);
31
32
  var _useState = react$1.useState(false),
32
33
  _useState2 = _slicedToArray(_useState, 2),
@@ -41,9 +42,9 @@ var MenuComponent = function MenuComponent(_ref) {
41
42
  var tree = react.useFloatingTree();
42
43
  var nodeId = react.useFloatingNodeId();
43
44
  var parentId = react.useFloatingParentNodeId();
44
- var isNested = parentId !== null;
45
+ var isNested = parentId !== null && !forDropdown;
45
46
  var _useFloating = react.useFloating({
46
- nodeId: nodeId,
47
+ nodeId: "menu-".concat(nodeId),
47
48
  open: !isNested || isOpen,
48
49
  onOpenChange: function onOpenChange(open, event, reason) {
49
50
  isNested && setIsOpen(open);
@@ -132,7 +132,7 @@ var MenuItem = function MenuItem(_ref) {
132
132
  (_onClick === null || _onClick === void 0 ? void 0 : _onClick(e)) !== false && (tree === null || tree === void 0 ? void 0 : tree.events.emit("click"));
133
133
  }
134
134
  }, minimal ? {} : aria), {}, {
135
- children: [hotKey && /*#__PURE__*/jsxRuntime.jsx(HotKey.HotKey, {
135
+ children: [!disabled && hotKey && /*#__PURE__*/jsxRuntime.jsx(HotKey.HotKey, {
136
136
  keyCombo: hotKey,
137
137
  handler: function handler() {
138
138
  var _elRef$current2, _elRef$current2$click;
@@ -2,11 +2,11 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var utilities = require('@react-fabric/utilities');
5
6
  var classNames = require('classnames');
6
7
  var react = require('react');
7
8
  var HotKey = require('../../hotkeys/HotKey.js');
8
9
  var Icon = require('../icon/Icon.js');
9
- var utilities = require('@react-fabric/utilities');
10
10
  var jsxRuntime = require('react/jsx-runtime');
11
11
 
12
12
  var _excluded = ["className", "onNavigate", "color", "children", "length", "current", "disableKeyHandlers"];
@@ -45,7 +45,7 @@ var Navigator = function Navigator(_ref) {
45
45
  aria = _objectWithoutProperties(_ref, _excluded);
46
46
  var navPrev = react.useCallback(function () {
47
47
  return (utilities.isEmpty(current) || current !== 0) && onNavigate(-1);
48
- }, [onNavigate, current]);
48
+ }, [onNavigate, current, length]);
49
49
  var navNext = react.useCallback(function () {
50
50
  return (utilities.isEmpty(current) || current + 1 < (length !== null && length !== void 0 ? length : 0)) && onNavigate(+1);
51
51
  }, [onNavigate, current, length]);
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var utilities = require('@react-fabric/utilities');
4
5
  var classNames = require('classnames');
5
6
  var react = require('react');
6
7
  var jsxRuntime = require('react/jsx-runtime');
7
- require('@react-fabric/utilities');
8
8
  var nodeCheck = require('../../utils/nodeCheck.js');
9
9
  var Tab = require('./Tab.js');
10
10
 
@@ -73,7 +73,8 @@ var TabPanel = function TabPanel(_ref) {
73
73
  tabs = _useMemo2[0],
74
74
  rest = _useMemo2[1];
75
75
  react.useEffect(function () {
76
- setActive(activeTab);
76
+ var _tabs$;
77
+ setActive(utilities.getValue(activeTab !== null && activeTab !== void 0 ? activeTab : (_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.props.id));
77
78
  }, [activeTab]);
78
79
  var activeTabPanel = react.useMemo(function () {
79
80
  var _tabs$find;
@@ -59,7 +59,8 @@ var ThemeProvider = function ThemeProvider(_ref) {
59
59
  accentColor = _ref.accentColor,
60
60
  tintColor = _ref.tintColor,
61
61
  colorScheme = _ref.colorScheme,
62
- rounding = _ref.rounding;
62
+ rounding = _ref.rounding,
63
+ className = _ref.className;
63
64
  var _useApplicationContex = Global.useApplicationContext(),
64
65
  currentColorScheme = _useApplicationContex.currentColorScheme;
65
66
  var styles = react.useMemo(function () {
@@ -88,7 +89,7 @@ var ThemeProvider = function ThemeProvider(_ref) {
88
89
  style: styles,
89
90
  "data-color-scheme": colorScheme !== null && colorScheme !== void 0 ? colorScheme : currentColorScheme,
90
91
  "data-rounding": rounding,
91
- className: classNames("fabric-themeProvider", "contents theme-base", branding),
92
+ className: classNames("fabric-themeProvider", "contents theme-base", branding, className),
92
93
  children: children
93
94
  });
94
95
  };
@@ -11,15 +11,16 @@ var useNavigator = function useNavigator() {
11
11
  _useState2 = _slicedToArray(_useState, 2),
12
12
  currentIndex = _useState2[0],
13
13
  setCurrentIndex = _useState2[1];
14
- var refCurrent = react.useRef(defaultIndex);
15
14
  var onNavigate = react.useCallback(function (dir) {
16
- if (dir === -1) {
17
- refCurrent.current = refCurrent.current > 0 ? refCurrent.current - 1 : totalCount - 1;
18
- }
19
- if (dir === 1) {
20
- refCurrent.current = refCurrent.current + 1 < totalCount ? refCurrent.current + 1 : 0;
21
- }
22
- setCurrentIndex(refCurrent.current);
15
+ setCurrentIndex(function (prevValue) {
16
+ if (dir === -1) {
17
+ return prevValue > 0 ? prevValue - 1 : totalCount - 1;
18
+ }
19
+ if (dir === 1) {
20
+ return prevValue + 1 < totalCount ? prevValue + 1 : 0;
21
+ }
22
+ return prevValue;
23
+ });
23
24
  }, [totalCount]);
24
25
  var headLabel = react.useMemo(function () {
25
26
  return /*#__PURE__*/jsxRuntime.jsxs("span", {
@@ -11,6 +11,13 @@ var jsxRuntime = require('react/jsx-runtime');
11
11
  var _excluded = ["onClose"];
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
+ // return the blank function since state functionality will execute if the value is function
15
+ var EMPTY_FC = function EMPTY_FC() {
16
+ return function () {
17
+ return null;
18
+ };
19
+ };
20
+
14
21
  /**
15
22
  * Hook to manage overlay components like modals or flyouts.
16
23
  * It provides a way to open an overlay with specified properties and handle its closure.
@@ -21,7 +28,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
21
28
  * of the overlay when it is closed, allowing you to handle the result in a controlled manner.
22
29
  *
23
30
  * @param ModalOrFlyout - The component to be used as an overlay.
24
- * @returns An array containing the current overlay and a function to open it.
31
+ * @param toggleOpen - If true, calling `openOverlay` while an overlay is already open will close the existing one instead of opening a new one.
32
+ * @returns An array containing the current overlay, a function to open it, and a boolean indicating if the overlay is open.
25
33
  *
26
34
  * @example
27
35
  * ```jsx
@@ -36,34 +44,47 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
36
44
  * ```
37
45
  */
38
46
  var useOverlayService = function useOverlayService(ModalOrFlyout) {
39
- var _useState = react.useState(null),
47
+ var _useState = react.useState(EMPTY_FC),
40
48
  _useState2 = _slicedToArray(_useState, 2),
41
49
  Overlay = _useState2[0],
42
50
  setOverlay = _useState2[1];
51
+ var existingOpenPromise = react.useRef(null);
43
52
  var openOverlay = /*#__PURE__*/function () {
44
53
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
45
54
  var _ref2,
46
55
  onClose,
47
- props,
56
+ outerProps,
48
57
  _args = arguments;
49
58
  return _regeneratorRuntime.wrap(function _callee$(_context) {
50
59
  while (1) switch (_context.prev = _context.next) {
51
60
  case 0:
52
- _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, onClose = _ref2.onClose, props = _objectWithoutProperties(_ref2, _excluded);
53
- _context.next = 3;
61
+ _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, onClose = _ref2.onClose, outerProps = _objectWithoutProperties(_ref2, _excluded);
62
+ if (!existingOpenPromise.current) {
63
+ _context.next = 3;
64
+ break;
65
+ }
66
+ return _context.abrupt("return");
67
+ case 3:
68
+ _context.next = 5;
54
69
  return new Promise(function (resolve) {
55
- var handleClose = function handleClose(args) {
56
- setOverlay(null);
70
+ existingOpenPromise.current = function (args) {
71
+ setOverlay(EMPTY_FC);
57
72
  resolve(args);
58
73
  onClose === null || onClose === void 0 || onClose(args);
74
+ existingOpenPromise.current = null;
59
75
  };
60
- setOverlay( /*#__PURE__*/jsxRuntime.jsx(ModalOrFlyout, _objectSpread(_objectSpread({}, props), {}, {
61
- onClose: handleClose
62
- })));
76
+ // eslint-disable-next-line react/display-name
77
+ setOverlay(function () {
78
+ return function (overrideProps) {
79
+ return /*#__PURE__*/jsxRuntime.jsx(ModalOrFlyout, _objectSpread(_objectSpread(_objectSpread({}, outerProps), overrideProps), {}, {
80
+ onClose: existingOpenPromise.current
81
+ }));
82
+ };
83
+ });
63
84
  });
64
- case 3:
85
+ case 5:
65
86
  return _context.abrupt("return", _context.sent);
66
- case 4:
87
+ case 6:
67
88
  case "end":
68
89
  return _context.stop();
69
90
  }
@@ -73,7 +94,7 @@ var useOverlayService = function useOverlayService(ModalOrFlyout) {
73
94
  return _ref.apply(this, arguments);
74
95
  };
75
96
  }();
76
- return [Overlay, openOverlay];
97
+ return [Overlay, openOverlay, existingOpenPromise.current];
77
98
  };
78
99
 
79
100
  exports.useOverlayService = useOverlayService;
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var i18next = require('i18next');
4
- var ar = require('./ar.json.js');
5
- var en = require('./en.json.js');
4
+ var core$1 = require('./ar/core.json.js');
5
+ var core = require('./en/core.json.js');
6
6
 
7
7
  /*
8
8
  * React Fabric
@@ -48,8 +48,8 @@ var addTranslationBundle = function addTranslationBundle(key, languageBundles) {
48
48
  }
49
49
  };
50
50
  addTranslationBundle("core", {
51
- en: en.default,
52
- ar: ar.default
51
+ en: core.default,
52
+ ar: core$1.default
53
53
  });
54
54
 
55
55
  exports.addTranslationBundle = addTranslationBundle;
package/dist/cjs/index.js CHANGED
@@ -82,6 +82,7 @@ var Global = require('./context/Global.js');
82
82
 
83
83
  exports.ActionLabel = ActionLabel.ActionLabel;
84
84
  exports.AnimationIndicator = Animations.AnimationIndicator;
85
+ exports.AnimationLoader = Animations.AnimationLoader;
85
86
  exports.LoadingBars = Animations.LoadingBars;
86
87
  exports.LoadingLine = Animations.LoadingLine;
87
88
  exports.LoadingSpinner = Animations.LoadingSpinner;
@@ -142,7 +142,7 @@ var Button = function Button(_ref) {
142
142
  "data-size": size,
143
143
  "data-loading": busy || loading,
144
144
  "data-disabled": disabled,
145
- children: [hotKey && /*#__PURE__*/jsx(HotKey, {
145
+ children: [!disabled && hotKey && /*#__PURE__*/jsx(HotKey, {
146
146
  keyCombo: hotKey,
147
147
  handler: hotKeyHandler.current
148
148
  }), /*#__PURE__*/jsx(TooltipWrapper, _objectSpread(_objectSpread({}, tooltipProps), {}, {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
- import { FloatingTree, useFloatingTree, useFloating, autoUpdate, shift, flip, offset, arrow, safePolygon, useDismiss, useInteractions, FloatingPortal, FloatingOverlay, FloatingFocusManager, FloatingArrow, useHover, useClick } from '@floating-ui/react';
5
+ import { useFloatingTree, FloatingTree, useFloatingNodeId, useFloating, autoUpdate, shift, flip, offset, arrow, safePolygon, useDismiss, useInteractions, FloatingPortal, FloatingOverlay, FloatingFocusManager, FloatingArrow, useHover, useClick } from '@floating-ui/react';
6
6
  import { mergeRefs } from '@react-fabric/utilities';
7
7
  import classNames from 'classnames';
8
8
  import { useRef, useState, useMemo, Children, useCallback, useEffect, Fragment, cloneElement } from 'react';
@@ -32,6 +32,7 @@ var DropdownElement = function DropdownElement(_ref) {
32
32
  isOpen = _useState2[0],
33
33
  setIsOpen = _useState2[1];
34
34
  var tree = useFloatingTree();
35
+ var nodeId = useFloatingNodeId();
35
36
  var _useMemo = useMemo(function () {
36
37
  return Children.toArray(children);
37
38
  }, [children]),
@@ -39,6 +40,7 @@ var DropdownElement = function DropdownElement(_ref) {
39
40
  anchor = _useMemo2[0],
40
41
  panel = _useMemo2[1];
41
42
  var _useFloating = useFloating({
43
+ nodeId: "dropdown-".concat(nodeId),
42
44
  open: isOpen,
43
45
  onOpenChange: function onOpenChange(open, _, reason) {
44
46
  var _ref2;
@@ -80,6 +82,10 @@ var DropdownElement = function DropdownElement(_ref) {
80
82
  }
81
83
  return undefined;
82
84
  }, [refs, isOpen, fitToParent]);
85
+ var dismissDropdown = useCallback(function () {
86
+ setIsOpen(false);
87
+ onClose === null || onClose === void 0 || onClose();
88
+ }, []);
83
89
  var tryClosing = useCallback(function (e) {
84
90
  var _refs$floating$curren, _refs$floating$curren2;
85
91
  if (!((_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 && _refs$floating$curren.contains(e.target.closest("[data-dropdown-dismiss='false']"))) && (!!closeOnClick || (_refs$floating$curren2 = refs.floating.current) !== null && _refs$floating$curren2 !== void 0 && _refs$floating$curren2.contains(e.target.closest("[data-dropdown-dismiss='true']")))) {
@@ -139,7 +145,9 @@ var DropdownElement = function DropdownElement(_ref) {
139
145
  role: "none",
140
146
  className: classNames("fabric-dropdownBody", dropdownClassName, !plainDropdown && "shadow-lg bg-base ring-1 ring-tint-100", "rounded-capped overflow-auto scroll-thin grid max-h-[70vh]"),
141
147
  onMouseUpCapture: tryClosing,
142
- children: panel
148
+ children: /*#__PURE__*/cloneElement(panel, {
149
+ dismiss: dismissDropdown
150
+ })
143
151
  }), showArrow && /*#__PURE__*/jsx(FloatingArrow, {
144
152
  ref: arrowRef,
145
153
  context: context,
@@ -184,6 +192,10 @@ var DropdownElement = function DropdownElement(_ref) {
184
192
  * @see {@link https://floating-ui.com/docs/react} for more details on Floating UI.
185
193
  */
186
194
  var Dropdown = function Dropdown(props) {
195
+ var tree = useFloatingTree();
196
+ if (tree) {
197
+ return /*#__PURE__*/jsx(DropdownElement, _objectSpread({}, props));
198
+ }
187
199
  return /*#__PURE__*/jsx(FloatingTree, {
188
200
  children: /*#__PURE__*/jsx(DropdownElement, _objectSpread({}, props))
189
201
  });
@@ -114,31 +114,31 @@ var Icon = function Icon(_ref) {
114
114
  /** ***************** render icon *******************/
115
115
  var iconEl = useMemo(function () {
116
116
  if ( /*#__PURE__*/isValidElement(icon)) return icon;
117
- if (!isString(icon)) {
118
- throw Error("Invalid icon expected string");
117
+ if (isString(icon)) {
118
+ return isSvg ? /*#__PURE__*/jsx("svg", {
119
+ viewBox: viewBox,
120
+ children: /*#__PURE__*/jsx("path", {
121
+ fill: "currentColor",
122
+ d: icon.toString()
123
+ })
124
+ }) : (icon === null || icon === void 0 ? void 0 : icon.toString().length) <= 4 ? /*#__PURE__*/jsx("svg", {
125
+ role: "img",
126
+ children: /*#__PURE__*/jsx("text", {
127
+ x: "50%",
128
+ y: "50%",
129
+ dy: ".1em",
130
+ dominantBaseline: "middle",
131
+ textAnchor: "middle",
132
+ style: {
133
+ fontSize: SvgTextSize[icon.length]
134
+ },
135
+ children: icon
136
+ })
137
+ }) : /*#__PURE__*/jsx("i", {
138
+ className: "".concat(icon)
139
+ });
119
140
  }
120
- return isSvg ? /*#__PURE__*/jsx("svg", {
121
- viewBox: viewBox,
122
- children: /*#__PURE__*/jsx("path", {
123
- fill: "currentColor",
124
- d: icon.toString()
125
- })
126
- }) : (icon === null || icon === void 0 ? void 0 : icon.toString().length) <= 4 ? /*#__PURE__*/jsx("svg", {
127
- role: "img",
128
- children: /*#__PURE__*/jsx("text", {
129
- x: "50%",
130
- y: "50%",
131
- dy: ".1em",
132
- dominantBaseline: "middle",
133
- textAnchor: "middle",
134
- style: {
135
- fontSize: SvgTextSize[icon.length]
136
- },
137
- children: icon
138
- })
139
- }) : /*#__PURE__*/jsx("i", {
140
- className: "".concat(icon)
141
- });
141
+ throw Error("Invalid icon expected string");
142
142
  }, [icon, isSvg, viewBox]);
143
143
  return /*#__PURE__*/jsxs("dfn", _objectSpread(_objectSpread({
144
144
  "data-ref": "icon",
@@ -13,7 +13,7 @@ import { nodeCheck } from '../../utils/nodeCheck.js';
13
13
  import { MenuItem } from './MenuItem.js';
14
14
  import { jsx, jsxs } from 'react/jsx-runtime';
15
15
 
16
- var _excluded = ["children", "minimal", "menuClassName", "onClick", "trigger", "ref"];
16
+ var _excluded = ["children", "minimal", "menuClassName", "onClick", "trigger", "ref", "forDropdown"];
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
  // FIXME: refactor menu implementation to differentiate between static and floating menus, implement context wrapper for each menu level
@@ -27,6 +27,7 @@ var MenuComponent = function MenuComponent(_ref) {
27
27
  _ref$trigger = _ref.trigger,
28
28
  trigger = _ref$trigger === void 0 ? "hover" : _ref$trigger,
29
29
  ref = _ref.ref,
30
+ forDropdown = _ref.forDropdown,
30
31
  rest = _objectWithoutProperties(_ref, _excluded);
31
32
  var _useState = useState(false),
32
33
  _useState2 = _slicedToArray(_useState, 2),
@@ -41,9 +42,9 @@ var MenuComponent = function MenuComponent(_ref) {
41
42
  var tree = useFloatingTree();
42
43
  var nodeId = useFloatingNodeId();
43
44
  var parentId = useFloatingParentNodeId();
44
- var isNested = parentId !== null;
45
+ var isNested = parentId !== null && !forDropdown;
45
46
  var _useFloating = useFloating({
46
- nodeId: nodeId,
47
+ nodeId: "menu-".concat(nodeId),
47
48
  open: !isNested || isOpen,
48
49
  onOpenChange: function onOpenChange(open, event, reason) {
49
50
  isNested && setIsOpen(open);
@@ -132,7 +132,7 @@ var MenuItem = function MenuItem(_ref) {
132
132
  (_onClick === null || _onClick === void 0 ? void 0 : _onClick(e)) !== false && (tree === null || tree === void 0 ? void 0 : tree.events.emit("click"));
133
133
  }
134
134
  }, minimal ? {} : aria), {}, {
135
- children: [hotKey && /*#__PURE__*/jsx(HotKey, {
135
+ children: [!disabled && hotKey && /*#__PURE__*/jsx(HotKey, {
136
136
  keyCombo: hotKey,
137
137
  handler: function handler() {
138
138
  var _elRef$current2, _elRef$current2$click;
@@ -2,11 +2,11 @@
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { isEmpty } from '@react-fabric/utilities';
5
6
  import classNames from 'classnames';
6
7
  import { useCallback } from 'react';
7
8
  import { HotKey } from '../../hotkeys/HotKey.js';
8
9
  import { Icon } from '../icon/Icon.js';
9
- import { isEmpty } from '@react-fabric/utilities';
10
10
  import { jsxs, jsx } from 'react/jsx-runtime';
11
11
 
12
12
  var _excluded = ["className", "onNavigate", "color", "children", "length", "current", "disableKeyHandlers"];
@@ -45,7 +45,7 @@ var Navigator = function Navigator(_ref) {
45
45
  aria = _objectWithoutProperties(_ref, _excluded);
46
46
  var navPrev = useCallback(function () {
47
47
  return (isEmpty(current) || current !== 0) && onNavigate(-1);
48
- }, [onNavigate, current]);
48
+ }, [onNavigate, current, length]);
49
49
  var navNext = useCallback(function () {
50
50
  return (isEmpty(current) || current + 1 < (length !== null && length !== void 0 ? length : 0)) && onNavigate(+1);
51
51
  }, [onNavigate, current, length]);