@khanacademy/wonder-blocks-form 4.9.2 → 4.9.4

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 (39) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/components/checkbox-core.d.ts +2 -2
  3. package/dist/components/checkbox.d.ts +2 -2
  4. package/dist/components/choice-internal.d.ts +2 -2
  5. package/dist/components/choice.d.ts +2 -2
  6. package/dist/components/labeled-text-field.d.ts +9 -1
  7. package/dist/components/radio-core.d.ts +2 -2
  8. package/dist/components/radio.d.ts +2 -2
  9. package/dist/components/text-area.d.ts +2 -2
  10. package/dist/components/text-field.d.ts +10 -5
  11. package/dist/es/index.js +93 -48
  12. package/dist/index.js +93 -48
  13. package/package.json +7 -7
  14. package/src/__tests__/__snapshots__/custom-snapshot.test.tsx.snap +0 -247
  15. package/src/__tests__/custom-snapshot.test.tsx +0 -48
  16. package/src/components/__tests__/checkbox-group.test.tsx +0 -162
  17. package/src/components/__tests__/checkbox.test.tsx +0 -138
  18. package/src/components/__tests__/field-heading.test.tsx +0 -225
  19. package/src/components/__tests__/labeled-text-field.test.tsx +0 -750
  20. package/src/components/__tests__/radio-group.test.tsx +0 -182
  21. package/src/components/__tests__/text-area.test.tsx +0 -1286
  22. package/src/components/__tests__/text-field.test.tsx +0 -562
  23. package/src/components/checkbox-core.tsx +0 -239
  24. package/src/components/checkbox-group.tsx +0 -174
  25. package/src/components/checkbox.tsx +0 -99
  26. package/src/components/choice-internal.tsx +0 -184
  27. package/src/components/choice.tsx +0 -157
  28. package/src/components/field-heading.tsx +0 -169
  29. package/src/components/group-styles.ts +0 -33
  30. package/src/components/labeled-text-field.tsx +0 -317
  31. package/src/components/radio-core.tsx +0 -171
  32. package/src/components/radio-group.tsx +0 -159
  33. package/src/components/radio.tsx +0 -82
  34. package/src/components/text-area.tsx +0 -430
  35. package/src/components/text-field.tsx +0 -399
  36. package/src/index.ts +0 -17
  37. package/src/util/types.ts +0 -85
  38. package/tsconfig-build.json +0 -19
  39. package/tsconfig-build.tsbuildinfo +0 -1
package/dist/index.js CHANGED
@@ -622,15 +622,14 @@ const RadioGroup = React__namespace.forwardRef(function RadioGroup(props, ref) {
622
622
  })));
623
623
  });
624
624
 
