carbon-react 111.22.0 → 111.22.2

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 (96) hide show
  1. package/esm/__internal__/fieldset/fieldset.component.d.ts +2 -0
  2. package/esm/__internal__/fieldset/fieldset.component.js +1 -0
  3. package/esm/__internal__/utils/storybook/partial-action.d.ts +3 -0
  4. package/esm/__internal__/utils/storybook/partial-action.js +13 -0
  5. package/esm/components/accordion/accordion-group/accordion-group.component.d.ts +5 -1
  6. package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -0
  7. package/esm/components/accordion/accordion.component.d.ts +1 -0
  8. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +18 -7
  9. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +2 -0
  10. package/esm/components/advanced-color-picker/advanced-color-picker.style.js +2 -2
  11. package/esm/components/button-bar/button-bar.component.d.ts +5 -1
  12. package/esm/components/button-bar/button-bar.component.js +2 -0
  13. package/esm/components/carousel/slide/slide.component.d.ts +6 -1
  14. package/esm/components/carousel/slide/slide.component.js +2 -0
  15. package/esm/components/duelling-picklist/duelling-picklist.component.js +5 -0
  16. package/esm/components/duelling-picklist/duelling-picklist.d.ts +4 -0
  17. package/esm/components/fieldset/fieldset.component.d.ts +4 -1
  18. package/esm/components/fieldset/fieldset.component.js +2 -0
  19. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +2 -0
  20. package/esm/components/flat-table/flat-table-cell/flat-table-cell.d.ts +1 -0
  21. package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +2 -0
  22. package/esm/components/flat-table/flat-table-header/flat-table-header.d.ts +1 -0
  23. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +2 -0
  24. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +1 -0
  25. package/esm/components/navigation-bar/navigation-bar.component.d.ts +2 -0
  26. package/esm/components/simple-color-picker/index.d.ts +4 -2
  27. package/esm/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg +0 -0
  28. package/esm/components/simple-color-picker/simple-color/index.d.ts +2 -0
  29. package/esm/components/simple-color-picker/simple-color/simple-color.component.d.ts +25 -0
  30. package/esm/components/simple-color-picker/simple-color/simple-color.component.js +28 -35
  31. package/esm/components/simple-color-picker/simple-color/simple-color.style.d.ts +9 -0
  32. package/esm/components/simple-color-picker/simple-color/simple-color.style.js +77 -3
  33. package/esm/components/simple-color-picker/simple-color-picker.component.d.ts +31 -0
  34. package/esm/components/simple-color-picker/simple-color-picker.component.js +201 -86
  35. package/esm/components/simple-color-picker/simple-color-picker.style.d.ts +9 -0
  36. package/esm/components/simple-color-picker/simple-color-picker.style.js +1 -1
  37. package/esm/components/tabs/tab/tab.component.js +12 -18
  38. package/esm/components/tabs/tabs.component.js +12 -18
  39. package/esm/components/vertical-divider/vertical-divider.component.d.ts +11 -2
  40. package/esm/components/vertical-divider/vertical-divider.component.js +2 -0
  41. package/lib/__internal__/fieldset/fieldset.component.d.ts +2 -0
  42. package/lib/__internal__/fieldset/fieldset.component.js +1 -0
  43. package/lib/__internal__/utils/storybook/partial-action.d.ts +3 -0
  44. package/lib/__internal__/utils/storybook/partial-action.js +21 -0
  45. package/lib/components/accordion/accordion-group/accordion-group.component.d.ts +5 -1
  46. package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -0
  47. package/lib/components/accordion/accordion.component.d.ts +1 -0
  48. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +18 -7
  49. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +3 -1
  50. package/lib/components/advanced-color-picker/advanced-color-picker.style.js +3 -3
  51. package/lib/components/button-bar/button-bar.component.d.ts +5 -1
  52. package/lib/components/button-bar/button-bar.component.js +3 -1
  53. package/lib/components/carousel/slide/slide.component.d.ts +6 -1
  54. package/lib/components/carousel/slide/slide.component.js +3 -1
  55. package/lib/components/duelling-picklist/duelling-picklist.component.js +5 -0
  56. package/lib/components/duelling-picklist/duelling-picklist.d.ts +4 -0
  57. package/lib/components/fieldset/fieldset.component.d.ts +4 -1
  58. package/lib/components/fieldset/fieldset.component.js +3 -1
  59. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +2 -0
  60. package/lib/components/flat-table/flat-table-cell/flat-table-cell.d.ts +1 -0
  61. package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +2 -0
  62. package/lib/components/flat-table/flat-table-header/flat-table-header.d.ts +1 -0
  63. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +2 -0
  64. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +1 -0
  65. package/lib/components/navigation-bar/navigation-bar.component.d.ts +2 -0
  66. package/lib/components/simple-color-picker/index.d.ts +4 -2
  67. package/lib/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg +0 -0
  68. package/lib/components/simple-color-picker/simple-color/index.d.ts +2 -0
  69. package/lib/components/simple-color-picker/simple-color/simple-color.component.d.ts +25 -0
  70. package/lib/components/simple-color-picker/simple-color/simple-color.component.js +35 -39
  71. package/lib/components/simple-color-picker/simple-color/simple-color.style.d.ts +9 -0
  72. package/lib/components/simple-color-picker/simple-color/simple-color.style.js +89 -4
  73. package/lib/components/simple-color-picker/simple-color-picker.component.d.ts +31 -0
  74. package/lib/components/simple-color-picker/simple-color-picker.component.js +204 -90
  75. package/lib/components/simple-color-picker/simple-color-picker.style.d.ts +9 -0
  76. package/lib/components/simple-color-picker/simple-color-picker.style.js +1 -1
  77. package/lib/components/tabs/tab/tab.component.js +12 -18
  78. package/lib/components/tabs/tabs.component.js +12 -18
  79. package/lib/components/vertical-divider/vertical-divider.component.d.ts +11 -2
  80. package/lib/components/vertical-divider/vertical-divider.component.js +3 -1
  81. package/package.json +2 -2
  82. package/esm/components/simple-color-picker/color-sample-box/color-sample-box.component.js +0 -33
  83. package/esm/components/simple-color-picker/color-sample-box/color-sample-box.style.js +0 -31
  84. package/esm/components/simple-color-picker/color-sample-box/index.js +0 -1
  85. package/esm/components/simple-color-picker/simple-color/simple-color.d.ts +0 -24
  86. package/esm/components/simple-color-picker/simple-color-input/simple-color-input.style.js +0 -25
  87. package/esm/components/simple-color-picker/simple-color-picker.d.ts +0 -41
  88. package/esm/components/simple-color-picker/tick-icon/tick-icon.style.js +0 -38
  89. package/lib/components/simple-color-picker/color-sample-box/color-sample-box.component.js +0 -48
  90. package/lib/components/simple-color-picker/color-sample-box/color-sample-box.style.js +0 -48
  91. package/lib/components/simple-color-picker/color-sample-box/index.js +0 -15
  92. package/lib/components/simple-color-picker/color-sample-box/package.json +0 -6
  93. package/lib/components/simple-color-picker/simple-color/simple-color.d.ts +0 -24
  94. package/lib/components/simple-color-picker/simple-color-input/simple-color-input.style.js +0 -38
  95. package/lib/components/simple-color-picker/simple-color-picker.d.ts +0 -41
  96. package/lib/components/simple-color-picker/tick-icon/tick-icon.style.js +0 -54
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useCallback, useState, useRef, useMemo, useEffect } from "react";
4
4
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
5
+ import invariant from "invariant";
6
6
  import Events from "../../__internal__/utils/helpers/events";
