carbon-react 115.0.2 → 116.0.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.
Files changed (31) hide show
  1. package/esm/__internal__/radio-button-mapper/radio-button-mapper.component.d.ts +1 -1
  2. package/esm/components/tile-select/__internal__/accordion/accordion.component.d.ts +10 -0
  3. package/esm/components/tile-select/__internal__/accordion/accordion.component.js +317 -9
  4. package/esm/components/tile-select/__internal__/accordion/accordion.style.d.ts +3 -0
  5. package/esm/components/tile-select/__internal__/accordion/index.d.ts +1 -0
  6. package/esm/components/tile-select/index.d.ts +4 -2
  7. package/esm/components/tile-select/index.js +2 -2
  8. package/esm/components/tile-select/tile-select-group.component.d.ts +25 -0
  9. package/esm/components/tile-select/tile-select-group.component.js +184 -59
  10. package/esm/components/tile-select/tile-select.component.d.ts +58 -0
  11. package/esm/components/tile-select/tile-select.component.js +192 -100
  12. package/esm/components/tile-select/tile-select.style.d.ts +36 -0
  13. package/lib/__internal__/radio-button-mapper/radio-button-mapper.component.d.ts +1 -1
  14. package/lib/components/tile-select/__internal__/accordion/accordion.component.d.ts +10 -0
  15. package/lib/components/tile-select/__internal__/accordion/accordion.component.js +316 -8
  16. package/lib/components/tile-select/__internal__/accordion/accordion.style.d.ts +3 -0
  17. package/lib/components/tile-select/__internal__/accordion/index.d.ts +1 -0
  18. package/lib/components/tile-select/index.d.ts +4 -2
  19. package/lib/components/tile-select/index.js +4 -4
  20. package/lib/components/tile-select/tile-select-group.component.d.ts +25 -0
  21. package/lib/components/tile-select/tile-select-group.component.js +188 -68
  22. package/lib/components/tile-select/tile-select.component.d.ts +58 -0
  23. package/lib/components/tile-select/tile-select.component.js +192 -105
  24. package/lib/components/tile-select/tile-select.style.d.ts +36 -0
  25. package/package.json +1 -1
  26. package/esm/components/tile-select/__internal__/accordion/accordion.d.ts +0 -13
  27. package/esm/components/tile-select/tile-select-group.d.ts +0 -27
  28. package/esm/components/tile-select/tile-select.d.ts +0 -51
  29. package/lib/components/tile-select/__internal__/accordion/accordion.d.ts +0 -13
  30. package/lib/components/tile-select/tile-select-group.d.ts +0 -27
  31. package/lib/components/tile-select/tile-select.d.ts +0 -51
@@ -2,26 +2,22 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React from "react";
4
4
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
6
5
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
7
- import TileSelect from "./tile-select.component";
8
6
  import RadioButtonMapper from "../../__internal__/radio-button-mapper/radio-button-mapper.component";
9
7
  import { StyledTileSelectFieldset, StyledGroupDescription } from "./tile-select.style";
10
8
  import { filterStyledSystemMarginProps } from "../../style/utils";
11
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
12
9
 
13
- const TileSelectGroup = props => {
14
- const {
15
- children,
16
- name,
17
- legend,
18
- description,
19
- onChange,
20
- onBlur,
21
- value,
22
- multiSelect,
23
- ...rest
24
- } = props;
10
+ const TileSelectGroup = ({
11
+ children,
12
+ name,
13
+ legend,
14
+ description,
15
+ onChange,
16
+ onBlur,
17
+ value,
18
+ multiSelect = false,
19
+ ...rest
20
+ }) => {
25
21
  let tiles;
26
22
 
27
23
  if (multiSelect) {
@@ -32,9 +28,15 @@ const TileSelectGroup = props => {
32
28
  onBlur: onBlur,
33
29
  onChange: onChange,
34
30
  value: value
35
- }, React.Children.map(children, child => /*#__PURE__*/React.cloneElement(child, {
36
- type: "radio"
37
- })));
31
+ }, React.Children.map(children, child => {
32
+ if ( /*#__PURE__*/React.isValidElement(child)) {
33
+ return /*#__PURE__*/React.cloneElement(child, {
34
+ type: "radio"
35
+ });
36
+ }
37
+
38
+ return child;
39
+ }));
38
40
  }
