@archbase/data 4.0.2 → 4.0.3
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
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { isDate as ve, parseISO as Ie } from "date-fns";
|
|
2
|
-
import { EventEmitter as
|
|
3
|
-
import { uniqueId as
|
|
4
|
-
import { archbaseI18next as
|
|
5
|
-
import { ADVANCED as
|
|
6
|
-
import { useState as
|
|
2
|
+
import { EventEmitter as Be } from "events";
|
|
3
|
+
import { uniqueId as $e, cloneDeep as Ne } from "lodash";
|
|
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 kt, FILTER_TYPE as Ut, NORMAL as _t, QUICK as Gt, useArchbaseBool as qt } from "@archbase/core";
|
|
6
|
+
import { useState as T, useCallback as l, useRef as ce, useMemo as z, useEffect as q, useReducer as ze } from "react";
|
|
7
7
|
import { produce as Q } from "immer";
|
|
8
8
|
import "reflect-metadata";
|
|
9
|
-
import
|
|
9
|
+
import X from "axios";
|
|
10
10
|
import * as ne from "inversify";
|
|
11
|
-
import { useContainer as
|
|
12
|
-
import { create as
|
|
13
|
-
import { createTrackedSelector as
|
|
11
|
+
import { useContainer as Me } from "inversify-react";
|
|
12
|
+
import { create as je } from "zustand";
|
|
13
|
+
import { createTrackedSelector as ke } from "react-tracked";
|
|
14
14
|
var a = /* @__PURE__ */ ((n) => (n[n.dataChanged = 0] = "dataChanged", n[n.recordChanged = 1] = "recordChanged", n[n.refreshData = 2] = "refreshData", n[n.fieldChanged = 3] = "fieldChanged", n[n.beforeClose = 4] = "beforeClose", n[n.afterClose = 5] = "afterClose", n[n.beforeOpen = 6] = "beforeOpen", n[n.afterOpen = 7] = "afterOpen", n[n.beforeAppend = 8] = "beforeAppend", n[n.afterAppend = 9] = "afterAppend", n[n.beforeRemove = 10] = "beforeRemove", n[n.afterRemove = 11] = "afterRemove", n[n.beforeInsert = 12] = "beforeInsert", n[n.afterInsert = 13] = "afterInsert", n[n.beforeEdit = 14] = "beforeEdit", n[n.afterEdit = 15] = "afterEdit", n[n.beforeSave = 16] = "beforeSave", n[n.afterSave = 17] = "afterSave", n[n.beforeCancel = 18] = "beforeCancel", n[n.afterCancel = 19] = "afterCancel", n[n.afterScroll = 20] = "afterScroll", n[n.onError = 21] = "onError", n[n.onFieldError = 22] = "onFieldError", n))(a || {});
|
|
15
|
-
class
|
|
15
|
+
class Ue {
|
|
16
16
|
eventEmitter;
|
|
17
17
|
listenersDisable = !1;
|
|
18
18
|
constructor() {
|
|
19
|
-
this.eventEmitter = new
|
|
19
|
+
this.eventEmitter = new Be();
|
|
20
20
|
}
|
|
21
21
|
disabledAllListeners() {
|
|
22
22
|
return this.listenersDisable = !0, this;
|
|
@@ -79,14 +79,14 @@ 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 Ue(), 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 : [];
|
|
86
86
|
}
|
|
87
87
|
validateDataSourceActive(e) {
|
|
88
88
|
if (!this.isActive()) {
|
|
89
|
-
const t =
|
|
89
|
+
const t = R.t("archbase:operationNotAllowed", { dataSourceName: this.name, operation: e });
|
|
90
90
|
throw this.publishEventError(t, {}), new g(t);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -99,7 +99,7 @@ class ye {
|
|
|
99
99
|
*/
|
|
100
100
|
clear() {
|
|
101
101
|
if (!this.isActive()) {
|
|
102
|
-
const e =
|
|
102
|
+
const e = R.t("archbase:operationNotAllowed", { dataSourceName: this.name, operation: "clear" });
|
|
103
103
|
throw this.publishEventError(e, {}), new g(e);
|
|
104
104
|
}
|
|
105
105
|
this.emitter.emit("beforeClose"), this.emit({
|
|
@@ -151,7 +151,7 @@ class ye {
|
|
|
151
151
|
}
|
|
152
152
|
goToRecord(e) {
|
|
153
153
|
if (this.validateDataSourceActive("goToRecord"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
154
|
-
const t =
|
|
154
|
+
const t = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
155
155
|
throw this.publishEventError(t, {}), new g(t);
|
|
156
156
|
}
|
|
157
157
|
e <= this.getTotalRecords() - 1 && (this.currentRecordIndex = e, this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -190,7 +190,7 @@ class ye {
|
|
|
190
190
|
}
|
|
191
191
|
append(e) {
|
|
192
192
|
if (this.validateDataSourceActive("append"), this.inserting || this.editing) {
|
|
193
|
-
const t =
|
|
193
|
+
const t = R.t("archbase:insertRecordIsNotAllowed", { dataSourceName: this.name });
|
|
194
194
|
throw this.publishEventError(t, {}), new g(t);
|
|
195
195
|
}
|
|
196
196
|
return this.emitter.emit("beforeAppend", e), this.emit({ type: 8, record: e }), this.records.push(e), this.filteredRecords = this.applyFilters(), this.grandTotalRecords++, this.filteredRecords.forEach((t, r) => {
|
|
@@ -209,7 +209,7 @@ class ye {
|
|
|
209
209
|
}
|
|
210
210
|
insert(e) {
|
|
211
211
|
if (this.validateDataSourceActive("insert"), this.inserting || this.editing) {
|
|
212
|
-
const r =
|
|
212
|
+
const r = R.t("archbase:insertRecordIsNotAllowed", { dataSourceName: this.name });
|
|
213
213
|
throw this.publishEventError(r, {}), new g(r);
|
|
214
214
|
}
|
|
215
215
|
this.emitter.emit("beforeInsert"), this.emit({
|
|
@@ -228,26 +228,26 @@ class ye {
|
|
|
228
228
|
}
|
|
229
229
|
edit() {
|
|
230
230
|
if (this.validateDataSourceActive("edit"), this.inserting || this.editing) {
|
|
231
|
-
const e =
|
|
231
|
+
const e = R.t("archbase:editRecordIsNotAllowed", { dataSourceName: this.name });
|
|
232
232
|
throw this.publishEventError(e, {}), new g(e);
|
|
233
233
|
}
|
|
234
234
|
if (this.isEmpty() || !this.currentRecord) {
|
|
235
|
-
const e =
|
|
235
|
+
const e = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
236
236
|
throw this.publishEventError(e, {}), new g(e);
|
|
237
237
|
}
|
|
238
238
|
if (this.isBOF()) {
|
|
239
|
-
const e =
|
|
239
|
+
const e = R.t("archbase:BOFDataSource", { dataSourceName: this.name });
|
|
240
240
|
throw this.publishEventError(e, {}), new g(e);
|
|
241
241
|
}
|
|
242
242
|
if (this.isEOF()) {
|
|
243
|
-
const e =
|
|
243
|
+
const e = R.t("archbase:EOFDataSource", { dataSourceName: this.name });
|
|
244
244
|
throw this.publishEventError(e, {}), new g(e);
|
|
245
245
|
}
|
|
246
246
|
return this.emitter.emit("beforeEdit", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
247
247
|
type: 14,
|
|
248
248
|
record: this.currentRecord,
|
|
249
249
|
index: this.getCurrentIndex()
|
|
250
|
-
}), this.editing = !0, this.currentRecord =
|
|
250
|
+
}), this.editing = !0, this.currentRecord = Ne(this.currentRecord), this.emitter.emit("afterEdit", this.currentRecord, this.getCurrentIndex()), this.emit({
|
|
251
251
|
type: 15,
|
|
252
252
|
record: this.currentRecord,
|
|
253
253
|
index: this.getCurrentIndex()
|
|
@@ -255,19 +255,19 @@ class ye {
|
|
|
255
255
|
}
|
|
256
256
|
async remove(e) {
|
|
257
257
|
if (this.validateDataSourceActive("remove"), this.inserting || this.editing) {
|
|
258
|
-
const s =
|
|
258
|
+
const s = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
|
|
259
259
|
throw this.publishEventError(s, {}), new g(s);
|
|
260
260
|
}
|
|
261
261
|
if (this.isEmpty() || !this.currentRecord) {
|
|
262
|
-
const s =
|
|
262
|
+
const s = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
263
263
|
throw this.publishEventError(s, {}), new g(s);
|
|
264
264
|
}
|
|
265
265
|
if (this.isBOF()) {
|
|
266
|
-
const s =
|
|
266
|
+
const s = R.t("archbase:BOFDataSource", { dataSourceName: this.name });
|
|
267
267
|
throw this.publishEventError(s, {}), new g(s);
|
|
268
268
|
}
|
|
269
269
|
if (this.isEOF()) {
|
|
270
|
-
const s =
|
|
270
|
+
const s = R.t("archbase:EOFDataSource", { dataSourceName: this.name });
|
|
271
271
|
throw this.publishEventError(s, {}), new g(s);
|
|
272
272
|
}
|
|
273
273
|
this.emitter.emit("beforeRemove", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
@@ -306,7 +306,7 @@ class ye {
|
|
|
306
306
|
publishEventErrors = (e) => {
|
|
307
307
|
e.forEach((t) => {
|
|
308
308
|
if (t.fieldName) {
|
|
309
|
-
const r =
|
|
309
|
+
const r = R.t(t.errorMessage, { keySeparator: !1 });
|
|
310
310
|
this.emitter.emit("onFieldError", t.fieldName, r), this.emit({
|
|
311
311
|
type: 22,
|
|
312
312
|
fieldName: t.fieldName,
|
|
@@ -314,7 +314,7 @@ class ye {
|
|
|
314
314
|
originalError: t
|
|
315
315
|
});
|
|
316
316
|
} else
|
|
317
|
-
this.publishEventError(
|
|
317
|
+
this.publishEventError(R.t(t.errorMessage, { keySeparator: !1 }), t);
|
|
318
318
|
});
|
|
319
319
|
};
|
|
320
320
|
publishEventError = (e, t) => {
|
|
@@ -329,7 +329,7 @@ class ye {
|
|
|
329
329
|
const e = this.validator.validateEntity(this.currentRecord);
|
|
330
330
|
if (e && e.length > 0)
|
|
331
331
|
if (this.publishEventErrors(e), e[0].fieldName) {
|
|
332
|
-
const t =
|
|
332
|
+
const t = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
333
333
|
throw new g(t);
|
|
334
334
|
} else
|
|
335
335
|
throw new g(e[0].errorMessage);
|
|
@@ -338,11 +338,11 @@ class ye {
|
|
|
338
338
|
}
|
|
339
339
|
async save(e) {
|
|
340
340
|
if (this.validateDataSourceActive("save"), !this.inserting && !this.editing) {
|
|
341
|
-
const r =
|
|
341
|
+
const r = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
|
|
342
342
|
throw this.publishEventError(r, {}), new g(r);
|
|
343
343
|
}
|
|
344
344
|
if (!this.currentRecord) {
|
|
345
|
-
const r =
|
|
345
|
+
const r = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
|
|
346
346
|
throw this.publishEventError(r, {}), new g(r);
|
|
347
347
|
}
|
|
348
348
|
if (this.emitter.emit("beforeSave", this.currentRecord, this.getCurrentIndex()), this.emit({
|
|
@@ -353,7 +353,7 @@ class ye {
|
|
|
353
353
|
const r = this.validator.validateEntity(this.currentRecord);
|
|
354
354
|
if (r && r.length > 0)
|
|
355
355
|
if (this.publishEventErrors(r), r[0].fieldName) {
|
|
356
|
-
const i =
|
|
356
|
+
const i = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
357
357
|
throw new g(i);
|
|
358
358
|
} else
|
|
359
359
|
throw new g(r[0].errorMessage);
|
|
@@ -371,7 +371,7 @@ class ye {
|
|
|
371
371
|
}
|
|
372
372
|
cancel() {
|
|
373
373
|
if (this.validateDataSourceActive("cancel"), !this.inserting && !this.editing) {
|
|
374
|
-
const e =
|
|
374
|
+
const e = R.t("archbase:notAllowCancelRecord", { dataSourceName: this.name });
|
|
375
375
|
throw this.publishEventError(e, {}), new g(e);
|
|
376
376
|
}
|
|
377
377
|
return this.emitter.emit("beforeCancel", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
@@ -401,7 +401,7 @@ class ye {
|
|
|
401
401
|
}
|
|
402
402
|
getFieldValue(e, t = "") {
|
|
403
403
|
if (this.validateDataSourceActive("getFieldValue"), !e) {
|
|
404
|
-
const s =
|
|
404
|
+
const s = R.t("archbase:invalidFieldName", { dataSourceName: this.name });
|
|
405
405
|
throw this.publishEventError(s, {}), new g(s);
|
|
406
406
|
}
|
|
407
407
|
if (this.isEmpty() || this.isBOF() || this.isEOF() && !this.inserting)
|
|
@@ -422,7 +422,7 @@ 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 o =
|
|
425
|
+
const o = R.t("archbase:recordNotBeingEdited", { dataSourceName: this.name });
|
|
426
426
|
throw this.publishEventError(o, {}), new g(o);
|
|
427
427
|
}
|
|
428
428
|
let r = t;
|
|
@@ -489,7 +489,7 @@ class ye {
|
|
|
489
489
|
}
|
|
490
490
|
next() {
|
|
491
491
|
if (this.validateDataSourceActive("next"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
492
|
-
const e =
|
|
492
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
493
493
|
throw this.publishEventError(e, {}), new g(e);
|
|
494
494
|
}
|
|
495
495
|
return this.currentRecordIndex + 1 > this.getTotalRecords() - 1 ? (this.currentRecordIndex++, this.currentRecord = void 0) : (this.currentRecordIndex++, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -499,7 +499,7 @@ class ye {
|
|
|
499
499
|
}
|
|
500
500
|
prior() {
|
|
501
501
|
if (this.validateDataSourceActive("prior"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
502
|
-
const e =
|
|
502
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
503
503
|
throw this.publishEventError(e, {}), new g(e);
|
|
504
504
|
}
|
|
505
505
|
return this.currentRecordIndex - 1 < 0 ? (this.currentRecordIndex = -1, this.currentRecord = void 0) : (this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -509,7 +509,7 @@ class ye {
|
|
|
509
509
|
}
|
|
510
510
|
first() {
|
|
511
511
|
if (this.validateDataSourceActive("first"), this.inserting || this.editing) {
|
|
512
|
-
const e =
|
|
512
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
513
513
|
throw this.publishEventError(e, {}), new g(e);
|
|
514
514
|
}
|
|
515
515
|
return this.getTotalRecords() === 0 ? (this.currentRecordIndex = -1, this.currentRecord = void 0) : (this.currentRecordIndex = 0, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -519,7 +519,7 @@ class ye {
|
|
|
519
519
|
}
|
|
520
520
|
last() {
|
|
521
521
|
if (this.validateDataSourceActive("last"), this.inserting || this.editing) {
|
|
522
|
-
const e =
|
|
522
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
523
523
|
throw this.publishEventError(e, {}), new g(e);
|
|
524
524
|
}
|
|
525
525
|
return this.getTotalRecords() === 0 ? (this.currentRecordIndex = -1, this.currentRecord = void 0) : (this.currentRecordIndex = this.getTotalRecords() - 1, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -531,7 +531,7 @@ class ye {
|
|
|
531
531
|
if (e === this.currentRecordIndex)
|
|
532
532
|
return this.currentRecord;
|
|
533
533
|
if (this.validateDataSourceActive("gotoRecord"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
534
|
-
const t =
|
|
534
|
+
const t = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
535
535
|
throw this.publishEventError(t, {}), new g(t);
|
|
536
536
|
}
|
|
537
537
|
if (e < 0 || e >= this.filteredRecords.length) {
|
|
@@ -545,7 +545,7 @@ class ye {
|
|
|
545
545
|
}
|
|
546
546
|
gotoRecordByData(e) {
|
|
547
547
|
if (this.validateDataSourceActive("gotoRecordByData"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
548
|
-
const r =
|
|
548
|
+
const r = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
549
549
|
throw this.publishEventError(r, {}), new g(r);
|
|
550
550
|
}
|
|
551
551
|
if (this.isEmpty())
|
|
@@ -565,7 +565,7 @@ class ye {
|
|
|
565
565
|
}
|
|
566
566
|
locate(e) {
|
|
567
567
|
if (!this.isBrowsing()) {
|
|
568
|
-
const i =
|
|
568
|
+
const i = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
569
569
|
throw this.publishEventError(i, {}), new g(i);
|
|
570
570
|
}
|
|
571
571
|
if (this.isEmpty())
|
|
@@ -579,7 +579,7 @@ class ye {
|
|
|
579
579
|
}
|
|
580
580
|
locateByFilter(e) {
|
|
581
581
|
if (this.validateDataSourceActive("locate"), this.inserting || this.editing) {
|
|
582
|
-
const r =
|
|
582
|
+
const r = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
583
583
|
throw this.publishEventError(r, {}), new g(r);
|
|
584
584
|
}
|
|
585
585
|
if (this.isEmpty())
|
|
@@ -613,8 +613,8 @@ class ye {
|
|
|
613
613
|
i = o === 0 ? s : `${i}.${s}`;
|
|
614
614
|
const c = this.fieldEventListeners[`field:${i}`];
|
|
615
615
|
if (c) {
|
|
616
|
-
const
|
|
617
|
-
|
|
616
|
+
const u = c.indexOf(t);
|
|
617
|
+
u !== -1 && c.splice(u, 1);
|
|
618
618
|
}
|
|
619
619
|
}), this;
|
|
620
620
|
}
|
|
@@ -624,7 +624,7 @@ class ye {
|
|
|
624
624
|
for (const o of i) {
|
|
625
625
|
s = s ? `${s}.${o}` : o;
|
|
626
626
|
const c = this.fieldEventListeners[`field:${s}`];
|
|
627
|
-
c && c.forEach((
|
|
627
|
+
c && c.forEach((u) => u(s, t, r));
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
/**
|
|
@@ -648,11 +648,11 @@ class Ae extends ye {
|
|
|
648
648
|
}
|
|
649
649
|
async save(e) {
|
|
650
650
|
if (this.validateDataSourceActive("save"), !this.inserting && !this.editing) {
|
|
651
|
-
const t =
|
|
651
|
+
const t = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
|
|
652
652
|
throw this.publishEventError(t, {}), new g(t);
|
|
653
653
|
}
|
|
654
654
|
if (!this.currentRecord) {
|
|
655
|
-
const t =
|
|
655
|
+
const t = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
|
|
656
656
|
throw this.publishEventError(t, {}), new g(t);
|
|
657
657
|
}
|
|
658
658
|
if (this.emitter.emit("beforeSave", this.currentRecord), this.emit({
|
|
@@ -663,7 +663,7 @@ class Ae extends ye {
|
|
|
663
663
|
const t = this.validator.validateEntity(this.currentRecord);
|
|
664
664
|
if (t && t.length > 0)
|
|
665
665
|
if (this.publishEventErrors(t), t[0].fieldName) {
|
|
666
|
-
const r =
|
|
666
|
+
const r = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
667
667
|
throw new g(r);
|
|
668
668
|
} else
|
|
669
669
|
throw new g(t[0].errorMessage);
|
|
@@ -681,7 +681,7 @@ class Ae extends ye {
|
|
|
681
681
|
} catch (t) {
|
|
682
682
|
t.response && t.response.data && t.response.data.apierror && t.response.data.apierror.subErrors && t.response.data.apierror.subErrors.forEach((i) => {
|
|
683
683
|
if (i.field) {
|
|
684
|
-
const s =
|
|
684
|
+
const s = R.t(i.message, { defaultValue: i.message });
|
|
685
685
|
this.emitter.emit("onFieldError", i.field, s), this.emit({
|
|
686
686
|
type: a.onFieldError,
|
|
687
687
|
fieldName: i.field,
|
|
@@ -690,7 +690,7 @@ class Ae extends ye {
|
|
|
690
690
|
});
|
|
691
691
|
}
|
|
692
692
|
});
|
|
693
|
-
const r =
|
|
693
|
+
const r = G(t);
|
|
694
694
|
throw this.emitter.emit("onError", r, t), this.emit({
|
|
695
695
|
type: a.onError,
|
|
696
696
|
error: r,
|
|
@@ -701,21 +701,21 @@ class Ae extends ye {
|
|
|
701
701
|
}
|
|
702
702
|
async remove(e) {
|
|
703
703
|
if (this.validateDataSourceActive("remove"), this.inserting || this.editing) {
|
|
704
|
-
const t =
|
|
704
|
+
const t = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
|
|
705
705
|
throw this.publishEventError(t, {}), new g(
|
|
706
706
|
t
|
|
707
707
|
);
|
|
708
708
|
}
|
|
709
709
|
if (this.isEmpty() || !this.currentRecord) {
|
|
710
|
-
const t =
|
|
710
|
+
const t = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
711
711
|
throw this.publishEventError(t, {}), new g(t);
|
|
712
712
|
}
|
|
713
713
|
if (this.isBOF()) {
|
|
714
|
-
const t =
|
|
714
|
+
const t = R.t("archbase:BOFDataSource", { dataSourceName: this.name });
|
|
715
715
|
throw this.publishEventError(t, {}), new g(t);
|
|
716
716
|
}
|
|
717
717
|
if (this.isEOF()) {
|
|
718
|
-
const t =
|
|
718
|
+
const t = R.t("archbase:EOFDataSource", { dataSourceName: this.name });
|
|
719
719
|
throw this.publishEventError(t, {}), new g(t);
|
|
720
720
|
}
|
|
721
721
|
this.emitter.emit("beforeRemove", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
@@ -735,7 +735,7 @@ class Ae extends ye {
|
|
|
735
735
|
index: i
|
|
736
736
|
}), this.lastDataBrowsingOn = (/* @__PURE__ */ new Date()).getTime(), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), e && e(), r;
|
|
737
737
|
} catch (t) {
|
|
738
|
-
const r =
|
|
738
|
+
const r = G(t);
|
|
739
739
|
throw this.emitter.emit("onError", r, t), this.emit({
|
|
740
740
|
type: a.onError,
|
|
741
741
|
error: r,
|
|
@@ -770,7 +770,7 @@ class Ae extends ye {
|
|
|
770
770
|
return e && e.sort ? e.sort.quickFilterSort : this.defaultSortFields;
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
|
-
class
|
|
773
|
+
class _e {
|
|
774
774
|
id;
|
|
775
775
|
companyId;
|
|
776
776
|
filter;
|
|
@@ -788,7 +788,7 @@ class je {
|
|
|
788
788
|
Object.assign(this, e);
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
|
-
class
|
|
791
|
+
class Ge extends ye {
|
|
792
792
|
getFilterById(e) {
|
|
793
793
|
if (this.locate({ id: e }))
|
|
794
794
|
return this.convertCurrentRecordToFilter();
|
|
@@ -808,7 +808,7 @@ class ke extends ye {
|
|
|
808
808
|
}
|
|
809
809
|
async addNewFilter(e, t) {
|
|
810
810
|
this.insert(
|
|
811
|
-
new
|
|
811
|
+
new _e({
|
|
812
812
|
id: e.id,
|
|
813
813
|
name: e.name,
|
|
814
814
|
description: e.description,
|
|
@@ -856,7 +856,7 @@ class ke extends ye {
|
|
|
856
856
|
) : [];
|
|
857
857
|
}
|
|
858
858
|
}
|
|
859
|
-
class
|
|
859
|
+
class qe {
|
|
860
860
|
id;
|
|
861
861
|
companyId;
|
|
862
862
|
filter;
|
|
@@ -875,7 +875,7 @@ class Ue {
|
|
|
875
875
|
Object.assign(this, e);
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
class
|
|
878
|
+
class Je extends Ae {
|
|
879
879
|
getFilterById(e) {
|
|
880
880
|
if (this.locate({ id: e }))
|
|
881
881
|
return this.convertCurrentRecordToFilter();
|
|
@@ -895,7 +895,7 @@ class _e extends Ae {
|
|
|
895
895
|
}
|
|
896
896
|
async addNewFilter(e, t) {
|
|
897
897
|
this.insert(
|
|
898
|
-
new
|
|
898
|
+
new qe({
|
|
899
899
|
id: e.id,
|
|
900
900
|
name: e.name,
|
|
901
901
|
description: e.description,
|
|
@@ -946,19 +946,19 @@ class _e extends Ae {
|
|
|
946
946
|
) : [];
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
function
|
|
950
|
-
const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s, o] =
|
|
951
|
-
c((
|
|
952
|
-
}, []), [
|
|
953
|
-
let
|
|
954
|
-
e && t && (
|
|
955
|
-
}, [e, t, r, i]),
|
|
956
|
-
e && t && ((
|
|
957
|
-
}, [e, t,
|
|
958
|
-
i ? (C(
|
|
959
|
-
}, [e, t, i]), d =
|
|
960
|
-
const
|
|
961
|
-
|
|
949
|
+
function yt(n, e, t, r) {
|
|
950
|
+
const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s, o] = T(r), [, c] = T(0), u = l(() => {
|
|
951
|
+
c((f) => f + 1);
|
|
952
|
+
}, []), [p, C] = T(r), [W, M] = T(0), P = l(() => {
|
|
953
|
+
let f = r;
|
|
954
|
+
e && t && (f = e.getFieldValue(t), f == null && (f = r)), i ? (C(f), M((b) => b + 1)) : o(f);
|
|
955
|
+
}, [e, t, r, i]), L = l((f) => {
|
|
956
|
+
e && t && ((f.type === a.dataChanged || f.type === a.recordChanged || f.type === a.afterScroll || f.type === a.afterCancel || f.type === a.afterEdit) && (P(), i || u()), f.type === a.onFieldError && f.fieldName === t && console.warn(`[${n}] Field error:`, f.error));
|
|
957
|
+
}, [e, t, P, u, i, n]), N = l((f, b) => {
|
|
958
|
+
i ? (C(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f)) : (o(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f));
|
|
959
|
+
}, [e, t, i]), d = l(() => {
|
|
960
|
+
const f = pe(e);
|
|
961
|
+
He.trackV2Usage(n, f);
|
|
962
962
|
}, [n, e]);
|
|
963
963
|
return ce(() => {
|
|
964
964
|
process.env.NODE_ENV === "production" && d();
|
|
@@ -967,12 +967,12 @@ function mt(n, e, t, r) {
|
|
|
967
967
|
isDataSourceV2: i,
|
|
968
968
|
dataSourceVersion: pe(e),
|
|
969
969
|
// Estados
|
|
970
|
-
currentValue: i ?
|
|
971
|
-
v1State: { currentValue: s, setCurrentValue: o, forceUpdate:
|
|
972
|
-
v2State: { v2Value:
|
|
970
|
+
currentValue: i ? p : s,
|
|
971
|
+
v1State: { currentValue: s, setCurrentValue: o, forceUpdate: u },
|
|
972
|
+
v2State: { v2Value: p, setV2Value: C, v2ShouldUpdate: W },
|
|
973
973
|
// Funções
|
|
974
|
-
loadDataSourceFieldValue:
|
|
975
|
-
dataSourceEvent:
|
|
974
|
+
loadDataSourceFieldValue: P,
|
|
975
|
+
dataSourceEvent: L,
|
|
976
976
|
handleValueChange: N,
|
|
977
977
|
// Utilitários
|
|
978
978
|
isReadOnly: e ? e.isBrowsing() : !1,
|
|
@@ -980,7 +980,7 @@ function mt(n, e, t, r) {
|
|
|
980
980
|
trackUsage: d
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
|
-
const
|
|
983
|
+
const vt = {
|
|
984
984
|
/**
|
|
985
985
|
* Valida se o componente está seguindo o padrão corretamente
|
|
986
986
|
*/
|
|
@@ -997,7 +997,7 @@ const Rt = {
|
|
|
997
997
|
"getFieldValue",
|
|
998
998
|
"setFieldValue"
|
|
999
999
|
].every((r) => typeof e[r] == "function") ? !0 : (console.error(`[${n}] V1 DataSource missing required methods`), !1)
|
|
1000
|
-
},
|
|
1000
|
+
}, It = `
|
|
1001
1001
|
// Em qualquer componente que use DataSource:
|
|
1002
1002
|
|
|
1003
1003
|
import { useArchbaseV1V2Compatibility } from '../core/patterns/ArchbaseV1V2CompatibilityPattern';
|
|
@@ -1278,8 +1278,8 @@ class U {
|
|
|
1278
1278
|
this.records = Q(this.records, (o) => {
|
|
1279
1279
|
const c = o[this.currentIndex];
|
|
1280
1280
|
if (c) {
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1281
|
+
const u = this.getNestedValue(c, e);
|
|
1282
|
+
u[t] !== void 0 && r(u[t]);
|
|
1283
1283
|
}
|
|
1284
1284
|
}), this.notifyStateChange(s), this.emit({
|
|
1285
1285
|
type: a.fieldChanged,
|
|
@@ -1522,7 +1522,7 @@ class U {
|
|
|
1522
1522
|
return i;
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
|
-
class
|
|
1525
|
+
class Qe {
|
|
1526
1526
|
name;
|
|
1527
1527
|
label;
|
|
1528
1528
|
service;
|
|
@@ -1623,7 +1623,7 @@ class Ge {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
edit() {
|
|
1625
1625
|
if (this.validateDataSourceActive("edit"), this.isEmpty() || !this.getCurrentRecord()) {
|
|
1626
|
-
const e =
|
|
1626
|
+
const e = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
1627
1627
|
throw this.publishEventError(e, {}), new g(e);
|
|
1628
1628
|
}
|
|
1629
1629
|
this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
|
|
@@ -1663,11 +1663,11 @@ class Ge {
|
|
|
1663
1663
|
// =================== Remote CRUD Operations ===================
|
|
1664
1664
|
async save(e) {
|
|
1665
1665
|
if (this.validateDataSourceActive("save"), !this.isInserting() && !this.isEditing()) {
|
|
1666
|
-
const r =
|
|
1666
|
+
const r = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
|
|
1667
1667
|
throw this.publishEventError(r, {}), new g(r);
|
|
1668
1668
|
}
|
|
1669
1669
|
if (!this.getCurrentRecord()) {
|
|
1670
|
-
const r =
|
|
1670
|
+
const r = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
|
|
1671
1671
|
throw this.publishEventError(r, {}), new g(r);
|
|
1672
1672
|
}
|
|
1673
1673
|
const t = this.getCurrentRecord();
|
|
@@ -1679,7 +1679,7 @@ class Ge {
|
|
|
1679
1679
|
const r = this.validator.validateEntity(t);
|
|
1680
1680
|
if (r && r.length > 0)
|
|
1681
1681
|
if (this.publishEventErrors(r), r[0].fieldName) {
|
|
1682
|
-
const i =
|
|
1682
|
+
const i = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
1683
1683
|
throw new g(i);
|
|
1684
1684
|
} else
|
|
1685
1685
|
throw new g(r[0].errorMessage);
|
|
@@ -1691,8 +1691,8 @@ class Ge {
|
|
|
1691
1691
|
});
|
|
1692
1692
|
let i = -1;
|
|
1693
1693
|
return this.records.forEach((s, o) => {
|
|
1694
|
-
const c = this.service.getId(s),
|
|
1695
|
-
(s === t || c !== void 0 && c ===
|
|
1694
|
+
const c = this.service.getId(s), u = this.service.getId(t);
|
|
1695
|
+
(s === t || c !== void 0 && c === u) && (i = o);
|
|
1696
1696
|
}), this.records = Q(this.records, (s) => {
|
|
1697
1697
|
i >= 0 ? s[i] = r : s.push(r);
|
|
1698
1698
|
}), this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
|
|
@@ -1701,16 +1701,16 @@ class Ge {
|
|
|
1701
1701
|
index: this.getCurrentIndex()
|
|
1702
1702
|
}), e && e(), r;
|
|
1703
1703
|
} catch (r) {
|
|
1704
|
-
throw this.handleSaveError(r, e), new g(
|
|
1704
|
+
throw this.handleSaveError(r, e), new g(G(r));
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
1707
1707
|
async remove(e) {
|
|
1708
1708
|
if (this.validateDataSourceActive("remove"), this.isInserting() || this.isEditing()) {
|
|
1709
|
-
const i =
|
|
1709
|
+
const i = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
|
|
1710
1710
|
throw this.publishEventError(i, {}), new g(i);
|
|
1711
1711
|
}
|
|
1712
1712
|
if (this.isEmpty() || !this.getCurrentRecord()) {
|
|
1713
|
-
const i =
|
|
1713
|
+
const i = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
1714
1714
|
throw this.publishEventError(i, {}), new g(i);
|
|
1715
1715
|
}
|
|
1716
1716
|
const t = this.getCurrentRecord(), r = this.currentIndex;
|
|
@@ -1730,7 +1730,7 @@ class Ge {
|
|
|
1730
1730
|
index: r
|
|
1731
1731
|
}), e && e(), t;
|
|
1732
1732
|
} catch (i) {
|
|
1733
|
-
const s =
|
|
1733
|
+
const s = G(i);
|
|
1734
1734
|
throw this.emit({
|
|
1735
1735
|
type: a.onError,
|
|
1736
1736
|
error: s,
|
|
@@ -1811,8 +1811,8 @@ class Ge {
|
|
|
1811
1811
|
this.filteredRecords = Q(this.filteredRecords, (o) => {
|
|
1812
1812
|
const c = o[this.currentIndex];
|
|
1813
1813
|
if (c) {
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1814
|
+
const u = this.getNestedValue(c, e);
|
|
1815
|
+
u[t] !== void 0 && r(u[t]);
|
|
1816
1816
|
}
|
|
1817
1817
|
}), this.notifyStateChange(s), this.emit({
|
|
1818
1818
|
type: a.fieldChanged,
|
|
@@ -1893,6 +1893,25 @@ class Ge {
|
|
|
1893
1893
|
}
|
|
1894
1894
|
console.log("[V2 refreshData] Chamando getDataWithoutFilter para página:", t), this.getDataWithoutFilter(t);
|
|
1895
1895
|
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Carrega um registro específico pelo ID.
|
|
1898
|
+
* Útil para cenários onde se deseja editar um registro específico.
|
|
1899
|
+
*
|
|
1900
|
+
* @param id ID do registro a ser carregado
|
|
1901
|
+
* @returns Promise com o registro carregado ou undefined se não encontrado
|
|
1902
|
+
*/
|
|
1903
|
+
async loadById(e) {
|
|
1904
|
+
try {
|
|
1905
|
+
console.log("[V2 loadById] Buscando registro com ID:", e);
|
|
1906
|
+
const t = await this.service.findOne(e);
|
|
1907
|
+
if (t)
|
|
1908
|
+
return console.log("[V2 loadById] Registro encontrado:", t), this.grandTotalRecords = 1, this.setRecords([t]), t;
|
|
1909
|
+
console.log("[V2 loadById] Registro não encontrado"), this.grandTotalRecords = 0, this.setRecords([]);
|
|
1910
|
+
return;
|
|
1911
|
+
} catch (t) {
|
|
1912
|
+
throw console.error("[V2 loadById] Erro ao buscar registro:", t), this.handleRemoteError(t), t;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1896
1915
|
/**
|
|
1897
1916
|
* Carrega dados com filtro RSQL
|
|
1898
1917
|
*/
|
|
@@ -2083,7 +2102,7 @@ class Ge {
|
|
|
2083
2102
|
originalError: i.message
|
|
2084
2103
|
}), this.onFieldError && this.onFieldError(i.field, i.message));
|
|
2085
2104
|
});
|
|
2086
|
-
const r =
|
|
2105
|
+
const r = G(e);
|
|
2087
2106
|
this.emit({
|
|
2088
2107
|
type: a.onError,
|
|
2089
2108
|
error: r,
|
|
@@ -2158,7 +2177,7 @@ class Ge {
|
|
|
2158
2177
|
return this.defaultSortFields;
|
|
2159
2178
|
}
|
|
2160
2179
|
handleRemoteError(e, t) {
|
|
2161
|
-
const r =
|
|
2180
|
+
const r = G(e);
|
|
2162
2181
|
this.emit({
|
|
2163
2182
|
type: a.onError,
|
|
2164
2183
|
error: r,
|
|
@@ -2167,11 +2186,11 @@ class Ge {
|
|
|
2167
2186
|
}
|
|
2168
2187
|
}
|
|
2169
2188
|
function xe(n) {
|
|
2170
|
-
const e = ce(null), [t, r] =
|
|
2189
|
+
const e = ce(null), [t, r] = T(null), [i, s] = T(-1), [o, c] = T(0), [u, p] = T(!0), [C, W] = T(!1), [M, P] = T(!1), [L, N] = T(!1), d = z(() => (e.current || (e.current = new U(n)), e.current), []), f = l((F) => {
|
|
2171
2190
|
switch (F.type) {
|
|
2172
2191
|
case a.dataChanged:
|
|
2173
2192
|
case a.recordChanged:
|
|
2174
|
-
r(d.getCurrentRecord()), s(d.getCurrentIndex()), c(d.getTotalRecords()),
|
|
2193
|
+
r(d.getCurrentRecord()), s(d.getCurrentIndex()), c(d.getTotalRecords()), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting());
|
|
2175
2194
|
break;
|
|
2176
2195
|
case a.fieldChanged:
|
|
2177
2196
|
break;
|
|
@@ -2186,7 +2205,7 @@ function xe(n) {
|
|
|
2186
2205
|
case a.afterInsert:
|
|
2187
2206
|
case a.afterSave:
|
|
2188
2207
|
case a.afterCancel:
|
|
2189
|
-
N(!1),
|
|
2208
|
+
N(!1), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting());
|
|
2190
2209
|
break;
|
|
2191
2210
|
case a.onError:
|
|
2192
2211
|
case a.onFieldError:
|
|
@@ -2194,57 +2213,57 @@ function xe(n) {
|
|
|
2194
2213
|
break;
|
|
2195
2214
|
}
|
|
2196
2215
|
}, [d]);
|
|
2197
|
-
|
|
2198
|
-
d.removeListener(
|
|
2199
|
-
}), [d,
|
|
2200
|
-
const b =
|
|
2216
|
+
q(() => (d.addListener(f), r(d.getCurrentRecord()), s(d.getCurrentIndex()), c(d.getTotalRecords()), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting()), () => {
|
|
2217
|
+
d.removeListener(f);
|
|
2218
|
+
}), [d, f]);
|
|
2219
|
+
const b = l((F, k) => {
|
|
2201
2220
|
d.setFieldValue(F, k);
|
|
2202
|
-
}, [d]),
|
|
2221
|
+
}, [d]), V = l((F) => d.getFieldValue(F), [d]), K = l(() => {
|
|
2203
2222
|
d instanceof U, d.edit();
|
|
2204
|
-
}, [d]),
|
|
2223
|
+
}, [d]), m = l(async () => await d.save(), [d]), h = l(() => {
|
|
2205
2224
|
d instanceof U, d.cancel();
|
|
2206
|
-
}, [d]),
|
|
2225
|
+
}, [d]), Y = l((F) => {
|
|
2207
2226
|
d instanceof U, d.insert(F);
|
|
2208
|
-
}, [d]), Z =
|
|
2227
|
+
}, [d]), Z = l(async (F) => await d.remove(F), [d]), E = l(() => {
|
|
2209
2228
|
d instanceof U, d.first();
|
|
2210
|
-
}, [d]),
|
|
2229
|
+
}, [d]), j = l(() => {
|
|
2211
2230
|
d instanceof U, d.last();
|
|
2212
|
-
}, [d]), ee =
|
|
2231
|
+
}, [d]), ee = l(() => {
|
|
2213
2232
|
d instanceof U, d.next();
|
|
2214
|
-
}, [d]), D =
|
|
2233
|
+
}, [d]), D = l(() => {
|
|
2215
2234
|
d instanceof U, d.prior();
|
|
2216
|
-
}, [d]), S =
|
|
2235
|
+
}, [d]), S = l((F) => {
|
|
2217
2236
|
d instanceof U, d.goToRecord(F);
|
|
2218
|
-
}, [d]), A =
|
|
2237
|
+
}, [d]), A = l((F, k) => {
|
|
2219
2238
|
d instanceof U && d.appendToFieldArray(F, k);
|
|
2220
|
-
}, [d]), B =
|
|
2239
|
+
}, [d]), B = l((F, k, de) => {
|
|
2221
2240
|
d instanceof U && d.updateFieldArrayItem(F, k, de);
|
|
2222
|
-
}, [d]),
|
|
2241
|
+
}, [d]), y = l((F, k) => {
|
|
2223
2242
|
d instanceof U && d.removeFromFieldArray(F, k);
|
|
2224
|
-
}, [d]),
|
|
2243
|
+
}, [d]), w = l((F, k, de) => {
|
|
2225
2244
|
d instanceof U && d.insertIntoFieldArray(F, k, de);
|
|
2226
|
-
}, [d]), x =
|
|
2245
|
+
}, [d]), x = l((F) => {
|
|
2227
2246
|
if (d instanceof U)
|
|
2228
2247
|
return d.getFieldArray(F);
|
|
2229
2248
|
const k = d.getFieldValue(F);
|
|
2230
2249
|
return Array.isArray(k) ? k : [];
|
|
2231
|
-
}, [d]), $ =
|
|
2250
|
+
}, [d]), $ = l((F) => {
|
|
2232
2251
|
if (d instanceof U)
|
|
2233
2252
|
return d.isFieldArray(F);
|
|
2234
2253
|
const k = d.getFieldValue(F);
|
|
2235
2254
|
return Array.isArray(k);
|
|
2236
|
-
}, [d]),
|
|
2255
|
+
}, [d]), v = z(() => i < o - 1, [i, o]), J = z(() => i > 0, [i]), te = z(() => o === 0, [o]), oe = z(() => i === 0, [i]), ae = z(() => i === o - 1, [i, o]), O = z(() => u, [u]), _ = z(() => C, [C]), re = z(() => M, [M]), ue = l(() => process.env.NODE_ENV === "development" ? {
|
|
2237
2256
|
...d.getDebugSnapshot(),
|
|
2238
2257
|
hookState: {
|
|
2239
2258
|
currentRecord: t,
|
|
2240
2259
|
currentIndex: i,
|
|
2241
2260
|
totalRecords: o,
|
|
2242
|
-
isBrowsing:
|
|
2243
|
-
isEditing:
|
|
2261
|
+
isBrowsing: O,
|
|
2262
|
+
isEditing: _,
|
|
2244
2263
|
isInserting: re,
|
|
2245
|
-
isLoading:
|
|
2264
|
+
isLoading: L
|
|
2246
2265
|
}
|
|
2247
|
-
} : null, [d, t, i, o,
|
|
2266
|
+
} : null, [d, t, i, o, O, _, re, L]);
|
|
2248
2267
|
return {
|
|
2249
2268
|
// DataSource instance (para casos onde acesso direto é necessário)
|
|
2250
2269
|
dataSource: d,
|
|
@@ -2252,42 +2271,42 @@ function xe(n) {
|
|
|
2252
2271
|
currentRecord: t,
|
|
2253
2272
|
currentIndex: i,
|
|
2254
2273
|
totalRecords: o,
|
|
2255
|
-
isLoading:
|
|
2274
|
+
isLoading: L,
|
|
2256
2275
|
// Estado derivado
|
|
2257
|
-
canNext:
|
|
2276
|
+
canNext: v,
|
|
2258
2277
|
canPrior: J,
|
|
2259
2278
|
isEmpty: te,
|
|
2260
2279
|
isFirst: oe,
|
|
2261
2280
|
isLast: ae,
|
|
2262
|
-
isBrowsing:
|
|
2263
|
-
isEditing:
|
|
2281
|
+
isBrowsing: O,
|
|
2282
|
+
isEditing: _,
|
|
2264
2283
|
isInserting: re,
|
|
2265
2284
|
// Operações básicas
|
|
2266
2285
|
setFieldValue: b,
|
|
2267
|
-
getFieldValue:
|
|
2268
|
-
edit:
|
|
2269
|
-
save:
|
|
2270
|
-
cancel:
|
|
2271
|
-
insert:
|
|
2286
|
+
getFieldValue: V,
|
|
2287
|
+
edit: K,
|
|
2288
|
+
save: m,
|
|
2289
|
+
cancel: h,
|
|
2290
|
+
insert: Y,
|
|
2272
2291
|
remove: Z,
|
|
2273
2292
|
// Navegação
|
|
2274
|
-
first:
|
|
2275
|
-
last:
|
|
2293
|
+
first: E,
|
|
2294
|
+
last: j,
|
|
2276
2295
|
next: ee,
|
|
2277
2296
|
prior: D,
|
|
2278
2297
|
goToRecord: S,
|
|
2279
2298
|
// Operações de array (V2)
|
|
2280
2299
|
appendToFieldArray: A,
|
|
2281
2300
|
updateFieldArrayItem: B,
|
|
2282
|
-
removeFromFieldArray:
|
|
2283
|
-
insertIntoFieldArray:
|
|
2301
|
+
removeFromFieldArray: y,
|
|
2302
|
+
insertIntoFieldArray: w,
|
|
2284
2303
|
getFieldArray: x,
|
|
2285
2304
|
isFieldArray: $,
|
|
2286
2305
|
// Debug
|
|
2287
2306
|
getDebugInfo: ue
|
|
2288
2307
|
};
|
|
2289
2308
|
}
|
|
2290
|
-
function
|
|
2309
|
+
function wt(n) {
|
|
2291
2310
|
const {
|
|
2292
2311
|
dataSource: e,
|
|
2293
2312
|
currentRecord: t,
|
|
@@ -2296,16 +2315,16 @@ function yt(n) {
|
|
|
2296
2315
|
canNext: s,
|
|
2297
2316
|
canPrior: o,
|
|
2298
2317
|
isEmpty: c,
|
|
2299
|
-
isFirst:
|
|
2300
|
-
isLast:
|
|
2318
|
+
isFirst: u,
|
|
2319
|
+
isLast: p,
|
|
2301
2320
|
isBrowsing: C,
|
|
2302
|
-
first:
|
|
2303
|
-
last:
|
|
2304
|
-
next:
|
|
2305
|
-
prior:
|
|
2321
|
+
first: W,
|
|
2322
|
+
last: M,
|
|
2323
|
+
next: P,
|
|
2324
|
+
prior: L,
|
|
2306
2325
|
goToRecord: N,
|
|
2307
2326
|
getFieldValue: d,
|
|
2308
|
-
getFieldArray:
|
|
2327
|
+
getFieldArray: f,
|
|
2309
2328
|
isFieldArray: b
|
|
2310
2329
|
} = xe(n);
|
|
2311
2330
|
return {
|
|
@@ -2316,178 +2335,191 @@ function yt(n) {
|
|
|
2316
2335
|
canNext: s,
|
|
2317
2336
|
canPrior: o,
|
|
2318
2337
|
isEmpty: c,
|
|
2319
|
-
isFirst:
|
|
2320
|
-
isLast:
|
|
2338
|
+
isFirst: u,
|
|
2339
|
+
isLast: p,
|
|
2321
2340
|
isBrowsing: C,
|
|
2322
|
-
first:
|
|
2323
|
-
last:
|
|
2324
|
-
next:
|
|
2325
|
-
prior:
|
|
2341
|
+
first: W,
|
|
2342
|
+
last: M,
|
|
2343
|
+
next: P,
|
|
2344
|
+
prior: L,
|
|
2326
2345
|
goToRecord: N,
|
|
2327
2346
|
getFieldValue: d,
|
|
2328
|
-
getFieldArray:
|
|
2347
|
+
getFieldArray: f,
|
|
2329
2348
|
isFieldArray: b
|
|
2330
2349
|
};
|
|
2331
2350
|
}
|
|
2332
|
-
function
|
|
2351
|
+
function Et(n) {
|
|
2333
2352
|
return xe(n);
|
|
2334
2353
|
}
|
|
2335
2354
|
function Ce(n) {
|
|
2336
|
-
const e = ce(null), [
|
|
2337
|
-
switch (
|
|
2355
|
+
const { id: e, loadOnStart: t = !0 } = n, r = ce(null), [i, s] = T(void 0), [o, c] = T(-1), [u, p] = T(0), [C, W] = T(0), [M, P] = T(!0), [L, N] = T(!1), [d, f] = T(!1), [b, V] = T(!1), [K, m] = T(null), h = z(() => (r.current || (r.current = new Qe(n)), r.current), []), Y = l((I) => {
|
|
2356
|
+
switch (I.type) {
|
|
2338
2357
|
case a.dataChanged:
|
|
2339
2358
|
case a.recordChanged:
|
|
2340
2359
|
case a.refreshData:
|
|
2341
|
-
|
|
2360
|
+
s(h.getCurrentRecord()), c(h.getCurrentIndex()), p(h.getTotalRecords()), W(h.getGrandTotalRecords()), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), V(!1), m(null);
|
|
2342
2361
|
break;
|
|
2343
2362
|
case a.fieldChanged:
|
|
2344
2363
|
break;
|
|
2345
2364
|
case a.afterScroll:
|
|
2346
|
-
|
|
2365
|
+
s(h.getCurrentRecord()), c(h.getCurrentIndex());
|
|
2347
2366
|
break;
|
|
2348
2367
|
case a.beforeEdit:
|
|
2349
2368
|
case a.beforeInsert:
|
|
2350
2369
|
case a.beforeSave:
|
|
2351
2370
|
case a.beforeRemove:
|
|
2352
|
-
|
|
2371
|
+
V(!0), m(null);
|
|
2353
2372
|
break;
|
|
2354
2373
|
case a.afterEdit:
|
|
2355
2374
|
case a.afterInsert:
|
|
2356
2375
|
case a.afterSave:
|
|
2357
2376
|
case a.afterCancel:
|
|
2358
2377
|
case a.afterRemove:
|
|
2359
|
-
|
|
2378
|
+
V(!1), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), m(null);
|
|
2360
2379
|
break;
|
|
2361
2380
|
case a.onError:
|
|
2362
|
-
|
|
2381
|
+
V(!1), m(I.error);
|
|
2363
2382
|
break;
|
|
2364
2383
|
case a.onFieldError:
|
|
2365
|
-
|
|
2384
|
+
V(!1);
|
|
2366
2385
|
break;
|
|
2367
2386
|
}
|
|
2368
2387
|
}, [h]);
|
|
2369
|
-
|
|
2370
|
-
h.removeListener(
|
|
2371
|
-
}), [h,
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2388
|
+
q(() => (h.addListener(Y), s(h.getCurrentRecord()), c(h.getCurrentIndex()), p(h.getTotalRecords()), W(h.getGrandTotalRecords()), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), () => {
|
|
2389
|
+
h.removeListener(Y);
|
|
2390
|
+
}), [h, Y]), q(() => {
|
|
2391
|
+
t && (e != null ? (V(!0), m(null), h.loadById(e).catch((I) => {
|
|
2392
|
+
m(I.message || "Erro ao carregar registro"), V(!1);
|
|
2393
|
+
})) : (V(!0), m(null), h.refreshData()));
|
|
2394
|
+
}, [e, t, h]);
|
|
2395
|
+
const Z = l((I, H) => {
|
|
2396
|
+
h.setFieldValue(I, H);
|
|
2397
|
+
}, [h]), E = l((I) => h.getFieldValue(I), [h]), j = l(() => {
|
|
2375
2398
|
h.edit();
|
|
2376
|
-
}, [h]),
|
|
2399
|
+
}, [h]), ee = l(async () => {
|
|
2377
2400
|
try {
|
|
2378
|
-
return
|
|
2379
|
-
} catch (
|
|
2380
|
-
throw
|
|
2401
|
+
return m(null), await h.save();
|
|
2402
|
+
} catch (I) {
|
|
2403
|
+
throw m(I.message || "Erro ao salvar"), I;
|
|
2381
2404
|
}
|
|
2382
|
-
}, [h]),
|
|
2405
|
+
}, [h]), D = l(() => {
|
|
2383
2406
|
h.cancel();
|
|
2384
|
-
}, [h]),
|
|
2385
|
-
h.insert(
|
|
2386
|
-
}, [h]),
|
|
2407
|
+
}, [h]), S = l((I) => {
|
|
2408
|
+
h.insert(I);
|
|
2409
|
+
}, [h]), A = l(async (I) => {
|
|
2387
2410
|
try {
|
|
2388
|
-
return
|
|
2389
|
-
} catch (
|
|
2390
|
-
throw
|
|
2411
|
+
return m(null), await h.remove(I);
|
|
2412
|
+
} catch (H) {
|
|
2413
|
+
throw m(H.message || "Erro ao remover"), H;
|
|
2391
2414
|
}
|
|
2392
|
-
}, [h]),
|
|
2415
|
+
}, [h]), B = l(() => {
|
|
2393
2416
|
h.first();
|
|
2394
|
-
}, [h]),
|
|
2417
|
+
}, [h]), y = l(() => {
|
|
2395
2418
|
h.last();
|
|
2396
|
-
}, [h]),
|
|
2419
|
+
}, [h]), w = l(() => {
|
|
2397
2420
|
h.next();
|
|
2398
|
-
}, [h]),
|
|
2421
|
+
}, [h]), x = l(() => {
|
|
2399
2422
|
h.prior();
|
|
2400
|
-
}, [h]),
|
|
2401
|
-
h.goToRecord(
|
|
2402
|
-
}, [h]),
|
|
2403
|
-
h.appendToFieldArray(w, M);
|
|
2404
|
-
}, [h]), $ = u((w, M, se) => {
|
|
2405
|
-
h.updateFieldArrayItem(w, M, se);
|
|
2406
|
-
}, [h]), y = u((w, M) => {
|
|
2407
|
-
h.removeFromFieldArray(w, M);
|
|
2408
|
-
}, [h]), J = u((w, M, se) => {
|
|
2409
|
-
h.insertIntoFieldArray(w, M, se);
|
|
2410
|
-
}, [h]), te = u((w) => h.getFieldArray(w), [h]), oe = u((w) => h.isFieldArray(w), [h]), ae = u((w, M, se) => {
|
|
2411
|
-
l(!0), L(null);
|
|
2423
|
+
}, [h]), $ = l((I) => {
|
|
2424
|
+
h.goToRecord(I);
|
|
2425
|
+
}, [h]), v = l(async (I) => {
|
|
2412
2426
|
try {
|
|
2413
|
-
|
|
2414
|
-
|
|
2427
|
+
return V(!0), m(null), await h.loadById(I);
|
|
2428
|
+
} catch (H) {
|
|
2429
|
+
throw m(H.message || "Erro ao carregar registro"), H;
|
|
2430
|
+
} finally {
|
|
2431
|
+
V(!1);
|
|
2432
|
+
}
|
|
2433
|
+
}, [h]), J = l((I, H) => {
|
|
2434
|
+
h.appendToFieldArray(I, H);
|
|
2435
|
+
}, [h]), te = l((I, H, se) => {
|
|
2436
|
+
h.updateFieldArrayItem(I, H, se);
|
|
2437
|
+
}, [h]), oe = l((I, H) => {
|
|
2438
|
+
h.removeFromFieldArray(I, H);
|
|
2439
|
+
}, [h]), ae = l((I, H, se) => {
|
|
2440
|
+
h.insertIntoFieldArray(I, H, se);
|
|
2441
|
+
}, [h]), O = l((I) => h.getFieldArray(I), [h]), _ = l((I) => h.isFieldArray(I), [h]), re = l((I, H, se) => {
|
|
2442
|
+
V(!0), m(null);
|
|
2443
|
+
try {
|
|
2444
|
+
h.applyRemoteFilter(I, H, () => {
|
|
2445
|
+
V(!1), se && se();
|
|
2415
2446
|
});
|
|
2416
|
-
} catch (
|
|
2417
|
-
|
|
2447
|
+
} catch (Le) {
|
|
2448
|
+
V(!1), m(Le.message || "Erro ao aplicar filtro");
|
|
2418
2449
|
}
|
|
2419
|
-
}, [h]),
|
|
2450
|
+
}, [h]), ue = l(async (I) => {
|
|
2420
2451
|
try {
|
|
2421
|
-
|
|
2422
|
-
} catch (
|
|
2423
|
-
throw
|
|
2452
|
+
V(!0), m(null), h.refreshData(I);
|
|
2453
|
+
} catch (H) {
|
|
2454
|
+
throw V(!1), m(H.message || "Erro ao atualizar dados"), H;
|
|
2424
2455
|
}
|
|
2425
|
-
}, [h]),
|
|
2426
|
-
h.setPageSize(
|
|
2427
|
-
}, [h]),
|
|
2456
|
+
}, [h]), F = l((I) => {
|
|
2457
|
+
h.setPageSize(I);
|
|
2458
|
+
}, [h]), k = l(() => h.getPageSize(), [h]), de = z(() => o < u - 1, [o, u]), De = z(() => o > 0, [o]), Ve = z(() => u === 0, [u]), Te = z(() => o === 0, [o]), Oe = z(() => o === u - 1, [o, u]), ge = z(() => M, [M]), fe = z(() => L, [L]), me = z(() => d, [d]), Pe = l(() => process.env.NODE_ENV === "development" ? {
|
|
2428
2459
|
...h.getDebugSnapshot(),
|
|
2429
2460
|
hookState: {
|
|
2430
|
-
currentRecord:
|
|
2431
|
-
currentIndex:
|
|
2432
|
-
totalRecords:
|
|
2433
|
-
grandTotalRecords:
|
|
2461
|
+
currentRecord: i,
|
|
2462
|
+
currentIndex: o,
|
|
2463
|
+
totalRecords: u,
|
|
2464
|
+
grandTotalRecords: C,
|
|
2434
2465
|
isBrowsing: ge,
|
|
2435
2466
|
isEditing: fe,
|
|
2436
2467
|
isInserting: me,
|
|
2437
|
-
isLoading:
|
|
2438
|
-
error:
|
|
2468
|
+
isLoading: b,
|
|
2469
|
+
error: K
|
|
2439
2470
|
}
|
|
2440
|
-
} : null, [h,
|
|
2471
|
+
} : null, [h, i, o, u, C, ge, fe, me, b, K]);
|
|
2441
2472
|
return {
|
|
2442
2473
|
// DataSource instance (para casos onde acesso direto é necessário)
|
|
2443
2474
|
dataSource: h,
|
|
2444
2475
|
// Estado reativo
|
|
2445
|
-
currentRecord:
|
|
2446
|
-
currentIndex:
|
|
2447
|
-
totalRecords:
|
|
2448
|
-
grandTotalRecords:
|
|
2449
|
-
isLoading:
|
|
2450
|
-
error:
|
|
2476
|
+
currentRecord: i,
|
|
2477
|
+
currentIndex: o,
|
|
2478
|
+
totalRecords: u,
|
|
2479
|
+
grandTotalRecords: C,
|
|
2480
|
+
isLoading: b,
|
|
2481
|
+
error: K,
|
|
2451
2482
|
// Estado derivado
|
|
2452
|
-
canNext:
|
|
2453
|
-
canPrior:
|
|
2454
|
-
isEmpty:
|
|
2455
|
-
isFirst:
|
|
2456
|
-
isLast:
|
|
2483
|
+
canNext: de,
|
|
2484
|
+
canPrior: De,
|
|
2485
|
+
isEmpty: Ve,
|
|
2486
|
+
isFirst: Te,
|
|
2487
|
+
isLast: Oe,
|
|
2457
2488
|
isBrowsing: ge,
|
|
2458
2489
|
isEditing: fe,
|
|
2459
2490
|
isInserting: me,
|
|
2460
2491
|
// Operações básicas
|
|
2461
|
-
setFieldValue:
|
|
2462
|
-
getFieldValue:
|
|
2463
|
-
edit:
|
|
2464
|
-
save:
|
|
2465
|
-
cancel:
|
|
2466
|
-
insert:
|
|
2467
|
-
remove:
|
|
2492
|
+
setFieldValue: Z,
|
|
2493
|
+
getFieldValue: E,
|
|
2494
|
+
edit: j,
|
|
2495
|
+
save: ee,
|
|
2496
|
+
cancel: D,
|
|
2497
|
+
insert: S,
|
|
2498
|
+
remove: A,
|
|
2468
2499
|
// Navegação
|
|
2469
|
-
first:
|
|
2470
|
-
last:
|
|
2471
|
-
next:
|
|
2472
|
-
prior:
|
|
2473
|
-
goToRecord:
|
|
2500
|
+
first: B,
|
|
2501
|
+
last: y,
|
|
2502
|
+
next: w,
|
|
2503
|
+
prior: x,
|
|
2504
|
+
goToRecord: $,
|
|
2505
|
+
loadById: v,
|
|
2474
2506
|
// Operações de array (V2)
|
|
2475
|
-
appendToFieldArray:
|
|
2476
|
-
updateFieldArrayItem:
|
|
2477
|
-
removeFromFieldArray:
|
|
2478
|
-
insertIntoFieldArray:
|
|
2479
|
-
getFieldArray:
|
|
2480
|
-
isFieldArray:
|
|
2507
|
+
appendToFieldArray: J,
|
|
2508
|
+
updateFieldArrayItem: te,
|
|
2509
|
+
removeFromFieldArray: oe,
|
|
2510
|
+
insertIntoFieldArray: ae,
|
|
2511
|
+
getFieldArray: O,
|
|
2512
|
+
isFieldArray: _,
|
|
2481
2513
|
// Operações remotas
|
|
2482
|
-
applyRemoteFilter:
|
|
2483
|
-
refreshData:
|
|
2484
|
-
setPageSize:
|
|
2485
|
-
getPageSize:
|
|
2514
|
+
applyRemoteFilter: re,
|
|
2515
|
+
refreshData: ue,
|
|
2516
|
+
setPageSize: F,
|
|
2517
|
+
getPageSize: k,
|
|
2486
2518
|
// Debug
|
|
2487
|
-
getDebugInfo:
|
|
2519
|
+
getDebugInfo: Pe
|
|
2488
2520
|
};
|
|
2489
2521
|
}
|
|
2490
|
-
function
|
|
2522
|
+
function St(n) {
|
|
2491
2523
|
const {
|
|
2492
2524
|
dataSource: e,
|
|
2493
2525
|
currentRecord: t,
|
|
@@ -2496,24 +2528,25 @@ function It(n) {
|
|
|
2496
2528
|
grandTotalRecords: s,
|
|
2497
2529
|
isLoading: o,
|
|
2498
2530
|
error: c,
|
|
2499
|
-
canNext:
|
|
2500
|
-
canPrior:
|
|
2531
|
+
canNext: u,
|
|
2532
|
+
canPrior: p,
|
|
2501
2533
|
isEmpty: C,
|
|
2502
|
-
isFirst:
|
|
2503
|
-
isLast:
|
|
2504
|
-
isBrowsing:
|
|
2505
|
-
first:
|
|
2534
|
+
isFirst: W,
|
|
2535
|
+
isLast: M,
|
|
2536
|
+
isBrowsing: P,
|
|
2537
|
+
first: L,
|
|
2506
2538
|
last: N,
|
|
2507
2539
|
next: d,
|
|
2508
|
-
prior:
|
|
2540
|
+
prior: f,
|
|
2509
2541
|
goToRecord: b,
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2542
|
+
loadById: V,
|
|
2543
|
+
getFieldValue: K,
|
|
2544
|
+
getFieldArray: m,
|
|
2545
|
+
isFieldArray: h,
|
|
2546
|
+
applyRemoteFilter: Y,
|
|
2547
|
+
refreshData: Z,
|
|
2548
|
+
getPageSize: E,
|
|
2549
|
+
getDebugInfo: j
|
|
2517
2550
|
} = Ce(n);
|
|
2518
2551
|
return {
|
|
2519
2552
|
dataSource: e,
|
|
@@ -2523,30 +2556,31 @@ function It(n) {
|
|
|
2523
2556
|
grandTotalRecords: s,
|
|
2524
2557
|
isLoading: o,
|
|
2525
2558
|
error: c,
|
|
2526
|
-
canNext:
|
|
2527
|
-
canPrior:
|
|
2559
|
+
canNext: u,
|
|
2560
|
+
canPrior: p,
|
|
2528
2561
|
isEmpty: C,
|
|
2529
|
-
isFirst:
|
|
2530
|
-
isLast:
|
|
2531
|
-
isBrowsing:
|
|
2532
|
-
first:
|
|
2562
|
+
isFirst: W,
|
|
2563
|
+
isLast: M,
|
|
2564
|
+
isBrowsing: P,
|
|
2565
|
+
first: L,
|
|
2533
2566
|
last: N,
|
|
2534
2567
|
next: d,
|
|
2535
|
-
prior:
|
|
2568
|
+
prior: f,
|
|
2536
2569
|
goToRecord: b,
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2570
|
+
loadById: V,
|
|
2571
|
+
getFieldValue: K,
|
|
2572
|
+
getFieldArray: m,
|
|
2573
|
+
isFieldArray: h,
|
|
2574
|
+
applyRemoteFilter: Y,
|
|
2575
|
+
refreshData: Z,
|
|
2576
|
+
getPageSize: E,
|
|
2577
|
+
getDebugInfo: j
|
|
2544
2578
|
};
|
|
2545
2579
|
}
|
|
2546
|
-
function
|
|
2580
|
+
function Ft(n) {
|
|
2547
2581
|
return Ce(n);
|
|
2548
2582
|
}
|
|
2549
|
-
class
|
|
2583
|
+
class At {
|
|
2550
2584
|
/**
|
|
2551
2585
|
* Gera chave de query baseada no DataSource e filtros
|
|
2552
2586
|
*/
|
|
@@ -2570,7 +2604,7 @@ class Et {
|
|
|
2570
2604
|
);
|
|
2571
2605
|
}
|
|
2572
2606
|
}
|
|
2573
|
-
const
|
|
2607
|
+
const xt = {
|
|
2574
2608
|
/** Configuração para dados que mudam raramente */
|
|
2575
2609
|
STATIC_DATA: {
|
|
2576
2610
|
staleTime: 30 * 60 * 1e3,
|
|
@@ -2600,32 +2634,32 @@ const St = {
|
|
|
2600
2634
|
// 1 minuto
|
|
2601
2635
|
retry: 5
|
|
2602
2636
|
}
|
|
2603
|
-
},
|
|
2604
|
-
const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store: o, validator: c } = n,
|
|
2637
|
+
}, Ct = (n) => {
|
|
2638
|
+
const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store: o, validator: c } = n, u = () => o && o.existsValue(t) ? o.getValue(t) : i || new ye(t, {
|
|
2605
2639
|
records: e,
|
|
2606
2640
|
grandTotalRecords: e.length,
|
|
2607
2641
|
currentPage: 0,
|
|
2608
2642
|
totalPages: 0,
|
|
2609
2643
|
pageSize: 0,
|
|
2610
2644
|
validator: c
|
|
2611
|
-
}, r), [
|
|
2612
|
-
|
|
2645
|
+
}, r), [p, C] = T(
|
|
2646
|
+
u()
|
|
2613
2647
|
);
|
|
2614
|
-
return
|
|
2615
|
-
o && o.setValue(t,
|
|
2616
|
-
}, [t]), { dataSource:
|
|
2617
|
-
},
|
|
2648
|
+
return q(() => {
|
|
2649
|
+
o && o.setValue(t, p), s && s(p);
|
|
2650
|
+
}, [t]), { dataSource: p };
|
|
2651
|
+
}, bt = (n) => {
|
|
2618
2652
|
const e = (r) => {
|
|
2619
2653
|
r.addListener(n.listener);
|
|
2620
2654
|
}, t = (r) => {
|
|
2621
2655
|
r.removeListener(n.listener);
|
|
2622
2656
|
};
|
|
2623
|
-
|
|
2657
|
+
q(() => (n.dataSource && (t(n.dataSource), e(n.dataSource)), () => {
|
|
2624
2658
|
n.dataSource && t(n.dataSource);
|
|
2625
2659
|
}), [n.dataSource?.uuid || n.dataSource?.getName()]);
|
|
2626
|
-
},
|
|
2627
|
-
const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = n, [o, c] =
|
|
2628
|
-
r ?? new
|
|
2660
|
+
}, Dt = (n) => {
|
|
2661
|
+
const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = n, [o, c] = T(
|
|
2662
|
+
r ?? new Ge(t, {
|
|
2629
2663
|
records: e,
|
|
2630
2664
|
grandTotalRecords: e.length,
|
|
2631
2665
|
currentPage: 0,
|
|
@@ -2634,9 +2668,9 @@ const St = {
|
|
|
2634
2668
|
validator: s
|
|
2635
2669
|
})
|
|
2636
2670
|
);
|
|
2637
|
-
return
|
|
2638
|
-
c((
|
|
2639
|
-
const
|
|
2671
|
+
return q(() => {
|
|
2672
|
+
c((u) => {
|
|
2673
|
+
const p = {
|
|
2640
2674
|
records: e,
|
|
2641
2675
|
grandTotalRecords: e.length,
|
|
2642
2676
|
totalPages: 0,
|
|
@@ -2644,7 +2678,7 @@ const St = {
|
|
|
2644
2678
|
pageSize: 0,
|
|
2645
2679
|
validator: s
|
|
2646
2680
|
};
|
|
2647
|
-
return
|
|
2681
|
+
return u.isActive() ? u.setData(p) : u.open(p), u;
|
|
2648
2682
|
}), i && i(o);
|
|
2649
2683
|
}, [e, t]), { dataSource: o };
|
|
2650
2684
|
};
|
|
@@ -2663,7 +2697,7 @@ class be {
|
|
|
2663
2697
|
}
|
|
2664
2698
|
async get(e, t, r, i) {
|
|
2665
2699
|
try {
|
|
2666
|
-
const s = this.prepareHeaders(t, r), o = await
|
|
2700
|
+
const s = this.prepareHeaders(t, r), o = await X.get(e, { headers: s, ...i });
|
|
2667
2701
|
return ie.convertJsonToObject(o.data);
|
|
2668
2702
|
} catch (s) {
|
|
2669
2703
|
return Promise.reject(s);
|
|
@@ -2671,7 +2705,7 @@ class be {
|
|
|
2671
2705
|
}
|
|
2672
2706
|
async post(e, t, r, i, s) {
|
|
2673
2707
|
try {
|
|
2674
|
-
const o = this.prepareHeaders(r, i), c = await
|
|
2708
|
+
const o = this.prepareHeaders(r, i), c = await X.post(
|
|
2675
2709
|
e,
|
|
2676
2710
|
ie.convertObjectToJson(t),
|
|
2677
2711
|
{
|
|
@@ -2687,7 +2721,7 @@ class be {
|
|
|
2687
2721
|
async postNoConvertId(e, t, r, i, s) {
|
|
2688
2722
|
try {
|
|
2689
2723
|
const o = this.prepareHeaders(r, i);
|
|
2690
|
-
return (await
|
|
2724
|
+
return (await X.post(
|
|
2691
2725
|
e,
|
|
2692
2726
|
t,
|
|
2693
2727
|
{
|
|
@@ -2701,7 +2735,7 @@ class be {
|
|
|
2701
2735
|
}
|
|
2702
2736
|
async put(e, t, r, i, s) {
|
|
2703
2737
|
try {
|
|
2704
|
-
const o = this.prepareHeaders(r, i), c = await
|
|
2738
|
+
const o = this.prepareHeaders(r, i), c = await X.put(e, ie.convertObjectToJson(t), {
|
|
2705
2739
|
headers: o,
|
|
2706
2740
|
...s
|
|
2707
2741
|
});
|
|
@@ -2713,7 +2747,7 @@ class be {
|
|
|
2713
2747
|
async putNoConvertId(e, t, r, i, s) {
|
|
2714
2748
|
try {
|
|
2715
2749
|
const o = this.prepareHeaders(r, i);
|
|
2716
|
-
return (await
|
|
2750
|
+
return (await X.put(e, t, {
|
|
2717
2751
|
headers: o,
|
|
2718
2752
|
...s
|
|
2719
2753
|
})).data;
|
|
@@ -2724,7 +2758,7 @@ class be {
|
|
|
2724
2758
|
async binaryPut(e, t, r = {}, i, s) {
|
|
2725
2759
|
try {
|
|
2726
2760
|
const o = this.prepareHeaders(r, i);
|
|
2727
|
-
return s = s || {}, (await
|
|
2761
|
+
return s = s || {}, (await X.put(e, t, {
|
|
2728
2762
|
headers: o,
|
|
2729
2763
|
...s
|
|
2730
2764
|
})).data;
|
|
@@ -2734,7 +2768,7 @@ class be {
|
|
|
2734
2768
|
}
|
|
2735
2769
|
async delete(e, t, r, i) {
|
|
2736
2770
|
try {
|
|
2737
|
-
const s = this.prepareHeaders(t, r), o = await
|
|
2771
|
+
const s = this.prepareHeaders(t, r), o = await X.delete(e, { headers: s, ...i });
|
|
2738
2772
|
return ie.convertJsonToObject(o.data);
|
|
2739
2773
|
} catch (s) {
|
|
2740
2774
|
return Promise.reject(s);
|
|
@@ -2742,7 +2776,7 @@ class be {
|
|
|
2742
2776
|
}
|
|
2743
2777
|
async patch(e, t, r, i, s) {
|
|
2744
2778
|
try {
|
|
2745
|
-
const o = this.prepareHeaders(r, i), c = await
|
|
2779
|
+
const o = this.prepareHeaders(r, i), c = await X.patch(e, ie.convertObjectToJson(t), {
|
|
2746
2780
|
headers: o,
|
|
2747
2781
|
...s
|
|
2748
2782
|
});
|
|
@@ -2754,7 +2788,7 @@ class be {
|
|
|
2754
2788
|
async patchNoConvertId(e, t, r, i, s) {
|
|
2755
2789
|
try {
|
|
2756
2790
|
const o = this.prepareHeaders(r, i);
|
|
2757
|
-
return (await
|
|
2791
|
+
return (await X.patch(e, t, {
|
|
2758
2792
|
headers: o,
|
|
2759
2793
|
...s
|
|
2760
2794
|
})).data;
|
|
@@ -2769,7 +2803,7 @@ class be {
|
|
|
2769
2803
|
async getBlob(e, t, r) {
|
|
2770
2804
|
try {
|
|
2771
2805
|
const i = this.prepareHeaders(t, r);
|
|
2772
|
-
return (await
|
|
2806
|
+
return (await X.get(e, {
|
|
2773
2807
|
headers: i,
|
|
2774
2808
|
responseType: "blob"
|
|
2775
2809
|
})).data;
|
|
@@ -2784,7 +2818,7 @@ class be {
|
|
|
2784
2818
|
async postBlob(e, t, r, i) {
|
|
2785
2819
|
try {
|
|
2786
2820
|
const s = this.prepareHeaders(r, i);
|
|
2787
|
-
return (await
|
|
2821
|
+
return (await X.post(e, t, {
|
|
2788
2822
|
headers: s,
|
|
2789
2823
|
responseType: "blob"
|
|
2790
2824
|
})).data;
|
|
@@ -2803,15 +2837,15 @@ class be {
|
|
|
2803
2837
|
const c = this.tokenManager.getToken();
|
|
2804
2838
|
c && (s.Authorization = `Bearer ${c.access_token}`);
|
|
2805
2839
|
}
|
|
2806
|
-
return (await
|
|
2840
|
+
return (await X.post(e, t, { headers: s })).data;
|
|
2807
2841
|
} catch (s) {
|
|
2808
2842
|
return Promise.reject(s);
|
|
2809
2843
|
}
|
|
2810
2844
|
}
|
|
2811
2845
|
}
|
|
2812
|
-
ne.decorate(ne.inject(
|
|
2846
|
+
ne.decorate(ne.inject(We.TokenManager), be, 0);
|
|
2813
2847
|
ne.decorate(ne.injectable(), be);
|
|
2814
|
-
class
|
|
2848
|
+
class Ke {
|
|
2815
2849
|
client;
|
|
2816
2850
|
constructor(e) {
|
|
2817
2851
|
this.client = e;
|
|
@@ -2911,7 +2945,7 @@ class qe {
|
|
|
2911
2945
|
return this.client.delete(`${this.getEndpoint()}/${e}`, t, !1);
|
|
2912
2946
|
}
|
|
2913
2947
|
}
|
|
2914
|
-
ne.decorate(ne.injectable(),
|
|
2948
|
+
ne.decorate(ne.injectable(), Ke);
|
|
2915
2949
|
class le {
|
|
2916
2950
|
content;
|
|
2917
2951
|
pageable;
|
|
@@ -2924,8 +2958,8 @@ class le {
|
|
|
2924
2958
|
first;
|
|
2925
2959
|
numberOfElements;
|
|
2926
2960
|
empty;
|
|
2927
|
-
constructor(e, t, r, i, s, o, c,
|
|
2928
|
-
this.content = e, this.totalElements = t, this.totalPages = r, this.number = i, this.size = s, this.sort = o || { sorted: !1, unsorted: !0, empty: !0 }, this.last = c !== void 0 ? c : i === r - 1, this.first =
|
|
2961
|
+
constructor(e, t, r, i, s, o, c, u, p, C) {
|
|
2962
|
+
this.content = e, this.totalElements = t, this.totalPages = r, this.number = i, this.size = s, this.sort = o || { sorted: !1, unsorted: !0, empty: !0 }, this.last = c !== void 0 ? c : i === r - 1, this.first = u !== void 0 ? u : i === 0, this.numberOfElements = p !== void 0 ? p : e.length, this.empty = C !== void 0 ? C : e.length === 0, this.pageable = {
|
|
2929
2963
|
sort: this.sort,
|
|
2930
2964
|
offset: i * s,
|
|
2931
2965
|
pageSize: s,
|
|
@@ -2938,16 +2972,16 @@ class le {
|
|
|
2938
2972
|
return new le(e, t, r, i, s);
|
|
2939
2973
|
}
|
|
2940
2974
|
}
|
|
2941
|
-
function
|
|
2975
|
+
function Ye(n) {
|
|
2942
2976
|
return n.totalElements || n.totalElements === 0 ? n.totalElements : n.page.totalElements;
|
|
2943
2977
|
}
|
|
2944
|
-
function
|
|
2978
|
+
function Xe(n) {
|
|
2945
2979
|
return n.totalPages || n.totalPages === 0 ? n.totalPages : n.page.totalPages;
|
|
2946
2980
|
}
|
|
2947
|
-
function
|
|
2981
|
+
function Ze(n) {
|
|
2948
2982
|
return n.pageable ? n.pageable.pageNumber : n.page.number;
|
|
2949
2983
|
}
|
|
2950
|
-
function
|
|
2984
|
+
function Vt(n) {
|
|
2951
2985
|
const {
|
|
2952
2986
|
name: e,
|
|
2953
2987
|
label: t,
|
|
@@ -2956,28 +2990,28 @@ function Ct(n) {
|
|
|
2956
2990
|
sort: s,
|
|
2957
2991
|
transformData: o,
|
|
2958
2992
|
onLoadComplete: c,
|
|
2959
|
-
onDestroy:
|
|
2960
|
-
filterData:
|
|
2993
|
+
onDestroy: u,
|
|
2994
|
+
filterData: p,
|
|
2961
2995
|
findAll: C,
|
|
2962
|
-
findAllWithSort:
|
|
2963
|
-
findAllWithFilter:
|
|
2964
|
-
findAllWithFilterAndSort:
|
|
2965
|
-
initialDataSource:
|
|
2996
|
+
findAllWithSort: W,
|
|
2997
|
+
findAllWithFilter: M,
|
|
2998
|
+
findAllWithFilterAndSort: P,
|
|
2999
|
+
initialDataSource: L,
|
|
2966
3000
|
pageSize: N = 50,
|
|
2967
3001
|
currentPage: d = 0,
|
|
2968
|
-
loadOnStart:
|
|
3002
|
+
loadOnStart: f = !0,
|
|
2969
3003
|
store: b,
|
|
2970
|
-
id:
|
|
2971
|
-
validator:
|
|
2972
|
-
} = n,
|
|
3004
|
+
id: V,
|
|
3005
|
+
validator: K
|
|
3006
|
+
} = n, m = ce(!1), h = () => !!(b && b.existsValue(e) || L), Y = () => b && b.existsValue(e) ? b.getValue(e) : L || new Ae(r, e, {
|
|
2973
3007
|
records: [],
|
|
2974
3008
|
grandTotalRecords: 0,
|
|
2975
3009
|
currentPage: d,
|
|
2976
3010
|
totalPages: 0,
|
|
2977
3011
|
pageSize: N,
|
|
2978
|
-
validator:
|
|
2979
|
-
}, t), Z = () => b && b.existsValue(e) ? b.getValue(e).getCurrentPage() :
|
|
2980
|
-
dataSource:
|
|
3012
|
+
validator: K
|
|
3013
|
+
}, t), Z = () => b && b.existsValue(e) ? b.getValue(e).getCurrentPage() : L ? L.getCurrentPage() : 0, [E, j] = T({
|
|
3014
|
+
dataSource: Y(),
|
|
2981
3015
|
isLoading: !1,
|
|
2982
3016
|
isError: !1,
|
|
2983
3017
|
error: "",
|
|
@@ -2985,156 +3019,156 @@ function Ct(n) {
|
|
|
2985
3019
|
label: t,
|
|
2986
3020
|
filter: i,
|
|
2987
3021
|
sort: s,
|
|
2988
|
-
id:
|
|
3022
|
+
id: V,
|
|
2989
3023
|
currentPage: Z(),
|
|
2990
3024
|
pageSize: N,
|
|
2991
|
-
loadDataCount:
|
|
2992
|
-
}), ee = async (
|
|
2993
|
-
let
|
|
3025
|
+
loadDataCount: h() ? 1 : 0
|
|
3026
|
+
}), ee = async (y, w, x, $, v, J, te, oe, ae) => {
|
|
3027
|
+
let O;
|
|
2994
3028
|
if (J) {
|
|
2995
|
-
const
|
|
2996
|
-
|
|
3029
|
+
const _ = await r.findOne(J);
|
|
3030
|
+
_ ? O = le.createFromValues([_], 1, 0, 0, 0) : O = le.createFromValues([], 0, 0, 0, 0);
|
|
2997
3031
|
} else
|
|
2998
|
-
|
|
2999
|
-
|
|
3032
|
+
P && $ && v && v.length > 0 ? O = await P($, w, x, v) : M && $ ? O = await M($, 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);
|
|
3033
|
+
p && (O = p(O)), o && (O = o(O)), j((_) => {
|
|
3000
3034
|
const re = {
|
|
3001
|
-
records:
|
|
3002
|
-
grandTotalRecords:
|
|
3003
|
-
totalPages:
|
|
3004
|
-
currentPage:
|
|
3035
|
+
records: O.content,
|
|
3036
|
+
grandTotalRecords: Ye(O),
|
|
3037
|
+
totalPages: Xe(O),
|
|
3038
|
+
currentPage: Ze(O),
|
|
3005
3039
|
pageSize: x,
|
|
3006
3040
|
filter: $,
|
|
3007
|
-
sort:
|
|
3041
|
+
sort: v,
|
|
3008
3042
|
originFilter: te,
|
|
3009
3043
|
originGlobalFilter: ae,
|
|
3010
3044
|
originSort: oe,
|
|
3011
|
-
validator:
|
|
3045
|
+
validator: K
|
|
3012
3046
|
};
|
|
3013
|
-
return
|
|
3014
|
-
...
|
|
3015
|
-
currentPage:
|
|
3047
|
+
return _.dataSource.isActive() ? _.dataSource.setData(re) : _.dataSource.open(re), {
|
|
3048
|
+
..._,
|
|
3049
|
+
currentPage: w,
|
|
3016
3050
|
pageSize: x,
|
|
3017
3051
|
filter: $,
|
|
3018
|
-
sort:
|
|
3052
|
+
sort: v,
|
|
3019
3053
|
id: J,
|
|
3020
3054
|
isLoading: !1,
|
|
3021
3055
|
isError: !1,
|
|
3022
3056
|
error: "",
|
|
3023
|
-
loadDataCount:
|
|
3057
|
+
loadDataCount: _.loadDataCount + 1
|
|
3024
3058
|
};
|
|
3025
|
-
}), b && b.setValue(e,
|
|
3059
|
+
}), b && b.setValue(e, E.dataSource);
|
|
3026
3060
|
};
|
|
3027
|
-
|
|
3028
|
-
c &&
|
|
3029
|
-
}, [
|
|
3030
|
-
const D =
|
|
3031
|
-
if (
|
|
3032
|
-
const
|
|
3061
|
+
q(() => {
|
|
3062
|
+
c && E.loadDataCount > 0 && c(E.dataSource);
|
|
3063
|
+
}, [E.loadDataCount]);
|
|
3064
|
+
const D = l((y) => {
|
|
3065
|
+
if (y.type === a.refreshData) {
|
|
3066
|
+
const w = y.options;
|
|
3033
3067
|
try {
|
|
3034
|
-
|
|
3068
|
+
j((x) => ({
|
|
3035
3069
|
...x,
|
|
3036
3070
|
isLoading: !0,
|
|
3037
|
-
filter:
|
|
3038
|
-
sort:
|
|
3039
|
-
currentPage:
|
|
3040
|
-
id:
|
|
3071
|
+
filter: w.filter,
|
|
3072
|
+
sort: w.sort,
|
|
3073
|
+
currentPage: w.currentPage,
|
|
3074
|
+
id: w.id
|
|
3041
3075
|
})), ee(
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3076
|
+
E.name,
|
|
3077
|
+
w.currentPage,
|
|
3078
|
+
w.pageSize,
|
|
3079
|
+
w.filter,
|
|
3080
|
+
w.sort,
|
|
3081
|
+
w.id,
|
|
3082
|
+
w.originFilter,
|
|
3083
|
+
w.originSort,
|
|
3084
|
+
w.originGlobalFilter
|
|
3051
3085
|
).catch((x) => {
|
|
3052
|
-
const $ =
|
|
3053
|
-
|
|
3054
|
-
...
|
|
3086
|
+
const $ = G(x);
|
|
3087
|
+
j((v) => ({
|
|
3088
|
+
...v,
|
|
3055
3089
|
isError: !0,
|
|
3056
3090
|
isLoading: !1,
|
|
3057
3091
|
error: $
|
|
3058
3092
|
})), n.onError && n.onError($, x);
|
|
3059
3093
|
});
|
|
3060
3094
|
} catch (x) {
|
|
3061
|
-
const $ =
|
|
3062
|
-
|
|
3063
|
-
...
|
|
3095
|
+
const $ = G(x);
|
|
3096
|
+
j((v) => ({
|
|
3097
|
+
...v,
|
|
3064
3098
|
isError: !0,
|
|
3065
3099
|
isLoading: !1,
|
|
3066
3100
|
error: $
|
|
3067
3101
|
})), n.onError && n.onError($, x);
|
|
3068
3102
|
}
|
|
3069
3103
|
}
|
|
3070
|
-
}, [ee,
|
|
3071
|
-
|
|
3072
|
-
}, [D]), A =
|
|
3073
|
-
|
|
3104
|
+
}, [ee, E.name, n.onError]), S = l((y) => {
|
|
3105
|
+
m.current || (y.addListener(D), m.current = !0);
|
|
3106
|
+
}, [D]), A = l((y) => {
|
|
3107
|
+
m.current && (y.removeListener(D), m.current = !1);
|
|
3074
3108
|
}, [D]);
|
|
3075
|
-
|
|
3109
|
+
q(() => {
|
|
3076
3110
|
try {
|
|
3077
|
-
return S(
|
|
3078
|
-
|
|
3111
|
+
return S(E.dataSource), f && E.loadDataCount === 0 ? (j((y) => ({ ...y, isLoading: !0 })), ee(
|
|
3112
|
+
E.name,
|
|
3079
3113
|
d,
|
|
3080
3114
|
N,
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
).catch((
|
|
3085
|
-
const
|
|
3086
|
-
|
|
3115
|
+
E.filter,
|
|
3116
|
+
E.sort,
|
|
3117
|
+
E.id
|
|
3118
|
+
).catch((y) => {
|
|
3119
|
+
const w = G(y);
|
|
3120
|
+
j((x) => ({
|
|
3087
3121
|
...x,
|
|
3088
3122
|
isError: !0,
|
|
3089
3123
|
isLoading: !1,
|
|
3090
|
-
error:
|
|
3091
|
-
})), n.onError && n.onError(
|
|
3092
|
-
})) : c && c(
|
|
3093
|
-
|
|
3124
|
+
error: w
|
|
3125
|
+
})), n.onError && n.onError(w, y);
|
|
3126
|
+
})) : c && c(E.dataSource), () => {
|
|
3127
|
+
u && (A(E.dataSource), u(E.dataSource));
|
|
3094
3128
|
};
|
|
3095
|
-
} catch (
|
|
3096
|
-
const
|
|
3097
|
-
|
|
3129
|
+
} catch (y) {
|
|
3130
|
+
const w = G(y);
|
|
3131
|
+
j((x) => ({
|
|
3098
3132
|
...x,
|
|
3099
3133
|
isError: !0,
|
|
3100
3134
|
isLoading: !1,
|
|
3101
|
-
error:
|
|
3102
|
-
})), n.onError && n.onError(
|
|
3135
|
+
error: w
|
|
3136
|
+
})), n.onError && n.onError(w, y);
|
|
3103
3137
|
}
|
|
3104
3138
|
}, [
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3139
|
+
E.name,
|
|
3140
|
+
E.sort,
|
|
3141
|
+
E.filter,
|
|
3142
|
+
E.id,
|
|
3143
|
+
E.currentPage,
|
|
3144
|
+
E.pageSize
|
|
3111
3145
|
]);
|
|
3112
3146
|
const B = () => {
|
|
3113
|
-
|
|
3114
|
-
...
|
|
3147
|
+
j((y) => ({
|
|
3148
|
+
...y,
|
|
3115
3149
|
isError: !1,
|
|
3116
3150
|
isLoading: !1,
|
|
3117
3151
|
error: ""
|
|
3118
3152
|
}));
|
|
3119
3153
|
};
|
|
3120
3154
|
return {
|
|
3121
|
-
isLoading:
|
|
3122
|
-
isError:
|
|
3123
|
-
error:
|
|
3124
|
-
dataSource:
|
|
3155
|
+
isLoading: E.isLoading,
|
|
3156
|
+
isError: E.isError,
|
|
3157
|
+
error: E.error,
|
|
3158
|
+
dataSource: E.dataSource,
|
|
3125
3159
|
clearError: B
|
|
3126
3160
|
};
|
|
3127
3161
|
}
|
|
3128
|
-
function
|
|
3162
|
+
function et(n) {
|
|
3129
3163
|
return n.totalElements || n.totalElements === 0 ? n.totalElements : n.page.totalElements;
|
|
3130
3164
|
}
|
|
3131
|
-
function
|
|
3165
|
+
function tt(n) {
|
|
3132
3166
|
return n.totalPages || n.totalPages === 0 ? n.totalPages : n.page.totalPages;
|
|
3133
3167
|
}
|
|
3134
|
-
function
|
|
3168
|
+
function rt(n) {
|
|
3135
3169
|
return n.pageable ? n.pageable.pageNumber : n.page.number;
|
|
3136
3170
|
}
|
|
3137
|
-
function
|
|
3171
|
+
function Tt(n) {
|
|
3138
3172
|
const {
|
|
3139
3173
|
name: e,
|
|
3140
3174
|
service: t,
|
|
@@ -3143,26 +3177,26 @@ function bt(n) {
|
|
|
3143
3177
|
transformData: s,
|
|
3144
3178
|
onLoadComplete: o,
|
|
3145
3179
|
onDestroy: c,
|
|
3146
|
-
filterData:
|
|
3147
|
-
findAll:
|
|
3180
|
+
filterData: u,
|
|
3181
|
+
findAll: p,
|
|
3148
3182
|
findAllWithSort: C,
|
|
3149
|
-
findAllWithFilter:
|
|
3150
|
-
findAllWithFilterAndSort:
|
|
3151
|
-
initialDataSource:
|
|
3152
|
-
pageSize:
|
|
3183
|
+
findAllWithFilter: W,
|
|
3184
|
+
findAllWithFilterAndSort: M,
|
|
3185
|
+
initialDataSource: P,
|
|
3186
|
+
pageSize: L = 50,
|
|
3153
3187
|
currentPage: N = 0,
|
|
3154
3188
|
loadOnStart: d = !0,
|
|
3155
|
-
store:
|
|
3189
|
+
store: f,
|
|
3156
3190
|
validator: b
|
|
3157
|
-
} = n,
|
|
3191
|
+
} = n, V = () => !!(f && f.existsValue(e) || P), K = () => f && f.existsValue(e) ? f.getValue(e) : P || new Je(t, e, {
|
|
3158
3192
|
records: [],
|
|
3159
3193
|
grandTotalRecords: 0,
|
|
3160
3194
|
currentPage: N,
|
|
3161
3195
|
totalPages: 0,
|
|
3162
|
-
pageSize:
|
|
3196
|
+
pageSize: L,
|
|
3163
3197
|
validator: b
|
|
3164
|
-
}), [
|
|
3165
|
-
dataSource:
|
|
3198
|
+
}), [m, h] = T({
|
|
3199
|
+
dataSource: K(),
|
|
3166
3200
|
isLoading: !1,
|
|
3167
3201
|
isError: !1,
|
|
3168
3202
|
error: "",
|
|
@@ -3170,20 +3204,20 @@ function bt(n) {
|
|
|
3170
3204
|
filter: r,
|
|
3171
3205
|
sort: i,
|
|
3172
3206
|
currentPage: N,
|
|
3173
|
-
pageSize:
|
|
3174
|
-
loadDataCount:
|
|
3175
|
-
}),
|
|
3176
|
-
let
|
|
3177
|
-
|
|
3207
|
+
pageSize: L,
|
|
3208
|
+
loadDataCount: V() ? 1 : 0
|
|
3209
|
+
}), Y = async (D, S, A, B, y, w, x, $) => {
|
|
3210
|
+
let v;
|
|
3211
|
+
M && B && y && y.length > 0 ? v = await M(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), u && (v = u(v)), s && (v = s(v)), h((J) => {
|
|
3178
3212
|
const te = {
|
|
3179
|
-
records:
|
|
3180
|
-
grandTotalRecords:
|
|
3181
|
-
totalPages:
|
|
3182
|
-
currentPage:
|
|
3213
|
+
records: v.content,
|
|
3214
|
+
grandTotalRecords: et(v),
|
|
3215
|
+
totalPages: tt(v),
|
|
3216
|
+
currentPage: rt(v),
|
|
3183
3217
|
pageSize: A,
|
|
3184
3218
|
filter: B,
|
|
3185
|
-
sort:
|
|
3186
|
-
originFilter:
|
|
3219
|
+
sort: y,
|
|
3220
|
+
originFilter: w,
|
|
3187
3221
|
originGlobalFilter: $,
|
|
3188
3222
|
originSort: x,
|
|
3189
3223
|
validator: b
|
|
@@ -3193,25 +3227,25 @@ function bt(n) {
|
|
|
3193
3227
|
currentPage: S,
|
|
3194
3228
|
pageSize: A,
|
|
3195
3229
|
filter: B,
|
|
3196
|
-
sort:
|
|
3230
|
+
sort: y,
|
|
3197
3231
|
isLoading: !1,
|
|
3198
3232
|
isError: !1,
|
|
3199
3233
|
error: "",
|
|
3200
3234
|
loadDataCount: J.loadDataCount + 1
|
|
3201
3235
|
};
|
|
3202
|
-
}),
|
|
3236
|
+
}), f && f.setValue(e, m.dataSource), o && o(m.dataSource);
|
|
3203
3237
|
}, Z = (D) => {
|
|
3204
3238
|
if (D.type === a.refreshData) {
|
|
3205
3239
|
const S = D.options;
|
|
3206
3240
|
try {
|
|
3207
|
-
|
|
3241
|
+
h((A) => ({
|
|
3208
3242
|
...A,
|
|
3209
3243
|
isLoading: !0,
|
|
3210
3244
|
filter: S.filter,
|
|
3211
3245
|
sort: S.sort,
|
|
3212
3246
|
currentPage: S.currentPage
|
|
3213
|
-
})),
|
|
3214
|
-
|
|
3247
|
+
})), Y(
|
|
3248
|
+
m.name,
|
|
3215
3249
|
S.currentPage,
|
|
3216
3250
|
S.pageSize,
|
|
3217
3251
|
S.filter,
|
|
@@ -3220,51 +3254,51 @@ function bt(n) {
|
|
|
3220
3254
|
S.originSort,
|
|
3221
3255
|
S.originGlobalFilter
|
|
3222
3256
|
).catch((A) => {
|
|
3223
|
-
const B =
|
|
3224
|
-
|
|
3225
|
-
...
|
|
3257
|
+
const B = G(A);
|
|
3258
|
+
h((y) => ({
|
|
3259
|
+
...y,
|
|
3226
3260
|
isError: !0,
|
|
3227
3261
|
isLoading: !1,
|
|
3228
3262
|
error: B
|
|
3229
3263
|
})), n.onError && n.onError(B, A);
|
|
3230
3264
|
});
|
|
3231
3265
|
} catch (A) {
|
|
3232
|
-
const B =
|
|
3233
|
-
|
|
3234
|
-
...
|
|
3266
|
+
const B = G(A);
|
|
3267
|
+
h((y) => ({
|
|
3268
|
+
...y,
|
|
3235
3269
|
isError: !0,
|
|
3236
3270
|
isLoading: !1,
|
|
3237
3271
|
error: B
|
|
3238
3272
|
})), n.onError && n.onError(B, A);
|
|
3239
3273
|
}
|
|
3240
3274
|
}
|
|
3241
|
-
},
|
|
3275
|
+
}, E = (D) => {
|
|
3242
3276
|
D.addListener(Z);
|
|
3243
|
-
},
|
|
3277
|
+
}, j = (D) => {
|
|
3244
3278
|
D.removeListener(Z);
|
|
3245
3279
|
};
|
|
3246
|
-
|
|
3280
|
+
q(() => {
|
|
3247
3281
|
try {
|
|
3248
|
-
return
|
|
3249
|
-
|
|
3282
|
+
return E(m.dataSource), d && m.loadDataCount === 0 && (h((D) => ({ ...D, isLoading: !0 })), Y(
|
|
3283
|
+
m.name,
|
|
3250
3284
|
N,
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3285
|
+
L,
|
|
3286
|
+
m.filter,
|
|
3287
|
+
m.sort
|
|
3254
3288
|
).catch((D) => {
|
|
3255
|
-
const S =
|
|
3256
|
-
|
|
3289
|
+
const S = G(D);
|
|
3290
|
+
h((A) => ({
|
|
3257
3291
|
...A,
|
|
3258
3292
|
isError: !0,
|
|
3259
3293
|
isLoading: !1,
|
|
3260
3294
|
error: S
|
|
3261
3295
|
})), n.onError && n.onError(S, D);
|
|
3262
3296
|
})), () => {
|
|
3263
|
-
c && (
|
|
3297
|
+
c && (j(m.dataSource), c(m.dataSource));
|
|
3264
3298
|
};
|
|
3265
3299
|
} catch (D) {
|
|
3266
|
-
const S =
|
|
3267
|
-
|
|
3300
|
+
const S = G(D);
|
|
3301
|
+
h((A) => ({
|
|
3268
3302
|
...A,
|
|
3269
3303
|
isError: !0,
|
|
3270
3304
|
isLoading: !1,
|
|
@@ -3272,14 +3306,14 @@ function bt(n) {
|
|
|
3272
3306
|
})), n.onError && n.onError(S, D);
|
|
3273
3307
|
}
|
|
3274
3308
|
}, [
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3309
|
+
m.name,
|
|
3310
|
+
m.sort,
|
|
3311
|
+
m.filter,
|
|
3312
|
+
m.currentPage,
|
|
3313
|
+
m.pageSize
|
|
3280
3314
|
]);
|
|
3281
3315
|
const ee = () => {
|
|
3282
|
-
|
|
3316
|
+
h((D) => ({
|
|
3283
3317
|
...D,
|
|
3284
3318
|
isError: !1,
|
|
3285
3319
|
isLoading: !1,
|
|
@@ -3287,46 +3321,46 @@ function bt(n) {
|
|
|
3287
3321
|
}));
|
|
3288
3322
|
};
|
|
3289
3323
|
return {
|
|
3290
|
-
isLoading:
|
|
3291
|
-
isError:
|
|
3292
|
-
error:
|
|
3293
|
-
dataSource:
|
|
3324
|
+
isLoading: m.isLoading,
|
|
3325
|
+
isError: m.isError,
|
|
3326
|
+
error: m.error,
|
|
3327
|
+
dataSource: m.dataSource,
|
|
3294
3328
|
clearError: ee
|
|
3295
3329
|
};
|
|
3296
3330
|
}
|
|
3297
|
-
function
|
|
3298
|
-
return
|
|
3331
|
+
function Ot(n) {
|
|
3332
|
+
return Me((e) => e.get(n));
|
|
3299
3333
|
}
|
|
3300
|
-
function
|
|
3301
|
-
|
|
3334
|
+
function Pt(n) {
|
|
3335
|
+
q(() => {
|
|
3302
3336
|
n();
|
|
3303
3337
|
}, []);
|
|
3304
3338
|
}
|
|
3305
|
-
function
|
|
3306
|
-
|
|
3339
|
+
function Lt(n, e) {
|
|
3340
|
+
q(() => {
|
|
3307
3341
|
n();
|
|
3308
3342
|
}, e);
|
|
3309
3343
|
}
|
|
3310
|
-
function
|
|
3311
|
-
|
|
3344
|
+
function Bt(n) {
|
|
3345
|
+
q(() => () => {
|
|
3312
3346
|
n();
|
|
3313
3347
|
}, []);
|
|
3314
3348
|
}
|
|
3315
|
-
function
|
|
3316
|
-
const [, n] =
|
|
3317
|
-
return
|
|
3349
|
+
function $t() {
|
|
3350
|
+
const [, n] = T(0);
|
|
3351
|
+
return l(() => {
|
|
3318
3352
|
n((t) => t + 1);
|
|
3319
3353
|
}, []);
|
|
3320
3354
|
}
|
|
3321
|
-
const
|
|
3322
|
-
function
|
|
3323
|
-
const [, n] =
|
|
3355
|
+
const it = (n) => (n + 1) % 1e6;
|
|
3356
|
+
function st() {
|
|
3357
|
+
const [, n] = ze(it, 0);
|
|
3324
3358
|
return n;
|
|
3325
3359
|
}
|
|
3326
|
-
function
|
|
3327
|
-
return
|
|
3360
|
+
function Nt() {
|
|
3361
|
+
return st();
|
|
3328
3362
|
}
|
|
3329
|
-
const
|
|
3363
|
+
const nt = je((n, e) => ({
|
|
3330
3364
|
values: /* @__PURE__ */ new Map(),
|
|
3331
3365
|
setValue: (t, r) => n((i) => {
|
|
3332
3366
|
const s = new Map(i.values);
|
|
@@ -3340,24 +3374,24 @@ const rt = We((n, e) => ({
|
|
|
3340
3374
|
}),
|
|
3341
3375
|
clearAllValues: () => n((t) => ({ values: /* @__PURE__ */ new Map() })),
|
|
3342
3376
|
reset: () => n((t) => ({ values: /* @__PURE__ */ new Map() }))
|
|
3343
|
-
})),
|
|
3344
|
-
const e =
|
|
3345
|
-
return { setValue: (
|
|
3346
|
-
e.setValue(`${n}.${
|
|
3347
|
-
}, getValue: (
|
|
3348
|
-
e.clearValue(`${n}.${
|
|
3349
|
-
}, existsValue: (
|
|
3350
|
-
for (const [
|
|
3351
|
-
|
|
3377
|
+
})), ot = ke(nt), Ht = (n = "default") => {
|
|
3378
|
+
const e = ot();
|
|
3379
|
+
return { setValue: (p, C) => {
|
|
3380
|
+
e.setValue(`${n}.${p}`, C);
|
|
3381
|
+
}, getValue: (p) => e.getValue(`${n}.${p}`), clearValue: (p) => {
|
|
3382
|
+
e.clearValue(`${n}.${p}`);
|
|
3383
|
+
}, existsValue: (p) => e.existsValue(`${n}.${p}`), clearAllValues: () => {
|
|
3384
|
+
for (const [p, C] of e.values.entries())
|
|
3385
|
+
p.startsWith(`${n}.`) && e.clearValue(p);
|
|
3352
3386
|
}, reset: () => {
|
|
3353
3387
|
e.clearAllValues();
|
|
3354
3388
|
}, values: e.values };
|
|
3355
3389
|
};
|
|
3356
|
-
function
|
|
3390
|
+
function Wt(n, e, t = window) {
|
|
3357
3391
|
const r = ce(e);
|
|
3358
|
-
|
|
3392
|
+
q(() => {
|
|
3359
3393
|
r.current = e;
|
|
3360
|
-
}, [e]),
|
|
3394
|
+
}, [e]), q(
|
|
3361
3395
|
() => {
|
|
3362
3396
|
if (t && t.addEventListener && r.current) {
|
|
3363
3397
|
const s = (o) => r.current(o);
|
|
@@ -3371,46 +3405,46 @@ function $t(n, e, t = window) {
|
|
|
3371
3405
|
);
|
|
3372
3406
|
}
|
|
3373
3407
|
export {
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3408
|
+
jt as ADVANCED,
|
|
3409
|
+
kt as ARCHBASE_IOC_API_TYPE,
|
|
3410
|
+
xt as ARCHBASE_QUERY_DEFAULTS,
|
|
3377
3411
|
be as ArchbaseAxiosRemoteApiClient,
|
|
3378
3412
|
ye as ArchbaseDataSource,
|
|
3379
3413
|
U as ArchbaseDataSourceV2,
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3414
|
+
Ge as ArchbaseLocalFilterDataSource,
|
|
3415
|
+
At as ArchbaseQueryUtils,
|
|
3416
|
+
Ke as ArchbaseRemoteApiService,
|
|
3383
3417
|
Ae as ArchbaseRemoteDataSource,
|
|
3384
|
-
|
|
3385
|
-
|
|
3418
|
+
Qe as ArchbaseRemoteDataSourceV2,
|
|
3419
|
+
Je as ArchbaseRemoteFilterDataSource,
|
|
3386
3420
|
a as DataSourceEventNames,
|
|
3387
3421
|
le as DefaultPage,
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3422
|
+
Ut as FILTER_TYPE,
|
|
3423
|
+
_e as LocalFilter,
|
|
3424
|
+
vt as MigrationValidation,
|
|
3425
|
+
_t as NORMAL,
|
|
3426
|
+
Gt as QUICK,
|
|
3427
|
+
qe as RemoteFilter,
|
|
3428
|
+
It as USAGE_EXAMPLE,
|
|
3429
|
+
qt as useArchbaseBool,
|
|
3430
|
+
Ct as useArchbaseDataSource,
|
|
3431
|
+
bt as useArchbaseDataSourceListener,
|
|
3398
3432
|
xe as useArchbaseDataSourceV2,
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3433
|
+
Et as useArchbaseDataSourceV2Editor,
|
|
3434
|
+
wt as useArchbaseDataSourceV2ReadOnly,
|
|
3435
|
+
Pt as useArchbaseDidMount,
|
|
3436
|
+
Lt as useArchbaseDidUpdate,
|
|
3437
|
+
Wt as useArchbaseEventListener,
|
|
3438
|
+
$t as useArchbaseForceRerender,
|
|
3439
|
+
Nt as useArchbaseForceUpdate,
|
|
3440
|
+
Dt as useArchbaseLocalFilterDataSource,
|
|
3441
|
+
Vt as useArchbaseRemoteDataSource,
|
|
3408
3442
|
Ce as useArchbaseRemoteDataSourceV2,
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3443
|
+
Ft as useArchbaseRemoteDataSourceV2Editor,
|
|
3444
|
+
St as useArchbaseRemoteDataSourceV2ReadOnly,
|
|
3445
|
+
Tt as useArchbaseRemoteFilterDataSource,
|
|
3446
|
+
Ot as useArchbaseRemoteServiceApi,
|
|
3447
|
+
Ht as useArchbaseStore,
|
|
3448
|
+
yt as useArchbaseV1V2Compatibility,
|
|
3449
|
+
Bt as useArchbaseWillUnmount
|
|
3416
3450
|
};
|