7
7
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
8
  import Fieldset from "../../__internal__/fieldset";
@@ -12,7 +12,6 @@ import { StyledContent, StyledColorOptions } from "./simple-color-picker.style";
12
12
  import ValidationIcon from "../../__internal__/validations/validation-icon.component";
13
13
  import { InputGroupContext } from "../../__internal__/input-behaviour";
14
14
  import { filterStyledSystemMarginProps } from "../../style/utils";
15
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
16
15
 
17
16
  const SimpleColorPicker = props => {
18
17
  const {
@@ -33,11 +32,21 @@ const SimpleColorPicker = props => {
33
32
  required,
34
33
  ...rest
35
34
  } = props;
36
- const filteredChildren = useMemo(() => React.Children.toArray(children), [children]);
37
- const myRef = useRef(null);
35
+ const hasProperChildren = useMemo(() => {
36
+ let hasSimpleColorChildren = true;
37
+ React.Children.toArray(children).forEach(child => {
38
+ if (typeof child === "string" || /*#__PURE__*/React.isValidElement(child) && child.type.displayName !== "SimpleColor") {
39
+ hasSimpleColorChildren = false;
40
+ }
41
+ });
42
+ return hasSimpleColorChildren;
43
+ }, [children]);
44
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `SimpleColorPicker accepts only children of type \`${SimpleColor.displayName}\`.`) : invariant(false) : void 0;
45
+ const filteredChildren = useMemo(() => React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child)), [children]);
46
+ const internalRef = useRef(null);
38
47
  const [blurBlocked, setIsBlurBlocked] = useState(isBlurBlocked);
