@fluidattacks/design 11.9.0 → 11.10.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/selectable-list/index.js +55 -50
- package/dist/components/selectable-list/index.stories.d.ts +2 -1
- package/dist/components/selectable-list/styles.d.ts +7 -2
- package/dist/components/selectable-list/styles.js +20 -9
- package/dist/components/selectable-list/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,83 +1,88 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useTheme as
|
|
4
|
-
import { StyledListHeader as
|
|
5
|
-
import { Checkbox as
|
|
6
|
-
import { Search as
|
|
1
|
+
import { jsxs as i, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useMemo as C, useCallback as g } from "react";
|
|
3
|
+
import { useTheme as x } from "styled-components";
|
|
4
|
+
import { StyledListHeader as $, StyledList as z, StyledListRow as k, StyledRowContent as R, StyledRowLabel as T } from "./styles.js";
|
|
5
|
+
import { Checkbox as j } from "../checkbox/index.js";
|
|
6
|
+
import { Search as H } from "../search/index.js";
|
|
7
|
+
import { Tag as q } from "../tag/index.js";
|
|
7
8
|
import "../typography/heading/index.js";
|
|
8
9
|
import "../typography/span/index.js";
|
|
9
|
-
import { Text as
|
|
10
|
-
const
|
|
10
|
+
import { Text as n } from "../typography/text/index.js";
|
|
11
|
+
const N = ({
|
|
11
12
|
counter: v,
|
|
12
|
-
emptyText:
|
|
13
|
-
items:
|
|
14
|
-
maxHeight:
|
|
13
|
+
emptyText: c,
|
|
14
|
+
items: o,
|
|
15
|
+
maxHeight: b = "20rem",
|
|
15
16
|
name: h,
|
|
16
17
|
onChange: p,
|
|
17
|
-
searchPlaceholder:
|
|
18
|
-
selected:
|
|
18
|
+
searchPlaceholder: y,
|
|
19
|
+
selected: t
|
|
19
20
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
const e =
|
|
22
|
-
return
|
|
23
|
-
(
|
|
21
|
+
const a = x(), [s, m] = L(""), u = C(() => {
|
|
22
|
+
const e = s.trim().toLowerCase();
|
|
23
|
+
return o.filter(
|
|
24
|
+
(r) => r.label.toLowerCase().includes(e)
|
|
24
25
|
);
|
|
25
|
-
}, [
|
|
26
|
-
(e) =>
|
|
27
|
-
).length,
|
|
26
|
+
}, [o, s]), S = o.filter(
|
|
27
|
+
(e) => t.has(e.value)
|
|
28
|
+
).length, f = g(
|
|
28
29
|
(e) => {
|
|
29
|
-
|
|
30
|
+
m(e.target.value);
|
|
30
31
|
},
|
|
31
32
|
[]
|
|
32
|
-
), w =
|
|
33
|
+
), w = g(
|
|
33
34
|
(e) => {
|
|
34
|
-
const { value:
|
|
35
|
-
|
|
35
|
+
const { value: r } = e.target, d = new Set(t);
|
|
36
|
+
d.has(r) ? d.delete(r) : d.add(r), p(d);
|
|
36
37
|
},
|
|
37
|
-
[p,
|
|
38
|
+
[p, t]
|
|
38
39
|
);
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ i("div", { children: [
|
|
41
|
+
/* @__PURE__ */ i($, { children: [
|
|
41
42
|
/* @__PURE__ */ l(
|
|
42
|
-
|
|
43
|
+
H,
|
|
43
44
|
{
|
|
44
45
|
name: `${h}-search`,
|
|
45
|
-
onChange:
|
|
46
|
-
placeholder:
|
|
47
|
-
value:
|
|
46
|
+
onChange: f,
|
|
47
|
+
placeholder: y,
|
|
48
|
+
value: s
|
|
48
49
|
}
|
|
49
50
|
),
|
|
50
51
|
/* @__PURE__ */ l(
|
|
51
|
-
|
|
52
|
+
n,
|
|
52
53
|
{
|
|
53
54
|
"aria-live": "polite",
|
|
54
|
-
color:
|
|
55
|
+
color: a.palette.gray[600],
|
|
55
56
|
display: "inline",
|
|
56
57
|
size: "md",
|
|
57
58
|
whiteSpace: "nowrap",
|
|
58
|
-
children: v(
|
|
59
|
+
children: v(S, o.length)
|
|
59
60
|
}
|
|
60
61
|
)
|
|
61
62
|
] }),
|
|
62
|
-
u.length === 0 &&
|
|
63
|
-
|
|
63
|
+
u.length === 0 && c !== void 0 ? /* @__PURE__ */ l(n, { color: a.palette.gray[600], py: 1, size: "md", children: c }) : /* @__PURE__ */ l(z, { $maxHeight: b, children: u.map((e) => /* @__PURE__ */ l(k, { $disabled: e.disabled === !0, children: /* @__PURE__ */ l(
|
|
64
|
+
j,
|
|
64
65
|
{
|
|
65
66
|
"aria-label": e.label,
|
|
66
|
-
checked:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
checked: t.has(e.value),
|
|
68
|
+
disabled: e.disabled,
|
|
69
|
+
label: /* @__PURE__ */ i(R, { children: [
|
|
70
|
+
/* @__PURE__ */ i(T, { children: [
|
|
71
|
+
/* @__PURE__ */ l(
|
|
72
|
+
n,
|
|
73
|
+
{
|
|
74
|
+
color: e.disabled === !0 ? a.palette.gray[400] : a.palette.gray[800],
|
|
75
|
+
display: "inline",
|
|
76
|
+
size: "md",
|
|
77
|
+
children: e.label
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
e.tag === void 0 ? void 0 : /* @__PURE__ */ l(q, { tagLabel: e.tag })
|
|
81
|
+
] }),
|
|
77
82
|
e.secondary === void 0 ? void 0 : /* @__PURE__ */ l(
|
|
78
|
-
|
|
83
|
+
n,
|
|
79
84
|
{
|
|
80
|
-
color:
|
|
85
|
+
color: a.palette.gray[600],
|
|
81
86
|
display: "inline",
|
|
82
87
|
size: "md",
|
|
83
88
|
whiteSpace: "nowrap",
|
|
@@ -93,5 +98,5 @@ const I = ({
|
|
|
93
98
|
] });
|
|
94
99
|
};
|
|
95
100
|
export {
|
|
96
|
-
|
|
101
|
+
N as SelectableList
|
|
97
102
|
};
|
|
@@ -2,5 +2,6 @@ import { Meta } from '@storybook/react-vite';
|
|
|
2
2
|
import { ISelectableListProps } from './types';
|
|
3
3
|
declare const config: Meta;
|
|
4
4
|
declare const Default: import('storybook/internal/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, ISelectableListProps>;
|
|
5
|
-
|
|
5
|
+
declare const WithDisabled: import('storybook/internal/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, ISelectableListProps>;
|
|
6
|
+
export { Default, WithDisabled };
|
|
6
7
|
export default config;
|
|
@@ -4,6 +4,11 @@ declare const StyledList: import('styled-components/dist/types').IStyledComponen
|
|
|
4
4
|
}, never> & Partial<Pick<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "$maxHeight"> & {
|
|
5
5
|
$maxHeight: string;
|
|
6
6
|
}, never>>> & string;
|
|
7
|
-
declare const StyledListRow: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('
|
|
7
|
+
declare const StyledListRow: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "$disabled"> & {
|
|
8
|
+
$disabled: boolean;
|
|
9
|
+
}, never> & Partial<Pick<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "$disabled"> & {
|
|
10
|
+
$disabled: boolean;
|
|
11
|
+
}, never>>> & string;
|
|
8
12
|
declare const StyledRowContent: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
|
|
9
|
-
|
|
13
|
+
declare const StyledRowLabel: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
|
|
14
|
+
export { StyledList, StyledListHeader, StyledListRow, StyledRowContent, StyledRowLabel, };
|
|
@@ -10,17 +10,18 @@ const n = e.div`
|
|
|
10
10
|
flex: 1;
|
|
11
11
|
min-width: 0;
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
14
|
-
${({ theme: t, $maxHeight:
|
|
13
|
+
`, o = e.ul`
|
|
14
|
+
${({ theme: t, $maxHeight: a }) => `
|
|
15
15
|
border-bottom: 1px solid ${t.palette.gray[200]};
|
|
16
16
|
list-style: none;
|
|
17
17
|
margin: 0;
|
|
18
|
-
max-height: ${
|
|
18
|
+
max-height: ${a};
|
|
19
19
|
overflow-y: auto;
|
|
20
20
|
padding: 0;
|
|
21
21
|
`}
|
|
22
|
-
`,
|
|
23
|
-
${({ theme: t }) => `
|
|
22
|
+
`, l = e.li`
|
|
23
|
+
${({ theme: t, $disabled: a }) => `
|
|
24
|
+
background-color: ${a ? t.palette.gray[50] : "transparent"};
|
|
24
25
|
border-bottom: 1px solid ${t.palette.gray[200]};
|
|
25
26
|
|
|
26
27
|
&:last-child {
|
|
@@ -28,7 +29,11 @@ const n = e.div`
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
&:hover {
|
|
31
|
-
background-color: ${t.palette.gray[25]};
|
|
32
|
+
background-color: ${t.palette.gray[a ? 50 : 25]};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.parent-checkbox input:disabled ~ span {
|
|
36
|
+
opacity: 1;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
&:has(input:focus-visible) {
|
|
@@ -53,10 +58,16 @@ const n = e.div`
|
|
|
53
58
|
gap: ${({ theme: t }) => t.spacing[1]};
|
|
54
59
|
justify-content: space-between;
|
|
55
60
|
min-width: 0;
|
|
61
|
+
`, p = e.span`
|
|
62
|
+
align-items: center;
|
|
63
|
+
display: flex;
|
|
64
|
+
gap: ${({ theme: t }) => t.spacing[0.5]};
|
|
65
|
+
min-width: 0;
|
|
56
66
|
`;
|
|
57
67
|
export {
|
|
58
|
-
|
|
68
|
+
o as StyledList,
|
|
59
69
|
n as StyledListHeader,
|
|
60
|
-
|
|
61
|
-
s as StyledRowContent
|
|
70
|
+
l as StyledListRow,
|
|
71
|
+
s as StyledRowContent,
|
|
72
|
+
p as StyledRowLabel
|
|
62
73
|
};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Selectable list item props.
|
|
3
3
|
* @interface ISelectableListItem
|
|
4
|
+
* @property { boolean } [disabled] - The row cannot be toggled and renders muted; its checkbox still reflects `selected`. Rows keep the order of `items`, so the owner places disabled rows.
|
|
4
5
|
* @property { string } label - The row's text, also what the search filters on.
|
|
5
6
|
* @property { string } [secondary] - Right-aligned detail, such as "5 repositories".
|
|
7
|
+
* @property { string } [tag] - Short status shown after the label, such as "Inactive".
|
|
6
8
|
* @property { string } value - Unique key stored in the selection.
|
|
7
9
|
*/
|
|
8
10
|
interface ISelectableListItem {
|
|
11
|
+
disabled?: boolean;
|
|
9
12
|
label: string;
|
|
10
13
|
secondary?: string;
|
|
14
|
+
tag?: string;
|
|
11
15
|
value: string;
|
|
12
16
|
}
|
|
13
17
|
/**
|
package/package.json
CHANGED