@qoretechnologies/reqore 0.35.3 → 0.36.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/KeyValueTable/index.d.ts +27 -0
- package/dist/components/KeyValueTable/index.d.ts.map +1 -0
- package/dist/components/KeyValueTable/index.js +87 -0
- package/dist/components/KeyValueTable/index.js.map +1 -0
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +19 -16
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +9 -3
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Table/value.d.ts +7 -0
- package/dist/components/Table/value.d.ts.map +1 -0
- package/dist/components/Table/value.js +37 -0
- package/dist/components/Table/value.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KeyValueTable/index.tsx +123 -0
- package/src/components/Table/index.tsx +20 -16
- package/src/components/Table/row.tsx +9 -3
- package/src/components/Table/value.tsx +27 -0
- package/src/index.tsx +2 -0
- package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +199 -0
- package/tests.json +1 -1
|
@@ -314,7 +314,7 @@ const ReqoreTable = ({
|
|
|
314
314
|
const transformedData = useMemo(() => {
|
|
315
315
|
// Filter by global query
|
|
316
316
|
let filteredData = _data.filter((datum) =>
|
|
317
|
-
JSON.stringify(datum).toLowerCase().includes(query.toLowerCase())
|
|
317
|
+
JSON.stringify(datum).toLowerCase().includes(query.toString().toLowerCase())
|
|
318
318
|
);
|
|
319
319
|
|
|
320
320
|
// Filter by column filters
|
|
@@ -440,12 +440,7 @@ const ReqoreTable = ({
|
|
|
440
440
|
}, []);
|
|
441
441
|
|
|
442
442
|
const columnsList = useMemo(() => {
|
|
443
|
-
const _columnsList: IReqorePanelSubAction[] = [
|
|
444
|
-
{
|
|
445
|
-
divider: true,
|
|
446
|
-
label: 'Show / hide columns',
|
|
447
|
-
},
|
|
448
|
-
];
|
|
443
|
+
const _columnsList: IReqorePanelSubAction[] = [];
|
|
449
444
|
|
|
450
445
|
const addColumn = (column: IReqoreTableColumn) => {
|
|
451
446
|
_columnsList.push({
|
|
@@ -471,6 +466,13 @@ const ReqoreTable = ({
|
|
|
471
466
|
}
|
|
472
467
|
});
|
|
473
468
|
|
|
469
|
+
if (count(_columnsList)) {
|
|
470
|
+
_columnsList.unshift({
|
|
471
|
+
divider: true,
|
|
472
|
+
label: 'Show / hide columns',
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
474
476
|
return _columnsList;
|
|
475
477
|
}, [finalColumns]);
|
|
476
478
|
|
|
@@ -494,15 +496,17 @@ const ReqoreTable = ({
|
|
|
494
496
|
const tableActions = useMemo<IReqorePanelAction[]>(() => {
|
|
495
497
|
const finalActions: IReqorePanelAction[] = [...actions];
|
|
496
498
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
499
|
+
if (count(columnsList)) {
|
|
500
|
+
finalActions.push({
|
|
501
|
+
label: 'Columns',
|
|
502
|
+
icon: 'LayoutColumnLine',
|
|
503
|
+
className: 'reqore-table-columns-options',
|
|
504
|
+
badge: getColumnsCount(getOnlyShownColumns(finalColumns)),
|
|
505
|
+
intent: hasHiddenColumns(finalColumns) ? 'info' : undefined,
|
|
506
|
+
multiSelect: true,
|
|
507
|
+
actions: columnsList,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
506
510
|
|
|
507
511
|
if (filterable) {
|
|
508
512
|
finalActions.push({
|
|
@@ -124,12 +124,18 @@ const ReqoreTableRow = ({
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
let content = cell?.content;
|
|
128
128
|
|
|
129
129
|
if (isFunction(content)) {
|
|
130
|
-
|
|
130
|
+
// Check what type does the content function return
|
|
131
|
+
if (React.isValidElement(content(data))) {
|
|
132
|
+
const Content = content;
|
|
133
|
+
// If it's a react element, return it
|
|
134
|
+
return <Content {...data} _size={size} _dataId={dataId} />;
|
|
135
|
+
}
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
// If it's a function, call it and return the result
|
|
138
|
+
content = content(data) as any;
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
if (isString(content)) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ReqoreIcon from '../Icon';
|
|
2
|
+
import { ReqoreP } from '../Paragraph';
|
|
3
|
+
|
|
4
|
+
export interface IReqoreTableValueProps {
|
|
5
|
+
value?: string | number | boolean | any[] | { [key: string]: any };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const ReqoreTableValue = ({ value }: IReqoreTableValueProps) => {
|
|
9
|
+
if (value === undefined || value === null) {
|
|
10
|
+
return <>-</>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
switch (typeof value) {
|
|
14
|
+
case 'string':
|
|
15
|
+
case 'number':
|
|
16
|
+
return <ReqoreP className='reqore-table-text'>{value}</ReqoreP>;
|
|
17
|
+
case 'boolean':
|
|
18
|
+
return (
|
|
19
|
+
<ReqoreIcon
|
|
20
|
+
icon={value ? 'CheckLine' : 'CloseLine'}
|
|
21
|
+
intent={value ? 'success' : 'danger'}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
default:
|
|
25
|
+
return <ReqoreP className='reqore-table-text'>{JSON.stringify(value)}</ReqoreP>;
|
|
26
|
+
}
|
|
27
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -24,6 +24,7 @@ export {
|
|
|
24
24
|
} from './components/Header';
|
|
25
25
|
export { default as ReqoreIcon } from './components/Icon';
|
|
26
26
|
export { default as ReqoreInput } from './components/Input';
|
|
27
|
+
export { IReqoreKeyValueTableProps, ReqoreKeyValueTable } from './components/KeyValueTable';
|
|
27
28
|
export { default as ReqoreLayoutContent } from './components/Layout/content';
|
|
28
29
|
export { default as ReqoreMenu } from './components/Menu';
|
|
29
30
|
export { default as ReqoreMenuDivider } from './components/Menu/divider';
|
|
@@ -49,6 +50,7 @@ export { default as ReqoreTable } from './components/Table';
|
|
|
49
50
|
export { ReqoreTableBodyCell } from './components/Table/cell';
|
|
50
51
|
export { ReqoreTableHeaderCell } from './components/Table/headerCell';
|
|
51
52
|
export { default as ReqoreTableRow } from './components/Table/row';
|
|
53
|
+
export { ReqoreTableValue } from './components/Table/value';
|
|
52
54
|
export { default as ReqoreTabs } from './components/Tabs';
|
|
53
55
|
export { default as ReqoreTabsContent } from './components/Tabs/content';
|
|
54
56
|
export { default as ReqoreTabsListItem } from './components/Tabs/item';
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
|
+
import ReqoreIcon from '../../components/Icon';
|
|
3
|
+
import { IReqoreKeyValueTableProps, ReqoreKeyValueTable } from '../../components/KeyValueTable';
|
|
4
|
+
import {
|
|
5
|
+
IReqoreTableProps,
|
|
6
|
+
IReqoreTableRowData,
|
|
7
|
+
TReqoreTableColumnContent,
|
|
8
|
+
} from '../../components/Table';
|
|
9
|
+
import { TReqorePaginationType } from '../../constants/paging';
|
|
10
|
+
import { CustomIntentArg, FlatArg, IntentArg, SizeArg, argManager } from '../utils/args';
|
|
11
|
+
|
|
12
|
+
const { createArg } = argManager<IReqoreKeyValueTableProps>();
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Collections/Key Value Table/Stories',
|
|
16
|
+
argTypes: {
|
|
17
|
+
...createArg('rounded', {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
name: 'Rounded',
|
|
20
|
+
description: 'If the table should have rounded corners',
|
|
21
|
+
}),
|
|
22
|
+
...createArg('striped', {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
name: 'Striped',
|
|
25
|
+
description: 'If the table should have striped rows',
|
|
26
|
+
}),
|
|
27
|
+
...createArg('width', {
|
|
28
|
+
type: 'number',
|
|
29
|
+
defaultValue: undefined,
|
|
30
|
+
name: 'Width',
|
|
31
|
+
description: 'The width of the table',
|
|
32
|
+
}),
|
|
33
|
+
...createArg('height', {
|
|
34
|
+
type: 'number',
|
|
35
|
+
defaultValue: 600,
|
|
36
|
+
name: 'Height',
|
|
37
|
+
description: 'The height of the table',
|
|
38
|
+
}),
|
|
39
|
+
...createArg('data', {
|
|
40
|
+
defaultValue: {
|
|
41
|
+
firstName: 'Filip',
|
|
42
|
+
lastName: 'Machinia',
|
|
43
|
+
age: 25,
|
|
44
|
+
married: false,
|
|
45
|
+
'In Relationship': true,
|
|
46
|
+
DOB: '1995-01-01',
|
|
47
|
+
occupation: 'Software Engineer',
|
|
48
|
+
address: {
|
|
49
|
+
street: 'Some street',
|
|
50
|
+
city: 'Some city',
|
|
51
|
+
country: 'Some country',
|
|
52
|
+
},
|
|
53
|
+
groups: ['Admin', 'User'],
|
|
54
|
+
race: 'Human',
|
|
55
|
+
sex: 'Male',
|
|
56
|
+
height: 180,
|
|
57
|
+
weight: 80,
|
|
58
|
+
device: undefined,
|
|
59
|
+
OS: 'MacOS',
|
|
60
|
+
browser: 'Chrome',
|
|
61
|
+
email: 'test@test.com',
|
|
62
|
+
phone: '+420 123 456 789',
|
|
63
|
+
website: 'https://machinia.com',
|
|
64
|
+
company: 'Machinia',
|
|
65
|
+
},
|
|
66
|
+
name: 'Data',
|
|
67
|
+
description: 'The data to be displayed in the table',
|
|
68
|
+
}),
|
|
69
|
+
...createArg('fill', {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
defaultValue: false,
|
|
72
|
+
name: 'Fill',
|
|
73
|
+
description: 'Whether the table should fill the parent',
|
|
74
|
+
}),
|
|
75
|
+
...SizeArg,
|
|
76
|
+
...FlatArg,
|
|
77
|
+
...IntentArg,
|
|
78
|
+
...CustomIntentArg('selectedRowIntent'),
|
|
79
|
+
},
|
|
80
|
+
} as Meta<IReqoreTableProps>;
|
|
81
|
+
|
|
82
|
+
const Template: Story<IReqoreKeyValueTableProps> = (args) => {
|
|
83
|
+
return <ReqoreKeyValueTable label='Table' {...args} />;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Basic = Template.bind({});
|
|
87
|
+
export const NoLabel = Template.bind({});
|
|
88
|
+
NoLabel.args = {
|
|
89
|
+
label: undefined,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const CustomWidth = Template.bind({});
|
|
93
|
+
CustomWidth.args = {
|
|
94
|
+
width: 400,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const NotFlat = Template.bind({});
|
|
98
|
+
NotFlat.args = {
|
|
99
|
+
flat: false,
|
|
100
|
+
};
|
|
101
|
+
export const Striped = Template.bind({});
|
|
102
|
+
Striped.args = {
|
|
103
|
+
striped: true,
|
|
104
|
+
};
|
|
105
|
+
export const Filterable = Template.bind({});
|
|
106
|
+
Filterable.args = {
|
|
107
|
+
filterable: true,
|
|
108
|
+
};
|
|
109
|
+
export const DefaultFilter = Template.bind({});
|
|
110
|
+
DefaultFilter.args = {
|
|
111
|
+
filterable: true,
|
|
112
|
+
filter: 'Mach',
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const DefaultValueFilter = Template.bind({});
|
|
116
|
+
DefaultValueFilter.args = {
|
|
117
|
+
defaultValueFilter: 80,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const AllFiltersActive = Template.bind({});
|
|
121
|
+
AllFiltersActive.args = {
|
|
122
|
+
filterable: true,
|
|
123
|
+
filter: 1,
|
|
124
|
+
defaultValueFilter: 80,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const NoDataMessage = Template.bind({});
|
|
128
|
+
NoDataMessage.args = {
|
|
129
|
+
filterable: true,
|
|
130
|
+
filter: 'asjkghakshgjkashg',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const Zoomable = Template.bind({});
|
|
134
|
+
Zoomable.args = {
|
|
135
|
+
zoomable: true,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const FillParent = Template.bind({});
|
|
139
|
+
FillParent.args = {
|
|
140
|
+
fill: true,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const Sizes = Template.bind({});
|
|
144
|
+
Sizes.args = {
|
|
145
|
+
size: 'small',
|
|
146
|
+
filterable: true,
|
|
147
|
+
wrapperSize: 'big',
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const DefaultPaging = Template.bind({});
|
|
151
|
+
DefaultPaging.args = {
|
|
152
|
+
paging: 'buttons',
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const CustomColumnWidths = Template.bind({});
|
|
156
|
+
CustomColumnWidths.args = {
|
|
157
|
+
minValueWidth: 500,
|
|
158
|
+
maxKeyWidth: 100,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const CustomKeyIntent = Template.bind({});
|
|
162
|
+
CustomKeyIntent.args = {
|
|
163
|
+
keyColumnIntent: 'success',
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const CustomAlign = Template.bind({});
|
|
167
|
+
CustomAlign.args = {
|
|
168
|
+
keyAlign: 'right',
|
|
169
|
+
valueAlign: 'center',
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const CustomPaging = Template.bind({});
|
|
173
|
+
CustomPaging.args = {
|
|
174
|
+
paging: {
|
|
175
|
+
fluid: true,
|
|
176
|
+
loadMoreLabel: 'Load more rows...',
|
|
177
|
+
showLabels: true,
|
|
178
|
+
infinite: true,
|
|
179
|
+
itemsPerPage: 2,
|
|
180
|
+
} as TReqorePaginationType<IReqoreTableRowData>,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const CustomValueRenderer = Template.bind({});
|
|
184
|
+
CustomValueRenderer.args = {
|
|
185
|
+
valueRenderer: ({ value, tableKey }, Component): TReqoreTableColumnContent | JSX.Element => {
|
|
186
|
+
switch (tableKey) {
|
|
187
|
+
case 'race':
|
|
188
|
+
return 'tag:success';
|
|
189
|
+
case 'sex':
|
|
190
|
+
return <ReqoreIcon icon={value === 'Male' ? 'User6Line' : 'User6Fill'} />;
|
|
191
|
+
case 'height':
|
|
192
|
+
return <>{value} cm</>;
|
|
193
|
+
case 'weight':
|
|
194
|
+
return <Component value={value} />;
|
|
195
|
+
default:
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
};
|