@sankhyalabs/sankhyablocks 0.0.0-feat-dev-KB-75149.0 → 0.0.0-feat-dev-KB-74182.0

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 (30) hide show
  1. package/dist/cjs/snk-application.cjs.entry.js +1 -7
  2. package/dist/cjs/snk-config-options_3.cjs.entry.js +17 -5
  3. package/dist/cjs/snk-detail-view.cjs.entry.js +1 -1
  4. package/dist/cjs/{snk-guides-viewer-eee43c8b.js → snk-guides-viewer-2139481c.js} +1 -1
  5. package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -1
  6. package/dist/cjs/snk-taskbar.cjs.entry.js +4 -2
  7. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +1 -1
  8. package/dist/collection/components/snk-form-config/snk-form-config.js +17 -5
  9. package/dist/collection/components/snk-taskbar/snk-taskbar.js +4 -2
  10. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +1 -7
  11. package/dist/components/snk-application2.js +1 -7
  12. package/dist/components/snk-detail-view2.js +1 -1
  13. package/dist/components/snk-form-config2.js +17 -5
  14. package/dist/components/snk-taskbar2.js +4 -2
  15. package/dist/esm/snk-application.entry.js +1 -7
  16. package/dist/esm/snk-config-options_3.entry.js +17 -5
  17. package/dist/esm/snk-detail-view.entry.js +1 -1
  18. package/dist/esm/{snk-guides-viewer-e8ca764a.js → snk-guides-viewer-b7ed39eb.js} +1 -1
  19. package/dist/esm/snk-guides-viewer.entry.js +1 -1
  20. package/dist/esm/snk-taskbar.entry.js +4 -2
  21. package/dist/sankhyablocks/{p-42130213.entry.js → p-4138da61.entry.js} +1 -1
  22. package/dist/sankhyablocks/{p-2aae03a1.entry.js → p-d5ceef5f.entry.js} +1 -1
  23. package/dist/sankhyablocks/{p-66e46f11.entry.js → p-da87e42c.entry.js} +3 -3
  24. package/dist/sankhyablocks/{p-43353d86.entry.js → p-e390641b.entry.js} +1 -1
  25. package/dist/sankhyablocks/{p-e3a285a2.js → p-e97be1c8.js} +1 -1
  26. package/dist/sankhyablocks/p-ec43fcc8.entry.js +1 -0
  27. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  28. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +0 -1
  29. package/package.json +1 -1
  30. package/dist/sankhyablocks/p-30ebcbe0.entry.js +0 -1