39
48
  const [focusedElement, setFocusedElement] = useState(null);
40
- const itemsPerRow = Math.floor(maxWidth / childWidth);
49
+ const itemsPerRow = Math.floor(+maxWidth / +childWidth);
41
50
  const rowCount = Math.ceil((filteredChildren === null || filteredChildren === void 0 ? void 0 : filteredChildren.length) / itemsPerRow);
42
51
  let blankSlots = itemsPerRow * rowCount - (filteredChildren === null || filteredChildren === void 0 ? void 0 : filteredChildren.length);
43
52
  let currentRow = 1;
@@ -90,19 +99,20 @@ const SimpleColorPicker = props => {
90
99
  const arrowKeys = [Events.isLeftKey(e), Events.isUpKey(e), Events.isRightKey(e), Events.isDownKey(e)];
91
100
  if (!arrowKeys.includes(true)) return;
92
101
  e.preventDefault();
93
- let itemIndex;
102
+ let itemIndex = null;
103
+ const target = e.target;
94
104
 
95
105
  if (Events.isUpKey(e)) {
96
- if (e.target.getAttribute("data-up") !== "true") return;
97
- itemIndex = e.target.getAttribute("data-item-up");
106
+ if (target.getAttribute("data-up") !== "true") return;
107
+ itemIndex = +target.getAttribute("data-item-up");
98
108
  } else if (Events.isDownKey(e)) {
99
- if (e.target.getAttribute("data-down") !== "true") return;
100
- itemIndex = e.target.getAttribute("data-item-down");
109
+ if (target.getAttribute("data-down") !== "true") return;
110
+ itemIndex = +target.getAttribute("data-item-down");
101
111
  }
102
112
 
103
113
  if (Events.isLeftKey(e) || Events.isRightKey(e)) {
104
114
  const position = element => {
105
- return e.target.getAttribute("value") === element.props.value;
115
+ return target.getAttribute("value") === element.props.value;
106
116
  };
107
117
 
108
118
  if (Events.isLeftKey(e)) {
@@ -117,14 +127,18 @@ const SimpleColorPicker = props => {
117
127
  itemIndex = 0;
118
128
  }
119
129
  }
130
+ /* istanbul ignore else */
131
+
120
132
 
121
- const item = navigationGrid[itemIndex].ref.current;
122
- item.focus();
123
- item.click();
124
- }, [onKeyDown, navigationGrid]);
133
+ if (itemIndex !== null) {
134
+ const item = gridItemRefs[itemIndex].current;
135
+ item === null || item === void 0 ? void 0 : item.focus();
136
+ item === null || item === void 0 ? void 0 : item.click();
137
+ }
138
+ }, [onKeyDown, navigationGrid, gridItemRefs]);
125
139
 
