@khanacademy/wonder-blocks-form 2.2.1 → 2.2.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.
Files changed (2) hide show
  1. package/dist/index.js +905 -803
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 11);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 21);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ([
@@ -119,33 +119,44 @@ module.exports = require("@khanacademy/wonder-blocks-typography");
119
119
  /* 5 */
120
120
  /***/ (function(module, exports) {
121
121
 
122
- function _extends() {
123
- module.exports = _extends = Object.assign || function (target) {
124
- for (var i = 1; i < arguments.length; i++) {
125
- var source = arguments[i];
126
-
127
- for (var key in source) {
128
- if (Object.prototype.hasOwnProperty.call(source, key)) {
129
- target[key] = source[key];
130
- }
131
- }
132
- }
122
+ module.exports = require("aphrodite");
133
123
 
134
- return target;
135
- };
124
+ /***/ }),
125
+ /* 6 */
126
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
136
127
 
137
- module.exports["default"] = module.exports, module.exports.__esModule = true;
138
- return _extends.apply(this, arguments);
139
- }
128
+ "use strict";
129
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
130
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_0__);
131
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
132
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1__);
133
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
134
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2__);
140
135
 
141
- module.exports = _extends;
142
- module.exports["default"] = module.exports, module.exports.__esModule = true;
143
136
 
144
- /***/ }),
145
- /* 6 */
146
- /***/ (function(module, exports) {
147
137
 
148
- module.exports = require("aphrodite");
138
+ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_0__["StyleSheet"].create({
139
+ fieldset: {
140
+ border: "none",
141
+ padding: 0,
142
+ margin: 0
143
+ },
144
+ legend: {
145
+ padding: 0
146
+ },
147
+ description: {
148
+ marginTop: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xxxSmall_4,
149
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1___default.a.offBlack64
150
+ },
151
+ error: {
152
+ marginTop: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xxxSmall_4,
153
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_1___default.a.red
154
+ },
155
+ defaultLineGap: {
156
+ marginTop: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_2___default.a.xSmall_8
157
+ }
158
+ });
159
+ /* harmony default export */ __webpack_exports__["a"] = (styles);
149
160
 
150
161
  /***/ }),
151
162
  /* 7 */
@@ -155,443 +166,308 @@ module.exports = require("@khanacademy/wonder-blocks-layout");
155
166
 
156
167
  /***/ }),
157
168
  /* 8 */
158
- /***/ (function(module, exports) {
169
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
170
+
171
+ "use strict";
172
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Checkbox; });
173
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
174
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
175
+ /* harmony import */ var _choice_internal_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
176
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
177
+
159
178
 
160
- function _objectWithoutPropertiesLoose(source, excluded) {
161
- if (source == null) return {};
162
- var target = {};
163
- var sourceKeys = Object.keys(source);
164
- var key, i;
179
+ // Keep synced with ChoiceComponentProps in ../util/types.js
165
180
 
166
- for (i = 0; i < sourceKeys.length; i++) {
167
- key = sourceKeys[i];
168
- if (excluded.indexOf(key) >= 0) continue;
169
- target[key] = source[key];
181
+ /**
182
+ * ☑️ A nicely styled checkbox for all your checking needs. Can optionally take
183
+ * label and description props.
184
+ *
185
+ * If you want a whole group of Checkbox[es] that are related, see the Choice
186
+ * and CheckboxGroup components.
187
+ */
188
+ class Checkbox extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
189
+ render() {
190
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_choice_internal_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"], _extends({
191
+ variant: "checkbox"
192
+ }, this.props));
170
193
  }
171
194
 
172
- return target;
173
195
  }
174
-
175
- module.exports = _objectWithoutPropertiesLoose;
176
- module.exports["default"] = module.exports, module.exports.__esModule = true;
196
+ Checkbox.defaultProps = {
197
+ disabled: false,
198
+ error: false
199
+ };
177
200
 
178
201
  /***/ }),
179
202
  /* 9 */
180
- /***/ (function(module, exports) {
181
-
182
- module.exports = require("@khanacademy/wonder-blocks-clickable");
183
-
184
- /***/ }),
185
- /* 10 */
186
- /***/ (function(module, exports) {
187
-
188
- module.exports = require("@khanacademy/wonder-blocks-icon");
189
-
190
- /***/ }),
191
- /* 11 */
192
203
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
193
204
 
194
205
  "use strict";
195
- // ESM COMPAT FLAG
196
- __webpack_require__.r(__webpack_exports__);
206
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Radio; });
207
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
208
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
209
+ /* harmony import */ var _choice_internal_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
210
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
197
211
 
198
- // EXPORTS
199
- __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return /* reexport */ checkbox_Checkbox; });
200
- __webpack_require__.d(__webpack_exports__, "Radio", function() { return /* reexport */ radio_Radio; });
201
- __webpack_require__.d(__webpack_exports__, "Choice", function() { return /* reexport */ choice_Choice; });
202
- __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return /* reexport */ checkbox_group_CheckboxGroup; });
203
- __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return /* reexport */ radio_group_RadioGroup; });
204
- __webpack_require__.d(__webpack_exports__, "TextField", function() { return /* reexport */ text_field; });
205
- __webpack_require__.d(__webpack_exports__, "LabeledTextField", function() { return /* reexport */ labeled_text_field; });
206
212
 
207
- // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/extends.js
208
- var helpers_extends = __webpack_require__(5);
209
- var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
210
-
211
- // EXTERNAL MODULE: external "react"
212
- var external_react_ = __webpack_require__(0);
213
+ // Keep synced with ChoiceComponentProps in ../util/types.js
213
214
 
214
- // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js
215
- var objectWithoutPropertiesLoose = __webpack_require__(8);
216
- var objectWithoutPropertiesLoose_default = /*#__PURE__*/__webpack_require__.n(objectWithoutPropertiesLoose);
215
+ /**
216
+ * 🔘 A nicely styled radio button for all your non-AMFM radio button needs. Can
217
+ * optionally take label and description props.
218
+ *
219
+ * This component should not really be used by itself because radio buttons are
220
+ * often grouped together. See RadioGroup.
221
+ */
222
+ class Radio extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
223
+ render() {
224
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_choice_internal_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"], _extends({
225
+ variant: "radio"
226
+ }, this.props));
227
+ }
217
228
 
218
- // EXTERNAL MODULE: external "aphrodite"
219
- var external_aphrodite_ = __webpack_require__(6);
229
+ }
230
+ Radio.defaultProps = {
231
+ disabled: false,
232
+ error: false
233
+ };
220
234
 
221
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-color"
222
- var wonder_blocks_color_ = __webpack_require__(1);
223
- var wonder_blocks_color_default = /*#__PURE__*/__webpack_require__.n(wonder_blocks_color_);
235
+ /***/ }),
236
+ /* 10 */
237
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
224
238
 
225
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-core"
226
- var wonder_blocks_core_ = __webpack_require__(2);
239
+ "use strict";
240
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
241
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
242
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
243
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
244
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
245
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
246
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
247
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__);
248
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4);
249
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
250
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
227
251
 
228
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-clickable"
229
- var wonder_blocks_clickable_ = __webpack_require__(9);
230
252
 
231
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-layout"
232
- var wonder_blocks_layout_ = __webpack_require__(7);
233
253
 
234
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-spacing"
235
- var wonder_blocks_spacing_ = __webpack_require__(3);
236
- var wonder_blocks_spacing_default = /*#__PURE__*/__webpack_require__.n(wonder_blocks_spacing_);
237
254
 
238
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-typography"
239
- var wonder_blocks_typography_ = __webpack_require__(4);
240
255
 
241
- // EXTERNAL MODULE: external "@khanacademy/wonder-blocks-icon"
242
- var wonder_blocks_icon_ = __webpack_require__(10);
243
- var wonder_blocks_icon_default = /*#__PURE__*/__webpack_require__.n(wonder_blocks_icon_);
244
256
 
245
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/checkbox-core.js
246
257
 
258
+ // TODO(WB-1081): Change class name back to TextField after Styleguidist is gone.
247
259
 
