@fluidattacks/design 8.3.1 → 8.4.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ITagProps, TTagVariant } from './types';
|
|
2
|
-
declare const Tag: ({ disabled, dot, icon, iconColor, iconType, id, filterId, filterValues, fontSize, href, linkLabel, onBodyClick, onClose, priority, selected, tagTitle, tagLabel, truncate, variant, }: Readonly<ITagProps>) => JSX.Element;
|
|
2
|
+
declare const Tag: ({ disabled, dot, icon, iconColor, iconType, id, filterId, filterValues, fontSize, fullWidth, href, linkLabel, onBodyClick, onClose, priority, selected, tagTitle, tagLabel, truncate, variant, }: Readonly<ITagProps>) => JSX.Element;
|
|
3
3
|
export type { ITagProps, TTagVariant };
|
|
4
4
|
export { Tag };
|
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
import { jsxs as e, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { l as
|
|
3
|
-
import { StyledTag as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import { IconButton as
|
|
2
|
+
import { l as k } from "../../_virtual/lodash.js";
|
|
3
|
+
import { StyledTag as E, StyledTagContent as j, StyledDot as K } from "./styles.js";
|
|
4
|
+
import { Icon as P } from "../icon/index.js";
|
|
5
|
+
import { IconButton as W } from "../icon-button/index.js";
|
|
6
6
|
import { Link as C } from "../link/index.js";
|
|
7
7
|
import "../typography/heading/index.js";
|
|
8
|
-
import { Span as
|
|
8
|
+
import { Span as q } from "../typography/span/index.js";
|
|
9
9
|
import "../typography/text/index.js";
|
|
10
|
-
const
|
|
10
|
+
const U = ({
|
|
11
11
|
disabled: f,
|
|
12
12
|
dot: h = !1,
|
|
13
|
-
icon:
|
|
13
|
+
icon: d,
|
|
14
14
|
iconColor: u = "inherit",
|
|
15
15
|
iconType: v = "fa-light",
|
|
16
16
|
id: g = "close-tag",
|
|
17
17
|
filterId: x = "",
|
|
18
|
-
filterValues:
|
|
18
|
+
filterValues: c = "",
|
|
19
19
|
fontSize: y,
|
|
20
|
+
fullWidth: S = !1,
|
|
20
21
|
href: r,
|
|
21
|
-
linkLabel:
|
|
22
|
+
linkLabel: $,
|
|
22
23
|
onBodyClick: i,
|
|
23
24
|
onClose: n,
|
|
24
|
-
priority:
|
|
25
|
+
priority: T = "default",
|
|
25
26
|
selected: a,
|
|
26
27
|
tagTitle: p = "",
|
|
27
|
-
tagLabel:
|
|
28
|
-
truncate:
|
|
29
|
-
variant:
|
|
28
|
+
tagLabel: l,
|
|
29
|
+
truncate: w = !0,
|
|
30
|
+
variant: z = "default"
|
|
30
31
|
}) => {
|
|
31
|
-
const
|
|
32
|
+
const D = l.length > 25 && w && k.isEmpty(p + c), I = `${l.slice(0, 25)}...`, N = (t) => {
|
|
32
33
|
t.target === t.currentTarget && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), i?.());
|
|
33
|
-
},
|
|
34
|
+
}, b = (t) => {
|
|
34
35
|
t.stopPropagation(), n?.();
|
|
35
|
-
},
|
|
36
|
+
}, s = i !== void 0, m = s && typeof a == "boolean";
|
|
36
37
|
return /* @__PURE__ */ e(
|
|
37
|
-
|
|
38
|
+
q,
|
|
38
39
|
{
|
|
39
40
|
className: "gap-0.5",
|
|
40
41
|
color: "inherit",
|
|
@@ -42,42 +43,43 @@ const R = ({
|
|
|
42
43
|
size: "md",
|
|
43
44
|
children: [
|
|
44
45
|
/* @__PURE__ */ e(
|
|
45
|
-
|
|
46
|
+
E,
|
|
46
47
|
{
|
|
47
48
|
$fontSize: y,
|
|
48
|
-
$
|
|
49
|
+
$fullWidth: S,
|
|
50
|
+
$interactive: s,
|
|
49
51
|
$selectable: m,
|
|
50
52
|
$selected: a === !0,
|
|
51
|
-
$variant:
|
|
52
|
-
className:
|
|
53
|
+
$variant: z,
|
|
54
|
+
className: T,
|
|
53
55
|
"data-testid": x,
|
|
54
|
-
...
|
|
56
|
+
...s && {
|
|
55
57
|
...m ? { "aria-pressed": a } : {},
|
|
56
58
|
onClick: i,
|
|
57
|
-
onKeyDown:
|
|
59
|
+
onKeyDown: N,
|
|
58
60
|
role: "button",
|
|
59
61
|
tabIndex: 0
|
|
60
62
|
},
|
|
61
63
|
children: [
|
|
62
|
-
/* @__PURE__ */ e(
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
/* @__PURE__ */ e(j, { children: [
|
|
65
|
+
d ? /* @__PURE__ */ o(
|
|
66
|
+
P,
|
|
65
67
|
{
|
|
66
|
-
icon:
|
|
68
|
+
icon: d,
|
|
67
69
|
iconColor: u,
|
|
68
70
|
iconSize: "sm",
|
|
69
71
|
iconType: v
|
|
70
72
|
}
|
|
71
73
|
) : void 0,
|
|
72
|
-
h ? /* @__PURE__ */ o(
|
|
74
|
+
h ? /* @__PURE__ */ o(K, { "data-testid": "tag-dot" }) : void 0,
|
|
73
75
|
/* @__PURE__ */ e("span", { className: "w-full", children: [
|
|
74
76
|
/* @__PURE__ */ o("strong", { children: p }),
|
|
75
|
-
/* @__PURE__ */ o("span", { children:
|
|
76
|
-
/* @__PURE__ */ o("strong", { className: "w-full", children:
|
|
77
|
+
/* @__PURE__ */ o("span", { children: D ? I : l }),
|
|
78
|
+
/* @__PURE__ */ o("strong", { className: "w-full", children: c })
|
|
77
79
|
] })
|
|
78
80
|
] }),
|
|
79
81
|
n ? /* @__PURE__ */ o(
|
|
80
|
-
|
|
82
|
+
W,
|
|
81
83
|
{
|
|
82
84
|
disabled: f,
|
|
83
85
|
icon: "xmark",
|
|
@@ -85,7 +87,7 @@ const R = ({
|
|
|
85
87
|
iconSize: "xs",
|
|
86
88
|
iconType: "fa-light",
|
|
87
89
|
id: g,
|
|
88
|
-
onClick: i !== void 0 ?
|
|
90
|
+
onClick: i !== void 0 ? b : n,
|
|
89
91
|
px: 0.125,
|
|
90
92
|
py: 0.125,
|
|
91
93
|
variant: "ghost"
|
|
@@ -94,11 +96,11 @@ const R = ({
|
|
|
94
96
|
]
|
|
95
97
|
}
|
|
96
98
|
),
|
|
97
|
-
r === void 0 ? void 0 : /* @__PURE__ */ o(C, { href: r, children:
|
|
99
|
+
r === void 0 ? void 0 : /* @__PURE__ */ o(C, { href: r, children: $ })
|
|
98
100
|
]
|
|
99
101
|
}
|
|
100
102
|
);
|
|
101
103
|
};
|
|
102
104
|
export {
|
|
103
|
-
|
|
105
|
+
U as Tag
|
|
104
106
|
};
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { styled as a } from "styled-components";
|
|
2
2
|
import { variantBuilder as i } from "../@core/variants/utils.js";
|
|
3
|
-
const { getVariant:
|
|
3
|
+
const { getVariant: g } = i(
|
|
4
4
|
(o) => ({
|
|
5
5
|
complementary: `
|
|
6
6
|
background-color: ${o.palette.complementary[300]};
|
|
7
7
|
color: ${o.palette.white};
|
|
8
8
|
`,
|
|
9
|
+
cwe: `
|
|
10
|
+
--tag-padding-y: calc(${o.spacing[0.125]} - 1px);
|
|
11
|
+
--tag-padding-x: ${o.spacing[0.25]};
|
|
12
|
+
|
|
13
|
+
background-color: ${o.palette.gray[50]};
|
|
14
|
+
border: 1px solid ${o.palette.gray[300]};
|
|
15
|
+
border-radius: ${o.spacing[0.5]};
|
|
16
|
+
color: ${o.palette.gray[600]};
|
|
17
|
+
|
|
18
|
+
a:hover & {
|
|
19
|
+
text-decoration: underline;
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
9
22
|
default: `
|
|
10
23
|
background-color: ${o.palette.gray[100]};
|
|
11
24
|
color: ${o.palette.gray[600]};
|
|
@@ -47,6 +60,21 @@ const { getVariant: p } = i(
|
|
|
47
60
|
color: ${o.palette.info[50]};
|
|
48
61
|
}
|
|
49
62
|
`,
|
|
63
|
+
overflow: `
|
|
64
|
+
--tag-padding-y: calc(${o.spacing[0.125]} - 1px);
|
|
65
|
+
--tag-padding-x: ${o.spacing[0.25]};
|
|
66
|
+
|
|
67
|
+
background-color: ${o.palette.gray[300]};
|
|
68
|
+
border: 1px solid ${o.palette.gray[300]};
|
|
69
|
+
border-radius: ${o.spacing[0.5]};
|
|
70
|
+
color: ${o.palette.gray[600]};
|
|
71
|
+
|
|
72
|
+
&[role="button"]:hover {
|
|
73
|
+
background-color: ${o.palette.gray[500]};
|
|
74
|
+
border-color: ${o.palette.gray[500]};
|
|
75
|
+
color: ${o.palette.gray[25]};
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
50
78
|
reachable: `
|
|
51
79
|
background-color: ${o.palette.gray[50]};
|
|
52
80
|
color: ${o.palette.gray[800]};
|
|
@@ -106,14 +134,15 @@ const { getVariant: p } = i(
|
|
|
106
134
|
&:hover {
|
|
107
135
|
background-color: ${r ? o.palette.gray[800] : o.palette.gray[100]};
|
|
108
136
|
}
|
|
109
|
-
`,
|
|
137
|
+
`, $ = a.span`
|
|
110
138
|
${({
|
|
111
139
|
theme: o,
|
|
112
140
|
$fontSize: r = o.typography.text.sm,
|
|
141
|
+
$fullWidth: t = !1,
|
|
113
142
|
$variant: l,
|
|
114
|
-
$interactive:
|
|
115
|
-
$selectable:
|
|
116
|
-
$selected:
|
|
143
|
+
$interactive: n = !1,
|
|
144
|
+
$selectable: c = !1,
|
|
145
|
+
$selected: p = !1
|
|
117
146
|
}) => `
|
|
118
147
|
align-items: center;
|
|
119
148
|
border-radius: ${o.spacing[l === "technique" ? 1 : 0.25]};
|
|
@@ -127,8 +156,8 @@ const { getVariant: p } = i(
|
|
|
127
156
|
line-height: 18px;
|
|
128
157
|
padding: var(--tag-padding-y) var(--tag-padding-x);
|
|
129
158
|
white-space: nowrap;
|
|
130
|
-
width: max-content;
|
|
131
|
-
${
|
|
159
|
+
width: ${t ? "100%" : "max-content"};
|
|
160
|
+
${n && !c ? "cursor: pointer;" : ""}
|
|
132
161
|
|
|
133
162
|
~ a {
|
|
134
163
|
font-size: ${o.typography.text.xs};
|
|
@@ -148,17 +177,17 @@ const { getVariant: p } = i(
|
|
|
148
177
|
}
|
|
149
178
|
}
|
|
150
179
|
|
|
151
|
-
${
|
|
152
|
-
${
|
|
180
|
+
${g(o, l)}
|
|
181
|
+
${c ? e(o, p) : ""}
|
|
153
182
|
`}
|
|
154
|
-
`,
|
|
183
|
+
`, u = a.span`
|
|
155
184
|
${({ theme: o }) => `
|
|
156
185
|
align-items: center;
|
|
157
186
|
display: inline-flex;
|
|
158
187
|
gap: ${o.spacing[0.25]};
|
|
159
188
|
min-width: 0;
|
|
160
189
|
`}
|
|
161
|
-
`,
|
|
190
|
+
`, y = a.span`
|
|
162
191
|
background-color: currentColor;
|
|
163
192
|
border-radius: 50%;
|
|
164
193
|
flex-shrink: 0;
|
|
@@ -166,7 +195,7 @@ const { getVariant: p } = i(
|
|
|
166
195
|
width: 6px;
|
|
167
196
|
`;
|
|
168
197
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
198
|
+
y as StyledDot,
|
|
199
|
+
$ as StyledTag,
|
|
200
|
+
u as StyledTagContent
|
|
172
201
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IIconModifiable } from '../@core';
|
|
2
|
-
type TTagVariant = "complementary" | "default" | "error" | "inactive" | "inactiveOutline" | "info" | "reachable" | "remediation" | "role" | "success" | "technique" | "warning";
|
|
2
|
+
type TTagVariant = "complementary" | "cwe" | "default" | "error" | "inactive" | "inactiveOutline" | "info" | "overflow" | "reachable" | "remediation" | "role" | "success" | "technique" | "warning";
|
|
3
3
|
type TTagPriority = "default" | "high" | "low" | "medium";
|
|
4
4
|
/**
|
|
5
5
|
* Tag component props.
|
|
@@ -10,6 +10,8 @@ type TTagPriority = "default" | "high" | "low" | "medium";
|
|
|
10
10
|
* @property { boolean } [dot] - Whether to render a status dot before the label.
|
|
11
11
|
* @property { string } [filterValues] - The filter values for the tag.
|
|
12
12
|
* @property { string } [fontSize] - The font size for the tag.
|
|
13
|
+
* @property { boolean } [fullWidth] - Whether the tag fills the width of its
|
|
14
|
+
* container instead of fitting its content.
|
|
13
15
|
* @property { string } [href] - The href for the tag.
|
|
14
16
|
* @property { string } [linkLabel] - The link label for the tag.
|
|
15
17
|
* @property { Function } [onClose] - Function handler for close button click.
|
|
@@ -29,6 +31,7 @@ interface ITagProps extends Partial<Pick<IIconModifiable, "icon" | "iconColor" |
|
|
|
29
31
|
filterValues?: string;
|
|
30
32
|
filterId?: string;
|
|
31
33
|
fontSize?: string;
|
|
34
|
+
fullWidth?: boolean;
|
|
32
35
|
href?: string;
|
|
33
36
|
linkLabel?: string;
|
|
34
37
|
onBodyClick?: () => void;
|
package/package.json
CHANGED