@khanacademy/wonder-blocks-form 6.0.6 → 7.0.1

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/dist/es/index.js CHANGED
@@ -5,7 +5,7 @@ import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutP
5
5
  import { StyleSheet } from 'aphrodite';
6
6
  import { addStyle, Id, View, useOnMountEffect } from '@khanacademy/wonder-blocks-core';
7
7
  import { Strut } from '@khanacademy/wonder-blocks-layout';
8
- import { spacing, mix, color, border, font } from '@khanacademy/wonder-blocks-tokens';
8
+ import { spacing, semanticColor, border, font } from '@khanacademy/wonder-blocks-tokens';
9
9
  import { LabelMedium, LabelSmall, styles as styles$7 } from '@khanacademy/wonder-blocks-typography';
10
10
  import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
11
11
  import checkIcon from '@phosphor-icons/core/bold/check-bold.svg';
@@ -22,15 +22,6 @@ function mapCheckedToAriaChecked(value) {
22
22
  return "mixed";
23
23
  }
24
24
  }
25
- const {
26
- blue: blue$1,
27
- red: red$1,
28
- white: white$1,
29
- offWhite: offWhite$1,
30
- offBlack16: offBlack16$1,
31
- offBlack32: offBlack32$1,
32
- offBlack50: offBlack50$1
33
- } = color;
34
25
  const size$1 = spacing.medium_16;
35
26
  const checkSize = spacing.small_12;
36
27
  const StyledInput$2 = addStyle("input");
