@sankhyalabs/sankhyablocks 1.3.31-beta.1 → 1.3.31-beta.10

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.
Files changed (79) hide show
  1. package/dist/cjs/{index-1133bc2a.js → index-c6671817.js} +416 -9
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  4. package/dist/cjs/snk-application.cjs.entry.js +280 -107
  5. package/dist/cjs/snk-crud.cjs.entry.js +64 -0
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +218 -0
  7. package/dist/cjs/snk-form_2.cjs.entry.js +170 -0
  8. package/dist/cjs/snk-pesquisa.cjs.entry.js +6 -3
  9. package/dist/cjs/snk-taskbar.cjs.entry.js +140 -0
  10. package/dist/cjs/taskbar-elements-7f99f0c9.js +70 -0
  11. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  12. package/dist/collection/collection-manifest.json +5 -0
  13. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +2 -2
  14. package/dist/collection/components/snk-application/snk-application.js +237 -62
  15. package/dist/collection/components/snk-crud/snk-crud.css +5 -0
  16. package/dist/collection/components/snk-crud/snk-crud.js +149 -0
  17. package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
  18. package/dist/collection/components/snk-data-unit/snk-data-unit.js +492 -0
  19. package/dist/collection/components/snk-form/snk-form.css +34 -0
  20. package/dist/collection/components/snk-form/snk-form.js +230 -0
  21. package/dist/collection/components/snk-grid/snk-grid.css +5 -0
  22. package/dist/collection/components/snk-grid/snk-grid.js +148 -0
  23. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +56 -13
  24. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +5 -1
  25. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +65 -0
  26. package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
  27. package/dist/collection/components/snk-taskbar/snk-taskbar.js +252 -0
  28. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
  29. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  30. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -0
  31. package/dist/components/snk-application2.js +280 -106
  32. package/dist/components/snk-crud.d.ts +11 -0
  33. package/dist/components/snk-crud.js +102 -0
  34. package/dist/components/snk-data-unit.d.ts +11 -0
  35. package/dist/components/snk-data-unit.js +242 -0
  36. package/dist/components/snk-form.d.ts +11 -0
  37. package/dist/components/snk-form.js +6 -0
  38. package/dist/components/snk-form2.js +134 -0
  39. package/dist/components/snk-grid.d.ts +11 -0
  40. package/dist/components/snk-grid.js +6 -0
  41. package/dist/components/snk-grid2.js +91 -0
  42. package/dist/components/snk-pesquisa2.js +5 -2
  43. package/dist/components/snk-taskbar.d.ts +11 -0
  44. package/dist/components/snk-taskbar.js +6 -0
  45. package/dist/components/snk-taskbar2.js +221 -0
  46. package/dist/esm/{index-ffda6382.js → index-6a83ac96.js} +416 -10
  47. package/dist/esm/loader.js +2 -2
  48. package/dist/esm/sankhyablocks.js +2 -2
  49. package/dist/esm/snk-application.entry.js +280 -107
  50. package/dist/esm/snk-crud.entry.js +60 -0
  51. package/dist/esm/snk-data-unit.entry.js +214 -0
  52. package/dist/esm/snk-form_2.entry.js +165 -0
  53. package/dist/esm/snk-pesquisa.entry.js +6 -3
  54. package/dist/esm/snk-taskbar.entry.js +136 -0
  55. package/dist/esm/taskbar-elements-e0b8a285.js +68 -0
  56. package/dist/esm/teste-pesquisa.entry.js +1 -1
  57. package/dist/sankhyablocks/p-18fe0469.entry.js +69 -0
  58. package/dist/sankhyablocks/p-4c7b32d6.entry.js +1 -0
  59. package/dist/sankhyablocks/p-5b5afdbe.entry.js +1 -0
  60. package/dist/sankhyablocks/p-7fe9e5c2.entry.js +1 -0
  61. package/dist/sankhyablocks/p-8650ae26.entry.js +1 -0
  62. package/dist/sankhyablocks/p-a5439706.js +1 -0
  63. package/dist/sankhyablocks/p-c3d20542.entry.js +1 -0
  64. package/dist/sankhyablocks/p-cd1dc099.js +2 -0
  65. package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-d25637c9.entry.js} +1 -1
  66. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  67. package/dist/types/components/snk-application/snk-application.d.ts +103 -15
  68. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +25 -0
  69. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +45 -0
  70. package/dist/types/components.d.ts +381 -6
  71. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
  72. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +3 -3
  73. package/package.json +5 -5
  74. package/react/components.d.ts +5 -0
  75. package/react/components.js +5 -0
  76. package/react/components.js.map +1 -1
  77. package/dist/sankhyablocks/p-d62412bb.entry.js +0 -1
  78. package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
  79. package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
