@sankhyalabs/sankhyablocks 1.3.30 → 1.3.31-beta.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.
Files changed (68) hide show
  1. package/dist/cjs/{index-1133bc2a.js → index-e42cb45d.js} +448 -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 +105 -79
  5. package/dist/cjs/snk-data-unit.cjs.entry.js +144 -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-bfa647c7.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 +325 -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 +32 -21
  25. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  26. package/dist/components/snk-application2.js +105 -78
  27. package/dist/components/snk-data-unit.d.ts +11 -0
  28. package/dist/components/snk-data-unit.js +165 -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-02c04e0f.js} +448 -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 +105 -79
  40. package/dist/esm/snk-data-unit.entry.js +140 -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-fe7cbf0e.js +66 -0
  46. package/dist/esm/teste-pesquisa.entry.js +1 -1
  47. package/dist/sankhyablocks/p-09e48ff8.entry.js +1 -0
  48. package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-376004ef.entry.js} +1 -1
  49. package/dist/sankhyablocks/p-37b06977.entry.js +1 -0
  50. package/dist/sankhyablocks/p-64e2471c.js +1 -0
  51. package/dist/sankhyablocks/p-b80352ac.entry.js +69 -0
  52. package/dist/sankhyablocks/p-c156b1da.entry.js +1 -0
  53. package/dist/sankhyablocks/p-cc9c348a.entry.js +1 -0
  54. package/dist/sankhyablocks/p-db215c74.js +2 -0
  55. package/dist/sankhyablocks/{p-d62412bb.entry.js → p-e38386b1.entry.js} +1 -1
  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 +112 -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
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-ffda6382.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-02c04e0f.js';
2
2
 
3
3
  /*
4
4
  Stencil Client Patch Esm v2.16.1 | MIT Licensed | https://stenciljs.com
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application",[[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",[[1,"teste-pesquisa"]]]], options);
13
+ return bootstrapLazy([["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-form",[[2,"snk-form",{"formTitle":[1,"form-title"],"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-grid",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"messageBuilder":[16],"getDataUnit":[64]}]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application",[[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",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_moreOptionsOpened":[32],"_permissions":[32]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-ffda6382.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-02c04e0f.js';
2
2
 
3
3
  /*
4
4
  Stencil Client Patch Browser v2.16.1 | MIT Licensed | https://stenciljs.com
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application",[[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",[[1,"teste-pesquisa"]]]], options);
16
+ return bootstrapLazy([["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-form",[[2,"snk-form",{"formTitle":[1,"form-title"],"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-grid",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32]}]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"messageBuilder":[16],"getDataUnit":[64]}]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-application",[[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",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_moreOptionsOpened":[32],"_permissions":[32]}]]]], options);
17
17
  });
@@ -1,7 +1,6 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-ffda6382.js';
2
- import { ErrorException, StringUtils, DataUnit, DataType, ChangeOperation, DateUtils, ObjectUtils, WaitingChangeException, WarningException, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
1
+ import { r as registerInstance, c as createEvent, h } from './index-02c04e0f.js';
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
 
6
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7
6
 
@@ -1232,7 +1231,7 @@ function isNode(maybeNode) {
1232
1231
  }
1233
1232
  /** Name */
1234
1233
 
1235
- let OperationTypeNode;
1234
+ var OperationTypeNode;
1236
1235
  exports.OperationTypeNode = OperationTypeNode;
1237
1236
 
