@fluidattacks/design 10.2.0 → 10.3.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,122 +1,108 @@
1
- import { jsxs as w, jsx as n } from "react/jsx-runtime";
2
- import { useFloating as Q, FloatingPortal as U } from "../../../../node_modules/@floating-ui/react/dist/floating-ui.react.js";
3
- import { useVirtualizer as q } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
4
- import { useState as m, useRef as k, useMemo as A, useCallback as i } from "react";
5
- import { useTheme as Y } from "styled-components";
6
- import { StyledFloatingDropdown as J, StyledOption as X } from "./styles.js";
7
- import { NoMatches as Z } from "../../search/no-matches/index.js";
8
- import { matchesQuery as ee } from "../../utils.js";
9
- import { StyledCombobox as te, StyledBar as oe, StyledChips as ne, StyledInput as re, StyledToggle as ie, StyledList as le } from "../include-exclude/styles.js";
10
- import { Icon as N } from "../../../icon/index.js";
1
+ import { jsxs as S, jsx as n } from "react/jsx-runtime";
2
+ import { FloatingPortal as Q } from "../../../../node_modules/@floating-ui/react/dist/floating-ui.react.js";
3
+ import { useVirtualizer as W } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
4
+ import { useState as m, useRef as k, useMemo as D, useCallback as i } from "react";
5
+ import { useTheme as q } from "styled-components";
6
+ import { StyledOption as U } from "./styles.js";
7
+ import { useFloatingDropdown as Y } from "../../hooks.js";
8
+ import { NoMatches as J } from "../../search/no-matches/index.js";
9
+ import { StyledFloatingDropdown as X } from "../../styles.js";
10
+ import { matchesQuery as Z } from "../../utils.js";
11
+ import { StyledCombobox as ee, StyledBar as te, StyledChips as oe, StyledInput as ne, StyledToggle as re, StyledList as ie } from "../include-exclude/styles.js";
12
+ import { Icon as z } from "../../../icon/index.js";
11
13
  import "../../../typography/heading/index.js";
12
- import { Span as ae } from "../../../typography/span/index.js";
14
+ import { Span as le } from "../../../typography/span/index.js";
13
15
  import "../../../typography/text/index.js";