@@ -32,7 +32,6 @@ const _0x5b7870=_0x2202;(function(_0x42e134,_0x5d9727){const _0x185c97=_0x2202,_
32
32
  class ParametersFetcher {
33
33
  constructor() {
34
34
  this._embeddedParams = new Map();
35
- this._cachedParams = new Map();
36
35
  this.templateByQuery = new Map();
37
36
  try {
38
37
  if (window["MGE_PARAMS"] != undefined) {
@@ -62,16 +61,11 @@ class ParametersFetcher {
62
61
  if (this._embeddedParams.has(name)) {
63
62
  return Promise.resolve(this._embeddedParams.get(name));
64
63
  }
65
- if (this._cachedParams.has(name)) {
66
- return this._cachedParams.get(name);
67
- }
68
64
  const completPath = `param://application?params=${name}`;
69
- const param = await DataFetcher.DataFetcher.get().callGraphQL({
65
+ return DataFetcher.DataFetcher.get().callGraphQL({
70
66
  values: { name: completPath },
71
67
  query: this.templateByQuery.get("fetchParam"),
72
68
  });
73
- this._cachedParams.set(name, param);
74
- return param;
75
69
  }
76
70
  async asString(name) {
77
71
  const paramArr = await this.getParam(name);
@@ -1049,7 +1049,7 @@ const SnkFormConfig = class {
1049
1049
  }
1050
1050
  }
1051
1051
  getLayoutFormConfig() {
1052
- var _a, _b;
1052
+ var _a, _b, _c;
1053
1053
  if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
1054
1054
  return;
1055
1055
  }
@@ -1062,7 +1062,11 @@ const SnkFormConfig = class {
1062
1062
  if (hasField == undefined) {
1063
1063
  fields.push(field);
1064
1064
  const fieldMD = this.dataUnit.getField(field.name);
1065
- if (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) {
1065
+ /**
1066
+ * Quando um campo é ocultado pelo dev, mas queremos manter ele na config precisamos fazer essa tratativa.
1067
+ */
1068
+ const visibleOnConfig = ((_b = fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.properties) === null || _b === void 0 ? void 0 : _b.visibleOnConfig) === true && (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) === false;
1069
+ if ((fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) || visibleOnConfig) {
1066
1070
  if (field.label == undefined || field.label === "") {
1067
1071
  field.label = fieldMD.label;
1068
1072
  }
@@ -1078,7 +1082,7 @@ const SnkFormConfig = class {
1078
1082
  visible = configTabs[0].visible;
1079
1083
  }
1080
1084
  }
1081
- const tabLabel = ((_b = field.tab) === null || _b === void 0 ? void 0 : _b.label) || field.tab;
1085
+ const tabLabel = ((_c = field.tab) === null || _c === void 0 ? void 0 : _c.label) || field.tab;
1082
1086
  if (visible !== null) {
1083
1087
  tab = { tab: tabLabel, groups: [], visible };
1084
1088
  }
@@ -1163,8 +1167,16 @@ const SnkFormConfig = class {
1163
1167
  for (const field of this._formConfig.fields) {
1164
1168
  fieldsFormConfig.push(field);
1165
1169
  }
1166
- const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado }) => _visibleMetadado === true
1167
- && fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado) === false);
1170
+ const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado, properties }) => {
1171
+ const hasCfg = fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado);
1172
+ /**
1173
+ * Quando a visibilidade de um campo é alterada pelo dataunit, mas o desenvolvedor deseja que o mesmo continue
1174
+ * sendo apresentado no configurador, precisamos fazer essa tratativa, verificando se o campo não tem configuração
1175
+ */
1176
+ if (!hasCfg && properties.visibleOnConfig === true && !_visibleMetadado)
1177
+ return properties.visibleOnConfig;
1178
+ return _visibleMetadado === true && hasCfg === false;
1179
+ });
1168
1180
  this._fieldsAvailable = listFieldsAvailable;
1169
1181
  this._listEnabledFields = listFieldsAvailable;
1170
1182
  if (((_b = this._filterFieldsAvailable) === null || _b === void 0 ? void 0 : _b.value) != undefined) {
@@ -17,7 +17,7 @@ require('./filter-item-type.enum-a7ffdaa6.js');
17
17
  require('./form-config-fetcher-39397ac5.js');
18
18
  const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
19
19
  const constants = require('./constants-35ddd366.js');
20
- const snkGuidesViewer = require('./snk-guides-viewer-eee43c8b.js');
20
+ const snkGuidesViewer = require('./snk-guides-viewer-2139481c.js');
21
21
  const SnkMessageBuilder = require('./SnkMessageBuilder-bae64d0d.js');
22
22
  require('./ConfigStorage-f079f5fd.js');
23
23
  require('./PrintUtils-bcaeb82f.js');
@@ -456,7 +456,7 @@ const SnkGuidesViewer = class {
456
456
  await this.openGuideNavigator(guideName);
457
457
  }
458
458
  if (action.type === core.Action.METADATA_LOADED) {
459
- this.loadGuides(false);
459
+ this.loadGuides(this.noGuideSelected());
460
460
  }
461
461
  }
462
462
  async addErrorBadgeToGuide(guideName) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const snkGuidesViewer = require('./snk-guides-viewer-eee43c8b.js');
5
+ const snkGuidesViewer = require('./snk-guides-viewer-2139481c.js');
6
6
  require('./index-f9e81701.js');
7
7
  require('@sankhyalabs/core');
8
8
  require('./SnkFormConfigManager-63369164.js');
@@ -389,6 +389,7 @@ const SnkTaskbar = class {
389
389
  const dataInfo = { dataUnit: this.dataUnit };
390
390
  core.ElementIDUtils.addIDInfo(this._element, null, dataInfo);
391
391
  this.handleOverFlowStrategy();
392
+ this.dataUnit.unsubscribe(this.onSaveEvent);
392
393
  this.dataUnit.subscribe(this.onSaveEvent);
393
394
  }
394
395
  componentDidRender() {
@@ -399,9 +400,10 @@ const SnkTaskbar = class {
399
400
  this._lastWidth = this._element.getBoundingClientRect().width;
400
401
  }
401
402
  disconnectedCallback() {
402
- var _a;
403
+ var _a, _b;
404
+ (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.unsubscribe(this.onSaveEvent);
403
405
  this.unlinkAllCustomElements();
404
- (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.destroy();
406
+ (_b = this._overFlowWatcher) === null || _b === void 0 ? void 0 : _b.destroy();
405
407
  }
406
408
  unlinkAllCustomElements() {
407
409
  var _a;
@@ -440,7 +440,7 @@ export class SnkGuidesViewer {
440
440
  await this.openGuideNavigator(guideName);
441
441
  }
442
442
  if (action.type === DUAction.METADATA_LOADED) {
443
- this.loadGuides(false);
443
+ this.loadGuides(this.noGuideSelected());
444
444
  }
445
445
  }
446
446
  async addErrorBadgeToGuide(guideName) {
@@ -679,7 +679,7 @@ export class SnkFormConfig {
679
679
  }
680
680
  }
681
681
  getLayoutFormConfig() {
682
- var _a, _b;
682
+ var _a, _b, _c;
683
683
  if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
684
684
  return;
685
685
  }
@@ -692,7 +692,11 @@ export class SnkFormConfig {
692
692
  if (hasField == undefined) {
693
693
  fields.push(field);
694
694
  const fieldMD = this.dataUnit.getField(field.name);
695
- if (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) {
695
+ /**
696
+ * Quando um campo é ocultado pelo dev, mas queremos manter ele na config precisamos fazer essa tratativa.
697
+ */
698
+ const visibleOnConfig = ((_b = fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.properties) === null || _b === void 0 ? void 0 : _b.visibleOnConfig) === true && (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) === false;
699
+ if ((fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) || visibleOnConfig) {
696
700
  if (field.label == undefined || field.label === "") {
697
701
  field.label = fieldMD.label;
698
702
  }
@@ -708,7 +712,7 @@ export class SnkFormConfig {
708
712
  visible = configTabs[0].visible;
709
713
  }
710
714
  }
711
- const tabLabel = ((_b = field.tab) === null || _b === void 0 ? void 0 : _b.label) || field.tab;
715
+ const tabLabel = ((_c = field.tab) === null || _c === void 0 ? void 0 : _c.label) || field.tab;
712
716
  if (visible !== null) {
713
717
  tab = { tab: tabLabel, groups: [], visible };
714
718
  }
@@ -793,8 +797,16 @@ export class SnkFormConfig {
793
797
  for (const field of this._formConfig.fields) {
794
798
  fieldsFormConfig.push(field);
795
799
  }
796
- const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado }) => _visibleMetadado === true
797
- && fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado) === false);
800
+ const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado, properties }) => {
801
+ const hasCfg = fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado);
802
+ /**
803
+ * Quando a visibilidade de um campo é alterada pelo dataunit, mas o desenvolvedor deseja que o mesmo continue
804
+ * sendo apresentado no configurador, precisamos fazer essa tratativa, verificando se o campo não tem configuração
805
+ */
806
+ if (!hasCfg && properties.visibleOnConfig === true && !_visibleMetadado)
807
+ return properties.visibleOnConfig;
808
+ return _visibleMetadado === true && hasCfg === false;
809
+ });
798
810
  this._fieldsAvailable = listFieldsAvailable;
799
811
  this._listEnabledFields = listFieldsAvailable;
800
812
  if (((_b = this._filterFieldsAvailable) === null || _b === void 0 ? void 0 : _b.value) != undefined) {
@@ -378,6 +378,7 @@ export class SnkTaskbar {
378
378
  const dataInfo = { dataUnit: this.dataUnit };
379
379
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
380
380
  this.handleOverFlowStrategy();
381
+ this.dataUnit.unsubscribe(this.onSaveEvent);
381
382
  this.dataUnit.subscribe(this.onSaveEvent);
382
383
  }
383
384
  componentDidRender() {
@@ -388,9 +389,10 @@ export class SnkTaskbar {
388
389
  this._lastWidth = this._element.getBoundingClientRect().width;
389
390
  }
390
391
  disconnectedCallback() {
391
- var _a;
392
+ var _a, _b;
393
+ (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.unsubscribe(this.onSaveEvent);
392
394
  this.unlinkAllCustomElements();
393
- (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.destroy();
395
+ (_b = this._overFlowWatcher) === null || _b === void 0 ? void 0 : _b.destroy();
394
396
  }
395
397
  unlinkAllCustomElements() {
396
398
  var _a;
@@ -4,7 +4,6 @@ import { DataFetcher } from "../DataFetcher";
4
4
  export default class ParametersFetcher {
5
5
  constructor() {
6
6
  this._embeddedParams = new Map();
7
- this._cachedParams = new Map();
8
7
  this.templateByQuery = new Map();
9
8
  try {
10
9
  if (window["MGE_PARAMS"] != undefined) {
@@ -34,16 +33,11 @@ export default class ParametersFetcher {
34
33
  if (this._embeddedParams.has(name)) {
35
34
  return Promise.resolve(this._embeddedParams.get(name));
36
35
  }
37
- if (this._cachedParams.has(name)) {
38
- return this._cachedParams.get(name);
39
- }
40
36
  const completPath = `param://application?params=${name}`;
41
- const param = await DataFetcher.get().callGraphQL({
37
+ return DataFetcher.get().callGraphQL({
42
38
  values: { name: completPath },
43
39
  query: this.templateByQuery.get("fetchParam"),
44
40
  });
45
- this._cachedParams.set(name, param);
46
- return param;
47
41
  }
48
42
  async asString(name) {
49
43
  const paramArr = await this.getParam(name);
@@ -74,7 +74,6 @@ class TotalsFetcher {
74
74
  class ParametersFetcher {
75
75
  constructor() {
76
76
  this._embeddedParams = new Map();
77
- this._cachedParams = new Map();
78
77
  this.templateByQuery = new Map();
79
78
  try {
80
79
  if (window["MGE_PARAMS"] != undefined) {
@@ -104,16 +103,11 @@ class ParametersFetcher {
104
103
  if (this._embeddedParams.has(name)) {
105
104
  return Promise.resolve(this._embeddedParams.get(name));
106
105
  }
107
- if (this._cachedParams.has(name)) {
108
- return this._cachedParams.get(name);
109
- }
110
106
  const completPath = `param://application?params=${name}`;
111
- const param = await DataFetcher.get().callGraphQL({
107
+ return DataFetcher.get().callGraphQL({
112
108
  values: { name: completPath },
113
109
  query: this.templateByQuery.get("fetchParam"),
114
110
  });
115
- this._cachedParams.set(name, param);
116
- return param;
117
111
  }
118
112
  async asString(name) {
119
113
  const paramArr = await this.getParam(name);
@@ -483,7 +483,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
483
483
  await this.openGuideNavigator(guideName);
484
484
  }
485
485
  if (action.type === Action.METADATA_LOADED) {
486
- this.loadGuides(false);
486
+ this.loadGuides(this.noGuideSelected());
487
487
  }
488
488
  }
489
489
  async addErrorBadgeToGuide(guideName) {
@@ -685,7 +685,7 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
685
685
  }
686
686
  }
687
687
  getLayoutFormConfig() {
688
- var _a, _b;
688
+ var _a, _b, _c;
689
689
  if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
690
690
  return;
691
691
  }
@@ -698,7 +698,11 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
698
698
  if (hasField == undefined) {
699
699
  fields.push(field);
700
700
  const fieldMD = this.dataUnit.getField(field.name);
701
- if (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) {
701
+ /**
702
+ * Quando um campo é ocultado pelo dev, mas queremos manter ele na config precisamos fazer essa tratativa.
703
+ */
704
+ const visibleOnConfig = ((_b = fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.properties) === null || _b === void 0 ? void 0 : _b.visibleOnConfig) === true && (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) === false;
705
+ if ((fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) || visibleOnConfig) {
702
706
  if (field.label == undefined || field.label === "") {
703
707
  field.label = fieldMD.label;
704
708
  }
@@ -714,7 +718,7 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
714
718
  visible = configTabs[0].visible;
715
719
  }
716
720
  }
717
- const tabLabel = ((_b = field.tab) === null || _b === void 0 ? void 0 : _b.label) || field.tab;
721
+ const tabLabel = ((_c = field.tab) === null || _c === void 0 ? void 0 : _c.label) || field.tab;
718
722
  if (visible !== null) {
719
723
  tab = { tab: tabLabel, groups: [], visible };
720
724
  }
@@ -799,8 +803,16 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
799
803
  for (const field of this._formConfig.fields) {
800
804
  fieldsFormConfig.push(field);
801
805
  }
802
- const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado }) => _visibleMetadado === true
803
- && fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado) === false);
806
+ const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado, properties }) => {
807
+ const hasCfg = fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado);
808
+ /**
809
+ * Quando a visibilidade de um campo é alterada pelo dataunit, mas o desenvolvedor deseja que o mesmo continue
810
+ * sendo apresentado no configurador, precisamos fazer essa tratativa, verificando se o campo não tem configuração
811
+ */
812
+ if (!hasCfg && properties.visibleOnConfig === true && !_visibleMetadado)
813
+ return properties.visibleOnConfig;
814
+ return _visibleMetadado === true && hasCfg === false;
815
+ });
804
816
  this._fieldsAvailable = listFieldsAvailable;
805
817
  this._listEnabledFields = listFieldsAvailable;
806
818
  if (((_b = this._filterFieldsAvailable) === null || _b === void 0 ? void 0 : _b.value) != undefined) {
@@ -502,6 +502,7 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
502
502
  const dataInfo = { dataUnit: this.dataUnit };
503
503
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
504
504
  this.handleOverFlowStrategy();
505
+ this.dataUnit.unsubscribe(this.onSaveEvent);
505
506
  this.dataUnit.subscribe(this.onSaveEvent);
506
507
  }
507
508
  componentDidRender() {
@@ -512,9 +513,10 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
512
513
  this._lastWidth = this._element.getBoundingClientRect().width;
513
514
  }
514
515
  disconnectedCallback() {
515
- var _a;
516
+ var _a, _b;
517
+ (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.unsubscribe(this.onSaveEvent);
516
518
  this.unlinkAllCustomElements();
517
- (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.destroy();
519
+ (_b = this._overFlowWatcher) === null || _b === void 0 ? void 0 : _b.destroy();
518
520
  }
519
521
  unlinkAllCustomElements() {
520
522
  var _a;
@@ -28,7 +28,6 @@ const _0x5b7870=_0x2202;(function(_0x42e134,_0x5d9727){const _0x185c97=_0x2202,_
28
28
  class ParametersFetcher {
29
29
  constructor() {
30
30
  this._embeddedParams = new Map();
31
- this._cachedParams = new Map();
32
31
  this.templateByQuery = new Map();
33
32
  try {
34
33
  if (window["MGE_PARAMS"] != undefined) {
@@ -58,16 +57,11 @@ class ParametersFetcher {
58
57
  if (this._embeddedParams.has(name)) {
59
58
  return Promise.resolve(this._embeddedParams.get(name));
60
59
  }
61
- if (this._cachedParams.has(name)) {
62
- return this._cachedParams.get(name);
63
- }
64
60
  const completPath = `param://application?params=${name}`;
65
- const param = await DataFetcher.get().callGraphQL({
61
+ return DataFetcher.get().callGraphQL({
66
62
  values: { name: completPath },
67
63
  query: this.templateByQuery.get("fetchParam"),
68
64
  });
69
- this._cachedParams.set(name, param);
70
- return param;
71
65
  }
72
66
  async asString(name) {
73
67
  const paramArr = await this.getParam(name);
@@ -1045,7 +1045,7 @@ const SnkFormConfig = class {
1045
1045
  }
1046
1046
  }
1047
1047
  getLayoutFormConfig() {
1048
- var _a, _b;
1048
+ var _a, _b, _c;
1049
1049
  if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
1050
1050
  return;
1051
1051
  }
@@ -1058,7 +1058,11 @@ const SnkFormConfig = class {
1058
1058
  if (hasField == undefined) {
1059
1059
  fields.push(field);
1060
1060
  const fieldMD = this.dataUnit.getField(field.name);
1061
- if (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) {
1061
+ /**
1062
+ * Quando um campo é ocultado pelo dev, mas queremos manter ele na config precisamos fazer essa tratativa.
1063
+ */
1064
+ const visibleOnConfig = ((_b = fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.properties) === null || _b === void 0 ? void 0 : _b.visibleOnConfig) === true && (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) === false;
1065
+ if ((fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) || visibleOnConfig) {
1062
1066
  if (field.label == undefined || field.label === "") {
1063
1067
  field.label = fieldMD.label;
1064
1068
  }
@@ -1074,7 +1078,7 @@ const SnkFormConfig = class {
1074
1078
  visible = configTabs[0].visible;
1075
1079
  }
1076
1080
  }
1077
- const tabLabel = ((_b = field.tab) === null || _b === void 0 ? void 0 : _b.label) || field.tab;
1081
+ const tabLabel = ((_c = field.tab) === null || _c === void 0 ? void 0 : _c.label) || field.tab;
1078
1082
  if (visible !== null) {
1079
1083
  tab = { tab: tabLabel, groups: [], visible };
1080
1084
  }
@@ -1159,8 +1163,16 @@ const SnkFormConfig = class {
1159
1163
  for (const field of this._formConfig.fields) {
1160
1164
  fieldsFormConfig.push(field);
1161
1165
  }
1162
- const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado }) => _visibleMetadado === true
1163
- && fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado) === false);
1166
+ const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado, properties }) => {
1167
+ const hasCfg = fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado);
1168
+ /**
1169
+ * Quando a visibilidade de um campo é alterada pelo dataunit, mas o desenvolvedor deseja que o mesmo continue
1170
+ * sendo apresentado no configurador, precisamos fazer essa tratativa, verificando se o campo não tem configuração
1171
+ */
1172
+ if (!hasCfg && properties.visibleOnConfig === true && !_visibleMetadado)
1173
+ return properties.visibleOnConfig;
1174
+ return _visibleMetadado === true && hasCfg === false;
1175
+ });
1164
1176
  this._fieldsAvailable = listFieldsAvailable;
1165
1177
  this._listEnabledFields = listFieldsAvailable;
1166
1178
  if (((_b = this._filterFieldsAvailable) === null || _b === void 0 ? void 0 : _b.value) != undefined) {
@@ -13,7 +13,7 @@ import './filter-item-type.enum-d45e026f.js';
13
13
  import './form-config-fetcher-a7d3e277.js';
14
14
  import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
15
15
  import { V as VIEW_MODE } from './constants-7302ee87.js';
16
- import { S as SnkGuidesViewer } from './snk-guides-viewer-e8ca764a.js';
16
+ import { S as SnkGuidesViewer } from './snk-guides-viewer-b7ed39eb.js';
17
17
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-6fff4a4c.js';
18
18
  import './ConfigStorage-6514d66e.js';
19
19
  import './PrintUtils-3e4ff0f5.js';
@@ -454,7 +454,7 @@ const SnkGuidesViewer = class {
454
454
  await this.openGuideNavigator(guideName);
455
455
  }
456
456
  if (action.type === Action.METADATA_LOADED) {
457
- this.loadGuides(false);
457
+ this.loadGuides(this.noGuideSelected());
458
458
  }
459
459
  }
460
460
  async addErrorBadgeToGuide(guideName) {
@@ -1,4 +1,4 @@
1
- export { S as snk_guides_viewer } from './snk-guides-viewer-e8ca764a.js';
1
+ export { S as snk_guides_viewer } from './snk-guides-viewer-b7ed39eb.js';
2
2
  import './index-a7d3d3f1.js';
3
3
  import '@sankhyalabs/core';
4
4
  import './SnkFormConfigManager-b409c745.js';
@@ -385,6 +385,7 @@ const SnkTaskbar = class {
385
385
  const dataInfo = { dataUnit: this.dataUnit };
386
386
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
387
387
  this.handleOverFlowStrategy();
388
+ this.dataUnit.unsubscribe(this.onSaveEvent);
388
389
  this.dataUnit.subscribe(this.onSaveEvent);
389
390
  }
390
391
  componentDidRender() {
@@ -395,9 +396,10 @@ const SnkTaskbar = class {
395
396
  this._lastWidth = this._element.getBoundingClientRect().width;
396
397
  }
397
398
  disconnectedCallback() {
398
- var _a;
399
+ var _a, _b;
400
+ (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.unsubscribe(this.onSaveEvent);
399
401
  this.unlinkAllCustomElements();
400
- (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.destroy();
402
+ (_b = this._overFlowWatcher) === null || _b === void 0 ? void 0 : _b.destroy();
401
403
  }
402
404
  unlinkAllCustomElements() {
403
405
  var _a;
@@ -1 +1 @@
1
- export{S as snk_guides_viewer}from"./p-e3a285a2.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-0e206e62.js";import"./p-9ffd9fc7.js";import"./p-126c58ea.js";import"./p-00278e07.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-95ce311a.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-23736d75.js";import"./p-7e7a7473.js";import"./p-30cf616e.js";import"./p-6dc031de.js";import"./p-341465ce.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-47d24ac8.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
1
+ export{S as snk_guides_viewer}from"./p-e97be1c8.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-0e206e62.js";import"./p-9ffd9fc7.js";import"./p-126c58ea.js";import"./p-00278e07.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-95ce311a.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-23736d75.js";import"./p-7e7a7473.js";import"./p-30cf616e.js";import"./p-6dc031de.js";import"./p-341465ce.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-47d24ac8.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
@@ -1 +1 @@
1
- import{r as t,c as s,h as i,H as e,g as a}from"./p-d2d301a6.js";import{Action as h,StringUtils as n,ApplicationContext as r,OVERFLOWED_CLASS_NAME as o,OverflowWatcher as l,OverflowDirection as d,ElementIDUtils as v}from"@sankhyalabs/core";import{A as u}from"./p-dc36cfbf.js";import{T as c,V as k,A as m,b,a as p}from"./p-7e7a7473.js";import{P as T}from"./p-30cf616e.js";import"./p-6dc031de.js";const f=class{constructor(i){t(this,i),this.actionClick=s(this,"actionClick",7),this.taskbarSaveLocker=s(this,"taskbarSaveLocker",7),this.taskbarSaveUnlocker=s(this,"taskbarSaveUnlocker",7),this.TASKBAR_ITEM_ID_PREFIX="TASKBAR_ITEM_",this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME="taskbar-custom-elements-container",this.ACTIONS_BUTTON_TAG="TASKBAR-ACTIONS-BUTTON",this.NOT_OVERFLOW_ELEMENTS=["moreOptions","dataExporter_snkDataExporter","actionsButton_snkActionsButton"],this._titleKeyByElement={[c.UPDATE]:"snkTaskbar.titleUpdate",[c.PREVIOUS]:"snkTaskbar.titlePrevious",[c.NEXT]:"snkTaskbar.titleNext",[c.REFRESH]:"snkTaskbar.titleRefresh",[c.CLONE]:"snkTaskbar.titleClone",[c.REMOVE]:"snkTaskbar.titleRemove",[c.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[c.INSERT]:"snkTaskbar.titleInsert",[c.CANCEL]:"snkTaskbar.titleCancel",[c.SAVE]:"snkTaskbar.titleSave",[c.GRID_MODE]:"snkTaskbar.titleGridMode",[c.FORM_MODE]:"snkTaskbar.titleFormMode",[c.CONFIGURATOR]:"snkTaskbar.titleConfigurator",[c.ATTACH]:"snkTaskbar.titleAttach"},this.onSaveEvent=t=>{switch(t.type){case h.FIELD_INVALIDATED:case h.INVALIDATE_CLEAN:case h.DATA_SAVED:case h.SAVING_ERROR:case h.SAVING_CANCELED:this._isWaitingForSave=!1;break;case h.SAVING_DATA:this._isWaitingForSave=!0}},this._permissions=void 0,this._overFlowedElements=[],this._customElements=void 0,this._customElementsId=void 0,this._slotContainer=void 0,this._hiddenActionsList=[],this._lastWidth=void 0,this._hasToUpdateOverFlow=!1,this._isWaitingForSave=!1,this.alignRigth=!1,this.customSlotId="TASKBAR_CUSTOM_ELEMENTS",this.customContainerId=void 0,this.overflowStrategy="hiddenItems",this.configName=void 0,this.resourceID=void 0,this.buttons=void 0,this.customButtons=void 0,this.actionsList=void 0,this.primaryButton=void 0,this.disabledButtons=void 0,this.dataUnit=void 0,this.presentationMode=T.PRIMARY,this.messagesBuilder=void 0}handleCustomSlotElementsLoaded(t){this.hasToSearchCustomElements(t)&&this.getCustomElements(!0)}handleTaskbarSaveLocker(){!0!==this._isWaitingForSave&&(this._isWaitingForSave=!0)}handleTaskbarSaveUnlocker(){!0===this._isWaitingForSave&&(this._isWaitingForSave=!1)}hasToSearchCustomElements(t){return this.customSlotId===t.detail&&!this._slotContainer}observeButtons(){this._definitions=void 0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()}))}))}observeDisabledButtons(){var t;null===(t=this._overFlowWatcher)||void 0===t||t.forceUpdate()}observeLastWidth(t,s){0===s&&0!==t&&(this._hasToUpdateOverFlow=!0)}observeIsWaitingForSave(t,s){1==t&&0==s&&this.taskbarSaveLocker.emit(),0==t&&1==s&&this.taskbarSaveUnlocker.emit()}elementsFromString(t){const s=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(k[t]||this.isAllowed(t))&&s.push(t.trim())})),s}isAllowed(t){return t===m.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[u.CONFIG_GRID]||this._permissions[u.CONFIG]):!m[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){var s;let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,{}):""}elementClick(t){if(this.dataUnit)switch(t){case c.PREVIOUS:this.dataUnit.previousRecord();break;case c.NEXT:this.dataUnit.nextRecord();break;case c.REFRESH:this.dataUnit.loadData();break;case c.CLONE:this.dataUnit.copySelected();break;case c.REMOVE:this.dataUnit.removeSelectedRecords();break;case c.INSERT:this.dataUnit.addRecord();break;case c.CANCEL:this.dataUnit.cancelEdition();break;case c.SAVE:this._isWaitingForSave||(this._isWaitingForSave=!0,this.dataUnit.saveData().finally((()=>{this._isWaitingForSave=!1})))}this.isEnabled(t)&&this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}validatePresentationMode(){Object.values(T).includes(this.presentationMode)||(this.presentationMode=T.PRIMARY)}getElement(t,s){let i=s===this.primaryButton?"ez-button--primary ":"";t>1&&(i+="ez-padding-left--medium");const e=c[s.toString()],a=this._element.dataset.exporterStoreKey||this.configName;return e?b(s,i,this.getIdElemBtnNative(s),(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.buildDynamicActionsList(),a,this.presentationMode):p(s,i,this.getIdElemBtnCustom(s),(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}buildDynamicActionsList(){var t;return this._hiddenActionsList.length?[...null!==(t=this.actionsList)&&void 0!==t?t:[],{type:"divider",label:"",value:""},...this._hiddenActionsList]:this.actionsList}getIdElemBtnNative(t){return n.toCamelCase(t)}getIdElemBtnCustom(t){return n.toCamelCase(t.name)}isDivider(t){var s;return void 0!==t&&(null===(s=t.t)||void 0===s?void 0:s["data-taskbar-divider"])}removeEmpty(t){let s;return t.filter((t=>!(null==t||this.isDivider(s)&&this.isDivider(t)||(s=t,0))))}appendCustomElementsInTaskbar(){this._customElementsId.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s),e=this._element.querySelector(`#${t}`);e?null==e||e.appendChild(i):this.unlinkCustomElementFromTaskbar(i)}))}addCustomElementContainer(t){var s;const e=`${this.TASKBAR_ITEM_ID_PREFIX}${t}`;return this._customElementsId.includes(e)||(this._customElementsId.push(e),null===(s=this._overFlowWatcher)||void 0===s||s.addNotOverFlowElement(e)),i("span",{class:"ez-padding-left--medium",key:e,id:e})}getCustomElements(t){var s,i;this._customElementsId=[],this._customElements=new Map,this._slotContainer=this.buildSlotContainer(t),Array.from(null!==(i=null===(s=this._slotContainer)||void 0===s?void 0:s.children)&&void 0!==i?i:[]).forEach((t=>this._customElements.set(t.id,t)))}buildSlotContainer(t){let s;if(this.customContainerId){const t=document.querySelector(`#${this.customContainerId}`);s=null==t?void 0:t.querySelector(`#${this.customSlotId}`)}else s=this._element.querySelector(`#${this.customSlotId}`);return t&&!s&&(s=document.querySelector(`#${this.customSlotId}`)),s}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)):this._permissions={},this.getCustomElements()}componentWillRender(){this.handleDefinitions(),this.validatePresentationMode(),this.updateOverFlowIfNeeded()}handleDefinitions(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}updateOverFlowIfNeeded(){this._hasToUpdateOverFlow&&(requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()})),this._hasToUpdateOverFlow=!1)}handleOverFlow(t){const s=t.filter((t=>!this.hasToIgnoreOverFlow(t)));this.resetOverFlowedElements(),this.doOverFlowElements(s)}resetOverFlowedElements(){this._overFlowedElements.forEach((t=>{t.classList.remove(o)})),this._hiddenActionsList=[],this._overFlowedElements=[]}doOverFlowElements(t){t.forEach((t=>{t.classList.add(o),this._overFlowedElements.push(t),this.addItemToActionList(t)}))}addItemToActionList(t){const s=this.getTaskbarElementName(t);if(s&&this.isEnabled(s)&&this.isAllowed(s)){const i={value:s,label:this.getTaskbarElementLabel(t),iconName:this.getTaskbarElementIcon(t)};this._hiddenActionsList.push(i)}}getTaskbarElementName(t){var s;return null!==(s=t.getAttribute("data-taskbar-element"))&&void 0!==s?s:""}getTaskbarElementIcon(t){var s;return null!==(s=t.getAttribute("data-taskbar-icon"))&&void 0!==s?s:""}getTaskbarElementLabel(t){var s;return null!==(s=t.getAttribute("data-taskbar-label"))&&void 0!==s?s:""}hasToIgnoreOverFlow(t){return t.classList.contains(this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME)}handleOverFlowStrategy(){"hiddenItems"===this.overflowStrategy&&(this._overFlowWatcher=new l(this.buildOverFlowWatcherParams()))}buildOverFlowWatcherParams(){return{element:this._element,callback:this.handleOverFlow.bind(this),overFlowDirection:d.HORIZONTAL,notOverFlow:this.NOT_OVERFLOW_ELEMENTS}}componentDidLoad(){v.addIDInfo(this._element,null,{dataUnit:this.dataUnit}),this.handleOverFlowStrategy(),this.dataUnit.subscribe(this.onSaveEvent)}componentDidRender(){this.appendCustomElementsInTaskbar(),this.updateLastWidth()}updateLastWidth(){this._lastWidth=this._element.getBoundingClientRect().width}disconnectedCallback(){var t;this.unlinkAllCustomElements(),null===(t=this._overFlowWatcher)||void 0===t||t.destroy()}unlinkAllCustomElements(){var t;null===(t=this._customElementsId)||void 0===t||t.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s);this.unlinkCustomElementFromTaskbar(i)}))}unlinkCustomElementFromTaskbar(t){this._slotContainer.appendChild(t)}render(){if(void 0===this._definitions)return;let t=0;return i(e,{class:this.getHostClasses()},this.removeEmpty(this._definitions.map((s=>{var e,a;return t++,c[s]?this.getElement(t,c[s]):(null===(e=this.customButtons)||void 0===e?void 0:e.has(s))?this.getElement(t,this.customButtons.get(s)):this._customElements.has(s)?this.addCustomElementContainer(s):(null===(a=this._overFlowWatcher)||void 0===a||a.addNotOverFlowElement(s),i("slot",{name:s}))}))),i("div",{class:this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME},i("slot",{name:this.customSlotId})))}getHostClasses(){return"hiddenItems"!==this.overflowStrategy?"no-wrap":"full-width "+(this.alignRigth?"align-right":"")}get _element(){return a(this)}static get watchers(){return{buttons:["observeButtons"],disabledButtons:["observeDisabledButtons"],_lastWidth:["observeLastWidth"],_isWaitingForSave:["observeIsWaitingForSave"]}}};f.style=".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";export{f as snk_taskbar}
1
+ import{r as t,c as s,h as i,H as e,g as a}from"./p-d2d301a6.js";import{Action as h,StringUtils as n,ApplicationContext as r,OVERFLOWED_CLASS_NAME as o,OverflowWatcher as l,OverflowDirection as d,ElementIDUtils as v}from"@sankhyalabs/core";import{A as u}from"./p-dc36cfbf.js";import{T as c,V as k,A as m,b,a as p}from"./p-7e7a7473.js";import{P as T}from"./p-30cf616e.js";import"./p-6dc031de.js";const f=class{constructor(i){t(this,i),this.actionClick=s(this,"actionClick",7),this.taskbarSaveLocker=s(this,"taskbarSaveLocker",7),this.taskbarSaveUnlocker=s(this,"taskbarSaveUnlocker",7),this.TASKBAR_ITEM_ID_PREFIX="TASKBAR_ITEM_",this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME="taskbar-custom-elements-container",this.ACTIONS_BUTTON_TAG="TASKBAR-ACTIONS-BUTTON",this.NOT_OVERFLOW_ELEMENTS=["moreOptions","dataExporter_snkDataExporter","actionsButton_snkActionsButton"],this._titleKeyByElement={[c.UPDATE]:"snkTaskbar.titleUpdate",[c.PREVIOUS]:"snkTaskbar.titlePrevious",[c.NEXT]:"snkTaskbar.titleNext",[c.REFRESH]:"snkTaskbar.titleRefresh",[c.CLONE]:"snkTaskbar.titleClone",[c.REMOVE]:"snkTaskbar.titleRemove",[c.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[c.INSERT]:"snkTaskbar.titleInsert",[c.CANCEL]:"snkTaskbar.titleCancel",[c.SAVE]:"snkTaskbar.titleSave",[c.GRID_MODE]:"snkTaskbar.titleGridMode",[c.FORM_MODE]:"snkTaskbar.titleFormMode",[c.CONFIGURATOR]:"snkTaskbar.titleConfigurator",[c.ATTACH]:"snkTaskbar.titleAttach"},this.onSaveEvent=t=>{switch(t.type){case h.FIELD_INVALIDATED:case h.INVALIDATE_CLEAN:case h.DATA_SAVED:case h.SAVING_ERROR:case h.SAVING_CANCELED:this._isWaitingForSave=!1;break;case h.SAVING_DATA:this._isWaitingForSave=!0}},this._permissions=void 0,this._overFlowedElements=[],this._customElements=void 0,this._customElementsId=void 0,this._slotContainer=void 0,this._hiddenActionsList=[],this._lastWidth=void 0,this._hasToUpdateOverFlow=!1,this._isWaitingForSave=!1,this.alignRigth=!1,this.customSlotId="TASKBAR_CUSTOM_ELEMENTS",this.customContainerId=void 0,this.overflowStrategy="hiddenItems",this.configName=void 0,this.resourceID=void 0,this.buttons=void 0,this.customButtons=void 0,this.actionsList=void 0,this.primaryButton=void 0,this.disabledButtons=void 0,this.dataUnit=void 0,this.presentationMode=T.PRIMARY,this.messagesBuilder=void 0}handleCustomSlotElementsLoaded(t){this.hasToSearchCustomElements(t)&&this.getCustomElements(!0)}handleTaskbarSaveLocker(){!0!==this._isWaitingForSave&&(this._isWaitingForSave=!0)}handleTaskbarSaveUnlocker(){!0===this._isWaitingForSave&&(this._isWaitingForSave=!1)}hasToSearchCustomElements(t){return this.customSlotId===t.detail&&!this._slotContainer}observeButtons(){this._definitions=void 0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()}))}))}observeDisabledButtons(){var t;null===(t=this._overFlowWatcher)||void 0===t||t.forceUpdate()}observeLastWidth(t,s){0===s&&0!==t&&(this._hasToUpdateOverFlow=!0)}observeIsWaitingForSave(t,s){1==t&&0==s&&this.taskbarSaveLocker.emit(),0==t&&1==s&&this.taskbarSaveUnlocker.emit()}elementsFromString(t){const s=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(k[t]||this.isAllowed(t))&&s.push(t.trim())})),s}isAllowed(t){return t===m.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[u.CONFIG_GRID]||this._permissions[u.CONFIG]):!m[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){var s;let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,{}):""}elementClick(t){if(this.dataUnit)switch(t){case c.PREVIOUS:this.dataUnit.previousRecord();break;case c.NEXT:this.dataUnit.nextRecord();break;case c.REFRESH:this.dataUnit.loadData();break;case c.CLONE:this.dataUnit.copySelected();break;case c.REMOVE:this.dataUnit.removeSelectedRecords();break;case c.INSERT:this.dataUnit.addRecord();break;case c.CANCEL:this.dataUnit.cancelEdition();break;case c.SAVE:this._isWaitingForSave||(this._isWaitingForSave=!0,this.dataUnit.saveData().finally((()=>{this._isWaitingForSave=!1})))}this.isEnabled(t)&&this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}validatePresentationMode(){Object.values(T).includes(this.presentationMode)||(this.presentationMode=T.PRIMARY)}getElement(t,s){let i=s===this.primaryButton?"ez-button--primary ":"";t>1&&(i+="ez-padding-left--medium");const e=c[s.toString()],a=this._element.dataset.exporterStoreKey||this.configName;return e?b(s,i,this.getIdElemBtnNative(s),(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.buildDynamicActionsList(),a,this.presentationMode):p(s,i,this.getIdElemBtnCustom(s),(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}buildDynamicActionsList(){var t;return this._hiddenActionsList.length?[...null!==(t=this.actionsList)&&void 0!==t?t:[],{type:"divider",label:"",value:""},...this._hiddenActionsList]:this.actionsList}getIdElemBtnNative(t){return n.toCamelCase(t)}getIdElemBtnCustom(t){return n.toCamelCase(t.name)}isDivider(t){var s;return void 0!==t&&(null===(s=t.t)||void 0===s?void 0:s["data-taskbar-divider"])}removeEmpty(t){let s;return t.filter((t=>!(null==t||this.isDivider(s)&&this.isDivider(t)||(s=t,0))))}appendCustomElementsInTaskbar(){this._customElementsId.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s),e=this._element.querySelector(`#${t}`);e?null==e||e.appendChild(i):this.unlinkCustomElementFromTaskbar(i)}))}addCustomElementContainer(t){var s;const e=`${this.TASKBAR_ITEM_ID_PREFIX}${t}`;return this._customElementsId.includes(e)||(this._customElementsId.push(e),null===(s=this._overFlowWatcher)||void 0===s||s.addNotOverFlowElement(e)),i("span",{class:"ez-padding-left--medium",key:e,id:e})}getCustomElements(t){var s,i;this._customElementsId=[],this._customElements=new Map,this._slotContainer=this.buildSlotContainer(t),Array.from(null!==(i=null===(s=this._slotContainer)||void 0===s?void 0:s.children)&&void 0!==i?i:[]).forEach((t=>this._customElements.set(t.id,t)))}buildSlotContainer(t){let s;if(this.customContainerId){const t=document.querySelector(`#${this.customContainerId}`);s=null==t?void 0:t.querySelector(`#${this.customSlotId}`)}else s=this._element.querySelector(`#${this.customSlotId}`);return t&&!s&&(s=document.querySelector(`#${this.customSlotId}`)),s}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)):this._permissions={},this.getCustomElements()}componentWillRender(){this.handleDefinitions(),this.validatePresentationMode(),this.updateOverFlowIfNeeded()}handleDefinitions(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}updateOverFlowIfNeeded(){this._hasToUpdateOverFlow&&(requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()})),this._hasToUpdateOverFlow=!1)}handleOverFlow(t){const s=t.filter((t=>!this.hasToIgnoreOverFlow(t)));this.resetOverFlowedElements(),this.doOverFlowElements(s)}resetOverFlowedElements(){this._overFlowedElements.forEach((t=>{t.classList.remove(o)})),this._hiddenActionsList=[],this._overFlowedElements=[]}doOverFlowElements(t){t.forEach((t=>{t.classList.add(o),this._overFlowedElements.push(t),this.addItemToActionList(t)}))}addItemToActionList(t){const s=this.getTaskbarElementName(t);if(s&&this.isEnabled(s)&&this.isAllowed(s)){const i={value:s,label:this.getTaskbarElementLabel(t),iconName:this.getTaskbarElementIcon(t)};this._hiddenActionsList.push(i)}}getTaskbarElementName(t){var s;return null!==(s=t.getAttribute("data-taskbar-element"))&&void 0!==s?s:""}getTaskbarElementIcon(t){var s;return null!==(s=t.getAttribute("data-taskbar-icon"))&&void 0!==s?s:""}getTaskbarElementLabel(t){var s;return null!==(s=t.getAttribute("data-taskbar-label"))&&void 0!==s?s:""}hasToIgnoreOverFlow(t){return t.classList.contains(this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME)}handleOverFlowStrategy(){"hiddenItems"===this.overflowStrategy&&(this._overFlowWatcher=new l(this.buildOverFlowWatcherParams()))}buildOverFlowWatcherParams(){return{element:this._element,callback:this.handleOverFlow.bind(this),overFlowDirection:d.HORIZONTAL,notOverFlow:this.NOT_OVERFLOW_ELEMENTS}}componentDidLoad(){v.addIDInfo(this._element,null,{dataUnit:this.dataUnit}),this.handleOverFlowStrategy(),this.dataUnit.unsubscribe(this.onSaveEvent),this.dataUnit.subscribe(this.onSaveEvent)}componentDidRender(){this.appendCustomElementsInTaskbar(),this.updateLastWidth()}updateLastWidth(){this._lastWidth=this._element.getBoundingClientRect().width}disconnectedCallback(){var t,s;null===(t=this.dataUnit)||void 0===t||t.unsubscribe(this.onSaveEvent),this.unlinkAllCustomElements(),null===(s=this._overFlowWatcher)||void 0===s||s.destroy()}unlinkAllCustomElements(){var t;null===(t=this._customElementsId)||void 0===t||t.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s);this.unlinkCustomElementFromTaskbar(i)}))}unlinkCustomElementFromTaskbar(t){this._slotContainer.appendChild(t)}render(){if(void 0===this._definitions)return;let t=0;return i(e,{class:this.getHostClasses()},this.removeEmpty(this._definitions.map((s=>{var e,a;return t++,c[s]?this.getElement(t,c[s]):(null===(e=this.customButtons)||void 0===e?void 0:e.has(s))?this.getElement(t,this.customButtons.get(s)):this._customElements.has(s)?this.addCustomElementContainer(s):(null===(a=this._overFlowWatcher)||void 0===a||a.addNotOverFlowElement(s),i("slot",{name:s}))}))),i("div",{class:this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME},i("slot",{name:this.customSlotId})))}getHostClasses(){return"hiddenItems"!==this.overflowStrategy?"no-wrap":"full-width "+(this.alignRigth?"align-right":"")}get _element(){return a(this)}static get watchers(){return{buttons:["observeButtons"],disabledButtons:["observeDisabledButtons"],_lastWidth:["observeLastWidth"],_isWaitingForSave:["observeIsWaitingForSave"]}}};f.style=".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";export{f as snk_taskbar}