@@ -1,7 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { ErrorException, StringUtils, DataUnit, DataType, ChangeOperation, DateUtils, ObjectUtils, WaitingChangeException, WarningException, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
2
+ import { ErrorException, StringUtils, DataUnit, DataType, ChangeOperation, DateUtils, ObjectUtils, WaitingChangeException, WarningException, DependencyType, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { DependencyType } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
5
4
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
6
5
 
7
6
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -1233,7 +1232,7 @@ function isNode(maybeNode) {
1233
1232
  }
1234
1233
  /** Name */
1235
1234
 
1236
- let OperationTypeNode;
1235
+ var OperationTypeNode;
1237
1236
  exports.OperationTypeNode = OperationTypeNode;
1238
1237
 
1239
1238
  (function (OperationTypeNode) {
@@ -1253,13 +1252,7 @@ exports.DirectiveLocation = void 0;
1253
1252
  /**
1254
1253
  * The set of allowed directive location values.
1255
1254
  */
1256
- let DirectiveLocation;
1257
- /**
1258
- * The enum type representing the directive location values.
1259
- *
1260
- * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1261
- */
1262
-
1255
+ var DirectiveLocation;
1263
1256
  exports.DirectiveLocation = DirectiveLocation;
1264
1257
 
1265
1258
  (function (DirectiveLocation) {
@@ -1283,6 +1276,11 @@ exports.DirectiveLocation = DirectiveLocation;
1283
1276
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
1284
1277
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
1285
1278
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
1279
+ /**
1280
+ * The enum type representing the directive location values.
1281
+ *
1282
+ * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1283
+ */
1286
1284
  });
1287
1285
 
1288
1286
  var kinds = createCommonjsModule(function (module, exports) {
@@ -1295,13 +1293,7 @@ exports.Kind = void 0;
1295
1293
  /**
1296
1294
  * The set of allowed kind values for AST nodes.
1297
1295
  */
1298
- let Kind;
1299
- /**
1300
- * The enum type representing the possible kind values of AST nodes.
1301
- *
1302
- * @deprecated Please use `Kind`. Will be remove in v17.
1303
- */
1304
-
1296
+ var Kind;
1305
1297
  exports.Kind = Kind;
1306
1298
 
1307
1299
  (function (Kind) {
@@ -1349,6 +1341,11 @@ exports.Kind = Kind;
1349
1341
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
1350
1342
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
1351
1343
  })(Kind || (exports.Kind = Kind = {}));
1344
+ /**
1345
+ * The enum type representing the possible kind values of AST nodes.
1346
+ *
1347
+ * @deprecated Please use `Kind`. Will be remove in v17.
1348
+ */
1352
1349
  });
1353
1350
 
1354
1351
  var characterClasses = createCommonjsModule(function (module, exports) {
@@ -1636,13 +1633,7 @@ exports.TokenKind = void 0;
1636
1633
  * An exported enum describing the different kinds of tokens that the
1637
1634
  * lexer emits.
1638
1635
  */
1639
- let TokenKind;
1640
- /**
1641
- * The enum type representing the token kinds values.
1642
- *
1643
- * @deprecated Please use `TokenKind`. Will be remove in v17.
1644
- */
1645
-
1636
+ var TokenKind;
1646
1637
  exports.TokenKind = TokenKind;
1647
1638
 
1648
1639
  (function (TokenKind) {
@@ -1669,6 +1660,11 @@ exports.TokenKind = TokenKind;
1669
1660
  TokenKind['BLOCK_STRING'] = 'BlockString';
1670
1661
  TokenKind['COMMENT'] = 'Comment';
1671
1662
  })(TokenKind || (exports.TokenKind = TokenKind = {}));
1663
+ /**
1664
+ * The enum type representing the token kinds values.
1665
+ *
1666
+ * @deprecated Please use `TokenKind`. Will be remove in v17.
1667
+ */
1672
1668
  });
1673
1669
 
1674
1670
  var lexer = createCommonjsModule(function (module, exports) {
@@ -3005,12 +3001,13 @@ function parseType(source, options) {
3005
3001
  */
3006
3002
 
3007
3003
  class Parser {
3008
- constructor(source$1, options) {
3004
+ constructor(source$1, options = {}) {
3009
3005
  const sourceObj = (0, source.isSource)(source$1)
3010
3006
  ? source$1
3011
3007
  : new source.Source(source$1);
3012
3008
  this._lexer = new lexer.Lexer(sourceObj);
3013
3009
  this._options = options;
3010
+ this._tokenCounter = 0;
3014
3011
  }
3015
3012
  /**
3016
3013
  * Converts a name lex token into a name parse node.
@@ -3345,18 +3342,12 @@ class Parser {
3345
3342
  */
3346
3343
 
3347
3344
  parseFragmentDefinition() {
3348
- var _this$_options;
3349
-
3350
3345
  const start = this._lexer.token;
3351
3346
  this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes
3352
3347
  // the grammar of FragmentDefinition:
3353
3348
  // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
3354
3349
 
3355
- if (
3356
- ((_this$_options = this._options) === null || _this$_options === void 0
3357
- ? void 0
3358
- : _this$_options.allowLegacyFragmentVariables) === true
3359
- ) {
3350
+ if (this._options.allowLegacyFragmentVariables === true) {
3360
3351
  return this.node(start, {
3361
3352
  kind: kinds.Kind.FRAGMENT_DEFINITION,
3362
3353
  name: this.parseFragmentName(),
@@ -3417,16 +3408,14 @@ class Parser {
3417
3408
  return this.parseObject(isConst);
3418
3409
 
3419
3410
  case tokenKind.TokenKind.INT:
3420
- this._lexer.advance();
3421
-
3411
+ this.advanceLexer();
3422
3412
  return this.node(token, {
3423
3413
  kind: kinds.Kind.INT,
3424
3414
  value: token.value,
3425
3415
  });
3426
3416
 
3427
3417
  case tokenKind.TokenKind.FLOAT:
3428
- this._lexer.advance();
3429
-
3418
+ this.advanceLexer();
3430
3419
  return this.node(token, {
3431
3420
  kind: kinds.Kind.FLOAT,
3432
3421
  value: token.value,
@@ -3437,7 +3426,7 @@ class Parser {
3437
3426
  return this.parseStringLiteral();
3438
3427
 
3439
3428
  case tokenKind.TokenKind.NAME:
3440
- this._lexer.advance();
3429
+ this.advanceLexer();
3441
3430
 
3442
3431
  switch (token.value) {
3443
3432
  case 'true':
@@ -3493,9 +3482,7 @@ class Parser {
3493
3482
 
3494
3483
  parseStringLiteral() {
3495
3484
  const token = this._lexer.token;
3496
-
3497
- this._lexer.advance();
3498
-
3485
+ this.advanceLexer();
3499
3486
  return this.node(token, {
3500
3487
  kind: kinds.Kind.STRING,
3501
3488
  value: token.value,
@@ -4286,13 +4273,7 @@ class Parser {
4286
4273
  */
4287
4274
 
4288
4275
  node(startToken, node) {
4289
- var _this$_options2;
4290
-
4291
- if (
4292
- ((_this$_options2 = this._options) === null || _this$_options2 === void 0
4293
- ? void 0
4294
- : _this$_options2.noLocation) !== true
4295
- ) {
4276
+ if (this._options.noLocation !== true) {
4296
4277
  node.loc = new ast.Location(
4297
4278
  startToken,
4298
4279
  this._lexer.lastToken,
@@ -4318,8 +4299,7 @@ class Parser {
4318
4299
  const token = this._lexer.token;
4319
4300
 
4320
4301
  if (token.kind === kind) {
4321
- this._lexer.advance();
4322
-
4302
+ this.advanceLexer();
4323
4303
  return token;
4324
4304
  }
4325
4305
 
@@ -4338,8 +4318,7 @@ class Parser {
4338
4318
  const token = this._lexer.token;
4339
4319
 
4340
4320
  if (token.kind === kind) {
4341
- this._lexer.advance();
4342
-
4321
+ this.advanceLexer();
4343
4322
  return true;
4344
4323
  }
4345
4324
 
@@ -4354,7 +4333,7 @@ class Parser {
4354
4333
  const token = this._lexer.token;
4355
4334
 
4356
4335
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4357
- this._lexer.advance();
4336
+ this.advanceLexer();
4358
4337
  } else {
4359
4338
  throw (0, syntaxError_1.syntaxError)(
4360
4339
  this._lexer.source,
@@ -4372,8 +4351,7 @@ class Parser {
4372
4351
  const token = this._lexer.token;
4373
4352
 
4374
4353
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4375
- this._lexer.advance();
4376
-
4354
+ this.advanceLexer();
4377
4355
  return true;
4378
4356
  }
4379
4357
 
@@ -4460,6 +4438,24 @@ class Parser {
4460
4438
 
4461
4439
  return nodes;
4462
4440
  }
4441
+
4442
+ advanceLexer() {
4443
+ const { maxTokens } = this._options;
4444
+
4445
+ const token = this._lexer.advance();
4446
+
4447
+ if (maxTokens !== undefined && token.kind !== tokenKind.TokenKind.EOF) {
4448
+ ++this._tokenCounter;
4449
+
4450
+ if (this._tokenCounter > maxTokens) {
4451
+ throw (0, syntaxError_1.syntaxError)(
4452
+ this._lexer.source,
4453
+ token.start,
4454
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`,
4455
+ );
4456
+ }
4457
+ }
4458
+ }
4463
4459
  }
4464
4460
  /**
4465
4461
  * A helper function to describe a token as a string for debugging.
@@ -6692,6 +6688,7 @@ class WaitingRequest {
6692
6688
  class DataUnitFetcher {
6693
6689
  constructor() {
6694
6690
  this.templateByQuery = new Map();
6691
+ this._loadDataTimeout = {};
6695
6692
  this.buldTemplates();
6696
6693
  }
6697
6694
  buldTemplates() {
@@ -6720,9 +6717,9 @@ class DataUnitFetcher {
6720
6717
  }
6721
6718
  }
6722
6719
  }`);
6723
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [InputFilter!] $sort: [InputSort!]) {
6720
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
6724
6721
  $queryAlias$: fetchDataUnit(name: $dataunit){
6725
- data(limit: $limit offset: $offset filters: $filter sort: $sort){
6722
+ data(limit: $limit offset: $offset filters: $filters sort: $sort){
6726
6723
  limit
6727
6724
  offset
6728
6725
  total
@@ -6751,7 +6748,7 @@ class DataUnitFetcher {
6751
6748
  getDataUnit(entityName, resourceID) {
6752
6749
  const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6753
6750
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6754
- dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6751
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
6755
6752
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6756
6753
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6757
6754
  return dataUnit;
@@ -6788,25 +6785,39 @@ class DataUnitFetcher {
6788
6785
  });
6789
6786
  });
6790
6787
  }
6791
- loadData(dataUnit, page, sort, filter) {
6788
+ loadData(dataUnit, request) {
6789
+ const duName = dataUnit.name;
6790
+ if (this._loadDataTimeout[duName]) {
6791
+ clearTimeout(this._loadDataTimeout[duName]);
6792
+ delete this._loadDataTimeout[duName];
6793
+ }
6792
6794
  return new Promise((resolve, reject) => {
6793
- var _a, _b, _c;
6794
- const variables = { dataunit: dataUnit.name, sort, filter };
6795
- if (page) {
6796
- variables.limit = page.limit;
6797
- variables.offset = page.offset;
6798
- }
6799
- if (!StringUtils.isEmpty((_a = page === null || page === void 0 ? void 0 : page.quickFilter) === null || _a === void 0 ? void 0 : _a.term)) {
6795
+ this._loadDataTimeout[duName] = setTimeout(() => {
6796
+ delete this._loadDataTimeout[duName];
6797
+ this.doLoadData(dataUnit, request)
6798
+ .then(result => resolve(result))
6799
+ .catch(reason => reject(reason));
6800
+ }, 200);
6801
+ });
6802
+ }
6803
+ doLoadData(dataUnit, request) {
6804
+ return new Promise((resolve, reject) => {
6805
+ var _a;
6806
+ const { sort, filters, limit, offset, quickFilter } = request;
6807
+ const variables = { dataunit: dataUnit.name, sort, filters };
6808
+ variables.limit = limit;
6809
+ variables.offset = offset;
6810
+ if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
6800
6811
  if (variables.filter === undefined) {
6801
6812
  variables.filter = [];
6802
6813
  }
6803
6814
  const quickFilterCriteria = {
6804
6815
  name: "__QUICK_FILTER__",
6805
6816
  expression: "__QUICK_FILTER__",
6806
- params: [{ name: "term", dataType: DataType.TEXT, value: page.quickFilter.term }]
6817
+ params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
6807
6818
  };
6808
- if (((_c = (_b = page.quickFilter) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.length) > 0) {
6809
- quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: page.quickFilter.fields });
6819
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6820
+ quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
6810
6821
  }
6811
6822
  variables.filter.push(quickFilterCriteria);
6812
6823
  }
@@ -6816,16 +6827,32 @@ class DataUnitFetcher {
6816
6827
  query: this.templateByQuery.get("fetchData"),
6817
6828
  })
6818
6829
  .then((resp) => {
6819
- const pageResult = resp.data;
6820
- const records = [];
6821
- pageResult.records.forEach((responseRecord) => {
6830
+ const { limit, offset, total, hasMore, records } = resp.data;
6831
+ let paginationInfo;
6832
+ if (limit) {
6833
+ const firstRecord = offset + 1;
6834
+ const lastRecord = offset + Math.min(records.length, limit);
6835
+ const currentPage = offset / limit;
6836
+ paginationInfo = {
6837
+ firstRecord,
6838
+ lastRecord,
6839
+ total,
6840
+ currentPage,
6841
+ hasMore
6842
+ };
6843
+ }
6844
+ const processedRecords = [];
6845
+ records.forEach((responseRecord) => {
6822
6846
  const duRecord = { __record__id__: responseRecord.id };
6823
6847
  responseRecord.fields.forEach(({ name, value }) => {
6824
6848
  duRecord[name] = dataUnit.valueFromString(name, value);
6825
6849
  });
6826
- records.push(duRecord);
6850
+ processedRecords.push(duRecord);
6851
+ });
6852
+ resolve({
6853
+ paginationInfo,
6854
+ records: processedRecords
6827
6855
  });
6828
- resolve(Object.assign(Object.assign({}, pageResult), { records }));
6829
6856
  })
6830
6857
  .catch((error) => {
6831
6858
  reject(error);
@@ -7051,15 +7078,16 @@ class GridConfigFetcher extends ResourceFetcher {
7051
7078
  super(...arguments);
7052
7079
  this.GRID_CONFIG_VERSION = "V3:";
7053
7080
  }
7054
- getConfig(resourceID) {
7081
+ getConfig(_gridName, resourceID) {
7055
7082
  const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
7056
7083
  return new Promise((resolve, reject) => {
7057
7084
  this.loadResource(completePath)
7058
7085
  .then(loadedResource => {
7086
+ let config = undefined;
7059
7087
  if (loadedResource) {
7060
- let config = JSON.parse(loadedResource);
7061
- resolve(config);
7088
+ config = JSON.parse(loadedResource);
7062
7089
  }
7090
+ resolve(config);
7063
7091
  }).catch((error) => {
7064
7092
  reject(error);
7065
7093
  });
@@ -7094,6 +7122,8 @@ class PesquisaFetcher {
7094
7122
  }`);
7095
7123
  }
7096
7124
  loadSearchOptions(entityName, argument, criteria, options) {
7125
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
7126
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
7097
7127
  return new Promise((resolve, reject) => {
7098
7128
  DataFetcher.get()
7099
7129
  .callGraphQL({
@@ -7234,7 +7264,7 @@ class SnkErrorHandler {
7234
7264
  }
7235
7265
  else {
7236
7266
  const title = (exception === null || exception === void 0 ? void 0 : exception.title) || "Erro detectado";
7237
- const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${exception}"`;
7267
+ const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${ObjectUtils.objectToString(exception)}"`;
7238
7268
  this._app.error(title, message);
7239
7269
  }
7240
7270
  }
@@ -7253,6 +7283,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7253
7283
  this.__registerHost();
7254
7284
  this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
7255
7285
  this.applicationLoading = createEvent(this, "applicationLoading", 7);
7286
+ this._authPromises = [];
7287
+ this._duCache = new Map();
7288
+ this._duPromises = new Map();
7256
7289
  this._requestListener = new RequestListenerLoadingBar();
7257
7290
  }
7258
7291
  get parameters() {
@@ -7271,18 +7304,31 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7271
7304
  return this._resourceID;
7272
7305
  }
7273
7306
  get auth() {
7274
- return new Promise((resolve, reject) => {
7275
- if (this._auth) {
7276
- resolve(this._auth);
7277
- }
7278
- else {
7279
- this.authFetcher.getData(this._resourceID).then((authList) => {
7280
- this._auth = authList;
7281
- resolve(authList);
7282
- }).catch(error => reject(error));
7283
- }
7284
- });
7307
+ if (this._auth) {
7308
+ return Promise.resolve(this._auth);
7309
+ }
7310
+ else {
7311
+ return new Promise((resolve, reject) => {
7312
+ const waitingAuth = this._authPromises.length > 0;
7313
+ this._authPromises.push(new PendingPromise(resolve, reject));
7314
+ if (!waitingAuth) {
7315
+ this.authFetcher.getData(this._resourceID).then((authList) => {
7316
+ this._auth = authList;
7317
+ while (this._authPromises.length > 0) {
7318
+ this._authPromises.pop().resolve(this._auth);
7319
+ }
7320
+ }).catch(error => {
7321
+ while (this._authPromises.length > 0) {
7322
+ this._authPromises.pop().reject(error);
7323
+ }
7324
+ });
7325
+ }
7326
+ });
7327
+ }
7285
7328
  }
7329
+ /**
7330
+ * Caso o usuário logado seja o SUP.
7331
+ */
7286
7332
  async isUserSup() {
7287
7333
  return new Promise((resolve, reject) => {
7288
7334
  this.auth.then((authorization) => {
@@ -7292,6 +7338,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7292
7338
  });
7293
7339
  });
7294
7340
  }
7341
+ /**
7342
+ * Se o usuário logado tem permissão pra determinada ação.
7343
+ */
7295
7344
  async hasAccess(access) {
7296
7345
  return new Promise((resolve, reject) => {
7297
7346
  this.auth.then((authorization) => {
@@ -7301,6 +7350,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7301
7350
  });
7302
7351
  });
7303
7352
  }
7353
+ /**
7354
+ * Retorna todos os acessos do usuário logado.
7355
+ */
7304
7356
  async getAllAccess() {
7305
7357
  return new Promise((resolve, reject) => {
7306
7358
  this.auth.then((authorization) => {
@@ -7315,34 +7367,54 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7315
7367
  });
7316
7368
  });
7317
7369
  }
7318
- async getAuthList(_auth) {
7319
- return await (new MGEAuthorization()).parseFromJSON(_auth);
7320
- }
7370
+ /**
7371
+ * Retorna o valor de um parâmetro do tipo string.
7372
+ */
7321
7373
  async getStringParam(name) {
7322
7374
  return this.parameters.asString(name, this.resourceID);
7323
7375
  }
7376
+ /**
7377
+ * Retorna o valor de um parâmetro do tipo Inteiro.
7378
+ */
7324
7379
  async getIntParam(name) {
7325
7380
  return this.parameters.asInteger(name, this.resourceID);
7326
7381
  }
7382
+ /**
7383
+ * Retorna o valor de um parâmetro do tipo Decimal.
7384
+ */
7327
7385
  async getFloatParam(name) {
7328
7386
  return this.parameters.asFloat(name, this.resourceID);
7329
7387
  }
7388
+ /**
7389
+ * Retorna o valor de um parâmetro do tipo booleano.
7390
+ */
7330
7391
  async getBooleanParam(name) {
7331
7392
  return this.parameters.asBoolean(name, this.resourceID);
7332
7393
  }
7394
+ /**
7395
+ * Retorna o valor de um parâmetro do tipo data.
7396
+ */
7333
7397
  async getDateParam(name) {
7334
7398
  return this.parameters.asDate(name, this.resourceID);
7335
7399
  }
7400
+ /**
7401
+ * Mostra o conteúdo passado em um Popup
7402
+ */
7336
7403
  async showPopUp(content) {
7404
+ this.clearPopUpContent();
7337
7405
  this._popUp.appendChild(content);
7338
- this._popUp["opened"] = true;
7406
+ this._popUp.opened = true;
7339
7407
  }
7408
+ /**
7409
+ * Fecha o popup, liberando o conteúdo.
7410
+ */
7340
7411
  async closePopUp() {
7341
- Array.from(this._popUp.children).forEach(c => {
7342
- this._popUp.removeChild(c);
7343
- });
7344
- this._popUp["opened"] = false;
7412
+ this.clearPopUpContent();
7413
+ this._popUp.opened = false;
7345
7414
  }
7415
+ /**
7416
+ * Verifica se a licença do cliente tem determinado opcional (produto)
7417
+ */
7346
7418
  async temOpcional(opcional) {
7347
7419
  const opts = opcional.split(",");
7348
7420
  return new Promise((resolve, reject) => {
@@ -7366,6 +7438,10 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7366
7438
  });
7367
7439
  });
7368
7440
  }
7441
+ /**
7442
+ * Retorna a configuração de um recurso por service broker
7443
+ * Veja também o método "loadConfig"
7444
+ */
7369
7445
  async getConfig(key) {
7370
7446
  let payload = {
7371
7447
  "serviceName": "SystemUtilsSP.getConf",
@@ -7383,6 +7459,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7383
7459
  .catch(error => reject(error));
7384
7460
  });
7385
7461
  }
7462
+ /**
7463
+ * Salva a configuração de determinado recurso.
7464
+ */
7386
7465
  async saveConfig(key, data) {
7387
7466
  let payload = {
7388
7467
  "serviceName": "SystemUtilsSP.saveConf",
@@ -7401,42 +7480,122 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7401
7480
  .catch(error => reject(error));
7402
7481
  });
7403
7482
  }
7483
+ /**
7484
+ * Acessa informações de contexto "empurrados" na abertura da tela
7485
+ */
7404
7486
  async getAttributeFromHTMLWrapper(attribName) {
7405
7487
  return Promise.resolve(window[attribName]);
7406
7488
  }
7489
+ /**
7490
+ * Abre determinada tela, repassando pkObject
7491
+ */
7407
7492
  async openApp(resourceId, pkObject) {
7408
7493
  Workspace.openAppActivity(resourceId, pkObject);
7409
7494
  }
7410
- async createDataunit(entityName) {
7411
- return new Promise(resolve => {
7412
- const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7413
- dataUnit.loadMetadata().then(() => resolve(dataUnit));
7495
+ getDuPromissesStack(dataUnitName) {
7496
+ let stack;
7497
+ if (dataUnitName) {
7498
+ stack = this._duPromises.get(dataUnitName);
7499
+ if (!stack) {
7500
+ stack = [];
7501
+ this._duPromises.set(dataUnitName, stack);
7502
+ }
7503
+ }
7504
+ return stack || [];
7505
+ }
7506
+ /**
7507
+ * Cria o DataUnit a partir do nome da entidade. É possível armazená-lo no cache
7508
+ * passando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit será usado
7509
+ */
7510
+ async createDataunit(entityName, dataUnitName) {
7511
+ return new Promise((resolve, reject) => {
7512
+ const duPromisses = this.getDuPromissesStack(dataUnitName);
7513
+ const waitingDu = duPromisses.length > 0;
7514
+ duPromisses.push(new PendingPromise(resolve, reject));
7515
+ if (!waitingDu) {
7516
+ const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
7517
+ dataUnit.loadMetadata().then(() => {
7518
+ if (dataUnitName) {
7519
+ this._duCache.set(dataUnitName, dataUnit);
7520
+ }
7521
+ while (duPromisses.length > 0) {
7522
+ duPromisses.pop().resolve(dataUnit);
7523
+ }
7524
+ }).catch(reason => {
7525
+ while (duPromisses.length > 0) {
7526
+ duPromisses.pop().reject(reason);
7527
+ }
7528
+ });
7529
+ }
7530
+ });
7531
+ }
7532
+ /**
7533
+ * Obtem um DataUnit do cache ou cria um caso ainda não tenha sido criado.
7534
+ */
7535
+ async getDataUnit(entityName, dataUnitName) {
7536
+ return new Promise((resolve, reject) => {
7537
+ const dataUnit = this._duCache.get(dataUnitName);
7538
+ if (dataUnit) {
7539
+ resolve(dataUnit);
7540
+ }
7541
+ else {
7542
+ this.createDataunit(entityName, dataUnitName).then(dataUnit => {
7543
+ resolve(dataUnit);
7544
+ }).catch(reason => reject(reason));
7545
+ }
7414
7546
  });
7415
7547
  }
7548
+ /**
7549
+ * Retorna o resourceID da tela em questão.
7550
+ */
7416
7551
  async getResourceID() {
7417
7552
  return Promise.resolve(this.resourceID);
7418
7553
  }
7554
+ /**
7555
+ * Mostra o diálogo de alerta de acordo com os parâmetros passados.
7556
+ */
7419
7557
  async alert(title, message, icon, options) {
7420
7558
  return ApplicationUtils.alert(title, message, icon, options);
7421
7559
  }
7560
+ /**
7561
+ * Mostra o diálogo de erro de acordo com os parâmetros passados.
7562
+ */
7422
7563
  async error(title, message, icon, options) {
7423
7564
  return ApplicationUtils.error(title, message, icon, options);
7424
7565
  }
7566
+ /**
7567
+ * Exibe um diálogo de confirmação
7568
+ */
7425
7569
  async confirm(title, message, icon, critical, options) {
7426
7570
  return ApplicationUtils.confirm(title, message, icon, critical, options);
7427
7571
  }
7572
+ /**
7573
+ * Mostra uma informação efêmera (de segundo plano).
7574
+ */
7428
7575
  async info(message, options) {
7429
7576
  return ApplicationUtils.info(message, options);
7430
7577
  }
7578
+ /**
7579
+ * Busca a configuração de formulário.
7580
+ */
7431
7581
  async loadFormConfig(name) {
7432
7582
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7433
7583
  }
7434
- async loadGridConfig() {
7435
- return this.gridConfigFetcher.getConfig(this.resourceID);
7584
+ /**
7585
+ * Busca a configuração de grade.
7586
+ */
7587
+ async loadGridConfig(name) {
7588
+ return this.gridConfigFetcher.getConfig(name, this.resourceID);
7436
7589
  }
7590
+ /**
7591
+ * Salva a configuração de grade.
7592
+ */
7437
7593
  async saveGridConfig(config) {
7438
7594
  return this.gridConfigFetcher.saveConfig(config, this.resourceID);
7439
7595
  }
7596
+ async getAuthList(_auth) {
7597
+ return await (new MGEAuthorization()).parseFromJSON(_auth);
7598
+ }
7440
7599
  get urlParams() {
7441
7600
  if (!this._urlParams) {
7442
7601
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -7514,7 +7673,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7514
7673
  pesquisaContent.searchLoader = (text) => this.pesquisaFetcher.loadAdvancedSearch(ENTITYNAME, text, criteria, searchOptions);
7515
7674
  pesquisaContent.selectItem = (option) => {
7516
7675
  accept(option);
7517
- this.cleanPopUpTitle();
7676
+ this.clearPopUpTitle();
7518
7677
  this.closePopUp();
7519
7678
  };
7520
7679
  this.setPopUpTitle(DESCRIPTIONENTITY);
@@ -7531,11 +7690,18 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7531
7690
  accept(window['isDebugMode']);
7532
7691
  });
7533
7692
  }
7534
- cleanPopUpTitle() {
7535
- this._popUp['ezTitle'] = "";
7693
+ clearPopUpContent() {
7694
+ if (this._popUp) {
7695
+ Array.from(this._popUp.children).forEach(c => {
7696
+ this._popUp.removeChild(c);
7697
+ });
7698
+ }
7699
+ }
7700
+ clearPopUpTitle() {
7701
+ this._popUp.ezTitle = "";
7536
7702
  }
7537
7703
  setPopUpTitle(title) {
7538
- this._popUp['ezTitle'] = title;
7704
+ this._popUp.ezTitle = title;
7539
7705
  }
7540
7706
  componentWillLoad() {
7541
7707
  this._errorHandler = new SnkErrorHandler(this);
@@ -7547,6 +7713,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7547
7713
  ErrorTracking.init();
7548
7714
  }
7549
7715
  connectedCallback() {
7716
+ ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
7550
7717
  DataFetcher.addRequestListener(this._requestListener);
7551
7718
  }
7552
7719
  disconnectedCallback() {
@@ -7579,6 +7746,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7579
7746
  "getAttributeFromHTMLWrapper": [64],
7580
7747
  "openApp": [64],
7581
7748
  "createDataunit": [64],
7749
+ "getDataUnit": [64],
7582
7750
  "getResourceID": [64],
7583
7751
  "alert": [64],
7584
7752
  "error": [64],
@@ -7613,6 +7781,12 @@ class RequestListenerLoadingBar {
7613
7781
  }
7614
7782
  ;
7615
7783
  }
7784
+ class PendingPromise {
7785
+ constructor(resolve, reject) {
7786
+ this.resolve = resolve;
7787
+ this.reject = reject;
7788
+ }
7789
+ }
7616
7790
  function defineCustomElement() {
7617
7791
  if (typeof customElements === "undefined") {
7618
7792
  return;