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.
- package/esm/__internal__/input/input-presentation.component.d.ts +3 -1
- package/esm/__internal__/input/input-presentation.component.js +5 -2
- package/esm/__internal__/input/input-presentation.style.d.ts +1 -1
- package/esm/__internal__/input/input-presentation.style.js +10 -3
- package/esm/__internal__/input-behaviour/useInputBehaviour.js +7 -2
- package/esm/__internal__/input-icon-toggle/input-icon-toggle.style.js +0 -2
- package/esm/components/date/date.style.js +5 -0
- package/esm/components/form/__internal__/form-summary.component.d.ts +18 -13
- package/esm/components/form/__internal__/form-summary.component.js +21 -20
- package/esm/components/form/__internal__/form-summary.style.d.ts +11 -3
- package/esm/components/form/__internal__/form-summary.style.js +5 -13
- package/esm/components/form/form.component.d.ts +35 -20
- package/esm/components/form/form.component.js +329 -47
- package/esm/components/form/form.config.d.ts +2 -1
- package/esm/components/form/form.config.js +0 -1
- package/esm/components/form/form.style.d.ts +21 -6
- package/esm/components/form/form.style.js +1 -17
- package/esm/components/form/index.d.ts +2 -1
- package/esm/components/menu/__internal__/spec-helper/index.js +4 -3
- package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/esm/components/menu/menu-item/menu-item.component.js +10 -2
- package/esm/components/menu/menu.component.js +19 -9
- package/esm/components/menu/menu.context.d.ts +2 -0
- package/esm/components/menu/menu.context.js +5 -1
- package/esm/components/select/__internal__/select-text/select-text.component.js +8 -3
- package/esm/components/select/__internal__/select-text/select-text.d.ts +2 -0
- package/esm/components/select/__internal__/select-text/select-text.style.js +4 -1
- package/esm/components/select/multi-select/multi-select.style.js +8 -1
- package/esm/components/select/select-textbox/select-textbox.component.js +3 -2
- package/esm/components/show-edit-pod/show-edit-pod.style.js +1 -1
- package/esm/components/textarea/textarea.component.js +3 -1
- package/esm/components/textarea/textarea.style.d.ts +1 -1
- package/esm/components/textarea/textarea.style.js +10 -5
- package/esm/components/textbox/textbox.component.js +4 -2
- package/esm/locales/en-gb.js +1 -1
- package/lib/__internal__/input/input-presentation.component.d.ts +3 -1
- package/lib/__internal__/input/input-presentation.component.js +5 -2
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
- package/lib/__internal__/input/input-presentation.style.js +11 -3
- package/lib/__internal__/input-behaviour/useInputBehaviour.js +7 -2
- package/lib/__internal__/input-icon-toggle/input-icon-toggle.style.js +0 -2
- package/lib/components/date/date.style.js +6 -0
- package/lib/components/form/__internal__/form-summary.component.d.ts +18 -13
- package/lib/components/form/__internal__/form-summary.component.js +22 -21
- package/lib/components/form/__internal__/form-summary.style.d.ts +11 -3
- package/lib/components/form/__internal__/form-summary.style.js +5 -14
- package/lib/components/form/form.component.d.ts +35 -20
- package/lib/components/form/form.component.js +330 -49
- package/lib/components/form/form.config.d.ts +2 -1
- package/lib/components/form/form.config.js +0 -1
- package/lib/components/form/form.style.d.ts +21 -6
- package/lib/components/form/form.style.js +1 -19
- package/lib/components/form/index.d.ts +2 -1
- package/lib/components/menu/__internal__/spec-helper/index.js +5 -3
- package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/lib/components/menu/menu-item/menu-item.component.js +10 -2
- package/lib/components/menu/menu.component.js +19 -9
- package/lib/components/menu/menu.context.d.ts +2 -0
- package/lib/components/menu/menu.context.js +5 -1
- package/lib/components/select/__internal__/select-text/select-text.component.js +8 -3
- package/lib/components/select/__internal__/select-text/select-text.d.ts +2 -0
- package/lib/components/select/__internal__/select-text/select-text.style.js +7 -1
- package/lib/components/select/multi-select/multi-select.style.js +9 -1
- package/lib/components/select/select-textbox/select-textbox.component.js +3 -2
- package/lib/components/show-edit-pod/show-edit-pod.style.js +2 -2
- package/lib/components/textarea/textarea.component.js +3 -1
- package/lib/components/textarea/textarea.style.d.ts +1 -1
- package/lib/components/textarea/textarea.style.js +10 -6
- package/lib/components/textbox/textbox.component.js +4 -2
- package/lib/locales/en-gb.js +1 -1
- package/package.json +1 -1
- package/esm/components/form/__internal__/form-summary.d.ts +0 -16
- package/esm/components/form/form.d.ts +0 -35
- package/lib/components/form/__internal__/form-summary.d.ts +0 -16
- 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
|
-
|
|
62
|
-
|
|
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
|
-
|
|
79
|
-
|
|
77
|
+
errorCount: errorCount,
|
|
78
|
+
warningCount: warningCount
|
|
80
79
|
}, saveButton))));
|
|
81
80
|
};
|
|
82
81
|
|
|
83
|
-
Form.propTypes = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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:
|
|
1
|
+
export declare const FORM_BUTTON_ALIGNMENTS: readonly ["left", "right"];
|
|
2
|
+
export declare type FormButtonAlignment = typeof FORM_BUTTON_ALIGNMENTS[number];
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const
|
|
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(
|
|
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
|
-
|
|
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 =
|
|
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.
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
56
|
+
indexInMenu: index
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return child;
|
|
61
|
+
})));
|
|
52
62
|
};
|
|
53
63
|
|
|
54
64
|
Menu.propTypes = {
|