@fluidattacks/design 8.3.0 → 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.
- package/dist/components/modal/columns-modal/index.js +32 -31
- package/dist/components/modal/dialog/index.d.ts +4 -0
- package/dist/components/modal/dialog/index.js +32 -0
- package/dist/components/modal/dialog/utils.d.ts +2 -0
- package/dist/components/modal/dialog/utils.js +26 -0
- package/dist/components/modal/index.js +71 -78
- package/dist/components/modal/types.d.ts +11 -1
- package/dist/components/table/table-column-toggle/index.js +4 -4
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/components/tag/index.js +36 -34
- package/dist/components/tag/styles.d.ts +1 -0
- package/dist/components/tag/styles.js +43 -14
- package/dist/components/tag/types.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as k, useState as j, useCallback as m } from "react";
|
|
3
3
|
import { createPortal as w } from "react-dom";
|
|
4
4
|
import { useTheme as H } from "styled-components";
|
|
5
|
-
import {
|
|
5
|
+
import { Dialog as S } from "../dialog/index.js";
|
|
6
|
+
import { ModalContainer as D } from "../styles.js";
|
|
6
7
|
import { Button as p } from "../../button/index.js";
|
|
7
8
|
import { Container as c } from "../../container/index.js";
|
|
8
9
|
import { Divider as d } from "../../divider/index.js";
|
|
9
|
-
import { IconButton as
|
|
10
|
-
import { PreviewPanel as
|
|
11
|
-
import { SearchPanel as
|
|
12
|
-
import { Heading as
|
|
10
|
+
import { IconButton as P } from "../../icon-button/index.js";
|
|
11
|
+
import { PreviewPanel as T } from "./preview-panel/index.js";
|
|
12
|
+
import { SearchPanel as z } from "./search-panel/index.js";
|
|
13
|
+
import { Heading as B } from "../../typography/heading/index.js";
|
|
13
14
|
import "../../typography/span/index.js";
|
|
14
15
|
import "../../typography/text/index.js";
|
|
15
|
-
const
|
|
16
|
+
const U = ({
|
|
16
17
|
_containerId: h = "portals",
|
|
17
18
|
title: y,
|
|
18
19
|
modalRef: e,
|
|
19
20
|
variant: f
|
|
20
21
|
}) => {
|
|
21
22
|
const a = H(), u = k(null), [o, g] = j(void 0), C = m(
|
|
22
|
-
(
|
|
23
|
-
const { checked: n, value:
|
|
23
|
+
(i) => {
|
|
24
|
+
const { checked: n, value: r } = i.target, x = e.columns.map((s) => s.name === r ? (s.toggleVisibility?.(n), { ...s, visible: n }) : s);
|
|
24
25
|
e.setColumns(x);
|
|
25
26
|
},
|
|
26
27
|
[e]
|
|
27
28
|
), b = m(
|
|
28
|
-
(
|
|
29
|
-
const n = e.columns.map((
|
|
29
|
+
(i) => {
|
|
30
|
+
const n = e.columns.map((r) => r.id === i ? (r.toggleVisibility?.(!1), { ...r, visible: !1 }) : r);
|
|
30
31
|
e.setColumns(n);
|
|
31
32
|
},
|
|
32
33
|
[e]
|
|
33
34
|
), v = m(() => {
|
|
34
|
-
const
|
|
35
|
-
o !==
|
|
35
|
+
const i = u.current?.scrollHeight;
|
|
36
|
+
o !== i && g(i);
|
|
36
37
|
}, [o]);
|
|
37
38
|
return e.isOpen ? w(
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
/* @__PURE__ */
|
|
39
|
+
/* @__PURE__ */ t(S, { label: e.name, children: /* @__PURE__ */ l(D, { $size: "md", flexDirection: "column", children: [
|
|
40
|
+
/* @__PURE__ */ l(
|
|
40
41
|
c,
|
|
41
42
|
{
|
|
42
43
|
display: "flex",
|
|
@@ -44,9 +45,9 @@ const N = ({
|
|
|
44
45
|
px: 1.25,
|
|
45
46
|
py: 1.25,
|
|
46
47
|
children: [
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
48
|
+
/* @__PURE__ */ t(B, { size: "sm", children: y }),
|
|
49
|
+
/* @__PURE__ */ t(
|
|
50
|
+
P,
|
|
50
51
|
{
|
|
51
52
|
icon: "close",
|
|
52
53
|
iconColor: a.palette.gray[400],
|
|
@@ -63,8 +64,8 @@ const N = ({
|
|
|
63
64
|
]
|
|
64
65
|
}
|
|
65
66
|
),
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ t(d, { mb: 0, mt: 0 }),
|
|
68
|
+
/* @__PURE__ */ l(
|
|
68
69
|
c,
|
|
69
70
|
{
|
|
70
71
|
display: "flex",
|
|
@@ -75,8 +76,8 @@ const N = ({
|
|
|
75
76
|
scroll: "y",
|
|
76
77
|
width: "100%",
|
|
77
78
|
children: [
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
79
|
+
/* @__PURE__ */ t(
|
|
80
|
+
z,
|
|
80
81
|
{
|
|
81
82
|
columns: e.columns,
|
|
82
83
|
formId: "columns-visibility",
|
|
@@ -84,15 +85,15 @@ const N = ({
|
|
|
84
85
|
variant: f
|
|
85
86
|
}
|
|
86
87
|
),
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ t(
|
|
88
89
|
c,
|
|
89
90
|
{
|
|
90
91
|
borderLeft: `2px solid ${a.palette.gray[100]}`,
|
|
91
92
|
height: o ? `${o}px` : "auto"
|
|
92
93
|
}
|
|
93
94
|
),
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
|
|
95
|
+
/* @__PURE__ */ t(
|
|
96
|
+
T,
|
|
96
97
|
{
|
|
97
98
|
description: "Click and drag to reorder the columns",
|
|
98
99
|
items: e.columns,
|
|
@@ -104,8 +105,8 @@ const N = ({
|
|
|
104
105
|
]
|
|
105
106
|
}
|
|
106
107
|
),
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ t(d, { mb: 0, mt: 0 }),
|
|
109
|
+
/* @__PURE__ */ l(
|
|
109
110
|
c,
|
|
110
111
|
{
|
|
111
112
|
display: "flex",
|
|
@@ -113,7 +114,7 @@ const N = ({
|
|
|
113
114
|
px: 1.25,
|
|
114
115
|
py: 1.25,
|
|
115
116
|
children: [
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
+
/* @__PURE__ */ t(
|
|
117
118
|
p,
|
|
118
119
|
{
|
|
119
120
|
disabled: !e.hasChanged,
|
|
@@ -126,7 +127,7 @@ const N = ({
|
|
|
126
127
|
children: "Reset to default"
|
|
127
128
|
}
|
|
128
129
|
),
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ t(
|
|
130
131
|
p,
|
|
131
132
|
{
|
|
132
133
|
id: "columns-modal-submit",
|
|
@@ -141,8 +142,8 @@ const N = ({
|
|
|
141
142
|
)
|
|
142
143
|
] }) }),
|
|
143
144
|
document.getElementById(h) ?? document.body
|
|
144
|
-
) : /* @__PURE__ */
|
|
145
|
+
) : /* @__PURE__ */ t("div", {});
|
|
145
146
|
};
|
|
146
147
|
export {
|
|
147
|
-
|
|
148
|
+
U as ColumnsModal
|
|
148
149
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as f, useState as c } from "react";
|
|
3
|
+
import { trapTabKey as o } from "./utils.js";
|
|
4
|
+
import { ModalWrapper as p } from "../styles.js";
|
|
5
|
+
import { useMountEffect as s } from "../../../hooks/use-mount-effect.js";
|
|
6
|
+
const w = ({
|
|
7
|
+
children: n = void 0,
|
|
8
|
+
id: a = void 0,
|
|
9
|
+
label: i
|
|
10
|
+
}) => {
|
|
11
|
+
const r = f(null), [t] = c(() => document.activeElement);
|
|
12
|
+
return s(() => {
|
|
13
|
+
const e = r.current;
|
|
14
|
+
return e?.contains(document.activeElement) !== !0 && e?.focus(), e?.addEventListener("keydown", o), () => {
|
|
15
|
+
e?.removeEventListener("keydown", o), t instanceof HTMLElement && t.focus();
|
|
16
|
+
};
|
|
17
|
+
}), /* @__PURE__ */ m(
|
|
18
|
+
p,
|
|
19
|
+
{
|
|
20
|
+
"aria-label": i,
|
|
21
|
+
"aria-modal": "true",
|
|
22
|
+
id: a,
|
|
23
|
+
ref: r,
|
|
24
|
+
role: "dialog",
|
|
25
|
+
tabIndex: -1,
|
|
26
|
+
children: n
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
w as Dialog
|
|
32
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const s = [
|
|
2
|
+
"a[href]",
|
|
3
|
+
"area[href]",
|
|
4
|
+
"button:not([disabled])",
|
|
5
|
+
"input:not([disabled]):not([type='hidden'])",
|
|
6
|
+
"select:not([disabled])",
|
|
7
|
+
"textarea:not([disabled])",
|
|
8
|
+
"iframe",
|
|
9
|
+
"[contenteditable='true']",
|
|
10
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
11
|
+
].join(", "), c = (t) => Array.from(t.querySelectorAll(s)), d = (t) => {
|
|
12
|
+
const { currentTarget: n } = t;
|
|
13
|
+
if (t.key !== "Tab" || !(n instanceof HTMLElement)) return;
|
|
14
|
+
const e = c(n);
|
|
15
|
+
if (e.length === 0) {
|
|
16
|
+
t.preventDefault();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const a = e.findIndex(
|
|
20
|
+
(r) => r === document.activeElement
|
|
21
|
+
), o = t.shiftKey && a <= 0, i = !t.shiftKey && a === e.length - 1;
|
|
22
|
+
(o || i) && (t.preventDefault(), e[o ? e.length - 1 : 0].focus());
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
d as trapTabKey
|
|
26
|
+
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r, jsxs as v } from "react/jsx-runtime";
|
|
2
2
|
import o from "../../_virtual/lodash.js";
|
|
3
3
|
import { useState as E, useRef as y, useEffect as F } from "react";
|
|
4
4
|
import { createPortal as $ } from "react-dom";
|
|
5
5
|
import { useTheme as z } from "styled-components";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { Dialog as k } from "./dialog/index.js";
|
|
7
|
+
import { ModalFooter as A } from "./footer/index.js";
|
|
8
|
+
import { Header as D } from "./header/index.js";
|
|
9
|
+
import { ModalConfirm as si } from "./modal-confirm/index.js";
|
|
10
|
+
import { ModalContainer as I, ModalContent as w, ImageContainer as B } from "./styles.js";
|
|
10
11
|
import { CloudImage as N } from "../cloud-image/index.js";
|
|
11
12
|
import { Container as P } from "../container/index.js";
|
|
12
|
-
import { Tabs as
|
|
13
|
+
import { Tabs as _ } from "../tabs/index.js";
|
|
13
14
|
import "../typography/heading/index.js";
|
|
14
15
|
import "../typography/span/index.js";
|
|
15
|
-
import { Text as
|
|
16
|
-
import { ColumnsModal as
|
|
17
|
-
const
|
|
16
|
+
import { Text as q } from "../typography/text/index.js";
|
|
17
|
+
import { ColumnsModal as ai } from "./columns-modal/index.js";
|
|
18
|
+
const oi = ({
|
|
18
19
|
_portal: b = !0,
|
|
19
20
|
alert: C,
|
|
20
21
|
cancelButton: n = void 0,
|
|
21
22
|
children: l = void 0,
|
|
22
23
|
confirmButton: p = void 0,
|
|
23
|
-
content:
|
|
24
|
+
content: i = void 0,
|
|
24
25
|
description: M = void 0,
|
|
25
26
|
dismissable: O = !0,
|
|
26
27
|
modalRef: e,
|
|
@@ -31,84 +32,76 @@ const er = ({
|
|
|
31
32
|
size: H,
|
|
32
33
|
id: c = "modal-container"
|
|
33
34
|
}) => {
|
|
34
|
-
const f = z(), [
|
|
35
|
+
const f = z(), [g, u] = E(void 0), d = y(null), a = y(!1), m = Array.isArray(t) && t.length > 0, S = n ?? p;
|
|
35
36
|
F(() => {
|
|
36
|
-
if (m && !
|
|
37
|
-
const x =
|
|
38
|
-
x > 50 && (
|
|
37
|
+
if (m && !a.current && d.current) {
|
|
38
|
+
const x = d.current.getBoundingClientRect().height;
|
|
39
|
+
x > 50 && (u(x), a.current = !0);
|
|
39
40
|
}
|
|
40
|
-
e.isOpen || (
|
|
41
|
+
e.isOpen || (u(void 0), a.current = !1);
|
|
41
42
|
}, [m, e.isOpen]);
|
|
42
|
-
const h = /* @__PURE__ */
|
|
43
|
+
const h = /* @__PURE__ */ r(k, { id: "modal-wrapper", label: e.name, children: /* @__PURE__ */ v(
|
|
43
44
|
I,
|
|
44
45
|
{
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
cancelButton: n,
|
|
95
|
-
confirmButton: p,
|
|
96
|
-
modalRef: e
|
|
97
|
-
}
|
|
98
|
-
)
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
)
|
|
46
|
+
$size: H,
|
|
47
|
+
"data-testid": c,
|
|
48
|
+
flexDirection: "column",
|
|
49
|
+
id: c,
|
|
50
|
+
ref: m ? d : void 0,
|
|
51
|
+
style: m && g ? { height: g } : void 0,
|
|
52
|
+
children: [
|
|
53
|
+
!o.isEmpty(s) && !o.isNil(s) && /* @__PURE__ */ r(
|
|
54
|
+
D,
|
|
55
|
+
{
|
|
56
|
+
description: M,
|
|
57
|
+
dismissable: O,
|
|
58
|
+
modalRef: e,
|
|
59
|
+
onClose: j,
|
|
60
|
+
otherActions: T,
|
|
61
|
+
title: s
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
t && /* @__PURE__ */ r(
|
|
65
|
+
P,
|
|
66
|
+
{
|
|
67
|
+
borderTop: `1px solid ${f.palette.gray[300]}`,
|
|
68
|
+
display: "block",
|
|
69
|
+
mb: 1.25,
|
|
70
|
+
position: "sticky",
|
|
71
|
+
children: /* @__PURE__ */ r(_, { items: t })
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
(o.isObject(i) || l) && /* @__PURE__ */ v(
|
|
75
|
+
w,
|
|
76
|
+
{
|
|
77
|
+
style: S ? { borderBottom: `1px solid ${f.palette.gray[200]}` } : void 0,
|
|
78
|
+
children: [
|
|
79
|
+
l,
|
|
80
|
+
o.isObject(i) && o.isString(i.imageSrc) && /* @__PURE__ */ r(B, { $framed: i.imageFramed, children: /* @__PURE__ */ r(N, { alt: "modal-img", publicId: i.imageSrc }) }),
|
|
81
|
+
o.isObject(i) && o.isString(i.imageText) && /* @__PURE__ */ r(q, { size: "md", children: i.imageText })
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
/* @__PURE__ */ r(
|
|
86
|
+
A,
|
|
87
|
+
{
|
|
88
|
+
alert: C,
|
|
89
|
+
cancelButton: n,
|
|
90
|
+
confirmButton: p,
|
|
91
|
+
modalRef: e
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
]
|
|
102
95
|
}
|
|
103
|
-
);
|
|
96
|
+
) });
|
|
104
97
|
return b && e.isOpen ? $(
|
|
105
98
|
h,
|
|
106
99
|
document.getElementById("portals") ?? document.body
|
|
107
100
|
) : e.isOpen ? h : null;
|
|
108
101
|
};
|
|
109
102
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
ai as ColumnsModal,
|
|
104
|
+
oi as Modal,
|
|
105
|
+
si as ModalConfirm,
|
|
106
|
+
A as ModalFooter
|
|
114
107
|
};
|
|
@@ -25,6 +25,16 @@ interface IModalContent {
|
|
|
25
25
|
imageFramed?: boolean;
|
|
26
26
|
imageText?: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Modal dialog props.
|
|
30
|
+
* @interface IDialogProps
|
|
31
|
+
* @property { string } [id] - The id of the dialog element.
|
|
32
|
+
* @property { string } label - The accessible name announced when the dialog takes focus.
|
|
33
|
+
*/
|
|
34
|
+
interface IDialogProps {
|
|
35
|
+
id?: string;
|
|
36
|
+
label: string;
|
|
37
|
+
}
|
|
28
38
|
/**
|
|
29
39
|
* Modal header component props.
|
|
30
40
|
* @interface IModalHeaderProps
|
|
@@ -92,4 +102,4 @@ interface IModalConfirmProps {
|
|
|
92
102
|
txtCancel?: string;
|
|
93
103
|
txtConfirm?: React.ReactNode | string;
|
|
94
104
|
}
|
|
95
|
-
export type { IModalProps, IModalContent, IModalConfirmProps, IModalFooterProps, IModalHeaderProps, TSize, };
|
|
105
|
+
export type { IDialogProps, IModalProps, IModalContent, IModalConfirmProps, IModalFooterProps, IModalHeaderProps, TSize, };
|
|
@@ -5,6 +5,7 @@ import { Button as f } from "../../button/index.js";
|
|
|
5
5
|
import "../../../_virtual/lodash.js";
|
|
6
6
|
import "react-dom";
|
|
7
7
|
import "styled-components";
|
|
8
|
+
import { useColumnsModal as b } from "../../../hooks/use-columns-modal.js";
|
|
8
9
|
import "../../container/index.js";
|
|
9
10
|
import "../../icon-button/index.js";
|
|
10
11
|
import "../../typography/heading/index.js";
|
|
@@ -14,8 +15,7 @@ import "../../cloud-image/index.js";
|
|
|
14
15
|
import "react-router";
|
|
15
16
|
import "../../notification-sign/index.js";
|
|
16
17
|
import "../../icon/index.js";
|
|
17
|
-
import { ColumnsModal as
|
|
18
|
-
import { useColumnsModal as C } from "../../../hooks/use-columns-modal.js";
|
|
18
|
+
import { ColumnsModal as C } from "../../modal/columns-modal/index.js";
|
|
19
19
|
const G = (s) => {
|
|
20
20
|
const { table: t } = s, { meta: m } = t.options, [, n] = t.getHeaderGroups(), a = t.getVisibleLeafColumns().filter((o) => o.id !== "selection").length, i = l(
|
|
21
21
|
() => t.getAllLeafColumns().filter((o) => o.id !== "selection"),
|
|
@@ -27,7 +27,7 @@ const G = (s) => {
|
|
|
27
27
|
name: typeof o.columnDef.header == "string" ? o.columnDef.header : o.columnDef.id ?? "",
|
|
28
28
|
toggleVisibility: o.toggleVisibility,
|
|
29
29
|
visible: o.getIsVisible()
|
|
30
|
-
})), [i]), e =
|
|
30
|
+
})), [i]), e = b({
|
|
31
31
|
columnOrder: m?.defaultColumnOrder ?? [],
|
|
32
32
|
items: d,
|
|
33
33
|
name: "table-column-management",
|
|
@@ -48,7 +48,7 @@ const G = (s) => {
|
|
|
48
48
|
}
|
|
49
49
|
),
|
|
50
50
|
/* @__PURE__ */ r(
|
|
51
|
-
|
|
51
|
+
C,
|
|
52
52
|
{
|
|
53
53
|
modalRef: e,
|
|
54
54
|
title: "Manage columns",
|
|
@@ -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