248
- const _excluded = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
260
+ /**
261
+ * A TextField is an element used to accept a single line of text from the user.
262
+ */
263
+ class TextFieldInternal extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
264
+ constructor(props) {
265
+ super(props);
266
+ this.state = {
267
+ error: null,
268
+ focused: false
269
+ };
249
270
 
271
+ this.maybeValidate = newValue => {
272
+ const {
273
+ validate,
274
+ onValidate
275
+ } = this.props;
250
276
 
277
+ if (validate) {
278
+ const maybeError = validate(newValue) || null;
279
+ this.setState({
280
+ error: maybeError
281
+ }, () => {
282
+ if (onValidate) {
283
+ onValidate(maybeError);
284
+ }
285
+ });
286
+ }
287
+ };
251
288
 
289
+ this.handleChange = event => {
290
+ const {
291
+ onChange
292
+ } = this.props;
293
+ const newValue = event.target.value;
294
+ this.maybeValidate(newValue);
295
+ onChange(newValue);
296
+ };
252
297
 
298
+ this.handleFocus = event => {
299
+ const {
300
+ onFocus
301
+ } = this.props;
302
+ this.setState({
303
+ focused: true
304
+ }, () => {
305
+ if (onFocus) {
306
+ onFocus(event);
307
+ }
308
+ });
309
+ };
253
310
 
254
- const {
255
- blue,
256
- red,
257
- white,
258
- offWhite,
259
- offBlack16,
260
- offBlack32,
261
- offBlack50
262
- } = wonder_blocks_color_default.a;
263
- const StyledInput = Object(wonder_blocks_core_["addStyle"])("input");
264
- const checkboxCheck = {
265
- 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"
266
- };
267
- /**
268
- * The internal stateless ☑️ Checkbox
269
- */
311
+ this.handleBlur = event => {
312
+ const {
313
+ onBlur
314
+ } = this.props;
315
+ this.setState({
316
+ focused: false
317
+ }, () => {
318
+ if (onBlur) {
319
+ onBlur(event);
320
+ }
321
+ });
322
+ };
270
323
 
271
- class checkbox_core_CheckboxCore extends external_react_["Component"] {
272
- constructor(...args) {
273
- super(...args);
324
+ if (props.validate) {
325
+ // Ensures error is updated on unmounted server-side renders
326
+ this.state.error = props.validate(props.value) || null;
327
+ }
328
+ }
274
329
 
275
- this.handleChange = () => {
276
- // Empty because change is handled by ClickableBehavior
277
- return;
278
- };
330
+ componentDidMount() {
331
+ this.maybeValidate(this.props.value);
279
332
  }
280
333
 
281
334
  render() {
282
- const _this$props = this.props,
283
- {
284
- checked,
285
- disabled,
286
- error,
287
- groupName,
335
+ const {
288
336
  id,
337
+ type,
338
+ value,
339
+ disabled,
340
+ onKeyDown,
341
+ placeholder,
342
+ required,
343
+ light,
344
+ style,
289
345
  testId,
290
- hovered,
291
- focused,
292
- pressed
293
- } = _this$props,
294
- sharedProps = objectWithoutPropertiesLoose_default()(_this$props, _excluded);
295
-
296
- const stateStyles = _generateStyles(checked, error);
346
+ readOnly,
347
+ autoComplete,
348
+ forwardedRef,
349
+ // The following props are being included here to avoid
350
+ // passing them down to the otherProps spread
351
+
352
+ /* eslint-disable no-unused-vars */
353
+ onFocus,
354
+ onBlur,
355
+ onValidate,
356
+ validate,
357
+ onChange,
297
358
 
298
- const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles.disabled];
299
- const props = {
300
- "data-test-id": testId
301
- };
302
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, /*#__PURE__*/external_react_["createElement"](StyledInput, extends_default()({}, sharedProps, {
303
- type: "checkbox",
304
- "aria-invalid": error,
305
- checked: checked,
306
- disabled: disabled,
359
+ /* eslint-enable no-unused-vars */
360
+ // Should only include Aria related props
361
+ ...otherProps
362
+ } = this.props;
363
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("input", _extends({
364
+ className: Object(aphrodite__WEBPACK_IMPORTED_MODULE_1__["css"])([styles.input, _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["styles"].LabelMedium, styles.default, // Prioritizes disabled, then focused, then error (if any)
365
+ disabled ? styles.disabled : this.state.focused ? [styles.focused, light && styles.defaultLight] : this.state.error && [styles.error, light && styles.errorLight], style && style]),
307
366
  id: id,
308
- name: groupName // Need to specify because this is a controlled React form
309
- // component, but we handle the click via ClickableBehavior
310
- ,
367
+ type: type,
368
+ placeholder: placeholder,
369
+ value: value,
370
+ disabled: disabled,
311
371
  onChange: this.handleChange,
312
- style: defaultStyle
313
- }, props)), checked && /*#__PURE__*/external_react_["createElement"](wonder_blocks_icon_default.a, {
314
- color: disabled ? offBlack32 : white,
315
- icon: checkboxCheck,
316
- size: "small",
317
- style: sharedStyles.checkIcon
318
- }));
372
+ onKeyDown: onKeyDown,
373
+ onFocus: this.handleFocus,
374
+ onBlur: this.handleBlur,
375
+ required: required,
376
+ "data-test-id": testId,
377
+ readOnly: readOnly,
378
+ autoComplete: autoComplete,
379
+ ref: forwardedRef
380
+ }, otherProps));
319
381
  }
320
382
 
321
383
  }