@@ -56,7 +47,7 @@ const CheckboxCore = React.forwardRef(function CheckboxCore(props, ref) {
56
47
  const stateStyles = _generateStyles$1(checked, error);
57
48
  const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, !disabled && stateStyles.default, disabled && sharedStyles$1.disabled];
58
49
  const checkboxIcon = React.createElement(PhosphorIcon, {
59
- color: disabled ? offBlack32$1 : white$1,
50
+ color: disabled ? semanticColor.icon.disabled : semanticColor.icon.inverse,
60
51
  icon: checked ? checkIcon : minusIcon,
61
52
  size: "small",
62
53
  style: [sharedStyles$1.checkboxIcon, {
@@ -86,6 +77,10 @@ const CheckboxCore = React.forwardRef(function CheckboxCore(props, ref) {
86
77
  "data-testid": testId
87
78
  })), checked || checked == null ? checkboxIcon : React.createElement(React.Fragment, null));
88
79
  });
80
+ const disabledState$1 = {
81
+ border: semanticColor.border.primary,
82
+ background: semanticColor.action.disabled.secondary
83
+ };
89
84
  const sharedStyles$1 = StyleSheet.create({
90
85
  inputReset: {
91
86
  appearance: "none",
@@ -101,14 +96,14 @@ const sharedStyles$1 = StyleSheet.create({
101
96
  outline: "none",
102
97
  boxSizing: "border-box",
103
98
  borderStyle: "solid",
104
- borderWidth: 1,
105
- borderRadius: 3
99
+ borderWidth: border.width.hairline,
100
+ borderRadius: border.radius.small_3
106
101
  },
107
102
  disabled: {
108
103
  cursor: "auto",
109
- backgroundColor: offWhite$1,
110
- borderColor: offBlack16$1,
111
- borderWidth: 1
104
+ backgroundColor: disabledState$1.background,
105
+ borderColor: disabledState$1.border,
106
+ borderWidth: border.width.hairline
112
107
  },
113
108
  checkboxIcon: {
114
109
  position: "absolute",
@@ -116,66 +111,67 @@ const sharedStyles$1 = StyleSheet.create({
116
111
  margin: (size$1 - checkSize) / 2
117
112
  }
118
113
  });
119
- const fadedBlue$1 = mix(color.fadedBlue16, white$1);
120
- const activeBlue = color.activeBlue;
121
- const fadedRed$1 = mix(color.fadedRed8, white$1);
122
- const activeRed = color.activeRed;
123
- const colors$1 = {
124
- default: {
125
- faded: fadedBlue$1,
126
- base: blue$1,
127
- active: activeBlue
128
- },
129
- error: {
130
- faded: fadedRed$1,
131
- base: red$1,
132
- active: activeRed
133
- }
134
- };
135
114
  const styles$6 = {};
136
115
  const _generateStyles$1 = (checked, error) => {
137
116
  const styleKey = `${String(checked)}-${String(error)}`;
138
117
  if (styles$6[styleKey]) {
139
118
  return styles$6[styleKey];
140
119
  }
141
- const palette = error ? colors$1.error : colors$1.default;
120
+ const isCheckedOrIndeterminate = checked || checked == null;
121
+ const actionType = error ? "destructive" : "progressive";
122
+ const styleType = isCheckedOrIndeterminate ? "filled" : "outlined";
123
+ const colorAction = semanticColor.action[styleType][actionType];
124
+ const states = {
125
+ default: {
126
+ border: colorAction.default.border,
127
+ background: colorAction.default.background
128
+ },
129
+ error: {
130
+ border: semanticColor.status.critical.foreground,
131
+ background: semanticColor.status.critical.background
132
+ }
133
+ };
142
134
  let newStyles = {};
143
- if (checked || checked == null) {
135
+ if (isCheckedOrIndeterminate) {
144
136
  newStyles = {
145
137
  default: {
146
- backgroundColor: palette.base,
147
- borderWidth: 0,
138
+ backgroundColor: states.default.background,
139
+ borderColor: states.default.border,
148
140
  ":focus-visible": {
149
- boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.base}`
141
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
142
+ outlineOffset: 1
150
143
  },
151
144
  ":hover": {
152
- boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.base}`
145
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
146
+ outlineOffset: 1
153
147
  },
154
148
  ":active": {
155
- boxShadow: `0 0 0 1px ${white$1}, 0 0 0 3px ${palette.active}`,
156
- background: palette.active
149
+ outline: `${border.width.thin}px solid ${colorAction.press.border}`,
150
+ outlineOffset: 1,
151
+ background: colorAction.press.background
157
152
  }
158
153
  }
159
154
  };
160
155
  } else {
156
+ const currentState = error ? states.error : states.default;
161
157
  newStyles = {
162
158
  default: {
163
- backgroundColor: error ? fadedRed$1 : white$1,
164
- borderColor: error ? red$1 : offBlack50$1,
159
+ backgroundColor: currentState.background,
160
+ borderColor: currentState.border,
165
161
  ":focus-visible": {
166
- backgroundColor: error ? fadedRed$1 : white$1,
167
- borderColor: palette.base,
168
- borderWidth: 2
162
+ backgroundColor: error ? states.error.background : colorAction.hover.background,
163
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
164
+ outlineOffset: -1
169
165
  },
170
166
  ":hover": {
171
- backgroundColor: error ? fadedRed$1 : white$1,
172
- borderColor: palette.base,
173
- borderWidth: 2
167
+ backgroundColor: error ? states.error.background : colorAction.hover.background,
168
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
169
+ outlineOffset: -1
174
170
  },
175
171
  ":active": {
176
- backgroundColor: palette.faded,
177
- borderColor: error ? activeRed : blue$1,
178
- borderWidth: 2
172
+ backgroundColor: colorAction.press.background,
173
+ outline: `${border.width.thin}px solid ${colorAction.press.border}`,
174
+ outlineOffset: -1
179
175
  }
180
176
  }
181
177
  };
@@ -185,15 +181,6 @@ const _generateStyles$1 = (checked, error) => {
185
181
  };
186
182
 
187
183
  const _excluded$6 = ["checked", "disabled", "error", "groupName", "id", "testId"];
188
- const {
189
- blue,
190
- red,
191
- white,
192
- offWhite,
193
- offBlack16,
194
- offBlack32,
195
- offBlack50
196
- } = color;
197
184
  const StyledInput$1 = addStyle("input");
198
185
  const RadioCore = React.forwardRef(function RadioCore(props, ref) {
199
186
  const handleChange = () => {
@@ -225,6 +212,10 @@ const RadioCore = React.forwardRef(function RadioCore(props, ref) {
225
212
  style: disabledChecked
226
213
  }));
227
214
  });
215
+ const disabledState = {
216
+ border: semanticColor.border.primary,
217
+ background: semanticColor.action.disabled.secondary
218
+ };
228
219
  const size = 16;
229
220
  const disabledChecked = {
230
221
  position: "absolute",
@@ -233,7 +224,7 @@ const disabledChecked = {
233
224
  height: size / 2,
234
225
  width: size / 2,
235
226
  borderRadius: "50%",
236
- backgroundColor: offBlack32
227
+ backgroundColor: semanticColor.action.disabled.default
237
228
  };
238
229
  const sharedStyles = StyleSheet.create({
239
230
  inputReset: {
@@ -250,75 +241,80 @@ const sharedStyles = StyleSheet.create({
250
241
  outline: "none",
251
242
  boxSizing: "border-box",
252
243
  borderStyle: "solid",
253
- borderWidth: 1,
244
+ borderWidth: border.width.hairline,
254
245
  borderRadius: "50%"
255
246
  },
256
247
  disabled: {
257
248
  cursor: "auto",
258
- backgroundColor: offWhite,
259
- borderColor: offBlack16,
260
- borderWidth: 1
249
+ backgroundColor: disabledState.background,
250
+ borderColor: disabledState.border,
251
+ borderWidth: border.width.hairline
261
252
  }
262
253
  });
263
- const fadedBlue = mix(color.fadedBlue16, white);
264
- const fadedRed = mix(color.fadedRed8, white);
265
- const colors = {
266
- default: {
267
- faded: fadedBlue,
268
- base: blue,
269
- active: color.activeBlue
270
- },
271
- error: {
272
- faded: fadedRed,
273
- base: red,
274
- active: color.activeRed
275
- }
276
- };
277
254
  const styles$5 = {};
278
255
  const _generateStyles = (checked, error) => {
279
256
  const styleKey = `${String(checked)}-${String(error)}`;
280
257
  if (styles$5[styleKey]) {
281
258
  return styles$5[styleKey];
282
259
  }
283
- const palette = error ? colors.error : colors.default;
260
+ const actionType = error ? "destructive" : "progressive";
261
+ const colorAction = semanticColor.action.outlined[actionType];
262
+ const states = {
263
+ unchecked: {
264
+ border: semanticColor.border.strong,
265
+ background: colorAction.default.background
266
+ },
267
+ checked: {
268
+ border: colorAction.default.foreground,
269
+ background: colorAction.default.background
270
+ },
271
+ error: {
272
+ border: semanticColor.status.critical.foreground,
273
+ background: semanticColor.status.critical.background
274
+ }
275
+ };
284
276
  let newStyles = {};
285
277
  if (checked) {
286
278
  newStyles = {
287
279
  default: {
288
- backgroundColor: white,
289
- borderColor: palette.base,
280
+ backgroundColor: states.checked.background,
281
+ borderColor: states.checked.border,
290
282
  borderWidth: size / 4,
291
283
  ":focus-visible": {
292
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
284
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
285
+ outlineOffset: 1
293
286
  },
294
287
  ":hover": {
295
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.base}`
288
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
289
+ outlineOffset: 1
296
290
  },
297
291
  ":active": {
298
- boxShadow: `0 0 0 1px ${white}, 0 0 0 3px ${palette.active}`,
299
- borderColor: palette.active
292
+ outline: `${border.width.thin}px solid ${colorAction.press.border}`,
293
+ outlineOffset: 1,
294
+ borderColor: colorAction.press.border
300
295
  }
301
296
  }
302
297
  };
303
298
  } else {
299
+ const currentState = error ? states.error : states.unchecked;
304
300
  newStyles = {
305
301
  default: {
306
- backgroundColor: error ? fadedRed : white,
307
- borderColor: error ? red : offBlack50,
302
+ backgroundColor: currentState.background,
303
+ borderColor: currentState.border,
308
304
  ":focus-visible": {
309
- backgroundColor: error ? fadedRed : white,
310
- borderColor: palette.base,
311
- borderWidth: 2
305
+ backgroundColor: error ? states.error.background : colorAction.hover.background,
306
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
307
+ outlineOffset: -1
312
308
  },
313
309
  ":hover": {
314
- backgroundColor: error ? fadedRed : white,
315
- borderColor: palette.base,
316
- borderWidth: 2
310
+ backgroundColor: error ? states.error.background : colorAction.hover.background,
311
+ outline: `${border.width.thin}px solid ${colorAction.hover.border}`,
312
+ outlineOffset: -1
317
313
  },
318
314
  ":active": {
319
- backgroundColor: palette.faded,
320
- borderColor: error ? color.activeRed : blue,
321
- borderWidth: 2
315
+ backgroundColor: colorAction.press.background,
316
+ outline: `${border.width.thin}px solid ${colorAction.press.border}`,
317
+ outlineOffset: -1
322
318
  }
323
319
  }
324
320
  };
@@ -402,12 +398,12 @@ const styles$4 = StyleSheet.create({
402
398
  marginTop: -2
403
399
  },
404
400
  disabledLabel: {
405
- color: color.offBlack32
401
+ color: semanticColor.text.disabled
406
402
  },
407
403
  description: {
408
404
  marginLeft: spacing.medium_16 + spacing.xSmall_8,
409
405
  marginTop: spacing.xxxSmall_4,
410
- color: color.offBlack64
406
+ color: semanticColor.text.secondary
411
407
  }
412
408
  });
413
409
 
@@ -478,11 +474,11 @@ const styles$3 = StyleSheet.create({
478
474
  },
479
475
  description: {
480
476
  marginTop: spacing.xxxSmall_4,
481
- color: color.offBlack64
477
+ color: semanticColor.text.secondary
482
478
  },
483
479
  error: {
484
480
  marginTop: spacing.xxxSmall_4,
485
- color: color.red
481
+ color: semanticColor.status.critical.foreground
486
482
  },
487
483
  defaultLineGap: {
488
484
  marginTop: spacing.xSmall_8
@@ -648,7 +644,7 @@ const useFieldValidation = ({
648
644
  };
649
645
  };
650
646
 
651
- const _excluded$2 = ["id", "type", "value", "name", "disabled", "light", "error", "validate", "onValidate", "required", "placeholder", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "instantValidation", "onKeyDown", "onChange", "onFocus", "onBlur"];
647
+ const _excluded$2 = ["id", "type", "value", "name", "disabled", "error", "validate", "onValidate", "required", "placeholder", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "instantValidation", "onKeyDown", "onChange", "onFocus", "onBlur"];
652
648
  const StyledInput = addStyle("input");
653
649
  const TextField = props => {
654
650
  const {
@@ -657,7 +653,6 @@ const TextField = props => {
657
653
  value,
658
654
  name,
659
655
  disabled = false,
660
- light = false,
661
656
  error,
662
657
  validate,
663
658
  onValidate,
@@ -705,16 +700,10 @@ const TextField = props => {
705
700
  onBlur(event);
706
701
  }
707
702
  };
708
- const getStyles = () => {
709
- const baseStyles = [styles$2.input, styles$7.LabelMedium];
710
- const defaultStyles = [styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error];
711
- const lightStyles = [styles$2.light, !disabled && styles$2.lightFocus, disabled && styles$2.lightDisabled, hasError && styles$2.lightError];
712
- return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
713
- };
714
703
  return React.createElement(Id, {
715
704
  id: id
716
705
  }, uniqueId => React.createElement(StyledInput, _extends({
717
- style: [getStyles(), style],
706
+ style: [styles$2.input, styles$7.LabelMedium, styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error, style],
718
707
  id: uniqueId,
719
708
  type: type,
720
709
  placeholder: placeholder,
@@ -734,6 +723,23 @@ const TextField = props => {
734
723
  "aria-invalid": hasError
735
724
  }, otherProps)));
736
725
  };
726
+ const states$1 = {
727
+ default: {
728
+ border: semanticColor.border.strong,
729
+ background: semanticColor.surface.primary,
730
+ foreground: semanticColor.text.primary
731
+ },
732
+ disabled: {
733
+ border: semanticColor.border.primary,
734
+ background: semanticColor.action.disabled.secondary,
735
+ foreground: semanticColor.text.secondary
736
+ },
737
+ error: {
738
+ border: semanticColor.status.critical.foreground,
739
+ background: semanticColor.status.critical.background,
740
+ foreground: semanticColor.text.primary
741
+ }
742
+ };
737
743
  const styles$2 = StyleSheet.create({
738
744
  input: {
739
745
  width: "100%",
@@ -744,86 +750,43 @@ const styles$2 = StyleSheet.create({
744
750
  margin: 0
745
751
  },
746
752
  default: {
747
- background: color.white,
748
- border: `1px solid ${color.offBlack50}`,
749
- color: color.offBlack,
753
+ background: states$1.default.background,
754
+ border: `${border.width.hairline}px solid ${states$1.default.border}`,
755
+ color: states$1.default.foreground,
750
756
  "::placeholder": {
751
- color: color.offBlack64
757
+ color: semanticColor.text.secondary
752
758
  }
753
759
  },
754
760
  defaultFocus: {
755
761
  ":focus-visible": {
756
- borderColor: color.blue,
757
- outline: `1px solid ${color.blue}`,
758
- outlineOffset: "-2px"
762
+ borderColor: semanticColor.border.focus,
763
+ outline: `${border.width.hairline}px solid ${semanticColor.border.focus}`,
764
+ outlineOffset: -2
759
765
  }
760
766
  },
761
767
  error: {
762
- background: color.fadedRed8,
763
- border: `1px solid ${color.red}`,
764
- color: color.offBlack,
768
+ background: states$1.error.background,
769
+ border: `${border.width.hairline}px solid ${states$1.error.border}`,
770
+ color: states$1.error.foreground,
765
771
  "::placeholder": {
766
- color: color.offBlack64
772
+ color: semanticColor.text.secondary
767
773
  },
768
774
  ":focus-visible": {
769
- outlineColor: color.red,
770
- borderColor: color.red
775
+ outlineColor: states$1.error.border,
776
+ borderColor: states$1.error.border
771
777
  }
772
778
  },
773
779
  disabled: {
774
- background: color.offWhite,
775
- border: `1px solid ${color.offBlack16}`,
776
- color: color.offBlack64,
777
- "::placeholder": {
778
- color: color.offBlack64
779
- },
780
- cursor: "not-allowed",
781
- ":focus-visible": {
782
- outline: `2px solid ${color.offBlack32}`,
783
- outlineOffset: "-3px"
784
- }
785
- },
786
- light: {
787
- background: color.white,
788
- border: `1px solid ${color.offBlack16}`,
789
- color: color.offBlack,
790
- "::placeholder": {
791
- color: color.offBlack64
792
- }
793
- },
794
- lightFocus: {
795
- ":focus-visible": {
796
- outline: `3px solid ${color.blue}`,
797
- outlineOffset: "-4px",
798
- borderColor: color.white
799
- }
800
- },
801
- lightDisabled: {
802
- backgroundColor: "transparent",
803
- border: `1px solid ${color.white32}`,
804
- color: color.white64,
780
+ background: states$1.disabled.background,
781
+ border: `${border.width.hairline}px solid ${states$1.disabled.border}`,
782
+ color: states$1.disabled.foreground,
805
783
  "::placeholder": {
806
- color: color.white64
784
+ color: states$1.disabled.foreground
807
785
  },
808
786
  cursor: "not-allowed",
809
787
  ":focus-visible": {
810
- borderColor: mix(color.white32, color.blue),
811
- outline: `3px solid ${color.fadedBlue}`,
812
- outlineOffset: "-4px"
813
- }
814
- },
815
- lightError: {
816
- background: color.fadedRed8,
817
- border: `1px solid ${color.white}`,
818
- outline: `2px solid ${color.red}`,
819
- outlineOffset: "-3px",
820
- color: color.offBlack,
821
- "::placeholder": {
822
- color: color.offBlack64
823
- },
824
- ":focus-visible": {
825
- outline: `3px solid ${color.red}`,
826
- outlineOffset: "-4px"
788
+ outline: `${border.width.thin}px solid ${semanticColor.action.disabled.default}`,
789
+ outlineOffset: -3
827
790
  }
828
791
  }
829
792
  });
@@ -838,15 +801,14 @@ class FieldHeading extends React.Component {
838
801
  label,
839
802
  id,
840
803
  required,
841
- testId,
842
- light
804
+ testId
843
805
  } = this.props;
844
806
  const requiredIcon = React.createElement(StyledSpan, {
845
- style: light ? styles$1.lightRequired : styles$1.required,
807
+ style: styles$1.required,
846
808
  "aria-hidden": true
847
809
  }, " ", "*");
848
810
  return React.createElement(React.Fragment, null, React.createElement(LabelMedium, {
849
- style: light ? styles$1.lightLabel : styles$1.label,
811
+ style: styles$1.label,
850
812
  tag: "label",
851
813
  htmlFor: id && `${id}-field`,
852
814
  testId: testId && `${testId}-label`
@@ -857,14 +819,13 @@ class FieldHeading extends React.Component {
857
819
  maybeRenderDescription() {
858
820
  const {
859
821
  description,
860
- testId,
861
- light
822
+ testId
862
823
  } = this.props;
863
824
  if (!description) {
864
825
  return null;
865
826
  }
866
827
  return React.createElement(React.Fragment, null, React.createElement(LabelSmall, {
867
- style: light ? styles$1.lightDescription : styles$1.description,
828
+ style: styles$1.description,
868
829
  testId: testId && `${testId}-description`
869
830
  }, description), React.createElement(Strut, {
870
831
  size: spacing.xxxSmall_4
@@ -874,8 +835,7 @@ class FieldHeading extends React.Component {
874
835
  const {
875
836
  error,
876
837
  id,
877
- testId,
878
- light
838
+ testId
879
839
  } = this.props;
880
840
  if (!error) {
881
841
  return null;
@@ -883,7 +843,7 @@ class FieldHeading extends React.Component {
883
843
  return React.createElement(React.Fragment, null, React.createElement(Strut, {
884
844
  size: spacing.small_12
885
845
  }), React.createElement(LabelSmall, {
886
- style: light ? styles$1.lightError : styles$1.error,
846
+ style: styles$1.error,
887
847
  role: "alert",
888
848
  id: id && `${id}-error`,
889
849
  testId: testId && `${testId}-error`
@@ -903,32 +863,20 @@ class FieldHeading extends React.Component {
903
863
  }
904
864
  const styles$1 = StyleSheet.create({
905
865
  label: {
906
- color: color.offBlack
907
- },
908
- lightLabel: {
909
- color: color.white
866
+ color: semanticColor.text.primary
910
867
  },
911
868
  description: {
912
- color: color.offBlack64
913
- },
914
- lightDescription: {
915
- color: color.white64
869
+ color: semanticColor.text.secondary
916
870
  },
917
871
  error: {
918
- color: color.red
919
- },
920
- lightError: {
921
- color: color.fadedRed
872
+ color: semanticColor.status.critical.foreground
922
873
  },
923
874
  required: {
924
- color: color.red
925
- },
926
- lightRequired: {
927
- color: color.fadedRed
875
+ color: semanticColor.status.critical.foreground
928
876
  }
929
877
  });
930
878
 
931
- const _excluded$1 = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "ariaDescribedby", "name", "onValidate", "onFocus", "onBlur"];
879
+ const _excluded$1 = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "ariaDescribedby", "name", "onValidate", "onFocus", "onBlur"];
932
880
  class LabeledTextField extends React.Component {
933
881
  constructor(props) {
934
882
  super(props);
@@ -987,7 +935,6 @@ class LabeledTextField extends React.Component {
987
935
  onChange,
988
936
  onKeyDown,
989
937
  placeholder,
990
- light,
991
938
  style,
992
939
  testId,
993
940
  readOnly,
@@ -1003,7 +950,6 @@ class LabeledTextField extends React.Component {
1003
950
  id: uniqueId,
1004
951
  testId: testId,
1005
952
  style: style,
1006
- light: light,
1007
953
  field: React.createElement(TextField$1, _extends({
1008
954
  id: `${uniqueId}-field`,
1009
955
  "aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
@@ -1020,7 +966,6 @@ class LabeledTextField extends React.Component {
1020
966
  onKeyDown: onKeyDown,
1021
967
  onFocus: this.handleFocus,
1022
968
  onBlur: this.handleBlur,
1023
- light: light,
1024
969
  readOnly: readOnly,
1025
970
  autoComplete: autoComplete,
1026
971
  ref: forwardedRef,
@@ -1035,14 +980,13 @@ class LabeledTextField extends React.Component {
1035
980
  }
1036
981
  LabeledTextField.defaultProps = {
1037
982
  type: "text",
1038
- disabled: false,
1039
- light: false
983
+ disabled: false
1040
984
  };
1041
985
  var labeledTextField = React.forwardRef((props, ref) => React.createElement(LabeledTextField, _extends({}, props, {
1042
986
  forwardedRef: ref
1043
987
  })));
1044
988
 
1045
- 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", "light", "rootStyle", "error", "instantValidation"];
989
+ 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"];
1046
990
  const StyledTextArea = addStyle("textarea");
1047
991
  const TextArea = React.forwardRef(function TextArea(props, ref) {
1048
992
  const {
@@ -1072,7 +1016,6 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
1072
1016
  onValidate,
1073
1017
  required,
1074
1018
  resizeType,
1075
- light,
1076
1019
  rootStyle,
1077
1020
  error,
1078
1021
  instantValidation = true
@@ -1104,12 +1047,6 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
1104
1047
  onBlur(event);
1105
1048
  }
1106
1049
  };
1107
- const getStyles = () => {
1108
- const baseStyles = [styles.textarea, styles$7.LabelMedium, resizeType && resizeStyles[resizeType]];
1109
- const defaultStyles = [styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error];
1110
- const lightStyles = [styles.light, !disabled && styles.lightFocus, disabled && styles.lightDisabled, hasError && styles.lightError];
1111
- return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
1112
- };
1113
1050
  return React.createElement(View, {
1114
1051
  style: [{
1115
1052
  width: "100%"
@@ -1119,7 +1056,7 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
1119
1056
  "data-testid": testId,
1120
1057
  ref: ref,
1121
1058
  className: className,
1122
- style: [getStyles(), style],
1059
+ style: [styles.textarea, styles$7.LabelMedium, resizeType && resizeStyles[resizeType], styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error, style],
1123
1060
  value: value,
1124
1061
  onChange: handleChange,
1125
1062
  placeholder: placeholder,
@@ -1145,6 +1082,23 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
1145
1082
  })));
1146
1083
  });
1147
1084
  const VERTICAL_SPACING_PX = 10;
1085
+ const states = {
1086
+ default: {
1087
+ border: semanticColor.border.strong,
1088
+ background: semanticColor.surface.primary,
1089
+ foreground: semanticColor.text.primary
1090
+ },
1091
+ disabled: {
1092
+ border: semanticColor.border.primary,
1093
+ background: semanticColor.action.disabled.secondary,
1094
+ foreground: semanticColor.text.secondary
1095
+ },
1096
+ error: {
1097
+ border: semanticColor.status.critical.foreground,
1098
+ background: semanticColor.status.critical.background,
1099
+ foreground: semanticColor.text.primary
1100
+ }
1101
+ };
1148
1102
  const styles = StyleSheet.create({
1149
1103
  textarea: {
1150
1104
  borderRadius: border.radius.medium_4,
@@ -1153,86 +1107,43 @@ const styles = StyleSheet.create({
1153
1107
  minHeight: `${VERTICAL_SPACING_PX * 2 + font.lineHeight.medium + 2 * border.width.hairline}px`
1154
1108
  },
1155
1109
  default: {
1156
- background: color.white,
1157
- border: `1px solid ${color.offBlack50}`,
1158
- color: color.offBlack,
1110
+ background: states.default.background,
1111
+ border: `${border.width.hairline}px solid ${states.default.border}`,
1112
+ color: states.default.foreground,
1159
1113
  "::placeholder": {
1160
- color: color.offBlack64
1114
+ color: semanticColor.text.secondary
1161
1115
  }
1162
1116
  },
1163
1117
  defaultFocus: {
1164
1118
  ":focus-visible": {
1165
- borderColor: color.blue,
1166
- outline: `1px solid ${color.blue}`,
1167
- outlineOffset: "-2px"
1119
+ borderColor: semanticColor.border.focus,
1120
+ outline: `${border.width.hairline}px solid ${semanticColor.border.focus}`,
1121
+ outlineOffset: -2
1168
1122
  }
1169
1123
  },
1170
1124
  disabled: {
1171
- background: color.offWhite,
1172
- border: `1px solid ${color.offBlack16}`,
1173
- color: color.offBlack64,
1125
+ background: states.disabled.background,
1126
+ border: `${border.width.hairline}px solid ${states.disabled.border}`,
1127
+ color: states.disabled.foreground,
1174
1128
  "::placeholder": {
1175
- color: color.offBlack64
1129
+ color: states.disabled.foreground
1176
1130
  },
1177
1131
  cursor: "not-allowed",
1178
1132
  ":focus-visible": {
1179
- outline: `2px solid ${color.offBlack32}`,
1180
- outlineOffset: "-3px"
1133
+ outline: `${border.width.thin}px solid ${semanticColor.action.disabled.default}`,
1134
+ outlineOffset: -3
1181
1135
  }
1182
1136
  },
1183
1137
  error: {
1184
- background: color.fadedRed8,
1185
- border: `1px solid ${color.red}`,
1186
- color: color.offBlack,
1187
- "::placeholder": {
1188
- color: color.offBlack64
1189
- },
1190
- ":focus-visible": {
1191
- outlineColor: color.red,
1192
- borderColor: color.red
1193
- }
1194
- },
1195
- light: {
1196
- background: color.white,
1197
- border: `1px solid ${color.offBlack16}`,
1198
- color: color.offBlack,
1199
- "::placeholder": {
1200
- color: color.offBlack64
1201
- }
1202
- },
1203
- lightFocus: {
1204
- ":focus-visible": {
1205
- outline: `3px solid ${color.blue}`,
1206
- outlineOffset: "-4px",
1207
- borderColor: color.white
1208
- }
1209
- },
1210
- lightDisabled: {
1211
- backgroundColor: "transparent",
1212
- border: `1px solid ${color.white32}`,
1213
- color: color.white64,
1214
- "::placeholder": {
1215
- color: color.white64
1216
- },
1217
- cursor: "not-allowed",
1218
- ":focus-visible": {
1219
- borderColor: mix(color.white32, color.blue),
1220
- outline: `3px solid ${color.fadedBlue}`,
1221
- outlineOffset: "-4px"
1222
- }
1223
- },
1224
- lightError: {
1225
- background: color.fadedRed8,
1226
- border: `1px solid ${color.white}`,
1227
- outline: `2px solid ${color.red}`,
1228
- outlineOffset: "-3px",
1229
- color: color.offBlack,
1138
+ background: states.error.background,
1139
+ border: `${border.width.hairline}px solid ${states.error.border}`,
1140
+ color: states.error.foreground,
1230
1141
  "::placeholder": {
1231
- color: color.offBlack64
1142
+ color: semanticColor.text.secondary
1232
1143
  },
1233
1144
  ":focus-visible": {
1234
- outline: `3px solid ${color.red}`,
1235
- outlineOffset: "-4px"
1145
+ outlineColor: states.error.border,
1146
+ borderColor: states.error.border
1236
1147
  }
1237
1148
  }
1238
1149
  });