carbon-react 111.8.2 → 111.8.4

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 (75) hide show
  1. package/esm/__internal__/input/input-presentation.component.d.ts +3 -1
  2. package/esm/__internal__/input/input-presentation.component.js +5 -2
  3. package/esm/__internal__/input/input-presentation.style.d.ts +1 -1
  4. package/esm/__internal__/input/input-presentation.style.js +10 -3
  5. package/esm/__internal__/input-behaviour/useInputBehaviour.js +7 -2
  6. package/esm/__internal__/input-icon-toggle/input-icon-toggle.style.js +0 -2
  7. package/esm/components/date/date.style.js +5 -0
  8. package/esm/components/form/__internal__/form-summary.component.d.ts +18 -13
  9. package/esm/components/form/__internal__/form-summary.component.js +21 -20
  10. package/esm/components/form/__internal__/form-summary.style.d.ts +11 -3
  11. package/esm/components/form/__internal__/form-summary.style.js +5 -13
  12. package/esm/components/form/form.component.d.ts +35 -20
  13. package/esm/components/form/form.component.js +329 -47
  14. package/esm/components/form/form.config.d.ts +2 -1
  15. package/esm/components/form/form.config.js +0 -1
  16. package/esm/components/form/form.style.d.ts +21 -6
  17. package/esm/components/form/form.style.js +1 -17
  18. package/esm/components/form/index.d.ts +2 -1
  19. package/esm/components/menu/__internal__/spec-helper/index.js +4 -3
  20. package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
  21. package/esm/components/menu/menu-item/menu-item.component.js +10 -2
  22. package/esm/components/menu/menu.component.js +19 -9
  23. package/esm/components/menu/menu.context.d.ts +2 -0
  24. package/esm/components/menu/menu.context.js +5 -1
  25. package/esm/components/select/__internal__/select-text/select-text.component.js +8 -3
  26. package/esm/components/select/__internal__/select-text/select-text.d.ts +2 -0
  27. package/esm/components/select/__internal__/select-text/select-text.style.js +4 -1
  28. package/esm/components/select/multi-select/multi-select.style.js +8 -1
  29. package/esm/components/select/select-textbox/select-textbox.component.js +3 -2
  30. package/esm/components/show-edit-pod/show-edit-pod.style.js +1 -1
  31. package/esm/components/textarea/textarea.component.js +3 -1
  32. package/esm/components/textarea/textarea.style.d.ts +1 -1
  33. package/esm/components/textarea/textarea.style.js +10 -5
  34. package/esm/components/textbox/textbox.component.js +4 -2
  35. package/esm/locales/en-gb.js +1 -1
  36. package/lib/__internal__/input/input-presentation.component.d.ts +3 -1
  37. package/lib/__internal__/input/input-presentation.component.js +5 -2
  38. package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
  39. package/lib/__internal__/input/input-presentation.style.js +11 -3
  40. package/lib/__internal__/input-behaviour/useInputBehaviour.js +7 -2
  41. package/lib/__internal__/input-icon-toggle/input-icon-toggle.style.js +0 -2
  42. package/lib/components/date/date.style.js +6 -0
  43. package/lib/components/form/__internal__/form-summary.component.d.ts +18 -13
  44. package/lib/components/form/__internal__/form-summary.component.js +22 -21
  45. package/lib/components/form/__internal__/form-summary.style.d.ts +11 -3
  46. package/lib/components/form/__internal__/form-summary.style.js +5 -14
  47. package/lib/components/form/form.component.d.ts +35 -20
  48. package/lib/components/form/form.component.js +330 -49
  49. package/lib/components/form/form.config.d.ts +2 -1
  50. package/lib/components/form/form.config.js +0 -1
  51. package/lib/components/form/form.style.d.ts +21 -6
  52. package/lib/components/form/form.style.js +1 -19
  53. package/lib/components/form/index.d.ts +2 -1
  54. package/lib/components/menu/__internal__/spec-helper/index.js +5 -3
  55. package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
  56. package/lib/components/menu/menu-item/menu-item.component.js +10 -2
  57. package/lib/components/menu/menu.component.js +19 -9
  58. package/lib/components/menu/menu.context.d.ts +2 -0
  59. package/lib/components/menu/menu.context.js +5 -1
  60. package/lib/components/select/__internal__/select-text/select-text.component.js +8 -3
  61. package/lib/components/select/__internal__/select-text/select-text.d.ts +2 -0
  62. package/lib/components/select/__internal__/select-text/select-text.style.js +7 -1
  63. package/lib/components/select/multi-select/multi-select.style.js +9 -1
  64. package/lib/components/select/select-textbox/select-textbox.component.js +3 -2
  65. package/lib/components/show-edit-pod/show-edit-pod.style.js +2 -2
  66. package/lib/components/textarea/textarea.component.js +3 -1
  67. package/lib/components/textarea/textarea.style.d.ts +1 -1
  68. package/lib/components/textarea/textarea.style.js +10 -6
  69. package/lib/components/textbox/textbox.component.js +4 -2
  70. package/lib/locales/en-gb.js +1 -1
  71. package/package.json +1 -1
  72. package/esm/components/form/__internal__/form-summary.d.ts +0 -16
  73. package/esm/components/form/form.d.ts +0 -35
  74. package/lib/components/form/__internal__/form-summary.d.ts +0 -16
  75. package/lib/components/form/form.d.ts +0 -35
