@iress-oss/ids-mcp-server 5.15.0 → 5.20.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.
Files changed (134) hide show
  1. package/generated/docs/components_components-alert-docs.md +496 -0
  2. package/generated/docs/components_components-autocomplete-docs.md +3429 -0
  3. package/generated/docs/{components-autocomplete-recipes-docs.md → components_components-autocomplete-recipes-docs.md} +39 -14
  4. package/generated/docs/{components-badge-docs.md → components_components-badge-docs.md} +222 -30
  5. package/generated/docs/components_components-button-docs.md +2078 -0
  6. package/generated/docs/components_components-button-recipes-docs.md +37 -0
  7. package/generated/docs/components_components-buttongroup-docs.md +1045 -0
  8. package/generated/docs/components_components-card-docs.md +2290 -0
  9. package/generated/docs/{components-card-recipes-docs.md → components_components-card-recipes-docs.md} +132 -15
  10. package/generated/docs/components_components-checkbox-docs.md +1040 -0
  11. package/generated/docs/{components-checkboxgroup-docs.md → components_components-checkboxgroup-docs.md} +1001 -82
  12. package/generated/docs/{components-checkboxgroup-recipes-docs.md → components_components-checkboxgroup-recipes-docs.md} +102 -12
  13. package/generated/docs/{components-col-docs.md → components_components-col-docs.md} +331 -58
  14. package/generated/docs/components_components-combobox-docs.md +3735 -0
  15. package/generated/docs/{components-container-docs.md → components_components-container-docs.md} +61 -24
  16. package/generated/docs/{components-divider-docs.md → components_components-divider-docs.md} +83 -24
  17. package/generated/docs/{components-expander-docs.md → components_components-expander-docs.md} +266 -33
  18. package/generated/docs/components_components-field-docs.md +1369 -0
  19. package/generated/docs/components_components-filter-docs.md +4080 -0
  20. package/generated/docs/{components-form-docs.md → components_components-form-docs.md} +1556 -360
  21. package/generated/docs/{components-form-recipes-docs.md → components_components-form-recipes-docs.md} +277 -60
  22. package/generated/docs/{components-hide-docs.md → components_components-hide-docs.md} +195 -124
  23. package/generated/docs/components_components-icon-docs.md +1337 -0
  24. package/generated/docs/{components-inline-docs.md → components_components-inline-docs.md} +462 -42
  25. package/generated/docs/components_components-input-docs.md +1468 -0
  26. package/generated/docs/components_components-input-recipes-docs.md +367 -0
  27. package/generated/docs/components_components-inputcurrency-docs.md +432 -0
  28. package/generated/docs/{components-inputcurrency-recipes-docs.md → components_components-inputcurrency-recipes-docs.md} +113 -17
  29. package/generated/docs/components_components-label-docs.md +323 -0
  30. package/generated/docs/components_components-menu-docs.md +2345 -0
  31. package/generated/docs/components_components-menu-menuitem-docs.md +633 -0
  32. package/generated/docs/{components-modal-docs.md → components_components-modal-docs.md} +1640 -231
  33. package/generated/docs/components_components-navbar-docs.md +1847 -0
  34. package/generated/docs/{components-navbar-recipes-docs.md → components_components-navbar-recipes-docs.md} +721 -40
  35. package/generated/docs/{components-panel-docs.md → components_components-panel-docs.md} +754 -57
  36. package/generated/docs/components_components-placeholder-docs.md +92 -0
  37. package/generated/docs/components_components-popover-docs.md +1643 -0
  38. package/generated/docs/components_components-popover-recipes-docs.md +491 -0
  39. package/generated/docs/components_components-progress-docs.md +115 -0
  40. package/generated/docs/{components-provider-docs.md → components_components-provider-docs.md} +42 -33
  41. package/generated/docs/components_components-radio-docs.md +491 -0
  42. package/generated/docs/{components-radiogroup-docs.md → components_components-radiogroup-docs.md} +927 -75
  43. package/generated/docs/components_components-readonly-docs.md +263 -0
  44. package/generated/docs/components_components-richselect-docs.md +6521 -0
  45. package/generated/docs/{components-row-docs.md → components_components-row-docs.md} +353 -43
  46. package/generated/docs/{components-select-docs.md → components_components-select-docs.md} +719 -61
  47. package/generated/docs/components_components-skeleton-docs.md +480 -0
  48. package/generated/docs/{components-skeleton-recipes-docs.md → components_components-skeleton-recipes-docs.md} +51 -11
  49. package/generated/docs/{components-skiplink-docs.md → components_components-skiplink-docs.md} +53 -14
  50. package/generated/docs/components_components-slideout-docs.md +2293 -0
  51. package/generated/docs/components_components-slider-docs.md +1276 -0
  52. package/generated/docs/components_components-spinner-docs.md +82 -0
  53. package/generated/docs/{components-stack-docs.md → components_components-stack-docs.md} +223 -40
  54. package/generated/docs/components_components-table-docs.md +3658 -0
  55. package/generated/docs/components_components-tabset-docs.md +772 -0
  56. package/generated/docs/components_components-tabset-tab-docs.md +262 -0
  57. package/generated/docs/components_components-tag-docs.md +257 -0
  58. package/generated/docs/{components-text-docs.md → components_components-text-docs.md} +491 -51
  59. package/generated/docs/{components-toaster-docs.md → components_components-toaster-docs.md} +187 -85
  60. package/generated/docs/components_components-toaster-toast-docs.md +634 -0
  61. package/generated/docs/components_components-toggle-docs.md +461 -0
  62. package/generated/docs/{components-tooltip-docs.md → components_components-tooltip-docs.md} +286 -41
  63. package/generated/docs/{components-validationmessage-docs.md → components_components-validationmessage-docs.md} +230 -61
  64. package/generated/docs/components_contact-us-docs.md +12 -0
  65. package/generated/docs/{foundations-accessibility-docs.md → components_foundations-accessibility-docs.md} +11 -21
  66. package/generated/docs/{foundations-colours-docs.md → components_foundations-colour-030-colours.md} +8 -15
  67. package/generated/docs/{foundations-consistency-docs.md → components_foundations-consistency-docs.md} +12 -20
  68. package/generated/docs/{foundations-content-docs.md → components_foundations-content-docs.md} +6 -11
  69. package/generated/docs/components_foundations-introduction-docs.md +15 -0
  70. package/generated/docs/{foundations-principles-docs.md → components_foundations-principles-docs.md} +14 -24
  71. package/generated/docs/components_foundations-typography-docs.md +608 -0
  72. package/generated/docs/{foundations-user-experience-docs.md → components_foundations-user-experience-docs.md} +16 -26
  73. package/generated/docs/{foundations-visual-design-docs.md → components_foundations-visual-design-docs.md} +10 -17
  74. package/generated/docs/{frequently-asked-questions-docs.md → components_frequently-asked-questions-docs.md} +14 -23
  75. package/generated/docs/components_get-started-develop-docs.md +84 -0
  76. package/generated/docs/components_get-started-using-storybook-docs.md +55 -0
  77. package/generated/docs/components_introduction-docs.md +15 -0
  78. package/generated/docs/{patterns-loading-docs.md → components_patterns-loading-docs.md} +798 -153
  79. package/generated/docs/components_resources-changelog-docs.md +4 -0
  80. package/generated/docs/{resources-code-katas-docs.md → components_resources-code-katas-docs.md} +5 -9
  81. package/generated/docs/{resources-migration-guides-from-v4-to-v5-docs.md → components_resources-migration-guides-from-v4-to-v5-docs.md} +54 -239
  82. package/generated/docs/components_sandbox-docs.md +4 -0
  83. package/generated/docs/{versions-docs.md → components_versions-docs.md} +5 -8
  84. package/generated/docs/guidelines.md +484 -200
  85. package/generated/docs/introduction-docs.md +19 -30
  86. package/package.json +41 -45
  87. package/generated/docs/components-alert-docs.md +0 -130
  88. package/generated/docs/components-autocomplete-docs.md +0 -754
  89. package/generated/docs/components-button-docs.md +0 -362
  90. package/generated/docs/components-button-recipes-docs.md +0 -76
  91. package/generated/docs/components-buttongroup-docs.md +0 -310
  92. package/generated/docs/components-card-docs.md +0 -494
  93. package/generated/docs/components-checkbox-docs.md +0 -193
  94. package/generated/docs/components-combobox-docs.md +0 -1016
  95. package/generated/docs/components-field-docs.md +0 -675
  96. package/generated/docs/components-filter-docs.md +0 -1109
  97. package/generated/docs/components-icon-docs.md +0 -553
  98. package/generated/docs/components-input-docs.md +0 -335
  99. package/generated/docs/components-input-recipes-docs.md +0 -140
  100. package/generated/docs/components-inputcurrency-docs.md +0 -157
  101. package/generated/docs/components-label-docs.md +0 -135
  102. package/generated/docs/components-menu-docs.md +0 -704
  103. package/generated/docs/components-menu-menuitem-docs.md +0 -193
  104. package/generated/docs/components-navbar-docs.md +0 -291
  105. package/generated/docs/components-placeholder-docs.md +0 -27
  106. package/generated/docs/components-popover-docs.md +0 -464
  107. package/generated/docs/components-popover-recipes-docs.md +0 -245
  108. package/generated/docs/components-progress-docs.md +0 -104
  109. package/generated/docs/components-radio-docs.md +0 -107
  110. package/generated/docs/components-readonly-docs.md +0 -89
  111. package/generated/docs/components-richselect-docs.md +0 -2433
  112. package/generated/docs/components-skeleton-docs.md +0 -214
  113. package/generated/docs/components-slideout-docs.md +0 -538
  114. package/generated/docs/components-slider-docs.md +0 -346
  115. package/generated/docs/components-spinner-docs.md +0 -59
  116. package/generated/docs/components-table-ag-grid-docs.md +0 -1074
  117. package/generated/docs/components-table-docs.md +0 -1305
  118. package/generated/docs/components-tabset-docs.md +0 -341
  119. package/generated/docs/components-tabset-tab-docs.md +0 -86
  120. package/generated/docs/components-tag-docs.md +0 -115
  121. package/generated/docs/components-toaster-toast-docs.md +0 -157
  122. package/generated/docs/components-toggle-docs.md +0 -158
  123. package/generated/docs/contact-us-docs.md +0 -27
  124. package/generated/docs/extensions-editor-docs.md +0 -288
  125. package/generated/docs/extensions-editor-recipes-docs.md +0 -39
  126. package/generated/docs/foundations-introduction-docs.md +0 -17
  127. package/generated/docs/foundations-typography-docs.md +0 -191
  128. package/generated/docs/get-started-develop-docs.md +0 -209
  129. package/generated/docs/get-started-using-storybook-docs.md +0 -68
  130. package/generated/docs/resources-changelog-docs.md +0 -6
  131. package/generated/docs/themes-available-themes-docs.md +0 -66
  132. package/generated/docs/themes-introduction-docs.md +0 -121
  133. package/generated/docs/themes-tokens-docs.md +0 -1200
  134. /package/{LICENSE.txt → LICENSE} +0 -0
