@timeax/form-palette 0.0.30 → 0.0.32
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/Readme.md +651 -0
- package/dist/extra.d.mts +213 -40
- package/dist/extra.d.ts +213 -40
- package/dist/extra.js +623 -85
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +621 -86
- package/dist/extra.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +240 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -84
- package/dist/index.mjs.map +1 -1
- package/dist/{variant-v0LBdshU.d.ts → variant-BhsBO5Yr.d.ts} +1 -1
- package/dist/{variant-BPDyK780.d.mts → variant-jHi2M5Ru.d.mts} +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23802,19 +23802,139 @@ function mapOptions(rawList, mapping, ctx) {
|
|
|
23802
23802
|
}
|
|
23803
23803
|
|
|
23804
23804
|
// src/presets/lister/engine/search.ts
|
|
23805
|
-
function
|
|
23806
|
-
|
|
23807
|
-
|
|
23808
|
-
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
|
|
23813
|
-
|
|
23814
|
-
|
|
23805
|
+
function getPath2(obj, path) {
|
|
23806
|
+
if (!obj || !path) return void 0;
|
|
23807
|
+
if (!path.includes(".")) return obj[path];
|
|
23808
|
+
let cur = obj;
|
|
23809
|
+
for (const part of path.split(".")) {
|
|
23810
|
+
if (cur == null) return void 0;
|
|
23811
|
+
cur = cur[part];
|
|
23812
|
+
}
|
|
23813
|
+
return cur;
|
|
23814
|
+
}
|
|
23815
|
+
function toText(v2) {
|
|
23816
|
+
if (v2 == null) return "";
|
|
23817
|
+
if (typeof v2 === "string") return v2;
|
|
23818
|
+
if (typeof v2 === "number" || typeof v2 === "boolean") return String(v2);
|
|
23819
|
+
return "";
|
|
23820
|
+
}
|
|
23821
|
+
function collectAllText(obj, out, depth = 2, budget = { n: 80 }) {
|
|
23822
|
+
if (obj == null || budget.n <= 0) return;
|
|
23823
|
+
const t4 = typeof obj;
|
|
23824
|
+
if (t4 === "string" || t4 === "number" || t4 === "boolean") {
|
|
23825
|
+
out.push(String(obj));
|
|
23826
|
+
budget.n -= 1;
|
|
23827
|
+
return;
|
|
23828
|
+
}
|
|
23829
|
+
if (depth <= 0) return;
|
|
23830
|
+
if (Array.isArray(obj)) {
|
|
23831
|
+
for (const x2 of obj) collectAllText(x2, out, depth - 1, budget);
|
|
23832
|
+
return;
|
|
23833
|
+
}
|
|
23834
|
+
if (t4 === "object") {
|
|
23835
|
+
for (const k2 of Object.keys(obj)) {
|
|
23836
|
+
collectAllText(obj[k2], out, depth - 1, budget);
|
|
23837
|
+
if (budget.n <= 0) break;
|
|
23838
|
+
}
|
|
23839
|
+
}
|
|
23840
|
+
}
|
|
23841
|
+
function matchQueryInText(q2, text) {
|
|
23842
|
+
if (!q2) return true;
|
|
23843
|
+
return text.toLowerCase().includes(q2);
|
|
23844
|
+
}
|
|
23845
|
+
function buildSearchTextForKeys(raw, keys) {
|
|
23846
|
+
const parts = [];
|
|
23847
|
+
for (const k2 of keys) {
|
|
23848
|
+
const key = String(k2);
|
|
23849
|
+
const v2 = getPath2(raw, key);
|
|
23850
|
+
if (v2 == null) continue;
|
|
23851
|
+
if (Array.isArray(v2)) {
|
|
23852
|
+
for (const x2 of v2) {
|
|
23853
|
+
const s4 = toText(x2);
|
|
23854
|
+
if (s4) parts.push(s4);
|
|
23855
|
+
}
|
|
23856
|
+
continue;
|
|
23857
|
+
}
|
|
23858
|
+
const s3 = toText(v2);
|
|
23859
|
+
if (s3) parts.push(s3);
|
|
23860
|
+
}
|
|
23861
|
+
return parts.join(" ");
|
|
23862
|
+
}
|
|
23863
|
+
function matchesSearch(raw, q2, search) {
|
|
23864
|
+
if (!q2) return true;
|
|
23865
|
+
if (search == null ? void 0 : search.searchAll) {
|
|
23866
|
+
return matchQueryInText(q2, buildSearchTextAll(raw));
|
|
23867
|
+
}
|
|
23868
|
+
if (Array.isArray(search == null ? void 0 : search.searchOnly) && search.searchOnly.length) {
|
|
23869
|
+
return matchQueryInText(
|
|
23870
|
+
q2,
|
|
23871
|
+
buildSearchTextForKeys(raw, search.searchOnly)
|
|
23872
|
+
);
|
|
23873
|
+
}
|
|
23874
|
+
if (typeof (search == null ? void 0 : search.subject) === "string" && search.subject) {
|
|
23875
|
+
return matchQueryInText(
|
|
23876
|
+
q2,
|
|
23877
|
+
buildSearchTextForKeys(raw, [search.subject])
|
|
23878
|
+
);
|
|
23879
|
+
}
|
|
23880
|
+
return matchQueryInText(q2, buildSearchTextAll(raw));
|
|
23881
|
+
}
|
|
23882
|
+
function buildSearchTextAll(raw) {
|
|
23883
|
+
const parts = [];
|
|
23884
|
+
collectAllText(raw, parts, 2);
|
|
23885
|
+
return parts.join(" ");
|
|
23886
|
+
}
|
|
23887
|
+
function isEmptyFilterValue(v2) {
|
|
23888
|
+
if (v2 === void 0 || v2 === null) return true;
|
|
23889
|
+
if (typeof v2 === "string" && v2.trim() === "") return true;
|
|
23890
|
+
return Array.isArray(v2) && v2.length === 0;
|
|
23891
|
+
}
|
|
23892
|
+
function matchesFilters(raw, filters) {
|
|
23893
|
+
if (!filters) return true;
|
|
23894
|
+
for (const key of Object.keys(filters)) {
|
|
23895
|
+
if (key === "search" || key === "subject" || key === "searchAll" || key === "searchOnly") {
|
|
23896
|
+
continue;
|
|
23897
|
+
}
|
|
23898
|
+
const fv = filters[key];
|
|
23899
|
+
if (isEmptyFilterValue(fv)) continue;
|
|
23900
|
+
const rv = getPath2(raw, key);
|
|
23901
|
+
if (Array.isArray(fv)) {
|
|
23902
|
+
if (Array.isArray(rv)) {
|
|
23903
|
+
const ok = rv.some((x2) => fv.includes(x2));
|
|
23904
|
+
if (!ok) return false;
|
|
23905
|
+
} else {
|
|
23906
|
+
if (!fv.includes(rv)) return false;
|
|
23907
|
+
}
|
|
23908
|
+
continue;
|
|
23909
|
+
}
|
|
23910
|
+
if (Array.isArray(rv)) {
|
|
23911
|
+
if (!rv.includes(fv)) return false;
|
|
23912
|
+
continue;
|
|
23913
|
+
}
|
|
23914
|
+
if (String(rv) !== String(fv)) return false;
|
|
23915
|
+
}
|
|
23916
|
+
return true;
|
|
23917
|
+
}
|
|
23918
|
+
function filterRawListLocal(rawList, query, search, filters, opts) {
|
|
23919
|
+
let list = Array.isArray(rawList) ? rawList : [];
|
|
23920
|
+
const ctx = { query, search, filters };
|
|
23921
|
+
const filtersLocal = (opts == null ? void 0 : opts.filtersSpec) && opts.filtersSpec.local;
|
|
23922
|
+
if (typeof filtersLocal === "function") {
|
|
23923
|
+
const out = filtersLocal(list, ctx);
|
|
23924
|
+
if (Array.isArray(out)) list = out;
|
|
23925
|
+
} else {
|
|
23926
|
+
list = list.filter(
|
|
23927
|
+
(r5) => matchesFilters(r5, filters)
|
|
23928
|
+
);
|
|
23929
|
+
}
|
|
23815
23930
|
const q2 = (query != null ? query : "").trim().toLowerCase();
|
|
23816
|
-
if (!q2) return
|
|
23817
|
-
|
|
23931
|
+
if (!q2) return list;
|
|
23932
|
+
const searchLocal = (opts == null ? void 0 : opts.searchSpec) && opts.searchSpec.local;
|
|
23933
|
+
if (typeof searchLocal === "function") {
|
|
23934
|
+
const out = searchLocal(list, ctx);
|
|
23935
|
+
if (Array.isArray(out)) return out;
|
|
23936
|
+
}
|
|
23937
|
+
return list.filter((r5) => matchesSearch(r5, q2, search));
|
|
23818
23938
|
}
|
|
23819
23939
|
|
|
23820
23940
|
// src/presets/lister/engine/selection.ts
|
|
@@ -23976,7 +24096,8 @@ function initialSessionState(sessionId) {
|
|
|
23976
24096
|
filtersPatch: {},
|
|
23977
24097
|
effectiveFilters: void 0,
|
|
23978
24098
|
// IMPORTANT: these are now OPTION IDS (not db values)
|
|
23979
|
-
selectedFilterValues: []
|
|
24099
|
+
selectedFilterValues: [],
|
|
24100
|
+
searchPayload: void 0
|
|
23980
24101
|
};
|
|
23981
24102
|
}
|
|
23982
24103
|
function buildSearchPayloadFromTarget(target) {
|
|
@@ -23988,7 +24109,7 @@ function buildSearchPayloadFromTarget(target) {
|
|
|
23988
24109
|
return subject ? { subject } : void 0;
|
|
23989
24110
|
}
|
|
23990
24111
|
if (target.mode === "only") {
|
|
23991
|
-
const only = Array.isArray(target.only) ? target.only.filter(
|
|
24112
|
+
const only = Array.isArray(target.only) ? target.only.filter((v2) => v2 !== null && v2 !== void 0) : void 0;
|
|
23992
24113
|
return only && only.length ? { searchOnly: only } : void 0;
|
|
23993
24114
|
}
|
|
23994
24115
|
return void 0;
|
|
@@ -24245,16 +24366,15 @@ function ListerProvider(props) {
|
|
|
24245
24366
|
);
|
|
24246
24367
|
const fetchAndHydrate = React67.useCallback(
|
|
24247
24368
|
async (id, reason, override) => {
|
|
24248
|
-
var _a2, _b2, _c2, _d, _e, _f, _g
|
|
24369
|
+
var _a2, _b2, _c2, _d, _e, _f, _g;
|
|
24249
24370
|
const s0 = getSession(id);
|
|
24250
24371
|
if (!(s0 == null ? void 0 : s0.definition)) return;
|
|
24251
24372
|
const myReq = ((_a2 = reqIdBySessionRef.current[id]) != null ? _a2 : 0) + 1;
|
|
24252
24373
|
reqIdBySessionRef.current[id] = myReq;
|
|
24253
24374
|
const query = (_b2 = override == null ? void 0 : override.query) != null ? _b2 : s0.query;
|
|
24254
24375
|
const filters = (_d = (_c2 = override == null ? void 0 : override.filters) != null ? _c2 : s0.effectiveFilters) != null ? _d : s0.filters;
|
|
24255
|
-
const
|
|
24256
|
-
|
|
24257
|
-
);
|
|
24376
|
+
const hasSearchOverride = !!override && Object.prototype.hasOwnProperty.call(override, "search");
|
|
24377
|
+
const search = hasSearchOverride ? override.search : (_e = s0.searchPayload) != null ? _e : buildSearchPayloadFromTarget(s0.searchTarget);
|
|
24258
24378
|
patchSession(id, {
|
|
24259
24379
|
errorCode: void 0,
|
|
24260
24380
|
loading: reason !== "refresh",
|
|
@@ -24287,7 +24407,7 @@ function ListerProvider(props) {
|
|
|
24287
24407
|
details: {
|
|
24288
24408
|
sessionId: id,
|
|
24289
24409
|
kind: s3 == null ? void 0 : s3.kind,
|
|
24290
|
-
endpoint: (
|
|
24410
|
+
endpoint: (_g = (_f = s3 == null ? void 0 : s3.definition) == null ? void 0 : _f.source) == null ? void 0 : _g.endpoint,
|
|
24291
24411
|
query,
|
|
24292
24412
|
filters,
|
|
24293
24413
|
search
|
|
@@ -24341,7 +24461,7 @@ function ListerProvider(props) {
|
|
|
24341
24461
|
nextPatch,
|
|
24342
24462
|
spec
|
|
24343
24463
|
);
|
|
24344
|
-
shouldFetch = (spec == null ? void 0 : spec.autoFetch) !== false;
|
|
24464
|
+
shouldFetch = (spec == null ? void 0 : spec.autoFetch) !== false && s4.searchMode !== "local";
|
|
24345
24465
|
return {
|
|
24346
24466
|
...s4,
|
|
24347
24467
|
filtersPatch: nextPatch,
|
|
@@ -24430,7 +24550,7 @@ function ListerProvider(props) {
|
|
|
24430
24550
|
);
|
|
24431
24551
|
const apiOpenAny = React67.useCallback(
|
|
24432
24552
|
async (kindOrDef, filters, opts) => {
|
|
24433
|
-
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i;
|
|
24553
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
24434
24554
|
const mode = (_a2 = opts == null ? void 0 : opts.mode) != null ? _a2 : "single";
|
|
24435
24555
|
try {
|
|
24436
24556
|
const def = typeof kindOrDef === "string" ? getPreset(kindOrDef) : kindOrDef;
|
|
@@ -24453,7 +24573,8 @@ function ListerProvider(props) {
|
|
|
24453
24573
|
const pos = anchorToPos(opts == null ? void 0 : opts.anchor);
|
|
24454
24574
|
const filtersSpec = (_d = opts == null ? void 0 : opts.filtersSpec) != null ? _d : prev == null ? void 0 : prev.filtersSpec;
|
|
24455
24575
|
const filtersPatch = (_e = prev == null ? void 0 : prev.filtersPatch) != null ? _e : {};
|
|
24456
|
-
const
|
|
24576
|
+
const resolvedSearchMode = (_g = (_f = opts == null ? void 0 : opts.searchMode) != null ? _f : prev == null ? void 0 : prev.searchMode) != null ? _g : "remote";
|
|
24577
|
+
const selectedFilterValues = (_h = prev == null ? void 0 : prev.selectedFilterValues) != null ? _h : [];
|
|
24457
24578
|
const effectiveFilters = computeEffectiveFilters(
|
|
24458
24579
|
filters,
|
|
24459
24580
|
filtersPatch,
|
|
@@ -24462,9 +24583,9 @@ function ListerProvider(props) {
|
|
|
24462
24583
|
const searchSpec = def == null ? void 0 : def.search;
|
|
24463
24584
|
const defaultCol = searchSpec == null ? void 0 : searchSpec.default;
|
|
24464
24585
|
const defaultSearchTarget = defaultCol ? { mode: "subject", subject: defaultCol, only: null } : void 0;
|
|
24465
|
-
const searchTarget = (
|
|
24466
|
-
const initialQuery = (
|
|
24467
|
-
const searchPayload = buildSearchPayloadFromTarget(searchTarget);
|
|
24586
|
+
const searchTarget = (_i = prev == null ? void 0 : prev.searchTarget) != null ? _i : defaultSearchTarget;
|
|
24587
|
+
const initialQuery = (_k = (_j = opts == null ? void 0 : opts.initialQuery) != null ? _j : prev == null ? void 0 : prev.query) != null ? _k : "";
|
|
24588
|
+
const searchPayload = (_l = prev == null ? void 0 : prev.searchPayload) != null ? _l : buildSearchPayloadFromTarget(searchTarget);
|
|
24468
24589
|
const { rawList, optionsList } = await performFetch(
|
|
24469
24590
|
def,
|
|
24470
24591
|
effectiveFilters,
|
|
@@ -24472,7 +24593,7 @@ function ListerProvider(props) {
|
|
|
24472
24593
|
);
|
|
24473
24594
|
return await new Promise(
|
|
24474
24595
|
(resolve) => {
|
|
24475
|
-
var _a3, _b3, _c3
|
|
24596
|
+
var _a3, _b3, _c3;
|
|
24476
24597
|
const base = initialSessionState(sessionId);
|
|
24477
24598
|
const nextSession = {
|
|
24478
24599
|
...prev ? { ...prev } : base,
|
|
@@ -24488,12 +24609,12 @@ function ListerProvider(props) {
|
|
|
24488
24609
|
draggable: (_a3 = opts == null ? void 0 : opts.draggable) != null ? _a3 : true,
|
|
24489
24610
|
position: pos,
|
|
24490
24611
|
hasMoved: false,
|
|
24491
|
-
searchMode:
|
|
24612
|
+
searchMode: resolvedSearchMode,
|
|
24492
24613
|
query: initialQuery,
|
|
24493
24614
|
searchSpec,
|
|
24494
24615
|
searchTarget,
|
|
24495
|
-
showRefresh: (
|
|
24496
|
-
refreshMode: (
|
|
24616
|
+
showRefresh: (_b3 = opts == null ? void 0 : opts.showRefresh) != null ? _b3 : false,
|
|
24617
|
+
refreshMode: (_c3 = opts == null ? void 0 : opts.refreshMode) != null ? _c3 : "preserve-selection",
|
|
24497
24618
|
// filters
|
|
24498
24619
|
filtersSpec,
|
|
24499
24620
|
filtersPatch,
|
|
@@ -24711,17 +24832,32 @@ function ListerProvider(props) {
|
|
|
24711
24832
|
);
|
|
24712
24833
|
const setSearchMode = React67.useCallback(
|
|
24713
24834
|
(id, mode) => {
|
|
24835
|
+
var _a2;
|
|
24836
|
+
const s3 = getSession(id);
|
|
24837
|
+
if (!s3) return;
|
|
24838
|
+
const prevMode = s3.searchMode;
|
|
24714
24839
|
patchSession(id, { searchMode: mode });
|
|
24840
|
+
if (prevMode === mode) return;
|
|
24841
|
+
if (mode === "local") {
|
|
24842
|
+
fetchAndHydrate(id, "refresh", {
|
|
24843
|
+
filters: (_a2 = s3.effectiveFilters) != null ? _a2 : s3.filters,
|
|
24844
|
+
query: "",
|
|
24845
|
+
// base fetch (unsearched)
|
|
24846
|
+
search: void 0
|
|
24847
|
+
// force NO search payload
|
|
24848
|
+
});
|
|
24849
|
+
}
|
|
24715
24850
|
},
|
|
24716
|
-
[patchSession]
|
|
24851
|
+
[fetchAndHydrate, getSession, patchSession]
|
|
24717
24852
|
);
|
|
24718
24853
|
const scheduleRemoteFetch = React67.useCallback(
|
|
24719
24854
|
(id, q2, payloadOverride) => {
|
|
24720
24855
|
if (timerBySessionRef.current[id])
|
|
24721
24856
|
clearTimeout(timerBySessionRef.current[id]);
|
|
24722
24857
|
timerBySessionRef.current[id] = setTimeout(() => {
|
|
24858
|
+
var _a2;
|
|
24723
24859
|
const s3 = getSession(id);
|
|
24724
|
-
const search = payloadOverride != null ? payloadOverride : buildSearchPayloadFromTarget(s3 == null ? void 0 : s3.searchTarget);
|
|
24860
|
+
const search = (_a2 = payloadOverride != null ? payloadOverride : s3 == null ? void 0 : s3.searchPayload) != null ? _a2 : buildSearchPayloadFromTarget(s3 == null ? void 0 : s3.searchTarget);
|
|
24725
24861
|
fetchAndHydrate(id, "search", { query: q2, search });
|
|
24726
24862
|
}, debounceMs);
|
|
24727
24863
|
},
|
|
@@ -24730,7 +24866,10 @@ function ListerProvider(props) {
|
|
|
24730
24866
|
const setSearchTarget = React67.useCallback(
|
|
24731
24867
|
(id, target) => {
|
|
24732
24868
|
var _a2, _b2;
|
|
24733
|
-
patchSession(id, {
|
|
24869
|
+
patchSession(id, {
|
|
24870
|
+
searchTarget: target,
|
|
24871
|
+
searchPayload: void 0
|
|
24872
|
+
});
|
|
24734
24873
|
const s3 = getSession(id);
|
|
24735
24874
|
const mode = (_a2 = s3 == null ? void 0 : s3.searchMode) != null ? _a2 : "remote";
|
|
24736
24875
|
const q2 = (_b2 = s3 == null ? void 0 : s3.query) != null ? _b2 : "";
|
|
@@ -24742,7 +24881,7 @@ function ListerProvider(props) {
|
|
|
24742
24881
|
);
|
|
24743
24882
|
const searchLocalImpl = React67.useCallback(
|
|
24744
24883
|
(id, q2, payload) => {
|
|
24745
|
-
patchSession(id, { query: q2 });
|
|
24884
|
+
patchSession(id, { query: q2, searchPayload: payload });
|
|
24746
24885
|
const s3 = getSession(id);
|
|
24747
24886
|
if (!s3) return;
|
|
24748
24887
|
if (s3.searchMode === "hybrid") {
|
|
@@ -24753,7 +24892,7 @@ function ListerProvider(props) {
|
|
|
24753
24892
|
);
|
|
24754
24893
|
const searchRemoteImpl = React67.useCallback(
|
|
24755
24894
|
(id, q2, payload) => {
|
|
24756
|
-
patchSession(id, { query: q2 });
|
|
24895
|
+
patchSession(id, { query: q2, searchPayload: payload });
|
|
24757
24896
|
scheduleRemoteFetch(id, q2, payload);
|
|
24758
24897
|
},
|
|
24759
24898
|
[patchSession, scheduleRemoteFetch]
|
|
@@ -24781,13 +24920,30 @@ function ListerProvider(props) {
|
|
|
24781
24920
|
);
|
|
24782
24921
|
const getVisibleOptions = React67.useCallback(
|
|
24783
24922
|
(id) => {
|
|
24923
|
+
var _a2, _b2, _c2, _d;
|
|
24784
24924
|
const s3 = getSession(id);
|
|
24785
24925
|
if (!s3) return [];
|
|
24786
|
-
if (s3.searchMode === "
|
|
24787
|
-
|
|
24788
|
-
if (
|
|
24789
|
-
|
|
24790
|
-
|
|
24926
|
+
if (s3.searchMode === "remote") return s3.optionsList;
|
|
24927
|
+
const def = s3.definition;
|
|
24928
|
+
if (!def) return [];
|
|
24929
|
+
const filters = (_a2 = s3.effectiveFilters) != null ? _a2 : s3.filters;
|
|
24930
|
+
const payload = (_b2 = s3.searchPayload) != null ? _b2 : buildSearchPayloadFromTarget(s3 == null ? void 0 : s3.searchTarget);
|
|
24931
|
+
const visibleRaw = filterRawListLocal(
|
|
24932
|
+
(_c2 = s3.rawList) != null ? _c2 : [],
|
|
24933
|
+
s3.query,
|
|
24934
|
+
payload,
|
|
24935
|
+
filters,
|
|
24936
|
+
{
|
|
24937
|
+
searchSpec: (_d = s3.searchSpec) != null ? _d : def.search,
|
|
24938
|
+
filtersSpec: s3.filtersSpec
|
|
24939
|
+
}
|
|
24940
|
+
);
|
|
24941
|
+
const mapCtx = { query: s3.query, filters };
|
|
24942
|
+
return mapOptions(
|
|
24943
|
+
visibleRaw,
|
|
24944
|
+
def.mapping,
|
|
24945
|
+
mapCtx
|
|
24946
|
+
);
|
|
24791
24947
|
},
|
|
24792
24948
|
[getSession]
|
|
24793
24949
|
);
|
|
@@ -24852,50 +25008,6 @@ function ListerProvider(props) {
|
|
|
24852
25008
|
);
|
|
24853
25009
|
return /* @__PURE__ */ jsx(Ctx.Provider, { value, children: props.children });
|
|
24854
25010
|
}
|
|
24855
|
-
function useLister() {
|
|
24856
|
-
const ctx = React67.useContext(Ctx);
|
|
24857
|
-
if (!ctx)
|
|
24858
|
-
throw new Error("useLister must be used within <ListerProvider />");
|
|
24859
|
-
const api = React67.useMemo(() => {
|
|
24860
|
-
const fetch = ((kindOrDef, filters, opts) => ctx.apiFetchAny(kindOrDef, filters, opts));
|
|
24861
|
-
const open = ((kindOrDef, filters, opts) => ctx.apiOpenAny(kindOrDef, filters, opts));
|
|
24862
|
-
return {
|
|
24863
|
-
fetch,
|
|
24864
|
-
open,
|
|
24865
|
-
registerPreset: (kind, def) => ctx.registerPreset(kind, def),
|
|
24866
|
-
getPreset: (kind) => ctx.getPreset(kind)
|
|
24867
|
-
};
|
|
24868
|
-
}, [ctx]);
|
|
24869
|
-
const active = ctx.store.activeId ? ctx.store.sessions[ctx.store.activeId] : void 0;
|
|
24870
|
-
return {
|
|
24871
|
-
api,
|
|
24872
|
-
store: ctx.store,
|
|
24873
|
-
state: active,
|
|
24874
|
-
actions: {
|
|
24875
|
-
focus: ctx.focus,
|
|
24876
|
-
dispose: ctx.dispose,
|
|
24877
|
-
apply: ctx.apply,
|
|
24878
|
-
cancel: ctx.cancel,
|
|
24879
|
-
close: ctx.close,
|
|
24880
|
-
toggle: ctx.toggle,
|
|
24881
|
-
select: ctx.select,
|
|
24882
|
-
deselect: ctx.deselect,
|
|
24883
|
-
clear: ctx.clear,
|
|
24884
|
-
setQuery: ctx.setQuery,
|
|
24885
|
-
setSearchMode: ctx.setSearchMode,
|
|
24886
|
-
setSearchTarget: ctx.setSearchTarget,
|
|
24887
|
-
searchLocal: ctx.searchLocal,
|
|
24888
|
-
searchRemote: ctx.searchRemote,
|
|
24889
|
-
refresh: ctx.refresh,
|
|
24890
|
-
setPosition: ctx.setPosition,
|
|
24891
|
-
getFilterCtx: ctx.getFilterCtx,
|
|
24892
|
-
applyFilterOption: ctx.applyFilterOption,
|
|
24893
|
-
registerPreset: ctx.registerPreset,
|
|
24894
|
-
getPreset: ctx.getPreset,
|
|
24895
|
-
getVisibleOptions: ctx.getVisibleOptions
|
|
24896
|
-
}
|
|
24897
|
-
};
|
|
24898
|
-
}
|
|
24899
25011
|
function asArray(v2) {
|
|
24900
25012
|
if (v2 == null) return [];
|
|
24901
25013
|
return Array.isArray(v2) ? v2 : [v2];
|
|
@@ -25378,7 +25490,7 @@ function SearchBar(props) {
|
|
|
25378
25490
|
{
|
|
25379
25491
|
variant: "select",
|
|
25380
25492
|
mode: "button",
|
|
25381
|
-
|
|
25493
|
+
defaultValue: searchMode,
|
|
25382
25494
|
triggerClassName: "border-none ring-0 shadow-none! px-1! cursor-pointer",
|
|
25383
25495
|
options: [
|
|
25384
25496
|
{
|
|
@@ -25524,6 +25636,50 @@ function FooterBar(props) {
|
|
|
25524
25636
|
}
|
|
25525
25637
|
);
|
|
25526
25638
|
}
|
|
25639
|
+
function useLister() {
|
|
25640
|
+
const ctx = React67.useContext(Ctx);
|
|
25641
|
+
if (!ctx)
|
|
25642
|
+
throw new Error("useLister must be used within <ListerProvider />");
|
|
25643
|
+
const api = React67.useMemo(() => {
|
|
25644
|
+
const fetch = ((kindOrDef, filters, opts) => ctx.apiFetchAny(kindOrDef, filters, opts));
|
|
25645
|
+
const open = ((kindOrDef, filters, opts) => ctx.apiOpenAny(kindOrDef, filters, opts));
|
|
25646
|
+
return {
|
|
25647
|
+
fetch,
|
|
25648
|
+
open,
|
|
25649
|
+
registerPreset: (kind, def) => ctx.registerPreset(kind, def),
|
|
25650
|
+
getPreset: (kind) => ctx.getPreset(kind)
|
|
25651
|
+
};
|
|
25652
|
+
}, [ctx]);
|
|
25653
|
+
const active = ctx.store.activeId ? ctx.store.sessions[ctx.store.activeId] : void 0;
|
|
25654
|
+
return {
|
|
25655
|
+
api,
|
|
25656
|
+
store: ctx.store,
|
|
25657
|
+
state: active,
|
|
25658
|
+
actions: {
|
|
25659
|
+
focus: ctx.focus,
|
|
25660
|
+
dispose: ctx.dispose,
|
|
25661
|
+
apply: ctx.apply,
|
|
25662
|
+
cancel: ctx.cancel,
|
|
25663
|
+
close: ctx.close,
|
|
25664
|
+
toggle: ctx.toggle,
|
|
25665
|
+
select: ctx.select,
|
|
25666
|
+
deselect: ctx.deselect,
|
|
25667
|
+
clear: ctx.clear,
|
|
25668
|
+
setQuery: ctx.setQuery,
|
|
25669
|
+
setSearchMode: ctx.setSearchMode,
|
|
25670
|
+
setSearchTarget: ctx.setSearchTarget,
|
|
25671
|
+
searchLocal: ctx.searchLocal,
|
|
25672
|
+
searchRemote: ctx.searchRemote,
|
|
25673
|
+
refresh: ctx.refresh,
|
|
25674
|
+
setPosition: ctx.setPosition,
|
|
25675
|
+
getFilterCtx: ctx.getFilterCtx,
|
|
25676
|
+
applyFilterOption: ctx.applyFilterOption,
|
|
25677
|
+
registerPreset: ctx.registerPreset,
|
|
25678
|
+
getPreset: ctx.getPreset,
|
|
25679
|
+
getVisibleOptions: ctx.getVisibleOptions
|
|
25680
|
+
}
|
|
25681
|
+
};
|
|
25682
|
+
}
|
|
25527
25683
|
function pick(raw, keyOrFn, ctx) {
|
|
25528
25684
|
if (!keyOrFn) return void 0;
|
|
25529
25685
|
if (typeof keyOrFn === "function") return keyOrFn(raw, ctx);
|