@@ -2,7 +2,6 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useRef, useContext } from "react";
4
4
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
6
5
  import { SidebarContext } from "../sidebar/sidebar.component";
7
6
  import { ModalContext } from "../modal/modal.component";
8
7
  import FormSummary from "./__internal__/form-summary.component";
@@ -30,8 +29,8 @@ const Form = ({
30
29
  const {
31
30
  isInModal
32
31
  } = useContext(ModalContext);
33
- const formRef = useRef();
34
- const formFooterRef = useRef();
32
+ const formRef = useRef(null);
33
+ const formFooterRef = useRef(null);
35
34
  const renderFooter = !!(saveButton || leftSideButtons || rightSideButtons || errorCount || warningCount);
36
35
  return /*#__PURE__*/React.createElement(StyledForm, _extends({
37
36
  ref: formRef,
@@ -58,8 +57,8 @@ const Form = ({
58
57
  }, leftSideButtons && /*#__PURE__*/React.createElement(StyledLeftButtons, {
59
58
  buttonAlignment: buttonAlignment
60
59
  }, leftSideButtons), /*#__PURE__*/React.createElement(FormSummary, {
61
- errors: errorCount,
62
- warnings: warningCount
60
+ errorCount: errorCount,
61
+ warningCount: warningCount
63
62
  }, saveButton), rightSideButtons && /*#__PURE__*/React.createElement(StyledRightButtons, {
64
63
  buttonAlignment: buttonAlignment
65
64
  }, rightSideButtons)), fullWidthButtons && renderFooter && /*#__PURE__*/React.createElement(StyledFormFooter, {
@@ -75,51 +74,334 @@ const Form = ({
75
74
  fullWidthButtons: fullWidthButtons
76
75
  }, rightSideButtons), /*#__PURE__*/React.createElement(StyledFullWidthButtons, null, /*#__PURE__*/React.createElement(FormSummary, {
77
76
  fullWidth: fullWidthButtons,
78
- errors: errorCount,
79
- warnings: warningCount
77
+ errorCount: errorCount,
78
+ warningCount: warningCount
80
79
  }, saveButton))));
81
80
  };
82
81
 
83
- Form.propTypes = { ...styledSystemPropTypes.space,
84
-
85
- /** Alignment of buttons */
86
- buttonAlignment: PropTypes.oneOf(["left", "right"]),
87
-
88
- /** Enables the sticky footer. */
89
- stickyFooter: PropTypes.bool,
90
-
91
- /** Additional buttons rendered on the left side of the save button */
92
- leftSideButtons: PropTypes.node,
93
-
94
- /** Additional buttons rendered on the right side of the save button */
95
- rightSideButtons: PropTypes.node,
96
-
97
- /** Callback passed to the form element */
98
- onSubmit: PropTypes.func,
99
-
100
- /** Child elements */
101
- children: PropTypes.node,
102
-
103
- /** Save button to be rendered */
104
- saveButton: PropTypes.node,
105
-
106
- /** The total number of errors present in the form */
107
- errorCount: PropTypes.number,
108
-
109
- /** The total number of warnings present in the form */
110
- warningCount: PropTypes.number,
111
-
112
- /** Spacing between form fields, given number will be multiplied by base spacing unit (8) */
113
- fieldSpacing: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 7]),
114
-
115
- /** Disable HTML5 validation */
116
- noValidate: PropTypes.bool,
117
-
118
- /** Height of the form (any valid CSS value) */
119
- height: PropTypes.string,
120
-
121
- /** Applies styling for full width buttons. Please note that you will still need to pass the `fullWidth` prop to the button you compose */
122
- fullWidthButtons: PropTypes.bool
82
+ Form.propTypes = {
83
+ "buttonAlignment": PropTypes.oneOf(["left", "right"]),
84
+ "children": PropTypes.node,
85
+ "errorCount": PropTypes.number,
86
+ "fieldSpacing": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7]),
87
+ "fullWidthButtons": PropTypes.bool,
88
+ "height": PropTypes.string,
89
+ "leftSideButtons": PropTypes.node,
90
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
91
+ "__@toStringTag": PropTypes.string.isRequired,
92
+ "description": PropTypes.string,
93
+ "toString": PropTypes.func.isRequired,
94
+ "valueOf": PropTypes.func.isRequired
95
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
96
+ "__@toStringTag": PropTypes.string.isRequired,
97
+ "description": PropTypes.string,
98
+ "toString": PropTypes.func.isRequired,
99
+ "valueOf": PropTypes.func.isRequired
100
+ }), PropTypes.string]),
101
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
102
+ "__@toStringTag": PropTypes.string.isRequired,
103
+ "description": PropTypes.string,
104
+ "toString": PropTypes.func.isRequired,
105
+ "valueOf": PropTypes.func.isRequired
106
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
107
+ "__@toStringTag": PropTypes.string.isRequired,
108
+ "description": PropTypes.string,
109
+ "toString": PropTypes.func.isRequired,
110
+ "valueOf": PropTypes.func.isRequired
111
+ }), PropTypes.string]),
112
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
113
+ "__@toStringTag": PropTypes.string.isRequired,
114
+ "description": PropTypes.string,
115
+ "toString": PropTypes.func.isRequired,
116
+ "valueOf": PropTypes.func.isRequired
117
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
118
+ "__@toStringTag": PropTypes.string.isRequired,
119
+ "description": PropTypes.string,
120
+ "toString": PropTypes.func.isRequired,
121
+ "valueOf": PropTypes.func.isRequired
122
+ }), PropTypes.string]),
123
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
124
+ "__@toStringTag": PropTypes.string.isRequired,
125
+ "description": PropTypes.string,
126
+ "toString": PropTypes.func.isRequired,
127
+ "valueOf": PropTypes.func.isRequired
128
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
129
+ "__@toStringTag": PropTypes.string.isRequired,
130
+ "description": PropTypes.string,
131
+ "toString": PropTypes.func.isRequired,
132
+ "valueOf": PropTypes.func.isRequired
133
+ }), PropTypes.string]),
134
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
135
+ "__@toStringTag": PropTypes.string.isRequired,
136
+ "description": PropTypes.string,
137
+ "toString": PropTypes.func.isRequired,
138
+ "valueOf": PropTypes.func.isRequired
139
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
140
+ "__@toStringTag": PropTypes.string.isRequired,
141
+ "description": PropTypes.string,
142
+ "toString": PropTypes.func.isRequired,
143
+ "valueOf": PropTypes.func.isRequired
144
+ }), PropTypes.string]),
145
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
146
+ "__@toStringTag": PropTypes.string.isRequired,
147
+ "description": PropTypes.string,
148
+ "toString": PropTypes.func.isRequired,
149
+ "valueOf": PropTypes.func.isRequired
150
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
151
+ "__@toStringTag": PropTypes.string.isRequired,
152
+ "description": PropTypes.string,
153
+ "toString": PropTypes.func.isRequired,
154
+ "valueOf": PropTypes.func.isRequired
155
+ }), PropTypes.string]),
156
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
157
+ "__@toStringTag": PropTypes.string.isRequired,
158
+ "description": PropTypes.string,
159
+ "toString": PropTypes.func.isRequired,
160
+ "valueOf": PropTypes.func.isRequired
161
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
162
+ "__@toStringTag": PropTypes.string.isRequired,
163
+ "description": PropTypes.string,
164
+ "toString": PropTypes.func.isRequired,
165
+ "valueOf": PropTypes.func.isRequired
166
+ }), PropTypes.string]),
167
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
168
+ "__@toStringTag": PropTypes.string.isRequired,
169
+ "description": PropTypes.string,
170
+ "toString": PropTypes.func.isRequired,
171
+ "valueOf": PropTypes.func.isRequired
172
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
173
+ "__@toStringTag": PropTypes.string.isRequired,
174
+ "description": PropTypes.string,
175
+ "toString": PropTypes.func.isRequired,
176
+ "valueOf": PropTypes.func.isRequired
177
+ }), PropTypes.string]),
178
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
179
+ "__@toStringTag": PropTypes.string.isRequired,
180
+ "description": PropTypes.string,
181
+ "toString": PropTypes.func.isRequired,
182
+ "valueOf": PropTypes.func.isRequired
183
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
184
+ "__@toStringTag": PropTypes.string.isRequired,
185
+ "description": PropTypes.string,
186
+ "toString": PropTypes.func.isRequired,
187
+ "valueOf": PropTypes.func.isRequired
188
+ }), PropTypes.string]),
189
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
190
+ "__@toStringTag": PropTypes.string.isRequired,
191
+ "description": PropTypes.string,
192
+ "toString": PropTypes.func.isRequired,
193
+ "valueOf": PropTypes.func.isRequired
194
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
195
+ "__@toStringTag": PropTypes.string.isRequired,
196
+ "description": PropTypes.string,
197
+ "toString": PropTypes.func.isRequired,
198
+ "valueOf": PropTypes.func.isRequired
199
+ }), PropTypes.string]),
200
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
201
+ "__@toStringTag": PropTypes.string.isRequired,
202
+ "description": PropTypes.string,
203
+ "toString": PropTypes.func.isRequired,
204
+ "valueOf": PropTypes.func.isRequired
205
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
206
+ "__@toStringTag": PropTypes.string.isRequired,
207
+ "description": PropTypes.string,
208
+ "toString": PropTypes.func.isRequired,
209
+ "valueOf": PropTypes.func.isRequired
210
+ }), PropTypes.string]),
211
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
212
+ "__@toStringTag": PropTypes.string.isRequired,
213
+ "description": PropTypes.string,
214
+ "toString": PropTypes.func.isRequired,
215
+ "valueOf": PropTypes.func.isRequired
216
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
217
+ "__@toStringTag": PropTypes.string.isRequired,
218
+ "description": PropTypes.string,
219
+ "toString": PropTypes.func.isRequired,
220
+ "valueOf": PropTypes.func.isRequired
221
+ }), PropTypes.string]),
222
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
223
+ "__@toStringTag": PropTypes.string.isRequired,
224
+ "description": PropTypes.string,
225
+ "toString": PropTypes.func.isRequired,
226
+ "valueOf": PropTypes.func.isRequired
227
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
228
+ "__@toStringTag": PropTypes.string.isRequired,
229
+ "description": PropTypes.string,
230
+ "toString": PropTypes.func.isRequired,
231
+ "valueOf": PropTypes.func.isRequired
232
+ }), PropTypes.string]),
233
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
234
+ "__@toStringTag": PropTypes.string.isRequired,
235
+ "description": PropTypes.string,
236
+ "toString": PropTypes.func.isRequired,
237
+ "valueOf": PropTypes.func.isRequired
238
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
239
+ "__@toStringTag": PropTypes.string.isRequired,
240
+ "description": PropTypes.string,
241
+ "toString": PropTypes.func.isRequired,
242
+ "valueOf": PropTypes.func.isRequired
243
+ }), PropTypes.string]),
244
+ "noValidate": PropTypes.bool,
245
+ "onSubmit": PropTypes.func,
246
+ "p": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
247
+ "__@toStringTag": PropTypes.string.isRequired,
248
+ "description": PropTypes.string,
249
+ "toString": PropTypes.func.isRequired,
250
+ "valueOf": PropTypes.func.isRequired
251
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
252
+ "__@toStringTag": PropTypes.string.isRequired,
253
+ "description": PropTypes.string,
254
+ "toString": PropTypes.func.isRequired,
255
+ "valueOf": PropTypes.func.isRequired
256
+ }), PropTypes.string]),
257
+ "padding": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
258
+ "__@toStringTag": PropTypes.string.isRequired,
259
+ "description": PropTypes.string,
260
+ "toString": PropTypes.func.isRequired,
261
+ "valueOf": PropTypes.func.isRequired
262
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
263
+ "__@toStringTag": PropTypes.string.isRequired,
264
+ "description": PropTypes.string,
265
+ "toString": PropTypes.func.isRequired,
266
+ "valueOf": PropTypes.func.isRequired
267
+ }), PropTypes.string]),
268
+ "paddingBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
269
+ "__@toStringTag": PropTypes.string.isRequired,
270
+ "description": PropTypes.string,
271
+ "toString": PropTypes.func.isRequired,
272
+ "valueOf": PropTypes.func.isRequired
273
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
274
+ "__@toStringTag": PropTypes.string.isRequired,
275
+ "description": PropTypes.string,
276
+ "toString": PropTypes.func.isRequired,
277
+ "valueOf": PropTypes.func.isRequired
278
+ }), PropTypes.string]),
279
+ "paddingLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
280
+ "__@toStringTag": PropTypes.string.isRequired,
281
+ "description": PropTypes.string,
282
+ "toString": PropTypes.func.isRequired,
283
+ "valueOf": PropTypes.func.isRequired
284
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
285
+ "__@toStringTag": PropTypes.string.isRequired,
286
+ "description": PropTypes.string,
287
+ "toString": PropTypes.func.isRequired,
288
+ "valueOf": PropTypes.func.isRequired
289
+ }), PropTypes.string]),
290
+ "paddingRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
291
+ "__@toStringTag": PropTypes.string.isRequired,
292
+ "description": PropTypes.string,
293
+ "toString": PropTypes.func.isRequired,
294
+ "valueOf": PropTypes.func.isRequired
295
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
296
+ "__@toStringTag": PropTypes.string.isRequired,
297
+ "description": PropTypes.string,
298
+ "toString": PropTypes.func.isRequired,
299
+ "valueOf": PropTypes.func.isRequired
300
+ }), PropTypes.string]),
301
+ "paddingTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
302
+ "__@toStringTag": PropTypes.string.isRequired,
303
+ "description": PropTypes.string,
304
+ "toString": PropTypes.func.isRequired,
305
+ "valueOf": PropTypes.func.isRequired
306
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
307
+ "__@toStringTag": PropTypes.string.isRequired,
308
+ "description": PropTypes.string,
309
+ "toString": PropTypes.func.isRequired,
310
+ "valueOf": PropTypes.func.isRequired
311
+ }), PropTypes.string]),
312
+ "paddingX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
313
+ "__@toStringTag": PropTypes.string.isRequired,
314
+ "description": PropTypes.string,
315
+ "toString": PropTypes.func.isRequired,
316
+ "valueOf": PropTypes.func.isRequired
317
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
318
+ "__@toStringTag": PropTypes.string.isRequired,
319
+ "description": PropTypes.string,
320
+ "toString": PropTypes.func.isRequired,
321
+ "valueOf": PropTypes.func.isRequired
322
+ }), PropTypes.string]),
323
+ "paddingY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
324
+ "__@toStringTag": PropTypes.string.isRequired,
325
+ "description": PropTypes.string,
326
+ "toString": PropTypes.func.isRequired,
327
+ "valueOf": PropTypes.func.isRequired
328
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
329
+ "__@toStringTag": PropTypes.string.isRequired,
330
+ "description": PropTypes.string,
331
+ "toString": PropTypes.func.isRequired,
332
+ "valueOf": PropTypes.func.isRequired
333
+ }), PropTypes.string]),
334
+ "pb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
335
+ "__@toStringTag": PropTypes.string.isRequired,
336
+ "description": PropTypes.string,
337
+ "toString": PropTypes.func.isRequired,
338
+ "valueOf": PropTypes.func.isRequired
339
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
340
+ "__@toStringTag": PropTypes.string.isRequired,
341
+ "description": PropTypes.string,
342
+ "toString": PropTypes.func.isRequired,
343
+ "valueOf": PropTypes.func.isRequired
344
+ }), PropTypes.string]),
345
+ "pl": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
346
+ "__@toStringTag": PropTypes.string.isRequired,
347
+ "description": PropTypes.string,
348
+ "toString": PropTypes.func.isRequired,
349
+ "valueOf": PropTypes.func.isRequired
350
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
351
+ "__@toStringTag": PropTypes.string.isRequired,
352
+ "description": PropTypes.string,
353
+ "toString": PropTypes.func.isRequired,
354
+ "valueOf": PropTypes.func.isRequired
355
+ }), PropTypes.string]),
356
+ "pr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
357
+ "__@toStringTag": PropTypes.string.isRequired,
358
+ "description": PropTypes.string,
359
+ "toString": PropTypes.func.isRequired,
360
+ "valueOf": PropTypes.func.isRequired
361
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
362
+ "__@toStringTag": PropTypes.string.isRequired,
363
+ "description": PropTypes.string,
364
+ "toString": PropTypes.func.isRequired,
365
+ "valueOf": PropTypes.func.isRequired
366
+ }), PropTypes.string]),
367
+ "pt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
368
+ "__@toStringTag": PropTypes.string.isRequired,
369
+ "description": PropTypes.string,
370
+ "toString": PropTypes.func.isRequired,
371
+ "valueOf": PropTypes.func.isRequired
372
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
373
+ "__@toStringTag": PropTypes.string.isRequired,
374
+ "description": PropTypes.string,
375
+ "toString": PropTypes.func.isRequired,
376
+ "valueOf": PropTypes.func.isRequired
377
+ }), PropTypes.string]),
378
+ "px": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
379
+ "__@toStringTag": PropTypes.string.isRequired,
380
+ "description": PropTypes.string,
381
+ "toString": PropTypes.func.isRequired,
382
+ "valueOf": PropTypes.func.isRequired
383
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
384
+ "__@toStringTag": PropTypes.string.isRequired,
385
+ "description": PropTypes.string,
386
+ "toString": PropTypes.func.isRequired,
387
+ "valueOf": PropTypes.func.isRequired
388
+ }), PropTypes.string]),
389
+ "py": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
390
+ "__@toStringTag": PropTypes.string.isRequired,
391
+ "description": PropTypes.string,
392
+ "toString": PropTypes.func.isRequired,
393
+ "valueOf": PropTypes.func.isRequired
394
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
395
+ "__@toStringTag": PropTypes.string.isRequired,
396
+ "description": PropTypes.string,
397
+ "toString": PropTypes.func.isRequired,
398
+ "valueOf": PropTypes.func.isRequired
399
+ }), PropTypes.string]),
400
+ "rightSideButtons": PropTypes.node,
401
+ "saveButton": PropTypes.node,
402
+ "stickyFooter": PropTypes.bool,
403
+ "warningCount": PropTypes.number
123
404
  };
