box-ui-elements 23.4.0-beta.30 → 23.4.0-beta.32

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/dist/explorer.css +1 -1
  2. package/dist/explorer.js +1 -1
  3. package/dist/openwith.js +1 -1
  4. package/dist/picker.js +1 -1
  5. package/dist/preview.css +1 -1
  6. package/dist/preview.js +1 -1
  7. package/dist/sharing.js +1 -1
  8. package/dist/sidebar.css +1 -1
  9. package/dist/sidebar.js +1 -1
  10. package/dist/uploader.js +1 -1
  11. package/es/common/types/metadata.js.flow +6 -0
  12. package/es/common/types/metadata.js.map +1 -1
  13. package/es/elements/content-sidebar/SidebarNav.js +14 -3
  14. package/es/elements/content-sidebar/SidebarNav.js.flow +23 -3
  15. package/es/elements/content-sidebar/SidebarNav.js.map +1 -1
  16. package/es/elements/content-sidebar/SidebarNavTablist.js +58 -17
  17. package/es/elements/content-sidebar/SidebarNavTablist.js.flow +80 -21
  18. package/es/elements/content-sidebar/SidebarNavTablist.js.map +1 -1
  19. package/es/features/metadata-instance-editor/CascadePolicy.js +53 -23
  20. package/es/features/metadata-instance-editor/CascadePolicy.js.flow +69 -27
  21. package/es/features/metadata-instance-editor/CascadePolicy.js.map +1 -1
  22. package/es/features/metadata-instance-editor/Instance.js +26 -4
  23. package/es/features/metadata-instance-editor/Instance.js.flow +33 -4
  24. package/es/features/metadata-instance-editor/Instance.js.map +1 -1
  25. package/es/features/metadata-instance-editor/constants.js +4 -1
  26. package/es/features/metadata-instance-editor/constants.js.flow +10 -1
  27. package/es/features/metadata-instance-editor/constants.js.map +1 -1
  28. package/es/features/metadata-instance-editor/messages.js +16 -0
  29. package/es/features/metadata-instance-editor/messages.js.flow +21 -0
  30. package/es/features/metadata-instance-editor/messages.js.map +1 -1
  31. package/es/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js +32 -0
  32. package/es/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js.flow +36 -0
  33. package/es/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js.map +1 -0
  34. package/i18n/bn-IN.js +4 -0
  35. package/i18n/da-DK.js +4 -0
  36. package/i18n/de-DE.js +4 -0
  37. package/i18n/en-AU.js +4 -0
  38. package/i18n/en-CA.js +4 -0
  39. package/i18n/en-GB.js +4 -0
  40. package/i18n/en-US.js +4 -0
  41. package/i18n/en-US.properties +8 -0
  42. package/i18n/en-x-pseudo.js +4 -0
  43. package/i18n/es-419.js +4 -0
  44. package/i18n/es-ES.js +4 -0
  45. package/i18n/fi-FI.js +4 -0
  46. package/i18n/fr-CA.js +4 -0
  47. package/i18n/fr-FR.js +4 -0
  48. package/i18n/hi-IN.js +4 -0
  49. package/i18n/it-IT.js +4 -0
  50. package/i18n/ja-JP.js +4 -0
  51. package/i18n/ko-KR.js +4 -0
  52. package/i18n/nb-NO.js +4 -0
  53. package/i18n/nl-NL.js +4 -0
  54. package/i18n/pl-PL.js +4 -0
  55. package/i18n/pt-BR.js +4 -0
  56. package/i18n/ru-RU.js +4 -0
  57. package/i18n/sv-SE.js +4 -0
  58. package/i18n/tr-TR.js +4 -0
  59. package/i18n/zh-CN.js +4 -0
  60. package/i18n/zh-TW.js +4 -0
  61. package/package.json +7 -7
  62. package/src/common/types/metadata.js +6 -0
  63. package/src/elements/content-sidebar/SidebarNav.js +23 -3
  64. package/src/elements/content-sidebar/SidebarNavTablist.js +80 -21
  65. package/src/elements/content-sidebar/__tests__/SidebarNav.test.js +99 -147
  66. package/src/elements/content-sidebar/__tests__/SidebarNavTablist.test.js +189 -42
  67. package/src/features/metadata-instance-editor/CascadePolicy.js +69 -27
  68. package/src/features/metadata-instance-editor/Instance.js +33 -4
  69. package/src/features/metadata-instance-editor/__tests__/CascadePolicy.test.js +70 -63
  70. package/src/features/metadata-instance-editor/__tests__/Instance.test.js +34 -19
  71. package/src/features/metadata-instance-editor/__tests__/Instances.test.js +15 -10
  72. package/src/features/metadata-instance-editor/__tests__/MetadataInstanceEditor.test.js +53 -10
  73. package/src/features/metadata-instance-editor/__tests__/__snapshots__/Instance.test.js.snap +2 -1
  74. package/src/features/metadata-instance-editor/constants.js +10 -1
  75. package/src/features/metadata-instance-editor/messages.js +21 -0
  76. package/src/features/metadata-instance-editor/stories/tests/CascadePolicy-visual.stories.js +36 -0
  77. package/src/features/metadata-instance-editor/__tests__/__snapshots__/CascadePolicy.test.js.snap +0 -108
