dce-reactkit 3.6.10 → 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.
@@ -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
  import React from 'react';
7
8
  import { IconProp } from '@fortawesome/fontawesome-svg-core';
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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.6.10",
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
- "react": "^x.x.x",
36
- "express": "^x.x.x"
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.19",
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
- className={`MultiSwitch-option-button${option.id === hoveredOptionId ? ' MultiSwitch-option-button-hovered' : ''}`}
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
- option.id === selectedOptionId
275
+ isSelected
262
276
  ? `option "${option.label}", currently selected`
263
277
  : `click to select option "${option.label}"`
264
278
  )}