@@ -1,22 +1,22 @@
1
- [](#form)Form
2
- =============
1
+ Form
2
+ ====
3
3
 
4
4
  Overview
5
5
  --------
6
6
 
7
7
  Use the `IressForm` component when you want to request, validate and process data from the user.
8
8
 
9
+ [](./iframe.html?id=components-form--simple)
10
+
9
11
  \*Required Name
10
12
 
11
13
  \*Required Email address
12
14
 
13
15
  Sign up
14
16
 
15
- Hide code
16
-
17
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
17
+ Hide codedrawOpen in CodeSandbox
18
18
 
19
- <IressForm\>
19
+ <ForwardedForm\>
20
20
  <IressStack gutter\="md"\>
21
21
  <IressFormField
22
22
  label\="Name"
@@ -44,16 +44,49 @@ Hide code
44
44
  \>
45
45
  Sign up </IressButton\>
46
46
  </IressStack\>
47
- </IressForm\>
47
+ </ForwardedForm\>
48
+
49
+ ```
50
+
51
+ Props
52
+ -----
53
+
54
+ Below are the custom props you can access when using `IressForm`, which includes the props for the [`useForm` hook from React Hook Forms](https://react-hook-form.com/docs/useform). In addition to these, you have access to the original props of the underlying [`form` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
55
+
56
+ | Name | Description | Default | Control |
57
+ | --- | --- | --- | --- |
58
+ | alert |
59
+ \-
60
+
61
+ | \- | alertChoose option...nonebasicAlert |
62
+ | children |
63
+
64
+ object
65
+
66
+
67
+
68
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
69
+ | form |
70
+
71
+ React hook form instance from `useForm`, use if you need more control over the internal state.
72
+
73
+ const form = useForm();
74
+ return <IressForm form={form} />;
75
+
76
+
77
+ UseFormReturn
78
+
48
79
 
49
- Copy
50
80
 
51
- [](#key-concepts)Key concepts
52
- -----------------------------
81
+ | \- | Set object |
82
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
83
+
84
+ Key concepts
85
+ ------------
53
86
 
54
87
  As of version 5, `IressForm` is built on top of [React Hook Forms](https://react-hook-form.com/). This provides you the power of React Hook Forms with the convenience of IDS form components. However, there are some key differences to be aware of as it may affect how you build your forms.
55
88
 
56
- ### [](#state-management)State management
89
+ ### State management
57
90
 
58
91
  `IressForm` manages the state of the form, including the form data and validation. This is done using the `useForm` hook from React Hook Forms. This hook provides a way to manage the form state, and provides methods to interact with the form. This was done to simplify the form components, make them more predictable (as the form becomes the single source of truth for all form related data) and improve performance by reducing re-renders (very important for large forms).
59
92
 
@@ -64,13 +97,15 @@ Due to this change, there are a few things you should consider during developmen
64
97
 
65
98
  See below an example comparing a version 4 and version 5 `IressForm` when managing form state.
66
99
 
67
- Mode
100
+ Diff
101
+
102
+ Old
68
103
 
69
- DiffOldNew
104
+ New
70
105
 
71
106
  <table class="css-1n5o7vh-diff-container"><tbody><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text">import { IressForm, IressField, IressInput, IressCheckboxGroup, IressCheckbox } from '@iress/components';</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text">import { IressForm, IressFormField, IressInput, IressCheckboxGroup, IressCheckbox } from '@iress-oss/ids-components';</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-10regm7-empty-line"><pre></pre></td><td class="css-vl0irh-content css-10regm7-empty-line"><pre class="css-o1u8iu-content-text"></pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-10regm7-empty-line"><pre></pre></td><td class="css-vl0irh-content css-10regm7-empty-line"><pre class="css-o1u8iu-content-text"></pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text">export const App = () =&gt; {</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text">const ConditionalFields = () =&gt; {</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> // We need to create our own state to manage the visibility of the fields, </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> // Instead of creating our own state, we can now use the form state via the useWatch hook, </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> // which means we have two sources of truth potentially making our code harder to maintain</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> // meaning we still have a single source of truth</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> const [show, setShow] = useState(['name']);</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> const show = IressForm.useWatch({ name: 'show'});</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-10regm7-empty-line"><pre></pre></td><td class="css-vl0irh-content css-10regm7-empty-line"><pre class="css-o1u8iu-content-text"></pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> return (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressForm&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressField label="Show fields"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressFormField </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressCheckboxGroup value={show} onChange={(newValues) =&gt; setShow(newValues)}&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> label="Show fields" </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> name="show"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> render={(controlledProps) =&gt; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressCheckboxGroup {...controlledProps}&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> &lt;IressCheckbox value="name"&gt;Name&lt;/IressCheckbox&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> &lt;IressCheckbox value="email"&gt;Email&lt;/IressCheckbox&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> &lt;/IressCheckboxGroup&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;/IressField&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> )}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> {show.includes('name') &amp;&amp; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressField label="Name"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> {show?.includes('name') &amp;&amp; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressInput name="name" /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressFormField </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;/IressField&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> label="Name" </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> )}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> name="name"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> {show.includes('email') &amp;&amp; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> render={(controlledProps) =&gt; &lt;IressInput {...controlledProps} /&gt;}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressField label="Email"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressInput name="email" type="email" /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> )}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;/IressField&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> {show?.includes('email') &amp;&amp; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> )}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressFormField </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;/IressForm&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> label="Email" </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> name="email"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> render={(controlledProps) =&gt; &lt;IressInput {...controlledProps} type="email" /&gt;}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> )}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;/&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> );</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text">};</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-10regm7-empty-line css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-10regm7-empty-line css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"></pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text">export const App = () =&gt; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressForm defaultValues={{ show: ['name'] }}&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;ConditionalFields /&gt; </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;/IressForm&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text">);</pre></td></tr></tbody></table>
72
107
 
73
- ### [](#validation)Validation
108
+ ### Validation
74
109
 
75
110
  Validation is now done declaratively using the `rules` prop on the `IressFormField` component. This is based on the [rules available in React Hook Forms](https://www.react-hook-form.com/api/useform/register/#options). This change was made to allow for more complex validation rules to be implemented.
76
111
 
@@ -82,13 +117,15 @@ Due to this change, there are a few things you should consider during developmen
82
117
 
83
118
  See below an example comparing a version 4 and version 5 `IressForm` when adding validation rules.
84
119
 
85
- Mode
120
+ Diff
86
121
 
87
- DiffOldNew
122
+ Old
123
+
124
+ New
88
125
 
89
126
  <table class="css-1n5o7vh-diff-container"><tbody><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text">import { IressForm, IressField, IressInput, IressButton } from '@iress/components';</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text">import { IressForm, IressFormField, IressInput, IressButton } from '@iress-oss/ids-components';</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-10regm7-empty-line"><pre></pre></td><td class="css-vl0irh-content css-10regm7-empty-line"><pre class="css-o1u8iu-content-text"></pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text">export const App = () =&gt; (</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressForm valueMissing="{{fieldName}} needs to be filled in!"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressForm&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressField label="Name"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressFormField </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressInput name="name" required /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> label="Name"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;/IressField&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> name="name"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressField label="Email"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> render={(controlledProps) =&gt; &lt;IressInput {...controlledProps} /&gt;}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;IressInput name="email" maxLength={10} /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> rules={{ required: 'Name needs to be filled in!' }}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-rq9a2a-diff-removed"><pre>-</pre></td><td class="css-vl0irh-content css-rq9a2a-diff-removed"><pre class="css-o1u8iu-content-text"> &lt;/IressField&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> &lt;IressFormField </pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> label="Email"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> name="email"</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> render={(controlledProps) =&gt; &lt;IressInput {...controlledProps} type="email" maxLength={10} /&gt;}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> rules={{ maxLength: 10 }}</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker css-cnnxkz-diff-added"><pre>+</pre></td><td class="css-vl0irh-content css-cnnxkz-diff-added"><pre class="css-o1u8iu-content-text"> /&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> &lt;IressButton type="submit" mode="primary"&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> Sign up</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> &lt;/IressButton&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text"> &lt;/IressForm&gt;</pre></td></tr><tr class="css-1n7ec1i-line"><td class="css-17vezug-marker"><pre></pre></td><td class="css-vl0irh-content"><pre class="css-o1u8iu-content-text">);</pre></td></tr></tbody></table>
90
127
 
91
- ### [](#syncing-state)Syncing state
128
+ ### Syncing state
92
129
 
93
130
  For most scenarios, you should use the `onSubmit` event to sync the form data with other state management systems (eg. server, browser storage or state management libraries such as Redux). This event is emitted when the form passes validation, and contains a map of the field names and the data entered by the user.
94
131
 
@@ -99,23 +136,6 @@ Consider the following for your development:
99
136
  * Only use other state management systems to fill out the form at the initial render using `defaultValues`. After that, use the `onSubmit` event to sync the form data with your state.
100
137
  * If you need to set form with data coming from an external system, use the `ref` of the form to `reset` the form values.
101
138
 
102
- \[data-radix-scroll-area-viewport\] {
103
- scrollbar-width: none;
104
- -ms-overflow-style: none;
105
- -webkit-overflow-scrolling: touch;
106
- }
107
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
108
- display: none;
109
- }
110
- :where(\[data-radix-scroll-area-viewport\]) {
111
- display: flex;
112
- flex-direction: column;
113
- align-items: stretch;
114
- }
115
- :where(\[data-radix-scroll-area-content\]) {
116
- flex-grow: 1;
117
- }
118
-
119
139
  const ref \= useRef<FormRef | null\>(null);
120
140
  const api \= useApi();
121
141
  const handleSubmit \= async (data) \=> {
@@ -129,12 +149,12 @@ return (
129
149
  ... </IressForm\>
130
150
  );
131
151
 
132
- Copy
152
+ ```
133
153
 
134
- [](#usage)Usage
135
- ---------------
154
+ Usage
155
+ -----
136
156
 
137
- ### [](#fields)Fields
157
+ ### Fields
138
158
 
139
159
  Use the `IressFormField` component to create form fields. This component is a layout component that wraps around form controls such as `IressInput`. It provides a consistent layout for form fields, and hooks into the `IressForm` component to provide validation and error handling.
140
160
 
@@ -144,35 +164,20 @@ It has three required props:
144
164
  * `label`: The label for the field.
145
165
  * `render`: A render prop that renders the form control. It is passed an object containing the props to be spread onto the form control to allow it to be controlled by the form.
146
166
 
147
- \[data-radix-scroll-area-viewport\] {
148
- scrollbar-width: none;
149
- -ms-overflow-style: none;
150
- -webkit-overflow-scrolling: touch;
151
- }
152
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
153
- display: none;
154
- }
155
- :where(\[data-radix-scroll-area-viewport\]) {
156
- display: flex;
157
- flex-direction: column;
158
- align-items: stretch;
159
- }
160
- :where(\[data-radix-scroll-area-content\]) {
161
- flex-grow: 1;
162
- }
163
-
164
167
  <IressFormField
165
168
  name\="email"
166
169
  label\="Email"
167
170
  render\={(controlledProps) \=> <IressInput {...controlledProps} type\="email" />}
168
171
  />
169
172
 
170
- Copy
173
+ ```
171
174
 
172
- #### [](#supported-form-controls)Supported form controls
175
+ #### Supported form controls
173
176
 
174
177
  Here are some examples of how to use `IressFormField` with different form controls. If you are using a form control that has multiple inputs inside (for example, `IressCheckboxGroup`), you can use `IressFormFieldset`, which changes the HTML structure to use a `fieldset` and `legend` element to group the inputs.
175
178
 
179
+ [](./iframe.html?id=components-form--fields)
180
+
176
181
  \*Required Name
177
182
 
178
183
  \*Required Date
@@ -205,6 +210,8 @@ Salad
205
210
 
206
211
  Type to copy an existing character's name
207
212
 
213
+ Type at least 1 character to search
214
+
208
215
  \*Required Your star wars sidekick
209
216
 
210
217
  None selected
@@ -221,11 +228,9 @@ None selected
221
228
 
222
229
  Sign up
223
230
 
224
- Hide code
231
+ Hide codedrawOpen in CodeSandbox
225
232
 
226
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
227
-
228
- <IressForm\>
233
+ <ForwardedForm\>
229
234
  <IressStack gutter\="md"\>
230
235
  <IressFormField
231
236
  label\="Name"
@@ -393,29 +398,146 @@ Hide code
393
398
  \>
394
399
  Sign up </IressButton\>
395
400
  </IressStack\>
396
- </IressForm\>
401
+ </ForwardedForm\>
402
+
403
+ ```
404
+
405
+ #### Props
406
+
407
+ | Name | Description | Default | Control |
408
+ | --- | --- | --- | --- |
409
+ | alert |
410
+ \-
411
+
412
+ | \- | alertChoose option...nonebasicAlert |
413
+ | children |
414
+
415
+ object
416
+
417
+
418
+
419
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
420
+ | form |
421
+
422
+ React hook form instance from `useForm`, use if you need more control over the internal state.
423
+
424
+ const form = useForm();
425
+ return <IressForm form={form} />;
426
+
427
+
428
+ UseFormReturn
429
+
430
+
431
+
432
+ | \- | Set object |
433
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
434
+
435
+ #### IressFormField props
436
+
437
+ | Name | Description | Default |
438
+ | --- | --- | --- |
439
+ | label |
440
+ string
441
+
442
+
443
+
444
+ | \- |
445
+ | name\* |
446
+
447
+ Name of the field. It is used to identify the field in the form. It must be unique within the form.
448
+
449
+ FieldPath
450
+
451
+
452
+
453
+ | \- |
454
+ | readOnly |
455
+
456
+ Text to be displayed instead of input field.
397
457
 
398
- Copy
458
+ boolean
399
459
 
400
- ### [](#rules)Rules
460
+
461
+
462
+ | \- |
463
+ | render\* |
464
+
465
+ Render function to provide the control for the field. To ensure the field is correctly registered with the form, the control must be passed as props to the rendered component. (eg. `render={field => <IressInput {...field} />}`)
466
+
467
+ (field: FormFieldRenderProps<T>) => ReactNode
468
+
469
+ | \- |
470
+ | rules |
471
+
472
+ Validation rules, including: required, min, max, minLength, maxLength, pattern, validate
473
+
474
+ [Learn more](https://react-hook-form.com/api/useform/register)
475
+
476
+ intersection
477
+
478
+
479
+
480
+ | \- |
481
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
482
+ | Show Field props itemsField props | Show Field props items |
483
+
484
+ ### Rules
401
485
 
402
486
  Use the `rules` prop on the `IressFormField` component to add validation rules. These are based on the [rules available in React Hook Forms](https://www.react-hook-form.com/api/useform/register/#options). The following rules are supported.
403
487
 
404
488
  **Note:** In version 5, you can no longer override default error messages for the whole form. To override the default messages, you must specify them in the `rules` prop per `IressFormField`.
405
489
 
406
- #### [](#required)`required`
490
+ #### `required`
407
491
 
408
492
  A boolean which, if `true`, indicates that the input must have a value before the form can be submitted. You can assign a string to return a custom error message.
409
493
 
494
+ [](./iframe.html?id=components-form-rules--required)
495
+
410
496
  \*Required Default message
411
497
 
412
498
  \*Required Custom message
413
499
 
414
500
  Validate
415
501
 
416
- Show code
502
+ Hide codedrawOpen in CodeSandbox
417
503
 
418
- #### [](#maxlength)`maxLength`
504
+ <ForwardedForm\>
505
+ <IressStack gutter\="lg"\>
506
+ <IressFormField
507
+ hint\=""
508
+ label\="Default message"
509
+ name\="IressInput-default"
510
+ render\={(controlledProps) \=> <IressInput {...controlledProps} />}
511
+ rules\={{
512
+ required: true
513
+ }}
514
+ />
515
+ <IressFormField
516
+ hint\=""
517
+ label\="Custom message"
518
+ name\="IressInput-custom"
519
+ render\={(controlledProps) \=> <IressInput {...controlledProps} />}
520
+ rules\={{
521
+ required: 'Please check this field'
522
+ }}
523
+ />
524
+ <IressButton
525
+ mode\="primary"
526
+ type\="submit"
527
+ \>
528
+ Validate </IressButton\>
529
+ </IressStack\>
530
+ </ForwardedForm\>
531
+
532
+ ```
533
+
534
+ #### Adjust
535
+
536
+ | Name | Description | Default | Control |
537
+ | --- | --- | --- | --- |
538
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
539
+
540
+ #### `maxLength`
419
541
 
420
542
  The maximum character length of the value to accept for this input.
421
543
 
@@ -424,6 +546,8 @@ The maximum character length of the value to accept for this input.
424
546
  * For `IressInput`, you should also set the `maxLength` to stop the user from entering more characters than allowed.
425
547
  * Only applies to: `IressAutocomplete`, `IressInput`, `IressRadioGroup` and `IressSelect`.
426
548
 
549
+ [](./iframe.html?id=components-form-rules--max-length)
550
+
427
551
  Default message
428
552
 
429
553
  Enter a maximum length of 5 characters
@@ -434,11 +558,9 @@ Enter a maximum length of 5 characters
434
558
 
435
559
  Validate
436
560
 
437
- Hide code
561
+ Hide codedrawOpen in CodeSandbox
438
562
 
439
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
440
-
441
- <IressForm\>
563
+ <ForwardedForm\>
442
564
  <IressStack gutter\="lg"\>
443
565
  <IressFormField
444
566
  hint\="Enter a maximum length of 5 characters"
@@ -467,11 +589,17 @@ Hide code
467
589
  \>
468
590
  Validate </IressButton\>
469
591
  </IressStack\>
470
- </IressForm\>
592
+ </ForwardedForm\>
593
+
594
+ ```
595
+
596
+ #### Adjust
471
597
 
472
- Copy
598
+ | Name | Description | Default | Control |
599
+ | --- | --- | --- | --- |
600
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
473
601
 
474
- #### [](#minlength)`minLength`
602
+ #### `minLength`
475
603
 
476
604
  The minimum character length of the value to accept for this input.
477
605
 
@@ -480,6 +608,8 @@ The minimum character length of the value to accept for this input.
480
608
  * For `IressInput`, you should also set the `minLength` to stop the user from entering more characters than allowed.
481
609
  * Only applies to: `IressAutocomplete`, `IressInput`, `IressRadioGroup` and `IressSelect`.
482
610
 
611
+ [](./iframe.html?id=components-form-rules--min-length)
612
+
483
613
  Default message
484
614
 
485
615
  Enter a minimum length of 7 characters
@@ -490,11 +620,9 @@ Enter a minimum length of 7 characters
490
620
 
491
621
  Validate
492
622
 
493
- Hide code
494
-
495
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
623
+ Hide codedrawOpen in CodeSandbox
496
624
 
497
- <IressForm\>
625
+ <ForwardedForm\>
498
626
  <IressStack gutter\="lg"\>
499
627
  <IressFormField
500
628
  hint\="Enter a minimum length of 7 characters"
@@ -523,11 +651,17 @@ Hide code
523
651
  \>
524
652
  Validate </IressButton\>
525
653
  </IressStack\>
526
- </IressForm\>
654
+ </ForwardedForm\>
655
+
656
+ ```
657
+
658
+ #### Adjust
527
659
 
528
- Copy
660
+ | Name | Description | Default | Control |
661
+ | --- | --- | --- | --- |
662
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
529
663
 
530
- #### [](#max)`max`
664
+ #### `max`
531
665
 
532
666
  The maximum number to accept for this input.
533
667
 
@@ -535,6 +669,8 @@ The maximum number to accept for this input.
535
669
 
536
670
  * Only applies to: `IressAutocomplete`, `IressInput`, `IressRadioGroup` and `IressSelect`.
537
671
 
672
+ [](./iframe.html?id=components-form-rules--max)
673
+
538
674
  Default message
539
675
 
540
676
  Select a maximum of 2
@@ -545,11 +681,9 @@ Select a maximum of 2
545
681
 
546
682
  Validate
547
683
 
548
- Hide code
549
-
550
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
684
+ Hide codedrawOpen in CodeSandbox
551
685
 
552
- <IressForm\>
686
+ <ForwardedForm\>
553
687
  <IressStack gutter\="lg"\>
554
688
  <IressFormField
555
689
  hint\="Select a maximum of 2"
@@ -578,11 +712,17 @@ Hide code
578
712
  \>
579
713
  Validate </IressButton\>
580
714
  </IressStack\>
581
- </IressForm\>
715
+ </ForwardedForm\>
716
+
717
+ ```
582
718
 
583
- Copy
719
+ #### Adjust
584
720
 
585
- #### [](#min)`min`
721
+ | Name | Description | Default | Control |
722
+ | --- | --- | --- | --- |
723
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
724
+
725
+ #### `min`
586
726
 
587
727
  The minimum number to accept for this input.
588
728
 
@@ -590,6 +730,8 @@ The minimum number to accept for this input.
590
730
 
591
731
  * Only applies to: `IressAutocomplete`, `IressInput`, `IressRadioGroup` and `IressSelect`.
592
732
 
733
+ [](./iframe.html?id=components-form-rules--min)
734
+
593
735
  Default message
594
736
 
595
737
  Select a minimum of 20
@@ -600,11 +742,9 @@ Select a minimum of 20
600
742
 
601
743
  Validate
602
744
 
603
- Hide code
745
+ Hide codedrawOpen in CodeSandbox
604
746
 
605
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
606
-
607
- <IressForm\>
747
+ <ForwardedForm\>
608
748
  <IressStack gutter\="lg"\>
609
749
  <IressFormField
610
750
  hint\="Select a minimum of 20"
@@ -633,11 +773,17 @@ Hide code
633
773
  \>
634
774
  Validate </IressButton\>
635
775
  </IressStack\>
636
- </IressForm\>
776
+ </ForwardedForm\>
777
+
778
+ ```
637
779
 
638
- Copy
780
+ #### Adjust
639
781
 
640
- #### [](#pattern)`pattern`
782
+ | Name | Description | Default | Control |
783
+ | --- | --- | --- | --- |
784
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
785
+
786
+ #### `pattern`
641
787
 
642
788
  The accepted regex pattern for the input.
643
789
 
@@ -645,6 +791,8 @@ The accepted regex pattern for the input.
645
791
 
646
792
  * Only applies to: `IressAutocomplete`, `IressInput`, `IressRadioGroup` and `IressSelect`.
647
793
 
794
+ [](./iframe.html?id=components-form-rules--pattern)
795
+
648
796
  Default message
649
797
 
650
798
  Enter a valid email address
@@ -655,11 +803,9 @@ Enter a valid email address
655
803
 
656
804
  Validate
657
805
 
658
- Hide code
659
-
660
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
806
+ Hide codedrawOpen in CodeSandbox
661
807
 
662
- <IressForm\>
808
+ <ForwardedForm\>
663
809
  <IressStack gutter\="lg"\>
664
810
  <IressFormField
665
811
  hint\="Enter a valid email address"
@@ -683,16 +829,24 @@ Hide code
683
829
  \>
684
830
  Validate </IressButton\>
685
831
  </IressStack\>
686
- </IressForm\>
832
+ </ForwardedForm\>
687
833
 
688
- Copy
834
+ ```
689
835
 
690
- #### [](#mindate)`minDate`
836
+ #### Adjust
837
+
838
+ | Name | Description | Default | Control |
839
+ | --- | --- | --- | --- |
840
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
841
+
842
+ #### `minDate`
691
843
 
692
844
  The minimum date to accept for this input.
693
845
 
694
846
  **Note:** This is a custom rule created for `IressForm` and its sub-components. It will translate the rule into a `validate` rule for react-hook-forms. It will not work with a `validate` function, only if you set the `validate` prop to an `object` of functions.
695
847
 
848
+ [](./iframe.html?id=components-form-rules--min-date)
849
+
696
850
  Default message
697
851
 
698
852
  Enter a date after today
@@ -703,11 +857,9 @@ Enter a date after today
703
857
 
704
858
  Validate
705
859
 
706
- Hide code
707
-
708
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
860
+ Hide codedrawOpen in CodeSandbox
709
861
 
710
- <IressForm\>
862
+ <ForwardedForm\>
711
863
  <IressStack gutter\="lg"\>
712
864
  <IressFormField
713
865
  hint\="Enter a date after today"
@@ -715,7 +867,7 @@ Hide code
715
867
  name\="IressInputDate-default"
716
868
  render\={(controlledProps) \=> <IressInput {...controlledProps} />}
717
869
  rules\={{
718
- minDate: new Date('2025-06-27T03:58:57.380Z')
870
+ minDate: new Date('2025-12-16T06:28:50.791Z')
719
871
  }}
720
872
  />
721
873
  <IressFormField
@@ -726,7 +878,7 @@ Hide code
726
878
  rules\={{
727
879
  minDate: {
728
880
  message: 'Please enter a date after today!',
729
- value: new Date('2025-06-27T03:58:57.380Z')
881
+ value: new Date('2025-12-16T06:28:50.791Z')
730
882
  }
731
883
  }}
732
884
  />
@@ -736,16 +888,169 @@ Hide code
736
888
  \>
737
889
  Validate </IressButton\>
738
890
  </IressStack\>
739
- </IressForm\>
891
+ </ForwardedForm\>
892
+
893
+ ```
894
+
895
+ #### Props
896
+
897
+ | Name | Description | Default | Control |
898
+ | --- | --- | --- | --- |
899
+ | children |
900
+ \-
901
+
902
+ | \- | \- |
903
+ | context |
904
+
905
+ This context object is mutable and will be injected into the `resolver`'s second argument (eg. [Yup](https://github.com/jquense/yup) validation's context object).
906
+
907
+ [Learn more](https://react-hook-form.com/docs/useform#context)
908
+
909
+ UseFormProps\['context'\]
910
+
911
+ | \- | Set object |
912
+ | criteriaMode |
913
+
914
+ Display all validation errors or one at a time.
915
+
916
+ [Learn more](https://react-hook-form.com/docs/useform#criteriaMode)
917
+
918
+ UseFormProps\['criteriaMode'\]
919
+
920
+ | \- | Set object |
921
+ | defaultValues |
922
+
923
+ Default values to be passed through when an input is unset.
924
+
925
+ [Learn more](https://react-hook-form.com/docs/useform#defaultValues)
926
+
927
+ DefaultValues
928
+
929
+
930
+
931
+ | \- | Set object |
932
+ | delayError |
933
+
934
+ Delay error from appearing instantly.
935
+
936
+ [Learn more](https://react-hook-form.com/docs/useform#delayError)
937
+
938
+ UseFormProps\['delayError'\]
939
+
940
+ | \- | Set object |
941
+ | form |
942
+
943
+ React hook form instance from `useForm`, use if you need more control over the internal state.
944
+
945
+ const form = useForm();
946
+ return <IressForm form={form} />;
947
+
948
+
949
+ UseFormReturn
950
+
951
+
952
+
953
+ | \- | Set object |
954
+ | mode |
955
+
956
+ Configure the validation strategy **before** a user submits the form.
957
+
958
+ [Learn more](https://react-hook-form.com/docs/useform#mode)
959
+
960
+ UseFormProps\['mode'\]
961
+
962
+ |
963
+
964
+ 'onSubmit'
965
+
966
+ | Set object |
967
+ | progressive |
968
+
969
+ Progressive Enhancement only applicable for SSR framework. [Learn more](https://react-hook-form.com/docs/useform)
970
+
971
+ UseFormProps\['progressive'\]
972
+
973
+ | \- | Set object |
974
+ | resetOptions |
975
+
976
+ This property is related to value update behaviors.
977
+
978
+ [Learn more](https://react-hook-form.com/docs/useform#resetOptions)
979
+
980
+ UseFormProps\['resetOptions'\]
981
+
982
+ | \- | Set object |
983
+ | resolver |
984
+
985
+ This function allows you to use any external validation library such as Yup, Zod, Joi, Vest, Ajv and many others.
986
+
987
+ [Learn more](https://react-hook-form.com/docs/useform#resolver)
988
+
989
+ UseFormProps\['resolver'\]
990
+
991
+ | \- | Set object |
992
+ | reValidateMode |
993
+
994
+ Configure validation strategy when inputs with errors get re-validated **after** a user submits the form.
995
+
996
+ [Learn more](https://react-hook-form.com/docs/useform#reValidateMode)
997
+
998
+ UseFormProps\['reValidateMode'\]
999
+
1000
+ |
1001
+
1002
+ 'onChange'
1003
+
1004
+ | Set object |
1005
+ | shouldFocusError |
1006
+
1007
+ When set to true, and the user submits a form that fails validation, focus is set on the first field with an error. By default, it is set based on the `hiddenErrorSummary` prop.
1008
+
1009
+ * If hiddenErrorSummary is true, it will focus on the first field with an error.
1010
+ * If hiddenErrorSummary is false, it will focus on the error summary.
740
1011
 
741
- Copy
1012
+ [Learn more](https://react-hook-form.com/docs/useform#shouldFocusError)
742
1013
 
743
- #### [](#maxdate)`maxDate`
1014
+ UseFormProps\['shouldFocusError'\]
1015
+
1016
+ | \- | Set object |
1017
+ | shouldUnregister |
1018
+
1019
+ By default, an input value will be retained when input is removed. However, you can set `shouldUnregister` to `true` to `unregister` input during unmount.
1020
+
1021
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUnregister)
1022
+
1023
+ UseFormProps\['shouldUnregister'\]
1024
+
1025
+ | \- | Set object |
1026
+ | shouldUseNativeValidation |
1027
+
1028
+ This config will enable browser native validation. It will also enable CSS selectors :valid and:invalid making styling inputs easier.
1029
+
1030
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUseNativeValidation)
1031
+
1032
+ UseFormProps\['shouldUseNativeValidation'\]
1033
+
1034
+ | \- | Set object |
1035
+ | values |
1036
+
1037
+ The values prop will react to changes and update the form values, which is useful when your form needs to be updated by external state or server data.
1038
+
1039
+ [Learn more](https://react-hook-form.com/docs/useform#values)
1040
+
1041
+ UseFormProps\['values'\]
1042
+
1043
+ | \- | Set object |
1044
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
1045
+
1046
+ #### `maxDate`
744
1047
 
745
1048
  The maximum date to accept for this input.
746
1049
 
747
1050
  **Note:** This is a custom rule created for `IressForm` and its sub-components. It will translate the rule into a `validate` rule for react-hook-forms. It will not work with a `validate` function, only if you set the `validate` prop to an `object` of functions.
748
1051
 
1052
+ [](./iframe.html?id=components-form-rules--max-date)
1053
+
749
1054
  Default message
750
1055
 
751
1056
  Enter a date before today
@@ -756,11 +1061,9 @@ Enter a date before today
756
1061
 
757
1062
  Validate
758
1063
 
759
- Hide code
1064
+ Hide codedrawOpen in CodeSandbox
760
1065
 
761
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
762
-
763
- <IressForm\>
1066
+ <ForwardedForm\>
764
1067
  <IressStack gutter\="lg"\>
765
1068
  <IressFormField
766
1069
  hint\="Enter a date before today"
@@ -768,7 +1071,7 @@ Hide code
768
1071
  name\="IressInputDate-default"
769
1072
  render\={(controlledProps) \=> <IressInput {...controlledProps} />}
770
1073
  rules\={{
771
- maxDate: new Date('2025-06-27T03:58:57.380Z')
1074
+ maxDate: new Date('2025-12-16T06:28:50.791Z')
772
1075
  }}
773
1076
  />
774
1077
  <IressFormField
@@ -779,7 +1082,7 @@ Hide code
779
1082
  rules\={{
780
1083
  maxDate: {
781
1084
  message: 'Please enter a date before today!',
782
- value: new Date('2025-06-27T03:58:57.380Z')
1085
+ value: new Date('2025-12-16T06:28:50.791Z')
783
1086
  }
784
1087
  }}
785
1088
  />
@@ -789,16 +1092,169 @@ Hide code
789
1092
  \>
790
1093
  Validate </IressButton\>
791
1094
  </IressStack\>
792
- </IressForm\>
1095
+ </ForwardedForm\>
1096
+
1097
+ ```
1098
+
1099
+ #### Props
1100
+
1101
+ | Name | Description | Default | Control |
1102
+ | --- | --- | --- | --- |
1103
+ | children |
1104
+ \-
1105
+
1106
+ | \- | \- |
1107
+ | context |
1108
+
1109
+ This context object is mutable and will be injected into the `resolver`'s second argument (eg. [Yup](https://github.com/jquense/yup) validation's context object).
1110
+
1111
+ [Learn more](https://react-hook-form.com/docs/useform#context)
1112
+
1113
+ UseFormProps\['context'\]
1114
+
1115
+ | \- | Set object |
1116
+ | criteriaMode |
1117
+
1118
+ Display all validation errors or one at a time.
1119
+
1120
+ [Learn more](https://react-hook-form.com/docs/useform#criteriaMode)
1121
+
1122
+ UseFormProps\['criteriaMode'\]
1123
+
1124
+ | \- | Set object |
1125
+ | defaultValues |
1126
+
1127
+ Default values to be passed through when an input is unset.
1128
+
1129
+ [Learn more](https://react-hook-form.com/docs/useform#defaultValues)
1130
+
1131
+ DefaultValues
1132
+
1133
+
1134
+
1135
+ | \- | Set object |
1136
+ | delayError |
1137
+
1138
+ Delay error from appearing instantly.
1139
+
1140
+ [Learn more](https://react-hook-form.com/docs/useform#delayError)
1141
+
1142
+ UseFormProps\['delayError'\]
1143
+
1144
+ | \- | Set object |
1145
+ | form |
1146
+
1147
+ React hook form instance from `useForm`, use if you need more control over the internal state.
1148
+
1149
+ const form = useForm();
1150
+ return <IressForm form={form} />;
1151
+
1152
+
1153
+ UseFormReturn
1154
+
1155
+
1156
+
1157
+ | \- | Set object |
1158
+ | mode |
1159
+
1160
+ Configure the validation strategy **before** a user submits the form.
1161
+
1162
+ [Learn more](https://react-hook-form.com/docs/useform#mode)
1163
+
1164
+ UseFormProps\['mode'\]
1165
+
1166
+ |
1167
+
1168
+ 'onSubmit'
1169
+
1170
+ | Set object |
1171
+ | progressive |
1172
+
1173
+ Progressive Enhancement only applicable for SSR framework. [Learn more](https://react-hook-form.com/docs/useform)
1174
+
1175
+ UseFormProps\['progressive'\]
1176
+
1177
+ | \- | Set object |
1178
+ | resetOptions |
1179
+
1180
+ This property is related to value update behaviors.
1181
+
1182
+ [Learn more](https://react-hook-form.com/docs/useform#resetOptions)
1183
+
1184
+ UseFormProps\['resetOptions'\]
1185
+
1186
+ | \- | Set object |
1187
+ | resolver |
793
1188
 
794
- Copy
1189
+ This function allows you to use any external validation library such as Yup, Zod, Joi, Vest, Ajv and many others.
795
1190
 
796
- #### [](#email)`email`
1191
+ [Learn more](https://react-hook-form.com/docs/useform#resolver)
1192
+
1193
+ UseFormProps\['resolver'\]
1194
+
1195
+ | \- | Set object |
1196
+ | reValidateMode |
1197
+
1198
+ Configure validation strategy when inputs with errors get re-validated **after** a user submits the form.
1199
+
1200
+ [Learn more](https://react-hook-form.com/docs/useform#reValidateMode)
1201
+
1202
+ UseFormProps\['reValidateMode'\]
1203
+
1204
+ |
1205
+
1206
+ 'onChange'
1207
+
1208
+ | Set object |
1209
+ | shouldFocusError |
1210
+
1211
+ When set to true, and the user submits a form that fails validation, focus is set on the first field with an error. By default, it is set based on the `hiddenErrorSummary` prop.
1212
+
1213
+ * If hiddenErrorSummary is true, it will focus on the first field with an error.
1214
+ * If hiddenErrorSummary is false, it will focus on the error summary.
1215
+
1216
+ [Learn more](https://react-hook-form.com/docs/useform#shouldFocusError)
1217
+
1218
+ UseFormProps\['shouldFocusError'\]
1219
+
1220
+ | \- | Set object |
1221
+ | shouldUnregister |
1222
+
1223
+ By default, an input value will be retained when input is removed. However, you can set `shouldUnregister` to `true` to `unregister` input during unmount.
1224
+
1225
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUnregister)
1226
+
1227
+ UseFormProps\['shouldUnregister'\]
1228
+
1229
+ | \- | Set object |
1230
+ | shouldUseNativeValidation |
1231
+
1232
+ This config will enable browser native validation. It will also enable CSS selectors :valid and:invalid making styling inputs easier.
1233
+
1234
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUseNativeValidation)
1235
+
1236
+ UseFormProps\['shouldUseNativeValidation'\]
1237
+
1238
+ | \- | Set object |
1239
+ | values |
1240
+
1241
+ The values prop will react to changes and update the form values, which is useful when your form needs to be updated by external state or server data.
1242
+
1243
+ [Learn more](https://react-hook-form.com/docs/useform#values)
1244
+
1245
+ UseFormProps\['values'\]
1246
+
1247
+ | \- | Set object |
1248
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
1249
+
1250
+ #### `email`
797
1251
 
798
1252
  Ensures the input is a valid email address.
799
1253
 
800
1254
  **Note:** This is a custom rule created for `IressForm` and its sub-components. It will translate the rule into a `validate` rule for react-hook-forms. It will not work with a `validate` function, only if you set the `validate` prop to an `object` of functions.
801
1255
 
1256
+ [](./iframe.html?id=components-form-rules--email)
1257
+
802
1258
  Default message
803
1259
 
804
1260
  Enter an email address
@@ -809,11 +1265,9 @@ Enter an email address
809
1265
 
810
1266
  Validate
811
1267
 
812
- Hide code
813
-
814
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1268
+ Hide codedrawOpen in CodeSandbox
815
1269
 
816
- <IressForm\>
1270
+ <ForwardedForm\>
817
1271
  <IressStack gutter\="lg"\>
818
1272
  <IressFormField
819
1273
  hint\="Enter an email address"
@@ -839,11 +1293,162 @@ Hide code
839
1293
  \>
840
1294
  Validate </IressButton\>
841
1295
  </IressStack\>
842
- </IressForm\>
1296
+ </ForwardedForm\>
1297
+
1298
+ ```
1299
+
1300
+ #### Props
1301
+
1302
+ | Name | Description | Default | Control |
1303
+ | --- | --- | --- | --- |
1304
+ | children |
1305
+ \-
1306
+
1307
+ | \- | \- |
1308
+ | context |
1309
+
1310
+ This context object is mutable and will be injected into the `resolver`'s second argument (eg. [Yup](https://github.com/jquense/yup) validation's context object).
1311
+
1312
+ [Learn more](https://react-hook-form.com/docs/useform#context)
1313
+
1314
+ UseFormProps\['context'\]
1315
+
1316
+ | \- | Set object |
1317
+ | criteriaMode |
1318
+
1319
+ Display all validation errors or one at a time.
1320
+
1321
+ [Learn more](https://react-hook-form.com/docs/useform#criteriaMode)
1322
+
1323
+ UseFormProps\['criteriaMode'\]
1324
+
1325
+ | \- | Set object |
1326
+ | defaultValues |
1327
+
1328
+ Default values to be passed through when an input is unset.
1329
+
1330
+ [Learn more](https://react-hook-form.com/docs/useform#defaultValues)
1331
+
1332
+ DefaultValues
1333
+
1334
+
1335
+
1336
+ | \- | Set object |
1337
+ | delayError |
1338
+
1339
+ Delay error from appearing instantly.
1340
+
1341
+ [Learn more](https://react-hook-form.com/docs/useform#delayError)
1342
+
1343
+ UseFormProps\['delayError'\]
1344
+
1345
+ | \- | Set object |
1346
+ | form |
1347
+
1348
+ React hook form instance from `useForm`, use if you need more control over the internal state.
1349
+
1350
+ const form = useForm();
1351
+ return <IressForm form={form} />;
1352
+
1353
+
1354
+ UseFormReturn
1355
+
1356
+
1357
+
1358
+ | \- | Set object |
1359
+ | mode |
1360
+
1361
+ Configure the validation strategy **before** a user submits the form.
843
1362
 
844
- Copy
1363
+ [Learn more](https://react-hook-form.com/docs/useform#mode)
845
1364
 
846
- #### [](#validate)`validate`
1365
+ UseFormProps\['mode'\]
1366
+
1367
+ |
1368
+
1369
+ 'onSubmit'
1370
+
1371
+ | Set object |
1372
+ | progressive |
1373
+
1374
+ Progressive Enhancement only applicable for SSR framework. [Learn more](https://react-hook-form.com/docs/useform)
1375
+
1376
+ UseFormProps\['progressive'\]
1377
+
1378
+ | \- | Set object |
1379
+ | resetOptions |
1380
+
1381
+ This property is related to value update behaviors.
1382
+
1383
+ [Learn more](https://react-hook-form.com/docs/useform#resetOptions)
1384
+
1385
+ UseFormProps\['resetOptions'\]
1386
+
1387
+ | \- | Set object |
1388
+ | resolver |
1389
+
1390
+ This function allows you to use any external validation library such as Yup, Zod, Joi, Vest, Ajv and many others.
1391
+
1392
+ [Learn more](https://react-hook-form.com/docs/useform#resolver)
1393
+
1394
+ UseFormProps\['resolver'\]
1395
+
1396
+ | \- | Set object |
1397
+ | reValidateMode |
1398
+
1399
+ Configure validation strategy when inputs with errors get re-validated **after** a user submits the form.
1400
+
1401
+ [Learn more](https://react-hook-form.com/docs/useform#reValidateMode)
1402
+
1403
+ UseFormProps\['reValidateMode'\]
1404
+
1405
+ |
1406
+
1407
+ 'onChange'
1408
+
1409
+ | Set object |
1410
+ | shouldFocusError |
1411
+
1412
+ When set to true, and the user submits a form that fails validation, focus is set on the first field with an error. By default, it is set based on the `hiddenErrorSummary` prop.
1413
+
1414
+ * If hiddenErrorSummary is true, it will focus on the first field with an error.
1415
+ * If hiddenErrorSummary is false, it will focus on the error summary.
1416
+
1417
+ [Learn more](https://react-hook-form.com/docs/useform#shouldFocusError)
1418
+
1419
+ UseFormProps\['shouldFocusError'\]
1420
+
1421
+ | \- | Set object |
1422
+ | shouldUnregister |
1423
+
1424
+ By default, an input value will be retained when input is removed. However, you can set `shouldUnregister` to `true` to `unregister` input during unmount.
1425
+
1426
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUnregister)
1427
+
1428
+ UseFormProps\['shouldUnregister'\]
1429
+
1430
+ | \- | Set object |
1431
+ | shouldUseNativeValidation |
1432
+
1433
+ This config will enable browser native validation. It will also enable CSS selectors :valid and:invalid making styling inputs easier.
1434
+
1435
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUseNativeValidation)
1436
+
1437
+ UseFormProps\['shouldUseNativeValidation'\]
1438
+
1439
+ | \- | Set object |
1440
+ | values |
1441
+
1442
+ The values prop will react to changes and update the form values, which is useful when your form needs to be updated by external state or server data.
1443
+
1444
+ [Learn more](https://react-hook-form.com/docs/useform#values)
1445
+
1446
+ UseFormProps\['values'\]
1447
+
1448
+ | \- | Set object |
1449
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
1450
+
1451
+ #### `validate`
847
1452
 
848
1453
  You can pass a callback function as the argument to validate, or you can pass an object of callback functions to validate against all of them. This function will be executed on its own without depending on other validation rules included.
849
1454
 
@@ -851,6 +1456,8 @@ You can pass a callback function as the argument to validate, or you can pass an
851
1456
 
852
1457
  * for `object` or `array` input data, it's recommended to use the validate function for validation as the other rules mostly apply to `string`, `string[]`, `number` and `boolean` data types.
853
1458
 
1459
+ [](./iframe.html?id=components-form-rules--validate)
1460
+
854
1461
  Default message
855
1462
 
856
1463
  If checkbox, click two items to pass. Anything else, make sure it is Google.
@@ -869,11 +1476,9 @@ Writing
869
1476
 
870
1477
  Validate
871
1478
 
872
- Hide code
873
-
874
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1479
+ Hide codedrawOpen in CodeSandbox
875
1480
 
876
- <IressForm\>
1481
+ <ForwardedForm\>
877
1482
  <IressStack gutter\="lg"\>
878
1483
  <IressFormFieldset
879
1484
  hint\="If checkbox, click two items to pass. Anything else, make sure it is Google."
@@ -915,34 +1520,185 @@ Hide code
915
1520
  \>
916
1521
  Validate </IressButton\>
917
1522
  </IressStack\>
918
- </IressForm\>
1523
+ </ForwardedForm\>
1524
+
1525
+ ```
1526
+
1527
+ #### Props
1528
+
1529
+ | Name | Description | Default | Control |
1530
+ | --- | --- | --- | --- |
1531
+ | children |
1532
+ \-
1533
+
1534
+ | \- | \- |
1535
+ | context |
1536
+
1537
+ This context object is mutable and will be injected into the `resolver`'s second argument (eg. [Yup](https://github.com/jquense/yup) validation's context object).
1538
+
1539
+ [Learn more](https://react-hook-form.com/docs/useform#context)
1540
+
1541
+ UseFormProps\['context'\]
1542
+
1543
+ | \- | Set object |
1544
+ | criteriaMode |
1545
+
1546
+ Display all validation errors or one at a time.
1547
+
1548
+ [Learn more](https://react-hook-form.com/docs/useform#criteriaMode)
1549
+
1550
+ UseFormProps\['criteriaMode'\]
1551
+
1552
+ | \- | Set object |
1553
+ | defaultValues |
1554
+
1555
+ Default values to be passed through when an input is unset.
1556
+
1557
+ [Learn more](https://react-hook-form.com/docs/useform#defaultValues)
1558
+
1559
+ DefaultValues
1560
+
1561
+
919
1562
 
920
- Copy
1563
+ | \- | Set object |
1564
+ | delayError |
921
1565
 
922
- ### [](#handling-submission)Handling submission
1566
+ Delay error from appearing instantly.
1567
+
1568
+ [Learn more](https://react-hook-form.com/docs/useform#delayError)
1569
+
1570
+ UseFormProps\['delayError'\]
1571
+
1572
+ | \- | Set object |
1573
+ | form |
1574
+
1575
+ React hook form instance from `useForm`, use if you need more control over the internal state.
1576
+
1577
+ const form = useForm();
1578
+ return <IressForm form={form} />;
1579
+
1580
+
1581
+ UseFormReturn
1582
+
1583
+
1584
+
1585
+ | \- | Set object |
1586
+ | mode |
1587
+
1588
+ Configure the validation strategy **before** a user submits the form.
1589
+
1590
+ [Learn more](https://react-hook-form.com/docs/useform#mode)
1591
+
1592
+ UseFormProps\['mode'\]
1593
+
1594
+ |
1595
+
1596
+ 'onSubmit'
1597
+
1598
+ | Set object |
1599
+ | progressive |
1600
+
1601
+ Progressive Enhancement only applicable for SSR framework. [Learn more](https://react-hook-form.com/docs/useform)
1602
+
1603
+ UseFormProps\['progressive'\]
1604
+
1605
+ | \- | Set object |
1606
+ | resetOptions |
1607
+
1608
+ This property is related to value update behaviors.
1609
+
1610
+ [Learn more](https://react-hook-form.com/docs/useform#resetOptions)
1611
+
1612
+ UseFormProps\['resetOptions'\]
1613
+
1614
+ | \- | Set object |
1615
+ | resolver |
1616
+
1617
+ This function allows you to use any external validation library such as Yup, Zod, Joi, Vest, Ajv and many others.
1618
+
1619
+ [Learn more](https://react-hook-form.com/docs/useform#resolver)
1620
+
1621
+ UseFormProps\['resolver'\]
1622
+
1623
+ | \- | Set object |
1624
+ | reValidateMode |
1625
+
1626
+ Configure validation strategy when inputs with errors get re-validated **after** a user submits the form.
1627
+
1628
+ [Learn more](https://react-hook-form.com/docs/useform#reValidateMode)
1629
+
1630
+ UseFormProps\['reValidateMode'\]
1631
+
1632
+ |
1633
+
1634
+ 'onChange'
1635
+
1636
+ | Set object |
1637
+ | shouldFocusError |
1638
+
1639
+ When set to true, and the user submits a form that fails validation, focus is set on the first field with an error. By default, it is set based on the `hiddenErrorSummary` prop.
1640
+
1641
+ * If hiddenErrorSummary is true, it will focus on the first field with an error.
1642
+ * If hiddenErrorSummary is false, it will focus on the error summary.
1643
+
1644
+ [Learn more](https://react-hook-form.com/docs/useform#shouldFocusError)
1645
+
1646
+ UseFormProps\['shouldFocusError'\]
1647
+
1648
+ | \- | Set object |
1649
+ | shouldUnregister |
1650
+
1651
+ By default, an input value will be retained when input is removed. However, you can set `shouldUnregister` to `true` to `unregister` input during unmount.
1652
+
1653
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUnregister)
1654
+
1655
+ UseFormProps\['shouldUnregister'\]
1656
+
1657
+ | \- | Set object |
1658
+ | shouldUseNativeValidation |
1659
+
1660
+ This config will enable browser native validation. It will also enable CSS selectors :valid and:invalid making styling inputs easier.
1661
+
1662
+ [Learn more](https://react-hook-form.com/docs/useform#shouldUseNativeValidation)
1663
+
1664
+ UseFormProps\['shouldUseNativeValidation'\]
1665
+
1666
+ | \- | Set object |
1667
+ | values |
1668
+
1669
+ The values prop will react to changes and update the form values, which is useful when your form needs to be updated by external state or server data.
1670
+
1671
+ [Learn more](https://react-hook-form.com/docs/useform#values)
1672
+
1673
+ UseFormProps\['values'\]
1674
+
1675
+ | \- | Set object |
1676
+ | Show Storybook only itemsStorybook only | Show Storybook only items |
1677
+
1678
+ ### Handling submission
923
1679
 
924
1680
  When the form passes validation (if not disabled), the `onSubmit` event is emitted. Its event details contain a map of the field names and the data entered by the user.
925
1681
 
1682
+ [](./iframe.html?id=components-form--handling-submission)
1683
+
926
1684
  \*Required Name
927
1685
 
928
1686
  \*Required Email address
929
1687
 
930
1688
  Sign up
931
1689
 
932
- Hide code
933
-
934
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1690
+ Hide codedrawOpen in CodeSandbox
935
1691
 
936
1692
  import {
937
1693
  IressTable,
938
- IressFormProps,
1694
+ type IressFormProps,
939
1695
  IressForm,
940
1696
  IressModal,
941
1697
  IressFormField,
942
1698
  IressInput,
943
1699
  IressStack,
944
1700
  IressButton,
945
- } from '@iress-oss/ids-components';
1701
+ } from '@/main';
946
1702
  import { useState } from 'react';
947
1703
  interface FieldValues {
948
1704
  name?: string;
@@ -994,12 +1750,49 @@ export const FormSubmission \= () \=> {
994
1750
  );
995
1751
  };
996
1752
 
997
- Copy
1753
+ ```
1754
+
1755
+ #### Props
1756
+
1757
+ | Name | Description | Default | Control |
1758
+ | --- | --- | --- | --- |
1759
+ | alert |
1760
+ \-
1761
+
1762
+ | \- | alertChoose option...nonebasicAlert |
1763
+ | children |
1764
+
1765
+ object
1766
+
998
1767
 
999
- ### [](#read-only)Read only
1768
+
1769
+ | \- | \- |
1770
+ | form |
1771
+
1772
+ React hook form instance from `useForm`, use if you need more control over the internal state.
1773
+
1774
+ const form = useForm();
1775
+ return <IressForm form={form} />;
1776
+
1777
+
1778
+ UseFormReturn
1779
+
1780
+
1781
+
1782
+ | \- | Set object |
1783
+ | onSubmit |
1784
+
1785
+ \-
1786
+
1787
+ | \- | \- |
1788
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
1789
+
1790
+ ### Read only
1000
1791
 
1001
1792
  You can pass the `readOnly` prop to remove the asterisk symbol (\*) even when the field is `required`, and that field will be exempted from validation.
1002
1793
 
1794
+ [](./iframe.html?id=components-form--exclude-read-only-validation)
1795
+
1003
1796
  Try hitting submit to see the validation summary: only email is being validated
1004
1797
  -------------------------------------------------------------------------------
1005
1798
 
@@ -1011,14 +1804,12 @@ Luke Skywalker
1011
1804
 
1012
1805
  Sign up
1013
1806
 
1014
- Hide code
1015
-
1016
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1807
+ Hide codedrawOpen in CodeSandbox
1017
1808
 
1018
1809
  <IressStack gutter\="md"\>
1019
1810
  <IressText element\="h2"\>
1020
1811
  Try hitting submit to see the validation summary: only email is being validated </IressText\>
1021
- <IressForm\>
1812
+ <ForwardedForm\>
1022
1813
  <IressStack gutter\="md"\>
1023
1814
  <IressFormField
1024
1815
  label\="Name"
@@ -1047,13 +1838,43 @@ Hide code
1047
1838
  \>
1048
1839
  Sign up </IressButton\>
1049
1840
  </IressStack\>
1050
- </IressForm\>
1841
+ </ForwardedForm\>
1051
1842
  </IressStack\>
1052
1843
 
1053
- Copy
1844
+ ```
1054
1845
 
1055
- [](#behaviour)Behaviour
1056
- -----------------------
1846
+ #### Props
1847
+
1848
+ | Name | Description | Default | Control |
1849
+ | --- | --- | --- | --- |
1850
+ | alert |
1851
+ \-
1852
+
1853
+ | \- | alertChoose option...nonebasicAlert |
1854
+ | children |
1855
+
1856
+ object
1857
+
1858
+
1859
+
1860
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
1861
+ | form |
1862
+
1863
+ React hook form instance from `useForm`, use if you need more control over the internal state.
1864
+
1865
+ const form = useForm();
1866
+ return <IressForm form={form} />;
1867
+
1868
+
1869
+ UseFormReturn
1870
+
1871
+
1872
+
1873
+ | \- | Set object |
1874
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
1875
+
1876
+ Behaviour
1877
+ ---------
1057
1878
 
1058
1879
  * Initial form validation is done when the user first submits the form. This allows them to focus on entering data without being overwhelmed by validation errors.
1059
1880
  * If there are validation errors on submission, they will be shown at the form level as a summary, as well as per field. Only the first failing error will be displayed per field.
@@ -1061,13 +1882,15 @@ Copy
1061
1882
 
1062
1883
  **Note:** The default user experience regarding validation is different to previous versions of IDS. This change was done to align IDS with the typical user experience found in other applications. If you would like to change the behaviour to be more consistent with the original IDS, set the `mode` prop of the form to `onBlur`.
1063
1884
 
1064
- [](#examples)Examples
1065
- ---------------------
1885
+ Examples
1886
+ --------
1066
1887
 
1067
- ### [](#validation-summary)Validation summary
1888
+ ### Validation summary
1068
1889
 
1069
1890
  If errors are present, they are displayed in a summary at the top of the page. This can be customised using the `errorSummaryHeading` prop.
1070
1891
 
1892
+ [](./iframe.html?id=components-form--validation-summary)
1893
+
1071
1894
  Try hitting submit to see the validation summary
1072
1895
  ------------------------------------------------
1073
1896
 
@@ -1077,14 +1900,12 @@ Try hitting submit to see the validation summary
1077
1900
 
1078
1901
  Sign up
1079
1902
 
1080
- Hide code
1081
-
1082
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1903
+ Hide codedrawOpen in CodeSandbox
1083
1904
 
1084
1905
  <IressStack gutter\="md"\>
1085
1906
  <IressText element\="h2"\>
1086
1907
  Try hitting submit to see the validation summary </IressText\>
1087
- <IressForm errorSummaryHeading\="We have seen the following errors in your submission..."\>
1908
+ <ForwardedForm errorSummaryHeading\="We have seen the following errors in your submission..."\>
1088
1909
  <IressStack gutter\="md"\>
1089
1910
  <IressFormField
1090
1911
  label\="Name"
@@ -1112,15 +1933,54 @@ Hide code
1112
1933
  \>
1113
1934
  Sign up </IressButton\>
1114
1935
  </IressStack\>
1115
- </IressForm\>
1936
+ </ForwardedForm\>
1116
1937
  </IressStack\>
1117
1938
 
1118
- Copy
1939
+ ```
1940
+
1941
+ #### Props
1942
+
1943
+ | Name | Description | Default | Control |
1944
+ | --- | --- | --- | --- |
1945
+ | alert |
1946
+ \-
1947
+
1948
+ | \- | alertChoose option...nonebasicAlert |
1949
+ | children |
1950
+
1951
+ object
1952
+
1953
+
1954
+
1955
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
1956
+ | errorSummaryHeading |
1957
+
1958
+ string
1959
+
1960
+
1961
+
1962
+ | \- | We have seen the following errors in your submission... |
1963
+ | form |
1119
1964
 
1120
- ### [](#hidden-validation-summary)Hidden validation summary
1965
+ React hook form instance from `useForm`, use if you need more control over the internal state.
1966
+
1967
+ const form = useForm();
1968
+ return <IressForm form={form} />;
1969
+
1970
+
1971
+ UseFormReturn
1972
+
1973
+
1974
+
1975
+ | \- | Set object |
1976
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
1977
+
1978
+ ### Hidden validation summary
1121
1979
 
1122
1980
  Use the `hiddenErrorSummary` prop to hide the summary altogether, and only show the errors on the fields. This is only recommended for short forms, for long forms it is recommended to keep the error summary shown for best accessibility.
1123
1981
 
1982
+ [](./iframe.html?id=components-form--hidden-error-summary)
1983
+
1124
1984
  Try hitting submit to see the errors only on the fields
1125
1985
  -------------------------------------------------------
1126
1986
 
@@ -1130,14 +1990,12 @@ Try hitting submit to see the errors only on the fields
1130
1990
 
1131
1991
  Sign up
1132
1992
 
1133
- Hide code
1134
-
1135
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1993
+ Hide codedrawOpen in CodeSandbox
1136
1994
 
1137
1995
  <IressStack gutter\="md"\>
1138
1996
  <IressText element\="h2"\>
1139
1997
  Try hitting submit to see the errors only on the fields </IressText\>
1140
- <IressForm hiddenErrorSummary\>
1998
+ <ForwardedForm hiddenErrorSummary\>
1141
1999
  <IressStack gutter\="md"\>
1142
2000
  <IressFormField
1143
2001
  label\="Name"
@@ -1165,39 +2023,76 @@ Hide code
1165
2023
  \>
1166
2024
  Sign up </IressButton\>
1167
2025
  </IressStack\>
1168
- </IressForm\>
2026
+ </ForwardedForm\>
1169
2027
  </IressStack\>
1170
2028
 
1171
- Copy
2029
+ ```
2030
+
2031
+ #### Props
2032
+
2033
+ | Name | Description | Default | Control |
2034
+ | --- | --- | --- | --- |
2035
+ | alert |
2036
+ \-
2037
+
2038
+ | \- | alertChoose option...nonebasicAlert |
2039
+ | children |
2040
+
2041
+ object
2042
+
1172
2043
 
1173
- ### [](#custom-error-handling)Custom error handling
2044
+
2045
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
2046
+ | form |
2047
+
2048
+ React hook form instance from `useForm`, use if you need more control over the internal state.
2049
+
2050
+ const form = useForm();
2051
+ return <IressForm form={form} />;
2052
+
2053
+
2054
+ UseFormReturn
2055
+
2056
+
2057
+
2058
+ | \- | Set object |
2059
+ | hiddenErrorSummary |
2060
+
2061
+ boolean
2062
+
2063
+
2064
+
2065
+ | \- | FalseTrue |
2066
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
2067
+
2068
+ ### Custom error handling
1174
2069
 
1175
2070
  The `onError` prop allows you to listen to any field errors. It takes two arguments. The first is a map of the field name and an object containing the first error message and type. The second is a ref to the original element that caused the error (the ref of the underlying input).
1176
2071
 
1177
2072
  One use case for this prop is to create your own error summary.
1178
2073
 
2074
+ [](./iframe.html?id=components-form--custom-error-handling)
2075
+
1179
2076
  \*Required Name
1180
2077
 
1181
2078
  \*Required Email address
1182
2079
 
1183
2080
  Sign up
1184
2081
 
1185
- Hide code
1186
-
1187
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
2082
+ Hide codedrawOpen in CodeSandbox
1188
2083
 
1189
2084
  import {
1190
2085
  IressTable,
1191
- IressFormProps,
2086
+ type IressFormProps,
1192
2087
  IressForm,
1193
2088
  IressModal,
1194
2089
  IressStack,
1195
2090
  IressFormField,
1196
2091
  IressInput,
1197
2092
  IressButton,
1198
- } from '@iress-oss/ids-components';
2093
+ } from '@/main';
1199
2094
  import { useState } from 'react';
1200
- import { FieldErrors } from 'react-hook-form';
2095
+ import { type FieldErrors } from 'react-hook-form';
1201
2096
  interface FieldValues {
1202
2097
  name?: string;
1203
2098
  email?: string;
@@ -1257,23 +2152,65 @@ export const CustomErrorHandlingForm \= () \=> {
1257
2152
  );
1258
2153
  };
1259
2154
 
1260
- Copy
2155
+ ```
2156
+
2157
+ #### Props
2158
+
2159
+ | Name | Description | Default | Control |
2160
+ | --- | --- | --- | --- |
2161
+ | alert |
2162
+ \-
2163
+
2164
+ | \- | alertChoose option...nonebasicAlert |
2165
+ | children |
2166
+
2167
+ object
2168
+
2169
+
2170
+
2171
+ | \- | \- |
2172
+ | form |
2173
+
2174
+ React hook form instance from `useForm`, use if you need more control over the internal state.
2175
+
2176
+ const form = useForm();
2177
+ return <IressForm form={form} />;
2178
+
2179
+
2180
+ UseFormReturn
2181
+
2182
+
2183
+
2184
+ | \- | Set object |
2185
+ | hiddenErrorSummary |
2186
+
2187
+ boolean
2188
+
2189
+
2190
+
2191
+ | \- | FalseTrue |
2192
+ | onError |
2193
+
2194
+ \-
1261
2195
 
1262
- ### [](#pre-fill-the-form)Pre-fill the form
2196
+ | \- | \- |
2197
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
2198
+
2199
+ ### Pre-fill the form
1263
2200
 
1264
2201
  You can set the `defaultValues` prop to pre-fill the form values.
1265
2202
 
2203
+ [](./iframe.html?id=components-form--default-values)
2204
+
1266
2205
  \*Required Name
1267
2206
 
1268
2207
  \*Required Email address
1269
2208
 
1270
2209
  Sign up
1271
2210
 
1272
- Hide code
2211
+ Hide codedrawOpen in CodeSandbox
1273
2212
 
1274
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
1275
-
1276
- <IressForm
2213
+ <ForwardedForm
1277
2214
  defaultValues\={{
1278
2215
  email: 'luke.skywalker@iress.com',
1279
2216
  name: 'Luke Skywalker'
@@ -1306,11 +2243,41 @@ Hide code
1306
2243
  \>
1307
2244
  Sign up </IressButton\>
1308
2245
  </IressStack\>
1309
- </IressForm\>
2246
+ </ForwardedForm\>
2247
+
2248
+ ```
2249
+
2250
+ #### Props
2251
+
2252
+ | Name | Description | Default | Control |
2253
+ | --- | --- | --- | --- |
2254
+ | alert |
2255
+ \-
2256
+
2257
+ | \- | alertChoose option...nonebasicAlert |
2258
+ | children |
2259
+
2260
+ object
2261
+
2262
+
2263
+
2264
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
2265
+ | form |
2266
+
2267
+ React hook form instance from `useForm`, use if you need more control over the internal state.
2268
+
2269
+ const form = useForm();
2270
+ return <IressForm form={form} />;
2271
+
2272
+
2273
+ UseFormReturn
2274
+
2275
+
1310
2276
 
1311
- Copy
2277
+ | \- | Set object |
2278
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
1312
2279
 
1313
- ### [](#values)`values`
2280
+ ### `values`
1314
2281
 
1315
2282
  If you would like more control over each value of the form, you should use the `values` prop. This will make the form controlled, meaning it will rely completely on the `values` state to render the value of each field. You will need to use the `onSubmit` prop to sync the form value with your state.
1316
2283
 
@@ -1321,6 +2288,8 @@ Use cases where you may need the `values` prop:
1321
2288
 
1322
2289
  **Note:** `values` takes precedence over `defaultValues`. To ensure your form state is predictable, it is best to only use one prop to manage form values.
1323
2290
 
2291
+ [](./iframe.html?id=components-form--values)
2292
+
1324
2293
  \*Required Name
1325
2294
 
1326
2295
  \*Required Email address
@@ -1331,10 +2300,21 @@ Sign up
1331
2300
 
1332
2301
  Last updateClear
1333
2302
 
1334
- Hide code
1335
-
1336
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
2303
+ Hide codedrawOpen in CodeSandbox
1337
2304
 
2305
+ import {
2306
+ type IressFormProps,
2307
+ IressForm,
2308
+ IressModal,
2309
+ IressDivider,
2310
+ IressButton,
2311
+ IressTable,
2312
+ IressInline,
2313
+ IressStack,
2314
+ IressFormField,
2315
+ IressInput,
2316
+ } from '@/main';
2317
+ import { useState } from 'react';
1338
2318
  interface FieldValues {
1339
2319
  name?: string;
1340
2320
  email?: string;
@@ -1407,9 +2387,44 @@ export const ControlledForm \= (args: IressFormProps<FieldValues\>) \=> {
1407
2387
  );
1408
2388
  };
1409
2389
 
1410
- Copy
2390
+ ```
2391
+
2392
+ #### Props
2393
+
2394
+ | Name | Description | Default | Control |
2395
+ | --- | --- | --- | --- |
2396
+ | alert |
2397
+ \-
2398
+
2399
+ | \- | alertChoose option...nonebasicAlert |
2400
+ | children |
2401
+
2402
+ object
1411
2403
 
1412
- ### [](#disable-validation)Disable validation
2404
+
2405
+
2406
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
2407
+ | form |
2408
+
2409
+ React hook form instance from `useForm`, use if you need more control over the internal state.
2410
+
2411
+ const form = useForm();
2412
+ return <IressForm form={form} />;
2413
+
2414
+
2415
+ UseFormReturn
2416
+
2417
+
2418
+
2419
+ | \- | Set object |
2420
+ | onSubmit |
2421
+
2422
+ \-
2423
+
2424
+ | \- | \- |
2425
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
2426
+
2427
+ ### Disable validation
1413
2428
 
1414
2429
  Disabling validation is not possible with the `IressForm` component. In cases where you do need to disable validation, please consider the following:
1415
2430
 
@@ -1418,6 +2433,8 @@ Disabling validation is not possible with the `IressForm` component. In cases wh
1418
2433
 
1419
2434
  Here we have an example showcasing option one.
1420
2435
 
2436
+ [](./iframe.html?id=components-form--disable-validation)
2437
+
1421
2438
  \*Required Name
1422
2439
 
1423
2440
  \*Required Email address
@@ -1428,22 +2445,20 @@ Sign up
1428
2445
 
1429
2446
  Save as draft
1430
2447
 
1431
- Hide code
1432
-
1433
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
2448
+ Hide codedrawOpen in CodeSandbox
1434
2449
 
1435
2450
  import {
1436
- FormRef,
2451
+ type FormRef,
1437
2452
  IressButton,
1438
2453
  IressDivider,
1439
2454
  IressForm,
1440
2455
  IressFormField,
1441
- IressFormProps,
2456
+ type IressFormProps,
1442
2457
  IressInput,
1443
2458
  IressStack,
1444
2459
  IressToasterProvider,
1445
2460
  useToaster,
1446
- } from '@iress-oss/ids-components';
2461
+ } from '@/main';
1447
2462
  import { useRef } from 'react';
1448
2463
  interface FieldValues {
1449
2464
  name?: string;
@@ -1514,14 +2529,56 @@ export const DisableValidationForm \= () \=> (
1514
2529
  </IressToasterProvider\>
1515
2530
  );
1516
2531
 
1517
- Copy
2532
+ ```
2533
+
2534
+ #### Props
2535
+
2536
+ | Name | Description | Default | Control |
2537
+ | --- | --- | --- | --- |
2538
+ | alert |
2539
+ \-
2540
+
2541
+ | \- | alertChoose option...nonebasicAlert |
2542
+ | children |
1518
2543
 
1519
- ### [](#resetting-the-form)Resetting the form
2544
+ object
2545
+
2546
+
2547
+
2548
+ | \- | \- |
2549
+ | form |
2550
+
2551
+ React hook form instance from `useForm`, use if you need more control over the internal state.
2552
+
2553
+ const form = useForm();
2554
+ return <IressForm form={form} />;
2555
+
2556
+
2557
+ UseFormReturn
2558
+
2559
+
2560
+
2561
+ | \- | Set object |
2562
+ | onError |
2563
+
2564
+ \-
2565
+
2566
+ | \- | \- |
2567
+ | onSubmit |
2568
+
2569
+ \-
2570
+
2571
+ | \- | \- |
2572
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
2573
+
2574
+ ### Resetting the form
1520
2575
 
1521
2576
  You can reset the form using the `ref` of the form. You must provide a `defaultValues` prop that contains all the fields in the form to ensure it resets properly.
1522
2577
 
1523
2578
  **Note:** `<button type="reset" />` does not work with `IressForm`. You need to add an `onClick` prop to the button and use the `ref.reset` method to reset the form.
1524
2579
 
2580
+ [](./iframe.html?id=components-form--reset-form)
2581
+
1525
2582
  \*Required Name
1526
2583
 
1527
2584
  \*Required Email address
@@ -1532,20 +2589,18 @@ Sign up
1532
2589
 
1533
2590
  Reset
1534
2591
 
1535
- Hide code
1536
-
1537
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
2592
+ Hide codedrawOpen in CodeSandbox
1538
2593
 
1539
2594
  import {
1540
- IressFormProps,
2595
+ type IressFormProps,
1541
2596
  IressForm,
1542
- FormRef,
2597
+ type FormRef,
1543
2598
  IressDivider,
1544
2599
  IressButton,
1545
2600
  IressStack,
1546
2601
  IressFormField,
1547
2602
  IressInput,
1548
- } from '@iress-oss/ids-components';
2603
+ } from '@/main';
1549
2604
  import { useRef } from 'react';
1550
2605
  interface FieldValues {
1551
2606
  name?: string;
@@ -1591,9 +2646,39 @@ export const FormReset \= () \=> {
1591
2646
  );
1592
2647
  };
1593
2648
 
1594
- Copy
2649
+ ```
1595
2650
 
1596
- ### [](#custom-form-field-components)Custom form field components
2651
+ #### Props
2652
+
2653
+ | Name | Description | Default | Control |
2654
+ | --- | --- | --- | --- |
2655
+ | alert |
2656
+ \-
2657
+
2658
+ | \- | alertChoose option...nonebasicAlert |
2659
+ | children |
2660
+
2661
+ object
2662
+
2663
+
2664
+
2665
+ | \- | \- |
2666
+ | form |
2667
+
2668
+ React hook form instance from `useForm`, use if you need more control over the internal state.
2669
+
2670
+ const form = useForm();
2671
+ return <IressForm form={form} />;
2672
+
2673
+
2674
+ UseFormReturn
2675
+
2676
+
2677
+
2678
+ | \- | Set object |
2679
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
2680
+
2681
+ ### Custom form field components
1597
2682
 
1598
2683
  You can integrate custom components within `IressFormField` to create enhanced form experiences.
1599
2684
 
@@ -1612,6 +2697,8 @@ Key features demonstrated:
1612
2697
  * **Form State Management**: Automatically integrates with form context using controlled props
1613
2698
  * **File Management**: Display uploaded files with remove functionality using `IressPanel`
1614
2699
 
2700
+ [](./iframe.html?id=components-form--custom-form-field-components)
2701
+
1615
2702
  Custom FormField Components
1616
2703
  ===========================
1617
2704
 
@@ -1625,12 +2712,22 @@ Upload
1625
2712
 
1626
2713
  Submit
1627
2714
 
1628
- Hide code
1629
-
1630
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
2715
+ Hide codedrawOpen in CodeSandbox
1631
2716
 
2717
+ import {
2718
+ IressButton,
2719
+ IressForm,
2720
+ type IressFormProps,
2721
+ IressInput,
2722
+ IressFormField,
2723
+ IressStack,
2724
+ IressIcon,
2725
+ IressText,
2726
+ IressPanel,
2727
+ IressInline,
2728
+ } from '@/main';
1632
2729
  import React, { useState } from 'react';
1633
-
2730
+ import { useDropzone } from 'react-dropzone';
1634
2731
  interface TranscriptFormValues {
1635
2732
  transcript: TranscriptData | string;
1636
2733
  }
@@ -1736,7 +2833,7 @@ const TranscriptTextBox \= ({
1736
2833
  reader.readAsText(file);
1737
2834
  };
1738
2835
  const handleTextChange \= (
1739
- e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement\>,
2836
+ \_e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement\>,
1740
2837
  textContent: string,
1741
2838
  ) \=> {
1742
2839
  onChange(createTranscriptData(textContent, 'text'));
@@ -1918,28 +3015,58 @@ export const CustomFormFieldComponents \= (
1918
3015
  );
1919
3016
  };
1920
3017
 
1921
- Copy
3018
+ ```
3019
+
3020
+ #### Props
3021
+
3022
+ | Name | Description | Default | Control |
3023
+ | --- | --- | --- | --- |
3024
+ | alert |
3025
+ \-
3026
+
3027
+ | \- | alertChoose option...nonebasicAlert |
3028
+ | children |
3029
+
3030
+ object
3031
+
3032
+
3033
+
3034
+ | \- | \- |
3035
+ | form |
3036
+
3037
+ React hook form instance from `useForm`, use if you need more control over the internal state.
3038
+
3039
+ const form = useForm();
3040
+ return <IressForm form={form} />;
3041
+
1922
3042
 
1923
- ### [](#forms-in-expanders-lazy-loading)Forms in expanders (lazy loading)
3043
+ UseFormReturn
3044
+
3045
+
3046
+
3047
+ | \- | \- |
3048
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
3049
+
3050
+ ### Forms in expanders (lazy loading)
1924
3051
 
1925
3052
  If you are using forms in expanders, or in other scenarios when the loading of the form may be delayed, it is recommended to only load the form when it is required. This will improve performance of your application, and make it more predictable. It may also fix act warnings in tests if you are seeing some appearing due to conditionally loaded `IressForm` elements.
1926
3053
 
3054
+ [](./iframe.html?id=components-form--forms-in-expanders)
3055
+
1927
3056
  Sender
1928
3057
 
1929
3058
  Recipient
1930
3059
 
1931
- Hide code
1932
-
1933
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
3060
+ Hide codedrawOpen in CodeSandbox
1934
3061
 
1935
3062
  import {
1936
3063
  IressExpander,
1937
3064
  IressForm,
1938
3065
  IressFormField,
1939
- IressFormProps,
3066
+ type IressFormProps,
1940
3067
  IressInput,
1941
3068
  IressStack,
1942
- } from '@iress-oss/ids-components';
3069
+ } from '@/main';
1943
3070
  import { useState } from 'react';
1944
3071
  interface FieldValues {
1945
3072
  name?: string;
@@ -1994,9 +3121,39 @@ export const FormExpanders \= () \=> {
1994
3121
  );
1995
3122
  };
1996
3123
 
1997
- Copy
3124
+ ```
3125
+
3126
+ #### Props
3127
+
3128
+ | Name | Description | Default | Control |
3129
+ | --- | --- | --- | --- |
3130
+ | alert |
3131
+ \-
3132
+
3133
+ | \- | alertChoose option...nonebasicAlert |
3134
+ | children |
3135
+
3136
+ object
3137
+
3138
+
3139
+
3140
+ | \- | \- |
3141
+ | form |
3142
+
3143
+ React hook form instance from `useForm`, use if you need more control over the internal state.
3144
+
3145
+ const form = useForm();
3146
+ return <IressForm form={form} />;
3147
+
3148
+
3149
+ UseFormReturn
1998
3150
 
1999
- ### [](#conditional-fields-usewatch)Conditional fields (useWatch)
3151
+
3152
+
3153
+ | \- | Set object |
3154
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
3155
+
3156
+ ### Conditional fields (useWatch)
2000
3157
 
2001
3158
  When you have fields that are conditionally shown, you can use the `IressForm.useWatch` hook to watch the value of another field and conditionally render the field.
2002
3159
 
@@ -2004,6 +3161,8 @@ When you have fields that are conditionally shown, you can use the `IressForm.us
2004
3161
 
2005
3162
  * You can use the `api.watch` method on the `IressForm`'s ref to watch the value of a field, but it is recommended to use the hook for better performance by isolating re-rendering at the component level.
2006
3163
 
3164
+ [](./iframe.html?id=components-form--use-watch)
3165
+
2007
3166
  This is a conditional field example using "useWatch".
2008
3167
 
2009
3168
  \*Required Select fields to show
@@ -2016,9 +3175,7 @@ Email
2016
3175
 
2017
3176
  Submit
2018
3177
 
2019
- Hide code
2020
-
2021
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
3178
+ Hide codedrawOpen in CodeSandbox
2022
3179
 
2023
3180
  import {
2024
3181
  IressButton,
@@ -2027,11 +3184,11 @@ import {
2027
3184
  IressDivider,
2028
3185
  IressForm,
2029
3186
  IressFormField,
2030
- IressFormProps,
3187
+ type IressFormProps,
2031
3188
  IressInput,
2032
3189
  IressStack,
2033
3190
  IressText,
2034
- } from '@iress-oss/ids-components';
3191
+ } from '@/main';
2035
3192
  interface FieldValues {
2036
3193
  show?: string\[\];
2037
3194
  name?: string;
@@ -2097,10 +3254,40 @@ export const UseWatchForm \= () \=> (
2097
3254
  </IressForm\>
2098
3255
  );
2099
3256
 
2100
- Copy
3257
+ ```
3258
+
3259
+ #### Props
3260
+
3261
+ | Name | Description | Default | Control |
3262
+ | --- | --- | --- | --- |
3263
+ | alert |
3264
+ \-
3265
+
3266
+ | \- | alertChoose option...nonebasicAlert |
3267
+ | children |
3268
+
3269
+ object
3270
+
3271
+
3272
+
3273
+ | \- | childrenChoose option...nonesimplesupportedControlsreadOnly |
3274
+ | form |
3275
+
3276
+ React hook form instance from `useForm`, use if you need more control over the internal state.
3277
+
3278
+ const form = useForm();
3279
+ return <IressForm form={form} />;
3280
+
3281
+
3282
+ UseFormReturn
3283
+
2101
3284
 
2102
- [](#iresshookform)`IressHookForm`
2103
- ---------------------------------
3285
+
3286
+ | \- | Set object |
3287
+ | Show React Hook Forms itemsReact Hook Forms | Show React Hook Forms items |
3288
+
3289
+ `IressHookForm`
3290
+ ---------------
2104
3291
 
2105
3292
  `IressHookForm` is the underlying component that `IressForm` is built upon. It has a single required prop, `form`, which expects the return value of the `useForm` hook from React Hook Forms.
2106
3293
 
@@ -2111,16 +3298,25 @@ Some use cases:
2111
3298
  1. You may need to use the `useForm` hook in a parent component to share the form state with multiple child components.
2112
3299
  2. You would like to use the return value of the `useForm` hook without having to use a ref to access the `react-hook-form` api.
2113
3300
 
3301
+ [](./iframe.html?id=components-form--hook-form)
3302
+
2114
3303
  \*Required First Name
2115
3304
 
2116
3305
  \*Required Last Name
2117
3306
 
2118
3307
  Submit
2119
3308
 
2120
- Hide code
2121
-
2122
- \[data-radix-scroll-area-viewport\] { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; } \[data-radix-scroll-area-viewport\]::-webkit-scrollbar { display: none; } :where(\[data-radix-scroll-area-viewport\]) { display: flex; flex-direction: column; align-items: stretch; } :where(\[data-radix-scroll-area-content\]) { flex-grow: 1; }
3309
+ Hide codedrawOpen in CodeSandbox
2123
3310
 
3311
+ import {
3312
+ IressButton,
3313
+ IressFormField,
3314
+ IressHookForm,
3315
+ IressInput,
3316
+ IressPanel,
3317
+ IressStack,
3318
+ } from '@/main';
3319
+ import { useForm } from 'react-hook-form';
2124
3320
  interface FieldValues {
2125
3321
  firstName: string;
2126
3322
  lastName: string;
@@ -2158,10 +3354,128 @@ export const HookFormExample \= () \=> {
2158
3354
  );
2159
3355
  };
2160
3356
 
2161
- Copy
3357
+ ```
3358
+
3359
+ #### Props
3360
+
3361
+ | Name | Description | Default | Control |
3362
+ | --- | --- | --- | --- |
3363
+ | alert |
3364
+ Section to place error summary when the app is in control of validation.
3365
+
3366
+ ReactReactNode
3367
+
3368
+
3369
+
3370
+ | \- | Set object |
3371
+ | children |
3372
+
3373
+ The content of the form, usually multiple `IressFormField` or `IressFormFieldset` components.
3374
+
3375
+ ReactReactNode
3376
+
3377
+
3378
+
3379
+ | \- | Set object |
3380
+ | errorSummaryHeading |
3381
+
3382
+ Content to be displayed in the title of the error summary.
3383
+
3384
+ ReactNode
3385
+
3386
+
3387
+
3388
+ | <h3>There was a problem submitting this form</h3> | Set object |
3389
+ | errorSummaryHeadingLevel |
3390
+
3391
+ Level of error summary heading for semantics.
3392
+
3393
+ HeadingLevel
3394
+
3395
+ <table class="css-ymgjf7"><tbody><tr><td colspan="2"><strong>Deprecated</strong>: Use errorSummaryHeading instead.</td></tr></tbody></table>
3396
+
3397
+ | \- | Set object |
3398
+ | errorSummaryHeadingText |
3399
+
3400
+ Text to be displayed in the title of the error summary.
3401
+
3402
+ string
2162
3403
 
2163
- [](#migration-to-version-5)Migration to version 5
2164
- -------------------------------------------------
3404
+ <table class="css-ymgjf7"><tbody><tr><td colspan="2"><strong>Deprecated</strong>: Use errorSummaryHeading instead.</td></tr></tbody></table>
3405
+
3406
+ | \- | Set string |
3407
+ | form\* |
3408
+
3409
+ React hook form instance.
3410
+
3411
+ UseFormReturn
3412
+
3413
+
3414
+
3415
+ | \- | Set object |
3416
+ | gutter |
3417
+
3418
+ Sets the amount of spacing between the heading, alert, children and footer.
3419
+
3420
+ union
3421
+
3422
+
3423
+
3424
+ |
3425
+
3426
+ 'lg'
3427
+
3428
+ | Set object |
3429
+ | hiddenErrorSummary |
3430
+
3431
+ Sets which of the block / inline layout options apply.
3432
+
3433
+ boolean
3434
+
3435
+
3436
+
3437
+ | \- | Set boolean |
3438
+ | onError |
3439
+
3440
+ Emitted when any field has an error. Called after the first submit if any errors are recorded, and from then on when any value changes.
3441
+
3442
+ [Learn more](https://react-hook-form.com/docs/useform/handlesubmit)
3443
+
3444
+ SubmitErrorHandler
3445
+
3446
+
3447
+
3448
+ | \- | Set object |
3449
+ | onSubmit |
3450
+
3451
+ Handler for when the submit method on the form is called after validation is passed.
3452
+
3453
+ [Learn more](https://react-hook-form.com/docs/useform/handlesubmit)
3454
+
3455
+ (data: T) => void
3456
+
3457
+ | \- | \- |
3458
+ | onValidChange |
3459
+
3460
+ Emitted when the form state is valid.
3461
+
3462
+ [Learn more](https://react-hook-form.com/docs/useform/formstate)
3463
+
3464
+ (isValid: boolean) => void
3465
+
3466
+ | \- | \- |
3467
+ | updateErrorSummaryOnSubmit |
3468
+
3469
+ If set to `true`, the summary will only update when the form is submitted, not on every field change. This is useful for performance reasons, especially in large forms.
3470
+
3471
+ boolean
3472
+
3473
+
3474
+
3475
+ | \- | Set boolean |
3476
+
3477
+ Migration to version 5
3478
+ ----------------------
2165
3479
 
2166
3480
  The previous form components contained a lot of logic to translate the HTML5 validation API to a format that matched the design system’s guidelines. This allowed users to use the default props of input such as `pattern` and `required`, and be assured that the `IressField` would display errors accordingly.
2167
3481
 
@@ -2173,30 +3487,13 @@ The validation logic has been stripped from all of the existing form components.
2173
3487
 
2174
3488
  Automated validation is now solely contained in `IressForm` and `IressFormField`, using [React Hook Form](https://react-hook-form.com/docs/useform) under the hood to simplify maintenance.
2175
3489
 
2176
- [](#testing)Testing
2177
- -------------------
3490
+ Testing
3491
+ -------
2178
3492
 
2179
3493
  Unfortunately due to the asynchronous nature of React Hook Form validation, `IressForm` still needs to be tested using `screen.findBy` queries (at least in the first query after render). If `findBy` is not used, you will start to see the dreaded `act warnings`. For more information on testing IressForm, please refer to the (React Hook Form testing documentation)\[[https://react-hook-form.com/advanced-usage#TestingForm](https://react-hook-form.com/advanced-usage#TestingForm)\]
2180
3494
 
2181
3495
  Here is an example of testing a form submission.
2182
3496
 
2183
- \[data-radix-scroll-area-viewport\] {
2184
- scrollbar-width: none;
2185
- -ms-overflow-style: none;
2186
- -webkit-overflow-scrolling: touch;
2187
- }
2188
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
2189
- display: none;
2190
- }
2191
- :where(\[data-radix-scroll-area-viewport\]) {
2192
- display: flex;
2193
- flex-direction: column;
2194
- align-items: stretch;
2195
- }
2196
- :where(\[data-radix-scroll-area-content\]) {
2197
- flex-grow: 1;
2198
- }
2199
-
2200
3497
  render(
2201
3498
  <IressForm\>
2202
3499
  <IressFormField
@@ -2221,34 +3518,17 @@ const summaryError \= await screen.findByText(
2221
3518
  );
2222
3519
  expect(summaryError).toBeInTheDocument();
2223
3520
 
2224
- Copy
3521
+ ```
2225
3522
 
2226
- [](#caveat)Caveat
2227
- -----------------
3523
+ Caveat
3524
+ ------
2228
3525
 
2229
- ### [](#using-iressselect-with-non-string-values-in-iressformfield)Using `IressSelect` with non-string values in `IressFormField`
3526
+ ### Using `IressSelect` with non-string values in `IressFormField`
2230
3527
 
2231
3528
  When using form controls that support non-string values (like `IressSelect` with number values), you might encounter type conflicts with React Hook Form's default event handling. By default, React Hook Form expects string values from form controls.
2232
3529
 
2233
3530
  **Problem:**
2234
3531
 
2235
- \[data-radix-scroll-area-viewport\] {
2236
- scrollbar-width: none;
2237
- -ms-overflow-style: none;
2238
- -webkit-overflow-scrolling: touch;
2239
- }
2240
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
2241
- display: none;
2242
- }
2243
- :where(\[data-radix-scroll-area-viewport\]) {
2244
- display: flex;
2245
- flex-direction: column;
2246
- align-items: stretch;
2247
- }
2248
- :where(\[data-radix-scroll-area-content\]) {
2249
- flex-grow: 1;
2250
- }
2251
-
2252
3532
  <IressFormField
2253
3533
  name\="dependents"
2254
3534
  label\="Dependents"
@@ -2264,29 +3544,12 @@ When using form controls that support non-string values (like `IressSelect` with
2264
3544
  )}
2265
3545
  />
2266
3546
 
2267
- Copy
3547
+ ```
2268
3548
 
2269
3549
  In this case, React Hook Form will try to convert the value to string, which might cause type issues.
2270
3550
 
2271
3551
  **Solution:** Override the `onChange` handler to pass the actual value as a second parameter:
2272
3552
 
2273
- \[data-radix-scroll-area-viewport\] {
2274
- scrollbar-width: none;
2275
- -ms-overflow-style: none;
2276
- -webkit-overflow-scrolling: touch;
2277
- }
2278
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
2279
- display: none;
2280
- }
2281
- :where(\[data-radix-scroll-area-viewport\]) {
2282
- display: flex;
2283
- flex-direction: column;
2284
- align-items: stretch;
2285
- }
2286
- :where(\[data-radix-scroll-area-content\]) {
2287
- flex-grow: 1;
2288
- }
2289
-
2290
3553
  <IressFormField
2291
3554
  name\="dependents"
2292
3555
  label\="Dependents"
@@ -2305,106 +3568,39 @@ In this case, React Hook Form will try to convert the value to string, which mig
2305
3568
  )}
2306
3569
  />
2307
3570
 
2308
- Copy
3571
+ ```
2309
3572
 
2310
3573
  This ensures the original value type is preserved when passed to React Hook Form. You can find out more about the code example in the [Switch Edit Readonly Form Documentation](?path=/docs/components-form-recipes--docs#switching-between-readonly-and-edit-modes).
2311
3574
 
2312
- ### [](#properly-resetting-fields)Properly resetting fields
3575
+ ### Properly resetting fields
2313
3576
 
2314
3577
  When resetting fields that accept non-string values (like `IressRichSelect`), you should reset them to `null` or `undefined` instead of an empty string. This is because the underlying component is strictly typed and expects a specific value type.
2315
3578
 
2316
3579
  **Problem:**
2317
3580
 
2318
- \[data-radix-scroll-area-viewport\] {
2319
- scrollbar-width: none;
2320
- -ms-overflow-style: none;
2321
- -webkit-overflow-scrolling: touch;
2322
- }
2323
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
2324
- display: none;
2325
- }
2326
- :where(\[data-radix-scroll-area-viewport\]) {
2327
- display: flex;
2328
- flex-direction: column;
2329
- align-items: stretch;
2330
- }
2331
- :where(\[data-radix-scroll-area-content\]) {
2332
- flex-grow: 1;
2333
- }
2334
-
2335
3581
  const { resetField } \= IressForm.useFormContext();
2336
3582
  resetField('rich-select', {
2337
3583
  label: '',
2338
3584
  value: '',
2339
3585
  });
2340
3586
 
2341
- Copy
3587
+ ```
2342
3588
 
2343
3589
  In this case, it will look like it cleared the field, but actually it has not. This is obvious with a `placeholder` set, as it will not show the placeholder.
2344
3590
 
2345
3591
  **Solution:** Override the `onChange` handler to pass the actual value as a second parameter:
2346
3592
 
2347
- \[data-radix-scroll-area-viewport\] {
2348
- scrollbar-width: none;
2349
- -ms-overflow-style: none;
2350
- -webkit-overflow-scrolling: touch;
2351
- }
2352
- \[data-radix-scroll-area-viewport\]::-webkit-scrollbar {
2353
- display: none;
2354
- }
2355
- :where(\[data-radix-scroll-area-viewport\]) {
2356
- display: flex;
2357
- flex-direction: column;
2358
- align-items: stretch;
2359
- }
2360
- :where(\[data-radix-scroll-area-content\]) {
2361
- flex-grow: 1;
2362
- }
2363
-
2364
3593
  const { resetField } \= IressForm.useFormContext();
2365
3594
  resetField('rich-select', null); // or undefined
2366
3595
 
2367
- Copy
3596
+ ```
2368
3597
 
2369
3598
  This will properly reset the field to null and clear the field value.
2370
3599
 
2371
- ### [](#conflicting-versions-of-react-hook-forms)Conflicting versions of React Hook Forms
3600
+ ### Conflicting versions of React Hook Forms
2372
3601
 
2373
3602
  If you are using React Hook Forms in your application, please ensure it is the same version IDS uses, otherwise there will be conflicts.
2374
3603
 
2375
3604
  The version we are using in IDS is:
2376
3605
 
2377
3606
  yarn add react-hook-form@7.53.1
2378
-
2379
- On this page
2380
-
2381
- * [Overview](#overview)
2382
- * [Props](#props)
2383
- * [Key concepts](#key-concepts)
2384
- * [State management](#state-management)
2385
- * [Validation](#validation)
2386
- * [Syncing state](#syncing-state)
2387
- * [Usage](#usage)
2388
- * [Fields](#fields)
2389
- * [Rules](#rules)
2390
- * [Handling submission](#handling-submission)
2391
- * [Read only](#read-only)
2392
- * [Behaviour](#behaviour)
2393
- * [Examples](#examples)
2394
- * [Validation summary](#validation-summary)
2395
- * [Hidden validation summary](#hidden-validation-summary)
2396
- * [Custom error handling](#custom-error-handling)
2397
- * [Pre-fill the form](#pre-fill-the-form)
2398
- * [values](#values)
2399
- * [Disable validation](#disable-validation)
2400
- * [Resetting the form](#resetting-the-form)
2401
- * [Custom form field components](#custom-form-field-components)
2402
- * [Forms in expanders (lazy loading)](#forms-in-expanders-lazy-loading)
2403
- * [Conditional fields (useWatch)](#conditional-fields-usewatch)
2404
- * [IressHookForm](#iresshookform)
2405
- * [Migration to version 5](#migration-to-version-5)
2406
- * [Testing](#testing)
2407
- * [Caveat](#caveat)
2408
- * [Using IressSelect with non-string values in IressFormField](#using-iressselect-with-non-string-values-in-iressformfield)
2409
- * [Properly resetting fields](#properly-resetting-fields)
2410
- * [Conflicting versions of React Hook Forms](#conflicting-versions-of-react-hook-forms)