dce-reactkit 3.11.2 → 3.11.4

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,10 @@
1
+ /**
2
+ * Get number of words in string
3
+ * @author Gardenia Liu
4
+ * @author Allison Zhang
5
+ * @author Gabe Abrams
6
+ * @param text the string to check
7
+ * @returns number of words in the string
8
+ */
9
+ declare const getWordCount: (text: string) => number;
10
+ export default getWordCount;
@@ -79,6 +79,7 @@ import someAsync from './helpers/asyncArrayFunctions/someAsync';
79
79
  import capitalize from './helpers/capitalize';
80
80
  import shuffleArray from './helpers/shuffleArray';
81
81
  import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
82
+ import getWordCount from './helpers/getWordCount';
82
83
  import ModalButtonType from './types/ModalButtonType';
83
84
  import ModalSize from './types/ModalSize';
84
85
  import ModalType from './types/ModalType';
@@ -99,4 +100,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
99
100
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
100
101
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
101
102
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
102
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, 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, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
103
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, 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, getWordCount, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
package/dist/index.d.ts CHANGED
@@ -1679,6 +1679,16 @@ declare const visitEndpointOnAnotherServer: (opts: {
1679
1679
  } | undefined;
1680
1680
  }) => Promise<any>;
1681
1681
 
1682
+ /**
1683
+ * Get number of words in string
1684
+ * @author Gardenia Liu
1685
+ * @author Allison Zhang
1686
+ * @author Gabe Abrams
1687
+ * @param text the string to check
1688
+ * @returns number of words in the string
1689
+ */
1690
+ declare const getWordCount: (text: string) => number;
1691
+
1682
1692
  /**
1683
1693
  * List of error codes built into the react kit
1684
1694
  * @author Gabe Abrams
@@ -1734,4 +1744,4 @@ declare const LogBuiltInMetadata: {
1734
1744
  };
1735
1745
  };
1736
1746
 
1737
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, 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, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
1747
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, 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, getWordCount, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.11.2",
3
+ "version": "3.11.4",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -315,7 +315,7 @@ const IntelliTable: React.FC<Props> = (props) => {
315
315
  checked={columnVisibilityMap[column.param]}
316
316
  ariaLabel={`show "${column.title}" column in the ${title} table`}
317
317
  checkedVariant={Variant.Light}
318
- uncheckedVariant={Variant.Secondary}
318
+ uncheckedVariant={Variant.Light}
319
319
  />
320
320
  );
321
321
  })
@@ -272,6 +272,7 @@ const NestableItemList: React.FC<Props> = (props) => {
272
272
  }}
273
273
  ariaLabel={`Select ${item.name}`}
274
274
  checkedVariant={Variant.Light}
275
+ uncheckedVariant={Variant.Light}
275
276
  />
276
277
 
277
278
  {/* Children */}
@@ -126,7 +126,7 @@ const genRouteHandler = (
126
126
  const originURL = String(
127
127
  req.get('origin')
128
128
  || req.headers.origin
129
- || req.headers.referer
129
+ || req.headers.referer,
130
130
  );
131
131
  const originHostname = (
132
132
  originURL
@@ -0,0 +1,26 @@
1
+ const punctuationRegex = /[!@#$%^&*(),.?\/;:'"\-\[\]]/g;
2
+
3
+ /**
4
+ * Get number of words in string
5
+ * @author Gardenia Liu
6
+ * @author Allison Zhang
7
+ * @author Gabe Abrams
8
+ * @param text the string to check
9
+ * @returns number of words in the string
10
+ */
11
+ const getWordCount = (text: string): number => {
12
+ const trimmedTextWithoutPunctuation = (
13
+ text
14
+ // Remove leading and trailing whitespace
15
+ .trim()
16
+ // Remove punctuation
17
+ .replace(punctuationRegex, '')
18
+ );
19
+ if (trimmedTextWithoutPunctuation.length === 0) {
20
+ return 0;
21
+ }
22
+
23
+ return trimmedTextWithoutPunctuation.split(/\s+/g).length;
24
+ };
25
+
26
+ export default getWordCount;
package/src/index.ts CHANGED
@@ -95,6 +95,7 @@ import someAsync from './helpers/asyncArrayFunctions/someAsync';
95
95
  import capitalize from './helpers/capitalize';
96
96
  import shuffleArray from './helpers/shuffleArray';
97
97
  import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
98
+ import getWordCount from './helpers/getWordCount';
98
99
 
99
100
  // Import types
100
101
  import ModalButtonType from './types/ModalButtonType';
@@ -201,6 +202,7 @@ export {
201
202
  someAsync,
202
203
  capitalize,
203
204
  shuffleArray,
205
+ getWordCount,
204
206
  // Client helpers
205
207
  initClient,
206
208
  visitServerEndpoint,