@archbase/data 4.0.1 → 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
- import { isDate as we, parseISO as Ee } from "date-fns";
2
- import { EventEmitter as Le } from "events";
3
- import { uniqueId as Be, cloneDeep as $e } from "lodash";
4
- import { archbaseI18next as m, ArchbaseDataSourceError as g, ArchbaseObjectHelper as ye, processErrorMessage as G, QUICK as Se, NORMAL as Fe, ADVANCED as Ae, ArchbaseFilterDSL as xe, QueryFilterEntity as ue, detectDataSourceVersion as ve, MigrationMetrics as Ne, ARCHBASE_IOC_API_TYPE as He, ArchbaseJacksonParser as ie } from "@archbase/core";
5
- import { ADVANCED as Mt, ARCHBASE_IOC_API_TYPE as jt, FILTER_TYPE as kt, NORMAL as Ut, QUICK as Gt, useArchbaseBool as qt } from "@archbase/core";
6
- import { useState as C, useCallback as l, useRef as le, useMemo as H, useEffect as J, useReducer as We } from "react";
7
- import { produce as _ } from "immer";
1
+ import { isDate as ve, parseISO as Ie } from "date-fns";
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
+ import { produce as Q } from "immer";
8
8
  import "reflect-metadata";
9
- import Y from "axios";
9
+ import X from "axios";
10
10
  import * as ne from "inversify";
11
- import { useContainer as ze } from "inversify-react";
12
- import { create as Me } from "zustand";
13
- import { createTrackedSelector as je } from "react-tracked";
14
- var d = /* @__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))(d || {});
15
- class ke {
11
+ import { useContainer as Me } from "inversify-react";
12
+ import { create as je } from "zustand";
13
+ import { createTrackedSelector as ke } from "react-tracked";
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 Ue {
16
16
  eventEmitter;
17
17
  listenersDisable = !1;
18
18
  constructor() {
19
- this.eventEmitter = new Le();
19
+ this.eventEmitter = new Be();
20
20
  }
21
21
  disabledAllListeners() {
22
22
  return this.listenersDisable = !0, this;
@@ -46,7 +46,7 @@ class ke {
46
46
  return this.eventEmitter.removeAllListeners(e), this;
47
47
  }
48
48
  }
49
- class Ie {
49
+ class ye {
50
50
  fieldEventListeners;
51
51
  records;
52
52
  filteredRecords;
@@ -79,14 +79,14 @@ class Ie {
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 ke(), this.uuid = Be(), this.validator = t.validator, this.getIdentity = t.getIdentity;
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 = m.t("archbase:operationNotAllowed", { dataSourceName: this.name, operation: e });
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 Ie {
99
99
  */
