carbon-react 114.17.5 → 114.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/__internal__/checkable-input/checkable-input.component.js +5 -1
- package/esm/__internal__/fieldset/fieldset.component.js +27 -23
- package/esm/__internal__/form-field/form-field.component.js +2 -2
- package/esm/__internal__/form-spacing-provider/form-spacing-context.d.ts +5 -0
- package/esm/__internal__/form-spacing-provider/form-spacing-context.js +2 -0
- package/esm/__internal__/form-spacing-provider/form-spacing-provider.component.d.ts +7 -0
- package/esm/__internal__/form-spacing-provider/form-spacing-provider.component.js +18 -0
- package/esm/__internal__/form-spacing-provider/index.d.ts +3 -0
- package/esm/__internal__/form-spacing-provider/index.js +2 -0
- package/esm/components/checkbox/checkbox-group.component.js +4 -1
- package/esm/components/checkbox/checkbox.component.js +7 -5
- package/esm/components/date/date.component.js +5 -2
- package/esm/components/date-range/date-range.component.js +8 -2
- package/esm/components/fieldset/fieldset.component.js +7 -3
- package/esm/components/form/form.component.js +5 -1
- package/esm/components/form/form.config.d.ts +10 -0
- package/esm/components/form/form.config.js +11 -1
- package/esm/components/form/form.style.js +2 -35
- package/esm/components/inline-inputs/inline-inputs.component.d.ts +3 -2
- package/esm/components/inline-inputs/inline-inputs.component.js +166 -4
- package/esm/components/inline-inputs/inline-inputs.style.js +3 -0
- package/esm/components/multi-action-button/multi-action-button.component.js +2 -1
- package/esm/components/numeral-date/numeral-date.component.js +4 -1
- package/esm/components/select/filterable-select/filterable-select.component.js +4 -2
- package/esm/components/select/multi-select/multi-select.component.js +4 -2
- package/esm/components/select/select-textbox/select-textbox.component.js +4 -1
- package/esm/components/select/simple-select/simple-select.component.js +4 -2
- package/esm/components/split-button/split-button.component.js +2 -1
- package/esm/components/switch/switch.component.js +3 -2
- package/esm/components/textarea/textarea.component.js +7 -6
- package/esm/hooks/__internal__/useFormSpacing/add-form-spacing/index.d.ts +3 -0
- package/esm/hooks/__internal__/useFormSpacing/add-form-spacing/index.js +30 -0
- package/esm/hooks/__internal__/useFormSpacing/index.d.ts +3 -0
- package/esm/hooks/__internal__/useFormSpacing/index.js +11 -0
- package/lib/__internal__/checkable-input/checkable-input.component.js +5 -1
- package/lib/__internal__/fieldset/fieldset.component.js +28 -23
- package/lib/__internal__/form-field/form-field.component.js +3 -3
- package/lib/__internal__/form-spacing-provider/form-spacing-context.d.ts +5 -0
- package/lib/__internal__/form-spacing-provider/form-spacing-context.js +14 -0
- package/lib/__internal__/form-spacing-provider/form-spacing-provider.component.d.ts +7 -0
- package/lib/__internal__/form-spacing-provider/form-spacing-provider.component.js +30 -0
- package/lib/__internal__/form-spacing-provider/index.d.ts +3 -0
- package/lib/__internal__/form-spacing-provider/index.js +23 -0
- package/lib/__internal__/form-spacing-provider/package.json +6 -0
- package/lib/components/checkbox/checkbox-group.component.js +5 -1
- package/lib/components/checkbox/checkbox.component.js +8 -6
- package/lib/components/date/date.component.js +6 -2
- package/lib/components/date-range/date-range.component.js +8 -2
- package/lib/components/fieldset/fieldset.component.js +9 -4
- package/lib/components/form/form.component.js +7 -1
- package/lib/components/form/form.config.d.ts +10 -0
- package/lib/components/form/form.config.js +13 -2
- package/lib/components/form/form.style.js +2 -38
- package/lib/components/inline-inputs/inline-inputs.component.d.ts +3 -2
- package/lib/components/inline-inputs/inline-inputs.component.js +168 -4
- package/lib/components/inline-inputs/inline-inputs.style.js +4 -0
- package/lib/components/multi-action-button/multi-action-button.component.js +2 -1
- package/lib/components/numeral-date/numeral-date.component.js +5 -1
- package/lib/components/select/filterable-select/filterable-select.component.js +4 -1
- package/lib/components/select/multi-select/multi-select.component.js +4 -1
- package/lib/components/select/select-textbox/select-textbox.component.js +4 -1
- package/lib/components/select/simple-select/simple-select.component.js +4 -1
- package/lib/components/split-button/split-button.component.js +2 -1
- package/lib/components/switch/switch.component.js +4 -3
- package/lib/components/textarea/textarea.component.js +7 -6
- package/lib/hooks/__internal__/useFormSpacing/add-form-spacing/index.d.ts +3 -0
- package/lib/hooks/__internal__/useFormSpacing/add-form-spacing/index.js +39 -0
- package/lib/hooks/__internal__/useFormSpacing/add-form-spacing/package.json +6 -0
- package/lib/hooks/__internal__/useFormSpacing/index.d.ts +3 -0
- package/lib/hooks/__internal__/useFormSpacing/index.js +26 -0
- package/lib/hooks/__internal__/useFormSpacing/package.json +6 -0
- package/package.json +2 -2
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
import React, { useRef } from "react";
|
|
2
4
|
import PropTypes from "prop-types";
|
|
3
5
|
import { StyledCheckableInput, StyledCheckableInputWrapper } from "./checkable-input.style";
|
|
@@ -103,7 +105,9 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
|
103
105
|
labelWidth: labelWidth,
|
|
104
106
|
labelInline: labelInline,
|
|
105
107
|
reverse: reverse
|
|
106
|
-
}, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField,
|
|
108
|
+
}, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({}, formFieldProps, {
|
|
109
|
+
my: 0
|
|
110
|
+
}), /*#__PURE__*/React.createElement(StyledCheckableInput, null, /*#__PURE__*/React.createElement(HiddenCheckableInput, inputProps), children))));
|
|
107
111
|
});
|
|
108
112
|
CheckableInput.propTypes = {
|
|
109
113
|
"about": PropTypes.string,
|
|
@@ -5,6 +5,7 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import { StyledFieldset, StyledLegend, StyledLegendContent } from "./fieldset.style";
|
|
6
6
|
import ValidationIcon from "../validations/validation-icon.component";
|
|
7
7
|
import { InputGroupBehaviour, InputGroupContext } from "../input-behaviour";
|
|
8
|
+
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
8
9
|
|
|
9
10
|
const Fieldset = ({
|
|
10
11
|
legend,
|
|
@@ -19,29 +20,32 @@ const Fieldset = ({
|
|
|
19
20
|
isRequired,
|
|
20
21
|
blockGroupBehaviour,
|
|
21
22
|
...rest
|
|
22
|
-
}) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
}) => {
|
|
24
|
+
const marginProps = useFormSpacing(rest);
|
|
25
|
+
return /*#__PURE__*/React.createElement(InputGroupBehaviour, {
|
|
26
|
+
blockGroupBehaviour: blockGroupBehaviour
|
|
27
|
+
}, /*#__PURE__*/React.createElement(StyledFieldset, _extends({
|
|
28
|
+
"data-component": "fieldset",
|
|
29
|
+
m: 0
|
|
30
|
+
}, marginProps, rest), legend && /*#__PURE__*/React.createElement(InputGroupContext.Consumer, null, ({
|
|
31
|
+
onMouseEnter,
|
|
32
|
+
onMouseLeave
|
|
33
|
+
}) => /*#__PURE__*/React.createElement(StyledLegend, {
|
|
34
|
+
onMouseEnter: onMouseEnter,
|
|
35
|
+
onMouseLeave: onMouseLeave,
|
|
36
|
+
inline: inline,
|
|
37
|
+
width: legendWidth,
|
|
38
|
+
align: legendAlign,
|
|
39
|
+
rightPadding: legendSpacing
|
|
40
|
+
}, /*#__PURE__*/React.createElement(StyledLegendContent, {
|
|
41
|
+
isRequired: isRequired
|
|
42
|
+
}, legend, /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
43
|
+
error: error,
|
|
44
|
+
warning: warning,
|
|
45
|
+
info: info,
|
|
46
|
+
tooltipFlipOverrides: ["top", "bottom"]
|
|
47
|
+
})))), children));
|
|
48
|
+
};
|
|
45
49
|
|
|
46
50
|
Fieldset.propTypes = {
|
|
47
51
|
"blockGroupBehaviour": PropTypes.bool,
|
|
@@ -3,13 +3,13 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import React, { useContext, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import invariant from "invariant";
|
|
6
|
-
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
7
6
|
import FormFieldStyle, { FieldLineStyle } from "./form-field.style";
|
|
8
7
|
import Label from "../label";
|
|
9
8
|
import FieldHelp from "../field-help";
|
|
10
9
|
import tagComponent from "../utils/helpers/tags/tags";
|
|
11
10
|
import { TabContext } from "../../components/tabs/tab";
|
|
12
11
|
import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
|
|
12
|
+
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
13
13
|
|
|
14
14
|
const FormField = ({
|
|
15
15
|
children,
|
|
@@ -62,6 +62,7 @@ const FormField = ({
|
|
|
62
62
|
setWarning,
|
|
63
63
|
setInfo
|
|
64
64
|
} = useContext(TabContext);
|
|
65
|
+
const marginProps = useFormSpacing(rest);
|
|
65
66
|
const isMounted = useRef(false);
|
|
66
67
|
useLayoutEffect(() => {
|
|
67
68
|
isMounted.current = true;
|
|
@@ -81,7 +82,6 @@ const FormField = ({
|
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
}, [id, setError, setWarning, setInfo, error, warning, info]);
|
|
84
|
-
const marginProps = filterStyledSystemMarginProps(rest);
|
|
85
85
|
const fieldHelp = fieldHelpContent ? /*#__PURE__*/React.createElement(FieldHelp, {
|
|
86
86
|
labelInline: inlineLabel,
|
|
87
87
|
labelWidth: labelWidth,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FormSpacingContextProps } from "./form-spacing-context";
|
|
3
|
+
interface FormSpacingProviderProps extends FormSpacingContextProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const FormSpacingProvider: ({ marginBottom, children, }: FormSpacingProviderProps) => JSX.Element;
|
|
7
|
+
export default FormSpacingProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { FormSpacingContext } from "./form-spacing-context";
|
|
4
|
+
|
|
5
|
+
const FormSpacingProvider = ({
|
|
6
|
+
marginBottom,
|
|
7
|
+
children
|
|
8
|
+
}) => /*#__PURE__*/React.createElement(FormSpacingContext.Provider, {
|
|
9
|
+
value: {
|
|
10
|
+
marginBottom
|
|
11
|
+
}
|
|
12
|
+
}, children);
|
|
13
|
+
|
|
14
|
+
FormSpacingProvider.propTypes = {
|
|
15
|
+
"children": PropTypes.node,
|
|
16
|
+
"marginBottom": PropTypes.string
|
|
17
|
+
};
|
|
18
|
+
export default FormSpacingProvider;
|
|
@@ -7,6 +7,7 @@ import StyledCheckboxGroup from "./checkbox-group.style";
|
|
|
7
7
|
import Fieldset from "../../__internal__/fieldset";
|
|
8
8
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
9
9
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
10
|
+
import FormSpacingProvider from "../../__internal__/form-spacing-provider";
|
|
10
11
|
export const CheckboxGroupContext = /*#__PURE__*/React.createContext({});
|
|
11
12
|
|
|
12
13
|
const CheckboxGroup = props => {
|
|
@@ -46,7 +47,9 @@ const CheckboxGroup = props => {
|
|
|
46
47
|
warning: !!warning,
|
|
47
48
|
info: !!info
|
|
48
49
|
}
|
|
49
|
-
},
|
|
50
|
+
}, /*#__PURE__*/React.createElement(FormSpacingProvider, {
|
|
51
|
+
marginBottom: undefined
|
|
52
|
+
}, children)))));
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
CheckboxGroup.propTypes = {
|
|
@@ -6,10 +6,10 @@ import CheckboxStyle from "./checkbox.style";
|
|
|
6
6
|
import CheckableInput from "../../__internal__/checkable-input/checkable-input.component";
|
|
7
7
|
import CheckboxSvg from "./checkbox-svg.component";
|
|
8
8
|
import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
|
|
9
|
-
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
10
9
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
11
10
|
import { CheckboxGroupContext } from "./checkbox-group.component";
|
|
12
11
|
import Logger from "../../__internal__/utils/logger";
|
|
12
|
+
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
13
13
|
let deprecateInputRefWarnTriggered = false;
|
|
14
14
|
const Checkbox = /*#__PURE__*/React.forwardRef(({
|
|
15
15
|
id,
|
|
@@ -44,15 +44,16 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
|
|
|
44
44
|
"data-role": dataRole,
|
|
45
45
|
helpAriaLabel,
|
|
46
46
|
inputRef,
|
|
47
|
-
...
|
|
47
|
+
...rest
|
|
48
48
|
}, ref) => {
|
|
49
49
|
const largeScreen = useIsAboveBreakpoint(adaptiveSpacingBreakpoint);
|
|
50
50
|
const adaptiveSpacingSmallScreen = !!(adaptiveSpacingBreakpoint && !largeScreen);
|
|
51
|
+
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
51
52
|
const {
|
|
52
53
|
error: contextError,
|
|
53
54
|
warning: contextWarning,
|
|
54
55
|
info: contextInfo
|
|
55
|
-
} =
|
|
56
|
+
} = checkboxGroupContext;
|
|
56
57
|
|
|
57
58
|
if (!deprecateInputRefWarnTriggered && inputRef) {
|
|
58
59
|
deprecateInputRefWarnTriggered = true;
|
|
@@ -86,8 +87,9 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
|
|
|
86
87
|
labelWidth,
|
|
87
88
|
tooltipPosition,
|
|
88
89
|
ref: ref || inputRef,
|
|
89
|
-
...
|
|
90
|
+
...rest
|
|
90
91
|
};
|
|
92
|
+
const marginProps = useFormSpacing(rest);
|
|
91
93
|
return /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
92
94
|
helpAriaLabel: helpAriaLabel,
|
|
93
95
|
tooltipPosition: tooltipPosition
|
|
@@ -105,7 +107,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
|
|
|
105
107
|
fieldHelpInline: fieldHelpInline,
|
|
106
108
|
reverse: reverse,
|
|
107
109
|
size: size
|
|
108
|
-
},
|
|
110
|
+
}, marginProps), /*#__PURE__*/React.createElement(CheckableInput, inputProps, /*#__PURE__*/React.createElement(CheckboxSvg, null))));
|
|
109
111
|
});
|
|
110
112
|
Checkbox.propTypes = {
|
|
111
113
|
"about": PropTypes.string,
|
|
@@ -14,6 +14,7 @@ import DatePicker from "./__internal__/date-picker";
|
|
|
14
14
|
import DateRangeContext from "../date-range/date-range.context";
|
|
15
15
|
import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
|
|
16
16
|
import Logger from "../../__internal__/utils/logger";
|
|
17
|
+
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
17
18
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
18
19
|
let deprecateInputRefWarnTriggered = false;
|
|
19
20
|
const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
@@ -295,6 +296,7 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
295
296
|
return value;
|
|
296
297
|
};
|
|
297
298
|
|
|
299
|
+
const marginProps = useFormSpacing(rest);
|
|
298
300
|
return /*#__PURE__*/React.createElement(StyledDateInput, _extends({
|
|
299
301
|
ref: wrapperRef,
|
|
300
302
|
role: "presentation",
|
|
@@ -303,7 +305,7 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
303
305
|
"data-component": dataComponent || "date",
|
|
304
306
|
"data-element": dataElement,
|
|
305
307
|
"data-role": dataRole
|
|
306
|
-
},
|
|
308
|
+
}, marginProps, {
|
|
307
309
|
applyDateRangeStyling: !!inputRefMap
|
|
308
310
|
}), /*#__PURE__*/React.createElement(Textbox, _extends({}, filterOutStyledSystemSpacingProps(rest), {
|
|
309
311
|
inputRef: inputRef,
|
|
@@ -325,7 +327,8 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
325
327
|
autoFocus: autoFocus,
|
|
326
328
|
size: size,
|
|
327
329
|
disabled: disabled,
|
|
328
|
-
readOnly: readOnly
|
|
330
|
+
readOnly: readOnly,
|
|
331
|
+
m: 0
|
|
329
332
|
})), /*#__PURE__*/React.createElement(DatePicker, {
|
|
330
333
|
disablePortal: disablePortal,
|
|
331
334
|
inputElement: parentRef,
|
|
@@ -217,14 +217,20 @@ const DateRange = ({
|
|
|
217
217
|
inputRefMap,
|
|
218
218
|
setInputRefMap: updateInputMap
|
|
219
219
|
}
|
|
220
|
-
}, /*#__PURE__*/React.createElement(DateInput, _extends({
|
|
220
|
+
}, /*#__PURE__*/React.createElement(DateInput, _extends({
|
|
221
|
+
my: 0 // prevents any form spacing being applied
|
|
222
|
+
|
|
223
|
+
}, dateProps("start"), {
|
|
221
224
|
onFocus: () => handleFocus("end"),
|
|
222
225
|
"data-element": "start-date",
|
|
223
226
|
labelWidth: inlineLabelWidth // Textbox only applies this when labelsInLine prop is true
|
|
224
227
|
,
|
|
225
228
|
tooltipPosition: tooltipPosition,
|
|
226
229
|
ref: startRef
|
|
227
|
-
})), /*#__PURE__*/React.createElement(DateInput, _extends({
|
|
230
|
+
})), /*#__PURE__*/React.createElement(DateInput, _extends({
|
|
231
|
+
my: 0 // prevents any form spacing being applied
|
|
232
|
+
|
|
233
|
+
}, dateProps("end"), {
|
|
228
234
|
onFocus: () => handleFocus("start"),
|
|
229
235
|
"data-element": "end-date",
|
|
230
236
|
labelWidth: inlineLabelWidth // Textbox only applies this when labelsInLine prop is true
|
|
@@ -3,9 +3,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
6
|
-
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
7
6
|
import { FieldsetStyle, LegendContainerStyle, FieldsetContentStyle } from "./fieldset.style";
|
|
8
7
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
8
|
+
import FormSpacingProvider from "../../__internal__/form-spacing-provider";
|
|
9
|
+
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
9
10
|
|
|
10
11
|
const Fieldset = ({
|
|
11
12
|
children,
|
|
@@ -23,16 +24,19 @@ const Fieldset = ({
|
|
|
23
24
|
}, legend));
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
const marginProps = useFormSpacing(rest);
|
|
26
28
|
return /*#__PURE__*/React.createElement(NewValidationContext.Provider, {
|
|
27
29
|
value: {
|
|
28
30
|
validationRedesignOptIn: false
|
|
29
31
|
}
|
|
30
32
|
}, /*#__PURE__*/React.createElement(FieldsetStyle, _extends({}, tagComponent("fieldset", rest), rest, {
|
|
31
33
|
m: 0
|
|
32
|
-
},
|
|
34
|
+
}, marginProps), /*#__PURE__*/React.createElement(FieldsetContentStyle, {
|
|
33
35
|
"data-component": "fieldset-style",
|
|
34
36
|
inline: inline
|
|
35
|
-
}, getLegend(),
|
|
37
|
+
}, getLegend(), /*#__PURE__*/React.createElement(FormSpacingProvider, {
|
|
38
|
+
marginBottom: undefined
|
|
39
|
+
}, children))));
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
Fieldset.propTypes = {
|
|
@@ -6,6 +6,8 @@ import { SidebarContext } from "../sidebar/sidebar.component";
|
|
|
6
6
|
import { ModalContext } from "../modal/modal.component";
|
|
7
7
|
import FormSummary from "./__internal__/form-summary.component";
|
|
8
8
|
import { StyledForm, StyledFormContent, StyledFormFooter, StyledLeftButtons, StyledRightButtons, StyledFullWidthButtons } from "./form.style";
|
|
9
|
+
import { formSpacing } from "./form.config";
|
|
10
|
+
import FormSpacingProvider from "../../__internal__/form-spacing-provider";
|
|
9
11
|
|
|
10
12
|
const Form = ({
|
|
11
13
|
children,
|
|
@@ -50,7 +52,9 @@ const Form = ({
|
|
|
50
52
|
className: stickyFooter ? "sticky" : "",
|
|
51
53
|
stickyFooter: stickyFooter,
|
|
52
54
|
isInModal: isInModal
|
|
53
|
-
},
|
|
55
|
+
}, /*#__PURE__*/React.createElement(FormSpacingProvider, {
|
|
56
|
+
marginBottom: formSpacing[fieldSpacing]
|
|
57
|
+
}, children)), !fullWidthButtons && renderFooter && /*#__PURE__*/React.createElement(StyledFormFooter, _extends({
|
|
54
58
|
"data-element": "form-footer",
|
|
55
59
|
className: classNames,
|
|
56
60
|
ref: formFooterRef,
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
export declare const FORM_BUTTON_ALIGNMENTS: readonly ["left", "right"];
|
|
2
2
|
export declare type FormButtonAlignment = typeof FORM_BUTTON_ALIGNMENTS[number];
|
|
3
|
+
export declare const formSpacing: {
|
|
4
|
+
0: string;
|
|
5
|
+
1: string;
|
|
6
|
+
2: string;
|
|
7
|
+
3: string;
|
|
8
|
+
4: string;
|
|
9
|
+
5: string;
|
|
10
|
+
6: string;
|
|
11
|
+
7: string;
|
|
12
|
+
};
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export const FORM_BUTTON_ALIGNMENTS = ["left", "right"];
|
|
1
|
+
export const FORM_BUTTON_ALIGNMENTS = ["left", "right"];
|
|
2
|
+
export const formSpacing = {
|
|
3
|
+
0: "var(--spacing000)",
|
|
4
|
+
1: "var(--spacing100)",
|
|
5
|
+
2: "var(--spacing200)",
|
|
6
|
+
3: "var(--spacing300)",
|
|
7
|
+
4: "var(--spacing400)",
|
|
8
|
+
5: "var(--spacing500)",
|
|
9
|
+
6: "var(--spacing600)",
|
|
10
|
+
7: "var(--spacing700)"
|
|
11
|
+
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { space, padding } from "styled-system";
|
|
3
3
|
import StyledFormField from "../../__internal__/form-field/form-field.style";
|
|
4
|
-
import { StyledFieldset } from "../../__internal__/fieldset/fieldset.style";
|
|
5
4
|
import StyledButton from "../button/button.style";
|
|
6
5
|
import baseTheme from "../../style/themes/base";
|
|
7
|
-
import { FieldsetStyle } from "../fieldset/fieldset.style";
|
|
8
|
-
import StyledInlineInputs from "../inline-inputs/inline-inputs.style";
|
|
9
6
|
import StyledSearch from "../search/search.style";
|
|
10
7
|
import StyledTextarea from "../textarea/textarea.style";
|
|
11
8
|
export const StyledFormContent = styled.div`
|
|
@@ -61,19 +58,7 @@ export const StyledFormFooter = styled.div`
|
|
|
61
58
|
`;
|
|
62
59
|
StyledFormFooter.defaultProps = {
|
|
63
60
|
theme: baseTheme
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const formBottomMargins = fieldSpacing => ({
|
|
67
|
-
0: "var(--spacing000)",
|
|
68
|
-
1: "var(--spacing100)",
|
|
69
|
-
2: "var(--spacing200)",
|
|
70
|
-
3: "var(--spacing300)",
|
|
71
|
-
4: "var(--spacing400)",
|
|
72
|
-
5: "var(--spacing500)",
|
|
73
|
-
6: "var(--spacing600)",
|
|
74
|
-
7: "var(--spacing700)"
|
|
75
|
-
})[fieldSpacing]; // Accounts for height of the header of Modal parent, the height form footer and some additional spacing
|
|
76
|
-
|
|
61
|
+
}; // Accounts for height of the header of Modal parent, the height form footer and some additional spacing
|
|
77
62
|
|
|
78
63
|
const HEIGHT_SPACING = 216;
|
|
79
64
|
export const StyledForm = styled.form`
|
|
@@ -88,29 +73,11 @@ export const StyledForm = styled.form`
|
|
|
88
73
|
${({
|
|
89
74
|
fieldSpacing
|
|
90
75
|
}) => css`
|
|
91
|
-
&
|
|
92
|
-
${StyledTextarea},
|
|
93
|
-
${StyledFormField},
|
|
94
|
-
${StyledFieldset},
|
|
95
|
-
${FieldsetStyle},
|
|
96
|
-
> ${StyledButton} {
|
|
97
|
-
margin-top: 0;
|
|
98
|
-
margin-bottom: ${formBottomMargins(fieldSpacing)};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
76
|
${StyledTextarea}
|
|
102
77
|
${StyledFormField} {
|
|
103
78
|
margin-bottom: 4px;
|
|
104
79
|
}
|
|
105
|
-
|
|
106
|
-
${StyledInlineInputs} {
|
|
107
|
-
${StyledFormField} {
|
|
108
|
-
margin-bottom: 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
margin-bottom: ${formBottomMargins(fieldSpacing)};
|
|
112
|
-
}
|
|
113
|
-
`}
|
|
80
|
+
`}
|
|
114
81
|
|
|
115
82
|
${StyledSearch} ${StyledFormField} {
|
|
116
83
|
margin-bottom: 0px;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
2
3
|
import { StyledContentContainerProps, StyledInlineInputsProps } from "./inline-inputs.style";
|
|
3
4
|
interface InlineInputsContextProps {
|
|
4
5
|
ariaLabelledBy?: string;
|
|
5
6
|
}
|
|
6
|
-
export interface InlineInputsProps extends StyledContentContainerProps, StyledInlineInputsProps {
|
|
7
|
+
export interface InlineInputsProps extends MarginProps, StyledContentContainerProps, StyledInlineInputsProps {
|
|
7
8
|
/** Breakpoint for adaptive label (inline label change to top aligned). Enables the adaptive behaviour when set */
|
|
8
9
|
adaptiveLabelBreakpoint?: number;
|
|
9
10
|
/** Children elements */
|
|
@@ -19,7 +20,7 @@ export interface InlineInputsProps extends StyledContentContainerProps, StyledIn
|
|
|
19
20
|
}
|
|
20
21
|
export declare const InlineInputsContext: React.Context<InlineInputsContextProps>;
|
|
21
22
|
declare const InlineInputs: {
|
|
22
|
-
({ adaptiveLabelBreakpoint, label, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, required, }: InlineInputsProps): JSX.Element;
|
|
23
|
+
({ adaptiveLabelBreakpoint, label, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, required, ...rest }: InlineInputsProps): JSX.Element;
|
|
23
24
|
displayName: string;
|
|
24
25
|
};
|
|
25
26
|
export default InlineInputs;
|