package/i18n/zh-CN.js CHANGED
@@ -612,6 +612,8 @@ export default {
612
612
  "boxui.metadataInstanceEditor.cannotApplyCascadePolicyText": "级联策略目前不适用于自定义元数据。",
613
613
  "boxui.metadataInstanceEditor.cascadePolicyLearnMore": "了解更多",
614
614
  "boxui.metadataInstanceEditor.cascadePolicyModeQuestion": "如果在将此模板及其值应用于现有项目时发生冲突,您要执行什么操作?这是一次性操作。",
615
+ "boxui.metadataInstanceEditor.cascadePolicyOptionsDisabledNotice": "This cascade policy cannot be edited. To modify it, deactivate the current policy and then re-enable it to set up a new one.",
616
+ "boxui.metadataInstanceEditor.cascadePolicyOptionsDisabledNoticeIconAriaLabel": "Disabled cascade options information",
615
617
  "boxui.metadataInstanceEditor.cascadePolicyOverwriteMode": "覆盖所有现有模板值",
616
618
  "boxui.metadataInstanceEditor.cascadePolicySkipMode": "跳过并保留所有现有模板值",
617
619
  "boxui.metadataInstanceEditor.customAdd": "添加",
@@ -629,6 +631,7 @@ export default {
629
631
  "boxui.metadataInstanceEditor.editTooltip": "编辑元数据",
630
632
  "boxui.metadataInstanceEditor.enableAIAutofill": "Box AI 自动填充",
631
633
  "boxui.metadataInstanceEditor.enableCascadePolicy": "启用级联策略",
634
+ "boxui.metadataInstanceEditor.enhancedAgentName": "Enhanced",
632
635
  "boxui.metadataInstanceEditor.fileMetadataRemoveCustomTemplateConfirm": "是否确定要从此文件中删除此自定义元数据及其所有值?",
633
636
  "boxui.metadataInstanceEditor.fileMetadataRemoveTemplateConfirm": "是否确定要从此文件中删除 \"{metadataName}\" 及其所有值?",
634
637
  "boxui.metadataInstanceEditor.folderMetadataRemoveCustomTemplateConfirm": "是否确定要删除此自定义元数据及其所有值?不会删除已应用于此文件夹中文件的任何元数据模板值。",
@@ -642,6 +645,7 @@ export default {
642
645
  "boxui.metadataInstanceEditor.noMetadataAddTemplate": "在右上角单击“添加”,以将元数据添加至此项目",
643
646
  "boxui.metadataInstanceEditor.operationNotImmediate": "此操作不会立即生效,可能需要一些时间。",
644
647
  "boxui.metadataInstanceEditor.removeTemplate": "移除",
648
+ "boxui.metadataInstanceEditor.standardAgentName": "Standard",
645
649
  "boxui.metadataInstanceEditor.templateAdd": "添加",
646
650
  "boxui.metadataInstanceEditor.templateSearchPlaceholder": "搜索所有模板",
647
651
  "boxui.metadataInstanceEditor.templatesFetchFailed": "对不起!我们无法获取模板。请联系管理员",
package/i18n/zh-TW.js CHANGED
@@ -612,6 +612,8 @@ export default {
612
612
  "boxui.metadataInstanceEditor.cannotApplyCascadePolicyText": "向下套用原則目前無法套用到自訂中繼資料。",
613
613
  "boxui.metadataInstanceEditor.cascadePolicyLearnMore": "詳細資訊",
614
614
  "boxui.metadataInstanceEditor.cascadePolicyModeQuestion": "若在將此範本及其值套用到現有項目時發生衝突,您要怎麼處理?此為一次性動作。",
615
+ "boxui.metadataInstanceEditor.cascadePolicyOptionsDisabledNotice": "This cascade policy cannot be edited. To modify it, deactivate the current policy and then re-enable it to set up a new one.",
616
+ "boxui.metadataInstanceEditor.cascadePolicyOptionsDisabledNoticeIconAriaLabel": "Disabled cascade options information",
615
617
  "boxui.metadataInstanceEditor.cascadePolicyOverwriteMode": "覆寫所有現有的範本值",
616
618
  "boxui.metadataInstanceEditor.cascadePolicySkipMode": "略過並保留所有現有的範本值",
617
619
  "boxui.metadataInstanceEditor.customAdd": "新增",
@@ -629,6 +631,7 @@ export default {
629
631
  "boxui.metadataInstanceEditor.editTooltip": "編輯中繼資料",
630
632
  "boxui.metadataInstanceEditor.enableAIAutofill": "Box AI 自動填充",
631
633
  "boxui.metadataInstanceEditor.enableCascadePolicy": "啟用向下套用原則",
634
+ "boxui.metadataInstanceEditor.enhancedAgentName": "Enhanced",
632
635
  "boxui.metadataInstanceEditor.fileMetadataRemoveCustomTemplateConfirm": "確定要從此檔案刪除此自訂中繼資料及其所有值?",
633
636
  "boxui.metadataInstanceEditor.fileMetadataRemoveTemplateConfirm": "確定要從此檔案刪除「{metadataName}」及其所有值?",
634
637
  "boxui.metadataInstanceEditor.folderMetadataRemoveCustomTemplateConfirm": "確定要刪除此自訂中繼資料及其所有值嗎?已套用至此資料夾內檔案的任何中繼資料範本值將不會遭到刪除。",
@@ -642,6 +645,7 @@ export default {
642
645
  "boxui.metadataInstanceEditor.noMetadataAddTemplate": "按一下右上方的「新增」,即可新增中繼資料至此項目",
643
646
  "boxui.metadataInstanceEditor.operationNotImmediate": "此作業不會立即生效,可能需要一些時間。",
644
647
  "boxui.metadataInstanceEditor.removeTemplate": "移除",
648
+ "boxui.metadataInstanceEditor.standardAgentName": "Standard",
645
649
  "boxui.metadataInstanceEditor.templateAdd": "新增",
646
650
  "boxui.metadataInstanceEditor.templateSearchPlaceholder": "搜尋所有範本",
647
651
  "boxui.metadataInstanceEditor.templatesFetchFailed": "很抱歉!我們無法擷取範本。請連絡您的管理員",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "box-ui-elements",
3
- "version": "23.4.0-beta.30",
3
+ "version": "23.4.0-beta.32",
4
4
  "description": "Box UI Elements",
5
5
  "author": "Box (https://www.box.com/)",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -129,15 +129,15 @@
129
129
  "@babel/template": "^7.24.7",
130
130
  "@babel/types": "^7.24.7",
131
131
  "@box/blueprint-web": "^12.7.1",
132
- "@box/blueprint-web-assets": "^4.53.0",
133
- "@box/box-ai-agent-selector": "^0.41.10",
132
+ "@box/blueprint-web-assets": "^4.60.0",
133
+ "@box/box-ai-agent-selector": "^0.48.5",
134
134
  "@box/box-ai-content-answers": "^0.124.1",
135
135
  "@box/cldr-data": "^34.2.0",
136
136
  "@box/combobox-with-api": "^0.34.9",
137
137
  "@box/frontend": "^11.0.1",
138
138
  "@box/item-icon": "^0.9.83",
139
139
  "@box/languages": "^1.0.0",
140
- "@box/metadata-editor": "^0.117.0",
140
+ "@box/metadata-editor": "^0.122.0",
141
141
  "@box/react-virtualized": "^9.22.3-rc-box.10",
142
142
  "@cfaester/enzyme-adapter-react-18": "^0.8.0",
143
143
  "@chromatic-com/storybook": "^4.0.1",
@@ -292,13 +292,13 @@
292
292
  },
293
293
  "peerDependencies": {
294
294
  "@box/blueprint-web": "^12.7.1",
295
- "@box/blueprint-web-assets": "^4.53.0",
296
- "@box/box-ai-agent-selector": "^0.41.10",
295
+ "@box/blueprint-web-assets": "^4.60.0",
296
+ "@box/box-ai-agent-selector": "^0.48.5",
297
297
  "@box/box-ai-content-answers": "^0.124.1",
298
298
  "@box/cldr-data": ">=34.2.0",
299
299
  "@box/combobox-with-api": "^0.34.9",
300
300
  "@box/item-icon": "^0.9.83",
301
- "@box/metadata-editor": "^0.117.0",
301
+ "@box/metadata-editor": "^0.122.0",
302
302
  "@box/react-virtualized": "^9.22.3-rc-box.10",
303
303
  "@hapi/address": "^2.1.4",
304
304
  "axios": "^0.30.0",
@@ -93,10 +93,15 @@ type MetadataCascadePolicy = {
93
93
  cascadePolicyType?: string,
94
94
  };
95
95
 
96
+ type MetadataCascadePolicyConfiguration = {
97
+ agent: string,
98
+ };
99
+
96
100
  type MetadataCascadingPolicyData = {
97
101
  id?: string,
98
102
  isEnabled: boolean,
99
103
  overwrite: boolean,
104
+ cascadePolicyConfiguration: MetadataCascadePolicyConfiguration | null,
100
105
  };
101
106
 
102
107
  type MetadataInstance = {
@@ -187,6 +192,7 @@ export type {
187
192
  MetadataQueryInstanceTypeField,
188
193
  MetadataType,
189
194
  MetadataCascadePolicy,
195
+ MetadataCascadePolicyConfiguration,
190
196
  MetadataCascadingPolicyData,
191
197
  MetadataInstanceV2,
192
198
  MetadataEditor,
@@ -35,6 +35,7 @@ import {
35
35
  } from '../../constants';
36
36
  import { useFeatureConfig } from '../common/feature-checking';
37
37
  import type { NavigateOptions, AdditionalSidebarTab } from './flowTypes';
38
+ import type { InternalSidebarNavigation, InternalSidebarNavigationHandler } from '../common/types/SidebarNavigation';
38
39
  import './SidebarNav.scss';
39
40
  import type { SignSidebarProps } from './SidebarNavSign';
40
41
 
@@ -49,10 +50,13 @@ type Props = {
49
50
  hasDocGen?: boolean,
50
51
  hasMetadata: boolean,
51
52
  hasSkills: boolean,
53
+ internalSidebarNavigation?: InternalSidebarNavigation,
54
+ internalSidebarNavigationHandler?: InternalSidebarNavigationHandler,
52
55
  intl: IntlShape,
53
56
  isOpen?: boolean,
54
57
  onNavigate?: (SyntheticEvent<>, NavigateOptions) => void,
55
58
  onPanelChange?: (name: string, isInitialState: boolean) => void,
59
+ routerDisabled?: boolean,
56
60
  signSidebarProps: SignSidebarProps,
57
61
  };
58
62
 
@@ -67,10 +71,13 @@ const SidebarNav = ({
67
71
  hasMetadata,
68
72
  hasSkills,
69
73
  hasDocGen = false,
74
+ internalSidebarNavigation,
75
+ internalSidebarNavigationHandler,
70
76
  intl,
71
77
  isOpen,
72
78
  onNavigate,
73
79
  onPanelChange = noop,
80
+ routerDisabled,
74
81
  signSidebarProps,
75
82
  }: Props) => {
76
83
  const { enabled: hasBoxSign } = signSidebarProps || {};
@@ -91,7 +98,14 @@ const SidebarNav = ({
91
98
  return (
92
99
  <div className="bcs-SidebarNav" aria-label={intl.formatMessage(messages.sidebarNavLabel)}>
93
100
  <div className="bcs-SidebarNav-tabs">
94
- <SidebarNavTablist elementId={elementId} isOpen={isOpen} onNavigate={onNavigate}>
101
+ <SidebarNavTablist
102
+ elementId={elementId}
103
+ internalSidebarNavigation={internalSidebarNavigation}
104
+ internalSidebarNavigationHandler={internalSidebarNavigationHandler}
105
+ isOpen={isOpen}
106
+ onNavigate={onNavigate}
107
+ routerDisabled={routerDisabled}
108
+ >
95
109
  {hasBoxAI && (
96
110
  <SidebarNavButton
97
111
  data-resin-target={SIDEBAR_NAV_TARGETS.BOXAI}
@@ -161,6 +175,7 @@ const SidebarNav = ({
161
175
  <SidebarNavButton
162
176
  data-resin-target={SIDEBAR_NAV_TARGETS.DOCGEN}
163
177
  data-target-id="SidebarNavButton-docGen"
178
+ data-testid="sidebardocgen"
164
179
  onClick={handleSidebarNavButtonClick}
165
180
  sidebarView={SIDEBAR_VIEW_DOCGEN}
166
181
  tooltip={intl.formatMessage(messages.sidebarDocGenTooltip)}
@@ -177,13 +192,18 @@ const SidebarNav = ({
177
192
  )}
178
193
 
179
194
  {hasAdditionalTabs && (
180
- <div className="bcs-SidebarNav-overflow">
195
+ <div className="bcs-SidebarNav-overflow" data-testid="additional-tabs-overflow">
181
196
  <AdditionalTabs key={fileId} tabs={additionalTabs} />
182
197
  </div>
183
198
  )}
184
199
  </div>
185
200
  <div className="bcs-SidebarNav-footer">
186
- <SidebarToggle isOpen={isOpen} />
201
+ <SidebarToggle
202
+ internalSidebarNavigation={internalSidebarNavigation}
203
+ internalSidebarNavigationHandler={internalSidebarNavigationHandler}
204
+ isOpen={isOpen}
205
+ routerDisabled={routerDisabled}
206
+ />
187
207
  </div>
188
208
  </div>
189
209
  );
@@ -9,50 +9,96 @@ import type { RouterHistory } from 'react-router-dom';
9
9
  import { withRouter } from 'react-router-dom';
10
10
  import { KEYS } from '../../constants';
11
11
  import type { NavigateOptions } from './flowTypes';
12
+ import type { InternalSidebarNavigation, InternalSidebarNavigationHandler } from '../common/types/SidebarNavigation';
12
13
 
13
14
  type Props = {
14
15
  children: React.Node,
15
16
  elementId: string,
16
- history: RouterHistory,
17
+ history?: RouterHistory,
18
+ internalSidebarNavigation?: InternalSidebarNavigation,
19
+ internalSidebarNavigationHandler?: InternalSidebarNavigationHandler,
17
20
  isOpen?: boolean,
18
21
  onNavigate?: (SyntheticEvent<>, NavigateOptions) => void,
22
+ routerDisabled?: boolean,
19
23
  };
20
24
 
21
- const SidebarNavTablist = ({ children, history, elementId, isOpen, onNavigate }: Props) => {
25
+ const SidebarNavTablist = ({
26
+ children,
27
+ history,
28
+ elementId,
29
+ internalSidebarNavigation,
30
+ internalSidebarNavigationHandler,
31
+ isOpen,
32
+ onNavigate,
33
+ routerDisabled = false,
34
+ }: Props) => {
22
35
  const refs = [];
23
- const tablist = React.Children.map(children, child => child && `/${child.props.sidebarView}`);
24
- const handleKeyDown = (event: SyntheticKeyboardEvent<>): void => {
25
- const currentIndex = tablist.indexOf(history.location.pathname);
36
+ const tablist = React.Children.map(children, child => child && child.props.sidebarView);
37
+
38
+ const handleKeyDownWithRouter = (event: SyntheticKeyboardEvent<>): void => {
39
+ if (!history) return;
40
+
41
+ const currentPath = history.location.pathname.replace('/', '');
42
+ const currentIndex = tablist.indexOf(currentPath);
26
43
  const { length } = tablist;
27
44
  let nextIndex = currentIndex;
45
+
28
46
  switch (event.key) {
29
47
  case KEYS.arrowUp:
30
48
  nextIndex = (currentIndex - 1 + length) % length;
31
-
32
- history.push(tablist[nextIndex]);
33
- if (refs.length > 0) {
34
- refs[nextIndex].focus();
35
- }
36
-
37
- event.stopPropagation();
38
- event.preventDefault();
39
49
  break;
40
50
  case KEYS.arrowDown:
41
51
  nextIndex = (currentIndex + 1) % length;
52
+ break;
53
+ default:
54
+ return;
55
+ }
42
56
 
43
- history.push(tablist[nextIndex]);
44
- if (refs.length > 0) {
45
- refs[nextIndex].focus();
46
- }
57
+ const nextTab = tablist[nextIndex];
58
+ history.push(`/${nextTab}`);
59
+
60
+ if (refs.length > nextIndex) {
61
+ refs[nextIndex].focus();
62
+ }
63
+
64
+ event.stopPropagation();
65
+ event.preventDefault();
66
+ };
67
+
68
+ const handleKeyDownWithoutRouter = (event: SyntheticKeyboardEvent<>): void => {
69
+ if (!internalSidebarNavigationHandler) return;
47
70
 
48
- event.stopPropagation();
49
- event.preventDefault();
71
+ const currentTab = internalSidebarNavigation?.sidebar;
72
+ const currentIndex = tablist.indexOf(currentTab);
73
+ const { length } = tablist;
74
+ let nextIndex = currentIndex;
75
+
76
+ switch (event.key) {
77
+ case KEYS.arrowUp:
78
+ nextIndex = (currentIndex - 1 + length) % length;
50
79
  break;
51
- default:
80
+ case KEYS.arrowDown:
81
+ nextIndex = (currentIndex + 1) % length;
52
82
  break;
83
+ default:
84
+ return;
53
85
  }
86
+
87
+ const nextTab = tablist[nextIndex];
88
+ internalSidebarNavigationHandler({
89
+ sidebar: nextTab,
90
+ });
91
+
92
+ if (refs.length > nextIndex) {
93
+ refs[nextIndex].focus();
94
+ }
95
+
96
+ event.stopPropagation();
97
+ event.preventDefault();
54
98
  };
55
99
 
100
+ const handleKeyDown = routerDisabled ? handleKeyDownWithoutRouter : handleKeyDownWithRouter;
101
+
56
102
  return (
57
103
  <div
58
104
  aria-orientation="vertical"
@@ -68,8 +114,11 @@ const SidebarNavTablist = ({ children, history, elementId, isOpen, onNavigate }:
68
114
 
69
115
  return React.cloneElement(tab, {
70
116
  elementId,
117
+ internalSidebarNavigation,
118
+ internalSidebarNavigationHandler,
71
119
  isOpen,
72
120
  onNavigate,
121
+ routerDisabled,
73
122
  ref: ref => {
74
123
  refs.push(ref);
75
124
  },
@@ -80,4 +129,14 @@ const SidebarNavTablist = ({ children, history, elementId, isOpen, onNavigate }:
80
129
  );
81
130
  };
82
131
 
83
- export default withRouter(SidebarNavTablist);
132
+ // Conditionally wrap with withRouter only when router is not disabled
133
+ const SidebarNavTablistWithRouter = withRouter(SidebarNavTablist);
134
+
135
+ const SidebarNavTablistWrapper = (props: Props) => {
136
+ if (props.routerDisabled) {
137
+ return <SidebarNavTablist {...props} />;
138
+ }
139
+ return <SidebarNavTablistWithRouter {...props} />;
140
+ };
141
+
142
+ export default SidebarNavTablistWrapper;