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

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 (68) hide show
  1. package/dist/cjs/{index-1133bc2a.js → index-ebe8245e.js} +453 -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 +109 -79
  5. package/dist/cjs/snk-data-unit.cjs.entry.js +174 -0
  6. package/dist/cjs/snk-form.cjs.entry.js +95 -0
  7. package/dist/cjs/snk-grid.cjs.entry.js +64 -0
  8. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
  10. package/dist/cjs/taskbar-elements-589a3744.js +68 -0
  11. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  12. package/dist/collection/collection-manifest.json +4 -0
  13. package/dist/collection/components/snk-application/snk-application.js +52 -5
  14. package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
  15. package/dist/collection/components/snk-data-unit/snk-data-unit.js +429 -0
  16. package/dist/collection/components/snk-form/snk-form.css +3 -0
  17. package/dist/collection/components/snk-form/snk-form.js +194 -0
  18. package/dist/collection/components/snk-grid/snk-grid.css +5 -0
  19. package/dist/collection/components/snk-grid/snk-grid.js +128 -0
  20. package/dist/collection/components/snk-taskbar/component/snk-popup-button.js +7 -0
  21. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +63 -0
  22. package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
  23. package/dist/collection/components/snk-taskbar/snk-taskbar.js +268 -0
  24. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +36 -21
  25. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  26. package/dist/components/snk-application2.js +109 -78
  27. package/dist/components/snk-data-unit.d.ts +11 -0
  28. package/dist/components/snk-data-unit.js +198 -0
  29. package/dist/components/snk-form.d.ts +11 -0
  30. package/dist/components/snk-form.js +121 -0
  31. package/dist/components/snk-grid.d.ts +11 -0
  32. package/dist/components/snk-grid.js +88 -0
  33. package/dist/components/snk-taskbar.d.ts +11 -0
  34. package/dist/components/snk-taskbar.js +6 -0
  35. package/dist/components/snk-taskbar2.js +239 -0
  36. package/dist/esm/{index-ffda6382.js → index-7565ae23.js} +453 -10
  37. package/dist/esm/loader.js +2 -2
  38. package/dist/esm/sankhyablocks.js +2 -2
  39. package/dist/esm/snk-application.entry.js +109 -79
  40. package/dist/esm/snk-data-unit.entry.js +170 -0
  41. package/dist/esm/snk-form.entry.js +91 -0
  42. package/dist/esm/snk-grid.entry.js +60 -0
  43. package/dist/esm/snk-pesquisa.entry.js +1 -1
  44. package/dist/esm/snk-taskbar.entry.js +155 -0
  45. package/dist/esm/taskbar-elements-b6822601.js +66 -0
  46. package/dist/esm/teste-pesquisa.entry.js +1 -1
  47. package/dist/sankhyablocks/p-306224bf.entry.js +1 -0
  48. package/dist/sankhyablocks/p-4ee1e12b.js +1 -0
  49. package/dist/sankhyablocks/{p-d62412bb.entry.js → p-6d82d7fd.entry.js} +1 -1
  50. package/dist/sankhyablocks/p-88278b85.entry.js +1 -0
  51. package/dist/sankhyablocks/p-90b832f7.js +2 -0
  52. package/dist/sankhyablocks/p-a4b2fa10.entry.js +69 -0
  53. package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-bb31ea2a.entry.js} +1 -1
  54. package/dist/sankhyablocks/p-bb8d8fe7.entry.js +1 -0
  55. package/dist/sankhyablocks/p-e7ade160.entry.js +1 -0
  56. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  57. package/dist/types/components/snk-application/snk-application.d.ts +3 -1
  58. package/dist/types/components/snk-taskbar/component/snk-popup-button.d.ts +12 -0
  59. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +24 -0
  60. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +28 -0
  61. package/dist/types/components.d.ts +119 -1
  62. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
  63. package/package.json +5 -5
  64. package/react/components.d.ts +4 -0
  65. package/react/components.js +4 -0
  66. package/react/components.js.map +1 -1
  67. package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
  68. package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-1133bc2a.js');
