@khanacademy/wonder-blocks-form 3.1.10 → 3.1.12
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 +46 -0
- package/dist/components/checkbox-core.d.ts +16 -0
- package/dist/components/checkbox-core.js.flow +26 -0
- package/dist/components/checkbox-group.d.ts +84 -0
- package/dist/components/checkbox-group.js.flow +103 -0
- package/dist/components/checkbox.d.ts +83 -0
- package/dist/components/checkbox.js.flow +106 -0
- package/dist/components/choice-internal.d.ts +63 -0
- package/dist/components/choice-internal.js.flow +100 -0
- package/dist/components/choice.d.ts +127 -0
- package/dist/components/choice.js.flow +161 -0
- package/dist/components/field-heading.d.ts +50 -0
- package/dist/components/field-heading.js.flow +64 -0
- package/dist/components/group-styles.d.ts +3 -0
- package/dist/components/group-styles.js.flow +10 -0
- package/dist/components/labeled-text-field.d.ts +169 -0
- package/dist/components/labeled-text-field.js.flow +211 -0
- package/dist/components/radio-core.d.ts +15 -0
- package/dist/components/radio-core.js.flow +26 -0
- package/dist/components/radio-group.d.ts +85 -0
- package/dist/components/radio-group.js.flow +104 -0
- package/dist/components/radio.d.ts +68 -0
- package/dist/components/radio.js.flow +92 -0
- package/dist/components/text-field.d.ts +146 -0
- package/dist/components/text-field.js.flow +186 -0
- package/dist/es/index.js +258 -224
- package/dist/index.d.ts +7 -0
- package/dist/index.js +281 -249
- package/dist/index.js.flow +21 -2
- package/dist/util/types.d.ts +62 -0
- package/dist/util/types.js.flow +138 -0
- package/package.json +10 -10
- package/src/__tests__/{custom-snapshot.test.js → custom-snapshot.test.tsx} +10 -11
- package/src/components/__tests__/{checkbox-group.test.js → checkbox-group.test.tsx} +7 -7
- package/src/components/__tests__/{field-heading.test.js → field-heading.test.tsx} +2 -3
- package/src/components/__tests__/{labeled-text-field.test.js → labeled-text-field.test.tsx} +5 -6
- package/src/components/__tests__/{radio-group.test.js → radio-group.test.tsx} +10 -10
- package/src/components/__tests__/{text-field.test.js → text-field.test.tsx} +23 -19
- package/src/components/{checkbox-core.js → checkbox-core.tsx} +13 -16
- package/src/components/{checkbox-group.js → checkbox-group.tsx} +21 -24
- package/src/components/{checkbox.js → checkbox.tsx} +19 -33
- package/src/components/{choice-internal.js → choice-internal.tsx} +27 -41
- package/src/components/{choice.js → choice.tsx} +26 -39
- package/src/components/{field-heading.js → field-heading.tsx} +16 -23
- package/src/components/{group-styles.js → group-styles.ts} +0 -1
- package/src/components/{labeled-text-field.js → labeled-text-field.tsx} +55 -70
- package/src/components/{radio-core.js → radio-core.tsx} +14 -17
- package/src/components/{radio-group.js → radio-group.tsx} +21 -24
- package/src/components/{radio.js → radio.tsx} +19 -33
- package/src/components/{text-field.js → text-field.tsx} +53 -64
- package/src/index.ts +15 -0
- package/src/util/{types.js → types.ts} +32 -35
- package/tsconfig.json +19 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/__docs__/_overview_.stories.mdx +0 -15
- package/src/components/__docs__/checkbox-accessibility.stories.mdx +0 -147
- package/src/components/__docs__/checkbox-group.stories.js +0 -300
- package/src/components/__docs__/checkbox.stories.js +0 -167
- package/src/components/__docs__/choice.stories.js +0 -86
- package/src/components/__docs__/labeled-text-field.argtypes.js +0 -248
- package/src/components/__docs__/labeled-text-field.stories.js +0 -709
- package/src/components/__docs__/radio-group.stories.js +0 -217
- package/src/components/__docs__/radio.stories.js +0 -161
- package/src/components/__docs__/text-field.argtypes.js +0 -206
- package/src/components/__docs__/text-field.stories.js +0 -780
- package/src/index.js +0 -16
- /package/src/__tests__/__snapshots__/{custom-snapshot.test.js.snap → custom-snapshot.test.tsx.snap} +0 -0
package/dist/index.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _extends = require('@babel/runtime/helpers/extends');
|
|
6
5
|
var React = require('react');
|
|
7
|
-
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
8
6
|
var aphrodite = require('aphrodite');
|
|
9
7
|
var Color = require('@khanacademy/wonder-blocks-color');
|
|
10
8
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
@@ -17,30 +15,70 @@ var Icon = require('@khanacademy/wonder-blocks-icon');
|
|
|
17
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
16
|
|
|
19
17
|
function _interopNamespace(e) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
}
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
31
27
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n["default"] = e;
|
|
32
|
+
return Object.freeze(n);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
38
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
39
|
-
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
40
36
|
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
41
37
|
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
42
38
|
var Icon__default = /*#__PURE__*/_interopDefaultLegacy(Icon);
|
|
43
39
|
|
|
40
|
+
function _extends() {
|
|
41
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
42
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
43
|
+
var source = arguments[i];
|
|
44
|
+
for (var key in source) {
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
46
|
+
target[key] = source[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return target;
|
|
51
|
+
};
|
|
52
|
+
return _extends.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _setPrototypeOf(o, p) {
|
|
56
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
57
|
+
o.__proto__ = p;
|
|
58
|
+
return o;
|
|
59
|
+
};
|
|
60
|
+
return _setPrototypeOf(o, p);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _inheritsLoose(subClass, superClass) {
|
|
64
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
65
|
+
subClass.prototype.constructor = subClass;
|
|
66
|
+
_setPrototypeOf(subClass, superClass);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
70
|
+
if (source == null) return {};
|
|
71
|
+
var target = {};
|
|
72
|
+
var sourceKeys = Object.keys(source);
|
|
73
|
+
var key, i;
|
|
74
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
75
|
+
key = sourceKeys[i];
|
|
76
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
77
|
+
target[key] = source[key];
|
|
78
|
+
}
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
|
|
44
82
|
const _excluded$4 = ["checked", "disabled", "error", "groupName", "id", "testId", "hovered", "focused", "pressed", "waiting"];
|
|
45
83
|
const {
|
|
46
84
|
blue: blue$1,
|
|
@@ -55,37 +93,37 @@ const StyledInput$1 = wonderBlocksCore.addStyle("input");
|
|
|
55
93
|
const checkboxCheck = {
|
|
56
94
|
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"
|
|
57
95
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
96
|
+
let CheckboxCore = function (_React$Component) {
|
|
97
|
+
_inheritsLoose(CheckboxCore, _React$Component);
|
|
98
|
+
function CheckboxCore(...args) {
|
|
99
|
+
var _this;
|
|
100
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
101
|
+
_this.handleChange = () => {
|
|
63
102
|
return;
|
|
64
103
|
};
|
|
104
|
+
return _this;
|
|
65
105
|
}
|
|
66
|
-
|
|
67
|
-
render() {
|
|
106
|
+
var _proto = CheckboxCore.prototype;
|
|
107
|
+
_proto.render = function render() {
|
|
68
108
|
const _this$props = this.props,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
109
|
+
{
|
|
110
|
+
checked,
|
|
111
|
+
disabled,
|
|
112
|
+
error,
|
|
113
|
+
groupName,
|
|
114
|
+
id,
|
|
115
|
+
testId,
|
|
116
|
+
hovered,
|
|
117
|
+
focused,
|
|
118
|
+
pressed
|
|
119
|
+
} = _this$props,
|
|
120
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
|
|
82
121
|
const stateStyles = _generateStyles$1(checked, error);
|
|
83
|
-
|
|
84
122
|
const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles$1.disabled];
|
|
85
123
|
const props = {
|
|
86
124
|
"data-test-id": testId
|
|
87
125
|
};
|
|
88
|
-
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1,
|
|
126
|
+
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends({}, sharedProps, {
|
|
89
127
|
type: "checkbox",
|
|
90
128
|
"aria-invalid": error,
|
|
91
129
|
checked: checked,
|
|
@@ -100,9 +138,9 @@ class CheckboxCore extends React__namespace.Component {
|
|
|
100
138
|
size: "small",
|
|
101
139
|
style: sharedStyles$1.checkIcon
|
|
102
140
|
}));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
141
|
+
};
|
|
142
|
+
return CheckboxCore;
|
|
143
|
+
}(React__namespace.Component);
|
|
106
144
|
const size$1 = 16;
|
|
107
145
|
const sharedStyles$1 = aphrodite.StyleSheet.create({
|
|
108
146
|
inputReset: {
|
|
@@ -150,17 +188,13 @@ const colors$1 = {
|
|
|
150
188
|
}
|
|
151
189
|
};
|
|
152
190
|
const styles$5 = {};
|
|
153
|
-
|
|
154
191
|
const _generateStyles$1 = (checked, error) => {
|
|
155
192
|
const styleKey = `${String(checked)}-${String(error)}`;
|
|
156
|
-
|
|
157
193
|
if (styles$5[styleKey]) {
|
|
158
194
|
return styles$5[styleKey];
|
|
159
195
|
}
|
|
160
|
-
|
|
161
196
|
const palette = error ? colors$1.error : colors$1.default;
|
|
162
197
|
let newStyles = {};
|
|
163
|
-
|
|
164
198
|
if (checked) {
|
|
165
199
|
newStyles = {
|
|
166
200
|
default: {
|
|
@@ -193,7 +227,6 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
193
227
|
}
|
|
194
228
|
};
|
|
195
229
|
}
|
|
196
|
-
|
|
197
230
|
styles$5[styleKey] = aphrodite.StyleSheet.create(newStyles);
|
|
198
231
|
return styles$5[styleKey];
|
|
199
232
|
};
|
|
@@ -209,37 +242,37 @@ const {
|
|
|
209
242
|
offBlack50
|
|
210
243
|
} = Color__default["default"];
|
|
211
244
|
const StyledInput = wonderBlocksCore.addStyle("input");
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
245
|
+
let RadioCore = function (_React$Component) {
|
|
246
|
+
_inheritsLoose(RadioCore, _React$Component);
|
|
247
|
+
function RadioCore(...args) {
|
|
248
|
+
var _this;
|
|
249
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
250
|
+
_this.handleChange = () => {
|
|
217
251
|
return;
|
|
218
252
|
};
|
|
253
|
+
return _this;
|
|
219
254
|
}
|
|
220
|
-
|
|
221
|
-
render() {
|
|
255
|
+
var _proto = RadioCore.prototype;
|
|
256
|
+
_proto.render = function render() {
|
|
222
257
|
const _this$props = this.props,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
258
|
+
{
|
|
259
|
+
checked,
|
|
260
|
+
disabled,
|
|
261
|
+
error,
|
|
262
|
+
groupName,
|
|
263
|
+
id,
|
|
264
|
+
testId,
|
|
265
|
+
hovered,
|
|
266
|
+
focused,
|
|
267
|
+
pressed
|
|
268
|
+
} = _this$props,
|
|
269
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$3);
|
|
236
270
|
const stateStyles = _generateStyles(checked, error);
|
|
237
|
-
|
|
238
271
|
const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, stateStyles.default, !disabled && (pressed ? stateStyles.active : (hovered || focused) && stateStyles.focus), disabled && sharedStyles.disabled];
|
|
239
272
|
const props = {
|
|
240
273
|
"data-test-id": testId
|
|
241
274
|
};
|
|
242
|
-
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput,
|
|
275
|
+
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput, _extends({}, sharedProps, {
|
|
243
276
|
type: "radio",
|
|
244
277
|
"aria-invalid": error,
|
|
245
278
|
checked: checked,
|
|
@@ -251,9 +284,9 @@ class RadioCore extends React__namespace.Component {
|
|
|
251
284
|
}, props)), disabled && checked && React__namespace.createElement("span", {
|
|
252
285
|
style: disabledChecked
|
|
253
286
|
}));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
}
|
|
287
|
+
};
|
|
288
|
+
return RadioCore;
|
|
289
|
+
}(React__namespace.Component);
|
|
257
290
|
const size = 16;
|
|
258
291
|
const disabledChecked = {
|
|
259
292
|
position: "absolute",
|
|
@@ -306,17 +339,13 @@ const colors = {
|
|
|
306
339
|
}
|
|
307
340
|
};
|
|
308
341
|
const styles$4 = {};
|
|
309
|
-
|
|
310
342
|
const _generateStyles = (checked, error) => {
|
|
311
343
|
const styleKey = `${String(checked)}-${String(error)}`;
|
|
312
|
-
|
|
313
344
|
if (styles$4[styleKey]) {
|
|
314
345
|
return styles$4[styleKey];
|
|
315
346
|
}
|
|
316
|
-
|
|
317
347
|
const palette = error ? colors.error : colors.default;
|
|
318
348
|
let newStyles = {};
|
|
319
|
-
|
|
320
349
|
if (checked) {
|
|
321
350
|
newStyles = {
|
|
322
351
|
default: {
|
|
@@ -350,44 +379,41 @@ const _generateStyles = (checked, error) => {
|
|
|
350
379
|
}
|
|
351
380
|
};
|
|
352
381
|
}
|
|
353
|
-
|
|
354
382
|
styles$4[styleKey] = aphrodite.StyleSheet.create(newStyles);
|
|
355
383
|
return styles$4[styleKey];
|
|
356
384
|
};
|
|
357
385
|
|
|
358
386
|
const _excluded$2 = ["label", "description", "onChange", "style", "className", "variant"];
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
387
|
+
let ChoiceInternal = function (_React$Component) {
|
|
388
|
+
_inheritsLoose(ChoiceInternal, _React$Component);
|
|
389
|
+
function ChoiceInternal(...args) {
|
|
390
|
+
var _this;
|
|
391
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
392
|
+
_this.handleLabelClick = event => {
|
|
364
393
|
event.preventDefault();
|
|
365
394
|
};
|
|
366
|
-
|
|
367
|
-
this.handleClick = () => {
|
|
395
|
+
_this.handleClick = () => {
|
|
368
396
|
const {
|
|
369
397
|
checked,
|
|
370
398
|
onChange,
|
|
371
399
|
variant
|
|
372
|
-
} =
|
|
373
|
-
|
|
400
|
+
} = _this.props;
|
|
374
401
|
if (variant === "radio" && checked) {
|
|
375
402
|
return;
|
|
376
403
|
}
|
|
377
|
-
|
|
378
404
|
onChange(!checked);
|
|
379
405
|
};
|
|
406
|
+
return _this;
|
|
380
407
|
}
|
|
381
|
-
|
|
382
|
-
getChoiceCoreComponent() {
|
|
408
|
+
var _proto = ChoiceInternal.prototype;
|
|
409
|
+
_proto.getChoiceCoreComponent = function getChoiceCoreComponent() {
|
|
383
410
|
if (this.props.variant === "radio") {
|
|
384
411
|
return RadioCore;
|
|
385
412
|
} else {
|
|
386
413
|
return CheckboxCore;
|
|
387
414
|
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
getLabel() {
|
|
415
|
+
};
|
|
416
|
+
_proto.getLabel = function getLabel() {
|
|
391
417
|
const {
|
|
392
418
|
disabled,
|
|
393
419
|
id,
|
|
@@ -399,9 +425,8 @@ class ChoiceInternal extends React__namespace.Component {
|
|
|
399
425
|
htmlFor: id,
|
|
400
426
|
onClick: this.handleLabelClick
|
|
401
427
|
}, label));
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
getDescription(id) {
|
|
428
|
+
};
|
|
429
|
+
_proto.getDescription = function getDescription(id) {
|
|
405
430
|
const {
|
|
406
431
|
description
|
|
407
432
|
} = this.props;
|
|
@@ -409,19 +434,17 @@ class ChoiceInternal extends React__namespace.Component {
|
|
|
409
434
|
style: styles$3.description,
|
|
410
435
|
id: id
|
|
411
436
|
}, description);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
render() {
|
|
437
|
+
};
|
|
438
|
+
_proto.render = function render() {
|
|
415
439
|
const _this$props = this.props,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
440
|
+
{
|
|
441
|
+
label,
|
|
442
|
+
description,
|
|
443
|
+
style,
|
|
444
|
+
className,
|
|
445
|
+
variant
|
|
446
|
+
} = _this$props,
|
|
447
|
+
coreProps = _objectWithoutPropertiesLoose(_this$props, _excluded$2);
|
|
425
448
|
const ChoiceCore = this.getChoiceCoreComponent();
|
|
426
449
|
const ClickableBehavior = wonderBlocksClickable.getClickableBehavior();
|
|
427
450
|
return React__namespace.createElement(wonderBlocksCore.UniqueIDProvider, {
|
|
@@ -437,20 +460,20 @@ class ChoiceInternal extends React__namespace.Component {
|
|
|
437
460
|
onClick: this.handleClick,
|
|
438
461
|
role: variant
|
|
439
462
|
}, (state, childrenProps) => {
|
|
440
|
-
return React__namespace.createElement(wonderBlocksCore.View,
|
|
463
|
+
return React__namespace.createElement(wonderBlocksCore.View, _extends({
|
|
441
464
|
style: styles$3.wrapper
|
|
442
465
|
}, childrenProps, {
|
|
443
466
|
tabIndex: -1
|
|
444
|
-
}), React__namespace.createElement(ChoiceCore,
|
|
467
|
+
}), React__namespace.createElement(ChoiceCore, _extends({}, coreProps, state, {
|
|
445
468
|
"aria-describedby": descriptionId
|
|
446
469
|
})), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
447
470
|
size: Spacing__default["default"].xSmall_8
|
|
448
471
|
}), label && this.getLabel());
|
|
449
472
|
}), description && this.getDescription(descriptionId));
|
|
450
473
|
});
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
}
|
|
474
|
+
};
|
|
475
|
+
return ChoiceInternal;
|
|
476
|
+
}(React__namespace.Component);
|
|
454
477
|
ChoiceInternal.defaultProps = {
|
|
455
478
|
checked: false,
|
|
456
479
|
disabled: false,
|
|
@@ -476,54 +499,67 @@ const styles$3 = aphrodite.StyleSheet.create({
|
|
|
476
499
|
}
|
|
477
500
|
});
|
|
478
501
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
502
|
+
let Checkbox = function (_React$Component) {
|
|
503
|
+
_inheritsLoose(Checkbox, _React$Component);
|
|
504
|
+
function Checkbox() {
|
|
505
|
+
return _React$Component.apply(this, arguments) || this;
|
|
506
|
+
}
|
|
507
|
+
var _proto = Checkbox.prototype;
|
|
508
|
+
_proto.render = function render() {
|
|
509
|
+
return React__namespace.createElement(ChoiceInternal, _extends({
|
|
482
510
|
variant: "checkbox"
|
|
483
511
|
}, this.props));
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
}
|
|
512
|
+
};
|
|
513
|
+
return Checkbox;
|
|
514
|
+
}(React__namespace.Component);
|
|
487
515
|
Checkbox.defaultProps = {
|
|
488
516
|
disabled: false,
|
|
489
517
|
error: false
|
|
490
518
|
};
|
|
491
519
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
520
|
+
let Radio = function (_React$Component) {
|
|
521
|
+
_inheritsLoose(Radio, _React$Component);
|
|
522
|
+
function Radio() {
|
|
523
|
+
return _React$Component.apply(this, arguments) || this;
|
|
524
|
+
}
|
|
525
|
+
var _proto = Radio.prototype;
|
|
526
|
+
_proto.render = function render() {
|
|
527
|
+
return React__namespace.createElement(ChoiceInternal, _extends({
|
|
495
528
|
variant: "radio"
|
|
496
529
|
}, this.props));
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
}
|
|
530
|
+
};
|
|
531
|
+
return Radio;
|
|
532
|
+
}(React__namespace.Component);
|
|
500
533
|
Radio.defaultProps = {
|
|
501
534
|
disabled: false,
|
|
502
535
|
error: false
|
|
503
536
|
};
|
|
504
537
|
|
|
505
538
|
const _excluded$1 = ["value", "variant"];
|
|
506
|
-
|
|
507
|
-
|
|
539
|
+
let Choice = function (_React$Component) {
|
|
540
|
+
_inheritsLoose(Choice, _React$Component);
|
|
541
|
+
function Choice() {
|
|
542
|
+
return _React$Component.apply(this, arguments) || this;
|
|
543
|
+
}
|
|
544
|
+
var _proto = Choice.prototype;
|
|
545
|
+
_proto.getChoiceComponent = function getChoiceComponent(variant) {
|
|
508
546
|
if (variant === "checkbox") {
|
|
509
547
|
return Checkbox;
|
|
510
548
|
} else {
|
|
511
549
|
return Radio;
|
|
512
550
|
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
render() {
|
|
551
|
+
};
|
|
552
|
+
_proto.render = function render() {
|
|
516
553
|
const _this$props = this.props,
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
554
|
+
{
|
|
555
|
+
variant
|
|
556
|
+
} = _this$props,
|
|
557
|
+
remainingProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
|
|
522
558
|
const ChoiceComponent = this.getChoiceComponent(variant);
|
|
523
559
|
return React__namespace.createElement(ChoiceComponent, remainingProps);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
}
|
|
560
|
+
};
|
|
561
|
+
return Choice;
|
|
562
|
+
}(React__namespace.Component);
|
|
527
563
|
Choice.defaultProps = {
|
|
528
564
|
checked: false,
|
|
529
565
|
disabled: false,
|
|
@@ -554,13 +590,17 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
554
590
|
|
|
555
591
|
const StyledFieldset$1 = wonderBlocksCore.addStyle("fieldset");
|
|
556
592
|
const StyledLegend$1 = wonderBlocksCore.addStyle("legend");
|
|
557
|
-
|
|
558
|
-
|
|
593
|
+
let CheckboxGroup = function (_React$Component) {
|
|
594
|
+
_inheritsLoose(CheckboxGroup, _React$Component);
|
|
595
|
+
function CheckboxGroup() {
|
|
596
|
+
return _React$Component.apply(this, arguments) || this;
|
|
597
|
+
}
|
|
598
|
+
var _proto = CheckboxGroup.prototype;
|
|
599
|
+
_proto.handleChange = function handleChange(changedValue, originalCheckedState) {
|
|
559
600
|
const {
|
|
560
601
|
onChange,
|
|
561
602
|
selectedValues
|
|
562
603
|
} = this.props;
|
|
563
|
-
|
|
564
604
|
if (originalCheckedState) {
|
|
565
605
|
const index = selectedValues.indexOf(changedValue);
|
|
566
606
|
const updatedSelection = [].concat(selectedValues.slice(0, index), selectedValues.slice(index + 1));
|
|
@@ -568,9 +608,8 @@ class CheckboxGroup extends React__namespace.Component {
|
|
|
568
608
|
} else {
|
|
569
609
|
onChange([].concat(selectedValues, [changedValue]));
|
|
570
610
|
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
render() {
|
|
611
|
+
};
|
|
612
|
+
_proto.render = function render() {
|
|
574
613
|
const {
|
|
575
614
|
children,
|
|
576
615
|
label,
|
|
@@ -612,18 +651,22 @@ class CheckboxGroup extends React__namespace.Component {
|
|
|
612
651
|
variant: "checkbox"
|
|
613
652
|
});
|
|
614
653
|
})));
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
}
|
|
654
|
+
};
|
|
655
|
+
return CheckboxGroup;
|
|
656
|
+
}(React__namespace.Component);
|
|
618
657
|
|
|
619
658
|
const StyledFieldset = wonderBlocksCore.addStyle("fieldset");
|
|
620
659
|
const StyledLegend = wonderBlocksCore.addStyle("legend");
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
660
|
+
let RadioGroup = function (_React$Component) {
|
|
661
|
+
_inheritsLoose(RadioGroup, _React$Component);
|
|
662
|
+
function RadioGroup() {
|
|
663
|
+
return _React$Component.apply(this, arguments) || this;
|
|
624
664
|
}
|
|
625
|
-
|
|
626
|
-
|
|
665
|
+
var _proto = RadioGroup.prototype;
|
|
666
|
+
_proto.handleChange = function handleChange(changedValue) {
|
|
667
|
+
this.props.onChange(changedValue);
|
|
668
|
+
};
|
|
669
|
+
_proto.render = function render() {
|
|
627
670
|
const {
|
|
628
671
|
children,
|
|
629
672
|
label,
|
|
@@ -665,31 +708,30 @@ class RadioGroup extends React__namespace.Component {
|
|
|
665
708
|
variant: "radio"
|
|
666
709
|
});
|
|
667
710
|
})));
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
}
|
|
711
|
+
};
|
|
712
|
+
return RadioGroup;
|
|
713
|
+
}(React__namespace.Component);
|
|
671
714
|
|
|
672
715
|
const _excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
|
|
673
716
|
const defaultErrorMessage = "This field is required.";
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
717
|
+
let TextField = function (_React$Component) {
|
|
718
|
+
_inheritsLoose(TextField, _React$Component);
|
|
719
|
+
function TextField(props) {
|
|
720
|
+
var _this;
|
|
721
|
+
_this = _React$Component.call(this, props) || this;
|
|
722
|
+
_this.state = {
|
|
679
723
|
error: null,
|
|
680
724
|
focused: false
|
|
681
725
|
};
|
|
682
|
-
|
|
683
|
-
this.maybeValidate = newValue => {
|
|
726
|
+
_this.maybeValidate = newValue => {
|
|
684
727
|
const {
|
|
685
728
|
validate,
|
|
686
729
|
onValidate,
|
|
687
730
|
required
|
|
688
|
-
} =
|
|
689
|
-
|
|
731
|
+
} = _this.props;
|
|
690
732
|
if (validate) {
|
|
691
733
|
const maybeError = validate(newValue) || null;
|
|
692
|
-
|
|
734
|
+
_this.setState({
|
|
693
735
|
error: maybeError
|
|
694
736
|
}, () => {
|
|
695
737
|
if (onValidate) {
|
|
@@ -699,7 +741,7 @@ class TextField extends React__namespace.Component {
|
|
|
699
741
|
} else if (required) {
|
|
700
742
|
const requiredString = typeof required === "string" ? required : defaultErrorMessage;
|
|
701
743
|
const maybeError = newValue ? null : requiredString;
|
|
702
|
-
|
|
744
|
+
_this.setState({
|
|
703
745
|
error: maybeError
|
|
704
746
|
}, () => {
|
|
705
747
|
if (onValidate) {
|
|
@@ -708,21 +750,19 @@ class TextField extends React__namespace.Component {
|
|
|
708
750
|
});
|
|
709
751
|
}
|
|
710
752
|
};
|
|
711
|
-
|
|
712
|
-
this.handleChange = event => {
|
|
753
|
+
_this.handleChange = event => {
|
|
713
754
|
const {
|
|
714
755
|
onChange
|
|
715
|
-
} =
|
|
756
|
+
} = _this.props;
|
|
716
757
|
const newValue = event.target.value;
|
|
717
|
-
|
|
758
|
+
_this.maybeValidate(newValue);
|
|
718
759
|
onChange(newValue);
|
|
719
760
|
};
|
|
720
|
-
|
|
721
|
-
this.handleFocus = event => {
|
|
761
|
+
_this.handleFocus = event => {
|
|
722
762
|
const {
|
|
723
763
|
onFocus
|
|
724
|
-
} =
|
|
725
|
-
|
|
764
|
+
} = _this.props;
|
|
765
|
+
_this.setState({
|
|
726
766
|
focused: true
|
|
727
767
|
}, () => {
|
|
728
768
|
if (onFocus) {
|
|
@@ -730,12 +770,11 @@ class TextField extends React__namespace.Component {
|
|
|
730
770
|
}
|
|
731
771
|
});
|
|
732
772
|
};
|
|
733
|
-
|
|
734
|
-
this.handleBlur = event => {
|
|
773
|
+
_this.handleBlur = event => {
|
|
735
774
|
const {
|
|
736
775
|
onBlur
|
|
737
|
-
} =
|
|
738
|
-
|
|
776
|
+
} = _this.props;
|
|
777
|
+
_this.setState({
|
|
739
778
|
focused: false
|
|
740
779
|
}, () => {
|
|
741
780
|
if (onBlur) {
|
|
@@ -743,37 +782,35 @@ class TextField extends React__namespace.Component {
|
|
|
743
782
|
}
|
|
744
783
|
});
|
|
745
784
|
};
|
|
746
|
-
|
|
747
785
|
if (props.validate && props.value !== "") {
|
|
748
|
-
|
|
786
|
+
_this.state.error = props.validate(props.value) || null;
|
|
749
787
|
}
|
|
788
|
+
return _this;
|
|
750
789
|
}
|
|
751
|
-
|
|
752
|
-
componentDidMount() {
|
|
790
|
+
var _proto = TextField.prototype;
|
|
791
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
753
792
|
if (this.props.value !== "") {
|
|
754
793
|
this.maybeValidate(this.props.value);
|
|
755
794
|
}
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
render() {
|
|
795
|
+
};
|
|
796
|
+
_proto.render = function render() {
|
|
759
797
|
const _this$props = this.props,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
return React__namespace.createElement("input", _extends__default["default"]({
|
|
798
|
+
{
|
|
799
|
+
id,
|
|
800
|
+
type,
|
|
801
|
+
value,
|
|
802
|
+
disabled,
|
|
803
|
+
onKeyDown,
|
|
804
|
+
placeholder,
|
|
805
|
+
light,
|
|
806
|
+
style,
|
|
807
|
+
testId,
|
|
808
|
+
readOnly,
|
|
809
|
+
autoComplete,
|
|
810
|
+
forwardedRef
|
|
811
|
+
} = _this$props,
|
|
812
|
+
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
813
|
+
return React__namespace.createElement("input", _extends({
|
|
777
814
|
className: aphrodite.css([styles$1.input, wonderBlocksTypography.styles.LabelMedium, styles$1.default, disabled ? styles$1.disabled : this.state.focused ? [styles$1.focused, light && styles$1.defaultLight] : this.state.error && [styles$1.error, light && styles$1.errorLight], style && style]),
|
|
778
815
|
id: id,
|
|
779
816
|
type: type,
|
|
@@ -789,10 +826,9 @@ class TextField extends React__namespace.Component {
|
|
|
789
826
|
autoComplete: autoComplete,
|
|
790
827
|
ref: forwardedRef
|
|
791
828
|
}, otherProps));
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
|
|
829
|
+
};
|
|
830
|
+
return TextField;
|
|
831
|
+
}(React__namespace.Component);
|
|
796
832
|
TextField.defaultProps = {
|
|
797
833
|
type: "text",
|
|
798
834
|
disabled: false,
|
|
@@ -848,13 +884,18 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
848
884
|
boxShadow: `0px 0px 0px 1px ${Color__default["default"].red}, 0px 0px 0px 2px ${Color__default["default"].white}`
|
|
849
885
|
}
|
|
850
886
|
});
|
|
851
|
-
var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField,
|
|
887
|
+
var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends({}, props, {
|
|
852
888
|
forwardedRef: ref
|
|
853
889
|
})));
|
|
854
890
|
|
|
855
891
|
const StyledSpan = wonderBlocksCore.addStyle("span");
|
|
856
|
-
|
|
857
|
-
|
|
892
|
+
let FieldHeading = function (_React$Component) {
|
|
893
|
+
_inheritsLoose(FieldHeading, _React$Component);
|
|
894
|
+
function FieldHeading() {
|
|
895
|
+
return _React$Component.apply(this, arguments) || this;
|
|
896
|
+
}
|
|
897
|
+
var _proto = FieldHeading.prototype;
|
|
898
|
+
_proto.renderLabel = function renderLabel() {
|
|
858
899
|
const {
|
|
859
900
|
label,
|
|
860
901
|
id,
|
|
@@ -873,37 +914,31 @@ class FieldHeading extends React__namespace.Component {
|
|
|
873
914
|
}, label, required && requiredIcon), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
874
915
|
size: Spacing__default["default"].xxxSmall_4
|
|
875
916
|
}));
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
maybeRenderDescription() {
|
|
917
|
+
};
|
|
918
|
+
_proto.maybeRenderDescription = function maybeRenderDescription() {
|
|
879
919
|
const {
|
|
880
920
|
description,
|
|
881
921
|
testId
|
|
882
922
|
} = this.props;
|
|
883
|
-
|
|
884
923
|
if (!description) {
|
|
885
924
|
return null;
|
|
886
925
|
}
|
|
887
|
-
|
|
888
926
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
889
927
|
style: styles.description,
|
|
890
928
|
testId: testId && `${testId}-description`
|
|
891
929
|
}, description), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
892
930
|
size: Spacing__default["default"].xxxSmall_4
|
|
893
931
|
}));
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
maybeRenderError() {
|
|
932
|
+
};
|
|
933
|
+
_proto.maybeRenderError = function maybeRenderError() {
|
|
897
934
|
const {
|
|
898
935
|
error,
|
|
899
936
|
id,
|
|
900
937
|
testId
|
|
901
938
|
} = this.props;
|
|
902
|
-
|
|
903
939
|
if (!error) {
|
|
904
940
|
return null;
|
|
905
941
|
}
|
|
906
|
-
|
|
907
942
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
908
943
|
size: Spacing__default["default"].small_12
|
|
909
944
|
}), React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
@@ -912,9 +947,8 @@ class FieldHeading extends React__namespace.Component {
|
|
|
912
947
|
id: id && `${id}-error`,
|
|
913
948
|
testId: testId && `${testId}-error`
|
|
914
949
|
}, error));
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
render() {
|
|
950
|
+
};
|
|
951
|
+
_proto.render = function render() {
|
|
918
952
|
const {
|
|
919
953
|
field,
|
|
920
954
|
style
|
|
@@ -924,9 +958,9 @@ class FieldHeading extends React__namespace.Component {
|
|
|
924
958
|
}, this.renderLabel(), this.maybeRenderDescription(), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
925
959
|
size: Spacing__default["default"].xSmall_8
|
|
926
960
|
}), field, this.maybeRenderError());
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
}
|
|
961
|
+
};
|
|
962
|
+
return FieldHeading;
|
|
963
|
+
}(React__namespace.Component);
|
|
930
964
|
const styles = aphrodite.StyleSheet.create({
|
|
931
965
|
label: {
|
|
932
966
|
color: Color__default["default"].offBlack
|
|
@@ -942,15 +976,16 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
942
976
|
}
|
|
943
977
|
});
|
|
944
978
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
979
|
+
let LabeledTextField = function (_React$Component) {
|
|
980
|
+
_inheritsLoose(LabeledTextField, _React$Component);
|
|
981
|
+
function LabeledTextField(props) {
|
|
982
|
+
var _this;
|
|
983
|
+
_this = _React$Component.call(this, props) || this;
|
|
984
|
+
_this.handleValidate = errorMessage => {
|
|
950
985
|
const {
|
|
951
986
|
onValidate
|
|
952
|
-
} =
|
|
953
|
-
|
|
987
|
+
} = _this.props;
|
|
988
|
+
_this.setState({
|
|
954
989
|
error: errorMessage
|
|
955
990
|
}, () => {
|
|
956
991
|
if (onValidate) {
|
|
@@ -958,12 +993,11 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
958
993
|
}
|
|
959
994
|
});
|
|
960
995
|
};
|
|
961
|
-
|
|
962
|
-
this.handleFocus = event => {
|
|
996
|
+
_this.handleFocus = event => {
|
|
963
997
|
const {
|
|
964
998
|
onFocus
|
|
965
|
-
} =
|
|
966
|
-
|
|
999
|
+
} = _this.props;
|
|
1000
|
+
_this.setState({
|
|
967
1001
|
focused: true
|
|
968
1002
|
}, () => {
|
|
969
1003
|
if (onFocus) {
|
|
@@ -971,12 +1005,11 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
971
1005
|
}
|
|
972
1006
|
});
|
|
973
1007
|
};
|
|
974
|
-
|
|
975
|
-
this.handleBlur = event => {
|
|
1008
|
+
_this.handleBlur = event => {
|
|
976
1009
|
const {
|
|
977
1010
|
onBlur
|
|
978
|
-
} =
|
|
979
|
-
|
|
1011
|
+
} = _this.props;
|
|
1012
|
+
_this.setState({
|
|
980
1013
|
focused: false
|
|
981
1014
|
}, () => {
|
|
982
1015
|
if (onBlur) {
|
|
@@ -984,14 +1017,14 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
984
1017
|
}
|
|
985
1018
|
});
|
|
986
1019
|
};
|
|
987
|
-
|
|
988
|
-
this.state = {
|
|
1020
|
+
_this.state = {
|
|
989
1021
|
error: null,
|
|
990
1022
|
focused: false
|
|
991
1023
|
};
|
|
1024
|
+
return _this;
|
|
992
1025
|
}
|
|
993
|
-
|
|
994
|
-
render() {
|
|
1026
|
+
var _proto = LabeledTextField.prototype;
|
|
1027
|
+
_proto.render = function render() {
|
|
995
1028
|
const {
|
|
996
1029
|
id,
|
|
997
1030
|
type,
|
|
@@ -1046,16 +1079,15 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1046
1079
|
required: !!required,
|
|
1047
1080
|
error: !this.state.focused && this.state.error || ""
|
|
1048
1081
|
}));
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1082
|
+
};
|
|
1083
|
+
return LabeledTextField;
|
|
1084
|
+
}(React__namespace.Component);
|
|
1053
1085
|
LabeledTextField.defaultProps = {
|
|
1054
1086
|
type: "text",
|
|
1055
1087
|
disabled: false,
|
|
1056
1088
|
light: false
|
|
1057
1089
|
};
|
|
1058
|
-
var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField,
|
|
1090
|
+
var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField, _extends({}, props, {
|
|
1059
1091
|
forwardedRef: ref
|
|
1060
1092
|
})));
|
|
1061
1093
|
|