@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.
@@ -1,83 +1,88 @@
1
- import { jsxs as s, jsx as l } from "react/jsx-runtime";
2
- import { useState as C, useMemo as x, useCallback as m } from "react";
3
- import { useTheme as L } from "styled-components";
4
- import { StyledListHeader as z, StyledList as $, StyledListRow as k, StyledRowContent as j } from "./styles.js";
5
- import { Checkbox as H } from "../checkbox/index.js";
6
- import { Search as R } from "../search/index.js";
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 i } from "../typography/text/index.js";
10
- const I = ({
10
+ import { Text as n } from "../typography/text/index.js";
11
+ const N = ({
11
12
  counter: v,
12
- emptyText: d,
13
- items: r,
14
- maxHeight: y = "20rem",
13
+ emptyText: c,
14
+ items: o,
15
+ maxHeight: b = "20rem",
15
16
  name: h,
16
17
  onChange: p,
17
- searchPlaceholder: g,
18
- selected: o
18
+ searchPlaceholder: y,
19
+ selected: t
19
20
  }) => {
20
- const t = L(), [c, S] = C(""), u = x(() => {
21
- const e = c.trim().toLowerCase();
22
- return r.filter(
23
- (a) => a.label.toLowerCase().includes(e)
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
- }, [r, c]), f = r.filter(
26
- (e) => o.has(e.value)
27
- ).length, b = m(
26
+ }, [o, s]), S = o.filter(
27
+ (e) => t.has(e.value)
28
+ ).length, f = g(
28
29
  (e) => {
29
- S(e.target.value);
30
+ m(e.target.value);
30
31
  },
31
32
  []
32
- ), w = m(
33
+ ), w = g(
33
34
  (e) => {
34
- const { value: a } = e.target, n = new Set(o);
35
- n.has(a) ? n.delete(a) : n.add(a), p(n);
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, o]
38
+ [p, t]
38
39
  );
39
- return /* @__PURE__ */ s("div", { children: [
40
- /* @__PURE__ */ s(z, { children: [
40
+ return /* @__PURE__ */ i("div", { children: [
41
+ /* @__PURE__ */ i($, { children: [
41
42
  /* @__PURE__ */ l(
42
- R,
43
+ H,
43
44
  {
44
45
  name: `${h}-search`,
45
- onChange: b,
46
- placeholder: g,
47
- value: c
46
+ onChange: f,
47
+ placeholder: y,
48
+ value: s
48
49
  }
49
50
  ),
50
51
  /* @__PURE__ */ l(
51
- i,
52
+ n,
52
53
  {
53
54
  "aria-live": "polite",
54
- color: t.palette.gray[600],
55
+ color: a.palette.gray[600],
55
56
  display: "inline",
56
57
  size: "md",
57
58
  whiteSpace: "nowrap",
58
- children: v(f, r.length)
59
+ children: v(S, o.length)
59
60
  }
60
61
  )
61
62
  ] }),
62
- u.length === 0 && d !== void 0 ? /* @__PURE__ */ l(i, { color: t.palette.gray[600], py: 1, size: "md", children: d }) : /* @__PURE__ */ l($, { $maxHeight: y, children: u.map((e) => /* @__PURE__ */ l(k, { children: /* @__PURE__ */ l(
63
- H,
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: o.has(e.value),
67
- label: /* @__PURE__ */ s(j, { children: [
68
- /* @__PURE__ */ l(
69
- i,
70
- {
71
- color: t.palette.gray[800],
72
- display: "inline",
73
- size: "md",
74
- children: e.label
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
- i,
83
+ n,
79
84
  {
80
- color: t.palette.gray[600],
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
- I as SelectableList
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
- export { Default };
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('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>>> & string;
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
- export { StyledList, StyledListHeader, StyledListRow, StyledRowContent };
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
- `, l = e.ul`
14
- ${({ theme: t, $maxHeight: i }) => `
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: ${i};
18
+ max-height: ${a};
19
19
  overflow-y: auto;
20
20
  padding: 0;
21
21
  `}
22
- `, a = e.li`
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
- l as StyledList,
68
+ o as StyledList,
59
69
  n as StyledListHeader,
60
- a as StyledListRow,
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
@@ -135,5 +135,5 @@
135
135
  "./dist/index.js"
136
136
  ],
137
137
  "typings": "./dist/index.d.ts",
138
- "version": "11.9.0"
138
+ "version": "11.10.0"
139
139
  }