dce-reactkit 3.6.15 → 3.6.17

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.
@@ -6,7 +6,7 @@ import express from 'express';
6
6
  type DCEMangoCollection = {
7
7
  /**
8
8
  * Find all items in the collection that match the filter query
9
- * @param filterQuery
9
+ * @param filterQuery query for the filter
10
10
  * @returns list of items that match the filter query
11
11
  */
12
12
  find: (filterQuery: any) => Promise<any[]>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Create a function that forces a render of a component. Use this only when
3
+ * absolutely necessary
4
+ * @author Gabe Abrams
5
+ * @param useReducer the useReducer hook
6
+ * @returns forceRender function
7
+ */
8
+ declare const useForceRender: (useReducer: any) => () => void;
9
+ export default useForceRender;
@@ -68,6 +68,7 @@ import validateString from './helpers/validators/validateString';
68
68
  import idify from './helpers/idify';
69
69
  import makeLinksClickable from './helpers/makeLinksClickable';
70
70
  import combineClassNames from './helpers/combineClassNames';
71
+ import prefixWithAOrAn from './helpers/prefixWithAOrAn';
71
72
  import ModalButtonType from './types/ModalButtonType';
72
73
  import ModalSize from './types/ModalSize';
73
74
  import ModalType from './types/ModalType';
@@ -86,4 +87,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
86
87
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
87
88
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
88
89
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
89
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, 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, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
90
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, 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, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, 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
@@ -1293,7 +1293,7 @@ declare const getLocalTimeInfo: (dateOrTimestamp?: Date | number) => {
1293
1293
  type DCEMangoCollection = {
1294
1294
  /**
1295
1295
  * Find all items in the collection that match the filter query
1296
- * @param filterQuery
1296
+ * @param filterQuery query for the filter
1297
1297
  * @returns list of items that match the filter query
1298
1298
  */
1299
1299
  find: (filterQuery: any) => Promise<any[]>;
@@ -1426,6 +1426,16 @@ declare const makeLinksClickable: (text: string, opts?: {
1426
1426
  */
1427
1427
  declare const combineClassNames: (classNames: (string | undefined | null | false)[]) => string;
1428
1428
 
1429
+ /**
1430
+ * Prefix a word or name with "a" or "an" depending on whether it starts with a
1431
+ * vowel or not
1432
+ * @author Gabe Abrams
1433
+ * @param text the text to prefix
1434
+ * @param capitalize whether to capitalize the "A" or "An"
1435
+ * @returns the text prefixed with "a" or "an"
1436
+ */
1437
+ declare const prefixWithAOrAn: (text: string, capitalize?: boolean) => string;
1438
+
1429
1439
  /**
1430
1440
  * List of error codes built into the react kit
1431
1441
  * @author Gabe Abrams
@@ -1476,4 +1486,4 @@ declare const LogBuiltInMetadata: {
1476
1486
  };
1477
1487
  };
1478
1488
 
1479
- export { AppWrapper, AutoscrollToBottomContainer, 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, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
1489
+ export { AppWrapper, AutoscrollToBottomContainer, 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, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.6.15",
3
+ "version": "3.6.17",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -15,7 +15,7 @@ import ParamType from '../types/ParamType';
15
15
  type DCEMangoCollection = {
16
16
  /**
17
17
  * Find all items in the collection that match the filter query
18
- * @param filterQuery
18
+ * @param filterQuery query for the filter
19
19
  * @returns list of items that match the filter query
20
20
  */
21
21
  find: (filterQuery: any) => Promise<any[]>,
@@ -0,0 +1,46 @@
1
+ /* -------- State Definition -------- */
2
+
3
+ type State = {
4
+ // The number of times the component has been forced to render
5
+ renderCount: number,
6
+ };
7
+
8
+ /* ------------- Reducer ------------ */
9
+
10
+ /**
11
+ * Reducer that executes actions
12
+ * @author Gabe Abrams
13
+ * @param state current state
14
+ */
15
+ const reducer = (state: State): State => {
16
+ return {
17
+ renderCount: state.renderCount + 1,
18
+ };
19
+ };
20
+
21
+ /* -------------- Main -------------- */
22
+
23
+ /**
24
+ * Create a function that forces a render of a component. Use this only when
25
+ * absolutely necessary
26
+ * @author Gabe Abrams
27
+ * @param useReducer the useReducer hook
28
+ * @returns forceRender function
29
+ */
30
+ const useForceRender = (useReducer: any) => {
31
+ // Initial state
32
+ const initialState: State = {
33
+ renderCount: 0,
34
+ };
35
+
36
+ // Initialize state
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
+ const [state, dispatch] = useReducer(reducer, initialState);
39
+
40
+ // Create and return the forceRender function
41
+ return () => {
42
+ dispatch();
43
+ };
44
+ };
45
+
46
+ export default useForceRender;
package/src/index.ts CHANGED
@@ -83,6 +83,7 @@ import validateString from './helpers/validators/validateString';
83
83
  import idify from './helpers/idify';
84
84
  import makeLinksClickable from './helpers/makeLinksClickable';
85
85
  import combineClassNames from './helpers/combineClassNames';
86
+ import prefixWithAOrAn from './helpers/prefixWithAOrAn';
86
87
 
87
88
  // Import types
88
89
  import ModalButtonType from './types/ModalButtonType';
@@ -177,6 +178,7 @@ export {
177
178
  getLocalTimeInfo,
178
179
  idify,
179
180
  makeLinksClickable,
181
+ prefixWithAOrAn,
180
182
  // Client helpers
181
183
  initClient,
182
184
  visitServerEndpoint,