@khanacademy/wonder-blocks-form 7.0.2 → 7.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Khan Academy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/es/index.js CHANGED
@@ -365,28 +365,29 @@ const ChoiceInternal = React.forwardRef(function ChoiceInternal(props, ref) {
365
365
  }, description);
366
366
  };
367
367
  const ChoiceCore = getChoiceCoreComponent();
368
- return React.createElement(Id, {
369
- id: id
370
- }, uniqueId => {
371
- const descriptionId = description ? `${uniqueId}-description` : undefined;
372
- return React.createElement(View, {
373
- style: style,
374
- className: className
375
- }, React.createElement(View, {
376
- style: styles$4.wrapper,
377
- tabIndex: -1
378
- }, React.createElement(ChoiceCore, _extends({}, coreProps, {
379
- id: uniqueId,
380
- checked: checked,
381
- "aria-describedby": descriptionId,
382
- onClick: handleClick,
383
- disabled: disabled,
384
- error: error,
385
- ref: ref
386
- })), React.createElement(Strut, {
387
- size: spacing.xSmall_8
388
- }), label && getLabel(uniqueId)), description && getDescription(descriptionId));
389
- });
368
+ return (React.createElement(Id, {
369
+ id: id
370
+ }, uniqueId => {
371
+ const descriptionId = description ? `${uniqueId}-description` : undefined;
372
+ return React.createElement(View, {
373
+ style: style,
374
+ className: className
375
+ }, React.createElement(View, {
376
+ style: styles$4.wrapper,
377
+ tabIndex: -1
378
+ }, React.createElement(ChoiceCore, _extends({}, coreProps, {
379
+ id: uniqueId,
380
+ checked: checked,
381
+ "aria-describedby": descriptionId,
382
+ onClick: handleClick,
383
+ disabled: disabled,
384
+ error: error,
385
+ ref: ref
386
+ })), React.createElement(Strut, {
387
+ size: spacing.xSmall_8
388
+ }), label && getLabel(uniqueId)), description && getDescription(descriptionId));
389
+ })
390
+ );
390
391
  });
