carbon-react 111.22.1 → 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 (88) 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/components/accordion/accordion-group/accordion-group.component.d.ts +5 -1
  4. package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -0
  5. package/esm/components/accordion/accordion.component.d.ts +1 -0
  6. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +18 -7
  7. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +2 -0
  8. package/esm/components/advanced-color-picker/advanced-color-picker.style.js +2 -2
  9. package/esm/components/button-bar/button-bar.component.d.ts +5 -1
  10. package/esm/components/button-bar/button-bar.component.js +2 -0
  11. package/esm/components/carousel/slide/slide.component.d.ts +6 -1
  12. package/esm/components/carousel/slide/slide.component.js +2 -0
  13. package/esm/components/duelling-picklist/duelling-picklist.component.js +5 -0
  14. package/esm/components/duelling-picklist/duelling-picklist.d.ts +4 -0
  15. package/esm/components/fieldset/fieldset.component.d.ts +4 -1
  16. package/esm/components/fieldset/fieldset.component.js +2 -0
  17. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +2 -0
  18. package/esm/components/flat-table/flat-table-cell/flat-table-cell.d.ts +1 -0
  19. package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +2 -0
  20. package/esm/components/flat-table/flat-table-header/flat-table-header.d.ts +1 -0
  21. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +2 -0
  22. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +1 -0
  23. package/esm/components/navigation-bar/navigation-bar.component.d.ts +2 -0
  24. package/esm/components/simple-color-picker/index.d.ts +4 -2
  25. package/esm/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg +0 -0
  26. package/esm/components/simple-color-picker/simple-color/index.d.ts +2 -0
  27. package/esm/components/simple-color-picker/simple-color/simple-color.component.d.ts +25 -0
  28. package/esm/components/simple-color-picker/simple-color/simple-color.component.js +28 -35
  29. package/esm/components/simple-color-picker/simple-color/simple-color.style.d.ts +9 -0
  30. package/esm/components/simple-color-picker/simple-color/simple-color.style.js +77 -3
  31. package/esm/components/simple-color-picker/simple-color-picker.component.d.ts +31 -0
  32. package/esm/components/simple-color-picker/simple-color-picker.component.js +201 -86
  33. package/esm/components/simple-color-picker/simple-color-picker.style.d.ts +9 -0
  34. package/esm/components/simple-color-picker/simple-color-picker.style.js +1 -1
  35. package/esm/components/vertical-divider/vertical-divider.component.d.ts +11 -2
  36. package/esm/components/vertical-divider/vertical-divider.component.js +2 -0
  37. package/lib/__internal__/fieldset/fieldset.component.d.ts +2 -0
  38. package/lib/__internal__/fieldset/fieldset.component.js +1 -0
  39. package/lib/components/accordion/accordion-group/accordion-group.component.d.ts +5 -1
  40. package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -0
  41. package/lib/components/accordion/accordion.component.d.ts +1 -0
  42. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +18 -7
  43. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +3 -1
  44. package/lib/components/advanced-color-picker/advanced-color-picker.style.js +3 -3
  45. package/lib/components/button-bar/button-bar.component.d.ts +5 -1
  46. package/lib/components/button-bar/button-bar.component.js +3 -1
  47. package/lib/components/carousel/slide/slide.component.d.ts +6 -1
  48. package/lib/components/carousel/slide/slide.component.js +3 -1
  49. package/lib/components/duelling-picklist/duelling-picklist.component.js +5 -0
  50. package/lib/components/duelling-picklist/duelling-picklist.d.ts +4 -0
  51. package/lib/components/fieldset/fieldset.component.d.ts +4 -1
  52. package/lib/components/fieldset/fieldset.component.js +3 -1
  53. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +2 -0
  54. package/lib/components/flat-table/flat-table-cell/flat-table-cell.d.ts +1 -0
  55. package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +2 -0
  56. package/lib/components/flat-table/flat-table-header/flat-table-header.d.ts +1 -0
  57. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +2 -0
  58. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +1 -0
  59. package/lib/components/navigation-bar/navigation-bar.component.d.ts +2 -0
  60. package/lib/components/simple-color-picker/index.d.ts +4 -2
  61. package/lib/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg +0 -0
  62. package/lib/components/simple-color-picker/simple-color/index.d.ts +2 -0
  63. package/lib/components/simple-color-picker/simple-color/simple-color.component.d.ts +25 -0
  64. package/lib/components/simple-color-picker/simple-color/simple-color.component.js +35 -39
  65. package/lib/components/simple-color-picker/simple-color/simple-color.style.d.ts +9 -0
  66. package/lib/components/simple-color-picker/simple-color/simple-color.style.js +89 -4
  67. package/lib/components/simple-color-picker/simple-color-picker.component.d.ts +31 -0
  68. package/lib/components/simple-color-picker/simple-color-picker.component.js +204 -90
  69. package/lib/components/simple-color-picker/simple-color-picker.style.d.ts +9 -0
  70. package/lib/components/simple-color-picker/simple-color-picker.style.js +1 -1
  71. package/lib/components/vertical-divider/vertical-divider.component.d.ts +11 -2
  72. package/lib/components/vertical-divider/vertical-divider.component.js +3 -1
  73. package/package.json +2 -2
  74. package/esm/components/simple-color-picker/color-sample-box/color-sample-box.component.js +0 -33
  75. package/esm/components/simple-color-picker/color-sample-box/color-sample-box.style.js +0 -31
  76. package/esm/components/simple-color-picker/color-sample-box/index.js +0 -1
  77. package/esm/components/simple-color-picker/simple-color/simple-color.d.ts +0 -24
  78. package/esm/components/simple-color-picker/simple-color-input/simple-color-input.style.js +0 -25
  79. package/esm/components/simple-color-picker/simple-color-picker.d.ts +0 -41
  80. package/esm/components/simple-color-picker/tick-icon/tick-icon.style.js +0 -38
  81. package/lib/components/simple-color-picker/color-sample-box/color-sample-box.component.js +0 -48
  82. package/lib/components/simple-color-picker/color-sample-box/color-sample-box.style.js +0 -48
  83. package/lib/components/simple-color-picker/color-sample-box/index.js +0 -15
  84. package/lib/components/simple-color-picker/color-sample-box/package.json +0 -6
  85. package/lib/components/simple-color-picker/simple-color/simple-color.d.ts +0 -24
  86. package/lib/components/simple-color-picker/simple-color-input/simple-color-input.style.js +0 -38
  87. package/lib/components/simple-color-picker/simple-color-picker.d.ts +0 -41
  88. package/lib/components/simple-color-picker/tick-icon/tick-icon.style.js +0 -54