126
140
  const handleClickOutside = ev => {
127
- if (myRef.current && ev.target && !myRef.current.contains(ev.target)) {
141
+ if (internalRef.current && ev.target && !internalRef.current.contains(ev.target)) {
128
142
  setIsBlurBlocked(false);
129
143
  }
130
144
  };
@@ -176,10 +190,7 @@ const SimpleColorPicker = props => {
176
190
  }) => /*#__PURE__*/React.createElement(StyledColorOptions, _extends({
177
191
  maxWidth: maxWidth,
178
192
  childWidth: childWidth,
179
- error: error,
180
- warning: warning,
181
- info: info,
182
- ref: myRef,
193
+ ref: internalRef,
183
194
  onMouseEnter: onMouseEnter,
184
195
  onMouseLeave: onMouseLeave
185
196
  }, validationProps), /*#__PURE__*/React.createElement(RadioButtonMapper, {
@@ -195,71 +206,175 @@ const SimpleColorPicker = props => {
195
206
  };
196
207
 
197
208
  SimpleColorPicker.propTypes = {
198
- /** Filtered styled system margin props */
199
- ...marginPropTypes,
200
-
201
- /** The SimpleColor components to be rendered in the group */
202
- children: (props, propName, componentName) => {
203
- let error;
204
- const prop = props[propName];
205
- React.Children.forEach(prop, child => {
206
- if (child === null) {
207
- return;
208
- }
209
-
210
- if (SimpleColor.displayName !== child.type.displayName) {
211
- error = new Error(`\`${componentName}\` only accepts children of type \`${SimpleColor.displayName}\`.`);
212
- }
213
- });
214
- return error;
215
- },
216
-
217
- /** Should the onBlur callback prop be initially blocked? */
218
- isBlurBlocked: PropTypes.bool,
219
-
220
- /** Indicate that error has occurred
221
- Pass string to display icon, tooltip and red border
222
- Pass true boolean to only display red border */
223
- error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
224
-
225
- /** Indicate that warning has occurred
226
- Pass string to display icon, tooltip and orange border
227
- Pass true boolean to only display orange border */
228
- warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
229
-
230
- /** Indicate additional information
231
- Pass string to display icon, tooltip and blue border
232
- Pass true boolean to only display blue border */
233
- info: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
234
-
235
- /** When true, validation icon will be placed on legend instead of being placed by the input */
236
- validationOnLegend: PropTypes.bool,
237
-
238
- /** The content for the RadioGroup Legend */
239
- legend: PropTypes.string.isRequired,
240
-
241
- /** The currently selected color. */
242
- value: PropTypes.string,
243
-
244
- /** The name to apply to the input. */
245
- name: PropTypes.string,
246
-
247
- /** A callback triggered when a color is selected. */
248
- onChange: PropTypes.func,
249
-
250
- /** A callback triggered when a color is selected. */
251
- onBlur: PropTypes.func,
252
-
253
- /** A callback triggered on key down. */
254
- onKeyDown: PropTypes.func,
255
-
256
- /** prop that sets max-width in css */
257
- maxWidth: PropTypes.string,
258
-
259
- /** prop that represents childWidth */
260
- childWidth: PropTypes.string,
261
-
262
- /** Flag to configure component as mandatory */
263
- required: PropTypes.bool
209
+ "children": PropTypes.node,
210
+ "childWidth": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
211
+ "error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
212
+ "info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
213
+ "isBlurBlocked": PropTypes.bool,
214
+ "legend": PropTypes.string.isRequired,
215
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
216
+ "__@toStringTag": PropTypes.string.isRequired,
217
+ "description": PropTypes.string,
218
+ "toString": PropTypes.func.isRequired,
219
+ "valueOf": PropTypes.func.isRequired
220
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
221
+ "__@toStringTag": PropTypes.string.isRequired,
222
+ "description": PropTypes.string,
223
+ "toString": PropTypes.func.isRequired,
224
+ "valueOf": PropTypes.func.isRequired
225
+ }), PropTypes.string]),
226
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
227
+ "__@toStringTag": PropTypes.string.isRequired,
228
+ "description": PropTypes.string,
229
+ "toString": PropTypes.func.isRequired,
230
+ "valueOf": PropTypes.func.isRequired
231
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
232
+ "__@toStringTag": PropTypes.string.isRequired,
233
+ "description": PropTypes.string,
234
+ "toString": PropTypes.func.isRequired,
235
+ "valueOf": PropTypes.func.isRequired
236
+ }), PropTypes.string]),
237
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
238
+ "__@toStringTag": PropTypes.string.isRequired,
239
+ "description": PropTypes.string,
240
+ "toString": PropTypes.func.isRequired,
241
+ "valueOf": PropTypes.func.isRequired
242
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
243
+ "__@toStringTag": PropTypes.string.isRequired,
244
+ "description": PropTypes.string,
245
+ "toString": PropTypes.func.isRequired,
246
+ "valueOf": PropTypes.func.isRequired
247
+ }), PropTypes.string]),
248
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
249
+ "__@toStringTag": PropTypes.string.isRequired,
250
+ "description": PropTypes.string,
251
+ "toString": PropTypes.func.isRequired,
252
+ "valueOf": PropTypes.func.isRequired
253
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
254
+ "__@toStringTag": PropTypes.string.isRequired,
255
+ "description": PropTypes.string,
256
+ "toString": PropTypes.func.isRequired,
257
+ "valueOf": PropTypes.func.isRequired
258
+ }), PropTypes.string]),
259
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
260
+ "__@toStringTag": PropTypes.string.isRequired,
261
+ "description": PropTypes.string,
262
+ "toString": PropTypes.func.isRequired,
263
+ "valueOf": PropTypes.func.isRequired
264
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
265
+ "__@toStringTag": PropTypes.string.isRequired,
266
+ "description": PropTypes.string,
267
+ "toString": PropTypes.func.isRequired,
268
+ "valueOf": PropTypes.func.isRequired
269
+ }), PropTypes.string]),
270
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
271
+ "__@toStringTag": PropTypes.string.isRequired,
272
+ "description": PropTypes.string,
273
+ "toString": PropTypes.func.isRequired,
274
+ "valueOf": PropTypes.func.isRequired
275
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
276
+ "__@toStringTag": PropTypes.string.isRequired,
277
+ "description": PropTypes.string,
278
+ "toString": PropTypes.func.isRequired,
279
+ "valueOf": PropTypes.func.isRequired
280
+ }), PropTypes.string]),
281
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
282
+ "__@toStringTag": PropTypes.string.isRequired,
283
+ "description": PropTypes.string,
284
+ "toString": PropTypes.func.isRequired,
285
+ "valueOf": PropTypes.func.isRequired
286
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
287
+ "__@toStringTag": PropTypes.string.isRequired,
288
+ "description": PropTypes.string,
289
+ "toString": PropTypes.func.isRequired,
290
+ "valueOf": PropTypes.func.isRequired
291
+ }), PropTypes.string]),
292
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
293
+ "__@toStringTag": PropTypes.string.isRequired,
294
+ "description": PropTypes.string,
295
+ "toString": PropTypes.func.isRequired,
296
+ "valueOf": PropTypes.func.isRequired
297
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
298
+ "__@toStringTag": PropTypes.string.isRequired,
299
+ "description": PropTypes.string,
300
+ "toString": PropTypes.func.isRequired,
301
+ "valueOf": PropTypes.func.isRequired
302
+ }), PropTypes.string]),
303
+ "maxWidth": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
304
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
305
+ "__@toStringTag": PropTypes.string.isRequired,
306
+ "description": PropTypes.string,
307
+ "toString": PropTypes.func.isRequired,
308
+ "valueOf": PropTypes.func.isRequired
309
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
310
+ "__@toStringTag": PropTypes.string.isRequired,
311
+ "description": PropTypes.string,
312
+ "toString": PropTypes.func.isRequired,
313
+ "valueOf": PropTypes.func.isRequired
314
+ }), PropTypes.string]),
315
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
316
+ "__@toStringTag": PropTypes.string.isRequired,
317
+ "description": PropTypes.string,
318
+ "toString": PropTypes.func.isRequired,
319
+ "valueOf": PropTypes.func.isRequired
320
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
321
+ "__@toStringTag": PropTypes.string.isRequired,
322
+ "description": PropTypes.string,
323
+ "toString": PropTypes.func.isRequired,
324
+ "valueOf": PropTypes.func.isRequired
325
+ }), PropTypes.string]),
326
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
327
+ "__@toStringTag": PropTypes.string.isRequired,
328
+ "description": PropTypes.string,
329
+ "toString": PropTypes.func.isRequired,
330
+ "valueOf": PropTypes.func.isRequired
331
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
332
+ "__@toStringTag": PropTypes.string.isRequired,
333
+ "description": PropTypes.string,
334
+ "toString": PropTypes.func.isRequired,
335
+ "valueOf": PropTypes.func.isRequired
336
+ }), PropTypes.string]),
337
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
338
+ "__@toStringTag": PropTypes.string.isRequired,
339
+ "description": PropTypes.string,
340
+ "toString": PropTypes.func.isRequired,
341
+ "valueOf": PropTypes.func.isRequired
342
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
343
+ "__@toStringTag": PropTypes.string.isRequired,
344
+ "description": PropTypes.string,
345
+ "toString": PropTypes.func.isRequired,
346
+ "valueOf": PropTypes.func.isRequired
347
+ }), PropTypes.string]),
348
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
349
+ "__@toStringTag": PropTypes.string.isRequired,
350
+ "description": PropTypes.string,
351
+ "toString": PropTypes.func.isRequired,
352
+ "valueOf": PropTypes.func.isRequired
353
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
354
+ "__@toStringTag": PropTypes.string.isRequired,
355
+ "description": PropTypes.string,
356
+ "toString": PropTypes.func.isRequired,
357
+ "valueOf": PropTypes.func.isRequired
358
+ }), PropTypes.string]),
359
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
360
+ "__@toStringTag": PropTypes.string.isRequired,
361
+ "description": PropTypes.string,
362
+ "toString": PropTypes.func.isRequired,
363
+ "valueOf": PropTypes.func.isRequired
364
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
365
+ "__@toStringTag": PropTypes.string.isRequired,
366
+ "description": PropTypes.string,
367
+ "toString": PropTypes.func.isRequired,
368
+ "valueOf": PropTypes.func.isRequired
369
+ }), PropTypes.string]),
370
+ "name": PropTypes.string.isRequired,
371
+ "onBlur": PropTypes.func,
372
+ "onChange": PropTypes.func,
373
+ "onKeyDown": PropTypes.func,
374
+ "required": PropTypes.bool,
375
+ "validationOnLegend": PropTypes.bool,
376
+ "value": PropTypes.string,
377
+ "warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
264
378
  };