39
41
 
40
42
  return /*#__PURE__*/React.createElement(StyledTileSelectFieldset, _extends({
@@ -46,46 +48,169 @@ const TileSelectGroup = props => {
46
48
  }, description) : null, /*#__PURE__*/React.createElement("div", null, tiles));
47
49
  };
48
50
 
49
- TileSelectGroup.propTypes = { ...marginPropTypes,
50
-
51
- /** The TileSelect components to be rendered in the group */
52
- children: (props, propName, componentName) => {
53
- let error;
54
- const prop = props[propName];
55
- React.Children.forEach(prop, child => {
56
- if (TileSelect.displayName !== child.type.displayName) {
57
- error = new Error(`\`${componentName}\` only accepts children of type \`${TileSelect.displayName}\`.`);
58
- }
59
- });
60
- return error;
61
- },
62
-
63
- /** The content for the TileSelectGroup Legend */
64
- legend: PropTypes.string,
65
-
66
- /** Description to be rendered below the legend */
67
- description: PropTypes.string,
68
-
69
- /** The currently selected value - only for single select mode. */
70
- value: PropTypes.string,
71
-
72
- /** The name to apply to the input - only for single select mode. */
73
- name: PropTypes.string,
74
-
75
- /** A callback triggered when one of tiles is selected - only for single select mode. */
76
- onChange: PropTypes.func,
77
-
78
- /** A callback triggered when one of tiles is blurred - only for single select mode. */
79
- onBlur: PropTypes.func,
80
-
81
- /** When passed as true TileSelectGroup serves only visual purpose */
82
-
83
- /** It wraps TileSelects in fieldset element and renders the legend and description props content */
84
-
85
- /** onChange, onBlur, value, checked and name props are meant to be passed individually on each of the TileSelects */
86
- multiSelect: PropTypes.bool
87
- };
88
- TileSelectGroup.defaultProps = {
89
- multiSelect: false
51
+ TileSelectGroup.propTypes = {
52
+ "children": PropTypes.node,
53
+ "description": PropTypes.string,
54
+ "legend": PropTypes.string,
55
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
56
+ "__@toStringTag": PropTypes.string.isRequired,
57
+ "description": PropTypes.string,
58
+ "toString": PropTypes.func.isRequired,
59
+ "valueOf": PropTypes.func.isRequired
60
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
61
+ "__@toStringTag": PropTypes.string.isRequired,
62
+ "description": PropTypes.string,
63
+ "toString": PropTypes.func.isRequired,
64
+ "valueOf": PropTypes.func.isRequired
65
+ }), PropTypes.string]),
66
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
67
+ "__@toStringTag": PropTypes.string.isRequired,
68
+ "description": PropTypes.string,
69
+ "toString": PropTypes.func.isRequired,
70
+ "valueOf": PropTypes.func.isRequired
71
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
72
+ "__@toStringTag": PropTypes.string.isRequired,
73
+ "description": PropTypes.string,
74
+ "toString": PropTypes.func.isRequired,
75
+ "valueOf": PropTypes.func.isRequired
76
+ }), PropTypes.string]),
77
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
78
+ "__@toStringTag": PropTypes.string.isRequired,
79
+ "description": PropTypes.string,
80
+ "toString": PropTypes.func.isRequired,
81
+ "valueOf": PropTypes.func.isRequired
82
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
83
+ "__@toStringTag": PropTypes.string.isRequired,
84
+ "description": PropTypes.string,
85
+ "toString": PropTypes.func.isRequired,
86
+ "valueOf": PropTypes.func.isRequired
87
+ }), PropTypes.string]),
88
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
89
+ "__@toStringTag": PropTypes.string.isRequired,
90
+ "description": PropTypes.string,
91
+ "toString": PropTypes.func.isRequired,
92
+ "valueOf": PropTypes.func.isRequired
93
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
94
+ "__@toStringTag": PropTypes.string.isRequired,
95
+ "description": PropTypes.string,
96
+ "toString": PropTypes.func.isRequired,
97
+ "valueOf": PropTypes.func.isRequired
98
+ }), PropTypes.string]),
99
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
100
+ "__@toStringTag": PropTypes.string.isRequired,
101
+ "description": PropTypes.string,
102
+ "toString": PropTypes.func.isRequired,
103
+ "valueOf": PropTypes.func.isRequired
104
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
105
+ "__@toStringTag": PropTypes.string.isRequired,
106
+ "description": PropTypes.string,
107
+ "toString": PropTypes.func.isRequired,
108
+ "valueOf": PropTypes.func.isRequired
109
+ }), PropTypes.string]),
110
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
111
+ "__@toStringTag": PropTypes.string.isRequired,
112
+ "description": PropTypes.string,
113
+ "toString": PropTypes.func.isRequired,
114
+ "valueOf": PropTypes.func.isRequired
115
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
116
+ "__@toStringTag": PropTypes.string.isRequired,
117
+ "description": PropTypes.string,
118
+ "toString": PropTypes.func.isRequired,
119
+ "valueOf": PropTypes.func.isRequired
120
+ }), PropTypes.string]),
121
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
122
+ "__@toStringTag": PropTypes.string.isRequired,
123
+ "description": PropTypes.string,
124
+ "toString": PropTypes.func.isRequired,
125
+ "valueOf": PropTypes.func.isRequired
126
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
127
+ "__@toStringTag": PropTypes.string.isRequired,
128
+ "description": PropTypes.string,
129
+ "toString": PropTypes.func.isRequired,
130
+ "valueOf": PropTypes.func.isRequired
131
+ }), PropTypes.string]),
132
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
133
+ "__@toStringTag": PropTypes.string.isRequired,
134
+ "description": PropTypes.string,
135
+ "toString": PropTypes.func.isRequired,
136
+ "valueOf": PropTypes.func.isRequired
137
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
138
+ "__@toStringTag": PropTypes.string.isRequired,
139
+ "description": PropTypes.string,
140
+ "toString": PropTypes.func.isRequired,
141
+ "valueOf": PropTypes.func.isRequired
142
+ }), PropTypes.string]),
143
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
144
+ "__@toStringTag": PropTypes.string.isRequired,
145
+ "description": PropTypes.string,
146
+ "toString": PropTypes.func.isRequired,
147
+ "valueOf": PropTypes.func.isRequired
148
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
149
+ "__@toStringTag": PropTypes.string.isRequired,
150
+ "description": PropTypes.string,
151
+ "toString": PropTypes.func.isRequired,
152
+ "valueOf": PropTypes.func.isRequired
153
+ }), PropTypes.string]),
154
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
155
+ "__@toStringTag": PropTypes.string.isRequired,
156
+ "description": PropTypes.string,
157
+ "toString": PropTypes.func.isRequired,
158
+ "valueOf": PropTypes.func.isRequired
159
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
160
+ "__@toStringTag": PropTypes.string.isRequired,
161
+ "description": PropTypes.string,
162
+ "toString": PropTypes.func.isRequired,
163
+ "valueOf": PropTypes.func.isRequired
164
+ }), PropTypes.string]),
165
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
166
+ "__@toStringTag": PropTypes.string.isRequired,
167
+ "description": PropTypes.string,
168
+ "toString": PropTypes.func.isRequired,
169
+ "valueOf": PropTypes.func.isRequired
170
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
171
+ "__@toStringTag": PropTypes.string.isRequired,
172
+ "description": PropTypes.string,
173
+ "toString": PropTypes.func.isRequired,
174
+ "valueOf": PropTypes.func.isRequired
175
+ }), PropTypes.string]),
176
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
177
+ "__@toStringTag": PropTypes.string.isRequired,
178
+ "description": PropTypes.string,
179
+ "toString": PropTypes.func.isRequired,
180
+ "valueOf": PropTypes.func.isRequired
181
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
182
+ "__@toStringTag": PropTypes.string.isRequired,
183
+ "description": PropTypes.string,
184
+ "toString": PropTypes.func.isRequired,
185
+ "valueOf": PropTypes.func.isRequired
186
+ }), PropTypes.string]),
187
+ "multiSelect": PropTypes.bool,
188
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
189
+ "__@toStringTag": PropTypes.string.isRequired,
190
+ "description": PropTypes.string,
191
+ "toString": PropTypes.func.isRequired,
192
+ "valueOf": PropTypes.func.isRequired
193
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
194
+ "__@toStringTag": PropTypes.string.isRequired,
195
+ "description": PropTypes.string,
196
+ "toString": PropTypes.func.isRequired,
197
+ "valueOf": PropTypes.func.isRequired
198
+ }), PropTypes.string]),
199
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
200
+ "__@toStringTag": PropTypes.string.isRequired,
201
+ "description": PropTypes.string,
202
+ "toString": PropTypes.func.isRequired,
203
+ "valueOf": PropTypes.func.isRequired
204
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
205
+ "__@toStringTag": PropTypes.string.isRequired,
206
+ "description": PropTypes.string,
207
+ "toString": PropTypes.func.isRequired,
208
+ "valueOf": PropTypes.func.isRequired
209
+ }), PropTypes.string]),
210
+ "name": PropTypes.string.isRequired,
211
+ "onBlur": PropTypes.func,
212
+ "onChange": PropTypes.func,
213
+ "value": PropTypes.string
90
214
  };
