@axinom/mosaic-ui 0.49.0-rc.5 → 0.49.0-rc.6

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 (46) hide show
  1. package/dist/components/DynamicDataList/DynamicDataList.d.ts.map +1 -1
  2. package/dist/components/Explorer/Explorer.d.ts.map +1 -1
  3. package/dist/components/FormStation/FormStationHeader/FormStationHeader.d.ts.map +1 -1
  4. package/dist/components/PageHeader/PageHeader.d.ts +9 -2
  5. package/dist/components/PageHeader/PageHeader.d.ts.map +1 -1
  6. package/dist/components/PageHeader/PageHeader.model.d.ts +11 -12
  7. package/dist/components/PageHeader/PageHeader.model.d.ts.map +1 -1
  8. package/dist/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroup.d.ts +35 -0
  9. package/dist/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroup.d.ts.map +1 -0
  10. package/dist/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroupsContext.d.ts +7 -0
  11. package/dist/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroupsContext.d.ts.map +1 -0
  12. package/dist/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroupsContextProvider.d.ts +3 -0
  13. package/dist/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroupsContextProvider.d.ts.map +1 -0
  14. package/dist/components/PageHeader/index.d.ts +1 -1
  15. package/dist/components/PageHeader/index.d.ts.map +1 -1
  16. package/dist/index.es.js +4 -4
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.js +4 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/{components/DynamicDataList/helpers/generateId.d.ts → utils/GenerateId.d.ts} +1 -1
  21. package/dist/utils/GenerateId.d.ts.map +1 -0
  22. package/package.json +3 -3
  23. package/src/components/DynamicDataList/DynamicDataList.spec.tsx +2 -1
  24. package/src/components/DynamicDataList/DynamicDataList.tsx +1 -1
  25. package/src/components/Explorer/Explorer.spec.tsx +26 -16
  26. package/src/components/Explorer/Explorer.tsx +47 -28
  27. package/src/components/Explorer/NavigationExplorer/NavigationExplorer.spec.tsx +2 -2
  28. package/src/components/Explorer/SelectionExplorer/SelectionExplorer.spec.tsx +8 -32
  29. package/src/components/FormStation/FormStationHeader/FormStationHeader.tsx +34 -30
  30. package/src/components/PageHeader/PageHeader.model.ts +10 -12
  31. package/src/components/PageHeader/PageHeader.scss +7 -3
  32. package/src/components/PageHeader/PageHeader.spec.tsx +28 -86
  33. package/src/components/PageHeader/PageHeader.stories.tsx +32 -7
  34. package/src/components/PageHeader/PageHeader.tsx +50 -77
  35. package/src/components/PageHeader/{PageHeaderBulkActions/PageHeaderBulkActions.scss → PageHeaderActionsGroup/PageHeaderActionsGroup.scss} +21 -21
  36. package/src/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroup.spec.tsx +105 -0
  37. package/src/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroup.tsx +224 -0
  38. package/src/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroupsContext.ts +13 -0
  39. package/src/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroupsContextProvider.tsx +30 -0
  40. package/src/components/PageHeader/index.ts +1 -1
  41. package/dist/components/DynamicDataList/helpers/generateId.d.ts.map +0 -1
  42. package/dist/components/PageHeader/PageHeaderBulkActions/PageHeaderBulkActions.d.ts +0 -22
  43. package/dist/components/PageHeader/PageHeaderBulkActions/PageHeaderBulkActions.d.ts.map +0 -1
  44. package/src/components/PageHeader/PageHeaderBulkActions/PageHeaderBulkActions.spec.tsx +0 -369
  45. package/src/components/PageHeader/PageHeaderBulkActions/PageHeaderBulkActions.tsx +0 -188
  46. /package/src/{components/DynamicDataList/helpers/generateId.ts → utils/GenerateId.ts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateId.d.ts","sourceRoot":"","sources":["../../../../src/components/DynamicDataList/helpers/generateId.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,IAAI,QAAO,MAKvB,CAAC"}
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { PageHeaderProps } from '../PageHeader.model';
3
- import { PageHeaderActionProps } from '../PageHeaderAction/PageHeaderAction.model';
4
- export interface PageHeaderBulkActionsProps extends Pick<PageHeaderProps, 'openBulkActionsOnStart' | 'onBulkActionsToggled'> {
5
- /** Array of Actions to be rendered (default: []) */
6
- actions?: PageHeaderActionProps[];
7
- /** Number of available slots actions can use in the PageHeader */
8
- availableActionSpace: number;
9
- /** Whether or not bulk actions are disabled (default: false)*/
10
- bulkActionsDisabled?: boolean;
11
- /** CSS Class name for additional styles */
12
- className?: string;
13
- }
14
- /**
15
- * Used to perform bulk operations from the PageHeader component.
16
- * @example
17
- * <PageHeaderBulkActions>
18
- * <PageHeaderAction action={action} onBulkActionsToggled={onBulkActionsToggledHandler} />
19
- * </PageHeaderBulkActions>
20
- */
21
- export declare const PageHeaderBulkActions: React.FC<PageHeaderBulkActionsProps>;
22
- //# sourceMappingURL=PageHeaderBulkActions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PageHeaderBulkActions.d.ts","sourceRoot":"","sources":["../../../../src/components/PageHeader/PageHeaderBulkActions/PageHeaderBulkActions.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,EACL,qBAAqB,EAEtB,MAAM,4CAA4C,CAAC;AAGpD,MAAM,WAAW,0BACf,SAAQ,IAAI,CACV,eAAe,EACf,wBAAwB,GAAG,sBAAsB,CAClD;IACD,oDAAoD;IACpD,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAClC,kEAAkE;IAClE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAoJtE,CAAC"}
@@ -1,369 +0,0 @@
1
- import { mount, shallow } from 'enzyme';
2
- import React from 'react';
3
- import { act } from 'react-dom/test-utils';
4
- import { noop } from '../../../helpers/utils';
5
- import { PageHeaderAction } from '../PageHeaderAction/PageHeaderAction';
6
- import {
7
- PageHeaderActionProps,
8
- PageHeaderActionType,
9
- } from '../PageHeaderAction/PageHeaderAction.model';
10
- import {
11
- PageHeaderBulkActions,
12
- PageHeaderBulkActionsProps,
13
- } from './PageHeaderBulkActions';
14
-
15
- const defaultActions: PageHeaderActionProps[] = [
16
- {
17
- label: 'Bulk Action 1',
18
- onClick: noop,
19
- },
20
- {
21
- label: 'Bulk Action 2',
22
- onClick: noop,
23
- },
24
- {
25
- label: 'Bulk Action 3',
26
- onClick: noop,
27
- },
28
- ];
29
-
30
- const defaultProps: PageHeaderBulkActionsProps = {
31
- availableActionSpace: 0,
32
- actions: defaultActions,
33
- };
34
-
35
- describe('PageHeaderBulkActions', () => {
36
- it('renders the component without crashing', () => {
37
- const wrapper = shallow(<PageHeaderBulkActions {...defaultProps} />);
38
- expect(wrapper).toBeTruthy();
39
- });
40
-
41
- it(`renders only 'Bulk Actions' by default`, () => {
42
- const wrapper = mount(<PageHeaderBulkActions {...defaultProps} />);
43
- const actions = wrapper.find(PageHeaderAction);
44
- expect(actions).toHaveLength(1);
45
- });
46
-
47
- it(`'Bulk Actions' has the 'Context' actionType when closed and 'Active' actionType when open`, () => {
48
- const wrapper = mount(
49
- <PageHeaderBulkActions
50
- {...defaultProps}
51
- availableActionSpace={defaultActions.length}
52
- />,
53
- );
54
- const bulkActionsToggle = wrapper.find(PageHeaderAction).first();
55
- let action = wrapper.find(PageHeaderAction);
56
-
57
- expect(action.prop('actionType')).toBe(PageHeaderActionType.Context);
58
-
59
- bulkActionsToggle.simulate('click');
60
- action = wrapper.find(PageHeaderAction).first();
61
-
62
- expect(action.prop('actionType')).toBe(PageHeaderActionType.Active);
63
- });
64
-
65
- it(`renders all actions when 'Bulk Actions' is selected and there is enough available action slots`, () => {
66
- const wrapper = mount(
67
- <PageHeaderBulkActions
68
- {...defaultProps}
69
- availableActionSpace={defaultActions.length}
70
- />,
71
- );
72
- const bulkActionsToggle = wrapper.find(PageHeaderAction).first();
73
- let actions = wrapper.find(PageHeaderAction);
74
- const bulkActionCount = 1;
75
- expect(actions).toHaveLength(1);
76
- bulkActionsToggle.simulate('click');
77
- actions = wrapper.find(PageHeaderAction);
78
- expect(actions).toHaveLength(bulkActionCount + defaultActions.length);
79
- });
80
-
81
- it(`'Bulk Actions' hides all actions when actions are shown`, () => {
82
- const wrapper = mount(
83
- <PageHeaderBulkActions
84
- {...defaultProps}
85
- availableActionSpace={defaultActions.length}
86
- openBulkActionsOnStart={true}
87
- />,
88
- );
89
- const bulkActionsToggle = wrapper.find(PageHeaderAction).first();
90
- let actions = wrapper.find(PageHeaderAction);
91
- const bulkActionCount = 1;
92
- expect(actions).toHaveLength(bulkActionCount + defaultActions.length);
93
- bulkActionsToggle.simulate('click');
94
- actions = wrapper.find(PageHeaderAction);
95
- expect(actions).toHaveLength(1);
96
- });
97
-
98
- it(`raises onBulkActionsToggled`, () => {
99
- const bulkActionSpy = jest.fn();
100
- const wrapper = mount(
101
- <PageHeaderBulkActions
102
- {...defaultProps}
103
- onBulkActionsToggled={bulkActionSpy}
104
- />,
105
- );
106
- const bulkActionsToggle = wrapper.find(PageHeaderAction).first();
107
- bulkActionsToggle.simulate('click');
108
- expect(bulkActionSpy).toHaveBeenCalledTimes(1);
109
- expect(bulkActionSpy).toHaveBeenCalledWith(true);
110
- });
111
-
112
- it(`renders 'Bulk Actions' and 'More Actions' if openBulkActionsOnStart is set to true and there isn't enough available space`, () => {
113
- const wrapper = mount(
114
- <PageHeaderBulkActions {...defaultProps} openBulkActionsOnStart={true} />,
115
- );
116
- const bulkActionCount = 1;
117
- const moreActionCount = 1;
118
- const actions = wrapper.find(PageHeaderAction);
119
- expect(actions).toHaveLength(bulkActionCount + moreActionCount);
120
- });
121
-
122
- it(`renders the dropdown list when 'More' actions are available on mouse enter and closes on mouse leave`, () => {
123
- const wrapper = mount(
124
- <PageHeaderBulkActions {...defaultProps} openBulkActionsOnStart={true} />,
125
- );
126
- const moreActionsToggle = wrapper.find('.hasMore');
127
-
128
- let dropDownActions = wrapper.find('.dropDownList');
129
- expect(dropDownActions.exists()).toBe(false);
130
-
131
- act(() => {
132
- // @ts-expect-error We don't pass event args
133
- moreActionsToggle.prop('onMouseEnter')();
134
- });
135
-
136
- wrapper.update();
137
-
138
- dropDownActions = wrapper.find('.dropDownList');
139
-
140
- expect(dropDownActions.exists()).toBe(true);
141
-
142
- act(() => {
143
- // @ts-expect-error We don't pass event args
144
- moreActionsToggle.prop('onMouseLeave')();
145
- });
146
-
147
- wrapper.update();
148
-
149
- dropDownActions = wrapper.find('.dropDownList');
150
-
151
- expect(dropDownActions.exists()).toBe(false);
152
- });
153
-
154
- it(`'More' action has the 'Context' actionType when closed and the 'Active' actionType when open`, () => {
155
- const wrapper = mount(
156
- <PageHeaderBulkActions {...defaultProps} openBulkActionsOnStart={true} />,
157
- );
158
- const moreActionsToggle = wrapper.find('.hasMore');
159
- let action = wrapper.find(PageHeaderAction).last();
160
-
161
- expect(action.prop('actionType')).toBe(PageHeaderActionType.Context);
162
-
163
- act(() => {
164
- // @ts-expect-error We don't pass event args
165
- moreActionsToggle.prop('onMouseEnter')();
166
- });
167
-
168
- wrapper.update();
169
-
170
- action = wrapper.find(PageHeaderAction).at(1);
171
-
172
- expect(action.prop('actionType')).toBe(PageHeaderActionType.Active);
173
- });
174
-
175
- it(`renders actions, that don't fit in the PageHeader, in the drop down list`, () => {
176
- const [mockAction1, mockAction2, mockAction3] = defaultActions;
177
- const wrapper = mount(
178
- <PageHeaderBulkActions {...defaultProps} openBulkActionsOnStart={true} />,
179
- );
180
- const moreActionsToggle = wrapper.find('.hasMore');
181
-
182
- act(() => {
183
- // @ts-expect-error We don't pass event args
184
- moreActionsToggle.prop('onMouseEnter')();
185
- });
186
-
187
- wrapper.update();
188
-
189
- const dropDownActions = wrapper.find('.dropDownList');
190
- const action1 = dropDownActions.childAt(0);
191
- const action2 = dropDownActions.childAt(1);
192
- const action3 = dropDownActions.childAt(2);
193
-
194
- expect(dropDownActions.children()).toHaveLength(defaultActions.length);
195
- expect(action1.text()).toBe(mockAction1.label);
196
- expect(action2.text()).toBe(mockAction2.label);
197
- expect(action3.text()).toBe(mockAction3.label);
198
- });
199
-
200
- it(`splits actions between the PageHeader and dropdown list when theres not enough space for all`, () => {
201
- const [mockAction1, mockAction2, mockAction3] = defaultActions;
202
- const wrapper = mount(
203
- <PageHeaderBulkActions
204
- {...defaultProps}
205
- openBulkActionsOnStart={true}
206
- availableActionSpace={2}
207
- />,
208
- );
209
- const moreActionsToggle = wrapper.find('.hasMore');
210
-
211
- act(() => {
212
- // @ts-expect-error We don't pass event args
213
- moreActionsToggle.prop('onMouseEnter')();
214
- });
215
-
216
- wrapper.update();
217
-
218
- const pageHeaderActions = wrapper.find('.container').first();
219
- const action1 = pageHeaderActions.find('.container:not(.hasMore)').at(1);
220
- const action2 = pageHeaderActions.find('.container:not(.hasMore)').at(2);
221
- let action3 = pageHeaderActions.find('.container:not(.hasMore)').at(3);
222
-
223
- expect(action1.text()).toBe(mockAction1.label);
224
- expect(action2.text()).toBe(mockAction2.label);
225
- expect(action3.text()).not.toBe(mockAction3.label);
226
-
227
- const dropDownActions = wrapper.find('.dropDownList');
228
- action3 = dropDownActions.childAt(0);
229
-
230
- expect(dropDownActions.children()).toHaveLength(1);
231
- expect(action3.text()).toBe(mockAction3.label);
232
- });
233
-
234
- it(`raises onClick for actions in the page header available space and drop down list`, () => {
235
- const pageHeaderSpy = jest.fn();
236
- const dropDownListSpy = jest.fn();
237
- const actionsWithSpies: PageHeaderActionProps[] = [
238
- {
239
- label: 'Bulk Action 1',
240
- onClick: pageHeaderSpy,
241
- },
242
- {
243
- label: 'Bulk Action 2',
244
- onClick: dropDownListSpy,
245
- },
246
- ];
247
-
248
- const wrapper = mount(
249
- <PageHeaderBulkActions
250
- {...defaultProps}
251
- actions={actionsWithSpies}
252
- openBulkActionsOnStart={true}
253
- availableActionSpace={1}
254
- />,
255
- );
256
- const moreActionsToggle = wrapper.find('.hasMore');
257
-
258
- act(() => {
259
- // @ts-expect-error We don't pass event args
260
- moreActionsToggle.prop('onMouseEnter')();
261
- });
262
-
263
- wrapper.update();
264
-
265
- const pageHeaderActions = wrapper.find('.container').first();
266
- const action1 = pageHeaderActions.find('.container:not(.hasMore)').at(1);
267
-
268
- action1.simulate('click');
269
-
270
- expect(pageHeaderSpy).toHaveBeenCalledTimes(1);
271
-
272
- const dropDownActions = wrapper.find('.dropDownList');
273
- const action2 = dropDownActions.childAt(0);
274
-
275
- action2.simulate('click');
276
-
277
- expect(dropDownListSpy).toHaveBeenCalledTimes(1);
278
- });
279
-
280
- it(`closes drop down list after clicking an action`, () => {
281
- const dropDownListSpy = jest.fn();
282
- const actionsWithSpies: PageHeaderActionProps[] = [
283
- {
284
- label: 'Bulk Action 1',
285
- onClick: dropDownListSpy,
286
- },
287
- ];
288
-
289
- const wrapper = mount(
290
- <PageHeaderBulkActions
291
- {...defaultProps}
292
- actions={actionsWithSpies}
293
- openBulkActionsOnStart={true}
294
- availableActionSpace={0}
295
- />,
296
- );
297
- const moreActionsToggle = wrapper.find('.hasMore');
298
- let dropDownActions = wrapper.find('.dropDownList');
299
-
300
- expect(dropDownActions.exists()).toBe(false);
301
-
302
- act(() => {
303
- // @ts-expect-error We don't pass event args
304
- moreActionsToggle.prop('onMouseEnter')();
305
- });
306
-
307
- wrapper.update();
308
-
309
- dropDownActions = wrapper.find('.dropDownList');
310
- expect(dropDownActions.exists()).toBe(true);
311
-
312
- const action = dropDownActions.childAt(0);
313
-
314
- action.simulate('click');
315
-
316
- dropDownActions = wrapper.find('.dropDownList');
317
-
318
- expect(dropDownActions.exists()).toBe(false);
319
- });
320
-
321
- it(`disables actions if 'isBulkActionsDisabled' prop is true`, () => {
322
- const pageHeaderSpy = jest.fn();
323
- const dropDownListSpy = jest.fn();
324
- const actionsWithSpies: PageHeaderActionProps[] = [
325
- {
326
- label: 'Bulk Action 1',
327
- onClick: pageHeaderSpy,
328
- },
329
- {
330
- label: 'Bulk Action 2',
331
- onClick: dropDownListSpy,
332
- },
333
- ];
334
-
335
- const wrapper = mount(
336
- <PageHeaderBulkActions
337
- {...defaultProps}
338
- actions={actionsWithSpies}
339
- openBulkActionsOnStart={true}
340
- availableActionSpace={1}
341
- bulkActionsDisabled={true}
342
- />,
343
- );
344
- const moreActionsToggle = wrapper.find('.hasMore');
345
-
346
- act(() => {
347
- // @ts-expect-error We don't pass event args
348
- moreActionsToggle.prop('onMouseEnter')();
349
- });
350
-
351
- wrapper.update();
352
-
353
- const pageHeaderActions = wrapper.find('.container').first();
354
- const action1 = pageHeaderActions.find('.container:not(.hasMore)').at(1);
355
-
356
- action1.simulate('click');
357
-
358
- expect(action1.prop('disabled')).toBe(true);
359
- expect(pageHeaderSpy).not.toHaveBeenCalled();
360
-
361
- const dropDownActions = wrapper.find('.dropDownList');
362
- const action2 = dropDownActions.childAt(0);
363
-
364
- action2.simulate('click');
365
-
366
- expect(action2.prop('disabled')).toBe(true);
367
- expect(dropDownListSpy).not.toHaveBeenCalled();
368
- });
369
- });
@@ -1,188 +0,0 @@
1
- import clsx from 'clsx';
2
- import React, { useEffect, useState } from 'react';
3
- import { noop } from '../../../helpers/utils';
4
- import { useExpand } from '../../../hooks/useExpand/useExpand';
5
- import { ConfirmationMode } from '../../ConfirmDialog';
6
- import { IconName } from '../../Icons';
7
- import { PageHeaderProps } from '../PageHeader.model';
8
- import {
9
- PageHeaderAction,
10
- isPageHeaderJsAction,
11
- } from '../PageHeaderAction/PageHeaderAction';
12
- import {
13
- PageHeaderActionProps,
14
- PageHeaderActionType,
15
- } from '../PageHeaderAction/PageHeaderAction.model';
16
- import classes from './PageHeaderBulkActions.scss';
17
-
18
- export interface PageHeaderBulkActionsProps
19
- extends Pick<
20
- PageHeaderProps,
21
- 'openBulkActionsOnStart' | 'onBulkActionsToggled'
22
- > {
23
- /** Array of Actions to be rendered (default: []) */
24
- actions?: PageHeaderActionProps[];
25
- /** Number of available slots actions can use in the PageHeader */
26
- availableActionSpace: number;
27
- /** Whether or not bulk actions are disabled (default: false)*/
28
- bulkActionsDisabled?: boolean;
29
- /** CSS Class name for additional styles */
30
- className?: string;
31
- }
32
-
33
- /**
34
- * Used to perform bulk operations from the PageHeader component.
35
- * @example
36
- * <PageHeaderBulkActions>
37
- * <PageHeaderAction action={action} onBulkActionsToggled={onBulkActionsToggledHandler} />
38
- * </PageHeaderBulkActions>
39
- */
40
- export const PageHeaderBulkActions: React.FC<PageHeaderBulkActionsProps> = ({
41
- actions = [],
42
- openBulkActionsOnStart = false,
43
- onBulkActionsToggled = noop,
44
- availableActionSpace = 0,
45
- bulkActionsDisabled = false,
46
- className = '',
47
- }) => {
48
- const { isExpanded, toggleExpanded, expand } = useExpand();
49
- const {
50
- isExpanded: isMoreExpanded,
51
- expand: moreExpanded,
52
- collapse: moreCollapse,
53
- toggleExpanded: toggleMoreExpanded,
54
- } = useExpand();
55
-
56
- useEffect(() => {
57
- if (openBulkActionsOnStart) {
58
- expand();
59
- }
60
- }, [expand, openBulkActionsOnStart]);
61
-
62
- const [isMouseOverMore, setIsMouseOverMore] = useState<boolean>(false);
63
- const [isConfirmOpen, setIsConfirmOpen] = useState<Record<string, boolean>>(
64
- {},
65
- );
66
-
67
- const onConfirmToggled = (
68
- isOpen: boolean,
69
- data: { id: string; mode: ConfirmationMode },
70
- ): void => {
71
- setIsConfirmOpen((prevState) => {
72
- return { ...prevState, [data.id]: isOpen };
73
- });
74
- };
75
-
76
- useEffect(() => {
77
- const hasConfirm: boolean = Object.values(isConfirmOpen).includes(true);
78
-
79
- // open drop down
80
- if (isMouseOverMore) {
81
- moreExpanded();
82
- // close drop down if no confirmation is active
83
- } else if (!isMouseOverMore && !hasConfirm) {
84
- moreCollapse();
85
- // keep the drop down open if confirmation is active
86
- } else if (!isMouseOverMore && hasConfirm) {
87
- return;
88
- }
89
- }, [isConfirmOpen, isMouseOverMore, moreCollapse, moreExpanded]);
90
-
91
- return (
92
- <div
93
- className={clsx(
94
- classes.container,
95
- 'page-header-bulk-action-container',
96
- className,
97
- )}
98
- >
99
- <PageHeaderAction
100
- label="Bulk Actions"
101
- actionType={
102
- isExpanded
103
- ? PageHeaderActionType.Active
104
- : PageHeaderActionType.Context
105
- }
106
- icon={IconName.Bulk}
107
- onClick={() => {
108
- toggleExpanded();
109
- onBulkActionsToggled(!isExpanded);
110
- }}
111
- />
112
- {isExpanded &&
113
- actions.slice(0, availableActionSpace).map((action, idx) =>
114
- isPageHeaderJsAction(action) ? (
115
- <PageHeaderAction
116
- key={idx}
117
- {...action}
118
- disabled={bulkActionsDisabled}
119
- confirmationConfig={{
120
- ...action.confirmationConfig,
121
- onConfirmOpen: (isOpen, args) => {
122
- onConfirmToggled(
123
- isOpen,
124
- args as { id: string; mode: ConfirmationMode },
125
- );
126
- action.confirmationConfig?.onConfirmOpen?.(isOpen, args);
127
- },
128
- }}
129
- />
130
- ) : (
131
- <PageHeaderAction key={idx} {...action} />
132
- ),
133
- )}
134
- {isExpanded && actions.length > availableActionSpace && (
135
- <div
136
- className={clsx(classes.hasMore)}
137
- onMouseEnter={() => setIsMouseOverMore(true)}
138
- onMouseLeave={() => setIsMouseOverMore(false)}
139
- >
140
- <PageHeaderAction
141
- label="More"
142
- icon={IconName.Ellipsis}
143
- actionType={
144
- isMoreExpanded
145
- ? PageHeaderActionType.Active
146
- : PageHeaderActionType.Context
147
- }
148
- onClick={() => toggleMoreExpanded()}
149
- />
150
- {isMoreExpanded && (
151
- <div className={clsx(classes.dropDownList)}>
152
- {actions.slice(availableActionSpace).map((action, idx) =>
153
- isPageHeaderJsAction(action) ? (
154
- <PageHeaderAction
155
- key={idx}
156
- {...action}
157
- disabled={bulkActionsDisabled}
158
- onClick={() => {
159
- action.onClick();
160
- moreCollapse();
161
- setIsMouseOverMore(false);
162
- }}
163
- className={clsx(classes.dropDown)}
164
- confirmationConfig={{
165
- ...action.confirmationConfig,
166
- onConfirmOpen: (isOpen, args) => {
167
- onConfirmToggled(
168
- isOpen,
169
- args as { id: string; mode: ConfirmationMode },
170
- );
171
- action.confirmationConfig?.onConfirmOpen?.(
172
- isOpen,
173
- args,
174
- );
175
- },
176
- }}
177
- />
178
- ) : (
179
- <PageHeaderAction key={idx} {...action} />
180
- ),
181
- )}
182
- </div>
183
- )}
184
- </div>
185
- )}
186
- </div>
187
- );
188
- };