carbon-react 109.1.3 → 109.2.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/components/badge/badge.style.d.ts +1 -4
- package/esm/components/button/button.component.d.ts +1 -4
- package/esm/components/button/button.component.js +26 -12
- package/esm/components/duelling-picklist/picklist-group/picklist-group.style.js +2 -2
- package/esm/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
- package/esm/components/multi-action-button/multi-action-button.component.js +1 -6
- package/esm/components/pill/index.d.ts +2 -1
- package/esm/components/pill/pill.component.d.ts +22 -0
- package/esm/components/pill/pill.component.js +219 -42
- package/esm/components/pill/pill.style.config.d.ts +18 -0
- package/esm/components/pill/pill.style.d.ts +22 -0
- package/esm/components/pill/pill.style.js +23 -22
- package/esm/components/search/search.style.js +22 -8
- package/esm/components/select/multi-select/multi-select.component.js +7 -2
- package/esm/components/select/multi-select/multi-select.d.ts +2 -0
- package/esm/components/select/multi-select/multi-select.style.js +1 -0
- package/esm/components/split-button/split-button.component.js +1 -6
- package/lib/components/badge/badge.style.d.ts +1 -4
- package/lib/components/button/button.component.d.ts +1 -4
- package/lib/components/button/button.component.js +29 -10
- package/lib/components/duelling-picklist/picklist-group/picklist-group.style.js +4 -2
- package/lib/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
- package/lib/components/multi-action-button/multi-action-button.component.js +1 -6
- package/lib/components/pill/index.d.ts +2 -1
- package/lib/components/pill/pill.component.d.ts +22 -0
- package/lib/components/pill/pill.component.js +220 -46
- package/lib/components/pill/pill.style.config.d.ts +18 -0
- package/lib/components/pill/pill.style.d.ts +22 -0
- package/lib/components/pill/pill.style.js +23 -23
- package/lib/components/search/search.style.js +22 -8
- package/lib/components/select/multi-select/multi-select.component.js +7 -2
- package/lib/components/select/multi-select/multi-select.d.ts +2 -0
- package/lib/components/select/multi-select/multi-select.style.js +1 -0
- package/lib/components/split-button/split-button.component.js +1 -6
- package/package.json +4 -4
- package/esm/components/pill/pill.d.ts +0 -24
- package/lib/components/pill/pill.d.ts +0 -24
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _polished = require("polished");
|
|
13
11
|
|
|
14
12
|
var _styledSystem = require("styled-system");
|
|
@@ -39,19 +37,20 @@ function addStyleToPillIcon(fontSize) {
|
|
|
39
37
|
`;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
const
|
|
43
|
-
${_styledSystem.margin}
|
|
40
|
+
const StyledPill = _styledComponents.default.span`
|
|
41
|
+
${_styledSystem.margin}
|
|
44
42
|
${({
|
|
45
|
-
|
|
43
|
+
wrapText,
|
|
46
44
|
borderColor,
|
|
47
|
-
|
|
48
|
-
inFill,
|
|
45
|
+
colorVariant,
|
|
49
46
|
isDeletable,
|
|
47
|
+
inFill,
|
|
48
|
+
maxWidth,
|
|
50
49
|
pillRole,
|
|
51
|
-
size
|
|
50
|
+
size,
|
|
51
|
+
theme
|
|
52
52
|
}) => {
|
|
53
53
|
const isStatus = pillRole === "status";
|
|
54
|
-
const variety = isStatus ? colorVariant : "primary";
|
|
55
54
|
let pillColor;
|
|
56
55
|
let buttonFocusColor;
|
|
57
56
|
let contentColor;
|
|
@@ -62,11 +61,15 @@ const PillStyle = _styledComponents.default.span`
|
|
|
62
61
|
buttonFocusColor = (0, _polished.shade)(0.2, (0, _getColorValue.default)(pillColor));
|
|
63
62
|
contentColor = (0, _polished.meetsContrastGuidelines)((0, _getColorValue.default)(pillColor), theme.compatibility.colorsUtilityYin090).AAA ? "var(--colorsUtilityYin090)" : "var(--colorsUtilityYang100)";
|
|
64
63
|
} else {
|
|
64
|
+
const {
|
|
65
|
+
status,
|
|
66
|
+
tag
|
|
67
|
+
} = (0, _pillStyle.default)();
|
|
65
68
|
const {
|
|
66
69
|
varietyColor,
|
|
67
70
|
buttonFocus,
|
|
68
71
|
content
|
|
69
|
-
} =
|
|
72
|
+
} = isStatus ? status[colorVariant] : tag.primary;
|
|
70
73
|
pillColor = varietyColor;
|
|
71
74
|
buttonFocusColor = buttonFocus;
|
|
72
75
|
contentColor = content;
|
|
@@ -88,7 +91,13 @@ const PillStyle = _styledComponents.default.span`
|
|
|
88
91
|
justify-content: center;
|
|
89
92
|
border: 2px solid ${pillColor};
|
|
90
93
|
height: auto;
|
|
91
|
-
|
|
94
|
+
${!wrapText && (0, _styledComponents.css)`
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
`}
|
|
97
|
+
${wrapText && (0, _styledComponents.css)`
|
|
98
|
+
white-space: break-spaces;
|
|
99
|
+
hyphens: auto;
|
|
100
|
+
`}
|
|
92
101
|
color: ${contentColor};
|
|
93
102
|
|
|
94
103
|
${inFill && (0, _styledComponents.css)`
|
|
@@ -278,23 +287,14 @@ const PillStyle = _styledComponents.default.span`
|
|
|
278
287
|
}
|
|
279
288
|
`}
|
|
280
289
|
`}
|
|
290
|
+
${maxWidth && `max-width: ${maxWidth}`}
|
|
281
291
|
`;
|
|
282
292
|
}}
|
|
283
293
|
`;
|
|
284
|
-
|
|
294
|
+
StyledPill.defaultProps = {
|
|
285
295
|
inFill: false,
|
|
286
|
-
colorVariant: "default",
|
|
287
296
|
isDeletable: false,
|
|
288
297
|
theme: _themes.baseTheme
|
|
289
298
|
};
|
|
290
|
-
|
|
291
|
-
inFill: _propTypes.default.bool,
|
|
292
|
-
colorVariant: _propTypes.default.oneOf(["neutral", "negative", "positive", "warning"]),
|
|
293
|
-
isDeletable: _propTypes.default.func,
|
|
294
|
-
size: _propTypes.default.oneOf(["S", "M", "L", "XL"]),
|
|
295
|
-
pillRole: _propTypes.default.oneOf(["tag", "status"]),
|
|
296
|
-
borderColor: _propTypes.default.string,
|
|
297
|
-
theme: _propTypes.default.object
|
|
298
|
-
};
|
|
299
|
-
var _default = PillStyle;
|
|
299
|
+
var _default = StyledPill;
|
|
300
300
|
exports.default = _default;
|
|
@@ -119,20 +119,34 @@ const StyledSearch = _styledComponents.default.div`
|
|
|
119
119
|
z-index: ${theme.zIndex.smallOverlay};
|
|
120
120
|
}
|
|
121
121
|
${_icon.default} {
|
|
122
|
-
|
|
122
|
+
${darkVariant && (0, _styledComponents.css)`
|
|
123
|
+
${iconColor && (0, _styledComponents.css)`
|
|
124
|
+
color: var(--colorsUtilityMajor400);
|
|
125
|
+
|
|
126
|
+
:hover {
|
|
127
|
+
color: var(--colorsUtilityMajor500);
|
|
128
|
+
}
|
|
129
|
+
`}
|
|
130
|
+
${!iconColor && (0, _styledComponents.css)`
|
|
131
|
+
color: var(--colorsUtilityMajor200);
|
|
132
|
+
|
|
133
|
+
:hover {
|
|
134
|
+
color: var(--colorsUtilityMajor100);
|
|
135
|
+
}
|
|
136
|
+
`}
|
|
137
|
+
`}
|
|
138
|
+
|
|
123
139
|
${!darkVariant && (0, _styledComponents.css)`
|
|
124
|
-
color: var(--
|
|
140
|
+
color: var(--colorsActionMinor500);
|
|
141
|
+
|
|
142
|
+
:hover {
|
|
143
|
+
color: var(--colorsActionMinor600);
|
|
144
|
+
}
|
|
125
145
|
`}
|
|
126
146
|
|
|
127
147
|
width: 20px;
|
|
128
148
|
height: 20px;
|
|
129
149
|
cursor: pointer;
|
|
130
|
-
:hover {
|
|
131
|
-
color: ${iconColor ? "var(--colorsUtilityMajor500)" : "var(--colorsUtilityMajor100)"};
|
|
132
|
-
${!darkVariant && (0, _styledComponents.css)`
|
|
133
|
-
color: var(--colorsUtilityMajor500);
|
|
134
|
-
`}
|
|
135
|
-
}
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
${_inputIconToggle.default} {
|
|
@@ -70,6 +70,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
70
70
|
"data-role": dataRole,
|
|
71
71
|
listPlacement = "bottom-start",
|
|
72
72
|
flipEnabled = true,
|
|
73
|
+
wrapPillText = true,
|
|
73
74
|
...textboxProps
|
|
74
75
|
}, inputRef) => {
|
|
75
76
|
const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
|
|
@@ -220,7 +221,8 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
220
221
|
return /*#__PURE__*/_react.default.createElement(_multiSelect.StyledSelectPillContainer, {
|
|
221
222
|
key: key
|
|
222
223
|
}, /*#__PURE__*/_react.default.createElement(_pill.default, _extends({
|
|
223
|
-
onDelete: canDelete ? () => removeSelectedValue(index) : undefined
|
|
224
|
+
onDelete: canDelete ? () => removeSelectedValue(index) : undefined,
|
|
225
|
+
wrapText: wrapPillText
|
|
224
226
|
}, pillProps), title));
|
|
225
227
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
226
228
|
}, [children, disabled, readOnly, selectedValue]);
|
|
@@ -530,7 +532,10 @@ MultiSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
|
|
|
530
532
|
listPlacement: _propTypes.default.oneOf(["auto", "auto-start", "auto-end", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"]),
|
|
531
533
|
|
|
532
534
|
/** Use the opposite list placement if the set placement does not fit */
|
|
533
|
-
flipEnabled: _propTypes.default.bool
|
|
535
|
+
flipEnabled: _propTypes.default.bool,
|
|
536
|
+
|
|
537
|
+
/** Wraps the pill text when it would overflow the input width */
|
|
538
|
+
wrapPillText: _propTypes.default.bool
|
|
534
539
|
};
|
|
535
540
|
MultiSelect.defaultProps = {
|
|
536
541
|
"data-component": "multiselect"
|
|
@@ -58,6 +58,8 @@ export interface MultiSelectProps
|
|
|
58
58
|
| "left-end";
|
|
59
59
|
/** Use the opposite list placement if the set placement does not fit */
|
|
60
60
|
flipEnabled?: bool;
|
|
61
|
+
/** Wraps the pill text when it would overflow the input width */
|
|
62
|
+
wrapPillText?: boolean;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
declare function MultiSelect(
|
|
@@ -17,7 +17,7 @@ var _useClickAwayListener = _interopRequireDefault(require("../../hooks/__intern
|
|
|
17
17
|
|
|
18
18
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
19
19
|
|
|
20
|
-
var _button =
|
|
20
|
+
var _button = _interopRequireDefault(require("../button"));
|
|
21
21
|
|
|
22
22
|
var _splitButton = _interopRequireDefault(require("./split-button.style"));
|
|
23
23
|
|
|
@@ -249,11 +249,6 @@ const SplitButton = ({
|
|
|
249
249
|
(_toggleButton$current = toggleButton.current) === null || _toggleButton$current === void 0 ? void 0 : _toggleButton$current.focus();
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
|
|
253
|
-
if (child.type === _button.default) {
|
|
254
|
-
return /*#__PURE__*/_react.default.createElement(_button.ButtonWithForwardRef, _extends({}, child.props, childProps));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
252
|
return /*#__PURE__*/_react.default.cloneElement(child, childProps);
|
|
258
253
|
});
|
|
259
254
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "109.
|
|
3
|
+
"version": "109.2.2",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts/check_rfcs.js"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"start": "node ./scripts/check_node_version.js && start-storybook -p 9001 -
|
|
17
|
+
"start": "node ./scripts/check_node_version.js && start-storybook -p 9001 -c .storybook",
|
|
18
18
|
"start:debug-theme": "cross-env STORYBOOK_DEBUG_THEME=true npm run start",
|
|
19
19
|
"test": "jest --config=./jest.conf.json",
|
|
20
20
|
"test-update": "jest --config=./jest.conf.json --updateSnapshot",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"prepublishOnly": "npm run precompile",
|
|
30
30
|
"postinstall": "node ./scripts/check_carbon_version.js && node ./scripts/check_rfcs.js",
|
|
31
31
|
"watch": "npm run clean-lib && npm run copy-files -- --watch & npm run babel -- --watch",
|
|
32
|
-
"build-storybook": "cross-env STORYBOOK_BUILD=true build-storybook -c .storybook
|
|
33
|
-
"start-storybook": "cross-env STORYBOOK_BUILD=true start-storybook -c .storybook
|
|
32
|
+
"build-storybook": "cross-env STORYBOOK_BUILD=true build-storybook -c .storybook",
|
|
33
|
+
"start-storybook": "cross-env STORYBOOK_BUILD=true start-storybook -c .storybook",
|
|
34
34
|
"start:static": "npx http-server -p 9001 ./storybook-static",
|
|
35
35
|
"babel": "cross-env NODE_ENV=production babel ./src --config-file ./babel.config.js --out-dir ./lib --ignore '**/*/__spec__.js','**/*.spec.js','**/*.spec.ts','**/*.spec.tsx','**/*.test.js','**/*.d.ts' --quiet --extensions '.js','.ts','.tsx'",
|
|
36
36
|
"clean-lib": "rimraf ./lib && rimraf ./esm",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { MarginProps } from "styled-system";
|
|
3
|
-
|
|
4
|
-
export interface PillProps extends MarginProps {
|
|
5
|
-
/** Override color variant, provide any color from palette or any valid css color value. */
|
|
6
|
-
borderColor?: string;
|
|
7
|
-
/** Change the color of a status pill. */
|
|
8
|
-
colorVariant?: "neutral" | "negative" | "positive" | "warning";
|
|
9
|
-
/** The content to display inside of the pill. */
|
|
10
|
-
children: string;
|
|
11
|
-
/** Fills the pill background with colour. When fill is false only the border is coloured. */
|
|
12
|
-
fill?: boolean;
|
|
13
|
-
/** Callback function for when the pill is clicked. */
|
|
14
|
-
onClick?: React.MouseEventHandler<HTMLSpanElement>;
|
|
15
|
-
/** Callback function for when the remove icon is clicked. */
|
|
16
|
-
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
17
|
-
/** Sets the type of pill in use. */
|
|
18
|
-
pillRole?: "tag" | "status";
|
|
19
|
-
size?: "S" | "M" | "L" | "XL";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare function Pill(props: PillProps): JSX.Element;
|
|
23
|
-
|
|
24
|
-
export default Pill;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { MarginProps } from "styled-system";
|
|
3
|
-
|
|
4
|
-
export interface PillProps extends MarginProps {
|
|
5
|
-
/** Override color variant, provide any color from palette or any valid css color value. */
|
|
6
|
-
borderColor?: string;
|
|
7
|
-
/** Change the color of a status pill. */
|
|
8
|
-
colorVariant?: "neutral" | "negative" | "positive" | "warning";
|
|
9
|
-
/** The content to display inside of the pill. */
|
|
10
|
-
children: string;
|
|
11
|
-
/** Fills the pill background with colour. When fill is false only the border is coloured. */
|
|
12
|
-
fill?: boolean;
|
|
13
|
-
/** Callback function for when the pill is clicked. */
|
|
14
|
-
onClick?: React.MouseEventHandler<HTMLSpanElement>;
|
|
15
|
-
/** Callback function for when the remove icon is clicked. */
|
|
16
|
-
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
17
|
-
/** Sets the type of pill in use. */
|
|
18
|
-
pillRole?: "tag" | "status";
|
|
19
|
-
size?: "S" | "M" | "L" | "XL";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare function Pill(props: PillProps): JSX.Element;
|
|
23
|
-
|
|
24
|
-
export default Pill;
|