405
+ export { Form };
124
406
  Form.displayName = "Form";
125
407
  export default Form;
@@ -1 +1,2 @@
1
- export const FORM_BUTTON_ALIGNMENTS: string[];
1
+ export declare const FORM_BUTTON_ALIGNMENTS: readonly ["left", "right"];
2
+ export declare type FormButtonAlignment = typeof FORM_BUTTON_ALIGNMENTS[number];
@@ -1,2 +1 @@
1
- // eslint-disable-next-line import/prefer-default-export
2
1
  export const FORM_BUTTON_ALIGNMENTS = ["left", "right"];
@@ -1,6 +1,21 @@
1
- export const StyledFormContent: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledFormFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export const StyledForm: import("styled-components").StyledComponent<"form", any, {}, never>;
4
- export const StyledRightButtons: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export const StyledFullWidthButtons: import("styled-components").StyledComponent<"div", any, {}, never>;
6
- export const StyledLeftButtons: import("styled-components").StyledComponent<"div", any, {}, never>;
1
+ import { FormButtonAlignment } from "./form.config";
2
+ interface StyledFormContentProps {
3
+ stickyFooter?: boolean;
4
+ isInModal?: boolean;
5
+ }
6
+ export declare const StyledFormContent: import("styled-components").StyledComponent<"div", any, StyledFormContentProps, never>;
7
+ interface ButtonProps extends StyledFormContentProps {
8
+ buttonAlignment?: FormButtonAlignment;
9
+ fullWidthButtons?: boolean;
10
+ }
11
+ export declare const StyledFormFooter: import("styled-components").StyledComponent<"div", any, ButtonProps, never>;
12
+ interface StyledFormProps extends StyledFormContentProps {
13
+ height?: string;
14
+ fieldSpacing: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
15
+ isInSidebar?: boolean;
16
+ }
17
+ export declare const StyledForm: import("styled-components").StyledComponent<"form", any, StyledFormProps, never>;
18
+ export declare const StyledRightButtons: import("styled-components").StyledComponent<"div", any, ButtonProps, never>;
19
+ export declare const StyledFullWidthButtons: import("styled-components").StyledComponent<"div", any, {}, never>;
20
+ export declare const StyledLeftButtons: import("styled-components").StyledComponent<"div", any, ButtonProps, never>;
21
+ export {};
@@ -1,5 +1,4 @@
1
1
  import styled, { css } from "styled-components";