215
+ export { TileSelectGroup };
91
216
  export default TileSelectGroup;
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ export interface TileSelectDeselectEvent {
4
+ target: {
5
+ name?: string;
6
+ id?: string;
7
+ value: null;
8
+ checked: false;
9
+ };
10
+ }
11
+ export interface TileSelectProps extends MarginProps {
12
+ /** title of the TileSelect */
13
+ title?: React.ReactNode;
14
+ /** adornment to be rendered next to the title */
15
+ titleAdornment?: React.ReactNode;
16
+ /** subtitle of the TileSelect */
17
+ subtitle?: React.ReactNode;
18
+ /** description of the TileSelect */
19
+ description?: React.ReactNode;
20
+ /** disables the TileSelect input */
21
+ disabled?: boolean;
22
+ /** the value that is represented by this TileSelect */
23
+ value?: string;
24
+ /** input id */
25
+ id?: string;
26
+ /** input name */
27
+ name?: string;
28
+ /** Callback triggered when user selects or deselects this tile */
29
+ onChange?: (ev: React.ChangeEvent<HTMLInputElement> | TileSelectDeselectEvent) => void;
30
+ /** Callback triggered when the user blurs this tile */
31
+ onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
32
+ /** Callback triggered when the user focus this tile */
33
+ onFocus?: (ev: React.FocusEvent<HTMLInputElement>) => void;
34
+ /** determines if this tile is selected or unselected */
35
+ checked?: boolean;
36
+ /** Custom class name passed to the root element of TileSelect */
37
+ className?: string;
38
+ /** Type of the TileSelect input */
39
+ type?: "radio" | "checkbox";
40
+ /** Render prop that allows overriding the default action button. */
41
+ customActionButton?: (onClick: () => void) => JSX.Element;
42
+ /** An additional help info icon rendered next to the action button */
43
+ actionButtonAdornment?: React.ReactNode;
44
+ /** footer of the TileSelect */
45
+ footer?: React.ReactNode;
46
+ /** Component to render in the top left corner of TileSelect */
47
+ prefixAdornment?: React.ReactNode;
48
+ /** Component to render additional information row between title and description */
49
+ additionalInformation?: React.ReactNode;
50
+ /** Components to render in the TileSelect Accordion */
51
+ accordionContent?: React.ReactNode;
52
+ /** Callback to toggle expanded state of TileSelect Accordion */
53
+ accordionControl?: (controlId: string, contentId: string) => JSX.Element;
54
+ /** Flag to control the open state of TileSelect Accordion */
55
+ accordionExpanded?: boolean;
56
+ }
57
+ declare const TileSelect: React.ForwardRefExoticComponent<TileSelectProps & React.RefAttributes<HTMLInputElement>>;
58
+ export default TileSelect;