@dt-dds/react-tag 1.0.0-beta.43
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/CHANGELOG.md +395 -0
- package/LICENSE.md +21 -0
- package/README.md +75 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +463 -0
- package/dist/index.mjs +429 -0
- package/package.json +55 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/Tag.tsx
|
|
22
|
+
import { Tooltip } from "@dt-dds/react-tooltip";
|
|
23
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
24
|
+
|
|
25
|
+
// ../../dt-dds-react/core/assets/svgs/AllOut.tsx
|
|
26
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
|
|
28
|
+
// ../../dt-dds-react/core/assets/svgs/Apis.tsx
|
|
29
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
30
|
+
|
|
31
|
+
// ../../dt-dds-react/core/assets/svgs/Apps.tsx
|
|
32
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
33
|
+
|
|
34
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowDropDown.tsx
|
|
35
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
36
|
+
|
|
37
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowDropUp.tsx
|
|
38
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
39
|
+
|
|
40
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowLeft.tsx
|
|
41
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
42
|
+
|
|
43
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowRight.tsx
|
|
44
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
45
|
+
|
|
46
|
+
// ../../dt-dds-react/core/assets/svgs/AvatarThumbnail.tsx
|
|
47
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
48
|
+
|
|
49
|
+
// ../../dt-dds-react/core/assets/svgs/Bolt.tsx
|
|
50
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
51
|
+
|
|
52
|
+
// ../../dt-dds-react/core/assets/svgs/CalendarMonth.tsx
|
|
53
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
54
|
+
|
|
55
|
+
// ../../dt-dds-react/core/assets/svgs/Cancel.tsx
|
|
56
|
+
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
57
|
+
|
|
58
|
+
// ../../dt-dds-react/core/assets/svgs/Check.tsx
|
|
59
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
60
|
+
|
|
61
|
+
// ../../dt-dds-react/core/assets/svgs/CheckCircle.tsx
|
|
62
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
63
|
+
|
|
64
|
+
// ../../dt-dds-react/core/assets/svgs/CheckCircleOutline.tsx
|
|
65
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
66
|
+
|
|
67
|
+
// ../../dt-dds-react/core/assets/svgs/Close.tsx
|
|
68
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
69
|
+
var CloseIcon = (props) => {
|
|
70
|
+
return /* @__PURE__ */ jsx15(
|
|
71
|
+
"svg",
|
|
72
|
+
__spreadProps(__spreadValues({
|
|
73
|
+
fill: "none",
|
|
74
|
+
height: "24",
|
|
75
|
+
viewBox: "0 0 24 24",
|
|
76
|
+
width: "24",
|
|
77
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
78
|
+
}, props), {
|
|
79
|
+
children: /* @__PURE__ */ jsx15(
|
|
80
|
+
"path",
|
|
81
|
+
{
|
|
82
|
+
d: "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",
|
|
83
|
+
fill: "currentColor"
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
var Close_default = CloseIcon;
|
|
90
|
+
|
|
91
|
+
// ../../dt-dds-react/core/assets/svgs/Copy.tsx
|
|
92
|
+
import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
93
|
+
|
|
94
|
+
// ../../dt-dds-react/core/assets/svgs/Delete.tsx
|
|
95
|
+
import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
96
|
+
|
|
97
|
+
// ../../dt-dds-react/core/assets/svgs/Edit.tsx
|
|
98
|
+
import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
99
|
+
|
|
100
|
+
// ../../dt-dds-react/core/assets/svgs/Email.tsx
|
|
101
|
+
import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
102
|
+
|
|
103
|
+
// ../../dt-dds-react/core/assets/svgs/EmailSend.tsx
|
|
104
|
+
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
105
|
+
|
|
106
|
+
// ../../dt-dds-react/core/assets/svgs/Error.tsx
|
|
107
|
+
import { useTheme } from "@emotion/react";
|
|
108
|
+
import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
109
|
+
|
|
110
|
+
// ../../dt-dds-react/core/assets/svgs/ErrorOutline.tsx
|
|
111
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
112
|
+
|
|
113
|
+
// ../../dt-dds-react/core/assets/svgs/EVStation.tsx
|
|
114
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
115
|
+
|
|
116
|
+
// ../../dt-dds-react/core/assets/svgs/Info.tsx
|
|
117
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
118
|
+
|
|
119
|
+
// ../../dt-dds-react/core/assets/svgs/InfoOutline.tsx
|
|
120
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
121
|
+
|
|
122
|
+
// ../../dt-dds-react/core/assets/svgs/Input.tsx
|
|
123
|
+
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
124
|
+
|
|
125
|
+
// ../../dt-dds-react/core/assets/svgs/Language.tsx
|
|
126
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
127
|
+
|
|
128
|
+
// ../../dt-dds-react/core/assets/svgs/LocationOn.tsx
|
|
129
|
+
import { jsx as jsx28, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
130
|
+
|
|
131
|
+
// ../../dt-dds-react/core/assets/svgs/LocationSearching.tsx
|
|
132
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
133
|
+
|
|
134
|
+
// ../../dt-dds-react/core/assets/svgs/MenuCompact.tsx
|
|
135
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
136
|
+
|
|
137
|
+
// ../../dt-dds-react/core/assets/svgs/MenuExpand.tsx
|
|
138
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
139
|
+
|
|
140
|
+
// ../../dt-dds-react/core/assets/svgs/Menu.tsx
|
|
141
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
142
|
+
|
|
143
|
+
// ../../dt-dds-react/core/assets/svgs/MoreHorizontal.tsx
|
|
144
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
145
|
+
|
|
146
|
+
// ../../dt-dds-react/core/assets/svgs/MoreVertical.tsx
|
|
147
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
148
|
+
|
|
149
|
+
// ../../dt-dds-react/core/assets/svgs/NoData.tsx
|
|
150
|
+
import { useTheme as useTheme2 } from "@emotion/react";
|
|
151
|
+
import { jsx as jsx35, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
152
|
+
|
|
153
|
+
// ../../dt-dds-react/core/assets/svgs/NotFound.tsx
|
|
154
|
+
import { jsx as jsx36, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
155
|
+
|
|
156
|
+
// ../../dt-dds-react/core/assets/svgs/OutlinedArrowDropDown.tsx
|
|
157
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
158
|
+
|
|
159
|
+
// ../../dt-dds-react/core/assets/svgs/OutlinedArrowDropUp.tsx
|
|
160
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
161
|
+
|
|
162
|
+
// ../../dt-dds-react/core/assets/svgs/PhoneOutlined.tsx
|
|
163
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
164
|
+
|
|
165
|
+
// ../../dt-dds-react/core/assets/svgs/Payments.tsx
|
|
166
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
167
|
+
|
|
168
|
+
// ../../dt-dds-react/core/assets/svgs/Products.tsx
|
|
169
|
+
import { jsx as jsx41, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
170
|
+
|
|
171
|
+
// ../../dt-dds-react/core/assets/svgs/RemoveCircleOutline.tsx
|
|
172
|
+
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
173
|
+
|
|
174
|
+
// ../../dt-dds-react/core/assets/svgs/Share.tsx
|
|
175
|
+
import { jsx as jsx43, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
176
|
+
|
|
177
|
+
// ../../dt-dds-react/core/assets/svgs/Signout.tsx
|
|
178
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
179
|
+
|
|
180
|
+
// ../../dt-dds-react/core/assets/svgs/Teams.tsx
|
|
181
|
+
import { jsx as jsx45, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
182
|
+
|
|
183
|
+
// ../../dt-dds-react/core/assets/svgs/Timeline.tsx
|
|
184
|
+
import { jsx as jsx46, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
185
|
+
|
|
186
|
+
// ../../dt-dds-react/core/assets/svgs/Topic.tsx
|
|
187
|
+
import { jsx as jsx47, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
188
|
+
|
|
189
|
+
// ../../dt-dds-react/core/assets/svgs/UnfoldLess.tsx
|
|
190
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
191
|
+
|
|
192
|
+
// ../../dt-dds-react/core/assets/svgs/UnfoldMore.tsx
|
|
193
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
194
|
+
|
|
195
|
+
// ../../dt-dds-react/core/assets/svgs/Username.tsx
|
|
196
|
+
import { jsx as jsx50, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
197
|
+
|
|
198
|
+
// ../../dt-dds-react/core/assets/svgs/ViewAgenda.tsx
|
|
199
|
+
import { jsx as jsx51, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
200
|
+
|
|
201
|
+
// ../../dt-dds-react/core/assets/svgs/Visibility.tsx
|
|
202
|
+
import { jsx as jsx52, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
203
|
+
|
|
204
|
+
// ../../dt-dds-react/core/assets/svgs/VisibilityOff.tsx
|
|
205
|
+
import { jsx as jsx53, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
206
|
+
|
|
207
|
+
// ../../dt-dds-react/core/assets/svgs/WarningOutline.tsx
|
|
208
|
+
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
209
|
+
|
|
210
|
+
// ../../dt-dds-react/core/assets/svgs/Warning.tsx
|
|
211
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
212
|
+
|
|
213
|
+
// ../../dt-dds-react/core/assets/svgs/Wifi.tsx
|
|
214
|
+
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
215
|
+
|
|
216
|
+
// ../../dt-dds-react/core/assets/svgs/Settings.tsx
|
|
217
|
+
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
218
|
+
|
|
219
|
+
// src/Tag.styled.ts
|
|
220
|
+
import styled from "@emotion/styled";
|
|
221
|
+
|
|
222
|
+
// src/utils/tagVariantColors.ts
|
|
223
|
+
var getColors = (variant, theme, isDisabled, color) => {
|
|
224
|
+
const resolvedColor = color === "primary" ? "accent" : color;
|
|
225
|
+
if (variant === "solid") {
|
|
226
|
+
const palette = theme.palette[resolvedColor];
|
|
227
|
+
return {
|
|
228
|
+
bgColor: isDisabled ? palette.light : palette.default,
|
|
229
|
+
hoveredBgColor: palette.dark
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if (variant === "outlined") {
|
|
233
|
+
const palette = theme.palette[resolvedColor];
|
|
234
|
+
return {
|
|
235
|
+
bgColor: palette.light,
|
|
236
|
+
hoveredBgColor: palette.medium,
|
|
237
|
+
borderTextColor: isDisabled ? palette.medium : palette.default,
|
|
238
|
+
hoveredBorderTextColor: palette.dark
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
var tagVariantColors = ({
|
|
243
|
+
theme,
|
|
244
|
+
color,
|
|
245
|
+
variant,
|
|
246
|
+
hasHover,
|
|
247
|
+
isDisabled
|
|
248
|
+
}) => {
|
|
249
|
+
const colors = getColors(variant, theme, isDisabled, color);
|
|
250
|
+
return {
|
|
251
|
+
solid: __spreadValues({
|
|
252
|
+
border: theme.spacing.none,
|
|
253
|
+
color: theme.palette.content.contrast,
|
|
254
|
+
backgroundColor: colors == null ? void 0 : colors.bgColor
|
|
255
|
+
}, hasHover && {
|
|
256
|
+
"&:hover": {
|
|
257
|
+
backgroundColor: colors == null ? void 0 : colors.hoveredBgColor,
|
|
258
|
+
color: theme.palette.content.contrast
|
|
259
|
+
}
|
|
260
|
+
}),
|
|
261
|
+
outlined: __spreadValues({
|
|
262
|
+
border: `1px solid ${colors == null ? void 0 : colors.borderTextColor}`,
|
|
263
|
+
color: colors == null ? void 0 : colors.borderTextColor,
|
|
264
|
+
backgroundColor: colors == null ? void 0 : colors.bgColor
|
|
265
|
+
}, hasHover && {
|
|
266
|
+
"&:hover": {
|
|
267
|
+
borderColor: colors == null ? void 0 : colors.hoveredBorderTextColor,
|
|
268
|
+
color: colors == null ? void 0 : colors.hoveredBorderTextColor,
|
|
269
|
+
backgroundColor: colors == null ? void 0 : colors.hoveredBgColor
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
}[variant];
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// src/utils/tagVariantSize.ts
|
|
276
|
+
var tagSizeStyles = (theme, size) => ({
|
|
277
|
+
medium: {
|
|
278
|
+
fontSize: "0.75rem",
|
|
279
|
+
fontWeight: "700",
|
|
280
|
+
lineHeight: "1rem",
|
|
281
|
+
padding: `${theme.spacing["4xs"]} ${theme.spacing["3xs"]}`,
|
|
282
|
+
height: "32px"
|
|
283
|
+
},
|
|
284
|
+
small: {
|
|
285
|
+
fontSize: "0.625rem",
|
|
286
|
+
fontWeight: "700",
|
|
287
|
+
lineHeight: "0.875rem",
|
|
288
|
+
padding: `${theme.spacing["6xs"]} ${theme.spacing["4xs"]}`,
|
|
289
|
+
height: "18px"
|
|
290
|
+
}
|
|
291
|
+
})[size];
|
|
292
|
+
|
|
293
|
+
// src/Tag.styled.ts
|
|
294
|
+
var TagStyled = styled.div(
|
|
295
|
+
({
|
|
296
|
+
theme,
|
|
297
|
+
border,
|
|
298
|
+
isDisabled,
|
|
299
|
+
isClickable,
|
|
300
|
+
isDismissible,
|
|
301
|
+
size,
|
|
302
|
+
variant,
|
|
303
|
+
color,
|
|
304
|
+
hasHover
|
|
305
|
+
}) => __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues({}, tagSizeStyles(theme, size)), tagVariantColors({ theme, variant, color, hasHover, isDisabled })), {
|
|
306
|
+
display: "flex",
|
|
307
|
+
textTransform: "uppercase",
|
|
308
|
+
alignItems: "center",
|
|
309
|
+
maxWidth: "max-content",
|
|
310
|
+
gap: theme.spacing["5xs"],
|
|
311
|
+
borderRadius: theme.radius[border === "rounded" ? "s" : "none"],
|
|
312
|
+
width: "150px",
|
|
313
|
+
["> :first-child"]: {
|
|
314
|
+
whiteSpace: "nowrap",
|
|
315
|
+
display: "block",
|
|
316
|
+
overflow: "hidden",
|
|
317
|
+
textOverflow: "ellipsis"
|
|
318
|
+
}
|
|
319
|
+
}), (isClickable || isDismissible) && { userSelect: "none" }), isClickable && { cursor: "pointer" }), isDisabled && { cursor: "not-allowed" }), {
|
|
320
|
+
["&:focus-visible"]: {
|
|
321
|
+
outline: `2px solid ${theme.palette.border.dark}`,
|
|
322
|
+
outlineOffset: "1px"
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
var TagButtonCloseStyled = styled.button`
|
|
327
|
+
${({ theme }) => ({
|
|
328
|
+
backgroundColor: "transparent",
|
|
329
|
+
color: "currentColor",
|
|
330
|
+
display: "inherit",
|
|
331
|
+
border: 0,
|
|
332
|
+
cursor: "pointer",
|
|
333
|
+
["&:disabled"]: { cursor: "not-allowed" },
|
|
334
|
+
["&:focus-visible"]: {
|
|
335
|
+
outline: `2px solid ${theme.palette.border.dark}`,
|
|
336
|
+
outlineOffset: "1px"
|
|
337
|
+
}
|
|
338
|
+
})}
|
|
339
|
+
`;
|
|
340
|
+
|
|
341
|
+
// src/Tag.tsx
|
|
342
|
+
import { jsx as jsx58, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
343
|
+
var Tag = forwardRef(
|
|
344
|
+
({
|
|
345
|
+
style,
|
|
346
|
+
children,
|
|
347
|
+
dataTestId,
|
|
348
|
+
variant = "solid",
|
|
349
|
+
color = "primary",
|
|
350
|
+
border = "squared",
|
|
351
|
+
size = "small",
|
|
352
|
+
isClickable = false,
|
|
353
|
+
isDisabled = false,
|
|
354
|
+
onClick,
|
|
355
|
+
onClose,
|
|
356
|
+
tooltipVariant = "opacity"
|
|
357
|
+
}, ref) => {
|
|
358
|
+
const dataTestIdName = dataTestId != null ? dataTestId : "tag";
|
|
359
|
+
const isDismissible = !!onClose;
|
|
360
|
+
const hasHoverStyle = !isDisabled && (!!onClick || isClickable || isDismissible);
|
|
361
|
+
const hasClickableStyle = !isDismissible && hasHoverStyle;
|
|
362
|
+
const handleClickTag = (event) => {
|
|
363
|
+
if (isDisabled || isDismissible) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
onClick == null ? void 0 : onClick(event);
|
|
367
|
+
};
|
|
368
|
+
const cellRef = useRef(null);
|
|
369
|
+
const [isOverflow, setIsOverflow] = useState(false);
|
|
370
|
+
const handleClickOnEnterKey = (event) => {
|
|
371
|
+
if (event.code === "Enter") {
|
|
372
|
+
handleClickTag(event);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
const handleCloseOnEnterKey = (event) => {
|
|
376
|
+
if (event.code === "Enter") {
|
|
377
|
+
onClose == null ? void 0 : onClose(event);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
useEffect(() => {
|
|
381
|
+
if (cellRef.current) {
|
|
382
|
+
const { current } = cellRef;
|
|
383
|
+
setIsOverflow(current.scrollWidth > current.clientWidth);
|
|
384
|
+
}
|
|
385
|
+
}, [children]);
|
|
386
|
+
return /* @__PURE__ */ jsxs25(Tooltip, { children: [
|
|
387
|
+
/* @__PURE__ */ jsxs25(
|
|
388
|
+
TagStyled,
|
|
389
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
390
|
+
"aria-disabled": isDisabled,
|
|
391
|
+
border,
|
|
392
|
+
color,
|
|
393
|
+
"data-testid": dataTestIdName,
|
|
394
|
+
hasHover: hasHoverStyle,
|
|
395
|
+
isClickable: hasClickableStyle,
|
|
396
|
+
isDisabled,
|
|
397
|
+
isDismissible,
|
|
398
|
+
onClick: handleClickTag
|
|
399
|
+
}, isClickable && { onKeyDown: handleClickOnEnterKey }), {
|
|
400
|
+
ref,
|
|
401
|
+
size,
|
|
402
|
+
style
|
|
403
|
+
}), isClickable && { tabIndex: 0 }), {
|
|
404
|
+
variant,
|
|
405
|
+
children: [
|
|
406
|
+
/* @__PURE__ */ jsx58("span", { ref: cellRef, children }),
|
|
407
|
+
isDismissible ? /* @__PURE__ */ jsx58(
|
|
408
|
+
TagButtonCloseStyled,
|
|
409
|
+
{
|
|
410
|
+
"aria-disabled": isDisabled,
|
|
411
|
+
color,
|
|
412
|
+
"data-testid": `${dataTestIdName}-close-button`,
|
|
413
|
+
disabled: isDisabled,
|
|
414
|
+
onClick: onClose,
|
|
415
|
+
onKeyDown: handleCloseOnEnterKey,
|
|
416
|
+
tabIndex: 0,
|
|
417
|
+
children: /* @__PURE__ */ jsx58(Close_default, { height: 12, width: 12 })
|
|
418
|
+
}
|
|
419
|
+
) : null
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
),
|
|
423
|
+
/* @__PURE__ */ jsx58(Tooltip.Content, { background: tooltipVariant, children: isOverflow ? children : "" })
|
|
424
|
+
] });
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
export {
|
|
428
|
+
Tag
|
|
429
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dt-dds/react-tag",
|
|
3
|
+
"version": "1.0.0-beta.43",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"dev": "tsup --watch",
|
|
17
|
+
"lint": "eslint --cache .",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:report": "open ./jest-coverage/lcov-report/index.html",
|
|
20
|
+
"test:update:snapshot": "jest -u"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@dt-dds/react-core": "1.0.0-beta.41",
|
|
24
|
+
"@dt-dds/react-tooltip": "1.0.0-beta.49"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@babel/core": "^7.22.9",
|
|
28
|
+
"@babel/preset-env": "^7.22.9",
|
|
29
|
+
"@babel/preset-react": "^7.22.5",
|
|
30
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
31
|
+
"@emotion/babel-plugin": "^11.11.0",
|
|
32
|
+
"@emotion/css": "^11.7.1",
|
|
33
|
+
"@emotion/jest": "^11.10.0",
|
|
34
|
+
"@emotion/react": "^11.8.2",
|
|
35
|
+
"@emotion/styled": "^11.8.1",
|
|
36
|
+
"@types/react": "^18.0.9",
|
|
37
|
+
"@types/react-dom": "^18.0.4",
|
|
38
|
+
"babel-loader": "^8.3.0",
|
|
39
|
+
"eslint-config-custom": "*",
|
|
40
|
+
"eslint-plugin-storybook": "^9.1.0",
|
|
41
|
+
"jest-config": "*",
|
|
42
|
+
"react": "^18.1.0",
|
|
43
|
+
"react-dom": "^18.2.0",
|
|
44
|
+
"tsconfig": "*",
|
|
45
|
+
"tsup": "^6.6.3",
|
|
46
|
+
"typescript": "^4.5.3"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@emotion/css": "^11.7.1",
|
|
50
|
+
"@emotion/react": "^11.8.2",
|
|
51
|
+
"@emotion/styled": "^11.8.1",
|
|
52
|
+
"react": ">=17.0.2",
|
|
53
|
+
"react-dom": ">=17.0.2"
|
|
54
|
+
}
|
|
55
|
+
}
|