@archbase/data 4.0.19 → 4.0.20
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/index.js
CHANGED
|
@@ -2,17 +2,17 @@ import { isDate as ve, parseISO as Ie } from "date-fns";
|
|
|
2
2
|
import { EventEmitter as Be } from "events";
|
|
3
3
|
import { uniqueId as $e, cloneDeep as Ne } from "lodash";
|
|
4
4
|
import { archbaseI18next as R, ArchbaseDataSourceError as g, ArchbaseObjectHelper as Re, processErrorMessage as G, QUICK as we, NORMAL as Ee, ADVANCED as Se, ArchbaseFilterDSL as Fe, QueryFilterEntity as he, detectDataSourceVersion as pe, MigrationMetrics as He, ARCHBASE_IOC_API_TYPE as We, ArchbaseJacksonParser as ie } from "@archbase/core";
|
|
5
|
-
import { ADVANCED as jt, ARCHBASE_IOC_API_TYPE as
|
|
6
|
-
import { useState as
|
|
5
|
+
import { ADVANCED as jt, ARCHBASE_IOC_API_TYPE as _t, FILTER_TYPE as kt, NORMAL as Ut, QUICK as Gt, useArchbaseBool as qt } from "@archbase/core";
|
|
6
|
+
import { useState as V, useCallback as u, useRef as ce, useMemo as M, useEffect as q, useReducer as Me } from "react";
|
|
7
7
|
import { produce as Q } from "immer";
|
|
8
8
|
import "reflect-metadata";
|
|
9
9
|
import X from "axios";
|
|
10
10
|
import * as ne from "inversify";
|
|
11
|
-
import { useContainer as
|
|
11
|
+
import { useContainer as ze } from "inversify-react";
|
|
12
12
|
import { create as je } from "zustand";
|
|
13
|
-
import { createTrackedSelector as
|
|
14
|
-
var
|
|
15
|
-
class
|
|
13
|
+
import { createTrackedSelector as _e } from "react-tracked";
|
|
14
|
+
var d = /* @__PURE__ */ ((o) => (o[o.dataChanged = 0] = "dataChanged", o[o.recordChanged = 1] = "recordChanged", o[o.refreshData = 2] = "refreshData", o[o.fieldChanged = 3] = "fieldChanged", o[o.beforeClose = 4] = "beforeClose", o[o.afterClose = 5] = "afterClose", o[o.beforeOpen = 6] = "beforeOpen", o[o.afterOpen = 7] = "afterOpen", o[o.beforeAppend = 8] = "beforeAppend", o[o.afterAppend = 9] = "afterAppend", o[o.beforeRemove = 10] = "beforeRemove", o[o.afterRemove = 11] = "afterRemove", o[o.beforeInsert = 12] = "beforeInsert", o[o.afterInsert = 13] = "afterInsert", o[o.beforeEdit = 14] = "beforeEdit", o[o.afterEdit = 15] = "afterEdit", o[o.beforeSave = 16] = "beforeSave", o[o.afterSave = 17] = "afterSave", o[o.beforeCancel = 18] = "beforeCancel", o[o.afterCancel = 19] = "afterCancel", o[o.afterScroll = 20] = "afterScroll", o[o.onError = 21] = "onError", o[o.onFieldError = 22] = "onFieldError", o))(d || {});
|
|
15
|
+
class ke {
|
|
16
16
|
eventEmitter;
|
|
17
17
|
listenersDisable = !1;
|
|
18
18
|
constructor() {
|
|
@@ -79,7 +79,7 @@ class ye {
|
|
|
79
79
|
validator;
|
|
80
80
|
getIdentity;
|
|
81
81
|
constructor(e, t, r) {
|
|
82
|
-
this.name = e, this.label = r || e, this.records = [], this.filteredRecords = [], this.loadOptions(t), this.fieldEventListeners = {}, this.emitter = new
|
|
82
|
+
this.name = e, this.label = r || e, this.records = [], this.filteredRecords = [], this.loadOptions(t), this.fieldEventListeners = {}, this.emitter = new ke(), this.uuid = $e(), this.validator = t.validator, this.getIdentity = t.getIdentity;
|
|
83
83
|
}
|
|
84
84
|
loadOptions(e) {
|
|
85
85
|
this.records = e.records, this.filters = [], e.filters && (this.filters = e.filters), this.currentRecord = void 0, this.currentRecordIndex = -1, this.filteredRecords = this.applyFilters(), this.filteredRecords.length > 0 && (this.currentRecordIndex = 0, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.grandTotalRecords = e.grandTotalRecords, this.currentPageIndex = e.currentPage, this.totalPages = e.totalPages, this.pageSize = e.pageSize, this.active = !0, this.filter = e.filter, this.sort = e.sort, this.originFilter = e.originFilter, this.originSort = e.originSort, this.originGlobalFilter = e.originGlobalFilter, this.defaultSortFields = e.defaultSortFields ? e.defaultSortFields : [];
|
|
@@ -277,8 +277,8 @@ class ye {
|
|
|
277
277
|
});
|
|
278
278
|
let t = -1;
|
|
279
279
|
const r = this.currentRecord, i = this.currentRecordIndex;
|
|
280
|
-
return this.records.forEach((s,
|
|
281
|
-
this.currentRecord === s && (t =
|
|
280
|
+
return this.records.forEach((s, n) => {
|
|
281
|
+
this.currentRecord === s && (t = n);
|
|
282
282
|
}), t >= 0 && this.records.splice(t, 1), this.records !== this.filteredRecords && this.filteredRecords.splice(this.getCurrentIndex(), 1), this.grandTotalRecords--, this.filteredRecords.length === 0 ? (this.currentRecord = void 0, this.currentRecordIndex = -1) : (this.currentRecordIndex > this.filteredRecords.length - 1 && this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.editing = !1, this.inserting = !1, this.emitter.emit("afterScroll"), this.emit({
|
|
283
283
|
type: 20
|
|
284
284
|
/* afterScroll */
|
|
@@ -361,8 +361,8 @@ class ye {
|
|
|
361
361
|
this.editing && (this.filteredRecords[this.getCurrentIndex()] = this.currentRecord);
|
|
362
362
|
let t = -1;
|
|
363
363
|
return this.records.forEach((r, i) => {
|
|
364
|
-
const s = this.getIdentity ? this.getIdentity(r) : r.id,
|
|
365
|
-
(r === this.currentRecord || s !== void 0 && s ===
|
|
364
|
+
const s = this.getIdentity ? this.getIdentity(r) : r.id, n = this.getIdentity ? this.getIdentity(this.currentRecord) : this.currentRecord.id;
|
|
365
|
+
(r === this.currentRecord || s !== void 0 && s === n) && (t = i);
|
|
366
366
|
}), t >= 0 ? this.records[t] = this.currentRecord : this.records.push(this.currentRecord), this.editing = !1, this.inserting = !1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.emitter.emit("afterSave", this.currentRecord, this.getCurrentIndex()), this.emit({
|
|
367
367
|
type: 17,
|
|
368
368
|
record: this.currentRecord,
|
|
@@ -422,8 +422,8 @@ class ye {
|
|
|
422
422
|
if (this.validateDataSourceActive("setFieldValue"), this.isEmpty() || !this.currentRecord)
|
|
423
423
|
return this;
|
|
424
424
|
if (!(this.inserting || this.editing || this.isBOF() || this.isEOF())) {
|
|
425
|
-
const
|
|
426
|
-
throw this.publishEventError(
|
|
425
|
+
const n = R.t("archbase:recordNotBeingEdited", { dataSourceName: this.name });
|
|
426
|
+
throw this.publishEventError(n, {}), new g(n);
|
|
427
427
|
}
|
|
428
428
|
let r = t;
|
|
429
429
|
const i = Re.getNestedProperty(this.currentRecord, e);
|
|
@@ -602,29 +602,29 @@ class ye {
|
|
|
602
602
|
addFieldChangeListener(e, t) {
|
|
603
603
|
const r = e.split(".");
|
|
604
604
|
let i = "";
|
|
605
|
-
return r.forEach((s,
|
|
606
|
-
i =
|
|
605
|
+
return r.forEach((s, n) => {
|
|
606
|
+
i = n === 0 ? s : `${i}.${s}`, this.fieldEventListeners[`field:${i}`] || (this.fieldEventListeners[`field:${i}`] = []), this.fieldEventListeners[`field:${i}`].includes(t) || this.fieldEventListeners[`field:${i}`].push(t);
|
|
607
607
|
}), this;
|
|
608
608
|
}
|
|
609
609
|
removeFieldChangeListener(e, t) {
|
|
610
610
|
const r = e.split(".");
|
|
611
611
|
let i = "";
|
|
612
|
-
return r.forEach((s,
|
|
613
|
-
i =
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
const
|
|
617
|
-
|
|
612
|
+
return r.forEach((s, n) => {
|
|
613
|
+
i = n === 0 ? s : `${i}.${s}`;
|
|
614
|
+
const a = this.fieldEventListeners[`field:${i}`];
|
|
615
|
+
if (a) {
|
|
616
|
+
const l = a.indexOf(t);
|
|
617
|
+
l !== -1 && a.splice(l, 1);
|
|
618
618
|
}
|
|
619
619
|
}), this;
|
|
620
620
|
}
|
|
621
621
|
emitFieldChangeEvent(e, t, r) {
|
|
622
622
|
const i = e.split(".");
|
|
623
623
|
let s = "";
|
|
624
|
-
for (const
|
|
625
|
-
s = s ? `${s}.${
|
|
626
|
-
const
|
|
627
|
-
|
|
624
|
+
for (const n of i) {
|
|
625
|
+
s = s ? `${s}.${n}` : n;
|
|
626
|
+
const a = this.fieldEventListeners[`field:${s}`];
|
|
627
|
+
a && a.forEach((l) => l(s, t, r));
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
/**
|
|
@@ -656,7 +656,7 @@ class Ae extends ye {
|
|
|
656
656
|
throw this.publishEventError(t, {}), new g(t);
|
|
657
657
|
}
|
|
658
658
|
if (this.emitter.emit("beforeSave", this.currentRecord), this.emit({
|
|
659
|
-
type:
|
|
659
|
+
type: d.beforeSave,
|
|
660
660
|
record: this.currentRecord,
|
|
661
661
|
index: this.getCurrentIndex()
|
|
662
662
|
}), this.validator) {
|
|
@@ -671,31 +671,35 @@ class Ae extends ye {
|
|
|
671
671
|
try {
|
|
672
672
|
let t = -1;
|
|
673
673
|
this.records.forEach((r, i) => {
|
|
674
|
-
const s = this.getIdentity ? this.getIdentity(r) : r.id,
|
|
675
|
-
(r === this.currentRecord || s !== void 0 && s ===
|
|
674
|
+
const s = this.getIdentity ? this.getIdentity(r) : r.id, n = this.getIdentity ? this.getIdentity(this.currentRecord) : this.currentRecord.id;
|
|
675
|
+
(r === this.currentRecord || s !== void 0 && s === n) && (t = i);
|
|
676
676
|
}), this.currentRecord = await this.service.save(this.currentRecord), this.editing && (this.filteredRecords = [...this.filteredRecords], this.filteredRecords[this.getCurrentIndex()] = this.currentRecord), this.records = [...this.records], t >= 0 ? this.records[t] = this.currentRecord : this.records.push(this.currentRecord), this.editing = !1, this.inserting = !1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.emitter.emit("afterSave", this.currentRecord), this.emit({
|
|
677
|
-
type:
|
|
677
|
+
type: d.afterSave,
|
|
678
678
|
record: this.currentRecord,
|
|
679
679
|
index: this.getCurrentIndex()
|
|
680
680
|
}), e && e();
|
|
681
681
|
} catch (t) {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
682
|
+
let r = !1;
|
|
683
|
+
const i = t?.response?.data?.apierror ?? t?.response?.data, s = i?.subErrors ?? i?.fieldErrors;
|
|
684
|
+
s && s.forEach((a) => {
|
|
685
|
+
const l = a.field ?? a.property;
|
|
686
|
+
if (l) {
|
|
687
|
+
r = !0;
|
|
688
|
+
const p = R.t(a.message, { defaultValue: a.message });
|
|
689
|
+
this.emitter.emit("onFieldError", l, p), this.emit({
|
|
690
|
+
type: d.onFieldError,
|
|
691
|
+
fieldName: l,
|
|
692
|
+
error: p,
|
|
693
|
+
originalError: a.message
|
|
690
694
|
});
|
|
691
695
|
}
|
|
692
696
|
});
|
|
693
|
-
const
|
|
694
|
-
throw this.emitter.emit("onError",
|
|
695
|
-
type:
|
|
696
|
-
error:
|
|
697
|
+
const n = G(t);
|
|
698
|
+
throw r || (this.emitter.emit("onError", n, t), this.emit({
|
|
699
|
+
type: d.onError,
|
|
700
|
+
error: n,
|
|
697
701
|
originalError: t
|
|
698
|
-
}), e && e(
|
|
702
|
+
})), e && e(n), new g(n);
|
|
699
703
|
}
|
|
700
704
|
return this.currentRecord;
|
|
701
705
|
}
|
|
@@ -719,7 +723,7 @@ class Ae extends ye {
|
|
|
719
723
|
throw this.publishEventError(t, {}), new g(t);
|
|
720
724
|
}
|
|
721
725
|
this.emitter.emit("beforeRemove", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
722
|
-
type:
|
|
726
|
+
type: d.beforeRemove,
|
|
723
727
|
record: this.currentRecord,
|
|
724
728
|
index: this.getCurrentIndex()
|
|
725
729
|
});
|
|
@@ -727,17 +731,17 @@ class Ae extends ye {
|
|
|
727
731
|
await this.service.delete(this.service.getId(this.currentRecord));
|
|
728
732
|
let t = -1;
|
|
729
733
|
const r = this.currentRecord, i = this.currentRecordIndex;
|
|
730
|
-
return this.records = [...this.records], this.filteredRecords = [...this.filteredRecords], this.records.forEach((s,
|
|
731
|
-
this.currentRecord === s && (t =
|
|
732
|
-
}), t >= 0 && this.records.splice(t, 1), this.records !== this.filteredRecords && this.filteredRecords.splice(this.getCurrentIndex(), 1), this.grandTotalRecords--, this.filteredRecords.length === 0 ? (this.currentRecord = void 0, this.currentRecordIndex = -1) : (this.currentRecordIndex > this.filteredRecords.length - 1 && this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.editing = !1, this.inserting = !1, this.emitter.emit("afterScroll"), this.emit({ type:
|
|
733
|
-
type:
|
|
734
|
+
return this.records = [...this.records], this.filteredRecords = [...this.filteredRecords], this.records.forEach((s, n) => {
|
|
735
|
+
this.currentRecord === s && (t = n);
|
|
736
|
+
}), t >= 0 && this.records.splice(t, 1), this.records !== this.filteredRecords && this.filteredRecords.splice(this.getCurrentIndex(), 1), this.grandTotalRecords--, this.filteredRecords.length === 0 ? (this.currentRecord = void 0, this.currentRecordIndex = -1) : (this.currentRecordIndex > this.filteredRecords.length - 1 && this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.editing = !1, this.inserting = !1, this.emitter.emit("afterScroll"), this.emit({ type: d.afterScroll }), this.emitter.emit("afterRemove", r, i), this.emit({
|
|
737
|
+
type: d.afterRemove,
|
|
734
738
|
record: r,
|
|
735
739
|
index: i
|
|
736
740
|
}), this.lastDataBrowsingOn = (/* @__PURE__ */ new Date()).getTime(), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), e && e(), r;
|
|
737
741
|
} catch (t) {
|
|
738
742
|
const r = G(t);
|
|
739
743
|
throw this.emitter.emit("onError", r, t), this.emit({
|
|
740
|
-
type:
|
|
744
|
+
type: d.onError,
|
|
741
745
|
error: r,
|
|
742
746
|
originalError: t
|
|
743
747
|
}), e && e(r), new g(r);
|
|
@@ -770,7 +774,7 @@ class Ae extends ye {
|
|
|
770
774
|
return e && e.sort ? e.sort.quickFilterSort : this.defaultSortFields;
|
|
771
775
|
}
|
|
772
776
|
}
|
|
773
|
-
class
|
|
777
|
+
class Ue {
|
|
774
778
|
id;
|
|
775
779
|
companyId;
|
|
776
780
|
filter;
|
|
@@ -808,7 +812,7 @@ class Ge extends ye {
|
|
|
808
812
|
}
|
|
809
813
|
async addNewFilter(e, t) {
|
|
810
814
|
this.insert(
|
|
811
|
-
new
|
|
815
|
+
new Ue({
|
|
812
816
|
id: e.id,
|
|
813
817
|
name: e.name,
|
|
814
818
|
description: e.description,
|
|
@@ -946,57 +950,57 @@ class Je extends Ae {
|
|
|
946
950
|
) : [];
|
|
947
951
|
}
|
|
948
952
|
}
|
|
949
|
-
function yt(
|
|
950
|
-
const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s,
|
|
951
|
-
|
|
952
|
-
}, []), [p, C] =
|
|
953
|
+
function yt(o, e, t, r) {
|
|
954
|
+
const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s, n] = V(r), [, a] = V(0), l = u(() => {
|
|
955
|
+
a((f) => f + 1);
|
|
956
|
+
}, []), [p, C] = V(r), [W, z] = V(0), L = u(() => {
|
|
953
957
|
let f = r;
|
|
954
|
-
e && t && (f = e.getFieldValue(t), f == null && (f = r)), i ? (C(f),
|
|
955
|
-
}, [e, t, r, i]),
|
|
956
|
-
e && t && ((f.type ===
|
|
957
|
-
}, [e, t,
|
|
958
|
-
i ? (C(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f)) : (
|
|
959
|
-
}, [e, t, i]),
|
|
958
|
+
e && t && (f = e.getFieldValue(t), f == null && (f = r)), i ? (C(f), z((b) => b + 1)) : n(f);
|
|
959
|
+
}, [e, t, r, i]), P = u((f) => {
|
|
960
|
+
e && t && ((f.type === d.dataChanged || f.type === d.recordChanged || f.type === d.afterScroll || f.type === d.afterCancel || f.type === d.afterEdit) && (L(), i || l()), f.type === d.onFieldError && f.fieldName === t && console.warn(`[${o}] Field error:`, f.error));
|
|
961
|
+
}, [e, t, L, l, i, o]), N = u((f, b) => {
|
|
962
|
+
i ? (C(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f)) : (n(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f));
|
|
963
|
+
}, [e, t, i]), c = u(() => {
|
|
960
964
|
const f = pe(e);
|
|
961
|
-
He.trackV2Usage(
|
|
962
|
-
}, [
|
|
965
|
+
He.trackV2Usage(o, f);
|
|
966
|
+
}, [o, e]);
|
|
963
967
|
return ce(() => {
|
|
964
|
-
process.env.NODE_ENV === "production" &&
|
|
968
|
+
process.env.NODE_ENV === "production" && c();
|
|
965
969
|
}).current, {
|
|
966
970
|
// Detecção de versão
|
|
967
971
|
isDataSourceV2: i,
|
|
968
972
|
dataSourceVersion: pe(e),
|
|
969
973
|
// Estados
|
|
970
974
|
currentValue: i ? p : s,
|
|
971
|
-
v1State: { currentValue: s, setCurrentValue:
|
|
975
|
+
v1State: { currentValue: s, setCurrentValue: n, forceUpdate: l },
|
|
972
976
|
v2State: { v2Value: p, setV2Value: C, v2ShouldUpdate: W },
|
|
973
977
|
// Funções
|
|
974
|
-
loadDataSourceFieldValue:
|
|
975
|
-
dataSourceEvent:
|
|
978
|
+
loadDataSourceFieldValue: L,
|
|
979
|
+
dataSourceEvent: P,
|
|
976
980
|
handleValueChange: N,
|
|
977
981
|
// Utilitários
|
|
978
982
|
isReadOnly: e ? e.isBrowsing() : !1,
|
|
979
983
|
isEditing: e ? e.isEditing() : !1,
|
|
980
|
-
trackUsage:
|
|
984
|
+
trackUsage: c
|
|
981
985
|
};
|
|
982
986
|
}
|
|
983
987
|
const vt = {
|
|
984
988
|
/**
|
|
985
989
|
* Valida se o componente está seguindo o padrão corretamente
|
|
986
990
|
*/
|
|
987
|
-
validatePattern: (
|
|
991
|
+
validatePattern: (o, e) => {
|
|
988
992
|
const t = [];
|
|
989
|
-
return e.dataSourceVersion === "NONE" && e.isDataSourceV2 && t.push("DataSource version detection inconsistent"), e.isDataSourceV2 && e.v1State.currentValue === e.currentValue && t.push("V2 should use v2Value, not v1 currentValue"), !e.isDataSourceV2 && e.v2State.v2Value === e.currentValue && t.push("V1 should use currentValue, not v2Value"), t.length > 0 ? (console.error(`[${
|
|
993
|
+
return e.dataSourceVersion === "NONE" && e.isDataSourceV2 && t.push("DataSource version detection inconsistent"), e.isDataSourceV2 && e.v1State.currentValue === e.currentValue && t.push("V2 should use v2Value, not v1 currentValue"), !e.isDataSourceV2 && e.v2State.v2Value === e.currentValue && t.push("V1 should use currentValue, not v2Value"), t.length > 0 ? (console.error(`[${o}] Migration pattern validation failed:`, t), !1) : !0;
|
|
990
994
|
},
|
|
991
995
|
/**
|
|
992
996
|
* Testa se o comportamento V1 está preservado
|
|
993
997
|
*/
|
|
994
|
-
testV1Compatibility: (
|
|
998
|
+
testV1Compatibility: (o, e) => !e || pe(e) !== "V1" || [
|
|
995
999
|
"isBrowsing",
|
|
996
1000
|
"isEditing",
|
|
997
1001
|
"getFieldValue",
|
|
998
1002
|
"setFieldValue"
|
|
999
|
-
].every((r) => typeof e[r] == "function") ? !0 : (console.error(`[${
|
|
1003
|
+
].every((r) => typeof e[r] == "function") ? !0 : (console.error(`[${o}] V1 DataSource missing required methods`), !1)
|
|
1000
1004
|
}, It = `
|
|
1001
1005
|
// Em qualquer componente que use DataSource:
|
|
1002
1006
|
|
|
@@ -1050,7 +1054,7 @@ export function MyComponent<T, ID>({ dataSource, dataField, value, onChangeValue
|
|
|
1050
1054
|
);
|
|
1051
1055
|
}
|
|
1052
1056
|
`;
|
|
1053
|
-
class
|
|
1057
|
+
class k {
|
|
1054
1058
|
name;
|
|
1055
1059
|
label;
|
|
1056
1060
|
records = [];
|
|
@@ -1098,24 +1102,24 @@ class U {
|
|
|
1098
1102
|
// =================== Navigation ===================
|
|
1099
1103
|
first() {
|
|
1100
1104
|
return this.records.length > 0 && (this.currentIndex = 0, this.emit({
|
|
1101
|
-
type:
|
|
1105
|
+
type: d.afterScroll
|
|
1102
1106
|
})), this;
|
|
1103
1107
|
}
|
|
1104
1108
|
last() {
|
|
1105
1109
|
return this.records.length > 0 && (this.currentIndex = this.records.length - 1, this.emit({
|
|
1106
|
-
type:
|
|
1110
|
+
type: d.afterScroll
|
|
1107
1111
|
})), this;
|
|
1108
1112
|
}
|
|
1109
1113
|
next() {
|
|
1110
1114
|
return this.currentIndex < this.records.length - 1 && (this.currentIndex++, this.emit({
|
|
1111
|
-
type:
|
|
1115
|
+
type: d.recordChanged,
|
|
1112
1116
|
record: this.getCurrentRecord(),
|
|
1113
1117
|
index: this.currentIndex
|
|
1114
1118
|
})), this;
|
|
1115
1119
|
}
|
|
1116
1120
|
prior() {
|
|
1117
1121
|
return this.currentIndex > 0 && (this.currentIndex--, this.emit({
|
|
1118
|
-
type:
|
|
1122
|
+
type: d.recordChanged,
|
|
1119
1123
|
record: this.getCurrentRecord(),
|
|
1120
1124
|
index: this.currentIndex
|
|
1121
1125
|
})), this;
|
|
@@ -1123,7 +1127,7 @@ class U {
|
|
|
1123
1127
|
goToRecord(e) {
|
|
1124
1128
|
if (e >= 0 && e < this.records.length)
|
|
1125
1129
|
return this.currentIndex = e, this.emit({
|
|
1126
|
-
type:
|
|
1130
|
+
type: d.recordChanged,
|
|
1127
1131
|
record: this.getCurrentRecord(),
|
|
1128
1132
|
index: this.currentIndex
|
|
1129
1133
|
}), this.getCurrentRecord();
|
|
@@ -1154,27 +1158,27 @@ class U {
|
|
|
1154
1158
|
if (this.validateDataSourceActive("edit"), this.isEmpty() || !this.getCurrentRecord())
|
|
1155
1159
|
throw new Error(`No records to edit in DataSource ${this.name}`);
|
|
1156
1160
|
return this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
|
|
1157
|
-
type:
|
|
1161
|
+
type: d.beforeEdit,
|
|
1158
1162
|
record: this.getCurrentRecord(),
|
|
1159
1163
|
index: this.currentIndex
|
|
1160
1164
|
}), this.emit({
|
|
1161
|
-
type:
|
|
1165
|
+
type: d.afterEdit,
|
|
1162
1166
|
record: this.getCurrentRecord(),
|
|
1163
1167
|
index: this.currentIndex
|
|
1164
1168
|
}), this;
|
|
1165
1169
|
}
|
|
1166
1170
|
cancel() {
|
|
1167
1171
|
return this.validateDataSourceActive("cancel"), this.state === "edit" && this.originalRecord ? (this.records = [...this.records], this.records[this.currentIndex] = { ...this.originalRecord }) : this.state === "insert" && (this.records = this.records.slice(0, -1), this.records.length > 0 ? this.currentIndex = Math.min(this.currentIndex, this.records.length - 1) : this.currentIndex = -1), this.state = "browse", this.originalRecord = null, this.emit({
|
|
1168
|
-
type:
|
|
1172
|
+
type: d.afterCancel,
|
|
1169
1173
|
record: this.getCurrentRecord(),
|
|
1170
1174
|
index: this.currentIndex
|
|
1171
1175
|
}), this;
|
|
1172
1176
|
}
|
|
1173
1177
|
insert(e) {
|
|
1174
1178
|
return this.validateDataSourceActive("insert"), this.state = "insert", this.emit({
|
|
1175
|
-
type:
|
|
1179
|
+
type: d.beforeInsert
|
|
1176
1180
|
}), this.records = [...this.records, e], this.currentIndex = this.records.length - 1, this.notifyStateChange(), this.emit({
|
|
1177
|
-
type:
|
|
1181
|
+
type: d.afterInsert,
|
|
1178
1182
|
record: e,
|
|
1179
1183
|
index: this.currentIndex
|
|
1180
1184
|
}), this;
|
|
@@ -1186,7 +1190,7 @@ class U {
|
|
|
1186
1190
|
throw new Error(`No record to save in DataSource ${this.name}`);
|
|
1187
1191
|
const t = this.getCurrentRecord();
|
|
1188
1192
|
if (this.emit({
|
|
1189
|
-
type:
|
|
1193
|
+
type: d.beforeSave,
|
|
1190
1194
|
record: t,
|
|
1191
1195
|
index: this.getCurrentIndex()
|
|
1192
1196
|
}), this.validator) {
|
|
@@ -1195,7 +1199,7 @@ class U {
|
|
|
1195
1199
|
throw new Error(r[0].errorMessage);
|
|
1196
1200
|
}
|
|
1197
1201
|
return this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
|
|
1198
|
-
type:
|
|
1202
|
+
type: d.afterSave,
|
|
1199
1203
|
record: t,
|
|
1200
1204
|
index: this.getCurrentIndex()
|
|
1201
1205
|
}), e && e(), t;
|
|
@@ -1207,11 +1211,11 @@ class U {
|
|
|
1207
1211
|
throw new Error(`No records to remove in DataSource ${this.name}`);
|
|
1208
1212
|
const t = this.getCurrentRecord(), r = this.currentIndex;
|
|
1209
1213
|
return this.emit({
|
|
1210
|
-
type:
|
|
1214
|
+
type: d.beforeRemove,
|
|
1211
1215
|
record: t,
|
|
1212
1216
|
index: r
|
|
1213
|
-
}), this.records = this.records.filter((i, s) => s !== this.currentIndex), this.records.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.records.length && (this.currentIndex = this.records.length - 1), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type:
|
|
1214
|
-
type:
|
|
1217
|
+
}), this.records = this.records.filter((i, s) => s !== this.currentIndex), this.records.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.records.length && (this.currentIndex = this.records.length - 1), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type: d.afterScroll }), this.emit({
|
|
1218
|
+
type: d.afterRemove,
|
|
1215
1219
|
record: t,
|
|
1216
1220
|
index: r
|
|
1217
1221
|
}), e && e(), t;
|
|
@@ -1225,10 +1229,10 @@ class U {
|
|
|
1225
1229
|
return this;
|
|
1226
1230
|
const i = [...this.records];
|
|
1227
1231
|
return this.records = Q(this.records, (s) => {
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1232
|
+
const n = s[this.currentIndex];
|
|
1233
|
+
n && this.setNestedValue(n, e, t);
|
|
1230
1234
|
}), this.notifyStateChange(i), this.emit({
|
|
1231
|
-
type:
|
|
1235
|
+
type: d.fieldChanged,
|
|
1232
1236
|
fieldName: e,
|
|
1233
1237
|
oldValue: r,
|
|
1234
1238
|
newValue: t,
|
|
@@ -1254,13 +1258,13 @@ class U {
|
|
|
1254
1258
|
throw new Error(`Field ${String(e)} is not an array (found: ${typeof r})`);
|
|
1255
1259
|
const i = [...this.records];
|
|
1256
1260
|
this.records = Q(this.records, (s) => {
|
|
1257
|
-
const
|
|
1258
|
-
if (
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
+
const n = s[this.currentIndex];
|
|
1262
|
+
if (n) {
|
|
1263
|
+
const a = this.getNestedValue(n, e);
|
|
1264
|
+
a && a.push(t);
|
|
1261
1265
|
}
|
|
1262
1266
|
}), this.notifyStateChange(i), this.emit({
|
|
1263
|
-
type:
|
|
1267
|
+
type: d.fieldChanged,
|
|
1264
1268
|
fieldName: e,
|
|
1265
1269
|
oldValue: r,
|
|
1266
1270
|
newValue: [...r, t],
|
|
@@ -1275,14 +1279,14 @@ class U {
|
|
|
1275
1279
|
if (!Array.isArray(i) || t < 0 || t >= i.length)
|
|
1276
1280
|
return;
|
|
1277
1281
|
const s = [...this.records];
|
|
1278
|
-
this.records = Q(this.records, (
|
|
1279
|
-
const
|
|
1280
|
-
if (
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1282
|
+
this.records = Q(this.records, (n) => {
|
|
1283
|
+
const a = n[this.currentIndex];
|
|
1284
|
+
if (a) {
|
|
1285
|
+
const l = this.getNestedValue(a, e);
|
|
1286
|
+
l[t] !== void 0 && r(l[t]);
|
|
1283
1287
|
}
|
|
1284
1288
|
}), this.notifyStateChange(s), this.emit({
|
|
1285
|
-
type:
|
|
1289
|
+
type: d.fieldChanged,
|
|
1286
1290
|
fieldName: e,
|
|
1287
1291
|
oldValue: i,
|
|
1288
1292
|
newValue: this.getFieldValue(e),
|
|
@@ -1300,10 +1304,10 @@ class U {
|
|
|
1300
1304
|
return;
|
|
1301
1305
|
const i = [...this.records];
|
|
1302
1306
|
this.records = Q(this.records, (s) => {
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1307
|
+
const n = s[this.currentIndex];
|
|
1308
|
+
n && this.getNestedValue(n, e).splice(t, 1);
|
|
1305
1309
|
}), this.notifyStateChange(i), this.emit({
|
|
1306
|
-
type:
|
|
1310
|
+
type: d.fieldChanged,
|
|
1307
1311
|
fieldName: e,
|
|
1308
1312
|
oldValue: r,
|
|
1309
1313
|
newValue: this.getFieldValue(e),
|
|
@@ -1318,11 +1322,11 @@ class U {
|
|
|
1318
1322
|
if (!Array.isArray(i))
|
|
1319
1323
|
throw new Error(`Field ${String(e)} is not an array`);
|
|
1320
1324
|
const s = [...this.records];
|
|
1321
|
-
this.records = Q(this.records, (
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1325
|
+
this.records = Q(this.records, (n) => {
|
|
1326
|
+
const a = n[this.currentIndex];
|
|
1327
|
+
a && this.getNestedValue(a, e).splice(t, 0, r);
|
|
1324
1328
|
}), this.notifyStateChange(s), this.emit({
|
|
1325
|
-
type:
|
|
1329
|
+
type: d.fieldChanged,
|
|
1326
1330
|
fieldName: e,
|
|
1327
1331
|
oldValue: i,
|
|
1328
1332
|
newValue: this.getFieldValue(e),
|
|
@@ -1348,7 +1352,7 @@ class U {
|
|
|
1348
1352
|
}
|
|
1349
1353
|
clear() {
|
|
1350
1354
|
this.records = [], this.currentIndex = -1, this.state = "browse", this.originalRecord = null, this.emit({
|
|
1351
|
-
type:
|
|
1355
|
+
type: d.dataChanged,
|
|
1352
1356
|
data: this.records
|
|
1353
1357
|
});
|
|
1354
1358
|
}
|
|
@@ -1358,7 +1362,7 @@ class U {
|
|
|
1358
1362
|
*/
|
|
1359
1363
|
setData(e) {
|
|
1360
1364
|
this.records = [...e.records || []], this.currentIndex = this.records.length > 0 ? 0 : -1, this.state = "browse", this.originalRecord = null, this.emit({
|
|
1361
|
-
type:
|
|
1365
|
+
type: d.dataChanged,
|
|
1362
1366
|
data: this.records
|
|
1363
1367
|
});
|
|
1364
1368
|
}
|
|
@@ -1396,7 +1400,7 @@ class U {
|
|
|
1396
1400
|
gotoRecordByData(e) {
|
|
1397
1401
|
const t = this.records.findIndex((r) => r === e);
|
|
1398
1402
|
return t >= 0 ? (this.currentIndex = t, this.emit({
|
|
1399
|
-
type:
|
|
1403
|
+
type: d.recordChanged,
|
|
1400
1404
|
record: this.getCurrentRecord(),
|
|
1401
1405
|
index: this.currentIndex
|
|
1402
1406
|
}), !0) : !1;
|
|
@@ -1409,7 +1413,7 @@ class U {
|
|
|
1409
1413
|
}
|
|
1410
1414
|
addFieldChangeListener(e, t) {
|
|
1411
1415
|
const r = (i) => {
|
|
1412
|
-
i.type ===
|
|
1416
|
+
i.type === d.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
|
|
1413
1417
|
};
|
|
1414
1418
|
return this.addListener(r), this;
|
|
1415
1419
|
}
|
|
@@ -1429,14 +1433,14 @@ class U {
|
|
|
1429
1433
|
for (let t = 0; t < this.records.length; t++) {
|
|
1430
1434
|
const r = this.records[t];
|
|
1431
1435
|
let i = !0;
|
|
1432
|
-
for (const [s,
|
|
1433
|
-
if (this.getNestedValue(r, s) !==
|
|
1436
|
+
for (const [s, n] of Object.entries(e))
|
|
1437
|
+
if (this.getNestedValue(r, s) !== n) {
|
|
1434
1438
|
i = !1;
|
|
1435
1439
|
break;
|
|
1436
1440
|
}
|
|
1437
1441
|
if (i)
|
|
1438
1442
|
return this.currentIndex = t, this.emit({
|
|
1439
|
-
type:
|
|
1443
|
+
type: d.recordChanged,
|
|
1440
1444
|
record: this.getCurrentRecord(),
|
|
1441
1445
|
index: this.currentIndex
|
|
1442
1446
|
}), !0;
|
|
@@ -1447,7 +1451,7 @@ class U {
|
|
|
1447
1451
|
for (let t = 0; t < this.records.length; t++)
|
|
1448
1452
|
if (e(this.records[t]))
|
|
1449
1453
|
return this.currentIndex = t, this.emit({
|
|
1450
|
-
type:
|
|
1454
|
+
type: d.recordChanged,
|
|
1451
1455
|
record: this.getCurrentRecord(),
|
|
1452
1456
|
index: this.currentIndex
|
|
1453
1457
|
}), !0;
|
|
@@ -1479,7 +1483,7 @@ class U {
|
|
|
1479
1483
|
setRecords(e) {
|
|
1480
1484
|
const t = [...this.records];
|
|
1481
1485
|
this.records = [...e], e.length > 0 ? this.currentIndex = 0 : this.currentIndex = -1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(t), this.emit({
|
|
1482
|
-
type:
|
|
1486
|
+
type: d.dataChanged,
|
|
1483
1487
|
data: this.records
|
|
1484
1488
|
});
|
|
1485
1489
|
}
|
|
@@ -1505,9 +1509,9 @@ class U {
|
|
|
1505
1509
|
setNestedValue(e, t, r) {
|
|
1506
1510
|
const i = t.split(".");
|
|
1507
1511
|
let s = e;
|
|
1508
|
-
for (let
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1512
|
+
for (let n = 0; n < i.length - 1; n++) {
|
|
1513
|
+
const a = i[n];
|
|
1514
|
+
a in s || (s[a] = {}), s = s[a];
|
|
1511
1515
|
}
|
|
1512
1516
|
s[i[i.length - 1]] = r;
|
|
1513
1517
|
}
|
|
@@ -1576,27 +1580,27 @@ class Qe {
|
|
|
1576
1580
|
// =================== Navigation ===================
|
|
1577
1581
|
first() {
|
|
1578
1582
|
this.filteredRecords.length > 0 && (this.currentIndex = 0, this.emit({
|
|
1579
|
-
type:
|
|
1583
|
+
type: d.afterScroll
|
|
1580
1584
|
}));
|
|
1581
1585
|
}
|
|
1582
1586
|
last() {
|
|
1583
1587
|
this.filteredRecords.length > 0 && (this.currentIndex = this.filteredRecords.length - 1, this.emit({
|
|
1584
|
-
type:
|
|
1588
|
+
type: d.afterScroll
|
|
1585
1589
|
}));
|
|
1586
1590
|
}
|
|
1587
1591
|
next() {
|
|
1588
1592
|
this.currentIndex < this.filteredRecords.length - 1 && (this.currentIndex++, this.emit({
|
|
1589
|
-
type:
|
|
1593
|
+
type: d.afterScroll
|
|
1590
1594
|
}));
|
|
1591
1595
|
}
|
|
1592
1596
|
prior() {
|
|
1593
1597
|
this.currentIndex > 0 && (this.currentIndex--, this.emit({
|
|
1594
|
-
type:
|
|
1598
|
+
type: d.afterScroll
|
|
1595
1599
|
}));
|
|
1596
1600
|
}
|
|
1597
1601
|
goToRecord(e) {
|
|
1598
1602
|
e >= 0 && e < this.filteredRecords.length && (this.currentIndex = e, this.emit({
|
|
1599
|
-
type:
|
|
1603
|
+
type: d.afterScroll
|
|
1600
1604
|
}));
|
|
1601
1605
|
}
|
|
1602
1606
|
isFirst() {
|
|
@@ -1627,11 +1631,11 @@ class Qe {
|
|
|
1627
1631
|
throw this.publishEventError(e, {}), new g(e);
|
|
1628
1632
|
}
|
|
1629
1633
|
this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
|
|
1630
|
-
type:
|
|
1634
|
+
type: d.beforeEdit,
|
|
1631
1635
|
record: this.getCurrentRecord(),
|
|
1632
1636
|
index: this.currentIndex
|
|
1633
1637
|
}), this.emit({
|
|
1634
|
-
type:
|
|
1638
|
+
type: d.afterEdit,
|
|
1635
1639
|
record: this.getCurrentRecord(),
|
|
1636
1640
|
index: this.currentIndex
|
|
1637
1641
|
});
|
|
@@ -1646,16 +1650,16 @@ class Qe {
|
|
|
1646
1650
|
} else
|
|
1647
1651
|
this.state === "insert" && (this.filteredRecords = this.filteredRecords.slice(0, -1), this.records = this.records.slice(0, -1), this.grandTotalRecords--, this.filteredRecords.length > 0 ? this.currentIndex = Math.min(this.currentIndex, this.filteredRecords.length - 1) : this.currentIndex = -1);
|
|
1648
1652
|
this.state = "browse", this.originalRecord = null, this.emit({
|
|
1649
|
-
type:
|
|
1653
|
+
type: d.afterCancel,
|
|
1650
1654
|
record: this.getCurrentRecord(),
|
|
1651
1655
|
index: this.currentIndex
|
|
1652
1656
|
});
|
|
1653
1657
|
}
|
|
1654
1658
|
insert(e) {
|
|
1655
1659
|
this.validateDataSourceActive("insert"), this.state = "insert", this.emit({
|
|
1656
|
-
type:
|
|
1660
|
+
type: d.beforeInsert
|
|
1657
1661
|
}), this.filteredRecords = [...this.filteredRecords, e], this.records = [...this.records, e], this.currentIndex = this.filteredRecords.length - 1, this.grandTotalRecords++, this.notifyStateChange(), this.emit({
|
|
1658
|
-
type:
|
|
1662
|
+
type: d.afterInsert,
|
|
1659
1663
|
record: e,
|
|
1660
1664
|
index: this.currentIndex
|
|
1661
1665
|
});
|
|
@@ -1672,7 +1676,7 @@ class Qe {
|
|
|
1672
1676
|
}
|
|
1673
1677
|
const t = this.getCurrentRecord();
|
|
1674
1678
|
if (this.emit({
|
|
1675
|
-
type:
|
|
1679
|
+
type: d.beforeSave,
|
|
1676
1680
|
record: t,
|
|
1677
1681
|
index: this.getCurrentIndex()
|
|
1678
1682
|
}), this.validator) {
|
|
@@ -1690,13 +1694,13 @@ class Qe {
|
|
|
1690
1694
|
s[this.currentIndex] = r;
|
|
1691
1695
|
});
|
|
1692
1696
|
let i = -1;
|
|
1693
|
-
return this.records.forEach((s,
|
|
1694
|
-
const
|
|
1695
|
-
(s === t ||
|
|
1697
|
+
return this.records.forEach((s, n) => {
|
|
1698
|
+
const a = this.service.getId(s), l = this.service.getId(t);
|
|
1699
|
+
(s === t || a !== void 0 && a === l) && (i = n);
|
|
1696
1700
|
}), this.records = Q(this.records, (s) => {
|
|
1697
1701
|
i >= 0 ? s[i] = r : s.push(r);
|
|
1698
1702
|
}), this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
|
|
1699
|
-
type:
|
|
1703
|
+
type: d.afterSave,
|
|
1700
1704
|
record: r,
|
|
1701
1705
|
index: this.getCurrentIndex()
|
|
1702
1706
|
}), e && e(), r;
|
|
@@ -1715,24 +1719,24 @@ class Qe {
|
|
|
1715
1719
|
}
|
|
1716
1720
|
const t = this.getCurrentRecord(), r = this.currentIndex;
|
|
1717
1721
|
this.emit({
|
|
1718
|
-
type:
|
|
1722
|
+
type: d.beforeRemove,
|
|
1719
1723
|
record: t,
|
|
1720
1724
|
index: r
|
|
1721
1725
|
});
|
|
1722
1726
|
try {
|
|
1723
|
-
await this.service.delete(this.service.getId(t)), this.filteredRecords = this.filteredRecords.filter((s,
|
|
1727
|
+
await this.service.delete(this.service.getId(t)), this.filteredRecords = this.filteredRecords.filter((s, n) => n !== this.currentIndex);
|
|
1724
1728
|
const i = this.records.findIndex(
|
|
1725
1729
|
(s) => this.service.getId(s) === this.service.getId(t)
|
|
1726
1730
|
);
|
|
1727
|
-
return i >= 0 && (this.records = this.records.filter((s,
|
|
1728
|
-
type:
|
|
1731
|
+
return i >= 0 && (this.records = this.records.filter((s, n) => n !== i)), this.grandTotalRecords--, this.filteredRecords.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.filteredRecords.length && (this.currentIndex = this.filteredRecords.length - 1), this.lastDataBrowsingOn = (/* @__PURE__ */ new Date()).getTime(), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type: d.afterScroll }), this.emit({
|
|
1732
|
+
type: d.afterRemove,
|
|
1729
1733
|
record: t,
|
|
1730
1734
|
index: r
|
|
1731
1735
|
}), e && e(), t;
|
|
1732
1736
|
} catch (i) {
|
|
1733
1737
|
const s = G(i);
|
|
1734
1738
|
throw this.emit({
|
|
1735
|
-
type:
|
|
1739
|
+
type: d.onError,
|
|
1736
1740
|
error: s,
|
|
1737
1741
|
originalError: i
|
|
1738
1742
|
}), e && e(s), new g(s);
|
|
@@ -1747,21 +1751,21 @@ class Qe {
|
|
|
1747
1751
|
return;
|
|
1748
1752
|
const i = [...this.filteredRecords];
|
|
1749
1753
|
if (this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1754
|
+
const n = s[this.currentIndex];
|
|
1755
|
+
n && this.setNestedValue(n, e, t);
|
|
1752
1756
|
}), this.state === "edit" || this.state === "insert") {
|
|
1753
1757
|
const s = this.getCurrentRecord() ? this.service.getId(this.getCurrentRecord()) : null;
|
|
1754
1758
|
if (s !== void 0) {
|
|
1755
|
-
const
|
|
1756
|
-
(
|
|
1759
|
+
const n = this.records.findIndex(
|
|
1760
|
+
(a) => this.service.getId(a) === s
|
|
1757
1761
|
);
|
|
1758
|
-
|
|
1759
|
-
this.setNestedValue(
|
|
1762
|
+
n >= 0 && (this.records = Q(this.records, (a) => {
|
|
1763
|
+
this.setNestedValue(a[n], e, t);
|
|
1760
1764
|
}));
|
|
1761
1765
|
}
|
|
1762
1766
|
}
|
|
1763
1767
|
this.notifyStateChange(i), this.emit({
|
|
1764
|
-
type:
|
|
1768
|
+
type: d.fieldChanged,
|
|
1765
1769
|
fieldName: e,
|
|
1766
1770
|
oldValue: r,
|
|
1767
1771
|
newValue: t,
|
|
@@ -1787,13 +1791,13 @@ class Qe {
|
|
|
1787
1791
|
throw new Error(`Field ${String(e)} is not an array (found: ${typeof r})`);
|
|
1788
1792
|
const i = [...this.filteredRecords];
|
|
1789
1793
|
this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1790
|
-
const
|
|
1791
|
-
if (
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1794
|
+
const n = s[this.currentIndex];
|
|
1795
|
+
if (n) {
|
|
1796
|
+
const a = this.getNestedValue(n, e);
|
|
1797
|
+
a && a.push(t);
|
|
1794
1798
|
}
|
|
1795
1799
|
}), this.notifyStateChange(i), this.emit({
|
|
1796
|
-
type:
|
|
1800
|
+
type: d.fieldChanged,
|
|
1797
1801
|
fieldName: e,
|
|
1798
1802
|
oldValue: r,
|
|
1799
1803
|
newValue: [...r, t],
|
|
@@ -1808,14 +1812,14 @@ class Qe {
|
|
|
1808
1812
|
if (!Array.isArray(i) || t < 0 || t >= i.length)
|
|
1809
1813
|
return;
|
|
1810
1814
|
const s = [...this.filteredRecords];
|
|
1811
|
-
this.filteredRecords = Q(this.filteredRecords, (
|
|
1812
|
-
const
|
|
1813
|
-
if (
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1815
|
+
this.filteredRecords = Q(this.filteredRecords, (n) => {
|
|
1816
|
+
const a = n[this.currentIndex];
|
|
1817
|
+
if (a) {
|
|
1818
|
+
const l = this.getNestedValue(a, e);
|
|
1819
|
+
l[t] !== void 0 && r(l[t]);
|
|
1816
1820
|
}
|
|
1817
1821
|
}), this.notifyStateChange(s), this.emit({
|
|
1818
|
-
type:
|
|
1822
|
+
type: d.fieldChanged,
|
|
1819
1823
|
fieldName: e,
|
|
1820
1824
|
oldValue: i,
|
|
1821
1825
|
newValue: this.getFieldValue(e),
|
|
@@ -1833,10 +1837,10 @@ class Qe {
|
|
|
1833
1837
|
return;
|
|
1834
1838
|
const i = [...this.filteredRecords];
|
|
1835
1839
|
this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1840
|
+
const n = s[this.currentIndex];
|
|
1841
|
+
n && this.getNestedValue(n, e).splice(t, 1);
|
|
1838
1842
|
}), this.notifyStateChange(i), this.emit({
|
|
1839
|
-
type:
|
|
1843
|
+
type: d.fieldChanged,
|
|
1840
1844
|
fieldName: e,
|
|
1841
1845
|
oldValue: r,
|
|
1842
1846
|
newValue: this.getFieldValue(e),
|
|
@@ -1851,11 +1855,11 @@ class Qe {
|
|
|
1851
1855
|
if (!Array.isArray(i))
|
|
1852
1856
|
throw new Error(`Field ${String(e)} is not an array`);
|
|
1853
1857
|
const s = [...this.filteredRecords];
|
|
1854
|
-
this.filteredRecords = Q(this.filteredRecords, (
|
|
1855
|
-
const
|
|
1856
|
-
|
|
1858
|
+
this.filteredRecords = Q(this.filteredRecords, (n) => {
|
|
1859
|
+
const a = n[this.currentIndex];
|
|
1860
|
+
a && this.getNestedValue(a, e).splice(t, 0, r);
|
|
1857
1861
|
}), this.notifyStateChange(s), this.emit({
|
|
1858
|
-
type:
|
|
1862
|
+
type: d.fieldChanged,
|
|
1859
1863
|
fieldName: e,
|
|
1860
1864
|
oldValue: i,
|
|
1861
1865
|
newValue: this.getFieldValue(e),
|
|
@@ -1884,14 +1888,17 @@ class Qe {
|
|
|
1884
1888
|
*
|
|
1885
1889
|
* @param options Opções de refresh incluindo página, filtro e ordenação
|
|
1886
1890
|
*/
|
|
1891
|
+
_isLoadingData = !1;
|
|
1887
1892
|
refreshData(e) {
|
|
1888
|
-
|
|
1893
|
+
if (this._isLoadingData)
|
|
1894
|
+
return;
|
|
1895
|
+
this._isLoadingData = !0, e?.pageSize !== void 0 && (this.pageSize = e.pageSize);
|
|
1889
1896
|
const t = e?.currentPage ?? this.currentPage;
|
|
1890
|
-
if (this.currentPage = t,
|
|
1891
|
-
|
|
1897
|
+
if (this.currentPage = t, "filter" in (e || {}) && (this.currentFilter = e?.filter), e?.sort !== void 0 && (this.currentSort = e.sort, this.defaultSortFields = e.sort), this.currentFilter && this.currentFilter.trim() !== "") {
|
|
1898
|
+
this.getDataWithRsqlFilter(t);
|
|
1892
1899
|
return;
|
|
1893
1900
|
}
|
|
1894
|
-
|
|
1901
|
+
this.getDataWithoutFilter(t);
|
|
1895
1902
|
}
|
|
1896
1903
|
/**
|
|
1897
1904
|
* Carrega um registro específico pelo ID.
|
|
@@ -1902,11 +1909,10 @@ class Qe {
|
|
|
1902
1909
|
*/
|
|
1903
1910
|
async loadById(e) {
|
|
1904
1911
|
try {
|
|
1905
|
-
console.log("[V2 loadById] Buscando registro com ID:", e);
|
|
1906
1912
|
const t = await this.service.findOne(e);
|
|
1907
1913
|
if (t)
|
|
1908
|
-
return
|
|
1909
|
-
|
|
1914
|
+
return this.grandTotalRecords = 1, this.setRecords([t]), t;
|
|
1915
|
+
this.grandTotalRecords = 0, this.setRecords([]);
|
|
1910
1916
|
return;
|
|
1911
1917
|
} catch (t) {
|
|
1912
1918
|
throw console.error("[V2 loadById] Erro ao buscar registro:", t), this.handleRemoteError(t), t;
|
|
@@ -1935,6 +1941,8 @@ class Qe {
|
|
|
1935
1941
|
), r && r.content && (this.grandTotalRecords = r.totalElements || r.content.length, this.setRecords(r.content)), t && t(), r;
|
|
1936
1942
|
} catch (r) {
|
|
1937
1943
|
throw this.handleRemoteError(r, t), r;
|
|
1944
|
+
} finally {
|
|
1945
|
+
this._isLoadingData = !1;
|
|
1938
1946
|
}
|
|
1939
1947
|
}
|
|
1940
1948
|
/**
|
|
@@ -1954,8 +1962,8 @@ class Qe {
|
|
|
1954
1962
|
this.getDataWithoutFilter(t, r);
|
|
1955
1963
|
return;
|
|
1956
1964
|
}
|
|
1957
|
-
const s = e.filter.filterType,
|
|
1958
|
-
s === we &&
|
|
1965
|
+
const s = e.filter.filterType, n = e.filter.quickFilterText;
|
|
1966
|
+
s === we && n && n !== "" ? this.getDataWithQuickFilter(e, t, r) : s === Ee || s === Se ? this.getDataWithFilter(e, t, r) : this.getDataWithoutFilter(t, r);
|
|
1959
1967
|
}
|
|
1960
1968
|
// =================== Event Management ===================
|
|
1961
1969
|
addListener(e) {
|
|
@@ -1971,7 +1979,7 @@ class Qe {
|
|
|
1971
1979
|
*/
|
|
1972
1980
|
addFieldChangeListener(e, t) {
|
|
1973
1981
|
const r = (i) => {
|
|
1974
|
-
i.type ===
|
|
1982
|
+
i.type === d.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
|
|
1975
1983
|
};
|
|
1976
1984
|
return this.addListener(r), this;
|
|
1977
1985
|
}
|
|
@@ -2023,11 +2031,11 @@ class Qe {
|
|
|
2023
2031
|
*/
|
|
2024
2032
|
locate(e) {
|
|
2025
2033
|
const t = Object.keys(e), r = this.filteredRecords.findIndex((i) => t.every((s) => {
|
|
2026
|
-
const
|
|
2027
|
-
return
|
|
2034
|
+
const n = i[s], a = e[s];
|
|
2035
|
+
return n === a;
|
|
2028
2036
|
}));
|
|
2029
2037
|
return r >= 0 ? (this.currentIndex = r, this.emit({
|
|
2030
|
-
type:
|
|
2038
|
+
type: d.afterScroll
|
|
2031
2039
|
}), !0) : !1;
|
|
2032
2040
|
}
|
|
2033
2041
|
/**
|
|
@@ -2047,13 +2055,13 @@ class Qe {
|
|
|
2047
2055
|
(i) => this.service.getId(i) === t
|
|
2048
2056
|
);
|
|
2049
2057
|
return r >= 0 ? (this.currentIndex = r, this.emit({
|
|
2050
|
-
type:
|
|
2058
|
+
type: d.afterScroll
|
|
2051
2059
|
}), !0) : !1;
|
|
2052
2060
|
}
|
|
2053
2061
|
setRecords(e, t) {
|
|
2054
2062
|
const r = [...this.filteredRecords];
|
|
2055
2063
|
this.records = [...e], this.filteredRecords = [...e], t !== void 0 ? this.grandTotalRecords = t : this.grandTotalRecords < e.length && (this.grandTotalRecords = e.length), e.length > 0 ? this.currentIndex = 0 : this.currentIndex = -1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(r), this.emit({
|
|
2056
|
-
type:
|
|
2064
|
+
type: d.dataChanged,
|
|
2057
2065
|
data: this.filteredRecords
|
|
2058
2066
|
});
|
|
2059
2067
|
}
|
|
@@ -2078,7 +2086,7 @@ class Qe {
|
|
|
2078
2086
|
}
|
|
2079
2087
|
publishEventError(e, t) {
|
|
2080
2088
|
this.emit({
|
|
2081
|
-
type:
|
|
2089
|
+
type: d.onError,
|
|
2082
2090
|
error: e,
|
|
2083
2091
|
originalError: t
|
|
2084
2092
|
}), this.onError && this.onError(e, t);
|
|
@@ -2086,7 +2094,7 @@ class Qe {
|
|
|
2086
2094
|
publishEventErrors(e) {
|
|
2087
2095
|
e.forEach((t) => {
|
|
2088
2096
|
t.fieldName && (this.emit({
|
|
2089
|
-
type:
|
|
2097
|
+
type: d.onFieldError,
|
|
2090
2098
|
fieldName: t.fieldName,
|
|
2091
2099
|
error: t.errorMessage,
|
|
2092
2100
|
originalError: t
|
|
@@ -2094,20 +2102,23 @@ class Qe {
|
|
|
2094
2102
|
});
|
|
2095
2103
|
}
|
|
2096
2104
|
handleSaveError(e, t) {
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2105
|
+
let r = !1;
|
|
2106
|
+
const i = e?.response?.data?.apierror ?? e?.response?.data, s = i?.subErrors ?? i?.fieldErrors;
|
|
2107
|
+
s && s.forEach((a) => {
|
|
2108
|
+
const l = a.field ?? a.property;
|
|
2109
|
+
l && (r = !0, this.emit({
|
|
2110
|
+
type: d.onFieldError,
|
|
2111
|
+
fieldName: l,
|
|
2112
|
+
error: a.message,
|
|
2113
|
+
originalError: a.message
|
|
2114
|
+
}), this.onFieldError && this.onFieldError(l, a.message));
|
|
2104
2115
|
});
|
|
2105
|
-
const
|
|
2106
|
-
this.emit({
|
|
2107
|
-
type:
|
|
2108
|
-
error:
|
|
2116
|
+
const n = G(e);
|
|
2117
|
+
r || (this.emit({
|
|
2118
|
+
type: d.onError,
|
|
2119
|
+
error: n,
|
|
2109
2120
|
originalError: e
|
|
2110
|
-
}), this.onError && this.onError(
|
|
2121
|
+
}), this.onError && this.onError(n, e)), t && t(n);
|
|
2111
2122
|
}
|
|
2112
2123
|
notifyStateChange(e) {
|
|
2113
2124
|
this.onStateChange && e && this.onStateChange(e, [...this.filteredRecords]);
|
|
@@ -2115,9 +2126,9 @@ class Qe {
|
|
|
2115
2126
|
setNestedValue(e, t, r) {
|
|
2116
2127
|
const i = t.split(".");
|
|
2117
2128
|
let s = e;
|
|
2118
|
-
for (let
|
|
2119
|
-
const
|
|
2120
|
-
|
|
2129
|
+
for (let n = 0; n < i.length - 1; n++) {
|
|
2130
|
+
const a = i[n];
|
|
2131
|
+
a in s || (s[a] = {}), s = s[a];
|
|
2121
2132
|
}
|
|
2122
2133
|
s[i[i.length - 1]] = r;
|
|
2123
2134
|
}
|
|
@@ -2137,8 +2148,8 @@ class Qe {
|
|
|
2137
2148
|
const i = new Fe();
|
|
2138
2149
|
i.buildFrom(e.filter, e.sort);
|
|
2139
2150
|
const s = i.toJSON();
|
|
2140
|
-
let
|
|
2141
|
-
return s ?
|
|
2151
|
+
let n;
|
|
2152
|
+
return s ? n = await this.service.findAllWithFilter(s, t, this.getPageSize()) : n = await this.getDataWithoutFilter(t), n && n.content && (this.grandTotalRecords = n.totalElements || n.content.length, this.setRecords(n.content)), r && r(), n;
|
|
2142
2153
|
} catch (i) {
|
|
2143
2154
|
throw this.handleRemoteError(i, r), i;
|
|
2144
2155
|
}
|
|
@@ -2146,25 +2157,28 @@ class Qe {
|
|
|
2146
2157
|
async getDataWithoutFilter(e, t) {
|
|
2147
2158
|
try {
|
|
2148
2159
|
const r = this.currentSort && this.currentSort.length > 0 ? this.currentSort : this.defaultSortFields;
|
|
2149
|
-
console.log("[V2 getDataWithoutFilter] Buscando página:", e, "pageSize:", this.getPageSize(), "sort:", r);
|
|
2150
2160
|
let i;
|
|
2151
|
-
return r.length > 0 ? i = await this.service.findAllWithSort(e, this.getPageSize(), r) : i = await this.service.findAll(e, this.getPageSize()),
|
|
2161
|
+
return r.length > 0 ? i = await this.service.findAllWithSort(e, this.getPageSize(), r) : i = await this.service.findAll(e, this.getPageSize()), i && i.content && (this.grandTotalRecords = i.totalElements || i.content.length, this.setRecords(i.content)), t && t(), i;
|
|
2152
2162
|
} catch (r) {
|
|
2153
2163
|
throw this.handleRemoteError(r, t), r;
|
|
2164
|
+
} finally {
|
|
2165
|
+
this._isLoadingData = !1;
|
|
2154
2166
|
}
|
|
2155
2167
|
}
|
|
2156
2168
|
async getDataWithQuickFilter(e, t, r) {
|
|
2157
2169
|
try {
|
|
2158
|
-
const i = Array.isArray(e.filter.quickFilterFieldsText) ? e.filter.quickFilterFieldsText.join(",") : e.filter.quickFilterFieldsText, s = this.getSortFields(e).join(","),
|
|
2170
|
+
const i = Array.isArray(e.filter.quickFilterFieldsText) ? e.filter.quickFilterFieldsText.join(",") : e.filter.quickFilterFieldsText, s = this.getSortFields(e).join(","), n = await this.service.findAllMultipleFields(
|
|
2159
2171
|
e.filter.quickFilterText,
|
|
2160
2172
|
i,
|
|
2161
2173
|
t,
|
|
2162
2174
|
this.getPageSize(),
|
|
2163
2175
|
s
|
|
2164
2176
|
);
|
|
2165
|
-
return
|
|
2177
|
+
return n && n.content && (this.grandTotalRecords = n.totalElements || n.content.length, this.setRecords(n.content)), r && r(), n;
|
|
2166
2178
|
} catch (i) {
|
|
2167
2179
|
throw this.handleRemoteError(i, r), i;
|
|
2180
|
+
} finally {
|
|
2181
|
+
this._isLoadingData = !1;
|
|
2168
2182
|
}
|
|
2169
2183
|
}
|
|
2170
2184
|
getSortFields(e) {
|
|
@@ -2180,99 +2194,99 @@ class Qe {
|
|
|
2180
2194
|
handleRemoteError(e, t) {
|
|
2181
2195
|
const r = G(e);
|
|
2182
2196
|
this.emit({
|
|
2183
|
-
type:
|
|
2197
|
+
type: d.onError,
|
|
2184
2198
|
error: r,
|
|
2185
2199
|
originalError: e
|
|
2186
2200
|
}), this.onError && this.onError(r, e), t && t();
|
|
2187
2201
|
}
|
|
2188
2202
|
}
|
|
2189
|
-
function xe(
|
|
2190
|
-
const e = ce(null), [t, r] =
|
|
2203
|
+
function xe(o) {
|
|
2204
|
+
const e = ce(null), [t, r] = V(null), [i, s] = V(-1), [n, a] = V(0), [l, p] = V(!0), [C, W] = V(!1), [z, L] = V(!1), [P, N] = V(!1), c = M(() => (e.current || (e.current = new k(o)), e.current), []), f = u((F) => {
|
|
2191
2205
|
switch (F.type) {
|
|
2192
|
-
case
|
|
2193
|
-
case
|
|
2194
|
-
r(
|
|
2206
|
+
case d.dataChanged:
|
|
2207
|
+
case d.recordChanged:
|
|
2208
|
+
r(c.getCurrentRecord()), s(c.getCurrentIndex()), a(c.getTotalRecords()), p(c.isBrowsing()), W(c.isEditing()), L(c.isInserting());
|
|
2195
2209
|
break;
|
|
2196
|
-
case
|
|
2210
|
+
case d.fieldChanged:
|
|
2197
2211
|
break;
|
|
2198
|
-
case
|
|
2199
|
-
r(
|
|
2212
|
+
case d.afterScroll:
|
|
2213
|
+
r(c.getCurrentRecord()), s(c.getCurrentIndex());
|
|
2200
2214
|
break;
|
|
2201
|
-
case
|
|
2202
|
-
case
|
|
2215
|
+
case d.beforeEdit:
|
|
2216
|
+
case d.beforeInsert:
|
|
2203
2217
|
N(!0);
|
|
2204
2218
|
break;
|
|
2205
|
-
case
|
|
2206
|
-
case
|
|
2207
|
-
case
|
|
2208
|
-
case
|
|
2209
|
-
N(!1), p(
|
|
2219
|
+
case d.afterEdit:
|
|
2220
|
+
case d.afterInsert:
|
|
2221
|
+
case d.afterSave:
|
|
2222
|
+
case d.afterCancel:
|
|
2223
|
+
N(!1), p(c.isBrowsing()), W(c.isEditing()), L(c.isInserting());
|
|
2210
2224
|
break;
|
|
2211
|
-
case
|
|
2212
|
-
case
|
|
2225
|
+
case d.onError:
|
|
2226
|
+
case d.onFieldError:
|
|
2213
2227
|
N(!1);
|
|
2214
2228
|
break;
|
|
2215
2229
|
}
|
|
2216
|
-
}, [
|
|
2217
|
-
q(() => (
|
|
2218
|
-
|
|
2219
|
-
}), [
|
|
2220
|
-
const b =
|
|
2221
|
-
|
|
2222
|
-
}, [
|
|
2223
|
-
|
|
2224
|
-
}, [
|
|
2225
|
-
|
|
2226
|
-
}, [
|
|
2227
|
-
|
|
2228
|
-
}, [
|
|
2229
|
-
|
|
2230
|
-
}, [
|
|
2231
|
-
|
|
2232
|
-
}, [
|
|
2233
|
-
|
|
2234
|
-
}, [
|
|
2235
|
-
|
|
2236
|
-
}, [
|
|
2237
|
-
|
|
2238
|
-
}, [
|
|
2239
|
-
|
|
2240
|
-
}, [
|
|
2241
|
-
|
|
2242
|
-
}, [
|
|
2243
|
-
|
|
2244
|
-
}, [
|
|
2245
|
-
|
|
2246
|
-
}, [
|
|
2247
|
-
if (
|
|
2248
|
-
return
|
|
2249
|
-
const
|
|
2250
|
-
return Array.isArray(
|
|
2251
|
-
}, [
|
|
2252
|
-
if (
|
|
2253
|
-
return
|
|
2254
|
-
const
|
|
2255
|
-
return Array.isArray(
|
|
2256
|
-
}, [
|
|
2257
|
-
...
|
|
2230
|
+
}, [c]);
|
|
2231
|
+
q(() => (c.addListener(f), r(c.getCurrentRecord()), s(c.getCurrentIndex()), a(c.getTotalRecords()), p(c.isBrowsing()), W(c.isEditing()), L(c.isInserting()), () => {
|
|
2232
|
+
c.removeListener(f);
|
|
2233
|
+
}), [c, f]);
|
|
2234
|
+
const b = u((F, _) => {
|
|
2235
|
+
c.setFieldValue(F, _);
|
|
2236
|
+
}, [c]), T = u((F) => c.getFieldValue(F), [c]), K = u(() => {
|
|
2237
|
+
c instanceof k, c.edit();
|
|
2238
|
+
}, [c]), m = u(async () => await c.save(), [c]), h = u(() => {
|
|
2239
|
+
c instanceof k, c.cancel();
|
|
2240
|
+
}, [c]), Y = u((F) => {
|
|
2241
|
+
c instanceof k, c.insert(F);
|
|
2242
|
+
}, [c]), Z = u(async (F) => await c.remove(F), [c]), E = u(() => {
|
|
2243
|
+
c instanceof k, c.first();
|
|
2244
|
+
}, [c]), j = u(() => {
|
|
2245
|
+
c instanceof k, c.last();
|
|
2246
|
+
}, [c]), ee = u(() => {
|
|
2247
|
+
c instanceof k, c.next();
|
|
2248
|
+
}, [c]), D = u(() => {
|
|
2249
|
+
c instanceof k, c.prior();
|
|
2250
|
+
}, [c]), S = u((F) => {
|
|
2251
|
+
c instanceof k, c.goToRecord(F);
|
|
2252
|
+
}, [c]), A = u((F, _) => {
|
|
2253
|
+
c instanceof k && c.appendToFieldArray(F, _);
|
|
2254
|
+
}, [c]), B = u((F, _, de) => {
|
|
2255
|
+
c instanceof k && c.updateFieldArrayItem(F, _, de);
|
|
2256
|
+
}, [c]), y = u((F, _) => {
|
|
2257
|
+
c instanceof k && c.removeFromFieldArray(F, _);
|
|
2258
|
+
}, [c]), w = u((F, _, de) => {
|
|
2259
|
+
c instanceof k && c.insertIntoFieldArray(F, _, de);
|
|
2260
|
+
}, [c]), x = u((F) => {
|
|
2261
|
+
if (c instanceof k)
|
|
2262
|
+
return c.getFieldArray(F);
|
|
2263
|
+
const _ = c.getFieldValue(F);
|
|
2264
|
+
return Array.isArray(_) ? _ : [];
|
|
2265
|
+
}, [c]), $ = u((F) => {
|
|
2266
|
+
if (c instanceof k)
|
|
2267
|
+
return c.isFieldArray(F);
|
|
2268
|
+
const _ = c.getFieldValue(F);
|
|
2269
|
+
return Array.isArray(_);
|
|
2270
|
+
}, [c]), v = M(() => i < n - 1, [i, n]), J = M(() => i > 0, [i]), te = M(() => n === 0, [n]), oe = M(() => i === 0, [i]), ae = M(() => i === n - 1, [i, n]), O = M(() => l, [l]), U = M(() => C, [C]), re = M(() => z, [z]), ue = u(() => process.env.NODE_ENV === "development" ? {
|
|
2271
|
+
...c.getDebugSnapshot(),
|
|
2258
2272
|
hookState: {
|
|
2259
2273
|
currentRecord: t,
|
|
2260
2274
|
currentIndex: i,
|
|
2261
|
-
totalRecords:
|
|
2275
|
+
totalRecords: n,
|
|
2262
2276
|
isBrowsing: O,
|
|
2263
|
-
isEditing:
|
|
2277
|
+
isEditing: U,
|
|
2264
2278
|
isInserting: re,
|
|
2265
|
-
isLoading:
|
|
2279
|
+
isLoading: P
|
|
2266
2280
|
}
|
|
2267
|
-
} : null, [
|
|
2281
|
+
} : null, [c, t, i, n, O, U, re, P]);
|
|
2268
2282
|
return {
|
|
2269
2283
|
// DataSource instance (para casos onde acesso direto é necessário)
|
|
2270
|
-
dataSource:
|
|
2284
|
+
dataSource: c,
|
|
2271
2285
|
// Estado reativo
|
|
2272
2286
|
currentRecord: t,
|
|
2273
2287
|
currentIndex: i,
|
|
2274
|
-
totalRecords:
|
|
2275
|
-
isLoading:
|
|
2288
|
+
totalRecords: n,
|
|
2289
|
+
isLoading: P,
|
|
2276
2290
|
// Estado derivado
|
|
2277
2291
|
canNext: v,
|
|
2278
2292
|
canPrior: J,
|
|
@@ -2280,11 +2294,11 @@ function xe(n) {
|
|
|
2280
2294
|
isFirst: oe,
|
|
2281
2295
|
isLast: ae,
|
|
2282
2296
|
isBrowsing: O,
|
|
2283
|
-
isEditing:
|
|
2297
|
+
isEditing: U,
|
|
2284
2298
|
isInserting: re,
|
|
2285
2299
|
// Operações básicas
|
|
2286
2300
|
setFieldValue: b,
|
|
2287
|
-
getFieldValue:
|
|
2301
|
+
getFieldValue: T,
|
|
2288
2302
|
edit: K,
|
|
2289
2303
|
save: m,
|
|
2290
2304
|
cancel: h,
|
|
@@ -2307,161 +2321,161 @@ function xe(n) {
|
|
|
2307
2321
|
getDebugInfo: ue
|
|
2308
2322
|
};
|
|
2309
2323
|
}
|
|
2310
|
-
function wt(
|
|
2324
|
+
function wt(o) {
|
|
2311
2325
|
const {
|
|
2312
2326
|
dataSource: e,
|
|
2313
2327
|
currentRecord: t,
|
|
2314
2328
|
currentIndex: r,
|
|
2315
2329
|
totalRecords: i,
|
|
2316
2330
|
canNext: s,
|
|
2317
|
-
canPrior:
|
|
2318
|
-
isEmpty:
|
|
2319
|
-
isFirst:
|
|
2331
|
+
canPrior: n,
|
|
2332
|
+
isEmpty: a,
|
|
2333
|
+
isFirst: l,
|
|
2320
2334
|
isLast: p,
|
|
2321
2335
|
isBrowsing: C,
|
|
2322
2336
|
first: W,
|
|
2323
|
-
last:
|
|
2324
|
-
next:
|
|
2325
|
-
prior:
|
|
2337
|
+
last: z,
|
|
2338
|
+
next: L,
|
|
2339
|
+
prior: P,
|
|
2326
2340
|
goToRecord: N,
|
|
2327
|
-
getFieldValue:
|
|
2341
|
+
getFieldValue: c,
|
|
2328
2342
|
getFieldArray: f,
|
|
2329
2343
|
isFieldArray: b
|
|
2330
|
-
} = xe(
|
|
2344
|
+
} = xe(o);
|
|
2331
2345
|
return {
|
|
2332
2346
|
dataSource: e,
|
|
2333
2347
|
currentRecord: t,
|
|
2334
2348
|
currentIndex: r,
|
|
2335
2349
|
totalRecords: i,
|
|
2336
2350
|
canNext: s,
|
|
2337
|
-
canPrior:
|
|
2338
|
-
isEmpty:
|
|
2339
|
-
isFirst:
|
|
2351
|
+
canPrior: n,
|
|
2352
|
+
isEmpty: a,
|
|
2353
|
+
isFirst: l,
|
|
2340
2354
|
isLast: p,
|
|
2341
2355
|
isBrowsing: C,
|
|
2342
2356
|
first: W,
|
|
2343
|
-
last:
|
|
2344
|
-
next:
|
|
2345
|
-
prior:
|
|
2357
|
+
last: z,
|
|
2358
|
+
next: L,
|
|
2359
|
+
prior: P,
|
|
2346
2360
|
goToRecord: N,
|
|
2347
|
-
getFieldValue:
|
|
2361
|
+
getFieldValue: c,
|
|
2348
2362
|
getFieldArray: f,
|
|
2349
2363
|
isFieldArray: b
|
|
2350
2364
|
};
|
|
2351
2365
|
}
|
|
2352
|
-
function Et(
|
|
2353
|
-
return xe(
|
|
2366
|
+
function Et(o) {
|
|
2367
|
+
return xe(o);
|
|
2354
2368
|
}
|
|
2355
|
-
function Ce(
|
|
2356
|
-
const { id: e, loadOnStart: t = !0 } =
|
|
2369
|
+
function Ce(o) {
|
|
2370
|
+
const { id: e, loadOnStart: t = !0 } = o, r = ce(null), [i, s] = V(void 0), [n, a] = V(-1), [l, p] = V(0), [C, W] = V(0), [z, L] = V(!0), [P, N] = V(!1), [c, f] = V(!1), [b, T] = V(!1), [K, m] = V(null), h = M(() => (r.current || (r.current = new Qe(o)), r.current), []), Y = u((I) => {
|
|
2357
2371
|
switch (I.type) {
|
|
2358
|
-
case
|
|
2359
|
-
case
|
|
2360
|
-
case
|
|
2361
|
-
s(h.getCurrentRecord()),
|
|
2372
|
+
case d.dataChanged:
|
|
2373
|
+
case d.recordChanged:
|
|
2374
|
+
case d.refreshData:
|
|
2375
|
+
s(h.getCurrentRecord()), a(h.getCurrentIndex()), p(h.getTotalRecords()), W(h.getGrandTotalRecords()), L(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), T(!1), m(null);
|
|
2362
2376
|
break;
|
|
2363
|
-
case
|
|
2377
|
+
case d.fieldChanged:
|
|
2364
2378
|
break;
|
|
2365
|
-
case
|
|
2366
|
-
s(h.getCurrentRecord()),
|
|
2379
|
+
case d.afterScroll:
|
|
2380
|
+
s(h.getCurrentRecord()), a(h.getCurrentIndex());
|
|
2367
2381
|
break;
|
|
2368
|
-
case
|
|
2369
|
-
case
|
|
2370
|
-
case
|
|
2371
|
-
case
|
|
2372
|
-
|
|
2382
|
+
case d.beforeEdit:
|
|
2383
|
+
case d.beforeInsert:
|
|
2384
|
+
case d.beforeSave:
|
|
2385
|
+
case d.beforeRemove:
|
|
2386
|
+
T(!0), m(null);
|
|
2373
2387
|
break;
|
|
2374
|
-
case
|
|
2375
|
-
case
|
|
2376
|
-
case
|
|
2377
|
-
case
|
|
2378
|
-
case
|
|
2379
|
-
|
|
2388
|
+
case d.afterEdit:
|
|
2389
|
+
case d.afterInsert:
|
|
2390
|
+
case d.afterSave:
|
|
2391
|
+
case d.afterCancel:
|
|
2392
|
+
case d.afterRemove:
|
|
2393
|
+
T(!1), L(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), m(null);
|
|
2380
2394
|
break;
|
|
2381
|
-
case
|
|
2382
|
-
|
|
2395
|
+
case d.onError:
|
|
2396
|
+
T(!1), m(I.error);
|
|
2383
2397
|
break;
|
|
2384
|
-
case
|
|
2385
|
-
|
|
2398
|
+
case d.onFieldError:
|
|
2399
|
+
T(!1);
|
|
2386
2400
|
break;
|
|
2387
2401
|
}
|
|
2388
2402
|
}, [h]);
|
|
2389
|
-
q(() => (h.addListener(Y), s(h.getCurrentRecord()),
|
|
2403
|
+
q(() => (h.addListener(Y), s(h.getCurrentRecord()), a(h.getCurrentIndex()), p(h.getTotalRecords()), W(h.getGrandTotalRecords()), L(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), () => {
|
|
2390
2404
|
h.removeListener(Y);
|
|
2391
2405
|
}), [h, Y]), q(() => {
|
|
2392
|
-
t && (e != null ? (
|
|
2393
|
-
m(I.message || "Erro ao carregar registro"),
|
|
2394
|
-
})) : (
|
|
2406
|
+
t && (e != null ? (T(!0), m(null), h.loadById(e).catch((I) => {
|
|
2407
|
+
m(I.message || "Erro ao carregar registro"), T(!1);
|
|
2408
|
+
})) : (T(!0), m(null), h.refreshData()));
|
|
2395
2409
|
}, [e, t, h]);
|
|
2396
|
-
const Z =
|
|
2410
|
+
const Z = u((I, H) => {
|
|
2397
2411
|
h.setFieldValue(I, H);
|
|
2398
|
-
}, [h]), E =
|
|
2412
|
+
}, [h]), E = u((I) => h.getFieldValue(I), [h]), j = u(() => {
|
|
2399
2413
|
h.edit();
|
|
2400
|
-
}, [h]), ee =
|
|
2414
|
+
}, [h]), ee = u(async () => {
|
|
2401
2415
|
try {
|
|
2402
2416
|
return m(null), await h.save();
|
|
2403
2417
|
} catch (I) {
|
|
2404
2418
|
throw m(I.message || "Erro ao salvar"), I;
|
|
2405
2419
|
}
|
|
2406
|
-
}, [h]), D =
|
|
2420
|
+
}, [h]), D = u(() => {
|
|
2407
2421
|
h.cancel();
|
|
2408
|
-
}, [h]), S =
|
|
2422
|
+
}, [h]), S = u((I) => {
|
|
2409
2423
|
h.insert(I);
|
|
2410
|
-
}, [h]), A =
|
|
2424
|
+
}, [h]), A = u(async (I) => {
|
|
2411
2425
|
try {
|
|
2412
2426
|
return m(null), await h.remove(I);
|
|
2413
2427
|
} catch (H) {
|
|
2414
2428
|
throw m(H.message || "Erro ao remover"), H;
|
|
2415
2429
|
}
|
|
2416
|
-
}, [h]), B =
|
|
2430
|
+
}, [h]), B = u(() => {
|
|
2417
2431
|
h.first();
|
|
2418
|
-
}, [h]), y =
|
|
2432
|
+
}, [h]), y = u(() => {
|
|
2419
2433
|
h.last();
|
|
2420
|
-
}, [h]), w =
|
|
2434
|
+
}, [h]), w = u(() => {
|
|
2421
2435
|
h.next();
|
|
2422
|
-
}, [h]), x =
|
|
2436
|
+
}, [h]), x = u(() => {
|
|
2423
2437
|
h.prior();
|
|
2424
|
-
}, [h]), $ =
|
|
2438
|
+
}, [h]), $ = u((I) => {
|
|
2425
2439
|
h.goToRecord(I);
|
|
2426
|
-
}, [h]), v =
|
|
2440
|
+
}, [h]), v = u(async (I) => {
|
|
2427
2441
|
try {
|
|
2428
|
-
return
|
|
2442
|
+
return T(!0), m(null), await h.loadById(I);
|
|
2429
2443
|
} catch (H) {
|
|
2430
2444
|
throw m(H.message || "Erro ao carregar registro"), H;
|
|
2431
2445
|
} finally {
|
|
2432
|
-
|
|
2446
|
+
T(!1);
|
|
2433
2447
|
}
|
|
2434
|
-
}, [h]), J =
|
|
2448
|
+
}, [h]), J = u((I, H) => {
|
|
2435
2449
|
h.appendToFieldArray(I, H);
|
|
2436
|
-
}, [h]), te =
|
|
2450
|
+
}, [h]), te = u((I, H, se) => {
|
|
2437
2451
|
h.updateFieldArrayItem(I, H, se);
|
|
2438
|
-
}, [h]), oe =
|
|
2452
|
+
}, [h]), oe = u((I, H) => {
|
|
2439
2453
|
h.removeFromFieldArray(I, H);
|
|
2440
|
-
}, [h]), ae =
|
|
2454
|
+
}, [h]), ae = u((I, H, se) => {
|
|
2441
2455
|
h.insertIntoFieldArray(I, H, se);
|
|
2442
|
-
}, [h]), O =
|
|
2443
|
-
|
|
2456
|
+
}, [h]), O = u((I) => h.getFieldArray(I), [h]), U = u((I) => h.isFieldArray(I), [h]), re = u((I, H, se) => {
|
|
2457
|
+
T(!0), m(null);
|
|
2444
2458
|
try {
|
|
2445
2459
|
h.applyRemoteFilter(I, H, () => {
|
|
2446
|
-
|
|
2460
|
+
T(!1), se && se();
|
|
2447
2461
|
});
|
|
2448
|
-
} catch (
|
|
2449
|
-
|
|
2462
|
+
} catch (Pe) {
|
|
2463
|
+
T(!1), m(Pe.message || "Erro ao aplicar filtro");
|
|
2450
2464
|
}
|
|
2451
|
-
}, [h]), ue =
|
|
2465
|
+
}, [h]), ue = u(async (I) => {
|
|
2452
2466
|
try {
|
|
2453
|
-
|
|
2467
|
+
T(!0), m(null), h.refreshData(I);
|
|
2454
2468
|
} catch (H) {
|
|
2455
|
-
throw
|
|
2469
|
+
throw T(!1), m(H.message || "Erro ao atualizar dados"), H;
|
|
2456
2470
|
}
|
|
2457
|
-
}, [h]), F =
|
|
2471
|
+
}, [h]), F = u((I) => {
|
|
2458
2472
|
h.setPageSize(I);
|
|
2459
|
-
}, [h]),
|
|
2473
|
+
}, [h]), _ = u(() => h.getPageSize(), [h]), de = M(() => n < l - 1, [n, l]), De = M(() => n > 0, [n]), Te = M(() => l === 0, [l]), Ve = M(() => n === 0, [n]), Oe = M(() => n === l - 1, [n, l]), ge = M(() => z, [z]), fe = M(() => P, [P]), me = M(() => c, [c]), Le = u(() => process.env.NODE_ENV === "development" ? {
|
|
2460
2474
|
...h.getDebugSnapshot(),
|
|
2461
2475
|
hookState: {
|
|
2462
2476
|
currentRecord: i,
|
|
2463
|
-
currentIndex:
|
|
2464
|
-
totalRecords:
|
|
2477
|
+
currentIndex: n,
|
|
2478
|
+
totalRecords: l,
|
|
2465
2479
|
grandTotalRecords: C,
|
|
2466
2480
|
isBrowsing: ge,
|
|
2467
2481
|
isEditing: fe,
|
|
@@ -2469,22 +2483,22 @@ function Ce(n) {
|
|
|
2469
2483
|
isLoading: b,
|
|
2470
2484
|
error: K
|
|
2471
2485
|
}
|
|
2472
|
-
} : null, [h, i,
|
|
2486
|
+
} : null, [h, i, n, l, C, ge, fe, me, b, K]);
|
|
2473
2487
|
return {
|
|
2474
2488
|
// DataSource instance (para casos onde acesso direto é necessário)
|
|
2475
2489
|
dataSource: h,
|
|
2476
2490
|
// Estado reativo
|
|
2477
2491
|
currentRecord: i,
|
|
2478
|
-
currentIndex:
|
|
2479
|
-
totalRecords:
|
|
2492
|
+
currentIndex: n,
|
|
2493
|
+
totalRecords: l,
|
|
2480
2494
|
grandTotalRecords: C,
|
|
2481
2495
|
isLoading: b,
|
|
2482
2496
|
error: K,
|
|
2483
2497
|
// Estado derivado
|
|
2484
2498
|
canNext: de,
|
|
2485
2499
|
canPrior: De,
|
|
2486
|
-
isEmpty:
|
|
2487
|
-
isFirst:
|
|
2500
|
+
isEmpty: Te,
|
|
2501
|
+
isFirst: Ve,
|
|
2488
2502
|
isLast: Oe,
|
|
2489
2503
|
isBrowsing: ge,
|
|
2490
2504
|
isEditing: fe,
|
|
@@ -2510,37 +2524,37 @@ function Ce(n) {
|
|
|
2510
2524
|
removeFromFieldArray: oe,
|
|
2511
2525
|
insertIntoFieldArray: ae,
|
|
2512
2526
|
getFieldArray: O,
|
|
2513
|
-
isFieldArray:
|
|
2527
|
+
isFieldArray: U,
|
|
2514
2528
|
// Operações remotas
|
|
2515
2529
|
applyRemoteFilter: re,
|
|
2516
2530
|
refreshData: ue,
|
|
2517
2531
|
setPageSize: F,
|
|
2518
|
-
getPageSize:
|
|
2532
|
+
getPageSize: _,
|
|
2519
2533
|
// Debug
|
|
2520
|
-
getDebugInfo:
|
|
2534
|
+
getDebugInfo: Le
|
|
2521
2535
|
};
|
|
2522
2536
|
}
|
|
2523
|
-
function St(
|
|
2537
|
+
function St(o) {
|
|
2524
2538
|
const {
|
|
2525
2539
|
dataSource: e,
|
|
2526
2540
|
currentRecord: t,
|
|
2527
2541
|
currentIndex: r,
|
|
2528
2542
|
totalRecords: i,
|
|
2529
2543
|
grandTotalRecords: s,
|
|
2530
|
-
isLoading:
|
|
2531
|
-
error:
|
|
2532
|
-
canNext:
|
|
2544
|
+
isLoading: n,
|
|
2545
|
+
error: a,
|
|
2546
|
+
canNext: l,
|
|
2533
2547
|
canPrior: p,
|
|
2534
2548
|
isEmpty: C,
|
|
2535
2549
|
isFirst: W,
|
|
2536
|
-
isLast:
|
|
2537
|
-
isBrowsing:
|
|
2538
|
-
first:
|
|
2550
|
+
isLast: z,
|
|
2551
|
+
isBrowsing: L,
|
|
2552
|
+
first: P,
|
|
2539
2553
|
last: N,
|
|
2540
|
-
next:
|
|
2554
|
+
next: c,
|
|
2541
2555
|
prior: f,
|
|
2542
2556
|
goToRecord: b,
|
|
2543
|
-
loadById:
|
|
2557
|
+
loadById: T,
|
|
2544
2558
|
getFieldValue: K,
|
|
2545
2559
|
getFieldArray: m,
|
|
2546
2560
|
isFieldArray: h,
|
|
@@ -2548,27 +2562,27 @@ function St(n) {
|
|
|
2548
2562
|
refreshData: Z,
|
|
2549
2563
|
getPageSize: E,
|
|
2550
2564
|
getDebugInfo: j
|
|
2551
|
-
} = Ce(
|
|
2565
|
+
} = Ce(o);
|
|
2552
2566
|
return {
|
|
2553
2567
|
dataSource: e,
|
|
2554
2568
|
currentRecord: t,
|
|
2555
2569
|
currentIndex: r,
|
|
2556
2570
|
totalRecords: i,
|
|
2557
2571
|
grandTotalRecords: s,
|
|
2558
|
-
isLoading:
|
|
2559
|
-
error:
|
|
2560
|
-
canNext:
|
|
2572
|
+
isLoading: n,
|
|
2573
|
+
error: a,
|
|
2574
|
+
canNext: l,
|
|
2561
2575
|
canPrior: p,
|
|
2562
2576
|
isEmpty: C,
|
|
2563
2577
|
isFirst: W,
|
|
2564
|
-
isLast:
|
|
2565
|
-
isBrowsing:
|
|
2566
|
-
first:
|
|
2578
|
+
isLast: z,
|
|
2579
|
+
isBrowsing: L,
|
|
2580
|
+
first: P,
|
|
2567
2581
|
last: N,
|
|
2568
|
-
next:
|
|
2582
|
+
next: c,
|
|
2569
2583
|
prior: f,
|
|
2570
2584
|
goToRecord: b,
|
|
2571
|
-
loadById:
|
|
2585
|
+
loadById: T,
|
|
2572
2586
|
getFieldValue: K,
|
|
2573
2587
|
getFieldArray: m,
|
|
2574
2588
|
isFieldArray: h,
|
|
@@ -2578,8 +2592,8 @@ function St(n) {
|
|
|
2578
2592
|
getDebugInfo: j
|
|
2579
2593
|
};
|
|
2580
2594
|
}
|
|
2581
|
-
function Ft(
|
|
2582
|
-
return Ce(
|
|
2595
|
+
function Ft(o) {
|
|
2596
|
+
return Ce(o);
|
|
2583
2597
|
}
|
|
2584
2598
|
class At {
|
|
2585
2599
|
/**
|
|
@@ -2635,31 +2649,31 @@ const xt = {
|
|
|
2635
2649
|
// 1 minuto
|
|
2636
2650
|
retry: 5
|
|
2637
2651
|
}
|
|
2638
|
-
}, Ct = (
|
|
2639
|
-
const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store:
|
|
2652
|
+
}, Ct = (o) => {
|
|
2653
|
+
const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store: n, validator: a } = o, l = () => n && n.existsValue(t) ? n.getValue(t) : i || new ye(t, {
|
|
2640
2654
|
records: e,
|
|
2641
2655
|
grandTotalRecords: e.length,
|
|
2642
2656
|
currentPage: 0,
|
|
2643
2657
|
totalPages: 0,
|
|
2644
2658
|
pageSize: 0,
|
|
2645
|
-
validator:
|
|
2646
|
-
}, r), [p, C] =
|
|
2647
|
-
|
|
2659
|
+
validator: a
|
|
2660
|
+
}, r), [p, C] = V(
|
|
2661
|
+
l()
|
|
2648
2662
|
);
|
|
2649
2663
|
return q(() => {
|
|
2650
|
-
|
|
2664
|
+
n && n.setValue(t, p), s && s(p);
|
|
2651
2665
|
}, [t]), { dataSource: p };
|
|
2652
|
-
}, bt = (
|
|
2666
|
+
}, bt = (o) => {
|
|
2653
2667
|
const e = (r) => {
|
|
2654
|
-
r.addListener(
|
|
2668
|
+
r.addListener(o.listener);
|
|
2655
2669
|
}, t = (r) => {
|
|
2656
|
-
r.removeListener(
|
|
2670
|
+
r.removeListener(o.listener);
|
|
2657
2671
|
};
|
|
2658
|
-
q(() => (
|
|
2659
|
-
|
|
2660
|
-
}), [
|
|
2661
|
-
}, Dt = (
|
|
2662
|
-
const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } =
|
|
2672
|
+
q(() => (o.dataSource && (t(o.dataSource), e(o.dataSource)), () => {
|
|
2673
|
+
o.dataSource && t(o.dataSource);
|
|
2674
|
+
}), [o.dataSource?.uuid || o.dataSource?.getName()]);
|
|
2675
|
+
}, Dt = (o) => {
|
|
2676
|
+
const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = o, [n, a] = V(
|
|
2663
2677
|
r ?? new Ge(t, {
|
|
2664
2678
|
records: e,
|
|
2665
2679
|
grandTotalRecords: e.length,
|
|
@@ -2670,7 +2684,7 @@ const xt = {
|
|
|
2670
2684
|
})
|
|
2671
2685
|
);
|
|
2672
2686
|
return q(() => {
|
|
2673
|
-
|
|
2687
|
+
a((l) => {
|
|
2674
2688
|
const p = {
|
|
2675
2689
|
records: e,
|
|
2676
2690
|
grandTotalRecords: e.length,
|
|
@@ -2679,9 +2693,9 @@ const xt = {
|
|
|
2679
2693
|
pageSize: 0,
|
|
2680
2694
|
validator: s
|
|
2681
2695
|
};
|
|
2682
|
-
return
|
|
2683
|
-
}), i && i(
|
|
2684
|
-
}, [e, t]), { dataSource:
|
|
2696
|
+
return l.isActive() ? l.setData(p) : l.open(p), l;
|
|
2697
|
+
}), i && i(n);
|
|
2698
|
+
}, [e, t]), { dataSource: n };
|
|
2685
2699
|
};
|
|
2686
2700
|
class be {
|
|
2687
2701
|
tokenManager;
|
|
@@ -2698,103 +2712,103 @@ class be {
|
|
|
2698
2712
|
}
|
|
2699
2713
|
async get(e, t, r, i) {
|
|
2700
2714
|
try {
|
|
2701
|
-
const s = this.prepareHeaders(t, r),
|
|
2702
|
-
return ie.convertJsonToObject(
|
|
2715
|
+
const s = this.prepareHeaders(t, r), n = await X.get(e, { headers: s, ...i });
|
|
2716
|
+
return ie.convertJsonToObject(n.data);
|
|
2703
2717
|
} catch (s) {
|
|
2704
2718
|
return Promise.reject(s);
|
|
2705
2719
|
}
|
|
2706
2720
|
}
|
|
2707
2721
|
async post(e, t, r, i, s) {
|
|
2708
2722
|
try {
|
|
2709
|
-
const
|
|
2723
|
+
const n = this.prepareHeaders(r, i), a = await X.post(
|
|
2710
2724
|
e,
|
|
2711
2725
|
ie.convertObjectToJson(t),
|
|
2712
2726
|
{
|
|
2713
|
-
headers:
|
|
2727
|
+
headers: n,
|
|
2714
2728
|
...s
|
|
2715
2729
|
}
|
|
2716
2730
|
);
|
|
2717
|
-
return ie.convertJsonToObject(
|
|
2718
|
-
} catch (
|
|
2719
|
-
return Promise.reject(
|
|
2731
|
+
return ie.convertJsonToObject(a.data);
|
|
2732
|
+
} catch (n) {
|
|
2733
|
+
return Promise.reject(n);
|
|
2720
2734
|
}
|
|
2721
2735
|
}
|
|
2722
2736
|
async postNoConvertId(e, t, r, i, s) {
|
|
2723
2737
|
try {
|
|
2724
|
-
const
|
|
2738
|
+
const n = this.prepareHeaders(r, i);
|
|
2725
2739
|
return (await X.post(
|
|
2726
2740
|
e,
|
|
2727
2741
|
t,
|
|
2728
2742
|
{
|
|
2729
|
-
headers:
|
|
2743
|
+
headers: n,
|
|
2730
2744
|
...s
|
|
2731
2745
|
}
|
|
2732
2746
|
)).data;
|
|
2733
|
-
} catch (
|
|
2734
|
-
return Promise.reject(
|
|
2747
|
+
} catch (n) {
|
|
2748
|
+
return Promise.reject(n);
|
|
2735
2749
|
}
|
|
2736
2750
|
}
|
|
2737
2751
|
async put(e, t, r, i, s) {
|
|
2738
2752
|
try {
|
|
2739
|
-
const
|
|
2740
|
-
headers:
|
|
2753
|
+
const n = this.prepareHeaders(r, i), a = await X.put(e, ie.convertObjectToJson(t), {
|
|
2754
|
+
headers: n,
|
|
2741
2755
|
...s
|
|
2742
2756
|
});
|
|
2743
|
-
return ie.convertJsonToObject(
|
|
2744
|
-
} catch (
|
|
2745
|
-
return Promise.reject(
|
|
2757
|
+
return ie.convertJsonToObject(a.data);
|
|
2758
|
+
} catch (n) {
|
|
2759
|
+
return Promise.reject(n);
|
|
2746
2760
|
}
|
|
2747
2761
|
}
|
|
2748
2762
|
async putNoConvertId(e, t, r, i, s) {
|
|
2749
2763
|
try {
|
|
2750
|
-
const
|
|
2764
|
+
const n = this.prepareHeaders(r, i);
|
|
2751
2765
|
return (await X.put(e, t, {
|
|
2752
|
-
headers:
|
|
2766
|
+
headers: n,
|
|
2753
2767
|
...s
|
|
2754
2768
|
})).data;
|
|
2755
|
-
} catch (
|
|
2756
|
-
return Promise.reject(
|
|
2769
|
+
} catch (n) {
|
|
2770
|
+
return Promise.reject(n);
|
|
2757
2771
|
}
|
|
2758
2772
|
}
|
|
2759
2773
|
async binaryPut(e, t, r = {}, i, s) {
|
|
2760
2774
|
try {
|
|
2761
|
-
const
|
|
2775
|
+
const n = this.prepareHeaders(r, i);
|
|
2762
2776
|
return s = s || {}, (await X.put(e, t, {
|
|
2763
|
-
headers:
|
|
2777
|
+
headers: n,
|
|
2764
2778
|
...s
|
|
2765
2779
|
})).data;
|
|
2766
|
-
} catch (
|
|
2767
|
-
return Promise.reject(
|
|
2780
|
+
} catch (n) {
|
|
2781
|
+
return Promise.reject(n);
|
|
2768
2782
|
}
|
|
2769
2783
|
}
|
|
2770
2784
|
async delete(e, t, r, i) {
|
|
2771
2785
|
try {
|
|
2772
|
-
const s = this.prepareHeaders(t, r),
|
|
2773
|
-
return ie.convertJsonToObject(
|
|
2786
|
+
const s = this.prepareHeaders(t, r), n = await X.delete(e, { headers: s, ...i });
|
|
2787
|
+
return ie.convertJsonToObject(n.data);
|
|
2774
2788
|
} catch (s) {
|
|
2775
2789
|
return Promise.reject(s);
|
|
2776
2790
|
}
|
|
2777
2791
|
}
|
|
2778
2792
|
async patch(e, t, r, i, s) {
|
|
2779
2793
|
try {
|
|
2780
|
-
const
|
|
2781
|
-
headers:
|
|
2794
|
+
const n = this.prepareHeaders(r, i), a = await X.patch(e, ie.convertObjectToJson(t), {
|
|
2795
|
+
headers: n,
|
|
2782
2796
|
...s
|
|
2783
2797
|
});
|
|
2784
|
-
return ie.convertJsonToObject(
|
|
2785
|
-
} catch (
|
|
2786
|
-
return Promise.reject(
|
|
2798
|
+
return ie.convertJsonToObject(a.data);
|
|
2799
|
+
} catch (n) {
|
|
2800
|
+
return Promise.reject(n);
|
|
2787
2801
|
}
|
|
2788
2802
|
}
|
|
2789
2803
|
async patchNoConvertId(e, t, r, i, s) {
|
|
2790
2804
|
try {
|
|
2791
|
-
const
|
|
2805
|
+
const n = this.prepareHeaders(r, i);
|
|
2792
2806
|
return (await X.patch(e, t, {
|
|
2793
|
-
headers:
|
|
2807
|
+
headers: n,
|
|
2794
2808
|
...s
|
|
2795
2809
|
})).data;
|
|
2796
|
-
} catch (
|
|
2797
|
-
return Promise.reject(
|
|
2810
|
+
} catch (n) {
|
|
2811
|
+
return Promise.reject(n);
|
|
2798
2812
|
}
|
|
2799
2813
|
}
|
|
2800
2814
|
/**
|
|
@@ -2835,8 +2849,8 @@ class be {
|
|
|
2835
2849
|
try {
|
|
2836
2850
|
const s = { ...r };
|
|
2837
2851
|
if (!i) {
|
|
2838
|
-
const
|
|
2839
|
-
|
|
2852
|
+
const a = this.tokenManager.getToken();
|
|
2853
|
+
a && (s.Authorization = `Bearer ${a.access_token}`);
|
|
2840
2854
|
}
|
|
2841
2855
|
return (await X.post(e, t, { headers: s })).data;
|
|
2842
2856
|
} catch (s) {
|
|
@@ -2907,22 +2921,22 @@ class Ke {
|
|
|
2907
2921
|
return this.transformPage(s), s;
|
|
2908
2922
|
}
|
|
2909
2923
|
async findAllMultipleFields(e, t, r, i, s) {
|
|
2910
|
-
const
|
|
2924
|
+
const n = this.configureHeaders(), a = await this.client.get(
|
|
2911
2925
|
`${this.getEndpoint()}/findMultipleFields?page=${r}&size=${i}&fields=${encodeURIComponent(
|
|
2912
2926
|
t
|
|
2913
2927
|
)}&filter=${encodeURIComponent(e)}&sort=${encodeURIComponent(s)}`,
|
|
2914
|
-
|
|
2928
|
+
n,
|
|
2915
2929
|
!1
|
|
2916
2930
|
);
|
|
2917
|
-
return this.transformPage(
|
|
2931
|
+
return this.transformPage(a), a;
|
|
2918
2932
|
}
|
|
2919
2933
|
async findAllWithFilterAndSort(e, t, r, i) {
|
|
2920
|
-
const s = this.configureHeaders(),
|
|
2934
|
+
const s = this.configureHeaders(), n = `${this.getEndpoint()}/findWithFilterAndSort?page=${t}&size=${r}&filter=${encodeURIComponent(
|
|
2921
2935
|
e
|
|
2922
2936
|
)}&sort=${i}`;
|
|
2923
|
-
console.log("[findAllWithFilterAndSort] URL:",
|
|
2924
|
-
const
|
|
2925
|
-
return this.transformPage(
|
|
2937
|
+
console.log("[findAllWithFilterAndSort] URL:", n), console.log("[findAllWithFilterAndSort] filter original:", e);
|
|
2938
|
+
const a = await this.client.get(n, s, !1);
|
|
2939
|
+
return this.transformPage(a), a;
|
|
2926
2940
|
}
|
|
2927
2941
|
async findOne(e) {
|
|
2928
2942
|
const t = this.configureHeaders(), r = await this.client.get(`${this.getEndpoint()}/${e}`, t, !1);
|
|
@@ -2959,8 +2973,8 @@ class le {
|
|
|
2959
2973
|
first;
|
|
2960
2974
|
numberOfElements;
|
|
2961
2975
|
empty;
|
|
2962
|
-
constructor(e, t, r, i, s,
|
|
2963
|
-
this.content = e, this.totalElements = t, this.totalPages = r, this.number = i, this.size = s, this.sort =
|
|
2976
|
+
constructor(e, t, r, i, s, n, a, l, p, C) {
|
|
2977
|
+
this.content = e, this.totalElements = t, this.totalPages = r, this.number = i, this.size = s, this.sort = n || { sorted: !1, unsorted: !0, empty: !0 }, this.last = a !== void 0 ? a : i === r - 1, this.first = l !== void 0 ? l : i === 0, this.numberOfElements = p !== void 0 ? p : e.length, this.empty = C !== void 0 ? C : e.length === 0, this.pageable = {
|
|
2964
2978
|
sort: this.sort,
|
|
2965
2979
|
offset: i * s,
|
|
2966
2980
|
pageSize: s,
|
|
@@ -2973,45 +2987,45 @@ class le {
|
|
|
2973
2987
|
return new le(e, t, r, i, s);
|
|
2974
2988
|
}
|
|
2975
2989
|
}
|
|
2976
|
-
function Ye(
|
|
2977
|
-
return
|
|
2990
|
+
function Ye(o) {
|
|
2991
|
+
return o.totalElements || o.totalElements === 0 ? o.totalElements : o.page.totalElements;
|
|
2978
2992
|
}
|
|
2979
|
-
function Xe(
|
|
2980
|
-
return
|
|
2993
|
+
function Xe(o) {
|
|
2994
|
+
return o.totalPages || o.totalPages === 0 ? o.totalPages : o.page.totalPages;
|
|
2981
2995
|
}
|
|
2982
|
-
function Ze(
|
|
2983
|
-
return
|
|
2996
|
+
function Ze(o) {
|
|
2997
|
+
return o.pageable ? o.pageable.pageNumber : o.page.number;
|
|
2984
2998
|
}
|
|
2985
|
-
function
|
|
2999
|
+
function Tt(o) {
|
|
2986
3000
|
const {
|
|
2987
3001
|
name: e,
|
|
2988
3002
|
label: t,
|
|
2989
3003
|
service: r,
|
|
2990
3004
|
filter: i,
|
|
2991
3005
|
sort: s,
|
|
2992
|
-
transformData:
|
|
2993
|
-
onLoadComplete:
|
|
2994
|
-
onDestroy:
|
|
3006
|
+
transformData: n,
|
|
3007
|
+
onLoadComplete: a,
|
|
3008
|
+
onDestroy: l,
|
|
2995
3009
|
filterData: p,
|
|
2996
3010
|
findAll: C,
|
|
2997
3011
|
findAllWithSort: W,
|
|
2998
|
-
findAllWithFilter:
|
|
2999
|
-
findAllWithFilterAndSort:
|
|
3000
|
-
initialDataSource:
|
|
3012
|
+
findAllWithFilter: z,
|
|
3013
|
+
findAllWithFilterAndSort: L,
|
|
3014
|
+
initialDataSource: P,
|
|
3001
3015
|
pageSize: N = 50,
|
|
3002
|
-
currentPage:
|
|
3016
|
+
currentPage: c = 0,
|
|
3003
3017
|
loadOnStart: f = !0,
|
|
3004
3018
|
store: b,
|
|
3005
|
-
id:
|
|
3019
|
+
id: T,
|
|
3006
3020
|
validator: K
|
|
3007
|
-
} =
|
|
3021
|
+
} = o, m = ce(!1), h = () => !!(b && b.existsValue(e) || P), Y = () => b && b.existsValue(e) ? b.getValue(e) : P || new Ae(r, e, {
|
|
3008
3022
|
records: [],
|
|
3009
3023
|
grandTotalRecords: 0,
|
|
3010
|
-
currentPage:
|
|
3024
|
+
currentPage: c,
|
|
3011
3025
|
totalPages: 0,
|
|
3012
3026
|
pageSize: N,
|
|
3013
3027
|
validator: K
|
|
3014
|
-
}, t), Z = () => b && b.existsValue(e) ? b.getValue(e).getCurrentPage() :
|
|
3028
|
+
}, t), Z = () => b && b.existsValue(e) ? b.getValue(e).getCurrentPage() : P ? P.getCurrentPage() : 0, [E, j] = V({
|
|
3015
3029
|
dataSource: Y(),
|
|
3016
3030
|
isLoading: !1,
|
|
3017
3031
|
isError: !1,
|
|
@@ -3020,18 +3034,18 @@ function Vt(n) {
|
|
|
3020
3034
|
label: t,
|
|
3021
3035
|
filter: i,
|
|
3022
3036
|
sort: s,
|
|
3023
|
-
id:
|
|
3037
|
+
id: T,
|
|
3024
3038
|
currentPage: Z(),
|
|
3025
3039
|
pageSize: N,
|
|
3026
3040
|
loadDataCount: h() ? 1 : 0
|
|
3027
3041
|
}), ee = async (y, w, x, $, v, J, te, oe, ae) => {
|
|
3028
3042
|
let O;
|
|
3029
3043
|
if (J) {
|
|
3030
|
-
const
|
|
3031
|
-
|
|
3044
|
+
const U = await r.findOne(J);
|
|
3045
|
+
U ? O = le.createFromValues([U], 1, 0, 0, 0) : O = le.createFromValues([], 0, 0, 0, 0);
|
|
3032
3046
|
} else
|
|
3033
|
-
|
|
3034
|
-
p && (O = p(O)),
|
|
3047
|
+
L && $ && v && v.length > 0 ? O = await L($, w, x, v) : z && $ ? O = await z($, w, x) : W && v && v.length > 0 ? O = await W(w, x, v) : C ? O = await C(w, x) : $ && v && v.length > 0 ? O = await r.findAllWithFilterAndSort($, w, x, v) : $ ? O = await r.findAllWithFilter($, w, x) : v && v.length > 0 ? O = await r.findAllWithSort(w, x, v) : O = await r.findAll(w, x);
|
|
3048
|
+
p && (O = p(O)), n && (O = n(O)), j((U) => {
|
|
3035
3049
|
const re = {
|
|
3036
3050
|
records: O.content,
|
|
3037
3051
|
grandTotalRecords: Ye(O),
|
|
@@ -3045,8 +3059,8 @@ function Vt(n) {
|
|
|
3045
3059
|
originSort: oe,
|
|
3046
3060
|
validator: K
|
|
3047
3061
|
};
|
|
3048
|
-
return
|
|
3049
|
-
...
|
|
3062
|
+
return U.dataSource.isActive() ? U.dataSource.setData(re) : U.dataSource.open(re), {
|
|
3063
|
+
...U,
|
|
3050
3064
|
currentPage: w,
|
|
3051
3065
|
pageSize: x,
|
|
3052
3066
|
filter: $,
|
|
@@ -3055,15 +3069,15 @@ function Vt(n) {
|
|
|
3055
3069
|
isLoading: !1,
|
|
3056
3070
|
isError: !1,
|
|
3057
3071
|
error: "",
|
|
3058
|
-
loadDataCount:
|
|
3072
|
+
loadDataCount: U.loadDataCount + 1
|
|
3059
3073
|
};
|
|
3060
3074
|
}), b && b.setValue(e, E.dataSource);
|
|
3061
3075
|
};
|
|
3062
3076
|
q(() => {
|
|
3063
|
-
|
|
3077
|
+
a && E.loadDataCount > 0 && a(E.dataSource);
|
|
3064
3078
|
}, [E.loadDataCount]);
|
|
3065
|
-
const D =
|
|
3066
|
-
if (y.type ===
|
|
3079
|
+
const D = u((y) => {
|
|
3080
|
+
if (y.type === d.refreshData) {
|
|
3067
3081
|
const w = y.options;
|
|
3068
3082
|
try {
|
|
3069
3083
|
j((x) => ({
|
|
@@ -3090,7 +3104,7 @@ function Vt(n) {
|
|
|
3090
3104
|
isError: !0,
|
|
3091
3105
|
isLoading: !1,
|
|
3092
3106
|
error: $
|
|
3093
|
-
})),
|
|
3107
|
+
})), o.onError && o.onError($, x);
|
|
3094
3108
|
});
|
|
3095
3109
|
} catch (x) {
|
|
3096
3110
|
const $ = G(x);
|
|
@@ -3099,19 +3113,19 @@ function Vt(n) {
|
|
|
3099
3113
|
isError: !0,
|
|
3100
3114
|
isLoading: !1,
|
|
3101
3115
|
error: $
|
|
3102
|
-
})),
|
|
3116
|
+
})), o.onError && o.onError($, x);
|
|
3103
3117
|
}
|
|
3104
3118
|
}
|
|
3105
|
-
}, [ee, E.name,
|
|
3119
|
+
}, [ee, E.name, o.onError]), S = u((y) => {
|
|
3106
3120
|
m.current || (y.addListener(D), m.current = !0);
|
|
3107
|
-
}, [D]), A =
|
|
3121
|
+
}, [D]), A = u((y) => {
|
|
3108
3122
|
m.current && (y.removeListener(D), m.current = !1);
|
|
3109
3123
|
}, [D]);
|
|
3110
3124
|
q(() => {
|
|
3111
3125
|
try {
|
|
3112
3126
|
return S(E.dataSource), f && E.loadDataCount === 0 ? (j((y) => ({ ...y, isLoading: !0 })), ee(
|
|
3113
3127
|
E.name,
|
|
3114
|
-
|
|
3128
|
+
c,
|
|
3115
3129
|
N,
|
|
3116
3130
|
E.filter,
|
|
3117
3131
|
E.sort,
|
|
@@ -3123,9 +3137,9 @@ function Vt(n) {
|
|
|
3123
3137
|
isError: !0,
|
|
3124
3138
|
isLoading: !1,
|
|
3125
3139
|
error: w
|
|
3126
|
-
})),
|
|
3127
|
-
})) :
|
|
3128
|
-
|
|
3140
|
+
})), o.onError && o.onError(w, y);
|
|
3141
|
+
})) : a && a(E.dataSource), () => {
|
|
3142
|
+
l && (A(E.dataSource), l(E.dataSource));
|
|
3129
3143
|
};
|
|
3130
3144
|
} catch (y) {
|
|
3131
3145
|
const w = G(y);
|
|
@@ -3134,7 +3148,7 @@ function Vt(n) {
|
|
|
3134
3148
|
isError: !0,
|
|
3135
3149
|
isLoading: !1,
|
|
3136
3150
|
error: w
|
|
3137
|
-
})),
|
|
3151
|
+
})), o.onError && o.onError(w, y);
|
|
3138
3152
|
}
|
|
3139
3153
|
}, [
|
|
3140
3154
|
E.name,
|
|
@@ -3160,43 +3174,43 @@ function Vt(n) {
|
|
|
3160
3174
|
clearError: B
|
|
3161
3175
|
};
|
|
3162
3176
|
}
|
|
3163
|
-
function et(
|
|
3164
|
-
return
|
|
3177
|
+
function et(o) {
|
|
3178
|
+
return o.totalElements || o.totalElements === 0 ? o.totalElements : o.page.totalElements;
|
|
3165
3179
|
}
|
|
3166
|
-
function tt(
|
|
3167
|
-
return
|
|
3180
|
+
function tt(o) {
|
|
3181
|
+
return o.totalPages || o.totalPages === 0 ? o.totalPages : o.page.totalPages;
|
|
3168
3182
|
}
|
|
3169
|
-
function rt(
|
|
3170
|
-
return
|
|
3183
|
+
function rt(o) {
|
|
3184
|
+
return o.pageable ? o.pageable.pageNumber : o.page.number;
|
|
3171
3185
|
}
|
|
3172
|
-
function
|
|
3186
|
+
function Vt(o) {
|
|
3173
3187
|
const {
|
|
3174
3188
|
name: e,
|
|
3175
3189
|
service: t,
|
|
3176
3190
|
filter: r,
|
|
3177
3191
|
sort: i,
|
|
3178
3192
|
transformData: s,
|
|
3179
|
-
onLoadComplete:
|
|
3180
|
-
onDestroy:
|
|
3181
|
-
filterData:
|
|
3193
|
+
onLoadComplete: n,
|
|
3194
|
+
onDestroy: a,
|
|
3195
|
+
filterData: l,
|
|
3182
3196
|
findAll: p,
|
|
3183
3197
|
findAllWithSort: C,
|
|
3184
3198
|
findAllWithFilter: W,
|
|
3185
|
-
findAllWithFilterAndSort:
|
|
3186
|
-
initialDataSource:
|
|
3187
|
-
pageSize:
|
|
3199
|
+
findAllWithFilterAndSort: z,
|
|
3200
|
+
initialDataSource: L,
|
|
3201
|
+
pageSize: P = 50,
|
|
3188
3202
|
currentPage: N = 0,
|
|
3189
|
-
loadOnStart:
|
|
3203
|
+
loadOnStart: c = !0,
|
|
3190
3204
|
store: f,
|
|
3191
3205
|
validator: b
|
|
3192
|
-
} =
|
|
3206
|
+
} = o, T = () => !!(f && f.existsValue(e) || L), K = () => f && f.existsValue(e) ? f.getValue(e) : L || new Je(t, e, {
|
|
3193
3207
|
records: [],
|
|
3194
3208
|
grandTotalRecords: 0,
|
|
3195
3209
|
currentPage: N,
|
|
3196
3210
|
totalPages: 0,
|
|
3197
|
-
pageSize:
|
|
3211
|
+
pageSize: P,
|
|
3198
3212
|
validator: b
|
|
3199
|
-
}), [m, h] =
|
|
3213
|
+
}), [m, h] = V({
|
|
3200
3214
|
dataSource: K(),
|
|
3201
3215
|
isLoading: !1,
|
|
3202
3216
|
isError: !1,
|
|
@@ -3205,11 +3219,11 @@ function Tt(n) {
|
|
|
3205
3219
|
filter: r,
|
|
3206
3220
|
sort: i,
|
|
3207
3221
|
currentPage: N,
|
|
3208
|
-
pageSize:
|
|
3209
|
-
loadDataCount:
|
|
3222
|
+
pageSize: P,
|
|
3223
|
+
loadDataCount: T() ? 1 : 0
|
|
3210
3224
|
}), Y = async (D, S, A, B, y, w, x, $) => {
|
|
3211
3225
|
let v;
|
|
3212
|
-
|
|
3226
|
+
z && B && y && y.length > 0 ? v = await z(B, S, A, y) : W && B ? v = await W(B, S, A) : C && y && y.length > 0 ? v = await C(S, A, y) : p ? v = await p(S, A) : B && y && y.length > 0 ? v = await t.findAllWithFilterAndSort(B, S, A, y) : B ? v = await t.findAllWithFilter(B, S, A) : y && y.length > 0 ? v = await t.findAllWithSort(S, A, y) : v = await t.findAll(S, A), l && (v = l(v)), s && (v = s(v)), h((J) => {
|
|
3213
3227
|
const te = {
|
|
3214
3228
|
records: v.content,
|
|
3215
3229
|
grandTotalRecords: et(v),
|
|
@@ -3234,9 +3248,9 @@ function Tt(n) {
|
|
|
3234
3248
|
error: "",
|
|
3235
3249
|
loadDataCount: J.loadDataCount + 1
|
|
3236
3250
|
};
|
|
3237
|
-
}), f && f.setValue(e, m.dataSource),
|
|
3251
|
+
}), f && f.setValue(e, m.dataSource), n && n(m.dataSource);
|
|
3238
3252
|
}, Z = (D) => {
|
|
3239
|
-
if (D.type ===
|
|
3253
|
+
if (D.type === d.refreshData) {
|
|
3240
3254
|
const S = D.options;
|
|
3241
3255
|
try {
|
|
3242
3256
|
h((A) => ({
|
|
@@ -3261,7 +3275,7 @@ function Tt(n) {
|
|
|
3261
3275
|
isError: !0,
|
|
3262
3276
|
isLoading: !1,
|
|
3263
3277
|
error: B
|
|
3264
|
-
})),
|
|
3278
|
+
})), o.onError && o.onError(B, A);
|
|
3265
3279
|
});
|
|
3266
3280
|
} catch (A) {
|
|
3267
3281
|
const B = G(A);
|
|
@@ -3270,7 +3284,7 @@ function Tt(n) {
|
|
|
3270
3284
|
isError: !0,
|
|
3271
3285
|
isLoading: !1,
|
|
3272
3286
|
error: B
|
|
3273
|
-
})),
|
|
3287
|
+
})), o.onError && o.onError(B, A);
|
|
3274
3288
|
}
|
|
3275
3289
|
}
|
|
3276
3290
|
}, E = (D) => {
|
|
@@ -3280,10 +3294,10 @@ function Tt(n) {
|
|
|
3280
3294
|
};
|
|
3281
3295
|
q(() => {
|
|
3282
3296
|
try {
|
|
3283
|
-
return E(m.dataSource),
|
|
3297
|
+
return E(m.dataSource), c && m.loadDataCount === 0 && (h((D) => ({ ...D, isLoading: !0 })), Y(
|
|
3284
3298
|
m.name,
|
|
3285
3299
|
N,
|
|
3286
|
-
|
|
3300
|
+
P,
|
|
3287
3301
|
m.filter,
|
|
3288
3302
|
m.sort
|
|
3289
3303
|
).catch((D) => {
|
|
@@ -3293,9 +3307,9 @@ function Tt(n) {
|
|
|
3293
3307
|
isError: !0,
|
|
3294
3308
|
isLoading: !1,
|
|
3295
3309
|
error: S
|
|
3296
|
-
})),
|
|
3310
|
+
})), o.onError && o.onError(S, D);
|
|
3297
3311
|
})), () => {
|
|
3298
|
-
|
|
3312
|
+
a && (j(m.dataSource), a(m.dataSource));
|
|
3299
3313
|
};
|
|
3300
3314
|
} catch (D) {
|
|
3301
3315
|
const S = G(D);
|
|
@@ -3304,7 +3318,7 @@ function Tt(n) {
|
|
|
3304
3318
|
isError: !0,
|
|
3305
3319
|
isLoading: !1,
|
|
3306
3320
|
error: S
|
|
3307
|
-
})),
|
|
3321
|
+
})), o.onError && o.onError(S, D);
|
|
3308
3322
|
}
|
|
3309
3323
|
}, [
|
|
3310
3324
|
m.name,
|
|
@@ -3329,101 +3343,101 @@ function Tt(n) {
|
|
|
3329
3343
|
clearError: ee
|
|
3330
3344
|
};
|
|
3331
3345
|
}
|
|
3332
|
-
function Ot(
|
|
3333
|
-
return
|
|
3346
|
+
function Ot(o) {
|
|
3347
|
+
return ze((e) => e.get(o));
|
|
3334
3348
|
}
|
|
3335
|
-
function
|
|
3349
|
+
function Lt(o) {
|
|
3336
3350
|
q(() => {
|
|
3337
|
-
|
|
3351
|
+
o();
|
|
3338
3352
|
}, []);
|
|
3339
3353
|
}
|
|
3340
|
-
function
|
|
3354
|
+
function Pt(o, e) {
|
|
3341
3355
|
q(() => {
|
|
3342
|
-
|
|
3356
|
+
o();
|
|
3343
3357
|
}, e);
|
|
3344
3358
|
}
|
|
3345
|
-
function Bt(
|
|
3359
|
+
function Bt(o) {
|
|
3346
3360
|
q(() => () => {
|
|
3347
|
-
|
|
3361
|
+
o();
|
|
3348
3362
|
}, []);
|
|
3349
3363
|
}
|
|
3350
3364
|
function $t() {
|
|
3351
|
-
const [,
|
|
3352
|
-
return
|
|
3353
|
-
|
|
3365
|
+
const [, o] = V(0);
|
|
3366
|
+
return u(() => {
|
|
3367
|
+
o((t) => t + 1);
|
|
3354
3368
|
}, []);
|
|
3355
3369
|
}
|
|
3356
|
-
const it = (
|
|
3370
|
+
const it = (o) => (o + 1) % 1e6;
|
|
3357
3371
|
function st() {
|
|
3358
|
-
const [,
|
|
3359
|
-
return
|
|
3372
|
+
const [, o] = Me(it, 0);
|
|
3373
|
+
return o;
|
|
3360
3374
|
}
|
|
3361
3375
|
function Nt() {
|
|
3362
3376
|
return st();
|
|
3363
3377
|
}
|
|
3364
|
-
const nt = je((
|
|
3378
|
+
const nt = je((o, e) => ({
|
|
3365
3379
|
values: /* @__PURE__ */ new Map(),
|
|
3366
|
-
setValue: (t, r) =>
|
|
3380
|
+
setValue: (t, r) => o((i) => {
|
|
3367
3381
|
const s = new Map(i.values);
|
|
3368
3382
|
return s.set(t, r), { values: s };
|
|
3369
3383
|
}),
|
|
3370
3384
|
getValue: (t) => e().values.get(t),
|
|
3371
3385
|
existsValue: (t) => e().values.has(t),
|
|
3372
|
-
clearValue: (t) =>
|
|
3386
|
+
clearValue: (t) => o((r) => {
|
|
3373
3387
|
const i = new Map(r.values);
|
|
3374
3388
|
return i.delete(t), { values: i };
|
|
3375
3389
|
}),
|
|
3376
|
-
clearAllValues: () =>
|
|
3377
|
-
reset: () =>
|
|
3378
|
-
})), ot =
|
|
3390
|
+
clearAllValues: () => o((t) => ({ values: /* @__PURE__ */ new Map() })),
|
|
3391
|
+
reset: () => o((t) => ({ values: /* @__PURE__ */ new Map() }))
|
|
3392
|
+
})), ot = _e(nt), Ht = (o = "default") => {
|
|
3379
3393
|
const e = ot();
|
|
3380
3394
|
return { setValue: (p, C) => {
|
|
3381
|
-
e.setValue(`${
|
|
3382
|
-
}, getValue: (p) => e.getValue(`${
|
|
3383
|
-
e.clearValue(`${
|
|
3384
|
-
}, existsValue: (p) => e.existsValue(`${
|
|
3395
|
+
e.setValue(`${o}.${p}`, C);
|
|
3396
|
+
}, getValue: (p) => e.getValue(`${o}.${p}`), clearValue: (p) => {
|
|
3397
|
+
e.clearValue(`${o}.${p}`);
|
|
3398
|
+
}, existsValue: (p) => e.existsValue(`${o}.${p}`), clearAllValues: () => {
|
|
3385
3399
|
for (const [p, C] of e.values.entries())
|
|
3386
|
-
p.startsWith(`${
|
|
3400
|
+
p.startsWith(`${o}.`) && e.clearValue(p);
|
|
3387
3401
|
}, reset: () => {
|
|
3388
3402
|
e.clearAllValues();
|
|
3389
3403
|
}, values: e.values };
|
|
3390
3404
|
};
|
|
3391
|
-
function Wt(
|
|
3405
|
+
function Wt(o, e, t = window) {
|
|
3392
3406
|
const r = ce(e);
|
|
3393
3407
|
q(() => {
|
|
3394
3408
|
r.current = e;
|
|
3395
3409
|
}, [e]), q(
|
|
3396
3410
|
() => {
|
|
3397
3411
|
if (t && t.addEventListener && r.current) {
|
|
3398
|
-
const s = (
|
|
3399
|
-
return t.addEventListener(
|
|
3400
|
-
t.removeEventListener(
|
|
3412
|
+
const s = (n) => r.current(n);
|
|
3413
|
+
return t.addEventListener(o, s), () => {
|
|
3414
|
+
t.removeEventListener(o, s);
|
|
3401
3415
|
};
|
|
3402
3416
|
}
|
|
3403
3417
|
},
|
|
3404
|
-
[
|
|
3418
|
+
[o, t]
|
|
3405
3419
|
// Executa novamente se eventName ou elemento mudar
|
|
3406
3420
|
);
|
|
3407
3421
|
}
|
|
3408
3422
|
export {
|
|
3409
3423
|
jt as ADVANCED,
|
|
3410
|
-
|
|
3424
|
+
_t as ARCHBASE_IOC_API_TYPE,
|
|
3411
3425
|
xt as ARCHBASE_QUERY_DEFAULTS,
|
|
3412
3426
|
be as ArchbaseAxiosRemoteApiClient,
|
|
3413
3427
|
ye as ArchbaseDataSource,
|
|
3414
|
-
|
|
3428
|
+
k as ArchbaseDataSourceV2,
|
|
3415
3429
|
Ge as ArchbaseLocalFilterDataSource,
|
|
3416
3430
|
At as ArchbaseQueryUtils,
|
|
3417
3431
|
Ke as ArchbaseRemoteApiService,
|
|
3418
3432
|
Ae as ArchbaseRemoteDataSource,
|
|
3419
3433
|
Qe as ArchbaseRemoteDataSourceV2,
|
|
3420
3434
|
Je as ArchbaseRemoteFilterDataSource,
|
|
3421
|
-
|
|
3435
|
+
d as DataSourceEventNames,
|
|
3422
3436
|
le as DefaultPage,
|
|
3423
|
-
|
|
3424
|
-
|
|
3437
|
+
kt as FILTER_TYPE,
|
|
3438
|
+
Ue as LocalFilter,
|
|
3425
3439
|
vt as MigrationValidation,
|
|
3426
|
-
|
|
3440
|
+
Ut as NORMAL,
|
|
3427
3441
|
Gt as QUICK,
|
|
3428
3442
|
qe as RemoteFilter,
|
|
3429
3443
|
It as USAGE_EXAMPLE,
|
|
@@ -3433,17 +3447,17 @@ export {
|
|
|
3433
3447
|
xe as useArchbaseDataSourceV2,
|
|
3434
3448
|
Et as useArchbaseDataSourceV2Editor,
|
|
3435
3449
|
wt as useArchbaseDataSourceV2ReadOnly,
|
|
3436
|
-
|
|
3437
|
-
|
|
3450
|
+
Lt as useArchbaseDidMount,
|
|
3451
|
+
Pt as useArchbaseDidUpdate,
|
|
3438
3452
|
Wt as useArchbaseEventListener,
|
|
3439
3453
|
$t as useArchbaseForceRerender,
|
|
3440
3454
|
Nt as useArchbaseForceUpdate,
|
|
3441
3455
|
Dt as useArchbaseLocalFilterDataSource,
|
|
3442
|
-
|
|
3456
|
+
Tt as useArchbaseRemoteDataSource,
|
|
3443
3457
|
Ce as useArchbaseRemoteDataSourceV2,
|
|
3444
3458
|
Ft as useArchbaseRemoteDataSourceV2Editor,
|
|
3445
3459
|
St as useArchbaseRemoteDataSourceV2ReadOnly,
|
|
3446
|
-
|
|
3460
|
+
Vt as useArchbaseRemoteFilterDataSource,
|
|
3447
3461
|
Ot as useArchbaseRemoteServiceApi,
|
|
3448
3462
|
Ht as useArchbaseStore,
|
|
3449
3463
|
yt as useArchbaseV1V2Compatibility,
|