dce-reactkit 3.4.0 → 3.4.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.
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Given an array of strings, create a single comma-separated string that includes
3
3
  * 'and' as well as an oxford comma.
4
- * Ex: ['apples'] => 'apples'
5
- * Ex: ['apples', 'bananas'] => 'apples and bananas'
6
- * Ex: ['apples', 'bananas', 'grapes'] => 'apples, bananas, and grapes'
4
+ * Ex: ['apples'] => 'apples'
5
+ * Ex: ['apples', 'bananas'] => 'apples and bananas'
6
+ * Ex: ['apples', 'bananas', 'grapes'] => 'apples, bananas, and grapes'
7
7
  * @author Austen Money
8
8
  * @param list an array of elements to be made into a single comma-separated string.
9
9
  * @returns a comma-separated string.
@@ -2,7 +2,7 @@
2
2
  * Result of a validation function.
3
3
  * @author Austen Money
4
4
  */
5
- type ValidationResult<CleanedValueType> = ({
5
+ declare type ValidationResult<CleanedValueType> = ({
6
6
  isValid: true;
7
7
  cleanedValue: CleanedValueType;
8
8
  } | {
@@ -54,6 +54,10 @@ import canReviewLogs from './helpers/canReviewLogs';
54
54
  import isMobileOrTablet from './helpers/isMobileOrTablet';
55
55
  import extractProp from './helpers/extractProp';
56
56
  import compareArraysByProp from './helpers/compareArraysByProp';
57
+ import genCommaList from './helpers/genCommaList';
58
+ import validateEmail from './helpers/validators/validateEmail';
59
+ import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
60
+ import validateString from './helpers/validators/validateString';
57
61
  import getLocalTimeInfo from './helpers/getLocalTimeInfo';
58
62
  import ModalButtonType from './types/ModalButtonType';
59
63
  import ModalSize from './types/ModalSize';
@@ -70,4 +74,4 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
70
74
  import LogMetadataType from './types/LogMetadataType';
71
75
  import IntelliTableColumn from './types/IntelliTableColumn';
72
76
  import PickableItem from './components/ItemPicker/types/PickableItem';
73
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, 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, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
77
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, 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, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
package/dist/index.d.ts CHANGED
@@ -1066,6 +1066,71 @@ declare const extractProp: (arr: any[], prop: string) => any[];
1066
1066
  */
1067
1067
  declare const compareArraysByProp: (a: any[], b: any[], prop: string) => boolean;
1068
1068
 
1069
+ /**
1070
+ * Given an array of strings, create a single comma-separated string that includes
1071
+ * 'and' as well as an oxford comma.
1072
+ * Ex: ['apples'] => 'apples'
1073
+ * Ex: ['apples', 'bananas'] => 'apples and bananas'
1074
+ * Ex: ['apples', 'bananas', 'grapes'] => 'apples, bananas, and grapes'
1075
+ * @author Austen Money
1076
+ * @param list an array of elements to be made into a single comma-separated string.
1077
+ * @returns a comma-separated string.
1078
+ */
1079
+ declare const genCommaList: (list: string[]) => string;
1080
+
1081
+ /**
1082
+ * Result of a validation function.
1083
+ * @author Austen Money
1084
+ */
1085
+ declare type ValidationResult<CleanedValueType> = ({
1086
+ isValid: true;
1087
+ cleanedValue: CleanedValueType;
1088
+ } | {
1089
+ isValid: false;
1090
+ errorMessage: string;
1091
+ });
1092
+
1093
+ /**
1094
+ * Determines whether a given email address is valid.
1095
+ * @author Austen Money
1096
+ * @param email email address to validate
1097
+ * @returns whether email fulfills proper formatting requirements, includes a
1098
+ * cleaned version of the address without leading or trailing
1099
+ * whitespace if valid or an error message if invalid.
1100
+ */
1101
+ declare const validateEmail: (email: string) => ValidationResult<string>;
1102
+
1103
+ /**
1104
+ * Determines whether a given phone number is valid.
1105
+ * @author Austen Money
1106
+ * @param phoneNumber phone number to validate
1107
+ * @returns whether phone number is considered valid - if valid, also returns
1108
+ * a cleaned version of the number without any formatting. If invalid,
1109
+ * returns an error message.
1110
+ */
1111
+ declare const validatePhoneNumber: (phoneNumber: string) => ValidationResult<string>;
1112
+
1113
+ /**
1114
+ * Determines whether a given input string is considered valid based on
1115
+ * the provided requirements.
1116
+ * @author Austen Money
1117
+ * @param input input string
1118
+ * @param opts options for validation
1119
+ * @returns whether input is considered valid according to reqs - if
1120
+ * valid, returns a cleaned version of input; if invalid, returns
1121
+ * a string containing error messages describing which requirements
1122
+ * were not met.
1123
+ */
1124
+ declare const validateString: (input: string, opts: {
1125
+ ignoreWhitespace?: boolean;
1126
+ minLen?: number;
1127
+ maxLen?: number;
1128
+ lettersOnly?: boolean;
1129
+ numbersOnly?: boolean;
1130
+ regexTest?: RegExp;
1131
+ regexDescription?: string;
1132
+ }) => ValidationResult<string>;
1133
+
1069
1134
  /**
1070
1135
  * Get current time info in local time
1071
1136
  * @author Gabe Abrams
@@ -1135,4 +1200,4 @@ declare const LogBuiltInMetadata: {
1135
1200
  };
1136
1201
  };
1137
1202
 
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 };
1203
+ 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, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, 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.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",