2
- import PropTypes from "prop-types";
3
2
  import { space } from "styled-system";
4
3
  import StyledFormField from "../../__internal__/form-field/form-field.style";
5
4
  import { StyledFieldset } from "../../__internal__/fieldset/fieldset.style";
@@ -7,7 +6,6 @@ import StyledButton from "../button/button.style";
7
6
  import baseTheme from "../../style/themes/base";
8
7
  import { FieldsetStyle } from "../fieldset/fieldset.style";
9
8
  import StyledInlineInputs from "../inline-inputs/inline-inputs.style";
10
- import { FORM_BUTTON_ALIGNMENTS } from "./form.config";
11
9
  import StyledSearch from "../search/search.style";
12
10
  import StyledTextarea from "../textarea/textarea.style";
13
11
  export const StyledFormContent = styled.div`
@@ -67,6 +65,7 @@ const formBottomMargins = fieldSpacing => ({
67
65
  3: "var(--spacing300)",
68
66
  4: "var(--spacing400)",
69
67
  5: "var(--spacing500)",
68
+ 6: "var(--spacing600)",
70
69
  7: "var(--spacing700)"
71
70
  })[fieldSpacing]; // Accounts for height of the header of Modal parent, the height form footer and some additional spacing
72
71
 
@@ -178,21 +177,6 @@ export const StyledLeftButtons = styled.div`
178
177
  margin-right: 0;
