@axinom/mosaic-ui 0.32.0-rc.9 → 0.32.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/dist/components/FormElements/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/List.d.ts.map +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Actions/Action/Action.spec.tsx +2 -2
- package/src/components/Actions/Action/Action.tsx +1 -1
- package/src/components/FormElements/ToggleButton/ToggleButton.tsx +1 -1
- package/src/components/List/List.spec.tsx +23 -0
- package/src/components/List/List.stories.tsx +8 -0
- package/src/components/List/List.tsx +15 -3
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.spec.tsx +1 -1
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.tsx +1 -1
- package/src/components/PageHeader/PageHeaderBulkActions/PageHeaderBulkActions.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.32.0
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build-storybook": "storybook build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@axinom/mosaic-core": "^0.4.5
|
|
35
|
+
"@axinom/mosaic-core": "^0.4.5",
|
|
36
36
|
"@faker-js/faker": "^7.4.0",
|
|
37
37
|
"@popperjs/core": "^2.9.2",
|
|
38
38
|
"clsx": "^1.1.0",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "b0c12ef914e4ead795480b4fc90b13bc1088bd3f"
|
|
106
106
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { mount, shallow } from 'enzyme';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
|
-
import { BrowserRouter as Router
|
|
4
|
+
import { Link, BrowserRouter as Router } from 'react-router-dom';
|
|
5
5
|
import { noop } from '../../../helpers/utils';
|
|
6
6
|
import { TextButton } from '../../Buttons';
|
|
7
|
-
import {
|
|
7
|
+
import { ConfirmDialog, ConfirmationConfig } from '../../ConfirmDialog';
|
|
8
8
|
import { IconName, Icons } from '../../Icons';
|
|
9
9
|
import {
|
|
10
10
|
Action,
|
|
@@ -2,8 +2,8 @@ import clsx from 'clsx';
|
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import { Link } from 'react-router-dom';
|
|
4
4
|
import {
|
|
5
|
-
ConfirmationConfig,
|
|
6
5
|
ConfirmDialog,
|
|
6
|
+
ConfirmationConfig,
|
|
7
7
|
useConfirmationDelay,
|
|
8
8
|
} from '../../ConfirmDialog';
|
|
9
9
|
import { IconName, Icons } from '../../Icons';
|
|
@@ -3,9 +3,9 @@ import React, { useEffect, useState } from 'react';
|
|
|
3
3
|
import { noop } from '../../../helpers/utils';
|
|
4
4
|
import { CommonJsButtonOptions } from '../../Buttons/Button.model';
|
|
5
5
|
import {
|
|
6
|
+
ConfirmDialog,
|
|
6
7
|
ConfirmationConfig,
|
|
7
8
|
ConfirmationMode,
|
|
8
|
-
ConfirmDialog,
|
|
9
9
|
} from '../../ConfirmDialog';
|
|
10
10
|
import { BaseFormControl } from '../Form.models';
|
|
11
11
|
import { FormElementContainer } from '../FormElementContainer';
|
|
@@ -92,6 +92,29 @@ describe('List', () => {
|
|
|
92
92
|
expect(props.columnSizes).toBe('1fr 1fr 1fr');
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
it.each([
|
|
96
|
+
{ value: true, visible: true },
|
|
97
|
+
{ value: () => true, visible: true },
|
|
98
|
+
{ value: () => false, visible: false },
|
|
99
|
+
])(
|
|
100
|
+
'does add an extra column if there is an action button',
|
|
101
|
+
({ value, visible }) => {
|
|
102
|
+
const wrapper = mount(
|
|
103
|
+
<List
|
|
104
|
+
columns={mockListColumns}
|
|
105
|
+
data={mockListData}
|
|
106
|
+
showActionButton={value}
|
|
107
|
+
/>,
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const rows = wrapper.find(ListRow);
|
|
111
|
+
const props = rows.first().props();
|
|
112
|
+
|
|
113
|
+
expect(props.columnSizes).toBe('1fr 1fr 1fr 50px');
|
|
114
|
+
expect(props.showActionButton).toBe(visible);
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
95
118
|
it.each`
|
|
96
119
|
data | count
|
|
97
120
|
${[{ row: 'one' }, { row: 'two' }, { row: 'three' }]} | ${3}
|
|
@@ -124,6 +124,14 @@ const meta: Meta<StoryListType> = {
|
|
|
124
124
|
description: `<b>[Storybook only]</b> The number of rows to display.
|
|
125
125
|
The story will generate the requests amount of items and assign it to the <code>data</code> prop.`,
|
|
126
126
|
},
|
|
127
|
+
showActionButton: {
|
|
128
|
+
...groups.showActionButton,
|
|
129
|
+
description: `Whether to show the action button in the header row.`,
|
|
130
|
+
options: [true, false, 'random'],
|
|
131
|
+
mapping: {
|
|
132
|
+
random: (): boolean => (Math.random() > 0.5 ? true : false),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
127
135
|
},
|
|
128
136
|
args: {
|
|
129
137
|
columns: defaultColumns,
|
|
@@ -73,7 +73,7 @@ export interface ListProps<T extends Data> {
|
|
|
73
73
|
* Defines whether an action button will be rendered (default: true)
|
|
74
74
|
* Will not render if selectMode is not 'None'
|
|
75
75
|
*/
|
|
76
|
-
showActionButton?: boolean;
|
|
76
|
+
showActionButton?: boolean | ((data: T) => boolean);
|
|
77
77
|
/** Defines when the loading of the next page is triggered. The number represents the number of row left, before a load is triggered. (default: 10) */
|
|
78
78
|
loadingTriggerOffset?: number;
|
|
79
79
|
/** Defines how the list data should be sorted */
|
|
@@ -245,7 +245,7 @@ export const List = <T extends Data>({
|
|
|
245
245
|
|
|
246
246
|
const columnSizes = getColumnsSizeDefinition(
|
|
247
247
|
columns,
|
|
248
|
-
showActionButton,
|
|
248
|
+
Boolean(showActionButton),
|
|
249
249
|
selectionMode,
|
|
250
250
|
!!inlineMenuActions,
|
|
251
251
|
);
|
|
@@ -345,7 +345,8 @@ export const List = <T extends Data>({
|
|
|
345
345
|
verticalTextAlign={verticalTextAlign}
|
|
346
346
|
selectionMode={selectionMode}
|
|
347
347
|
showActionButton={
|
|
348
|
-
|
|
348
|
+
selectionMode === ListSelectMode.None &&
|
|
349
|
+
getActionButtonVisibility(item.data, showActionButton)
|
|
349
350
|
}
|
|
350
351
|
showCheckMark={selectionMode === ListSelectMode.Single}
|
|
351
352
|
showItemCheckbox={selectionMode === ListSelectMode.Multi}
|
|
@@ -383,3 +384,14 @@ export const List = <T extends Data>({
|
|
|
383
384
|
</div>
|
|
384
385
|
);
|
|
385
386
|
};
|
|
387
|
+
|
|
388
|
+
function getActionButtonVisibility<T>(
|
|
389
|
+
data: T,
|
|
390
|
+
showActionButton: boolean | ((item: T) => boolean),
|
|
391
|
+
): boolean {
|
|
392
|
+
if (typeof showActionButton === 'boolean') {
|
|
393
|
+
return showActionButton;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return showActionButton(data);
|
|
397
|
+
}
|
|
@@ -4,7 +4,7 @@ import { act } from 'react-dom/test-utils';
|
|
|
4
4
|
import { Link, BrowserRouter as Router } from 'react-router-dom';
|
|
5
5
|
import { noop } from '../../../helpers/utils';
|
|
6
6
|
import { TextButton } from '../../Buttons';
|
|
7
|
-
import {
|
|
7
|
+
import { ConfirmDialog, ConfirmationConfig } from '../../ConfirmDialog';
|
|
8
8
|
import { IconName } from '../../Icons';
|
|
9
9
|
import {
|
|
10
10
|
PageHeaderAction,
|
|
@@ -3,9 +3,9 @@ import React, { useEffect, useState } from 'react';
|
|
|
3
3
|
import { Link } from 'react-router-dom';
|
|
4
4
|
import { noop } from '../../../helpers/utils';
|
|
5
5
|
import {
|
|
6
|
+
ConfirmDialog,
|
|
6
7
|
ConfirmationConfig,
|
|
7
8
|
ConfirmationMode,
|
|
8
|
-
ConfirmDialog,
|
|
9
9
|
useConfirmationDelay,
|
|
10
10
|
} from '../../ConfirmDialog';
|
|
11
11
|
import { IconName, Icons } from '../../Icons';
|
|
@@ -6,8 +6,8 @@ import { ConfirmationMode } from '../../ConfirmDialog';
|
|
|
6
6
|
import { IconName } from '../../Icons';
|
|
7
7
|
import { PageHeaderProps } from '../PageHeader.model';
|
|
8
8
|
import {
|
|
9
|
-
isPageHeaderJsAction,
|
|
10
9
|
PageHeaderAction,
|
|
10
|
+
isPageHeaderJsAction,
|
|
11
11
|
} from '../PageHeaderAction/PageHeaderAction';
|
|
12
12
|
import {
|
|
13
13
|
PageHeaderActionProps,
|