379
+ export { SimpleColorPicker };
265
380
  export default SimpleColorPicker;
@@ -0,0 +1,9 @@
1
+ import { ValidationProps } from "../../__internal__/validations";
2
+ declare type Width = string | number;
3
+ declare const StyledContent: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ interface StyledColorOptionsProps extends ValidationProps {
5
+ maxWidth: Width;
6
+ childWidth: Width;
7
+ }
8
+ declare const StyledColorOptions: import("styled-components").StyledComponent<"div", any, StyledColorOptionsProps, never>;
9
+ export { StyledContent, StyledColorOptions };
@@ -2,7 +2,7 @@ import styled, { css } from "styled-components";
2
2
  import StyledValidationIcon from "../../__internal__/validations/validation-icon.style";
3
3
  const BORDER_WIDTH = 2;
4
4
 
5
- const getRoundedMaxWidth = (maxWidth, childWidth) => Math.floor(maxWidth / childWidth) * childWidth;
5
+ const getRoundedMaxWidth = (maxWidth, childWidth) => Math.floor(+maxWidth / +childWidth) * +childWidth;
6
6
 
7
7
  const StyledContent = styled.div`
8
8
  display: flex;
@@ -28,26 +28,20 @@ const Tab = ({
28
28
  const [tabWarnings, setTabWarnings] = useState({});
29
29
  const [tabInfos, setTabInfos] = useState({});
30
30
  const setError = useCallback((childId, error) => {
31
- if (tabErrors[childId] !== error) {
32
- setTabErrors({ ...tabErrors,
33
- [childId]: error
34
- });
35
- }
36
- }, [tabErrors]);
31
+ setTabErrors(state => state[childId] !== error ? { ...state,
32
+ [childId]: error
33
+ } : state);
34
+ }, []);
37
35
  const setWarning = useCallback((childId, warning) => {
38
- if (tabWarnings[childId] !== warning) {
39
- setTabWarnings({ ...tabWarnings,
40
- [childId]: warning
41
- });
42
- }
43
- }, [tabWarnings]);
36
+ setTabWarnings(state => state[childId] !== warning ? { ...state,
37
+ [childId]: warning
38
+ } : state);
39
+ }, []);
44
40
  const setInfo = useCallback((childId, info) => {
45
- if (tabInfos[childId] !== info) {
46
- setTabInfos({ ...tabInfos,
47
- [childId]: info
48
- });
49
- }
50
- }, [tabInfos]);
41
+ setTabInfos(state => state[childId] !== info ? { ...state,
42
+ [childId]: info
43
+ } : state);
44
+ }, []);
51
45
  useEffect(() => {
52
46
  if (updateErrors) {
53
47
  updateErrors(tabId, tabErrors);
@@ -50,26 +50,20 @@ const Tabs = ({
50
50
  const [tabsWarnings, setTabsWarnings] = useState({});
51
51
  const [tabsInfos, setTabsInfos] = useState({});
52
52
  const updateErrors = useCallback((id, error) => {
53
- if (tabsErrors[id] !== error) {
54
- setTabsErrors({ ...tabsErrors,
55
- [id]: error
56
- });
57
- }
58
- }, [tabsErrors]);
53
+ setTabsErrors(state => ({ ...state,
54
+ [id]: error
55
+ }));
56
+ }, []);
59
57
  const updateWarnings = useCallback((id, warning) => {
60
- if (tabsWarnings[id] !== warning) {
61
- setTabsWarnings({ ...tabsWarnings,
62
- [id]: warning
63
- });
64
- }
65
- }, [tabsWarnings]);
58
+ setTabsWarnings(state => ({ ...state,
59
+ [id]: warning
60
+ }));
61
+ }, []);
66
62
  const updateInfos = useCallback((id, info) => {
67
- if (tabsInfos[id] !== info) {
68
- setTabsInfos({ ...tabsInfos,
69
- [id]: info
70
- });
71
- }
72
- }, [tabsInfos]);
63
+ setTabsInfos(state => ({ ...state,
64
+ [id]: info
65
+ }));
66
+ }, []);
73
67
  /** Returns true/false for if the given tab id is selected. */
74
68
 
75
69
  const isTabSelected = useCallback(tabId => tabId === selectedTabIdState, [selectedTabIdState]);
@@ -2,11 +2,20 @@
2
2
  import { SpaceProps } from "styled-system";
3
3
  declare type TintRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100;
4
4
  export interface VerticalDividerProps extends SpaceProps {
5
+ /** Shorthand for the height attribute */
5
6
  h?: number | string;
7
+ /** Height attribute of the component */
6
8
  height?: number | string;
9
+ /**
10
+ * Sets the display: inline css attribute on the component
11
+ * To be used in non-flex containers.
12
+ */
7
13
  displayInline?: boolean;
8
- /** the supported rage is 1-100 */
14
+ /** Custom tint of the divider, the supported rage is 1-100 */
9
15
  tint?: TintRange;
10
16
  }
11
- declare const VerticalDivider: ({ h, height, displayInline, tint, ...props }: VerticalDividerProps) => JSX.Element;
17
+ export declare const VerticalDivider: {
18
+ ({ h, height, displayInline, tint, ...props }: VerticalDividerProps): JSX.Element;
19
+ displayName: string;
20
+ };
12
21
  export default VerticalDivider;
@@ -342,4 +342,6 @@ VerticalDivider.propTypes = {
342
342
  }), PropTypes.string]),
343
343
  "tint": PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])
344
344
  };
345
+ export { VerticalDivider };
346
+ VerticalDivider.displayName = "VerticalDivider";
345
347
  export default VerticalDivider;
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  export interface FieldsetProps extends MarginProps {
4
+ /** Role */
5
+ role?: string;
4
6
  /** Fieldset content */
5
7
  children: React.ReactNode;
6
8
  /** The content for the Fieldset Legend */
@@ -221,6 +221,7 @@ Fieldset.propTypes = {
221
221
  "toString": _propTypes.default.func.isRequired,
222
222
  "valueOf": _propTypes.default.func.isRequired
223
223
  }), _propTypes.default.string]),
224
+ "role": _propTypes.default.string,
224
225
  "warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
225
226
  };
226
227
  var _default = Fieldset;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare function partialAction(actionName: string): (eventObj?: string | React.SyntheticEvent<Element, Event> | undefined, ...args: string[]) => void;
3
+ export default partialAction;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _addonActions = require("@storybook/addon-actions");
9
+
10
+ function partialAction(actionName) {
11
+ return (eventObj, ...args) => {
12
+ (0, _addonActions.action)(actionName)(typeof eventObj === "string" ? {
13
+ view: undefined
14
+ } : { ...eventObj,
15
+ view: undefined
16
+ }, ...args);
17
+ };
18
+ }
19
+
20
+ var _default = partialAction;
21
+ exports.default = _default;
@@ -4,7 +4,11 @@ declare type AccordionGroupChild = React.ReactElement | boolean | null | undefin
4
4
  interface AccordionGroupChildArray extends Array<AccordionGroupChild> {
5
5
  }
6
6
  export interface AccordionGroupProps extends MarginProps {
7
+ /** An Accordion or list of Accordion components to be rendered inside the AccordionGroup */
7
8
  children?: AccordionGroupChild;
8
9
  }
9
- export declare const AccordionGroup: ({ children, ...rest }: AccordionGroupProps) => JSX.Element;
10
+ export declare const AccordionGroup: {
11
+ ({ children, ...rest }: AccordionGroupProps): JSX.Element;
12
+ displayName: string;
13
+ };
10
14
  export default AccordionGroup;
@@ -281,5 +281,6 @@ AccordionGroup.propTypes = {
281
281
  "valueOf": _propTypes.default.func.isRequired
282
282
  }), _propTypes.default.string])
283
283
  };
284
+ AccordionGroup.displayName = "AccordionGroup";
284
285
  var _default = AccordionGroup;
285
286
  exports.default = _default;
@@ -4,6 +4,7 @@ import { StyledAccordionContainerProps } from "./accordion.style";
4
4
  export interface AccordionProps extends StyledAccordionContainerProps, SpaceProps {
5
5
  /** Width of the buttonHeading when it's set, defaults to 150px */
6
6
  buttonWidth?: number;
7
+ /** Content of the Accordion component */
7
8
  children?: React.ReactNode;
8
9
  /** Set the default state of expansion of the Accordion if component is meant to be used as uncontrolled */
9
10
  defaultExpanded?: boolean;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ButtonTypes } from "../../button/button.component";
2
+ import { ButtonIconPosition, ButtonTypes, SizeOptions } from "../../button/button.component";
3
3
  import { IconType } from "../../icon";
4
4
  export declare type ActionPopoverMenuButtonAria = {
5
5
  "aria-haspopup": string;
@@ -8,14 +8,25 @@ export declare type ActionPopoverMenuButtonAria = {
8
8
  "aria-expanded": string;
9
9
  };
10
10
  export interface ActionPopoverMenuButtonProps {
11
- children?: string;
11
+ /** ARIA attributes to be applied to the button HTML element */
12
+ ariaAttributes: ActionPopoverMenuButtonAria;
13
+ /** Variant of the menu button */
12
14
  buttonType?: ButtonTypes;
15
+ /** Identifier used for testing purposes, applied to the root element of the component. */
16
+ "data-element": string;
17
+ /** Content of the button */
18
+ children?: string;
19
+ /** Defines an Icon position related to the children: "before" | "after" */
20
+ iconPosition?: ButtonIconPosition;
21
+ /** Defines an Icon type within the button */
13
22
  iconType?: IconType;
14
- iconPosition?: "after" | "before";
15
- size?: "small" | "medium" | "large";
23
+ /** Assigns a size to the button: "small" | "medium" | "large" */
24
+ size?: SizeOptions;
25
+ /** Overrides the default tabindex of the component */
16
26
  tabIndex: number;
17
- ariaAttributes: ActionPopoverMenuButtonAria;
18
- "data-element": string;
19
27
  }
20
- declare const ActionPopoverMenuButton: ({ buttonType, iconType, iconPosition, size, children, ...props }: ActionPopoverMenuButtonProps) => JSX.Element;
28
+ export declare const ActionPopoverMenuButton: {
29
+ ({ buttonType, iconType, iconPosition, size, children, ...props }: ActionPopoverMenuButtonProps): JSX.Element;
30
+ displayName: string;
31
+ };
21
32
  export default ActionPopoverMenuButton;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.ActionPopoverMenuButton = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -31,6 +31,7 @@ const ActionPopoverMenuButton = ({
31
31
  size: size
32
32
  }, props), children));
33
33
 
34
+ exports.ActionPopoverMenuButton = ActionPopoverMenuButton;
34
35
  ActionPopoverMenuButton.propTypes = {
35
36
  "ariaAttributes": _propTypes.default.shape({
36
37
  "aria-controls": _propTypes.default.string.isRequired,
@@ -46,5 +47,6 @@ ActionPopoverMenuButton.propTypes = {
46
47
  "size": _propTypes.default.oneOf(["large", "medium", "small"]),
47
48
  "tabIndex": _propTypes.default.number.isRequired
48
49
  };
50
+ ActionPopoverMenuButton.displayName = "ActionPopoverMenuButton";
49
51
  var _default = ActionPopoverMenuButton;
50
52
  exports.default = _default;