@mittwald/flow-react-components 0.1.0-alpha.57 → 0.1.0-alpha.59

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.
Files changed (69) hide show
  1. package/dist/{Button-h6RkBrWE.js → Button-DTVMsKTK.js} +1 -1
  2. package/dist/Button.js +1 -1
  3. package/dist/ContextMenu.js +7 -65
  4. package/dist/ContextMenuItem-Cc7czdsZ.js +67 -0
  5. package/dist/CopyButton.js +1 -1
  6. package/dist/FieldDescription.js +1 -1
  7. package/dist/IconChevronDown-C3dBD472.js +9 -0
  8. package/dist/IconPlus-DXNLmWa2.js +11 -0
  9. package/dist/Icons.js +69 -68
  10. package/dist/List.js +303 -219
  11. package/dist/NumberField.js +8 -8
  12. package/dist/StatusBadge.js +1 -1
  13. package/dist/Text-c5-UeE0Y.js +43 -0
  14. package/dist/Text.js +1 -1
  15. package/dist/styles.css +1 -1
  16. package/dist/types/components/EmulatedBoldText/EmulatedBoldText.d.ts +6 -0
  17. package/dist/types/components/EmulatedBoldText/index.d.ts +4 -0
  18. package/dist/types/components/EmulatedBoldText/stories/Default.stories.d.ts +7 -0
  19. package/dist/types/components/Icon/components/icons/IconSubdomain.d.ts +5 -0
  20. package/dist/types/components/Icon/components/icons/index.d.ts +1 -0
  21. package/dist/types/components/List/List.d.ts +1 -3
  22. package/dist/types/components/List/components/Footer/Footer/Footer.d.ts +4 -0
  23. package/dist/types/components/List/components/Footer/Footer/index.d.ts +4 -0
  24. package/dist/types/components/List/components/{PaginationInfos → Footer/PaginationInfos}/PaginationInfos.d.ts +1 -1
  25. package/dist/types/components/List/components/{ShowNextBatchButton → Footer/ShowNextBatchButton}/ShowNextBatchButton.d.ts +1 -1
  26. package/dist/types/components/List/components/Header/ActiveFilters/ActiveFilters.d.ts +4 -0
  27. package/dist/types/components/List/components/Header/ActiveFilters/index.d.ts +4 -0
  28. package/dist/types/components/List/components/Header/FilterPicker/FilterPicker.d.ts +9 -0
  29. package/dist/types/components/List/components/{Items/Items.d.ts → Header/Header/Header.d.ts} +2 -2
  30. package/dist/types/components/List/components/Header/Header/index.d.ts +4 -0
  31. package/dist/types/components/List/components/{ListFilter.d.ts → Header/ListFilter.d.ts} +1 -1
  32. package/dist/types/components/List/components/{ListSorting.d.ts → Header/ListSorting.d.ts} +2 -1
  33. package/dist/types/components/List/components/{FilterBar/components → Header}/SortingPickerItem/SortingPickerItem.d.ts +2 -2
  34. package/dist/types/components/List/components/{Item → Items/Item}/FallbackRenderer.d.ts +1 -1
  35. package/dist/types/components/List/components/{Item → Items/Item}/index.d.ts +1 -0
  36. package/dist/types/components/List/components/{FilterBar/FilterBar.d.ts → Items/ItemList/ItemList.d.ts} +2 -2
  37. package/dist/types/components/List/components/Items/ItemList/index.d.ts +4 -0
  38. package/dist/types/components/List/components/{ListItemView.d.ts → Items/ListItemView.d.ts} +1 -1
  39. package/dist/types/components/List/index.d.ts +3 -3
  40. package/dist/types/components/List/model/List.d.ts +4 -1
  41. package/dist/types/components/List/model/filter/Filter.d.ts +4 -0
  42. package/dist/types/components/List/model/filter/types.d.ts +1 -0
  43. package/dist/types/components/List/model/sorting/Sorting.d.ts +6 -1
  44. package/dist/types/components/List/model/sorting/types.d.ts +4 -0
  45. package/dist/types/components/List/model/types.d.ts +0 -1
  46. package/dist/types/components/List/testData/domainApi.d.ts +25 -0
  47. package/dist/types/components/Text/Text.d.ts +1 -0
  48. package/dist/types/lib/react/components/Translate/Translate.d.ts +10 -0
  49. package/dist/types/lib/react/components/Translate/index.d.ts +4 -0
  50. package/package.json +32 -32
  51. package/dist/IconChevronUp-DJu_PD8w.js +0 -10
  52. package/dist/IconPlus-BZwxakYk.js +0 -10
  53. package/dist/Text-Dc6eN_n2.js +0 -29
  54. package/dist/deepHas-ocYuTM8M.js +0 -7
  55. package/dist/types/components/List/components/FilterBar/components/FilterPicker/FilterPicker.d.ts +0 -3
  56. package/dist/types/components/List/components/FilterBar/components/FilterPickerItem/FilterPickerItem.d.ts +0 -9
  57. package/dist/types/components/List/components/FilterBar/components/FilterPickerItem/index.d.ts +0 -4
  58. package/dist/types/components/List/components/FilterBar/index.d.ts +0 -4
  59. package/dist/types/components/List/components/Items/index.d.ts +0 -4
  60. package/dist/types/components/List/testData/userApi.d.ts +0 -57
  61. /package/dist/types/components/List/components/{PaginationInfos → Footer/PaginationInfos}/index.d.ts +0 -0
  62. /package/dist/types/components/List/components/{ShowNextBatchButton → Footer/ShowNextBatchButton}/index.d.ts +0 -0
  63. /package/dist/types/components/List/components/{FilterBar/components → Header}/FilterPicker/index.d.ts +0 -0
  64. /package/dist/types/components/List/components/{FilterBar/components → Header}/SortingPicker/SortingPicker.d.ts +0 -0
  65. /package/dist/types/components/List/components/{FilterBar/components → Header}/SortingPicker/index.d.ts +0 -0
  66. /package/dist/types/components/List/components/{FilterBar/components → Header}/SortingPickerItem/index.d.ts +0 -0
  67. /package/dist/types/components/List/components/{Item → Items/Item}/Item.d.ts +0 -0
  68. /package/dist/types/components/List/components/{OptionsButton → Items/OptionsButton}/OptionsButton.d.ts +0 -0
  69. /package/dist/types/components/List/components/{OptionsButton → Items/OptionsButton}/index.d.ts +0 -0