@@ -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 */
@@ -208,6 +208,7 @@ Fieldset.propTypes = {
208
208
  "toString": PropTypes.func.isRequired,
209
209
  "valueOf": PropTypes.func.isRequired
210
210
  }), PropTypes.string]),
211
+ "role": PropTypes.string,
211
212
  "warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
212
213
  };
213
214
  export default Fieldset;
@@ -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;
@@ -261,4 +261,5 @@ AccordionGroup.propTypes = {
261
261
  }), PropTypes.string])
262
262
  };
263
263
  export { AccordionGroup };
264
+ AccordionGroup.displayName = "AccordionGroup";
264
265
  export default AccordionGroup;
@@ -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;
@@ -34,4 +34,6 @@ ActionPopoverMenuButton.propTypes = {
34
34
  "size": PropTypes.oneOf(["large", "medium", "small"]),
35
35
  "tabIndex": PropTypes.number.isRequired
36
36
  };
37
+ export { ActionPopoverMenuButton };
38
+ ActionPopoverMenuButton.displayName = "ActionPopoverMenuButton";
37
39
  export default ActionPopoverMenuButton;
@@ -2,11 +2,11 @@ import styled, { css } from "styled-components";
2
2
  import { margin } from "styled-system";
3
3
  import StyledAdvancedColorPickerCell from "./advanced-color-picker-cell.style";
4
4
  import { StyledColorOptions } from "../simple-color-picker/simple-color-picker.style";
5
- import StyledSimpleColor from "../simple-color-picker/simple-color/simple-color.style";
5
+ import { StyledSimpleColor } from "../simple-color-picker/simple-color/simple-color.style";
6
6
  import { StyledDialogContent, StyledDialogInnerContent } from "../dialog/dialog.style";
7
7
  import Dialog from "../dialog/dialog.component";
8
8
  import StyledIconButton from "../icon-button/icon-button.style";
