carbon-react 109.1.3 → 109.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/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/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/package.json +4 -4
- package/esm/components/pill/pill.d.ts +0 -24
- package/lib/components/pill/pill.d.ts +0 -24
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./pill";
|
|
1
|
+
export { default } from "./pill.component";
|
|
2
|
+
export type { PillProps } from "./pill.component";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledPillProps } from "./pill.style";
|
|
3
|
+
export interface PillProps extends StyledPillProps {
|
|
4
|
+
/** The content to display inside of the pill. */
|
|
5
|
+
children: string;
|
|
6
|
+
/** Change the color of a status pill. */
|
|
7
|
+
colorVariant?: "neutral" | "negative" | "positive" | "warning";
|
|
8
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
9
|
+
"data-element"?: string;
|
|
10
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
11
|
+
"data-role"?: string;
|
|
12
|
+
/** Fills the pill background with colour. When fill is false only the border is coloured. */
|
|
13
|
+
fill?: boolean;
|
|
14
|
+
/** Callback function for when the pill is clicked. */
|
|
15
|
+
onClick?: React.MouseEventHandler<HTMLSpanElement>;
|
|
16
|
+
/** Callback function for when the remove icon is clicked. */
|
|
17
|
+
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
18
|
+
/** Sets the type of pill in use. */
|
|
19
|
+
pillRole?: "tag" | "status";
|
|
20
|
+
}
|
|
21
|
+
export declare const Pill: ({ wrapText, borderColor, colorVariant, children, fill, maxWidth, onClick, onDelete, pillRole, size, ...rest }: PillProps) => JSX.Element;
|
|
22
|
+
export default Pill;
|
|
@@ -2,13 +2,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
5
|
import StyledPill from "./pill.style";
|
|
7
6
|
import Icon from "../icon";
|
|
8
7
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
9
8
|
import IconButton from "../icon-button";
|
|
10
|
-
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
11
|
-
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
12
9
|
|
|
13
10
|
const renderCloseIcon = onDelete => /*#__PURE__*/React.createElement(IconButton, {
|
|
14
11
|
onAction: onDelete,
|
|
@@ -19,57 +16,237 @@ const renderCloseIcon = onDelete => /*#__PURE__*/React.createElement(IconButton,
|
|
|
19
16
|
}));
|
|
20
17
|
|
|
21
18
|
const Pill = ({
|
|
22
|
-
|
|
23
|
-
onDelete,
|
|
24
|
-
colorVariant,
|
|
19
|
+
wrapText,
|
|
25
20
|
borderColor,
|
|
26
|
-
|
|
21
|
+
colorVariant = "neutral",
|
|
27
22
|
children,
|
|
28
|
-
|
|
23
|
+
fill = false,
|
|
24
|
+
maxWidth,
|
|
29
25
|
onClick,
|
|
26
|
+
onDelete,
|
|
27
|
+
pillRole = "tag",
|
|
28
|
+
size = "M",
|
|
30
29
|
...rest
|
|
31
30
|
}) => /*#__PURE__*/React.createElement(StyledPill, _extends({
|
|
32
31
|
inFill: fill,
|
|
33
32
|
colorVariant: colorVariant,
|
|
34
|
-
isDeletable: onDelete,
|
|
33
|
+
isDeletable: !!onDelete,
|
|
35
34
|
pillRole: pillRole,
|
|
36
35
|
size: size,
|
|
37
36
|
borderColor: borderColor,
|
|
38
37
|
onClick: onClick
|
|
39
|
-
}, tagComponent("pill", rest),
|
|
38
|
+
}, tagComponent("pill", rest), {
|
|
39
|
+
maxWidth: maxWidth,
|
|
40
|
+
wrapText: wrapText
|
|
41
|
+
}, rest), children, onDelete && renderCloseIcon(onDelete));
|
|
40
42
|
|
|
41
43
|
Pill.propTypes = {
|
|
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
|
-
|
|
44
|
+
"borderColor": PropTypes.string,
|
|
45
|
+
"children": PropTypes.string.isRequired,
|
|
46
|
+
"colorVariant": PropTypes.oneOf(["negative", "neutral", "positive", "warning"]),
|
|
47
|
+
"data-element": PropTypes.string,
|
|
48
|
+
"data-role": PropTypes.string,
|
|
49
|
+
"fill": PropTypes.bool,
|
|
50
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
51
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
52
|
+
"description": PropTypes.string,
|
|
53
|
+
"toString": PropTypes.func.isRequired,
|
|
54
|
+
"valueOf": PropTypes.func.isRequired
|
|
55
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
56
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
57
|
+
"description": PropTypes.string,
|
|
58
|
+
"toString": PropTypes.func.isRequired,
|
|
59
|
+
"valueOf": PropTypes.func.isRequired
|
|
60
|
+
}), PropTypes.string]),
|
|
61
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
62
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
63
|
+
"description": PropTypes.string,
|
|
64
|
+
"toString": PropTypes.func.isRequired,
|
|
65
|
+
"valueOf": PropTypes.func.isRequired
|
|
66
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
67
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
68
|
+
"description": PropTypes.string,
|
|
69
|
+
"toString": PropTypes.func.isRequired,
|
|
70
|
+
"valueOf": PropTypes.func.isRequired
|
|
71
|
+
}), PropTypes.string]),
|
|
72
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
73
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
74
|
+
"description": PropTypes.string,
|
|
75
|
+
"toString": PropTypes.func.isRequired,
|
|
76
|
+
"valueOf": PropTypes.func.isRequired
|
|
77
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
78
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
79
|
+
"description": PropTypes.string,
|
|
80
|
+
"toString": PropTypes.func.isRequired,
|
|
81
|
+
"valueOf": PropTypes.func.isRequired
|
|
82
|
+
}), PropTypes.string]),
|
|
83
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
84
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
85
|
+
"description": PropTypes.string,
|
|
86
|
+
"toString": PropTypes.func.isRequired,
|
|
87
|
+
"valueOf": PropTypes.func.isRequired
|
|
88
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
89
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
90
|
+
"description": PropTypes.string,
|
|
91
|
+
"toString": PropTypes.func.isRequired,
|
|
92
|
+
"valueOf": PropTypes.func.isRequired
|
|
93
|
+
}), PropTypes.string]),
|
|
94
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
95
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
96
|
+
"description": PropTypes.string,
|
|
97
|
+
"toString": PropTypes.func.isRequired,
|
|
98
|
+
"valueOf": PropTypes.func.isRequired
|
|
99
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
100
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
101
|
+
"description": PropTypes.string,
|
|
102
|
+
"toString": PropTypes.func.isRequired,
|
|
103
|
+
"valueOf": PropTypes.func.isRequired
|
|
104
|
+
}), PropTypes.string]),
|
|
105
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
106
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
107
|
+
"description": PropTypes.string,
|
|
108
|
+
"toString": PropTypes.func.isRequired,
|
|
109
|
+
"valueOf": PropTypes.func.isRequired
|
|
110
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
111
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
112
|
+
"description": PropTypes.string,
|
|
113
|
+
"toString": PropTypes.func.isRequired,
|
|
114
|
+
"valueOf": PropTypes.func.isRequired
|
|
115
|
+
}), PropTypes.string]),
|
|
116
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
117
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
118
|
+
"description": PropTypes.string,
|
|
119
|
+
"toString": PropTypes.func.isRequired,
|
|
120
|
+
"valueOf": PropTypes.func.isRequired
|
|
121
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
122
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
123
|
+
"description": PropTypes.string,
|
|
124
|
+
"toString": PropTypes.func.isRequired,
|
|
125
|
+
"valueOf": PropTypes.func.isRequired
|
|
126
|
+
}), PropTypes.string]),
|
|
127
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
128
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
129
|
+
"description": PropTypes.string,
|
|
130
|
+
"toString": PropTypes.func.isRequired,
|
|
131
|
+
"valueOf": PropTypes.func.isRequired
|
|
132
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
133
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
134
|
+
"description": PropTypes.string,
|
|
135
|
+
"toString": PropTypes.func.isRequired,
|
|
136
|
+
"valueOf": PropTypes.func.isRequired
|
|
137
|
+
}), PropTypes.string]),
|
|
138
|
+
"maxWidth": PropTypes.string,
|
|
139
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
140
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
141
|
+
"description": PropTypes.string,
|
|
142
|
+
"toString": PropTypes.func.isRequired,
|
|
143
|
+
"valueOf": PropTypes.func.isRequired
|
|
144
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
145
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
146
|
+
"description": PropTypes.string,
|
|
147
|
+
"toString": PropTypes.func.isRequired,
|
|
148
|
+
"valueOf": PropTypes.func.isRequired
|
|
149
|
+
}), PropTypes.string]),
|
|
150
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
151
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
152
|
+
"description": PropTypes.string,
|
|
153
|
+
"toString": PropTypes.func.isRequired,
|
|
154
|
+
"valueOf": PropTypes.func.isRequired
|
|
155
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
156
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
157
|
+
"description": PropTypes.string,
|
|
158
|
+
"toString": PropTypes.func.isRequired,
|
|
159
|
+
"valueOf": PropTypes.func.isRequired
|
|
160
|
+
}), PropTypes.string]),
|
|
161
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
162
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
163
|
+
"description": PropTypes.string,
|
|
164
|
+
"toString": PropTypes.func.isRequired,
|
|
165
|
+
"valueOf": PropTypes.func.isRequired
|
|
166
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
167
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
168
|
+
"description": PropTypes.string,
|
|
169
|
+
"toString": PropTypes.func.isRequired,
|
|
170
|
+
"valueOf": PropTypes.func.isRequired
|
|
171
|
+
}), PropTypes.string]),
|
|
172
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
173
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
174
|
+
"description": PropTypes.string,
|
|
175
|
+
"toString": PropTypes.func.isRequired,
|
|
176
|
+
"valueOf": PropTypes.func.isRequired
|
|
177
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
178
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
179
|
+
"description": PropTypes.string,
|
|
180
|
+
"toString": PropTypes.func.isRequired,
|
|
181
|
+
"valueOf": PropTypes.func.isRequired
|
|
182
|
+
}), PropTypes.string]),
|
|
183
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
184
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
185
|
+
"description": PropTypes.string,
|
|
186
|
+
"toString": PropTypes.func.isRequired,
|
|
187
|
+
"valueOf": PropTypes.func.isRequired
|
|
188
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
189
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
190
|
+
"description": PropTypes.string,
|
|
191
|
+
"toString": PropTypes.func.isRequired,
|
|
192
|
+
"valueOf": PropTypes.func.isRequired
|
|
193
|
+
}), PropTypes.string]),
|
|
194
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
195
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
196
|
+
"description": PropTypes.string,
|
|
197
|
+
"toString": PropTypes.func.isRequired,
|
|
198
|
+
"valueOf": PropTypes.func.isRequired
|
|
199
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
200
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
201
|
+
"description": PropTypes.string,
|
|
202
|
+
"toString": PropTypes.func.isRequired,
|
|
203
|
+
"valueOf": PropTypes.func.isRequired
|
|
204
|
+
}), PropTypes.string]),
|
|
205
|
+
"onClick": PropTypes.func,
|
|
206
|
+
"onDelete": PropTypes.func,
|
|
207
|
+
"pillRole": PropTypes.oneOf(["status", "tag"]),
|
|
208
|
+
"size": PropTypes.oneOf(["L", "M", "S", "XL"]),
|
|
209
|
+
"theme": PropTypes.shape({
|
|
210
|
+
"colors": PropTypes.shape({
|
|
211
|
+
"destructive": PropTypes.shape({
|
|
212
|
+
"hover": PropTypes.string.isRequired
|
|
213
|
+
}),
|
|
214
|
+
"error": PropTypes.string,
|
|
215
|
+
"focus": PropTypes.string,
|
|
216
|
+
"info": PropTypes.string,
|
|
217
|
+
"loadingBarBackground": PropTypes.string,
|
|
218
|
+
"placeholder": PropTypes.string,
|
|
219
|
+
"primary": PropTypes.string,
|
|
220
|
+
"secondary": PropTypes.string,
|
|
221
|
+
"tertiary": PropTypes.string,
|
|
222
|
+
"warning": PropTypes.string,
|
|
223
|
+
"warningText": PropTypes.string,
|
|
224
|
+
"white": PropTypes.oneOf(["#FFFFFF"])
|
|
225
|
+
}),
|
|
226
|
+
"compatibility": PropTypes.object,
|
|
227
|
+
"disabled": PropTypes.shape({
|
|
228
|
+
"background": PropTypes.string.isRequired
|
|
229
|
+
}),
|
|
230
|
+
"name": PropTypes.string,
|
|
231
|
+
"palette": PropTypes.shape({
|
|
232
|
+
"blackOpacity": PropTypes.func.isRequired,
|
|
233
|
+
"whiteOpacity": PropTypes.func.isRequired
|
|
234
|
+
}),
|
|
235
|
+
"space": PropTypes.arrayOf(PropTypes.string),
|
|
236
|
+
"spacing": PropTypes.number,
|
|
237
|
+
"zIndex": PropTypes.shape({
|
|
238
|
+
"aboveAll": PropTypes.number.isRequired,
|
|
239
|
+
"fullScreenModal": PropTypes.number.isRequired,
|
|
240
|
+
"header": PropTypes.number.isRequired,
|
|
241
|
+
"modal": PropTypes.number.isRequired,
|
|
242
|
+
"nav": PropTypes.number.isRequired,
|
|
243
|
+
"notification": PropTypes.number.isRequired,
|
|
244
|
+
"overlay": PropTypes.number.isRequired,
|
|
245
|
+
"popover": PropTypes.number.isRequired,
|
|
246
|
+
"smallOverlay": PropTypes.number.isRequired
|
|
247
|
+
})
|
|
248
|
+
}),
|
|
249
|
+
"wrapText": PropTypes.bool
|
|
74
250
|
};
|
|
251
|
+
export { Pill };
|
|
75
252
|
export default Pill;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface StyledPillInnerConfigProps {
|
|
2
|
+
varietyColor: string;
|
|
3
|
+
buttonFocus: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
interface StyledPillConfig {
|
|
7
|
+
status: {
|
|
8
|
+
neutral: StyledPillInnerConfigProps;
|
|
9
|
+
negative: StyledPillInnerConfigProps;
|
|
10
|
+
warning: StyledPillInnerConfigProps;
|
|
11
|
+
positive: StyledPillInnerConfigProps;
|
|
12
|
+
};
|
|
13
|
+
tag: {
|
|
14
|
+
primary: StyledPillInnerConfigProps;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
declare const _default: () => StyledPillConfig;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MarginProps } from "styled-system";
|
|
2
|
+
import { ThemeObject } from "../../style/themes/base/base-theme.config";
|
|
3
|
+
export interface StyledPillProps extends MarginProps {
|
|
4
|
+
/** Override color variant, provide any color from palette or any valid css color value. */
|
|
5
|
+
borderColor?: string;
|
|
6
|
+
/** Sets the max-width of the pill. */
|
|
7
|
+
maxWidth?: string;
|
|
8
|
+
/** Sets the size of the pill. */
|
|
9
|
+
size?: "S" | "M" | "L" | "XL";
|
|
10
|
+
/** @private @ignore */
|
|
11
|
+
theme?: Partial<ThemeObject>;
|
|
12
|
+
/** Allow the text within pill to wrap. */
|
|
13
|
+
wrapText?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface AllStyledPillProps extends StyledPillProps {
|
|
16
|
+
inFill?: boolean;
|
|
17
|
+
isDeletable: boolean;
|
|
18
|
+
colorVariant: "neutral" | "negative" | "positive" | "warning";
|
|
19
|
+
pillRole: "tag" | "status";
|
|
20
|
+
}
|
|
21
|
+
declare const StyledPill: import("styled-components").StyledComponent<"span", any, AllStyledPillProps, never>;
|
|
22
|
+
export default StyledPill;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { shade, meetsContrastGuidelines } from "polished";
|
|
4
3
|
import { margin } from "styled-system";
|
|
5
4
|
import styleConfig from "./pill.style.config";
|
|
@@ -18,19 +17,20 @@ function addStyleToPillIcon(fontSize) {
|
|
|
18
17
|
`;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
${margin}
|
|
20
|
+
const StyledPill = styled.span`
|
|
21
|
+
${margin}
|
|
23
22
|
${({
|
|
24
|
-
|
|
23
|
+
wrapText,
|
|
25
24
|
borderColor,
|
|
26
|
-
|
|
27
|
-
inFill,
|
|
25
|
+
colorVariant,
|
|
28
26
|
isDeletable,
|
|
27
|
+
inFill,
|
|
28
|
+
maxWidth,
|
|
29
29
|
pillRole,
|
|
30
|
-
size
|
|
30
|
+
size,
|
|
31
|
+
theme
|
|
31
32
|
}) => {
|
|
32
33
|
const isStatus = pillRole === "status";
|
|
33
|
-
const variety = isStatus ? colorVariant : "primary";
|
|
34
34
|
let pillColor;
|
|
35
35
|
let buttonFocusColor;
|
|
36
36
|
let contentColor;
|
|
@@ -41,11 +41,15 @@ const PillStyle = styled.span`
|
|
|
41
41
|
buttonFocusColor = shade(0.2, getColorValue(pillColor));
|
|
42
42
|
contentColor = meetsContrastGuidelines(getColorValue(pillColor), theme.compatibility.colorsUtilityYin090).AAA ? "var(--colorsUtilityYin090)" : "var(--colorsUtilityYang100)";
|
|
43
43
|
} else {
|
|
44
|
+
const {
|
|
45
|
+
status,
|
|
46
|
+
tag
|
|
47
|
+
} = styleConfig();
|
|
44
48
|
const {
|
|
45
49
|
varietyColor,
|
|
46
50
|
buttonFocus,
|
|
47
51
|
content
|
|
48
|
-
} =
|
|
52
|
+
} = isStatus ? status[colorVariant] : tag.primary;
|
|
49
53
|
pillColor = varietyColor;
|
|
50
54
|
buttonFocusColor = buttonFocus;
|
|
51
55
|
contentColor = content;
|
|
@@ -67,7 +71,13 @@ const PillStyle = styled.span`
|
|
|
67
71
|
justify-content: center;
|
|
68
72
|
border: 2px solid ${pillColor};
|
|
69
73
|
height: auto;
|
|
70
|
-
|
|
74
|
+
${!wrapText && css`
|
|
75
|
+
white-space: nowrap;
|
|
76
|
+
`}
|
|
77
|
+
${wrapText && css`
|
|
78
|
+
white-space: break-spaces;
|
|
79
|
+
hyphens: auto;
|
|
80
|
+
`}
|
|
71
81
|
color: ${contentColor};
|
|
72
82
|
|
|
73
83
|
${inFill && css`
|
|
@@ -257,22 +267,13 @@ const PillStyle = styled.span`
|
|
|
257
267
|
}
|
|
258
268
|
`}
|
|
259
269
|
`}
|
|
270
|
+
${maxWidth && `max-width: ${maxWidth}`}
|
|
260
271
|
`;
|
|
261
272
|
}}
|
|
262
273
|
`;
|
|
263
|
-
|
|
274
|
+
StyledPill.defaultProps = {
|
|
264
275
|
inFill: false,
|
|
265
|
-
colorVariant: "default",
|
|
266
276
|
isDeletable: false,
|
|
267
277
|
theme: baseTheme
|
|
268
278
|
};
|
|
269
|
-
|
|
270
|
-
inFill: PropTypes.bool,
|
|
271
|
-
colorVariant: PropTypes.oneOf(["neutral", "negative", "positive", "warning"]),
|
|
272
|
-
isDeletable: PropTypes.func,
|
|
273
|
-
size: PropTypes.oneOf(["S", "M", "L", "XL"]),
|
|
274
|
-
pillRole: PropTypes.oneOf(["tag", "status"]),
|
|
275
|
-
borderColor: PropTypes.string,
|
|
276
|
-
theme: PropTypes.object
|
|
277
|
-
};
|
|
278
|
-
export default PillStyle;
|
|
279
|
+
export default StyledPill;
|
|
@@ -43,6 +43,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
43
43
|
"data-role": dataRole,
|
|
44
44
|
listPlacement = "bottom-start",
|
|
45
45
|
flipEnabled = true,
|
|
46
|
+
wrapPillText = true,
|
|
46
47
|
...textboxProps
|
|
47
48
|
}, inputRef) => {
|
|
48
49
|
const [activeDescendantId, setActiveDescendantId] = useState();
|
|
@@ -192,7 +193,8 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
192
193
|
return /*#__PURE__*/React.createElement(StyledSelectPillContainer, {
|
|
193
194
|
key: key
|
|
194
195
|
}, /*#__PURE__*/React.createElement(Pill, _extends({
|
|
195
|
-
onDelete: canDelete ? () => removeSelectedValue(index) : undefined
|
|
196
|
+
onDelete: canDelete ? () => removeSelectedValue(index) : undefined,
|
|
197
|
+
wrapText: wrapPillText
|
|
196
198
|
}, pillProps), title));
|
|
197
199
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
198
200
|
}, [children, disabled, readOnly, selectedValue]);
|
|
@@ -500,7 +502,10 @@ MultiSelect.propTypes = { ...formInputPropTypes,
|
|
|
500
502
|
listPlacement: PropTypes.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"]),
|
|
501
503
|
|
|
502
504
|
/** Use the opposite list placement if the set placement does not fit */
|
|
503
|
-
flipEnabled: PropTypes.bool
|
|
505
|
+
flipEnabled: PropTypes.bool,
|
|
506
|
+
|
|
507
|
+
/** Wraps the pill text when it would overflow the input width */
|
|
508
|
+
wrapPillText: PropTypes.bool
|
|
504
509
|
};
|
|
505
510
|
MultiSelect.defaultProps = {
|
|
506
511
|
"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(
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./pill";
|
|
1
|
+
export { default } from "./pill.component";
|
|
2
|
+
export type { PillProps } from "./pill.component";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledPillProps } from "./pill.style";
|
|
3
|
+
export interface PillProps extends StyledPillProps {
|
|
4
|
+
/** The content to display inside of the pill. */
|
|
5
|
+
children: string;
|
|
6
|
+
/** Change the color of a status pill. */
|
|
7
|
+
colorVariant?: "neutral" | "negative" | "positive" | "warning";
|
|
8
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
9
|
+
"data-element"?: string;
|
|
10
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
11
|
+
"data-role"?: string;
|
|
12
|
+
/** Fills the pill background with colour. When fill is false only the border is coloured. */
|
|
13
|
+
fill?: boolean;
|
|
14
|
+
/** Callback function for when the pill is clicked. */
|
|
15
|
+
onClick?: React.MouseEventHandler<HTMLSpanElement>;
|
|
16
|
+
/** Callback function for when the remove icon is clicked. */
|
|
17
|
+
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
18
|
+
/** Sets the type of pill in use. */
|
|
19
|
+
pillRole?: "tag" | "status";
|
|
20
|
+
}
|
|
21
|
+
export declare const Pill: ({ wrapText, borderColor, colorVariant, children, fill, maxWidth, onClick, onDelete, pillRole, size, ...rest }: PillProps) => JSX.Element;
|
|
22
|
+
export default Pill;
|
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.Pill = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
|
|
13
|
-
|
|
14
12
|
var _pill = _interopRequireDefault(require("./pill.style"));
|
|
15
13
|
|
|
16
14
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
@@ -19,14 +17,10 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
|
|
|
19
17
|
|
|
20
18
|
var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
21
19
|
|
|
22
|
-
var _utils = require("../../style/utils");
|
|
23
|
-
|
|
24
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
21
|
|
|
26
22
|
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); }
|
|
27
23
|
|
|
28
|
-
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
29
|
-
|
|
30
24
|
const renderCloseIcon = onDelete => /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
31
25
|
onAction: onDelete,
|
|
32
26
|
"data-element": "close",
|
|
@@ -36,58 +30,238 @@ const renderCloseIcon = onDelete => /*#__PURE__*/_react.default.createElement(_i
|
|
|
36
30
|
}));
|
|
37
31
|
|
|
38
32
|
const Pill = ({
|
|
39
|
-
|
|
40
|
-
onDelete,
|
|
41
|
-
colorVariant,
|
|
33
|
+
wrapText,
|
|
42
34
|
borderColor,
|
|
43
|
-
|
|
35
|
+
colorVariant = "neutral",
|
|
44
36
|
children,
|
|
45
|
-
|
|
37
|
+
fill = false,
|
|
38
|
+
maxWidth,
|
|
46
39
|
onClick,
|
|
40
|
+
onDelete,
|
|
41
|
+
pillRole = "tag",
|
|
42
|
+
size = "M",
|
|
47
43
|
...rest
|
|
48
44
|
}) => /*#__PURE__*/_react.default.createElement(_pill.default, _extends({
|
|
49
45
|
inFill: fill,
|
|
50
46
|
colorVariant: colorVariant,
|
|
51
|
-
isDeletable: onDelete,
|
|
47
|
+
isDeletable: !!onDelete,
|
|
52
48
|
pillRole: pillRole,
|
|
53
49
|
size: size,
|
|
54
50
|
borderColor: borderColor,
|
|
55
51
|
onClick: onClick
|
|
56
|
-
}, (0, _tags.default)("pill", rest),
|
|
52
|
+
}, (0, _tags.default)("pill", rest), {
|
|
53
|
+
maxWidth: maxWidth,
|
|
54
|
+
wrapText: wrapText
|
|
55
|
+
}, rest), children, onDelete && renderCloseIcon(onDelete));
|
|
57
56
|
|
|
57
|
+
exports.Pill = Pill;
|
|
58
58
|
Pill.propTypes = {
|
|
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
|
-
|
|
59
|
+
"borderColor": _propTypes.default.string,
|
|
60
|
+
"children": _propTypes.default.string.isRequired,
|
|
61
|
+
"colorVariant": _propTypes.default.oneOf(["negative", "neutral", "positive", "warning"]),
|
|
62
|
+
"data-element": _propTypes.default.string,
|
|
63
|
+
"data-role": _propTypes.default.string,
|
|
64
|
+
"fill": _propTypes.default.bool,
|
|
65
|
+
"m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
66
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
67
|
+
"description": _propTypes.default.string,
|
|
68
|
+
"toString": _propTypes.default.func.isRequired,
|
|
69
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
70
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
71
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
72
|
+
"description": _propTypes.default.string,
|
|
73
|
+
"toString": _propTypes.default.func.isRequired,
|
|
74
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
75
|
+
}), _propTypes.default.string]),
|
|
76
|
+
"margin": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
77
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
78
|
+
"description": _propTypes.default.string,
|
|
79
|
+
"toString": _propTypes.default.func.isRequired,
|
|
80
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
81
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
82
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
83
|
+
"description": _propTypes.default.string,
|
|
84
|
+
"toString": _propTypes.default.func.isRequired,
|
|
85
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
86
|
+
}), _propTypes.default.string]),
|
|
87
|
+
"marginBottom": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
88
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
89
|
+
"description": _propTypes.default.string,
|
|
90
|
+
"toString": _propTypes.default.func.isRequired,
|
|
91
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
92
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
93
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
94
|
+
"description": _propTypes.default.string,
|
|
95
|
+
"toString": _propTypes.default.func.isRequired,
|
|
96
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
97
|
+
}), _propTypes.default.string]),
|
|
98
|
+
"marginLeft": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
99
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
100
|
+
"description": _propTypes.default.string,
|
|
101
|
+
"toString": _propTypes.default.func.isRequired,
|
|
102
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
103
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
104
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
105
|
+
"description": _propTypes.default.string,
|
|
106
|
+
"toString": _propTypes.default.func.isRequired,
|
|
107
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
108
|
+
}), _propTypes.default.string]),
|
|
109
|
+
"marginRight": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
110
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
111
|
+
"description": _propTypes.default.string,
|
|
112
|
+
"toString": _propTypes.default.func.isRequired,
|
|
113
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
114
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
115
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
116
|
+
"description": _propTypes.default.string,
|
|
117
|
+
"toString": _propTypes.default.func.isRequired,
|
|
118
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
119
|
+
}), _propTypes.default.string]),
|
|
120
|
+
"marginTop": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
121
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
122
|
+
"description": _propTypes.default.string,
|
|
123
|
+
"toString": _propTypes.default.func.isRequired,
|
|
124
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
125
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
126
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
127
|
+
"description": _propTypes.default.string,
|
|
128
|
+
"toString": _propTypes.default.func.isRequired,
|
|
129
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
130
|
+
}), _propTypes.default.string]),
|
|
131
|
+
"marginX": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
132
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
133
|
+
"description": _propTypes.default.string,
|
|
134
|
+
"toString": _propTypes.default.func.isRequired,
|
|
135
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
136
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
137
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
138
|
+
"description": _propTypes.default.string,
|
|
139
|
+
"toString": _propTypes.default.func.isRequired,
|
|
140
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
141
|
+
}), _propTypes.default.string]),
|
|
142
|
+
"marginY": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
143
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
144
|
+
"description": _propTypes.default.string,
|
|
145
|
+
"toString": _propTypes.default.func.isRequired,
|
|
146
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
147
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
148
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
149
|
+
"description": _propTypes.default.string,
|
|
150
|
+
"toString": _propTypes.default.func.isRequired,
|
|
151
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
152
|
+
}), _propTypes.default.string]),
|
|
153
|
+
"maxWidth": _propTypes.default.string,
|
|
154
|
+
"mb": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
155
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
156
|
+
"description": _propTypes.default.string,
|
|
157
|
+
"toString": _propTypes.default.func.isRequired,
|
|
158
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
159
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
160
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
161
|
+
"description": _propTypes.default.string,
|
|
162
|
+
"toString": _propTypes.default.func.isRequired,
|
|
163
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
164
|
+
}), _propTypes.default.string]),
|
|
165
|
+
"ml": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
166
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
167
|
+
"description": _propTypes.default.string,
|
|
168
|
+
"toString": _propTypes.default.func.isRequired,
|
|
169
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
170
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
171
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
172
|
+
"description": _propTypes.default.string,
|
|
173
|
+
"toString": _propTypes.default.func.isRequired,
|
|
174
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
175
|
+
}), _propTypes.default.string]),
|
|
176
|
+
"mr": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
177
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
178
|
+
"description": _propTypes.default.string,
|
|
179
|
+
"toString": _propTypes.default.func.isRequired,
|
|
180
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
181
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
182
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
183
|
+
"description": _propTypes.default.string,
|
|
184
|
+
"toString": _propTypes.default.func.isRequired,
|
|
185
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
186
|
+
}), _propTypes.default.string]),
|
|
187
|
+
"mt": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
188
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
189
|
+
"description": _propTypes.default.string,
|
|
190
|
+
"toString": _propTypes.default.func.isRequired,
|
|
191
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
192
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
193
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
194
|
+
"description": _propTypes.default.string,
|
|
195
|
+
"toString": _propTypes.default.func.isRequired,
|
|
196
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
197
|
+
}), _propTypes.default.string]),
|
|
198
|
+
"mx": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
199
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
200
|
+
"description": _propTypes.default.string,
|
|
201
|
+
"toString": _propTypes.default.func.isRequired,
|
|
202
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
203
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
204
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
205
|
+
"description": _propTypes.default.string,
|
|
206
|
+
"toString": _propTypes.default.func.isRequired,
|
|
207
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
208
|
+
}), _propTypes.default.string]),
|
|
209
|
+
"my": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
210
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
211
|
+
"description": _propTypes.default.string,
|
|
212
|
+
"toString": _propTypes.default.func.isRequired,
|
|
213
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
214
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
215
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
216
|
+
"description": _propTypes.default.string,
|
|
217
|
+
"toString": _propTypes.default.func.isRequired,
|
|
218
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
219
|
+
}), _propTypes.default.string]),
|
|
220
|
+
"onClick": _propTypes.default.func,
|
|
221
|
+
"onDelete": _propTypes.default.func,
|
|
222
|
+
"pillRole": _propTypes.default.oneOf(["status", "tag"]),
|
|
223
|
+
"size": _propTypes.default.oneOf(["L", "M", "S", "XL"]),
|
|
224
|
+
"theme": _propTypes.default.shape({
|
|
225
|
+
"colors": _propTypes.default.shape({
|
|
226
|
+
"destructive": _propTypes.default.shape({
|
|
227
|
+
"hover": _propTypes.default.string.isRequired
|
|
228
|
+
}),
|
|
229
|
+
"error": _propTypes.default.string,
|
|
230
|
+
"focus": _propTypes.default.string,
|
|
231
|
+
"info": _propTypes.default.string,
|
|
232
|
+
"loadingBarBackground": _propTypes.default.string,
|
|
233
|
+
"placeholder": _propTypes.default.string,
|
|
234
|
+
"primary": _propTypes.default.string,
|
|
235
|
+
"secondary": _propTypes.default.string,
|
|
236
|
+
"tertiary": _propTypes.default.string,
|
|
237
|
+
"warning": _propTypes.default.string,
|
|
238
|
+
"warningText": _propTypes.default.string,
|
|
239
|
+
"white": _propTypes.default.oneOf(["#FFFFFF"])
|
|
240
|
+
}),
|
|
241
|
+
"compatibility": _propTypes.default.object,
|
|
242
|
+
"disabled": _propTypes.default.shape({
|
|
243
|
+
"background": _propTypes.default.string.isRequired
|
|
244
|
+
}),
|
|
245
|
+
"name": _propTypes.default.string,
|
|
246
|
+
"palette": _propTypes.default.shape({
|
|
247
|
+
"blackOpacity": _propTypes.default.func.isRequired,
|
|
248
|
+
"whiteOpacity": _propTypes.default.func.isRequired
|
|
249
|
+
}),
|
|
250
|
+
"space": _propTypes.default.arrayOf(_propTypes.default.string),
|
|
251
|
+
"spacing": _propTypes.default.number,
|
|
252
|
+
"zIndex": _propTypes.default.shape({
|
|
253
|
+
"aboveAll": _propTypes.default.number.isRequired,
|
|
254
|
+
"fullScreenModal": _propTypes.default.number.isRequired,
|
|
255
|
+
"header": _propTypes.default.number.isRequired,
|
|
256
|
+
"modal": _propTypes.default.number.isRequired,
|
|
257
|
+
"nav": _propTypes.default.number.isRequired,
|
|
258
|
+
"notification": _propTypes.default.number.isRequired,
|
|
259
|
+
"overlay": _propTypes.default.number.isRequired,
|
|
260
|
+
"popover": _propTypes.default.number.isRequired,
|
|
261
|
+
"smallOverlay": _propTypes.default.number.isRequired
|
|
262
|
+
})
|
|
263
|
+
}),
|
|
264
|
+
"wrapText": _propTypes.default.bool
|
|
91
265
|
};
|
|
92
266
|
var _default = Pill;
|
|
93
267
|
exports.default = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface StyledPillInnerConfigProps {
|
|
2
|
+
varietyColor: string;
|
|
3
|
+
buttonFocus: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
interface StyledPillConfig {
|
|
7
|
+
status: {
|
|
8
|
+
neutral: StyledPillInnerConfigProps;
|
|
9
|
+
negative: StyledPillInnerConfigProps;
|
|
10
|
+
warning: StyledPillInnerConfigProps;
|
|
11
|
+
positive: StyledPillInnerConfigProps;
|
|
12
|
+
};
|
|
13
|
+
tag: {
|
|
14
|
+
primary: StyledPillInnerConfigProps;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
declare const _default: () => StyledPillConfig;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MarginProps } from "styled-system";
|
|
2
|
+
import { ThemeObject } from "../../style/themes/base/base-theme.config";
|
|
3
|
+
export interface StyledPillProps extends MarginProps {
|
|
4
|
+
/** Override color variant, provide any color from palette or any valid css color value. */
|
|
5
|
+
borderColor?: string;
|
|
6
|
+
/** Sets the max-width of the pill. */
|
|
7
|
+
maxWidth?: string;
|
|
8
|
+
/** Sets the size of the pill. */
|
|
9
|
+
size?: "S" | "M" | "L" | "XL";
|
|
10
|
+
/** @private @ignore */
|
|
11
|
+
theme?: Partial<ThemeObject>;
|
|
12
|
+
/** Allow the text within pill to wrap. */
|
|
13
|
+
wrapText?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface AllStyledPillProps extends StyledPillProps {
|
|
16
|
+
inFill?: boolean;
|
|
17
|
+
isDeletable: boolean;
|
|
18
|
+
colorVariant: "neutral" | "negative" | "positive" | "warning";
|
|
19
|
+
pillRole: "tag" | "status";
|
|
20
|
+
}
|
|
21
|
+
declare const StyledPill: import("styled-components").StyledComponent<"span", any, AllStyledPillProps, never>;
|
|
22
|
+
export default StyledPill;
|
|
@@ -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;
|
|
@@ -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(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "109.
|
|
3
|
+
"version": "109.2.0",
|
|
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;
|