@atlaskit/editor-toolbar 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-toolbar
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 0.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`36e649e4988d3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/36e649e4988d3) -
14
+ [ux] ED-29072 close all menus on nested menu item clicked
15
+ - Updated dependencies
16
+
3
17
  ## 0.6.0
4
18
 
5
19
  ### Minor Changes
package/dist/cjs/index.js CHANGED
@@ -388,6 +388,12 @@ Object.defineProperty(exports, "ToolbarDropdownMenu", {
388
388
  return _ToolbarDropdownMenu.ToolbarDropdownMenu;
389
389
  }
390
390
  });
391
+ Object.defineProperty(exports, "ToolbarDropdownMenuProvider", {
392
+ enumerable: true,
393
+ get: function get() {
394
+ return _ToolbarDropdownMenuContext.ToolbarDropdownMenuProvider;
395
+ }
396
+ });
391
397
  Object.defineProperty(exports, "ToolbarKeyboardShortcutHint", {
392
398
  enumerable: true,
393
399
  get: function get() {
@@ -13,6 +13,7 @@ var _css = require("@atlaskit/css");
13
13
  var _dropdownMenu = require("@atlaskit/dropdown-menu");
14
14
  var _compiled = require("@atlaskit/primitives/compiled");
15
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
+ var _ToolbarDropdownMenuContext = require("./ToolbarDropdownMenuContext");
16
17
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
18
  var styles = {
18
19
  toolbarDropdownItem: "_18zrpxbi _1rjcu2gc _1e0c1txw _kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _1ul9163w _1basglpi _1ah31i6y",
@@ -56,8 +57,14 @@ var ToolbarDropdownItem = exports.ToolbarDropdownItem = function ToolbarDropdown
56
57
  href = _ref2.href,
57
58
  target = _ref2.target,
58
59
  rel = _ref2.rel;
60
+ var parentContext = (0, _ToolbarDropdownMenuContext.useToolbarDropdownMenuNew)();
59
61
  return /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
60
- onClick: onClick,
62
+ onClick: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) ? function (e) {
63
+ if (!hasNestedDropdownMenu) {
64
+ parentContext === null || parentContext === void 0 || parentContext.closeMenu();
65
+ }
66
+ onClick === null || onClick === void 0 || onClick(e);
67
+ } : onClick,
61
68
  elemBefore: elemBefore,
62
69
  elemAfter: elemAfter,
63
70
  isSelected: isSelected,
@@ -31,23 +31,20 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
31
31
  label = _ref.label;
32
32
  var _useToolbarUI = (0, _uiContext.useToolbarUI)(),
33
33
  onDropdownOpenChanged = _useToolbarUI.onDropdownOpenChanged;
34
- var _useToolbarDropdownMe = (0, _ToolbarDropdownMenuContext.useToolbarDropdownMenu)(),
35
- closeMenu = _useToolbarDropdownMe.closeMenu,
36
- isOpen = _useToolbarDropdownMe.isOpen,
37
- openMenu = _useToolbarDropdownMe.openMenu;
34
+ var menuContext = (0, _ToolbarDropdownMenuContext.useToolbarDropdownMenu)();
38
35
  var handleOpenChange = (0, _react.useCallback)(function (args) {
39
36
  onDropdownOpenChanged(args);
40
37
  if (!args.isOpen) {
41
- closeMenu();
38
+ menuContext === null || menuContext === void 0 || menuContext.closeMenu();
42
39
  }
43
- }, [closeMenu, onDropdownOpenChanged]);
40
+ }, [menuContext, onDropdownOpenChanged]);
44
41
  var handleClick = (0, _react.useCallback)(function () {
45
- if (!isOpen) {
46
- openMenu();
42
+ if (!(menuContext !== null && menuContext !== void 0 && menuContext.isOpen)) {
43
+ menuContext === null || menuContext === void 0 || menuContext.openMenu();
47
44
  } else {
48
- closeMenu();
45
+ menuContext === null || menuContext === void 0 || menuContext.closeMenu();
49
46
  }
50
- }, [closeMenu, openMenu, isOpen]);
47
+ }, [menuContext]);
51
48
  return /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
52
49
  trigger: function trigger(triggerProps) {
53
50
  return /*#__PURE__*/_react.default.createElement(_ToolbarButton.ToolbarButton, {
@@ -69,7 +66,7 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
69
66
  });
70
67
  },
71
68
  onOpenChange: handleOpenChange,
72
- isOpen: isOpen
69
+ isOpen: menuContext === null || menuContext === void 0 ? void 0 : menuContext.isOpen
73
70
  }, children);
74
71
  };
75
72
  var ToolbarDropdownMenu = exports.ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
@@ -82,12 +79,23 @@ var ToolbarDropdownMenu = exports.ToolbarDropdownMenu = function ToolbarDropdown
82
79
  hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi,
83
80
  _ref2$enableMaxHeight = _ref2.enableMaxHeight,
84
81
  enableMaxHeight = _ref2$enableMaxHeight === void 0 ? false : _ref2$enableMaxHeight;
85
- return /*#__PURE__*/_react.default.createElement(_ToolbarDropdownMenuContext.ToolbarDropdownMenuProvider, null, /*#__PURE__*/_react.default.createElement(ToolbarDropdownMenuContent, {
86
- iconBefore: iconBefore,
87
- isDisabled: isDisabled,
88
- testId: testId,
89
- label: label
90
- }, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
91
- xcss: (0, _react2.cx)(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, (0, _expValEquals.expValEquals)('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
92
- }, children)));
82
+ if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true)) {
83
+ return /*#__PURE__*/_react.default.createElement(ToolbarDropdownMenuContent, {
84
+ iconBefore: iconBefore,
85
+ isDisabled: isDisabled,
86
+ testId: testId,
87
+ label: label
88
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
89
+ xcss: (0, _react2.cx)(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, (0, _expValEquals.expValEquals)('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
90
+ }, children));
91
+ } else {
92
+ return /*#__PURE__*/_react.default.createElement(_ToolbarDropdownMenuContext.ToolbarDropdownMenuProvider, null, /*#__PURE__*/_react.default.createElement(ToolbarDropdownMenuContent, {
93
+ iconBefore: iconBefore,
94
+ isDisabled: isDisabled,
95
+ testId: testId,
96
+ label: label
97
+ }, /*#__PURE__*/_react.default.createElement("div", {
98
+ className: (0, _runtime.ax)([hasSectionMargin && styles.sectionMargin, (0, _expValEquals.expValEquals)('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator])
99
+ }, children)));
100
+ }
93
101
  };
@@ -5,18 +5,26 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.useToolbarDropdownMenu = exports.ToolbarDropdownMenuProvider = void 0;
8
+ exports.useToolbarDropdownMenuOld = exports.useToolbarDropdownMenuNew = exports.useToolbarDropdownMenu = exports.ToolbarDropdownMenuProvider = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
+ var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
12
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
12
14
  var ToolbarDropdownMenuContext = /*#__PURE__*/(0, _react.createContext)(undefined);
13
- var useToolbarDropdownMenu = exports.useToolbarDropdownMenu = function useToolbarDropdownMenu() {
15
+ var useToolbarDropdownMenuOld = exports.useToolbarDropdownMenuOld = function useToolbarDropdownMenuOld() {
14
16
  var context = (0, _react.useContext)(ToolbarDropdownMenuContext);
15
17
  if (!context) {
16
18
  throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
17
19
  }
18
20
  return context;
19
21
  };
22
+ var useToolbarDropdownMenuNew = exports.useToolbarDropdownMenuNew = function useToolbarDropdownMenuNew() {
23
+ return (0, _react.useContext)(ToolbarDropdownMenuContext);
24
+ };
25
+ var useToolbarDropdownMenu = exports.useToolbarDropdownMenu = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(function () {
26
+ return (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true);
27
+ }, useToolbarDropdownMenuNew, useToolbarDropdownMenuOld);
20
28
  var ToolbarDropdownMenuProvider = exports.ToolbarDropdownMenuProvider = function ToolbarDropdownMenuProvider(_ref) {
21
29
  var children = _ref.children;
22
30
  var _useState = (0, _react.useState)(false),
@@ -10,7 +10,7 @@ export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
10
10
  export { ToolbarSection } from './ui/ToolbarSection';
11
11
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
12
12
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
13
- export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
13
+ export { useToolbarDropdownMenu, ToolbarDropdownMenuProvider } from './ui/ToolbarDropdownMenuContext';
14
14
  export { ResponsiveContainer } from './ui/ResponsiveContainer';
15
15
  export { Show } from './ui/Show';
16
16
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
@@ -6,6 +6,7 @@ import { cx } from '@atlaskit/css';
6
6
  import { DropdownItem } from '@atlaskit/dropdown-menu';
7
7
  import { Pressable } from '@atlaskit/primitives/compiled';
8
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
+ import { useToolbarDropdownMenuNew } from './ToolbarDropdownMenuContext';
9
10
  const styles = {
10
11
  toolbarDropdownItem: "_18zrpxbi _1rjcu2gc _1e0c1txw _kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _1ul9163w _1basglpi _1ah31i6y",
11
12
  enabled: "_irr3166n _1di61dty",
@@ -48,8 +49,14 @@ export const ToolbarDropdownItem = ({
48
49
  target,
49
50
  rel
50
51
  }) => {
52
+ const parentContext = useToolbarDropdownMenuNew();
51
53
  return /*#__PURE__*/React.createElement(DropdownItem, {
52
- onClick: onClick,
54
+ onClick: expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) ? e => {
55
+ if (!hasNestedDropdownMenu) {
56
+ parentContext === null || parentContext === void 0 ? void 0 : parentContext.closeMenu();
57
+ }
58
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
59
+ } : onClick,
53
60
  elemBefore: elemBefore,
54
61
  elemAfter: elemAfter,
55
62
  isSelected: isSelected,
@@ -24,24 +24,20 @@ const ToolbarDropdownMenuContent = ({
24
24
  const {
25
25
  onDropdownOpenChanged
26
26
  } = useToolbarUI();
27
- const {
28
- closeMenu,
29
- isOpen,
30
- openMenu
31
- } = useToolbarDropdownMenu();
27
+ const menuContext = useToolbarDropdownMenu();
32
28
  const handleOpenChange = useCallback(args => {
33
29
  onDropdownOpenChanged(args);
34
30
  if (!args.isOpen) {
35
- closeMenu();
31
+ menuContext === null || menuContext === void 0 ? void 0 : menuContext.closeMenu();
36
32
  }
37
- }, [closeMenu, onDropdownOpenChanged]);
33
+ }, [menuContext, onDropdownOpenChanged]);
38
34
  const handleClick = useCallback(() => {
39
- if (!isOpen) {
40
- openMenu();
35
+ if (!(menuContext !== null && menuContext !== void 0 && menuContext.isOpen)) {
36
+ menuContext === null || menuContext === void 0 ? void 0 : menuContext.openMenu();
41
37
  } else {
42
- closeMenu();
38
+ menuContext === null || menuContext === void 0 ? void 0 : menuContext.closeMenu();
43
39
  }
44
- }, [closeMenu, openMenu, isOpen]);
40
+ }, [menuContext]);
45
41
  return /*#__PURE__*/React.createElement(DropdownMenu, {
46
42
  trigger: triggerProps => /*#__PURE__*/React.createElement(ToolbarButton, {
47
43
  ref: triggerProps.triggerRef,
@@ -61,7 +57,7 @@ const ToolbarDropdownMenuContent = ({
61
57
  label: label
62
58
  }),
63
59
  onOpenChange: handleOpenChange,
64
- isOpen: isOpen
60
+ isOpen: menuContext === null || menuContext === void 0 ? void 0 : menuContext.isOpen
65
61
  }, children);
66
62
  };
67
63
  export const ToolbarDropdownMenu = ({
@@ -73,12 +69,23 @@ export const ToolbarDropdownMenu = ({
73
69
  hasSectionMargin = true,
74
70
  enableMaxHeight = false
75
71
  }) => {
76
- return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
77
- iconBefore: iconBefore,
78
- isDisabled: isDisabled,
79
- testId: testId,
80
- label: label
81
- }, /*#__PURE__*/React.createElement(Box, {
82
- xcss: cx(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
83
- }, children)));
72
+ if (expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true)) {
73
+ return /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
74
+ iconBefore: iconBefore,
75
+ isDisabled: isDisabled,
76
+ testId: testId,
77
+ label: label
78
+ }, /*#__PURE__*/React.createElement(Box, {
79
+ xcss: cx(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
80
+ }, children));
81
+ } else {
82
+ return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
83
+ iconBefore: iconBefore,
84
+ isDisabled: isDisabled,
85
+ testId: testId,
86
+ label: label
87
+ }, /*#__PURE__*/React.createElement("div", {
88
+ className: ax([hasSectionMargin && styles.sectionMargin, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator])
89
+ }, children)));
90
+ }
84
91
  };
@@ -1,12 +1,18 @@
1
1
  import React, { createContext, useContext, useState } from 'react';
2
+ import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
4
  const ToolbarDropdownMenuContext = /*#__PURE__*/createContext(undefined);
3
- export const useToolbarDropdownMenu = () => {
5
+ export const useToolbarDropdownMenuOld = () => {
4
6
  const context = useContext(ToolbarDropdownMenuContext);
5
7
  if (!context) {
6
8
  throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
7
9
  }
8
10
  return context;
9
11
  };
12
+ export const useToolbarDropdownMenuNew = () => {
13
+ return useContext(ToolbarDropdownMenuContext);
14
+ };
15
+ export const useToolbarDropdownMenu = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true), useToolbarDropdownMenuNew, useToolbarDropdownMenuOld);
10
16
  export const ToolbarDropdownMenuProvider = ({
11
17
  children
12
18
  }) => {
package/dist/esm/index.js CHANGED
@@ -10,7 +10,7 @@ export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
10
10
  export { ToolbarSection } from './ui/ToolbarSection';
11
11
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
12
12
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
13
- export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
13
+ export { useToolbarDropdownMenu, ToolbarDropdownMenuProvider } from './ui/ToolbarDropdownMenuContext';
14
14
  export { ResponsiveContainer } from './ui/ResponsiveContainer';
15
15
  export { Show } from './ui/Show';
16
16
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
@@ -6,6 +6,7 @@ import { cx } from '@atlaskit/css';
6
6
  import { DropdownItem } from '@atlaskit/dropdown-menu';
7
7
  import { Pressable } from '@atlaskit/primitives/compiled';
8
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
+ import { useToolbarDropdownMenuNew } from './ToolbarDropdownMenuContext';
9
10
  var styles = {
10
11
  toolbarDropdownItem: "_18zrpxbi _1rjcu2gc _1e0c1txw _kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _1ul9163w _1basglpi _1ah31i6y",
11
12
  enabled: "_irr3166n _1di61dty",
@@ -48,8 +49,14 @@ export var ToolbarDropdownItem = function ToolbarDropdownItem(_ref2) {
48
49
  href = _ref2.href,
49
50
  target = _ref2.target,
50
51
  rel = _ref2.rel;
52
+ var parentContext = useToolbarDropdownMenuNew();
51
53
  return /*#__PURE__*/React.createElement(DropdownItem, {
52
- onClick: onClick,
54
+ onClick: expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) ? function (e) {
55
+ if (!hasNestedDropdownMenu) {
56
+ parentContext === null || parentContext === void 0 || parentContext.closeMenu();
57
+ }
58
+ onClick === null || onClick === void 0 || onClick(e);
59
+ } : onClick,
53
60
  elemBefore: elemBefore,
54
61
  elemAfter: elemAfter,
55
62
  isSelected: isSelected,
@@ -22,23 +22,20 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
22
22
  label = _ref.label;
23
23
  var _useToolbarUI = useToolbarUI(),
24
24
  onDropdownOpenChanged = _useToolbarUI.onDropdownOpenChanged;
25
- var _useToolbarDropdownMe = useToolbarDropdownMenu(),
26
- closeMenu = _useToolbarDropdownMe.closeMenu,
27
- isOpen = _useToolbarDropdownMe.isOpen,
28
- openMenu = _useToolbarDropdownMe.openMenu;
25
+ var menuContext = useToolbarDropdownMenu();
29
26
  var handleOpenChange = useCallback(function (args) {
30
27
  onDropdownOpenChanged(args);
31
28
  if (!args.isOpen) {
32
- closeMenu();
29
+ menuContext === null || menuContext === void 0 || menuContext.closeMenu();
33
30
  }
34
- }, [closeMenu, onDropdownOpenChanged]);
31
+ }, [menuContext, onDropdownOpenChanged]);
35
32
  var handleClick = useCallback(function () {
36
- if (!isOpen) {
37
- openMenu();
33
+ if (!(menuContext !== null && menuContext !== void 0 && menuContext.isOpen)) {
34
+ menuContext === null || menuContext === void 0 || menuContext.openMenu();
38
35
  } else {
39
- closeMenu();
36
+ menuContext === null || menuContext === void 0 || menuContext.closeMenu();
40
37
  }
41
- }, [closeMenu, openMenu, isOpen]);
38
+ }, [menuContext]);
42
39
  return /*#__PURE__*/React.createElement(DropdownMenu, {
43
40
  trigger: function trigger(triggerProps) {
44
41
  return /*#__PURE__*/React.createElement(ToolbarButton, {
@@ -60,7 +57,7 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
60
57
  });
61
58
  },
62
59
  onOpenChange: handleOpenChange,
63
- isOpen: isOpen
60
+ isOpen: menuContext === null || menuContext === void 0 ? void 0 : menuContext.isOpen
64
61
  }, children);
65
62
  };
66
63
  export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
@@ -73,12 +70,23 @@ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
73
70
  hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi,
74
71
  _ref2$enableMaxHeight = _ref2.enableMaxHeight,
75
72
  enableMaxHeight = _ref2$enableMaxHeight === void 0 ? false : _ref2$enableMaxHeight;
76
- return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
77
- iconBefore: iconBefore,
78
- isDisabled: isDisabled,
79
- testId: testId,
80
- label: label
81
- }, /*#__PURE__*/React.createElement(Box, {
82
- xcss: cx(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
83
- }, children)));
73
+ if (expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true)) {
74
+ return /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
75
+ iconBefore: iconBefore,
76
+ isDisabled: isDisabled,
77
+ testId: testId,
78
+ label: label
79
+ }, /*#__PURE__*/React.createElement(Box, {
80
+ xcss: cx(hasSectionMargin && styles.sectionMargin, enableMaxHeight && styles.scrollContainer, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator)
81
+ }, children));
82
+ } else {
83
+ return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
84
+ iconBefore: iconBefore,
85
+ isDisabled: isDisabled,
86
+ testId: testId,
87
+ label: label
88
+ }, /*#__PURE__*/React.createElement("div", {
89
+ className: ax([hasSectionMargin && styles.sectionMargin, expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true) && styles.firstSectionSeparator])
90
+ }, children)));
91
+ }
84
92
  };
@@ -1,13 +1,21 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { createContext, useContext, useState } from 'react';
3
+ import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
5
  var ToolbarDropdownMenuContext = /*#__PURE__*/createContext(undefined);
4
- export var useToolbarDropdownMenu = function useToolbarDropdownMenu() {
6
+ export var useToolbarDropdownMenuOld = function useToolbarDropdownMenuOld() {
5
7
  var context = useContext(ToolbarDropdownMenuContext);
6
8
  if (!context) {
7
9
  throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
8
10
  }
9
11
  return context;
10
12
  };
13
+ export var useToolbarDropdownMenuNew = function useToolbarDropdownMenuNew() {
14
+ return useContext(ToolbarDropdownMenuContext);
15
+ };
16
+ export var useToolbarDropdownMenu = conditionalHooksFactory(function () {
17
+ return expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true);
18
+ }, useToolbarDropdownMenuNew, useToolbarDropdownMenuOld);
11
19
  export var ToolbarDropdownMenuProvider = function ToolbarDropdownMenuProvider(_ref) {
12
20
  var children = _ref.children;
13
21
  var _useState = useState(false),
@@ -9,7 +9,7 @@ export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
9
9
  export { ToolbarSection } from './ui/ToolbarSection';
10
10
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
11
11
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
12
- export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
12
+ export { useToolbarDropdownMenu, ToolbarDropdownMenuProvider, } from './ui/ToolbarDropdownMenuContext';
13
13
  export { ResponsiveContainer } from './ui/ResponsiveContainer';
14
14
  export { Show } from './ui/Show';
15
15
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
@@ -4,7 +4,9 @@ interface ToolbarDropdownMenuContextValue {
4
4
  isOpen: boolean;
5
5
  openMenu: () => void;
6
6
  }
7
- export declare const useToolbarDropdownMenu: () => ToolbarDropdownMenuContextValue;
7
+ export declare const useToolbarDropdownMenuOld: () => ToolbarDropdownMenuContextValue;
8
+ export declare const useToolbarDropdownMenuNew: () => ToolbarDropdownMenuContextValue | undefined;
9
+ export declare const useToolbarDropdownMenu: (...args: never[]) => ToolbarDropdownMenuContextValue | undefined;
8
10
  interface ToolbarDropdownMenuProviderProps {
9
11
  children: React.ReactNode;
10
12
  }
@@ -9,7 +9,7 @@ export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
9
9
  export { ToolbarSection } from './ui/ToolbarSection';
10
10
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
11
11
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
12
- export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
12
+ export { useToolbarDropdownMenu, ToolbarDropdownMenuProvider, } from './ui/ToolbarDropdownMenuContext';
13
13
  export { ResponsiveContainer } from './ui/ResponsiveContainer';
14
14
  export { Show } from './ui/Show';
15
15
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
@@ -4,7 +4,9 @@ interface ToolbarDropdownMenuContextValue {
4
4
  isOpen: boolean;
5
5
  openMenu: () => void;
6
6
  }
7
- export declare const useToolbarDropdownMenu: () => ToolbarDropdownMenuContextValue;
7
+ export declare const useToolbarDropdownMenuOld: () => ToolbarDropdownMenuContextValue;
8
+ export declare const useToolbarDropdownMenuNew: () => ToolbarDropdownMenuContextValue | undefined;
9
+ export declare const useToolbarDropdownMenu: (...args: never[]) => ToolbarDropdownMenuContextValue | undefined;
8
10
  interface ToolbarDropdownMenuProviderProps {
9
11
  children: React.ReactNode;
10
12
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://registry.npmjs.org/"
5
5
  },
6
- "version": "0.6.0",
6
+ "version": "0.6.2",
7
7
  "description": "Common UI for Toolbars across the platform",
8
8
  "atlassian": {
9
9
  "team": "Editor: Jenga",
@@ -28,9 +28,10 @@
28
28
  "@atlaskit/icon": "^28.1.0",
29
29
  "@atlaskit/icon-lab": "^5.7.0",
30
30
  "@atlaskit/logo": "^19.7.0",
31
+ "@atlaskit/platform-feature-flags-react": "^0.3.0",
31
32
  "@atlaskit/popup": "^4.3.0",
32
33
  "@atlaskit/primitives": "^14.12.0",
33
- "@atlaskit/tmp-editor-statsig": "^11.11.0",
34
+ "@atlaskit/tmp-editor-statsig": "^12.0.0",
34
35
  "@atlaskit/tokens": "^6.1.0",
35
36
  "@atlaskit/tooltip": "^20.4.0",
36
37
  "@babel/runtime": "^7.0.0",