9
- import checkerBoardSvg from "../simple-color-picker/color-sample-box/checker-board.svg";
9
+ import checkerBoardSvg from "../simple-color-picker/simple-color/checker-board.svg";
10
10
  import baseTheme from "../../style/themes/base";
11
11
  const StyledAdvancedColorPickerWrapper = styled.div`
12
12
  ${margin}
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { SpaceProps } from "styled-system";
3
3
  export interface ButtonBarProps extends SpaceProps {
4
+ /** Button or IconButton Elements, to be rendered inside the component */
4
5
  children: React.ReactNode;
5
6
  /** Apply fullWidth style to the button bar */
6
7
  fullWidth?: boolean;
@@ -9,5 +10,8 @@ export interface ButtonBarProps extends SpaceProps {
9
10
  /** Assigns a size to the buttons: "small" | "medium" | "large" */
10
11
  size?: "small" | "medium" | "large";
11
12
  }
12
- declare const ButtonBar: ({ children, size, iconPosition, fullWidth, ...rest }: ButtonBarProps) => JSX.Element;
13
+ export declare const ButtonBar: {
14
+ ({ children, size, iconPosition, fullWidth, ...rest }: ButtonBarProps): JSX.Element;
15
+ displayName: string;
16
+ };
13
17
  export default ButtonBar;
@@ -359,4 +359,6 @@ ButtonBar.propTypes = {
359
359
  }), PropTypes.string]),
360
360
  "size": PropTypes.oneOf(["large", "medium", "small"])
361
361
  };
362
+ export { ButtonBar };
363
+ ButtonBar.displayName = "ButtonBar";
362
364
  export default ButtonBar;
@@ -1,7 +1,12 @@
1
1
  import React from "react";
2
2
  export interface SlideProps {
3
+ /** Content of the Slide */
3
4
  children?: React.ReactNode;
5
+ /** Accepts a callback function which is triggered on Slide click */
4
6
  onClick?: (ev: React.MouseEvent<HTMLDivElement>) => void;
5
7
  }
6
- declare const Slide: (props: SlideProps) => JSX.Element;
8
+ export declare const Slide: {
9
+ (props: SlideProps): JSX.Element;
10
+ displayName: string;
11
+ };
7
12
  export default Slide;
@@ -12,4 +12,6 @@ Slide.propTypes = {
12
12
  "children": PropTypes.node,
13
13
  "onClick": PropTypes.func
14
14
  };
15
+ export { Slide };
16
+ Slide.displayName = "Slide";
15
17
  export default Slide;
@@ -60,6 +60,11 @@ const DuellingPicklist = ({
60
60
  };
61
61
 
62
62
  DuellingPicklist.propTypes = { ...marginPropTypes,
63
+
64
+ /**
65
+ * Content of the component, should contain two Picklist children
66
+ * and a PicklistDivider
67
+ */
63
68
  children: (props, propName) => {
64
69
  const prop = props[propName];
65
70
  let error;
@@ -2,6 +2,10 @@ import * as React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
 
4
4
  export interface DuellingPicklistProps extends MarginProps {
5
+ /**
6
+ * Content of the component, should contain two Picklist children
7
+ * and a PicklistDivider
8
+ */
5
9
  children?: React.ReactNode;
6
10
  /** Indicate if component is disabled */
7
11
  disabled?: boolean;
@@ -7,5 +7,8 @@ export interface FieldsetProps extends StyledFieldsetProps, MarginProps {
7
7
  /** The text for the fieldsets legend element. */
8
8
  legend?: string;
9
9
  }
10
- declare const Fieldset: ({ children, inline, legend, ...rest }: FieldsetProps) => JSX.Element;
10
+ export declare const Fieldset: {
11
+ ({ children, inline, legend, ...rest }: FieldsetProps): JSX.Element;
12
+ displayName: string;
13
+ };
11
14
  export default Fieldset;
@@ -194,4 +194,6 @@ Fieldset.propTypes = {
194
194
  "valueOf": PropTypes.func.isRequired
195
195
  }), PropTypes.string])
196
196
  };
197
+ export { Fieldset };
198
+ Fieldset.displayName = "Fieldset";
197
199
  export default Fieldset;
@@ -65,6 +65,8 @@ FlatTableCell.propTypes = {
65
65
 
66
66
  /** Content alignment */
67
67
  align: PropTypes.oneOf(["center", "left", "right"]),
68
+
69
+ /** Cell content */
68
70
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
69
71
 
70
72
  /** Number of columns that a cell should span */
@@ -5,6 +5,7 @@ import { TableBorderSize } from "..";
5
5
  export interface FlatTableCellProps extends PaddingProps {
6
6
  /** Content alignment */
7
7
  align?: "left" | "center" | "right";
8
+ /** Cell content */
8
9
  children?: React.ReactNode | string;
9
10
  /** Number of columns that a cell should span */
10
11
  colspan?: number | string;
@@ -54,6 +54,8 @@ FlatTableHeader.propTypes = {
54
54
 
55
55
  /** Content alignment */
56
56
  align: PropTypes.oneOf(["center", "left", "right"]),
57
+
58
+ /** Header content */
57
59
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
58
60
 
59
61
  /** Number of columns that a header cell should span */
@@ -8,6 +8,7 @@ export interface FlatTableHeaderProps extends PaddingProps {
8
8
  align?: "left" | "center" | "right";
9
9
  /** If true sets alternative background color */
10
10
  alternativeBgColor?: boolean;
11
+ /** Header content */
11
12
  children?: React.ReactNode | string;
12
13
  /** Number of columns that a header cell should span */
13
14
  colspan?: number | string;
@@ -60,6 +60,8 @@ FlatTableRowHeader.propTypes = {
60
60
 
61
61
  /** Content alignment */
62
62
  align: PropTypes.oneOf(["center", "left", "right"]),
63
+
64
+ /** RowHeader content */
63
65
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
64
66
 
65
67
  /** Column width, pass a number to set a fixed width in pixels */
@@ -5,6 +5,7 @@ import { TableBorderSize } from "..";
5
5
  export interface FlatTableRowHeaderProps extends PaddingProps {
6
6
  /** Content alignment */
7
7
  align?: string;
8
+ /** RowHeader content */
8
9
  children?: React.ReactNode | string;
9
10
  /** Column width, pass a number to set a fixed width in pixels */
10
11
  width?: number;
@@ -4,7 +4,9 @@ export declare type Position = "sticky" | "fixed";
4
4
  export declare type Orientation = "top" | "bottom";
5
5
  export declare type NavigationType = "light" | "dark" | "white" | "black";
6
6
  export interface NavigationBarProps extends PaddingProps, FlexboxProps {
7
+ /** Content of the component */
7
8
  children?: React.ReactNode;
9
+ /** HTML aria-label attribute */
8
10
  ariaLabel?: string;
9
11
  /** Color scheme of navigation component */
10
12
  navigationType?: NavigationType;
@@ -1,2 +1,4 @@
1
- export { default as SimpleColorPicker } from "./simple-color-picker";
2
- export { default as SimpleColor } from "./simple-color/simple-color";
1
+ export { default as SimpleColorPicker } from "./simple-color-picker.component";
2
+ export type { SimpleColorPickerProps } from "./simple-color-picker.component";
3
+ export { default as SimpleColor } from "./simple-color";
4
+ export type { SimpleColorProps } from "./simple-color";
@@ -0,0 +1,2 @@
1
+ export { default } from "./simple-color.component";
2
+ export type { SimpleColorProps } from "./simple-color.component";
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ export interface SimpleColorProps {
3
+ /** the value of the color that is represented by this SimpleColor */
4
+ value: string;
5
+ /** the input name */
6
+ name?: string;
7
+ /** the input id */
8
+ id?: string;
9
+ /** if true, input will be disabled */
10
+ disabled?: boolean;
11
+ /** called when the user selects or deselects this color option */
12
+ onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
13
+ /** Prop for `onBlur` events */
14
+ onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
15
+ /** Prop for `onMouseDown` events */
16
+ onMouseDown?: (ev: React.MouseEvent<HTMLInputElement>) => void;
17
+ /** determines if this color option is selected or unselected */
18
+ checked?: boolean;
19
+ /** determines if this color option is selected or unselected when component is used as uncontrolled */
20
+ defaultChecked?: boolean;
21
+ /** [Legacy] Custom classname */
22
+ className?: string;
23
+ }
24
+ export declare const SimpleColor: React.ForwardRefExoticComponent<SimpleColorProps & React.RefAttributes<HTMLInputElement>>;
25
+ export default SimpleColor;
@@ -1,11 +1,10 @@
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, { useRef } from "react";
3
4
  import PropTypes from "prop-types";
4
- import React from "react";
5
+ import guid from "../../../__internal__/utils/helpers/guid";
5
6
  import tagComponent from "../../../__internal__/utils/helpers/tags/tags";
6
- import StyledSimpleColor from "./simple-color.style";
7
- import ColorSampleBox from "../color-sample-box";
8
- import StyledSimpleColorInput from "../simple-color-input/simple-color-input.style";
7
+ import { StyledSimpleColor, StyledColorSampleBox, StyledTickIcon, StyledSimpleColorInput } from "./simple-color.style";
9
8
  const SimpleColor = /*#__PURE__*/React.forwardRef((props, ref) => {
10
9
  const {
11
10
  onChange,
@@ -13,13 +12,16 @@ const SimpleColor = /*#__PURE__*/React.forwardRef((props, ref) => {
13
12
  onMouseDown,
14
13
  value,
15
14
  name,
16
- checked,
15
+ checked = false,
17
16
  className,
17
+ id,
18
+ defaultChecked,
18
19
  ...rest
19
20
  } = props;
21
+ const {
22
+ current: inputId
23
+ } = useRef(id || guid());
20
24
  return /*#__PURE__*/React.createElement(StyledSimpleColor, _extends({
21
- color: value,
22
- checked: checked,
23
25
  className: className
24
26
  }, tagComponent("simple-color", props)), /*#__PURE__*/React.createElement(StyledSimpleColorInput, _extends({
25
27
  onChange: onChange,
@@ -31,37 +33,28 @@ const SimpleColor = /*#__PURE__*/React.forwardRef((props, ref) => {
31
33
  role: "radio",
32
34
  value: value,
33
35
  "aria-checked": checked,
34
- ref: ref
35
- }, rest)), /*#__PURE__*/React.createElement(ColorSampleBox, {
36
+ ref: ref,
37
+ id: inputId,
38
+ defaultChecked: defaultChecked
39
+ }, rest)), /*#__PURE__*/React.createElement(StyledColorSampleBox, {
40
+ color: value
41
+ }, checked && /*#__PURE__*/React.createElement(StyledTickIcon, {
36
42
  color: value,
37
- checked: checked
38
- }));
43
+ type: "tick"
44
+ })));
39
45
  });
40
- SimpleColor.defaultProps = {
41
- checked: false,
42
- onChange: null
43
- };
44
46
  SimpleColor.propTypes = {
45
- /** the value of the color that is represented by this SimpleColor */
46
- value: PropTypes.string,
47
-
48
- /** the input name */
49
- name: PropTypes.string,
50
-
51
- /** called when the user selects or deselects this color option */
52
- onChange: PropTypes.func,
53
-
54
- /** A callback triggered when a color is selected. */
55
- onBlur: PropTypes.func,
56
-
57
- /** A callback triggered when a color is selected. */
58
- onMouseDown: PropTypes.func,
59
-
60
- /** determines if this color option is selected or unselected */
61
- checked: PropTypes.bool,
62
-
63
- /** [Legacy] Custom classname */
64
- className: PropTypes.string
47
+ "checked": PropTypes.bool,
48
+ "className": PropTypes.string,
49
+ "defaultChecked": PropTypes.bool,
50
+ "disabled": PropTypes.bool,
51
+ "id": PropTypes.string,
52
+ "name": PropTypes.string,
53
+ "onBlur": PropTypes.func,
54
+ "onChange": PropTypes.func,
55
+ "onMouseDown": PropTypes.func,
56
+ "value": PropTypes.string.isRequired
65
57
  };
58
+ export { SimpleColor };
66
59
  SimpleColor.displayName = "SimpleColor";
67
60
  export default SimpleColor;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledSimpleColor: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledColorSampleBox: import("styled-components").StyledComponent<"div", any, {
4
+ color: string;
5
+ }, never>;
6
+ export declare const StyledSimpleColorInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../__internal__/input").InputProps & import("react").RefAttributes<HTMLInputElement>>, any, {}, never>;
7
+ export declare const StyledTickIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {
8
+ color: string;
9
+ }, never>;
@@ -1,5 +1,9 @@
1
- import styled from "styled-components";
2
- const StyledSimpleColor = styled.div`
1
+ import styled, { css } from "styled-components";
2
+ import { Input } from "../../../__internal__/input";
3
+ import checkerBoardSvg from "./checker-board.svg";
4
+ import Icon from "../../icon";
5
+ import getRgbValues from "../../../style/utils/get-rgb-values";
6
+ export const StyledSimpleColor = styled.div`
3
7
  width: var(--sizing700);
4
8
  height: var(--sizing700);
5
9
  margin-right: 2px;
@@ -9,4 +13,74 @@ const StyledSimpleColor = styled.div`
9
13
  cursor: pointer;
