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.
- package/esm/__internal__/fieldset/fieldset.component.d.ts +2 -0
- package/esm/__internal__/fieldset/fieldset.component.js +1 -0
- package/esm/__internal__/utils/storybook/partial-action.d.ts +3 -0
- package/esm/__internal__/utils/storybook/partial-action.js +13 -0
- package/esm/components/accordion/accordion-group/accordion-group.component.d.ts +5 -1
- package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -0
- package/esm/components/accordion/accordion.component.d.ts +1 -0
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +18 -7
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +2 -0
- package/esm/components/advanced-color-picker/advanced-color-picker.style.js +2 -2
- package/esm/components/button-bar/button-bar.component.d.ts +5 -1
- package/esm/components/button-bar/button-bar.component.js +2 -0
- package/esm/components/carousel/slide/slide.component.d.ts +6 -1
- package/esm/components/carousel/slide/slide.component.js +2 -0
- package/esm/components/duelling-picklist/duelling-picklist.component.js +5 -0
- package/esm/components/duelling-picklist/duelling-picklist.d.ts +4 -0
- package/esm/components/fieldset/fieldset.component.d.ts +4 -1
- package/esm/components/fieldset/fieldset.component.js +2 -0
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +2 -0
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.d.ts +1 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +2 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.d.ts +1 -0
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +2 -0
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +1 -0
- package/esm/components/navigation-bar/navigation-bar.component.d.ts +2 -0
- package/esm/components/simple-color-picker/index.d.ts +4 -2
- package/esm/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg +0 -0
- package/esm/components/simple-color-picker/simple-color/index.d.ts +2 -0
- package/esm/components/simple-color-picker/simple-color/simple-color.component.d.ts +25 -0
- package/esm/components/simple-color-picker/simple-color/simple-color.component.js +28 -35
- package/esm/components/simple-color-picker/simple-color/simple-color.style.d.ts +9 -0
- package/esm/components/simple-color-picker/simple-color/simple-color.style.js +77 -3
- package/esm/components/simple-color-picker/simple-color-picker.component.d.ts +31 -0
- package/esm/components/simple-color-picker/simple-color-picker.component.js +201 -86
- package/esm/components/simple-color-picker/simple-color-picker.style.d.ts +9 -0
- package/esm/components/simple-color-picker/simple-color-picker.style.js +1 -1
- package/esm/components/tabs/tab/tab.component.js +12 -18
- package/esm/components/tabs/tabs.component.js +12 -18
- package/esm/components/vertical-divider/vertical-divider.component.d.ts +11 -2
- package/esm/components/vertical-divider/vertical-divider.component.js +2 -0
- package/lib/__internal__/fieldset/fieldset.component.d.ts +2 -0
- package/lib/__internal__/fieldset/fieldset.component.js +1 -0
- package/lib/__internal__/utils/storybook/partial-action.d.ts +3 -0
- package/lib/__internal__/utils/storybook/partial-action.js +21 -0
- package/lib/components/accordion/accordion-group/accordion-group.component.d.ts +5 -1
- package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -0
- package/lib/components/accordion/accordion.component.d.ts +1 -0
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +18 -7
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +3 -1
- package/lib/components/advanced-color-picker/advanced-color-picker.style.js +3 -3
- package/lib/components/button-bar/button-bar.component.d.ts +5 -1
- package/lib/components/button-bar/button-bar.component.js +3 -1
- package/lib/components/carousel/slide/slide.component.d.ts +6 -1
- package/lib/components/carousel/slide/slide.component.js +3 -1
- package/lib/components/duelling-picklist/duelling-picklist.component.js +5 -0
- package/lib/components/duelling-picklist/duelling-picklist.d.ts +4 -0
- package/lib/components/fieldset/fieldset.component.d.ts +4 -1
- package/lib/components/fieldset/fieldset.component.js +3 -1
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +2 -0
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.d.ts +1 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +2 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.d.ts +1 -0
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +2 -0
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +1 -0
- package/lib/components/navigation-bar/navigation-bar.component.d.ts +2 -0
- package/lib/components/simple-color-picker/index.d.ts +4 -2
- package/lib/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg +0 -0
- package/lib/components/simple-color-picker/simple-color/index.d.ts +2 -0
- package/lib/components/simple-color-picker/simple-color/simple-color.component.d.ts +25 -0
- package/lib/components/simple-color-picker/simple-color/simple-color.component.js +35 -39
- package/lib/components/simple-color-picker/simple-color/simple-color.style.d.ts +9 -0
- package/lib/components/simple-color-picker/simple-color/simple-color.style.js +89 -4
- package/lib/components/simple-color-picker/simple-color-picker.component.d.ts +31 -0
- package/lib/components/simple-color-picker/simple-color-picker.component.js +204 -90
- package/lib/components/simple-color-picker/simple-color-picker.style.d.ts +9 -0
- package/lib/components/simple-color-picker/simple-color-picker.style.js +1 -1
- package/lib/components/tabs/tab/tab.component.js +12 -18
- package/lib/components/tabs/tabs.component.js +12 -18
- package/lib/components/vertical-divider/vertical-divider.component.d.ts +11 -2
- package/lib/components/vertical-divider/vertical-divider.component.js +3 -1
- package/package.json +2 -2
- package/esm/components/simple-color-picker/color-sample-box/color-sample-box.component.js +0 -33
- package/esm/components/simple-color-picker/color-sample-box/color-sample-box.style.js +0 -31
- package/esm/components/simple-color-picker/color-sample-box/index.js +0 -1
- package/esm/components/simple-color-picker/simple-color/simple-color.d.ts +0 -24
- package/esm/components/simple-color-picker/simple-color-input/simple-color-input.style.js +0 -25
- package/esm/components/simple-color-picker/simple-color-picker.d.ts +0 -41
- package/esm/components/simple-color-picker/tick-icon/tick-icon.style.js +0 -38
- package/lib/components/simple-color-picker/color-sample-box/color-sample-box.component.js +0 -48
- package/lib/components/simple-color-picker/color-sample-box/color-sample-box.style.js +0 -48
- package/lib/components/simple-color-picker/color-sample-box/index.js +0 -15
- package/lib/components/simple-color-picker/color-sample-box/package.json +0 -6
- package/lib/components/simple-color-picker/simple-color/simple-color.d.ts +0 -24
- package/lib/components/simple-color-picker/simple-color-input/simple-color-input.style.js +0 -38
- package/lib/components/simple-color-picker/simple-color-picker.d.ts +0 -41
- package/lib/components/simple-color-picker/tick-icon/tick-icon.style.js +0 -54
|
@@ -19,7 +19,7 @@ var _advancedColorPickerCell = _interopRequireDefault(require("./advanced-color-
|
|
|
19
19
|
|
|
20
20
|
var _simpleColorPicker = require("../simple-color-picker/simple-color-picker.style");
|
|
21
21
|
|
|
22
|
-
var _simpleColor =
|
|
22
|
+
var _simpleColor = require("../simple-color-picker/simple-color/simple-color.style");
|
|
23
23
|
|
|
24
24
|
var _dialog = require("../dialog/dialog.style");
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ var _dialog2 = _interopRequireDefault(require("../dialog/dialog.component"));
|
|
|
27
27
|
|
|
28
28
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
29
29
|
|
|
30
|
-
var _checkerBoard = _interopRequireDefault(require("../simple-color-picker/color
|
|
30
|
+
var _checkerBoard = _interopRequireDefault(require("../simple-color-picker/simple-color/checker-board.svg"));
|
|
31
31
|
|
|
32
32
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
33
33
|
|
|
@@ -81,7 +81,7 @@ const DialogStyle = (0, _styledComponents.default)(_dialog2.default)`
|
|
|
81
81
|
|
|
82
82
|
${_simpleColorPicker.StyledColorOptions} {
|
|
83
83
|
max-width: 285px;
|
|
84
|
-
${_simpleColor.
|
|
84
|
+
${_simpleColor.StyledSimpleColor} {
|
|
85
85
|
border: 1px solid var(--colorsUtilityYin090);
|
|
86
86
|
margin-right: -1px;
|
|
87
87
|
margin-bottom: -1px;
|
|
@@ -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:
|
|
13
|
+
export declare const ButtonBar: {
|
|
14
|
+
({ children, size, iconPosition, fullWidth, ...rest }: ButtonBarProps): JSX.Element;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
13
17
|
export default ButtonBar;
|
|
@@ -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.ButtonBar = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -64,6 +64,7 @@ const ButtonBar = ({
|
|
|
64
64
|
}), _react.default.Children.map(children, child => /*#__PURE__*/_react.default.createElement(child.type, getBtnProps(child))));
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
exports.ButtonBar = ButtonBar;
|
|
67
68
|
ButtonBar.propTypes = {
|
|
68
69
|
"children": _propTypes.default.node,
|
|
69
70
|
"fullWidth": _propTypes.default.bool,
|
|
@@ -378,5 +379,6 @@ ButtonBar.propTypes = {
|
|
|
378
379
|
}), _propTypes.default.string]),
|
|
379
380
|
"size": _propTypes.default.oneOf(["large", "medium", "small"])
|
|
380
381
|
};
|
|
382
|
+
ButtonBar.displayName = "ButtonBar";
|
|
381
383
|
var _default = ButtonBar;
|
|
382
384
|
exports.default = _default;
|
|
@@ -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:
|
|
8
|
+
export declare const Slide: {
|
|
9
|
+
(props: SlideProps): JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
7
12
|
export default Slide;
|
|
@@ -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.Slide = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -19,9 +19,11 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
19
19
|
|
|
20
20
|
const Slide = props => /*#__PURE__*/_react.default.createElement(_slide.SlideStyle, _extends({}, props, (0, _tags.default)("slide", props)));
|
|
21
21
|
|
|
22
|
+
exports.Slide = Slide;
|
|
22
23
|
Slide.propTypes = {
|
|
23
24
|
"children": _propTypes.default.node,
|
|
24
25
|
"onClick": _propTypes.default.func
|
|
25
26
|
};
|
|
27
|
+
Slide.displayName = "Slide";
|
|
26
28
|
var _default = Slide;
|
|
27
29
|
exports.default = _default;
|
|
@@ -81,6 +81,11 @@ const DuellingPicklist = ({
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
DuellingPicklist.propTypes = { ...marginPropTypes,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Content of the component, should contain two Picklist children
|
|
87
|
+
* and a PicklistDivider
|
|
88
|
+
*/
|
|
84
89
|
children: (props, propName) => {
|
|
85
90
|
const prop = props[propName];
|
|
86
91
|
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:
|
|
10
|
+
export declare const Fieldset: {
|
|
11
|
+
({ children, inline, legend, ...rest }: FieldsetProps): JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
11
14
|
export default Fieldset;
|
|
@@ -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.Fieldset = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -49,6 +49,7 @@ const Fieldset = ({
|
|
|
49
49
|
}, getLegend(), children)));
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
exports.Fieldset = Fieldset;
|
|
52
53
|
Fieldset.propTypes = {
|
|
53
54
|
"children": _propTypes.default.node,
|
|
54
55
|
"inline": _propTypes.default.bool,
|
|
@@ -208,5 +209,6 @@ Fieldset.propTypes = {
|
|
|
208
209
|
"valueOf": _propTypes.default.func.isRequired
|
|
209
210
|
}), _propTypes.default.string])
|
|
210
211
|
};
|
|
212
|
+
Fieldset.displayName = "Fieldset";
|
|
211
213
|
var _default = Fieldset;
|
|
212
214
|
exports.default = _default;
|
|
@@ -84,6 +84,8 @@ FlatTableCell.propTypes = {
|
|
|
84
84
|
|
|
85
85
|
/** Content alignment */
|
|
86
86
|
align: _propTypes.default.oneOf(["center", "left", "right"]),
|
|
87
|
+
|
|
88
|
+
/** Cell content */
|
|
87
89
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
|
|
88
90
|
|
|
89
91
|
/** 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;
|
|
@@ -73,6 +73,8 @@ FlatTableHeader.propTypes = {
|
|
|
73
73
|
|
|
74
74
|
/** Content alignment */
|
|
75
75
|
align: _propTypes.default.oneOf(["center", "left", "right"]),
|
|
76
|
+
|
|
77
|
+
/** Header content */
|
|
76
78
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
|
|
77
79
|
|
|
78
80
|
/** 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;
|
|
@@ -79,6 +79,8 @@ FlatTableRowHeader.propTypes = {
|
|
|
79
79
|
|
|
80
80
|
/** Content alignment */
|
|
81
81
|
align: _propTypes.default.oneOf(["center", "left", "right"]),
|
|
82
|
+
|
|
83
|
+
/** RowHeader content */
|
|
82
84
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
|
|
83
85
|
|
|
84
86
|
/** 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 {
|
|
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";
|
package/lib/components/simple-color-picker/{color-sample-box → simple-color}/checker-board.svg
RENAMED
|
File without changes
|
|
@@ -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;
|
|
@@ -3,21 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.SimpleColor = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
9
|
|
|
8
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
11
13
|
|
|
12
14
|
var _tags = _interopRequireDefault(require("../../../__internal__/utils/helpers/tags/tags"));
|
|
13
15
|
|
|
14
|
-
var _simpleColor =
|
|
16
|
+
var _simpleColor = require("./simple-color.style");
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
19
21
|
|
|
20
|
-
function
|
|
22
|
+
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; }
|
|
21
23
|
|
|
22
24
|
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); }
|
|
23
25
|
|
|
@@ -28,15 +30,18 @@ const SimpleColor = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
28
30
|
onMouseDown,
|
|
29
31
|
value,
|
|
30
32
|
name,
|
|
31
|
-
checked,
|
|
33
|
+
checked = false,
|
|
32
34
|
className,
|
|
35
|
+
id,
|
|
36
|
+
defaultChecked,
|
|
33
37
|
...rest
|
|
34
38
|
} = props;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const {
|
|
40
|
+
current: inputId
|
|
41
|
+
} = (0, _react.useRef)(id || (0, _guid.default)());
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_simpleColor.StyledSimpleColor, _extends({
|
|
38
43
|
className: className
|
|
39
|
-
}, (0, _tags.default)("simple-color", props)), /*#__PURE__*/_react.default.createElement(
|
|
44
|
+
}, (0, _tags.default)("simple-color", props)), /*#__PURE__*/_react.default.createElement(_simpleColor.StyledSimpleColorInput, _extends({
|
|
40
45
|
onChange: onChange,
|
|
41
46
|
onBlur: onBlur,
|
|
42
47
|
onMouseDown: onMouseDown,
|
|
@@ -46,38 +51,29 @@ const SimpleColor = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
46
51
|
role: "radio",
|
|
47
52
|
value: value,
|
|
48
53
|
"aria-checked": checked,
|
|
49
|
-
ref: ref
|
|
50
|
-
|
|
54
|
+
ref: ref,
|
|
55
|
+
id: inputId,
|
|
56
|
+
defaultChecked: defaultChecked
|
|
57
|
+
}, rest)), /*#__PURE__*/_react.default.createElement(_simpleColor.StyledColorSampleBox, {
|
|
58
|
+
color: value
|
|
59
|
+
}, checked && /*#__PURE__*/_react.default.createElement(_simpleColor.StyledTickIcon, {
|
|
51
60
|
color: value,
|
|
52
|
-
|
|
53
|
-
}));
|
|
61
|
+
type: "tick"
|
|
62
|
+
})));
|
|
54
63
|
});
|
|
55
64
|
|
|
56
|
-
SimpleColor
|
|
57
|
-
checked: false,
|
|
58
|
-
onChange: null
|
|
59
|
-
};
|
|
65
|
+
exports.SimpleColor = SimpleColor;
|
|
60
66
|
SimpleColor.propTypes = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
onChange: _propTypes.default.func,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
onBlur: _propTypes.default.func,
|
|
72
|
-
|
|
73
|
-
/** A callback triggered when a color is selected. */
|
|
74
|
-
onMouseDown: _propTypes.default.func,
|
|
75
|
-
|
|
76
|
-
/** determines if this color option is selected or unselected */
|
|
77
|
-
checked: _propTypes.default.bool,
|
|
78
|
-
|
|
79
|
-
/** [Legacy] Custom classname */
|
|
80
|
-
className: _propTypes.default.string
|
|
67
|
+
"checked": _propTypes.default.bool,
|
|
68
|
+
"className": _propTypes.default.string,
|
|
69
|
+
"defaultChecked": _propTypes.default.bool,
|
|
70
|
+
"disabled": _propTypes.default.bool,
|
|
71
|
+
"id": _propTypes.default.string,
|
|
72
|
+
"name": _propTypes.default.string,
|
|
73
|
+
"onBlur": _propTypes.default.func,
|
|
74
|
+
"onChange": _propTypes.default.func,
|
|
75
|
+
"onMouseDown": _propTypes.default.func,
|
|
76
|
+
"value": _propTypes.default.string.isRequired
|
|
81
77
|
};
|
|
82
78
|
SimpleColor.displayName = "SimpleColor";
|
|
83
79
|
var _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>;
|
|
@@ -3,12 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.StyledTickIcon = exports.StyledSimpleColorInput = exports.StyledColorSampleBox = exports.StyledSimpleColor = void 0;
|
|
7
7
|
|
|
8
|
-
var _styledComponents =
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _input = require("../../../__internal__/input");
|
|
11
|
+
|
|
12
|
+
var _checkerBoard = _interopRequireDefault(require("./checker-board.svg"));
|
|
13
|
+
|
|
14
|
+
var _icon = _interopRequireDefault(require("../../icon"));
|
|
15
|
+
|
|
16
|
+
var _getRgbValues = _interopRequireDefault(require("../../../style/utils/get-rgb-values"));
|
|
9
17
|
|
|
10
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
19
|
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
12
24
|
const StyledSimpleColor = _styledComponents.default.div`
|
|
13
25
|
width: var(--sizing700);
|
|
14
26
|
height: var(--sizing700);
|
|
@@ -19,5 +31,78 @@ const StyledSimpleColor = _styledComponents.default.div`
|
|
|
19
31
|
cursor: pointer;
|
|
20
32
|
}
|
|
21
33
|
`;
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
exports.StyledSimpleColor = StyledSimpleColor;
|
|
35
|
+
const StyledColorSampleBox = _styledComponents.default.div`
|
|
36
|
+
height: 100%;
|
|
37
|
+
width: 100%;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
border: 2px solid transparent;
|
|
43
|
+
|
|
44
|
+
${({
|
|
45
|
+
color
|
|
46
|
+
}) => color !== "transparent" && (0, _styledComponents.css)`
|
|
47
|
+
background-color: ${color};
|
|
48
|
+
`}
|
|
49
|
+
|
|
50
|
+
${({
|
|
51
|
+
color
|
|
52
|
+
}) => color === "transparent" && (0, _styledComponents.css)`
|
|
53
|
+
background-color: #eeeeee;
|
|
54
|
+
background-image: url(${_checkerBoard.default});
|
|
55
|
+
background-size: 14px 14px;
|
|
56
|
+
background-position: -2px -2px;
|
|
57
|
+
`}
|
|
58
|
+
`;
|
|
59
|
+
exports.StyledColorSampleBox = StyledColorSampleBox;
|
|
60
|
+
const StyledSimpleColorInput = (0, _styledComponents.default)(_input.Input)`
|
|
61
|
+
position: absolute;
|
|
62
|
+
opacity: 0;
|
|
63
|
+
height: var(--sizing700);
|
|
64
|
+
width: var(--sizing700);
|
|
65
|
+
margin: 0;
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:disabled:hover {
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:focus + ${StyledColorSampleBox} {
|
|
76
|
+
box-shadow: inset 0px 0px 0px var(--borderWidth200)
|
|
77
|
+
var(--colorsUtilityYang100);
|
|
78
|
+
border: 2px solid var(--colorsSemanticFocus500);
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
exports.StyledSimpleColorInput = StyledSimpleColorInput;
|
|
82
|
+
|
|
83
|
+
const getIconColor = color => {
|
|
84
|
+
const rgbValues = (0, _getRgbValues.default)(color);
|
|
85
|
+
const [r, g, b] = rgbValues; // color contrast calculating formula as per W3 suggestions
|
|
86
|
+
|
|
87
|
+
const redMultiplier = 299,
|
|
88
|
+
greenMultiplier = 587,
|
|
89
|
+
blueMultiplier = 114;
|
|
90
|
+
const contrast = (Math.round(r * redMultiplier) + Math.round(g * greenMultiplier) + Math.round(b * blueMultiplier)) / 1000;
|
|
91
|
+
if (contrast < 128) return "var(--colorsUtilityYang100)";
|
|
92
|
+
return "var(--colorsUtilityYin090)";
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const StyledTickIcon = (0, _styledComponents.default)(_icon.default)`
|
|
96
|
+
height: 22px;
|
|
97
|
+
width: 22px;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
display: block;
|
|
100
|
+
|
|
101
|
+
&::before {
|
|
102
|
+
font-size: 22px;
|
|
103
|
+
color: ${({
|
|
104
|
+
color
|
|
105
|
+
}) => getIconColor(color)};
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
exports.StyledTickIcon = StyledTickIcon;
|
|
@@ -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;
|