14
- import { useClickOutside as se } from "../../../../hooks/use-click-outside.js";
15
- import { autoUpdate as ce } from "../../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
16
- import { offset as de, flip as pe, shift as fe, size as ue } from "../../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js";
17
- const he = 36, me = 4, S = 8, g = -1, ge = [
16
+ import { useClickOutside as ae } from "../../../../hooks/use-click-outside.js";
17
+ const se = 36, g = -1, ce = [
18
18
  "ArrowDown",
19
19
  "ArrowUp",
20
20
  "Home",
21
21
  "End"
22
- ], ve = (o, l, a) => o === "Home" ? 0 : o === "End" ? a : o === "ArrowDown" ? l >= a ? 0 : l + 1 : l <= 0 ? a : l - 1, Pe = ({
22
+ ], pe = (o, l, a) => o === "Home" ? 0 : o === "End" ? a : o === "ArrowDown" ? l >= a ? 0 : l + 1 : l <= 0 ? a : l - 1, Te = ({
23
23
  name: o,
24
24
  items: l,
25
25
  selected: a,
26
- placeholder: z,
27
- onSelect: b
26
+ placeholder: A,
27
+ onSelect: w
28
28
  }) => {
29
- const I = Y(), [r, O] = m(!1), [v, C] = m(""), [d, y] = m(g), [P, R] = m(null), $ = k(null), u = k(null), { floatingStyles: F, refs: x } = Q({
30
- middleware: [
31
- de(me),
32
- pe({ padding: S }),
33
- fe({ padding: S }),
34
- ue({
35
- apply: ({ elements: e, rects: t }) => {
36
- e.floating.style.width = `${t.reference.width}px`;
37
- },
38
- padding: S
39
- })
40
- ],
41
- placement: "bottom-start",
42
- whileElementsMounted: ce
43
- }), s = A(() => {
29
+ const b = q(), [r, C] = m(!1), [v, I] = m(""), [p, y] = m(g), [N, F] = m(null), $ = k(null), f = k(null), { floatingStyles: P, refs: x } = Y(), s = D(() => {
44
30
  const e = v.trim().toLowerCase();
45
- return e === "" ? [...l] : l.filter((t) => ee(t, e));
46
- }, [v, l]), _ = i(
31
+ return e === "" ? [...l] : l.filter((t) => Z(t, e));
32
+ }, [v, l]), R = i(
47
33
  () => $.current,
48
34
  []
49
- ), V = i(() => he, []), f = q({
35
+ ), H = i(() => se, []), u = W({
50
36
  count: s.length,
51
- estimateSize: V,
52
- getScrollElement: _,
37
+ estimateSize: H,
38
+ getScrollElement: R,
53
39
  overscan: 6,
54
40
  useFlushSync: !1
55
- }), G = f.getVirtualItems(), c = i(() => {
56
- C(""), y(g), O(!1);
57
- }, []), p = i(() => {
58
- O(!0);
59
- }, []), H = i(
41
+ }), V = u.getVirtualItems(), c = i(() => {
42
+ I(""), y(g), C(!1);
43
+ }, []), d = i(() => {
44
+ C(!0);
45
+ }, []), _ = i(
60
46
  (e) => {
61
- e.preventDefault(), e.stopPropagation(), r ? c() : (u.current?.focus(), p());
47
+ e.preventDefault(), e.stopPropagation(), r ? c() : (f.current?.focus(), d());
62
48
  },
63
- [r, c, p]
64
- ), W = i(() => {
65
- u.current?.focus(), p();
66
- }, [p]), h = i(
49
+ [r, c, d]
50
+ ), K = i(() => {
51
+ f.current?.focus(), d();
52
+ }, [d]), h = i(
67
53
  (e) => {
68
- b(e)(), c();
54
+ w(e)(), c();
69
55
  },
70
- [b, c]
71
- ), K = i(
56
+ [w, c]
57
+ ), L = i(
72
58
  (e) => (t) => {
73
59
  t.stopPropagation(), h(e);
74
60
  },
75
61
  [h]
76
- ), L = i(
62
+ ), j = i(
77
63
  (e) => {
78
- C(e.target.value), y(g);
64
+ I(e.target.value), y(g);
79
65
  },
80
66
  []
81
- ), E = i(
67
+ ), O = i(
82
68
  (e) => {
83
69
  if (!r) {
84
- p();
70
+ d();
85
71
  return;
86
72
  }
87
73
  if (s.length === 0) return;
88
- const t = ve(e, d, s.length - 1);
89
- y(t), f.scrollToIndex(t);
74
+ const t = pe(e, p, s.length - 1);
75
+ y(t), u.scrollToIndex(t);
90
76
  },
91
- [d, s.length, p, r, f]
92
- ), M = i(
77
+ [p, s.length, d, r, u]
78
+ ), B = i(
93
79
  (e) => {
94
80
  const { key: t } = e;
95
81
  if (t === "Escape")
96
- c(), u.current?.blur();
82
+ c(), f.current?.blur();
97
83
  else if (t === "Tab")
98
84
  r && c();
99
85
  else if (t === "Enter") {
100
86
  e.preventDefault();
101
- const D = r ? s[d] : void 0;
102
- D !== void 0 && h(D.value);
103
- } else ge.includes(t) && (e.preventDefault(), E(t));
87
+ const E = r ? s[p] : void 0;
88
+ E !== void 0 && h(E.value);
89
+ } else ce.includes(t) && (e.preventDefault(), O(t));
104
90
  },
105
- [d, s, c, E, r, h]
106
- ), j = A(() => {
91
+ [p, s, c, O, r, h]
92
+ ), G = D(() => {
107
93
  if (a === null || a === "") return "";
108
94
  const e = l.find((t) => t.value === a);
109
95
  return e?.label ?? e?.value ?? "";
110
96
  }, [l, a]), T = i(
111
97
  (e) => `${o}-option-${e}`,
112
98
  [o]
113
- ), B = d === g ? void 0 : T(d);
114
- return se(r ? P : null, c, [x.floating]), /* @__PURE__ */ w(te, { ref: R, children: [
115
- /* @__PURE__ */ w(oe, { onClick: W, ref: x.setReference, children: [
116
- /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(
117
- re,
99
+ ), M = p === g ? void 0 : T(p);
100
+ return ae(r ? N : null, c, [x.floating]), /* @__PURE__ */ S(ee, { ref: F, children: [
101
+ /* @__PURE__ */ S(te, { onClick: K, ref: x.setReference, children: [
102
+ /* @__PURE__ */ n(oe, { children: /* @__PURE__ */ n(
103
+ ne,
118
104
  {
119
- "aria-activedescendant": B,
105
+ "aria-activedescendant": M,
120
106
  "aria-autocomplete": "list",
121
107
  "aria-controls": `popover-${o}`,
122
108
  "aria-expanded": r,
@@ -124,29 +110,29 @@ const he = 36, me = 4, S = 8, g = -1, ge = [
124
110
  autoComplete: "off",
125
111
  id: `${o}-search`,
126
112
  name: `${o}-search`,
127
- onChange: L,
128
- onFocus: p,
129
- onKeyDown: M,
130
- placeholder: z,
131
- ref: u,
113
+ onChange: j,
114
+ onFocus: d,
115
+ onKeyDown: B,
116
+ placeholder: A,
117
+ ref: f,
132
118
  role: "combobox",
133
119
  type: "search",
134
- value: r ? v : j
120
+ value: r ? v : G
135
121
  }
136
122
  ) }),
137
123
  /* @__PURE__ */ n(
138
- ie,
124
+ re,
139
125
  {
140
126
  "aria-controls": `popover-${o}`,
141
127
  "aria-expanded": r,
142
128
  "aria-label": `${o}-toggle`,
143
- onClick: H,
129
+ onClick: _,
144
130
  type: "button",
145
131
  children: /* @__PURE__ */ n(
146
- N,
132
+ z,
147
133
  {
148
134
  icon: r ? "chevron-up" : "chevron-down",
149
- iconColor: I.palette.gray[700],
135
+ iconColor: b.palette.gray[700],
150
136
  iconSize: "sm",
151
137
  iconType: "fa-light"
152
138
  }
@@ -154,29 +140,29 @@ const he = 36, me = 4, S = 8, g = -1, ge = [
154
140
  }
155
141
  )
156
142
  ] }),
157
- r ? /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
158
- J,
143
+ r ? /* @__PURE__ */ n(Q, { children: /* @__PURE__ */ n(
144
+ X,
159
145
  {
160
146
  "data-testid": `${o}-dropdown`,
161
147
  id: `popover-${o}`,
162
148
  ref: x.setFloating,
163
- style: F,
164
- children: /* @__PURE__ */ n(le, { ref: $, role: "listbox", children: s.length > 0 ? /* @__PURE__ */ n(
149
+ style: P,
150
+ children: /* @__PURE__ */ n(ie, { ref: $, role: "listbox", children: s.length > 0 ? /* @__PURE__ */ n(
165
151
  "div",
166
152
  {
167
153
  role: "presentation",
168
154
  style: {
169
- height: `${f.getTotalSize()}px`,
155
+ height: `${u.getTotalSize()}px`,
170
156
  position: "relative",
171
157
  width: "100%"
172
158
  },
173
- children: G.map((e) => {
159
+ children: V.map((e) => {
174
160
  const t = s[e.index];
175
161
  return /* @__PURE__ */ n(
176
162
  "div",
177
163
  {
178
164
  "data-index": e.index,
179
- ref: f.measureElement,
165
+ ref: u.measureElement,
180
166
  role: "presentation",
181
167
  style: {
182
168
  left: 0,
@@ -184,22 +170,22 @@ const he = 36, me = 4, S = 8, g = -1, ge = [
184
170
  top: `${e.start}px`,
185
171
  width: "100%"
186
172
  },
187
- children: /* @__PURE__ */ w(
188
- X,
173
+ children: /* @__PURE__ */ S(
174
+ U,
189
175
  {
190
176
  "aria-selected": t.value === a,
191
177
  as: "button",
192
- "data-active": e.index === d,
178
+ "data-active": e.index === p,
193
179
  id: T(e.index),
194
- onClick: K(t.value),
180
+ onClick: L(t.value),
195
181
  role: "option",
196
182
  tabIndex: -1,
197
183
  type: "button",
198
184
  children: [
199
185
  /* @__PURE__ */ n(
200
- ae,
186
+ le,
201
187
  {
202
- color: I.palette.gray[800],
188
+ color: b.palette.gray[800],
203
189
  display: "block",
204
190
  overflow: "hidden",
205
191
  size: "md",
@@ -211,7 +197,7 @@ const he = 36, me = 4, S = 8, g = -1, ge = [
211
197
  ),
212
198
  /* @__PURE__ */ n("span", { className: "filter-item" }),
213
199
  t.value === a ? /* @__PURE__ */ n("div", { style: { marginLeft: "auto" }, children: /* @__PURE__ */ n(
214
- N,
200
+ z,
215
201
  {
216
202
  icon: "check",
217
203
  iconClass: "selected",
@@ -227,11 +213,11 @@ const he = 36, me = 4, S = 8, g = -1, ge = [
227
213
  );
228
214
  })
229
215
  }
230
- ) : /* @__PURE__ */ n(Z, {}) })
216
+ ) : /* @__PURE__ */ n(J, {}) })
231
217
  }
232
218
  ) }) : void 0
233
219
  ] });
234
220
  };
235
221
  export {
236
- Pe as SingleSelectSearch
222
+ Te as SingleSelectSearch
237
223
  };
@@ -9,5 +9,4 @@ declare const StyledOption: import('styled-components/dist/types').IStyledCompon
9
9
  }, "ref"> & {
10
10
  ref?: ((instance: HTMLDivElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLDivElement> | null | undefined;
11
11
  }, never>>> & string;
12
- declare const StyledFloatingDropdown: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
13
- export { StyledFloatingDropdown, StyledOption };
12
+ export { StyledOption };
@@ -1,33 +1,16 @@
1
1
  import t from "styled-components";
2
- import { StyledItem as e } from "../../styles.js";
3
- const s = t(e)`
4
- ${({ theme: o }) => `
2
+ import { StyledItem as o } from "../../styles.js";
3
+ const a = t(o)`
4
+ ${({ theme: e }) => `
5
5
  /*
6
6
  * Focus never leaves the input, so the keyboard cursor has no :focus to
7
7
  * ride on. It gets the same shade the mouse gets on hover.
8
8
  */
9
9
  &[data-active="true"] {
10
- background: ${o.palette.gray[100]};
10
+ background: ${e.palette.gray[100]};
11
11
  }
12
12
  `}
13
- `, d = t.div`
14
- ${({ theme: o }) => `
15
- background-color: ${o.palette.white};
16
- border: 1px solid ${o.palette.gray[200]};
17
- border-radius: ${o.spacing[0.5]};
18
- box-shadow: ${o.shadows.md};
19
- overflow: hidden;
20
- /*
21
- * scrollbar-color is inherited, and the portal takes this out of the
22
- * subtree that provides it, so the themed bar is restated here.
23
- */
24
- scrollbar-color: ${o.palette.gray[600]} ${o.palette.gray[100]};
25
- scroll-padding: ${o.spacing[0.5]};
26
- /* The options panel sits at 99999, and this floats above it. */
27
- z-index: 100000;
28
- `}
29
13
  `;
30
14
  export {
31
- d as StyledFloatingDropdown,
32
- s as StyledOption
15
+ a as StyledOption
33
16
  };
@@ -21,4 +21,5 @@ declare const StyledActionButton: import('styled-components/dist/types').IStyled
21
21
  }, never>>> & string;
22
22
  declare const StyledActiveFilters: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
23
23
  declare const StyledItemCount: 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;
24
- export { StyledActionButton, StyledModalContainer, StyledHeader, StyledContent, StyledFloatingActions, StyledItem, StyledItemCount, StyledActiveFilters, };
24
+ declare const StyledFloatingDropdown: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
25
+ export { StyledActionButton, StyledModalContainer, StyledHeader, StyledContent, StyledFloatingActions, StyledFloatingDropdown, StyledItem, StyledItemCount, StyledActiveFilters, };
@@ -1,5 +1,5 @@
1
1
  import { styled as i } from "styled-components";
2
- import { sharedStyles as o } from "../link/styles.js";
2
+ import { sharedStyles as e } from "../link/styles.js";
3
3
  const s = i.div`
4
4
  ${({ theme: t, $left: a = "0" }) => `
5
5
  align-items: flex-start;
@@ -26,7 +26,7 @@ const s = i.div`
26
26
  padding: ${t.spacing[0.875]} ${t.spacing[0.875]} 0 ${t.spacing[0.875]};
27
27
  width: 100%;
28
28
  `}
29
- `, p = i.div`
29
+ `, r = i.div`
30
30
  ${({ theme: t }) => `
31
31
  background-color: ${t.palette.white};
32
32
  border-radius: 0 ${t.spacing[0.5]} 0 0;
@@ -38,14 +38,14 @@ const s = i.div`
38
38
  top: 0;
39
39
  z-index: 1;
40
40
  `}
41
- `, r = i.div`
42
- ${({ theme: t, $border: a, $overflow: n }) => `
41
+ `, p = i.div`
42
+ ${({ theme: t, $border: a, $overflow: o }) => `
43
43
  align-items: flex-start;
44
44
  border-top: ${a ? `1px solid ${t.palette.gray[200]}` : "unset"};
45
45
  display: flex;
46
46
  flex-direction: column;
47
47
  justify-content: center;
48
- overflow: ${n ? "hidden auto" : "unset"};
48
+ overflow: ${o ? "hidden auto" : "unset"};
49
49
  padding: ${t.spacing[0.875]};
50
50
  width: 100%;
51
51
 
@@ -84,7 +84,7 @@ const s = i.div`
84
84
  }
85
85
  `}
86
86
  `, g = i.button`
87
- ${o}
87
+ ${e}
88
88
  min-width: fit-content;
89
89
  `, $ = i.div`
90
90
  ${({ theme: t }) => `
@@ -106,16 +106,33 @@ const s = i.div`
106
106
  margin-left: auto;
107
107
  }
108
108
  `}
109
- `, f = i.span`
109
+ `, y = i.span`
110
110
  margin-left: auto;
111
+ `, f = i.div`
112
+ ${({ theme: t }) => `
113
+ background-color: ${t.palette.white};
114
+ border: 1px solid ${t.palette.gray[200]};
115
+ border-radius: ${t.spacing[0.5]};
116
+ box-shadow: ${t.shadows.md};
117
+ overflow: hidden;
118
+ /*
119
+ * scrollbar-color is inherited, and the portal takes this out of the
120
+ * subtree that provides it, so the themed bar is restated here.
121
+ */
122
+ scrollbar-color: ${t.palette.gray[600]} ${t.palette.gray[100]};
123
+ scroll-padding: ${t.spacing[0.5]};
124
+ /* The options panel sits at 99999, and this floats above it. */
125
+ z-index: 100000;
126
+ `}
111
127
  `;
112
128
  export {
113
129
  g as StyledActionButton,
114
130
  $ as StyledActiveFilters,
115
- r as StyledContent,
116
- p as StyledFloatingActions,
131
+ p as StyledContent,
132
+ r as StyledFloatingActions,
133
+ f as StyledFloatingDropdown,
117
134
  d as StyledHeader,
118
135
  c as StyledItem,
119
- f as StyledItemCount,
136
+ y as StyledItemCount,
120
137
  s as StyledModalContainer
121
138
  };
@@ -3,7 +3,7 @@ import { default as React } from 'react';
3
3
  import { TSearchValues, TSetSearchValues } from './context/types';
4
4
  import { IIconModifiable } from '../@core';
5
5
  import { IUseFiltersReturn } from '../../hooks/use-filters';
6
- type TFilterType = "checkboxes" | "combobox" | "dateRange" | "numberRange" | "includeExclude" | "list" | "text";
6
+ type TFilterType = "checkboxes" | "combobox" | "dateRange" | "numberRange" | "includeExclude" | "list" | "multiSelect" | "text";
7
7
  /** The side a chip belongs to in an includeExclude filter. */
8
8
  type TIncludeExcludeMode = "include" | "exclude";
9
9
  /** Active filter properties. */
@@ -52,7 +52,7 @@ interface IFilterItem {
52
52
  label?: string;
53
53
  /** How many records match this option. Rendered right-aligned when set. */
54
54
  count?: number;
55
- /** Extra terms the combobox and includeExclude searches match without rendering them. */
55
+ /** Extra terms the combobox, multiSelect and includeExclude searches match without rendering them. */
56
56
  searchTerms?: readonly string[];
57
57
  }
58
58
  /** Filter option properties. */
package/package.json CHANGED
@@ -135,5 +135,5 @@
135
135
  "./dist/index.js"
136
136
  ],
137
137
  "typings": "./dist/index.d.ts",
138
- "version": "10.2.0"
138
+ "version": "10.3.0"
139
139
  }