@khanacademy/wonder-blocks-form 2.3.1 → 2.3.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @khanacademy/wonder-blocks-form
2
+
3
+ ## 2.3.2
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [901bfe82]
7
+ - @khanacademy/wonder-blocks-clickable@2.2.2
package/dist/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _extends from '@babel/runtime/helpers/extends';
2
- import { Component, createElement, Fragment, Children, cloneElement, forwardRef } from 'react';
2
+ import * as React from 'react';
3
3
  import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
4
4
  import { StyleSheet, css } from 'aphrodite';
5
5
  import Color, { mix, fade } from '@khanacademy/wonder-blocks-color';
@@ -10,17 +10,17 @@ import Spacing from '@khanacademy/wonder-blocks-spacing';
10
10
  import { LabelMedium, LabelSmall, styles as styles$6 } from '@khanacademy/wonder-blocks-typography';
11
11
  import Icon from '@khanacademy/wonder-blocks-icon';
12
12
 
13
- const _excluded = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
13
+ const _excluded$4 = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
14
14
  const {
15
- blue,
16
- red,
17
- white,
18
- offWhite,
19
- offBlack16,
20
- offBlack32,
21
- offBlack50
15
+ blue: blue$1,
16
+ red: red$1,
17
+ white: white$1,
18
+ offWhite: offWhite$1,
19
+ offBlack16: offBlack16$1,
20
+ offBlack32: offBlack32$1,
21
+ offBlack50: offBlack50$1
22
22
  } = Color;
23
- const StyledInput = addStyle("input");
23
+ const StyledInput$1 = addStyle("input");
24
24
  const checkboxCheck = {
25
25
  small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z"
26
26
  };
