dce-reactkit 3.6.9 → 3.6.11
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 +34 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/MultiSwitch.d.ts +1 -0
- package/dist/cjs/types/helpers/combineClassNames.d.ts +8 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/esm/index.js +34 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/MultiSwitch.d.ts +1 -0
- package/dist/esm/types/helpers/combineClassNames.d.ts +8 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/index.d.ts +10 -1
- package/package.json +5 -5
- package/src/components/MultiSwitch.tsx +16 -2
- package/src/helpers/combineClassNames.ts +27 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges a list of class names into a class name, intelligently handling spaces
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param classNames the list of class names to merge
|
|
5
|
+
* @returns the merged class name
|
|
6
|
+
*/
|
|
7
|
+
declare const combineClassNames: (classNames: string[]) => string;
|
|
8
|
+
export default combineClassNames;
|
|
@@ -67,6 +67,7 @@ import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
|
|
|
67
67
|
import validateString from './helpers/validators/validateString';
|
|
68
68
|
import idify from './helpers/idify';
|
|
69
69
|
import makeLinksClickable from './helpers/makeLinksClickable';
|
|
70
|
+
import combineClassNames from './helpers/combineClassNames';
|
|
70
71
|
import ModalButtonType from './types/ModalButtonType';
|
|
71
72
|
import ModalSize from './types/ModalSize';
|
|
72
73
|
import ModalType from './types/ModalType';
|
|
@@ -85,4 +86,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
85
86
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
86
87
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
87
88
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
88
|
-
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, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
|
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, };
|
package/dist/index.d.ts
CHANGED
|
@@ -642,6 +642,7 @@ declare const AutoscrollToBottomContainer: React.FC<Props$1>;
|
|
|
642
642
|
* A switch with multiple options for selection
|
|
643
643
|
* @author Alessandra De Lucas
|
|
644
644
|
* @author Gabe Abrams
|
|
645
|
+
* @author Austen Money
|
|
645
646
|
*/
|
|
646
647
|
|
|
647
648
|
type Props = {
|
|
@@ -1416,6 +1417,14 @@ declare const makeLinksClickable: (text: string, opts?: {
|
|
|
1416
1417
|
inheritColor?: boolean;
|
|
1417
1418
|
}) => React.ReactNode;
|
|
1418
1419
|
|
|
1420
|
+
/**
|
|
1421
|
+
* Merges a list of class names into a class name, intelligently handling spaces
|
|
1422
|
+
* @author Gabe Abrams
|
|
1423
|
+
* @param classNames the list of class names to merge
|
|
1424
|
+
* @returns the merged class name
|
|
1425
|
+
*/
|
|
1426
|
+
declare const combineClassNames: (classNames: string[]) => string;
|
|
1427
|
+
|
|
1419
1428
|
/**
|
|
1420
1429
|
* List of error codes built into the react kit
|
|
1421
1430
|
* @author Gabe Abrams
|
|
@@ -1466,4 +1475,4 @@ declare const LogBuiltInMetadata: {
|
|
|
1466
1475
|
};
|
|
1467
1476
|
};
|
|
1468
1477
|
|
|
1469
|
-
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, 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 };
|
|
1478
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-reactkit",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.11",
|
|
4
4
|
"description": "Shared components for Harvard DCE apps",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"react-select": "^5.7.3"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
+
"@fortawesome/fontawesome-svg-core": "^x.x.x",
|
|
30
31
|
"@fortawesome/free-regular-svg-icons": "^x.x.x",
|
|
31
32
|
"@fortawesome/free-solid-svg-icons": "^x.x.x",
|
|
32
|
-
"@fortawesome/fontawesome-svg-core": "^x.x.x",
|
|
33
33
|
"@fortawesome/react-fontawesome": "^x.x.x",
|
|
34
34
|
"bootstrap": "^5.x.x",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"express": "^x.x.x",
|
|
36
|
+
"react": "^x.x.x"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
56
56
|
"jest": "^28.1.3",
|
|
57
57
|
"jest-environment-jsdom": "^28.1.3",
|
|
58
|
-
"raixa": "^1.0.
|
|
58
|
+
"raixa": "^1.0.21",
|
|
59
59
|
"rollup": "^2.70.2",
|
|
60
60
|
"rollup-plugin-dts": "^4.2.1",
|
|
61
61
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* A switch with multiple options for selection
|
|
3
3
|
* @author Alessandra De Lucas
|
|
4
4
|
* @author Gabe Abrams
|
|
5
|
+
* @author Austen Money
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
// Import React
|
|
@@ -11,6 +12,10 @@ import React, { useReducer } from 'react';
|
|
|
11
12
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
12
13
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
13
14
|
|
|
15
|
+
// Import shared helpers
|
|
16
|
+
import idify from '../helpers/idify';
|
|
17
|
+
import combineClassNames from '../helpers/combineClassNames';
|
|
18
|
+
|
|
14
19
|
/*------------------------------------------------------------------------*/
|
|
15
20
|
/* -------------------------------- Types ------------------------------- */
|
|
16
21
|
/*------------------------------------------------------------------------*/
|
|
@@ -253,12 +258,21 @@ const MultiSwitch: React.FC<Props> = (props) => {
|
|
|
253
258
|
/*----------------------------------------*/
|
|
254
259
|
|
|
255
260
|
const optionElements = options.map((option) => {
|
|
261
|
+
const isSelected = (option.id === selectedOptionId);
|
|
262
|
+
const isHovered = (option.id === hoveredOptionId);
|
|
263
|
+
|
|
256
264
|
return (
|
|
257
265
|
<button
|
|
258
266
|
type="button"
|
|
259
|
-
|
|
267
|
+
key={option.id}
|
|
268
|
+
className={combineClassNames([
|
|
269
|
+
'MultiSwitch-option-button',
|
|
270
|
+
(isHovered ? 'MultiSwitch-option-button-hovered' : ''),
|
|
271
|
+
`MultiSwitch-option-button-with-id-${idify(option.id)}`,
|
|
272
|
+
`MultiSwitch-option-button-is${isSelected ? '' : '-not'}-selected`,
|
|
273
|
+
])}
|
|
260
274
|
aria-label={(
|
|
261
|
-
|
|
275
|
+
isSelected
|
|
262
276
|
? `option "${option.label}", currently selected`
|
|
263
277
|
: `click to select option "${option.label}"`
|
|
264
278
|
)}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges a list of class names into a class name, intelligently handling spaces
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param classNames the list of class names to merge
|
|
5
|
+
* @returns the merged class name
|
|
6
|
+
*/
|
|
7
|
+
const combineClassNames = (classNames: string[]): string => {
|
|
8
|
+
return (
|
|
9
|
+
classNames
|
|
10
|
+
// Trim whitespace
|
|
11
|
+
.map((className) => {
|
|
12
|
+
return className.trim();
|
|
13
|
+
})
|
|
14
|
+
// Remove empty class names
|
|
15
|
+
.filter((className) => {
|
|
16
|
+
return className.length > 0;
|
|
17
|
+
})
|
|
18
|
+
// Change multiple spaces for just one space
|
|
19
|
+
.map((className) => {
|
|
20
|
+
return className.replace(/\s+/g, ' ');
|
|
21
|
+
})
|
|
22
|
+
// Join with spaces
|
|
23
|
+
.join(' ')
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default combineClassNames;
|
package/src/index.ts
CHANGED
|
@@ -82,6 +82,7 @@ import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
|
|
|
82
82
|
import validateString from './helpers/validators/validateString';
|
|
83
83
|
import idify from './helpers/idify';
|
|
84
84
|
import makeLinksClickable from './helpers/makeLinksClickable';
|
|
85
|
+
import combineClassNames from './helpers/combineClassNames';
|
|
85
86
|
|
|
86
87
|
// Import types
|
|
87
88
|
import ModalButtonType from './types/ModalButtonType';
|
|
@@ -182,6 +183,7 @@ export {
|
|
|
182
183
|
logClientEvent,
|
|
183
184
|
addFatalErrorHandler,
|
|
184
185
|
leaveToURL,
|
|
186
|
+
combineClassNames,
|
|
185
187
|
// Server helpers
|
|
186
188
|
initServer,
|
|
187
189
|
genRouteHandler,
|