package/dist/List.js CHANGED
@@ -1,111 +1,143 @@
1
1
  "use client"
2
2
  /* */
3
- var H = Object.defineProperty;
4
- var q = (i, t, e) => t in i ? H(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
5
- var o = (i, t, e) => (q(i, typeof t != "symbol" ? t + "" : t, e), e);
6
- import n, { createContext as j, useContext as J, createElement as W, useEffect as y, useState as K, Suspense as G } from "react";
7
- import { useMessageFormatter as Q, useLocalizedStringFormatter as V } from "react-aria";
8
- import { T as X } from "./Text-Dc6eN_n2.js";
9
- import { B as f } from "./Button-h6RkBrWE.js";
10
- import "@tabler/icons-react";
11
- import z from "clsx";
12
- import "html-react-parser";
3
+ var Q = Object.defineProperty;
4
+ var X = (i, t, e) => t in i ? Q(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
5
+ var o = (i, t, e) => (X(i, typeof t != "symbol" ? t + "" : t, e), e);
6
+ import r, { createContext as Y, useContext as Z, createElement as _, useEffect as C, useState as tt, Suspense as et } from "react";
7
+ import * as x from "react-aria-components";
8
+ import { MenuTrigger as at } from "react-aria-components";
13
9
  import "./propsContext-Dx7WKmmM.js";
14
10
  import "@react-aria/utils";
15
- import { times as Y } from "remeda";
11
+ import { times as st } from "remeda";
16
12
  import "@mittwald/react-tunnel";
17
- import { a as Z, I as _ } from "./IconChevronUp-DJu_PD8w.js";
18
- import { L as tt } from "./Label-Bjdbr72t.js";
19
- import { getProperty as et } from "dot-prop";
20
- import { useReactTable as at, getCoreRowModel as st, getSortedRowModel as it, getFilteredRowModel as nt, getPaginationRowModel as rt, getFacetedUniqueValues as ot } from "@tanstack/react-table";
21
- import lt from "invariant";
22
- import { useLocalObservable as ct } from "mobx-react-lite";
23
- import { autorun as ut, runInAction as mt, makeObservable as ht, observable as P, computed as k, action as S } from "mobx";
24
- import { getAsyncResource as D } from "@mittwald/react-use-promise";
25
- import { u as N } from "./useSelector-DpU7_HMO.js";
26
- import { P as dt } from "./PropsContextProvider-BsrVIv1a.js";
27
- import { W as gt } from "./Wrap-DGT1h1o3.js";
28
- import { d as pt } from "./deepHas-ocYuTM8M.js";
29
- import { L as ft } from "./Link-DtSY1xrt.js";
30
- import { I as bt } from "./IconContextMenu-BF-N2Mtz.js";
31
- import { MenuTrigger as St } from "react-aria-components";
13
+ import { a as U, C as O, d as rt } from "./ContextMenuItem-Cc7czdsZ.js";
14
+ import { T as b } from "./Text-c5-UeE0Y.js";
15
+ import "@tabler/icons-react";
16
+ import $ from "clsx";
17
+ import "html-react-parser";
18
+ import { I as H } from "./IconChevronDown-C3dBD472.js";
19
+ import { B as h } from "./Button-DTVMsKTK.js";
32
20
  import "react-children-utilities";
33
- import { d as p, a as R } from "./deepFindOfType-6pG0fH7S.js";
34
- import { I as yt } from "./InlineCode-DZzyKdCm.js";
35
- import { ListLoaderAsyncResource as wt } from "./List/ListLoaderAsyncResource.js";
36
- const O = j({}), h = () => J(O).list, Ct = (i) => /* @__PURE__ */ n.createElement(n.Fragment, null, i.children()), vt = () => h().loader.getLoaderInvocationHooks().map((t, e) => /* @__PURE__ */ n.createElement(Ct, { key: e }, () => {
21
+ import { useMessageFormatter as q, useLocalizedStringFormatter as K } from "react-aria";
22
+ import { I as nt } from "./IconClose-DIMx1m3Z.js";
23
+ import { getProperty as it } from "dot-prop";
24
+ import { useReactTable as ot, getCoreRowModel as lt, getSortedRowModel as ct, getFilteredRowModel as ut, getPaginationRowModel as mt, getFacetedUniqueValues as dt } from "@tanstack/react-table";
25
+ import j from "invariant";
26
+ import { useLocalObservable as ht } from "mobx-react-lite";
27
+ import { autorun as gt, runInAction as pt, makeObservable as ft, observable as k, computed as D, action as y } from "mobx";
28
+ import { getAsyncResource as P } from "@mittwald/react-use-promise";
29
+ import { u as R } from "./useSelector-DpU7_HMO.js";
30
+ import { P as bt } from "./PropsContextProvider-BsrVIv1a.js";
31
+ import { W as St } from "./Wrap-DGT1h1o3.js";
32
+ import { L as yt } from "./Link-DtSY1xrt.js";
33
+ import { I as Ct } from "./IconContextMenu-BF-N2Mtz.js";
34
+ import { d as f, a as V } from "./deepFindOfType-6pG0fH7S.js";
35
+ import "./context-BlNV7smK.js";
36
+ import { I as vt } from "./InlineCode-DZzyKdCm.js";
37
+ import { ListLoaderAsyncResource as Ft } from "./List/ListLoaderAsyncResource.js";
38
+ const J = Y({}), m = () => Z(J).list, Tt = (i) => /* @__PURE__ */ r.createElement(r.Fragment, null, i.children()), Et = () => m().loader.getLoaderInvocationHooks().map((t, e) => /* @__PURE__ */ r.createElement(Tt, { key: e }, () => {
37
39
  t();
38
- })), w = {
40
+ })), wt = (i) => {
41
+ const { sorting: t } = i;
42
+ return /* @__PURE__ */ r.createElement(U, { id: t.getTableColumn().id }, t.name);
43
+ }, g = {
39
44
  "de-DE": {
40
45
  options: "Optionen",
41
46
  paginationInfo: "{visibleItemsCount} von insgesamt {totalItemsCount} angezeigt",
42
47
  paginationInfoFiltered: "{visibleItemsCount} von insgesamt {filteredItemsCount} (gefiltert aus {totalItemsCount}) angezeigt",
43
- showMore: "Mehr anzeigen"
48
+ resetAll: "Alles zurücksetzen",
49
+ setSorting: "Sortierung: {property}",
50
+ showMore: "Mehr anzeigen",
51
+ sorting: "Sortierung"
44
52
  },
45
53
  "en-EN": {
46
54
  options: "Options",
47
55
  paginationInfo: "Showing {visibleRows} of {totalRows}",
48
56
  paginationInfoFiltered: "Showing {visibleItemsCount} of {filteredItemsCount} (unfiltered total count {totalItemsCount})",
49
- showMore: "Show more"
50
- }
51
- }, Ft = (i) => {
52
- const t = Q(w), e = h(), a = e.batches, s = e.isFiltered() && !e.loader.manualFiltering, r = a.getTotalItemsCount(), l = a.getFilteredItemsCount(), c = a.getVisibleItemsCount();
53
- if (r === 0)
57
+ resetAll: "Reset filters",
58
+ setSorting: "Sorting: {property}",
59
+ showMore: "Show more",
60
+ sorting: "Sorting"
61
+ }
62
+ }, v = (i) => {
63
+ const { children: t, locales: e, variables: a } = i;
64
+ return q(e)(t, a);
65
+ }, Lt = () => {
66
+ const i = m(), t = i.sorting.map((s) => /* @__PURE__ */ r.createElement(wt, { sorting: s, key: s.getTableColumn().id }));
67
+ if (i.sorting.length === 0)
54
68
  return null;
55
- const b = s ? t("paginationInfoFiltered", {
56
- visibleItemsCount: c,
57
- filteredItemsCount: l,
58
- totalItemsCount: r
59
- }) : t("paginationInfo", {
60
- visibleItemsCount: c,
61
- totalItemsCount: r
62
- });
63
- return /* @__PURE__ */ n.createElement(X, { ...i }, b);
64
- }, Tt = () => null, It = (i) => {
65
- const { sorting: t } = i, e = t.direction, a = e === "asc" ? Z : e === "desc" ? _ : Tt, s = e !== !1;
66
- return /* @__PURE__ */ n.createElement(
67
- f,
69
+ const e = i.sorting.find((s) => s.isSorted()), a = /* @__PURE__ */ r.createElement(b, null, e ? /* @__PURE__ */ r.createElement(
70
+ v,
71
+ {
72
+ locales: g,
73
+ variables: {
74
+ property: e.name ?? e.property
75
+ }
76
+ },
77
+ "setSorting"
78
+ ) : /* @__PURE__ */ r.createElement(v, { locales: g }, "sorting"));
79
+ return /* @__PURE__ */ r.createElement(x.MenuTrigger, null, /* @__PURE__ */ r.createElement(h, { style: "soft", size: "s", variant: "secondary" }, a, /* @__PURE__ */ r.createElement(H, null)), /* @__PURE__ */ r.createElement(
80
+ O,
68
81
  {
69
- variant: s ? "primary" : "secondary",
70
- onPress: t.getTableColumn().getToggleSortingHandler()
82
+ selectionMode: "single",
83
+ selectedKeys: e ? [e.property] : [],
84
+ onAction: (s) => {
85
+ i.getSorting(String(s)).enable();
86
+ }
87
+ },
88
+ t
89
+ ));
90
+ }, It = (i) => {
91
+ const { filter: t } = i, e = t.values.map((n) => /* @__PURE__ */ r.createElement(U, { key: t.getValueId(n), id: String(n) }, String(n))), a = t.values.filter((n) => t.isValueActive(n)).map((n) => String(n)), s = (n) => {
92
+ t.toggleValue(n);
93
+ };
94
+ return /* @__PURE__ */ r.createElement(x.MenuTrigger, null, /* @__PURE__ */ r.createElement(h, { style: "soft", size: "s", variant: "secondary" }, /* @__PURE__ */ r.createElement(b, null, t.name ?? t.property), /* @__PURE__ */ r.createElement(H, null)), /* @__PURE__ */ r.createElement(
95
+ O,
96
+ {
97
+ onAction: s,
98
+ selectionMode: "multiple",
99
+ selectedKeys: a
71
100
  },
72
- t.getTableColumn().id,
73
- /* @__PURE__ */ n.createElement(a, { size: "s" })
101
+ e
102
+ ));
103
+ }, Bt = "flow--list--header", At = "flow--list--header--picker-list", M = {
104
+ header: Bt,
105
+ pickerList: At
106
+ }, kt = "flow--list--header--active-filters", Dt = "flow--list--header--clear-button", N = {
107
+ activeFilters: kt,
108
+ clearButton: Dt
109
+ }, Pt = () => {
110
+ const i = m(), t = i.filters.flatMap(
111
+ (e) => e.values.filter((a) => e.isValueActive(a)).map((a) => /* @__PURE__ */ r.createElement(
112
+ h,
113
+ {
114
+ style: "soft",
115
+ size: "s",
116
+ key: String(a),
117
+ onPress: () => e.deactivateValue(a)
118
+ },
119
+ /* @__PURE__ */ r.createElement(b, null, String(a)),
120
+ /* @__PURE__ */ r.createElement(nt, null)
121
+ ))
74
122
  );
75
- }, Lt = "flow--list--filter-bar--sorting-picker", Bt = "flow--list--filter-bar--sorting-picker--items", M = {
76
- sortingPicker: Lt,
77
- items: Bt
78
- }, Et = () => {
79
- const { sorting: i } = h(), t = i.map((e) => /* @__PURE__ */ n.createElement(It, { sorting: e, key: e.getTableColumn().id }));
80
- return /* @__PURE__ */ n.createElement("div", { className: M.sortingPicker }, /* @__PURE__ */ n.createElement("div", { className: M.items }, t));
81
- }, Pt = "flow--list--filter-bar--filter-picker-item", kt = "flow--list--filter-bar--filter-picker-item--items", A = {
82
- filterPickerItem: Pt,
83
- items: kt
84
- }, Dt = (i) => {
85
- const { filter: t } = i, a = t.values.map((s) => /* @__PURE__ */ n.createElement(
86
- f,
123
+ return t.length <= 0 ? null : /* @__PURE__ */ r.createElement("div", { className: N.activeFilters }, t, /* @__PURE__ */ r.createElement(
124
+ h,
87
125
  {
88
- variant: t.isValueActive(s) ? "primary" : "secondary",
89
- key: t.getValueId(s),
90
- onPress: () => t.toggleValue(s)
126
+ className: N.clearButton,
127
+ size: "s",
128
+ style: "plain",
129
+ onPress: () => i.clearFilters()
91
130
  },
92
- String(s)
131
+ /* @__PURE__ */ r.createElement(v, { locales: g }, "resetAll")
93
132
  ));
94
- return /* @__PURE__ */ n.createElement("div", { className: A.filterPickerItem }, /* @__PURE__ */ n.createElement(tt, null, t.property), /* @__PURE__ */ n.createElement("div", { className: A.items }, a));
95
- }, Nt = () => h().filters.map((t) => /* @__PURE__ */ n.createElement(Dt, { key: t.property, filter: t })), Rt = "flow--list--filter-bar", Mt = {
96
- filterBar: Rt
97
- }, At = (i) => {
98
- const { className: t } = i;
99
- return /* @__PURE__ */ n.createElement("div", { className: z(t, Mt.filterBar) }, /* @__PURE__ */ n.createElement(Et, null), /* @__PURE__ */ n.createElement(Nt, null));
100
- }, xt = "flow--list", Vt = "flow--list--filter-bar", zt = "flow--list--items", Ot = "flow--list--pagination-infos", Ut = "flow--list--show-more-button", g = {
101
- list: xt,
102
- filterBar: Vt,
103
- items: zt,
104
- paginationInfos: Ot,
105
- showMoreButton: Ut
133
+ }, Rt = (i) => {
134
+ const { className: t } = i, a = m().filters.map((s) => /* @__PURE__ */ r.createElement(It, { key: s.property, filter: s }));
135
+ return /* @__PURE__ */ r.createElement("div", { className: $(t, M.header) }, /* @__PURE__ */ r.createElement("div", { className: M.pickerList }, /* @__PURE__ */ r.createElement(Lt, null), a), /* @__PURE__ */ r.createElement(Pt, null));
136
+ }, Vt = "flow--list", Mt = {
137
+ list: Vt
106
138
  };
107
- var m;
108
- let $t = (m = class {
139
+ var u;
140
+ let Nt = (u = class {
109
141
  constructor(t, e, a) {
110
142
  o(this, "id");
111
143
  o(this, "data");
@@ -113,25 +145,25 @@ let $t = (m = class {
113
145
  this.collection = t, this.id = e, this.data = a;
114
146
  }
115
147
  render() {
116
- return (this.collection.list.render ?? m.fallbackRenderItemFn)(this.data);
148
+ return (this.collection.list.render ?? u.fallbackRenderItemFn)(this.data);
117
149
  }
118
150
  static fromRow(t, e) {
119
- return new m(t, e.id, e.original);
151
+ return new u(t, e.id, e.original);
120
152
  }
121
- }, o(m, "fallbackRenderItemFn", (t) => W("pre", void 0, JSON.stringify(t))), m);
122
- class C {
153
+ }, o(u, "fallbackRenderItemFn", (t) => _("pre", void 0, JSON.stringify(t))), u);
154
+ class F {
123
155
  constructor(t) {
124
156
  o(this, "list");
125
157
  this.list = t;
126
158
  }
127
159
  static useNew(t) {
128
- return new C(t);
160
+ return new F(t);
129
161
  }
130
162
  get entries() {
131
- return this.list.reactTable.table.getRowModel().rows.map((t) => $t.fromRow(this, t));
163
+ return this.list.reactTable.table.getRowModel().rows.map((t) => Nt.fromRow(this, t));
132
164
  }
133
165
  }
134
- class Ht {
166
+ class zt {
135
167
  constructor(t, e = {}) {
136
168
  o(this, "batchSize");
137
169
  o(this, "list");
@@ -180,35 +212,36 @@ class Ht {
180
212
  }
181
213
  }
182
214
  }
183
- const qt = (i, t) => i === t;
184
- class jt {
215
+ const xt = (i, t) => i === t;
216
+ class Ut {
185
217
  constructor(t, e) {
186
218
  o(this, "_values");
187
219
  o(this, "list");
188
220
  o(this, "property");
189
221
  o(this, "mode");
190
222
  o(this, "matcher");
223
+ o(this, "name");
191
224
  o(this, "onFilterUpdateCallbacks", /* @__PURE__ */ new Set());
192
- this.list = t, this.property = e.property, this.mode = e.mode ?? "one", this._values = e.values, this.matcher = e.matcher ?? qt;
225
+ this.list = t, this.property = e.property, this.mode = e.mode ?? "one", this._values = e.values, this.matcher = e.matcher ?? xt, this.name = e.name;
193
226
  }
194
227
  updateTableColumnDef(t) {
195
228
  t.enableColumnFilter = !0, t.filterFn = this.getReactTableFilterFn();
196
229
  }
197
230
  getReactTableFilterFn() {
198
231
  return (t, e, a) => this.checkFilterMatches(
199
- et(t.original, this.property),
232
+ it(t.original, this.property),
200
233
  a
201
234
  );
202
235
  }
203
236
  checkFilterMatches(t, e) {
204
237
  if (e === null)
205
238
  return !0;
206
- const a = (r) => Array.isArray(r) ? r : [r], s = (r) => this.matcher(r, t);
239
+ const a = (n) => Array.isArray(n) ? n : [n], s = (n) => this.matcher(n, t);
207
240
  if (this.mode === "all")
208
241
  return a(e).every(s);
209
242
  if (this.mode === "some") {
210
- const r = a(e);
211
- return r.length === 0 || r.some(s);
243
+ const n = a(e);
244
+ return n.length === 0 || n.some(s);
212
245
  } else if (this.mode === "one")
213
246
  return s(e);
214
247
  throw new Error(`Unknown filter mode '${this.mode}'`);
@@ -239,33 +272,56 @@ class jt {
239
272
  isActive() {
240
273
  return this.getArrayValue().length > 0;
241
274
  }
275
+ activateValue(t) {
276
+ const e = this.getArrayValue();
277
+ let a;
278
+ this.mode === "all" || this.mode === "some" ? a = [...e, t] : a = t, this.list.reactTable.getTableColumn(this.property).setFilterValue(a), this.onFilterUpdateCallbacks.forEach((s) => s());
279
+ }
280
+ deactivateValue(t) {
281
+ const e = this.getArrayValue();
282
+ let a;
283
+ this.mode === "all" || this.mode === "some" ? a = e.filter((s) => s !== t) : a = null, this.list.reactTable.getTableColumn(this.property).setFilterValue(a), this.onFilterUpdateCallbacks.forEach((s) => s());
284
+ }
285
+ clearValues() {
286
+ let t;
287
+ this.mode === "all" || this.mode === "some" ? t = [] : t = null, this.list.reactTable.getTableColumn(this.property).setFilterValue(t), this.onFilterUpdateCallbacks.forEach((e) => e());
288
+ }
242
289
  toggleValue(t) {
243
290
  const e = this.isValueActive(t), a = this.getArrayValue();
244
291
  let s;
245
- this.mode === "all" || this.mode === "some" ? e ? s = a.filter((r) => r !== t) : s = [...a, t] : s = e ? null : t, this.list.reactTable.getTableColumn(this.property).setFilterValue(s), this.onFilterUpdateCallbacks.forEach((r) => r());
292
+ this.mode === "all" || this.mode === "some" ? e ? s = a.filter((n) => n !== t) : s = [...a, t] : s = e ? null : t, this.list.reactTable.getTableColumn(this.property).setFilterValue(s), this.onFilterUpdateCallbacks.forEach((n) => n());
246
293
  }
247
294
  onFilterUpdated(t) {
248
295
  this.onFilterUpdateCallbacks.add(t);
249
296
  }
250
297
  }
251
- class Jt {
298
+ class Ot {
252
299
  constructor(t, e) {
253
300
  o(this, "list");
254
301
  o(this, "property");
255
- this.list = t, this.property = e.property;
302
+ o(this, "name");
303
+ o(this, "direction");
304
+ o(this, "defaultEnabled");
305
+ this.list = t, this.property = e.property, this.name = e.name, this.direction = e.direction ?? "asc", this.defaultEnabled = !!e.defaultEnabled;
256
306
  }
257
307
  updateTableColumnDef(t) {
258
308
  t.enableSorting = !0;
259
309
  }
260
- get direction() {
261
- return this.list.reactTable.getTableColumn(this.property).getIsSorted();
310
+ isSorted() {
311
+ return this.list.reactTable.getTableColumn(this.property).getIsSorted() !== !1;
262
312
  }
263
313
  getTableColumn() {
264
314
  return this.list.reactTable.getTableColumn(this.property);
265
315
  }
316
+ enable() {
317
+ this.list.reactTable.getTableColumn(this.property).toggleSorting(this.direction === "desc", !1);
318
+ }
319
+ clear() {
320
+ this.list.reactTable.getTableColumn(this.property).clearSorting();
321
+ }
266
322
  }
267
- const Wt = (i) => y(ut(i));
268
- class v {
323
+ const $t = (i) => C(gt(i));
324
+ class T {
269
325
  constructor(t, e = {}) {
270
326
  o(this, "list");
271
327
  o(this, "table");
@@ -275,36 +331,40 @@ class v {
275
331
  if (!e)
276
332
  return;
277
333
  const a = typeof t == "function" ? t(e) : t;
278
- mt(() => {
334
+ pt(() => {
279
335
  this.tableState.value = this.getUpdatedTableState(e, a);
280
336
  });
281
337
  });
282
- this.list = t, this.tableState = ct(() => ({ value: void 0 })), this.table = this.useReactTable(e);
338
+ this.list = t, this.tableState = ht(() => ({ value: void 0 })), this.table = this.useReactTable(e);
283
339
  }
284
340
  static useNew(t, e = {}) {
285
- return new v(t, e);
341
+ return new T(t, e);
286
342
  }
287
343
  useReactTable(t = {}) {
288
- const e = this.list.loader.useData(), a = at({
344
+ const e = this.list.loader.useData(), a = this.list.sorting.filter((n) => n.defaultEnabled), s = ot({
289
345
  data: e,
290
346
  initialState: {
291
347
  pagination: {
292
348
  pageSize: this.list.batches.batchSize
293
- }
349
+ },
350
+ sorting: a.map((n) => ({
351
+ id: String(n.property),
352
+ desc: n.direction === "desc"
353
+ }))
294
354
  },
295
355
  columns: this.getTableColumnDefs(),
296
- getCoreRowModel: st(),
297
- getSortedRowModel: it(),
298
- getFilteredRowModel: nt(),
299
- getPaginationRowModel: rt(),
300
- getFacetedUniqueValues: ot(),
356
+ getCoreRowModel: lt(),
357
+ getSortedRowModel: ct(),
358
+ getFilteredRowModel: ut(),
359
+ getPaginationRowModel: mt(),
360
+ getFacetedUniqueValues: dt(),
301
361
  onStateChange: this.onTableStateChange,
302
362
  ...t
303
363
  });
304
- return this.useUpdateTableState(a), a;
364
+ return this.useUpdateTableState(s), s;
305
365
  }
306
366
  useUpdateTableState(t) {
307
- Wt(() => {
367
+ $t(() => {
308
368
  const e = this.tableState.value;
309
369
  e ? t.setOptions((a) => ({
310
370
  ...a,
@@ -317,20 +377,20 @@ class v {
317
377
  }
318
378
  getTableColumn(t) {
319
379
  const e = this.table.getColumn(t);
320
- return lt(!!e, `Column #${t} is not defined`), e;
380
+ return j(!!e, `Column #${t} is not defined`), e;
321
381
  }
322
382
  getTableColumnDefs() {
323
383
  const t = /* @__PURE__ */ new Map(), e = (a) => {
324
384
  const s = t.get(a);
325
385
  if (s)
326
386
  return s;
327
- const r = {
387
+ const n = {
328
388
  id: a,
329
389
  accessorKey: a,
330
390
  enableSorting: !1,
331
391
  enableColumnFilter: !1
332
392
  };
333
- return t.set(a, r), r;
393
+ return t.set(a, n), n;
334
394
  };
335
395
  return this.list.filters.forEach(
336
396
  (a) => a.updateTableColumnDef(e(a.property))
@@ -339,23 +399,23 @@ class v {
339
399
  ), Array.from(t.values());
340
400
  }
341
401
  }
342
- class F {
402
+ class E {
343
403
  constructor() {
344
404
  o(this, "dataBatches", []);
345
405
  o(this, "prevDataBatches", []);
346
406
  o(this, "batchLoadingStates", []);
347
- ht(this, {
348
- dataBatches: P,
349
- batchLoadingStates: P,
350
- mergedData: k,
351
- isLoading: k,
352
- reset: S.bound,
353
- setDataBatch: S.bound,
354
- setBatchLoadingState: S.bound
407
+ ft(this, {
408
+ dataBatches: k,
409
+ batchLoadingStates: k,
410
+ mergedData: D,
411
+ isLoading: D,
412
+ reset: y.bound,
413
+ setDataBatch: y.bound,
414
+ setBatchLoadingState: y.bound
355
415
  });
356
416
  }
357
417
  static useNew() {
358
- return K(new F())[0];
418
+ return tt(new E())[0];
359
419
  }
360
420
  reset() {
361
421
  this.batchLoadingStates = [], this.dataBatches = [];
@@ -370,17 +430,17 @@ class F {
370
430
  return (this.dataBatches.length === 0 ? this.prevDataBatches : this.dataBatches).flatMap((e) => e);
371
431
  }
372
432
  useMergedData() {
373
- return N(() => this.mergedData);
433
+ return R(() => this.mergedData);
374
434
  }
375
435
  get isLoading() {
376
436
  return this.batchLoadingStates.some((t) => t === "loading");
377
437
  }
378
438
  useIsLoading() {
379
- return N(() => this.isLoading);
439
+ return R(() => this.isLoading);
380
440
  }
381
441
  }
382
- const Kt = [];
383
- class T {
442
+ const Ht = [];
443
+ class w {
384
444
  constructor(t, e = {}) {
385
445
  o(this, "list");
386
446
  o(this, "dataSource");
@@ -389,12 +449,12 @@ class T {
389
449
  o(this, "manualPagination");
390
450
  o(this, "loaderState");
391
451
  const { source: a } = e;
392
- this.dataSource = a ?? { staticData: Kt };
393
- const s = "manualPagination" in this.dataSource ? this.dataSource.manualPagination : void 0, r = "manualFiltering" in this.dataSource ? this.dataSource.manualFiltering : void 0, l = "manualSorting" in this.dataSource ? this.dataSource.manualSorting : void 0;
394
- this.list = t, this.loaderState = F.useNew(), this.manualPagination = s ?? !1, this.manualFiltering = r ?? this.manualPagination, this.manualSorting = l ?? this.manualPagination, this.list.filters.forEach((c) => c.onFilterUpdated(() => this.reset()));
452
+ this.dataSource = a ?? { staticData: Ht };
453
+ const s = "manualPagination" in this.dataSource ? this.dataSource.manualPagination : void 0, n = "manualFiltering" in this.dataSource ? this.dataSource.manualFiltering : void 0, l = "manualSorting" in this.dataSource ? this.dataSource.manualSorting : void 0;
454
+ this.list = t, this.loaderState = E.useNew(), this.manualPagination = s ?? !1, this.manualFiltering = n ?? this.manualPagination, this.manualSorting = l ?? this.manualPagination, this.list.filters.forEach((d) => d.onFilterUpdated(() => this.reset()));
395
455
  }
396
456
  static useNew(t, e = {}) {
397
- return new T(t, e);
457
+ return new w(t, e);
398
458
  }
399
459
  reset() {
400
460
  this.loaderState.reset();
@@ -406,7 +466,7 @@ class T {
406
466
  return this.loaderState.useMergedData();
407
467
  }
408
468
  getLoaderInvocationHooks() {
409
- return Y(this.list.batches.getBatchIndex() + 1, (e) => e).map((e) => () => {
469
+ return st(this.list.batches.getBatchIndex() + 1, (e) => e).map((e) => () => {
410
470
  this.useLoadBatch(e);
411
471
  });
412
472
  }
@@ -414,12 +474,12 @@ class T {
414
474
  const e = this.getBatchDataAsyncResource(t), a = e.use({
415
475
  useSuspense: !1
416
476
  });
417
- y(() => {
477
+ C(() => {
418
478
  if (!a.hasValue)
419
479
  return;
420
- const { data: s, itemTotalCount: r } = a.value;
421
- this.loaderState.setDataBatch(t, s), r !== void 0 && this.list.batches.updateItemTotalCount(r);
422
- }, [t, a.maybeValue]), y(() => (this.loaderState.setBatchLoadingState(
480
+ const { data: s, itemTotalCount: n } = a.value;
481
+ this.loaderState.setDataBatch(t, s), n !== void 0 && this.list.batches.updateItemTotalCount(n);
482
+ }, [t, a.maybeValue]), C(() => (this.loaderState.setBatchLoadingState(
423
483
  t,
424
484
  e.state.value
425
485
  ), e.state.observe((s) => {
@@ -433,7 +493,7 @@ class T {
433
493
  offset: this.list.batches.batchSize * t
434
494
  } : void 0,
435
495
  sorting: this.manualSorting ? Object.fromEntries(
436
- this.list.sorting.filter((e) => e.direction !== !1).map((e) => [e.property, e.direction])
496
+ this.list.sorting.filter((e) => e.isSorted()).map((e) => [e.property, e.direction])
437
497
  ) : void 0,
438
498
  filtering: this.manualFiltering ? Object.fromEntries(
439
499
  this.list.filters.filter((e) => e.getValue() !== null).map((e) => [
@@ -447,7 +507,7 @@ class T {
447
507
  const e = this.dataSource, a = this.getDataLoaderOptions(t);
448
508
  if ("staticData" in e) {
449
509
  const s = e.staticData;
450
- return D(
510
+ return P(
451
511
  async () => ({
452
512
  data: s,
453
513
  itemTotalCount: s.length
@@ -457,7 +517,7 @@ class T {
457
517
  }
458
518
  if ("asyncLoader" in e) {
459
519
  const s = e.asyncLoader;
460
- return D(s, [a]);
520
+ return P(s, [a]);
461
521
  }
462
522
  if ("asyncResourceFactory" in e) {
463
523
  const s = e.asyncResourceFactory;
@@ -466,7 +526,7 @@ class T {
466
526
  throw new Error("Unknown data source");
467
527
  }
468
528
  }
469
- let Gt = class U {
529
+ let qt = class W {
470
530
  constructor(t) {
471
531
  o(this, "filters");
472
532
  o(this, "sorting");
@@ -475,154 +535,178 @@ let Gt = class U {
475
535
  o(this, "reactTable");
476
536
  o(this, "batches");
477
537
  o(this, "loader");
478
- const {
479
- render: e,
480
- filters: a = [],
481
- sorting: s = [],
482
- batchesController: r,
483
- enableMultiSort: l = !1
484
- } = t;
485
- this.render = e, this.items = C.useNew(this), this.filters = a.map((c) => new jt(this, c)), this.sorting = s.map((c) => new Jt(this, c)), this.batches = new Ht(this, r), this.loader = T.useNew(this, t.loader), this.reactTable = v.useNew(this, {
486
- enableMultiSort: l,
538
+ const { render: e, filters: a = [], sorting: s = [], batchesController: n } = t;
539
+ this.render = e, this.items = F.useNew(this), this.filters = a.map((l) => new Ut(this, l)), this.sorting = s.map((l) => new Ot(this, l)), this.batches = new zt(this, n), this.loader = w.useNew(this, t.loader), this.reactTable = T.useNew(this, {
487
540
  manualFiltering: this.loader.manualFiltering,
488
541
  manualPagination: this.loader.manualPagination,
489
542
  manualSorting: this.loader.manualSorting
490
543
  });
491
544
  }
492
545
  static useNew(t) {
493
- return new U(t);
546
+ return new W(t);
494
547
  }
495
548
  isFiltered() {
496
549
  return this.filters.some((t) => t.isActive());
497
550
  }
551
+ getSorting(t) {
552
+ const e = this.sorting.find((a) => a.property === t);
553
+ return j(!!e, `Could not get Sorting (property: ${t})`), e;
554
+ }
555
+ clearSorting() {
556
+ return this.sorting.forEach((t) => t.clear());
557
+ }
558
+ clearFilters() {
559
+ return this.filters.forEach((t) => t.clearValues());
560
+ }
498
561
  };
499
- const Qt = "flow--list--items", Xt = "flow--list--items--is-loading", x = {
500
- items: Qt,
501
- isLoading: Xt
502
- }, Yt = "flow--list--item", Zt = "flow--list--item--options-button", _t = "flow--list--item--avatar", te = "flow--list--item--text", ee = "flow--list--item--heading", ae = "flow--list--item--content", u = {
503
- item: Yt,
504
- optionsButton: Zt,
505
- avatar: _t,
506
- text: te,
507
- heading: ee,
508
- content: ae
509
- }, se = (i) => {
510
- const { className: t, children: e } = i, a = V(w);
511
- return /* @__PURE__ */ n.createElement(St, null, /* @__PURE__ */ n.createElement(
512
- f,
562
+ const Kt = "flow--list--items--item-list", jt = "flow--list--items--is-loading", z = {
563
+ itemList: Kt,
564
+ isLoading: jt
565
+ }, Jt = "flow--list--items--item", Wt = "flow--list--items--options-button", Gt = "flow--list--items--avatar", Qt = "flow--list--items--text", Xt = "flow--list--items--status-badge", Yt = "flow--list--items--heading", Zt = "flow--list--items--content", c = {
566
+ item: Jt,
567
+ optionsButton: Wt,
568
+ avatar: Gt,
569
+ text: Qt,
570
+ statusBadge: Xt,
571
+ heading: Yt,
572
+ content: Zt
573
+ }, _t = (i) => {
574
+ const { className: t, children: e } = i, a = K(g);
575
+ return /* @__PURE__ */ r.createElement(at, null, /* @__PURE__ */ r.createElement(
576
+ h,
513
577
  {
514
578
  style: "plain",
515
579
  className: t,
516
580
  "aria-label": a.format("options")
517
581
  },
518
- /* @__PURE__ */ n.createElement(bt, null)
582
+ /* @__PURE__ */ r.createElement(Ct, null)
519
583
  ), e);
520
- }, ie = (i) => {
521
- const { children: t } = i, e = pt(t, ft), a = {
584
+ }, te = (i) => {
585
+ const { children: t } = i, e = rt(t, yt), a = {
522
586
  Avatar: {
523
- className: u.avatar
587
+ className: c.avatar
524
588
  },
525
589
  Heading: {
526
- className: u.heading
590
+ className: c.heading,
591
+ level: 3
527
592
  },
528
593
  Text: {
529
- className: u.text
594
+ className: c.text
595
+ },
596
+ StatusBadge: {
597
+ className: c.statusBadge
530
598
  },
531
599
  Content: {
532
- className: u.content
600
+ className: c.content
533
601
  },
534
602
  ContextMenu: {
535
603
  placement: "bottom end",
536
- hoc: (r) => /* @__PURE__ */ n.createElement(se, { className: u.optionsButton }, r)
604
+ hoc: (n) => /* @__PURE__ */ r.createElement(_t, { className: c.optionsButton }, n)
537
605
  }
538
606
  }, s = {
539
607
  ...a,
540
608
  Link: {
541
- className: u.item,
609
+ className: c.item,
542
610
  unstyled: !0,
543
611
  ...a
544
612
  }
545
613
  };
546
- return /* @__PURE__ */ n.createElement(gt, { if: !e }, /* @__PURE__ */ n.createElement("div", { className: u.item }, /* @__PURE__ */ n.createElement(dt, { props: s }, t)));
547
- }, ne = (i) => {
548
- const { className: t } = i, e = h(), a = e.loader.useIsLoading(), s = e.items.entries.map((l) => /* @__PURE__ */ n.createElement(ie, { key: l.id }, /* @__PURE__ */ n.createElement(G, null, l.render()))), r = z(
549
- x.items,
614
+ return /* @__PURE__ */ r.createElement(St, { if: !e }, /* @__PURE__ */ r.createElement("div", { className: c.item }, /* @__PURE__ */ r.createElement(bt, { props: s }, t)));
615
+ }, ee = (i) => /* @__PURE__ */ r.createElement(vt, null, JSON.stringify(i.data)), ae = (i) => {
616
+ const { className: t } = i, e = m(), a = e.loader.useIsLoading(), s = e.items.entries.map((l) => /* @__PURE__ */ r.createElement(te, { key: l.id }, /* @__PURE__ */ r.createElement(et, null, l.render()))), n = $(
617
+ z.itemList,
550
618
  t,
551
- a && x.isLoading
619
+ a && z.isLoading
552
620
  );
553
- return /* @__PURE__ */ n.createElement("div", { className: r }, s);
621
+ return /* @__PURE__ */ r.createElement("div", { className: n }, s);
554
622
  };
555
- function re(i) {
623
+ function se(i) {
556
624
  return null;
557
625
  }
558
- function oe(i) {
626
+ function re(i) {
559
627
  return null;
560
628
  }
561
- function le(i) {
629
+ function ne(i) {
562
630
  return null;
563
631
  }
564
- function ce(i) {
632
+ function ie(i) {
565
633
  return null;
566
634
  }
567
- function ue(i) {
635
+ function oe(i) {
568
636
  return null;
569
637
  }
570
- const me = (i) => /* @__PURE__ */ n.createElement(yt, null, JSON.stringify(i.data)), he = (i) => {
571
- const t = V(w), e = h(), a = e.loader.useIsLoading(), r = e.batches.hasNextBatch();
572
- return /* @__PURE__ */ n.createElement(
573
- f,
638
+ const le = "flow--list--footer", ce = {
639
+ footer: le
640
+ }, ue = (i) => {
641
+ const t = q(g), e = m(), a = e.batches, s = e.isFiltered() && !e.loader.manualFiltering, n = a.getTotalItemsCount(), l = a.getFilteredItemsCount(), d = a.getVisibleItemsCount();
642
+ if (n === 0)
643
+ return null;
644
+ const S = s ? t("paginationInfoFiltered", {
645
+ visibleItemsCount: d,
646
+ filteredItemsCount: l,
647
+ totalItemsCount: n
648
+ }) : t("paginationInfo", {
649
+ visibleItemsCount: d,
650
+ totalItemsCount: n
651
+ });
652
+ return /* @__PURE__ */ r.createElement(b, { ...i }, S);
653
+ }, me = (i) => {
654
+ const t = K(g), e = m(), a = e.loader.useIsLoading(), n = e.batches.hasNextBatch();
655
+ return /* @__PURE__ */ r.createElement(
656
+ h,
574
657
  {
575
658
  isPending: a,
576
659
  ...i,
577
660
  onPress: () => e.batches.nextBatch(),
578
661
  style: "plain",
579
- isDisabled: !r
662
+ isDisabled: !n,
663
+ size: "s"
580
664
  },
581
665
  t.format("showMore")
582
666
  );
583
- };
667
+ }, de = () => /* @__PURE__ */ r.createElement("div", { className: ce.footer }, /* @__PURE__ */ r.createElement(ue, null), /* @__PURE__ */ r.createElement(me, null));
584
668
  function je(i) {
585
- var I, L, B, E;
586
- const { children: t, batchSize: e, ...a } = i, s = (I = p(t, re)) == null ? void 0 : I.props, r = (L = p(
669
+ var L, I, B, A;
670
+ const { children: t, batchSize: e, ...a } = i, s = (L = f(t, se)) == null ? void 0 : L.props, n = (I = f(
587
671
  t,
588
- wt
589
- )) == null ? void 0 : L.props, l = (B = p(t, ue)) == null ? void 0 : B.props, c = {
672
+ Ft
673
+ )) == null ? void 0 : I.props, l = (B = f(t, oe)) == null ? void 0 : B.props, d = {
590
674
  source: s ? {
591
675
  ...s,
592
676
  asyncLoader: s.children
593
- } : r ? {
594
- ...r,
595
- asyncResourceFactory: r.children
677
+ } : n ? {
678
+ ...n,
679
+ asyncResourceFactory: n.children
596
680
  } : l ? {
597
681
  staticData: l.data
598
682
  } : void 0
599
- }, b = (d) => /* @__PURE__ */ n.createElement(me, { data: d }), $ = Gt.useNew({
600
- loader: c,
601
- filters: R(t, oe).map((d) => d.props),
602
- sorting: R(t, le).map((d) => d.props),
603
- render: ((E = p(t, ce)) == null ? void 0 : E.props.children) ?? b,
683
+ }, S = (p) => /* @__PURE__ */ r.createElement(ee, { data: p }), G = qt.useNew({
684
+ loader: d,
685
+ filters: V(t, re).map((p) => p.props),
686
+ sorting: V(t, ne).map((p) => p.props),
687
+ render: ((A = f(t, ie)) == null ? void 0 : A.props.children) ?? S,
604
688
  ...a,
605
689
  batchesController: {
606
690
  batchSize: e
607
691
  }
608
692
  });
609
- return /* @__PURE__ */ n.createElement(
610
- O.Provider,
693
+ return /* @__PURE__ */ r.createElement(
694
+ J.Provider,
611
695
  {
612
696
  value: {
613
- list: $
697
+ list: G
614
698
  }
615
699
  },
616
- /* @__PURE__ */ n.createElement(vt, null),
617
- /* @__PURE__ */ n.createElement("div", { className: g.list }, /* @__PURE__ */ n.createElement(At, { className: g.filterBar }), /* @__PURE__ */ n.createElement(ne, { className: g.rows }), /* @__PURE__ */ n.createElement(Ft, { className: g.paginationInfos }), /* @__PURE__ */ n.createElement(he, { className: g.showMoreButton }))
700
+ /* @__PURE__ */ r.createElement(Et, null),
701
+ /* @__PURE__ */ r.createElement("div", { className: Mt.list }, /* @__PURE__ */ r.createElement(Rt, null), /* @__PURE__ */ r.createElement(ae, null), /* @__PURE__ */ r.createElement(de, null))
618
702
  );
619
703
  }
620
704
  export {
621
705
  je as List,
622
- oe as ListFilter,
623
- ce as ListItemView,
624
- re as ListLoaderAsync,
625
- le as ListSorting,
626
- ue as ListStaticData,
706
+ re as ListFilter,
707
+ ie as ListItemView,
708
+ se as ListLoaderAsync,
709
+ ne as ListSorting,
710
+ oe as ListStaticData,
627
711
  je as default
628
712
  };