carbon-react 110.3.0 → 110.4.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__/radio-button-mapper/index.d.ts +2 -0
- package/esm/__internal__/radio-button-mapper/index.js +1 -0
- package/esm/__internal__/radio-button-mapper/radio-button-mapper.d.ts +21 -0
- package/esm/__internal__/utils/helpers/tags/index.d.ts +1 -0
- package/esm/components/button-toggle/button-toggle.component.d.ts +3 -3
- package/esm/components/button-toggle/button-toggle.component.js +21 -20
- package/esm/components/button-toggle/button-toggle.style.d.ts +1 -1
- package/esm/components/button-toggle-group/button-toggle-group.component.d.ts +45 -0
- package/esm/components/button-toggle-group/button-toggle-group.component.js +187 -92
- package/esm/components/button-toggle-group/button-toggle-group.style.d.ts +4 -0
- package/esm/components/button-toggle-group/button-toggle-group.style.js +2 -2
- package/esm/components/button-toggle-group/index.d.ts +2 -1
- package/lib/__internal__/radio-button-mapper/index.d.ts +2 -0
- package/lib/{components/button-toggle-group/documentation → __internal__/radio-button-mapper}/index.js +2 -2
- package/lib/__internal__/radio-button-mapper/package.json +6 -0
- package/lib/__internal__/radio-button-mapper/radio-button-mapper.d.ts +21 -0
- package/lib/__internal__/utils/helpers/tags/index.d.ts +1 -0
- package/lib/components/button-toggle/button-toggle.component.d.ts +3 -3
- package/lib/components/button-toggle/button-toggle.component.js +22 -20
- package/lib/components/button-toggle/button-toggle.style.d.ts +1 -1
- package/lib/components/button-toggle-group/button-toggle-group.component.d.ts +45 -0
- package/lib/components/button-toggle-group/button-toggle-group.component.js +190 -93
- package/lib/components/button-toggle-group/button-toggle-group.style.d.ts +4 -0
- package/lib/components/button-toggle-group/button-toggle-group.style.js +2 -2
- package/lib/components/button-toggle-group/index.d.ts +2 -1
- package/package.json +1 -1
- package/esm/components/button-toggle-group/__definition__.js +0 -38
- package/esm/components/button-toggle-group/button-toggle-group.d.ts +0 -58
- package/esm/components/button-toggle-group/documentation/index.js +0 -1
- package/lib/components/button-toggle-group/__definition__.js +0 -50
- package/lib/components/button-toggle-group/button-toggle-group.d.ts +0 -58
- package/lib/components/button-toggle-group/documentation/package.json +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./radio-button-mapper.component";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface RadioButtonMapperProps {
|
|
4
|
+
/** The RadioButton objects to be rendered in the group */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Specifies the name prop to be applied to each button in the group */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Callback fired when each RadioButton is blurred */
|
|
9
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
10
|
+
/** Callback fired when the user selects a RadioButton */
|
|
11
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
/** Callback fired on key down */
|
|
13
|
+
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
14
|
+
/** Value of the selected RadioButton */
|
|
15
|
+
value?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare function RadioButtonMapper(props?: RadioButtonMapperProps): JSX.Element;
|
|
19
|
+
RadioButtonMapper.displayName = "RadioButtonMapper";
|
|
20
|
+
|
|
21
|
+
export default RadioButtonMapper;
|
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { StyledButtonToggleLabelProps } from "./button-toggle.style";
|
|
3
3
|
import { ButtonToggleInputProps } from "./button-toggle-input.component";
|
|
4
4
|
export interface ButtonToggleProps extends ButtonToggleInputProps, Partial<StyledButtonToggleLabelProps> {
|
|
5
|
-
/**
|
|
6
|
-
children
|
|
5
|
+
/** Text to display for the button. */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
7
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
8
|
"data-component"?: string;
|
|
9
9
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
@@ -18,7 +18,7 @@ export interface ButtonToggleProps extends ButtonToggleInputProps, Partial<Style
|
|
|
18
18
|
onClick?: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
|
19
19
|
}
|
|
20
20
|
export declare const ButtonToggle: {
|
|
21
|
-
(
|
|
21
|
+
({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, buttonIcon, buttonIconSize, checked, children, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, disabled, grouped, name, onBlur, onChange, onFocus, size, value, }: ButtonToggleProps): JSX.Element;
|
|
22
22
|
displayName: string;
|
|
23
23
|
};
|
|
24
24
|
export default ButtonToggle;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import React, { useContext, useRef } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
+
import invariant from "invariant";
|
|
3
4
|
import { StyledButtonToggle, StyledButtonToggleLabel, StyledButtonToggleContentWrapper } from "./button-toggle.style";
|
|
4
5
|
import guid from "../../__internal__/utils/helpers/guid";
|
|
5
6
|
import ButtonToggleIcon from "./button-toggle-icon.component";
|
|
6
7
|
import ButtonToggleInput from "./button-toggle-input.component";
|
|
7
8
|
import { InputGroupContext } from "../../__internal__/input-behaviour";
|
|
8
9
|
|
|
9
|
-
const ButtonToggle =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
const ButtonToggle = ({
|
|
11
|
+
"aria-label": ariaLabel,
|
|
12
|
+
"aria-labelledby": ariaLabelledBy,
|
|
13
|
+
buttonIcon,
|
|
14
|
+
buttonIconSize = "small",
|
|
15
|
+
checked,
|
|
16
|
+
children,
|
|
17
|
+
"data-component": dataComponent,
|
|
18
|
+
"data-element": dataElement,
|
|
19
|
+
"data-role": dataRole,
|
|
20
|
+
disabled,
|
|
21
|
+
grouped,
|
|
22
|
+
name,
|
|
23
|
+
onBlur,
|
|
24
|
+
onChange,
|
|
25
|
+
onFocus,
|
|
26
|
+
size = "medium",
|
|
27
|
+
value
|
|
28
|
+
}) => {
|
|
29
|
+
!!!(children || buttonIcon) ? process.env.NODE_ENV !== "production" ? invariant(false, "Either prop `buttonIcon` must be defined, or this node must have children") : invariant(false) : void 0;
|
|
29
30
|
const {
|
|
30
31
|
onMouseEnter,
|
|
31
32
|
onMouseLeave
|
|
@@ -2,7 +2,7 @@ import { IconType } from "../icon";
|
|
|
2
2
|
export declare type ButtonToggleIconSizes = "small" | "large";
|
|
3
3
|
declare const StyledButtonToggleContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export interface StyledButtonToggleLabelProps {
|
|
5
|
-
/**
|
|
5
|
+
/** The icon to be rendered inside of the button */
|
|
6
6
|
buttonIcon?: IconType;
|
|
7
7
|
/** Sets the size of the buttonIcon (eg. large) */
|
|
8
8
|
buttonIconSize?: ButtonToggleIconSizes;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { ValidationProps } from "../../__internal__/validations";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
export interface ButtonToggleGroupProps extends ValidationProps, MarginProps, TagProps {
|
|
6
|
+
/** Unique id for the root element of the component */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Specifies the name prop to be applied to each button in the group */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Togglable buttons to be rendered. Only accepts children of type ButtonToggle */
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
/** When true, validation icon will be placed on label instead of being placed on the input */
|
|
13
|
+
validationOnLabel?: boolean;
|
|
14
|
+
/** Text for the label. */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Text for the labels help tooltip. */
|
|
17
|
+
labelHelp?: React.ReactNode;
|
|
18
|
+
/** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
|
|
19
|
+
labelSpacing?: 1 | 2;
|
|
20
|
+
/** The percentage width of the ButtonToggleGroup. */
|
|
21
|
+
inputWidth?: number | string;
|
|
22
|
+
/** The text for the field help. */
|
|
23
|
+
fieldHelp?: string;
|
|
24
|
+
/** Sets the field help to inline. */
|
|
25
|
+
fieldHelpInline?: boolean;
|
|
26
|
+
/** Sets the label to be inline. */
|
|
27
|
+
labelInline?: boolean;
|
|
28
|
+
/** The percentage width of the label. */
|
|
29
|
+
labelWidth?: number;
|
|
30
|
+
/** The alignment for the text in the label. */
|
|
31
|
+
labelAlign?: "left" | "right";
|
|
32
|
+
/** Callback triggered by blur event on the input. */
|
|
33
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
34
|
+
/** Callback triggered by change event on the input. */
|
|
35
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
36
|
+
/** The value of the Button Toggle Group */
|
|
37
|
+
value?: string;
|
|
38
|
+
/** Aria label for rendered help component */
|
|
39
|
+
helpAriaLabel?: string;
|
|
40
|
+
}
|
|
41
|
+
declare const ButtonToggleGroup: {
|
|
42
|
+
({ children, name, error, warning, info, validationOnLabel, label, labelHelp, labelSpacing, inputWidth, fieldHelp, fieldHelpInline, labelInline, labelWidth, labelAlign, onChange, onBlur, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, ...props }: ButtonToggleGroupProps): JSX.Element;
|
|
43
|
+
displayName: string;
|
|
44
|
+
};
|
|
45
|
+
export default ButtonToggleGroup;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
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
2
|
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import
|
|
5
|
+
import invariant from "invariant";
|
|
6
6
|
import FormField from "../../__internal__/form-field";
|
|
7
|
-
import
|
|
7
|
+
import StyledButtonToggleGroup from "./button-toggle-group.style";
|
|
8
8
|
import ButtonToggle from "../button-toggle";
|
|
9
|
-
import RadioButtonMapper from "../../__internal__/radio-button-mapper
|
|
9
|
+
import RadioButtonMapper from "../../__internal__/radio-button-mapper";
|
|
10
10
|
import ValidationIcon from "../../__internal__/validations/validation-icon.component";
|
|
11
11
|
import { InputGroupBehaviour } from "../../__internal__/input-behaviour";
|
|
12
12
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
13
13
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
14
|
-
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
15
14
|
|
|
16
15
|
const ButtonToggleGroup = ({
|
|
17
16
|
children,
|
|
@@ -44,6 +43,13 @@ const ButtonToggleGroup = ({
|
|
|
44
43
|
warning,
|
|
45
44
|
info
|
|
46
45
|
};
|
|
46
|
+
const hasCorrectItemStructure = useMemo(() => {
|
|
47
|
+
const incorrectChild = React.Children.toArray(children).find(child => {
|
|
48
|
+
return ! /*#__PURE__*/React.isValidElement(child) || child.type.displayName !== ButtonToggle.displayName;
|
|
49
|
+
});
|
|
50
|
+
return !incorrectChild;
|
|
51
|
+
}, [children]);
|
|
52
|
+
!hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? invariant(false, `\`ButtonToggleGroup\` only accepts children of type \`${ButtonToggle.displayName}\``) : invariant(false) : void 0;
|
|
47
53
|
return /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
48
54
|
helpAriaLabel: helpAriaLabel
|
|
49
55
|
}, /*#__PURE__*/React.createElement(InputGroupBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
|
|
@@ -60,7 +66,7 @@ const ButtonToggleGroup = ({
|
|
|
60
66
|
"data-role": dataRole,
|
|
61
67
|
"data-element": dataElement,
|
|
62
68
|
id: id
|
|
63
|
-
}, validationProps, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(
|
|
69
|
+
}, validationProps, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(StyledButtonToggleGroup, _extends({
|
|
64
70
|
"aria-label": label,
|
|
65
71
|
role: "radiogroup",
|
|
66
72
|
inputWidth: inputWidth
|
|
@@ -74,95 +80,184 @@ const ButtonToggleGroup = ({
|
|
|
74
80
|
}))))));
|
|
75
81
|
};
|
|
76
82
|
|
|
77
|
-
ButtonToggleGroup.propTypes = {
|
|
78
|
-
|
|
79
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
83
|
+
ButtonToggleGroup.propTypes = {
|
|
84
|
+
"children": PropTypes.node,
|
|
80
85
|
"data-component": PropTypes.string,
|
|
81
|
-
|
|
82
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
83
86
|
"data-element": PropTypes.string,
|
|
84
|
-
|
|
85
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
86
87
|
"data-role": PropTypes.string,
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
88
|
+
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
89
|
+
"fieldHelp": PropTypes.string,
|
|
90
|
+
"fieldHelpInline": PropTypes.bool,
|
|
91
|
+
"helpAriaLabel": PropTypes.string,
|
|
92
|
+
"id": PropTypes.string.isRequired,
|
|
93
|
+
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
94
|
+
"inputWidth": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
95
|
+
"label": PropTypes.string,
|
|
96
|
+
"labelAlign": PropTypes.oneOf(["left", "right"]),
|
|
97
|
+
"labelHelp": PropTypes.node,
|
|
98
|
+
"labelInline": PropTypes.bool,
|
|
99
|
+
"labelSpacing": PropTypes.oneOf([1, 2]),
|
|
100
|
+
"labelWidth": PropTypes.number,
|
|
101
|
+
"m": 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
|
+
"margin": 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
|
+
"marginBottom": 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
|
+
"marginLeft": 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
|
+
"marginRight": 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
|
+
"marginTop": 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
|
+
"marginX": 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
|
+
"marginY": 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
|
+
"mb": 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
|
+
"ml": 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
|
+
"mr": 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
|
+
"mt": 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
|
+
"mx": 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
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
245
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
246
|
+
"description": PropTypes.string,
|
|
247
|
+
"toString": PropTypes.func.isRequired,
|
|
248
|
+
"valueOf": PropTypes.func.isRequired
|
|
249
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
250
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
251
|
+
"description": PropTypes.string,
|
|
252
|
+
"toString": PropTypes.func.isRequired,
|
|
253
|
+
"valueOf": PropTypes.func.isRequired
|
|
254
|
+
}), PropTypes.string]),
|
|
255
|
+
"name": PropTypes.string.isRequired,
|
|
256
|
+
"onBlur": PropTypes.func,
|
|
257
|
+
"onChange": PropTypes.func,
|
|
258
|
+
"validationOnLabel": PropTypes.bool,
|
|
259
|
+
"value": PropTypes.string,
|
|
260
|
+
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
166
261
|
};
|
|
167
262
|
ButtonToggleGroup.displayName = "ButtonToggleGroup";
|
|
168
263
|
export default ButtonToggleGroup;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ButtonToggleGroupProps } from ".";
|
|
2
|
+
import { ValidationProps } from "../../__internal__/validations";
|
|
3
|
+
declare const StyledButtonToggleGroup: import("styled-components").StyledComponent<"div", any, ValidationProps & Pick<ButtonToggleGroupProps, "inputWidth">, never>;
|
|
4
|
+
export default StyledButtonToggleGroup;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { StyledButtonToggleLabel } from "../button-toggle/button-toggle.style";
|
|
3
3
|
import ValidationIconStyle from "../../__internal__/validations/validation-icon.style";
|
|
4
|
-
const
|
|
4
|
+
const StyledButtonToggleGroup = styled.div`
|
|
5
5
|
display: flex;
|
|
6
6
|
|
|
7
7
|
${({
|
|
@@ -34,4 +34,4 @@ const ButtonToggleGroupStyle = styled.div`
|
|
|
34
34
|
margin-left: 4px;
|
|
35
35
|
}
|
|
36
36
|
`;
|
|
37
|
-
export default
|
|
37
|
+
export default StyledButtonToggleGroup;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./button-toggle-group";
|
|
1
|
+
export { default } from "./button-toggle-group.component";
|
|
2
|
+
export type { ButtonToggleGroupProps } from "./button-toggle-group.component";
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _radioButtonMapper.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _radioButtonMapper = _interopRequireDefault(require("./radio-button-mapper.component"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface RadioButtonMapperProps {
|
|
4
|
+
/** The RadioButton objects to be rendered in the group */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Specifies the name prop to be applied to each button in the group */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Callback fired when each RadioButton is blurred */
|
|
9
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
10
|
+
/** Callback fired when the user selects a RadioButton */
|
|
11
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
/** Callback fired on key down */
|
|
13
|
+
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
14
|
+
/** Value of the selected RadioButton */
|
|
15
|
+
value?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare function RadioButtonMapper(props?: RadioButtonMapperProps): JSX.Element;
|
|
19
|
+
RadioButtonMapper.displayName = "RadioButtonMapper";
|
|
20
|
+
|
|
21
|
+
export default RadioButtonMapper;
|
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { StyledButtonToggleLabelProps } from "./button-toggle.style";
|
|
3
3
|
import { ButtonToggleInputProps } from "./button-toggle-input.component";
|
|
4
4
|
export interface ButtonToggleProps extends ButtonToggleInputProps, Partial<StyledButtonToggleLabelProps> {
|
|
5
|
-
/**
|
|
6
|
-
children
|
|
5
|
+
/** Text to display for the button. */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
7
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
8
|
"data-component"?: string;
|
|
9
9
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
@@ -18,7 +18,7 @@ export interface ButtonToggleProps extends ButtonToggleInputProps, Partial<Style
|
|
|
18
18
|
onClick?: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
|
19
19
|
}
|
|
20
20
|
export declare const ButtonToggle: {
|
|
21
|
-
(
|
|
21
|
+
({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, buttonIcon, buttonIconSize, checked, children, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, disabled, grouped, name, onBlur, onChange, onFocus, size, value, }: ButtonToggleProps): JSX.Element;
|
|
22
22
|
displayName: string;
|
|
23
23
|
};
|
|
24
24
|
export default ButtonToggle;
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
13
|
+
|
|
12
14
|
var _buttonToggle = require("./button-toggle.style");
|
|
13
15
|
|
|
14
16
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
@@ -25,26 +27,26 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
25
27
|
|
|
26
28
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
28
|
-
const ButtonToggle =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
const ButtonToggle = ({
|
|
31
|
+
"aria-label": ariaLabel,
|
|
32
|
+
"aria-labelledby": ariaLabelledBy,
|
|
33
|
+
buttonIcon,
|
|
34
|
+
buttonIconSize = "small",
|
|
35
|
+
checked,
|
|
36
|
+
children,
|
|
37
|
+
"data-component": dataComponent,
|
|
38
|
+
"data-element": dataElement,
|
|
39
|
+
"data-role": dataRole,
|
|
40
|
+
disabled,
|
|
41
|
+
grouped,
|
|
42
|
+
name,
|
|
43
|
+
onBlur,
|
|
44
|
+
onChange,
|
|
45
|
+
onFocus,
|
|
46
|
+
size = "medium",
|
|
47
|
+
value
|
|
48
|
+
}) => {
|
|
49
|
+
!!!(children || buttonIcon) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Either prop `buttonIcon` must be defined, or this node must have children") : (0, _invariant.default)(false) : void 0;
|
|
48
50
|
const {
|
|
49
51
|
onMouseEnter,
|
|
50
52
|
onMouseLeave
|