391
392
  const styles$4 = StyleSheet.create({
392
393
  wrapper: {
@@ -987,7 +988,7 @@ var labeledTextField = React.forwardRef((props, ref) => React.createElement(Labe
987
988
  })));
988
989
 
989
990
  const _excluded = ["onChange", "value", "placeholder", "disabled", "id", "testId", "style", "readOnly", "autoComplete", "name", "className", "autoFocus", "rows", "spellCheck", "wrap", "minLength", "maxLength", "onClick", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "validate", "onValidate", "required", "resizeType", "rootStyle", "error", "instantValidation"];
990
- const StyledTextArea = addStyle("textarea");
991
+ const StyledTextarea = addStyle("textarea");
991
992
  const TextArea = React.forwardRef(function TextArea(props, ref) {
992
993
  const {
993
994
  onChange,
@@ -1051,7 +1052,7 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
1051
1052
  style: [{
1052
1053
  width: "100%"
1053
1054
  }, rootStyle]
1054
- }, React.createElement(StyledTextArea, _extends({
1055
+ }, React.createElement(StyledTextarea, _extends({
1055
1056
  id: uniqueId,
1056
1057
  "data-testid": testId,
1057
1058
  ref: ref,
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var _extends = require('@babel/runtime/helpers/extends');
6
4
  var React = require('react');
7
5
  var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
@@ -14,10 +12,7 @@ var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
14
12
  var checkIcon = require('@phosphor-icons/core/bold/check-bold.svg');
15
13
  var minusIcon = require('@phosphor-icons/core/bold/minus-bold.svg');
16
14
 
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
-
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
15
+ function _interopNamespaceDefault(e) {
21
16
  var n = Object.create(null);
22
17
  if (e) {
23
18
  Object.keys(e).forEach(function (k) {
@@ -30,15 +25,11 @@ function _interopNamespace(e) {
30
25
  }
31
26
  });
32
27
  }
33
- n["default"] = e;
28
+ n.default = e;
34
29
  return Object.freeze(n);
35
30
  }
36
31
 
37
- var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
38
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
- var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
40
- var checkIcon__default = /*#__PURE__*/_interopDefaultLegacy(checkIcon);
41
- var minusIcon__default = /*#__PURE__*/_interopDefaultLegacy(minusIcon);
32
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
42
33
 
43
34
  const _excluded$7 = ["checked", "disabled", "error", "groupName", "id", "testId"];
44
35
  function mapCheckedToAriaChecked(value) {
@@ -63,7 +54,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
63
54
  id,
64
55
  testId
65
56
  } = props,
66
- sharedProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$7);
57
+ sharedProps = _objectWithoutPropertiesLoose(props, _excluded$7);
67
58
  const innerRef = React__namespace.useRef(null);
68
59
  React__namespace.useEffect(() => {
69
60
  if (innerRef.current != null) {
@@ -77,7 +68,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
77
68
  const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, !disabled && stateStyles.default, disabled && sharedStyles$1.disabled];
78
69
  const checkboxIcon = React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
79
70
  color: disabled ? wonderBlocksTokens.semanticColor.icon.disabled : wonderBlocksTokens.semanticColor.icon.inverse,
80
- icon: checked ? checkIcon__default["default"] : minusIcon__default["default"],
71
+ icon: checked ? checkIcon : minusIcon,
81
72
  size: "small",
82
73
  style: [sharedStyles$1.checkboxIcon, {
83
74
  width: checkSize,
@@ -85,7 +76,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
85
76
  }]
86
77
  });
87
78
  const ariaChecked = mapCheckedToAriaChecked(checked);
88
- return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$2, _extends__default["default"]({}, sharedProps, {
79
+ return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$2, _extends({}, sharedProps, {
89
80
  ref: node => {
90
81
  innerRef.current = node;
91
82
  if (typeof ref === "function") {
@@ -223,10 +214,10 @@ const RadioCore = React__namespace.forwardRef(function RadioCore(props, ref) {
223
214
  id,
224
215
  testId
225
216
  } = props,
226
- sharedProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$6);
217
+ sharedProps = _objectWithoutPropertiesLoose(props, _excluded$6);
227
218
  const stateStyles = _generateStyles(checked, error);
228
219
  const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, !disabled && stateStyles.default, disabled && sharedStyles.disabled];
229
- return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends__default["default"]({}, sharedProps, {
220
+ return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends({}, sharedProps, {
230
221
  type: "radio",
231
222
  "aria-invalid": error,
232
223
  checked: checked != null ? checked : undefined,
@@ -366,7 +357,7 @@ const ChoiceInternal = React__namespace.forwardRef(function ChoiceInternal(props
366
357
  className,
367
358
  variant
368
359
  } = props,
369
- coreProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$5);
360
+ coreProps = _objectWithoutPropertiesLoose(props, _excluded$5);
370
361
  const handleClick = () => {
371
362
  if (variant === "radio" && checked) {
372
363
  return;
@@ -394,28 +385,29 @@ const ChoiceInternal = React__namespace.forwardRef(function ChoiceInternal(props
394
385
  }, description);
395
386
  };
396
387
  const ChoiceCore = getChoiceCoreComponent();
397
- return React__namespace.createElement(wonderBlocksCore.Id, {
398
- id: id
399
- }, uniqueId => {
400
- const descriptionId = description ? `${uniqueId}-description` : undefined;
401
- return React__namespace.createElement(wonderBlocksCore.View, {
402
- style: style,
403
- className: className
404
- }, React__namespace.createElement(wonderBlocksCore.View, {
405
- style: styles$4.wrapper,
406
- tabIndex: -1
407
- }, React__namespace.createElement(ChoiceCore, _extends__default["default"]({}, coreProps, {
408
- id: uniqueId,
409
- checked: checked,
410
- "aria-describedby": descriptionId,
411
- onClick: handleClick,
412
- disabled: disabled,
413
- error: error,
414
- ref: ref
415
- })), React__namespace.createElement(wonderBlocksLayout.Strut, {
416
- size: wonderBlocksTokens.spacing.xSmall_8
417
- }), label && getLabel(uniqueId)), description && getDescription(descriptionId));
418
- });
388
+ return (React__namespace.createElement(wonderBlocksCore.Id, {
389
+ id: id
390
+ }, uniqueId => {
391
+ const descriptionId = description ? `${uniqueId}-description` : undefined;
392
+ return React__namespace.createElement(wonderBlocksCore.View, {
393
+ style: style,
394
+ className: className
395
+ }, React__namespace.createElement(wonderBlocksCore.View, {
396
+ style: styles$4.wrapper,
397
+ tabIndex: -1
398
+ }, React__namespace.createElement(ChoiceCore, _extends({}, coreProps, {
399
+ id: uniqueId,
400
+ checked: checked,
401
+ "aria-describedby": descriptionId,
402
+ onClick: handleClick,
403
+ disabled: disabled,
404
+ error: error,
405
+ ref: ref
406
+ })), React__namespace.createElement(wonderBlocksLayout.Strut, {
407
+ size: wonderBlocksTokens.spacing.xSmall_8
408
+ }), label && getLabel(uniqueId)), description && getDescription(descriptionId));
409
+ })
410
+ );
419
411
  });
420
412
  const styles$4 = aphrodite.StyleSheet.create({
421
413
  wrapper: {
@@ -441,7 +433,7 @@ const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
441
433
  disabled = false,
442
434
  error = false
443
435
  } = props;
444
- return React__namespace.createElement(ChoiceInternal, _extends__default["default"]({}, props, {
436
+ return React__namespace.createElement(ChoiceInternal, _extends({}, props, {
445
437
  variant: "checkbox",
446
438
  disabled: disabled,
447
439
  error: error,
@@ -455,8 +447,8 @@ const Radio = React__namespace.forwardRef(function Radio(props, ref) {
455
447
  disabled = false,
456
448
  error = false
457
449
  } = props,
458
- otherProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$4);
459
- return React__namespace.createElement(ChoiceInternal, _extends__default["default"]({}, otherProps, {
450
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded$4);
451
+ return React__namespace.createElement(ChoiceInternal, _extends({}, otherProps, {
460
452
  variant: "radio",
461
453
  disabled: disabled,
462
454
  error: error,
@@ -472,7 +464,7 @@ const Choice = React__namespace.forwardRef(function Choice(props, ref) {
472
464
  onChange = () => {},
473
465
  variant
474
466
  } = props,
475
- remainingProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$3);
467
+ remainingProps = _objectWithoutPropertiesLoose(props, _excluded$3);
476
468
  const getChoiceComponent = variant => {
477
469
  if (variant === "checkbox") {
478
470
  return Checkbox;
@@ -481,7 +473,7 @@ const Choice = React__namespace.forwardRef(function Choice(props, ref) {
481
473
  }
482
474
  };
483
475
  const ChoiceComponent = getChoiceComponent(variant);
484
- return React__namespace.createElement(ChoiceComponent, _extends__default["default"]({}, remainingProps, {
476
+ return React__namespace.createElement(ChoiceComponent, _extends({}, remainingProps, {
485
477
  checked: checked,
486
478
  disabled: disabled,
487
479
  onChange: onChange,
@@ -699,7 +691,7 @@ const TextField = props => {
699
691
  onFocus,
700
692
  onBlur
701
693
  } = props,
702
- otherProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$2);
694
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
703
695
  const {
704
696
  errorMessage,
705
697
  onBlurValidation,
@@ -731,7 +723,7 @@ const TextField = props => {
731
723
  };
732
724
  return React__namespace.createElement(wonderBlocksCore.Id, {
733
725
  id: id
734
- }, uniqueId => React__namespace.createElement(StyledInput, _extends__default["default"]({
726
+ }, uniqueId => React__namespace.createElement(StyledInput, _extends({
735
727
  style: [styles$2.input, wonderBlocksTypography.styles.LabelMedium, styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error, style],
736
728
  id: uniqueId,
737
729
  type: type,
@@ -819,7 +811,7 @@ const styles$2 = aphrodite.StyleSheet.create({
819
811
  }
820
812
  }
821
813
  });
822
- var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends__default["default"]({}, props, {
814
+ var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends({}, props, {
823
815
  forwardedRef: ref
824
816
  })));
825
817
 
@@ -972,14 +964,14 @@ class LabeledTextField extends React__namespace.Component {
972
964
  ariaDescribedby,
973
965
  name
974
966
  } = _this$props,
975
- otherProps = _objectWithoutPropertiesLoose__default["default"](_this$props, _excluded$1);
967
+ otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
976
968
  return React__namespace.createElement(wonderBlocksCore.Id, {
977
969
  id: id
978
970
  }, uniqueId => React__namespace.createElement(FieldHeading, {
979
971
  id: uniqueId,
980
972
  testId: testId,
981
973
  style: style,
982
- field: React__namespace.createElement(TextField$1, _extends__default["default"]({
974
+ field: React__namespace.createElement(TextField$1, _extends({
983
975
  id: `${uniqueId}-field`,
984
976
  "aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
985
977
  "aria-required": required ? "true" : "false",
@@ -1011,12 +1003,12 @@ LabeledTextField.defaultProps = {
1011
1003
  type: "text",
1012
1004
  disabled: false
1013
1005
  };
1014
- var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField, _extends__default["default"]({}, props, {
1006
+ var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField, _extends({}, props, {
1015
1007
  forwardedRef: ref
1016
1008
  })));
1017
1009
 
1018
1010
  const _excluded = ["onChange", "value", "placeholder", "disabled", "id", "testId", "style", "readOnly", "autoComplete", "name", "className", "autoFocus", "rows", "spellCheck", "wrap", "minLength", "maxLength", "onClick", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "validate", "onValidate", "required", "resizeType", "rootStyle", "error", "instantValidation"];
1019
- const StyledTextArea = wonderBlocksCore.addStyle("textarea");
1011
+ const StyledTextarea = wonderBlocksCore.addStyle("textarea");
1020
1012
  const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
1021
1013
  const {
1022
1014
  onChange,
@@ -1049,7 +1041,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
1049
1041
  error,
1050
1042
  instantValidation = true
1051
1043
  } = props,
1052
- otherProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded);
1044
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded);
1053
1045
  const {
1054
1046
  errorMessage,
1055
1047
  onBlurValidation,
@@ -1080,7 +1072,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
1080
1072
  style: [{
1081
1073
  width: "100%"
1082
1074
  }, rootStyle]
1083
- }, React__namespace.createElement(StyledTextArea, _extends__default["default"]({
1075
+ }, React__namespace.createElement(StyledTextarea, _extends({
1084
1076
  id: uniqueId,
1085
1077
  "data-testid": testId,
1086
1078
  ref: ref,
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-form",
3
- "version": "7.0.2",
3
+ "version": "7.1.0",
4
4
  "design": "v1",
5
5
  "description": "Form components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/es/index.js",
8
8
  "types": "dist/index.d.ts",
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
11
- "prepublishOnly": "../../utils/publish/package-pre-publish-check.sh"
12
- },
13
9
  "author": "",
14
10
  "license": "MIT",
15
11
  "publishConfig": {
16
12
  "access": "public"
17
13
  },
18
14
  "dependencies": {
19
- "@babel/runtime": "^7.18.6",
20
- "@khanacademy/wonder-blocks-clickable": "^6.0.0",
21
- "@khanacademy/wonder-blocks-core": "^12.0.0",
22
- "@khanacademy/wonder-blocks-icon": "^5.0.6",
23
- "@khanacademy/wonder-blocks-layout": "^3.0.8",
24
- "@khanacademy/wonder-blocks-tokens": "^4.1.0",
25
- "@khanacademy/wonder-blocks-typography": "^3.0.6"
15
+ "@babel/runtime": "^7.24.5",
16
+ "@khanacademy/wonder-blocks-clickable": "6.1.0",
17
+ "@khanacademy/wonder-blocks-core": "12.1.0",
18
+ "@khanacademy/wonder-blocks-icon": "5.1.0",
19
+ "@khanacademy/wonder-blocks-layout": "3.1.0",
20
+ "@khanacademy/wonder-blocks-tokens": "4.2.0",
21
+ "@khanacademy/wonder-blocks-typography": "3.1.0"
26
22
  },
27
23
  "peerDependencies": {
24
+ "@phosphor-icons/core": "^2.0.2",
28
25
  "aphrodite": "^1.2.5",
29
26
  "react": "18.2.0"
30
27
  },
31
28
  "devDependencies": {
32
- "@khanacademy/wb-dev-build-settings": "^2.0.0"
29
+ "@khanacademy/wb-dev-build-settings": "2.1.0"
30
+ },
31
+ "scripts": {
32
+ "test": "echo \"Error: no test specified\" && exit 1"
33
33
  }
34
34
  }