625
- const _excluded$2 = ["id", "type", "value", "name", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
625
+ const _excluded$2 = ["id", "type", "value", "name", "disabled", "onKeyDown", "placeholder", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "light", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
626
626
  const defaultErrorMessage$1 = "This field is required.";
627
627
  const StyledInput = wonderBlocksCore.addStyle("input");
628
628
  class TextField extends React__namespace.Component {
629
629
  constructor(props) {
630
630
  super(props);
631
631
  this.state = {
632
- error: null,
633
- focused: false
632
+ error: null
634
633
  };
635
634
  this.maybeValidate = newValue => {
636
635
  const {
@@ -671,25 +670,30 @@ class TextField extends React__namespace.Component {
671
670
  const {
672
671
  onFocus
673
672
  } = this.props;
674
- this.setState({
675
- focused: true
676
- }, () => {
677
- if (onFocus) {
678
- onFocus(event);
679
- }
680
- });
673
+ if (onFocus) {
674
+ onFocus(event);
675
+ }
681
676
  };
682
677
  this.handleBlur = event => {
683
678
  const {
684
679
  onBlur
685
680
  } = this.props;
686
- this.setState({
687
- focused: false
688
- }, () => {
689
- if (onBlur) {
690
- onBlur(event);
691
- }
692
- });
681
+ if (onBlur) {
682
+ onBlur(event);
683
+ }
684
+ };
685
+ this.getStyles = () => {
686
+ const {
687
+ disabled,
688
+ light
689
+ } = this.props;
690
+ const {
691
+ error
692
+ } = this.state;
693
+ const baseStyles = [styles$2.input, wonderBlocksTypography.styles.LabelMedium];
694
+ const defaultStyles = [styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, !!error && styles$2.error];
695
+ const lightStyles = [styles$2.light, !disabled && styles$2.lightFocus, disabled && styles$2.lightDisabled, !!error && styles$2.lightError];
696
+ return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
693
697
  };
694
698
  if (props.validate && props.value !== "") {
695
699
  this.state.error = props.validate(props.value) || null;
@@ -710,7 +714,6 @@ class TextField extends React__namespace.Component {
710
714
  disabled,
711
715
  onKeyDown,
712
716
  placeholder,
713
- light,
714
717
  style,
715
718
  testId,
716
719
  readOnly,
@@ -723,19 +726,19 @@ class TextField extends React__namespace.Component {
723
726
  id: id,
724
727
  scope: "text-field"
725
728
  }, uniqueId => React__namespace.createElement(StyledInput, _extends__default["default"]({
726
- style: [styles$2.input, wonderBlocksTypography.styles.LabelMedium, styles$2.default, disabled ? styles$2.disabled : this.state.focused ? [styles$2.focused, light && styles$2.defaultLight] : !!this.state.error && [styles$2.error, light && styles$2.errorLight], !!this.state.error && styles$2.error, style && style],
729
+ style: [this.getStyles(), style],
727
730
  id: uniqueId,
728
731
  type: type,
729
732
  placeholder: placeholder,
730
733
  value: value,
731
734
  name: name,
732
- disabled: disabled,
735
+ "aria-disabled": disabled,
733
736
  onChange: this.handleChange,
734
- onKeyDown: onKeyDown,
737
+ onKeyDown: disabled ? undefined : onKeyDown,
735
738
  onFocus: this.handleFocus,
736
739
  onBlur: this.handleBlur,
737
740
  "data-testid": testId,
738
- readOnly: readOnly,
741
+ readOnly: readOnly || disabled,
739
742
  autoFocus: autoFocus,
740
743
  autoComplete: autoComplete,
741
744
  ref: forwardedRef
@@ -753,12 +756,10 @@ const styles$2 = aphrodite.StyleSheet.create({
753
756
  input: {
754
757
  width: "100%",
755
758
  height: 40,
756
- borderRadius: 4,
759
+ borderRadius: wonderBlocksTokens.border.radius.medium_4,
757
760
  boxSizing: "border-box",
758
761
  paddingLeft: wonderBlocksTokens.spacing.medium_16,
759
- margin: 0,
760
- outline: "none",
761
- boxShadow: "none"
762
+ margin: 0
762
763
  },
763
764
  default: {
764
765
  background: wonderBlocksTokens.color.white,
@@ -768,12 +769,23 @@ const styles$2 = aphrodite.StyleSheet.create({
768
769
  color: wonderBlocksTokens.color.offBlack64
769
770
  }
770
771
  },
772
+ defaultFocus: {
773
+ ":focus-visible": {
774
+ borderColor: wonderBlocksTokens.color.blue,
775
+ outline: `1px solid ${wonderBlocksTokens.color.blue}`,
776
+ outlineOffset: "-2px"
777
+ }
778
+ },
771
779
  error: {
772
780
  background: wonderBlocksTokens.color.fadedRed8,
773
781
  border: `1px solid ${wonderBlocksTokens.color.red}`,
774
782
  color: wonderBlocksTokens.color.offBlack,
775
783
  "::placeholder": {
776
784
  color: wonderBlocksTokens.color.offBlack64
785
+ },
786
+ ":focus-visible": {
787
+ outlineColor: wonderBlocksTokens.color.red,
788
+ borderColor: wonderBlocksTokens.color.red
777
789
  }
778
790
  },
779
791
  disabled: {
@@ -781,22 +793,56 @@ const styles$2 = aphrodite.StyleSheet.create({
781
793
  border: `1px solid ${wonderBlocksTokens.color.offBlack16}`,
782
794
  color: wonderBlocksTokens.color.offBlack64,
783
795
  "::placeholder": {
784
- color: wonderBlocksTokens.color.offBlack32
796
+ color: wonderBlocksTokens.color.offBlack64
797
+ },
798
+ cursor: "not-allowed",
799
+ ":focus-visible": {
800
+ outline: `2px solid ${wonderBlocksTokens.color.offBlack32}`,
801
+ outlineOffset: "-3px"
785
802
  }
786
803
  },
787
- focused: {
804
+ light: {
788
805
  background: wonderBlocksTokens.color.white,
789
- border: `1px solid ${wonderBlocksTokens.color.blue}`,
806
+ border: `1px solid ${wonderBlocksTokens.color.offBlack16}`,
790
807
  color: wonderBlocksTokens.color.offBlack,
791
808
  "::placeholder": {
792
809
  color: wonderBlocksTokens.color.offBlack64
793
810
  }
794
811
  },
795
- defaultLight: {
796
- boxShadow: `0px 0px 0px 1px ${wonderBlocksTokens.color.blue}, 0px 0px 0px 2px ${wonderBlocksTokens.color.white}`
812
+ lightFocus: {
813
+ ":focus-visible": {
814
+ outline: `3px solid ${wonderBlocksTokens.color.blue}`,
815
+ outlineOffset: "-4px",
816
+ borderColor: wonderBlocksTokens.color.white
817
+ }
818
+ },
819
+ lightDisabled: {
820
+ backgroundColor: "transparent",
821
+ border: `1px solid ${wonderBlocksTokens.color.white32}`,
822
+ color: wonderBlocksTokens.color.white64,
823
+ "::placeholder": {
824
+ color: wonderBlocksTokens.color.white64
825
+ },
826
+ cursor: "not-allowed",
827
+ ":focus-visible": {
828
+ borderColor: wonderBlocksTokens.mix(wonderBlocksTokens.color.white32, wonderBlocksTokens.color.blue),
829
+ outline: `3px solid ${wonderBlocksTokens.color.fadedBlue}`,
830
+ outlineOffset: "-4px"
831
+ }
797
832
  },
798
- errorLight: {
799
- boxShadow: `0px 0px 0px 1px ${wonderBlocksTokens.color.red}, 0px 0px 0px 2px ${wonderBlocksTokens.color.white}`
833
+ lightError: {
834
+ background: wonderBlocksTokens.color.fadedRed8,
835
+ border: `1px solid ${wonderBlocksTokens.color.white}`,
836
+ outline: `2px solid ${wonderBlocksTokens.color.red}`,
837
+ outlineOffset: "-3px",
838
+ color: wonderBlocksTokens.color.offBlack,
839
+ "::placeholder": {
840
+ color: wonderBlocksTokens.color.offBlack64
841
+ },
842
+ ":focus-visible": {
843
+ outline: `3px solid ${wonderBlocksTokens.color.red}`,
844
+ outlineOffset: "-4px"
845
+ }
800
846
  }
801
847
  });
802
848
  var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends__default["default"]({}, props, {
@@ -1092,7 +1138,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
1092
1138
  "data-testid": testId,
1093
1139
  ref: ref,
1094
1140
  className: className,
1095
- style: [...getStyles(), style],
1141
+ style: [getStyles(), style],
1096
1142
  value: value,
1097
1143
  onChange: handleChange,
1098
1144
  placeholder: placeholder,
@@ -1136,7 +1182,7 @@ const styles = aphrodite.StyleSheet.create({
1136
1182
  ":focus-visible": {
1137
1183
  borderColor: wonderBlocksTokens.color.blue,
1138
1184
  outline: `1px solid ${wonderBlocksTokens.color.blue}`,
1139
- outlineOffset: 0
1185
+ outlineOffset: "-2px"
1140
1186
  }
1141
1187
  },
1142
1188
  disabled: {
@@ -1148,8 +1194,8 @@ const styles = aphrodite.StyleSheet.create({
1148
1194
  },
1149
1195
  cursor: "not-allowed",
1150
1196
  ":focus-visible": {
1151
- outline: "none",
1152
- boxShadow: `0 0 0 1px ${wonderBlocksTokens.color.white}, 0 0 0 3px ${wonderBlocksTokens.color.offBlack32}`
1197
+ outline: `2px solid ${wonderBlocksTokens.color.offBlack32}`,
1198
+ outlineOffset: "-3px"
1153
1199
  }
1154
1200
  },
1155
1201
  error: {
@@ -1174,10 +1220,9 @@ const styles = aphrodite.StyleSheet.create({
1174
1220
  },
1175
1221
  lightFocus: {
1176
1222
  ":focus-visible": {
1177
- outline: `1px solid ${wonderBlocksTokens.color.blue}`,
1178
- outlineOffset: 0,
1179
- borderColor: wonderBlocksTokens.color.blue,
1180
- boxShadow: `0px 0px 0px 2px ${wonderBlocksTokens.color.blue}, 0px 0px 0px 3px ${wonderBlocksTokens.color.white}`
1223
+ outline: `3px solid ${wonderBlocksTokens.color.blue}`,
1224
+ outlineOffset: "-4px",
1225
+ borderColor: wonderBlocksTokens.color.white
1181
1226
  }
1182
1227
  },
1183
1228
  lightDisabled: {
@@ -1190,22 +1235,22 @@ const styles = aphrodite.StyleSheet.create({
1190
1235
  cursor: "not-allowed",
1191
1236
  ":focus-visible": {
1192
1237
  borderColor: wonderBlocksTokens.mix(wonderBlocksTokens.color.white32, wonderBlocksTokens.color.blue),
1193
- outline: "none",
1194
- boxShadow: `0 0 0 1px ${wonderBlocksTokens.color.offBlack32}, 0 0 0 3px ${wonderBlocksTokens.color.fadedBlue}`
1238
+ outline: `3px solid ${wonderBlocksTokens.color.fadedBlue}`,
1239
+ outlineOffset: "-4px"
1195
1240
  }
1196
1241
  },
1197
1242
  lightError: {
1198
1243
  background: wonderBlocksTokens.color.fadedRed8,
1199
- border: `1px solid ${wonderBlocksTokens.color.red}`,
1200
- boxShadow: `0px 0px 0px 1px ${wonderBlocksTokens.color.red}, 0px 0px 0px 2px ${wonderBlocksTokens.color.white}`,
1244
+ border: `1px solid ${wonderBlocksTokens.color.white}`,
1245
+ outline: `2px solid ${wonderBlocksTokens.color.red}`,
1246
+ outlineOffset: "-3px",
1201
1247
  color: wonderBlocksTokens.color.offBlack,
1202
1248
  "::placeholder": {
1203
1249
  color: wonderBlocksTokens.color.offBlack64
1204
1250
  },
1205
1251
  ":focus-visible": {
1206
- outlineColor: wonderBlocksTokens.color.red,
1207
- borderColor: wonderBlocksTokens.color.red,
1208
- boxShadow: `0px 0px 0px 2px ${wonderBlocksTokens.color.red}, 0px 0px 0px 3px ${wonderBlocksTokens.color.white}`
1252
+ outline: `3px solid ${wonderBlocksTokens.color.red}`,
1253
+ outlineOffset: "-4px"
1209
1254
  }
1210
1255
  }
1211
1256
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-form",
3
- "version": "4.9.2",
3
+ "version": "4.9.4",
4
4
  "design": "v1",
5
5
  "description": "Form components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -16,12 +16,12 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^4.2.7",
20
- "@khanacademy/wonder-blocks-core": "^7.0.0",
21
- "@khanacademy/wonder-blocks-icon": "^4.1.4",
22
- "@khanacademy/wonder-blocks-layout": "^2.2.0",
23
- "@khanacademy/wonder-blocks-tokens": "^2.0.0",
24
- "@khanacademy/wonder-blocks-typography": "^2.1.15"
19
+ "@khanacademy/wonder-blocks-clickable": "^4.2.8",
20
+ "@khanacademy/wonder-blocks-core": "^7.0.1",
21
+ "@khanacademy/wonder-blocks-icon": "^4.1.5",
22
+ "@khanacademy/wonder-blocks-layout": "^2.2.1",
23
+ "@khanacademy/wonder-blocks-tokens": "^2.0.1",
24
+ "@khanacademy/wonder-blocks-typography": "^2.1.16"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "aphrodite": "^1.2.5",
@@ -1,247 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`CheckboxCore type:default checked:false 1`] = `
4
- <div>
5
- <input
6
- aria-checked="false"
7
- aria-invalid="false"
8
- class=""
9
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; background-color: rgb(255, 255, 255); border-color: rgba(33,36,44,0.50);"
10
- type="checkbox"
11
- />
12
- </div>
13
- `;
14
-
15
- exports[`CheckboxCore type:default checked:null 1`] = `
16
- <div>
17
- <input
18
- aria-checked="mixed"
19
- aria-invalid="false"
20
- class=""
21
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(24, 101, 242);"
22
- type="checkbox"
23
- />
24
- <span
25
- class=""
26
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(minus-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
27
- />
28
- </div>
29
- `;
30
-
31
- exports[`CheckboxCore type:default checked:true 1`] = `
32
- <div>
33
- <input
34
- aria-checked="true"
35
- aria-invalid="false"
36
- checked=""
37
- class=""
38
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(24, 101, 242);"
39
- type="checkbox"
40
- />
41
- <span
42
- class=""
43
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(check-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
44
- />
45
- </div>
46
- `;
47
-
48
- exports[`CheckboxCore type:disabled checked:false 1`] = `
49
- <div>
50
- <input
51
- aria-checked="false"
52
- aria-invalid="false"
53
- class=""
54
- disabled=""
55
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
56
- type="checkbox"
57
- />
58
- </div>
59
- `;
60
-
61
- exports[`CheckboxCore type:disabled checked:null 1`] = `
62
- <div>
63
- <input
64
- aria-checked="mixed"
65
- aria-invalid="false"
66
- class=""
67
- disabled=""
68
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
69
- type="checkbox"
70
- />
71
- <span
72
- class=""
73
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgba(33, 36, 44, 0.32); width: 12px; height: 12px; mask-image: url(minus-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
74
- />
75
- </div>
76
- `;
77
-
78
- exports[`CheckboxCore type:disabled checked:true 1`] = `
79
- <div>
80
- <input
81
- aria-checked="true"
82
- aria-invalid="false"
83
- checked=""
84
- class=""
85
- disabled=""
86
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
87
- type="checkbox"
88
- />
89
- <span
90
- class=""
91
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgba(33, 36, 44, 0.32); width: 12px; height: 12px; mask-image: url(check-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
92
- />
93
- </div>
94
- `;
95
-
96
- exports[`CheckboxCore type:error checked:false 1`] = `
97
- <div>
98
- <input
99
- aria-checked="false"
100
- aria-invalid="true"
101
- class=""
102
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 3px; background-color: rgb(252, 238, 236); border-color: #d92916;"
103
- type="checkbox"
104
- />
105
- </div>
106
- `;
107
-
108
- exports[`CheckboxCore type:error checked:null 1`] = `
109
- <div>
110
- <input
111
- aria-checked="mixed"
112
- aria-invalid="true"
113
- class=""
114
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(217, 41, 22);"
115
- type="checkbox"
116
- />
117
- <span
118
- class=""
119
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(minus-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
120
- />
121
- </div>
122
- `;
123
-
124
- exports[`CheckboxCore type:error checked:true 1`] = `
125
- <div>
126
- <input
127
- aria-checked="true"
128
- aria-invalid="true"
129
- checked=""
130
- class=""
131
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 0px; border-radius: 3px; background-color: rgb(217, 41, 22);"
132
- type="checkbox"
133
- />
134
- <span
135
- class=""
136
- style="display: inline-block; vertical-align: text-bottom; flex-shrink: 0; flex-grow: 0; mask-size: 100%; mask-repeat: no-repeat; mask-position: center; background-color: rgb(255, 255, 255); width: 12px; height: 12px; mask-image: url(check-bold.svg); position: absolute; pointer-events: none; margin: 2px;"
137
- />
138
- </div>
139
- `;
140
-
141
- exports[`RadioCore type:default checked:false 1`] = `
142
- <div>
143
- <input
144
- aria-invalid="false"
145
- class=""
146
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: rgba(33,36,44,0.50);"
147
- type="radio"
148
- />
149
- </div>
150
- `;
151
-
152
- exports[`RadioCore type:default checked:null 1`] = `
153
- <div>
154
- <input
155
- aria-invalid="false"
156
- class=""
157
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: rgba(33,36,44,0.50);"
158
- type="radio"
159
- />
160
- </div>
161
- `;
162
-
163
- exports[`RadioCore type:default checked:true 1`] = `
164
- <div>
165
- <input
166
- aria-invalid="false"
167
- checked=""
168
- class=""
169
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 4px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: #1865f2;"
170
- type="radio"
171
- />
172
- </div>
173
- `;
174
-
175
- exports[`RadioCore type:disabled checked:false 1`] = `
176
- <div>
177
- <input
178
- aria-invalid="false"
179
- class=""
180
- disabled=""
181
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
182
- type="radio"
183
- />
184
- </div>
185
- `;
186
-
187
- exports[`RadioCore type:disabled checked:null 1`] = `
188
- <div>
189
- <input
190
- aria-invalid="false"
191
- class=""
192
- disabled=""
193
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
194
- type="radio"
195
- />
196
- </div>
197
- `;
198
-
199
- exports[`RadioCore type:disabled checked:true 1`] = `
200
- <div>
201
- <input
202
- aria-invalid="false"
203
- checked=""
204
- class=""
205
- disabled=""
206
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; cursor: auto; background-color: rgb(247, 248, 250); border-color: rgba(33,36,44,0.16);"
207
- type="radio"
208
- />
209
- <span
210
- style="position: absolute; top: 4px; left: 4px; height: 8px; width: 8px; border-radius: 50%; background-color: rgba(33, 36, 44, 0.32);"
211
- />
212
- </div>
213
- `;
214
-
215
- exports[`RadioCore type:error checked:false 1`] = `
216
- <div>
217
- <input
218
- aria-invalid="true"
219
- class=""
220
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(252, 238, 236); border-color: #d92916;"
221
- type="radio"
222
- />
223
- </div>
224
- `;
225
-
226
- exports[`RadioCore type:error checked:null 1`] = `
227
- <div>
228
- <input
229
- aria-invalid="true"
230
- class=""
231
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 1px; border-radius: 50%; background-color: rgb(252, 238, 236); border-color: #d92916;"
232
- type="radio"
233
- />
234
- </div>
235
- `;
236
-
237
- exports[`RadioCore type:error checked:true 1`] = `
238
- <div>
239
- <input
240
- aria-invalid="true"
241
- checked=""
242
- class=""
243
- style="appearance: none; height: 16px; width: 16px; min-height: 16px; min-width: 16px; margin: 0px; outline: none; box-sizing: border-box; border-style: solid; border-width: 4px; border-radius: 50%; background-color: rgb(255, 255, 255); border-color: #d92916;"
244
- type="radio"
245
- />
246
- </div>
247
- `;
@@ -1,48 +0,0 @@
1
- import * as React from "react";
2
- import {render} from "@testing-library/react";
3
-
4
- import CheckboxCore from "../components/checkbox-core";
5
- import RadioCore from "../components/radio-core";
6
-
7
- const states = ["default", "error", "disabled"];
8
- const checkedStates = [false, true, null];
9
-
10
- describe("CheckboxCore", () => {
11
- states.forEach((state: any) => {
12
- checkedStates.forEach((checked: any) => {
13
- test(`type:${state} checked:${String(checked)}`, () => {
14
- const disabled = state === "disabled";
15
- const {container} = render(
16
- <CheckboxCore
17
- checked={checked}
18
- disabled={disabled}
19
- error={state === "error"}
20
- onClick={() => {}}
21
- />,
22
- );
23
-
24
- expect(container).toMatchSnapshot();
25
- });
26
- });
27
- });
28
- });
29
-
30
- describe("RadioCore", () => {
31
- states.forEach((state: any) => {
32
- checkedStates.forEach((checked: any) => {
33
- test(`type:${state} checked:${String(checked)}`, () => {
34
- const disabled = state === "disabled";
35
- const {container} = render(
36
- <RadioCore
37
- checked={checked}
38
- disabled={disabled}
39
- error={state === "error"}
40
- onClick={() => {}}
41
- />,
42
- );
43
-
44
- expect(container).toMatchSnapshot();
45
- });
46
- });
47
- });
48
- });