@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,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.
@@ -6720,9 +6716,9 @@ class DataUnitFetcher {
6720
6716
  }
6721
6717
  }
6722
6718
  }`);
6723
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [InputFilter!] $sort: [InputSort!]) {
6719
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
6724
6720
  $queryAlias$: fetchDataUnit(name: $dataunit){
6725
- data(limit: $limit offset: $offset filters: $filter sort: $sort){
6721
+ data(limit: $limit offset: $offset filters: $filters sort: $sort){
6726
6722
  limit
6727
6723
  offset
6728
6724
  total
@@ -6751,7 +6747,7 @@ class DataUnitFetcher {
6751
6747
  getDataUnit(entityName, resourceID) {
6752
6748
  const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6753
6749
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6754
- dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6750
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
6755
6751
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6756
6752
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6757
6753
  return dataUnit;
@@ -6788,25 +6784,24 @@ class DataUnitFetcher {
6788
6784
  });
6789
6785
  });
6790
6786
  }
6791
- loadData(dataUnit, page, sort, filter) {
6787
+ loadData(dataUnit, request) {
6792
6788
  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)) {
6789
+ var _a;
6790
+ const { sort, filters, limit, offset, quickFilter } = request;
6791
+ const variables = { dataunit: dataUnit.name, sort, filters };
6792
+ variables.limit = limit;
6793
+ variables.offset = offset;
6794
+ if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
6800
6795
  if (variables.filter === undefined) {
6801
6796
  variables.filter = [];
6802
6797
  }
6803
6798
  const quickFilterCriteria = {
6804
6799
  name: "__QUICK_FILTER__",
6805
6800
  expression: "__QUICK_FILTER__",
6806
- params: [{ name: "term", dataType: DataType.TEXT, value: page.quickFilter.term }]
6801
+ params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
6807
6802
  };
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 });
6803
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6804
+ quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
6810
6805
  }
6811
6806
  variables.filter.push(quickFilterCriteria);
6812
6807
  }
@@ -6816,16 +6811,28 @@ class DataUnitFetcher {
6816
6811
  query: this.templateByQuery.get("fetchData"),
6817
6812
  })
6818
6813
  .then((resp) => {
6819
- const pageResult = resp.data;
6820
- const records = [];
6821
- pageResult.records.forEach((responseRecord) => {
6814
+ const { limit, offset, total, hasMore, records } = resp.data;
6815
+ const firstRecord = offset + 1;
6816
+ const lastRecord = offset + Math.min(records.length, limit);
6817
+ const currentPage = offset / limit;
6818
+ const processedRecords = [];
6819
+ records.forEach((responseRecord) => {
6822
6820
  const duRecord = { __record__id__: responseRecord.id };
6823
6821
  responseRecord.fields.forEach(({ name, value }) => {
6824
6822
  duRecord[name] = dataUnit.valueFromString(name, value);
6825
6823
  });
6826
- records.push(duRecord);
6824
+ processedRecords.push(duRecord);
6825
+ });
6826
+ resolve({
6827
+ paginationInfo: {
6828
+ firstRecord,
6829
+ lastRecord,
6830
+ total,
6831
+ currentPage,
6832
+ hasMore
6833
+ },
6834
+ records: processedRecords
6827
6835
  });
6828
- resolve(Object.assign(Object.assign({}, pageResult), { records }));
6829
6836
  })
6830
6837
  .catch((error) => {
6831
6838
  reject(error);
@@ -7051,15 +7058,16 @@ class GridConfigFetcher extends ResourceFetcher {
7051
7058
  super(...arguments);
7052
7059
  this.GRID_CONFIG_VERSION = "V3:";
7053
7060
  }
7054
- getConfig(resourceID) {
7061
+ getConfig(_gridName, resourceID) {
7055
7062
  const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
7056
7063
  return new Promise((resolve, reject) => {
7057
7064
  this.loadResource(completePath)
7058
7065
  .then(loadedResource => {
7066
+ let config = undefined;
7059
7067
  if (loadedResource) {
7060
- let config = JSON.parse(loadedResource);
7061
- resolve(config);
7068
+ config = JSON.parse(loadedResource);
7062
7069
  }
7070
+ resolve(config);
7063
7071
  }).catch((error) => {
7064
7072
  reject(error);
7065
7073
  });
@@ -7253,6 +7261,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7253
7261
  this.__registerHost();
7254
7262
  this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
7255
7263
  this.applicationLoading = createEvent(this, "applicationLoading", 7);
7264
+ this._duCache = new Map();
7256
7265
  this._requestListener = new RequestListenerLoadingBar();
7257
7266
  }
7258
7267
  get parameters() {
@@ -7413,6 +7422,22 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7413
7422
  dataUnit.loadMetadata().then(() => resolve(dataUnit));
7414
7423
  });
7415
7424
  }
7425
+ async getOrCreateDataUnit(entityName, dataUnitName) {
7426
+ return new Promise((resolve, reject) => {
7427
+ const dataUnit = this._duCache.get(dataUnitName);
7428
+ if (dataUnit) {
7429
+ resolve(dataUnit);
7430
+ }
7431
+ else {
7432
+ this.createDataunit(entityName).then(dataUnit => {
7433
+ if (dataUnitName) {
7434
+ this._duCache.set(dataUnitName, dataUnit);
7435
+ }
7436
+ resolve(dataUnit);
7437
+ }).catch(reason => reject(reason));
7438
+ }
7439
+ });
7440
+ }
7416
7441
  async getResourceID() {
7417
7442
  return Promise.resolve(this.resourceID);
7418
7443
  }
@@ -7431,8 +7456,8 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7431
7456
  async loadFormConfig(name) {
7432
7457
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7433
7458
  }
7434
- async loadGridConfig() {
7435
- return this.gridConfigFetcher.getConfig(this.resourceID);
7459
+ async loadGridConfig(name) {
7460
+ return this.gridConfigFetcher.getConfig(name, this.resourceID);
7436
7461
  }
7437
7462
  async saveGridConfig(config) {
7438
7463
  return this.gridConfigFetcher.saveConfig(config, this.resourceID);
@@ -7545,6 +7570,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7545
7570
  });
7546
7571
  ApplicationContext.setContextValue("__EZUI__GRID_LICENSE__", agGridLicense);
7547
7572
  ErrorTracking.init();
7573
+ ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
7548
7574
  }
7549
7575
  connectedCallback() {
7550
7576
  DataFetcher.addRequestListener(this._requestListener);
@@ -7579,6 +7605,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7579
7605
  "getAttributeFromHTMLWrapper": [64],
7580
7606
  "openApp": [64],
7581
7607
  "createDataunit": [64],
7608
+ "getOrCreateDataUnit": [64],
7582
7609
  "getResourceID": [64],
7583
7610
  "alert": [64],
7584
7611
  "error": [64],
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkDataUnit extends Components.SnkDataUnit, HTMLElement {}
4
+ export const SnkDataUnit: {
5
+ prototype: SnkDataUnit;
6
+ new (): SnkDataUnit;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,165 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
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$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ this.__registerHost();
11
+ this.dataStateChange = createEvent(this, "dataStateChange", 7);
12
+ this.dataUnitReady = createEvent(this, "dataUnitReady", 7);
13
+ this._onDataUnitResolve = [];
14
+ this._dataUnitObserver = (action) => {
15
+ let msg = this.getActionInfo(action.type);
16
+ if (msg) {
17
+ ApplicationUtils.info(msg);
18
+ }
19
+ const duState = {
20
+ insertionMode: false,
21
+ hasNext: this.dataUnit.hasNext(),
22
+ hasPrevious: this.dataUnit.hasPrevious(),
23
+ copyMode: false,
24
+ isDirty: this.dataUnit.isDirty(),
25
+ selectedRecords: this.dataUnit.getSelectedRecords()
26
+ };
27
+ this.dataUnit.records.forEach(r => {
28
+ if (r.__record__id__.startsWith('NEW_')) {
29
+ duState.insertionMode = true;
30
+ duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
31
+ }
32
+ });
33
+ this.dataState = duState;
34
+ };
35
+ }
36
+ async getDataUnit() {
37
+ return new Promise((resolve) => {
38
+ if (this.dataUnit) {
39
+ resolve(this.dataUnit);
40
+ }
41
+ else {
42
+ this._onDataUnitResolve.push(resolve);
43
+ }
44
+ });
45
+ }
46
+ async interceptAction(action) {
47
+ return new Promise(resolve => {
48
+ if (action.type === Action.EDITION_CANCELED) {
49
+ ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
50
+ .then((result) => resolve(result ? action : undefined));
51
+ }
52
+ else if (action.type === Action.REMOVING_RECORDS) {
53
+ ApplicationUtils.confirm(this.i18n("components.delete"), this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
54
+ .then((result) => resolve(result ? action : undefined));
55
+ }
56
+ else {
57
+ resolve(action);
58
+ }
59
+ });
60
+ }
61
+ getActionInfo(action) {
62
+ if (this.messageBuilder) {
63
+ return this.messageBuilder(action, this.dataState, this.dataUnit);
64
+ }
65
+ else {
66
+ if (action === Action.EDITION_CANCELED) {
67
+ return this.i18n("components.editionCanceled");
68
+ }
69
+ }
70
+ }
71
+ observePageSize() {
72
+ if (this.dataUnit) {
73
+ this.dataUnit.pageSize = this.pageSize;
74
+ }
75
+ }
76
+ observeDataUnitName(newValue, oldValue) {
77
+ if (oldValue != newValue) {
78
+ this.dataUnit = undefined;
79
+ this.dataUnitName = newValue;
80
+ this.loadDataUnit();
81
+ }
82
+ }
83
+ observeEntityName(newValue, oldValue) {
84
+ if (oldValue != newValue) {
85
+ this.dataUnit = undefined;
86
+ this.entityName = newValue;
87
+ this.loadDataUnit();
88
+ }
89
+ }
90
+ observeDataState(newValue, oldValue) {
91
+ if (oldValue != newValue) {
92
+ this.dataStateChange.emit(newValue);
93
+ }
94
+ }
95
+ observeDataUnit() {
96
+ this.dataUnitReady.emit(this.dataUnit);
97
+ }
98
+ async loadDataUnit() {
99
+ if (!this.dataUnit) {
100
+ const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
101
+ if (app && this.entityName) {
102
+ this.dataUnit = await app.getOrCreateDataUnit(this.entityName, this.dataUnitName);
103
+ this.dataUnit.pageSize = this.pageSize;
104
+ this.dataUnit.unsubscribe(this._dataUnitObserver);
105
+ this.dataUnit.addInterceptor(this);
106
+ this.dataUnit.subscribe(this._dataUnitObserver);
107
+ let resolver;
108
+ while (resolver = this._onDataUnitResolve.pop()) {
109
+ resolver(this.dataUnit);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ i18n(key) {
115
+ const pt_br = {
116
+ "components.warning": "Aviso",
117
+ "components.delete": "Excluir",
118
+ "components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
119
+ "components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
120
+ "components.editionCanceled": "Todas as alterações foram descartadas.",
121
+ };
122
+ return pt_br[key];
123
+ }
124
+ componentDidRender() {
125
+ this.loadDataUnit();
126
+ }
127
+ render() {
128
+ return (h(Host, null));
129
+ }
130
+ get element() { return this; }
131
+ static get watchers() { return {
132
+ "pageSize": ["observePageSize"],
133
+ "dataUnitName": ["observeDataUnitName"],
134
+ "entityName": ["observeEntityName"],
135
+ "dataState": ["observeDataState"],
136
+ "dataUnit": ["observeDataUnit"]
137
+ }; }
138
+ static get style() { return snkDataUnitCss; }
139
+ }, [2, "snk-data-unit", {
140
+ "dataState": [1040],
141
+ "dataUnitName": [1, "data-unit-name"],
142
+ "entityName": [1, "entity-name"],
143
+ "pageSize": [2, "page-size"],
144
+ "dataUnit": [1040],
145
+ "messageBuilder": [16],
146
+ "getDataUnit": [64]
147
+ }]);
148
+ function defineCustomElement$1() {
149
+ if (typeof customElements === "undefined") {
150
+ return;
151
+ }
152
+ const components = ["snk-data-unit"];
153
+ components.forEach(tagName => { switch (tagName) {
154
+ case "snk-data-unit":
155
+ if (!customElements.get(tagName)) {
156
+ customElements.define(tagName, SnkDataUnit$1);
157
+ }
158
+ break;
159
+ } });
160
+ }
161
+
162
+ const SnkDataUnit = SnkDataUnit$1;
163
+ const defineCustomElement = defineCustomElement$1;
164
+
165
+ export { SnkDataUnit, defineCustomElement };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkForm extends Components.SnkForm, HTMLElement {}
4
+ export const SnkForm: {
5
+ prototype: SnkForm;
6
+ new (): SnkForm;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;