@@ -28,7 +28,7 @@ const checkboxCheck = {
28
28
  * The internal stateless ☑️ Checkbox
29
29
  */
30
30
 
31
- class CheckboxCore extends Component {
31
+ class CheckboxCore extends React.Component {
32
32
  constructor(...args) {
33
33
  super(...args);
34
34
 
@@ -51,15 +51,15 @@ class CheckboxCore extends Component {
51
51
  focused,
52
52
  pressed
53
53
  } = _this$props,
54
- sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
54
+ sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
55
55
 
56
- const stateStyles = _generateStyles(checked, error);
56
+ const stateStyles = _generateStyles$1(checked, error);
57
57
 
58
- const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles.disabled];
58
+ const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles$1.disabled];
59
59
  const props = {
60
60
  "data-test-id": testId
61
61
  };
62
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(StyledInput, _extends({}, sharedProps, {
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledInput$1, _extends({}, sharedProps, {
63
63
  type: "checkbox",
64
64
  "aria-invalid": error,
65
65
  checked: checked,
@@ -70,17 +70,17 @@ class CheckboxCore extends Component {
70
70
  ,
71
71
  onChange: this.handleChange,
72
72
  style: defaultStyle
73
- }, props)), checked && /*#__PURE__*/createElement(Icon, {
74
- color: disabled ? offBlack32 : white,
73
+ }, props)), checked && /*#__PURE__*/React.createElement(Icon, {
74
+ color: disabled ? offBlack32$1 : white$1,
75
75
  icon: checkboxCheck,
76
76
  size: "small",
77
- style: sharedStyles.checkIcon
77
+ style: sharedStyles$1.checkIcon
78
78
  }));
79
79
  }
80
80
 
81
81
  }
82
- const size = 16;
83
- const sharedStyles = StyleSheet.create({
82
+ const size$1 = 16;
83
+ const sharedStyles$1 = StyleSheet.create({
84
84
  // Reset the default styled input element
85
85
  inputReset: {
86
86
  appearance: "none",
@@ -88,10 +88,10 @@ const sharedStyles = StyleSheet.create({
88
88
  MozAppearance: "none"
89
89
  },
90
90
  default: {
91
- height: size,
92
- width: size,
93
- minHeight: size,
94
- minWidth: size,
91
+ height: size$1,
92
+ width: size$1,
93
+ minHeight: size$1,
94
+ minWidth: size$1,
95
95
  margin: 0,
96
96
  outline: "none",
97
97
  boxSizing: "border-box",
@@ -101,8 +101,8 @@ const sharedStyles = StyleSheet.create({
101
101
  },
102
102
  disabled: {
103
103
  cursor: "auto",
104
- backgroundColor: offWhite,
105
- borderColor: offBlack16,
104
+ backgroundColor: offWhite$1,
105
+ borderColor: offBlack16$1,
106
106
  borderWidth: 1
107
107
  },
108
108
  checkIcon: {
@@ -110,33 +110,33 @@ const sharedStyles = StyleSheet.create({
110
110
  pointerEvents: "none"
111
111
  }
112
112
  });
113
- const fadedBlue = mix(fade(blue, 0.16), white);
114
- const activeBlue = mix(offBlack32, blue);
115
- const fadedRed = mix(fade(red, 0.08), white);
116
- const activeRed = mix(offBlack32, red);
117
- const colors = {
113
+ const fadedBlue$1 = mix(fade(blue$1, 0.16), white$1);
114
+ const activeBlue$1 = mix(offBlack32$1, blue$1);
115
+ const fadedRed$1 = mix(fade(red$1, 0.08), white$1);
116
+ const activeRed$1 = mix(offBlack32$1, red$1);
117
+ const colors$1 = {
118
118
  default: {
119
- faded: fadedBlue,
120
- base: blue,
121
- active: activeBlue
119
+ faded: fadedBlue$1,
120
+ base: blue$1,
121
+ active: activeBlue$1
122
122
  },
123
123
  error: {
124
- faded: fadedRed,
125
- base: red,
126
- active: activeRed
124
+ faded: fadedRed$1,
125
+ base: red$1,
126
+ active: activeRed$1
127
127
  }
128
128
  };
129
- const styles = {};
129
+ const styles$5 = {};
130
130
 
131
- const _generateStyles = (checked, error) => {
131
+ const _generateStyles$1 = (checked, error) => {
132
132
  // "hash" the parameters
133
133
  const styleKey = `${String(checked)}-${String(error)}`;
134
134
 
135
- if (styles[styleKey]) {
136
- return styles[styleKey];
135
+ if (styles$5[styleKey]) {
136
+ return styles$5[styleKey];
137
137
  }
138
138
 
139
- const palette = error ? colors.error : colors.default;
139
+ const palette = error ? colors$1.error : colors$1.default;
140
140
  let newStyles = {};
141
141
 
142
142
  if (checked) {
@@ -146,52 +146,52 @@ const _generateStyles = (checked, error) => {
146
146
  borderWidth: 0
147
147
  },
148
148
  focus: {
149
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
149
+ boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.base}`
150
150
  },
151
151
  active: {
152
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.active}`,
152
+ boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.active}`,
153
153
  background: palette.active
154
154
  }
155
155
  };
156
156
  } else {
157
157
  newStyles = {
158
158
  default: {
159
- backgroundColor: error ? fadedRed : white,
160
- borderColor: error ? red : offBlack50
159
+ backgroundColor: error ? fadedRed$1 : white$1,
160
+ borderColor: error ? red$1 : offBlack50$1
161
161
  },
162
162
  focus: {
163
- backgroundColor: error ? fadedRed : white,
163
+ backgroundColor: error ? fadedRed$1 : white$1,
164
164
  borderColor: palette.base,
165
165
  borderWidth: 2
166
166
  },
167
167
  active: {
168
168
  backgroundColor: palette.faded,
169
- borderColor: error ? activeRed : blue,
169
+ borderColor: error ? activeRed$1 : blue$1,
170
170
  borderWidth: 2
171
171
  }
172
172
  };
173
173
  }
174
174
 
175
- styles[styleKey] = StyleSheet.create(newStyles);
176
- return styles[styleKey];
175
+ styles$5[styleKey] = StyleSheet.create(newStyles);
176
+ return styles$5[styleKey];
177
177
  };
178
178
 
179
- const _excluded$1 = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
179
+ const _excluded$3 = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
180
180
  const {
181
- blue: blue$1,
182
- red: red$1,
183
- white: white$1,
184
- offWhite: offWhite$1,
185
- offBlack16: offBlack16$1,
186
- offBlack32: offBlack32$1,
187
- offBlack50: offBlack50$1
181
+ blue,
182
+ red,
183
+ white,
184
+ offWhite,
185
+ offBlack16,
186
+ offBlack32,
187
+ offBlack50
188
188
  } = Color;
189
- const StyledInput$1 = addStyle("input");
189
+ const StyledInput = addStyle("input");
190
190
  /**
191
191
  * The internal stateless 🔘 Radio button
192
192
  */
193
193
 
194
- class RadioCore extends Component {
194
+ class RadioCore extends React.Component {
195
195
  constructor(...args) {
196
196
  super(...args);
197
197
 
@@ -214,15 +214,15 @@ class RadioCore extends Component {
214
214
  focused,
215
215
  pressed
216
216
  } = _this$props,
217
- sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
217
+ sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$3);
218
218
 
219
- const stateStyles = _generateStyles$1(checked, error);
219
+ const stateStyles = _generateStyles(checked, error);
220
220
 
221
- const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles$1.disabled];
221
+ const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles.disabled];
222
222
  const props = {
223
223
  "data-test-id": testId
224
224
  };
225
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(StyledInput$1, _extends({}, sharedProps, {
225
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledInput, _extends({}, sharedProps, {
226
226
  type: "radio",
227
227
  "aria-invalid": error,
228
228
  checked: checked,
@@ -233,24 +233,24 @@ class RadioCore extends Component {
233
233
  ,
234
234
  onChange: this.handleChange,
235
235
  style: defaultStyle
236
- }, props)), disabled && checked && /*#__PURE__*/createElement("span", {
236
+ }, props)), disabled && checked && /*#__PURE__*/React.createElement("span", {
237
237
  style: disabledChecked
238
238
  }));
239
239
  }
240
240
 
241
241
  }
242
- const size$1 = 16; // circle with a different color. Here, we add that center circle. // If the checkbox is disabled and selected, it has a border but also an inner
242
+ const size = 16; // circle with a different color. Here, we add that center circle. // If the checkbox is disabled and selected, it has a border but also an inner
243
243
 
244
244
  const disabledChecked = {
245
245
  position: "absolute",
246
- top: size$1 / 4,
247
- left: size$1 / 4,
248
- height: size$1 / 2,
249
- width: size$1 / 2,
246
+ top: size / 4,
247
+ left: size / 4,
248
+ height: size / 2,
249
+ width: size / 2,
250
250
  borderRadius: "50%",
251
- backgroundColor: offBlack32$1
251
+ backgroundColor: offBlack32
252
252
  };
253
- const sharedStyles$1 = StyleSheet.create({
253
+ const sharedStyles = StyleSheet.create({
254
254
  // Reset the default styled input element
255
255
  inputReset: {
256
256
  appearance: "none",
@@ -258,10 +258,10 @@ const sharedStyles$1 = StyleSheet.create({
258
258
  MozAppearance: "none"
259
259
  },
260
260
  default: {
261
- height: size$1,
262
- width: size$1,
263
- minHeight: size$1,
264
- minWidth: size$1,
261
+ height: size,
262
+ width: size,
263
+ minHeight: size,
264
+ minWidth: size,
265
265
  margin: 0,
266
266
  outline: "none",
267
267
  boxSizing: "border-box",
@@ -271,76 +271,76 @@ const sharedStyles$1 = StyleSheet.create({
271
271
  },
272
272
  disabled: {
273
273
  cursor: "auto",
274
- backgroundColor: offWhite$1,
275
- borderColor: offBlack16$1,
274
+ backgroundColor: offWhite,
275
+ borderColor: offBlack16,
276
276
  borderWidth: 1
277
277
  }
278
278
  });
279
- const fadedBlue$1 = mix(fade(blue$1, 0.16), white$1);
280
- const activeBlue$1 = mix(offBlack32$1, blue$1);
281
- const fadedRed$1 = mix(fade(red$1, 0.08), white$1);
282
- const activeRed$1 = mix(offBlack32$1, red$1);
283
- const colors$1 = {
279
+ const fadedBlue = mix(fade(blue, 0.16), white);
280
+ const activeBlue = mix(offBlack32, blue);
281
+ const fadedRed = mix(fade(red, 0.08), white);
282
+ const activeRed = mix(offBlack32, red);
283
+ const colors = {
284
284
  default: {
285
- faded: fadedBlue$1,
286
- base: blue$1,
287
- active: activeBlue$1
285
+ faded: fadedBlue,
286
+ base: blue,
287
+ active: activeBlue
288
288
  },
289
289
  error: {
290
- faded: fadedRed$1,
291
- base: red$1,
292
- active: activeRed$1
290
+ faded: fadedRed,
291
+ base: red,
292
+ active: activeRed
293
293
  }
294
294
  };
295
- const styles$1 = {};
295
+ const styles$4 = {};
296
296
 
297
- const _generateStyles$1 = (checked, error) => {
297
+ const _generateStyles = (checked, error) => {
298
298
  // "hash" the parameters
299
299
  const styleKey = `${String(checked)}-${String(error)}`;
300
300
 
301
- if (styles$1[styleKey]) {
302
- return styles$1[styleKey];
301
+ if (styles$4[styleKey]) {
302
+ return styles$4[styleKey];
303
303
  }
304
304
 
305
- const palette = error ? colors$1.error : colors$1.default;
305
+ const palette = error ? colors.error : colors.default;
306
306
  let newStyles = {};
307
307
 
308
308
  if (checked) {
309
309
  newStyles = {
310
310
  default: {
311
- backgroundColor: white$1,
311
+ backgroundColor: white,
312
312
  borderColor: palette.base,
313
- borderWidth: size$1 / 4
313
+ borderWidth: size / 4
314
314
  },
315
315
  focus: {
316
- boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.base}`
316
+ boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
317
317
  },
318
318
  active: {
319
- boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.active}`,
319
+ boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.active}`,
320
320
  borderColor: palette.active
321
321
  }
322
322
  };
323
323
  } else {
324
324
  newStyles = {
325
325
  default: {
326
- backgroundColor: error ? fadedRed$1 : white$1,
327
- borderColor: error ? red$1 : offBlack50$1
326
+ backgroundColor: error ? fadedRed : white,
327
+ borderColor: error ? red : offBlack50
328
328
  },
329
329
  focus: {
330
- backgroundColor: error ? fadedRed$1 : white$1,
330
+ backgroundColor: error ? fadedRed : white,
331
331
  borderColor: palette.base,
332
332
  borderWidth: 2
333
333
  },
334
334
  active: {
335
335
  backgroundColor: palette.faded,
336
- borderColor: error ? activeRed$1 : blue$1,
336
+ borderColor: error ? activeRed : blue,
337
337
  borderWidth: 2
338
338
  }
339
339
  };
340
340
  }
341
341
 
342
- styles$1[styleKey] = StyleSheet.create(newStyles);
343
- return styles$1[styleKey];
342
+ styles$4[styleKey] = StyleSheet.create(newStyles);
343
+ return styles$4[styleKey];
344
344
  };
345
345
 
346
346
  const _excluded$2 = ["label", "description", "onChange", "style", "className", "variant"];
@@ -353,7 +353,7 @@ const _excluded$2 = ["label", "description", "onChange", "style", "className", "
353
353
  * example, we can make onChange a required prop on Checkbox but not on Choice
354
354
  * (because for Choice, that prop would be auto-populated by CheckboxGroup).
355
355
  */
356
- class ChoiceInternal extends Component {
356
+ class ChoiceInternal extends React.Component {
357
357
  constructor(...args) {
358
358
  super(...args);
359
359
 
@@ -392,9 +392,9 @@ class ChoiceInternal extends Component {
392
392
  id,
393
393
  label
394
394
  } = this.props;
395
- return /*#__PURE__*/createElement(LabelMedium, {
396
- style: [styles$2.label, disabled && styles$2.disabledLabel]
397
- }, /*#__PURE__*/createElement("label", {
395
+ return /*#__PURE__*/React.createElement(LabelMedium, {
396
+ style: [styles$3.label, disabled && styles$3.disabledLabel]
397
+ }, /*#__PURE__*/React.createElement("label", {
398
398
  htmlFor: id,
399
399
  onClick: this.handleLabelClick
400
400
  }, label));
@@ -404,8 +404,8 @@ class ChoiceInternal extends Component {
404
404
  const {
405
405
  description
406
406
  } = this.props;
407
- return /*#__PURE__*/createElement(LabelSmall, {
408
- style: styles$2.description,
407
+ return /*#__PURE__*/React.createElement(LabelSmall, {
408
+ style: styles$3.description,
409
409
  id: id
410
410
  }, description);
411
411
  }
@@ -423,29 +423,29 @@ class ChoiceInternal extends Component {
423
423
 
424
424
  const ChoiceCore = this.getChoiceCoreComponent();
425
425
  const ClickableBehavior = getClickableBehavior();
426
- return /*#__PURE__*/createElement(UniqueIDProvider, {
426
+ return /*#__PURE__*/React.createElement(UniqueIDProvider, {
427
427
  mockOnFirstRender: true,
428
428
  scope: "choice"
429
429
  }, ids => {
430
430
  const descriptionId = description && ids.get("description");
431
- return /*#__PURE__*/createElement(View, {
431
+ return /*#__PURE__*/React.createElement(View, {
432
432
  style: style,
433
433
  className: className
434
- }, /*#__PURE__*/createElement(ClickableBehavior, {
434
+ }, /*#__PURE__*/React.createElement(ClickableBehavior, {
435
435
  disabled: coreProps.disabled,
436
436
  onClick: this.handleClick,
437
437
  role: variant
438
438
  }, (state, childrenProps) => {
439
- return /*#__PURE__*/createElement(View, _extends({
440
- style: styles$2.wrapper
439
+ return /*#__PURE__*/React.createElement(View, _extends({
440
+ style: styles$3.wrapper
441
441
  }, childrenProps, {
442
442
  // We are resetting the tabIndex=0 from handlers
443
443
  // because the ChoiceCore component will receive
444
444
  // focus on basis of it being an input element.
445
445
  tabIndex: -1
446
- }), /*#__PURE__*/createElement(ChoiceCore, _extends({}, coreProps, state, {
446
+ }), /*#__PURE__*/React.createElement(ChoiceCore, _extends({}, coreProps, state, {
447
447
  "aria-describedby": descriptionId
448
- })), /*#__PURE__*/createElement(Strut, {
448
+ })), /*#__PURE__*/React.createElement(Strut, {
449
449
  size: Spacing.xSmall_8
450
450
  }), label && this.getLabel());
451
451
  }), description && this.getDescription(descriptionId));
@@ -458,7 +458,7 @@ ChoiceInternal.defaultProps = {
458
458
  disabled: false,
459
459
  error: false
460
460
  };
461
- const styles$2 = StyleSheet.create({
461
+ const styles$3 = StyleSheet.create({
462
462
  wrapper: {
463
463
  flexDirection: "row",
464
464
  alignItems: "flex-start",
@@ -490,9 +490,9 @@ const styles$2 = StyleSheet.create({
490
490
  * If you want a whole group of Checkbox[es] that are related, see the Choice
491
491
  * and CheckboxGroup components.
492
492
  */
493
- class Checkbox extends Component {
493
+ class Checkbox extends React.Component {
494
494
  render() {
495
- return /*#__PURE__*/createElement(ChoiceInternal, _extends({
495
+ return /*#__PURE__*/React.createElement(ChoiceInternal, _extends({
496
496
  variant: "checkbox"
497
497
  }, this.props));
498
498
  }
@@ -510,9 +510,9 @@ Checkbox.defaultProps = {
510
510
  * This component should not really be used by itself because radio buttons are
511
511
  * often grouped together. See RadioGroup.
512
512
  */
513
- class Radio extends Component {
513
+ class Radio extends React.Component {
514
514
  render() {
515
- return /*#__PURE__*/createElement(ChoiceInternal, _extends({
515
+ return /*#__PURE__*/React.createElement(ChoiceInternal, _extends({
516
516
  variant: "radio"
517
517
  }, this.props));
518
518
  }
@@ -523,7 +523,7 @@ Radio.defaultProps = {
523
523
  error: false
524
524
  };
525
525
 
526
- const _excluded$3 = ["value", "variant"];
526
+ const _excluded$1 = ["value", "variant"];
527
527
 
528
528
  /**
529
529
  * This is a labeled 🔘 or ☑️ item. Choice is meant to be used as children of
@@ -534,7 +534,7 @@ const _excluded$3 = ["value", "variant"];
534
534
  * If you wish to use just a single field, use Checkbox or Radio with the
535
535
  * optional label and description props.
536
536
  */
537
- class Choice extends Component {
537
+ class Choice extends React.Component {
538
538
  getChoiceComponent(variant) {
539
539
  if (variant === "checkbox") {
540
540
  return Checkbox;
@@ -550,10 +550,10 @@ class Choice extends Component {
550
550
  {
551
551
  variant
552
552
  } = _this$props,
553
- remainingProps = _objectWithoutPropertiesLoose(_this$props, _excluded$3);
553
+ remainingProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
554
554
 
555
555
  const ChoiceComponent = this.getChoiceComponent(variant);
556
- return /*#__PURE__*/createElement(ChoiceComponent, remainingProps);
556
+ return /*#__PURE__*/React.createElement(ChoiceComponent, remainingProps);
557
557
  }
558
558
 
559
559
  }
@@ -563,7 +563,7 @@ Choice.defaultProps = {
563
563
  onChange: () => {}
564
564
  };
565
565
 
566
- const styles$3 = StyleSheet.create({
566
+ const styles$2 = StyleSheet.create({
567
567
  fieldset: {
568
568
  border: "none",
569
569
  padding: 0,
@@ -585,8 +585,8 @@ const styles$3 = StyleSheet.create({
585
585
  }
586
586
  });
587
587
 
588
- const StyledFieldset = addStyle("fieldset");
589
- const StyledLegend = addStyle("legend");
588
+ const StyledFieldset$1 = addStyle("fieldset");
589
+ const StyledLegend$1 = addStyle("legend");
590
590
  /**
591
591
  * A checkbox group allows multiple selection. This component auto-populates
592
592
  * many props for its children Choice components. The Choice component is
@@ -594,7 +594,7 @@ const StyledLegend = addStyle("legend");
594
594
  * disabled.
595
595
  */
596
596
 
597
- class CheckboxGroup extends Component {
597
+ class CheckboxGroup extends React.Component {
598
598
  handleChange(changedValue, originalCheckedState) {
599
599
  const {
600
600
  onChange,
@@ -621,33 +621,33 @@ class CheckboxGroup extends Component {
621
621
  style,
622
622
  testId
623
623
  } = this.props;
624
- return /*#__PURE__*/createElement(StyledFieldset, {
624
+ return /*#__PURE__*/React.createElement(StyledFieldset$1, {
625
625
  "data-test-id": testId,
626
- style: styles$3.fieldset
627
- }, /*#__PURE__*/createElement(View, {
626
+ style: styles$2.fieldset
627
+ }, /*#__PURE__*/React.createElement(View, {
628
628
  style: style
629
- }, typeof label === "string" ? /*#__PURE__*/createElement(StyledLegend, {
630
- style: styles$3.legend
631
- }, /*#__PURE__*/createElement(LabelMedium, null, label)) : label && label, typeof description === "string" ? /*#__PURE__*/createElement(LabelSmall, {
632
- style: styles$3.description
633
- }, description) : description && description, errorMessage && /*#__PURE__*/createElement(LabelSmall, {
634
- style: styles$3.error
635
- }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/createElement(Strut, {
629
+ }, typeof label === "string" ? /*#__PURE__*/React.createElement(StyledLegend$1, {
630
+ style: styles$2.legend
631
+ }, /*#__PURE__*/React.createElement(LabelMedium, null, label)) : label && label, typeof description === "string" ? /*#__PURE__*/React.createElement(LabelSmall, {
632
+ style: styles$2.description
633
+ }, description) : description && description, errorMessage && /*#__PURE__*/React.createElement(LabelSmall, {
634
+ style: styles$2.error
635
+ }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/React.createElement(Strut, {
636
636
  size: Spacing.small_12
637
- }), Children.map(children, (child, index) => {
637
+ }), React.Children.map(children, (child, index) => {
638
638
  const {
639
639
  style,
640
640
  value
641
641
  } = child.props;
642
642
  const checked = selectedValues.includes(value);
643
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/cloneElement(child, {
643
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(child, {
644
644
  checked: checked,
645
645
  error: !!errorMessage,
646
646
  groupName: groupName,
647
647
  id: `${groupName}-${value}`,
648
648
  key: value,
649
649
  onChange: () => this.handleChange(value, checked),
650
- style: [index > 0 && styles$3.defaultLineGap, style],
650
+ style: [index > 0 && styles$2.defaultLineGap, style],
651
651
  variant: "checkbox"
652
652
  }));
653
653
  })));
@@ -655,8 +655,8 @@ class CheckboxGroup extends Component {
655
655
 
656
656
  }
657
657
 
658
- const StyledFieldset$1 = addStyle("fieldset");
659
- const StyledLegend$1 = addStyle("legend");
658
+ const StyledFieldset = addStyle("fieldset");
659
+ const StyledLegend = addStyle("legend");
660
660
  /**
661
661
  * A radio group allows only single selection. Like CheckboxGroup, this
662
662
  * component auto-populates many props for its children Choice components. The
@@ -666,7 +666,7 @@ const StyledLegend$1 = addStyle("legend");
666
666
  * accessibility.
667
667
  */
668
668
 
669
- class RadioGroup extends Component {
669
+ class RadioGroup extends React.Component {
670
670
  handleChange(changedValue) {
671
671
  this.props.onChange(changedValue);
672
672
  }
@@ -682,33 +682,33 @@ class RadioGroup extends Component {
682
682
  style,
683
683
  testId
684
684
  } = this.props;
685
- return /*#__PURE__*/createElement(StyledFieldset$1, {
685
+ return /*#__PURE__*/React.createElement(StyledFieldset, {
686
686
  "data-test-id": testId,
687
- style: styles$3.fieldset
688
- }, /*#__PURE__*/createElement(View, {
687
+ style: styles$2.fieldset
688
+ }, /*#__PURE__*/React.createElement(View, {
689
689
  style: style
690
- }, label && /*#__PURE__*/createElement(StyledLegend$1, {
691
- style: styles$3.legend
692
- }, /*#__PURE__*/createElement(LabelMedium, null, label)), description && /*#__PURE__*/createElement(LabelSmall, {
693
- style: styles$3.description
694
- }, description), errorMessage && /*#__PURE__*/createElement(LabelSmall, {
695
- style: styles$3.error
696
- }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/createElement(Strut, {
690
+ }, label && /*#__PURE__*/React.createElement(StyledLegend, {
691
+ style: styles$2.legend
692
+ }, /*#__PURE__*/React.createElement(LabelMedium, null, label)), description && /*#__PURE__*/React.createElement(LabelSmall, {
693
+ style: styles$2.description
694
+ }, description), errorMessage && /*#__PURE__*/React.createElement(LabelSmall, {
695
+ style: styles$2.error
696
+ }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/React.createElement(Strut, {
697
697
  size: Spacing.small_12
698
- }), Children.map(children, (child, index) => {
698
+ }), React.Children.map(children, (child, index) => {
699
699
  const {
700
700
  style,
701
701
  value
702
702
  } = child.props;
703
703
  const checked = selectedValue === value;
704
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/cloneElement(child, {
704
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(child, {
705
705
  checked: checked,
706
706
  error: !!errorMessage,
707
707
  groupName: groupName,
708
708
  id: `${groupName}-${value}`,
709
709
  key: value,
710
710
  onChange: () => this.handleChange(value),
711
- style: [index > 0 && styles$3.defaultLineGap, style],
711
+ style: [index > 0 && styles$2.defaultLineGap, style],
712
712
  variant: "radio"
713
713
  }));
714
714
  })));
@@ -716,14 +716,14 @@ class RadioGroup extends Component {
716
716
 
717
717
  }
718
718
 
719
- const _excluded$4 = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "required", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange"];
719
+ const _excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "required", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange"];
720
720
 
721
721
  // TODO(WB-1081): Change class name back to TextField after Styleguidist is gone.
722
722
 
723
723
  /**
724
724
  * A TextField is an element used to accept a single line of text from the user.
725
725
  */
726
- class TextFieldInternal extends Component {
726
+ class TextFieldInternal extends React.Component {
727
727
  constructor(props) {
728
728
  super(props);
729
729
  this.state = {
@@ -811,11 +811,11 @@ class TextFieldInternal extends Component {
811
811
  autoComplete,
812
812
  forwardedRef
813
813
  } = _this$props,
814
- otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
814
+ otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
815
815
 
816
- return /*#__PURE__*/createElement("input", _extends({
817
- className: css([styles$4.input, styles$6.LabelMedium, styles$4.default, // Prioritizes disabled, then focused, then error (if any)
818
- disabled ? styles$4.disabled : this.state.focused ? [styles$4.focused, light && styles$4.defaultLight] : this.state.error && [styles$4.error, light && styles$4.errorLight], style && style]),
816
+ return /*#__PURE__*/React.createElement("input", _extends({
817
+ className: css([styles$1.input, styles$6.LabelMedium, styles$1.default, // Prioritizes disabled, then focused, then error (if any)
818
+ disabled ? styles$1.disabled : this.state.focused ? [styles$1.focused, light && styles$1.defaultLight] : this.state.error && [styles$1.error, light && styles$1.errorLight], style && style]),
819
819
  id: id,
820
820
  type: type,
821
821
  placeholder: placeholder,
@@ -840,7 +840,7 @@ TextFieldInternal.defaultProps = {
840
840
  disabled: false,
841
841
  light: false
842
842
  };
843
- const styles$4 = StyleSheet.create({
843
+ const styles$1 = StyleSheet.create({
844
844
  input: {
845
845
  width: "100%",
846
846
  height: 40,
@@ -890,7 +890,7 @@ const styles$4 = StyleSheet.create({
890
890
  boxShadow: `0px 0px 0px 1px ${Color.red}, 0px 0px 0px 2px ${Color.white}`
891
891
  }
892
892
  });
893
- const TextField = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/createElement(TextFieldInternal, _extends({}, props, {
893
+ const TextField = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(TextFieldInternal, _extends({}, props, {
894
894
  forwardedRef: ref
895
895
  })));
896
896
 
@@ -898,19 +898,19 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/createEle
898
898
  * A FieldHeading is an element that provides a label, description, and error element
899
899
  * to present better context and hints to any type of form field component.
900
900
  */
901
- class FieldHeading extends Component {
901
+ class FieldHeading extends React.Component {
902
902
  renderLabel() {
903
903
  const {
904
904
  label,
905
905
  id,
906
906
  testId
907
907
  } = this.props;
908
- return /*#__PURE__*/createElement(Fragment, null, typeof label === "string" ? /*#__PURE__*/createElement(LabelMedium, {
909
- style: styles$5.label,
908
+ return /*#__PURE__*/React.createElement(React.Fragment, null, typeof label === "string" ? /*#__PURE__*/React.createElement(LabelMedium, {
909
+ style: styles.label,
910
910
  tag: "label",
911
911
  htmlFor: id && `${id}-field`,
912
912
  testId: testId && `${testId}-label`
913
- }, label) : label, /*#__PURE__*/createElement(Strut, {
913
+ }, label) : label, /*#__PURE__*/React.createElement(Strut, {
914
914
  size: Spacing.xxxSmall_4
915
915
  }));
916
916
  }
@@ -925,10 +925,10 @@ class FieldHeading extends Component {
925
925
  return null;
926
926
  }
927
927
 
928
- return /*#__PURE__*/createElement(Fragment, null, typeof description === "string" ? /*#__PURE__*/createElement(LabelSmall, {
929
- style: styles$5.description,
928
+ return /*#__PURE__*/React.createElement(React.Fragment, null, typeof description === "string" ? /*#__PURE__*/React.createElement(LabelSmall, {
929
+ style: styles.description,
930
930
  testId: testId && `${testId}-description`
931
- }, description) : description, /*#__PURE__*/createElement(Strut, {
931
+ }, description) : description, /*#__PURE__*/React.createElement(Strut, {
932
932
  size: Spacing.xxxSmall_4
933
933
  }));
934
934
  }
@@ -944,10 +944,10 @@ class FieldHeading extends Component {
944
944
  return null;
945
945
  }
946
946
 
947
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Strut, {
947
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Strut, {
948
948
  size: Spacing.small_12
949
- }), typeof error === "string" ? /*#__PURE__*/createElement(LabelSmall, {
950
- style: styles$5.error,
949
+ }), typeof error === "string" ? /*#__PURE__*/React.createElement(LabelSmall, {
950
+ style: styles.error,
951
951
  role: "alert",
952
952
  id: id && `${id}-error`,
953
953
  testId: testId && `${testId}-error`
@@ -959,15 +959,15 @@ class FieldHeading extends Component {
959
959
  field,
960
960
  style
961
961
  } = this.props;
962
- return /*#__PURE__*/createElement(View, {
962
+ return /*#__PURE__*/React.createElement(View, {
963
963
  style: style
964
- }, this.renderLabel(), this.maybeRenderDescription(), /*#__PURE__*/createElement(Strut, {
964
+ }, this.renderLabel(), this.maybeRenderDescription(), /*#__PURE__*/React.createElement(Strut, {
965
965
  size: Spacing.xSmall_8
966
966
  }), field, this.maybeRenderError());
967
967
  }
968
968
 
969
969
  }
970
- const styles$5 = StyleSheet.create({
970
+ const styles = StyleSheet.create({
971
971
  label: {
972
972
  color: Color.offBlack
973
973
  },
@@ -985,7 +985,7 @@ const styles$5 = StyleSheet.create({
985
985
  * A LabeledTextField is an element used to accept a single line of text
986
986
  * from the user paired with a label, description, and error field elements.
987
987
  */
988
- class LabeledTextFieldInternal extends Component {
988
+ class LabeledTextFieldInternal extends React.Component {
989
989
  constructor(props) {
990
990
  super(props);
991
991
 
@@ -1054,14 +1054,14 @@ class LabeledTextFieldInternal extends Component {
1054
1054
  forwardedRef,
1055
1055
  ariaDescribedby
1056
1056
  } = this.props;
1057
- return /*#__PURE__*/createElement(IDProvider, {
1057
+ return /*#__PURE__*/React.createElement(IDProvider, {
1058
1058
  id: id,
1059
1059
  scope: "labeled-text-field"
1060
- }, uniqueId => /*#__PURE__*/createElement(FieldHeading, {
1060
+ }, uniqueId => /*#__PURE__*/React.createElement(FieldHeading, {
1061
1061
  id: uniqueId,
1062
1062
  testId: testId,
1063
1063
  style: style,
1064
- field: /*#__PURE__*/createElement(TextField, {
1064
+ field: /*#__PURE__*/React.createElement(TextField, {
1065
1065
  id: `${uniqueId}-field`,
1066
1066
  "aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
1067
1067
  "aria-invalid": this.state.error ? "true" : "false",
@@ -1094,7 +1094,7 @@ LabeledTextFieldInternal.defaultProps = {
1094
1094
  disabled: false,
1095
1095
  light: false
1096
1096
  };
1097
- const LabeledTextField = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/createElement(LabeledTextFieldInternal, _extends({}, props, {
1097
+ const LabeledTextField = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(LabeledTextFieldInternal, _extends({}, props, {
1098
1098
  forwardedRef: ref
1099
1099
  })));
1100
1100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-form",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "design": "v1",
5
5
  "description": "Form components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.16.3",
19
- "@khanacademy/wonder-blocks-clickable": "^2.2.1",
19
+ "@khanacademy/wonder-blocks-clickable": "^2.2.2",
20
20
  "@khanacademy/wonder-blocks-color": "^1.1.20",
21
21
  "@khanacademy/wonder-blocks-core": "^4.0.0",
22
22
  "@khanacademy/wonder-blocks-icon": "^1.2.24",
@@ -30,6 +30,5 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "wb-dev-build-settings": "^0.2.0"
33
- },
34
- "gitHead": "9ebea88533e702011165072f090a377e02fa3f0f"
33
+ }
35
34
  }
@@ -1,6 +1,7 @@
1
1
  //@flow
2
2
  import * as React from "react";
3
3
  import {mount} from "enzyme";
4
+ import "jest-enzyme";
4
5
 
5
6
  import CheckboxGroup from "../checkbox-group.js";
6
7
  import Choice from "../choice.js";
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
  import * as React from "react";
3
3
  import {mount} from "enzyme";
4
+ import "jest-enzyme";
4
5
  import {StyleSheet} from "aphrodite";
5
6
 
6
7
  import FieldHeading from "../field-heading.js";
@@ -1,6 +1,7 @@
1
1
  //@flow
2
2
  import * as React from "react";
3
3
  import {mount} from "enzyme";
4
+ import "jest-enzyme";
4
5
  import {render, screen} from "@testing-library/react";
5
6
 
6
7
  import {StyleSheet} from "aphrodite";
@@ -1,6 +1,7 @@
1
1
  //@flow
2
2
  import * as React from "react";
3
3
  import {mount} from "enzyme";
4
+ import "jest-enzyme";
4
5
 
5
6
  import RadioGroup from "../radio-group.js";
6
7
  import Choice from "../choice.js";
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
  import * as React from "react";
3
3
  import {mount} from "enzyme";
4
+ import "jest-enzyme";
4
5
 
5
6
  import TextField from "../text-field.js";
6
7
 
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Khan Academy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.