179
178
  }
180
179
  `;
181
- StyledForm.propTypes = {
182
- theme: PropTypes.object,
183
- stickyFooter: PropTypes.bool,
184
- fieldSpacing: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 7])
185
- };
186
180
  StyledForm.defaultProps = {
187
181
  theme: baseTheme
188
- };
189
- StyledLeftButtons.propTypes = {
190
- buttonAlignment: PropTypes.oneOf(FORM_BUTTON_ALIGNMENTS)
191
- };
192
- StyledRightButtons.propTypes = {
193
- buttonAlignment: PropTypes.oneOf(FORM_BUTTON_ALIGNMENTS)
194
- };
195
- StyledFormFooter.propTypes = {
196
- buttonAlignment: PropTypes.oneOf(FORM_BUTTON_ALIGNMENTS),
197
- stickyFooter: PropTypes.bool
198
182
  };
@@ -1 +1,2 @@
1
- export { default } from "./form";
1
+ export { default } from "./form.component";
2
+ export type { FormProps } from "./form.component";
@@ -1,5 +1,6 @@
1
1
  import { act } from "react-dom/test-utils";
2
2
  import StyledMenuItemWrapper from "../../menu-item/menu-item.style";
3
+ import { StyledSubmenuWrapper } from "../submenu/submenu.style";
3
4
  const events = {
4
5
  space: {
5
6
  key: " ",
@@ -7,12 +8,12 @@ const events = {
7
8
  }
8
9
  };
9
10
 
10
- const openSubmenu = wrapper => {
11
- const menuWrapper = wrapper.find('[data-component="submenu-wrapper"]');
11
+ const openSubmenu = (wrapper, index = 0) => {
12
+ const menuWrapper = wrapper.find(StyledSubmenuWrapper).at(index);
12
13
  const menuItem = menuWrapper.exists("a") ? menuWrapper.find("a") : menuWrapper.find("button");
13
14
  menuItem.getDOMNode().focus();
14
15
  act(() => {
15
- wrapper.find(StyledMenuItemWrapper).at(0).props().onKeyDown(events.space);
16
+ menuWrapper.find(StyledMenuItemWrapper).props().onKeyDown(events.space);
16
17
  });
17
18
  wrapper.update();
18
19
  };
@@ -29,12 +29,15 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
29
29
  onSubmenuOpen,
30
30
  onSubmenuClose,
31
31
  onClick,
32
+ indexInMenu,
32
33
  ...rest
33
34
  }, ref) => {
34
35
  const [blockDoubleFocus, setBlockDoubleFocus] = useState(false);
35
36
  const menuContext = useContext(MenuContext);
36
37
  const {
37
- inFullscreenView
38
+ inFullscreenView,
39
+ openSubmenuIndex,
40
+ setOpenSubmenuIndex
38
41
  } = menuContext;
39
42
  const [submenuOpen, setSubmenuOpen] = useState(false);
40
43
  const [submenuFocusIndex, setSubmenuFocusIndex] = useState(undefined);
@@ -78,15 +81,26 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
78
81
  }, [startCharacterTimeout]);
79
82
  const openSubmenu = useCallback(() => {
80
83
  setSubmenuOpen(true);
84
+ setOpenSubmenuIndex(indexInMenu);
81
85
  if (onSubmenuOpen) onSubmenuOpen();
82
- }, [onSubmenuOpen]);
86
+ }, [onSubmenuOpen, indexInMenu, setOpenSubmenuIndex]);
83
87
  const closeSubmenu = useCallback(() => {
84
88
  setSubmenuOpen(false);
89
+
90
+ if (openSubmenuIndex === indexInMenu) {
91
+ setOpenSubmenuIndex(null);
92
+ }
93
+
85
94
  if (onSubmenuClose) onSubmenuClose();
86
95
  setSubmenuFocusIndex(undefined);
87
96
  setBlockDoubleFocus(false);
88
97
  setCharacterString("");
89
- }, [onSubmenuClose]);
98
+ }, [onSubmenuClose, setOpenSubmenuIndex, indexInMenu, openSubmenuIndex]);
99
+ useEffect(() => {
100
+ if (openSubmenuIndex !== indexInMenu) {
101
+ closeSubmenu();
102
+ }
103
+ }, [openSubmenuIndex, indexInMenu, closeSubmenu]);
90
104
  const handleKeyDown = useCallback((event, index = submenuFocusIndex) => {
91
105
  if (!submenuOpen) {
92
106
  if (Events.isEnterKey(event) || Events.isSpaceKey(event) || Events.isDownKey(event) || Events.isUpKey(event)) {
@@ -350,6 +364,9 @@ Submenu.propTypes = {
350
364
  onSubmenuClose: PropTypes.func,
351
365
 
352
366
  /** Callback triggered when the top-level menu item is clicked */
353
- onClick: PropTypes.func
367
+ onClick: PropTypes.func,
368
+
369
+ /** index of child in the parent menu */
370
+ indexInMenu: PropTypes.number
354
371
  };
355
372
  export default Submenu;
@@ -33,12 +33,13 @@ const MenuItem = ({
33
33
  onSubmenuClose,
34
34
  overrideColor,
35
35
  rel,
36
+ isFocused,
36
37
  ...rest
37
38
  }) => {
38
39
  const menuContext = useContext(MenuContext);
39
40
  const submenuContext = useContext(SubmenuContext);
40
41
  const ref = useRef(null);
41
- const focusFromMenu = menuContext.isFocused;
42
+ const focusFromMenu = isFocused;
42
43
  const focusFromSubmenu = submenuContext.isFocused;
43
44
  const isChildSearch = useRef(false);
44
45
  const childRef = useRef();
@@ -238,6 +239,13 @@ MenuItem.propTypes = {
238
239
  onSubmenuClose: PropTypes.func,
239
240
 
240
241
  /** @ignore @private */
241
- overrideColor: PropTypes.bool
242
+ overrideColor: PropTypes.bool,
243
+
244
+ /** @ignore @private */
245
+ isFocused: PropTypes.bool,
246
+
247
+ /** @ignore @private */
248
+ indexInMenu: PropTypes.number
242
249
  };
250
+ MenuItem.displayName = "MenuItem";
243
251
  export default MenuItem;
@@ -14,6 +14,7 @@ const Menu = ({
14
14
  ...rest
15
15
  }) => {
16
16
  const [focusedItemIndex, setFocusedItemIndex] = useState(undefined);
17
+ const [openSubmenuIndex, setOpenSubmenuIndex] = useState(null);
17
18
  const ref = useRef();
18
19
  const handleKeyDown = useCallback(event => {
19
20
  const newIndex = menuKeyboardNavigation(event, React.Children.toArray(children));
@@ -38,17 +39,26 @@ const Menu = ({
38
39
  }, rest, {
39
40
  ref: ref,
40
41
  role: "list"
41
- }), React.Children.map(children, (child, index) => {
42
+ }), /*#__PURE__*/React.createElement(MenuContext.Provider, {
43
+ value: {
44
+ menuType,
45
+ handleKeyDown,
46
+ inMenu: true,
47
+ openSubmenuIndex,
48
+ setOpenSubmenuIndex
49
+ }
50
+ }, React.Children.map(children, (child, index) => {
42
51
  const isFocused = focusedItemIndex === index;
43
- return /*#__PURE__*/React.createElement(MenuContext.Provider, {
44
- value: {
45
- menuType,
46
- handleKeyDown: ev => handleKeyDown(ev, index),
52
+
53
+ if ( /*#__PURE__*/React.isValidElement(child) && child.type.displayName === "MenuItem" && child.props.submenu) {
54
+ return /*#__PURE__*/React.cloneElement(child, {
47
55
  isFocused,
48
- inMenu: true
49
- }
50
- }, child);
51
- }));
56
+ indexInMenu: index
57
+ });
58
+ }
59
+
60
+ return child;
61
+ })));
52
62
  };
53
63
 
54
64
  Menu.propTypes = {
@@ -1,6 +1,8 @@
1
1
  declare var _default: React.Context<{
2
2
  menuType: string;
3
3
  inMenu: boolean;
4
+ openSubmenuIndex: null;
5
+ setOpenSubmenuIndex: () => void;
4
6
  }>;
5
7
  export default _default;
6
8
  import React from "react";