@performant-software/semantic-components 1.0.2 → 1.0.3-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 +3 -3
- package/src/components/ArrowButtons.js +12 -10
- package/src/components/DataList.js +87 -3
- package/src/components/DataTable.js +83 -31
- package/src/components/DataTableColumnSelector.js +41 -5
- package/src/components/DataView.js +1 -1
- package/src/components/EditModal.js +23 -3
- package/src/components/EditPage.js +32 -3
- package/src/components/EmbeddedList.js +17 -35
- package/src/components/FileUpload.js +15 -0
- package/src/components/FileUploadModal.js +36 -3
- package/src/components/ItemCollection.js +43 -6
- package/src/components/ItemList.js +27 -30
- package/src/components/Items.js +79 -9
- package/src/components/List.js +128 -26
- package/src/components/ListTable.js +50 -15
- package/types/components/ArrowButtons.js.flow +12 -10
- package/types/components/DataList.js.flow +87 -3
- package/types/components/DataTable.js.flow +83 -31
- package/types/components/DataTableColumnSelector.js.flow +41 -5
- package/types/components/DataView.js.flow +1 -1
- package/types/components/EditModal.js.flow +23 -3
- package/types/components/EditPage.js.flow +32 -3
- package/types/components/EmbeddedList.js.flow +17 -35
- package/types/components/FileUpload.js.flow +15 -0
- package/types/components/FileUploadModal.js.flow +36 -3
- package/types/components/ItemCollection.js.flow +43 -6
- package/types/components/ItemList.js.flow +27 -30
- package/types/components/Items.js.flow +79 -9
- package/types/components/List.js.flow +128 -26
- package/types/components/ListTable.js.flow +50 -15
|
@@ -8,26 +8,106 @@ import i18n from '../i18n/i18n';
|
|
|
8
8
|
import Toaster from './Toaster';
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Name of the collection to retrieve from the API response.
|
|
13
|
+
*/
|
|
11
14
|
collectionName: string,
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The default number of records to display on a single page.
|
|
18
|
+
*/
|
|
12
19
|
defaultPerPage?: number,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The default value for the search input element.
|
|
23
|
+
*/
|
|
13
24
|
defaultSearch?: string,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The default value to use for sorting the list.
|
|
28
|
+
*/
|
|
14
29
|
defaultSort?: string,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The default direction in which to sort the list.
|
|
33
|
+
*/
|
|
15
34
|
defaultSortDirection?: string,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* If provided, the passed <code>component</code> will be rendered when the filter button is clicked.
|
|
38
|
+
* <br />
|
|
39
|
+
* <br />
|
|
40
|
+
*
|
|
41
|
+
* Values passed in the <code>defaults</code> and <code>props</code> properties will be made available in the
|
|
42
|
+
* passed component.
|
|
43
|
+
* <br />
|
|
44
|
+
* <br />
|
|
45
|
+
*
|
|
46
|
+
* The <code>onChange</code> callback will fire when the filters are modified. This action will also reload the list,
|
|
47
|
+
* passing the new filters the <code>onLoad</code> callback.
|
|
48
|
+
*/
|
|
16
49
|
filters?: {
|
|
17
50
|
component: ComponentType<any>,
|
|
18
51
|
defaults?: any,
|
|
19
52
|
props?: any,
|
|
20
53
|
onChange?: (filter: any) => Promise<any>
|
|
21
54
|
},
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Callback fired when the "delete" action is clicked.
|
|
58
|
+
* @param item
|
|
59
|
+
*/
|
|
22
60
|
onDelete?: (item: any) => Promise<any>,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Callback fired when the "delete all" action is clicked. This action is typically renedered in the header and will
|
|
64
|
+
* apply to every item in the list.
|
|
65
|
+
*/
|
|
23
66
|
onDeleteAll?: () => Promise<any>,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Callback fired when loading the list of items from an API. This callback is fired any time the list changes.
|
|
70
|
+
*/
|
|
24
71
|
onLoad: (params: any) => Promise<any>,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Callback fired when an item is saved via the add/edit modal.
|
|
75
|
+
*/
|
|
25
76
|
onSave?: (item: any) => Promise<any>,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The numeric list of options to allow the user to select for the number of records to display per page.
|
|
80
|
+
*/
|
|
26
81
|
perPageOptions?: Array<number>,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* If provided, the <code>onLoad</code> callback will fire after a timeout of the passed number of milliseconds. This
|
|
85
|
+
* can be useful in order to show progress (file upload, download, etc) that must be retrieved from the server.
|
|
86
|
+
*/
|
|
27
87
|
polling?: number,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Callback fired when an error occurs. The passed error can take any form and is up to the consuming component to
|
|
91
|
+
* interpret. The return value should be an array of user-friendly error messages.
|
|
92
|
+
*/
|
|
28
93
|
resolveErrors?: (error: any) => Array<string>,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Used to inform the list that an external save has taken place. When set to <code>true</code>, a success toaster
|
|
97
|
+
* will display.
|
|
98
|
+
*/
|
|
29
99
|
saved?: boolean,
|
|
30
|
-
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* If <code>true</code>, this component will render a search input element in the list header.
|
|
103
|
+
*/
|
|
104
|
+
searchable?: boolean,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* If provided, list properties (page number, columns, filters, etc) will be stored in the passed storage element
|
|
108
|
+
* and rehydrated each time the component is mounted. This is useful in order to persist filters, searches, and
|
|
109
|
+
* other properties when a user navigates away from the list.
|
|
110
|
+
*/
|
|
31
111
|
session?: {
|
|
32
112
|
key: string,
|
|
33
113
|
storage: typeof sessionStorage
|
|
@@ -444,7 +524,7 @@ const useDataList = (WrappedComponent: ComponentType<any>) => (
|
|
|
444
524
|
sortColumn={this.state.sortColumn}
|
|
445
525
|
sortDirection={this.state.sortDirection}
|
|
446
526
|
/>
|
|
447
|
-
{
|
|
527
|
+
{this.state.saved && (
|
|
448
528
|
<Toaster
|
|
449
529
|
onDismiss={() => this.setState({ saved: false })}
|
|
450
530
|
type={Toaster.MessageTypes.positive}
|
|
@@ -457,7 +537,7 @@ const useDataList = (WrappedComponent: ComponentType<any>) => (
|
|
|
457
537
|
/>
|
|
458
538
|
</Toaster>
|
|
459
539
|
)}
|
|
460
|
-
{
|
|
540
|
+
{this.state.error && (
|
|
461
541
|
<Toaster
|
|
462
542
|
onDismiss={() => this.setState({ error: false })}
|
|
463
543
|
timeout={0}
|
|
@@ -563,3 +643,7 @@ export {
|
|
|
563
643
|
SORT_ASCENDING,
|
|
564
644
|
SORT_DESCENDING
|
|
565
645
|
};
|
|
646
|
+
|
|
647
|
+
export type {
|
|
648
|
+
Props
|
|
649
|
+
};
|
|
@@ -13,45 +13,98 @@ import {
|
|
|
13
13
|
import _ from 'underscore';
|
|
14
14
|
import i18n from '../i18n/i18n';
|
|
15
15
|
import ColumnResize from './ColumnResize';
|
|
16
|
-
import useColumnSelector from './DataTableColumnSelector';
|
|
17
|
-
import useList from './List';
|
|
16
|
+
import useColumnSelector, { Props as ColumnSelectorProps } from './DataTableColumnSelector';
|
|
17
|
+
import useList, { Props as ListProps } from './List';
|
|
18
18
|
import './DataTable.css';
|
|
19
19
|
|
|
20
20
|
import type { Action } from './List';
|
|
21
21
|
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
render?: (item: any) => void,
|
|
28
|
-
renderHeader?: (item: any) => void,
|
|
29
|
-
resolve?: (item: any) => void,
|
|
30
|
-
sortable: boolean
|
|
31
|
-
};
|
|
22
|
+
type Props = ListProps & ColumnSelectorProps & {
|
|
23
|
+
/**
|
|
24
|
+
* If <code>true</code>, the rows of the table can be expanded and collapsed.
|
|
25
|
+
*/
|
|
26
|
+
expandableRows?: boolean,
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Function that returns JSX to render when the row for the passed item is expanded.
|
|
30
|
+
*/
|
|
31
|
+
expandPanel?: (item: any, activePanel: any) => Element<any>,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Callback returning <code>true</code> if the row for the passed item is selected.
|
|
35
|
+
*/
|
|
36
|
+
isRowSelected?: (item: any) => boolean,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An array of objects to render as rows in the list.
|
|
40
|
+
*/
|
|
40
41
|
items: ?Array<any>,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Set to <code>true</code> if the list is currently loading data. If true, a loading indicator will display.
|
|
45
|
+
*/
|
|
46
|
+
loading?: boolean,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Callback to clear the selected set of records.
|
|
50
|
+
*/
|
|
51
|
+
onClearSelected?: () => void,
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Callback fired when the passed column is clicked.
|
|
55
|
+
*/
|
|
56
|
+
onColumnClick?: (column: Column) => void,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Callback fired when the passed item is selected. This callback is <i>only</i> fired if the <code>selectable</code>
|
|
60
|
+
* prop is passed as <code>true</code>.
|
|
61
|
+
*/
|
|
62
|
+
onRowSelect?: (item: any)=> void,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Callback fired when the select all checkbox in the table header is clicked.
|
|
66
|
+
*/
|
|
67
|
+
onSelectAll?: (items: Array<any>) => void,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A function that returns a JSX element to render when the list is empty.
|
|
71
|
+
*/
|
|
72
|
+
renderEmptyMessage?: () => Element<any>,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A function that returns a custom JSX element to render when the list is empty. This element will replace the
|
|
76
|
+
* entire single row of the table.
|
|
77
|
+
*/
|
|
47
78
|
renderEmptyRow?: () => void,
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A function that returns a custom JSX element to render for the passed item. This element will replace the entire
|
|
82
|
+
* table row.
|
|
83
|
+
*/
|
|
48
84
|
renderItem?: (item: any, index: number, children?: any) => Element<any>,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* If set to <code>true</code>, checkboxes will render as the first table column, allowing each row to be selectable.
|
|
88
|
+
* The consuming component is responsible for tracking the selected items.
|
|
89
|
+
*/
|
|
90
|
+
selectable?: boolean,
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Name of the current sort column.
|
|
94
|
+
*/
|
|
49
95
|
sortColumn?: string,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Current sort direction (ascending or descending).
|
|
99
|
+
*/
|
|
50
100
|
sortDirection?: string,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Customization props for the
|
|
104
|
+
* <a target="_blank" href="https://react.semantic-ui.com/collections/table/"><code>Table</code></a>
|
|
105
|
+
* component.
|
|
106
|
+
*/
|
|
107
|
+
tableProps?: any
|
|
55
108
|
};
|
|
56
109
|
|
|
57
110
|
type State = {
|
|
@@ -596,7 +649,6 @@ DataTable.defaultProps = {
|
|
|
596
649
|
renderSearch: undefined,
|
|
597
650
|
renderItem: undefined,
|
|
598
651
|
showRecordCount: false,
|
|
599
|
-
selectedRows: [],
|
|
600
652
|
sortColumn: undefined,
|
|
601
653
|
sortDirection: undefined,
|
|
602
654
|
};
|
|
@@ -604,5 +656,5 @@ DataTable.defaultProps = {
|
|
|
604
656
|
export default useColumnSelector(useList(DataTable));
|
|
605
657
|
|
|
606
658
|
export type {
|
|
607
|
-
|
|
659
|
+
Props
|
|
608
660
|
};
|
|
@@ -5,14 +5,45 @@ import React, { Component, type ComponentType, type Element } from 'react';
|
|
|
5
5
|
import { Checkbox, Dropdown, Icon } from 'semantic-ui-react';
|
|
6
6
|
import _ from 'underscore';
|
|
7
7
|
import Draggable from './Draggable';
|
|
8
|
+
import type { Props as ListProps } from './List';
|
|
8
9
|
import './DataTableColumnSelector.css';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
type Column = {
|
|
12
|
+
className?: string,
|
|
13
|
+
hidden?: boolean,
|
|
14
|
+
label?: string,
|
|
15
|
+
name: string,
|
|
16
|
+
render?: (item: any) => Element<any>,
|
|
17
|
+
renderHeader?: (item: any) => Element<any>,
|
|
18
|
+
resolve?: (item: any) => any,
|
|
19
|
+
sortable: boolean
|
|
20
|
+
};
|
|
11
21
|
|
|
12
|
-
type Props = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
type Props = ListProps & {
|
|
23
|
+
/**
|
|
24
|
+
* CSS class name to append to the wrapped component.
|
|
25
|
+
*/
|
|
26
|
+
className?: string,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An array of columns to display within the <code>Table</code>.
|
|
30
|
+
* <br />
|
|
31
|
+
* <br />
|
|
32
|
+
*
|
|
33
|
+
* If only a <code>name</code> attribute is provided, the value for each record will be pulled from the item property
|
|
34
|
+
* matching that name.
|
|
35
|
+
* <br />
|
|
36
|
+
* <br />
|
|
37
|
+
*
|
|
38
|
+
* If a <code>resolve</code> callback is provided, the item will be passed to the function and the return value will
|
|
39
|
+
* display as the property value.
|
|
40
|
+
* <br />
|
|
41
|
+
* <br />
|
|
42
|
+
*
|
|
43
|
+
* If a <code>render</code> callback is provided, the item will be passed to the function and the return JSX
|
|
44
|
+
* will display as the property value.
|
|
45
|
+
*/
|
|
46
|
+
columns: Array<Column>
|
|
16
47
|
};
|
|
17
48
|
|
|
18
49
|
type State = {
|
|
@@ -165,3 +196,8 @@ const useColumnSelector = (WrappedComponent: ComponentType<any>) => (
|
|
|
165
196
|
);
|
|
166
197
|
|
|
167
198
|
export default useColumnSelector;
|
|
199
|
+
|
|
200
|
+
export type {
|
|
201
|
+
Column,
|
|
202
|
+
Props
|
|
203
|
+
};
|
|
@@ -19,7 +19,7 @@ import ModalContext from '../context/ModalContext';
|
|
|
19
19
|
import useDataList, { SORT_ASCENDING, SORT_DESCENDING } from './DataList';
|
|
20
20
|
import './DataView.css';
|
|
21
21
|
|
|
22
|
-
import type { Column } from './
|
|
22
|
+
import type { Column } from './DataTableColumnSelector';
|
|
23
23
|
|
|
24
24
|
type Sort = {
|
|
25
25
|
label: string,
|
|
@@ -14,13 +14,33 @@ import i18n from '../i18n/i18n';
|
|
|
14
14
|
import './EditModal.css';
|
|
15
15
|
|
|
16
16
|
type Props = EditContainerProps & {
|
|
17
|
+
/**
|
|
18
|
+
* The form component to render.
|
|
19
|
+
*/
|
|
17
20
|
component: ComponentType<any>,
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Callback fired when the close button is clicked.
|
|
24
|
+
*/
|
|
18
25
|
onClose: () => void,
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Callback fired when the save button is clicked.
|
|
29
|
+
*/
|
|
19
30
|
onSave: () => Promise<any>,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* If <code>true</code>, a loading indicator will display.
|
|
34
|
+
*/
|
|
20
35
|
showLoading: boolean
|
|
21
36
|
};
|
|
22
37
|
|
|
23
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The <code>EditModal</code> component can be used to edit the details of a single record within a modal view. This
|
|
40
|
+
* component uses the <code>EditContainer</code> higher-order component to facilitate all of the editing functionality.
|
|
41
|
+
* This component is responsible for rendering the container in which the editable form is rendered.
|
|
42
|
+
*/
|
|
43
|
+
const EditModal = useEditContainer((props: Props) => {
|
|
24
44
|
const OuterComponent = props.component;
|
|
25
45
|
|
|
26
46
|
const [showToaster, setShowToaster] = useState(false);
|
|
@@ -89,10 +109,10 @@ const EditModal = (props: Props) => {
|
|
|
89
109
|
</Modal.Actions>
|
|
90
110
|
</OuterComponent>
|
|
91
111
|
);
|
|
92
|
-
};
|
|
112
|
+
});
|
|
93
113
|
|
|
94
114
|
EditModal.defaultProps = {
|
|
95
115
|
showLoading: true
|
|
96
116
|
};
|
|
97
117
|
|
|
98
|
-
export default
|
|
118
|
+
export default EditModal;
|
|
@@ -18,11 +18,34 @@ import i18n from '../i18n/i18n';
|
|
|
18
18
|
import './EditPage.css';
|
|
19
19
|
|
|
20
20
|
type Props = EditContainerProps & {
|
|
21
|
+
/**
|
|
22
|
+
* CSS class name to append to the container <code>div</code> element.
|
|
23
|
+
*/
|
|
21
24
|
className?: string,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The form component to render.
|
|
28
|
+
*/
|
|
22
29
|
component: ComponentType<any>,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* If provided, the passed menu will render as tabs at the top of the page.
|
|
33
|
+
*/
|
|
23
34
|
menu?: MenuProps,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Callback fired when the close button is clicked.
|
|
38
|
+
*/
|
|
24
39
|
onClose: () => void,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Callback fired when the save button is clicked.
|
|
43
|
+
*/
|
|
25
44
|
onSave: () => Promise<any>,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If <code>true</code>, a loading indicator will display.
|
|
48
|
+
*/
|
|
26
49
|
showLoading: boolean
|
|
27
50
|
};
|
|
28
51
|
|
|
@@ -31,7 +54,12 @@ type State = {
|
|
|
31
54
|
showToaster: boolean
|
|
32
55
|
};
|
|
33
56
|
|
|
34
|
-
|
|
57
|
+
/**
|
|
58
|
+
* The <code>EditPage</code> component can be used to edit the details of a single record within a page view. This
|
|
59
|
+
* component uses the <code>EditContainer</code> higher-order component to facilitate all of the editing functionality.
|
|
60
|
+
* This component is responsible for rendering the container in which the editable form is rendered.
|
|
61
|
+
*/
|
|
62
|
+
class EditPageClass extends Component<Props, State> {
|
|
35
63
|
static defaultProps: any;
|
|
36
64
|
|
|
37
65
|
/**
|
|
@@ -238,11 +266,12 @@ class EditPage extends Component<Props, State> {
|
|
|
238
266
|
}
|
|
239
267
|
}
|
|
240
268
|
|
|
241
|
-
|
|
269
|
+
EditPageClass.defaultProps = {
|
|
242
270
|
showLoading: true
|
|
243
271
|
};
|
|
244
272
|
|
|
245
|
-
|
|
273
|
+
const EditPage = useEditContainer(EditPageClass);
|
|
274
|
+
export default EditPage;
|
|
246
275
|
|
|
247
276
|
export type EditPageProps = EditContainerProps & {
|
|
248
277
|
currentTab: string
|
|
@@ -4,45 +4,27 @@ import React, { Component, type ComponentType } from 'react';
|
|
|
4
4
|
import { Table } from 'semantic-ui-react';
|
|
5
5
|
import uuid from 'react-uuid';
|
|
6
6
|
import _ from 'underscore';
|
|
7
|
-
import DataTable from './DataTable';
|
|
7
|
+
import DataTable, { type Props as DataTableProps } from './DataTable';
|
|
8
8
|
import Draggable from './Draggable';
|
|
9
9
|
import './EmbeddedList.css';
|
|
10
10
|
|
|
11
|
-
import type {
|
|
12
|
-
import type { Column } from './DataTable';
|
|
11
|
+
import type { Column, Props as ColumnSelectorProps } from './DataTableColumnSelector';
|
|
13
12
|
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type Props = {
|
|
19
|
-
actions: Array<Action>,
|
|
20
|
-
addButton?: {
|
|
21
|
-
location: string,
|
|
22
|
-
color: string
|
|
23
|
-
},
|
|
24
|
-
buttons?: Array<ListButton>,
|
|
25
|
-
className?: string,
|
|
26
|
-
columns: Array<Column>,
|
|
27
|
-
configurable: boolean,
|
|
13
|
+
type Props = DataTableProps & ColumnSelectorProps & {
|
|
14
|
+
/**
|
|
15
|
+
* The name of the default sort column.
|
|
16
|
+
*/
|
|
28
17
|
defaultSort?: string,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The default direction to sort the list (ascending vs. descending).
|
|
21
|
+
*/
|
|
29
22
|
defaultSortDirection?: string,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
onCopy?: (item: any) => any,
|
|
37
|
-
onDelete: (item: any) => void,
|
|
38
|
-
onDrag?: (dragIndex: number, hoverIndex: number) => void,
|
|
39
|
-
onSave?: (item: any) => void,
|
|
40
|
-
renderDeleteModal?: ({ selectedItem: any, onCancel: () => void, onConfirm: () => void }) => void,
|
|
41
|
-
renderEmptyRow?: () => void,
|
|
42
|
-
selectable: boolean,
|
|
43
|
-
onRowSelect: (Array<{id: number}>),
|
|
44
|
-
selectedRows: Array<{id: number}>,
|
|
45
|
-
showRecordCount: boolean,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Callback fired when a table row is dragged.
|
|
26
|
+
*/
|
|
27
|
+
onDrag?: (dragIndex: number, hoverIndex: number) => void
|
|
46
28
|
};
|
|
47
29
|
|
|
48
30
|
type State = {
|
|
@@ -55,8 +37,8 @@ const SORT_ASCENDING = 'ascending';
|
|
|
55
37
|
const SORT_DESCENDING = 'descending';
|
|
56
38
|
|
|
57
39
|
/**
|
|
58
|
-
* The EmbeddedList component can be used to display a collection of records that live within a parent
|
|
59
|
-
* especially useful when the collection is to be saved at the same time as the parent.
|
|
40
|
+
* The <code>EmbeddedList</code> component can be used to display a collection of records that live within a parent
|
|
41
|
+
* object. This is especially useful when the collection is to be saved at the same time as the parent.
|
|
60
42
|
*/
|
|
61
43
|
class EmbeddedList extends Component<Props, State> {
|
|
62
44
|
static defaultProps: any;
|
|
@@ -8,8 +8,19 @@ import i18n from '../i18n/i18n';
|
|
|
8
8
|
import './FileUpload.css';
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* A list of file types to include
|
|
13
|
+
*/
|
|
11
14
|
fileTypes?: Array<string>,
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The maximum size for a single file
|
|
18
|
+
*/
|
|
12
19
|
maxSize?: number,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Call back for when files are added
|
|
23
|
+
*/
|
|
13
24
|
onFilesAdded: (files: Array<File>) => void,
|
|
14
25
|
};
|
|
15
26
|
|
|
@@ -23,6 +34,10 @@ type FileEvent = {
|
|
|
23
34
|
target: HTMLInputElement
|
|
24
35
|
};
|
|
25
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The <code>FileUpload</code> component renders a dropzone and allows a user to drop or select one or more files
|
|
39
|
+
* from their local file system. Optionally, the files can be limited by size or type.
|
|
40
|
+
*/
|
|
26
41
|
class FileUpload extends Component<Props, State> {
|
|
27
42
|
fileInput: any;
|
|
28
43
|
filePattern: any;
|
|
@@ -17,13 +17,44 @@ import ModalContext from '../context/ModalContext';
|
|
|
17
17
|
import Toaster from './Toaster';
|
|
18
18
|
|
|
19
19
|
type Props = {
|
|
20
|
+
/**
|
|
21
|
+
* Content to display on the button used to open the modal
|
|
22
|
+
*/
|
|
20
23
|
button: string,
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Determines if the component should render a button as a trigger for the modal
|
|
27
|
+
*/
|
|
21
28
|
includeButton?: boolean,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Component to render within the modal
|
|
32
|
+
*/
|
|
22
33
|
itemComponent: ComponentType<any>,
|
|
23
|
-
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Callback fired when a file is added
|
|
37
|
+
*/
|
|
38
|
+
onAddFile: (file: File) => void,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Callback fired when the close button is clicked
|
|
42
|
+
*/
|
|
24
43
|
onClose?: () => void,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Callback fired when the save button is clicked
|
|
47
|
+
*/
|
|
25
48
|
onSave: (items: Array<any>) => Promise<any>,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* An object with keys containing the names of properties that are required
|
|
52
|
+
*/
|
|
26
53
|
required: { [string]: string },
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Title value to display in the modal header
|
|
57
|
+
*/
|
|
27
58
|
title?: string
|
|
28
59
|
};
|
|
29
60
|
|
|
@@ -35,9 +66,11 @@ type State = {
|
|
|
35
66
|
|
|
36
67
|
const LIST_DELIMITER = ', ';
|
|
37
68
|
|
|
69
|
+
/**
|
|
70
|
+
* The <code>FileUploadModal</code> is a convenience wrapper for the <code>FileUpload</code> component, allowing
|
|
71
|
+
* it to render in a modal.
|
|
72
|
+
*/
|
|
38
73
|
class FileUploadModal extends Component<Props, State> {
|
|
39
|
-
static defaultProps: any;
|
|
40
|
-
|
|
41
74
|
/**
|
|
42
75
|
* Constructs a new FileUploadModal component.
|
|
43
76
|
*
|
|
@@ -6,27 +6,64 @@ import uuid from 'react-uuid';
|
|
|
6
6
|
import { Loader } from 'semantic-ui-react';
|
|
7
7
|
import _ from 'underscore';
|
|
8
8
|
import i18n from '../i18n/i18n';
|
|
9
|
-
import Items from './Items';
|
|
9
|
+
import Items, { type Props as ItemsProps } from './Items';
|
|
10
10
|
import './ItemCollection.css';
|
|
11
11
|
|
|
12
|
-
type Props = {
|
|
12
|
+
type Props = ItemsProps & {
|
|
13
|
+
/**
|
|
14
|
+
* Appends the passed <code>className</code> and passes it to the <code>Items</code> component.
|
|
15
|
+
*/
|
|
13
16
|
className?: string,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The DOM element responsible for infinite scrolling. If no context is provided, the document <code>body</code>
|
|
20
|
+
* will be assumed.
|
|
21
|
+
*/
|
|
14
22
|
context: {
|
|
15
23
|
current: HTMLElement
|
|
16
24
|
},
|
|
17
|
-
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* If <code>true</code>, the list will display a loading indicator.
|
|
28
|
+
*/
|
|
18
29
|
loading?: boolean,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Callback fired when the bottom of the scroll container is reached.
|
|
33
|
+
*/
|
|
19
34
|
onBottomReached?: (page: number) => void,
|
|
20
|
-
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Callback fired when the delete action is clicked.
|
|
38
|
+
*/
|
|
39
|
+
onDelete?: (item: any) => void,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Callback fired when a new record is added to the list.
|
|
43
|
+
*/
|
|
21
44
|
onSave?: (item: any) => void,
|
|
22
|
-
|
|
23
|
-
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The number of records to display on a single page.
|
|
48
|
+
*/
|
|
49
|
+
perPage?: number,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The number of pixels from the bottom of the scroll container the <code>onBottomReached</code> callback
|
|
53
|
+
* should fire.
|
|
54
|
+
*/
|
|
55
|
+
scrollOffset?: number
|
|
24
56
|
};
|
|
25
57
|
|
|
26
58
|
type State = {
|
|
27
59
|
page: number
|
|
28
60
|
};
|
|
29
61
|
|
|
62
|
+
/**
|
|
63
|
+
* An <code>ItemCollection</code> component can be used to render a list of records stored on an object in memory. This
|
|
64
|
+
* component is responsible for handling infinite scroll and rendering the <code>Items</code> component, which handles
|
|
65
|
+
* the presentation.
|
|
66
|
+
*/
|
|
30
67
|
class ItemCollection extends Component<Props, State> {
|
|
31
68
|
static defaultProps: any;
|
|
32
69
|
|