1238
1237
  (function (OperationTypeNode) {
@@ -1252,13 +1251,7 @@ exports.DirectiveLocation = void 0;
1252
1251
  /**
1253
1252
  * The set of allowed directive location values.
1254
1253
  */
1255
- let DirectiveLocation;
1256
- /**
1257
- * The enum type representing the directive location values.
1258
- *
1259
- * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1260
- */
1261
-
1254
+ var DirectiveLocation;
1262
1255
  exports.DirectiveLocation = DirectiveLocation;
1263
1256
 
1264
1257
  (function (DirectiveLocation) {
@@ -1282,6 +1275,11 @@ exports.DirectiveLocation = DirectiveLocation;
1282
1275
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
1283
1276
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
1284
1277
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
1278
+ /**
1279
+ * The enum type representing the directive location values.
1280
+ *
1281
+ * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
1282
+ */
1285
1283
  });
1286
1284
 
1287
1285
  var kinds = createCommonjsModule(function (module, exports) {
@@ -1294,13 +1292,7 @@ exports.Kind = void 0;
1294
1292
  /**
1295
1293
  * The set of allowed kind values for AST nodes.
1296
1294
  */
1297
- let Kind;
1298
- /**
1299
- * The enum type representing the possible kind values of AST nodes.
1300
- *
1301
- * @deprecated Please use `Kind`. Will be remove in v17.
1302
- */
1303
-
1295
+ var Kind;
1304
1296
  exports.Kind = Kind;
1305
1297
 
1306
1298
  (function (Kind) {
@@ -1348,6 +1340,11 @@ exports.Kind = Kind;
1348
1340
  Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
1349
1341
  Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
1350
1342
  })(Kind || (exports.Kind = Kind = {}));
1343
+ /**
1344
+ * The enum type representing the possible kind values of AST nodes.
1345
+ *
1346
+ * @deprecated Please use `Kind`. Will be remove in v17.
1347
+ */
1351
1348
  });
1352
1349
 
1353
1350
  var characterClasses = createCommonjsModule(function (module, exports) {
@@ -1635,13 +1632,7 @@ exports.TokenKind = void 0;
1635
1632
  * An exported enum describing the different kinds of tokens that the
1636
1633
  * lexer emits.
1637
1634
  */
1638
- let TokenKind;
1639
- /**
1640
- * The enum type representing the token kinds values.
1641
- *
1642
- * @deprecated Please use `TokenKind`. Will be remove in v17.
1643
- */
1644
-
1635
+ var TokenKind;
1645
1636
  exports.TokenKind = TokenKind;
1646
1637
 
1647
1638
  (function (TokenKind) {
@@ -1668,6 +1659,11 @@ exports.TokenKind = TokenKind;
1668
1659
  TokenKind['BLOCK_STRING'] = 'BlockString';
1669
1660
  TokenKind['COMMENT'] = 'Comment';
1670
1661
  })(TokenKind || (exports.TokenKind = TokenKind = {}));
1662
+ /**
1663
+ * The enum type representing the token kinds values.
1664
+ *
1665
+ * @deprecated Please use `TokenKind`. Will be remove in v17.
1666
+ */
1671
1667
  });
1672
1668
 
1673
1669
  var lexer = createCommonjsModule(function (module, exports) {
@@ -3004,12 +3000,13 @@ function parseType(source, options) {
3004
3000
  */
3005
3001
 
3006
3002
  class Parser {
3007
- constructor(source$1, options) {
3003
+ constructor(source$1, options = {}) {
3008
3004
  const sourceObj = (0, source.isSource)(source$1)
3009
3005
  ? source$1
3010
3006
  : new source.Source(source$1);
3011
3007
  this._lexer = new lexer.Lexer(sourceObj);
3012
3008
  this._options = options;
3009
+ this._tokenCounter = 0;
3013
3010
  }
3014
3011
  /**
3015
3012
  * Converts a name lex token into a name parse node.
@@ -3344,18 +3341,12 @@ class Parser {
3344
3341
  */
3345
3342
 
3346
3343
  parseFragmentDefinition() {
3347
- var _this$_options;
3348
-
3349
3344
  const start = this._lexer.token;
3350
3345
  this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes
3351
3346
  // the grammar of FragmentDefinition:
3352
3347
  // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
3353
3348
 
3354
- if (
3355
- ((_this$_options = this._options) === null || _this$_options === void 0
3356
- ? void 0
3357
- : _this$_options.allowLegacyFragmentVariables) === true
3358
- ) {
3349
+ if (this._options.allowLegacyFragmentVariables === true) {
3359
3350
  return this.node(start, {
3360
3351
  kind: kinds.Kind.FRAGMENT_DEFINITION,
3361
3352
  name: this.parseFragmentName(),
@@ -3416,16 +3407,14 @@ class Parser {
3416
3407
  return this.parseObject(isConst);
3417
3408
 
3418
3409
  case tokenKind.TokenKind.INT:
3419
- this._lexer.advance();
3420
-
3410
+ this.advanceLexer();
3421
3411
  return this.node(token, {
3422
3412
  kind: kinds.Kind.INT,
3423
3413
  value: token.value,
3424
3414
  });
3425
3415
 
3426
3416
  case tokenKind.TokenKind.FLOAT:
3427
- this._lexer.advance();
3428
-
3417
+ this.advanceLexer();
3429
3418
  return this.node(token, {
3430
3419
  kind: kinds.Kind.FLOAT,
3431
3420
  value: token.value,
@@ -3436,7 +3425,7 @@ class Parser {
3436
3425
  return this.parseStringLiteral();
3437
3426
 
3438
3427
  case tokenKind.TokenKind.NAME:
3439
- this._lexer.advance();
3428
+ this.advanceLexer();
3440
3429
 
3441
3430
  switch (token.value) {
3442
3431
  case 'true':
@@ -3492,9 +3481,7 @@ class Parser {
3492
3481
 
3493
3482
  parseStringLiteral() {
3494
3483
  const token = this._lexer.token;
3495
-
3496
- this._lexer.advance();
3497
-
3484
+ this.advanceLexer();
3498
3485
  return this.node(token, {
3499
3486
  kind: kinds.Kind.STRING,
3500
3487
  value: token.value,
@@ -4285,13 +4272,7 @@ class Parser {
4285
4272
  */
4286
4273
 
4287
4274
  node(startToken, node) {
4288
- var _this$_options2;
4289
-
4290
- if (
4291
- ((_this$_options2 = this._options) === null || _this$_options2 === void 0
4292
- ? void 0
4293
- : _this$_options2.noLocation) !== true
4294
- ) {
4275
+ if (this._options.noLocation !== true) {
4295
4276
  node.loc = new ast.Location(
4296
4277
  startToken,
4297
4278
  this._lexer.lastToken,
@@ -4317,8 +4298,7 @@ class Parser {
4317
4298
  const token = this._lexer.token;
4318
4299
 
4319
4300
  if (token.kind === kind) {
4320
- this._lexer.advance();
4321
-
4301
+ this.advanceLexer();
4322
4302
  return token;
4323
4303
  }
4324
4304
 
@@ -4337,8 +4317,7 @@ class Parser {
4337
4317
  const token = this._lexer.token;
4338
4318
 
4339
4319
  if (token.kind === kind) {
4340
- this._lexer.advance();
4341
-
4320
+ this.advanceLexer();
4342
4321
  return true;
4343
4322
  }
4344
4323
 
@@ -4353,7 +4332,7 @@ class Parser {
4353
4332
  const token = this._lexer.token;
4354
4333
 
4355
4334
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4356
- this._lexer.advance();
4335
+ this.advanceLexer();
4357
4336
  } else {
4358
4337
  throw (0, syntaxError_1.syntaxError)(
4359
4338
  this._lexer.source,
@@ -4371,8 +4350,7 @@ class Parser {
4371
4350
  const token = this._lexer.token;
4372
4351
 
4373
4352
  if (token.kind === tokenKind.TokenKind.NAME && token.value === value) {
4374
- this._lexer.advance();
4375
-
4353
+ this.advanceLexer();
4376
4354
  return true;
4377
4355
  }
4378
4356
 
@@ -4459,6 +4437,24 @@ class Parser {
4459
4437
 
4460
4438
  return nodes;
4461
4439
  }
4440
+
4441
+ advanceLexer() {
4442
+ const { maxTokens } = this._options;
4443
+
4444
+ const token = this._lexer.advance();
4445
+
4446
+ if (maxTokens !== undefined && token.kind !== tokenKind.TokenKind.EOF) {
4447
+ ++this._tokenCounter;
4448
+
4449
+ if (this._tokenCounter > maxTokens) {
4450
+ throw (0, syntaxError_1.syntaxError)(
4451
+ this._lexer.source,
4452
+ token.start,
4453
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`,
4454
+ );
4455
+ }
4456
+ }
4457
+ }
4462
4458
  }
4463
4459
  /**
4464
4460
  * A helper function to describe a token as a string for debugging.
@@ -6719,9 +6715,9 @@ class DataUnitFetcher {
6719
6715
  }
6720
6716
  }
6721
6717
  }`);
6722
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [InputFilter!] $sort: [InputSort!]) {
6718
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
6723
6719
  $queryAlias$: fetchDataUnit(name: $dataunit){
6724
- data(limit: $limit offset: $offset filters: $filter sort: $sort){
6720
+ data(limit: $limit offset: $offset filters: $filters sort: $sort){
6725
6721
  limit
6726
6722
  offset
6727
6723
  total
@@ -6750,7 +6746,7 @@ class DataUnitFetcher {
6750
6746
  getDataUnit(entityName, resourceID) {
6751
6747
  const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6752
6748
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6753
- dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6749
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
6754
6750
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6755
6751
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6756
6752
  return dataUnit;
@@ -6787,25 +6783,24 @@ class DataUnitFetcher {
6787
6783
  });
6788
6784
  });
6789
6785
  }
6790
- loadData(dataUnit, page, sort, filter) {
6786
+ loadData(dataUnit, request) {
6791
6787
  return new Promise((resolve, reject) => {
6792
- var _a, _b, _c;
6793
- const variables = { dataunit: dataUnit.name, sort, filter };
6794
- if (page) {
6795
- variables.limit = page.limit;
6796
- variables.offset = page.offset;
6797
- }
6798
- if (!StringUtils.isEmpty((_a = page === null || page === void 0 ? void 0 : page.quickFilter) === null || _a === void 0 ? void 0 : _a.term)) {
6788
+ var _a;
6789
+ const { sort, filters, limit, offset, quickFilter } = request;
6790
+ const variables = { dataunit: dataUnit.name, sort, filters };
6791
+ variables.limit = limit;
6792
+ variables.offset = offset;
6793
+ if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
6799
6794
  if (variables.filter === undefined) {
6800
6795
  variables.filter = [];
6801
6796
  }
6802
6797
  const quickFilterCriteria = {
6803
6798
  name: "__QUICK_FILTER__",
6804
6799
  expression: "__QUICK_FILTER__",
6805
- params: [{ name: "term", dataType: DataType.TEXT, value: page.quickFilter.term }]
6800
+ params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
6806
6801
  };
6807
- if (((_c = (_b = page.quickFilter) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.length) > 0) {
6808
- quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: page.quickFilter.fields });
6802
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6803
+ quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
6809
6804
  }
6810
6805
  variables.filter.push(quickFilterCriteria);
6811
6806
  }
@@ -6815,16 +6810,28 @@ class DataUnitFetcher {
6815
6810
  query: this.templateByQuery.get("fetchData"),
6816
6811
  })
6817
6812
  .then((resp) => {
6818
- const pageResult = resp.data;
6819
- const records = [];
6820
- pageResult.records.forEach((responseRecord) => {
6813
+ const { limit, offset, total, hasMore, records } = resp.data;
6814
+ const firstRecord = offset + 1;
6815
+ const lastRecord = offset + Math.min(records.length, limit);
6816
+ const currentPage = offset / limit;
6817
+ const processedRecords = [];
6818
+ records.forEach((responseRecord) => {
6821
6819
  const duRecord = { __record__id__: responseRecord.id };
6822
6820
  responseRecord.fields.forEach(({ name, value }) => {
6823
6821
  duRecord[name] = dataUnit.valueFromString(name, value);
6824
6822
  });
6825
- records.push(duRecord);
6823
+ processedRecords.push(duRecord);
6824
+ });
6825
+ resolve({
6826
+ paginationInfo: {
6827
+ firstRecord,
6828
+ lastRecord,
6829
+ total,
6830
+ currentPage,
6831
+ hasMore
6832
+ },
6833
+ records: processedRecords
6826
6834
  });
6827
- resolve(Object.assign(Object.assign({}, pageResult), { records }));
6828
6835
  })
6829
6836
  .catch((error) => {
6830
6837
  reject(error);
@@ -7050,15 +7057,16 @@ class GridConfigFetcher extends ResourceFetcher {
7050
7057
  super(...arguments);
7051
7058
  this.GRID_CONFIG_VERSION = "V3:";
7052
7059
  }
7053
- getConfig(resourceID) {
7060
+ getConfig(_gridName, resourceID) {
7054
7061
  const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
7055
7062
  return new Promise((resolve, reject) => {
7056
7063
  this.loadResource(completePath)
7057
7064
  .then(loadedResource => {
7065
+ let config = undefined;
7058
7066
  if (loadedResource) {
7059
- let config = JSON.parse(loadedResource);
7060
- resolve(config);
7067
+ config = JSON.parse(loadedResource);
7061
7068
  }
7069
+ resolve(config);
7062
7070
  }).catch((error) => {
7063
7071
  reject(error);
7064
7072
  });
@@ -7251,6 +7259,7 @@ const SnkApplication = class {
7251
7259
  registerInstance(this, hostRef);
7252
7260
  this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
7253
7261
  this.applicationLoading = createEvent(this, "applicationLoading", 7);
7262
+ this._duCache = new Map();
7254
7263
  this._requestListener = new RequestListenerLoadingBar();
7255
7264
  }
7256
7265
  get parameters() {
@@ -7411,6 +7420,22 @@ const SnkApplication = class {
7411
7420
  dataUnit.loadMetadata().then(() => resolve(dataUnit));
7412
7421
  });
7413
7422
  }
7423
+ async getOrCreateDataUnit(entityName, dataUnitName) {
7424
+ return new Promise((resolve, reject) => {
7425
+ const dataUnit = this._duCache.get(dataUnitName);
7426
+ if (dataUnit) {
7427
+ resolve(dataUnit);
7428
+ }
7429
+ else {
7430
+ this.createDataunit(entityName).then(dataUnit => {
7431
+ if (dataUnitName) {
7432
+ this._duCache.set(dataUnitName, dataUnit);
7433
+ }
7434
+ resolve(dataUnit);
7435
+ }).catch(reason => reject(reason));
7436
+ }
7437
+ });
7438
+ }
7414
7439
  async getResourceID() {
7415
7440
  return Promise.resolve(this.resourceID);
7416
7441
  }
@@ -7429,8 +7454,8 @@ const SnkApplication = class {
7429
7454
  async loadFormConfig(name) {
7430
7455
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7431
7456
  }
7432
- async loadGridConfig() {
7433
- return this.gridConfigFetcher.getConfig(this.resourceID);
7457
+ async loadGridConfig(name) {
7458
+ return this.gridConfigFetcher.getConfig(name, this.resourceID);
7434
7459
  }
7435
7460
  async saveGridConfig(config) {
7436
7461
  return this.gridConfigFetcher.saveConfig(config, this.resourceID);
@@ -7543,6 +7568,7 @@ const SnkApplication = class {
7543
7568
  });
7544
7569
  ApplicationContext.setContextValue("__EZUI__GRID_LICENSE__", agGridLicense);
7545
7570
  ErrorTracking.init();
7571
+ ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
7546
7572
  }
7547
7573
  connectedCallback() {
7548
7574
  DataFetcher.addRequestListener(this._requestListener);
@@ -0,0 +1,140 @@
1
+ import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-02c04e0f.js';
2
+ import { Action, ApplicationContext } from '@sankhyalabs/core';
3
+ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
+
5
+ const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
6
+
7
+ const SnkDataUnit = class {
8
+ constructor(hostRef) {
9
+ registerInstance(this, hostRef);
10
+ this.dataStateChange = createEvent(this, "dataStateChange", 7);
11
+ this.dataUnitReady = createEvent(this, "dataUnitReady", 7);
12
+ this._onDataUnitResolve = [];
13
+ this._dataUnitObserver = (action) => {
14
+ let msg = this.getActionInfo(action.type);
15
+ if (msg) {
16
+ ApplicationUtils.info(msg);
17
+ }
18
+ const duState = {
19
+ insertionMode: false,
20
+ hasNext: this.dataUnit.hasNext(),
21
+ hasPrevious: this.dataUnit.hasPrevious(),
22
+ copyMode: false,
23
+ isDirty: this.dataUnit.isDirty(),
24
+ selectedRecords: this.dataUnit.getSelectedRecords()
25
+ };
26
+ this.dataUnit.records.forEach(r => {
27
+ if (r.__record__id__.startsWith('NEW_')) {
28
+ duState.insertionMode = true;
29
+ duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
30
+ }
31
+ });
32
+ this.dataState = duState;
33
+ };
34
+ }
35
+ async getDataUnit() {
36
+ return new Promise((resolve) => {
37
+ if (this.dataUnit) {
38
+ resolve(this.dataUnit);
39
+ }
40
+ else {
41
+ this._onDataUnitResolve.push(resolve);
42
+ }
43
+ });
44
+ }
45
+ async interceptAction(action) {
46
+ return new Promise(resolve => {
47
+ if (action.type === Action.EDITION_CANCELED) {
48
+ ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
49
+ .then((result) => resolve(result ? action : undefined));
50
+ }
51
+ else if (action.type === Action.REMOVING_RECORDS) {
52
+ ApplicationUtils.confirm(this.i18n("components.delete"), this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
53
+ .then((result) => resolve(result ? action : undefined));
54
+ }
55
+ else {
56
+ resolve(action);
57
+ }
58
+ });
59
+ }
60
+ getActionInfo(action) {
61
+ if (this.messageBuilder) {
62
+ return this.messageBuilder(action, this.dataState, this.dataUnit);
63
+ }
64
+ else {
65
+ if (action === Action.EDITION_CANCELED) {
66
+ return this.i18n("components.editionCanceled");
67
+ }
68
+ }
69
+ }
70
+ observePageSize() {
71
+ if (this.dataUnit) {
72
+ this.dataUnit.pageSize = this.pageSize;
73
+ }
74
+ }
75
+ observeDataUnitName(newValue, oldValue) {
76
+ if (oldValue != newValue) {
77
+ this.dataUnit = undefined;
78
+ this.dataUnitName = newValue;
79
+ this.loadDataUnit();
80
+ }
81
+ }
82
+ observeEntityName(newValue, oldValue) {
83
+ if (oldValue != newValue) {
84
+ this.dataUnit = undefined;
85
+ this.entityName = newValue;
86
+ this.loadDataUnit();
87
+ }
88
+ }
89
+ observeDataState(newValue, oldValue) {
90
+ if (oldValue != newValue) {
91
+ this.dataStateChange.emit(newValue);
92
+ }
93
+ }
94
+ observeDataUnit() {
95
+ this.dataUnitReady.emit(this.dataUnit);
96
+ }
97
+ async loadDataUnit() {
98
+ if (!this.dataUnit) {
99
+ const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
100
+ if (app && this.entityName) {
101
+ this.dataUnit = await app.getOrCreateDataUnit(this.entityName, this.dataUnitName);
102
+ this.dataUnit.pageSize = this.pageSize;
103
+ this.dataUnit.unsubscribe(this._dataUnitObserver);
104
+ this.dataUnit.addInterceptor(this);
105
+ this.dataUnit.subscribe(this._dataUnitObserver);
106
+ let resolver;
107
+ while (resolver = this._onDataUnitResolve.pop()) {
108
+ resolver(this.dataUnit);
109
+ }
110
+ }
111
+ }
112
+ }
113
+ i18n(key) {
114
+ const pt_br = {
115
+ "components.warning": "Aviso",
116
+ "components.delete": "Excluir",
117
+ "components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
118
+ "components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
119
+ "components.editionCanceled": "Todas as alterações foram descartadas.",
120
+ };
121
+ return pt_br[key];
122
+ }
123
+ componentDidRender() {
124
+ this.loadDataUnit();
125
+ }
126
+ render() {
127
+ return (h(Host, null));
128
+ }
129
+ get element() { return getElement(this); }
130
+ static get watchers() { return {
131
+ "pageSize": ["observePageSize"],
132
+ "dataUnitName": ["observeDataUnitName"],
133
+ "entityName": ["observeEntityName"],
134
+ "dataState": ["observeDataState"],
135
+ "dataUnit": ["observeDataUnit"]
136
+ }; }
137
+ };
138
+ SnkDataUnit.style = snkDataUnitCss;
139
+
140
+ export { SnkDataUnit as snk_data_unit };
@@ -0,0 +1,91 @@
1
+ import { r as registerInstance, c as createEvent, h, g as getElement } from './index-02c04e0f.js';
2
+ import { ApplicationContext } from '@sankhyalabs/core';
3
+
4
+ const snkFormCss = ".sc-snk-form-h{display:block}";
5
+
6
+ const SnkForm = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.exit = createEvent(this, "exit", 7);
10
+ this.actionClick = createEvent(this, "actionClick", 7);
11
+ }
12
+ getFormConfig() {
13
+ return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
14
+ }
15
+ getInsertionHiddenFields(formConfig) {
16
+ const hiddenFields = [];
17
+ formConfig === null || formConfig === void 0 ? void 0 : formConfig.forEach(cfg => {
18
+ const def = this._dataUnit.getField(cfg.name);
19
+ if (def === null || def === void 0 ? void 0 : def.readOnly) {
20
+ hiddenFields.push(cfg.name);
21
+ }
22
+ });
23
+ return hiddenFields;
24
+ }
25
+ exitForm() {
26
+ if (this._dataUnit.isDirty()) {
27
+ this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
28
+ }
29
+ else {
30
+ this.exit.emit();
31
+ }
32
+ }
33
+ getDisabledButtons() {
34
+ const disabled = [];
35
+ if (!this._dataState.hasPrevious) {
36
+ disabled.push("PREVIOUS");
37
+ }
38
+ if (!this._dataState.hasNext) {
39
+ disabled.push("NEXT");
40
+ }
41
+ return disabled;
42
+ }
43
+ componentWillLoad() {
44
+ let parent = this._element.parentElement;
45
+ while (parent) {
46
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
47
+ this._snkDataUnit = parent;
48
+ this._dataUnit = this._snkDataUnit.dataUnit;
49
+ this._dataState = this._snkDataUnit.dataState;
50
+ if (!this._dataUnit) {
51
+ this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
52
+ this._dataUnit = evt.detail;
53
+ });
54
+ }
55
+ this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
56
+ this._dataState = evt.detail;
57
+ });
58
+ break;
59
+ }
60
+ parent = parent.parentElement;
61
+ }
62
+ }
63
+ componentWillRender() {
64
+ if (this._dataUnit && !this._configLoaded) {
65
+ const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
66
+ if (snkApplication) {
67
+ snkApplication.loadFormConfig(this.configName).then(cfg => {
68
+ this._configLoaded = true;
69
+ this._editionFormConfig = cfg;
70
+ this._insertionFormConfig = cfg.filter(fieldCfg => {
71
+ const def = this._dataUnit.getField(fieldCfg.name);
72
+ if (def === null || def === void 0 ? void 0 : def.readOnly) {
73
+ return false;
74
+ }
75
+ return true;
76
+ });
77
+ });
78
+ }
79
+ }
80
+ }
81
+ render() {
82
+ if (!this._configLoaded || !this._dataUnit || !this._dataState) {
83
+ return undefined;
84
+ }
85
+ return (h("section", { class: "ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.formTitle)), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", buttons: this._dataState.isDirty ? "CANCEL,SAVE" : "PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,INSERT", primaryButton: this._dataState.isDirty ? "SAVE" : "INSERT", disabledButtons: this.getDisabledButtons(), actionsList: this.actionsList, dataUnit: this._dataUnit }))), h("div", { class: "ez-padding--small" }), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig() }))))));
86
+ }
87
+ get _element() { return getElement(this); }
88
+ };
89
+ SnkForm.style = snkFormCss;
90
+
91
+ export { SnkForm as snk_form };