10
14
  }
11
15
  `;
12
- export default StyledSimpleColor;
16
+ export const StyledColorSampleBox = styled.div`
17
+ height: 100%;
18
+ width: 100%;
19
+ box-sizing: border-box;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ border: 2px solid transparent;
24
+
25
+ ${({
26
+ color
27
+ }) => color !== "transparent" && css`
28
+ background-color: ${color};
29
+ `}
30
+
31
+ ${({
32
+ color
33
+ }) => color === "transparent" && css`
34
+ background-color: #eeeeee;
35
+ background-image: url(${checkerBoardSvg});
36
+ background-size: 14px 14px;
37
+ background-position: -2px -2px;
38
+ `}
39
+ `;
40
+ export const StyledSimpleColorInput = styled(Input)`
41
+ position: absolute;
42
+ opacity: 0;
43
+ height: var(--sizing700);
44
+ width: var(--sizing700);
45
+ margin: 0;
46
+
47
+ &:hover {
48
+ cursor: pointer;
49
+ }
50
+
51
+ &:disabled:hover {
52
+ cursor: not-allowed;
53
+ }
54
+
55
+ &:focus + ${StyledColorSampleBox} {
56
+ box-shadow: inset 0px 0px 0px var(--borderWidth200)
57
+ var(--colorsUtilityYang100);
58
+ border: 2px solid var(--colorsSemanticFocus500);
59
+ }
60
+ `;
61
+
62
+ const getIconColor = color => {
63
+ const rgbValues = getRgbValues(color);
64
+ const [r, g, b] = rgbValues; // color contrast calculating formula as per W3 suggestions
65
+
66
+ const redMultiplier = 299,
67
+ greenMultiplier = 587,
68
+ blueMultiplier = 114;
69
+ const contrast = (Math.round(r * redMultiplier) + Math.round(g * greenMultiplier) + Math.round(b * blueMultiplier)) / 1000;
70
+ if (contrast < 128) return "var(--colorsUtilityYang100)";
71
+ return "var(--colorsUtilityYin090)";
72
+ };
73
+
74
+ export const StyledTickIcon = styled(Icon)`
75
+ height: 22px;
76
+ width: 22px;
77
+ pointer-events: none;
78
+ display: block;
79
+
80
+ &::before {
81
+ font-size: 22px;
82
+ color: ${({
83
+ color
84
+ }) => getIconColor(color)};
85
+ }
86
+ `;
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ import { ValidationProps } from "../../__internal__/validations";
4
+ export interface SimpleColorPickerProps extends ValidationProps, MarginProps {
5
+ /** The SimpleColor components to be rendered in the group */
6
+ children?: React.ReactNode;
7
+ /** prop that represents childWidth */
8
+ childWidth?: string | number;
9
+ /** Should the onBlur callback prop be initially blocked? */
10
+ isBlurBlocked?: boolean;
11
+ /** The content for the Legend */
12
+ legend: string;
13
+ /** prop that sets max-width in css */
14
+ maxWidth?: string | number;
15
+ /** The name to apply to the input. */
16
+ name: string;
17
+ /** Prop for `onChange` events */
18
+ onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
19
+ /** Prop for `onKeyDown` events */
20
+ onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
21
+ /** Prop for `onBlur` events */
22
+ onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
23
+ /** Flag to configure component as mandatory */
24
+ required?: boolean;
25
+ /** When true, validation icon will be placed on legend instead of being placed by the input */
26
+ validationOnLegend?: boolean;
27
+ /** The currently selected color. */
28
+ value?: string;
29
+ }
30
+ export declare const SimpleColorPicker: (props: SimpleColorPickerProps) => JSX.Element;
31
+ export default SimpleColorPicker;