@performant-software/semantic-components 1.0.23-beta.2 → 1.0.24-beta.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/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DataTable.js +0 -1
- package/src/components/FileUploadModal.js +9 -0
- package/src/components/List.js +0 -72
- package/src/components/ListTable.js +0 -9
- package/src/i18n/en.json +0 -1
- package/types/components/DataTable.js.flow +0 -1
- package/types/components/FileUploadModal.js.flow +9 -0
- package/types/components/List.js.flow +0 -72
- package/types/components/ListTable.js.flow +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@performant-software/semantic-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24-beta.0",
|
|
4
4
|
"description": "A package of shared components based on the Semantic UI Framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "webpack --mode production && flow-copy-source -v src types"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@performant-software/shared-components": "^1.0.
|
|
15
|
+
"@performant-software/shared-components": "^1.0.24-beta.0",
|
|
16
16
|
"@react-google-maps/api": "^2.8.1",
|
|
17
17
|
"axios": "^0.26.1",
|
|
18
18
|
"i18next": "^19.4.4",
|
|
@@ -48,6 +48,11 @@ type Props = {
|
|
|
48
48
|
*/
|
|
49
49
|
onClose: () => void,
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Callback fired when the upload has completed.
|
|
53
|
+
*/
|
|
54
|
+
onComplete: () => void,
|
|
55
|
+
|
|
51
56
|
/**
|
|
52
57
|
* Callback fired when the save button is clicked. See <code>strategy</code> prop.
|
|
53
58
|
*/
|
|
@@ -151,6 +156,10 @@ const FileUploadModal: ComponentType<any> = (props: Props) => {
|
|
|
151
156
|
const onComplete = useCallback(() => {
|
|
152
157
|
setUploading(false);
|
|
153
158
|
|
|
159
|
+
if (props.onComplete) {
|
|
160
|
+
props.onComplete();
|
|
161
|
+
}
|
|
162
|
+
|
|
154
163
|
if (props.closeOnComplete) {
|
|
155
164
|
props.onClose();
|
|
156
165
|
}
|
package/src/components/List.js
CHANGED
|
@@ -79,15 +79,6 @@ type Props = {
|
|
|
79
79
|
*/
|
|
80
80
|
className?: string,
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* If provided, a CSV export button will be rendered in the list header.
|
|
84
|
-
*/
|
|
85
|
-
csvExportButton?: {
|
|
86
|
-
color: string,
|
|
87
|
-
location: string,
|
|
88
|
-
onClick?: () => void
|
|
89
|
-
},
|
|
90
|
-
|
|
91
82
|
/**
|
|
92
83
|
* If provided, a "delete all" button will be rendered in the list header.
|
|
93
84
|
*/
|
|
@@ -217,7 +208,6 @@ type State = {
|
|
|
217
208
|
};
|
|
218
209
|
|
|
219
210
|
const BUTTON_KEY_ADD = 'add';
|
|
220
|
-
const BUTTON_KEY_CSV_EXPORT = 'csv-export';
|
|
221
211
|
const BUTTON_KEY_DELETE_ALL = 'delete-all';
|
|
222
212
|
|
|
223
213
|
/**
|
|
@@ -239,7 +229,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
239
229
|
},
|
|
240
230
|
buttons: [],
|
|
241
231
|
className: '',
|
|
242
|
-
csvExportButton: undefined,
|
|
243
232
|
filters: undefined,
|
|
244
233
|
modal: undefined,
|
|
245
234
|
page: 1,
|
|
@@ -280,7 +269,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
280
269
|
|
|
281
270
|
const {
|
|
282
271
|
addButton = {},
|
|
283
|
-
csvExportButton = {},
|
|
284
272
|
deleteButton = {},
|
|
285
273
|
modal,
|
|
286
274
|
selectable
|
|
@@ -300,13 +288,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
300
288
|
});
|
|
301
289
|
}
|
|
302
290
|
|
|
303
|
-
// Add the CSV export button to the list if the csvExport prop is passed
|
|
304
|
-
if (csvExportButton.location === location && !selectable) {
|
|
305
|
-
buttons.push({
|
|
306
|
-
render: this.renderCsvExportButton.bind(this)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
291
|
// Resolve the array of other buttons
|
|
311
292
|
buttons.push(..._.filter(this.props.buttons, (button) => {
|
|
312
293
|
let include = false;
|
|
@@ -350,36 +331,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
350
331
|
this.setState({ selectedItem: copy, modalEdit: true });
|
|
351
332
|
}
|
|
352
333
|
|
|
353
|
-
/**
|
|
354
|
-
* Generates and downloads a CSV file containing all
|
|
355
|
-
* the data in the table.
|
|
356
|
-
*
|
|
357
|
-
* @param items
|
|
358
|
-
*/
|
|
359
|
-
onCsvExportButton() {
|
|
360
|
-
let csv = `${this.props.columns.map((col) => `"${col.label}"`).join(',')}\n`;
|
|
361
|
-
|
|
362
|
-
this.props.items.forEach((item) => {
|
|
363
|
-
csv = csv.concat(`${this.props.columns.map((col) => {
|
|
364
|
-
if (col.resolve) {
|
|
365
|
-
return col.resolve(item);
|
|
366
|
-
}
|
|
367
|
-
return `"${item[col.name]}"`;
|
|
368
|
-
}).join(',')}\n`);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
const element = document.createElement('a');
|
|
372
|
-
element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(csv)}`);
|
|
373
|
-
element.setAttribute('download', `${this.props.collectionName || 'table'}.csv`);
|
|
374
|
-
|
|
375
|
-
element.style.display = 'none';
|
|
376
|
-
document.body.appendChild(element);
|
|
377
|
-
|
|
378
|
-
element.click();
|
|
379
|
-
|
|
380
|
-
document.body.removeChild(element);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
334
|
/**
|
|
384
335
|
* Deletes the currently selected item and clears the state.
|
|
385
336
|
*
|
|
@@ -582,29 +533,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
582
533
|
);
|
|
583
534
|
}
|
|
584
535
|
|
|
585
|
-
/**
|
|
586
|
-
* Renders the CSV export button.
|
|
587
|
-
*
|
|
588
|
-
* @returns {null|*}
|
|
589
|
-
*/
|
|
590
|
-
renderCsvExportButton() {
|
|
591
|
-
if (!this.props.csvExportButton) {
|
|
592
|
-
return null;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
return (
|
|
596
|
-
<Button
|
|
597
|
-
basic
|
|
598
|
-
color={this.props.csvExportButton.color}
|
|
599
|
-
key={BUTTON_KEY_CSV_EXPORT}
|
|
600
|
-
onClick={this.onCsvExportButton.bind(this)}
|
|
601
|
-
>
|
|
602
|
-
<Icon name='shopping basket' />
|
|
603
|
-
{ i18n.t('List.buttons.csvExport') }
|
|
604
|
-
</Button>
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
536
|
/**
|
|
609
537
|
* Renders the delete all button.
|
|
610
538
|
*
|
|
@@ -14,15 +14,6 @@ type Props = DataListProps & DataTableProps & {
|
|
|
14
14
|
*/
|
|
15
15
|
configurable?: boolean,
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* If provided, a CSV export button will be rendered in the list header.
|
|
19
|
-
*/
|
|
20
|
-
csvExportButton?: {
|
|
21
|
-
color: string,
|
|
22
|
-
location: string,
|
|
23
|
-
onClick?: () => void
|
|
24
|
-
},
|
|
25
|
-
|
|
26
17
|
/**
|
|
27
18
|
* The name of the default sort column.
|
|
28
19
|
*/
|
package/src/i18n/en.json
CHANGED
|
@@ -48,6 +48,11 @@ type Props = {
|
|
|
48
48
|
*/
|
|
49
49
|
onClose: () => void,
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Callback fired when the upload has completed.
|
|
53
|
+
*/
|
|
54
|
+
onComplete: () => void,
|
|
55
|
+
|
|
51
56
|
/**
|
|
52
57
|
* Callback fired when the save button is clicked. See <code>strategy</code> prop.
|
|
53
58
|
*/
|
|
@@ -151,6 +156,10 @@ const FileUploadModal: ComponentType<any> = (props: Props) => {
|
|
|
151
156
|
const onComplete = useCallback(() => {
|
|
152
157
|
setUploading(false);
|
|
153
158
|
|
|
159
|
+
if (props.onComplete) {
|
|
160
|
+
props.onComplete();
|
|
161
|
+
}
|
|
162
|
+
|
|
154
163
|
if (props.closeOnComplete) {
|
|
155
164
|
props.onClose();
|
|
156
165
|
}
|
|
@@ -79,15 +79,6 @@ type Props = {
|
|
|
79
79
|
*/
|
|
80
80
|
className?: string,
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* If provided, a CSV export button will be rendered in the list header.
|
|
84
|
-
*/
|
|
85
|
-
csvExportButton?: {
|
|
86
|
-
color: string,
|
|
87
|
-
location: string,
|
|
88
|
-
onClick?: () => void
|
|
89
|
-
},
|
|
90
|
-
|
|
91
82
|
/**
|
|
92
83
|
* If provided, a "delete all" button will be rendered in the list header.
|
|
93
84
|
*/
|
|
@@ -217,7 +208,6 @@ type State = {
|
|
|
217
208
|
};
|
|
218
209
|
|
|
219
210
|
const BUTTON_KEY_ADD = 'add';
|
|
220
|
-
const BUTTON_KEY_CSV_EXPORT = 'csv-export';
|
|
221
211
|
const BUTTON_KEY_DELETE_ALL = 'delete-all';
|
|
222
212
|
|
|
223
213
|
/**
|
|
@@ -239,7 +229,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
239
229
|
},
|
|
240
230
|
buttons: [],
|
|
241
231
|
className: '',
|
|
242
|
-
csvExportButton: undefined,
|
|
243
232
|
filters: undefined,
|
|
244
233
|
modal: undefined,
|
|
245
234
|
page: 1,
|
|
@@ -280,7 +269,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
280
269
|
|
|
281
270
|
const {
|
|
282
271
|
addButton = {},
|
|
283
|
-
csvExportButton = {},
|
|
284
272
|
deleteButton = {},
|
|
285
273
|
modal,
|
|
286
274
|
selectable
|
|
@@ -300,13 +288,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
300
288
|
});
|
|
301
289
|
}
|
|
302
290
|
|
|
303
|
-
// Add the CSV export button to the list if the csvExport prop is passed
|
|
304
|
-
if (csvExportButton.location === location && !selectable) {
|
|
305
|
-
buttons.push({
|
|
306
|
-
render: this.renderCsvExportButton.bind(this)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
291
|
// Resolve the array of other buttons
|
|
311
292
|
buttons.push(..._.filter(this.props.buttons, (button) => {
|
|
312
293
|
let include = false;
|
|
@@ -350,36 +331,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
350
331
|
this.setState({ selectedItem: copy, modalEdit: true });
|
|
351
332
|
}
|
|
352
333
|
|
|
353
|
-
/**
|
|
354
|
-
* Generates and downloads a CSV file containing all
|
|
355
|
-
* the data in the table.
|
|
356
|
-
*
|
|
357
|
-
* @param items
|
|
358
|
-
*/
|
|
359
|
-
onCsvExportButton() {
|
|
360
|
-
let csv = `${this.props.columns.map((col) => `"${col.label}"`).join(',')}\n`;
|
|
361
|
-
|
|
362
|
-
this.props.items.forEach((item) => {
|
|
363
|
-
csv = csv.concat(`${this.props.columns.map((col) => {
|
|
364
|
-
if (col.resolve) {
|
|
365
|
-
return col.resolve(item);
|
|
366
|
-
}
|
|
367
|
-
return `"${item[col.name]}"`;
|
|
368
|
-
}).join(',')}\n`);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
const element = document.createElement('a');
|
|
372
|
-
element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(csv)}`);
|
|
373
|
-
element.setAttribute('download', `${this.props.collectionName || 'table'}.csv`);
|
|
374
|
-
|
|
375
|
-
element.style.display = 'none';
|
|
376
|
-
document.body.appendChild(element);
|
|
377
|
-
|
|
378
|
-
element.click();
|
|
379
|
-
|
|
380
|
-
document.body.removeChild(element);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
334
|
/**
|
|
384
335
|
* Deletes the currently selected item and clears the state.
|
|
385
336
|
*
|
|
@@ -582,29 +533,6 @@ const useList = (WrappedComponent: ComponentType<any>) => (
|
|
|
582
533
|
);
|
|
583
534
|
}
|
|
584
535
|
|
|
585
|
-
/**
|
|
586
|
-
* Renders the CSV export button.
|
|
587
|
-
*
|
|
588
|
-
* @returns {null|*}
|
|
589
|
-
*/
|
|
590
|
-
renderCsvExportButton() {
|
|
591
|
-
if (!this.props.csvExportButton) {
|
|
592
|
-
return null;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
return (
|
|
596
|
-
<Button
|
|
597
|
-
basic
|
|
598
|
-
color={this.props.csvExportButton.color}
|
|
599
|
-
key={BUTTON_KEY_CSV_EXPORT}
|
|
600
|
-
onClick={this.onCsvExportButton.bind(this)}
|
|
601
|
-
>
|
|
602
|
-
<Icon name='shopping basket' />
|
|
603
|
-
{ i18n.t('List.buttons.csvExport') }
|
|
604
|
-
</Button>
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
536
|
/**
|
|
609
537
|
* Renders the delete all button.
|
|
610
538
|
*
|
|
@@ -14,15 +14,6 @@ type Props = DataListProps & DataTableProps & {
|
|
|
14
14
|
*/
|
|
15
15
|
configurable?: boolean,
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* If provided, a CSV export button will be rendered in the list header.
|
|
19
|
-
*/
|
|
20
|
-
csvExportButton?: {
|
|
21
|
-
color: string,
|
|
22
|
-
location: string,
|
|
23
|
-
onClick?: () => void
|
|
24
|
-
},
|
|
25
|
-
|
|
26
17
|
/**
|
|
27
18
|
* The name of the default sort column.
|
|
28
19
|
*/
|