@khanacademy/wonder-blocks-form 7.1.0 → 7.1.2
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 +37 -0
- package/dist/components/labeled-text-field.d.ts +4 -0
- package/dist/components/text-area.d.ts +11 -0
- package/dist/components/text-field.d.ts +7 -0
- package/dist/es/index.js +25 -25
- package/dist/index.js +57 -48
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-form
|
|
2
2
|
|
|
3
|
+
## 7.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5655b9f: Switch to use `focus.outer` semanticColor token
|
|
8
|
+
- 7bb37a2: Update component docs to include labelling guidelines
|
|
9
|
+
- 8f53293: Rename action tokens: `filled` -> `primary`, `outlined` -> `secondary`.
|
|
10
|
+
- 051f0f8: Rework action.disabled tokens to include properties per kind (border, background, foreground).
|
|
11
|
+
- 7bb37a2: Marking LabeledTextField with `@deprecated` in favour of LabeledField + TextField
|
|
12
|
+
- Updated dependencies [ed26d66]
|
|
13
|
+
- Updated dependencies [5655b9f]
|
|
14
|
+
- Updated dependencies [5655b9f]
|
|
15
|
+
- Updated dependencies [8f53293]
|
|
16
|
+
- Updated dependencies [051f0f8]
|
|
17
|
+
- Updated dependencies [8fc65a9]
|
|
18
|
+
- Updated dependencies [e1b78db]
|
|
19
|
+
- Updated dependencies [051f0f8]
|
|
20
|
+
- @khanacademy/wonder-blocks-core@12.2.0
|
|
21
|
+
- @khanacademy/wonder-blocks-tokens@5.0.0
|
|
22
|
+
- @khanacademy/wonder-blocks-clickable@6.1.2
|
|
23
|
+
- @khanacademy/wonder-blocks-icon@5.1.2
|
|
24
|
+
- @khanacademy/wonder-blocks-layout@3.1.2
|
|
25
|
+
- @khanacademy/wonder-blocks-typography@3.1.2
|
|
26
|
+
|
|
27
|
+
## 7.1.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- ee8d95a: Rollback rollup version from v4 to v2 to prevent an issue with CJS builds in unit tests
|
|
32
|
+
- Updated dependencies [ee8d95a]
|
|
33
|
+
- @khanacademy/wonder-blocks-clickable@6.1.1
|
|
34
|
+
- @khanacademy/wonder-blocks-core@12.1.1
|
|
35
|
+
- @khanacademy/wonder-blocks-icon@5.1.1
|
|
36
|
+
- @khanacademy/wonder-blocks-layout@3.1.1
|
|
37
|
+
- @khanacademy/wonder-blocks-tokens@4.2.1
|
|
38
|
+
- @khanacademy/wonder-blocks-typography@3.1.1
|
|
39
|
+
|
|
3
40
|
## 7.1.0
|
|
4
41
|
|
|
5
42
|
### Minor Changes
|
|
@@ -158,9 +158,13 @@ declare class LabeledTextField extends React.Component<PropsWithForwardRef, Stat
|
|
|
158
158
|
}
|
|
159
159
|
type ExportProps = OmitConstrained<JSX.LibraryManagedAttributes<typeof LabeledTextField, React.ComponentProps<typeof LabeledTextField>>, "forwardedRef">;
|
|
160
160
|
/**
|
|
161
|
+
* **DEPRECATED**: Please use `LabeledField` with `TextField` instead.
|
|
162
|
+
*
|
|
161
163
|
* A LabeledTextField is an element used to accept a single line of text
|
|
162
164
|
* from the user paired with a label, description, and error field elements.
|
|
163
165
|
*
|
|
166
|
+
* @deprecated
|
|
167
|
+
*
|
|
164
168
|
* ### Usage
|
|
165
169
|
*
|
|
166
170
|
* ```jsx
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
/**
|
|
4
|
+
* A TextArea is an element used to accept text from the user.
|
|
5
|
+
*
|
|
6
|
+
* Make sure to provide a label for the field. This can be done by either:
|
|
7
|
+
* - (recommended) Using the **LabeledField** component to provide a label,
|
|
8
|
+
* description, and/or error message for the field
|
|
9
|
+
* - Using a `label` html tag with the `htmlFor` prop set to the unique id of
|
|
10
|
+
* the field
|
|
11
|
+
* - Using an `aria-label` attribute on the field
|
|
12
|
+
* - Using an `aria-labelledby` attribute on the field
|
|
13
|
+
*/
|
|
3
14
|
declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
4
15
|
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
5
16
|
}> & {
|
|
@@ -152,6 +152,13 @@ type ExportProps = OmitConstrained<JSX.LibraryManagedAttributes<typeof TextField
|
|
|
152
152
|
/**
|
|
153
153
|
* A TextField is an element used to accept a single line of text from the user.
|
|
154
154
|
*
|
|
155
|
+
* Make sure to provide a label for the field. This can be done by either:
|
|
156
|
+
* - (recommended) Using the **LabeledField** component to provide a label,
|
|
157
|
+
* description, and/or error message for the field
|
|
158
|
+
* - Using a `label` html tag with the `htmlFor` prop set to the unique id of
|
|
159
|
+
* the field
|
|
160
|
+
* - Using an `aria-label` attribute on the field
|
|
161
|
+
* - Using an `aria-labelledby` attribute on the field
|
|
155
162
|
* ### Usage
|
|
156
163
|
*
|
|
157
164
|
* ```jsx
|
package/dist/es/index.js
CHANGED
|
@@ -78,8 +78,8 @@ const CheckboxCore = React.forwardRef(function CheckboxCore(props, ref) {
|
|
|
78
78
|
})), checked || checked == null ? checkboxIcon : React.createElement(React.Fragment, null));
|
|
79
79
|
});
|
|
80
80
|
const disabledState$1 = {
|
|
81
|
-
border: semanticColor.border
|
|
82
|
-
background: semanticColor.action.disabled.
|
|
81
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
82
|
+
background: semanticColor.action.secondary.disabled.background
|
|
83
83
|
};
|
|
84
84
|
const sharedStyles$1 = StyleSheet.create({
|
|
85
85
|
inputReset: {
|
|
@@ -119,7 +119,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
119
119
|
}
|
|
120
120
|
const isCheckedOrIndeterminate = checked || checked == null;
|
|
121
121
|
const actionType = error ? "destructive" : "progressive";
|
|
122
|
-
const styleType = isCheckedOrIndeterminate ? "
|
|
122
|
+
const styleType = isCheckedOrIndeterminate ? "primary" : "secondary";
|
|
123
123
|
const colorAction = semanticColor.action[styleType][actionType];
|
|
124
124
|
const states = {
|
|
125
125
|
default: {
|
|
@@ -138,7 +138,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
138
138
|
backgroundColor: states.default.background,
|
|
139
139
|
borderColor: states.default.border,
|
|
140
140
|
":focus-visible": {
|
|
141
|
-
outline: `${border.width.thin}px solid ${
|
|
141
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
142
142
|
outlineOffset: 1
|
|
143
143
|
},
|
|
144
144
|
":hover": {
|
|
@@ -160,7 +160,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
160
160
|
borderColor: currentState.border,
|
|
161
161
|
":focus-visible": {
|
|
162
162
|
backgroundColor: error ? states.error.background : colorAction.hover.background,
|
|
163
|
-
outline: `${border.width.thin}px solid ${
|
|
163
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
164
164
|
outlineOffset: -1
|
|
165
165
|
},
|
|
166
166
|
":hover": {
|
|
@@ -213,8 +213,8 @@ const RadioCore = React.forwardRef(function RadioCore(props, ref) {
|
|
|
213
213
|
}));
|
|
214
214
|
});
|
|
215
215
|
const disabledState = {
|
|
216
|
-
border: semanticColor.border
|
|
217
|
-
background: semanticColor.action.disabled.
|
|
216
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
217
|
+
background: semanticColor.action.secondary.disabled.background
|
|
218
218
|
};
|
|
219
219
|
const size = 16;
|
|
220
220
|
const disabledChecked = {
|
|
@@ -224,7 +224,7 @@ const disabledChecked = {
|
|
|
224
224
|
height: size / 2,
|
|
225
225
|
width: size / 2,
|
|
226
226
|
borderRadius: "50%",
|
|
227
|
-
backgroundColor: semanticColor.action.disabled.
|
|
227
|
+
backgroundColor: semanticColor.action.primary.disabled.background
|
|
228
228
|
};
|
|
229
229
|
const sharedStyles = StyleSheet.create({
|
|
230
230
|
inputReset: {
|
|
@@ -258,7 +258,7 @@ const _generateStyles = (checked, error) => {
|
|
|
258
258
|
return styles$5[styleKey];
|
|
259
259
|
}
|
|
260
260
|
const actionType = error ? "destructive" : "progressive";
|
|
261
|
-
const colorAction = semanticColor.action.
|
|
261
|
+
const colorAction = semanticColor.action.secondary[actionType];
|
|
262
262
|
const states = {
|
|
263
263
|
unchecked: {
|
|
264
264
|
border: semanticColor.border.strong,
|
|
@@ -281,7 +281,7 @@ const _generateStyles = (checked, error) => {
|
|
|
281
281
|
borderColor: states.checked.border,
|
|
282
282
|
borderWidth: size / 4,
|
|
283
283
|
":focus-visible": {
|
|
284
|
-
outline: `${border.width.thin}px solid ${
|
|
284
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
285
285
|
outlineOffset: 1
|
|
286
286
|
},
|
|
287
287
|
":hover": {
|
|
@@ -303,7 +303,7 @@ const _generateStyles = (checked, error) => {
|
|
|
303
303
|
borderColor: currentState.border,
|
|
304
304
|
":focus-visible": {
|
|
305
305
|
backgroundColor: error ? states.error.background : colorAction.hover.background,
|
|
306
|
-
outline: `${border.width.thin}px solid ${
|
|
306
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
307
307
|
outlineOffset: -1
|
|
308
308
|
},
|
|
309
309
|
":hover": {
|
|
@@ -399,7 +399,7 @@ const styles$4 = StyleSheet.create({
|
|
|
399
399
|
marginTop: -2
|
|
400
400
|
},
|
|
401
401
|
disabledLabel: {
|
|
402
|
-
color: semanticColor.
|
|
402
|
+
color: semanticColor.action.secondary.disabled.foreground
|
|
403
403
|
},
|
|
404
404
|
description: {
|
|
405
405
|
marginLeft: spacing.medium_16 + spacing.xSmall_8,
|
|
@@ -731,8 +731,8 @@ const states$1 = {
|
|
|
731
731
|
foreground: semanticColor.text.primary
|
|
732
732
|
},
|
|
733
733
|
disabled: {
|
|
734
|
-
border: semanticColor.border
|
|
735
|
-
background: semanticColor.action.disabled.
|
|
734
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
735
|
+
background: semanticColor.action.secondary.disabled.background,
|
|
736
736
|
foreground: semanticColor.text.secondary
|
|
737
737
|
},
|
|
738
738
|
error: {
|
|
@@ -760,8 +760,8 @@ const styles$2 = StyleSheet.create({
|
|
|
760
760
|
},
|
|
761
761
|
defaultFocus: {
|
|
762
762
|
":focus-visible": {
|
|
763
|
-
borderColor: semanticColor.
|
|
764
|
-
outline: `${border.width.hairline}px solid ${semanticColor.
|
|
763
|
+
borderColor: semanticColor.focus.outer,
|
|
764
|
+
outline: `${border.width.hairline}px solid ${semanticColor.focus.outer}`,
|
|
765
765
|
outlineOffset: -2
|
|
766
766
|
}
|
|
767
767
|
},
|
|
@@ -773,8 +773,8 @@ const styles$2 = StyleSheet.create({
|
|
|
773
773
|
color: semanticColor.text.secondary
|
|
774
774
|
},
|
|
775
775
|
":focus-visible": {
|
|
776
|
-
outlineColor:
|
|
777
|
-
|
|
776
|
+
outlineColor: semanticColor.focus.outer,
|
|
777
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`
|
|
778
778
|
}
|
|
779
779
|
},
|
|
780
780
|
disabled: {
|
|
@@ -786,7 +786,7 @@ const styles$2 = StyleSheet.create({
|
|
|
786
786
|
},
|
|
787
787
|
cursor: "not-allowed",
|
|
788
788
|
":focus-visible": {
|
|
789
|
-
outline: `${border.width.thin}px solid ${semanticColor.
|
|
789
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
790
790
|
outlineOffset: -3
|
|
791
791
|
}
|
|
792
792
|
}
|
|
@@ -1090,8 +1090,8 @@ const states = {
|
|
|
1090
1090
|
foreground: semanticColor.text.primary
|
|
1091
1091
|
},
|
|
1092
1092
|
disabled: {
|
|
1093
|
-
border: semanticColor.border
|
|
1094
|
-
background: semanticColor.action.disabled.
|
|
1093
|
+
border: semanticColor.action.secondary.disabled.border,
|
|
1094
|
+
background: semanticColor.action.secondary.disabled.background,
|
|
1095
1095
|
foreground: semanticColor.text.secondary
|
|
1096
1096
|
},
|
|
1097
1097
|
error: {
|
|
@@ -1117,8 +1117,8 @@ const styles = StyleSheet.create({
|
|
|
1117
1117
|
},
|
|
1118
1118
|
defaultFocus: {
|
|
1119
1119
|
":focus-visible": {
|
|
1120
|
-
borderColor: semanticColor.
|
|
1121
|
-
outline: `${border.width.hairline}px solid ${semanticColor.
|
|
1120
|
+
borderColor: semanticColor.focus.outer,
|
|
1121
|
+
outline: `${border.width.hairline}px solid ${semanticColor.focus.outer}`,
|
|
1122
1122
|
outlineOffset: -2
|
|
1123
1123
|
}
|
|
1124
1124
|
},
|
|
@@ -1131,7 +1131,7 @@ const styles = StyleSheet.create({
|
|
|
1131
1131
|
},
|
|
1132
1132
|
cursor: "not-allowed",
|
|
1133
1133
|
":focus-visible": {
|
|
1134
|
-
outline: `${border.width.thin}px solid ${semanticColor.
|
|
1134
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
1135
1135
|
outlineOffset: -3
|
|
1136
1136
|
}
|
|
1137
1137
|
},
|
|
@@ -1143,7 +1143,7 @@ const styles = StyleSheet.create({
|
|
|
1143
1143
|
color: semanticColor.text.secondary
|
|
1144
1144
|
},
|
|
1145
1145
|
":focus-visible": {
|
|
1146
|
-
|
|
1146
|
+
outline: `${border.width.thin}px solid ${semanticColor.focus.outer}`,
|
|
1147
1147
|
borderColor: states.error.border
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
4
6
|
var React = require('react');
|
|
5
7
|
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
@@ -12,7 +14,10 @@ var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
|
|
|
12
14
|
var checkIcon = require('@phosphor-icons/core/bold/check-bold.svg');
|
|
13
15
|
var minusIcon = require('@phosphor-icons/core/bold/minus-bold.svg');
|
|
14
16
|
|
|
15
|
-
function
|
|
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;
|
|
16
21
|
var n = Object.create(null);
|
|
17
22
|
if (e) {
|
|
18
23
|
Object.keys(e).forEach(function (k) {
|
|
@@ -25,11 +30,15 @@ function _interopNamespaceDefault(e) {
|
|
|
25
30
|
}
|
|
26
31
|
});
|
|
27
32
|
}
|
|
28
|
-
n
|
|
33
|
+
n["default"] = e;
|
|
29
34
|
return Object.freeze(n);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
var
|
|
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);
|
|
33
42
|
|
|
34
43
|
const _excluded$7 = ["checked", "disabled", "error", "groupName", "id", "testId"];
|
|
35
44
|
function mapCheckedToAriaChecked(value) {
|
|
@@ -54,7 +63,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
|
|
|
54
63
|
id,
|
|
55
64
|
testId
|
|
56
65
|
} = props,
|
|
57
|
-
sharedProps =
|
|
66
|
+
sharedProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$7);
|
|
58
67
|
const innerRef = React__namespace.useRef(null);
|
|
59
68
|
React__namespace.useEffect(() => {
|
|
60
69
|
if (innerRef.current != null) {
|
|
@@ -68,7 +77,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
|
|
|
68
77
|
const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, !disabled && stateStyles.default, disabled && sharedStyles$1.disabled];
|
|
69
78
|
const checkboxIcon = React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
70
79
|
color: disabled ? wonderBlocksTokens.semanticColor.icon.disabled : wonderBlocksTokens.semanticColor.icon.inverse,
|
|
71
|
-
icon: checked ?
|
|
80
|
+
icon: checked ? checkIcon__default["default"] : minusIcon__default["default"],
|
|
72
81
|
size: "small",
|
|
73
82
|
style: [sharedStyles$1.checkboxIcon, {
|
|
74
83
|
width: checkSize,
|
|
@@ -76,7 +85,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
|
|
|
76
85
|
}]
|
|
77
86
|
});
|
|
78
87
|
const ariaChecked = mapCheckedToAriaChecked(checked);
|
|
79
|
-
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$2,
|
|
88
|
+
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$2, _extends__default["default"]({}, sharedProps, {
|
|
80
89
|
ref: node => {
|
|
81
90
|
innerRef.current = node;
|
|
82
91
|
if (typeof ref === "function") {
|
|
@@ -98,8 +107,8 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
|
|
|
98
107
|
})), checked || checked == null ? checkboxIcon : React__namespace.createElement(React__namespace.Fragment, null));
|
|
99
108
|
});
|
|
100
109
|
const disabledState$1 = {
|
|
101
|
-
border: wonderBlocksTokens.semanticColor.border
|
|
102
|
-
background: wonderBlocksTokens.semanticColor.action.disabled.
|
|
110
|
+
border: wonderBlocksTokens.semanticColor.action.secondary.disabled.border,
|
|
111
|
+
background: wonderBlocksTokens.semanticColor.action.secondary.disabled.background
|
|
103
112
|
};
|
|
104
113
|
const sharedStyles$1 = aphrodite.StyleSheet.create({
|
|
105
114
|
inputReset: {
|
|
@@ -139,7 +148,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
139
148
|
}
|
|
140
149
|
const isCheckedOrIndeterminate = checked || checked == null;
|
|
141
150
|
const actionType = error ? "destructive" : "progressive";
|
|
142
|
-
const styleType = isCheckedOrIndeterminate ? "
|
|
151
|
+
const styleType = isCheckedOrIndeterminate ? "primary" : "secondary";
|
|
143
152
|
const colorAction = wonderBlocksTokens.semanticColor.action[styleType][actionType];
|
|
144
153
|
const states = {
|
|
145
154
|
default: {
|
|
@@ -158,7 +167,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
158
167
|
backgroundColor: states.default.background,
|
|
159
168
|
borderColor: states.default.border,
|
|
160
169
|
":focus-visible": {
|
|
161
|
-
outline: `${wonderBlocksTokens.border.width.thin}px solid ${
|
|
170
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
162
171
|
outlineOffset: 1
|
|
163
172
|
},
|
|
164
173
|
":hover": {
|
|
@@ -180,7 +189,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
180
189
|
borderColor: currentState.border,
|
|
181
190
|
":focus-visible": {
|
|
182
191
|
backgroundColor: error ? states.error.background : colorAction.hover.background,
|
|
183
|
-
outline: `${wonderBlocksTokens.border.width.thin}px solid ${
|
|
192
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
184
193
|
outlineOffset: -1
|
|
185
194
|
},
|
|
186
195
|
":hover": {
|
|
@@ -214,10 +223,10 @@ const RadioCore = React__namespace.forwardRef(function RadioCore(props, ref) {
|
|
|
214
223
|
id,
|
|
215
224
|
testId
|
|
216
225
|
} = props,
|
|
217
|
-
sharedProps =
|
|
226
|
+
sharedProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$6);
|
|
218
227
|
const stateStyles = _generateStyles(checked, error);
|
|
219
228
|
const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, !disabled && stateStyles.default, disabled && sharedStyles.disabled];
|
|
220
|
-
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1,
|
|
229
|
+
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends__default["default"]({}, sharedProps, {
|
|
221
230
|
type: "radio",
|
|
222
231
|
"aria-invalid": error,
|
|
223
232
|
checked: checked != null ? checked : undefined,
|
|
@@ -233,8 +242,8 @@ const RadioCore = React__namespace.forwardRef(function RadioCore(props, ref) {
|
|
|
233
242
|
}));
|
|
234
243
|
});
|
|
235
244
|
const disabledState = {
|
|
236
|
-
border: wonderBlocksTokens.semanticColor.border
|
|
237
|
-
background: wonderBlocksTokens.semanticColor.action.disabled.
|
|
245
|
+
border: wonderBlocksTokens.semanticColor.action.secondary.disabled.border,
|
|
246
|
+
background: wonderBlocksTokens.semanticColor.action.secondary.disabled.background
|
|
238
247
|
};
|
|
239
248
|
const size = 16;
|
|
240
249
|
const disabledChecked = {
|
|
@@ -244,7 +253,7 @@ const disabledChecked = {
|
|
|
244
253
|
height: size / 2,
|
|
245
254
|
width: size / 2,
|
|
246
255
|
borderRadius: "50%",
|
|
247
|
-
backgroundColor: wonderBlocksTokens.semanticColor.action.disabled.
|
|
256
|
+
backgroundColor: wonderBlocksTokens.semanticColor.action.primary.disabled.background
|
|
248
257
|
};
|
|
249
258
|
const sharedStyles = aphrodite.StyleSheet.create({
|
|
250
259
|
inputReset: {
|
|
@@ -278,7 +287,7 @@ const _generateStyles = (checked, error) => {
|
|
|
278
287
|
return styles$5[styleKey];
|
|
279
288
|
}
|
|
280
289
|
const actionType = error ? "destructive" : "progressive";
|
|
281
|
-
const colorAction = wonderBlocksTokens.semanticColor.action.
|
|
290
|
+
const colorAction = wonderBlocksTokens.semanticColor.action.secondary[actionType];
|
|
282
291
|
const states = {
|
|
283
292
|
unchecked: {
|
|
284
293
|
border: wonderBlocksTokens.semanticColor.border.strong,
|
|
@@ -301,7 +310,7 @@ const _generateStyles = (checked, error) => {
|
|
|
301
310
|
borderColor: states.checked.border,
|
|
302
311
|
borderWidth: size / 4,
|
|
303
312
|
":focus-visible": {
|
|
304
|
-
outline: `${wonderBlocksTokens.border.width.thin}px solid ${
|
|
313
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
305
314
|
outlineOffset: 1
|
|
306
315
|
},
|
|
307
316
|
":hover": {
|
|
@@ -323,7 +332,7 @@ const _generateStyles = (checked, error) => {
|
|
|
323
332
|
borderColor: currentState.border,
|
|
324
333
|
":focus-visible": {
|
|
325
334
|
backgroundColor: error ? states.error.background : colorAction.hover.background,
|
|
326
|
-
outline: `${wonderBlocksTokens.border.width.thin}px solid ${
|
|
335
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
327
336
|
outlineOffset: -1
|
|
328
337
|
},
|
|
329
338
|
":hover": {
|
|
@@ -357,7 +366,7 @@ const ChoiceInternal = React__namespace.forwardRef(function ChoiceInternal(props
|
|
|
357
366
|
className,
|
|
358
367
|
variant
|
|
359
368
|
} = props,
|
|
360
|
-
coreProps =
|
|
369
|
+
coreProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$5);
|
|
361
370
|
const handleClick = () => {
|
|
362
371
|
if (variant === "radio" && checked) {
|
|
363
372
|
return;
|
|
@@ -395,7 +404,7 @@ const ChoiceInternal = React__namespace.forwardRef(function ChoiceInternal(props
|
|
|
395
404
|
}, React__namespace.createElement(wonderBlocksCore.View, {
|
|
396
405
|
style: styles$4.wrapper,
|
|
397
406
|
tabIndex: -1
|
|
398
|
-
}, React__namespace.createElement(ChoiceCore,
|
|
407
|
+
}, React__namespace.createElement(ChoiceCore, _extends__default["default"]({}, coreProps, {
|
|
399
408
|
id: uniqueId,
|
|
400
409
|
checked: checked,
|
|
401
410
|
"aria-describedby": descriptionId,
|
|
@@ -419,7 +428,7 @@ const styles$4 = aphrodite.StyleSheet.create({
|
|
|
419
428
|
marginTop: -2
|
|
420
429
|
},
|
|
421
430
|
disabledLabel: {
|
|
422
|
-
color: wonderBlocksTokens.semanticColor.
|
|
431
|
+
color: wonderBlocksTokens.semanticColor.action.secondary.disabled.foreground
|
|
423
432
|
},
|
|
424
433
|
description: {
|
|
425
434
|
marginLeft: wonderBlocksTokens.spacing.medium_16 + wonderBlocksTokens.spacing.xSmall_8,
|
|
@@ -433,7 +442,7 @@ const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
|
433
442
|
disabled = false,
|
|
434
443
|
error = false
|
|
435
444
|
} = props;
|
|
436
|
-
return React__namespace.createElement(ChoiceInternal,
|
|
445
|
+
return React__namespace.createElement(ChoiceInternal, _extends__default["default"]({}, props, {
|
|
437
446
|
variant: "checkbox",
|
|
438
447
|
disabled: disabled,
|
|
439
448
|
error: error,
|
|
@@ -447,8 +456,8 @@ const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
|
447
456
|
disabled = false,
|
|
448
457
|
error = false
|
|
449
458
|
} = props,
|
|
450
|
-
otherProps =
|
|
451
|
-
return React__namespace.createElement(ChoiceInternal,
|
|
459
|
+
otherProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$4);
|
|
460
|
+
return React__namespace.createElement(ChoiceInternal, _extends__default["default"]({}, otherProps, {
|
|
452
461
|
variant: "radio",
|
|
453
462
|
disabled: disabled,
|
|
454
463
|
error: error,
|
|
@@ -464,7 +473,7 @@ const Choice = React__namespace.forwardRef(function Choice(props, ref) {
|
|
|
464
473
|
onChange = () => {},
|
|
465
474
|
variant
|
|
466
475
|
} = props,
|
|
467
|
-
remainingProps =
|
|
476
|
+
remainingProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$3);
|
|
468
477
|
const getChoiceComponent = variant => {
|
|
469
478
|
if (variant === "checkbox") {
|
|
470
479
|
return Checkbox;
|
|
@@ -473,7 +482,7 @@ const Choice = React__namespace.forwardRef(function Choice(props, ref) {
|
|
|
473
482
|
}
|
|
474
483
|
};
|
|
475
484
|
const ChoiceComponent = getChoiceComponent(variant);
|
|
476
|
-
return React__namespace.createElement(ChoiceComponent,
|
|
485
|
+
return React__namespace.createElement(ChoiceComponent, _extends__default["default"]({}, remainingProps, {
|
|
477
486
|
checked: checked,
|
|
478
487
|
disabled: disabled,
|
|
479
488
|
onChange: onChange,
|
|
@@ -691,7 +700,7 @@ const TextField = props => {
|
|
|
691
700
|
onFocus,
|
|
692
701
|
onBlur
|
|
693
702
|
} = props,
|
|
694
|
-
otherProps =
|
|
703
|
+
otherProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$2);
|
|
695
704
|
const {
|
|
696
705
|
errorMessage,
|
|
697
706
|
onBlurValidation,
|
|
@@ -723,7 +732,7 @@ const TextField = props => {
|
|
|
723
732
|
};
|
|
724
733
|
return React__namespace.createElement(wonderBlocksCore.Id, {
|
|
725
734
|
id: id
|
|
726
|
-
}, uniqueId => React__namespace.createElement(StyledInput,
|
|
735
|
+
}, uniqueId => React__namespace.createElement(StyledInput, _extends__default["default"]({
|
|
727
736
|
style: [styles$2.input, wonderBlocksTypography.styles.LabelMedium, styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error, style],
|
|
728
737
|
id: uniqueId,
|
|
729
738
|
type: type,
|
|
@@ -751,8 +760,8 @@ const states$1 = {
|
|
|
751
760
|
foreground: wonderBlocksTokens.semanticColor.text.primary
|
|
752
761
|
},
|
|
753
762
|
disabled: {
|
|
754
|
-
border: wonderBlocksTokens.semanticColor.border
|
|
755
|
-
background: wonderBlocksTokens.semanticColor.action.disabled.
|
|
763
|
+
border: wonderBlocksTokens.semanticColor.action.secondary.disabled.border,
|
|
764
|
+
background: wonderBlocksTokens.semanticColor.action.secondary.disabled.background,
|
|
756
765
|
foreground: wonderBlocksTokens.semanticColor.text.secondary
|
|
757
766
|
},
|
|
758
767
|
error: {
|
|
@@ -780,8 +789,8 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
780
789
|
},
|
|
781
790
|
defaultFocus: {
|
|
782
791
|
":focus-visible": {
|
|
783
|
-
borderColor: wonderBlocksTokens.semanticColor.
|
|
784
|
-
outline: `${wonderBlocksTokens.border.width.hairline}px solid ${wonderBlocksTokens.semanticColor.
|
|
792
|
+
borderColor: wonderBlocksTokens.semanticColor.focus.outer,
|
|
793
|
+
outline: `${wonderBlocksTokens.border.width.hairline}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
785
794
|
outlineOffset: -2
|
|
786
795
|
}
|
|
787
796
|
},
|
|
@@ -793,8 +802,8 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
793
802
|
color: wonderBlocksTokens.semanticColor.text.secondary
|
|
794
803
|
},
|
|
795
804
|
":focus-visible": {
|
|
796
|
-
outlineColor:
|
|
797
|
-
|
|
805
|
+
outlineColor: wonderBlocksTokens.semanticColor.focus.outer,
|
|
806
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`
|
|
798
807
|
}
|
|
799
808
|
},
|
|
800
809
|
disabled: {
|
|
@@ -806,12 +815,12 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
806
815
|
},
|
|
807
816
|
cursor: "not-allowed",
|
|
808
817
|
":focus-visible": {
|
|
809
|
-
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.
|
|
818
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
810
819
|
outlineOffset: -3
|
|
811
820
|
}
|
|
812
821
|
}
|
|
813
822
|
});
|
|
814
|
-
var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField,
|
|
823
|
+
var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends__default["default"]({}, props, {
|
|
815
824
|
forwardedRef: ref
|
|
816
825
|
})));
|
|
817
826
|
|
|
@@ -964,14 +973,14 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
964
973
|
ariaDescribedby,
|
|
965
974
|
name
|
|
966
975
|
} = _this$props,
|
|
967
|
-
otherProps =
|
|
976
|
+
otherProps = _objectWithoutPropertiesLoose__default["default"](_this$props, _excluded$1);
|
|
968
977
|
return React__namespace.createElement(wonderBlocksCore.Id, {
|
|
969
978
|
id: id
|
|
970
979
|
}, uniqueId => React__namespace.createElement(FieldHeading, {
|
|
971
980
|
id: uniqueId,
|
|
972
981
|
testId: testId,
|
|
973
982
|
style: style,
|
|
974
|
-
field: React__namespace.createElement(TextField$1,
|
|
983
|
+
field: React__namespace.createElement(TextField$1, _extends__default["default"]({
|
|
975
984
|
id: `${uniqueId}-field`,
|
|
976
985
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
977
986
|
"aria-required": required ? "true" : "false",
|
|
@@ -1003,7 +1012,7 @@ LabeledTextField.defaultProps = {
|
|
|
1003
1012
|
type: "text",
|
|
1004
1013
|
disabled: false
|
|
1005
1014
|
};
|
|
1006
|
-
var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField,
|
|
1015
|
+
var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField, _extends__default["default"]({}, props, {
|
|
1007
1016
|
forwardedRef: ref
|
|
1008
1017
|
})));
|
|
1009
1018
|
|
|
@@ -1041,7 +1050,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1041
1050
|
error,
|
|
1042
1051
|
instantValidation = true
|
|
1043
1052
|
} = props,
|
|
1044
|
-
otherProps =
|
|
1053
|
+
otherProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded);
|
|
1045
1054
|
const {
|
|
1046
1055
|
errorMessage,
|
|
1047
1056
|
onBlurValidation,
|
|
@@ -1072,7 +1081,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1072
1081
|
style: [{
|
|
1073
1082
|
width: "100%"
|
|
1074
1083
|
}, rootStyle]
|
|
1075
|
-
}, React__namespace.createElement(StyledTextarea,
|
|
1084
|
+
}, React__namespace.createElement(StyledTextarea, _extends__default["default"]({
|
|
1076
1085
|
id: uniqueId,
|
|
1077
1086
|
"data-testid": testId,
|
|
1078
1087
|
ref: ref,
|
|
@@ -1110,8 +1119,8 @@ const states = {
|
|
|
1110
1119
|
foreground: wonderBlocksTokens.semanticColor.text.primary
|
|
1111
1120
|
},
|
|
1112
1121
|
disabled: {
|
|
1113
|
-
border: wonderBlocksTokens.semanticColor.border
|
|
1114
|
-
background: wonderBlocksTokens.semanticColor.action.disabled.
|
|
1122
|
+
border: wonderBlocksTokens.semanticColor.action.secondary.disabled.border,
|
|
1123
|
+
background: wonderBlocksTokens.semanticColor.action.secondary.disabled.background,
|
|
1115
1124
|
foreground: wonderBlocksTokens.semanticColor.text.secondary
|
|
1116
1125
|
},
|
|
1117
1126
|
error: {
|
|
@@ -1137,8 +1146,8 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
1137
1146
|
},
|
|
1138
1147
|
defaultFocus: {
|
|
1139
1148
|
":focus-visible": {
|
|
1140
|
-
borderColor: wonderBlocksTokens.semanticColor.
|
|
1141
|
-
outline: `${wonderBlocksTokens.border.width.hairline}px solid ${wonderBlocksTokens.semanticColor.
|
|
1149
|
+
borderColor: wonderBlocksTokens.semanticColor.focus.outer,
|
|
1150
|
+
outline: `${wonderBlocksTokens.border.width.hairline}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
1142
1151
|
outlineOffset: -2
|
|
1143
1152
|
}
|
|
1144
1153
|
},
|
|
@@ -1151,7 +1160,7 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
1151
1160
|
},
|
|
1152
1161
|
cursor: "not-allowed",
|
|
1153
1162
|
":focus-visible": {
|
|
1154
|
-
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.
|
|
1163
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
1155
1164
|
outlineOffset: -3
|
|
1156
1165
|
}
|
|
1157
1166
|
},
|
|
@@ -1163,7 +1172,7 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
1163
1172
|
color: wonderBlocksTokens.semanticColor.text.secondary
|
|
1164
1173
|
},
|
|
1165
1174
|
":focus-visible": {
|
|
1166
|
-
|
|
1175
|
+
outline: `${wonderBlocksTokens.border.width.thin}px solid ${wonderBlocksTokens.semanticColor.focus.outer}`,
|
|
1167
1176
|
borderColor: states.error.border
|
|
1168
1177
|
}
|
|
1169
1178
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-form",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.2",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Form components for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/runtime": "^7.24.5",
|
|
16
|
-
"@khanacademy/wonder-blocks-clickable": "6.1.
|
|
17
|
-
"@khanacademy/wonder-blocks-core": "12.
|
|
18
|
-
"@khanacademy/wonder-blocks-icon": "5.1.
|
|
19
|
-
"@khanacademy/wonder-blocks-layout": "3.1.
|
|
20
|
-
"@khanacademy/wonder-blocks-tokens": "
|
|
21
|
-
"@khanacademy/wonder-blocks-typography": "3.1.
|
|
16
|
+
"@khanacademy/wonder-blocks-clickable": "6.1.2",
|
|
17
|
+
"@khanacademy/wonder-blocks-core": "12.2.0",
|
|
18
|
+
"@khanacademy/wonder-blocks-icon": "5.1.2",
|
|
19
|
+
"@khanacademy/wonder-blocks-layout": "3.1.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-tokens": "5.0.0",
|
|
21
|
+
"@khanacademy/wonder-blocks-typography": "3.1.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@phosphor-icons/core": "^2.0.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react": "18.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@khanacademy/wb-dev-build-settings": "2.1.
|
|
29
|
+
"@khanacademy/wb-dev-build-settings": "2.1.1"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"test": "echo \"Error: no test specified\" && exit 1"
|