@mittwald/flow-react-components 0.1.0-alpha.180 → 0.1.0-alpha.182
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 +44 -27
- package/dist/styles.css +1 -1
- package/dist/types/components/List/model/List.d.ts +1 -0
- package/dist/types/components/List/model/ReactTable.d.ts +1 -1
- package/dist/types/components/List/model/sorting/Sorting.d.ts +4 -3
- package/dist/types/components/List/model/sorting/types.d.ts +2 -1
- package/package.json +38 -38
package/dist/List.js
CHANGED
|
@@ -28,13 +28,13 @@ import { T as It } from "./TextField-DhdMjRzb.js";
|
|
|
28
28
|
import { autorun as At, runInAction as kt, makeObservable as Vt, observable as O, computed as H, action as L } from "mobx";
|
|
29
29
|
import "./context-BB3_MApL.js";
|
|
30
30
|
import { u as xt } from "./useOnChange-C1Quwyuz.js";
|
|
31
|
-
import { getProperty as
|
|
32
|
-
import { useReactTable as
|
|
31
|
+
import { getProperty as Bt } from "dot-prop";
|
|
32
|
+
import { useReactTable as Pt, getCoreRowModel as Dt, getSortedRowModel as Nt, getFilteredRowModel as Rt, getPaginationRowModel as zt, getFacetedUniqueValues as Mt } from "@tanstack/react-table";
|
|
33
33
|
import _ from "invariant";
|
|
34
34
|
import { useLocalObservable as Ut } from "mobx-react-lite";
|
|
35
35
|
import { getAsyncResource as q } from "@mittwald/react-use-promise";
|
|
36
36
|
import { u as G } from "./useSelector-DpU7_HMO.js";
|
|
37
|
-
import * as
|
|
37
|
+
import * as B from "react-aria-components";
|
|
38
38
|
import { I as $t } from "./IllustratedMessage-B3MHD01M.js";
|
|
39
39
|
import { I as Ot } from "./IconSearch-Bxe-heXD.js";
|
|
40
40
|
import { H as tt } from "./Heading-1M1gRZfk.js";
|
|
@@ -130,10 +130,10 @@ const Gt = "flow--list--items--item--view", Kt = "flow--list--items--item--view-
|
|
|
130
130
|
const { children: t, locales: e, variables: a } = i;
|
|
131
131
|
return b(e).format(t, a);
|
|
132
132
|
}, ae = () => {
|
|
133
|
-
const i = h(), t = i.
|
|
134
|
-
if (
|
|
133
|
+
const i = h(), t = i.visibleSorting.map((s) => /* @__PURE__ */ n.createElement(ee, { sorting: s, key: s.id }));
|
|
134
|
+
if (t.length === 0)
|
|
135
135
|
return null;
|
|
136
|
-
const e = i.
|
|
136
|
+
const e = i.visibleSorting.find((s) => s.isSorted()), a = /* @__PURE__ */ n.createElement(S, null, e ? /* @__PURE__ */ n.createElement(
|
|
137
137
|
A,
|
|
138
138
|
{
|
|
139
139
|
locales: g,
|
|
@@ -240,7 +240,10 @@ const Gt = "flow--list--items--item--view", Kt = "flow--list--items--item--view-
|
|
|
240
240
|
...e.textFieldProps
|
|
241
241
|
});
|
|
242
242
|
}, he = (i) => {
|
|
243
|
-
const { className: t } = i, e = h()
|
|
243
|
+
const { className: t } = i, e = h();
|
|
244
|
+
if (e.filters.length === 0 && e.visibleSorting.length === 0 && !e.search)
|
|
245
|
+
return null;
|
|
246
|
+
const a = e.filters.map((s) => /* @__PURE__ */ n.createElement(se, { key: s.property, filter: s }));
|
|
244
247
|
return /* @__PURE__ */ n.createElement("div", { className: C(t, w.header) }, /* @__PURE__ */ n.createElement("div", { className: w.pickerListAndSearch }, /* @__PURE__ */ n.createElement("div", { className: w.pickerList }, /* @__PURE__ */ n.createElement(ae, null), a), e.search && /* @__PURE__ */ n.createElement(de, { className: w.searchField, search: e.search })), /* @__PURE__ */ n.createElement(ue, null));
|
|
245
248
|
}, ge = "flow--list", pe = {
|
|
246
249
|
list: ge
|
|
@@ -329,7 +332,7 @@ class ye {
|
|
|
329
332
|
}
|
|
330
333
|
getReactTableFilterFn() {
|
|
331
334
|
return (t, e, a) => this.checkFilterMatches(
|
|
332
|
-
|
|
335
|
+
Bt(t.original, this.property),
|
|
333
336
|
a
|
|
334
337
|
);
|
|
335
338
|
}
|
|
@@ -404,11 +407,17 @@ class we {
|
|
|
404
407
|
r(this, "name");
|
|
405
408
|
r(this, "direction");
|
|
406
409
|
r(this, "defaultEnabled");
|
|
407
|
-
this.list = t, this.property = e.property, this.name = e.name, this.direction = e.direction ?? "asc", this.defaultEnabled =
|
|
410
|
+
this.list = t, this.property = e.property, this.name = e.name, this.direction = e.direction ?? "asc", this.defaultEnabled = e.defaultEnabled ?? !1;
|
|
408
411
|
}
|
|
409
412
|
updateTableColumnDef(t) {
|
|
410
413
|
t.enableSorting = !0;
|
|
411
414
|
}
|
|
415
|
+
getReactTableColumnSort() {
|
|
416
|
+
return {
|
|
417
|
+
id: this.property,
|
|
418
|
+
desc: this.direction === "desc"
|
|
419
|
+
};
|
|
420
|
+
}
|
|
412
421
|
isSorted() {
|
|
413
422
|
return this.getTableColumn().getIsSorted() == this.direction;
|
|
414
423
|
}
|
|
@@ -426,7 +435,7 @@ class we {
|
|
|
426
435
|
}
|
|
427
436
|
}
|
|
428
437
|
const Ee = (i) => T(At(i));
|
|
429
|
-
class
|
|
438
|
+
class P {
|
|
430
439
|
constructor(t, e = {}) {
|
|
431
440
|
r(this, "list");
|
|
432
441
|
r(this, "table");
|
|
@@ -437,25 +446,24 @@ class B {
|
|
|
437
446
|
return;
|
|
438
447
|
const a = typeof t == "function" ? t(e) : t;
|
|
439
448
|
kt(() => {
|
|
440
|
-
this.tableState.value =
|
|
449
|
+
this.finalizeTableState(a), this.tableState.value = a;
|
|
441
450
|
});
|
|
442
451
|
});
|
|
443
452
|
this.list = t, this.tableState = Ut(() => ({ value: void 0 })), this.table = this.useReactTable(e);
|
|
444
453
|
}
|
|
445
454
|
static useNew(t, e = {}) {
|
|
446
|
-
return new
|
|
455
|
+
return new P(t, e);
|
|
447
456
|
}
|
|
448
457
|
useReactTable(t = {}) {
|
|
449
|
-
const e = this.list.loader.useData(), a = this.list.sorting.filter(
|
|
458
|
+
const e = this.list.loader.useData(), a = this.list.sorting.filter(
|
|
459
|
+
(o) => o.defaultEnabled !== !1
|
|
460
|
+
), s = Pt({
|
|
450
461
|
data: e,
|
|
451
462
|
initialState: {
|
|
452
463
|
pagination: {
|
|
453
464
|
pageSize: this.list.batches.batchSize
|
|
454
465
|
},
|
|
455
|
-
sorting: a.map((o) => (
|
|
456
|
-
id: String(o.property),
|
|
457
|
-
desc: o.direction === "desc"
|
|
458
|
-
}))
|
|
466
|
+
sorting: a.map((o) => o.getReactTableColumnSort())
|
|
459
467
|
},
|
|
460
468
|
columns: this.getTableColumnDefs(),
|
|
461
469
|
getCoreRowModel: Dt(),
|
|
@@ -478,8 +486,11 @@ class B {
|
|
|
478
486
|
})) : this.tableState.value = t.getState();
|
|
479
487
|
});
|
|
480
488
|
}
|
|
481
|
-
|
|
482
|
-
|
|
489
|
+
finalizeTableState(t) {
|
|
490
|
+
const e = this.list.sorting.filter(
|
|
491
|
+
(a) => a.defaultEnabled === "hidden" && !t.sorting.some((s) => s.id === a.property)
|
|
492
|
+
).map((a) => a.getReactTableColumnSort());
|
|
493
|
+
t.sorting.unshift(...e);
|
|
483
494
|
}
|
|
484
495
|
get searchString() {
|
|
485
496
|
var t;
|
|
@@ -515,6 +526,9 @@ class D {
|
|
|
515
526
|
r(this, "prevDataBatches", []);
|
|
516
527
|
r(this, "batchLoadingStates", ["void"]);
|
|
517
528
|
Vt(this, {
|
|
529
|
+
prevDataBatches: !1,
|
|
530
|
+
useMergedData: !1,
|
|
531
|
+
useIsLoading: !1,
|
|
518
532
|
dataBatches: O.shallow,
|
|
519
533
|
batchLoadingStates: O.shallow,
|
|
520
534
|
mergedData: H,
|
|
@@ -704,7 +718,7 @@ let k = E, Le = class it {
|
|
|
704
718
|
batchesController: o,
|
|
705
719
|
hasAction: l
|
|
706
720
|
} = t;
|
|
707
|
-
this.items = new be(this), this.filters = a.map((c) => new ye(this, c)), this.sorting = s.map((c) => new we(this, c)), this.search = t.search ? new Fe(this, t.search) : void 0, this.itemView = new k(this, e), this.batches = new Se(this, o), this.loader = N.useNew(this, t.loader), this.reactTable =
|
|
721
|
+
this.items = new be(this), this.filters = a.map((c) => new ye(this, c)), this.sorting = s.map((c) => new we(this, c)), this.search = t.search ? new Fe(this, t.search) : void 0, this.itemView = new k(this, e), this.batches = new Se(this, o), this.loader = N.useNew(this, t.loader), this.reactTable = P.useNew(this, {
|
|
708
722
|
manualFiltering: this.loader.manualFiltering,
|
|
709
723
|
manualPagination: this.loader.manualPagination,
|
|
710
724
|
manualSorting: this.loader.manualSorting
|
|
@@ -716,6 +730,9 @@ let k = E, Le = class it {
|
|
|
716
730
|
get isFiltered() {
|
|
717
731
|
return this.filters.some((t) => t.isActive()) || !!this.search && this.search.isSet;
|
|
718
732
|
}
|
|
733
|
+
get visibleSorting() {
|
|
734
|
+
return this.sorting.filter((t) => t.defaultEnabled !== "hidden");
|
|
735
|
+
}
|
|
719
736
|
getSorting(t) {
|
|
720
737
|
const e = this.sorting.find((a) => a.id === t);
|
|
721
738
|
return _(!!e, `Could not get Sorting (ID: ${t})`), e;
|
|
@@ -740,7 +757,7 @@ const Te = "flow--list--items", Ie = "flow--list--items--is-loading", J = {
|
|
|
740
757
|
}, Ve = (i) => {
|
|
741
758
|
const { data: t, children: e } = i, a = h(), s = a.itemView, o = s.onAction, l = s.textValue ? s.textValue(t) : void 0, c = o ? () => o(t) : void 0, m = s.href ? s.href(t) : void 0, u = a.hasAction || !!c || !!m, v = C(V.item, u && V.hasAction);
|
|
742
759
|
return /* @__PURE__ */ n.createElement(
|
|
743
|
-
|
|
760
|
+
B.GridListItem,
|
|
744
761
|
{
|
|
745
762
|
className: v,
|
|
746
763
|
onAction: c,
|
|
@@ -749,11 +766,11 @@ const Te = "flow--list--items", Ie = "flow--list--items--is-loading", J = {
|
|
|
749
766
|
},
|
|
750
767
|
e ?? s.render(t)
|
|
751
768
|
);
|
|
752
|
-
}, xe = (i) => /* @__PURE__ */ n.createElement(
|
|
769
|
+
}, xe = (i) => /* @__PURE__ */ n.createElement(B.GridListItem, { textValue: "-", className: V.item }, i.children), Be = () => {
|
|
753
770
|
const i = b(g);
|
|
754
771
|
return /* @__PURE__ */ n.createElement($t, null, /* @__PURE__ */ n.createElement(Ot, null), /* @__PURE__ */ n.createElement(tt, null, i.format("list.noResult.heading")), /* @__PURE__ */ n.createElement(S, null, i.format("list.noResult.text")));
|
|
755
|
-
},
|
|
756
|
-
const t = h().itemView.fallback ?? /* @__PURE__ */ n.createElement(
|
|
772
|
+
}, Pe = () => /* @__PURE__ */ n.createElement(et, null, /* @__PURE__ */ n.createElement(tt, null, /* @__PURE__ */ n.createElement(I, { width: "200px" })), /* @__PURE__ */ n.createElement(S, null, /* @__PURE__ */ n.createElement(I, { width: "300px" }))), De = () => {
|
|
773
|
+
const t = h().itemView.fallback ?? /* @__PURE__ */ n.createElement(Pe, null);
|
|
757
774
|
return Array.from(Array(5)).map((e, a) => /* @__PURE__ */ n.createElement(xe, { key: a }, bt(t)));
|
|
758
775
|
}, Ne = (i) => {
|
|
759
776
|
const { className: t, ...e } = i, a = h(), s = a.loader.useIsLoading(), o = a.loader.useIsInitiallyLoading(), l = a.useIsEmpty(), c = a.items.entries.map((u) => /* @__PURE__ */ n.createElement(Ve, { key: u.id, data: u.data })), m = C(
|
|
@@ -761,7 +778,7 @@ const Te = "flow--list--items", Ie = "flow--list--items--is-loading", J = {
|
|
|
761
778
|
t,
|
|
762
779
|
s && J.isLoading
|
|
763
780
|
);
|
|
764
|
-
return l ? /* @__PURE__ */ n.createElement(
|
|
781
|
+
return l ? /* @__PURE__ */ n.createElement(Be, null) : /* @__PURE__ */ n.createElement("div", { "aria-hidden": o, "aria-busy": s }, /* @__PURE__ */ n.createElement(B.GridList, { className: m, ...e }, o ? /* @__PURE__ */ n.createElement(De, null) : c));
|
|
765
782
|
}, nt = (i) => null, Re = () => nt, rt = (i) => null, ze = () => rt, ot = (i) => null, Me = () => ot, lt = (i) => null, Ue = () => lt, ct = (i) => null, $e = () => ct, Oe = "flow--list--footer", He = {
|
|
766
783
|
footer: Oe
|
|
767
784
|
}, qe = (i) => {
|
|
@@ -838,7 +855,7 @@ const je = () => ut, Je = Lt("List", (i) => {
|
|
|
838
855
|
/* @__PURE__ */ n.createElement(te, null),
|
|
839
856
|
/* @__PURE__ */ n.createElement("div", { className: pe.list }, /* @__PURE__ */ n.createElement(he, null), /* @__PURE__ */ n.createElement(Ne, { ...a }), /* @__PURE__ */ n.createElement(Ke, null))
|
|
840
857
|
);
|
|
841
|
-
}),
|
|
858
|
+
}), Ba = () => ({
|
|
842
859
|
List: Je,
|
|
843
860
|
Filter: ze(),
|
|
844
861
|
Search: je(),
|
|
@@ -862,5 +879,5 @@ export {
|
|
|
862
879
|
Re as TypedListLoaderAsync,
|
|
863
880
|
Me as TypedListSorting,
|
|
864
881
|
$e as TypedListStaticData,
|
|
865
|
-
|
|
882
|
+
Ba as typedList
|
|
866
883
|
};
|