dce-reactkit 3.6.10 → 3.6.12
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 +38 -25
- 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 +3 -2
- package/dist/esm/index.js +38 -25
- 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 +3 -2
- package/dist/index.d.ts +4 -2
- package/package.json +5 -5
- package/src/components/MultiSwitch.tsx +16 -2
- package/src/helpers/combineClassNames.ts +7 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Merges a list of class names into a class name, intelligently handling spaces
|
|
3
3
|
* @author Gabe Abrams
|
|
4
|
-
* @param classNames the list of class names to merge
|
|
4
|
+
* @param classNames the list of class names to merge (or falsey values to
|
|
5
|
+
* ignore)
|
|
5
6
|
* @returns the merged class name
|
|
6
7
|
*/
|
|
7
|
-
declare const combineClassNames: (classNames: string[]) => string;
|
|
8
|
+
declare const combineClassNames: (classNames: (string | undefined | null | false)[]) => string;
|
|
8
9
|
export default combineClassNames;
|
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 = {
|
|
@@ -1419,10 +1420,11 @@ declare const makeLinksClickable: (text: string, opts?: {
|
|
|
1419
1420
|
/**
|
|
1420
1421
|
* Merges a list of class names into a class name, intelligently handling spaces
|
|
1421
1422
|
* @author Gabe Abrams
|
|
1422
|
-
* @param classNames the list of class names to merge
|
|
1423
|
+
* @param classNames the list of class names to merge (or falsey values to
|
|
1424
|
+
* ignore)
|
|
1423
1425
|
* @returns the merged class name
|
|
1424
1426
|
*/
|
|
1425
|
-
declare const combineClassNames: (classNames: string[]) => string;
|
|
1427
|
+
declare const combineClassNames: (classNames: (string | undefined | null | false)[]) => string;
|
|
1426
1428
|
|
|
1427
1429
|
/**
|
|
1428
1430
|
* List of error codes built into the react kit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-reactkit",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.12",
|
|
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
|
)}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Merges a list of class names into a class name, intelligently handling spaces
|
|
3
3
|
* @author Gabe Abrams
|
|
4
|
-
* @param classNames the list of class names to merge
|
|
4
|
+
* @param classNames the list of class names to merge (or falsey values to
|
|
5
|
+
* ignore)
|
|
5
6
|
* @returns the merged class name
|
|
6
7
|
*/
|
|
7
|
-
const combineClassNames = (classNames: string[]): string => {
|
|
8
|
+
const combineClassNames = (classNames: (string | undefined | null | false)[]): string => {
|
|
8
9
|
return (
|
|
9
10
|
classNames
|
|
11
|
+
// Turn falsey values into empty strings
|
|
12
|
+
.map((className) => {
|
|
13
|
+
return className || '';
|
|
14
|
+
})
|
|
10
15
|
// Trim whitespace
|
|
11
16
|
.map((className) => {
|
|
12
17
|
return className.trim();
|