5
+ const index = require('./index-ebe8245e.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.16.1 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application.cjs",[[2,"snk-application",{"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
17
+ return index.bootstrapLazy([["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-form.cjs",[[2,"snk-form",{"formTitle":[1,"form-title"],"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-grid.cjs",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"messageBuilder":[16],"beforeSave":[16],"afterSave":[16],"autoLoad":[4,"auto-load"],"getDataUnit":[64]}]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application.cjs",[[2,"snk-application",{"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getOrCreateDataUnit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["snk-taskbar.cjs",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_moreOptionsOpened":[32],"_permissions":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-1133bc2a.js');
3
+ const index = require('./index-ebe8245e.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.16.1 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application.cjs",[[2,"snk-application",{"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
18
+ return index.bootstrapLazy([["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-form.cjs",[[2,"snk-form",{"formTitle":[1,"form-title"],"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-grid.cjs",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"messageBuilder":[16],"beforeSave":[16],"afterSave":[16],"autoLoad":[4,"auto-load"],"getDataUnit":[64]}]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application.cjs",[[2,"snk-application",{"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getOrCreateDataUnit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["snk-taskbar.cjs",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_moreOptionsOpened":[32],"_permissions":[32]}]]]], options);
19
19
  });
@@ -2,10 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-1133bc2a.js');
5
+ const index = require('./index-ebe8245e.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
8
- const UnitMetadata = require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
9
8
 
10
9
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
11
10
 
@@ -1236,7 +1235,7 @@ function isNode(maybeNode) {
1236
1235
  }
1237
1236
  /** Name */
1238
1237
 
1239
- let OperationTypeNode;
1238
+ var OperationTypeNode;
1240
1239
  exports.OperationTypeNode = OperationTypeNode;
1241
1240
 
1242
1241
  (function (OperationTypeNode) {
@@ -1256,13 +1255,7 @@ exports.DirectiveLocation = void 0;
1256
1255
  /**
1257
1256
  * The set of allowed directive location values.
1258
1257
  */
1259
- let DirectiveLocation;
1260
- /**
1261
- * The enum type representing the directive location values.
1262
- *
1263
- * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1264
- */
1265
-
1258
+ var DirectiveLocation;
1266
1259
  exports.DirectiveLocation = DirectiveLocation;
1267
1260
 
1268
1261
  (function (DirectiveLocation) {
@@ -1286,6 +1279,11 @@ exports.DirectiveLocation = DirectiveLocation;
1286
1279
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
1287
1280
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
1288
1281
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
1282
+ /**
1283
+ * The enum type representing the directive location values.
1284
+ *
1285
+ * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1286
+ */
1289
1287
  });
1290
1288
 
1291
1289
  var kinds = createCommonjsModule(function (module, exports) {
@@ -1298,13 +1296,7 @@ exports.Kind = void 0;
1298
1296
  /**
1299
1297
  * The set of allowed kind values for AST nodes.
1300
1298
  */
1301
- let Kind;
1302
- /**
1303
- * The enum type representing the possible kind values of AST nodes.
1304
- *
1305
- * @deprecated Please use `Kind`. Will be remove in v17.
1306
- */
1307
-
1299
+ var Kind;
1308
1300
  exports.Kind = Kind;
1309
1301
 
1310
1302
  (function (Kind) {
@@ -1352,6 +1344,11 @@ exports.Kind = Kind;
1352
1344
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
1353
1345
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
1354
1346
  })(Kind || (exports.Kind = Kind = {}));
1347
+ /**
1348
+ * The enum type representing the possible kind values of AST nodes.
1349
+ *
1350
+ * @deprecated Please use `Kind`. Will be remove in v17.
1351
+ */
1355
1352
  });
1356
1353
 
1357
1354
  var characterClasses = createCommonjsModule(function (module, exports) {
@@ -1639,13 +1636,7 @@ exports.TokenKind = void 0;
1639
1636
  * An exported enum describing the different kinds of tokens that the
1640
1637
  * lexer emits.
1641
1638
  */
1642
- let TokenKind;
1643
- /**
1644
- * The enum type representing the token kinds values.
1645
- *
1646
- * @deprecated Please use `TokenKind`. Will be remove in v17.
1647
- */
1648
-
1639
+ var TokenKind;
1649
1640
  exports.TokenKind = TokenKind;
1650
1641
 
1651
1642
  (function (TokenKind) {
@@ -1672,6 +1663,11 @@ exports.TokenKind = TokenKind;
1672
1663
  TokenKind['BLOCK_STRING'] = 'BlockString';
1673
1664
  TokenKind['COMMENT'] = 'Comment';
1674
1665
  })(TokenKind || (exports.TokenKind = TokenKind = {}));
1666
+ /**
1667
+ * The enum type representing the token kinds values.
1668
+ *
1669
+ * @deprecated Please use `TokenKind`. Will be remove in v17.
1670
+ */
1675
1671
  });
1676
1672
 
1677
1673
  var lexer = createCommonjsModule(function (module, exports) {
@@ -3008,12 +3004,13 @@ function parseType(source, options) {
3008
3004
  */
3009
3005
 
3010
3006
  class Parser {
3011
- constructor(source$1, options) {
3007
+ constructor(source$1, options = {}) {
3012
3008
  const sourceObj = (0, source.isSource)(source$1)
3013
3009
  ? source$1
3014
3010
  : new source.Source(source$1);
3015
3011
  this._lexer = new lexer.Lexer(sourceObj);
3016
3012
  this._options = options;
3013
+ this._tokenCounter = 0;
3017
3014
  }
3018
3015
  /**
3019
3016
  * Converts a name lex token into a name parse node.
@@ -3348,18 +3345,12 @@ class Parser {
3348
3345
  */
3349
3346
 
3350
3347
  parseFragmentDefinition() {
3351
- var _this$_options;
3352
-
3353
3348
  const start = this._lexer.token;
3354
3349
  this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes
3355
3350
  // the grammar of FragmentDefinition:
3356
3351
  // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
3357
3352
 
3358
- if (
3359
- ((_this$_options = this._options) === null || _this$_options === void 0
3360
- ? void 0
3361
- : _this$_options.allowLegacyFragmentVariables) === true
3362
- ) {
3353
+ if (this._options.allowLegacyFragmentVariables === true) {
3363
3354
  return this.node(start, {
3364
3355
  kind: kinds.Kind.FRAGMENT_DEFINITION,
3365
3356
  name: this.parseFragmentName(),
@@ -3420,16 +3411,14 @@ class Parser {
3420
3411
  return this.parseObject(isConst);
3421
3412
 
3422
3413
  case tokenKind.TokenKind.INT:
3423
- this._lexer.advance();
3424
-
3414
+ this.advanceLexer();
3425
3415
  return this.node(token, {
3426
3416
  kind: kinds.Kind.INT,
3427
3417
  value: token.value,
3428
3418
  });
3429
3419
 
3430
3420
  case tokenKind.TokenKind.FLOAT:
3431
- this._lexer.advance();
3432
-
3421
+ this.advanceLexer();
3433
3422
  return this.node(token, {
3434
3423
  kind: kinds.Kind.FLOAT,
3435
3424
  value: token.value,
@@ -3440,7 +3429,7 @@ class Parser {
3440
3429
  return this.parseStringLiteral();
3441
3430
 
3442
3431
  case tokenKind.TokenKind.NAME:
3443
- this._lexer.advance();
3432
+ this.advanceLexer();
3444
3433
 
3445
3434
  switch (token.value) {
3446
3435
  case 'true':
@@ -3496,9 +3485,7 @@ class Parser {
3496
3485
 
3497
3486
  parseStringLiteral() {
3498
3487
  const token = this._lexer.token;
3499
-
3500
- this._lexer.advance();
3501
-
3488
+ this.advanceLexer();
3502
3489
  return this.node(token, {
3503
3490
  kind: kinds.Kind.STRING,
3504
3491
  value: token.value,
@@ -4289,13 +4276,7 @@ class Parser {
4289
4276
  */
4290
4277
 
4291
4278
  node(startToken, node) {
4292
- var _this$_options2;
4293
-
4294
- if (
4295
- ((_this$_options2 = this._options) === null || _this$_options2 === void 0
4296
- ? void 0
4297
- : _this$_options2.noLocation) !== true
4298
- ) {
4279
+ if (this._options.noLocation !== true) {
4299
4280
  node.loc = new ast.Location(
4300
4281
  startToken,
4301
4282
  this._lexer.lastToken,
@@ -4321,8 +4302,7 @@ class Parser {
4321
4302
  const token = this._lexer.token;
4322
4303
 
4323
4304
  if (token.kind === kind) {
4324
- this._lexer.advance();
4325
-
4305
+ this.advanceLexer();
4326
4306
  return token;
4327
4307
  }
4328
4308
 
@@ -4341,8 +4321,7 @@ class Parser {
4341
4321
  const token = this._lexer.token;
4342
4322
 
4343
4323
  if (token.kind === kind) {
4344
- this._lexer.advance();
4345
-
4324
+ this.advanceLexer();
4346
4325
  return true;
4347
4326
  }
4348
4327
 
@@ -4357,7 +4336,7 @@ class Parser {
4357
4336
  const token = this._lexer.token;
4358
4337
 
4359
4338
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4360
- this._lexer.advance();
4339
+ this.advanceLexer();
4361
4340
  } else {
4362
4341
  throw (0, syntaxError_1.syntaxError)(
4363
4342
  this._lexer.source,
@@ -4375,8 +4354,7 @@ class Parser {
4375
4354
  const token = this._lexer.token;
4376
4355
 
4377
4356
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4378
- this._lexer.advance();
4379
-
4357
+ this.advanceLexer();
4380
4358
  return true;
4381
4359
  }
4382
4360
 
@@ -4463,6 +4441,24 @@ class Parser {
4463
4441
 
4464
4442
  return nodes;
4465
4443
  }
4444
+
4445
+ advanceLexer() {
4446
+ const { maxTokens } = this._options;
4447
+
4448
+ const token = this._lexer.advance();
4449
+
4450
+ if (maxTokens !== undefined && token.kind !== tokenKind.TokenKind.EOF) {
4451
+ ++this._tokenCounter;
4452
+
4453
+ if (this._tokenCounter > maxTokens) {
4454
+ throw (0, syntaxError_1.syntaxError)(
4455
+ this._lexer.source,
4456
+ token.start,
4457
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`,
4458
+ );
4459
+ }
4460
+ }
4461
+ }
4466
4462
  }
4467
4463
  /**
4468
4464
  * A helper function to describe a token as a string for debugging.
@@ -6723,9 +6719,9 @@ class DataUnitFetcher {
6723
6719
  }
6724
6720
  }
6725
6721
  }`);
6726
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [InputFilter!] $sort: [InputSort!]) {
6722
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
6727
6723
  $queryAlias$: fetchDataUnit(name: $dataunit){
6728
- data(limit: $limit offset: $offset filters: $filter sort: $sort){
6724
+ data(limit: $limit offset: $offset filters: $filters sort: $sort){
6729
6725
  limit
6730
6726
  offset
6731
6727
  total
@@ -6754,7 +6750,7 @@ class DataUnitFetcher {
6754
6750
  getDataUnit(entityName, resourceID) {
6755
6751
  const dataUnit = new core.DataUnit(`dd://${entityName}/${resourceID}`);
6756
6752
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6757
- dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6753
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
6758
6754
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6759
6755
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6760
6756
  return dataUnit;
@@ -6791,25 +6787,24 @@ class DataUnitFetcher {
6791
6787
  });
6792
6788
  });
6793
6789
  }
6794
- loadData(dataUnit, page, sort, filter) {
6790
+ loadData(dataUnit, request) {
6795
6791
  return new Promise((resolve, reject) => {
6796
- var _a, _b, _c;
6797
- const variables = { dataunit: dataUnit.name, sort, filter };
6798
- if (page) {
6799
- variables.limit = page.limit;
6800
- variables.offset = page.offset;
6801
- }
6802
- if (!core.StringUtils.isEmpty((_a = page === null || page === void 0 ? void 0 : page.quickFilter) === null || _a === void 0 ? void 0 : _a.term)) {
6792
+ var _a;
6793
+ const { sort, filters, limit, offset, quickFilter } = request;
6794
+ const variables = { dataunit: dataUnit.name, sort, filters };
6795
+ variables.limit = limit;
6796
+ variables.offset = offset;
6797
+ if (!core.StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
6803
6798
  if (variables.filter === undefined) {
6804
6799
  variables.filter = [];
6805
6800
  }
6806
6801
  const quickFilterCriteria = {
6807
6802
  name: "__QUICK_FILTER__",
6808
6803
  expression: "__QUICK_FILTER__",
6809
- params: [{ name: "term", dataType: core.DataType.TEXT, value: page.quickFilter.term }]
6804
+ params: [{ name: "term", dataType: core.DataType.TEXT, value: quickFilter.term }]
6810
6805
  };
6811
- if (((_c = (_b = page.quickFilter) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.length) > 0) {
6812
- quickFilterCriteria.params.push({ name: "fields", dataType: core.DataType.OBJECT, value: page.quickFilter.fields });
6806
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6807
+ quickFilterCriteria.params.push({ name: "fields", dataType: core.DataType.OBJECT, value: quickFilter.fields });
6813
6808
  }
6814
6809
  variables.filter.push(quickFilterCriteria);
6815
6810
  }
@@ -6819,16 +6814,32 @@ class DataUnitFetcher {
6819
6814
  query: this.templateByQuery.get("fetchData"),
6820
6815
  })
6821
6816
  .then((resp) => {
6822
- const pageResult = resp.data;
6823
- const records = [];
6824
- pageResult.records.forEach((responseRecord) => {
6817
+ const { limit, offset, total, hasMore, records } = resp.data;
6818
+ let paginationInfo;
6819
+ if (limit) {
6820
+ const firstRecord = offset + 1;
6821
+ const lastRecord = offset + Math.min(records.length, limit);
6822
+ const currentPage = offset / limit;
6823
+ paginationInfo = {
6824
+ firstRecord,
6825
+ lastRecord,
6826
+ total,
6827
+ currentPage,
6828
+ hasMore
6829
+ };
6830
+ }
6831
+ const processedRecords = [];
6832
+ records.forEach((responseRecord) => {
6825
6833
  const duRecord = { __record__id__: responseRecord.id };
6826
6834
  responseRecord.fields.forEach(({ name, value }) => {
6827
6835
  duRecord[name] = dataUnit.valueFromString(name, value);
6828
6836
  });
6829
- records.push(duRecord);
6837
+ processedRecords.push(duRecord);
6838
+ });
6839
+ resolve({
6840
+ paginationInfo,
6841
+ records: processedRecords
6830
6842
  });
6831
- resolve(Object.assign(Object.assign({}, pageResult), { records }));
6832
6843
  })
6833
6844
  .catch((error) => {
6834
6845
  reject(error);
@@ -7054,15 +7065,16 @@ class GridConfigFetcher extends ResourceFetcher {
7054
7065
  super(...arguments);
7055
7066
  this.GRID_CONFIG_VERSION = "V3:";
7056
7067
  }
7057
- getConfig(resourceID) {
7068
+ getConfig(_gridName, resourceID) {
7058
7069
  const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
7059
7070
  return new Promise((resolve, reject) => {
7060
7071
  this.loadResource(completePath)
7061
7072
  .then(loadedResource => {
7073
+ let config = undefined;
7062
7074
  if (loadedResource) {
7063
- let config = JSON.parse(loadedResource);
7064
- resolve(config);
7075
+ config = JSON.parse(loadedResource);
7065
7076
  }
7077
+ resolve(config);
7066
7078
  }).catch((error) => {
7067
7079
  reject(error);
7068
7080
  });
@@ -7255,6 +7267,7 @@ const SnkApplication = class {
7255
7267
  index.registerInstance(this, hostRef);
7256
7268
  this.applicationLoaded = index.createEvent(this, "applicationLoaded", 7);
7257
7269
  this.applicationLoading = index.createEvent(this, "applicationLoading", 7);
7270
+ this._duCache = new Map();
7258
7271
  this._requestListener = new RequestListenerLoadingBar();
7259
7272
  }
7260
7273
  get parameters() {
@@ -7415,6 +7428,22 @@ const SnkApplication = class {
7415
7428
  dataUnit.loadMetadata().then(() => resolve(dataUnit));
7416
7429
  });
7417
7430
  }
7431
+ async getOrCreateDataUnit(entityName, dataUnitName) {
7432
+ return new Promise((resolve, reject) => {
7433
+ const dataUnit = this._duCache.get(dataUnitName);
7434
+ if (dataUnit) {
7435
+ resolve(dataUnit);
7436
+ }
7437
+ else {
7438
+ this.createDataunit(entityName).then(dataUnit => {
7439
+ if (dataUnitName) {
7440
+ this._duCache.set(dataUnitName, dataUnit);
7441
+ }
7442
+ resolve(dataUnit);
7443
+ }).catch(reason => reject(reason));
7444
+ }
7445
+ });
7446
+ }
7418
7447
  async getResourceID() {
7419
7448
  return Promise.resolve(this.resourceID);
7420
7449
  }
@@ -7433,8 +7462,8 @@ const SnkApplication = class {
7433
7462
  async loadFormConfig(name) {
7434
7463
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7435
7464
  }
7436
- async loadGridConfig() {
7437
- return this.gridConfigFetcher.getConfig(this.resourceID);
7465
+ async loadGridConfig(name) {
7466
+ return this.gridConfigFetcher.getConfig(name, this.resourceID);
7438
7467
  }
7439
7468
  async saveGridConfig(config) {
7440
7469
  return this.gridConfigFetcher.saveConfig(config, this.resourceID);
@@ -7491,7 +7520,7 @@ const SnkApplication = class {
7491
7520
  };
7492
7521
  dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => { var _a; return (_a = dep.masterFields) === null || _a === void 0 ? void 0 : _a.every(f => { var _a; return (_a = dataUnit.getField(f)) === null || _a === void 0 ? void 0 : _a.visible; }); }).forEach(dependency => {
7493
7522
  var _a;
7494
- if (dependency.type === UnitMetadata.DependencyType.SEARCHING) {
7523
+ if (dependency.type === core.DependencyType.SEARCHING) {
7495
7524
  if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
7496
7525
  criteria = {
7497
7526
  expression: dependency.expression,
@@ -7547,6 +7576,7 @@ const SnkApplication = class {
7547
7576
  });
7548
7577
  core.ApplicationContext.setContextValue("__EZUI__GRID_LICENSE__", agGridLicense);
7549
7578
  core.ErrorTracking.init();
7579
+ core.ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
7550
7580
  }
7551
7581
  connectedCallback() {
7552
7582
  DataFetcher.addRequestListener(this._requestListener);
@@ -0,0 +1,174 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ebe8245e.js');
6
+ const core = require('@sankhyalabs/core');
7
+ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
8
+
9
+ const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
10
+
11
+ const SnkDataUnit = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.insertionMode = index.createEvent(this, "insertionMode", 7);
15
+ this.dataStateChange = index.createEvent(this, "dataStateChange", 7);
16
+ this.dataUnitReady = index.createEvent(this, "dataUnitReady", 7);
17
+ this._onDataUnitResolve = [];
18
+ this._dataUnitObserver = (action) => {
19
+ let msg = this.getActionInfo(action.type);
20
+ if (msg) {
21
+ utils.ApplicationUtils.info(msg);
22
+ }
23
+ if (action.type === core.Action.RECORDS_ADDED || action.type === core.Action.RECORDS_COPIED) {
24
+ this.insertionMode.emit();
25
+ }
26
+ const duState = {
27
+ insertionMode: false,
28
+ hasNext: this.dataUnit.hasNext(),
29
+ hasPrevious: this.dataUnit.hasPrevious(),
30
+ copyMode: false,
31
+ isDirty: this.dataUnit.isDirty(),
32
+ selectedRecords: this.dataUnit.getSelectedRecords()
33
+ };
34
+ this.dataUnit.records.forEach(r => {
35
+ if (r.__record__id__.startsWith('NEW_')) {
36
+ duState.insertionMode = true;
37
+ duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
38
+ }
39
+ });
40
+ this.dataState = duState;
41
+ };
42
+ }
43
+ async getDataUnit() {
44
+ return new Promise((resolve) => {
45
+ if (this.dataUnit) {
46
+ resolve(this.dataUnit);
47
+ }
48
+ else {
49
+ this._onDataUnitResolve.push(resolve);
50
+ }
51
+ });
52
+ }
53
+ async interceptAction(action) {
54
+ return new Promise(resolve => {
55
+ switch (action.type) {
56
+ case core.Action.SAVING_DATA:
57
+ if (this.beforeSave) {
58
+ const continueAction = this.beforeSave(this.dataUnit);
59
+ if (continueAction instanceof Promise) {
60
+ continueAction.then(result => resolve(result ? action : undefined));
61
+ }
62
+ else {
63
+ resolve(continueAction ? action : undefined);
64
+ }
65
+ }
66
+ else {
67
+ resolve(action);
68
+ }
69
+ break;
70
+ case core.Action.DATA_SAVED:
71
+ if (this.afterSave) {
72
+ this.afterSave(this.dataUnit);
73
+ }
74
+ else {
75
+ resolve(action);
76
+ }
77
+ break;
78
+ case core.Action.EDITION_CANCELED:
79
+ utils.ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
80
+ .then((result) => resolve(result ? action : undefined));
81
+ break;
82
+ case core.Action.REMOVING_RECORDS:
83
+ utils.ApplicationUtils.confirm(this.i18n("components.delete"), this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
84
+ .then((result) => resolve(result ? action : undefined));
85
+ break;
86
+ default:
87
+ resolve(action);
88
+ }
89
+ });
90
+ }
91
+ getActionInfo(action) {
92
+ if (this.messageBuilder) {
93
+ return this.messageBuilder(action, this.dataState, this.dataUnit);
94
+ }
95
+ else {
96
+ if (action === core.Action.EDITION_CANCELED) {
97
+ return this.i18n("components.editionCanceled");
98
+ }
99
+ }
100
+ }
101
+ observePageSize() {
102
+ if (this.dataUnit) {
103
+ this.dataUnit.pageSize = this.pageSize;
104
+ }
105
+ }
106
+ observeDataUnitName(newValue, oldValue) {
107
+ if (oldValue != newValue) {
108
+ this.dataUnit = undefined;
109
+ this.dataUnitName = newValue;
110
+ this.loadDataUnit();
111
+ }
112
+ }
113
+ observeEntityName(newValue, oldValue) {
114
+ if (oldValue != newValue) {
115
+ this.dataUnit = undefined;
116
+ this.entityName = newValue;
117
+ this.loadDataUnit();
118
+ }
119
+ }
120
+ observeDataState(newValue, oldValue) {
121
+ if (oldValue != newValue) {
122
+ this.dataStateChange.emit(newValue);
123
+ }
124
+ }
125
+ observeDataUnit() {
126
+ this.dataUnitReady.emit(this.dataUnit);
127
+ }
128
+ async loadDataUnit() {
129
+ if (!this.dataUnit) {
130
+ const app = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
131
+ if (app && this.entityName) {
132
+ this.dataUnit = await app.getOrCreateDataUnit(this.entityName, this.dataUnitName);
133
+ this.dataUnit.pageSize = this.pageSize;
134
+ this.dataUnit.unsubscribe(this._dataUnitObserver);
135
+ this.dataUnit.addInterceptor(this);
136
+ this.dataUnit.subscribe(this._dataUnitObserver);
137
+ let resolver;
138
+ while (resolver = this._onDataUnitResolve.pop()) {
139
+ resolver(this.dataUnit);
140
+ }
141
+ if (this.autoLoad) {
142
+ this.dataUnit.loadData();
143
+ }
144
+ }
145
+ }
146
+ }
147
+ i18n(key) {
148
+ const pt_br = {
149
+ "components.warning": "Aviso",
150
+ "components.delete": "Excluir",
151
+ "components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
152
+ "components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
153
+ "components.editionCanceled": "Todas as alterações foram descartadas.",
154
+ };
155
+ return pt_br[key];
156
+ }
157
+ componentDidRender() {
158
+ this.loadDataUnit();
159
+ }
160
+ render() {
161
+ return (index.h(index.Host, null));
162
+ }
163
+ get element() { return index.getElement(this); }
164
+ static get watchers() { return {
165
+ "pageSize": ["observePageSize"],
166
+ "dataUnitName": ["observeDataUnitName"],
167
+ "entityName": ["observeEntityName"],
168
+ "dataState": ["observeDataState"],
169
+ "dataUnit": ["observeDataUnit"]
170
+ }; }
171
+ };
172
+ SnkDataUnit.style = snkDataUnitCss;
173
+
174
+ exports.snk_data_unit = SnkDataUnit;