dce-reactkit 3.9.9 → 3.10.0

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.
@@ -11,10 +11,12 @@ type Props = {
11
11
  title?: string;
12
12
  selected?: boolean;
13
13
  id?: string;
14
+ className?: string;
14
15
  noMarginOnRight?: boolean;
15
16
  selectedVariant?: Variant;
16
17
  unselectedVariant?: Variant;
17
18
  small?: boolean;
19
+ useComplexFormatting?: boolean;
18
20
  };
19
21
  declare const RadioButton: React.FC<Props>;
20
22
  export default RadioButton;
package/dist/index.d.ts CHANGED
@@ -244,10 +244,12 @@ type Props$i = {
244
244
  title?: string;
245
245
  selected?: boolean;
246
246
  id?: string;
247
+ className?: string;
247
248
  noMarginOnRight?: boolean;
248
249
  selectedVariant?: Variant;
249
250
  unselectedVariant?: Variant;
250
251
  small?: boolean;
252
+ useComplexFormatting?: boolean;
251
253
  };
252
254
  declare const RadioButton: React$1.FC<Props$i>;
253
255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.9.9",
3
+ "version": "3.10.0",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -126,21 +126,21 @@ const CheckboxButton: React.FC<Props> = (props) => {
126
126
  </div>
127
127
  {
128
128
  useComplexFormatting
129
- ? (
130
- <pre
131
- className="ps-2 text-start text-break"
132
- style={{
133
- whiteSpace: 'pre-wrap',
134
- }}
135
- >
136
- {text}
137
- </pre>
138
- )
139
- : (
140
- <div className="flex-grow-1 text-start text-break ps-2">
141
- {text}
142
- </div>
143
- )
129
+ ? (
130
+ <pre
131
+ className="ps-2 text-start text-break"
132
+ style={{
133
+ whiteSpace: 'pre-wrap',
134
+ }}
135
+ >
136
+ {text}
137
+ </pre>
138
+ )
139
+ : (
140
+ <div className="flex-grow-1 text-start text-break ps-2">
141
+ {text}
142
+ </div>
143
+ )
144
144
  }
145
145
  </div>
146
146
  </button>
@@ -32,6 +32,8 @@ type Props = {
32
32
  selected?: boolean,
33
33
  // The id of the button
34
34
  id?: string,
35
+ // Custom class name of the button
36
+ className?: string,
35
37
  // If true, no margin on right
36
38
  noMarginOnRight?: boolean,
37
39
  // Variant for when radio is selected
@@ -40,6 +42,8 @@ type Props = {
40
42
  unselectedVariant?: Variant,
41
43
  // True if using a small button
42
44
  small?: boolean,
45
+ // If true, use complex formatting (tabs, newlines) in the text
46
+ useComplexFormatting?: boolean,
43
47
  };
44
48
 
45
49
  /*------------------------------------------------------------------------*/
@@ -60,6 +64,7 @@ const RadioButton: React.FC<Props> = (props) => {
60
64
  title,
61
65
  selected,
62
66
  id,
67
+ className,
63
68
  noMarginOnRight,
64
69
  selectedVariant = (
65
70
  isDarkModeOn()
@@ -72,6 +77,7 @@ const RadioButton: React.FC<Props> = (props) => {
72
77
  : Variant.Light
73
78
  ),
74
79
  small,
80
+ useComplexFormatting,
75
81
  } = props;
76
82
 
77
83
  /*------------------------------------------------------------------------*/
@@ -87,7 +93,7 @@ const RadioButton: React.FC<Props> = (props) => {
87
93
  type="button"
88
94
  id={id}
89
95
  title={title}
90
- className={`btn btn-${selected ? selectedVariant : unselectedVariant}${selected ? ' selected' : ''}${small ? ' btn-sm' : ''} m-0${noMarginOnRight ? '' : ' me-1'}`}
96
+ className={`btn btn-${selected ? selectedVariant : unselectedVariant}${selected ? ' selected' : ''}${small ? ' btn-sm' : ''} m-0${noMarginOnRight ? '' : ' me-1'} ${className ?? ''}`}
91
97
  aria-label={`${ariaLabel}${selected ? ': currently selected' : ''}`}
92
98
  onClick={() => {
93
99
  if (!selected) {
@@ -99,7 +105,24 @@ const RadioButton: React.FC<Props> = (props) => {
99
105
  icon={selected ? faDotCircle : faCircle}
100
106
  className="me-1"
101
107
  />
102
- {text}
108
+ {
109
+ useComplexFormatting
110
+ ? (
111
+ <pre
112
+ className="ps-2 text-start text-break"
113
+ style={{
114
+ whiteSpace: 'pre-wrap',
115
+ }}
116
+ >
117
+ {text}
118
+ </pre>
119
+ )
120
+ : (
121
+ <div className="flex-grow-1 text-start text-break ps-2">
122
+ {text}
123
+ </div>
124
+ )
125
+ }
103
126
  </button>
104
127
  );
105
128
  };
@@ -625,16 +625,16 @@ const genRouteHandler = (
625
625
 
626
626
  // Main log info
627
627
  const mainLogInfo: LogMainInfo = {
628
- id: `${launchInfo ? 'unknown' : launchInfo.userId}-${Date.now()}-${Math.floor(Math.random() * 100000)}-${Math.floor(Math.random() * 100000)}`,
629
- userFirstName: (launchInfo ? 'unknown' : launchInfo.userFirstName),
630
- userLastName: (launchInfo ? 'unknown' : launchInfo.userLastName),
631
- userEmail: (launchInfo ? 'unknown' : launchInfo.userEmail),
632
- userId: (launchInfo ? 'unknown' : launchInfo.userId),
628
+ id: `${launchInfo ? launchInfo.userId : 'unknown'}-${Date.now()}-${Math.floor(Math.random() * 100000)}-${Math.floor(Math.random() * 100000)}`,
629
+ userFirstName: (launchInfo ? launchInfo.userFirstName: 'unknown'),
630
+ userLastName: (launchInfo ? launchInfo.userLastName : 'unknown'),
631
+ userEmail: (launchInfo ? launchInfo.userEmail : 'unknown'),
632
+ userId: (launchInfo ? launchInfo.userId : 'unknown'),
633
633
  isLearner: (launchInfo && !!launchInfo.isLearner),
634
634
  isAdmin: (launchInfo && !!launchInfo.isAdmin),
635
635
  isTTM: (launchInfo && !!launchInfo.isTTM),
636
- courseId: (launchInfo ? 'unknown' : launchInfo.courseId),
637
- courseName: (launchInfo ? 'unknown' : launchInfo.contextLabel),
636
+ courseId: (launchInfo ? launchInfo.courseId : 'unknown' ),
637
+ courseName: (launchInfo ? launchInfo.contextLabel : 'unknown'),
638
638
  browser,
639
639
  device,
640
640
  year,