@khanacademy/wonder-blocks-form 4.5.1 → 4.6.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/CHANGELOG.md +21 -0
- package/dist/components/labeled-text-field.d.ts +12 -7
- package/dist/components/text-field.d.ts +24 -6
- package/dist/es/index.js +37 -34
- package/dist/index.js +37 -34
- package/dist/util/types.d.ts +3 -0
- package/package.json +6 -6
- package/src/__tests__/__snapshots__/custom-snapshot.test.tsx.snap +165 -785
- package/src/__tests__/custom-snapshot.test.tsx +21 -23
- package/src/components/__tests__/labeled-text-field.test.tsx +41 -0
- package/src/components/labeled-text-field.tsx +23 -7
- package/src/components/text-field.tsx +27 -6
- package/src/util/types.ts +6 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-form
|
|
2
2
|
|
|
3
|
+
## 4.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 29563c0d: Fix onValidate prop so it gets properly called when it is defined in the call site
|
|
8
|
+
|
|
9
|
+
## 4.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 96515513: TextField number inputs can now use `min`, `max`, and `snap` props
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [5dfac06e]
|
|
18
|
+
- @khanacademy/wonder-blocks-core@6.4.1
|
|
19
|
+
- @khanacademy/wonder-blocks-clickable@4.2.2
|
|
20
|
+
- @khanacademy/wonder-blocks-icon@4.1.1
|
|
21
|
+
- @khanacademy/wonder-blocks-layout@2.0.33
|
|
22
|
+
- @khanacademy/wonder-blocks-typography@2.1.12
|
|
23
|
+
|
|
3
24
|
## 4.5.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
-
import {
|
|
3
|
+
import type { NumericInputProps } from "./text-field";
|
|
4
|
+
import { OmitConstrained } from "../util/types";
|
|
4
5
|
type WithForwardRef = {
|
|
5
6
|
forwardedRef: React.ForwardedRef<HTMLInputElement>;
|
|
6
7
|
};
|
|
7
|
-
type
|
|
8
|
+
type CommonProps = {
|
|
8
9
|
/**
|
|
9
10
|
* An optional unique identifier for the TextField.
|
|
10
11
|
* If no id is specified, a unique id will be auto-generated.
|
|
11
12
|
*/
|
|
12
13
|
id?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Determines the type of input. Defaults to text.
|
|
15
|
-
*/
|
|
16
|
-
type: TextFieldType;
|
|
17
14
|
/**
|
|
18
15
|
* Provide a label for the TextField.
|
|
19
16
|
*/
|
|
@@ -116,6 +113,14 @@ type Props = {
|
|
|
116
113
|
*/
|
|
117
114
|
autoComplete?: string;
|
|
118
115
|
};
|
|
116
|
+
type OtherInputProps = CommonProps & {
|
|
117
|
+
/**
|
|
118
|
+
* Determines the type of input. Defaults to text.
|
|
119
|
+
*/
|
|
120
|
+
type: "text" | "password" | "email" | "tel";
|
|
121
|
+
};
|
|
122
|
+
type FullNumericInputProps = NumericInputProps & CommonProps;
|
|
123
|
+
type Props = OtherInputProps | FullNumericInputProps;
|
|
119
124
|
type PropsWithForwardRef = Props & WithForwardRef;
|
|
120
125
|
type DefaultProps = {
|
|
121
126
|
type: PropsWithForwardRef["type"];
|
|
@@ -144,7 +149,7 @@ declare class LabeledTextField extends React.Component<PropsWithForwardRef, Stat
|
|
|
144
149
|
handleBlur: (event: React.FocusEvent<HTMLInputElement>) => unknown;
|
|
145
150
|
render(): React.ReactNode;
|
|
146
151
|
}
|
|
147
|
-
type ExportProps =
|
|
152
|
+
type ExportProps = OmitConstrained<JSX.LibraryManagedAttributes<typeof LabeledTextField, React.ComponentProps<typeof LabeledTextField>>, "forwardedRef">;
|
|
148
153
|
/**
|
|
149
154
|
* A LabeledTextField is an element used to accept a single line of text
|
|
150
155
|
* from the user paired with a label, description, and error field elements.
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { StyleType, AriaProps } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import { OmitConstrained } from "../util/types";
|
|
3
4
|
export type TextFieldType = "text" | "password" | "email" | "number" | "tel";
|
|
4
5
|
type WithForwardRef = {
|
|
5
6
|
forwardedRef: React.ForwardedRef<HTMLInputElement>;
|
|
6
7
|
};
|
|
7
|
-
type
|
|
8
|
+
type CommonProps = AriaProps & {
|
|
8
9
|
/**
|
|
9
10
|
* The unique identifier for the input.
|
|
10
11
|
*/
|
|
11
12
|
id: string;
|
|
12
|
-
/**
|
|
13
|
-
* Determines the type of input. Defaults to text.
|
|
14
|
-
*/
|
|
15
|
-
type: TextFieldType;
|
|
16
13
|
/**
|
|
17
14
|
* The input value.
|
|
18
15
|
*/
|
|
@@ -103,6 +100,27 @@ type Props = AriaProps & {
|
|
|
103
100
|
*/
|
|
104
101
|
autoComplete?: string;
|
|
105
102
|
};
|
|
103
|
+
type OtherInputProps = CommonProps & {
|
|
104
|
+
type: "text" | "password" | "email" | "tel";
|
|
105
|
+
};
|
|
106
|
+
export type NumericInputProps = {
|
|
107
|
+
type: "number";
|
|
108
|
+
/**
|
|
109
|
+
* The minimum numeric value for the input.
|
|
110
|
+
*/
|
|
111
|
+
min?: number;
|
|
112
|
+
/**
|
|
113
|
+
* The maximum numeric value for the input.
|
|
114
|
+
*/
|
|
115
|
+
max?: number;
|
|
116
|
+
/**
|
|
117
|
+
* The numeric value to increment or decrement by.
|
|
118
|
+
* Requires the input to be multiples of this value.
|
|
119
|
+
*/
|
|
120
|
+
step?: number;
|
|
121
|
+
};
|
|
122
|
+
type FullNumericInputProps = CommonProps & NumericInputProps;
|
|
123
|
+
type Props = OtherInputProps | FullNumericInputProps;
|
|
106
124
|
type PropsWithForwardRef = Props & WithForwardRef;
|
|
107
125
|
type DefaultProps = {
|
|
108
126
|
type: PropsWithForwardRef["type"];
|
|
@@ -133,7 +151,7 @@ declare class TextField extends React.Component<PropsWithForwardRef, State> {
|
|
|
133
151
|
handleBlur: (event: React.FocusEvent<HTMLInputElement>) => unknown;
|
|
134
152
|
render(): React.ReactNode;
|
|
135
153
|
}
|
|
136
|
-
type ExportProps =
|
|
154
|
+
type ExportProps = OmitConstrained<JSX.LibraryManagedAttributes<typeof TextField, React.ComponentProps<typeof TextField>>, "forwardedRef">;
|
|
137
155
|
/**
|
|
138
156
|
* A TextField is an element used to accept a single line of text from the user.
|
|
139
157
|
*
|
package/dist/es/index.js
CHANGED
|
@@ -36,7 +36,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
36
36
|
return target;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const _excluded$
|
|
39
|
+
const _excluded$6 = ["checked", "disabled", "error", "groupName", "id", "testId"];
|
|
40
40
|
function mapCheckedToAriaChecked(value) {
|
|
41
41
|
switch (value) {
|
|
42
42
|
case true:
|
|
@@ -68,7 +68,7 @@ const CheckboxCore = React.forwardRef(function CheckboxCore(props, ref) {
|
|
|
68
68
|
id,
|
|
69
69
|
testId
|
|
70
70
|
} = props,
|
|
71
|
-
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
71
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$6);
|
|
72
72
|
const innerRef = React.useRef(null);
|
|
73
73
|
React.useEffect(() => {
|
|
74
74
|
if (innerRef.current != null) {
|
|
@@ -209,7 +209,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
209
209
|
return styles$5[styleKey];
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
const _excluded$
|
|
212
|
+
const _excluded$5 = ["checked", "disabled", "error", "groupName", "id", "testId"];
|
|
213
213
|
const {
|
|
214
214
|
blue,
|
|
215
215
|
red,
|
|
@@ -232,7 +232,7 @@ const RadioCore = React.forwardRef(function RadioCore(props, ref) {
|
|
|
232
232
|
id,
|
|
233
233
|
testId
|
|
234
234
|
} = props,
|
|
235
|
-
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
235
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
236
236
|
const stateStyles = _generateStyles(checked, error);
|
|
237
237
|
const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, !disabled && stateStyles.default, disabled && sharedStyles.disabled];
|
|
238
238
|
return React.createElement(React.Fragment, null, React.createElement(StyledInput$1, _extends({}, sharedProps, {
|
|
@@ -352,7 +352,7 @@ const _generateStyles = (checked, error) => {
|
|
|
352
352
|
return styles$4[styleKey];
|
|
353
353
|
};
|
|
354
354
|
|
|
355
|
-
const _excluded$
|
|
355
|
+
const _excluded$4 = ["checked", "description", "disabled", "error", "id", "label", "onChange", "style", "className", "variant"];
|
|
356
356
|
const ChoiceInternal = React.forwardRef(function ChoiceInternal(props, ref) {
|
|
357
357
|
const {
|
|
358
358
|
checked,
|
|
@@ -366,7 +366,7 @@ const ChoiceInternal = React.forwardRef(function ChoiceInternal(props, ref) {
|
|
|
366
366
|
className,
|
|
367
367
|
variant
|
|
368
368
|
} = props,
|
|
369
|
-
coreProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
369
|
+
coreProps = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
370
370
|
const handleClick = () => {
|
|
371
371
|
if (variant === "radio" && checked) {
|
|
372
372
|
return;
|
|
@@ -451,13 +451,13 @@ const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
|
451
451
|
}));
|
|
452
452
|
});
|
|
453
453
|
|
|
454
|
-
const _excluded$
|
|
454
|
+
const _excluded$3 = ["disabled", "error"];
|
|
455
455
|
const Radio = React.forwardRef(function Radio(props, ref) {
|
|
456
456
|
const {
|
|
457
457
|
disabled = false,
|
|
458
458
|
error = false
|
|
459
459
|
} = props,
|
|
460
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
460
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
461
461
|
return React.createElement(ChoiceInternal, _extends({}, otherProps, {
|
|
462
462
|
variant: "radio",
|
|
463
463
|
disabled: disabled,
|
|
@@ -466,7 +466,7 @@ const Radio = React.forwardRef(function Radio(props, ref) {
|
|
|
466
466
|
}));
|
|
467
467
|
});
|
|
468
468
|
|
|
469
|
-
const _excluded$
|
|
469
|
+
const _excluded$2 = ["checked", "disabled", "onChange", "value", "variant"];
|
|
470
470
|
const Choice = React.forwardRef(function Choice(props, ref) {
|
|
471
471
|
const {
|
|
472
472
|
checked = false,
|
|
@@ -474,7 +474,7 @@ const Choice = React.forwardRef(function Choice(props, ref) {
|
|
|
474
474
|
onChange = () => {},
|
|
475
475
|
variant
|
|
476
476
|
} = props,
|
|
477
|
-
remainingProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
477
|
+
remainingProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
478
478
|
const getChoiceComponent = variant => {
|
|
479
479
|
if (variant === "checkbox") {
|
|
480
480
|
return Checkbox;
|
|
@@ -618,7 +618,7 @@ const RadioGroup = React.forwardRef(function RadioGroup(props, ref) {
|
|
|
618
618
|
})));
|
|
619
619
|
});
|
|
620
620
|
|
|
621
|
-
const _excluded = ["id", "type", "value", "name", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
|
|
621
|
+
const _excluded$1 = ["id", "type", "value", "name", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
|
|
622
622
|
const defaultErrorMessage = "This field is required.";
|
|
623
623
|
const StyledInput = addStyle("input");
|
|
624
624
|
class TextField extends React.Component {
|
|
@@ -714,7 +714,7 @@ class TextField extends React.Component {
|
|
|
714
714
|
autoComplete,
|
|
715
715
|
forwardedRef
|
|
716
716
|
} = _this$props,
|
|
717
|
-
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
717
|
+
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
|
|
718
718
|
return React.createElement(StyledInput, _extends({
|
|
719
719
|
style: [styles$1.input, styles$6.LabelMedium, styles$1.default, disabled ? styles$1.disabled : this.state.focused ? [styles$1.focused, light && styles$1.defaultLight] : !!this.state.error && [styles$1.error, light && styles$1.errorLight], !!this.state.error && styles$1.error, style && style],
|
|
720
720
|
id: id,
|
|
@@ -878,6 +878,7 @@ const styles = StyleSheet.create({
|
|
|
878
878
|
}
|
|
879
879
|
});
|
|
880
880
|
|
|
881
|
+
const _excluded = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "ariaDescribedby", "onValidate"];
|
|
881
882
|
class LabeledTextField extends React.Component {
|
|
882
883
|
constructor(props) {
|
|
883
884
|
super(props);
|
|
@@ -923,26 +924,28 @@ class LabeledTextField extends React.Component {
|
|
|
923
924
|
};
|
|
924
925
|
}
|
|
925
926
|
render() {
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
927
|
+
const _this$props = this.props,
|
|
928
|
+
{
|
|
929
|
+
id,
|
|
930
|
+
type,
|
|
931
|
+
label,
|
|
932
|
+
description,
|
|
933
|
+
value,
|
|
934
|
+
disabled,
|
|
935
|
+
required,
|
|
936
|
+
validate,
|
|
937
|
+
onChange,
|
|
938
|
+
onKeyDown,
|
|
939
|
+
placeholder,
|
|
940
|
+
light,
|
|
941
|
+
style,
|
|
942
|
+
testId,
|
|
943
|
+
readOnly,
|
|
944
|
+
autoComplete,
|
|
945
|
+
forwardedRef,
|
|
946
|
+
ariaDescribedby
|
|
947
|
+
} = _this$props,
|
|
948
|
+
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
946
949
|
return React.createElement(IDProvider, {
|
|
947
950
|
id: id,
|
|
948
951
|
scope: "labeled-text-field"
|
|
@@ -950,7 +953,7 @@ class LabeledTextField extends React.Component {
|
|
|
950
953
|
id: uniqueId,
|
|
951
954
|
testId: testId,
|
|
952
955
|
style: style,
|
|
953
|
-
field: React.createElement(TextField$1, {
|
|
956
|
+
field: React.createElement(TextField$1, _extends({
|
|
954
957
|
id: `${uniqueId}-field`,
|
|
955
958
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
956
959
|
"aria-required": required ? "true" : "false",
|
|
@@ -970,7 +973,7 @@ class LabeledTextField extends React.Component {
|
|
|
970
973
|
readOnly: readOnly,
|
|
971
974
|
autoComplete: autoComplete,
|
|
972
975
|
ref: forwardedRef
|
|
973
|
-
}),
|
|
976
|
+
}, otherProps)),
|
|
974
977
|
label: label,
|
|
975
978
|
description: description,
|
|
976
979
|
required: !!required,
|
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
64
64
|
return target;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const _excluded$
|
|
67
|
+
const _excluded$6 = ["checked", "disabled", "error", "groupName", "id", "testId"];
|
|
68
68
|
function mapCheckedToAriaChecked(value) {
|
|
69
69
|
switch (value) {
|
|
70
70
|
case true:
|
|
@@ -96,7 +96,7 @@ const CheckboxCore = React__namespace.forwardRef(function CheckboxCore(props, re
|
|
|
96
96
|
id,
|
|
97
97
|
testId
|
|
98
98
|
} = props,
|
|
99
|
-
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
99
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$6);
|
|
100
100
|
const innerRef = React__namespace.useRef(null);
|
|
101
101
|
React__namespace.useEffect(() => {
|
|
102
102
|
if (innerRef.current != null) {
|
|
@@ -237,7 +237,7 @@ const _generateStyles$1 = (checked, error) => {
|
|
|
237
237
|
return styles$5[styleKey];
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
-
const _excluded$
|
|
240
|
+
const _excluded$5 = ["checked", "disabled", "error", "groupName", "id", "testId"];
|
|
241
241
|
const {
|
|
242
242
|
blue,
|
|
243
243
|
red,
|
|
@@ -260,7 +260,7 @@ const RadioCore = React__namespace.forwardRef(function RadioCore(props, ref) {
|
|
|
260
260
|
id,
|
|
261
261
|
testId
|
|
262
262
|
} = props,
|
|
263
|
-
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
263
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
264
264
|
const stateStyles = _generateStyles(checked, error);
|
|
265
265
|
const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, !disabled && stateStyles.default, disabled && sharedStyles.disabled];
|
|
266
266
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends({}, sharedProps, {
|
|
@@ -380,7 +380,7 @@ const _generateStyles = (checked, error) => {
|
|
|
380
380
|
return styles$4[styleKey];
|
|
381
381
|
};
|
|
382
382
|
|
|
383
|
-
const _excluded$
|
|
383
|
+
const _excluded$4 = ["checked", "description", "disabled", "error", "id", "label", "onChange", "style", "className", "variant"];
|
|
384
384
|
const ChoiceInternal = React__namespace.forwardRef(function ChoiceInternal(props, ref) {
|
|
385
385
|
const {
|
|
386
386
|
checked,
|
|
@@ -394,7 +394,7 @@ const ChoiceInternal = React__namespace.forwardRef(function ChoiceInternal(props
|
|
|
394
394
|
className,
|
|
395
395
|
variant
|
|
396
396
|
} = props,
|
|
397
|
-
coreProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
397
|
+
coreProps = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
398
398
|
const handleClick = () => {
|
|
399
399
|
if (variant === "radio" && checked) {
|
|
400
400
|
return;
|
|
@@ -479,13 +479,13 @@ const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
|
479
479
|
}));
|
|
480
480
|
});
|
|
481
481
|
|
|
482
|
-
const _excluded$
|
|
482
|
+
const _excluded$3 = ["disabled", "error"];
|
|
483
483
|
const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
484
484
|
const {
|
|
485
485
|
disabled = false,
|
|
486
486
|
error = false
|
|
487
487
|
} = props,
|
|
488
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
488
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
489
489
|
return React__namespace.createElement(ChoiceInternal, _extends({}, otherProps, {
|
|
490
490
|
variant: "radio",
|
|
491
491
|
disabled: disabled,
|
|
@@ -494,7 +494,7 @@ const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
|
494
494
|
}));
|
|
495
495
|
});
|
|
496
496
|
|
|
497
|
-
const _excluded$
|
|
497
|
+
const _excluded$2 = ["checked", "disabled", "onChange", "value", "variant"];
|
|
498
498
|
const Choice = React__namespace.forwardRef(function Choice(props, ref) {
|
|
499
499
|
const {
|
|
500
500
|
checked = false,
|
|
@@ -502,7 +502,7 @@ const Choice = React__namespace.forwardRef(function Choice(props, ref) {
|
|
|
502
502
|
onChange = () => {},
|
|
503
503
|
variant
|
|
504
504
|
} = props,
|
|
505
|
-
remainingProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
505
|
+
remainingProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
506
506
|
const getChoiceComponent = variant => {
|
|
507
507
|
if (variant === "checkbox") {
|
|
508
508
|
return Checkbox;
|
|
@@ -646,7 +646,7 @@ const RadioGroup = React__namespace.forwardRef(function RadioGroup(props, ref) {
|
|
|
646
646
|
})));
|
|
647
647
|
});
|
|
648
648
|
|
|
649
|
-
const _excluded = ["id", "type", "value", "name", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
|
|
649
|
+
const _excluded$1 = ["id", "type", "value", "name", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
|
|
650
650
|
const defaultErrorMessage = "This field is required.";
|
|
651
651
|
const StyledInput = wonderBlocksCore.addStyle("input");
|
|
652
652
|
class TextField extends React__namespace.Component {
|
|
@@ -742,7 +742,7 @@ class TextField extends React__namespace.Component {
|
|
|
742
742
|
autoComplete,
|
|
743
743
|
forwardedRef
|
|
744
744
|
} = _this$props,
|
|
745
|
-
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
745
|
+
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
|
|
746
746
|
return React__namespace.createElement(StyledInput, _extends({
|
|
747
747
|
style: [styles$1.input, wonderBlocksTypography.styles.LabelMedium, styles$1.default, disabled ? styles$1.disabled : this.state.focused ? [styles$1.focused, light && styles$1.defaultLight] : !!this.state.error && [styles$1.error, light && styles$1.errorLight], !!this.state.error && styles$1.error, style && style],
|
|
748
748
|
id: id,
|
|
@@ -906,6 +906,7 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
906
906
|
}
|
|
907
907
|
});
|
|
908
908
|
|
|
909
|
+
const _excluded = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "ariaDescribedby", "onValidate"];
|
|
909
910
|
class LabeledTextField extends React__namespace.Component {
|
|
910
911
|
constructor(props) {
|
|
911
912
|
super(props);
|
|
@@ -951,26 +952,28 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
951
952
|
};
|
|
952
953
|
}
|
|
953
954
|
render() {
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
955
|
+
const _this$props = this.props,
|
|
956
|
+
{
|
|
957
|
+
id,
|
|
958
|
+
type,
|
|
959
|
+
label,
|
|
960
|
+
description,
|
|
961
|
+
value,
|
|
962
|
+
disabled,
|
|
963
|
+
required,
|
|
964
|
+
validate,
|
|
965
|
+
onChange,
|
|
966
|
+
onKeyDown,
|
|
967
|
+
placeholder,
|
|
968
|
+
light,
|
|
969
|
+
style,
|
|
970
|
+
testId,
|
|
971
|
+
readOnly,
|
|
972
|
+
autoComplete,
|
|
973
|
+
forwardedRef,
|
|
974
|
+
ariaDescribedby
|
|
975
|
+
} = _this$props,
|
|
976
|
+
otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
974
977
|
return React__namespace.createElement(wonderBlocksCore.IDProvider, {
|
|
975
978
|
id: id,
|
|
976
979
|
scope: "labeled-text-field"
|
|
@@ -978,7 +981,7 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
978
981
|
id: uniqueId,
|
|
979
982
|
testId: testId,
|
|
980
983
|
style: style,
|
|
981
|
-
field: React__namespace.createElement(TextField$1, {
|
|
984
|
+
field: React__namespace.createElement(TextField$1, _extends({
|
|
982
985
|
id: `${uniqueId}-field`,
|
|
983
986
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
984
987
|
"aria-required": required ? "true" : "false",
|
|
@@ -998,7 +1001,7 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
998
1001
|
readOnly: readOnly,
|
|
999
1002
|
autoComplete: autoComplete,
|
|
1000
1003
|
ref: forwardedRef
|
|
1001
|
-
}),
|
|
1004
|
+
}, otherProps)),
|
|
1002
1005
|
label: label,
|
|
1003
1006
|
description: description,
|
|
1004
1007
|
required: !!required,
|
package/dist/util/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-form",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.1",
|
|
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.
|
|
20
|
-
"@khanacademy/wonder-blocks-core": "^6.4.
|
|
21
|
-
"@khanacademy/wonder-blocks-icon": "^4.1.
|
|
22
|
-
"@khanacademy/wonder-blocks-layout": "^2.0.
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^4.2.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-core": "^6.4.1",
|
|
21
|
+
"@khanacademy/wonder-blocks-icon": "^4.1.1",
|
|
22
|
+
"@khanacademy/wonder-blocks-layout": "^2.0.33",
|
|
23
23
|
"@khanacademy/wonder-blocks-tokens": "^1.3.0",
|
|
24
|
-
"@khanacademy/wonder-blocks-typography": "^2.1.
|
|
24
|
+
"@khanacademy/wonder-blocks-typography": "^2.1.12"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"aphrodite": "^1.2.5",
|