@atlaskit/editor-toolbar-model 0.3.1 → 0.4.0

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,23 @@
1
1
  # @atlaskit/editor-toolbar-model
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`52d4b8fab3118`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/52d4b8fab3118) -
8
+ Add platform_editor_toolbar_hide_overflow_menu experiment, add logic to hide menu button if there
9
+ are no menu items rendered
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 0.3.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 0.3.1
4
22
 
5
23
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ToolbarModelRenderer = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
11
  var _common = require("./common");
11
12
  var hasParents = function hasParents(component) {
12
13
  return component.type !== 'toolbar';
@@ -41,6 +42,16 @@ var getFallbackComponent = function getFallbackComponent(type, fallbacks) {
41
42
  }
42
43
  };
43
44
  var hasMenuItems = function hasMenuItems(menuSections, allComponents) {
45
+ if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_hide_overflow_menu', 'isEnabled', true)) {
46
+ return menuSections.some(function (menuSection) {
47
+ return allComponents.some(function (component) {
48
+ var _component$isHidden;
49
+ return component.type === 'menu-item' && component.parents.some(function (parent) {
50
+ return parent.key === menuSection.key;
51
+ }) && (!('isHidden' in component) || !((_component$isHidden = component.isHidden) !== null && _component$isHidden !== void 0 && _component$isHidden.call(component)));
52
+ });
53
+ });
54
+ }
44
55
  return menuSections.some(function (menuSection) {
45
56
  return allComponents.some(function (component) {
46
57
  return component.type === 'menu-item' && component.parents.some(function (parent) {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { getSortedChildren, isSection, NoOp } from './common';
3
4
  const hasParents = component => {
4
5
  return component.type !== 'toolbar';
@@ -33,6 +34,14 @@ const getFallbackComponent = (type, fallbacks) => {
33
34
  }
34
35
  };
35
36
  const hasMenuItems = (menuSections, allComponents) => {
37
+ if (expValEquals('platform_editor_toolbar_hide_overflow_menu', 'isEnabled', true)) {
38
+ return menuSections.some(menuSection => {
39
+ return allComponents.some(component => {
40
+ var _component$isHidden;
41
+ return component.type === 'menu-item' && component.parents.some(parent => parent.key === menuSection.key) && (!('isHidden' in component) || !((_component$isHidden = component.isHidden) !== null && _component$isHidden !== void 0 && _component$isHidden.call(component)));
42
+ });
43
+ });
44
+ }
36
45
  return menuSections.some(menuSection => {
37
46
  return allComponents.some(component => component.type === 'menu-item' && component.parents.some(parent => parent.key === menuSection.key));
38
47
  });
@@ -1,5 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import React from 'react';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { getSortedChildren, isSection, NoOp } from './common';
4
5
  var hasParents = function hasParents(component) {
5
6
  return component.type !== 'toolbar';
@@ -34,6 +35,16 @@ var getFallbackComponent = function getFallbackComponent(type, fallbacks) {
34
35
  }
35
36
  };
36
37
  var hasMenuItems = function hasMenuItems(menuSections, allComponents) {
38
+ if (expValEquals('platform_editor_toolbar_hide_overflow_menu', 'isEnabled', true)) {
39
+ return menuSections.some(function (menuSection) {
40
+ return allComponents.some(function (component) {
41
+ var _component$isHidden;
42
+ return component.type === 'menu-item' && component.parents.some(function (parent) {
43
+ return parent.key === menuSection.key;
44
+ }) && (!('isHidden' in component) || !((_component$isHidden = component.isHidden) !== null && _component$isHidden !== void 0 && _component$isHidden.call(component)));
45
+ });
46
+ });
47
+ }
37
48
  return menuSections.some(function (menuSection) {
38
49
  return allComponents.some(function (component) {
39
50
  return component.type === 'menu-item' && component.parents.some(function (parent) {
@@ -92,6 +92,7 @@ export type RegisterToolbarMenuSection = ToolbarMenuSectionType & {
92
92
  };
93
93
  export type RegisterToolbarMenuItem = ToolbarMenuItemType & {
94
94
  component?: ToolbarMenuItemComponent;
95
+ isHidden?: () => boolean;
95
96
  parents: Parents<ToolbarMenuSectionType>;
96
97
  };
97
98
  export type RegisterComponent = RegisterToolbar | RegisterToolbarSection | RegisterToolbarGroup | RegisterToolbarButton | RegisterToolbarMenu | RegisterToolbarNestedMenu | RegisterToolbarMenuSection | RegisterToolbarMenuItem;
@@ -92,6 +92,7 @@ export type RegisterToolbarMenuSection = ToolbarMenuSectionType & {
92
92
  };
93
93
  export type RegisterToolbarMenuItem = ToolbarMenuItemType & {
94
94
  component?: ToolbarMenuItemComponent;
95
+ isHidden?: () => boolean;
95
96
  parents: Parents<ToolbarMenuSectionType>;
96
97
  };
97
98
  export type RegisterComponent = RegisterToolbar | RegisterToolbarSection | RegisterToolbarGroup | RegisterToolbarButton | RegisterToolbarMenu | RegisterToolbarNestedMenu | RegisterToolbarMenuSection | RegisterToolbarMenuItem;
package/package.json CHANGED
@@ -21,7 +21,8 @@
21
21
  ],
22
22
  "atlaskit:src": "src/index.ts",
23
23
  "dependencies": {
24
- "@atlaskit/tokens": "^10.1.0",
24
+ "@atlaskit/tmp-editor-statsig": "^29.5.0",
25
+ "@atlaskit/tokens": "^11.0.0",
25
26
  "@babel/runtime": "^7.0.0",
26
27
  "@compiled/react": "^0.18.6"
27
28
  },
@@ -69,7 +70,7 @@
69
70
  }
70
71
  },
71
72
  "name": "@atlaskit/editor-toolbar-model",
72
- "version": "0.3.1",
73
+ "version": "0.4.0",
73
74
  "description": "register and render toolbar component",
74
75
  "author": "Atlassian Pty Ltd",
75
76
  "license": "Apache-2.0",