322
- const size = 16;
323
- const sharedStyles = external_aphrodite_["StyleSheet"].create({
324
- // Reset the default styled input element
325
- inputReset: {
326
- appearance: "none",
327
- WebkitAppearance: "none",
328
- MozAppearance: "none"
329
- },
330
- default: {
331
- height: size,
332
- width: size,
333
- minHeight: size,
334
- minWidth: size,
384
+
385
+ TextFieldInternal.defaultProps = {
386
+ type: "text",
387
+ disabled: false,
388
+ light: false
389
+ };
390
+ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
391
+ input: {
392
+ width: "100%",
393
+ height: 40,
394
+ borderRadius: 4,
395
+ boxSizing: "border-box",
396
+ paddingLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.medium_16,
335
397
  margin: 0,
336
398
  outline: "none",
337
- boxSizing: "border-box",
338
- borderStyle: "solid",
339
- borderWidth: 1,
340
- borderRadius: 3
399
+ boxShadow: "none"
341
400
  },
342
- disabled: {
343
- cursor: "auto",
344
- backgroundColor: offWhite,
345
- borderColor: offBlack16,
346
- borderWidth: 1
347
- },
348
- checkIcon: {
349
- position: "absolute",
350
- pointerEvents: "none"
351
- }
352
- });
353
- const fadedBlue = Object(wonder_blocks_color_["mix"])(Object(wonder_blocks_color_["fade"])(blue, 0.16), white);
354
- const activeBlue = Object(wonder_blocks_color_["mix"])(offBlack32, blue);
355
- const fadedRed = Object(wonder_blocks_color_["mix"])(Object(wonder_blocks_color_["fade"])(red, 0.08), white);
356
- const activeRed = Object(wonder_blocks_color_["mix"])(offBlack32, red);
357
- const colors = {
358
- default: {
359
- faded: fadedBlue,
360
- base: blue,
361
- active: activeBlue
401
+ default: {
402
+ background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white,
403
+ border: `1px solid ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack16}`,
404
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack,
405
+ "::placeholder": {
406
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64
407
+ }
362
408
  },
363
409
  error: {
364
- faded: fadedRed,
365
- base: red,
366
- active: activeRed
367
- }
368
- };
369
- const styles = {};
370
-
371
- const _generateStyles = (checked, error) => {
372
- // "hash" the parameters
373
- const styleKey = `${String(checked)}-${String(error)}`;
374
-
375
- if (styles[styleKey]) {
376
- return styles[styleKey];
377
- }
378
-
379
- const palette = error ? colors.error : colors.default;
380
- let newStyles = {};
381
-
382
- if (checked) {
383
- newStyles = {
384
- default: {
385
- backgroundColor: palette.base,
386
- borderWidth: 0
387
- },
388
- focus: {
389
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
390
- },
391
- active: {
392
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.active}`,
393
- background: palette.active
394
- }
395
- };
396
- } else {
397
- newStyles = {
398
- default: {
399
- backgroundColor: error ? fadedRed : white,
400
- borderColor: error ? red : offBlack50
401
- },
402
- focus: {
403
- backgroundColor: error ? fadedRed : white,
404
- borderColor: palette.base,
405
- borderWidth: 2
406
- },
407
- active: {
408
- backgroundColor: palette.faded,
409
- borderColor: error ? activeRed : blue,
410
- borderWidth: 2
411
- }
412
- };
413
- }
414
-
415
- styles[styleKey] = external_aphrodite_["StyleSheet"].create(newStyles);
416
- return styles[styleKey];
417
- };
418
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/radio-core.js
419
-
420
-
421
- const radio_core_excluded = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
422
-
423
-
424
-
425
-
426
- const {
427
- blue: radio_core_blue,
428
- red: radio_core_red,
429
- white: radio_core_white,
430
- offWhite: radio_core_offWhite,
431
- offBlack16: radio_core_offBlack16,
432
- offBlack32: radio_core_offBlack32,
433
- offBlack50: radio_core_offBlack50
434
- } = wonder_blocks_color_default.a;
435
- const radio_core_StyledInput = Object(wonder_blocks_core_["addStyle"])("input");
436
- /**
437
- * The internal stateless 🔘 Radio button
438
- */
439
-
440
- class radio_core_RadioCore extends external_react_["Component"] {
441
- constructor(...args) {
442
- super(...args);
443
-
444
- this.handleChange = () => {
445
- // Empty because change is handled by ClickableBehavior
446
- return;
447
- };
448
- }
449
-
450
- render() {
451
- const _this$props = this.props,
452
- {
453
- checked,
454
- disabled,
455
- error,
456
- groupName,
457
- id,
458
- testId,
459
- hovered,
460
- focused,
461
- pressed
462
- } = _this$props,
463
- sharedProps = objectWithoutPropertiesLoose_default()(_this$props, radio_core_excluded);
464
-
465
- const stateStyles = radio_core_generateStyles(checked, error);
466
-
467
- const defaultStyle = [radio_core_sharedStyles.inputReset, radio_core_sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && radio_core_sharedStyles.disabled];
468
- const props = {
469
- "data-test-id": testId
470
- };
471
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, /*#__PURE__*/external_react_["createElement"](radio_core_StyledInput, extends_default()({}, sharedProps, {
472
- type: "radio",
473
- "aria-invalid": error,
474
- checked: checked,
475
- disabled: disabled,
476
- id: id,
477
- name: groupName // Need to specify because this is a controlled React form
478
- // component, but we handle the click via ClickableBehavior
479
- ,
480
- onChange: this.handleChange,
481
- style: defaultStyle
482
- }, props)), disabled && checked && /*#__PURE__*/external_react_["createElement"]("span", {
483
- style: disabledChecked
484
- }));
485
- }
486
-
487
- }
488
- const radio_core_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
489
-
490
- const disabledChecked = {
491
- position: "absolute",
492
- top: radio_core_size / 4,
493
- left: radio_core_size / 4,
494
- height: radio_core_size / 2,
495
- width: radio_core_size / 2,
496
- borderRadius: "50%",
497
- backgroundColor: radio_core_offBlack32
498
- };
499
- const radio_core_sharedStyles = external_aphrodite_["StyleSheet"].create({
500
- // Reset the default styled input element
501
- inputReset: {
502
- appearance: "none",
503
- WebkitAppearance: "none",
504
- MozAppearance: "none"
505
- },
506
- default: {
507
- height: radio_core_size,
508
- width: radio_core_size,
509
- minHeight: radio_core_size,
510
- minWidth: radio_core_size,
511
- margin: 0,
512
- outline: "none",
513
- boxSizing: "border-box",
514
- borderStyle: "solid",
515
- borderWidth: 1,
516
- borderRadius: "50%"
410
+ background: `${Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["fade"])(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.red, 0.06), _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white)}`,
411
+ border: `1px solid ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.red}`,
412
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack,
413
+ "::placeholder": {
414
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64
415
+ }
517
416
  },
518
417
  disabled: {
519
- cursor: "auto",
520
- backgroundColor: radio_core_offWhite,
521
- borderColor: radio_core_offBlack16,
522
- borderWidth: 1
523
- }
524
- });
525
- const radio_core_fadedBlue = Object(wonder_blocks_color_["mix"])(Object(wonder_blocks_color_["fade"])(radio_core_blue, 0.16), radio_core_white);
526
- const radio_core_activeBlue = Object(wonder_blocks_color_["mix"])(radio_core_offBlack32, radio_core_blue);
527
- const radio_core_fadedRed = Object(wonder_blocks_color_["mix"])(Object(wonder_blocks_color_["fade"])(radio_core_red, 0.08), radio_core_white);
528
- const radio_core_activeRed = Object(wonder_blocks_color_["mix"])(radio_core_offBlack32, radio_core_red);
529
- const radio_core_colors = {
530
- default: {
531
- faded: radio_core_fadedBlue,
532
- base: radio_core_blue,
533
- active: radio_core_activeBlue
418
+ background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offWhite,
419
+ border: `1px solid ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack16}`,
420
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64,
421
+ "::placeholder": {
422
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack32
423
+ }
534
424
  },
535
- error: {
536
- faded: radio_core_fadedRed,
537
- base: radio_core_red,
538
- active: radio_core_activeRed
539
- }
540
- };
541
- const radio_core_styles = {};
542
-
543
- const radio_core_generateStyles = (checked, error) => {
544
- // "hash" the parameters
545
- const styleKey = `${String(checked)}-${String(error)}`;
546
-
547
- if (radio_core_styles[styleKey]) {
548
- return radio_core_styles[styleKey];
549
- }
550
-
551
- const palette = error ? radio_core_colors.error : radio_core_colors.default;
552
- let newStyles = {};
553
-
554
- if (checked) {
555
- newStyles = {
556
- default: {
557
- backgroundColor: radio_core_white,
558
- borderColor: palette.base,
559
- borderWidth: radio_core_size / 4
560
- },
561
- focus: {
562
- boxShadow: `0 0 0 1px ${radio_core_white}, 0 0 0 3px ${palette.base}`
563
- },
564
- active: {
565
- boxShadow: `0 0 0 1px ${radio_core_white}, 0 0 0 3px ${palette.active}`,
566
- borderColor: palette.active
567
- }
568
- };
569
- } else {
570
- newStyles = {
571
- default: {
572
- backgroundColor: error ? radio_core_fadedRed : radio_core_white,
573
- borderColor: error ? radio_core_red : radio_core_offBlack50
574
- },
575
- focus: {
576
- backgroundColor: error ? radio_core_fadedRed : radio_core_white,
577
- borderColor: palette.base,
578
- borderWidth: 2
579
- },
580
- active: {
581
- backgroundColor: palette.faded,
582
- borderColor: error ? radio_core_activeRed : radio_core_blue,
583
- borderWidth: 2
584
- }
585
- };
425
+ focused: {
426
+ background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white,
427
+ border: `1px solid ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.blue}`,
428
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack,
429
+ "::placeholder": {
430
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64
431
+ }
432
+ },
433
+ defaultLight: {
434
+ boxShadow: `0px 0px 0px 1px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.blue}, 0px 0px 0px 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white}`
435
+ },
436
+ errorLight: {
437
+ boxShadow: `0px 0px 0px 1px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.red}, 0px 0px 0px 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white}`
586
438
  }
439
+ });
440
+ const TextField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["forwardRef"]((props, ref) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](TextFieldInternal, _extends({}, props, {
441
+ forwardedRef: ref
442
+ })));
443
+ /* harmony default export */ __webpack_exports__["a"] = (TextField);
587
444
 
588
- radio_core_styles[styleKey] = external_aphrodite_["StyleSheet"].create(newStyles);
589
- return radio_core_styles[styleKey];
590
- };
591
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/choice-internal.js
445
+ /***/ }),
446
+ /* 11 */
447
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
592
448
 
449
+ "use strict";
450
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ChoiceInternal; });
451
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
452
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
453
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
454
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
455
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
456
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
457
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
458
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
459
+ /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(16);
460
+ /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_4__);
461
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
462
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__);
463
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
464
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__);
465
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4);
466
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__);
467
+ /* harmony import */ var _checkbox_core_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(17);
468
+ /* harmony import */ var _radio_core_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(19);
469
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
593
470
 
594
- const choice_internal_excluded = ["label", "description", "onChange", "style", "className", "variant"];
595
471
 
596
472
 
597
473
 
@@ -611,7 +487,7 @@ const choice_internal_excluded = ["label", "description", "onChange", "style", "
611
487
  * example, we can make onChange a required prop on Checkbox but not on Choice
612
488
  * (because for Choice, that prop would be auto-populated by CheckboxGroup).
613
489
  */
614
- class choice_internal_ChoiceInternal extends external_react_["Component"] {
490
+ class ChoiceInternal extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
615
491
  constructor(...args) {
616
492
  super(...args);
617
493
 
@@ -638,9 +514,9 @@ class choice_internal_ChoiceInternal extends external_react_["Component"] {
638
514
 
639
515
  getChoiceCoreComponent() {
640
516
  if (this.props.variant === "radio") {
641
- return radio_core_RadioCore;
517
+ return _radio_core_js__WEBPACK_IMPORTED_MODULE_9__[/* default */ "a"];
642
518
  } else {
643
- return checkbox_core_CheckboxCore;
519
+ return _checkbox_core_js__WEBPACK_IMPORTED_MODULE_8__[/* default */ "a"];
644
520
  }
645
521
  }
646
522
 
@@ -650,9 +526,9 @@ class choice_internal_ChoiceInternal extends external_react_["Component"] {
650
526
  id,
651
527
  label
652
528
  } = this.props;
653
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelMedium"], {
654
- style: [choice_internal_styles.label, disabled && choice_internal_styles.disabledLabel]
655
- }, /*#__PURE__*/external_react_["createElement"]("label", {
529
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__["LabelMedium"], {
530
+ style: [styles.label, disabled && styles.disabledLabel]
531
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("label", {
656
532
  htmlFor: id,
657
533
  onClick: this.handleLabelClick
658
534
  }, label));
@@ -662,61 +538,61 @@ class choice_internal_ChoiceInternal extends external_react_["Component"] {
662
538
  const {
663
539
  description
664
540
  } = this.props;
665
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
666
- style: choice_internal_styles.description,
541
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__["LabelSmall"], {
542
+ style: styles.description,
667
543
  id: id
668
544
  }, description);
669
545
  }
670
546
 
671
547
  render() {
672
- const _this$props = this.props,
673
- {
548
+ const {
674
549
  label,
675
550
  description,
551
+ // eslint-disable-next-line no-unused-vars
552
+ onChange,
676
553
  style,
677
554
  className,
678
- variant
679
- } = _this$props,
680
- coreProps = objectWithoutPropertiesLoose_default()(_this$props, choice_internal_excluded);
681
-
555
+ variant,
556
+ ...coreProps
557
+ } = this.props;
682
558
  const ChoiceCore = this.getChoiceCoreComponent();
683
- const ClickableBehavior = Object(wonder_blocks_clickable_["getClickableBehavior"])();
684
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["UniqueIDProvider"], {
559
+ const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_4__["getClickableBehavior"])();
560
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["UniqueIDProvider"], {
685
561
  mockOnFirstRender: true,
686
562
  scope: "choice"
687
563
  }, ids => {
688
564
  const descriptionId = description && ids.get("description");
689
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
565
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
690
566
  style: style,
691
567
  className: className
692
- }, /*#__PURE__*/external_react_["createElement"](ClickableBehavior, {
568
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
693
569
  disabled: coreProps.disabled,
694
570
  onClick: this.handleClick,
695
571
  role: variant
696
572
  }, (state, childrenProps) => {
697
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], extends_default()({
698
- style: choice_internal_styles.wrapper
573
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], _extends({
574
+ style: styles.wrapper
699
575
  }, childrenProps, {
700
576
  // We are resetting the tabIndex=0 from handlers
701
577
  // because the ChoiceCore component will receive
702
578
  // focus on basis of it being an input element.
703
579
  tabIndex: -1
704
- }), /*#__PURE__*/external_react_["createElement"](ChoiceCore, extends_default()({}, coreProps, state, {
580
+ }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ChoiceCore, _extends({}, coreProps, state, {
705
581
  "aria-describedby": descriptionId
706
- })), /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
707
- size: wonder_blocks_spacing_default.a.xSmall_8
582
+ })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_5__["Strut"], {
583
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xSmall_8
708
584
  }), label && this.getLabel());
709
585
  }), description && this.getDescription(descriptionId));
710
586
  });
711
587
  }
712
588
 
713
589
  }
714
- choice_internal_ChoiceInternal.defaultProps = {
590
+ ChoiceInternal.defaultProps = {
715
591
  checked: false,
716
592
  disabled: false,
717
593
  error: false
718
594
  };
719
- const choice_internal_styles = external_aphrodite_["StyleSheet"].create({
595
+ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
720
596
  wrapper: {
721
597
  flexDirection: "row",
722
598
  alignItems: "flex-start",
@@ -731,66 +607,26 @@ const choice_internal_styles = external_aphrodite_["StyleSheet"].create({
731
607
  marginTop: -2
732
608
  },
733
609
  disabledLabel: {
734
- color: wonder_blocks_color_default.a.offBlack32
610
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack32
735
611
  },
736
612
  description: {
737
613
  // 16 for icon + 8 for spacing strut
738
- marginLeft: wonder_blocks_spacing_default.a.medium_16 + wonder_blocks_spacing_default.a.xSmall_8,
739
- marginTop: wonder_blocks_spacing_default.a.xxxSmall_4,
740
- color: wonder_blocks_color_default.a.offBlack64
614
+ marginLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.medium_16 + _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xSmall_8,
615
+ marginTop: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xxxSmall_4,
616
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64
741
617
  }
742
618
  });
743
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/checkbox.js
744
-
745
-
746
- // Keep synced with ChoiceComponentProps in ../util/types.js
747
-
748
- /**
749
- * ☑️ A nicely styled checkbox for all your checking needs. Can optionally take
750
- * label and description props.
751
- *
752
- * If you want a whole group of Checkbox[es] that are related, see the Choice
753
- * and CheckboxGroup components.
754
- */
755
- class checkbox_Checkbox extends external_react_["Component"] {
756
- render() {
757
- return /*#__PURE__*/external_react_["createElement"](choice_internal_ChoiceInternal, extends_default()({
758
- variant: "checkbox"
759
- }, this.props));
760
- }
761
-
762
- }
763
- checkbox_Checkbox.defaultProps = {
764
- disabled: false,
765
- error: false
766
- };
767
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/radio.js
768
-
769
-
770
- // Keep synced with ChoiceComponentProps in ../util/types.js
771
-
772
- /**
773
- * 🔘 A nicely styled radio button for all your non-AMFM radio button needs. Can
774
- * optionally take label and description props.
775
- *
776
- * This component should not really be used by itself because radio buttons are
777
- * often grouped together. See RadioGroup.
778
- */
779
- class radio_Radio extends external_react_["Component"] {
780
- render() {
781
- return /*#__PURE__*/external_react_["createElement"](choice_internal_ChoiceInternal, extends_default()({
782
- variant: "radio"
783
- }, this.props));
784
- }
785
619
 
786
- }
787
- radio_Radio.defaultProps = {
788
- disabled: false,
789
- error: false
790
- };
791
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/choice.js
620
+ /***/ }),
621
+ /* 12 */
622
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
792
623
 
793
- const choice_excluded = ["value", "variant"];
624
+ "use strict";
625
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Choice; });
626
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
627
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
628
+ /* harmony import */ var _checkbox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
629
+ /* harmony import */ var _radio_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
794
630
 
795
631
 
796
632
 
@@ -804,69 +640,59 @@ const choice_excluded = ["value", "variant"];
804
640
  * If you wish to use just a single field, use Checkbox or Radio with the
805
641
  * optional label and description props.
806
642
  */
807
- class choice_Choice extends external_react_["Component"] {
643
+ class Choice extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
808
644
  getChoiceComponent(variant) {
809
645
  if (variant === "checkbox") {
810
- return checkbox_Checkbox;
646
+ return _checkbox_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"];
811
647
  } else {
812
- return radio_Radio;
648
+ return _radio_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"];
813
649
  }
814
650
  }
815
651
 
816
652
  render() {
817
653
  // we don't need this going into the ChoiceComponent
818
654
  // eslint-disable-next-line no-unused-vars
819
- const _this$props = this.props,
820
- {
821
- variant
822
- } = _this$props,
823
- remainingProps = objectWithoutPropertiesLoose_default()(_this$props, choice_excluded);
824
-
655
+ const {
656
+ value,
657
+ variant,
658
+ ...remainingProps
659
+ } = this.props;
825
660
  const ChoiceComponent = this.getChoiceComponent(variant);
826
- return /*#__PURE__*/external_react_["createElement"](ChoiceComponent, remainingProps);
661
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ChoiceComponent, remainingProps);
827
662
  }
828
663
 
829
664
  }
830
- choice_Choice.defaultProps = {
665
+ Choice.defaultProps = {
831
666
  checked: false,
832
667
  disabled: false,
833
668
  onChange: () => {}
834
669
  };
835
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/group-styles.js
836
670
 
671
+ /***/ }),
672
+ /* 13 */
673
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
837
674
 
838
-
839
- const group_styles_styles = external_aphrodite_["StyleSheet"].create({
840
- fieldset: {
841
- border: "none",
842
- padding: 0,
843
- margin: 0
844
- },
845
- legend: {
846
- padding: 0
847
- },
848
- description: {
849
- marginTop: wonder_blocks_spacing_default.a.xxxSmall_4,
850
- color: wonder_blocks_color_default.a.offBlack64
851
- },
852
- error: {
853
- marginTop: wonder_blocks_spacing_default.a.xxxSmall_4,
854
- color: wonder_blocks_color_default.a.red
855
- },
856
- defaultLineGap: {
857
- marginTop: wonder_blocks_spacing_default.a.xSmall_8
858
- }
859
- });
860
- /* harmony default export */ var group_styles = (group_styles_styles);
861
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/checkbox-group.js
675
+ "use strict";
676
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CheckboxGroup; });
677
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
678
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
679
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
680
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__);
681
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
682
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__);
683
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
684
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__);
685
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4);
686
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
687
+ /* harmony import */ var _group_styles_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
862
688
 
863
689
 
864
690
 
865
691
 
866
692
 
867
693
 
868
- const StyledFieldset = Object(wonder_blocks_core_["addStyle"])("fieldset");
869
- const StyledLegend = Object(wonder_blocks_core_["addStyle"])("legend");
694
+ const StyledFieldset = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["addStyle"])("fieldset");
695
+ const StyledLegend = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["addStyle"])("legend");
870
696
  /**
871
697
  * A checkbox group allows multiple selection. This component auto-populates
872
698
  * many props for its children Choice components. The Choice component is
@@ -874,7 +700,7 @@ const StyledLegend = Object(wonder_blocks_core_["addStyle"])("legend");
874
700
  * disabled.
875
701
  */
876
702
 
877
- class checkbox_group_CheckboxGroup extends external_react_["Component"] {
703
+ class CheckboxGroup extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
878
704
  handleChange(changedValue, originalCheckedState) {
879
705
  const {
880
706
  onChange,
@@ -901,48 +727,65 @@ class checkbox_group_CheckboxGroup extends external_react_["Component"] {
901
727
  style,
902
728
  testId
903
729
  } = this.props;
904
- return /*#__PURE__*/external_react_["createElement"](StyledFieldset, {
730
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledFieldset, {
905
731
  "data-test-id": testId,
906
- style: group_styles.fieldset
907
- }, /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
732
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].fieldset
733
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["View"], {
908
734
  style: style
909
- }, typeof label === "string" ? /*#__PURE__*/external_react_["createElement"](StyledLegend, {
910
- style: group_styles.legend
911
- }, /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelMedium"], null, label)) : label && label, typeof description === "string" ? /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
912
- style: group_styles.description
913
- }, description) : description && description, errorMessage && /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
914
- style: group_styles.error
915
- }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
916
- size: wonder_blocks_spacing_default.a.small_12
917
- }), external_react_["Children"].map(children, (child, index) => {
735
+ }, typeof label === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledLegend, {
736
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].legend
737
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelMedium"], null, label)) : label && label, typeof description === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"], {
738
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].description
739
+ }, description) : description && description, errorMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"], {
740
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].error
741
+ }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["Strut"], {
742
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.small_12
743
+ }), react__WEBPACK_IMPORTED_MODULE_0__["Children"].map(children, (child, index) => {
918
744
  const {
919
745
  style,
920
746
  value
921
747
  } = child.props;
922
748
  const checked = selectedValues.includes(value);
923
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, /*#__PURE__*/external_react_["cloneElement"](child, {
749
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["cloneElement"](child, {
924
750
  checked: checked,
925
751
  error: !!errorMessage,
926
752
  groupName: groupName,
927
753
  id: `${groupName}-${value}`,
928
754
  key: value,
929
755
  onChange: () => this.handleChange(value, checked),
930
- style: [index > 0 && group_styles.defaultLineGap, style],
756
+ style: [index > 0 && _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].defaultLineGap, style],
931
757
  variant: "checkbox"
932
758
  }));
933
759
  })));
934
760
  }
935
761
 
936
762
  }
937
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/radio-group.js
763
+
764
+ /***/ }),
765
+ /* 14 */
766
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
767
+
768
+ "use strict";
769
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RadioGroup; });
770
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
771
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
772
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
773
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__);
774
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
775
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__);
776
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
777
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__);
778
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4);
779
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
780
+ /* harmony import */ var _group_styles_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
938
781
 
939
782
 
940
783
 
941
784
 
942
785
 
943
786
 
944
- const radio_group_StyledFieldset = Object(wonder_blocks_core_["addStyle"])("fieldset");
945
- const radio_group_StyledLegend = Object(wonder_blocks_core_["addStyle"])("legend");
787
+ const StyledFieldset = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["addStyle"])("fieldset");
788
+ const StyledLegend = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["addStyle"])("legend");
946
789
  /**
947
790
  * A radio group allows only single selection. Like CheckboxGroup, this
948
791
  * component auto-populates many props for its children Choice components. The
@@ -952,7 +795,7 @@ const radio_group_StyledLegend = Object(wonder_blocks_core_["addStyle"])("legend
952
795
  * accessibility.
953
796
  */
954
797
 
955
- class radio_group_RadioGroup extends external_react_["Component"] {
798
+ class RadioGroup extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
956
799
  handleChange(changedValue) {
957
800
  this.props.onChange(changedValue);
958
801
  }
@@ -968,87 +811,79 @@ class radio_group_RadioGroup extends external_react_["Component"] {
968
811
  style,
969
812
  testId
970
813
  } = this.props;
971
- return /*#__PURE__*/external_react_["createElement"](radio_group_StyledFieldset, {
814
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledFieldset, {
972
815
  "data-test-id": testId,
973
- style: group_styles.fieldset
974
- }, /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
816
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].fieldset
817
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["View"], {
975
818
  style: style
976
- }, label && /*#__PURE__*/external_react_["createElement"](radio_group_StyledLegend, {
977
- style: group_styles.legend
978
- }, /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelMedium"], null, label)), description && /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
979
- style: group_styles.description
980
- }, description), errorMessage && /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
981
- style: group_styles.error
982
- }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
983
- size: wonder_blocks_spacing_default.a.small_12
984
- }), external_react_["Children"].map(children, (child, index) => {
819
+ }, label && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledLegend, {
820
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].legend
821
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelMedium"], null, label)), description && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"], {
822
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].description
823
+ }, description), errorMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"], {
824
+ style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].error
825
+ }, errorMessage), (label || description || errorMessage) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["Strut"], {
826
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.small_12
827
+ }), react__WEBPACK_IMPORTED_MODULE_0__["Children"].map(children, (child, index) => {
985
828
  const {
986
829
  style,
987
830
  value
988
831
  } = child.props;
989
832
  const checked = selectedValue === value;
990
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, /*#__PURE__*/external_react_["cloneElement"](child, {
833
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["cloneElement"](child, {
991
834
  checked: checked,
992
835
  error: !!errorMessage,
993
836
  groupName: groupName,
994
837
  id: `${groupName}-${value}`,
995
838
  key: value,
996
839
  onChange: () => this.handleChange(value),
997
- style: [index > 0 && group_styles.defaultLineGap, style],
840
+ style: [index > 0 && _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].defaultLineGap, style],
998
841
  variant: "radio"
999
842
  }));
1000
843
  })));
1001
844
  }
1002
845
 
1003
846
  }
1004
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/text-field.js
1005
847
 
848
+ /***/ }),
849
+ /* 15 */
850
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1006
851
 
1007
- const text_field_excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "required", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange"];
852
+ "use strict";
853
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
854
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
855
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
856
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__);
857
+ /* harmony import */ var _field_heading_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
858
+ /* harmony import */ var _text_field_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
859
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1008
860
 
1009
861
 
1010
862
 
1011
863
 
1012
864
 
1013
865
 
1014
- // TODO(WB-1081): Change class name back to TextField after Styleguidist is gone.
866
+ // TODO(WB-1081): Change class name back to LabeledTextField after Styleguidist is gone.
1015
867
 
1016
868
  /**
1017
- * A TextField is an element used to accept a single line of text from the user.
869
+ * A LabeledTextField is an element used to accept a single line of text
870
+ * from the user paired with a label, description, and error field elements.
1018
871
  */
1019
- class text_field_TextFieldInternal extends external_react_["Component"] {
872
+ class LabeledTextFieldInternal extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
1020
873
  constructor(props) {
1021
874
  super(props);
1022
- this.state = {
1023
- error: null,
1024
- focused: false
1025
- };
1026
875
 
1027
- this.maybeValidate = newValue => {
876
+ this.handleValidate = errorMessage => {
1028
877
  const {
1029
- validate,
1030
878
  onValidate
1031
879
  } = this.props;
1032
-
1033
- if (validate) {
1034
- const maybeError = validate(newValue) || null;
1035
- this.setState({
1036
- error: maybeError
1037
- }, () => {
1038
- if (onValidate) {
1039
- onValidate(maybeError);
1040
- }
1041
- });
1042
- }
1043
- };
1044
-
1045
- this.handleChange = event => {
1046
- const {
1047
- onChange
1048
- } = this.props;
1049
- const newValue = event.target.value;
1050
- this.maybeValidate(newValue);
1051
- onChange(newValue);
880
+ this.setState({
881
+ error: errorMessage
882
+ }, () => {
883
+ if (onValidate) {
884
+ onValidate(errorMessage);
885
+ }
886
+ });
1052
887
  };
1053
888
 
1054
889
  this.handleFocus = event => {
@@ -1077,117 +912,482 @@ class text_field_TextFieldInternal extends external_react_["Component"] {
1077
912
  });
1078
913
  };
1079
914
 
1080
- if (props.validate) {
1081
- // Ensures error is updated on unmounted server-side renders
1082
- this.state.error = props.validate(props.value) || null;
1083
- }
1084
- }
1085
-
1086
- componentDidMount() {
1087
- this.maybeValidate(this.props.value);
915
+ this.state = {
916
+ error: null,
917
+ focused: false
918
+ };
1088
919
  }
1089
920
 
1090
921
  render() {
1091
- const _this$props = this.props,
1092
- {
922
+ const {
1093
923
  id,
1094
924
  type,
925
+ label,
926
+ description,
1095
927
  value,
1096
928
  disabled,
929
+ validate,
930
+ onChange,
1097
931
  onKeyDown,
1098
932
  placeholder,
1099
- required,
1100
933
  light,
1101
934
  style,
1102
935
  testId,
1103
936
  readOnly,
1104
937
  autoComplete,
1105
938
  forwardedRef
1106
- } = _this$props,
1107
- otherProps = objectWithoutPropertiesLoose_default()(_this$props, text_field_excluded);
939
+ } = this.props;
940
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["IDProvider"], {
941
+ id: id,
942
+ scope: "labeled-text-field"
943
+ }, uniqueId => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_field_heading_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"], {
944
+ id: uniqueId,
945
+ testId: testId,
946
+ style: style,
947
+ field: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_text_field_js__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"], {
948
+ id: `${uniqueId}-field`,
949
+ "aria-describedby": `${uniqueId}-error`,
950
+ "aria-invalid": this.state.error ? "true" : "false",
951
+ testId: testId && `${testId}-field`,
952
+ type: type,
953
+ value: value,
954
+ placeholder: placeholder,
955
+ disabled: disabled,
956
+ validate: validate,
957
+ onValidate: this.handleValidate,
958
+ onChange: onChange,
959
+ onKeyDown: onKeyDown,
960
+ onFocus: this.handleFocus,
961
+ onBlur: this.handleBlur,
962
+ light: light,
963
+ readOnly: readOnly,
964
+ autoComplete: autoComplete,
965
+ ref: forwardedRef
966
+ }),
967
+ label: label,
968
+ description: description,
969
+ error: !this.state.focused && this.state.error || ""
970
+ }));
971
+ }
972
+
973
+ }
974
+
975
+ LabeledTextFieldInternal.defaultProps = {
976
+ type: "text",
977
+ disabled: false,
978
+ light: false
979
+ };
980
+ const LabeledTextField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["forwardRef"]((props, ref) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](LabeledTextFieldInternal, _extends({}, props, {
981
+ forwardedRef: ref
982
+ })));
983
+ /* harmony default export */ __webpack_exports__["a"] = (LabeledTextField);
984
+
985
+ /***/ }),
986
+ /* 16 */
987
+ /***/ (function(module, exports) {
988
+
989
+ module.exports = require("@khanacademy/wonder-blocks-clickable");
990
+
991
+ /***/ }),
992
+ /* 17 */
993
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
994
+
995
+ "use strict";
996
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CheckboxCore; });
997
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
998
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
999
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
1000
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
1001
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
1002
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
1003
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
1004
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
1005
+ /* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18);
1006
+ /* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4__);
1007
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+ const {
1015
+ blue,
1016
+ red,
1017
+ white,
1018
+ offWhite,
1019
+ offBlack16,
1020
+ offBlack32,
1021
+ offBlack50
1022
+ } = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a;
1023
+ const StyledInput = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["addStyle"])("input");
1024
+ const checkboxCheck = {
1025
+ 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"
1026
+ };
1027
+ /**
1028
+ * The internal stateless ☑️ Checkbox
1029
+ */
1030
+
1031
+ class CheckboxCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
1032
+ constructor(...args) {
1033
+ super(...args);
1034
+
1035
+ this.handleChange = () => {
1036
+ // Empty because change is handled by ClickableBehavior
1037
+ return;
1038
+ };
1039
+ }
1040
+
1041
+ render() {
1042
+ const {
1043
+ checked,
1044
+ disabled,
1045
+ error,
1046
+ groupName,
1047
+ id,
1048
+ testId,
1049
+ hovered,
1050
+ focused,
1051
+ pressed,
1052
+ waiting: _,
1053
+ ...sharedProps
1054
+ } = this.props;
1055
+
1056
+ const stateStyles = _generateStyles(checked, error);
1057
+
1058
+ const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles.disabled];
1059
+ const props = {
1060
+ "data-test-id": testId
1061
+ };
1062
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledInput, _extends({}, sharedProps, {
1063
+ type: "checkbox",
1064
+ "aria-invalid": error,
1065
+ checked: checked,
1066
+ disabled: disabled,
1067
+ id: id,
1068
+ name: groupName // Need to specify because this is a controlled React form
1069
+ // component, but we handle the click via ClickableBehavior
1070
+ ,
1071
+ onChange: this.handleChange,
1072
+ style: defaultStyle
1073
+ }, props)), checked && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4___default.a, {
1074
+ color: disabled ? offBlack32 : white,
1075
+ icon: checkboxCheck,
1076
+ size: "small",
1077
+ style: sharedStyles.checkIcon
1078
+ }));
1079
+ }
1080
+
1081
+ }
1082
+ const size = 16;
1083
+ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
1084
+ // Reset the default styled input element
1085
+ inputReset: {
1086
+ appearance: "none",
1087
+ WebkitAppearance: "none",
1088
+ MozAppearance: "none"
1089
+ },
1090
+ default: {
1091
+ height: size,
1092
+ width: size,
1093
+ minHeight: size,
1094
+ minWidth: size,
1095
+ margin: 0,
1096
+ outline: "none",
1097
+ boxSizing: "border-box",
1098
+ borderStyle: "solid",
1099
+ borderWidth: 1,
1100
+ borderRadius: 3
1101
+ },
1102
+ disabled: {
1103
+ cursor: "auto",
1104
+ backgroundColor: offWhite,
1105
+ borderColor: offBlack16,
1106
+ borderWidth: 1
1107
+ },
1108
+ checkIcon: {
1109
+ position: "absolute",
1110
+ pointerEvents: "none"
1111
+ }
1112
+ });
1113
+ const fadedBlue = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["fade"])(blue, 0.16), white);
1114
+ const activeBlue = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(offBlack32, blue);
1115
+ const fadedRed = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["fade"])(red, 0.08), white);
1116
+ const activeRed = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(offBlack32, red);
1117
+ const colors = {
1118
+ default: {
1119
+ faded: fadedBlue,
1120
+ base: blue,
1121
+ active: activeBlue
1122
+ },
1123
+ error: {
1124
+ faded: fadedRed,
1125
+ base: red,
1126
+ active: activeRed
1127
+ }
1128
+ };
1129
+ const styles = {};
1130
+
1131
+ const _generateStyles = (checked, error) => {
1132
+ // "hash" the parameters
1133
+ const styleKey = `${String(checked)}-${String(error)}`;
1134
+
1135
+ if (styles[styleKey]) {
1136
+ return styles[styleKey];
1137
+ }
1138
+
1139
+ const palette = error ? colors.error : colors.default;
1140
+ let newStyles = {};
1141
+
1142
+ if (checked) {
1143
+ newStyles = {
1144
+ default: {
1145
+ backgroundColor: palette.base,
1146
+ borderWidth: 0
1147
+ },
1148
+ focus: {
1149
+ boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
1150
+ },
1151
+ active: {
1152
+ boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.active}`,
1153
+ background: palette.active
1154
+ }
1155
+ };
1156
+ } else {
1157
+ newStyles = {
1158
+ default: {
1159
+ backgroundColor: error ? fadedRed : white,
1160
+ borderColor: error ? red : offBlack50
1161
+ },
1162
+ focus: {
1163
+ backgroundColor: error ? fadedRed : white,
1164
+ borderColor: palette.base,
1165
+ borderWidth: 2
1166
+ },
1167
+ active: {
1168
+ backgroundColor: palette.faded,
1169
+ borderColor: error ? activeRed : blue,
1170
+ borderWidth: 2
1171
+ }
1172
+ };
1173
+ }
1174
+
1175
+ styles[styleKey] = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create(newStyles);
1176
+ return styles[styleKey];
1177
+ };
1178
+
1179
+ /***/ }),
1180
+ /* 18 */
1181
+ /***/ (function(module, exports) {
1182
+
1183
+ module.exports = require("@khanacademy/wonder-blocks-icon");
1184
+
1185
+ /***/ }),
1186
+ /* 19 */
1187
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1188
+
1189
+ "use strict";
1190
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RadioCore; });
1191
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
1192
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1193
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
1194
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
1195
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
1196
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
1197
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
1198
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
1199
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+ const {
1206
+ blue,
1207
+ red,
1208
+ white,
1209
+ offWhite,
1210
+ offBlack16,
1211
+ offBlack32,
1212
+ offBlack50
1213
+ } = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a;
1214
+ const StyledInput = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["addStyle"])("input");
1215
+ /**
1216
+ * The internal stateless 🔘 Radio button
1217
+ */
1218
+
1219
+ class RadioCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
1220
+ constructor(...args) {
1221
+ super(...args);
1222
+
1223
+ this.handleChange = () => {
1224
+ // Empty because change is handled by ClickableBehavior
1225
+ return;
1226
+ };
1227
+ }
1228
+
1229
+ render() {
1230
+ const {
1231
+ checked,
1232
+ disabled,
1233
+ error,
1234
+ groupName,
1235
+ id,
1236
+ testId,
1237
+ hovered,
1238
+ focused,
1239
+ pressed,
1240
+ waiting: _,
1241
+ ...sharedProps
1242
+ } = this.props;
1108
1243
 
1109
- return /*#__PURE__*/external_react_["createElement"]("input", extends_default()({
1110
- className: Object(external_aphrodite_["css"])([text_field_styles.input, wonder_blocks_typography_["styles"].LabelMedium, text_field_styles.default, // Prioritizes disabled, then focused, then error (if any)
1111
- disabled ? text_field_styles.disabled : this.state.focused ? [text_field_styles.focused, light && text_field_styles.defaultLight] : this.state.error && [text_field_styles.error, light && text_field_styles.errorLight], style && style]),
1112
- id: id,
1113
- type: type,
1114
- placeholder: placeholder,
1115
- value: value,
1244
+ const stateStyles = _generateStyles(checked, error);
1245
+
1246
+ const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles.disabled];
1247
+ const props = {
1248
+ "data-test-id": testId
1249
+ };
1250
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledInput, _extends({}, sharedProps, {
1251
+ type: "radio",
1252
+ "aria-invalid": error,
1253
+ checked: checked,
1116
1254
  disabled: disabled,
1255
+ id: id,
1256
+ name: groupName // Need to specify because this is a controlled React form
1257
+ // component, but we handle the click via ClickableBehavior
1258
+ ,
1117
1259
  onChange: this.handleChange,
1118
- onKeyDown: onKeyDown,
1119
- onFocus: this.handleFocus,
1120
- onBlur: this.handleBlur,
1121
- required: required,
1122
- "data-test-id": testId,
1123
- readOnly: readOnly,
1124
- autoComplete: autoComplete,
1125
- ref: forwardedRef
1126
- }, otherProps));
1260
+ style: defaultStyle
1261
+ }, props)), disabled && checked && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("span", {
1262
+ style: disabledChecked
1263
+ }));
1127
1264
  }
