@fluidattacks/design 10.2.0 → 10.3.1
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/filters/hooks.d.ts +4 -1
- package/dist/components/filters/hooks.js +35 -17
- package/dist/components/filters/options-menu/include-exclude/multi-select.d.ts +5 -1
- package/dist/components/filters/options-menu/include-exclude/multi-select.js +142 -112
- package/dist/components/filters/options-menu/index.js +156 -151
- package/dist/components/filters/options-menu/options/index.js +141 -114
- package/dist/components/filters/options-menu/options/types.d.ts +1 -0
- package/dist/components/filters/options-menu/single-select/index.js +83 -97
- package/dist/components/filters/options-menu/single-select/styles.d.ts +1 -2
- package/dist/components/filters/options-menu/single-select/styles.js +5 -22
- package/dist/components/filters/styles.d.ts +2 -1
- package/dist/components/filters/styles.js +27 -10
- package/dist/components/filters/types.d.ts +2 -2
- package/dist/components/toggle/styles.js +6 -4
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useFloating } from '@floating-ui/react';
|
|
1
2
|
import { ICalendarState, IScrollState, ISearchState } from './context/types';
|
|
2
3
|
declare const useFilterSearchState: () => {
|
|
3
4
|
searchState: ISearchState;
|
|
@@ -9,4 +10,6 @@ declare const useFilterScrollState: () => {
|
|
|
9
10
|
declare const useFilterCalendarState: () => {
|
|
10
11
|
calendarState: ICalendarState;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
/** Floats a dropdown under its bar, as wide as the bar and kept on screen. */
|
|
14
|
+
declare const useFloatingDropdown: () => ReturnType<typeof useFloating>;
|
|
15
|
+
export { useFilterSearchState, useFilterScrollState, useFilterCalendarState, useFloatingDropdown, };
|
|
@@ -1,25 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useFloating as c } from "../../node_modules/@floating-ui/react/dist/floating-ui.react.js";
|
|
2
|
+
import { useState as s, useCallback as n, useRef as i, useMemo as d } from "react";
|
|
3
|
+
import { autoUpdate as p } from "../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
4
|
+
import { offset as u, flip as S, shift as f, size as m } from "../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js";
|
|
5
|
+
const C = () => {
|
|
6
|
+
const [t, e] = s({
|
|
4
7
|
previousValue: ""
|
|
5
|
-
}), a =
|
|
8
|
+
}), a = n(
|
|
6
9
|
(r) => {
|
|
7
|
-
|
|
10
|
+
e((l) => ({ ...l, ...r }));
|
|
8
11
|
},
|
|
9
12
|
[]
|
|
10
13
|
);
|
|
11
|
-
return { searchState:
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
return { scrollState:
|
|
15
|
-
},
|
|
16
|
-
const [
|
|
17
|
-
|
|
14
|
+
return { searchState: t, updateSearch: a };
|
|
15
|
+
}, O = () => {
|
|
16
|
+
const t = i(null);
|
|
17
|
+
return { scrollState: d(() => ({ ref: t }), []) };
|
|
18
|
+
}, P = () => {
|
|
19
|
+
const [t, e] = s(!1), a = n((r) => {
|
|
20
|
+
e(r);
|
|
18
21
|
}, []);
|
|
19
|
-
return { calendarState: { isOpen:
|
|
20
|
-
}
|
|
22
|
+
return { calendarState: { isOpen: t, updateCalendarState: a } };
|
|
23
|
+
}, h = 4, o = 8, R = () => c({
|
|
24
|
+
middleware: [
|
|
25
|
+
u(h),
|
|
26
|
+
S({ padding: o }),
|
|
27
|
+
f({ padding: o }),
|
|
28
|
+
m({
|
|
29
|
+
apply: ({ elements: t, rects: e }) => {
|
|
30
|
+
t.floating.style.width = `${e.reference.width}px`;
|
|
31
|
+
},
|
|
32
|
+
padding: o
|
|
33
|
+
})
|
|
34
|
+
],
|
|
35
|
+
placement: "bottom-start",
|
|
36
|
+
whileElementsMounted: p
|
|
37
|
+
});
|
|
21
38
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
P as useFilterCalendarState,
|
|
40
|
+
O as useFilterScrollState,
|
|
41
|
+
C as useFilterSearchState,
|
|
42
|
+
R as useFloatingDropdown
|
|
25
43
|
};
|
|
@@ -12,7 +12,11 @@ interface IMultiSelectSearchProps {
|
|
|
12
12
|
onToggle: (value: string) => void;
|
|
13
13
|
/** When true, this dropdown opens on navigation (e.g. chip click). */
|
|
14
14
|
autoOpen?: boolean;
|
|
15
|
+
/** Whether the options and the summary show each value; otherwise only labels. */
|
|
16
|
+
showValues?: boolean;
|
|
17
|
+
/** Whether the dropdown floats above its container instead of being clipped by it. */
|
|
18
|
+
portal?: boolean;
|
|
15
19
|
}
|
|
16
|
-
declare const MultiSelectSearch: ({ name, items, selected, placeholder, onToggle, autoOpen, }: Readonly<IMultiSelectSearchProps>) => JSX.Element;
|
|
20
|
+
declare const MultiSelectSearch: ({ name, items, selected, placeholder, onToggle, autoOpen, showValues, portal, }: Readonly<IMultiSelectSearchProps>) => JSX.Element;
|
|
17
21
|
export type { IMultiSelectSearchProps };
|
|
18
22
|
export { MultiSelectSearch };
|
|
@@ -1,103 +1,123 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { jsxs as $, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { FloatingPortal as _ } from "../../../../node_modules/@floating-ui/react/dist/floating-ui.react.js";
|
|
3
|
+
import { useVirtualizer as A } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
|
|
4
|
+
import { useState as m, useRef as R, useMemo as g, useCallback as l, forwardRef as J } from "react";
|
|
5
|
+
import { useTheme as U } from "styled-components";
|
|
6
|
+
import { StyledCombobox as V, StyledBar as X, StyledChips as Y, StyledInput as Z, StyledToggle as ee, StyledList as te, StyledCode as oe, StyledDropdown as re } from "./styles.js";
|
|
7
|
+
import { useFloatingDropdown as ne } from "../../hooks.js";
|
|
8
|
+
import { NoMatches as le } from "../../search/no-matches/index.js";
|
|
9
|
+
import { StyledItem as ae, StyledFloatingDropdown as ie } from "../../styles.js";
|
|
10
|
+
import { matchesQuery as se } from "../../utils.js";
|
|
11
|
+
import { Checkbox as ce } from "../../../checkbox/index.js";
|
|
12
|
+
import { Icon as de } from "../../../icon/index.js";
|
|
13
|
+
import { useClickOutside as ue } from "../../../../hooks/use-click-outside.js";
|
|
14
|
+
const pe = 36, fe = J(function({ children: i, floatingStyle: r, id: u, portal: p, testId: f }, s) {
|
|
15
|
+
return p ? /* @__PURE__ */ o(_, { children: /* @__PURE__ */ o(
|
|
16
|
+
ie,
|
|
17
|
+
{
|
|
18
|
+
"data-testid": f,
|
|
19
|
+
id: u,
|
|
20
|
+
ref: s,
|
|
21
|
+
style: r,
|
|
22
|
+
children: i
|
|
23
|
+
}
|
|
24
|
+
) }) : /* @__PURE__ */ o(re, { "data-testid": f, id: u, children: i });
|
|
25
|
+
}), Ie = ({
|
|
26
|
+
name: n,
|
|
27
|
+
items: i,
|
|
28
|
+
selected: r,
|
|
29
|
+
placeholder: u,
|
|
30
|
+
onToggle: p,
|
|
31
|
+
autoOpen: f = !1,
|
|
32
|
+
showValues: s = !0,
|
|
33
|
+
portal: k = !1
|
|
19
34
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
() => new Set(
|
|
22
|
-
), [
|
|
23
|
-
() => [...
|
|
24
|
-
(e, t) => Number(
|
|
35
|
+
const T = U(), [a, D] = m(f), y = k ? `popover-${n}` : `${n}-dropdown`, { floatingStyles: O, refs: S } = ne(), [v, I] = m(""), [w, E] = m(
|
|
36
|
+
() => new Set(r)
|
|
37
|
+
), [j, P] = m(null), z = R(null), h = R(null), F = g(() => new Set(r), [r]), b = g(
|
|
38
|
+
() => [...i].sort(
|
|
39
|
+
(e, t) => Number(w.has(t.value)) - Number(w.has(e.value))
|
|
25
40
|
),
|
|
26
|
-
[
|
|
27
|
-
),
|
|
28
|
-
const e =
|
|
29
|
-
return e === "" ?
|
|
30
|
-
(t) =>
|
|
41
|
+
[i, w]
|
|
42
|
+
), C = g(() => {
|
|
43
|
+
const e = v.trim().toLowerCase();
|
|
44
|
+
return e === "" ? b : b.filter(
|
|
45
|
+
(t) => se(t, e)
|
|
31
46
|
);
|
|
32
|
-
}, [
|
|
33
|
-
() =>
|
|
47
|
+
}, [v, b]), M = l(
|
|
48
|
+
() => z.current,
|
|
34
49
|
[]
|
|
35
|
-
),
|
|
36
|
-
count:
|
|
37
|
-
estimateSize:
|
|
38
|
-
getScrollElement:
|
|
50
|
+
), N = l(() => pe, []), x = A({
|
|
51
|
+
count: C.length,
|
|
52
|
+
estimateSize: N,
|
|
53
|
+
getScrollElement: M,
|
|
39
54
|
overscan: 6,
|
|
40
55
|
useFlushSync: !1
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
-
}, [
|
|
56
|
+
}), B = x.getVirtualItems(), c = l(() => {
|
|
57
|
+
E(new Set(r)), I(""), D(!1);
|
|
58
|
+
}, [r]), d = l(() => {
|
|
59
|
+
E(new Set(r)), D(!0);
|
|
60
|
+
}, [r]), H = l(
|
|
46
61
|
(e) => {
|
|
47
|
-
e.preventDefault(), e.stopPropagation(), a ?
|
|
62
|
+
e.preventDefault(), e.stopPropagation(), a ? c() : (h.current?.focus(), d());
|
|
48
63
|
},
|
|
49
|
-
[a,
|
|
50
|
-
),
|
|
51
|
-
|
|
52
|
-
}, [
|
|
64
|
+
[a, c, d]
|
|
65
|
+
), K = l(() => {
|
|
66
|
+
h.current?.focus(), d();
|
|
67
|
+
}, [d]), L = l(
|
|
53
68
|
(e) => (t) => {
|
|
54
|
-
t.stopPropagation(),
|
|
69
|
+
t.stopPropagation(), p(e);
|
|
55
70
|
},
|
|
56
|
-
[
|
|
57
|
-
),
|
|
71
|
+
[p]
|
|
72
|
+
), Q = l(
|
|
58
73
|
(e) => {
|
|
59
|
-
|
|
74
|
+
I(e.target.value);
|
|
60
75
|
},
|
|
61
76
|
[]
|
|
62
|
-
),
|
|
77
|
+
), W = l(
|
|
63
78
|
(e) => {
|
|
64
|
-
e.key === "Enter" ? e.preventDefault() : e.key === "Escape" && (
|
|
79
|
+
e.key === "Enter" ? e.preventDefault() : e.key === "Escape" && (c(), h.current?.blur());
|
|
65
80
|
},
|
|
66
|
-
[
|
|
67
|
-
),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
[c]
|
|
82
|
+
), q = g(() => {
|
|
83
|
+
const e = s ? r : r.map(
|
|
84
|
+
(t) => i.find((G) => G.value === t)?.label ?? t
|
|
85
|
+
);
|
|
86
|
+
return e.length === 0 ? "" : e.length <= 2 ? e.join(", ") : `${e.slice(0, 2).join(", ")}, +${e.length - 2} more`;
|
|
87
|
+
}, [i, r, s]);
|
|
88
|
+
return ue(a ? j : null, c, [S.floating]), /* @__PURE__ */ $(V, { ref: P, children: [
|
|
89
|
+
/* @__PURE__ */ $(X, { onClick: K, ref: S.setReference, children: [
|
|
90
|
+
/* @__PURE__ */ o(Y, { children: /* @__PURE__ */ o(
|
|
91
|
+
Z,
|
|
72
92
|
{
|
|
73
|
-
"aria-controls":
|
|
93
|
+
"aria-controls": y,
|
|
74
94
|
"aria-expanded": a,
|
|
75
|
-
"aria-label": `${
|
|
95
|
+
"aria-label": `${n}-search`,
|
|
76
96
|
autoComplete: "off",
|
|
77
|
-
id: `${
|
|
78
|
-
name: `${
|
|
79
|
-
onChange:
|
|
80
|
-
onFocus:
|
|
81
|
-
onKeyDown:
|
|
82
|
-
placeholder:
|
|
83
|
-
ref:
|
|
97
|
+
id: `${n}-search`,
|
|
98
|
+
name: `${n}-search`,
|
|
99
|
+
onChange: Q,
|
|
100
|
+
onFocus: d,
|
|
101
|
+
onKeyDown: W,
|
|
102
|
+
placeholder: u,
|
|
103
|
+
ref: h,
|
|
84
104
|
type: "search",
|
|
85
|
-
value: a ?
|
|
105
|
+
value: a ? v : q
|
|
86
106
|
}
|
|
87
107
|
) }),
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
|
|
108
|
+
/* @__PURE__ */ o(
|
|
109
|
+
ee,
|
|
90
110
|
{
|
|
91
|
-
"aria-controls":
|
|
111
|
+
"aria-controls": y,
|
|
92
112
|
"aria-expanded": a,
|
|
93
|
-
"aria-label": `${
|
|
94
|
-
onClick:
|
|
113
|
+
"aria-label": `${n}-toggle`,
|
|
114
|
+
onClick: H,
|
|
95
115
|
type: "button",
|
|
96
|
-
children: /* @__PURE__ */
|
|
97
|
-
|
|
116
|
+
children: /* @__PURE__ */ o(
|
|
117
|
+
de,
|
|
98
118
|
{
|
|
99
119
|
icon: a ? "chevron-up" : "chevron-down",
|
|
100
|
-
iconColor:
|
|
120
|
+
iconColor: T.palette.gray[700],
|
|
101
121
|
iconSize: "sm",
|
|
102
122
|
iconType: "fa-light"
|
|
103
123
|
}
|
|
@@ -105,48 +125,58 @@ const oe = 36, me = ({
|
|
|
105
125
|
}
|
|
106
126
|
)
|
|
107
127
|
] }),
|
|
108
|
-
a ? /* @__PURE__ */
|
|
109
|
-
|
|
128
|
+
a ? /* @__PURE__ */ o(
|
|
129
|
+
fe,
|
|
110
130
|
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
style: {
|
|
124
|
-
left: 0,
|
|
125
|
-
position: "absolute",
|
|
126
|
-
top: `${e.start}px`,
|
|
127
|
-
width: "100%"
|
|
128
|
-
},
|
|
129
|
-
children: /* @__PURE__ */ r(X, { "aria-selected": $.has(t.value), children: /* @__PURE__ */ r(
|
|
130
|
-
Z,
|
|
131
|
-
{
|
|
132
|
-
checked: $.has(t.value),
|
|
133
|
-
label: /* @__PURE__ */ y("span", { children: [
|
|
134
|
-
/* @__PURE__ */ r(J, { children: t.value }),
|
|
135
|
-
t.label
|
|
136
|
-
] }),
|
|
137
|
-
name: t.value,
|
|
138
|
-
onChange: P(t.value),
|
|
139
|
-
value: t.value
|
|
140
|
-
}
|
|
141
|
-
) })
|
|
131
|
+
floatingStyle: O,
|
|
132
|
+
id: y,
|
|
133
|
+
portal: k,
|
|
134
|
+
ref: S.setFloating,
|
|
135
|
+
testId: `${n}-dropdown`,
|
|
136
|
+
children: /* @__PURE__ */ o(te, { ref: z, role: "listbox", children: C.length > 0 ? /* @__PURE__ */ o(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
style: {
|
|
140
|
+
height: `${x.getTotalSize()}px`,
|
|
141
|
+
position: "relative",
|
|
142
|
+
width: "100%"
|
|
142
143
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
children: B.map((e) => {
|
|
145
|
+
const t = C[e.index];
|
|
146
|
+
return /* @__PURE__ */ o(
|
|
147
|
+
"div",
|
|
148
|
+
{
|
|
149
|
+
"data-index": e.index,
|
|
150
|
+
ref: x.measureElement,
|
|
151
|
+
style: {
|
|
152
|
+
left: 0,
|
|
153
|
+
position: "absolute",
|
|
154
|
+
top: `${e.start}px`,
|
|
155
|
+
width: "100%"
|
|
156
|
+
},
|
|
157
|
+
children: /* @__PURE__ */ o(ae, { "aria-selected": F.has(t.value), children: /* @__PURE__ */ o(
|
|
158
|
+
ce,
|
|
159
|
+
{
|
|
160
|
+
checked: F.has(t.value),
|
|
161
|
+
label: s ? /* @__PURE__ */ $("span", { children: [
|
|
162
|
+
/* @__PURE__ */ o(oe, { children: t.value }),
|
|
163
|
+
t.label
|
|
164
|
+
] }) : t.label,
|
|
165
|
+
name: t.value,
|
|
166
|
+
onChange: L(t.value),
|
|
167
|
+
value: t.value
|
|
168
|
+
}
|
|
169
|
+
) })
|
|
170
|
+
},
|
|
171
|
+
`${n}-${t.value}`
|
|
172
|
+
);
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
) : /* @__PURE__ */ o(le, {}) })
|
|
146
176
|
}
|
|
147
|
-
) :
|
|
177
|
+
) : void 0
|
|
148
178
|
] });
|
|
149
179
|
};
|
|
150
180
|
export {
|
|
151
|
-
|
|
181
|
+
Ie as MultiSelectSearch
|
|
152
182
|
};
|