dce-reactkit 3.7.35 → 3.7.37

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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shuffle a given array
3
+ * @author Austen Money
4
+ * @param arr the array to shuffle
5
+ * @returns the shuffled array
6
+ */
7
+ declare const shuffleArray: <T>(arr: T[]) => T[];
8
+ export default shuffleArray;
@@ -76,6 +76,7 @@ import forEachAsync from './helpers/asyncArrayFunctions/forEachAsync';
76
76
  import mapAsync from './helpers/asyncArrayFunctions/mapAsync';
77
77
  import someAsync from './helpers/asyncArrayFunctions/someAsync';
78
78
  import capitalize from './helpers/capitalize';
79
+ import shuffleArray from './helpers/shuffleArray';
79
80
  import ModalButtonType from './types/ModalButtonType';
80
81
  import ModalSize from './types/ModalSize';
81
82
  import ModalType from './types/ModalType';
@@ -95,4 +96,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
95
96
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
96
97
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
97
98
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
98
- 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, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
99
+ 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, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
package/dist/index.d.ts CHANGED
@@ -1559,6 +1559,14 @@ declare const someAsync: <T>(array: T[], operatorFunction: (item: T, index: numb
1559
1559
  */
1560
1560
  declare const capitalize: (str: string) => string;
1561
1561
 
1562
+ /**
1563
+ * Shuffle a given array
1564
+ * @author Austen Money
1565
+ * @param arr the array to shuffle
1566
+ * @returns the shuffled array
1567
+ */
1568
+ declare const shuffleArray: <T>(arr: T[]) => T[];
1569
+
1562
1570
  /**
1563
1571
  * List of error codes built into the react kit
1564
1572
  * @author Gabe Abrams
@@ -1609,4 +1617,4 @@ declare const LogBuiltInMetadata: {
1609
1617
  };
1610
1618
  };
1611
1619
 
1612
- 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, LogFunction, 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, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
1620
+ 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, LogFunction, 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, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.7.35",
3
+ "version": "3.7.37",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shuffle a given array
3
+ * @author Austen Money
4
+ * @param arr the array to shuffle
5
+ * @returns the shuffled array
6
+ */
7
+ const shuffleArray = <T>(arr: T[]): T[] => {
8
+ const newArr = [...arr];
9
+
10
+ // Shuffle using Durstenfeld algorithm
11
+ for (let i = arr.length - 1; i > 0; i--) {
12
+ const j = Math.floor(Math.random() * (i + 1));
13
+ [newArr[i], newArr[j]] = [newArr[j], newArr[i]];
14
+ }
15
+
16
+ return newArr;
17
+ };
18
+
19
+ export default shuffleArray;
@@ -123,12 +123,24 @@ const visitServerEndpoint = async (
123
123
  );
124
124
  }
125
125
 
126
+ // Remove properties with undefined values
127
+ let params: { [key in string]: any } | undefined;
128
+ if (opts.params) {
129
+ params = Object.fromEntries(
130
+ Object
131
+ .entries(opts.params)
132
+ .filter(([key, value]) => {
133
+ return value !== undefined;
134
+ }),
135
+ );
136
+ }
137
+
126
138
  // Send the request
127
139
  const sendRequest = await getSendRequest();
128
140
  const response = await sendRequest({
129
141
  path: opts.path,
130
142
  method: opts.method ?? 'GET',
131
- params: opts.params,
143
+ params,
132
144
  });
133
145
 
134
146
  // Check for failure
package/src/index.ts CHANGED
@@ -91,6 +91,7 @@ import forEachAsync from './helpers/asyncArrayFunctions/forEachAsync';
91
91
  import mapAsync from './helpers/asyncArrayFunctions/mapAsync';
92
92
  import someAsync from './helpers/asyncArrayFunctions/someAsync';
93
93
  import capitalize from './helpers/capitalize';
94
+ import shuffleArray from './helpers/shuffleArray';
94
95
 
95
96
  // Import types
96
97
  import ModalButtonType from './types/ModalButtonType';
@@ -193,6 +194,7 @@ export {
193
194
  mapAsync,
194
195
  someAsync,
195
196
  capitalize,
197
+ shuffleArray,
196
198
  // Client helpers
197
199
  initClient,
198
200
  visitServerEndpoint,