1128
1265
 
1129
1266
  }
1267
+ 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
1130
1268
 
1131
- text_field_TextFieldInternal.defaultProps = {
1132
- type: "text",
1133
- disabled: false,
1134
- light: false
1269
+ const disabledChecked = {
1270
+ position: "absolute",
1271
+ top: size / 4,
1272
+ left: size / 4,
1273
+ height: size / 2,
1274
+ width: size / 2,
1275
+ borderRadius: "50%",
1276
+ backgroundColor: offBlack32
1135
1277
  };
1136
- const text_field_styles = external_aphrodite_["StyleSheet"].create({
1137
- input: {
1138
- width: "100%",
1139
- height: 40,
1140
- borderRadius: 4,
1141
- boxSizing: "border-box",
1142
- paddingLeft: wonder_blocks_spacing_default.a.medium_16,
1278
+ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
1279
+ // Reset the default styled input element
1280
+ inputReset: {
1281
+ appearance: "none",
1282
+ WebkitAppearance: "none",
1283
+ MozAppearance: "none"
1284
+ },
1285
+ default: {
1286
+ height: size,
1287
+ width: size,
1288
+ minHeight: size,
1289
+ minWidth: size,
1143
1290
  margin: 0,
1144
1291
  outline: "none",
1145
- boxShadow: "none"
1292
+ boxSizing: "border-box",
1293
+ borderStyle: "solid",
1294
+ borderWidth: 1,
1295
+ borderRadius: "50%"
1146
1296
  },
1297
+ disabled: {
1298
+ cursor: "auto",
1299
+ backgroundColor: offWhite,
1300
+ borderColor: offBlack16,
1301
+ borderWidth: 1
1302
+ }
1303
+ });
1304
+ const fadedBlue = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["fade"])(blue, 0.16), white);
1305
+ const activeBlue = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(offBlack32, blue);
1306
+ const fadedRed = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["fade"])(red, 0.08), white);
1307
+ const activeRed = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(offBlack32, red);
1308
+ const colors = {
1147
1309
  default: {
1148
- background: wonder_blocks_color_default.a.white,
1149
- border: `1px solid ${wonder_blocks_color_default.a.offBlack16}`,
1150
- color: wonder_blocks_color_default.a.offBlack,
1151
- "::placeholder": {
1152
- color: wonder_blocks_color_default.a.offBlack64
1153
- }
1310
+ faded: fadedBlue,
1311
+ base: blue,
1312
+ active: activeBlue
1154
1313
  },
1155
1314
  error: {
1156
- background: `${Object(wonder_blocks_color_["mix"])(Object(wonder_blocks_color_["fade"])(wonder_blocks_color_default.a.red, 0.06), wonder_blocks_color_default.a.white)}`,
1157
- border: `1px solid ${wonder_blocks_color_default.a.red}`,
1158
- color: wonder_blocks_color_default.a.offBlack,
1159
- "::placeholder": {
1160
- color: wonder_blocks_color_default.a.offBlack64
1161
- }
1162
- },
1163
- disabled: {
1164
- background: wonder_blocks_color_default.a.offWhite,
1165
- border: `1px solid ${wonder_blocks_color_default.a.offBlack16}`,
1166
- color: wonder_blocks_color_default.a.offBlack64,
1167
- "::placeholder": {
1168
- color: wonder_blocks_color_default.a.offBlack32
1169
- }
1170
- },
1171
- focused: {
1172
- background: wonder_blocks_color_default.a.white,
1173
- border: `1px solid ${wonder_blocks_color_default.a.blue}`,
1174
- color: wonder_blocks_color_default.a.offBlack,
1175
- "::placeholder": {
1176
- color: wonder_blocks_color_default.a.offBlack64
1177
- }
1178
- },
1179
- defaultLight: {
1180
- boxShadow: `0px 0px 0px 1px ${wonder_blocks_color_default.a.blue}, 0px 0px 0px 2px ${wonder_blocks_color_default.a.white}`
1181
- },
1182
- errorLight: {
1183
- boxShadow: `0px 0px 0px 1px ${wonder_blocks_color_default.a.red}, 0px 0px 0px 2px ${wonder_blocks_color_default.a.white}`
1315
+ faded: fadedRed,
1316
+ base: red,
1317
+ active: activeRed
1184
1318
  }
1185
- });
1186
- const TextField = /*#__PURE__*/external_react_["forwardRef"]((props, ref) => /*#__PURE__*/external_react_["createElement"](text_field_TextFieldInternal, extends_default()({}, props, {
1187
- forwardedRef: ref
1188
- })));
1189
- /* harmony default export */ var text_field = (TextField);
1190
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/field-heading.js
1319
+ };
1320
+ const styles = {};
1321
+
1322
+ const _generateStyles = (checked, error) => {
1323
+ // "hash" the parameters
1324
+ const styleKey = `${String(checked)}-${String(error)}`;
1325
+
1326
+ if (styles[styleKey]) {
1327
+ return styles[styleKey];
1328
+ }
1329
+
1330
+ const palette = error ? colors.error : colors.default;
1331
+ let newStyles = {};
1332
+
1333
+ if (checked) {
1334
+ newStyles = {
1335
+ default: {
1336
+ backgroundColor: white,
1337
+ borderColor: palette.base,
1338
+ borderWidth: size / 4
1339
+ },
1340
+ focus: {
1341
+ boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
1342
+ },
1343
+ active: {
1344
+ boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.active}`,
1345
+ borderColor: palette.active
1346
+ }
1347
+ };
1348
+ } else {
1349
+ newStyles = {
1350
+ default: {
1351
+ backgroundColor: error ? fadedRed : white,
1352
+ borderColor: error ? red : offBlack50
1353
+ },
1354
+ focus: {
1355
+ backgroundColor: error ? fadedRed : white,
1356
+ borderColor: palette.base,
1357
+ borderWidth: 2
1358
+ },
1359
+ active: {
1360
+ backgroundColor: palette.faded,
1361
+ borderColor: error ? activeRed : blue,
1362
+ borderWidth: 2
1363
+ }
1364
+ };
1365
+ }
1366
+
1367
+ styles[styleKey] = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create(newStyles);
1368
+ return styles[styleKey];
1369
+ };
1370
+
1371
+ /***/ }),
1372
+ /* 20 */
1373
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1374
+
1375
+ "use strict";
1376
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return FieldHeading; });
1377
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
1378
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1379
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
1380
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
1381
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
1382
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__);
1383
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
1384
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
1385
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
1386
+ /* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__);
1387
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3);
1388
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__);
1389
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4);
1390
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__);
1191
1391
 
1192
1392
 
1193
1393
 
@@ -1200,20 +1400,20 @@ const TextField = /*#__PURE__*/external_react_["forwardRef"]((props, ref) => /*#
1200
1400
  * A FieldHeading is an element that provides a label, description, and error element
1201
1401
  * to present better context and hints to any type of form field component.
1202
1402
  */
1203
- class field_heading_FieldHeading extends external_react_["Component"] {
1403
+ class FieldHeading extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
1204
1404
  renderLabel() {
1205
1405
  const {
1206
1406
  label,
1207
1407
  id,
1208
1408
  testId
1209
1409
  } = this.props;
1210
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, typeof label === "string" ? /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelMedium"], {
1211
- style: field_heading_styles.label,
1410
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, typeof label === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelMedium"], {
1411
+ style: styles.label,
1212
1412
  tag: "label",
1213
1413
  htmlFor: id && `${id}-field`,
1214
1414
  testId: testId && `${testId}-label`
1215
- }, label) : label, /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
1216
- size: wonder_blocks_spacing_default.a.xxxSmall_4
1415
+ }, label) : label, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["Strut"], {
1416
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xxxSmall_4
1217
1417
  }));
1218
1418
  }
1219
1419
 
@@ -1227,11 +1427,11 @@ class field_heading_FieldHeading extends external_react_["Component"] {
1227
1427
  return null;
1228
1428
  }
1229
1429
 
1230
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, typeof description === "string" ? /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
1231
- style: field_heading_styles.description,
1430
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, typeof description === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelSmall"], {
1431
+ style: styles.description,
1232
1432
  testId: testId && `${testId}-description`
1233
- }, description) : description, /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
1234
- size: wonder_blocks_spacing_default.a.xxxSmall_4
1433
+ }, description) : description, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["Strut"], {
1434
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xxxSmall_4
1235
1435
  }));
1236
1436
  }
1237
1437
 
@@ -1246,10 +1446,10 @@ class field_heading_FieldHeading extends external_react_["Component"] {
1246
1446
  return null;
1247
1447
  }
1248
1448
 
1249
- return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
1250
- size: wonder_blocks_spacing_default.a.small_12
1251
- }), typeof error === "string" ? /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
1252
- style: field_heading_styles.error,
1449
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["Strut"], {
1450
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.small_12
1451
+ }), typeof error === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelSmall"], {
1452
+ style: styles.error,
1253
1453
  role: "alert",
1254
1454
  id: id && `${id}-error`,
1255
1455
  testId: testId && `${testId}-error`
@@ -1261,151 +1461,53 @@ class field_heading_FieldHeading extends external_react_["Component"] {
1261
1461
  field,
1262
1462
  style
1263
1463
  } = this.props;
1264
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
1464
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__["View"], {
1265
1465
  style: style
1266
- }, this.renderLabel(), this.maybeRenderDescription(), /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["Strut"], {
1267
- size: wonder_blocks_spacing_default.a.xSmall_8
1466
+ }, this.renderLabel(), this.maybeRenderDescription(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["Strut"], {
1467
+ size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xSmall_8
1268
1468
  }), field, this.maybeRenderError());
1269
1469
  }
1270
1470
 
1271
1471
  }
1272
- const field_heading_styles = external_aphrodite_["StyleSheet"].create({
1472
+ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
1273
1473
  label: {
1274
- color: wonder_blocks_color_default.a.offBlack
1474
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default.a.offBlack
1275
1475
  },
1276
1476
  description: {
1277
- color: wonder_blocks_color_default.a.offBlack64
1477
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default.a.offBlack64
1278
1478
  },
1279
1479
  error: {
1280
- color: wonder_blocks_color_default.a.red
1480
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default.a.red
1281
1481
  }
1282
1482
  });
1283
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/components/labeled-text-field.js
1284
1483
 
1484
+ /***/ }),
1485
+ /* 21 */
1486
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1285
1487
 
1488
+ "use strict";
1489
+ __webpack_require__.r(__webpack_exports__);
1490
+ /* harmony import */ var _components_checkbox_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
1491
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _components_checkbox_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
1286
1492
 
1493
+ /* harmony import */ var _components_radio_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
1494
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Radio", function() { return _components_radio_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
1287
1495
 
1496
+ /* harmony import */ var _components_choice_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12);
1497
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Choice", function() { return _components_choice_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
1288
1498
 
1499
+ /* harmony import */ var _components_checkbox_group_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(13);
1500
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _components_checkbox_group_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
1289
1501
 
1290
- // TODO(WB-1081): Change class name back to LabeledTextField after Styleguidist is gone.
1291
-
1292
- /**
1293
- * A LabeledTextField is an element used to accept a single line of text
1294
- * from the user paired with a label, description, and error field elements.
1295
- */
1296
- class labeled_text_field_LabeledTextFieldInternal extends external_react_["Component"] {
1297
- constructor(props) {
1298
- super(props);
1299
-
1300
- this.handleValidate = errorMessage => {
1301
- const {
1302
- onValidate
1303
- } = this.props;
1304
- this.setState({
1305
- error: errorMessage
1306
- }, () => {
1307
- if (onValidate) {
1308
- onValidate(errorMessage);
1309
- }
1310
- });
1311
- };
1312
-
1313
- this.handleFocus = event => {
1314
- const {
1315
- onFocus
1316
- } = this.props;
1317
- this.setState({
1318
- focused: true
1319
- }, () => {
1320
- if (onFocus) {
1321
- onFocus(event);
1322
- }
1323
- });
1324
- };
1325
-
1326
- this.handleBlur = event => {
1327
- const {
1328
- onBlur
1329
- } = this.props;
1330
- this.setState({
1331
- focused: false
1332
- }, () => {
1333
- if (onBlur) {
1334
- onBlur(event);
1335
- }
1336
- });
1337
- };
1338
-
1339
- this.state = {
1340
- error: null,
1341
- focused: false
1342
- };
1343
- }
1502
+ /* harmony import */ var _components_radio_group_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(14);
1503
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _components_radio_group_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
1344
1504
 
1345
- render() {
1346
- const {
1347
- id,
1348
- type,
1349
- label,
1350
- description,
1351
- value,
1352
- disabled,
1353
- validate,
1354
- onChange,
1355
- onKeyDown,
1356
- placeholder,
1357
- light,
1358
- style,
1359
- testId,
1360
- readOnly,
1361
- autoComplete,
1362
- forwardedRef
1363
- } = this.props;
1364
- return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["IDProvider"], {
1365
- id: id,
1366
- scope: "labeled-text-field"
1367
- }, uniqueId => /*#__PURE__*/external_react_["createElement"](field_heading_FieldHeading, {
1368
- id: uniqueId,
1369
- testId: testId,
1370
- style: style,
1371
- field: /*#__PURE__*/external_react_["createElement"](text_field, {
1372
- id: `${uniqueId}-field`,
1373
- "aria-describedby": `${uniqueId}-error`,
1374
- "aria-invalid": this.state.error ? "true" : "false",
1375
- testId: testId && `${testId}-field`,
1376
- type: type,
1377
- value: value,
1378
- placeholder: placeholder,
1379
- disabled: disabled,
1380
- validate: validate,
1381
- onValidate: this.handleValidate,
1382
- onChange: onChange,
1383
- onKeyDown: onKeyDown,
1384
- onFocus: this.handleFocus,
1385
- onBlur: this.handleBlur,
1386
- light: light,
1387
- readOnly: readOnly,
1388
- autoComplete: autoComplete,
1389
- ref: forwardedRef
1390
- }),
1391
- label: label,
1392
- description: description,
1393
- error: !this.state.focused && this.state.error || ""
1394
- }));
1395
- }
1505
+ /* harmony import */ var _components_text_field_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(10);
1506
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextField", function() { return _components_text_field_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
1396
1507
 
1397
- }
1508
+ /* harmony import */ var _components_labeled_text_field_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(15);
1509
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LabeledTextField", function() { return _components_labeled_text_field_js__WEBPACK_IMPORTED_MODULE_6__["a"]; });
1398
1510
 
1399
- labeled_text_field_LabeledTextFieldInternal.defaultProps = {
1400
- type: "text",
1401
- disabled: false,
1402
- light: false
1403
- };
1404
- const LabeledTextField = /*#__PURE__*/external_react_["forwardRef"]((props, ref) => /*#__PURE__*/external_react_["createElement"](labeled_text_field_LabeledTextFieldInternal, extends_default()({}, props, {
1405
- forwardedRef: ref
1406
- })));
1407
- /* harmony default export */ var labeled_text_field = (LabeledTextField);
1408
- // CONCATENATED MODULE: ./packages/wonder-blocks-form/src/index.js
1409
1511
 
1410
1512
 
1411
1513