@availity/mui-controlled-form 1.0.6 → 1.1.0

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 CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.1.0](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.0.7...@availity/mui-controlled-form@1.1.0) (2025-03-21)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `mui-autocomplete` updated to version `1.0.7`
10
+ * `mui-datepicker` updated to version `1.0.7`
11
+ * `mui-form-utils` updated to version `1.0.7`
12
+ * `mui-textfield` updated to version `1.0.7`
13
+ * `theme-provider` updated to version `1.0.7`
14
+
15
+ ### Features
16
+
17
+ * **mui-textfield, mui-form-utils:** add placeholder support to select ([3a6b1ef](https://github.com/Availity/element/commit/3a6b1ef2e5ceedca632bd1916734e56402371ffb))
18
+ * **mui-textfield:** add optional character count to textfield ([1c3f0dc](https://github.com/Availity/element/commit/1c3f0dc886e153c79afc81c98b3326ed8990b305))
19
+
20
+ ## [1.0.7](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.0.6...@availity/mui-controlled-form@1.0.7) (2025-03-13)
21
+
22
+ ### Dependency Updates
23
+
24
+ * `mui-autocomplete` updated to version `1.0.6`
25
+ * `@availity/mock` updated to version `1.0.6`
5
26
  ## [1.0.6](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.0.5...@availity/mui-controlled-form@1.0.6) (2025-03-13)
6
27
 
7
28
  ### Dependency Updates
package/dist/index.js CHANGED
@@ -693,11 +693,17 @@ var ControlledTextField = (_a) => {
693
693
  shouldUnregister,
694
694
  render: (_a2) => {
695
695
  var _b2 = _a2, { field: _c } = _b2, _d = _c, { ref } = _d, field = __objRest(_d, ["ref"]), { fieldState: { error } } = _b2;
696
+ var _a3;
696
697
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
697
698
  import_mui_textfield.TextField,
698
699
  __spreadProps(__spreadValues(__spreadValues({
699
700
  required: typeof rules.required === "object" ? rules.required.value : !!rules.required
700
701
  }, field), rest), {
702
+ slotProps: __spreadProps(__spreadValues({}, rest.slotProps), {
703
+ htmlInput: __spreadValues({
704
+ maxLength: rules.maxLength
705
+ }, (_a3 = rest.slotProps) == null ? void 0 : _a3.htmlInput)
706
+ }),
701
707
  inputRef: ref,
702
708
  error: !!error,
703
709
  helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
package/dist/index.mjs CHANGED
@@ -657,11 +657,17 @@ var ControlledTextField = (_a) => {
657
657
  shouldUnregister,
658
658
  render: (_a2) => {
659
659
  var _b2 = _a2, { field: _c } = _b2, _d = _c, { ref } = _d, field = __objRest(_d, ["ref"]), { fieldState: { error } } = _b2;
660
+ var _a3;
660
661
  return /* @__PURE__ */ jsx11(
661
662
  TextField,
662
663
  __spreadProps(__spreadValues(__spreadValues({
663
664
  required: typeof rules.required === "object" ? rules.required.value : !!rules.required
664
665
  }, field), rest), {
666
+ slotProps: __spreadProps(__spreadValues({}, rest.slotProps), {
667
+ htmlInput: __spreadValues({
668
+ maxLength: rules.maxLength
669
+ }, (_a3 = rest.slotProps) == null ? void 0 : _a3.htmlInput)
670
+ }),
665
671
  inputRef: ref,
666
672
  error: !!error,
667
673
  helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs8(Fragment8, { children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-controlled-form",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
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.5",
43
+ "@availity/mui-autocomplete": "^1.0.7",
44
44
  "@availity/mui-checkbox": "^1.0.1",
45
- "@availity/mui-datepicker": "^1.0.2",
46
- "@availity/mui-form-utils": "^1.0.1",
47
- "@availity/mui-textfield": "^1.0.1",
45
+ "@availity/mui-datepicker": "^1.0.3",
46
+ "@availity/mui-form-utils": "^1.1.0",
47
+ "@availity/mui-textfield": "^1.1.0",
48
48
  "react-hook-form": "^7.54.2"
49
49
  },
50
50
  "devDependencies": {
@@ -7,15 +7,14 @@ const onSubmit = jest.fn();
7
7
  describe('ControlledTextField', () => {
8
8
  test('should render the error styling if an error is returned', async () => {
9
9
  const screen = render(
10
- <TestForm UseFormOptions={{values: { controlledTextField: undefined }}} onSubmit={onSubmit}>
10
+ <TestForm UseFormOptions={{ values: { controlledTextField: undefined } }} onSubmit={onSubmit}>
11
11
  <ControlledTextField
12
12
  name="controlledTextField"
13
13
  helperText="This is some helper text"
14
14
  placeholder="Name"
15
- rules= {{
16
- required:"This field is required.",
17
- maxLength:{ value: 10, message: 'Too long' }
18
-
15
+ rules={{
16
+ required: 'This field is required.',
17
+ maxLength: { value: 10, message: 'Too long' },
19
18
  }}
20
19
  inputProps={{
21
20
  'data-testid': 'testTextField',
@@ -37,15 +36,14 @@ describe('ControlledTextField', () => {
37
36
 
38
37
  test('should not render the error styling if no error is returned', async () => {
39
38
  const screen = render(
40
- <TestForm UseFormOptions={{values: { controlledTextField: undefined }}} onSubmit={onSubmit}>
39
+ <TestForm UseFormOptions={{ values: { controlledTextField: undefined } }} onSubmit={onSubmit}>
41
40
  <ControlledTextField
42
41
  name="controlledTextField"
43
42
  helperText="This is some helper text"
44
43
  placeholder="Name"
45
- rules= {{
46
- required:"This field is required.",
47
- maxLength:{ value: 10, message: 'Too long' }
48
-
44
+ rules={{
45
+ required: 'This field is required.',
46
+ maxLength: { value: 10, message: 'Too long' },
49
47
  }}
50
48
  inputProps={{
51
49
  'data-testid': 'testTextField',
@@ -68,4 +66,53 @@ describe('ControlledTextField', () => {
68
66
  expect(formValues).toBe('Some Text');
69
67
  });
70
68
  });
69
+
70
+ describe('TextField character counter', () => {
71
+ test('should render character counter successfully via inputProps', () => {
72
+ const { getByText, getByTestId, getByTitle } = render(
73
+ <TestForm UseFormOptions={{ values: { controlledTextField: undefined } }} onSubmit={onSubmit}>
74
+ <ControlledTextField
75
+ name="controlledTextField"
76
+ label="Test"
77
+ showCharacterCount
78
+ inputProps={{ 'data-testid': 'testTextField', maxLength: 20 }}
79
+ />
80
+ </TestForm>
81
+ );
82
+
83
+ expect(getByText('0/20')).toBeTruthy();
84
+
85
+ const input = getByTestId('testTextField');
86
+ fireEvent.change(input, { target: { value: 'Some Text' } });
87
+
88
+ expect(getByText('9/20')).toBeTruthy();
89
+
90
+ fireEvent.change(input, { target: { value: "Some More Text that doesn't fit" } });
91
+
92
+ expect(getByTitle('Error')).toBeTruthy();
93
+ });
94
+
95
+ test('should render character counter successfully via slotProps', () => {
96
+ const { getByText, getByTestId, getByTitle } = render(
97
+ <TestForm UseFormOptions={{ values: { controlledTextField: undefined } }} onSubmit={onSubmit}>
98
+ <ControlledTextField
99
+ name="controlledTextField"
100
+ label="Test"
101
+ showCharacterCount
102
+ slotProps={{ htmlInput: { 'data-testid': 'testTextField', maxLength: 20 } }}
103
+ />
104
+ </TestForm>
105
+ );
106
+ expect(getByText('0/20')).toBeTruthy();
107
+
108
+ const input = getByTestId('testTextField');
109
+ fireEvent.change(input, { target: { value: 'Some Text' } });
110
+
111
+ expect(getByText('9/20')).toBeTruthy();
112
+
113
+ fireEvent.change(input, { target: { value: "Some More Text that doesn't fit" } });
114
+
115
+ expect(getByTitle('Error')).toBeTruthy();
116
+ });
117
+ });
71
118
  });
@@ -36,6 +36,13 @@ export const ControlledTextField = ({
36
36
  required={typeof rules.required === 'object' ? rules.required.value : !!rules.required}
37
37
  {...field}
38
38
  {...rest}
39
+ slotProps={{
40
+ ...rest.slotProps,
41
+ htmlInput: {
42
+ maxLength: rules.maxLength,
43
+ ...rest.slotProps?.htmlInput,
44
+ },
45
+ }}
39
46
  inputRef={ref}
40
47
  error={!!error}
41
48
  helperText={