dce-reactkit 3.3.5 → 3.4.0-beta.1
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/cjs/index.js +37524 -380
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +10 -0
- package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +33 -0
- package/dist/cjs/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +8 -0
- package/dist/cjs/types/components/DBEntryManagerPanel/index.d.ts +25 -0
- package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +8 -0
- package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +49 -0
- package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +12 -0
- package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +40 -0
- package/dist/cjs/types/index.d.ts +6 -1
- package/dist/esm/index.js +37698 -575
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +10 -0
- package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +33 -0
- package/dist/esm/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +8 -0
- package/dist/esm/types/components/DBEntryManagerPanel/index.d.ts +25 -0
- package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +8 -0
- package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +49 -0
- package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +12 -0
- package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +40 -0
- package/dist/esm/types/index.d.ts +6 -1
- package/dist/index.d.ts +166 -35
- package/package.json +8 -3
- package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.tsx +290 -0
- package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/index.tsx +699 -0
- package/src/components/DBEntryManagerPanel/helpers/generateEndpointPath.ts +15 -0
- package/src/components/DBEntryManagerPanel/index.tsx +511 -0
- package/src/components/DBEntryManagerPanel/types/DBEntry.ts +7 -0
- package/src/components/DBEntryManagerPanel/types/DBEntryField.ts +94 -0
- package/src/components/DBEntryManagerPanel/types/DBEntryFieldType.ts +18 -0
- package/src/helpers/addDBEditorEndpoints.ts +121 -0
- package/src/helpers/getLocalTimeInfo.tsx +4 -1
- package/src/index.ts +11 -1
package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import DBEntryFieldType from '../types/DBEntryFieldType';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
type: DBEntryFieldType.StringArray | DBEntryFieldType.NumberArray;
|
|
5
|
+
values: string[] | number[];
|
|
6
|
+
onChange: (values: string[] | number[]) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const CreatableMultiselect: React.FC<Props>;
|
|
10
|
+
export default CreatableMultiselect;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel for adding a DBEntry to the database
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import DBEntry from '../types/DBEntry';
|
|
7
|
+
import DBEntryField from '../types/DBEntryField';
|
|
8
|
+
declare type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* Handler for when the user finishes adding the DBEntry
|
|
11
|
+
* (if no DBEntry is returned, process was cancelled)
|
|
12
|
+
* @param DBEntry the DBEntry that was just created
|
|
13
|
+
*/
|
|
14
|
+
onFinished: (dbEntry?: DBEntry) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Function to validate the DBEntry before saving
|
|
17
|
+
* @param dbEntry
|
|
18
|
+
*/
|
|
19
|
+
validateEntry?: (dbEntry: DBEntry) => Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Function to modify the DBEntry before saving
|
|
22
|
+
* @param dbEntry
|
|
23
|
+
* @returns the modified DBEntry
|
|
24
|
+
*/
|
|
25
|
+
modifyEntry?: (dbEntry: DBEntry) => DBEntry;
|
|
26
|
+
entryFields: DBEntryField[];
|
|
27
|
+
dbEntryToEdit?: DBEntry;
|
|
28
|
+
idPropName: string;
|
|
29
|
+
saveEndpointPath: string;
|
|
30
|
+
entries: DBEntry[];
|
|
31
|
+
};
|
|
32
|
+
declare const AddOrEditDBEntry: React.FC<Props>;
|
|
33
|
+
export default AddOrEditDBEntry;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the endpoint path for the given collection name
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
* @param collectionName the name of the collection
|
|
5
|
+
* @param [adminsOnly] true if the endpoint is for admins only
|
|
6
|
+
*/
|
|
7
|
+
declare const generateEndpointPath: (collectionName: string, adminsOnly?: boolean | undefined) => string;
|
|
8
|
+
export default generateEndpointPath;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DB Entry Manager Panel
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import DBEntry from './types/DBEntry';
|
|
7
|
+
import DBEntryField from './types/DBEntryField';
|
|
8
|
+
declare type Props = {
|
|
9
|
+
entryFields: DBEntryField[];
|
|
10
|
+
idPropName: string;
|
|
11
|
+
titlePropName: string;
|
|
12
|
+
descriptionPropName: string;
|
|
13
|
+
itemListTitle: string;
|
|
14
|
+
itemName: string;
|
|
15
|
+
validateEntry?: (dbEntry: DBEntry) => Promise<void>;
|
|
16
|
+
modifyEntry?: (dbEntry: DBEntry) => Promise<DBEntry>;
|
|
17
|
+
disableEdit?: boolean;
|
|
18
|
+
collectionName: string;
|
|
19
|
+
adminsOnly?: boolean;
|
|
20
|
+
filterQuery?: {
|
|
21
|
+
[k: string]: any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
declare const DBEntryManagerPanel: React.FC<Props>;
|
|
25
|
+
export default DBEntryManagerPanel;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import DBEntryFieldType from './DBEntryFieldType';
|
|
2
|
+
/**
|
|
3
|
+
* A database entry input field
|
|
4
|
+
* @author Yuen Ler Chow
|
|
5
|
+
*/
|
|
6
|
+
declare type DBEntryField = ({
|
|
7
|
+
label: string;
|
|
8
|
+
objectKey: string;
|
|
9
|
+
placeholder: string;
|
|
10
|
+
lockAfterCreation?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
} & ({
|
|
13
|
+
type: DBEntryFieldType.String;
|
|
14
|
+
minNumChars?: number;
|
|
15
|
+
maxNumChars?: number;
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
choices?: {
|
|
18
|
+
title: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
} | {
|
|
22
|
+
type: DBEntryFieldType.Number;
|
|
23
|
+
minNumber?: number;
|
|
24
|
+
maxNumber?: number;
|
|
25
|
+
defaultValue?: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: DBEntryFieldType.StringArray;
|
|
28
|
+
minNumElements?: number;
|
|
29
|
+
maxNumElements?: number;
|
|
30
|
+
defaultValue?: string[];
|
|
31
|
+
choices?: {
|
|
32
|
+
title: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}[];
|
|
35
|
+
} | {
|
|
36
|
+
type: DBEntryFieldType.NumberArray;
|
|
37
|
+
minNumElements?: number;
|
|
38
|
+
maxNumElements?: number;
|
|
39
|
+
minNumber?: number;
|
|
40
|
+
maxNumber?: number;
|
|
41
|
+
defaultValue?: number[];
|
|
42
|
+
} | {
|
|
43
|
+
type: DBEntryFieldType.Object;
|
|
44
|
+
defaultValue?: {
|
|
45
|
+
[k: string]: any;
|
|
46
|
+
};
|
|
47
|
+
subfields: DBEntryField[];
|
|
48
|
+
}));
|
|
49
|
+
export default DBEntryField;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for field types
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
*/
|
|
5
|
+
declare enum DBEntryFieldType {
|
|
6
|
+
String = "String",
|
|
7
|
+
Number = "Number",
|
|
8
|
+
Object = "Object",
|
|
9
|
+
StringArray = "StringArray",
|
|
10
|
+
NumberArray = "NumberArray"
|
|
11
|
+
}
|
|
12
|
+
export default DBEntryFieldType;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for a collection in the database
|
|
4
|
+
* @author Yuen Ler Chow
|
|
5
|
+
*/
|
|
6
|
+
interface Collection {
|
|
7
|
+
/**
|
|
8
|
+
* Find all items in the collection that match the filter query
|
|
9
|
+
* @param filterQuery
|
|
10
|
+
* @returns list of items that match the filter query
|
|
11
|
+
*/
|
|
12
|
+
find: (filterQuery: any) => Promise<any[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Insert an item into the collection
|
|
15
|
+
* @param item the item to insert
|
|
16
|
+
*/
|
|
17
|
+
insert: (item: any) => Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete an item in the collection
|
|
20
|
+
* @param id the id of the item to delete
|
|
21
|
+
*/
|
|
22
|
+
delete: (filterQuery: {
|
|
23
|
+
id: string;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Add all routes for the DBEditor
|
|
28
|
+
* @author Yuen Ler Chow
|
|
29
|
+
* @param opts object containing all arguments
|
|
30
|
+
* @param opts.app express app to add routes too
|
|
31
|
+
* @param opts.collectionName the name of the collection
|
|
32
|
+
* @param opts.adminsOnly true if the endpoint is for admins only
|
|
33
|
+
*/
|
|
34
|
+
declare const addDBEditorEndpoints: (opts: {
|
|
35
|
+
app: express.Application;
|
|
36
|
+
collectionName: string;
|
|
37
|
+
adminsOnly: boolean;
|
|
38
|
+
collection: Collection;
|
|
39
|
+
}) => void;
|
|
40
|
+
export default addDBEditorEndpoints;
|
|
@@ -16,6 +16,7 @@ import ItemPicker from './components/ItemPicker';
|
|
|
16
16
|
import LogReviewer from './components/LogReviewer';
|
|
17
17
|
import IntelliTable from './components/IntelliTable';
|
|
18
18
|
import CSVDownloadButton from './components/CSVDownloadButton';
|
|
19
|
+
import DBEntryManagerPanel from './components/DBEntryManagerPanel';
|
|
19
20
|
import ErrorWithCode from './errors/ErrorWithCode';
|
|
20
21
|
import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
|
|
21
22
|
import HOUR_IN_MS from './constants/HOUR_IN_MS';
|
|
@@ -55,6 +56,7 @@ import isMobileOrTablet from './helpers/isMobileOrTablet';
|
|
|
55
56
|
import extractProp from './helpers/extractProp';
|
|
56
57
|
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
57
58
|
import getLocalTimeInfo from './helpers/getLocalTimeInfo';
|
|
59
|
+
import addDBEditorEndpoints from './helpers/addDBEditorEndpoints';
|
|
58
60
|
import ModalButtonType from './types/ModalButtonType';
|
|
59
61
|
import ModalSize from './types/ModalSize';
|
|
60
62
|
import ModalType from './types/ModalType';
|
|
@@ -70,4 +72,7 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
|
|
|
70
72
|
import LogMetadataType from './types/LogMetadataType';
|
|
71
73
|
import IntelliTableColumn from './types/IntelliTableColumn';
|
|
72
74
|
import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
73
|
-
|
|
75
|
+
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
76
|
+
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
77
|
+
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
78
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, getLocalTimeInfo, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import express from 'express';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Bootstrap variants
|
|
@@ -22,7 +23,7 @@ declare enum Variant {
|
|
|
22
23
|
* @author Gabe Abrams
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
|
-
declare type Props$
|
|
26
|
+
declare type Props$h = {
|
|
26
27
|
children: React.ReactNode;
|
|
27
28
|
dark?: boolean;
|
|
28
29
|
};
|
|
@@ -61,7 +62,7 @@ declare const confirm: (title: string, text: string, opts?: {
|
|
|
61
62
|
* @param [errorTitle] title of the error box
|
|
62
63
|
*/
|
|
63
64
|
declare const showFatalError: (error: any, errorTitle?: string) => undefined;
|
|
64
|
-
declare const AppWrapper: React.FC<Props$
|
|
65
|
+
declare const AppWrapper: React.FC<Props$h>;
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* Loading spinner/indicator
|
|
@@ -74,12 +75,12 @@ declare const LoadingSpinner: () => JSX.Element;
|
|
|
74
75
|
* @author Gabe Abrams
|
|
75
76
|
*/
|
|
76
77
|
|
|
77
|
-
declare type Props$
|
|
78
|
+
declare type Props$g = {
|
|
78
79
|
error: any;
|
|
79
80
|
title?: string;
|
|
80
81
|
onClose?: () => void;
|
|
81
82
|
};
|
|
82
|
-
declare const ErrorBox: React.FC<Props$
|
|
83
|
+
declare const ErrorBox: React.FC<Props$g>;
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Types of buttons in the modal
|
|
@@ -130,7 +131,7 @@ declare enum ModalType {
|
|
|
130
131
|
* @author Gabe Abrams
|
|
131
132
|
*/
|
|
132
133
|
|
|
133
|
-
declare type Props$
|
|
134
|
+
declare type Props$f = {
|
|
134
135
|
type?: ModalType;
|
|
135
136
|
size?: ModalSize;
|
|
136
137
|
title?: React.ReactNode;
|
|
@@ -159,27 +160,27 @@ declare type Props$e = {
|
|
|
159
160
|
confirmVariant?: Variant;
|
|
160
161
|
onTopOfOtherModals?: boolean;
|
|
161
162
|
};
|
|
162
|
-
declare const Modal: React.FC<Props$
|
|
163
|
+
declare const Modal: React.FC<Props$f>;
|
|
163
164
|
|
|
164
165
|
/**
|
|
165
166
|
* A box with a tab on the top that holds buttons and other content
|
|
166
167
|
* @author Gabe Abrams
|
|
167
168
|
*/
|
|
168
169
|
|
|
169
|
-
declare type Props$
|
|
170
|
+
declare type Props$e = {
|
|
170
171
|
title: React.ReactNode;
|
|
171
172
|
children: React.ReactNode;
|
|
172
173
|
noBottomMargin?: boolean;
|
|
173
174
|
noBottomPadding?: boolean;
|
|
174
175
|
};
|
|
175
|
-
declare const TabBox: React.FC<Props$
|
|
176
|
+
declare const TabBox: React.FC<Props$e>;
|
|
176
177
|
|
|
177
178
|
/**
|
|
178
179
|
* A radio selection button
|
|
179
180
|
* @author Gabe Abrams
|
|
180
181
|
*/
|
|
181
182
|
|
|
182
|
-
declare type Props$
|
|
183
|
+
declare type Props$d = {
|
|
183
184
|
text: string;
|
|
184
185
|
onSelected: () => void;
|
|
185
186
|
ariaLabel: string;
|
|
@@ -191,14 +192,14 @@ declare type Props$c = {
|
|
|
191
192
|
unselectedVariant?: Variant;
|
|
192
193
|
small?: boolean;
|
|
193
194
|
};
|
|
194
|
-
declare const RadioButton: React.FC<Props$
|
|
195
|
+
declare const RadioButton: React.FC<Props$d>;
|
|
195
196
|
|
|
196
197
|
/**
|
|
197
198
|
* A checkbox button
|
|
198
199
|
* @author Gabe Abrams
|
|
199
200
|
*/
|
|
200
201
|
|
|
201
|
-
declare type Props$
|
|
202
|
+
declare type Props$c = {
|
|
202
203
|
text: string;
|
|
203
204
|
onChanged: (checked: boolean) => void;
|
|
204
205
|
ariaLabel: string;
|
|
@@ -212,28 +213,28 @@ declare type Props$b = {
|
|
|
212
213
|
small?: boolean;
|
|
213
214
|
dashed?: boolean;
|
|
214
215
|
};
|
|
215
|
-
declare const CheckboxButton: React.FC<Props$
|
|
216
|
+
declare const CheckboxButton: React.FC<Props$c>;
|
|
216
217
|
|
|
217
218
|
/**
|
|
218
219
|
* Input group with a title and space for buttons
|
|
219
220
|
* @author Gabe Abrams
|
|
220
221
|
*/
|
|
221
222
|
|
|
222
|
-
declare type Props$
|
|
223
|
+
declare type Props$b = {
|
|
223
224
|
label: string;
|
|
224
225
|
minLabelWidth?: string;
|
|
225
226
|
children: React.ReactNode;
|
|
226
227
|
className?: string;
|
|
227
228
|
wrapButtonsAndAddGaps?: boolean;
|
|
228
229
|
};
|
|
229
|
-
declare const ButtonInputGroup: React.FC<Props$
|
|
230
|
+
declare const ButtonInputGroup: React.FC<Props$b>;
|
|
230
231
|
|
|
231
232
|
/**
|
|
232
233
|
* A very simple, lightweight date chooser
|
|
233
234
|
* @author Gabe Abrams
|
|
234
235
|
*/
|
|
235
236
|
|
|
236
|
-
declare type Props$
|
|
237
|
+
declare type Props$a = {
|
|
237
238
|
ariaLabel: string;
|
|
238
239
|
name: string;
|
|
239
240
|
month: number;
|
|
@@ -249,61 +250,61 @@ declare type Props$9 = {
|
|
|
249
250
|
numMonthsToShow?: number;
|
|
250
251
|
chooseFromPast?: boolean;
|
|
251
252
|
};
|
|
252
|
-
declare const SimpleDateChooser: React.FC<Props$
|
|
253
|
+
declare const SimpleDateChooser: React.FC<Props$a>;
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
256
|
* Drawer container
|
|
256
257
|
* @author Gabe Abrams
|
|
257
258
|
*/
|
|
258
259
|
|
|
259
|
-
declare type Props$
|
|
260
|
+
declare type Props$9 = {
|
|
260
261
|
customBackgroundColor?: string;
|
|
261
262
|
children: React.ReactNode;
|
|
262
263
|
};
|
|
263
|
-
declare const Drawer: React.FC<Props$
|
|
264
|
+
declare const Drawer: React.FC<Props$9>;
|
|
264
265
|
|
|
265
266
|
/**
|
|
266
267
|
* Success checkmark that pops into view
|
|
267
268
|
* @author Gabe Abrams
|
|
268
269
|
*/
|
|
269
270
|
|
|
270
|
-
declare type Props$
|
|
271
|
+
declare type Props$8 = {
|
|
271
272
|
sizeRem?: number;
|
|
272
273
|
circleVariant?: string;
|
|
273
274
|
checkVariant?: string;
|
|
274
275
|
};
|
|
275
|
-
declare const PopSuccessMark: React.FC<Props$
|
|
276
|
+
declare const PopSuccessMark: React.FC<Props$8>;
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
279
|
* Failure x mark that pops into view
|
|
279
280
|
* @author Gabe Abrams
|
|
280
281
|
*/
|
|
281
282
|
|
|
282
|
-
declare type Props$
|
|
283
|
+
declare type Props$7 = {
|
|
283
284
|
sizeRem?: number;
|
|
284
285
|
circleVariant?: string;
|
|
285
286
|
xVariant?: string;
|
|
286
287
|
};
|
|
287
|
-
declare const PopFailureMark: React.FC<Props$
|
|
288
|
+
declare const PopFailureMark: React.FC<Props$7>;
|
|
288
289
|
|
|
289
290
|
/**
|
|
290
291
|
* Failure pending that pops into view
|
|
291
292
|
* @author Gabe Abrams
|
|
292
293
|
*/
|
|
293
294
|
|
|
294
|
-
declare type Props$
|
|
295
|
+
declare type Props$6 = {
|
|
295
296
|
sizeRem?: number;
|
|
296
297
|
circleVariant?: string;
|
|
297
298
|
hourglassVariant?: string;
|
|
298
299
|
};
|
|
299
|
-
declare const PopPendingMark: React.FC<Props$
|
|
300
|
+
declare const PopPendingMark: React.FC<Props$6>;
|
|
300
301
|
|
|
301
302
|
/**
|
|
302
303
|
* Copiable text box
|
|
303
304
|
* @author Gabe Abrams
|
|
304
305
|
*/
|
|
305
306
|
|
|
306
|
-
declare type Props$
|
|
307
|
+
declare type Props$5 = {
|
|
307
308
|
text: string;
|
|
308
309
|
maxTextWidthRem?: number;
|
|
309
310
|
label?: string;
|
|
@@ -315,7 +316,7 @@ declare type Props$4 = {
|
|
|
315
316
|
textAreaId?: string;
|
|
316
317
|
copyButtonId?: string;
|
|
317
318
|
};
|
|
318
|
-
declare const CopiableBox: React.FC<Props$
|
|
319
|
+
declare const CopiableBox: React.FC<Props$5>;
|
|
319
320
|
|
|
320
321
|
/**
|
|
321
322
|
* An item that can be chosen (for use within ItemPicker)
|
|
@@ -338,7 +339,7 @@ declare type PickableItem = ({
|
|
|
338
339
|
* @author Yuen Ler Chow
|
|
339
340
|
*/
|
|
340
341
|
|
|
341
|
-
declare type Props$
|
|
342
|
+
declare type Props$4 = {
|
|
342
343
|
title: string;
|
|
343
344
|
items: PickableItem[];
|
|
344
345
|
/**
|
|
@@ -349,7 +350,7 @@ declare type Props$3 = {
|
|
|
349
350
|
onChanged: (updatedItems: PickableItem[]) => void;
|
|
350
351
|
noBottomMargin?: boolean;
|
|
351
352
|
};
|
|
352
|
-
declare const ItemPicker: React.FC<Props$
|
|
353
|
+
declare const ItemPicker: React.FC<Props$4>;
|
|
353
354
|
|
|
354
355
|
/**
|
|
355
356
|
* Type of the context map in a LogMetadata file
|
|
@@ -394,11 +395,11 @@ declare type LogMetadataType = {
|
|
|
394
395
|
* @author Gabe Abrams
|
|
395
396
|
*/
|
|
396
397
|
|
|
397
|
-
declare type Props$
|
|
398
|
+
declare type Props$3 = {
|
|
398
399
|
LogMetadata: LogMetadataType;
|
|
399
400
|
onClose: () => void;
|
|
400
401
|
};
|
|
401
|
-
declare const LogReviewer: React.FC<Props$
|
|
402
|
+
declare const LogReviewer: React.FC<Props$3>;
|
|
402
403
|
|
|
403
404
|
/**
|
|
404
405
|
* Server-side API param types
|
|
@@ -433,7 +434,7 @@ declare type IntelliTableColumn = {
|
|
|
433
434
|
* @author Gabe Abrams
|
|
434
435
|
*/
|
|
435
436
|
|
|
436
|
-
declare type Props$
|
|
437
|
+
declare type Props$2 = {
|
|
437
438
|
title: string;
|
|
438
439
|
id: string;
|
|
439
440
|
data: {
|
|
@@ -443,14 +444,14 @@ declare type Props$1 = {
|
|
|
443
444
|
columns: IntelliTableColumn[];
|
|
444
445
|
csvName?: string;
|
|
445
446
|
};
|
|
446
|
-
declare const IntelliTable: React.FC<Props$
|
|
447
|
+
declare const IntelliTable: React.FC<Props$2>;
|
|
447
448
|
|
|
448
449
|
/**
|
|
449
450
|
* Button for downloading a csv file
|
|
450
451
|
* @author Gabe Abrams
|
|
451
452
|
*/
|
|
452
453
|
|
|
453
|
-
declare type Props = {
|
|
454
|
+
declare type Props$1 = {
|
|
454
455
|
filename: string;
|
|
455
456
|
csv: string;
|
|
456
457
|
id?: string;
|
|
@@ -462,7 +463,98 @@ declare type Props = {
|
|
|
462
463
|
onClick?: () => void;
|
|
463
464
|
children?: React.ReactNode;
|
|
464
465
|
};
|
|
465
|
-
declare const CSVDownloadButton: React.FC<Props>;
|
|
466
|
+
declare const CSVDownloadButton: React.FC<Props$1>;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Generic type for an object
|
|
470
|
+
* @author Yuen Ler Chow
|
|
471
|
+
*/
|
|
472
|
+
declare type DBEntry = {
|
|
473
|
+
[k: string]: any;
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Options for field types
|
|
478
|
+
* @author Yuen Ler Chow
|
|
479
|
+
*/
|
|
480
|
+
declare enum DBEntryFieldType {
|
|
481
|
+
String = "String",
|
|
482
|
+
Number = "Number",
|
|
483
|
+
Object = "Object",
|
|
484
|
+
StringArray = "StringArray",
|
|
485
|
+
NumberArray = "NumberArray"
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* A database entry input field
|
|
490
|
+
* @author Yuen Ler Chow
|
|
491
|
+
*/
|
|
492
|
+
declare type DBEntryField = ({
|
|
493
|
+
label: string;
|
|
494
|
+
objectKey: string;
|
|
495
|
+
placeholder: string;
|
|
496
|
+
lockAfterCreation?: boolean;
|
|
497
|
+
required?: boolean;
|
|
498
|
+
} & ({
|
|
499
|
+
type: DBEntryFieldType.String;
|
|
500
|
+
minNumChars?: number;
|
|
501
|
+
maxNumChars?: number;
|
|
502
|
+
defaultValue?: string;
|
|
503
|
+
choices?: {
|
|
504
|
+
title: string;
|
|
505
|
+
value: string;
|
|
506
|
+
}[];
|
|
507
|
+
} | {
|
|
508
|
+
type: DBEntryFieldType.Number;
|
|
509
|
+
minNumber?: number;
|
|
510
|
+
maxNumber?: number;
|
|
511
|
+
defaultValue?: number;
|
|
512
|
+
} | {
|
|
513
|
+
type: DBEntryFieldType.StringArray;
|
|
514
|
+
minNumElements?: number;
|
|
515
|
+
maxNumElements?: number;
|
|
516
|
+
defaultValue?: string[];
|
|
517
|
+
choices?: {
|
|
518
|
+
title: string;
|
|
519
|
+
value: string;
|
|
520
|
+
}[];
|
|
521
|
+
} | {
|
|
522
|
+
type: DBEntryFieldType.NumberArray;
|
|
523
|
+
minNumElements?: number;
|
|
524
|
+
maxNumElements?: number;
|
|
525
|
+
minNumber?: number;
|
|
526
|
+
maxNumber?: number;
|
|
527
|
+
defaultValue?: number[];
|
|
528
|
+
} | {
|
|
529
|
+
type: DBEntryFieldType.Object;
|
|
530
|
+
defaultValue?: {
|
|
531
|
+
[k: string]: any;
|
|
532
|
+
};
|
|
533
|
+
subfields: DBEntryField[];
|
|
534
|
+
}));
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* DB Entry Manager Panel
|
|
538
|
+
* @author Yuen Ler Chow
|
|
539
|
+
*/
|
|
540
|
+
|
|
541
|
+
declare type Props = {
|
|
542
|
+
entryFields: DBEntryField[];
|
|
543
|
+
idPropName: string;
|
|
544
|
+
titlePropName: string;
|
|
545
|
+
descriptionPropName: string;
|
|
546
|
+
itemListTitle: string;
|
|
547
|
+
itemName: string;
|
|
548
|
+
validateEntry?: (dbEntry: DBEntry) => Promise<void>;
|
|
549
|
+
modifyEntry?: (dbEntry: DBEntry) => Promise<DBEntry>;
|
|
550
|
+
disableEdit?: boolean;
|
|
551
|
+
collectionName: string;
|
|
552
|
+
adminsOnly?: boolean;
|
|
553
|
+
filterQuery?: {
|
|
554
|
+
[k: string]: any;
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
declare const DBEntryManagerPanel: React.FC<Props>;
|
|
466
558
|
|
|
467
559
|
/**
|
|
468
560
|
* An error with a code
|
|
@@ -1085,6 +1177,45 @@ declare const getLocalTimeInfo: (dateOrTimestamp?: number | Date | undefined) =>
|
|
|
1085
1177
|
isPM: boolean;
|
|
1086
1178
|
};
|
|
1087
1179
|
|
|
1180
|
+
/**
|
|
1181
|
+
* Interface for a collection in the database
|
|
1182
|
+
* @author Yuen Ler Chow
|
|
1183
|
+
*/
|
|
1184
|
+
interface Collection {
|
|
1185
|
+
/**
|
|
1186
|
+
* Find all items in the collection that match the filter query
|
|
1187
|
+
* @param filterQuery
|
|
1188
|
+
* @returns list of items that match the filter query
|
|
1189
|
+
*/
|
|
1190
|
+
find: (filterQuery: any) => Promise<any[]>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Insert an item into the collection
|
|
1193
|
+
* @param item the item to insert
|
|
1194
|
+
*/
|
|
1195
|
+
insert: (item: any) => Promise<void>;
|
|
1196
|
+
/**
|
|
1197
|
+
* Delete an item in the collection
|
|
1198
|
+
* @param id the id of the item to delete
|
|
1199
|
+
*/
|
|
1200
|
+
delete: (filterQuery: {
|
|
1201
|
+
id: string;
|
|
1202
|
+
}) => Promise<void>;
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Add all routes for the DBEditor
|
|
1206
|
+
* @author Yuen Ler Chow
|
|
1207
|
+
* @param opts object containing all arguments
|
|
1208
|
+
* @param opts.app express app to add routes too
|
|
1209
|
+
* @param opts.collectionName the name of the collection
|
|
1210
|
+
* @param opts.adminsOnly true if the endpoint is for admins only
|
|
1211
|
+
*/
|
|
1212
|
+
declare const addDBEditorEndpoints: (opts: {
|
|
1213
|
+
app: express.Application;
|
|
1214
|
+
collectionName: string;
|
|
1215
|
+
adminsOnly: boolean;
|
|
1216
|
+
collection: Collection;
|
|
1217
|
+
}) => void;
|
|
1218
|
+
|
|
1088
1219
|
/**
|
|
1089
1220
|
* List of error codes built into the react kit
|
|
1090
1221
|
* @author Gabe Abrams
|
|
@@ -1135,4 +1266,4 @@ declare const LogBuiltInMetadata: {
|
|
|
1135
1266
|
};
|
|
1136
1267
|
};
|
|
1137
1268
|
|
|
1138
|
-
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
|
1269
|
+
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, addDBEditorEndpoints, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-reactkit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-beta.1",
|
|
4
4
|
"description": "Shared components for Harvard DCE apps",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -28,13 +28,15 @@
|
|
|
28
28
|
"@fortawesome/free-solid-svg-icons": "^x.x.x",
|
|
29
29
|
"@fortawesome/react-fontawesome": "^x.x.x",
|
|
30
30
|
"bootstrap": "^5.x.x",
|
|
31
|
-
"react": "^x.x.x"
|
|
31
|
+
"react": "^x.x.x",
|
|
32
|
+
"express": "^x.x.x"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
35
36
|
"@rollup/plugin-json": "^4.1.0",
|
|
36
37
|
"@rollup/plugin-node-resolve": "^13.2.1",
|
|
37
38
|
"@rollup/plugin-typescript": "^8.3.2",
|
|
39
|
+
"@types/express": "^4.17.17",
|
|
38
40
|
"@types/jest": "^28.1.7",
|
|
39
41
|
"@types/react": "^17.0.7",
|
|
40
42
|
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
@@ -54,5 +56,8 @@
|
|
|
54
56
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
55
57
|
"ts-jest": "^28.0.8",
|
|
56
58
|
"typescript": "^4.6.3"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"react-select": "^5.7.3"
|
|
57
62
|
}
|
|
58
|
-
}
|
|
63
|
+
}
|