100
100
  clear() {
101
101
  if (!this.isActive()) {
102
- const e = m.t("archbase:operationNotAllowed", { dataSourceName: this.name, operation: "clear" });
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 Ie {
151
151
  }
152
152
  goToRecord(e) {
153
153
  if (this.validateDataSourceActive("goToRecord"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
154
- const t = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
190
190
  }
191
191
  append(e) {
192
192
  if (this.validateDataSourceActive("append"), this.inserting || this.editing) {
193
- const t = m.t("archbase:insertRecordIsNotAllowed", { dataSourceName: this.name });
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 Ie {
209
209
  }
210
210
  insert(e) {
211
211
  if (this.validateDataSourceActive("insert"), this.inserting || this.editing) {
212
- const r = m.t("archbase:insertRecordIsNotAllowed", { dataSourceName: this.name });
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 Ie {
228
228
  }
229
229
  edit() {
230
230
  if (this.validateDataSourceActive("edit"), this.inserting || this.editing) {
231
- const e = m.t("archbase:editRecordIsNotAllowed", { dataSourceName: this.name });
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 = m.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
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 = m.t("archbase:BOFDataSource", { dataSourceName: this.name });
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 = m.t("archbase:EOFDataSource", { dataSourceName: this.name });
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 = $e(this.currentRecord), this.emitter.emit("afterEdit", this.currentRecord, this.getCurrentIndex()), this.emit({
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 Ie {
255
255
  }
256
256
  async remove(e) {
257
257
  if (this.validateDataSourceActive("remove"), this.inserting || this.editing) {
258
- const s = m.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
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 = m.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
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 = m.t("archbase:BOFDataSource", { dataSourceName: this.name });
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 = m.t("archbase:EOFDataSource", { dataSourceName: this.name });
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 Ie {
306
306
  publishEventErrors = (e) => {
307
307
  e.forEach((t) => {
308
308
  if (t.fieldName) {
309
- const r = m.t(t.errorMessage, { keySeparator: !1 });
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 Ie {
314
314
  originalError: t
315
315
  });
316
316
  } else
317
- this.publishEventError(m.t(t.errorMessage, { keySeparator: !1 }), t);
317
+ this.publishEventError(R.t(t.errorMessage, { keySeparator: !1 }), t);
318
318
  });
319
319
  };
320
320
  publishEventError = (e, t) => {
@@ -329,7 +329,7 @@ class Ie {
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 = m.t("archbase:errorSavingRecord", { dataSourceName: this.label });
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 Ie {
338
338
  }
339
339
  async save(e) {
340
340
  if (this.validateDataSourceActive("save"), !this.inserting && !this.editing) {
341
- const r = m.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
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 = m.t("archbase:noRecordToSave", { dataSourceName: this.name });
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 Ie {
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 = m.t("archbase:errorSavingRecord", { dataSourceName: this.label });
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 Ie {
371
371
  }
372
372
  cancel() {
373
373
  if (this.validateDataSourceActive("cancel"), !this.inserting && !this.editing) {
374
- const e = m.t("archbase:notAllowCancelRecord", { dataSourceName: this.name });
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 Ie {
401
401
  }
402
402
  getFieldValue(e, t = "") {
403
403
  if (this.validateDataSourceActive("getFieldValue"), !e) {
404
- const s = m.t("archbase:invalidFieldName", { dataSourceName: this.name });
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)
@@ -414,20 +414,20 @@ class Ie {
414
414
  fieldValueByName(e, t) {
415
415
  if (e === void 0)
416
416
  return;
417
- const r = ye.getNestedProperty(e, t);
417
+ const r = Re.getNestedProperty(e, t);
418
418
  if (r !== void 0)
419
- return we(r) ? Ee(r) : r;
419
+ return ve(r) ? Ie(r) : r;
420
420
  }
421
421
  setFieldValue(e, t) {
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 = m.t("archbase:recordNotBeingEdited", { dataSourceName: this.name });
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;
429
- const i = ye.getNestedProperty(this.currentRecord, e);
430
- return we(t) && (r = Ee(t)), e.split(".").length > 1 ? ye.setNestedProperty(this.currentRecord, e, r) : this.currentRecord[e] = r, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.emitFieldChangeEvent(e, i, r), this.emitter.emit("fieldChanged", this.currentRecord, this.getCurrentIndex(), e, i, r), this.emit({
429
+ const i = Re.getNestedProperty(this.currentRecord, e);
430
+ return ve(t) && (r = Ie(t)), e.split(".").length > 1 ? Re.setNestedProperty(this.currentRecord, e, r) : this.currentRecord[e] = r, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.emitFieldChangeEvent(e, i, r), this.emitter.emit("fieldChanged", this.currentRecord, this.getCurrentIndex(), e, i, r), this.emit({
431
431
  type: 3,
432
432
  record: this.currentRecord,
433
433
  index: this.getCurrentIndex(),
@@ -489,7 +489,7 @@ class Ie {
489
489
  }
490
490
  next() {
491
491
  if (this.validateDataSourceActive("next"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
492
- const e = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
499
499
  }
500
500
  prior() {
501
501
  if (this.validateDataSourceActive("prior"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
502
- const e = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
509
509
  }
510
510
  first() {
511
511
  if (this.validateDataSourceActive("first"), this.inserting || this.editing) {
512
- const e = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
519
519
  }
520
520
  last() {
521
521
  if (this.validateDataSourceActive("last"), this.inserting || this.editing) {
522
- const e = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
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 = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
545
545
  }
546
546
  gotoRecordByData(e) {
547
547
  if (this.validateDataSourceActive("gotoRecordByData"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
548
- const r = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
565
565
  }
566
566
  locate(e) {
567
567
  if (!this.isBrowsing()) {
568
- const i = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
579
579
  }
580
580
  locateByFilter(e) {
581
581
  if (this.validateDataSourceActive("locate"), this.inserting || this.editing) {
582
- const r = m.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
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 Ie {
613
613
  i = o === 0 ? s : `${i}.${s}`;
614
614
  const c = this.fieldEventListeners[`field:${i}`];
615
615
  if (c) {
616
- const f = c.indexOf(t);
617
- f !== -1 && c.splice(f, 1);
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 Ie {
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((f) => f(s, t, r));
627
+ c && c.forEach((u) => u(s, t, r));
628
628
  }
629
629
  }
630
630
  /**
@@ -641,29 +641,29 @@ class Ie {
641
641
  }));
642
642
  }
643
643
  }
644
- class Ce extends Ie {
644
+ class Ae extends ye {
645
645
  service;
646
646
  constructor(e, t, r, i) {
647
647
  super(t, r, i), this.service = e;
648
648
  }
649
649
  async save(e) {
650
650
  if (this.validateDataSourceActive("save"), !this.inserting && !this.editing) {
651
- const t = m.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
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 = m.t("archbase:noRecordToSave", { dataSourceName: this.name });
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({
659
- type: d.beforeSave,
659
+ type: a.beforeSave,
660
660
  record: this.currentRecord,
661
661
  index: this.getCurrentIndex()
662
662
  }), this.validator) {
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 = m.t("archbase:errorSavingRecord", { dataSourceName: this.label });
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);
@@ -674,16 +674,16 @@ class Ce extends Ie {
674
674
  const s = this.getIdentity ? this.getIdentity(r) : r.id, o = this.getIdentity ? this.getIdentity(this.currentRecord) : this.currentRecord.id;
675
675
  (r === this.currentRecord || s !== void 0 && s === o) && (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: d.afterSave,
677
+ type: a.afterSave,
678
678
  record: this.currentRecord,
679
679
  index: this.getCurrentIndex()
680
680
  }), e && e();
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 = m.t(i.message, { defaultValue: i.message });
684
+ const s = R.t(i.message, { defaultValue: i.message });
685
685
  this.emitter.emit("onFieldError", i.field, s), this.emit({
686
- type: d.onFieldError,
686
+ type: a.onFieldError,
687
687
  fieldName: i.field,
688
688
  error: s,
689
689
  originalError: i.message
@@ -692,7 +692,7 @@ class Ce extends Ie {
692
692
  });
693
693
  const r = G(t);
694
694
  throw this.emitter.emit("onError", r, t), this.emit({
695
- type: d.onError,
695
+ type: a.onError,
696
696
  error: r,
697
697
  originalError: t
698
698
  }), e && e(r), new g(r);
@@ -701,25 +701,25 @@ class Ce extends Ie {
701
701
  }
702
702
  async remove(e) {
703
703
  if (this.validateDataSourceActive("remove"), this.inserting || this.editing) {
704
- const t = m.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
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 = m.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
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 = m.t("archbase:BOFDataSource", { dataSourceName: this.name });
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 = m.t("archbase:EOFDataSource", { dataSourceName: this.name });
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({
722
- type: d.beforeRemove,
722
+ type: a.beforeRemove,
723
723
  record: this.currentRecord,
724
724
  index: this.getCurrentIndex()
725
725
  });
@@ -729,25 +729,25 @@ class Ce extends Ie {
729
729
  const r = this.currentRecord, i = this.currentRecordIndex;
730
730
  return this.records = [...this.records], this.filteredRecords = [...this.filteredRecords], this.records.forEach((s, o) => {
731
731
  this.currentRecord === s && (t = o);
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: d.afterScroll }), this.emitter.emit("afterRemove", r, i), this.emit({
733
- type: d.afterRemove,
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: a.afterScroll }), this.emitter.emit("afterRemove", r, i), this.emit({
733
+ type: a.afterRemove,
734
734
  record: r,
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
738
  const r = G(t);
739
739
  throw this.emitter.emit("onError", r, t), this.emit({
740
- type: d.onError,
740
+ type: a.onError,
741
741
  error: r,
742
742
  originalError: t
743
743
  }), e && e(r), new g(r);
744
744
  }
745
745
  }
746
746
  applyRemoteFilter(e, t, r) {
747
- return e && e.filter.filterType === Se && e.filter.quickFilterText && e.filter.quickFilterText !== "" ? this.getDataWithQuickFilter(e, t) : e && (e.filter.filterType === Fe || e.filter.filterType === Ae) ? this.getDataWithFilter(e, t) : this.getDataWithoutFilter(t);
747
+ return e && e.filter.filterType === we && e.filter.quickFilterText && e.filter.quickFilterText !== "" ? this.getDataWithQuickFilter(e, t) : e && (e.filter.filterType === Ee || e.filter.filterType === Se) ? this.getDataWithFilter(e, t) : this.getDataWithoutFilter(t);
748
748
  }
749
749
  async getDataWithFilter(e, t) {
750
- const r = new xe();
750
+ const r = new Fe();
751
751
  r.buildFrom(e.filter, e.sort);
752
752
  const i = r.toJSON();
753
753
  let s;
@@ -770,7 +770,7 @@ class Ce extends Ie {
770
770
  return e && e.sort ? e.sort.quickFilterSort : this.defaultSortFields;
771
771
  }
772
772
  }
773
- class Ue {
773
+ class _e {
774
774
  id;
775
775
  companyId;
776
776
  filter;
@@ -788,13 +788,13 @@ class Ue {
788
788
  Object.assign(this, e);
789
789
  }
790
790
  }
791
- class Ge extends Ie {
791
+ class Ge extends ye {
792
792
  getFilterById(e) {
793
793
  if (this.locate({ id: e }))
794
794
  return this.convertCurrentRecordToFilter();
795
795
  }
796
796
  convertCurrentRecordToFilter() {
797
- return new ue({
797
+ return new he({
798
798
  id: this.getFieldValue("id"),
799
799
  name: this.getFieldValue("name"),
800
800
  description: this.getFieldValue("description"),
@@ -808,7 +808,7 @@ class Ge extends Ie {
808
808
  }
809
809
  async addNewFilter(e, t) {
810
810
  this.insert(
811
- new Ue({
811
+ new _e({
812
812
  id: e.id,
813
813
  name: e.name,
814
814
  description: e.description,
@@ -842,7 +842,7 @@ class Ge extends Ie {
842
842
  }
843
843
  getFilters() {
844
844
  return this.getTotalRecords() > 0 ? this.browseRecords().map(
845
- (e) => new ue({
845
+ (e) => new he({
846
846
  id: e.id,
847
847
  name: e.name,
848
848
  description: e.description,
@@ -875,13 +875,13 @@ class qe {
875
875
  Object.assign(this, e);
876
876
  }
877
877
  }
878
- class _e extends Ce {
878
+ class Je extends Ae {
879
879
  getFilterById(e) {
880
880
  if (this.locate({ id: e }))
881
881
  return this.convertCurrentRecordToFilter();
882
882
  }
883
883
  convertCurrentRecordToFilter() {
884
- return new ue({
884
+ return new he({
885
885
  id: this.getFieldValue("id"),
886
886
  name: this.getFieldValue("name"),
887
887
  description: this.getFieldValue("description"),
@@ -932,7 +932,7 @@ class _e extends Ce {
932
932
  }
933
933
  getFilters() {
934
934
  return this.getTotalRecords() > 0 ? this.browseRecords().map(
935
- (e) => new ue({
935
+ (e) => new he({
936
936
  id: e.id,
937
937
  name: e.name,
938
938
  description: e.description,
@@ -946,41 +946,41 @@ class _e extends Ce {
946
946
  ) : [];
947
947
  }
948
948
  }
949
- function pt(n, e, t, r) {
950
- const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s, o] = C(r), [, c] = C(0), f = l(() => {
951
- c((u) => u + 1);
952
- }, []), [R, b] = C(r), [N, W] = C(0), T = l(() => {
953
- let u = r;
954
- e && t && (u = e.getFieldValue(t), u == null && (u = r)), i ? (b(u), W((a) => a + 1)) : o(u);
955
- }, [e, t, r, i]), O = l((u) => {
956
- e && t && ((u.type === d.dataChanged || u.type === d.recordChanged || u.type === d.afterScroll || u.type === d.afterCancel || u.type === d.afterEdit) && (T(), i || f()), u.type === d.onFieldError && u.fieldName === t && console.warn(`[${n}] Field error:`, u.error));
957
- }, [e, t, T, f, i, n]), $ = l((u, a) => {
958
- i ? (b(u), e && !e.isBrowsing() && t && e.getFieldValue(t) !== u && e.setFieldValue(t, u)) : (o(u), e && !e.isBrowsing() && t && e.getFieldValue(t) !== u && e.setFieldValue(t, u));
959
- }, [e, t, i]), z = l(() => {
960
- const u = ve(e);
961
- Ne.trackV2Usage(n, u);
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
- return le(() => {
964
- process.env.NODE_ENV === "production" && z();
963
+ return ce(() => {
964
+ process.env.NODE_ENV === "production" && d();
965
965
  }).current, {
966
966
  // Detecção de versão
967
967
  isDataSourceV2: i,
968
- dataSourceVersion: ve(e),
968
+ dataSourceVersion: pe(e),
969
969
  // Estados
970
- currentValue: i ? R : s,
971
- v1State: { currentValue: s, setCurrentValue: o, forceUpdate: f },
972
- v2State: { v2Value: R, setV2Value: b, v2ShouldUpdate: N },
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: T,
975
- dataSourceEvent: O,
976
- handleValueChange: $,
974
+ loadDataSourceFieldValue: P,
975
+ dataSourceEvent: L,
976
+ handleValueChange: N,
977
977
  // Utilitários
978
978
  isReadOnly: e ? e.isBrowsing() : !1,
979
979
  isEditing: e ? e.isEditing() : !1,
980
- trackUsage: z
980
+ trackUsage: d
981
981
  };
982
982
  }
983
- const yt = {
983
+ const vt = {
984
984
  /**
985
985
  * Valida se o componente está seguindo o padrão corretamente
986
986
  */
@@ -991,13 +991,13 @@ const yt = {
991
991
  /**
992
992
  * Testa se o comportamento V1 está preservado
993
993
  */
994
- testV1Compatibility: (n, e) => !e || ve(e) !== "V1" || [
994
+ testV1Compatibility: (n, e) => !e || pe(e) !== "V1" || [
995
995
  "isBrowsing",
996
996
  "isEditing",
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
- }, vt = `
1000
+ }, It = `
1001
1001
  // Em qualquer componente que use DataSource:
1002
1002
 
1003
1003
  import { useArchbaseV1V2Compatibility } from '../core/patterns/ArchbaseV1V2CompatibilityPattern';
@@ -1050,7 +1050,7 @@ export function MyComponent<T, ID>({ dataSource, dataField, value, onChangeValue
1050
1050
  );
1051
1051
  }
1052
1052
  `;
1053
- class k {
1053
+ class U {
1054
1054
  name;
1055
1055
  label;
1056
1056
  records = [];
@@ -1098,24 +1098,24 @@ class k {
1098
1098
  // =================== Navigation ===================
1099
1099
  first() {
1100
1100
  return this.records.length > 0 && (this.currentIndex = 0, this.emit({
1101
- type: d.afterScroll
1101
+ type: a.afterScroll
1102
1102
  })), this;
1103
1103
  }
1104
1104
  last() {
1105
1105
  return this.records.length > 0 && (this.currentIndex = this.records.length - 1, this.emit({
1106
- type: d.afterScroll
1106
+ type: a.afterScroll
1107
1107
  })), this;
1108
1108
  }
1109
1109
  next() {
1110
1110
  return this.currentIndex < this.records.length - 1 && (this.currentIndex++, this.emit({
1111
- type: d.recordChanged,
1111
+ type: a.recordChanged,
1112
1112
  record: this.getCurrentRecord(),
1113
1113
  index: this.currentIndex
1114
1114
  })), this;
1115
1115
  }
1116
1116
  prior() {
1117
1117
  return this.currentIndex > 0 && (this.currentIndex--, this.emit({
1118
- type: d.recordChanged,
1118
+ type: a.recordChanged,
1119
1119
  record: this.getCurrentRecord(),
1120
1120
  index: this.currentIndex
1121
1121
  })), this;
@@ -1123,7 +1123,7 @@ class k {
1123
1123
  goToRecord(e) {
1124
1124
  if (e >= 0 && e < this.records.length)
1125
1125
  return this.currentIndex = e, this.emit({
1126
- type: d.recordChanged,
1126
+ type: a.recordChanged,
1127
1127
  record: this.getCurrentRecord(),
1128
1128
  index: this.currentIndex
1129
1129
  }), this.getCurrentRecord();
@@ -1154,27 +1154,27 @@ class k {
1154
1154
  if (this.validateDataSourceActive("edit"), this.isEmpty() || !this.getCurrentRecord())
1155
1155
  throw new Error(`No records to edit in DataSource ${this.name}`);
1156
1156
  return this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
1157
- type: d.beforeEdit,
1157
+ type: a.beforeEdit,
1158
1158
  record: this.getCurrentRecord(),
1159
1159
  index: this.currentIndex
1160
1160
  }), this.emit({
1161
- type: d.afterEdit,
1161
+ type: a.afterEdit,
1162
1162
  record: this.getCurrentRecord(),
1163
1163
  index: this.currentIndex
1164
1164
  }), this;
1165
1165
  }
1166
1166
  cancel() {
1167
1167
  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: d.afterCancel,
1168
+ type: a.afterCancel,
1169
1169
  record: this.getCurrentRecord(),
1170
1170
  index: this.currentIndex
1171
1171
  }), this;
1172
1172
  }
1173
1173
  insert(e) {
1174
1174
  return this.validateDataSourceActive("insert"), this.state = "insert", this.emit({
1175
- type: d.beforeInsert
1175
+ type: a.beforeInsert
1176
1176
  }), this.records = [...this.records, e], this.currentIndex = this.records.length - 1, this.notifyStateChange(), this.emit({
1177
- type: d.afterInsert,
1177
+ type: a.afterInsert,
1178
1178
  record: e,
1179
1179
  index: this.currentIndex
1180
1180
  }), this;
@@ -1186,7 +1186,7 @@ class k {
1186
1186
  throw new Error(`No record to save in DataSource ${this.name}`);
1187
1187
  const t = this.getCurrentRecord();
1188
1188
  if (this.emit({
1189
- type: d.beforeSave,
1189
+ type: a.beforeSave,
1190
1190
  record: t,
1191
1191
  index: this.getCurrentIndex()
1192
1192
  }), this.validator) {
@@ -1195,7 +1195,7 @@ class k {
1195
1195
  throw new Error(r[0].errorMessage);
1196
1196
  }
1197
1197
  return this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
1198
- type: d.afterSave,
1198
+ type: a.afterSave,
1199
1199
  record: t,
1200
1200
  index: this.getCurrentIndex()
1201
1201
  }), e && e(), t;
@@ -1207,11 +1207,11 @@ class k {
1207
1207
  throw new Error(`No records to remove in DataSource ${this.name}`);
1208
1208
  const t = this.getCurrentRecord(), r = this.currentIndex;
1209
1209
  return this.emit({
1210
- type: d.beforeRemove,
1210
+ type: a.beforeRemove,
1211
1211
  record: t,
1212
1212
  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: d.afterScroll }), this.emit({
1214
- type: d.afterRemove,
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: a.afterScroll }), this.emit({
1214
+ type: a.afterRemove,
1215
1215
  record: t,
1216
1216
  index: r
1217
1217
  }), e && e(), t;
@@ -1224,19 +1224,16 @@ class k {
1224
1224
  if (r === t)
1225
1225
  return this;
1226
1226
  const i = [...this.records];
1227
- return this.records = _(this.records, (s) => {
1227
+ return this.records = Q(this.records, (s) => {
1228
1228
  const o = s[this.currentIndex];
1229
1229
  o && this.setNestedValue(o, e, t);
1230
1230
  }), this.notifyStateChange(i), this.emit({
1231
- type: d.fieldChanged,
1231
+ type: a.fieldChanged,
1232
1232
  fieldName: e,
1233
1233
  oldValue: r,
1234
1234
  newValue: t,
1235
1235
  record: this.getCurrentRecord(),
1236
1236
  index: this.currentIndex
1237
- }), this.emit({
1238
- type: d.dataChanged,
1239
- data: this.records
1240
1237
  }), this;
1241
1238
  }
1242
1239
  getFieldValue(e) {
@@ -1256,14 +1253,14 @@ class k {
1256
1253
  if (!Array.isArray(r))
1257
1254
  throw new Error(`Field ${String(e)} is not an array (found: ${typeof r})`);
1258
1255
  const i = [...this.records];
1259
- this.records = _(this.records, (s) => {
1256
+ this.records = Q(this.records, (s) => {
1260
1257
  const o = s[this.currentIndex];
1261
1258
  if (o) {
1262
1259
  const c = this.getNestedValue(o, e);
1263
1260
  c && c.push(t);
1264
1261
  }
1265
1262
  }), this.notifyStateChange(i), this.emit({
1266
- type: d.fieldChanged,
1263
+ type: a.fieldChanged,
1267
1264
  fieldName: e,
1268
1265
  oldValue: r,
1269
1266
  newValue: [...r, t],
@@ -1278,14 +1275,14 @@ class k {
1278
1275
  if (!Array.isArray(i) || t < 0 || t >= i.length)
1279
1276
  return;
1280
1277
  const s = [...this.records];
1281
- this.records = _(this.records, (o) => {
1278
+ this.records = Q(this.records, (o) => {
1282
1279
  const c = o[this.currentIndex];
1283
1280
  if (c) {
1284
- const f = this.getNestedValue(c, e);
1285
- f[t] !== void 0 && r(f[t]);
1281
+ const u = this.getNestedValue(c, e);
1282
+ u[t] !== void 0 && r(u[t]);
1286
1283
  }
1287
1284
  }), this.notifyStateChange(s), this.emit({
1288
- type: d.fieldChanged,
1285
+ type: a.fieldChanged,
1289
1286
  fieldName: e,
1290
1287
  oldValue: i,
1291
1288
  newValue: this.getFieldValue(e),
@@ -1302,11 +1299,11 @@ class k {
1302
1299
  if (t < 0 || t >= r.length)
1303
1300
  return;
1304
1301
  const i = [...this.records];
1305
- this.records = _(this.records, (s) => {
1302
+ this.records = Q(this.records, (s) => {
1306
1303
  const o = s[this.currentIndex];
1307
1304
  o && this.getNestedValue(o, e).splice(t, 1);
1308
1305
  }), this.notifyStateChange(i), this.emit({
1309
- type: d.fieldChanged,
1306
+ type: a.fieldChanged,
1310
1307
  fieldName: e,
1311
1308
  oldValue: r,
1312
1309
  newValue: this.getFieldValue(e),
@@ -1321,11 +1318,11 @@ class k {
1321
1318
  if (!Array.isArray(i))
1322
1319
  throw new Error(`Field ${String(e)} is not an array`);
1323
1320
  const s = [...this.records];
1324
- this.records = _(this.records, (o) => {
1321
+ this.records = Q(this.records, (o) => {
1325
1322
  const c = o[this.currentIndex];
1326
1323
  c && this.getNestedValue(c, e).splice(t, 0, r);
1327
1324
  }), this.notifyStateChange(s), this.emit({
1328
- type: d.fieldChanged,
1325
+ type: a.fieldChanged,
1329
1326
  fieldName: e,
1330
1327
  oldValue: i,
1331
1328
  newValue: this.getFieldValue(e),
@@ -1351,7 +1348,7 @@ class k {
1351
1348
  }
1352
1349
  clear() {
1353
1350
  this.records = [], this.currentIndex = -1, this.state = "browse", this.originalRecord = null, this.emit({
1354
- type: d.dataChanged,
1351
+ type: a.dataChanged,
1355
1352
  data: this.records
1356
1353
  });
1357
1354
  }
@@ -1361,7 +1358,7 @@ class k {
1361
1358
  */
1362
1359
  setData(e) {
1363
1360
  this.records = [...e.records || []], this.currentIndex = this.records.length > 0 ? 0 : -1, this.state = "browse", this.originalRecord = null, this.emit({
1364
- type: d.dataChanged,
1361
+ type: a.dataChanged,
1365
1362
  data: this.records
1366
1363
  });
1367
1364
  }
@@ -1399,7 +1396,7 @@ class k {
1399
1396
  gotoRecordByData(e) {
1400
1397
  const t = this.records.findIndex((r) => r === e);
1401
1398
  return t >= 0 ? (this.currentIndex = t, this.emit({
1402
- type: d.recordChanged,
1399
+ type: a.recordChanged,
1403
1400
  record: this.getCurrentRecord(),
1404
1401
  index: this.currentIndex
1405
1402
  }), !0) : !1;
@@ -1412,7 +1409,7 @@ class k {
1412
1409
  }
1413
1410
  addFieldChangeListener(e, t) {
1414
1411
  const r = (i) => {
1415
- i.type === d.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
1412
+ i.type === a.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
1416
1413
  };
1417
1414
  return this.addListener(r), this;
1418
1415
  }
@@ -1439,7 +1436,7 @@ class k {
1439
1436
  }
1440
1437
  if (i)
1441
1438
  return this.currentIndex = t, this.emit({
1442
- type: d.recordChanged,
1439
+ type: a.recordChanged,
1443
1440
  record: this.getCurrentRecord(),
1444
1441
  index: this.currentIndex
1445
1442
  }), !0;
@@ -1450,7 +1447,7 @@ class k {
1450
1447
  for (let t = 0; t < this.records.length; t++)
1451
1448
  if (e(this.records[t]))
1452
1449
  return this.currentIndex = t, this.emit({
1453
- type: d.recordChanged,
1450
+ type: a.recordChanged,
1454
1451
  record: this.getCurrentRecord(),
1455
1452
  index: this.currentIndex
1456
1453
  }), !0;
@@ -1482,7 +1479,7 @@ class k {
1482
1479
  setRecords(e) {
1483
1480
  const t = [...this.records];
1484
1481
  this.records = [...e], e.length > 0 ? this.currentIndex = 0 : this.currentIndex = -1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(t), this.emit({
1485
- type: d.dataChanged,
1482
+ type: a.dataChanged,
1486
1483
  data: this.records
1487
1484
  });
1488
1485
  }
@@ -1525,7 +1522,7 @@ class k {
1525
1522
  return i;
1526
1523
  }
1527
1524
  }
1528
- class Je {
1525
+ class Qe {
1529
1526
  name;
1530
1527
  label;
1531
1528
  service;
@@ -1579,27 +1576,27 @@ class Je {
1579
1576
  // =================== Navigation ===================
1580
1577
  first() {
1581
1578
  this.filteredRecords.length > 0 && (this.currentIndex = 0, this.emit({
1582
- type: d.afterScroll
1579
+ type: a.afterScroll
1583
1580
  }));
1584
1581
  }
1585
1582
  last() {
1586
1583
  this.filteredRecords.length > 0 && (this.currentIndex = this.filteredRecords.length - 1, this.emit({
1587
- type: d.afterScroll
1584
+ type: a.afterScroll
1588
1585
  }));
1589
1586
  }
1590
1587
  next() {
1591
1588
  this.currentIndex < this.filteredRecords.length - 1 && (this.currentIndex++, this.emit({
1592
- type: d.afterScroll
1589
+ type: a.afterScroll
1593
1590
  }));
1594
1591
  }
1595
1592
  prior() {
1596
1593
  this.currentIndex > 0 && (this.currentIndex--, this.emit({
1597
- type: d.afterScroll
1594
+ type: a.afterScroll
1598
1595
  }));
1599
1596
  }
1600
1597
  goToRecord(e) {
1601
1598
  e >= 0 && e < this.filteredRecords.length && (this.currentIndex = e, this.emit({
1602
- type: d.afterScroll
1599
+ type: a.afterScroll
1603
1600
  }));
1604
1601
  }
1605
1602
  isFirst() {
@@ -1626,15 +1623,15 @@ class Je {
1626
1623
  }
1627
1624
  edit() {
1628
1625
  if (this.validateDataSourceActive("edit"), this.isEmpty() || !this.getCurrentRecord()) {
1629
- const e = m.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
1626
+ const e = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
1630
1627
  throw this.publishEventError(e, {}), new g(e);
1631
1628
  }
1632
1629
  this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
1633
- type: d.beforeEdit,
1630
+ type: a.beforeEdit,
1634
1631
  record: this.getCurrentRecord(),
1635
1632
  index: this.currentIndex
1636
1633
  }), this.emit({
1637
- type: d.afterEdit,
1634
+ type: a.afterEdit,
1638
1635
  record: this.getCurrentRecord(),
1639
1636
  index: this.currentIndex
1640
1637
  });
@@ -1649,16 +1646,16 @@ class Je {
1649
1646
  } else
1650
1647
  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);
1651
1648
  this.state = "browse", this.originalRecord = null, this.emit({
1652
- type: d.afterCancel,
1649
+ type: a.afterCancel,
1653
1650
  record: this.getCurrentRecord(),
1654
1651
  index: this.currentIndex
1655
1652
  });
1656
1653
  }
1657
1654
  insert(e) {
1658
1655
  this.validateDataSourceActive("insert"), this.state = "insert", this.emit({
1659
- type: d.beforeInsert
1656
+ type: a.beforeInsert
1660
1657
  }), this.filteredRecords = [...this.filteredRecords, e], this.records = [...this.records, e], this.currentIndex = this.filteredRecords.length - 1, this.grandTotalRecords++, this.notifyStateChange(), this.emit({
1661
- type: d.afterInsert,
1658
+ type: a.afterInsert,
1662
1659
  record: e,
1663
1660
  index: this.currentIndex
1664
1661
  });
@@ -1666,40 +1663,40 @@ class Je {
1666
1663
  // =================== Remote CRUD Operations ===================
1667
1664
  async save(e) {
1668
1665
  if (this.validateDataSourceActive("save"), !this.isInserting() && !this.isEditing()) {
1669
- const r = m.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
1666
+ const r = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
1670
1667
  throw this.publishEventError(r, {}), new g(r);
1671
1668
  }
1672
1669
  if (!this.getCurrentRecord()) {
1673
- const r = m.t("archbase:noRecordToSave", { dataSourceName: this.name });
1670
+ const r = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
1674
1671
  throw this.publishEventError(r, {}), new g(r);
1675
1672
  }
1676
1673
  const t = this.getCurrentRecord();
1677
1674
  if (this.emit({
1678
- type: d.beforeSave,
1675
+ type: a.beforeSave,
1679
1676
  record: t,
1680
1677
  index: this.getCurrentIndex()
1681
1678
  }), this.validator) {
1682
1679
  const r = this.validator.validateEntity(t);
1683
1680
  if (r && r.length > 0)
1684
1681
  if (this.publishEventErrors(r), r[0].fieldName) {
1685
- const i = m.t("archbase:errorSavingRecord", { dataSourceName: this.label });
1682
+ const i = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
1686
1683
  throw new g(i);
1687
1684
  } else
1688
1685
  throw new g(r[0].errorMessage);
1689
1686
  }
1690
1687
  try {
1691
1688
  const r = await this.service.save(t);
1692
- this.filteredRecords = _(this.filteredRecords, (s) => {
1689
+ this.filteredRecords = Q(this.filteredRecords, (s) => {
1693
1690
  s[this.currentIndex] = r;
1694
1691
  });
1695
1692
  let i = -1;
1696
1693
  return this.records.forEach((s, o) => {
1697
- const c = this.service.getId(s), f = this.service.getId(t);
1698
- (s === t || c !== void 0 && c === f) && (i = o);
1699
- }), this.records = _(this.records, (s) => {
1694
+ const c = this.service.getId(s), u = this.service.getId(t);
1695
+ (s === t || c !== void 0 && c === u) && (i = o);
1696
+ }), this.records = Q(this.records, (s) => {
1700
1697
  i >= 0 ? s[i] = r : s.push(r);
1701
1698
  }), this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
1702
- type: d.afterSave,
1699
+ type: a.afterSave,
1703
1700
  record: r,
1704
1701
  index: this.getCurrentIndex()
1705
1702
  }), e && e(), r;
@@ -1709,16 +1706,16 @@ class Je {
1709
1706
  }
1710
1707
  async remove(e) {
1711
1708
  if (this.validateDataSourceActive("remove"), this.isInserting() || this.isEditing()) {
1712
- const i = m.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
1709
+ const i = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
1713
1710
  throw this.publishEventError(i, {}), new g(i);
1714
1711
  }
1715
1712
  if (this.isEmpty() || !this.getCurrentRecord()) {
1716
- const i = m.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
1713
+ const i = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
1717
1714
  throw this.publishEventError(i, {}), new g(i);
1718
1715
  }
1719
1716
  const t = this.getCurrentRecord(), r = this.currentIndex;
1720
1717
  this.emit({
1721
- type: d.beforeRemove,
1718
+ type: a.beforeRemove,
1722
1719
  record: t,
1723
1720
  index: r
1724
1721
  });
@@ -1727,15 +1724,15 @@ class Je {
1727
1724
  const i = this.records.findIndex(
1728
1725
  (s) => this.service.getId(s) === this.service.getId(t)
1729
1726
  );
1730
- return i >= 0 && (this.records = this.records.filter((s, o) => o !== 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({
1731
- type: d.afterRemove,
1727
+ return i >= 0 && (this.records = this.records.filter((s, o) => o !== 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: a.afterScroll }), this.emit({
1728
+ type: a.afterRemove,
1732
1729
  record: t,
1733
1730
  index: r
1734
1731
  }), e && e(), t;
1735
1732
  } catch (i) {
1736
1733
  const s = G(i);
1737
1734
  throw this.emit({
1738
- type: d.onError,
1735
+ type: a.onError,
1739
1736
  error: s,
1740
1737
  originalError: i
1741
1738
  }), e && e(s), new g(s);
@@ -1749,7 +1746,7 @@ class Je {
1749
1746
  if (r === t)
1750
1747
  return;
1751
1748
  const i = [...this.filteredRecords];
1752
- if (this.filteredRecords = _(this.filteredRecords, (s) => {
1749
+ if (this.filteredRecords = Q(this.filteredRecords, (s) => {
1753
1750
  const o = s[this.currentIndex];
1754
1751
  o && this.setNestedValue(o, e, t);
1755
1752
  }), this.state === "edit" || this.state === "insert") {
@@ -1758,21 +1755,18 @@ class Je {
1758
1755
  const o = this.records.findIndex(
1759
1756
  (c) => this.service.getId(c) === s
1760
1757
  );
1761
- o >= 0 && (this.records = _(this.records, (c) => {
1758
+ o >= 0 && (this.records = Q(this.records, (c) => {
1762
1759
  this.setNestedValue(c[o], e, t);
1763
1760
  }));
1764
1761
  }
1765
1762
  }
1766
1763
  this.notifyStateChange(i), this.emit({
1767
- type: d.fieldChanged,
1764
+ type: a.fieldChanged,
1768
1765
  fieldName: e,
1769
1766
  oldValue: r,
1770
1767
  newValue: t,
1771
1768
  record: this.getCurrentRecord(),
1772
1769
  index: this.currentIndex
1773
- }), this.emit({
1774
- type: d.dataChanged,
1775
- data: this.filteredRecords
1776
1770
  });
1777
1771
  }
1778
1772
  getFieldValue(e) {
@@ -1792,14 +1786,14 @@ class Je {
1792
1786
  if (!Array.isArray(r))
1793
1787
  throw new Error(`Field ${String(e)} is not an array (found: ${typeof r})`);
1794
1788
  const i = [...this.filteredRecords];
1795
- this.filteredRecords = _(this.filteredRecords, (s) => {
1789
+ this.filteredRecords = Q(this.filteredRecords, (s) => {
1796
1790
  const o = s[this.currentIndex];
1797
1791
  if (o) {
1798
1792
  const c = this.getNestedValue(o, e);
1799
1793
  c && c.push(t);
1800
1794
  }
1801
1795
  }), this.notifyStateChange(i), this.emit({
1802
- type: d.fieldChanged,
1796
+ type: a.fieldChanged,
1803
1797
  fieldName: e,
1804
1798
  oldValue: r,
1805
1799
  newValue: [...r, t],
@@ -1814,14 +1808,14 @@ class Je {
1814
1808
  if (!Array.isArray(i) || t < 0 || t >= i.length)
1815
1809
  return;
1816
1810
  const s = [...this.filteredRecords];
1817
- this.filteredRecords = _(this.filteredRecords, (o) => {
1811
+ this.filteredRecords = Q(this.filteredRecords, (o) => {
1818
1812
  const c = o[this.currentIndex];
1819
1813
  if (c) {
1820
- const f = this.getNestedValue(c, e);
1821
- f[t] !== void 0 && r(f[t]);
1814
+ const u = this.getNestedValue(c, e);
1815
+ u[t] !== void 0 && r(u[t]);
1822
1816
  }
1823
1817
  }), this.notifyStateChange(s), this.emit({
1824
- type: d.fieldChanged,
1818
+ type: a.fieldChanged,
1825
1819
  fieldName: e,
1826
1820
  oldValue: i,
1827
1821
  newValue: this.getFieldValue(e),
@@ -1838,11 +1832,11 @@ class Je {
1838
1832
  if (t < 0 || t >= r.length)
1839
1833
  return;
1840
1834
  const i = [...this.filteredRecords];
1841
- this.filteredRecords = _(this.filteredRecords, (s) => {
1835
+ this.filteredRecords = Q(this.filteredRecords, (s) => {
1842
1836
  const o = s[this.currentIndex];
1843
1837
  o && this.getNestedValue(o, e).splice(t, 1);
1844
1838
  }), this.notifyStateChange(i), this.emit({
1845
- type: d.fieldChanged,
1839
+ type: a.fieldChanged,
1846
1840
  fieldName: e,
1847
1841
  oldValue: r,
1848
1842
  newValue: this.getFieldValue(e),
@@ -1857,11 +1851,11 @@ class Je {
1857
1851
  if (!Array.isArray(i))
1858
1852
  throw new Error(`Field ${String(e)} is not an array`);
1859
1853
  const s = [...this.filteredRecords];
1860
- this.filteredRecords = _(this.filteredRecords, (o) => {
1854
+ this.filteredRecords = Q(this.filteredRecords, (o) => {
1861
1855
  const c = o[this.currentIndex];
1862
1856
  c && this.getNestedValue(c, e).splice(t, 0, r);
1863
1857
  }), this.notifyStateChange(s), this.emit({
1864
- type: d.fieldChanged,
1858
+ type: a.fieldChanged,
1865
1859
  fieldName: e,
1866
1860
  oldValue: i,
1867
1861
  newValue: this.getFieldValue(e),
@@ -1899,6 +1893,25 @@ class Je {
1899
1893
  }
1900
1894
  console.log("[V2 refreshData] Chamando getDataWithoutFilter para página:", t), this.getDataWithoutFilter(t);
1901
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
+ }
1902
1915
  /**
1903
1916
  * Carrega dados com filtro RSQL
1904
1917
  */
@@ -1942,7 +1955,7 @@ class Je {
1942
1955
  return;
1943
1956
  }
1944
1957
  const s = e.filter.filterType, o = e.filter.quickFilterText;
1945
- s === Se && o && o !== "" ? this.getDataWithQuickFilter(e, t, r) : s === Fe || s === Ae ? this.getDataWithFilter(e, t, r) : this.getDataWithoutFilter(t, r);
1958
+ s === we && o && o !== "" ? this.getDataWithQuickFilter(e, t, r) : s === Ee || s === Se ? this.getDataWithFilter(e, t, r) : this.getDataWithoutFilter(t, r);
1946
1959
  }
1947
1960
  // =================== Event Management ===================
1948
1961
  addListener(e) {
@@ -1951,6 +1964,24 @@ class Je {
1951
1964
  removeListener(e) {
1952
1965
  this.listeners.delete(e);
1953
1966
  }
1967
+ /**
1968
+ * Adiciona um listener para mudanças em um campo específico.
1969
+ * Permite que componentes escutem apenas mudanças no campo que exibem,
1970
+ * evitando re-renders desnecessários.
1971
+ */
1972
+ addFieldChangeListener(e, t) {
1973
+ const r = (i) => {
1974
+ i.type === a.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
1975
+ };
1976
+ return this.addListener(r), this;
1977
+ }
1978
+ /**
1979
+ * Remove um listener de campo específico.
1980
+ * Nota: A remoção exata não é suportada nesta versão simplificada.
1981
+ */
1982
+ removeFieldChangeListener(e, t) {
1983
+ return this;
1984
+ }
1954
1985
  emit(e) {
1955
1986
  this.listeners.forEach((t) => {
1956
1987
  try {
@@ -1996,7 +2027,7 @@ class Je {
1996
2027
  return o === c;
1997
2028
  }));
1998
2029
  return r >= 0 ? (this.currentIndex = r, this.emit({
1999
- type: d.afterScroll
2030
+ type: a.afterScroll
2000
2031
  }), !0) : !1;
2001
2032
  }
2002
2033
  /**
@@ -2016,13 +2047,13 @@ class Je {
2016
2047
  (i) => this.service.getId(i) === t
2017
2048
  );
2018
2049
  return r >= 0 ? (this.currentIndex = r, this.emit({
2019
- type: d.afterScroll
2050
+ type: a.afterScroll
2020
2051
  }), !0) : !1;
2021
2052
  }
2022
2053
  setRecords(e, t) {
2023
2054
  const r = [...this.filteredRecords];
2024
2055
  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({
2025
- type: d.dataChanged,
2056
+ type: a.dataChanged,
2026
2057
  data: this.filteredRecords
2027
2058
  });
2028
2059
  }
@@ -2047,7 +2078,7 @@ class Je {
2047
2078
  }
2048
2079
  publishEventError(e, t) {
2049
2080
  this.emit({
2050
- type: d.onError,
2081
+ type: a.onError,
2051
2082
  error: e,
2052
2083
  originalError: t
2053
2084
  }), this.onError && this.onError(e, t);
@@ -2055,7 +2086,7 @@ class Je {
2055
2086
  publishEventErrors(e) {
2056
2087
  e.forEach((t) => {
2057
2088
  t.fieldName && (this.emit({
2058
- type: d.onFieldError,
2089
+ type: a.onFieldError,
2059
2090
  fieldName: t.fieldName,
2060
2091
  error: t.errorMessage,
2061
2092
  originalError: t
@@ -2065,7 +2096,7 @@ class Je {
2065
2096
  handleSaveError(e, t) {
2066
2097
  e.response && e.response.data && e.response.data.apierror && e.response.data.apierror.subErrors && e.response.data.apierror.subErrors.forEach((i) => {
2067
2098
  i.field && (this.emit({
2068
- type: d.onFieldError,
2099
+ type: a.onFieldError,
2069
2100
  fieldName: i.field,
2070
2101
  error: i.message,
2071
2102
  originalError: i.message
@@ -2073,7 +2104,7 @@ class Je {
2073
2104
  });
2074
2105
  const r = G(e);
2075
2106
  this.emit({
2076
- type: d.onError,
2107
+ type: a.onError,
2077
2108
  error: r,
2078
2109
  originalError: e
2079
2110
  }), this.onError && this.onError(r, e), t && t(r);
@@ -2103,7 +2134,7 @@ class Je {
2103
2134
  // =================== Remote Data Loading ===================
2104
2135
  async getDataWithFilter(e, t, r) {
2105
2136
  try {
2106
- const i = new xe();
2137
+ const i = new Fe();
2107
2138
  i.buildFrom(e.filter, e.sort);
2108
2139
  const s = i.toJSON();
2109
2140
  let o;
@@ -2148,135 +2179,134 @@ class Je {
2148
2179
  handleRemoteError(e, t) {
2149
2180
  const r = G(e);
2150
2181
  this.emit({
2151
- type: d.onError,
2182
+ type: a.onError,
2152
2183
  error: r,
2153
2184
  originalError: e
2154
2185
  }), this.onError && this.onError(r, e), t && t();
2155
2186
  }
2156
2187
  }
2157
- function be(n) {
2158
- const e = le(null), [t, r] = C(null), [i, s] = C(-1), [o, c] = C(0), [f, R] = C(!0), [b, N] = C(!1), [W, T] = C(!1), [O, $] = C(!1), [, z] = C({}), u = l(() => z({}), []), a = H(() => (e.current || (e.current = new k(n)), e.current), []), V = l((F) => {
2188
+ function xe(n) {
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) => {
2159
2190
  switch (F.type) {
2160
- case d.dataChanged:
2161
- case d.recordChanged:
2162
- r(a.getCurrentRecord()), s(a.getCurrentIndex()), c(a.getTotalRecords()), R(a.isBrowsing()), N(a.isEditing()), T(a.isInserting());
2191
+ case a.dataChanged:
2192
+ case a.recordChanged:
2193
+ r(d.getCurrentRecord()), s(d.getCurrentIndex()), c(d.getTotalRecords()), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting());
2163
2194
  break;
2164
- case d.fieldChanged:
2165
- r(a.getCurrentRecord()), u();
2195
+ case a.fieldChanged:
2166
2196
  break;
2167
- case d.afterScroll:
2168
- r(a.getCurrentRecord()), s(a.getCurrentIndex());
2197
+ case a.afterScroll:
2198
+ r(d.getCurrentRecord()), s(d.getCurrentIndex());
2169
2199
  break;
2170
- case d.beforeEdit:
2171
- case d.beforeInsert:
2172
- $(!0);
2200
+ case a.beforeEdit:
2201
+ case a.beforeInsert:
2202
+ N(!0);
2173
2203
  break;
2174
- case d.afterEdit:
2175
- case d.afterInsert:
2176
- case d.afterSave:
2177
- case d.afterCancel:
2178
- $(!1), R(a.isBrowsing()), N(a.isEditing()), T(a.isInserting());
2204
+ case a.afterEdit:
2205
+ case a.afterInsert:
2206
+ case a.afterSave:
2207
+ case a.afterCancel:
2208
+ N(!1), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting());
2179
2209
  break;
2180
- case d.onError:
2181
- case d.onFieldError:
2182
- $(!1);
2210
+ case a.onError:
2211
+ case a.onFieldError:
2212
+ N(!1);
2183
2213
  break;
2184
2214
  }
2185
- }, [a, u]);
2186
- J(() => (a.addListener(V), r(a.getCurrentRecord()), s(a.getCurrentIndex()), c(a.getTotalRecords()), R(a.isBrowsing()), N(a.isEditing()), T(a.isInserting()), () => {
2187
- a.removeListener(V);
2188
- }), [a, V]);
2189
- const X = l((F, j) => {
2190
- a.setFieldValue(F, j);
2191
- }, [a]), S = l((F) => a.getFieldValue(F), [a]), h = l(() => {
2192
- a instanceof k, a.edit();
2193
- }, [a]), Q = l(async () => await a.save(), [a]), Z = l(() => {
2194
- a instanceof k, a.cancel();
2195
- }, [a]), I = l((F) => {
2196
- a instanceof k, a.insert(F);
2197
- }, [a]), U = l(async (F) => await a.remove(F), [a]), ee = l(() => {
2198
- a instanceof k, a.first();
2199
- }, [a]), D = l(() => {
2200
- a instanceof k, a.last();
2201
- }, [a]), E = l(() => {
2202
- a instanceof k, a.next();
2203
- }, [a]), A = l(() => {
2204
- a instanceof k, a.prior();
2205
- }, [a]), P = l((F) => {
2206
- a instanceof k, a.goToRecord(F);
2207
- }, [a]), p = l((F, j) => {
2208
- a instanceof k && a.appendToFieldArray(F, j);
2209
- }, [a]), v = l((F, j, he) => {
2210
- a instanceof k && a.updateFieldArrayItem(F, j, he);
2211
- }, [a]), x = l((F, j) => {
2212
- a instanceof k && a.removeFromFieldArray(F, j);
2213
- }, [a]), L = l((F, j, he) => {
2214
- a instanceof k && a.insertIntoFieldArray(F, j, he);
2215
- }, [a]), y = l((F) => {
2216
- if (a instanceof k)
2217
- return a.getFieldArray(F);
2218
- const j = a.getFieldValue(F);
2219
- return Array.isArray(j) ? j : [];
2220
- }, [a]), q = l((F) => {
2221
- if (a instanceof k)
2222
- return a.isFieldArray(F);
2223
- const j = a.getFieldValue(F);
2224
- return Array.isArray(j);
2225
- }, [a]), te = H(() => i < o - 1, [i, o]), oe = H(() => i > 0, [i]), ae = H(() => o === 0, [o]), B = H(() => i === 0, [i]), K = H(() => i === o - 1, [i, o]), re = H(() => f, [f]), de = H(() => b, [b]), ce = H(() => W, [W]), fe = l(() => process.env.NODE_ENV === "development" ? {
2226
- ...a.getDebugSnapshot(),
2215
+ }, [d]);
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) => {
2220
+ d.setFieldValue(F, k);
2221
+ }, [d]), V = l((F) => d.getFieldValue(F), [d]), K = l(() => {
2222
+ d instanceof U, d.edit();
2223
+ }, [d]), m = l(async () => await d.save(), [d]), h = l(() => {
2224
+ d instanceof U, d.cancel();
2225
+ }, [d]), Y = l((F) => {
2226
+ d instanceof U, d.insert(F);
2227
+ }, [d]), Z = l(async (F) => await d.remove(F), [d]), E = l(() => {
2228
+ d instanceof U, d.first();
2229
+ }, [d]), j = l(() => {
2230
+ d instanceof U, d.last();
2231
+ }, [d]), ee = l(() => {
2232
+ d instanceof U, d.next();
2233
+ }, [d]), D = l(() => {
2234
+ d instanceof U, d.prior();
2235
+ }, [d]), S = l((F) => {
2236
+ d instanceof U, d.goToRecord(F);
2237
+ }, [d]), A = l((F, k) => {
2238
+ d instanceof U && d.appendToFieldArray(F, k);
2239
+ }, [d]), B = l((F, k, de) => {
2240
+ d instanceof U && d.updateFieldArrayItem(F, k, de);
2241
+ }, [d]), y = l((F, k) => {
2242
+ d instanceof U && d.removeFromFieldArray(F, k);
2243
+ }, [d]), w = l((F, k, de) => {
2244
+ d instanceof U && d.insertIntoFieldArray(F, k, de);
2245
+ }, [d]), x = l((F) => {
2246
+ if (d instanceof U)
2247
+ return d.getFieldArray(F);
2248
+ const k = d.getFieldValue(F);
2249
+ return Array.isArray(k) ? k : [];
2250
+ }, [d]), $ = l((F) => {
2251
+ if (d instanceof U)
2252
+ return d.isFieldArray(F);
2253
+ const k = d.getFieldValue(F);
2254
+ return Array.isArray(k);
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" ? {
2256
+ ...d.getDebugSnapshot(),
2227
2257
  hookState: {
2228
2258
  currentRecord: t,
2229
2259
  currentIndex: i,
2230
2260
  totalRecords: o,
2231
- isBrowsing: re,
2232
- isEditing: de,
2233
- isInserting: ce,
2234
- isLoading: O
2261
+ isBrowsing: O,
2262
+ isEditing: _,
2263
+ isInserting: re,
2264
+ isLoading: L
2235
2265
  }
2236
- } : null, [a, t, i, o, re, de, ce, O]);
2266
+ } : null, [d, t, i, o, O, _, re, L]);
2237
2267
  return {
2238
2268
  // DataSource instance (para casos onde acesso direto é necessário)
2239
- dataSource: a,
2269
+ dataSource: d,
2240
2270
  // Estado reativo
2241
2271
  currentRecord: t,
2242
2272
  currentIndex: i,
2243
2273
  totalRecords: o,
2244
- isLoading: O,
2274
+ isLoading: L,
2245
2275
  // Estado derivado
2246
- canNext: te,
2247
- canPrior: oe,
2248
- isEmpty: ae,
2249
- isFirst: B,
2250
- isLast: K,
2251
- isBrowsing: re,
2252
- isEditing: de,
2253
- isInserting: ce,
2276
+ canNext: v,
2277
+ canPrior: J,
2278
+ isEmpty: te,
2279
+ isFirst: oe,
2280
+ isLast: ae,
2281
+ isBrowsing: O,
2282
+ isEditing: _,
2283
+ isInserting: re,
2254
2284
  // Operações básicas
2255
- setFieldValue: X,
2256
- getFieldValue: S,
2257
- edit: h,
2258
- save: Q,
2259
- cancel: Z,
2260
- insert: I,
2261
- remove: U,
2285
+ setFieldValue: b,
2286
+ getFieldValue: V,
2287
+ edit: K,
2288
+ save: m,
2289
+ cancel: h,
2290
+ insert: Y,
2291
+ remove: Z,
2262
2292
  // Navegação
2263
- first: ee,
2264
- last: D,
2265
- next: E,
2266
- prior: A,
2267
- goToRecord: P,
2293
+ first: E,
2294
+ last: j,
2295
+ next: ee,
2296
+ prior: D,
2297
+ goToRecord: S,
2268
2298
  // Operações de array (V2)
2269
- appendToFieldArray: p,
2270
- updateFieldArrayItem: v,
2271
- removeFromFieldArray: x,
2272
- insertIntoFieldArray: L,
2273
- getFieldArray: y,
2274
- isFieldArray: q,
2299
+ appendToFieldArray: A,
2300
+ updateFieldArrayItem: B,
2301
+ removeFromFieldArray: y,
2302
+ insertIntoFieldArray: w,
2303
+ getFieldArray: x,
2304
+ isFieldArray: $,
2275
2305
  // Debug
2276
- getDebugInfo: fe
2306
+ getDebugInfo: ue
2277
2307
  };
2278
2308
  }
2279
- function It(n) {
2309
+ function wt(n) {
2280
2310
  const {
2281
2311
  dataSource: e,
2282
2312
  currentRecord: t,
@@ -2285,18 +2315,18 @@ function It(n) {
2285
2315
  canNext: s,
2286
2316
  canPrior: o,
2287
2317
  isEmpty: c,
2288
- isFirst: f,
2289
- isLast: R,
2290
- isBrowsing: b,
2291
- first: N,
2292
- last: W,
2293
- next: T,
2294
- prior: O,
2295
- goToRecord: $,
2296
- getFieldValue: z,
2297
- getFieldArray: u,
2298
- isFieldArray: a
2299
- } = be(n);
2318
+ isFirst: u,
2319
+ isLast: p,
2320
+ isBrowsing: C,
2321
+ first: W,
2322
+ last: M,
2323
+ next: P,
2324
+ prior: L,
2325
+ goToRecord: N,
2326
+ getFieldValue: d,
2327
+ getFieldArray: f,
2328
+ isFieldArray: b
2329
+ } = xe(n);
2300
2330
  return {
2301
2331
  dataSource: e,
2302
2332
  currentRecord: t,
@@ -2305,179 +2335,191 @@ function It(n) {
2305
2335
  canNext: s,
2306
2336
  canPrior: o,
2307
2337
  isEmpty: c,
2308
- isFirst: f,
2309
- isLast: R,
2310
- isBrowsing: b,
2311
- first: N,
2312
- last: W,
2313
- next: T,
2314
- prior: O,
2315
- goToRecord: $,
2316
- getFieldValue: z,
2317
- getFieldArray: u,
2318
- isFieldArray: a
2338
+ isFirst: u,
2339
+ isLast: p,
2340
+ isBrowsing: C,
2341
+ first: W,
2342
+ last: M,
2343
+ next: P,
2344
+ prior: L,
2345
+ goToRecord: N,
2346
+ getFieldValue: d,
2347
+ getFieldArray: f,
2348
+ isFieldArray: b
2319
2349
  };
2320
2350
  }
2321
- function wt(n) {
2322
- return be(n);
2351
+ function Et(n) {
2352
+ return xe(n);
2323
2353
  }
2324
- function De(n) {
2325
- const e = le(null), [t, r] = C(void 0), [i, s] = C(-1), [o, c] = C(0), [f, R] = C(0), [b, N] = C(!0), [W, T] = C(!1), [O, $] = C(!1), [z, u] = C(!1), [a, V] = C(null), [, X] = C({}), S = l(() => X({}), []), h = H(() => (e.current || (e.current = new Je(n)), e.current), []), Q = l((w) => {
2326
- switch (w.type) {
2327
- case d.dataChanged:
2328
- case d.recordChanged:
2329
- case d.refreshData:
2330
- r(h.getCurrentRecord()), s(h.getCurrentIndex()), c(h.getTotalRecords()), R(h.getGrandTotalRecords()), N(h.isBrowsing()), T(h.isEditing()), $(h.isInserting()), u(!1), V(null);
2354
+ function Ce(n) {
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) {
2357
+ case a.dataChanged:
2358
+ case a.recordChanged:
2359
+ case a.refreshData:
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);
2331
2361
  break;
2332
- case d.fieldChanged:
2333
- r(h.getCurrentRecord()), S();
2362
+ case a.fieldChanged:
2334
2363
  break;
2335
- case d.afterScroll:
2336
- r(h.getCurrentRecord()), s(h.getCurrentIndex());
2364
+ case a.afterScroll:
2365
+ s(h.getCurrentRecord()), c(h.getCurrentIndex());
2337
2366
  break;
2338
- case d.beforeEdit:
2339
- case d.beforeInsert:
2340
- case d.beforeSave:
2341
- case d.beforeRemove:
2342
- u(!0), V(null);
2367
+ case a.beforeEdit:
2368
+ case a.beforeInsert:
2369
+ case a.beforeSave:
2370
+ case a.beforeRemove:
2371
+ V(!0), m(null);
2343
2372
  break;
2344
- case d.afterEdit:
2345
- case d.afterInsert:
2346
- case d.afterSave:
2347
- case d.afterCancel:
2348
- case d.afterRemove:
2349
- u(!1), N(h.isBrowsing()), T(h.isEditing()), $(h.isInserting()), V(null);
2373
+ case a.afterEdit:
2374
+ case a.afterInsert:
2375
+ case a.afterSave:
2376
+ case a.afterCancel:
2377
+ case a.afterRemove:
2378
+ V(!1), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), m(null);
2350
2379
  break;
2351
- case d.onError:
2352
- u(!1), V(w.error);
2380
+ case a.onError:
2381
+ V(!1), m(I.error);
2353
2382
  break;
2354
- case d.onFieldError:
2355
- u(!1);
2383
+ case a.onFieldError:
2384
+ V(!1);
2356
2385
  break;
2357
2386
  }
2358
- }, [h, S]);
2359
- J(() => (h.addListener(Q), r(h.getCurrentRecord()), s(h.getCurrentIndex()), c(h.getTotalRecords()), R(h.getGrandTotalRecords()), N(h.isBrowsing()), T(h.isEditing()), $(h.isInserting()), () => {
2360
- h.removeListener(Q);
2361
- }), [h, Q]);
2362
- const Z = l((w, M) => {
2363
- h.setFieldValue(w, M);
2364
- }, [h]), I = l((w) => h.getFieldValue(w), [h]), U = l(() => {
2387
+ }, [h]);
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(() => {
2365
2398
  h.edit();
2366
2399
  }, [h]), ee = l(async () => {
2367
2400
  try {
2368
- return V(null), await h.save();
2369
- } catch (w) {
2370
- throw V(w.message || "Erro ao salvar"), w;
2401
+ return m(null), await h.save();
2402
+ } catch (I) {
2403
+ throw m(I.message || "Erro ao salvar"), I;
2371
2404
  }
2372
2405
  }, [h]), D = l(() => {
2373
2406
  h.cancel();
2374
- }, [h]), E = l((w) => {
2375
- h.insert(w);
2376
- }, [h]), A = l(async (w) => {
2407
+ }, [h]), S = l((I) => {
2408
+ h.insert(I);
2409
+ }, [h]), A = l(async (I) => {
2377
2410
  try {
2378
- return V(null), await h.remove(w);
2379
- } catch (M) {
2380
- throw V(M.message || "Erro ao remover"), M;
2411
+ return m(null), await h.remove(I);
2412
+ } catch (H) {
2413
+ throw m(H.message || "Erro ao remover"), H;
2381
2414
  }
2382
- }, [h]), P = l(() => {
2415
+ }, [h]), B = l(() => {
2383
2416
  h.first();
2384
- }, [h]), p = l(() => {
2417
+ }, [h]), y = l(() => {
2385
2418
  h.last();
2386
- }, [h]), v = l(() => {
2419
+ }, [h]), w = l(() => {
2387
2420
  h.next();
2388
2421
  }, [h]), x = l(() => {
2389
2422
  h.prior();
2390
- }, [h]), L = l((w) => {
2391
- h.goToRecord(w);
2392
- }, [h]), y = l((w, M) => {
2393
- h.appendToFieldArray(w, M);
2394
- }, [h]), q = l((w, M, se) => {
2395
- h.updateFieldArrayItem(w, M, se);
2396
- }, [h]), te = l((w, M) => {
2397
- h.removeFromFieldArray(w, M);
2398
- }, [h]), oe = l((w, M, se) => {
2399
- h.insertIntoFieldArray(w, M, se);
2400
- }, [h]), ae = l((w) => h.getFieldArray(w), [h]), B = l((w) => h.isFieldArray(w), [h]), K = l((w, M, se) => {
2401
- u(!0), V(null);
2423
+ }, [h]), $ = l((I) => {
2424
+ h.goToRecord(I);
2425
+ }, [h]), v = l(async (I) => {
2402
2426
  try {
2403
- h.applyRemoteFilter(w, M, () => {
2404
- u(!1), se && se();
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();
2405
2446
  });
2406
- } catch (Pe) {
2407
- u(!1), V(Pe.message || "Erro ao aplicar filtro");
2447
+ } catch (Le) {
2448
+ V(!1), m(Le.message || "Erro ao aplicar filtro");
2408
2449
  }
2409
- }, [h]), re = l(async (w) => {
2450
+ }, [h]), ue = l(async (I) => {
2410
2451
  try {
2411
- u(!0), V(null), h.refreshData(w);
2412
- } catch (M) {
2413
- throw u(!1), V(M.message || "Erro ao atualizar dados"), M;
2452
+ V(!0), m(null), h.refreshData(I);
2453
+ } catch (H) {
2454
+ throw V(!1), m(H.message || "Erro ao atualizar dados"), H;
2414
2455
  }
2415
- }, [h]), de = l((w) => {
2416
- h.setPageSize(w);
2417
- }, [h]), ce = l(() => h.getPageSize(), [h]), fe = H(() => i < o - 1, [i, o]), F = H(() => i > 0, [i]), j = H(() => o === 0, [o]), he = H(() => i === 0, [i]), Te = H(() => i === o - 1, [i, o]), me = H(() => b, [b]), Re = H(() => W, [W]), pe = H(() => O, [O]), Oe = l(() => process.env.NODE_ENV === "development" ? {
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" ? {
2418
2459
  ...h.getDebugSnapshot(),
2419
2460
  hookState: {
2420
- currentRecord: t,
2421
- currentIndex: i,
2422
- totalRecords: o,
2423
- grandTotalRecords: f,
2424
- isBrowsing: me,
2425
- isEditing: Re,
2426
- isInserting: pe,
2427
- isLoading: z,
2428
- error: a
2429
- }
2430
- } : null, [h, t, i, o, f, me, Re, pe, z, a]);
2461
+ currentRecord: i,
2462
+ currentIndex: o,
2463
+ totalRecords: u,
2464
+ grandTotalRecords: C,
2465
+ isBrowsing: ge,
2466
+ isEditing: fe,
2467
+ isInserting: me,
2468
+ isLoading: b,
2469
+ error: K
2470
+ }
2471
+ } : null, [h, i, o, u, C, ge, fe, me, b, K]);
2431
2472
  return {
2432
2473
  // DataSource instance (para casos onde acesso direto é necessário)
2433
2474
  dataSource: h,
2434
2475
  // Estado reativo
2435
- currentRecord: t,
2436
- currentIndex: i,
2437
- totalRecords: o,
2438
- grandTotalRecords: f,
2439
- isLoading: z,
2440
- error: a,
2476
+ currentRecord: i,
2477
+ currentIndex: o,
2478
+ totalRecords: u,
2479
+ grandTotalRecords: C,
2480
+ isLoading: b,
2481
+ error: K,
2441
2482
  // Estado derivado
2442
- canNext: fe,
2443
- canPrior: F,
2444
- isEmpty: j,
2445
- isFirst: he,
2446
- isLast: Te,
2447
- isBrowsing: me,
2448
- isEditing: Re,
2449
- isInserting: pe,
2483
+ canNext: de,
2484
+ canPrior: De,
2485
+ isEmpty: Ve,
2486
+ isFirst: Te,
2487
+ isLast: Oe,
2488
+ isBrowsing: ge,
2489
+ isEditing: fe,
2490
+ isInserting: me,
2450
2491
  // Operações básicas
2451
2492
  setFieldValue: Z,
2452
- getFieldValue: I,
2453
- edit: U,
2493
+ getFieldValue: E,
2494
+ edit: j,
2454
2495
  save: ee,
2455
2496
  cancel: D,
2456
- insert: E,
2497
+ insert: S,
2457
2498
  remove: A,
2458
2499
  // Navegação
2459
- first: P,
2460
- last: p,
2461
- next: v,
2500
+ first: B,
2501
+ last: y,
2502
+ next: w,
2462
2503
  prior: x,
2463
- goToRecord: L,
2504
+ goToRecord: $,
2505
+ loadById: v,
2464
2506
  // Operações de array (V2)
2465
- appendToFieldArray: y,
2466
- updateFieldArrayItem: q,
2467
- removeFromFieldArray: te,
2468
- insertIntoFieldArray: oe,
2469
- getFieldArray: ae,
2470
- isFieldArray: B,
2507
+ appendToFieldArray: J,
2508
+ updateFieldArrayItem: te,
2509
+ removeFromFieldArray: oe,
2510
+ insertIntoFieldArray: ae,
2511
+ getFieldArray: O,
2512
+ isFieldArray: _,
2471
2513
  // Operações remotas
2472
- applyRemoteFilter: K,
2473
- refreshData: re,
2474
- setPageSize: de,
2475
- getPageSize: ce,
2514
+ applyRemoteFilter: re,
2515
+ refreshData: ue,
2516
+ setPageSize: F,
2517
+ getPageSize: k,
2476
2518
  // Debug
2477
- getDebugInfo: Oe
2519
+ getDebugInfo: Pe
2478
2520
  };
2479
2521
  }
2480
- function Et(n) {
2522
+ function St(n) {
2481
2523
  const {
2482
2524
  dataSource: e,
2483
2525
  currentRecord: t,
@@ -2486,25 +2528,26 @@ function Et(n) {
2486
2528
  grandTotalRecords: s,
2487
2529
  isLoading: o,
2488
2530
  error: c,
2489
- canNext: f,
2490
- canPrior: R,
2491
- isEmpty: b,
2492
- isFirst: N,
2493
- isLast: W,
2494
- isBrowsing: T,
2495
- first: O,
2496
- last: $,
2497
- next: z,
2498
- prior: u,
2499
- goToRecord: a,
2500
- getFieldValue: V,
2501
- getFieldArray: X,
2502
- isFieldArray: S,
2503
- applyRemoteFilter: h,
2504
- refreshData: Q,
2505
- getPageSize: Z,
2506
- getDebugInfo: I
2507
- } = De(n);
2531
+ canNext: u,
2532
+ canPrior: p,
2533
+ isEmpty: C,
2534
+ isFirst: W,
2535
+ isLast: M,
2536
+ isBrowsing: P,
2537
+ first: L,
2538
+ last: N,
2539
+ next: d,
2540
+ prior: f,
2541
+ goToRecord: b,
2542
+ loadById: V,
2543
+ getFieldValue: K,
2544
+ getFieldArray: m,
2545
+ isFieldArray: h,
2546
+ applyRemoteFilter: Y,
2547
+ refreshData: Z,
2548
+ getPageSize: E,
2549
+ getDebugInfo: j
2550
+ } = Ce(n);
2508
2551
  return {
2509
2552
  dataSource: e,
2510
2553
  currentRecord: t,
@@ -2513,30 +2556,31 @@ function Et(n) {
2513
2556
  grandTotalRecords: s,
2514
2557
  isLoading: o,
2515
2558
  error: c,
2516
- canNext: f,
2517
- canPrior: R,
2518
- isEmpty: b,
2519
- isFirst: N,
2520
- isLast: W,
2521
- isBrowsing: T,
2522
- first: O,
2523
- last: $,
2524
- next: z,
2525
- prior: u,
2526
- goToRecord: a,
2527
- getFieldValue: V,
2528
- getFieldArray: X,
2529
- isFieldArray: S,
2530
- applyRemoteFilter: h,
2531
- refreshData: Q,
2532
- getPageSize: Z,
2533
- getDebugInfo: I
2559
+ canNext: u,
2560
+ canPrior: p,
2561
+ isEmpty: C,
2562
+ isFirst: W,
2563
+ isLast: M,
2564
+ isBrowsing: P,
2565
+ first: L,
2566
+ last: N,
2567
+ next: d,
2568
+ prior: f,
2569
+ goToRecord: b,
2570
+ loadById: V,
2571
+ getFieldValue: K,
2572
+ getFieldArray: m,
2573
+ isFieldArray: h,
2574
+ applyRemoteFilter: Y,
2575
+ refreshData: Z,
2576
+ getPageSize: E,
2577
+ getDebugInfo: j
2534
2578
  };
2535
2579
  }
2536
- function St(n) {
2537
- return De(n);
2580
+ function Ft(n) {
2581
+ return Ce(n);
2538
2582
  }
2539
- class Ft {
2583
+ class At {
2540
2584
  /**
2541
2585
  * Gera chave de query baseada no DataSource e filtros
2542
2586
  */
@@ -2560,7 +2604,7 @@ class Ft {
2560
2604
  );
2561
2605
  }
2562
2606
  }
2563
- const At = {
2607
+ const xt = {
2564
2608
  /** Configuração para dados que mudam raramente */
2565
2609
  STATIC_DATA: {
2566
2610
  staleTime: 30 * 60 * 1e3,
@@ -2590,31 +2634,31 @@ const At = {
2590
2634
  // 1 minuto
2591
2635
  retry: 5
2592
2636
  }
2593
- }, xt = (n) => {
2594
- const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store: o, validator: c } = n, f = () => o && o.existsValue(t) ? o.getValue(t) : i || new Ie(t, {
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, {
2595
2639
  records: e,
2596
2640
  grandTotalRecords: e.length,
2597
2641
  currentPage: 0,
2598
2642
  totalPages: 0,
2599
2643
  pageSize: 0,
2600
2644
  validator: c
2601
- }, r), [R, b] = C(
2602
- f()
2645
+ }, r), [p, C] = T(
2646
+ u()
2603
2647
  );
2604
- return J(() => {
2605
- o && o.setValue(t, R), s && s(R);
2606
- }, [t]), { dataSource: R };
2607
- }, Ct = (n) => {
2648
+ return q(() => {
2649
+ o && o.setValue(t, p), s && s(p);
2650
+ }, [t]), { dataSource: p };
2651
+ }, bt = (n) => {
2608
2652
  const e = (r) => {
2609
2653
  r.addListener(n.listener);
2610
2654
  }, t = (r) => {
2611
2655
  r.removeListener(n.listener);
2612
2656
  };
2613
- J(() => (n.dataSource && (t(n.dataSource), e(n.dataSource)), () => {
2657
+ q(() => (n.dataSource && (t(n.dataSource), e(n.dataSource)), () => {
2614
2658
  n.dataSource && t(n.dataSource);
2615
2659
  }), [n.dataSource?.uuid || n.dataSource?.getName()]);
2616
- }, bt = (n) => {
2617
- const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = n, [o, c] = C(
2660
+ }, Dt = (n) => {
2661
+ const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = n, [o, c] = T(
2618
2662
  r ?? new Ge(t, {
2619
2663
  records: e,
2620
2664
  grandTotalRecords: e.length,
@@ -2624,9 +2668,9 @@ const At = {
2624
2668
  validator: s
2625
2669
  })
2626
2670
  );
2627
- return J(() => {
2628
- c((f) => {
2629
- const R = {
2671
+ return q(() => {
2672
+ c((u) => {
2673
+ const p = {
2630
2674
  records: e,
2631
2675
  grandTotalRecords: e.length,
2632
2676
  totalPages: 0,
@@ -2634,11 +2678,11 @@ const At = {
2634
2678
  pageSize: 0,
2635
2679
  validator: s
2636
2680
  };
2637
- return f.isActive() ? f.setData(R) : f.open(R), f;
2681
+ return u.isActive() ? u.setData(p) : u.open(p), u;
2638
2682
  }), i && i(o);
2639
2683
  }, [e, t]), { dataSource: o };
2640
2684
  };
2641
- class Ve {
2685
+ class be {
2642
2686
  tokenManager;
2643
2687
  constructor(e) {
2644
2688
  this.tokenManager = e;
@@ -2653,7 +2697,7 @@ class Ve {
2653
2697
  }
2654
2698
  async get(e, t, r, i) {
2655
2699
  try {
2656
- const s = this.prepareHeaders(t, r), o = await Y.get(e, { headers: s, ...i });
2700
+ const s = this.prepareHeaders(t, r), o = await X.get(e, { headers: s, ...i });
2657
2701
  return ie.convertJsonToObject(o.data);
2658
2702
  } catch (s) {
2659
2703
  return Promise.reject(s);
@@ -2661,7 +2705,7 @@ class Ve {
2661
2705
  }
2662
2706
  async post(e, t, r, i, s) {
2663
2707
  try {
2664
- const o = this.prepareHeaders(r, i), c = await Y.post(
2708
+ const o = this.prepareHeaders(r, i), c = await X.post(
2665
2709
  e,
2666
2710
  ie.convertObjectToJson(t),
2667
2711
  {
@@ -2677,7 +2721,7 @@ class Ve {
2677
2721
  async postNoConvertId(e, t, r, i, s) {
2678
2722
  try {
2679
2723
  const o = this.prepareHeaders(r, i);
2680
- return (await Y.post(
2724
+ return (await X.post(
2681
2725
  e,
2682
2726
  t,
2683
2727
  {
@@ -2691,7 +2735,7 @@ class Ve {
2691
2735
  }
2692
2736
  async put(e, t, r, i, s) {
2693
2737
  try {
2694
- const o = this.prepareHeaders(r, i), c = await Y.put(e, ie.convertObjectToJson(t), {
2738
+ const o = this.prepareHeaders(r, i), c = await X.put(e, ie.convertObjectToJson(t), {
2695
2739
  headers: o,
2696
2740
  ...s
2697
2741
  });
@@ -2703,7 +2747,7 @@ class Ve {
2703
2747
  async putNoConvertId(e, t, r, i, s) {
2704
2748
  try {
2705
2749
  const o = this.prepareHeaders(r, i);
2706
- return (await Y.put(e, t, {
2750
+ return (await X.put(e, t, {
2707
2751
  headers: o,
2708
2752
  ...s
2709
2753
  })).data;
@@ -2714,7 +2758,7 @@ class Ve {
2714
2758
  async binaryPut(e, t, r = {}, i, s) {
2715
2759
  try {
2716
2760
  const o = this.prepareHeaders(r, i);
2717
- return s = s || {}, (await Y.put(e, t, {
2761
+ return s = s || {}, (await X.put(e, t, {
2718
2762
  headers: o,
2719
2763
  ...s
2720
2764
  })).data;
@@ -2724,7 +2768,7 @@ class Ve {
2724
2768
  }
2725
2769
  async delete(e, t, r, i) {
2726
2770
  try {
2727
- const s = this.prepareHeaders(t, r), o = await Y.delete(e, { headers: s, ...i });
2771
+ const s = this.prepareHeaders(t, r), o = await X.delete(e, { headers: s, ...i });
2728
2772
  return ie.convertJsonToObject(o.data);
2729
2773
  } catch (s) {
2730
2774
  return Promise.reject(s);
@@ -2732,7 +2776,7 @@ class Ve {
2732
2776
  }
2733
2777
  async patch(e, t, r, i, s) {
2734
2778
  try {
2735
- const o = this.prepareHeaders(r, i), c = await Y.patch(e, ie.convertObjectToJson(t), {
2779
+ const o = this.prepareHeaders(r, i), c = await X.patch(e, ie.convertObjectToJson(t), {
2736
2780
  headers: o,
2737
2781
  ...s
2738
2782
  });
@@ -2744,7 +2788,7 @@ class Ve {
2744
2788
  async patchNoConvertId(e, t, r, i, s) {
2745
2789
  try {
2746
2790
  const o = this.prepareHeaders(r, i);
2747
- return (await Y.patch(e, t, {
2791
+ return (await X.patch(e, t, {
2748
2792
  headers: o,
2749
2793
  ...s
2750
2794
  })).data;
@@ -2759,7 +2803,7 @@ class Ve {
2759
2803
  async getBlob(e, t, r) {
2760
2804
  try {
2761
2805
  const i = this.prepareHeaders(t, r);
2762
- return (await Y.get(e, {
2806
+ return (await X.get(e, {
2763
2807
  headers: i,
2764
2808
  responseType: "blob"
2765
2809
  })).data;
@@ -2774,7 +2818,7 @@ class Ve {
2774
2818
  async postBlob(e, t, r, i) {
2775
2819
  try {
2776
2820
  const s = this.prepareHeaders(r, i);
2777
- return (await Y.post(e, t, {
2821
+ return (await X.post(e, t, {
2778
2822
  headers: s,
2779
2823
  responseType: "blob"
2780
2824
  })).data;
@@ -2793,15 +2837,15 @@ class Ve {
2793
2837
  const c = this.tokenManager.getToken();
2794
2838
  c && (s.Authorization = `Bearer ${c.access_token}`);
2795
2839
  }
2796
- return (await Y.post(e, t, { headers: s })).data;
2840
+ return (await X.post(e, t, { headers: s })).data;
2797
2841
  } catch (s) {
2798
2842
  return Promise.reject(s);
2799
2843
  }
2800
2844
  }
2801
2845
  }
2802
- ne.decorate(ne.inject(He.TokenManager), Ve, 0);
2803
- ne.decorate(ne.injectable(), Ve);
2804
- class Qe {
2846
+ ne.decorate(ne.inject(We.TokenManager), be, 0);
2847
+ ne.decorate(ne.injectable(), be);
2848
+ class Ke {
2805
2849
  client;
2806
2850
  constructor(e) {
2807
2851
  this.client = e;
@@ -2901,8 +2945,8 @@ class Qe {
2901
2945
  return this.client.delete(`${this.getEndpoint()}/${e}`, t, !1);
2902
2946
  }
2903
2947
  }
2904
- ne.decorate(ne.injectable(), Qe);
2905
- class ge {
2948
+ ne.decorate(ne.injectable(), Ke);
2949
+ class le {
2906
2950
  content;
2907
2951
  pageable;
2908
2952
  totalElements;
@@ -2914,8 +2958,8 @@ class ge {
2914
2958
  first;
2915
2959
  numberOfElements;
2916
2960
  empty;
2917
- constructor(e, t, r, i, s, o, c, f, R, b) {
2918
- 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 = f !== void 0 ? f : i === 0, this.numberOfElements = R !== void 0 ? R : e.length, this.empty = b !== void 0 ? b : e.length === 0, this.pageable = {
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 = {
2919
2963
  sort: this.sort,
2920
2964
  offset: i * s,
2921
2965
  pageSize: s,
@@ -2925,19 +2969,19 @@ class ge {
2925
2969
  };
2926
2970
  }
2927
2971
  static createFromValues(e, t, r, i, s) {
2928
- return new ge(e, t, r, i, s);
2972
+ return new le(e, t, r, i, s);
2929
2973
  }
2930
2974
  }
2931
- function Ke(n) {
2975
+ function Ye(n) {
2932
2976
  return n.totalElements || n.totalElements === 0 ? n.totalElements : n.page.totalElements;
2933
2977
  }
2934
- function Ye(n) {
2978
+ function Xe(n) {
2935
2979
  return n.totalPages || n.totalPages === 0 ? n.totalPages : n.page.totalPages;
2936
2980
  }
2937
- function Xe(n) {
2981
+ function Ze(n) {
2938
2982
  return n.pageable ? n.pageable.pageNumber : n.page.number;
2939
2983
  }
2940
- function Dt(n) {
2984
+ function Vt(n) {
2941
2985
  const {
2942
2986
  name: e,
2943
2987
  label: t,
@@ -2946,28 +2990,28 @@ function Dt(n) {
2946
2990
  sort: s,
2947
2991
  transformData: o,
2948
2992
  onLoadComplete: c,
2949
- onDestroy: f,
2950
- filterData: R,
2951
- findAll: b,
2952
- findAllWithSort: N,
2953
- findAllWithFilter: W,
2954
- findAllWithFilterAndSort: T,
2955
- initialDataSource: O,
2956
- pageSize: $ = 50,
2957
- currentPage: z = 0,
2958
- loadOnStart: u = !0,
2959
- store: a,
2993
+ onDestroy: u,
2994
+ filterData: p,
2995
+ findAll: C,
2996
+ findAllWithSort: W,
2997
+ findAllWithFilter: M,
2998
+ findAllWithFilterAndSort: P,
2999
+ initialDataSource: L,
3000
+ pageSize: N = 50,
3001
+ currentPage: d = 0,
3002
+ loadOnStart: f = !0,
3003
+ store: b,
2960
3004
  id: V,
2961
- validator: X
2962
- } = n, S = le(!1), h = () => !!(a && a.existsValue(e) || O), Q = () => a && a.existsValue(e) ? a.getValue(e) : O || new Ce(r, e, {
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, {
2963
3007
  records: [],
2964
3008
  grandTotalRecords: 0,
2965
- currentPage: z,
3009
+ currentPage: d,
2966
3010
  totalPages: 0,
2967
- pageSize: $,
2968
- validator: X
2969
- }, t), Z = () => a && a.existsValue(e) ? a.getValue(e).getCurrentPage() : O ? O.getCurrentPage() : 0, [I, U] = C({
2970
- dataSource: Q(),
3011
+ pageSize: N,
3012
+ validator: K
3013
+ }, t), Z = () => b && b.existsValue(e) ? b.getValue(e).getCurrentPage() : L ? L.getCurrentPage() : 0, [E, j] = T({
3014
+ dataSource: Y(),
2971
3015
  isLoading: !1,
2972
3016
  isError: !1,
2973
3017
  error: "",
@@ -2977,154 +3021,154 @@ function Dt(n) {
2977
3021
  sort: s,
2978
3022
  id: V,
2979
3023
  currentPage: Z(),
2980
- pageSize: $,
3024
+ pageSize: N,
2981
3025
  loadDataCount: h() ? 1 : 0
2982
- }), ee = async (p, v, x, L, y, q, te, oe, ae) => {
2983
- let B;
2984
- if (q) {
2985
- const K = await r.findOne(q);
2986
- K ? B = ge.createFromValues([K], 1, 0, 0, 0) : B = ge.createFromValues([], 0, 0, 0, 0);
3026
+ }), ee = async (y, w, x, $, v, J, te, oe, ae) => {
3027
+ let O;
3028
+ if (J) {
3029
+ const _ = await r.findOne(J);
3030
+ _ ? O = le.createFromValues([_], 1, 0, 0, 0) : O = le.createFromValues([], 0, 0, 0, 0);
2987
3031
  } else
2988
- T && L && y && y.length > 0 ? B = await T(L, v, x, y) : W && L ? B = await W(L, v, x) : N && y && y.length > 0 ? B = await N(v, x, y) : b ? B = await b(v, x) : L && y && y.length > 0 ? B = await r.findAllWithFilterAndSort(L, v, x, y) : L ? B = await r.findAllWithFilter(L, v, x) : y && y.length > 0 ? B = await r.findAllWithSort(v, x, y) : B = await r.findAll(v, x);
2989
- R && (B = R(B)), o && (B = o(B)), U((K) => {
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((_) => {
2990
3034
  const re = {
2991
- records: B.content,
2992
- grandTotalRecords: Ke(B),
2993
- totalPages: Ye(B),
2994
- currentPage: Xe(B),
3035
+ records: O.content,
3036
+ grandTotalRecords: Ye(O),
3037
+ totalPages: Xe(O),
3038
+ currentPage: Ze(O),
2995
3039
  pageSize: x,
2996
- filter: L,
2997
- sort: y,
3040
+ filter: $,
3041
+ sort: v,
2998
3042
  originFilter: te,
2999
3043
  originGlobalFilter: ae,
3000
3044
  originSort: oe,
3001
- validator: X
3045
+ validator: K
3002
3046
  };
3003
- return K.dataSource.isActive() ? K.dataSource.setData(re) : K.dataSource.open(re), {
3004
- ...K,
3005
- currentPage: v,
3047
+ return _.dataSource.isActive() ? _.dataSource.setData(re) : _.dataSource.open(re), {
3048
+ ..._,
3049
+ currentPage: w,
3006
3050
  pageSize: x,
3007
- filter: L,
3008
- sort: y,
3009
- id: q,
3051
+ filter: $,
3052
+ sort: v,
3053
+ id: J,
3010
3054
  isLoading: !1,
3011
3055
  isError: !1,
3012
3056
  error: "",
3013
- loadDataCount: K.loadDataCount + 1
3057
+ loadDataCount: _.loadDataCount + 1
3014
3058
  };
3015
- }), a && a.setValue(e, I.dataSource);
3059
+ }), b && b.setValue(e, E.dataSource);
3016
3060
  };
3017
- J(() => {
3018
- c && I.loadDataCount > 0 && c(I.dataSource);
3019
- }, [I.loadDataCount]);
3020
- const D = l((p) => {
3021
- if (p.type === d.refreshData) {
3022
- const v = p.options;
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;
3023
3067
  try {
3024
- U((x) => ({
3068
+ j((x) => ({
3025
3069
  ...x,
3026
3070
  isLoading: !0,
3027
- filter: v.filter,
3028
- sort: v.sort,
3029
- currentPage: v.currentPage,
3030
- id: v.id
3071
+ filter: w.filter,
3072
+ sort: w.sort,
3073
+ currentPage: w.currentPage,
3074
+ id: w.id
3031
3075
  })), ee(
3032
- I.name,
3033
- v.currentPage,
3034
- v.pageSize,
3035
- v.filter,
3036
- v.sort,
3037
- v.id,
3038
- v.originFilter,
3039
- v.originSort,
3040
- v.originGlobalFilter
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
3041
3085
  ).catch((x) => {
3042
- const L = G(x);
3043
- U((y) => ({
3044
- ...y,
3086
+ const $ = G(x);
3087
+ j((v) => ({
3088
+ ...v,
3045
3089
  isError: !0,
3046
3090
  isLoading: !1,
3047
- error: L
3048
- })), n.onError && n.onError(L, x);
3091
+ error: $
3092
+ })), n.onError && n.onError($, x);
3049
3093
  });
3050
3094
  } catch (x) {
3051
- const L = G(x);
3052
- U((y) => ({
3053
- ...y,
3095
+ const $ = G(x);
3096
+ j((v) => ({
3097
+ ...v,
3054
3098
  isError: !0,
3055
3099
  isLoading: !1,
3056
- error: L
3057
- })), n.onError && n.onError(L, x);
3100
+ error: $
3101
+ })), n.onError && n.onError($, x);
3058
3102
  }
3059
3103
  }
3060
- }, [ee, I.name, n.onError]), E = l((p) => {
3061
- S.current || (p.addListener(D), S.current = !0);
3062
- }, [D]), A = l((p) => {
3063
- S.current && (p.removeListener(D), S.current = !1);
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);
3064
3108
  }, [D]);
3065
- J(() => {
3109
+ q(() => {
3066
3110
  try {
3067
- return E(I.dataSource), u && I.loadDataCount === 0 ? (U((p) => ({ ...p, isLoading: !0 })), ee(
3068
- I.name,
3069
- z,
3070
- $,
3071
- I.filter,
3072
- I.sort,
3073
- I.id
3074
- ).catch((p) => {
3075
- const v = G(p);
3076
- U((x) => ({
3111
+ return S(E.dataSource), f && E.loadDataCount === 0 ? (j((y) => ({ ...y, isLoading: !0 })), ee(
3112
+ E.name,
3113
+ d,
3114
+ N,
3115
+ E.filter,
3116
+ E.sort,
3117
+ E.id
3118
+ ).catch((y) => {
3119
+ const w = G(y);
3120
+ j((x) => ({
3077
3121
  ...x,
3078
3122
  isError: !0,
3079
3123
  isLoading: !1,
3080
- error: v
3081
- })), n.onError && n.onError(v, p);
3082
- })) : c && c(I.dataSource), () => {
3083
- f && (A(I.dataSource), f(I.dataSource));
3124
+ error: w
3125
+ })), n.onError && n.onError(w, y);
3126
+ })) : c && c(E.dataSource), () => {
3127
+ u && (A(E.dataSource), u(E.dataSource));
3084
3128
  };
3085
- } catch (p) {
3086
- const v = G(p);
3087
- U((x) => ({
3129
+ } catch (y) {
3130
+ const w = G(y);
3131
+ j((x) => ({
3088
3132
  ...x,
3089
3133
  isError: !0,
3090
3134
  isLoading: !1,
3091
- error: v
3092
- })), n.onError && n.onError(v, p);
3135
+ error: w
3136
+ })), n.onError && n.onError(w, y);
3093
3137
  }
3094
3138
  }, [
3095
- I.name,
3096
- I.sort,
3097
- I.filter,
3098
- I.id,
3099
- I.currentPage,
3100
- I.pageSize
3139
+ E.name,
3140
+ E.sort,
3141
+ E.filter,
3142
+ E.id,
3143
+ E.currentPage,
3144
+ E.pageSize
3101
3145
  ]);
3102
- const P = () => {
3103
- U((p) => ({
3104
- ...p,
3146
+ const B = () => {
3147
+ j((y) => ({
3148
+ ...y,
3105
3149
  isError: !1,
3106
3150
  isLoading: !1,
3107
3151
  error: ""
3108
3152
  }));
3109
3153
  };
3110
3154
  return {
3111
- isLoading: I.isLoading,
3112
- isError: I.isError,
3113
- error: I.error,
3114
- dataSource: I.dataSource,
3115
- clearError: P
3155
+ isLoading: E.isLoading,
3156
+ isError: E.isError,
3157
+ error: E.error,
3158
+ dataSource: E.dataSource,
3159
+ clearError: B
3116
3160
  };
3117
3161
  }
3118
- function Ze(n) {
3162
+ function et(n) {
3119
3163
  return n.totalElements || n.totalElements === 0 ? n.totalElements : n.page.totalElements;
3120
3164
  }
3121
- function et(n) {
3165
+ function tt(n) {
3122
3166
  return n.totalPages || n.totalPages === 0 ? n.totalPages : n.page.totalPages;
3123
3167
  }
3124
- function tt(n) {
3168
+ function rt(n) {
3125
3169
  return n.pageable ? n.pageable.pageNumber : n.page.number;
3126
3170
  }
3127
- function Vt(n) {
3171
+ function Tt(n) {
3128
3172
  const {
3129
3173
  name: e,
3130
3174
  service: t,
@@ -3133,140 +3177,140 @@ function Vt(n) {
3133
3177
  transformData: s,
3134
3178
  onLoadComplete: o,
3135
3179
  onDestroy: c,
3136
- filterData: f,
3137
- findAll: R,
3138
- findAllWithSort: b,
3139
- findAllWithFilter: N,
3140
- findAllWithFilterAndSort: W,
3141
- initialDataSource: T,
3142
- pageSize: O = 50,
3143
- currentPage: $ = 0,
3144
- loadOnStart: z = !0,
3145
- store: u,
3146
- validator: a
3147
- } = n, V = () => !!(u && u.existsValue(e) || T), X = () => u && u.existsValue(e) ? u.getValue(e) : T || new _e(t, e, {
3180
+ filterData: u,
3181
+ findAll: p,
3182
+ findAllWithSort: C,
3183
+ findAllWithFilter: W,
3184
+ findAllWithFilterAndSort: M,
3185
+ initialDataSource: P,
3186
+ pageSize: L = 50,
3187
+ currentPage: N = 0,
3188
+ loadOnStart: d = !0,
3189
+ store: f,
3190
+ validator: b
3191
+ } = n, V = () => !!(f && f.existsValue(e) || P), K = () => f && f.existsValue(e) ? f.getValue(e) : P || new Je(t, e, {
3148
3192
  records: [],
3149
3193
  grandTotalRecords: 0,
3150
- currentPage: $,
3194
+ currentPage: N,
3151
3195
  totalPages: 0,
3152
- pageSize: O,
3153
- validator: a
3154
- }), [S, h] = C({
3155
- dataSource: X(),
3196
+ pageSize: L,
3197
+ validator: b
3198
+ }), [m, h] = T({
3199
+ dataSource: K(),
3156
3200
  isLoading: !1,
3157
3201
  isError: !1,
3158
3202
  error: "",
3159
3203
  name: e,
3160
3204
  filter: r,
3161
3205
  sort: i,
3162
- currentPage: $,
3163
- pageSize: O,
3206
+ currentPage: N,
3207
+ pageSize: L,
3164
3208
  loadDataCount: V() ? 1 : 0
3165
- }), Q = async (D, E, A, P, p, v, x, L) => {
3166
- let y;
3167
- W && P && p && p.length > 0 ? y = await W(P, E, A, p) : N && P ? y = await N(P, E, A) : b && p && p.length > 0 ? y = await b(E, A, p) : R ? y = await R(E, A) : P && p && p.length > 0 ? y = await t.findAllWithFilterAndSort(P, E, A, p) : P ? y = await t.findAllWithFilter(P, E, A) : p && p.length > 0 ? y = await t.findAllWithSort(E, A, p) : y = await t.findAll(E, A), f && (y = f(y)), s && (y = s(y)), h((q) => {
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) => {
3168
3212
  const te = {
3169
- records: y.content,
3170
- grandTotalRecords: Ze(y),
3171
- totalPages: et(y),
3172
- currentPage: tt(y),
3213
+ records: v.content,
3214
+ grandTotalRecords: et(v),
3215
+ totalPages: tt(v),
3216
+ currentPage: rt(v),
3173
3217
  pageSize: A,
3174
- filter: P,
3175
- sort: p,
3176
- originFilter: v,
3177
- originGlobalFilter: L,
3218
+ filter: B,
3219
+ sort: y,
3220
+ originFilter: w,
3221
+ originGlobalFilter: $,
3178
3222
  originSort: x,
3179
- validator: a
3223
+ validator: b
3180
3224
  };
3181
- return q.dataSource.isActive() ? q.dataSource.setData(te) : q.dataSource.open(te), {
3182
- ...q,
3183
- currentPage: E,
3225
+ return J.dataSource.isActive() ? J.dataSource.setData(te) : J.dataSource.open(te), {
3226
+ ...J,
3227
+ currentPage: S,
3184
3228
  pageSize: A,
3185
- filter: P,
3186
- sort: p,
3229
+ filter: B,
3230
+ sort: y,
3187
3231
  isLoading: !1,
3188
3232
  isError: !1,
3189
3233
  error: "",
3190
- loadDataCount: q.loadDataCount + 1
3234
+ loadDataCount: J.loadDataCount + 1
3191
3235
  };
3192
- }), u && u.setValue(e, S.dataSource), o && o(S.dataSource);
3236
+ }), f && f.setValue(e, m.dataSource), o && o(m.dataSource);
3193
3237
  }, Z = (D) => {
3194
- if (D.type === d.refreshData) {
3195
- const E = D.options;
3238
+ if (D.type === a.refreshData) {
3239
+ const S = D.options;
3196
3240
  try {
3197
3241
  h((A) => ({
3198
3242
  ...A,
3199
3243
  isLoading: !0,
3200
- filter: E.filter,
3201
- sort: E.sort,
3202
- currentPage: E.currentPage
3203
- })), Q(
3204
- S.name,
3205
- E.currentPage,
3206
- E.pageSize,
3207
- E.filter,
3208
- E.sort,
3209
- E.originFilter,
3210
- E.originSort,
3211
- E.originGlobalFilter
3244
+ filter: S.filter,
3245
+ sort: S.sort,
3246
+ currentPage: S.currentPage
3247
+ })), Y(
3248
+ m.name,
3249
+ S.currentPage,
3250
+ S.pageSize,
3251
+ S.filter,
3252
+ S.sort,
3253
+ S.originFilter,
3254
+ S.originSort,
3255
+ S.originGlobalFilter
3212
3256
  ).catch((A) => {
3213
- const P = G(A);
3214
- h((p) => ({
3215
- ...p,
3257
+ const B = G(A);
3258
+ h((y) => ({
3259
+ ...y,
3216
3260
  isError: !0,
3217
3261
  isLoading: !1,
3218
- error: P
3219
- })), n.onError && n.onError(P, A);
3262
+ error: B
3263
+ })), n.onError && n.onError(B, A);
3220
3264
  });
3221
3265
  } catch (A) {
3222
- const P = G(A);
3223
- h((p) => ({
3224
- ...p,
3266
+ const B = G(A);
3267
+ h((y) => ({
3268
+ ...y,
3225
3269
  isError: !0,
3226
3270
  isLoading: !1,
3227
- error: P
3228
- })), n.onError && n.onError(P, A);
3271
+ error: B
3272
+ })), n.onError && n.onError(B, A);
3229
3273
  }
3230
3274
  }
3231
- }, I = (D) => {
3275
+ }, E = (D) => {
3232
3276
  D.addListener(Z);
3233
- }, U = (D) => {
3277
+ }, j = (D) => {
3234
3278
  D.removeListener(Z);
3235
3279
  };
3236
- J(() => {
3280
+ q(() => {
3237
3281
  try {
3238
- return I(S.dataSource), z && S.loadDataCount === 0 && (h((D) => ({ ...D, isLoading: !0 })), Q(
3239
- S.name,
3240
- $,
3241
- O,
3242
- S.filter,
3243
- S.sort
3282
+ return E(m.dataSource), d && m.loadDataCount === 0 && (h((D) => ({ ...D, isLoading: !0 })), Y(
3283
+ m.name,
3284
+ N,
3285
+ L,
3286
+ m.filter,
3287
+ m.sort
3244
3288
  ).catch((D) => {
3245
- const E = G(D);
3289
+ const S = G(D);
3246
3290
  h((A) => ({
3247
3291
  ...A,
3248
3292
  isError: !0,
3249
3293
  isLoading: !1,
3250
- error: E
3251
- })), n.onError && n.onError(E, D);
3294
+ error: S
3295
+ })), n.onError && n.onError(S, D);
3252
3296
  })), () => {
3253
- c && (U(S.dataSource), c(S.dataSource));
3297
+ c && (j(m.dataSource), c(m.dataSource));
3254
3298
  };
3255
3299
  } catch (D) {
3256
- const E = G(D);
3300
+ const S = G(D);
3257
3301
  h((A) => ({
3258
3302
  ...A,
3259
3303
  isError: !0,
3260
3304
  isLoading: !1,
3261
- error: E
3262
- })), n.onError && n.onError(E, D);
3305
+ error: S
3306
+ })), n.onError && n.onError(S, D);
3263
3307
  }
3264
3308
  }, [
3265
- S.name,
3266
- S.sort,
3267
- S.filter,
3268
- S.currentPage,
3269
- S.pageSize
3309
+ m.name,
3310
+ m.sort,
3311
+ m.filter,
3312
+ m.currentPage,
3313
+ m.pageSize
3270
3314
  ]);
3271
3315
  const ee = () => {
3272
3316
  h((D) => ({
@@ -3277,46 +3321,46 @@ function Vt(n) {
3277
3321
  }));
3278
3322
  };
3279
3323
  return {
3280
- isLoading: S.isLoading,
3281
- isError: S.isError,
3282
- error: S.error,
3283
- dataSource: S.dataSource,
3324
+ isLoading: m.isLoading,
3325
+ isError: m.isError,
3326
+ error: m.error,
3327
+ dataSource: m.dataSource,
3284
3328
  clearError: ee
3285
3329
  };
3286
3330
  }
3287
- function Tt(n) {
3288
- return ze((e) => e.get(n));
3289
- }
3290
3331
  function Ot(n) {
3291
- J(() => {
3332
+ return Me((e) => e.get(n));
3333
+ }
3334
+ function Pt(n) {
3335
+ q(() => {
3292
3336
  n();
3293
3337
  }, []);
3294
3338
  }
3295
- function Pt(n, e) {
3296
- J(() => {
3339
+ function Lt(n, e) {
3340
+ q(() => {
3297
3341
  n();
3298
3342
  }, e);
3299
3343
  }
3300
- function Lt(n) {
3301
- J(() => () => {
3344
+ function Bt(n) {
3345
+ q(() => () => {
3302
3346
  n();
3303
3347
  }, []);
3304
3348
  }
3305
- function Bt() {
3306
- const [, n] = C(0);
3349
+ function $t() {
3350
+ const [, n] = T(0);
3307
3351
  return l(() => {
3308
3352
  n((t) => t + 1);
3309
3353
  }, []);
3310
3354
  }
3311
- const rt = (n) => (n + 1) % 1e6;
3312
- function it() {
3313
- const [, n] = We(rt, 0);
3355
+ const it = (n) => (n + 1) % 1e6;
3356
+ function st() {
3357
+ const [, n] = ze(it, 0);
3314
3358
  return n;
3315
3359
  }
3316
- function $t() {
3317
- return it();
3360
+ function Nt() {
3361
+ return st();
3318
3362
  }
3319
- const st = Me((n, e) => ({
3363
+ const nt = je((n, e) => ({
3320
3364
  values: /* @__PURE__ */ new Map(),
3321
3365
  setValue: (t, r) => n((i) => {
3322
3366
  const s = new Map(i.values);
@@ -3330,24 +3374,24 @@ const st = Me((n, e) => ({
3330
3374
  }),
3331
3375
  clearAllValues: () => n((t) => ({ values: /* @__PURE__ */ new Map() })),
3332
3376
  reset: () => n((t) => ({ values: /* @__PURE__ */ new Map() }))
3333
- })), nt = je(st), Nt = (n = "default") => {
3334
- const e = nt();
3335
- return { setValue: (R, b) => {
3336
- e.setValue(`${n}.${R}`, b);
3337
- }, getValue: (R) => e.getValue(`${n}.${R}`), clearValue: (R) => {
3338
- e.clearValue(`${n}.${R}`);
3339
- }, existsValue: (R) => e.existsValue(`${n}.${R}`), clearAllValues: () => {
3340
- for (const [R, b] of e.values.entries())
3341
- R.startsWith(`${n}.`) && e.clearValue(R);
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);
3342
3386
  }, reset: () => {
3343
3387
  e.clearAllValues();
3344
3388
  }, values: e.values };
3345
3389
  };
3346
- function Ht(n, e, t = window) {
3347
- const r = le(e);
3348
- J(() => {
3390
+ function Wt(n, e, t = window) {
3391
+ const r = ce(e);
3392
+ q(() => {
3349
3393
  r.current = e;
3350
- }, [e]), J(
3394
+ }, [e]), q(
3351
3395
  () => {
3352
3396
  if (t && t.addEventListener && r.current) {
3353
3397
  const s = (o) => r.current(o);
@@ -3361,46 +3405,46 @@ function Ht(n, e, t = window) {
3361
3405
  );
3362
3406
  }
3363
3407
  export {
3364
- Mt as ADVANCED,
3365
- jt as ARCHBASE_IOC_API_TYPE,
3366
- At as ARCHBASE_QUERY_DEFAULTS,
3367
- Ve as ArchbaseAxiosRemoteApiClient,
3368
- Ie as ArchbaseDataSource,
3369
- k as ArchbaseDataSourceV2,
3408
+ jt as ADVANCED,
3409
+ kt as ARCHBASE_IOC_API_TYPE,
3410
+ xt as ARCHBASE_QUERY_DEFAULTS,
3411
+ be as ArchbaseAxiosRemoteApiClient,
3412
+ ye as ArchbaseDataSource,
3413
+ U as ArchbaseDataSourceV2,
3370
3414
  Ge as ArchbaseLocalFilterDataSource,
3371
- Ft as ArchbaseQueryUtils,
3372
- Qe as ArchbaseRemoteApiService,
3373
- Ce as ArchbaseRemoteDataSource,
3374
- Je as ArchbaseRemoteDataSourceV2,
3375
- _e as ArchbaseRemoteFilterDataSource,
3376
- d as DataSourceEventNames,
3377
- ge as DefaultPage,
3378
- kt as FILTER_TYPE,
3379
- Ue as LocalFilter,
3380
- yt as MigrationValidation,
3381
- Ut as NORMAL,
3415
+ At as ArchbaseQueryUtils,
3416
+ Ke as ArchbaseRemoteApiService,
3417
+ Ae as ArchbaseRemoteDataSource,
3418
+ Qe as ArchbaseRemoteDataSourceV2,
3419
+ Je as ArchbaseRemoteFilterDataSource,
3420
+ a as DataSourceEventNames,
3421
+ le as DefaultPage,
3422
+ Ut as FILTER_TYPE,
3423
+ _e as LocalFilter,
3424
+ vt as MigrationValidation,
3425
+ _t as NORMAL,
3382
3426
  Gt as QUICK,
3383
3427
  qe as RemoteFilter,
3384
- vt as USAGE_EXAMPLE,
3428
+ It as USAGE_EXAMPLE,
3385
3429
  qt as useArchbaseBool,
3386
- xt as useArchbaseDataSource,
3387
- Ct as useArchbaseDataSourceListener,
3388
- be as useArchbaseDataSourceV2,
3389
- wt as useArchbaseDataSourceV2Editor,
3390
- It as useArchbaseDataSourceV2ReadOnly,
3391
- Ot as useArchbaseDidMount,
3392
- Pt as useArchbaseDidUpdate,
3393
- Ht as useArchbaseEventListener,
3394
- Bt as useArchbaseForceRerender,
3395
- $t as useArchbaseForceUpdate,
3396
- bt as useArchbaseLocalFilterDataSource,
3397
- Dt as useArchbaseRemoteDataSource,
3398
- De as useArchbaseRemoteDataSourceV2,
3399
- St as useArchbaseRemoteDataSourceV2Editor,
3400
- Et as useArchbaseRemoteDataSourceV2ReadOnly,
3401
- Vt as useArchbaseRemoteFilterDataSource,
3402
- Tt as useArchbaseRemoteServiceApi,
3403
- Nt as useArchbaseStore,
3404
- pt as useArchbaseV1V2Compatibility,
3405
- Lt as useArchbaseWillUnmount
3430
+ Ct as useArchbaseDataSource,
3431
+ bt as useArchbaseDataSourceListener,
3432
+ xe as useArchbaseDataSourceV2,
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,
3442
+ Ce as useArchbaseRemoteDataSourceV2,
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
3406
3450
  };