@khanacademy/wonder-blocks-form 2.4.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/es/index.js +11 -11
- package/dist/index.js +71 -75
- package/docs.md +5 -1
- package/package.json +2 -2
- package/src/__docs__/_overview_.stories.mdx +15 -0
- package/src/components/__docs__/checkbox-group.stories.js +0 -1
- package/src/components/__docs__/labeled-text-field.argtypes.js +2 -2
- package/src/components/__docs__/labeled-text-field.stories.js +25 -0
- package/src/components/__docs__/radio.stories.js +3 -2
- package/src/components/__tests__/checkbox-group.test.js +118 -67
- package/src/components/__tests__/field-heading.test.js +40 -0
- package/src/components/__tests__/radio-group.test.js +131 -58
- package/src/components/checkbox-group.js +5 -13
- package/src/components/checkbox.js +2 -2
- package/src/components/choice-internal.js +5 -3
- package/src/components/choice.js +2 -2
- package/src/components/field-heading.js +27 -43
- package/src/components/labeled-text-field.js +2 -3
- package/src/components/radio-group.js +2 -2
- package/src/components/radio.js +2 -2
- package/src/index.js +0 -2
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +0 -6126
- package/src/__tests__/generated-snapshot.test.js +0 -654
- package/src/components/checkbox-group.md +0 -200
- package/src/components/checkbox.md +0 -134
- package/src/components/field-heading.md +0 -43
- package/src/components/labeled-text-field.md +0 -535
- package/src/components/radio-group.md +0 -129
- package/src/components/radio.md +0 -26
- package/src/components/text-field.md +0 -770
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-form
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 3bae2aba: Remove Radio from wonder-blocks-form's exports so that RadioGroup is used
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- e91fb6c0: Update label, description, and error props in form components to accept React.Node
|
|
12
|
+
- Updated dependencies [3bae2aba]
|
|
13
|
+
- @khanacademy/wonder-blocks-icon@1.2.31
|
|
14
|
+
|
|
3
15
|
## 2.4.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -397,7 +397,7 @@ class ChoiceInternal extends React.Component {
|
|
|
397
397
|
mockOnFirstRender: true,
|
|
398
398
|
scope: "choice"
|
|
399
399
|
}, ids => {
|
|
400
|
-
const descriptionId = description
|
|
400
|
+
const descriptionId = description ? ids.get("description") : undefined;
|
|
401
401
|
return React.createElement(View, {
|
|
402
402
|
style: style,
|
|
403
403
|
className: className
|
|
@@ -555,11 +555,11 @@ class CheckboxGroup extends React.Component {
|
|
|
555
555
|
style: styles$2.fieldset
|
|
556
556
|
}, React.createElement(View, {
|
|
557
557
|
style: style
|
|
558
|
-
},
|
|
558
|
+
}, label && React.createElement(StyledLegend$1, {
|
|
559
559
|
style: styles$2.legend
|
|
560
|
-
}, React.createElement(LabelMedium, null, label))
|
|
560
|
+
}, React.createElement(LabelMedium, null, label)), description && React.createElement(LabelSmall, {
|
|
561
561
|
style: styles$2.description
|
|
562
|
-
}, description)
|
|
562
|
+
}, description), errorMessage && React.createElement(LabelSmall, {
|
|
563
563
|
style: styles$2.error
|
|
564
564
|
}, errorMessage), (label || description || errorMessage) && React.createElement(Strut, {
|
|
565
565
|
size: Spacing.small_12
|
|
@@ -832,12 +832,12 @@ class FieldHeading extends React.Component {
|
|
|
832
832
|
style: styles.required,
|
|
833
833
|
"aria-hidden": true
|
|
834
834
|
}, " ", "*");
|
|
835
|
-
return React.createElement(React.Fragment, null,
|
|
835
|
+
return React.createElement(React.Fragment, null, React.createElement(LabelMedium, {
|
|
836
836
|
style: styles.label,
|
|
837
837
|
tag: "label",
|
|
838
838
|
htmlFor: id && `${id}-field`,
|
|
839
839
|
testId: testId && `${testId}-label`
|
|
840
|
-
}, label, required && requiredIcon)
|
|
840
|
+
}, label, required && requiredIcon), React.createElement(Strut, {
|
|
841
841
|
size: Spacing.xxxSmall_4
|
|
842
842
|
}));
|
|
843
843
|
}
|
|
@@ -852,10 +852,10 @@ class FieldHeading extends React.Component {
|
|
|
852
852
|
return null;
|
|
853
853
|
}
|
|
854
854
|
|
|
855
|
-
return React.createElement(React.Fragment, null,
|
|
855
|
+
return React.createElement(React.Fragment, null, React.createElement(LabelSmall, {
|
|
856
856
|
style: styles.description,
|
|
857
857
|
testId: testId && `${testId}-description`
|
|
858
|
-
}, description)
|
|
858
|
+
}, description), React.createElement(Strut, {
|
|
859
859
|
size: Spacing.xxxSmall_4
|
|
860
860
|
}));
|
|
861
861
|
}
|
|
@@ -873,12 +873,12 @@ class FieldHeading extends React.Component {
|
|
|
873
873
|
|
|
874
874
|
return React.createElement(React.Fragment, null, React.createElement(Strut, {
|
|
875
875
|
size: Spacing.small_12
|
|
876
|
-
}),
|
|
876
|
+
}), React.createElement(LabelSmall, {
|
|
877
877
|
style: styles.error,
|
|
878
878
|
role: "alert",
|
|
879
879
|
id: id && `${id}-error`,
|
|
880
880
|
testId: testId && `${testId}-error`
|
|
881
|
-
}, error)
|
|
881
|
+
}, error));
|
|
882
882
|
}
|
|
883
883
|
|
|
884
884
|
render() {
|
|
@@ -1026,4 +1026,4 @@ const LabeledTextField = React.forwardRef((props, ref) => React.createElement(La
|
|
|
1026
1026
|
forwardedRef: ref
|
|
1027
1027
|
})));
|
|
1028
1028
|
|
|
1029
|
-
export { Checkbox, CheckboxGroup, Choice, LabeledTextField,
|
|
1029
|
+
export { Checkbox, CheckboxGroup, Choice, LabeledTextField, RadioGroup, TextField };
|
package/dist/index.js
CHANGED
|
@@ -197,7 +197,7 @@ module.exports = require("@khanacademy/wonder-blocks-layout");
|
|
|
197
197
|
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
198
198
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
|
199
199
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
200
|
-
/* harmony import */ var _choice_internal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
200
|
+
/* harmony import */ var _choice_internal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
|
|
201
201
|
|
|
202
202
|
|
|
203
203
|
// Keep synced with ChoiceComponentProps in ../util/types.js
|
|
@@ -240,41 +240,6 @@ Checkbox.defaultProps = {
|
|
|
240
240
|
/* 10 */
|
|
241
241
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
242
242
|
|
|
243
|
-
"use strict";
|
|
244
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Radio; });
|
|
245
|
-
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
246
|
-
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
247
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
|
248
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
249
|
-
/* harmony import */ var _choice_internal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// Keep synced with ChoiceComponentProps in ../util/types.js
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* 🔘 A nicely styled radio button for all your non-AMFM radio button needs. Can
|
|
256
|
-
* optionally take label and description props.
|
|
257
|
-
*
|
|
258
|
-
* This component should not really be used by itself because radio buttons are
|
|
259
|
-
* often grouped together. See RadioGroup.
|
|
260
|
-
*/
|
|
261
|
-
class Radio extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
262
|
-
render() {
|
|
263
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_choice_internal_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"], _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({
|
|
264
|
-
variant: "radio"
|
|
265
|
-
}, this.props));
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
Radio.defaultProps = {
|
|
270
|
-
disabled: false,
|
|
271
|
-
error: false
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
/***/ }),
|
|
275
|
-
/* 11 */
|
|
276
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
277
|
-
|
|
278
243
|
"use strict";
|
|
279
244
|
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
280
245
|
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
@@ -514,7 +479,7 @@ const TextField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["forwardRef"](
|
|
|
514
479
|
/* harmony default export */ __webpack_exports__["a"] = (TextField);
|
|
515
480
|
|
|
516
481
|
/***/ }),
|
|
517
|
-
/*
|
|
482
|
+
/* 11 */
|
|
518
483
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
519
484
|
|
|
520
485
|
"use strict";
|
|
@@ -529,7 +494,7 @@ const TextField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["forwardRef"](
|
|
|
529
494
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
530
495
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
531
496
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
532
|
-
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
497
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(16);
|
|
533
498
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__);
|
|
534
499
|
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8);
|
|
535
500
|
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_6__);
|
|
@@ -537,8 +502,8 @@ const TextField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["forwardRef"](
|
|
|
537
502
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7__);
|
|
538
503
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4);
|
|
539
504
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8__);
|
|
540
|
-
/* harmony import */ var _checkbox_core_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
|
|
541
|
-
/* harmony import */ var _radio_core_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(
|
|
505
|
+
/* harmony import */ var _checkbox_core_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(17);
|
|
506
|
+
/* harmony import */ var _radio_core_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(19);
|
|
542
507
|
|
|
543
508
|
|
|
544
509
|
|
|
@@ -633,7 +598,7 @@ class ChoiceInternal extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
|
633
598
|
mockOnFirstRender: true,
|
|
634
599
|
scope: "choice"
|
|
635
600
|
}, ids => {
|
|
636
|
-
const descriptionId = description
|
|
601
|
+
const descriptionId = description ? ids.get("description") : undefined;
|
|
637
602
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["View"], {
|
|
638
603
|
style: style,
|
|
639
604
|
className: className
|
|
@@ -690,7 +655,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
690
655
|
});
|
|
691
656
|
|
|
692
657
|
/***/ }),
|
|
693
|
-
/*
|
|
658
|
+
/* 12 */
|
|
694
659
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
695
660
|
|
|
696
661
|
"use strict";
|
|
@@ -698,7 +663,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
698
663
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
699
664
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
700
665
|
/* harmony import */ var _checkbox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
701
|
-
/* harmony import */ var _radio_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
666
|
+
/* harmony import */ var _radio_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
|
|
702
667
|
|
|
703
668
|
|
|
704
669
|
|
|
@@ -798,7 +763,7 @@ Choice.defaultProps = {
|
|
|
798
763
|
};
|
|
799
764
|
|
|
800
765
|
/***/ }),
|
|
801
|
-
/*
|
|
766
|
+
/* 13 */
|
|
802
767
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
803
768
|
|
|
804
769
|
"use strict";
|
|
@@ -888,11 +853,11 @@ class CheckboxGroup extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
888
853
|
style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].fieldset
|
|
889
854
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_1__["View"], {
|
|
890
855
|
style: style
|
|
891
|
-
},
|
|
856
|
+
}, label && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledLegend, {
|
|
892
857
|
style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].legend
|
|
893
|
-
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelMedium"], null, label))
|
|
858
|
+
}, /*#__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"], {
|
|
894
859
|
style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].description
|
|
895
|
-
}, description)
|
|
860
|
+
}, description), errorMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"], {
|
|
896
861
|
style: _group_styles_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].error
|
|
897
862
|
}, errorMessage), (label || description || errorMessage) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["Strut"], {
|
|
898
863
|
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.small_12
|
|
@@ -918,7 +883,7 @@ class CheckboxGroup extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
918
883
|
}
|
|
919
884
|
|
|
920
885
|
/***/ }),
|
|
921
|
-
/*
|
|
886
|
+
/* 14 */
|
|
922
887
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
923
888
|
|
|
924
889
|
"use strict";
|
|
@@ -1029,7 +994,7 @@ class RadioGroup extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1029
994
|
}
|
|
1030
995
|
|
|
1031
996
|
/***/ }),
|
|
1032
|
-
/*
|
|
997
|
+
/* 15 */
|
|
1033
998
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1034
999
|
|
|
1035
1000
|
"use strict";
|
|
@@ -1040,7 +1005,7 @@ class RadioGroup extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1040
1005
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
1041
1006
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__);
|
|
1042
1007
|
/* harmony import */ var _field_heading_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21);
|
|
1043
|
-
/* harmony import */ var _text_field_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
1008
|
+
/* harmony import */ var _text_field_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
|
|
1044
1009
|
|
|
1045
1010
|
|
|
1046
1011
|
|
|
@@ -1193,13 +1158,13 @@ const LabeledTextField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["forwar
|
|
|
1193
1158
|
/* harmony default export */ __webpack_exports__["a"] = (LabeledTextField);
|
|
1194
1159
|
|
|
1195
1160
|
/***/ }),
|
|
1196
|
-
/*
|
|
1161
|
+
/* 16 */
|
|
1197
1162
|
/***/ (function(module, exports) {
|
|
1198
1163
|
|
|
1199
1164
|
module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
1200
1165
|
|
|
1201
1166
|
/***/ }),
|
|
1202
|
-
/*
|
|
1167
|
+
/* 17 */
|
|
1203
1168
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1204
1169
|
|
|
1205
1170
|
"use strict";
|
|
@@ -1214,7 +1179,7 @@ module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
|
1214
1179
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
1215
1180
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
1216
1181
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
1217
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
1182
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(18);
|
|
1218
1183
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__);
|
|
1219
1184
|
|
|
1220
1185
|
|
|
@@ -1388,13 +1353,13 @@ const _generateStyles = (checked, error) => {
|
|
|
1388
1353
|
};
|
|
1389
1354
|
|
|
1390
1355
|
/***/ }),
|
|
1391
|
-
/*
|
|
1356
|
+
/* 18 */
|
|
1392
1357
|
/***/ (function(module, exports) {
|
|
1393
1358
|
|
|
1394
1359
|
module.exports = require("@khanacademy/wonder-blocks-icon");
|
|
1395
1360
|
|
|
1396
1361
|
/***/ }),
|
|
1397
|
-
/*
|
|
1362
|
+
/* 19 */
|
|
1398
1363
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1399
1364
|
|
|
1400
1365
|
"use strict";
|
|
@@ -1580,6 +1545,41 @@ const _generateStyles = (checked, error) => {
|
|
|
1580
1545
|
return styles[styleKey];
|
|
1581
1546
|
};
|
|
1582
1547
|
|
|
1548
|
+
/***/ }),
|
|
1549
|
+
/* 20 */
|
|
1550
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1551
|
+
|
|
1552
|
+
"use strict";
|
|
1553
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Radio; });
|
|
1554
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
1555
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
1556
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
|
1557
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
1558
|
+
/* harmony import */ var _choice_internal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
// Keep synced with ChoiceComponentProps in ../util/types.js
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* 🔘 A nicely styled radio button for all your non-AMFM radio button needs. Can
|
|
1565
|
+
* optionally take label and description props.
|
|
1566
|
+
*
|
|
1567
|
+
* This component should not really be used by itself because radio buttons are
|
|
1568
|
+
* often grouped together. See RadioGroup.
|
|
1569
|
+
*/
|
|
1570
|
+
class Radio extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
1571
|
+
render() {
|
|
1572
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_choice_internal_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"], _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({
|
|
1573
|
+
variant: "radio"
|
|
1574
|
+
}, this.props));
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
}
|
|
1578
|
+
Radio.defaultProps = {
|
|
1579
|
+
disabled: false,
|
|
1580
|
+
error: false
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
1583
|
/***/ }),
|
|
1584
1584
|
/* 21 */
|
|
1585
1585
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
@@ -1625,12 +1625,12 @@ class FieldHeading extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1625
1625
|
style: styles.required,
|
|
1626
1626
|
"aria-hidden": true
|
|
1627
1627
|
}, " ", "*");
|
|
1628
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null,
|
|
1628
|
+
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_typography__WEBPACK_IMPORTED_MODULE_6__["LabelMedium"], {
|
|
1629
1629
|
style: styles.label,
|
|
1630
1630
|
tag: "label",
|
|
1631
1631
|
htmlFor: id && `${id}-field`,
|
|
1632
1632
|
testId: testId && `${testId}-label`
|
|
1633
|
-
}, label, required && requiredIcon)
|
|
1633
|
+
}, label, required && requiredIcon), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["Strut"], {
|
|
1634
1634
|
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xxxSmall_4
|
|
1635
1635
|
}));
|
|
1636
1636
|
}
|
|
@@ -1645,10 +1645,10 @@ class FieldHeading extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1645
1645
|
return null;
|
|
1646
1646
|
}
|
|
1647
1647
|
|
|
1648
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null,
|
|
1648
|
+
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_typography__WEBPACK_IMPORTED_MODULE_6__["LabelSmall"], {
|
|
1649
1649
|
style: styles.description,
|
|
1650
1650
|
testId: testId && `${testId}-description`
|
|
1651
|
-
}, description)
|
|
1651
|
+
}, description), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["Strut"], {
|
|
1652
1652
|
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xxxSmall_4
|
|
1653
1653
|
}));
|
|
1654
1654
|
}
|
|
@@ -1666,12 +1666,12 @@ class FieldHeading extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1666
1666
|
|
|
1667
1667
|
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"], {
|
|
1668
1668
|
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.small_12
|
|
1669
|
-
}),
|
|
1669
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelSmall"], {
|
|
1670
1670
|
style: styles.error,
|
|
1671
1671
|
role: "alert",
|
|
1672
1672
|
id: id && `${id}-error`,
|
|
1673
1673
|
testId: testId && `${testId}-error`
|
|
1674
|
-
}, error)
|
|
1674
|
+
}, error));
|
|
1675
1675
|
}
|
|
1676
1676
|
|
|
1677
1677
|
render() {
|
|
@@ -1711,24 +1711,20 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1711
1711
|
/* harmony import */ var _components_checkbox_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
|
|
1712
1712
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _components_checkbox_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
1713
1713
|
|
|
1714
|
-
/* harmony import */ var
|
|
1715
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1716
|
-
|
|
1717
|
-
/* harmony import */ var _components_choice_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
|
|
1718
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Choice", function() { return _components_choice_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
1719
|
-
|
|
1720
|
-
/* harmony import */ var _components_checkbox_group_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
|
|
1721
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _components_checkbox_group_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
1714
|
+
/* harmony import */ var _components_choice_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
|
|
1715
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Choice", function() { return _components_choice_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
1722
1716
|
|
|
1723
|
-
/* harmony import */ var
|
|
1724
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1717
|
+
/* harmony import */ var _components_checkbox_group_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
|
|
1718
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _components_checkbox_group_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
1725
1719
|
|
|
1726
|
-
/* harmony import */ var
|
|
1727
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1720
|
+
/* harmony import */ var _components_radio_group_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
|
|
1721
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _components_radio_group_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
1728
1722
|
|
|
1729
|
-
/* harmony import */ var
|
|
1730
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
1723
|
+
/* harmony import */ var _components_text_field_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
|
|
1724
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextField", function() { return _components_text_field_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
|
|
1731
1725
|
|
|
1726
|
+
/* harmony import */ var _components_labeled_text_field_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(15);
|
|
1727
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LabeledTextField", function() { return _components_labeled_text_field_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
|
|
1732
1728
|
|
|
1733
1729
|
|
|
1734
1730
|
|
package/docs.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-form",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Form components for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@khanacademy/wonder-blocks-clickable": "^2.3.1",
|
|
20
20
|
"@khanacademy/wonder-blocks-color": "^1.2.0",
|
|
21
21
|
"@khanacademy/wonder-blocks-core": "^4.4.0",
|
|
22
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
22
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.31",
|
|
23
23
|
"@khanacademy/wonder-blocks-layout": "^1.4.11",
|
|
24
24
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
25
25
|
"@khanacademy/wonder-blocks-typography": "^1.1.33"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {Meta} from "@storybook/addon-docs";
|
|
2
|
+
|
|
3
|
+
<Meta
|
|
4
|
+
title="Form / Overview"
|
|
5
|
+
parameters={{
|
|
6
|
+
chromatic: {
|
|
7
|
+
disableSnapshot: true,
|
|
8
|
+
},
|
|
9
|
+
}}
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
# Form
|
|
13
|
+
|
|
14
|
+
`wonder-blocks-form` provides building blocks form Form components, including
|
|
15
|
+
TextField, Choice, Checkbox, RadioButton, etc.
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
type: {required: true},
|
|
35
35
|
table: {
|
|
36
36
|
type: {
|
|
37
|
-
summary: "
|
|
37
|
+
summary: "React.Node",
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
control: {
|
|
@@ -45,7 +45,7 @@ export default {
|
|
|
45
45
|
description: "Provide a description for the TextField.",
|
|
46
46
|
table: {
|
|
47
47
|
type: {
|
|
48
|
-
summary: "
|
|
48
|
+
summary: "React.Node",
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
control: {
|
|
@@ -9,6 +9,7 @@ import Color from "@khanacademy/wonder-blocks-color";
|
|
|
9
9
|
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
10
10
|
import {Strut} from "@khanacademy/wonder-blocks-layout";
|
|
11
11
|
import Button from "@khanacademy/wonder-blocks-button";
|
|
12
|
+
import Link from "@khanacademy/wonder-blocks-link";
|
|
12
13
|
|
|
13
14
|
import type {StoryComponentType} from "@storybook/react";
|
|
14
15
|
|
|
@@ -528,6 +529,30 @@ CustomStyle.parameters = {
|
|
|
528
529
|
},
|
|
529
530
|
};
|
|
530
531
|
|
|
532
|
+
export const WithMarkup: StoryComponentType = (args) => {
|
|
533
|
+
return (
|
|
534
|
+
<LabeledTextField
|
|
535
|
+
{...args}
|
|
536
|
+
label="Name"
|
|
537
|
+
description={
|
|
538
|
+
<span>
|
|
539
|
+
Description with <strong>strong</strong> text and a{" "}
|
|
540
|
+
<Link href="/path/to/resource">link</Link>
|
|
541
|
+
</span>
|
|
542
|
+
}
|
|
543
|
+
/>
|
|
544
|
+
);
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
WithMarkup.parameters = {
|
|
548
|
+
docs: {
|
|
549
|
+
storyDescription: `\`LabeledTextField\`'s \`label\` and \`description\` props
|
|
550
|
+
can accept \`React.Node\`s. This is helpful when you need to decorate or use
|
|
551
|
+
specific elements in your form field (e.g. including Popovers, Tooltips or
|
|
552
|
+
emphasized text)`,
|
|
553
|
+
},
|
|
554
|
+
};
|
|
555
|
+
|
|
531
556
|
export const Ref: StoryComponentType = () => {
|
|
532
557
|
const [value, setValue] = React.useState("Khan");
|
|
533
558
|
const inputRef = React.createRef();
|
|
@@ -3,15 +3,16 @@ import * as React from "react";
|
|
|
3
3
|
import {StyleSheet} from "aphrodite";
|
|
4
4
|
|
|
5
5
|
import {View} from "@khanacademy/wonder-blocks-core";
|
|
6
|
-
import {Radio} from "@khanacademy/wonder-blocks-form";
|
|
7
6
|
import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
|
|
8
7
|
import type {StoryComponentType} from "@storybook/react";
|
|
9
8
|
|
|
10
9
|
import ComponentInfo from "../../../../../.storybook/components/component-info.js";
|
|
11
10
|
import {name, version} from "../../../package.json";
|
|
12
11
|
|
|
12
|
+
import Radio from "../radio.js";
|
|
13
|
+
|
|
13
14
|
export default {
|
|
14
|
-
title: "Form / Radio",
|
|
15
|
+
title: "Form / Radio (internal)",
|
|
15
16
|
component: Radio,
|
|
16
17
|
parameters: {
|
|
17
18
|
componentSubtitle: ((
|