@availity/mui-controlled-form 1.1.1 → 1.1.3
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 +13 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
- package/src/lib/TextField.stories.tsx +53 -6
- package/src/lib/TextField.test.tsx +8 -4
- package/src/lib/TextField.tsx +1 -1
- package/src/lib/Types.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.1.3](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.1.2...@availity/mui-controlled-form@1.1.3) (2025-03-27)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-autocomplete` updated to version `1.1.2`
|
|
10
|
+
* `mui-datepicker` updated to version `1.1.2`
|
|
11
|
+
* `mui-textfield` updated to version `1.1.2`
|
|
12
|
+
## [1.1.2](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.1.1...@availity/mui-controlled-form@1.1.2) (2025-03-25)
|
|
13
|
+
|
|
14
|
+
### Dependency Updates
|
|
15
|
+
|
|
16
|
+
* `mui-datepicker` updated to version `1.1.1`
|
|
17
|
+
* `theme-provider` updated to version `1.1.1`
|
|
5
18
|
## [1.1.1](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.1.0...@availity/mui-controlled-form@1.1.1) (2025-03-24)
|
|
6
19
|
|
|
7
20
|
### Dependency Updates
|
package/dist/index.js
CHANGED
|
@@ -701,7 +701,7 @@ var ControlledTextField = (_a) => {
|
|
|
701
701
|
}, field), rest), {
|
|
702
702
|
slotProps: __spreadProps(__spreadValues({}, rest.slotProps), {
|
|
703
703
|
htmlInput: __spreadValues({
|
|
704
|
-
maxLength: rules.maxLength
|
|
704
|
+
maxLength: typeof rules.maxLength === "object" ? rules.maxLength.value : rules.maxLength
|
|
705
705
|
}, (_a3 = rest.slotProps) == null ? void 0 : _a3.htmlInput)
|
|
706
706
|
}),
|
|
707
707
|
inputRef: ref,
|
package/dist/index.mjs
CHANGED
|
@@ -665,7 +665,7 @@ var ControlledTextField = (_a) => {
|
|
|
665
665
|
}, field), rest), {
|
|
666
666
|
slotProps: __spreadProps(__spreadValues({}, rest.slotProps), {
|
|
667
667
|
htmlInput: __spreadValues({
|
|
668
|
-
maxLength: rules.maxLength
|
|
668
|
+
maxLength: typeof rules.maxLength === "object" ? rules.maxLength.value : rules.maxLength
|
|
669
669
|
}, (_a3 = rest.slotProps) == null ? void 0 : _a3.htmlInput)
|
|
670
670
|
}),
|
|
671
671
|
inputRef: ref,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-controlled-form",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Availity MUI/react-hook-form controlled form components - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@availity/mui-autocomplete": "^1.0.
|
|
43
|
+
"@availity/mui-autocomplete": "^1.0.8",
|
|
44
44
|
"@availity/mui-checkbox": "^1.0.1",
|
|
45
|
-
"@availity/mui-datepicker": "^1.0.
|
|
45
|
+
"@availity/mui-datepicker": "^1.0.6",
|
|
46
46
|
"@availity/mui-form-utils": "^1.1.0",
|
|
47
|
-
"@availity/mui-textfield": "^1.1.
|
|
47
|
+
"@availity/mui-textfield": "^1.1.1",
|
|
48
48
|
"react-hook-form": "^7.54.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
@@ -16,7 +16,7 @@ const meta: Meta<typeof ControlledTextField> = {
|
|
|
16
16
|
...TextFieldPropsCategorized,
|
|
17
17
|
helperText: {
|
|
18
18
|
type: 'string',
|
|
19
|
-
table: { category: 'Input Props' }
|
|
19
|
+
table: { category: 'Input Props' },
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
};
|
|
@@ -25,22 +25,67 @@ export default meta;
|
|
|
25
25
|
|
|
26
26
|
export const _ControlledTextField: StoryObj<typeof ControlledTextField> = {
|
|
27
27
|
render: (args: ControlledTextFieldProps) => {
|
|
28
|
-
const methods = useForm({values:{ [args.name]: '' }});
|
|
28
|
+
const methods = useForm({ values: { [args.name]: '' } });
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<FormProvider {...methods}>
|
|
32
32
|
<form onSubmit={methods.handleSubmit((data) => data)}>
|
|
33
33
|
<ControlledTextField {...args} />
|
|
34
34
|
<Grid container direction="row" justifyContent="space-between" marginTop={1}>
|
|
35
|
-
<Button
|
|
35
|
+
<Button
|
|
36
|
+
disabled={!methods?.formState?.isSubmitSuccessful}
|
|
37
|
+
children="Reset"
|
|
38
|
+
color="secondary"
|
|
39
|
+
onClick={() => methods.reset()}
|
|
40
|
+
/>
|
|
36
41
|
<Button type="submit" disabled={methods?.formState?.isSubmitSuccessful} children="Submit" />
|
|
37
42
|
</Grid>
|
|
38
|
-
{
|
|
43
|
+
{methods?.formState?.isSubmitSuccessful ? (
|
|
39
44
|
<Paper sx={{ padding: '1.5rem', marginTop: '1.5rem' }}>
|
|
40
45
|
<Typography variant="h2">Submitted Values</Typography>
|
|
41
46
|
<pre data-testid="result">{JSON.stringify(methods.getValues(), null, 2)}</pre>
|
|
42
47
|
</Paper>
|
|
43
|
-
) : null
|
|
48
|
+
) : null}
|
|
49
|
+
</form>
|
|
50
|
+
</FormProvider>
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
args: {
|
|
54
|
+
name: 'controlledTextField',
|
|
55
|
+
placeholder: 'Name',
|
|
56
|
+
required: true,
|
|
57
|
+
rules: {
|
|
58
|
+
required: 'This field is required.',
|
|
59
|
+
maxLength: { value: 10, message: 'Too long' },
|
|
60
|
+
},
|
|
61
|
+
label: 'TextField Label',
|
|
62
|
+
showCharacterCount: true,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const _ControlledTextFieldDisplayOverflow: StoryObj<typeof ControlledTextField> = {
|
|
67
|
+
render: (args: ControlledTextFieldProps) => {
|
|
68
|
+
const methods = useForm({ values: { [args.name]: '' } });
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<FormProvider {...methods}>
|
|
72
|
+
<form onSubmit={methods.handleSubmit((data) => data)}>
|
|
73
|
+
<ControlledTextField {...args} />
|
|
74
|
+
<Grid container direction="row" justifyContent="space-between" marginTop={1}>
|
|
75
|
+
<Button
|
|
76
|
+
disabled={!methods?.formState?.isSubmitSuccessful}
|
|
77
|
+
children="Reset"
|
|
78
|
+
color="secondary"
|
|
79
|
+
onClick={() => methods.reset()}
|
|
80
|
+
/>
|
|
81
|
+
<Button type="submit" disabled={methods?.formState?.isSubmitSuccessful} children="Submit" />
|
|
82
|
+
</Grid>
|
|
83
|
+
{methods?.formState?.isSubmitSuccessful ? (
|
|
84
|
+
<Paper sx={{ padding: '1.5rem', marginTop: '1.5rem' }}>
|
|
85
|
+
<Typography variant="h2">Submitted Values</Typography>
|
|
86
|
+
<pre data-testid="result">{JSON.stringify(methods.getValues(), null, 2)}</pre>
|
|
87
|
+
</Paper>
|
|
88
|
+
) : null}
|
|
44
89
|
</form>
|
|
45
90
|
</FormProvider>
|
|
46
91
|
);
|
|
@@ -52,8 +97,10 @@ export const _ControlledTextField: StoryObj<typeof ControlledTextField> = {
|
|
|
52
97
|
required: true,
|
|
53
98
|
rules: {
|
|
54
99
|
required: 'This field is required.',
|
|
55
|
-
maxLength: { value: 10, message: 'Too long' }
|
|
100
|
+
maxLength: { value: 10, message: 'Too long' },
|
|
56
101
|
},
|
|
57
102
|
label: 'TextField Label',
|
|
103
|
+
displayOverflowMaxLength: true,
|
|
104
|
+
showCharacterCount: true,
|
|
58
105
|
},
|
|
59
106
|
};
|
|
@@ -80,12 +80,14 @@ describe('ControlledTextField', () => {
|
|
|
80
80
|
</TestForm>
|
|
81
81
|
);
|
|
82
82
|
|
|
83
|
-
expect(getByText('0
|
|
83
|
+
expect(getByText('0')).toBeTruthy();
|
|
84
|
+
expect(getByText('/20')).toBeTruthy();
|
|
84
85
|
|
|
85
86
|
const input = getByTestId('testTextField');
|
|
86
87
|
fireEvent.change(input, { target: { value: 'Some Text' } });
|
|
87
88
|
|
|
88
|
-
expect(getByText('9
|
|
89
|
+
expect(getByText('9')).toBeTruthy();
|
|
90
|
+
expect(getByText('/20')).toBeTruthy();
|
|
89
91
|
|
|
90
92
|
fireEvent.change(input, { target: { value: "Some More Text that doesn't fit" } });
|
|
91
93
|
|
|
@@ -103,12 +105,14 @@ describe('ControlledTextField', () => {
|
|
|
103
105
|
/>
|
|
104
106
|
</TestForm>
|
|
105
107
|
);
|
|
106
|
-
expect(getByText('0
|
|
108
|
+
expect(getByText('0')).toBeTruthy();
|
|
109
|
+
expect(getByText('/20')).toBeTruthy();
|
|
107
110
|
|
|
108
111
|
const input = getByTestId('testTextField');
|
|
109
112
|
fireEvent.change(input, { target: { value: 'Some Text' } });
|
|
110
113
|
|
|
111
|
-
expect(getByText('9
|
|
114
|
+
expect(getByText('9')).toBeTruthy();
|
|
115
|
+
expect(getByText('/20')).toBeTruthy();
|
|
112
116
|
|
|
113
117
|
fireEvent.change(input, { target: { value: "Some More Text that doesn't fit" } });
|
|
114
118
|
|
package/src/lib/TextField.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export const ControlledTextField = ({
|
|
|
39
39
|
slotProps={{
|
|
40
40
|
...rest.slotProps,
|
|
41
41
|
htmlInput: {
|
|
42
|
-
maxLength: rules.maxLength,
|
|
42
|
+
maxLength: typeof rules.maxLength === 'object' ? rules.maxLength.value : rules.maxLength,
|
|
43
43
|
...rest.slotProps?.htmlInput,
|
|
44
44
|
},
|
|
45
45
|
}}
|
package/src/lib/Types.tsx
CHANGED
|
@@ -188,6 +188,7 @@ export const AllControllerPropertiesCategorized: CategorizedControllerPropsObjec
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
export const TextFieldPropsCategorized: TextFieldPropsObject = {
|
|
191
|
+
displayOverflowMaxLength: { table: { category: 'Input Props' } },
|
|
191
192
|
slotProps: { table: { category: 'Input Props' } },
|
|
192
193
|
className: { table: { category: 'Input Props' } },
|
|
193
194
|
style: { table: { category: 'Input Props' } },
|