@mittwald/flow-react-components 0.1.0-alpha.121 → 0.1.0-alpha.122

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/List.js CHANGED
@@ -1,48 +1,49 @@
1
1
  "use client"
2
2
  /* */
3
- var Q = Object.defineProperty;
4
- var X = (r, t, e) => t in r ? Q(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
5
- var o = (r, t, e) => (X(r, typeof t != "symbol" ? t + "" : t, e), e);
6
- import s, { createContext as Z, useContext as _, createElement as tt, useEffect as C, useState as et, Suspense as at } from "react";
7
- import { C as O } from "./ContextMenu-BGfJXwpB.js";
8
- import { M as $, d as st } from "./MenuItem-CzSUuXS-.js";
9
- import * as H from "react-aria-components";
10
- import { MenuTrigger as nt } from "react-aria-components";
11
- import { T as f } from "./Text-DXApO_Re.js";
3
+ var Z = Object.defineProperty;
4
+ var _ = (i, t, e) => t in i ? Z(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
5
+ var o = (i, t, e) => (_(i, typeof t != "symbol" ? t + "" : t, e), e);
6
+ import s, { createContext as tt, useContext as et, createElement as at, useEffect as v, useRef as st, Suspense as nt } from "react";
7
+ import { C as H } from "./ContextMenu-BGfJXwpB.js";
8
+ import { M as q, d as it } from "./MenuItem-CzSUuXS-.js";
9
+ import * as K from "react-aria-components";
10
+ import { MenuTrigger as rt } from "react-aria-components";
11
+ import { T as S } from "./Text-DXApO_Re.js";
12
12
  import "@tabler/icons-react";
13
13
  import "./Icon-DhFv_0k_.js";
14
- import { I as q } from "./IconChevronDown-gLJKgegq.js";
14
+ import { I as j } from "./IconChevronDown-gLJKgegq.js";
15
15
  import { B as g } from "./Button-BGCNzfmU.js";
16
- import { useMessageFormatter as K, useLocalizedStringFormatter as E } from "react-aria";
17
- import j from "clsx";
18
- import { I as rt } from "./IconClose-BEe9M79E.js";
19
- import { getProperty as it } from "dot-prop";
20
- import { useReactTable as ot, getCoreRowModel as lt, getSortedRowModel as ct, getFilteredRowModel as ut, getPaginationRowModel as mt, getFacetedUniqueValues as dt } from "@tanstack/react-table";
21
- import J from "invariant";
22
- import { useLocalObservable as ht } from "mobx-react-lite";
23
- import { autorun as gt, runInAction as pt, makeObservable as ft, observable as k, computed as D, action as y } from "mobx";
24
- import { getAsyncResource as P } from "@mittwald/react-use-promise";
25
- import { times as bt } from "remeda";
26
- import { u as M } from "./useSelector-DpU7_HMO.js";
16
+ import { useMessageFormatter as J, useLocalizedStringFormatter as I } from "react-aria";
17
+ import W from "clsx";
18
+ import { I as ot } from "./IconClose-BEe9M79E.js";
19
+ import { getProperty as lt } from "dot-prop";
20
+ import { useReactTable as ct, getCoreRowModel as ut, getSortedRowModel as mt, getFilteredRowModel as dt, getPaginationRowModel as ht, getFacetedUniqueValues as gt } from "@tanstack/react-table";
21
+ import Y from "invariant";
22
+ import { useLocalObservable as pt } from "mobx-react-lite";
23
+ import { autorun as ft, runInAction as bt, makeObservable as St, observable as P, computed as R, action as E } from "mobx";
24
+ import { getAsyncResource as M } from "@mittwald/react-use-promise";
25
+ import { times as yt } from "remeda";
26
+ import { u as V } from "./useSelector-DpU7_HMO.js";
27
27
  import "./propsContext-CauylOgH.js";
28
- import { P as St } from "./PropsContextProvider-DZvwqHLP.js";
28
+ import { P as Ct } from "./PropsContextProvider-DZvwqHLP.js";
29
29
  import "@react-aria/utils";
30
- import { d as yt } from "./dynamic-ClpUSmEt.js";
31
- import { W as Ct } from "./Wrap-DGT1h1o3.js";
32
- import { L as vt } from "./Link-BK57CeBv.js";
33
- import { I as Et } from "./IconContextMenu-B9OI5d_u.js";
34
- import { TunnelProvider as Ft, TunnelExit as N } from "@mittwald/react-tunnel";
35
- import { I as Tt } from "./IllustratedMessage-D1xVzeZO.js";
36
- import { I as wt } from "./IconSearch-BO1yNi13.js";
37
- import { H as It } from "./Heading-CYit9Nf-.js";
38
- import { d as b, a as V } from "./deepFindOfType-6pG0fH7S.js";
39
- import { I as Lt } from "./InlineCode-BV2i5uN0.js";
40
- import { ListLoaderAsyncResource as Bt } from "./List/ListLoaderAsyncResource.js";
41
- const W = Z({}), h = () => _(W).list, At = (r) => /* @__PURE__ */ s.createElement(s.Fragment, null, r.children()), Rt = () => h().loader.getLoaderInvocationHooks().map((t, e) => /* @__PURE__ */ s.createElement(At, { key: e }, () => {
30
+ import { d as Et } from "./dynamic-ClpUSmEt.js";
31
+ import { W as vt } from "./Wrap-DGT1h1o3.js";
32
+ import { L as Ft } from "./Link-BK57CeBv.js";
33
+ import { I as It } from "./IconContextMenu-B9OI5d_u.js";
34
+ import { TunnelProvider as Tt, TunnelExit as x } from "@mittwald/react-tunnel";
35
+ import { I as wt } from "./IllustratedMessage-D1xVzeZO.js";
36
+ import { I as Lt } from "./IconSearch-BO1yNi13.js";
37
+ import { H as Bt } from "./Heading-CYit9Nf-.js";
38
+ import { S as kt } from "./Skeleton-D97e6aVe.js";
39
+ import { d as C, a as z } from "./deepFindOfType-6pG0fH7S.js";
40
+ import { I as At } from "./InlineCode-BV2i5uN0.js";
41
+ import { ListLoaderAsyncResource as Dt } from "./List/ListLoaderAsyncResource.js";
42
+ const G = tt({}), h = () => et(G).list, Nt = (i) => /* @__PURE__ */ s.createElement(s.Fragment, null, i.children()), Pt = () => h().loader.getLoaderInvocationHooks().map((t, e) => /* @__PURE__ */ s.createElement(Nt, { key: e }, () => {
42
43
  t();
43
- })), kt = (r) => {
44
- const { sorting: t } = r;
45
- return /* @__PURE__ */ s.createElement($, { id: t.getTableColumn().id }, t.name);
44
+ })), Rt = (i) => {
45
+ const { sorting: t } = i;
46
+ return /* @__PURE__ */ s.createElement(q, { id: t.getTableColumn().id }, t.name);
46
47
  }, d = {
47
48
  "de-DE": {
48
49
  "list.noResult.heading": "Keine Suchergebnisse gefunden",
@@ -66,15 +67,15 @@ const W = Z({}), h = () => _(W).list, At = (r) => /* @__PURE__ */ s.createElemen
66
67
  "list.showMore": "Show more",
67
68
  "list.sorting": "Sorting"
68
69
  }
69
- }, v = (r) => {
70
- const { children: t, locales: e, variables: a } = r;
71
- return K(e)(t, a);
72
- }, Dt = () => {
73
- const r = h(), t = r.sorting.map((n) => /* @__PURE__ */ s.createElement(kt, { sorting: n, key: n.getTableColumn().id }));
74
- if (r.sorting.length === 0)
70
+ }, F = (i) => {
71
+ const { children: t, locales: e, variables: a } = i;
72
+ return J(e)(t, a);
73
+ }, Mt = () => {
74
+ const i = h(), t = i.sorting.map((n) => /* @__PURE__ */ s.createElement(Rt, { sorting: n, key: n.getTableColumn().id }));
75
+ if (i.sorting.length === 0)
75
76
  return null;
76
- const e = r.sorting.find((n) => n.isSorted()), a = /* @__PURE__ */ s.createElement(f, null, e ? /* @__PURE__ */ s.createElement(
77
- v,
77
+ const e = i.sorting.find((n) => n.isSorted()), a = /* @__PURE__ */ s.createElement(S, null, e ? /* @__PURE__ */ s.createElement(
78
+ F,
78
79
  {
79
80
  locales: d,
80
81
  variables: {
@@ -82,24 +83,24 @@ const W = Z({}), h = () => _(W).list, At = (r) => /* @__PURE__ */ s.createElemen
82
83
  }
83
84
  },
84
85
  "list.setSorting"
85
- ) : /* @__PURE__ */ s.createElement(v, { locales: d }, "list.sorting"));
86
- return /* @__PURE__ */ s.createElement(H.MenuTrigger, null, /* @__PURE__ */ s.createElement(g, { variant: "soft", size: "s", color: "secondary" }, a, /* @__PURE__ */ s.createElement(q, null)), /* @__PURE__ */ s.createElement(
87
- O,
86
+ ) : /* @__PURE__ */ s.createElement(F, { locales: d }, "list.sorting"));
87
+ return /* @__PURE__ */ s.createElement(K.MenuTrigger, null, /* @__PURE__ */ s.createElement(g, { variant: "soft", size: "s", color: "secondary" }, a, /* @__PURE__ */ s.createElement(j, null)), /* @__PURE__ */ s.createElement(
88
+ H,
88
89
  {
89
90
  selectionMode: "single",
90
91
  selectedKeys: e ? [e.property] : [],
91
92
  onAction: (n) => {
92
- r.getSorting(String(n)).enable();
93
+ i.getSorting(String(n)).enable();
93
94
  }
94
95
  },
95
96
  t
96
97
  ));
97
- }, Pt = (r) => {
98
- const { filter: t } = r, e = t.values.map((i) => /* @__PURE__ */ s.createElement($, { key: t.getValueId(i), id: String(i) }, String(i))), a = t.values.filter((i) => t.isValueActive(i)).map((i) => String(i)), n = (i) => {
99
- t.toggleValue(i);
98
+ }, Vt = (i) => {
99
+ const { filter: t } = i, e = t.values.map((r) => /* @__PURE__ */ s.createElement(q, { key: t.getValueId(r), id: String(r) }, String(r))), a = t.values.filter((r) => t.isValueActive(r)).map((r) => String(r)), n = (r) => {
100
+ t.toggleValue(r);
100
101
  };
101
- return /* @__PURE__ */ s.createElement(H.MenuTrigger, null, /* @__PURE__ */ s.createElement(g, { variant: "soft", size: "s", color: "secondary" }, /* @__PURE__ */ s.createElement(f, null, t.name ?? t.property), /* @__PURE__ */ s.createElement(q, null)), /* @__PURE__ */ s.createElement(
102
- O,
102
+ return /* @__PURE__ */ s.createElement(K.MenuTrigger, null, /* @__PURE__ */ s.createElement(g, { variant: "soft", size: "s", color: "secondary" }, /* @__PURE__ */ s.createElement(S, null, t.name ?? t.property), /* @__PURE__ */ s.createElement(j, null)), /* @__PURE__ */ s.createElement(
103
+ H,
103
104
  {
104
105
  onAction: n,
105
106
  selectionMode: "multiple",
@@ -107,14 +108,14 @@ const W = Z({}), h = () => _(W).list, At = (r) => /* @__PURE__ */ s.createElemen
107
108
  },
108
109
  e
109
110
  ));
110
- }, Mt = "flow--list--header", Nt = "flow--list--header--picker-list", x = {
111
- header: Mt,
112
- pickerList: Nt
113
- }, Vt = "flow--list--header--active-filters", xt = "flow--list--header--clear-button", z = {
114
- activeFilters: Vt,
115
- clearButton: xt
116
- }, zt = () => {
117
- const r = h(), t = r.filters.flatMap(
111
+ }, xt = "flow--list--header", zt = "flow--list--header--picker-list", O = {
112
+ header: xt,
113
+ pickerList: zt
114
+ }, Ot = "flow--list--header--active-filters", Ut = "flow--list--header--clear-button", U = {
115
+ activeFilters: Ot,
116
+ clearButton: Ut
117
+ }, $t = () => {
118
+ const i = h(), t = i.filters.flatMap(
118
119
  (e) => e.values.filter((a) => e.isValueActive(a)).map((a) => /* @__PURE__ */ s.createElement(
119
120
  g,
120
121
  {
@@ -123,28 +124,28 @@ const W = Z({}), h = () => _(W).list, At = (r) => /* @__PURE__ */ s.createElemen
123
124
  key: String(a),
124
125
  onPress: () => e.deactivateValue(a)
125
126
  },
126
- /* @__PURE__ */ s.createElement(f, null, String(a)),
127
- /* @__PURE__ */ s.createElement(rt, null)
127
+ /* @__PURE__ */ s.createElement(S, null, String(a)),
128
+ /* @__PURE__ */ s.createElement(ot, null)
128
129
  ))
129
130
  );
130
- return t.length <= 0 ? null : /* @__PURE__ */ s.createElement("div", { className: z.activeFilters }, t, /* @__PURE__ */ s.createElement(
131
+ return t.length <= 0 ? null : /* @__PURE__ */ s.createElement("div", { className: U.activeFilters }, t, /* @__PURE__ */ s.createElement(
131
132
  g,
132
133
  {
133
- className: z.clearButton,
134
+ className: U.clearButton,
134
135
  size: "s",
135
136
  variant: "plain",
136
- onPress: () => r.clearFilters()
137
+ onPress: () => i.clearFilters()
137
138
  },
138
- /* @__PURE__ */ s.createElement(v, { locales: d }, "list.resetAll")
139
+ /* @__PURE__ */ s.createElement(F, { locales: d }, "list.resetAll")
139
140
  ));
140
- }, Ut = (r) => {
141
- const { className: t } = r, a = h().filters.map((n) => /* @__PURE__ */ s.createElement(Pt, { key: n.property, filter: n }));
142
- return /* @__PURE__ */ s.createElement("div", { className: j(t, x.header) }, /* @__PURE__ */ s.createElement("div", { className: x.pickerList }, /* @__PURE__ */ s.createElement(Dt, null), a), /* @__PURE__ */ s.createElement(zt, null));
143
- }, Ot = "flow--list", $t = {
144
- list: Ot
141
+ }, Ht = (i) => {
142
+ const { className: t } = i, a = h().filters.map((n) => /* @__PURE__ */ s.createElement(Vt, { key: n.property, filter: n }));
143
+ return /* @__PURE__ */ s.createElement("div", { className: W(t, O.header) }, /* @__PURE__ */ s.createElement("div", { className: O.pickerList }, /* @__PURE__ */ s.createElement(Mt, null), a), /* @__PURE__ */ s.createElement($t, null));
144
+ }, qt = "flow--list", Kt = {
145
+ list: qt
145
146
  };
146
147
  var m;
147
- let Ht = (m = class {
148
+ let jt = (m = class {
148
149
  constructor(t, e, a) {
149
150
  o(this, "id");
150
151
  o(this, "data");
@@ -157,20 +158,20 @@ let Ht = (m = class {
157
158
  static fromRow(t, e) {
158
159
  return new m(t, e.id, e.original);
159
160
  }
160
- }, o(m, "fallbackRenderItemFn", (t) => tt("pre", void 0, JSON.stringify(t))), m);
161
- class F {
161
+ }, o(m, "fallbackRenderItemFn", (t) => at("pre", void 0, JSON.stringify(t))), m);
162
+ class T {
162
163
  constructor(t) {
163
164
  o(this, "list");
164
165
  this.list = t;
165
166
  }
166
167
  static useNew(t) {
167
- return new F(t);
168
+ return new T(t);
168
169
  }
169
170
  get entries() {
170
- return this.list.reactTable.table.getRowModel().rows.map((t) => Ht.fromRow(this, t));
171
+ return this.list.reactTable.table.getRowModel().rows.map((t) => jt.fromRow(this, t));
171
172
  }
172
173
  }
173
- class qt {
174
+ class Jt {
174
175
  constructor(t, e = {}) {
175
176
  o(this, "batchSize");
176
177
  o(this, "list");
@@ -219,8 +220,8 @@ class qt {
219
220
  }
220
221
  }
221
222
  }
222
- const Kt = (r, t) => r === t;
223
- class jt {
223
+ const Wt = (i, t) => i === t;
224
+ class Yt {
224
225
  constructor(t, e) {
225
226
  o(this, "_values");
226
227
  o(this, "list");
@@ -229,26 +230,26 @@ class jt {
229
230
  o(this, "matcher");
230
231
  o(this, "name");
231
232
  o(this, "onFilterUpdateCallbacks", /* @__PURE__ */ new Set());
232
- this.list = t, this.property = e.property, this.mode = e.mode ?? "one", this._values = e.values, this.matcher = e.matcher ?? Kt, this.name = e.name;
233
+ this.list = t, this.property = e.property, this.mode = e.mode ?? "one", this._values = e.values, this.matcher = e.matcher ?? Wt, this.name = e.name;
233
234
  }
234
235
  updateTableColumnDef(t) {
235
236
  t.enableColumnFilter = !0, t.filterFn = this.getReactTableFilterFn();
236
237
  }
237
238
  getReactTableFilterFn() {
238
239
  return (t, e, a) => this.checkFilterMatches(
239
- it(t.original, this.property),
240
+ lt(t.original, this.property),
240
241
  a
241
242
  );
242
243
  }
243
244
  checkFilterMatches(t, e) {
244
245
  if (e === null)
245
246
  return !0;
246
- const a = (i) => Array.isArray(i) ? i : [i], n = (i) => this.matcher(i, t);
247
+ const a = (r) => Array.isArray(r) ? r : [r], n = (r) => this.matcher(r, t);
247
248
  if (this.mode === "all")
248
249
  return a(e).every(n);
249
250
  if (this.mode === "some") {
250
- const i = a(e);
251
- return i.length === 0 || i.some(n);
251
+ const r = a(e);
252
+ return r.length === 0 || r.some(n);
252
253
  } else if (this.mode === "one")
253
254
  return n(e);
254
255
  throw new Error(`Unknown filter mode '${this.mode}'`);
@@ -296,13 +297,13 @@ class jt {
296
297
  toggleValue(t) {
297
298
  const e = this.isValueActive(t), a = this.getArrayValue();
298
299
  let n;
299
- this.mode === "all" || this.mode === "some" ? e ? n = a.filter((i) => i !== t) : n = [...a, t] : n = e ? null : t, this.list.reactTable.getTableColumn(this.property).setFilterValue(n), this.onFilterUpdateCallbacks.forEach((i) => i());
300
+ this.mode === "all" || this.mode === "some" ? e ? n = a.filter((r) => r !== t) : n = [...a, t] : n = e ? null : t, this.list.reactTable.getTableColumn(this.property).setFilterValue(n), this.onFilterUpdateCallbacks.forEach((r) => r());
300
301
  }
301
302
  onFilterUpdated(t) {
302
303
  this.onFilterUpdateCallbacks.add(t);
303
304
  }
304
305
  }
305
- class Jt {
306
+ class Gt {
306
307
  constructor(t, e) {
307
308
  o(this, "list");
308
309
  o(this, "property");
@@ -327,8 +328,8 @@ class Jt {
327
328
  this.list.reactTable.getTableColumn(this.property).clearSorting();
328
329
  }
329
330
  }
330
- const Wt = (r) => C(gt(r));
331
- class T {
331
+ const Qt = (i) => v(ft(i));
332
+ class w {
332
333
  constructor(t, e = {}) {
333
334
  o(this, "list");
334
335
  o(this, "table");
@@ -338,40 +339,40 @@ class T {
338
339
  if (!e)
339
340
  return;
340
341
  const a = typeof t == "function" ? t(e) : t;
341
- pt(() => {
342
+ bt(() => {
342
343
  this.tableState.value = this.getUpdatedTableState(e, a);
343
344
  });
344
345
  });
345
- this.list = t, this.tableState = ht(() => ({ value: void 0 })), this.table = this.useReactTable(e);
346
+ this.list = t, this.tableState = pt(() => ({ value: void 0 })), this.table = this.useReactTable(e);
346
347
  }
347
348
  static useNew(t, e = {}) {
348
- return new T(t, e);
349
+ return new w(t, e);
349
350
  }
350
351
  useReactTable(t = {}) {
351
- const e = this.list.loader.useData(), a = this.list.sorting.filter((i) => i.defaultEnabled), n = ot({
352
+ const e = this.list.loader.useData(), a = this.list.sorting.filter((r) => r.defaultEnabled), n = ct({
352
353
  data: e,
353
354
  initialState: {
354
355
  pagination: {
355
356
  pageSize: this.list.batches.batchSize
356
357
  },
357
- sorting: a.map((i) => ({
358
- id: String(i.property),
359
- desc: i.direction === "desc"
358
+ sorting: a.map((r) => ({
359
+ id: String(r.property),
360
+ desc: r.direction === "desc"
360
361
  }))
361
362
  },
362
363
  columns: this.getTableColumnDefs(),
363
- getCoreRowModel: lt(),
364
- getSortedRowModel: ct(),
365
- getFilteredRowModel: ut(),
366
- getPaginationRowModel: mt(),
367
- getFacetedUniqueValues: dt(),
364
+ getCoreRowModel: ut(),
365
+ getSortedRowModel: mt(),
366
+ getFilteredRowModel: dt(),
367
+ getPaginationRowModel: ht(),
368
+ getFacetedUniqueValues: gt(),
368
369
  onStateChange: this.onTableStateChange,
369
370
  ...t
370
371
  });
371
372
  return this.useUpdateTableState(n), n;
372
373
  }
373
374
  useUpdateTableState(t) {
374
- Wt(() => {
375
+ Qt(() => {
375
376
  const e = this.tableState.value;
376
377
  e ? t.setOptions((a) => ({
377
378
  ...a,
@@ -384,20 +385,20 @@ class T {
384
385
  }
385
386
  getTableColumn(t) {
386
387
  const e = this.table.getColumn(t);
387
- return J(!!e, `Column #${t} is not defined`), e;
388
+ return Y(!!e, `Column #${t} is not defined`), e;
388
389
  }
389
390
  getTableColumnDefs() {
390
391
  const t = /* @__PURE__ */ new Map(), e = (a) => {
391
392
  const n = t.get(a);
392
393
  if (n)
393
394
  return n;
394
- const i = {
395
+ const r = {
395
396
  id: a,
396
397
  accessorKey: a,
397
398
  enableSorting: !1,
398
399
  enableColumnFilter: !1
399
400
  };
400
- return t.set(a, i), i;
401
+ return t.set(a, r), r;
401
402
  };
402
403
  return this.list.filters.forEach(
403
404
  (a) => a.updateTableColumnDef(e(a.property))
@@ -406,23 +407,23 @@ class T {
406
407
  ), Array.from(t.values());
407
408
  }
408
409
  }
409
- class w {
410
+ class L {
410
411
  constructor() {
411
412
  o(this, "dataBatches", []);
412
413
  o(this, "prevDataBatches", []);
413
- o(this, "batchLoadingStates", []);
414
- ft(this, {
415
- dataBatches: k,
416
- batchLoadingStates: k,
417
- mergedData: D,
418
- isLoading: D,
419
- reset: y.bound,
420
- setDataBatch: y.bound,
421
- setBatchLoadingState: y.bound
414
+ o(this, "batchLoadingStates", ["void"]);
415
+ St(this, {
416
+ dataBatches: P.shallow,
417
+ batchLoadingStates: P.shallow,
418
+ mergedData: R,
419
+ isLoading: R,
420
+ reset: E.bound,
421
+ setDataBatch: E.bound,
422
+ setBatchLoadingState: E.bound
422
423
  });
423
424
  }
424
425
  static useNew() {
425
- return et(new w())[0];
426
+ return st(new L()).current;
426
427
  }
427
428
  reset() {
428
429
  this.batchLoadingStates = [], this.dataBatches = [];
@@ -437,17 +438,17 @@ class w {
437
438
  return (this.dataBatches.length === 0 ? this.prevDataBatches : this.dataBatches).flatMap((e) => e);
438
439
  }
439
440
  useMergedData() {
440
- return M(() => this.mergedData);
441
+ return V(() => this.mergedData);
441
442
  }
442
443
  get isLoading() {
443
- return this.batchLoadingStates.some((t) => t === "loading");
444
+ return this.batchLoadingStates.some((t) => t === "loading" || t === "void");
444
445
  }
445
446
  useIsLoading() {
446
- return M(() => this.isLoading);
447
+ return V(() => this.isLoading);
447
448
  }
448
449
  }
449
- const Yt = [];
450
- class I {
450
+ const Xt = [];
451
+ class B {
451
452
  constructor(t, e = {}) {
452
453
  o(this, "list");
453
454
  o(this, "dataSource");
@@ -456,12 +457,12 @@ class I {
456
457
  o(this, "manualPagination");
457
458
  o(this, "loaderState");
458
459
  const { source: a } = e;
459
- this.dataSource = a ?? { staticData: Yt };
460
- const n = "manualPagination" in this.dataSource ? this.dataSource.manualPagination : void 0, i = "manualFiltering" in this.dataSource ? this.dataSource.manualFiltering : void 0, l = "manualSorting" in this.dataSource ? this.dataSource.manualSorting : void 0;
461
- this.list = t, this.loaderState = w.useNew(), this.manualPagination = n ?? !1, this.manualFiltering = i ?? this.manualPagination, this.manualSorting = l ?? this.manualPagination, this.list.filters.forEach((u) => u.onFilterUpdated(() => this.reset()));
460
+ this.dataSource = a ?? { staticData: Xt };
461
+ const n = "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;
462
+ this.list = t, this.loaderState = L.useNew(), this.manualPagination = n ?? !1, this.manualFiltering = r ?? this.manualPagination, this.manualSorting = l ?? this.manualPagination, this.list.filters.forEach((u) => u.onFilterUpdated(() => this.reset()));
462
463
  }
463
464
  static useNew(t, e = {}) {
464
- return new I(t, e);
465
+ return new B(t, e);
465
466
  }
466
467
  reset() {
467
468
  this.loaderState.reset();
@@ -469,29 +470,41 @@ class I {
469
470
  useIsLoading() {
470
471
  return this.loaderState.useIsLoading();
471
472
  }
473
+ useIsInitiallyLoading() {
474
+ return this.useIsLoading() && this.list.batches.getBatchIndex() === 0;
475
+ }
472
476
  useData() {
473
477
  return this.loaderState.useMergedData();
474
478
  }
475
479
  getLoaderInvocationHooks() {
476
- return bt(this.list.batches.getBatchIndex() + 1, (e) => e).map((e) => () => {
480
+ return yt(this.list.batches.getBatchIndex() + 1, (e) => e).map((e) => () => {
477
481
  this.useLoadBatch(e);
478
482
  });
479
483
  }
480
484
  useLoadBatch(t) {
481
- const e = this.getBatchDataAsyncResource(t), a = e.use({
485
+ const e = this.getBatchDataAsyncResource(t);
486
+ e.use({
482
487
  useSuspense: !1
483
- });
484
- C(() => {
485
- if (!a.hasValue)
486
- return;
487
- const { data: n, itemTotalCount: i } = a.value;
488
- this.loaderState.setDataBatch(t, n), i !== void 0 && this.list.batches.updateItemTotalCount(i);
489
- }, [t, a.maybeValue]), C(() => (this.loaderState.setBatchLoadingState(
490
- t,
491
- e.state.value
492
- ), e.state.observe((n) => {
493
- this.loaderState.setBatchLoadingState(t, n);
494
- })), [e, t]);
488
+ }), this.useObserveBatchData(e, t), this.useObserveBatchLoadingState(e, t);
489
+ }
490
+ useObserveBatchLoadingState(t, e) {
491
+ v(() => (this.loaderState.setBatchLoadingState(
492
+ e,
493
+ t.state.value
494
+ ), t.state.observe((a) => {
495
+ this.loaderState.setBatchLoadingState(e, a);
496
+ })), [t, e]);
497
+ }
498
+ useObserveBatchData(t, e) {
499
+ v(
500
+ () => t.value.observe((a) => {
501
+ if (!a.isSet)
502
+ return;
503
+ const { data: n, itemTotalCount: r } = a.value;
504
+ this.loaderState.setDataBatch(e, n), r !== void 0 && this.list.batches.updateItemTotalCount(r);
505
+ }),
506
+ [t, e]
507
+ );
495
508
  }
496
509
  getDataLoaderOptions(t) {
497
510
  return {
@@ -514,7 +527,7 @@ class I {
514
527
  const e = this.dataSource, a = this.getDataLoaderOptions(t);
515
528
  if ("staticData" in e) {
516
529
  const n = e.staticData;
517
- return P(
530
+ return M(
518
531
  async () => ({
519
532
  data: n,
520
533
  itemTotalCount: n.length
@@ -524,7 +537,7 @@ class I {
524
537
  }
525
538
  if ("asyncLoader" in e) {
526
539
  const n = e.asyncLoader;
527
- return P(n, [a]);
540
+ return M(n, [a]);
528
541
  }
529
542
  if ("asyncResourceFactory" in e) {
530
543
  const n = e.asyncResourceFactory;
@@ -533,7 +546,7 @@ class I {
533
546
  throw new Error("Unknown data source");
534
547
  }
535
548
  }
536
- let Gt = class Y {
549
+ let Zt = class Q {
537
550
  constructor(t) {
538
551
  o(this, "filters");
539
552
  o(this, "sorting");
@@ -542,22 +555,22 @@ let Gt = class Y {
542
555
  o(this, "reactTable");
543
556
  o(this, "batches");
544
557
  o(this, "loader");
545
- const { render: e, filters: a = [], sorting: n = [], batchesController: i } = t;
546
- this.render = e, this.items = F.useNew(this), this.filters = a.map((l) => new jt(this, l)), this.sorting = n.map((l) => new Jt(this, l)), this.batches = new qt(this, i), this.loader = I.useNew(this, t.loader), this.reactTable = T.useNew(this, {
558
+ const { render: e, filters: a = [], sorting: n = [], batchesController: r } = t;
559
+ this.render = e, this.items = T.useNew(this), this.filters = a.map((l) => new Yt(this, l)), this.sorting = n.map((l) => new Gt(this, l)), this.batches = new Jt(this, r), this.loader = B.useNew(this, t.loader), this.reactTable = w.useNew(this, {
547
560
  manualFiltering: this.loader.manualFiltering,
548
561
  manualPagination: this.loader.manualPagination,
549
562
  manualSorting: this.loader.manualSorting
550
563
  });
551
564
  }
552
565
  static useNew(t) {
553
- return new Y(t);
566
+ return new Q(t);
554
567
  }
555
568
  isFiltered() {
556
569
  return this.filters.some((t) => t.isActive());
557
570
  }
558
571
  getSorting(t) {
559
572
  const e = this.sorting.find((a) => a.property === t);
560
- return J(!!e, `Could not get Sorting (property: ${t})`), e;
573
+ return Y(!!e, `Could not get Sorting (property: ${t})`), e;
561
574
  }
562
575
  clearSorting() {
563
576
  return this.sorting.forEach((t) => t.clear());
@@ -565,41 +578,44 @@ let Gt = class Y {
565
578
  clearFilters() {
566
579
  return this.filters.forEach((t) => t.clearValues());
567
580
  }
581
+ useIsEmpty() {
582
+ return !this.loader.useIsLoading() && this.items.entries.length === 0;
583
+ }
568
584
  };
569
- const Qt = "flow--list--items--item-list", Xt = "flow--list--items--is-loading", U = {
570
- itemList: Qt,
571
- isLoading: Xt
572
- }, Zt = "flow--list--items--item", _t = "flow--list--items--title", te = "flow--list--items--top-content", ee = "flow--list--items--content", ae = "flow--list--items--action", se = "flow--list--items--avatar", ne = "flow--list--items--text", re = "flow--list--items--status-badge", ie = "flow--list--items--heading", c = {
573
- item: Zt,
574
- title: _t,
575
- topContent: te,
576
- content: ee,
577
- action: ae,
578
- avatar: se,
579
- text: ne,
580
- statusBadge: re,
581
- heading: ie
582
- }, oe = (r) => {
583
- const { className: t, children: e } = r, a = E(d);
584
- return /* @__PURE__ */ s.createElement(nt, null, /* @__PURE__ */ s.createElement(
585
+ const _t = "flow--list--items--item-list", te = "flow--list--items--is-loading", $ = {
586
+ itemList: _t,
587
+ isLoading: te
588
+ }, ee = "flow--list--items--item", ae = "flow--list--items--title", se = "flow--list--items--top-content", ne = "flow--list--items--content", ie = "flow--list--items--action", re = "flow--list--items--avatar", oe = "flow--list--items--text", le = "flow--list--items--status-badge", ce = "flow--list--items--heading", c = {
589
+ item: ee,
590
+ title: ae,
591
+ topContent: se,
592
+ content: ne,
593
+ action: ie,
594
+ avatar: re,
595
+ text: oe,
596
+ statusBadge: le,
597
+ heading: ce
598
+ }, ue = (i) => {
599
+ const { className: t, children: e } = i, a = I(d);
600
+ return /* @__PURE__ */ s.createElement(rt, null, /* @__PURE__ */ s.createElement(
585
601
  g,
586
602
  {
587
603
  variant: "plain",
588
604
  className: t,
589
605
  "aria-label": a.format("list.options")
590
606
  },
591
- /* @__PURE__ */ s.createElement(Et, null)
607
+ /* @__PURE__ */ s.createElement(It, null)
592
608
  ), e);
593
- }, le = (r) => r === "top" ? c.topContent : r === "bottom" ? c.content : c.topContent, ce = (r) => {
594
- const { children: t } = r, e = st(t, vt), a = {
609
+ }, me = (i) => i === "top" ? c.topContent : i === "bottom" ? c.content : c.topContent, X = (i) => {
610
+ const { children: t } = i, e = it(t, Ft), a = {
595
611
  ContextMenu: {
596
- render: (i, l) => /* @__PURE__ */ s.createElement(oe, { className: c.action }, /* @__PURE__ */ s.createElement(i, { ...l, placement: "bottom end" }))
612
+ render: (r, l) => /* @__PURE__ */ s.createElement(ue, { className: c.action }, /* @__PURE__ */ s.createElement(r, { ...l, placement: "bottom end" }))
597
613
  },
598
614
  Button: {
599
615
  className: c.action
600
616
  },
601
617
  Content: {
602
- className: yt((i) => le(i.slot)),
618
+ className: Et((r) => me(r.slot)),
603
619
  tunnelId: "topContent"
604
620
  },
605
621
  Avatar: {
@@ -627,101 +643,103 @@ const Qt = "flow--list--items--item-list", Xt = "flow--list--items--is-loading",
627
643
  ...a
628
644
  }
629
645
  };
630
- return /* @__PURE__ */ s.createElement(Ct, { if: !e }, /* @__PURE__ */ s.createElement("div", { className: c.item }, /* @__PURE__ */ s.createElement(St, { props: n }, /* @__PURE__ */ s.createElement(Ft, null, t, /* @__PURE__ */ s.createElement("div", { className: c.title }, /* @__PURE__ */ s.createElement(N, { id: "title" })), /* @__PURE__ */ s.createElement(N, { id: "topContent" })))));
631
- }, ue = (r) => /* @__PURE__ */ s.createElement(Lt, null, JSON.stringify(r.data)), me = (r) => {
632
- const { className: t } = r, e = h(), a = e.loader.useIsLoading(), n = E(d), i = e.items.entries.map((u) => /* @__PURE__ */ s.createElement(ce, { key: u.id }, /* @__PURE__ */ s.createElement(at, null, u.render()))), l = j(
633
- U.itemList,
646
+ return /* @__PURE__ */ s.createElement(vt, { if: !e }, /* @__PURE__ */ s.createElement("div", { className: c.item }, /* @__PURE__ */ s.createElement(Ct, { props: n }, /* @__PURE__ */ s.createElement(Tt, null, t, /* @__PURE__ */ s.createElement("div", { className: c.title }, /* @__PURE__ */ s.createElement(x, { id: "title" })), /* @__PURE__ */ s.createElement(x, { id: "topContent" })))));
647
+ }, de = (i) => /* @__PURE__ */ s.createElement(At, null, JSON.stringify(i.data)), he = "flow--list--items--item-skeleton", ge = {
648
+ itemSkeleton: he
649
+ }, b = () => /* @__PURE__ */ s.createElement(X, null, /* @__PURE__ */ s.createElement(kt, { className: ge.itemSkeleton })), pe = (i) => {
650
+ const { className: t } = i, e = h(), a = e.loader.useIsLoading(), n = e.loader.useIsInitiallyLoading(), r = e.useIsEmpty(), l = I(d), u = e.items.entries.map((y) => /* @__PURE__ */ s.createElement(X, { key: y.id }, /* @__PURE__ */ s.createElement(nt, null, y.render()))), p = W(
651
+ $.itemList,
634
652
  t,
635
- a && U.isLoading
653
+ a && $.isLoading
636
654
  );
637
- return /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("div", { className: l }, i), i.length <= 0 && !a && /* @__PURE__ */ s.createElement(Tt, null, /* @__PURE__ */ s.createElement(wt, null), /* @__PURE__ */ s.createElement(It, null, n.format("list.noResult.heading")), /* @__PURE__ */ s.createElement(f, null, n.format("list.noResult.text"))));
638
- };
639
- function de(r) {
655
+ return r ? /* @__PURE__ */ s.createElement(wt, null, /* @__PURE__ */ s.createElement(Lt, null), /* @__PURE__ */ s.createElement(Bt, null, l.format("list.noResult.heading")), /* @__PURE__ */ s.createElement(S, null, l.format("list.noResult.text"))) : /* @__PURE__ */ s.createElement("div", { className: p }, n ? fe : u);
656
+ }, fe = /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement(b, null), /* @__PURE__ */ s.createElement(b, null), /* @__PURE__ */ s.createElement(b, null), /* @__PURE__ */ s.createElement(b, null), /* @__PURE__ */ s.createElement(b, null));
657
+ function be(i) {
640
658
  return null;
641
659
  }
642
- function he(r) {
660
+ function Se(i) {
643
661
  return null;
644
662
  }
645
- function ge(r) {
663
+ function ye(i) {
646
664
  return null;
647
665
  }
648
- function pe(r) {
666
+ function Ce(i) {
649
667
  return null;
650
668
  }
651
- function fe(r) {
669
+ function Ee(i) {
652
670
  return null;
653
671
  }
654
- const be = "flow--list--footer", Se = {
655
- footer: be
656
- }, ye = (r) => {
657
- const t = K(d), e = h(), a = e.batches, n = e.isFiltered() && !e.loader.manualFiltering, i = a.getTotalItemsCount(), l = a.getFilteredItemsCount(), u = a.getVisibleItemsCount();
658
- if (i === 0)
672
+ const ve = "flow--list--footer", Fe = {
673
+ footer: ve
674
+ }, Ie = (i) => {
675
+ const t = J(d), e = h(), a = e.batches, n = e.isFiltered() && !e.loader.manualFiltering, r = a.getTotalItemsCount(), l = a.getFilteredItemsCount(), u = a.getVisibleItemsCount();
676
+ if (r === 0)
659
677
  return null;
660
- const S = n ? t("list.paginationInfoFiltered", {
678
+ const p = n ? t("list.paginationInfoFiltered", {
661
679
  visibleItemsCount: u,
662
680
  filteredItemsCount: l,
663
- totalItemsCount: i
681
+ totalItemsCount: r
664
682
  }) : t("list.paginationInfo", {
665
683
  visibleItemsCount: u,
666
- totalItemsCount: i
684
+ totalItemsCount: r
667
685
  });
668
- return /* @__PURE__ */ s.createElement(f, { ...r }, S);
669
- }, Ce = (r) => {
670
- const t = E(d), e = h(), a = e.loader.useIsLoading();
671
- return e.batches.hasNextBatch() ? /* @__PURE__ */ s.createElement(
686
+ return /* @__PURE__ */ s.createElement(S, { ...i }, p);
687
+ }, Te = (i) => {
688
+ const t = I(d), e = h(), a = e.loader.useIsLoading(), n = e.loader.useIsInitiallyLoading(), l = e.batches.hasNextBatch();
689
+ return n || !l && !a ? null : /* @__PURE__ */ s.createElement(
672
690
  g,
673
691
  {
674
692
  isPending: a,
675
- ...r,
693
+ ...i,
676
694
  onPress: () => e.batches.nextBatch(),
677
695
  variant: "plain",
678
696
  size: "s"
679
697
  },
680
698
  t.format("list.showMore")
681
- ) : null;
682
- }, ve = () => /* @__PURE__ */ s.createElement("div", { className: Se.footer }, /* @__PURE__ */ s.createElement(ye, null), /* @__PURE__ */ s.createElement(Ce, null));
683
- function sa(r) {
684
- var L, B, A, R;
685
- const { children: t, batchSize: e, ...a } = r, n = (L = b(t, de)) == null ? void 0 : L.props, i = (B = b(
699
+ );
700
+ }, we = () => /* @__PURE__ */ s.createElement("div", { className: Fe.footer }, /* @__PURE__ */ s.createElement(Ie, null), /* @__PURE__ */ s.createElement(Te, null));
701
+ function ca(i) {
702
+ var k, A, D, N;
703
+ const { children: t, batchSize: e, ...a } = i, n = (k = C(t, be)) == null ? void 0 : k.props, r = (A = C(
686
704
  t,
687
- Bt
688
- )) == null ? void 0 : B.props, l = (A = b(t, fe)) == null ? void 0 : A.props, u = {
705
+ Dt
706
+ )) == null ? void 0 : A.props, l = (D = C(t, Ee)) == null ? void 0 : D.props, u = {
689
707
  source: n ? {
690
708
  ...n,
691
709
  asyncLoader: n.children
692
- } : i ? {
693
- ...i,
694
- asyncResourceFactory: i.children
710
+ } : r ? {
711
+ ...r,
712
+ asyncResourceFactory: r.children
695
713
  } : l ? {
696
714
  staticData: l.data
697
715
  } : void 0
698
- }, S = (p) => /* @__PURE__ */ s.createElement(ue, { data: p }), G = Gt.useNew({
716
+ }, p = (f) => /* @__PURE__ */ s.createElement(de, { data: f }), y = Zt.useNew({
699
717
  loader: u,
700
- filters: V(t, he).map((p) => p.props),
701
- sorting: V(t, ge).map((p) => p.props),
702
- render: ((R = b(t, pe)) == null ? void 0 : R.props.children) ?? S,
718
+ filters: z(t, Se).map((f) => f.props),
719
+ sorting: z(t, ye).map((f) => f.props),
720
+ render: ((N = C(t, Ce)) == null ? void 0 : N.props.children) ?? p,
703
721
  ...a,
704
722
  batchesController: {
705
723
  batchSize: e
706
724
  }
707
725
  });
708
726
  return /* @__PURE__ */ s.createElement(
709
- W.Provider,
727
+ G.Provider,
710
728
  {
711
729
  value: {
712
- list: G
730
+ list: y
713
731
  }
714
732
  },
715
- /* @__PURE__ */ s.createElement(Rt, null),
716
- /* @__PURE__ */ s.createElement("div", { className: $t.list }, /* @__PURE__ */ s.createElement(Ut, null), /* @__PURE__ */ s.createElement(me, null), /* @__PURE__ */ s.createElement(ve, null))
733
+ /* @__PURE__ */ s.createElement(Pt, null),
734
+ /* @__PURE__ */ s.createElement("div", { className: Kt.list }, /* @__PURE__ */ s.createElement(Ht, null), /* @__PURE__ */ s.createElement(pe, null), /* @__PURE__ */ s.createElement(we, null))
717
735
  );
718
736
  }
719
737
  export {
720
- sa as List,
721
- he as ListFilter,
722
- pe as ListItemView,
723
- de as ListLoaderAsync,
724
- ge as ListSorting,
725
- fe as ListStaticData,
726
- sa as default
738
+ ca as List,
739
+ Se as ListFilter,
740
+ Ce as ListItemView,
741
+ be as ListLoaderAsync,
742
+ ye as ListSorting,
743
+ Ee as ListStaticData,
744
+ ca as default
727
745
  };