@sankhyalabs/sankhyablocks 8.16.0-dev.99 → 8.16.0-ms.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. package/dist/cjs/{ClientSideExporterProvider-cc82b68a.js → ClientSideExporterProvider-2f5f350c.js} +21 -55
  2. package/dist/cjs/{ConfigStorage-2235f35e.js → ConfigStorage-d024aec8.js} +2 -2
  3. package/dist/cjs/{DataFetcher-875371e9.js → DataFetcher-65879b2c.js} +1 -1
  4. package/dist/cjs/ISave-e91b70a7.js +9 -0
  5. package/dist/cjs/{SnkFormConfigManager-6637cd6b.js → SnkFormConfigManager-c11d8468.js} +2 -2
  6. package/dist/cjs/{auth-fetcher-abad589f.js → auth-fetcher-8480751c.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-b95768e8.js → dataunit-fetcher-449d51a3.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-db332748.js → form-config-fetcher-90126e4c.js} +1 -15
  9. package/dist/cjs/index-f9e81701.js +2 -2
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/{ISave-62fbb1dd.js → pesquisa-fetcher-5c583c93.js} +1 -9
  12. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +6 -5
  13. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  14. package/dist/cjs/{snk-actions-button_7.cjs.entry.js → snk-actions-button_5.cjs.entry.js} +6 -65
  15. package/dist/cjs/snk-application.cjs.entry.js +7 -50
  16. package/dist/cjs/snk-attach.cjs.entry.js +6 -5
  17. package/dist/cjs/snk-config-options_3.cjs.entry.js +4 -4
  18. package/dist/cjs/snk-configurator.cjs.entry.js +1 -8
  19. package/dist/cjs/snk-crud.cjs.entry.js +7 -7
  20. package/dist/cjs/snk-data-exporter.cjs.entry.js +7 -6
  21. package/dist/cjs/{snk-data-unit-33937ffe.js → snk-data-unit-bbd384bf.js} +1 -1
  22. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
  23. package/dist/cjs/snk-detail-view.cjs.entry.js +10 -10
  24. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +3 -3
  25. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  26. package/dist/cjs/snk-grid.cjs.entry.js +7 -6
  27. package/dist/cjs/{snk-guides-viewer-0e4f3b1a.js → snk-guides-viewer-5396062f.js} +7 -6
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -7
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  30. package/dist/cjs/snk-pesquisa.cjs.entry.js +12 -11
  31. package/dist/cjs/snk-simple-crud.cjs.entry.js +9 -9
  32. package/dist/collection/collection-manifest.json +0 -2
  33. package/dist/collection/components/snk-application/snk-application.js +0 -41
  34. package/dist/collection/components/snk-configurator/snk-configurator.js +1 -26
  35. package/dist/collection/components/snk-crud/snk-crud.js +1 -20
  36. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.css +1 -10
  37. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -25
  38. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +1 -1
  39. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +16 -51
  40. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +1 -1
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -20
  42. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
  43. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +0 -14
  44. package/dist/components/ContinuousInsertUtils.js +16 -51
  45. package/dist/components/DataFetcher.js +1 -1
  46. package/dist/components/form-config-fetcher.js +0 -14
  47. package/dist/components/index.d.ts +0 -2
  48. package/dist/components/index.js +0 -2
  49. package/dist/components/snk-application2.js +0 -45
  50. package/dist/components/snk-attach2.js +22 -34
  51. package/dist/components/snk-configurator2.js +2 -22
  52. package/dist/components/snk-crud.js +62 -76
  53. package/dist/components/snk-data-exporter2.js +1 -1
  54. package/dist/components/snk-detail-view2.js +86 -110
  55. package/dist/components/snk-simple-crud2.js +19 -33
  56. package/dist/esm/{ClientSideExporterProvider-8191676b.js → ClientSideExporterProvider-3537805a.js} +21 -55
  57. package/dist/esm/{ConfigStorage-9bd805d6.js → ConfigStorage-373bb440.js} +2 -2
  58. package/dist/esm/{DataFetcher-ecf5f903.js → DataFetcher-5221b992.js} +1 -1
  59. package/dist/esm/ISave-d8c8bc59.js +9 -0
  60. package/dist/esm/{SnkFormConfigManager-fbc6a9a8.js → SnkFormConfigManager-5022f87f.js} +2 -2
  61. package/dist/esm/{auth-fetcher-07d33333.js → auth-fetcher-e32fe8a4.js} +1 -1
  62. package/dist/esm/{dataunit-fetcher-ed6e65ef.js → dataunit-fetcher-91b094f2.js} +1 -1
  63. package/dist/esm/{form-config-fetcher-ac17cff4.js → form-config-fetcher-126e2471.js} +1 -15
  64. package/dist/esm/index-a7d3d3f1.js +2 -2
  65. package/dist/esm/loader.js +1 -1
  66. package/dist/esm/{ISave-7d546dce.js → pesquisa-fetcher-4284f2a3.js} +2 -10
  67. package/dist/esm/pesquisa-grid_2.entry.js +5 -4
  68. package/dist/esm/sankhyablocks.js +1 -1
  69. package/dist/esm/{snk-actions-button_7.entry.js → snk-actions-button_5.entry.js} +8 -65
  70. package/dist/esm/snk-application.entry.js +6 -49
  71. package/dist/esm/snk-attach.entry.js +6 -5
  72. package/dist/esm/snk-config-options_3.entry.js +4 -4
  73. package/dist/esm/snk-configurator.entry.js +1 -8
  74. package/dist/esm/snk-crud.entry.js +7 -7
  75. package/dist/esm/snk-data-exporter.entry.js +7 -6
  76. package/dist/esm/{snk-data-unit-6258b8ae.js → snk-data-unit-b03bb5cf.js} +1 -1
  77. package/dist/esm/snk-data-unit.entry.js +3 -3
  78. package/dist/esm/snk-detail-view.entry.js +10 -10
  79. package/dist/esm/snk-filter-bar_4.entry.js +3 -3
  80. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  81. package/dist/esm/snk-grid.entry.js +7 -6
  82. package/dist/esm/{snk-guides-viewer-80a8709c.js → snk-guides-viewer-749d027c.js} +7 -6
  83. package/dist/esm/snk-guides-viewer.entry.js +8 -7
  84. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  85. package/dist/esm/snk-pesquisa.entry.js +5 -4
  86. package/dist/esm/snk-simple-crud.entry.js +9 -9
  87. package/dist/sankhyablocks/p-13391b3d.entry.js +1 -0
  88. package/dist/sankhyablocks/p-1435701f.js +26 -0
  89. package/dist/sankhyablocks/{p-13f17dab.js → p-19dc71e9.js} +1 -1
  90. package/dist/sankhyablocks/{p-340e2447.entry.js → p-1cf39cfd.entry.js} +1 -1
  91. package/dist/sankhyablocks/p-21749402.js +1 -0
  92. package/dist/sankhyablocks/{p-abd9681c.js → p-23b47a92.js} +1 -1
  93. package/dist/sankhyablocks/{p-7e0a0aae.js → p-3653374d.js} +1 -1
  94. package/dist/sankhyablocks/p-389ba782.entry.js +1 -0
  95. package/dist/sankhyablocks/p-3ba431c9.js +1 -0
  96. package/dist/sankhyablocks/{p-108fee57.js → p-41c3bee5.js} +2 -2
  97. package/dist/sankhyablocks/{p-2746d606.entry.js → p-44efbeed.entry.js} +1 -1
  98. package/dist/sankhyablocks/p-4be6e0e7.entry.js +1 -0
  99. package/dist/sankhyablocks/p-4c9adf1c.entry.js +1 -0
  100. package/dist/sankhyablocks/p-4d87cd45.entry.js +1 -0
  101. package/dist/sankhyablocks/p-4fa79d68.entry.js +1 -0
  102. package/dist/sankhyablocks/p-5dd7f4c7.js +1 -0
  103. package/dist/sankhyablocks/p-6234bda8.entry.js +1 -0
  104. package/dist/sankhyablocks/p-647f9830.entry.js +11 -0
  105. package/dist/sankhyablocks/p-7b87d1a8.js +1 -0
  106. package/dist/sankhyablocks/{p-0bcd4757.entry.js → p-82ee6dc3.entry.js} +1 -1
  107. package/dist/sankhyablocks/{p-5fea0816.entry.js → p-974fdba6.entry.js} +1 -1
  108. package/dist/sankhyablocks/p-ad5e4f9d.entry.js +1 -0
  109. package/dist/sankhyablocks/p-b2de1bcc.entry.js +1 -0
  110. package/dist/sankhyablocks/{p-f467153c.entry.js → p-c021a3a9.entry.js} +1 -1
  111. package/dist/sankhyablocks/p-ca316523.entry.js +1 -0
  112. package/dist/sankhyablocks/{p-5a7e18f4.js → p-d62228fb.js} +1 -1
  113. package/dist/sankhyablocks/p-ee53b000.entry.js +1 -0
  114. package/dist/sankhyablocks/{p-48729c8c.js → p-f0b9303b.js} +1 -1
  115. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  116. package/dist/types/components/snk-application/snk-application.d.ts +0 -10
  117. package/dist/types/components/snk-configurator/snk-configurator.d.ts +0 -6
  118. package/dist/types/components/snk-crud/snk-crud.d.ts +0 -4
  119. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +0 -5
  120. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +0 -7
  121. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -4
  122. package/dist/types/components.d.ts +1 -77
  123. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +0 -6
  124. package/package.json +1 -1
  125. package/react/components.d.ts +0 -2
  126. package/react/components.js +0 -2
  127. package/react/components.js.map +1 -1
  128. package/dist/collection/components/snk-layout-form-config/snk-layout-form-config.css +0 -3
  129. package/dist/collection/components/snk-layout-form-config/snk-layout-form-config.js +0 -73
  130. package/dist/collection/components/snk-layout-form-config/snk-view-representation/snk-view-representation.css +0 -78
  131. package/dist/collection/components/snk-layout-form-config/snk-view-representation/snk-view-representation.js +0 -57
  132. package/dist/collection/lib/configs/LayoutFormConfig.js +0 -25
  133. package/dist/components/snk-layout-form-config.d.ts +0 -11
  134. package/dist/components/snk-layout-form-config.js +0 -6
  135. package/dist/components/snk-layout-form-config2.js +0 -73
  136. package/dist/components/snk-view-representation.d.ts +0 -11
  137. package/dist/components/snk-view-representation.js +0 -6
  138. package/dist/components/snk-view-representation2.js +0 -41
  139. package/dist/sankhyablocks/p-01512409.js +0 -26
  140. package/dist/sankhyablocks/p-02c6dc9f.entry.js +0 -1
  141. package/dist/sankhyablocks/p-35fcf37e.js +0 -1
  142. package/dist/sankhyablocks/p-3a36d4b3.entry.js +0 -1
  143. package/dist/sankhyablocks/p-513af002.entry.js +0 -1
  144. package/dist/sankhyablocks/p-950e3cbe.entry.js +0 -1
  145. package/dist/sankhyablocks/p-9907cf67.entry.js +0 -1
  146. package/dist/sankhyablocks/p-af58c9d7.entry.js +0 -1
  147. package/dist/sankhyablocks/p-c5acb7ba.entry.js +0 -11
  148. package/dist/sankhyablocks/p-c7c6eab7.entry.js +0 -1
  149. package/dist/sankhyablocks/p-cb9d725a.js +0 -1
  150. package/dist/sankhyablocks/p-d1f04e2c.js +0 -1
  151. package/dist/sankhyablocks/p-d2065bb4.entry.js +0 -1
  152. package/dist/sankhyablocks/p-dc617b0c.entry.js +0 -1
  153. package/dist/sankhyablocks/p-e5d8891d.entry.js +0 -1
  154. package/dist/sankhyablocks/p-f861bfcb.entry.js +0 -1
  155. package/dist/types/components/snk-layout-form-config/snk-layout-form-config.d.ts +0 -15
  156. package/dist/types/components/snk-layout-form-config/snk-view-representation/snk-view-representation.d.ts +0 -10
  157. package/dist/types/lib/configs/LayoutFormConfig.d.ts +0 -11
@@ -1 +0,0 @@
1
- import{r as i,h as t,H as s,g as e,c as n}from"./p-d2d301a6.js";import{ApplicationContext as o,StringUtils as r,ErrorException as a,WarningException as l,ObjectUtils as c,DateUtils as d,ServiceUtils as h,StorageType as u,ArrayUtils as g,ElementIDUtils as f}from"@sankhyalabs/core";import{D as m}from"./p-5a7e18f4.js";import{P as v}from"./p-eaad0aa8.js";import"./p-108fee57.js";import"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import{F as p}from"./p-01512409.js";import{O as b}from"./p-1d19a5b0.js";import{g as _}from"./p-7dd49d15.js";import{R as k}from"./p-688dcb4c.js";import{ApplicationUtils as w,DialogType as y,FormLayout as x}from"@sankhyalabs/ezui/dist/collection/utils";import{CheckMode as C}from"@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode";import{C as z}from"./p-13f17dab.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";class S{execute(i){var t;const s={actionID:i.actionID,refreshType:null===(t=i.actionConfig.javaCall)||void 0===t?void 0:t.refreshType};return new Promise((i=>{i({execSource:s,callback:this.callExecJava})}))}async callExecJava(i){const t={requestBody:{javaCall:i}};await m.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(t))}}class A{execute(i){var t;const s={actionID:i.actionID,refreshType:null===(t=i.actionConfig.runScript)||void 0===t?void 0:t.refreshType};return new Promise((i=>{i({execSource:s,callback:this.callExecScript})}))}async callExecScript(i){const t={runScript:i};await m.get().callServiceBroker("ActionButtonsSP.executeScript",t)}}class O{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(i,t){const s=i.resourceID;if(!s)return;let e=await this.buildLaunchObject(i,t);return this._application.openApp(s,e),null}buildLaunchObject(i,t){return new Promise((s=>{let e=i.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let l=t.getFieldValue(e);if(!l){let s=t.getField(e).label;throw s=r.isEmpty(t.getField(e).label)?e:s,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:i.description,localFieldLabel:s}))}l=r.isEmpty(l.toString())?void 0:l.toString(),n[s.targetField]=l,o.push({fieldName:s.targetField,value:l})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class P{execute(i){var t,s,e;const n=null===(t=i.actionConfig.dbCall)||void 0===t?void 0:t.name,o=null===(s=i.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,r={actionID:i.actionID,refreshType:null===(e=i.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((i=>{i({execSource:r,callback:this.callExecProcedure})}))}async callExecProcedure(i){const t={requestBody:{stpCall:i}};await m.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(t))}}var N,L;!function(i){i.LAUNCH_SCREEN="LC",i.JAVASCRIPT="SC",i.JAVA="RJ",i.PROCEDURE="SP",i.EMBEDDED="EB"}(N||(N={}));class D{constructor(i){this.actionType=i,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case N.LAUNCH_SCREEN:return new O;case N.JAVASCRIPT:return new A;case N.JAVA:return new S;case N.PROCEDURE:return new P;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(i){i.NONE="NONE",i.PARENT="PARENT",i.MASTER="MASTER",i.ALL="ALL"}(L||(L={}));const I="__MASTER_ROW__";class E{constructor(i,t,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=i,this._dataUnit=t,this._selectedRows=(null===(e=null==t?void 0:t.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==t?void 0:t.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}getPrimaryKeys(){return _(this._dataUnit).map((({name:i})=>i))}apply(i,t){this._application.closePopUp(),this._actionsExecuteInterface.execute(i,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(i,s,t).then((()=>{this.actionExecute(s,e)}))}))}async execute(i){var t;if(!i.actionConfig)throw new l(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:i.description}));if(null===(t=i.actionConfig.params)||void 0===t?void 0:t.promptParam){const t=i.actionConfig.params.promptParam;let s=!1;for(let i=0;i<t.length;i++)if(!s&&"true"===t[i].saveLast){s=!0;break}s&&(i.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(i));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=c.copy(i),e.applyParameters=i=>{this.apply(i,s)},e.openPopup()}else i.type!=N.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(i,this._dataUnit).then((({execSource:i,callback:t})=>{this.actionExecute(i,t)})):this._actionsExecuteInterface.execute(i,this._dataUnit)}loadSavedValuesIntoParams(i){return this.loadLastValues(i).then((t=>{let s=i.actionConfig.params.promptParam;return t&&t.param.forEach((i=>{s=s.map((t=>t.name!==i.paramName?t:Object.assign(Object.assign({},t),"B"===t.paramType?{value:"S"===i.$}:{value:i.$})))})),s}))}async actionExecute(i,t){i.virtualPage=this.buildVirtualPage(),await this.prepareAndExecute(i,t),this.recordsReloader(i.refreshType)}resolvePromptParams(i,t,s){return new Promise((e=>{let n=[];i.actionConfig.params.promptParam.forEach((i=>{n.push(this.buildPromptParam(i))})),this.putParamsOnExecSource(n,t),s&&this.saveLastValues(i,n),e()}))}buildPromptParam(i){let t,s,e=i.paramType,n=!1,o=i.value;switch(e){case v.DATE:e="D";break;case v.DATETIME:e="H";break;case v.DECIMAL:e="F",t={"sk-precision":Number(i.precision)};break;case v.BOOLEAN:e="S",n=!0,o=i.value?"S":"N";break;case v.ENTITY:t={"sk-entity-name":i.entityName,"sk-allow-show-hierarchical-mode":i.hierarchyEntity,"sk-data-type":"S"},i.hierarchyEntity&&i.entityPK&&(s=i.entityPK),o=i.value?Number(i.value):null;break;case v.OPTIONS:e="O";let r=i.options.split(";").map((function(i,t){let s,e;if(i.indexOf("=")>-1){let t=i.split("=");s=t[0],e=t[1]}else s=t+1,e=i;return{data:s,value:e}}));t={"sk-options":r}}return{description:i.label,required:"true"==i.required,fieldName:i.name,fieldNameOri:i.name,entityPK:s,paramType:i.paramType,type:e,isCheckbox:n,saveLast:i.saveLast,fieldProp:t,value:o,isGeneratedName:i.isGeneratedName}}putParamsOnExecSource(i,t){t.params={param:[]},i.forEach((i=>{if(i.isGeneratedName&&i.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));r.isEmpty(i.value)||t.params.param.push({type:this.getParamDataType(i.paramType),paramName:i.fieldName,$:this.getParamValue(i)})}))}getParamDataType(i){let t;switch(i){case"D":t="F";break;case"DT":case"DH":t="D";break;case"B":case"ENTITY":case"SO":t="S";break;default:t=i}return t}getParamValue(i){let t=i.value;return t?("DT"==i.paramType?t=d.formatDate(t):"DH"==i.paramType&&(t=d.formatDateTime(t)),t):t}async loadLastValues(i){const t=await this.buildResourceId(i.actionID);return new Promise(((i,s)=>{if(this._lastValuesCache[t])i(this._lastValuesCache[t]);else{const e={config:{chave:t,tipo:"T"}};m.get().callServiceBroker("SystemUtilsSP.getConf",e).then((s=>{var e,n;let o;(null===(n=null===(e=s.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=s.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[t]=o,i(o)})).catch((i=>{s(i)}))}}))}async saveLastValues(i,t){if(this._application){let s={params:{param:[]}};t.forEach((i=>{"true"==i.saveLast&&s.params.param.push({paramName:i.fieldName,$:i.value})}));const e=await this.buildResourceId(i.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(i){return this._appResourceId+".actionconfig."+i}async prepareAndExecute(i,t){this.addRows(i),await t(i)}addRows(i){const t=this.getPrimaryKeys(),s={row:[]},e=this._selectedRows;for(const i in e){const n=e[i],o={};n.hasOwnProperty(I)&&(o.master="S",o.entityName=n.__ENTITY_NAME__,delete n[I],delete n.__ENTITY_NAME__),o.field||(o.field=[]);for(const i of t)o.field.push({fieldName:i,$:n[i]});s.row.push(o)}s.row.length>0&&(i.rows=s)}recordsReloader(i){switch(i){case L.NONE:break;case L.PARENT:case L.MASTER:case L.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var i,t,s,e;if(null===(t=null===(i=this._dataUnit)||void 0===i?void 0:i.getSelectionInfo())||void 0===t?void 0:t.isAllRecords())return{filters:{filters:null===(s=this._dataUnit)||void 0===s?void 0:s.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class j{async clientConfirm(i,t){return new Promise((s=>{const e=o.getContextValue("__SNK__APPLICATION__");let n="";i.content.event.hasOwnProperty("stpCall")?(t.requestBody=i.content.event.stpCall,n=N.PROCEDURE):i.content.event.hasOwnProperty("runScript")?(t.requestBody=i.content.event.runScript,n=N.JAVASCRIPT):i.content.event.hasOwnProperty("javaCall")&&(t.requestBody=i.content.event.javaCall,n=N.JAVA);let r={type:"S",sequence:i.content.event.sequence};t.requestBody.params?Array.isArray(t.requestBody.params.param)||(t.requestBody.params.param=[t.requestBody.params.param]):t.requestBody.params={param:[]},t.requestBody.params.param.push(r);const a=i.content.event.title.$,l=i.content.event.message.$;let c;switch(n){case N.JAVASCRIPT:c={runScript:t.requestBody};break;case N.PROCEDURE:c={requestBody:{stpCall:t.requestBody}};break;case N.JAVA:c={requestBody:{javaCall:t.requestBody}}}if("S"==i.content.event.showNoOption){r.paramName="__ESCOLHA_SIMNAO__";const i=document.createElement("snk-client-confirm");window.document.body.appendChild(i),i.titleMessage=a,i.message=l,i.accept=async()=>{r.$="S",await t.reCall(c),s()},i.cancel=async()=>{r.$="N",await t.reCall(c),s()},i.openPopup()}else e.confirm(a,l,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async i=>{i&&(r.paramName="__CONFIRMACAO__",r.$="S",await t.reCall(c),s())}))}))}}const T=class{constructor(t){i(this,t),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this._actions=[],this.handleClick=i=>{const t=this._actions.find((t=>t.actionID==i.detail.id)),s=new D(t.type).executor;new E(s,this._dataUnit,this._resourceID).execute(Object.assign({},t)),this._showDropdown=!1},this._items=[],this._showDropdown=!1}async getActions(){const i=await h.useCacheWithService(`SnkActionsButton_${this._entityName}-${this._resourceID}`,(async()=>{var i;const t={param:{entityName:this._entityName,resourceID:this._resourceID}};return(null===(i=(await m.get().callServiceBroker("ActionButtonsSP.getActions",t)).actions)||void 0===i?void 0:i.action)||[]}),u.IN_MEMORY_CACHE);this._actions=T.parameters.isOrderActions?g.sortAlphabetically(i,"description"):i}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var i;return this._showDropdown&&(null===(i=this._items)||void 0===i?void 0:i.length)>0}positionDropdown(){var i;const t=null===(i=this._ezButton)||void 0===i?void 0:i.getBoundingClientRect();t&&this._dropdownParent&&(this._dropdownParent.style.top=t.y+t.height+5+"px",this._dropdownParent.style.left=t.x+"px")}closeDropdown(i){const t=null==i?void 0:i.target;t&&(t.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),await this.loadParameters();const i=this._element.parentElement;this._dataUnit=null==i?void 0:i.dataUnit,this._resourceID=null==i?void 0:i.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await k.getResourceID()),this.setEvents(),await this.getActions(),this.loadItems()}async componentDidLoad(){if(this._element&&(f.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const i=new j;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,i.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((i=>{this._items.push({id:i.actionID,label:i.description})}))}getElementID(i){return{[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:f.getInternalIDInfo(i)}}async loadParameters(){null==T.parameters.isOrderActions&&(T.parameters.isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas"))}render(){return t(s,null,this._actions&&this._actions.length>0&&t("div",{class:`ez-padding-left--medium snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},t("ez-button",Object.assign({ref:i=>this._ezButton=i,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),t("div",Object.assign({ref:i=>this._dropdownParent=i,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&t("ez-dropdown",Object.assign({items:this._items,onEzClick:i=>this.handleClick(i)},this.getElementID("dropdown"))))),this.canShowDropdown()&&t("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};T.parameters={isOrderActions:null},T.style=".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";const B=class{constructor(t){i(this,t),this.configChange=n(this,"configChange",7),this.configCancel=n(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0,this.columns=void 0,this.config=void 0,this.configName=void 0,this.resourceID=void 0}getMessage(i,t){return o.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage(i,t)}getSortableColumns(){let i=[];return this.columns.filter((i=>{var t;return r.getBooleanValue(null===(t=null==i?void 0:i.props)||void 0===t?void 0:t.get("sortable"),!0)})).forEach((t=>{var s;let e=null===(s=this.config)||void 0===s?void 0:s.columns.find((i=>i.name===t.name)),n={name:t.name,label:t.label};e&&(n.orderIndex=e.orderIndex,n.ascending=e.ascending),t.hidden||i.push(n)})),i}createOrderList(){let i=this.getSortableColumns();i.sort(((i,t)=>0!=i.orderIndex||0!=t.orderIndex||null==i.ascending&&null==t.ascending?null!=i.ascending&&null!=t.ascending?i.orderIndex-t.orderIndex:null!=i.ascending||null!=t.ascending?null!=i.ascending?-1:null!=t.ascending?1:0:i.orderIndex-t.orderIndex:null!=i.ascending?-1:null!=t.ascending?1:0)),this._orderListItems=i}createColumnList(){let i={group:this.getMessage("snkGridConfig.group.visible"),items:[]},t={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:b.asc.value};this.columns.forEach((s=>{let e={label:s.label};s.hidden?t.items.push(e):i.items.push(e)})),this._columListItems=[i,t]}createColumnListSlotDataElementId(i){return`configItem_${r.replaceAccentuatedChars(r.toCamelCase(i.label))}`}buildColumnListSlot(i,s){const e=this.createColumnListSlotDataElementId(i);return t("div",null,t("ez-check",{mode:C.SWITCH,id:C.SWITCH+((null==i?void 0:i.label)||"")+((null==s?void 0:s.group)||""),value:s.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":e,onEzChange:t=>{this.switchColumnGroup(t,i)}}))}createOrderListSlotDataElementId(i){return`${this._element.getAttribute(f.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${r.toCamelCase(i.label)}`}buildOrderListSlot(i){const s=this.createOrderListSlotDataElementId(i);let e=b.none.value;return null!=(null==i?void 0:i.ascending)&&(e=1==i.ascending?b.asc.value:b.desc.value),t("div",null,t("snk-select-box",{selectedOption:e,key:"snk-select-box-"+this._componenteInternalKey+"-"+i,"data-element-id":s,onEzChange:t=>{t.stopPropagation(),this.updateOrder(t.detail,i.label)}}))}updateOrder(i,t){var s;this._dataChanged=!0;let e,n=[...this.columns],o=n.find((i=>i.label===t));o&&(o.sort=i.value===b.none.value?void 0:i.value),(null===(s=this._orderPriorityList)||void 0===s?void 0:s.length)>0?(this._orderPriorityList.find((i=>i.label===o.label)).sort=i,this._orderPriorityList.filter((i=>i.sort)).forEach(((i,t)=>{i.label===o.label&&(o.sortIndex=t)}))):(e=n.filter((i=>i.sort&&!0!==i.hidden)).map(((i,t)=>({label:i.label,orderIndex:t}))),e.forEach((i=>{n.find((t=>t.label===i.label)).sortIndex=i.orderIndex}))),this.columns=n}switchColumnGroup(i,t){i.stopPropagation();let s=[...this._columListItems];if(this._dataChanged=!0,!0===i.detail){let i=s.find((i=>i.group===this.getMessage("snkGridConfig.group.hidden"))),e=i.items.findIndex((i=>i.label===t.label));e>=0&&i.items.splice(e,1),s.find((i=>i.group===this.getMessage("snkGridConfig.group.visible"))).items.push(t),this._columListItems=s,this.createOrderList()}else if(!1===i.detail){let i=s.find((i=>i.group===this.getMessage("snkGridConfig.group.visible"))),e=i.items.findIndex((i=>i.label===t.label));e>=0&&i.items.splice(e,1),s.find((i=>i.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(t),this._columListItems=s,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let i=[];this._columListItems.forEach((t=>{t.items.forEach((s=>{const e=this.columns.find((i=>i.label===s.label));let n=Object.assign({},e);n.hidden=t.group===this.getMessage("snkGridConfig.group.hidden"),i.push(n)}))})),this.columns=i,this._dataChanged=!1,this.closeConfig(),this.save()}saveGridConfigOnStorage(i){z.saveGridConfig(i,this.configName,this.resourceID).then((i=>{this.configChange.emit(i),this._orderList.clearHistory(),w.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}reOrderPriorityColumns(i,t){let s=[];s=i.filter((i=>i.sort&&!0!==i.hidden)).map((i=>({label:i.label,orderIndex:0})));let e=0,n=[];return t.forEach((i=>{let t=s.find((t=>t.label===i.label));t&&(t.orderIndex=e,n.push(t),e++)})),n.length>0&&(s=n),s}save(){var i;let t;t=this.config?this.config:this.createConfigFromState(this.columns);let s,e=[];(null===(i=this._orderPriorityList)||void 0===i?void 0:i.length)>0&&(s=this.reOrderPriorityColumns(this.columns,this._orderPriorityList)),this.columns.forEach((i=>{let n=t.columns.find((t=>i.name===t.name));!0===i.hidden&&n||(n?n.width=i.width:!1===i.hidden&&(n={name:i.name,width:i.width,orderIndex:0}),n&&(i.sort?(n.ascending=i.sort.toUpperCase()===b.asc.value,s?function(i,t){if(s){let e=s.find((t=>t.label===i.label));e&&(t.orderIndex=e.orderIndex)}}(i,n):n.orderIndex=i.sortIndex):(delete n.ascending,n.orderIndex=0),e.push(n)))})),t.columns=e,this.saveGridConfigOnStorage(t)}createConfigFromState(i){let t={columns:[]};return i.forEach((i=>{if(!i.hidden){let s={name:i.name};i.width&&(s.width=i.width),i.sort?(s.ascending=i.sort.toUpperCase()===b.asc.value,s.orderIndex=i.sortIndex):s.orderIndex=0,s&&t.columns.push(s)}})),t}async locateColumn(i,t){var s;const e="Enter"===i.key;if(!(t=t||(null===(s=i.currentTarget)||void 0===s?void 0:s.value)))return void this.removeSelection();const n=await this.getMatchedIndexes(t),o=this.getNewSelectedIndex(n,e);this._selectedIndex=o,1===this.selectedIndex?this.updateOrderListSelection(o):this.updateColumnListSelection(o)}async getMatchedIndexes(i){const t=[];return 1===this.selectedIndex?(await this._orderList.getList()).forEach(((s,e)=>{this.compareWords(s,i)&&t.push(e)})):this.columns.forEach(((s,e)=>{this.compareWords(s,i)&&t.push(e)})),t}getNewSelectedIndex(i,t){if(0===i.length)return-1;if(t)for(const t of i)if(t>this._selectedIndex)return t;return i[0]}updateOrderListSelection(i){-1!==i?this._orderList.getList().then((t=>{const s=t[i];s?this._orderList.setSelection(s,!0):this._orderList.removeSelection()})):this._orderList.removeSelection()}updateColumnListSelection(i){if(-1===i)return void this._columnList.removeSelection();const t=this.columns[i];if(t){const i=this._columListItems.map((i=>i.items)).flat().find((i=>i.label===t.label));i?this._columnList.setSelection(i,!0):this._columnList.removeSelection()}else this._columnList.removeSelection()}removeSelection(){1===this.selectedIndex?this._orderList.removeSelection():this._columnList.removeSelection()}compareWords(i,t){var s,e;const n=null===(s=r.replaceAccentuatedChars(null==i?void 0:i.label))||void 0===s?void 0:s.toUpperCase(),o=null===(e=r.replaceAccentuatedChars(t))||void 0===e?void 0:e.toUpperCase();return!r.isEmpty(n)&&!r.isEmpty(o)&&n.includes(o)}getColumnNames(){const i=[];return i.push(this.getMessage("snkGridConfig.tab.columns")),i.push(this.getMessage("snkGridConfig.tab.lineOrdering")),i.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let i={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};w.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,y.WARN,i).then((i=>{i?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(i){null!=(null==i?void 0:i.index)&&(this.selectedIndex!==i.index&&(0===i.index?this._orderList.scrollToTop():1===i.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===i.index&&this.createOrderList(),this.selectedIndex=i.index)}handleColumnListChange(i){var t;if(i.detail){let s=null===(t=i.detail.find((i=>i.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===t?void 0:t.items;s&&(this._dataChanged=!0,this._orderListItems=s)}}handleOrderListChange(i){if(i.detail){let t=i.detail;t&&(this._dataChanged=!0,this._orderPriorityList=t)}}componentWillRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.createColumnList()}componentDidRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentDidLoad(){f.addIDInfo(this._element)}render(){return t(s,null,t("div",{class:"grid-config__header"},t("div",{class:"title-container"},t("div",{class:""},t("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),t("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),t("div",{class:"button-close"},t("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),t("div",{class:"tabselector-container"},t("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:i=>{this.handleTabChange(i.detail)},tabs:this.getColumnNames()})),t("div",null,t("ez-text-input",{"data-element-id":"searchColums",ref:i=>this._searchElement=i,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:i=>this.locateColumn(i)},t("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),t("div",{class:"grid-config__main"},t("ez-list",{ref:i=>this._columnList=i,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:i=>this.handleColumnListChange(i),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(i,t)=>this.buildColumnListSlot(i,t),useGroups:!0,"data-element-id":"configCols"}),t("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),t("ez-list",{ref:i=>this._orderList=i,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:i=>this.handleOrderListChange(i),ezDraggable:!0,itemSlotBuilder:i=>this.buildOrderListSlot(i),"data-element-id":"configDataOrder"})),t("div",{class:"grid-config__footer"},t("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),t("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return e(this)}};B.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);--snk-grid-config__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-grid-config__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-grid-config__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-grid-config__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__scrollbar--width:var(--space--small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-snk-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-grid-config__scrollbar--color-clicked) var(--snk-grid-config__scrollbar--color-background);padding-right:var(--snk-grid-config__main--padding-right)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar{width:var(--snk-grid-config__scrollbar--width);max-width:var(--snk-grid-config__scrollbar--width);min-width:var(--snk-grid-config__scrollbar--width);background-color:var(--snk-grid-config__scrollbar--color-background)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-track{background-color:var(--snk-grid-config__scrollbar--color-background);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb{background-color:var(--snk-grid-config__scrollbar--color-default);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:hover,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-grid-config__scrollbar--color-hover)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:active,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-grid-config__scrollbar--color-clicked)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const G=class{constructor(t){i(this,t),this._formConfigFetcher=new p,this.layoutType=x.CASCADE}async save(){this._LayoutFormConfigSingleton.setConfig(this.layoutType),this._formConfigFetcher.saveLayoutFormConfig("formColCfg."+this._resourceID,{config:this.layoutType,newConfig:!0})}async componentWillLoad(){const i=o.getContextValue("__SNK__APPLICATION__");this._LayoutFormConfigSingleton=await(null==i?void 0:i.getLayoutFormConfig()),this._resourceID=await(null==i?void 0:i.getResourceID()),this.setLayoutInit()}setLayoutInit(){if(!this._LayoutFormConfigSingleton)return;const{config:i}=this._LayoutFormConfigSingleton;this.layoutType=Number(i)in x?Number(i):x.CASCADE}toggleLayout(i){this.layoutType=i}render(){return t("div",{class:"ez-flex ez-flex--column"},t("div",{class:"ez-margin-bottom--small"},t("ez-check",{label:"Layout em cascata",class:"ez-margin-bottom--small",onEzChange:()=>this.toggleLayout(x.CASCADE),value:this.layoutType===x.CASCADE}),t("snk-view-representation",{mode:x.CASCADE}),t("label",{class:"ez-label ez-margin--small ez-flex ez-text--medium"},"Todos os campos serão organizados em uma coluna única.")),t("div",null,t("ez-check",{label:"Layout lado a lado",class:"ez-margin-bottom--small",onEzChange:()=>this.toggleLayout(x.SIDE_BY_SIDE),value:this.layoutType===x.SIDE_BY_SIDE}),t("snk-view-representation",{mode:x.SIDE_BY_SIDE}),t("label",{class:"ez-label ez-margin--small ez-flex ez-text--medium"},"Todos os campos serão dispostos lado a lado, ajustando-se automaticamente à largura da tela.")))}};G.style=".sc-snk-layout-form-config-h{display:block}";const R=class{constructor(t){i(this,t),this.ezChange=n(this,"ezChange",7),this.selectedOption=b.none}render(){return t("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(b).map((i=>t("option",{value:b[i].value},b[i].label))))}static get assetsDirs(){return["../assets"]}};R.style="ez-combo-box{width:100px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const F=class{constructor(t){i(this,t),this.snkConfigSaved=n(this,"snkConfigSaved",7),this._formConfigFetcher=new p,this.fieldsToSave=[],this.dataUnit=void 0,this.configName=void 0,this.avaliableFields=[],this.selectedFields=[]}async show(){var i;await(null===(i=this.ezDoubleListRef)||void 0===i?void 0:i.resetSelectedLists()),await this.initializeFormConfig(),this.ezPopupRef.opened=!0}async initializeFormConfig(){if(!this.configName)return;const i=this.getAllVisibleFieldsFromDataUnit(),t=await this.getConfig();if(0===t.length)return this.avaliableFields=[],this.selectedFields=[...i],void(this.fieldsToSave=[...this.selectedFields]);const s=this.sortDisplayedFields(t,i),e=i.filter((i=>!t.includes(i.id)));this.avaliableFields=[...e],this.selectedFields=[...s],this.fieldsToSave=[...this.selectedFields]}async getConfig(){const i=await this._formConfigFetcher.fetchSimpleFormConfig(this.configName);return[...this.removeDuplicates(i)]}removeDuplicates(i){return i.filter(((t,s)=>i.indexOf(t)===s))}sortDisplayedFields(i,t){const s=[];return i.forEach((i=>{const e=t.find((t=>t.id===i));e&&s.push(e)})),s}getAllVisibleFieldsFromDataUnit(){var i,t,s;return(null!==(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.metadata)||void 0===t?void 0:t.fields)&&void 0!==s?s:[]).filter((i=>i.visible)).map((i=>({id:i.name,label:i.label})))}close(){this.ezPopupRef.opened=!1}async handleResetConfigs(){await this._formConfigFetcher.restoreFormConfig(this.configName),await this.initializeFormConfig(),await this.handleSave()}handleCancel(){this.close()}async handleSave(){const i=this.fieldsToSave.map((i=>i.id));await this._formConfigFetcher.saveSimpleFormConfig(this.configName,i),this.close(),this.snkConfigSaved.emit()}render(){return t("ez-popup",{ref:i=>this.ezPopupRef=i,heightMode:"auto",size:"auto",ezTitle:"Configurar formulário"},t("div",{class:"config-container"},t("div",{class:"config-lists"},t("ez-double-list",{ref:i=>this.ezDoubleListRef=i,leftList:this.avaliableFields,leftTitle:"Campos disponíveis",rightList:this.selectedFields,rightTitle:"Campos selecionados",onEzRightListChanged:({detail:i})=>this.fieldsToSave=[...i],entityLabel:"campo",entityLabelPlural:"campos"})),t("div",{class:"config-actions"},t("ez-button",{label:"Restaurar",onClick:this.handleResetConfigs.bind(this),size:"small"}),t("ez-button",{label:"Cancelar",onClick:this.handleCancel.bind(this),size:"small"}),t("ez-button",{label:"Salvar",class:"ez-button--primary",onClick:this.handleSave.bind(this),size:"small"}))))}};F.style=":host{display:block}.config-container{display:flex;flex-direction:column;align-items:center;justify-content:space-between}.config-lists{margin-bottom:12px}.config-actions{display:flex;flex-direction:row;justify-content:flex-end;width:100%;gap:12px}";const K=class{constructor(t){i(this,t),this.mode=x.SIDE_BY_SIDE}renderCascadeLayout(){return t("div",{class:"svg-container__collumn"},[...Array(3)].map((()=>t("div",{class:"svg-container__section"},t("div",{class:"svg-container__line svg-container__line--short"}),t("div",{class:"svg-container__line svg-container__line--long"})))))}renderSideBySideLayout(){return t("div",{class:"svg-container__inline"},[...Array(2)].map((()=>this.renderCascadeLayout())))}render(){return t("div",{class:"svg-container ez-margin-left--small"},t("div",{class:"svg-container__background"},t("div",{class:"svg-container__header"},t("div",{class:"svg-container__circle svg-container__circle--red"}),t("div",{class:"svg-container__circle svg-container__circle--yellow"}),t("div",{class:"svg-container__circle svg-container__circle--green"})),this.mode===x.CASCADE?this.renderCascadeLayout():this.renderSideBySideLayout()))}};K.style=".sc-snk-view-representation-h{display:block}.svg-container.sc-snk-view-representation{display:flex;width:185px;height:125px;border-radius:8px;background-color:#f7f7f7;padding:10px 12px;box-sizing:border-box;position:relative}.svg-container__background.sc-snk-view-representation{display:flex;flex-direction:column;width:100%}.svg-container__header.sc-snk-view-representation{display:flex;gap:2px;margin-bottom:12px}.svg-container__circle.sc-snk-view-representation{width:9px;height:9px;border-radius:50%}.svg-container__circle--red.sc-snk-view-representation{background-color:#ed7678}.svg-container__circle--yellow.sc-snk-view-representation{background-color:#eddb76}.svg-container__circle--green.sc-snk-view-representation{background-color:#7ad08e}.svg-container__section.sc-snk-view-representation{width:100%}.svg-container__collumn.sc-snk-view-representation{width:100%;display:flex;flex-direction:column}.svg-container__inline.sc-snk-view-representation{display:flex;flex-direction:row;gap:6px}.svg-container__line.sc-snk-view-representation{height:13px;border-radius:4px;background-color:#d9d9d9;margin-bottom:4px}.svg-container__line--short.sc-snk-view-representation{width:39.68px;height:7px;border-radius:3.5px}.svg-container__line--long.sc-snk-view-representation{width:100%}";const M=class{constructor(t){i(this,t),this.taskbarActionSelected=n(this,"taskbarActionSelected",7),this.taskbarActionsOpened=n(this,"taskbarActionsOpened",7),this.taskbarActionsButtonDisconnected=n(this,"taskbarActionsButtonDisconnected",7),this._showDropdown=!1,this.title=void 0,this.enabled=void 0,this.actions=void 0}async handleKeyDown(i){"Escape"!==i.key&&"Esc"!==i.key||await this.hideActions()}async handleClose(){await this.hideActions()}async showActions(){this._showDropdown=!0,requestAnimationFrame((()=>{this._element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}async hideActions(){this._showDropdown=!1}async isOpened(){return this._showDropdown}controlDropdown(){this._showDropdown=!this._showDropdown}loadItems(){return this.actions.filter((i=>void 0!==i)).map((i=>{var t;return{id:i.value,label:i.label,value:i.value,type:null!==(t=i.type)&&void 0!==t?t:"item",children:i.children,iconName:i.iconName,subAction:i.subAction,group:i.group,disableCloseOnSelect:i.disableCloseOnSelect}}))}canShowDropdown(){var i;return this._showDropdown&&(null===(i=this.actions)||void 0===i?void 0:i.length)>0}onSelectAction(i){const t=this.actions.map((i=>Object.assign(Object.assign({},i),{id:i.value}))),s=this.getSelectedAction(i.id,t);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(i,t){let s=null;for(const e of t){if(e.id===i){s=e;break}if((null==e?void 0:e.children)&&(s=this.getSelectedAction(i,e.children),s))break}return s}dropdownItemBuilder(i,s){const e=this.actions.find((t=>t.value===i.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?t("div",{innerHTML:n}):n}initializeEagerItems(){var i;null===(i=this.actions)||void 0===i||i.forEach((i=>{var t;i&&i.eagerInitialize&&i.itemBuilder&&(null===(t=i.itemBuilder)||void 0===t||t.call(i,this._element,i))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return t(s,null,t("div",{class:this.canShowDropdown()?" ez-elevation--16":""},t("ez-button",{title:this.title,mode:"icon",iconName:"dots-vertical",size:"small",enabled:this.enabled,onClick:()=>this.controlDropdown()}),this.canShowDropdown()&&t("ez-dropdown",{items:this.loadItems(),onEzClick:i=>this.onSelectAction(i.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(i,t)=>this.dropdownItemBuilder(i,t)})))}get _element(){return e(this)}};M.style=".sc-taskbar-actions-button-h{display:flex;width:fit-content;height:fit-content}";export{T as snk_actions_button,B as snk_grid_config,G as snk_layout_form_config,R as snk_select_box,F as snk_simple_form_config,K as snk_view_representation,M as taskbar_actions_button}
@@ -1,11 +0,0 @@
1
- import{r as t,c as i,h as e,H as s,g as n}from"./p-d2d301a6.js";import{DateUtils as r,StringUtils as a,ObjectUtils as o,WaitingChangeException as h,WarningException as c,ErrorException as l,KeyboardManager as d,OnboardingUtils as u,DependencyType as p,ArrayUtils as m,SearchUtils as g,ElementIDUtils as w,ApplicationContext as y,DataType as f,ErrorTracking as v,UserAgentUtils as z,LockManager as P,LockManagerOperation as _}from"@sankhyalabs/core";import{ApplicationUtils as k}from"@sankhyalabs/ezui/dist/collection/utils";import{C as A}from"./p-13f17dab.js";import{d as x,D as I,U as S}from"./p-5a7e18f4.js";import{A as T,a as C}from"./p-48729c8c.js";import{P as b,D as L}from"./p-7e0a0aae.js";import{P as N}from"./p-108fee57.js";import{S as E}from"./p-17425c72.js";import{T as D}from"./p-1d19a5b0.js";import"./p-0f3698af.js";import"./p-ff1990ad.js";import{F as O}from"./p-01512409.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class M{static webConnectionCaller(t,i,e){var s;null===(s=window.AppletCaller)||void 0===s||s.webConnectionCaller(t,i,e)}}const R=j;function j(t,i){const e=F();return(j=function(t){return e[t-=378]})(t,i)}function F(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(F=function(){return t})()}!function(){const t=j,i=F();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;i.push(i.shift())}catch(t){i.push(i.shift())}}();class U{[R(397)](t){const i=R;if(typeof(t=utxt(t[i(390)]))==i(392)&&(t=JSON[i(400)](t)),null==t)throw Error(i(395));const e=new $("S"===t[i(402)]||!0===t[i(402)]);return Array[i(394)](t[i(391)])&&t[i(391)][i(385)]((t=>e.putAccess(t[i(382)],String(t.status)==i(398)))),e}}class ${constructor(t){const i=R;this.isSup=t,this[i(384)]={}}[R(378)](t,i){this[R(384)][t]=i}[R(393)](t){const i=R;if(this[i(402)])return!0;let e=!0;return this[i(384)][i(380)](t)&&(e=this.actions[t]),e}isUserSup(){return this.isSup}}class q{constructor(){this._embeddedParams=new Map,this._cachedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[i,e]=t.split("__=__");this._embeddedParams.set(i,e)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",x.gql`query($name: String!) {
2
- $queryAlias$: fetchResource(name: $name){
3
- name
4
- resource
5
- }
6
- }`)}async getParam(t){if(this._embeddedParams.has(t))return Promise.resolve(this._embeddedParams.get(t));if(this._cachedParams.has(t))return this._cachedParams.get(t);const i=`param://application?params=${t}`,e=await I.get().callGraphQL({values:{name:i},query:this.templateByQuery.get("fetchParam")});return this._cachedParams.set(t,e),e}async asString(t){const i=await this.getParam(t);return this.getValue(i)}async asInteger(t){const i=await this.getParam(t);return parseInt(this.getValue(i))}async asFloat(t){const i=await this.getParam(t);return parseFloat(this.getValue(i))}async asBoolean(t){const i=await this.getParam(t);return"S"===this.getValue(i)}async asDate(t){const i=await this.getParam(t);return r.strToDate(this.getValue(i))}async getBatchParams(t){const i=await this.getParam(t.join(",")),e={};return i.forEach((t=>e[t.name]=t.resource)),e}getValue(t={}){if(Array.isArray(t)&&t.length>0&&(t=t[0]),"string"==typeof t)return t;if(a.isEmpty(t.resource))return"";try{const i=o.stringToObject(t.resource),[e]=Object.keys(i);return i[e]}catch(t){console.warn("Erro ao converter string JSON.")}}}class B{constructor(){this.templateByQuery=new Map,this.cancel=[],this.buildTemplates()}buildTemplates(){this.templateByQuery.set("fetchTotals",x.gql`query($filters: [InputFilter!] $name: String!) {
7
- $queryAlias$: fetchTotals(name: $name, filters: $filters ){
8
- name
9
- value
10
- }
11
- }`)}fetchTotals(t,i,e=[]){const s=`${t}_${i}`,n=this.cancel.findIndex((t=>t[s]));return n>=0&&(this.cancel[n][s](),this.cancel.splice(n,1)),Promise.race([new Promise((t=>this.cancel.push({[s]:t}))),this.getTotals(t,i,e)]).then((t=>{let i=new Map;if(t){i=t;const e=this.cancel.findIndex((t=>t[s]));e>=0&&this.cancel.splice(e,1)}return i}))}getTotals(t,i,e=[]){return new Promise(((s,n)=>{I.get().callGraphQL({query:this.templateByQuery.get("fetchTotals"),values:{name:`totals://${t}/${i}`,filters:e}}).then((t=>{if(t.length>0){const i=new Map;return t.forEach((t=>i.set(t.name,parseFloat(t.value)))),s(i)}return n("Não foi possível recuperar os totalizadores")})).catch(n)}))}}function H(){const t=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(H=function(){return t})()}const K=V;function V(t,i){const e=H();return(V=function(t){return e[t-=392]})(t,i)}!function(){const t=V,i=H();for(;;)try{if(951926==-parseInt(t(398))/1+-parseInt(t(393))/2+parseInt(t(395))/3+-parseInt(t(400))/4*(parseInt(t(392))/5)+-parseInt(t(401))/6*(-parseInt(t(402))/7)+parseInt(t(397))/8+-parseInt(t(399))/9*(-parseInt(t(394))/10))break;i.push(i.shift())}catch(t){i.push(i.shift())}}();const W=K(396);var G;class J{static openAppActivity(t,i){var e;null===(e=window.workspace)||void 0===e||e.openAppActivity(t,i)}static getAppLabel(t){if(null!=(null===window||void 0===window?void 0:window.workspace))return null==window.workspace.getAppLabel&&(window.workspace.getAppLabel=t=>(t||"").split(".").pop()),window.workspace.getAppLabel(t)}static setScreenToUseV3Layout(){var t;null===(t=window.workspace)||void 0===t||t.setScreenToUseV3Layout()}static setScreenToUseOldLayout(){var t;null===(t=window.workspace)||void 0===t||t.setScreenToUseOldLayout()}static showDesktop(){var t,i;null===(i=null===(t=window.workspace)||void 0===t?void 0:t.showDesktop)||void 0===i||i.call(t)}static searchApp(){var t,i;null===(i=null===(t=window.workspace)||void 0===t?void 0:t.searchApp)||void 0===i||i.call(t)}static openHelp(){var t,i;null===(i=null===(t=window.workspace)||void 0===t?void 0:t.openHelp)||void 0===i||i.call(t)}static applicationClick(){var t,i;(null===(t=window.workspace)||void 0===t?void 0:t.applicationClick)&&(null===(i=window.workspace)||void 0===i||i.applicationClick())}}J.resourceID=null===(G=window.workspace)||void 0===G?void 0:G.resourceID;class Y{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}rejectionHandler(t){const i=t.reason;i instanceof h||(i?this.processException(i):this._app.isDebugMode().then((t=>{t&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(t){this.processException(t.error)}buildErrorCodeHTML(t){return'<br><a href="#" onclick="try{window.workspace.openHelp(\'_tbcode:'+t+"')} catch(e){alert('Não é possível abrir a ajuda fora do workspace Sankhya');}\">Código: "+t+"</a>"}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t.errorCode)),t instanceof h||t instanceof c?this._app.alert(t.title,t.message):t instanceof l?this._app.error(t.title,t.message):this._app.isDebugMode().then((i=>{if(i)if(t instanceof Error)this._app.error(t.name,t.message);else{const i=(null==t?void 0:t.title)||"Erro detectado",e="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(i,e)}}))}}class X{constructor(){this._debounceTime=1500,this.requests=new Map,this.requestsLoadingBar=[]}onRequestStart(t){if(t.url.includes("quietMode=true"))return;this.requestsLoadingBar.push(t.requestId);const i=setTimeout((()=>{this.ezLoadingBar.show()}),this._debounceTime);this.requests.set(t.requestId,i)}onRequestEnd(t){var i,e,s;const n=this.requests.get(t.requestId);clearTimeout(n),(null===(i=this.requestsLoadingBar)||void 0===i?void 0:i.includes(t.requestId))&&(this.requestsLoadingBar=null===(e=this.requestsLoadingBar)||void 0===e?void 0:e.filter((i=>i!==t.requestId)),!this.requestsLoadingBar.length&&(null===(s=this.ezLoadingBar)||void 0===s||s.hide()))}}class Z{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.ezLoadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.ezLoadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){if(null==t)return!1;if(t.url.includes("quietMode=true"))return!0;if(null==t.requestBody)return!1;if(1==t.requestBody.length){const{name:i}=t.requestBody[0].variables;if(i){const t=i.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class Q{static create({strategy:t}){switch(t){case"request_name":return new Z;case"request_time":return new X;default:throw new Error("Strategy not found")}}}class tt{constructor(){this._config=null,this.listeners=[]}static getInstance(){return tt.instance||(tt.instance=new tt),tt.instance}get config(){return this._config}setConfig(t){this._config=t,this.notifyListeners()}onConfigChange(t){this.listeners.push(t)}notifyListeners(){this.listeners.forEach((t=>t(this._config)))}}const it=class{constructor(e){t(this,e),this.applicationLoaded=i(this,"applicationLoaded",7),this.applicationLoading=i(this,"applicationLoading",7),this.NEW_VERSION_POPUP_LOCKER="NEW_VERSION_POPUP_LOCKER",this._authPromises=[],this._keyboardManager=new d,this._waitingAppReady=new Array,this._duCache=new Map,this._duPromises=new Map,this._requestListener=Q.create({strategy:"request_time"}),this._maxTimerAppLoading=1e4,this._isBrowserTypeElectron=!1,this._pendingActions=new Map,this._loadPkParameter=null,this._isLoadedByPk=!1,this._formConfigFetcher=new O,this._LayoutFormConfigSingleton=tt.getInstance(),this._applicationReady=!1,this._templateSkeleton=D.GRID,this._activeScrimWindow=!1,this.enableLockManagerLoadingApp=void 0,this.messagesBuilder=void 0,this.configName=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.loadByPK=void 0}async processPendingActions(t){const i=this._pendingActions.get(t);i&&i.length&&(i.forEach((t=>t())),this._pendingActions.set(t,[]))}get parameters(){return this._parameters||(this._parameters=new q),this._parameters}async getAuth(t){return null==t?this.getApplicationAuth():new Promise(((i,e)=>{this.authFetcher.getData(t).then((t=>{i(t)})).catch((t=>{e(t)}))}))}async getApplicationAuth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,i)=>{const e=this._authPromises.length>0;this._authPromises.push(new et(t,i)),e||this.authFetcher.getData(this.applicationResourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}watchPropHandler(t,i){t&&this._loadPkParameter&&(this.loadByPK(this._loadPkParameter.pk,this._loadPkParameter.redirect),this._loadPkParameter=null)}async getKeyboardManager(){return Promise.resolve(this._keyboardManager)}async getLayoutFormConfig(){return Promise.resolve(this._LayoutFormConfigSingleton)}async isUserSup(){return new Promise(((t,i)=>{this.getAuth().then((e=>{this.getAuthList(e).then((i=>{t(i.isSup)})).catch((t=>i(t)))}))}))}async addPendingAction(t,i){var e;const s=null!==(e=this._pendingActions.get(t))&&void 0!==e?e:[];this._pendingActions.set(t,[...s,i])}async callServiceBroker(t,i,e){return I.get().callServiceBroker(t,i,e)}async initOnboarding(t){this.hasToShowNewVersionPopup()?await this.addPendingAction(this.NEW_VERSION_POPUP_LOCKER,(()=>this.doInitOnboarding(t))):this.doInitOnboarding(t)}doInitOnboarding(t){u.getInstance().init(t,window.envContext)}async hasAccess(t,i){return new Promise(((e,s)=>{this.getAuth(i).then((i=>{this.getAuthList(i).then((i=>{e(i.isSup||i.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(t){return new Promise(((i,e)=>{this.getAuth(t).then((t=>{this.getAuthList(t).then((t=>{const e={};e.isSup=t.isSup,Object.entries(T).forEach((i=>{e[i[0]]=i[1]===T.CLONE?t.actions[T.INSERT]&&t.actions[T.CLONE]||!1:t.actions[i[1]]||!1})),i(e)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,i="full",e=!0,s){this.clearContent(this._popUp),this._popUp.addEventListener("ezClosePopup",(()=>{s()}),{once:!0}),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=i,this._popUp.useHeader=e,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}showAlerts(t){return k.showAlerts({alerts:t})}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const i=t.split(",");return new Promise(((t,e)=>{this.getAttributeFromHTMLWrapper("opc0009").then((s=>{"1"===s?t(!0):Promise.all(i.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((i=>{t(i.includes("1"))})).catch((t=>{e(t)}))})).catch((t=>{e(t)}))}))}async getConfig(t){let i={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,e)=>{I.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(i)).then((i=>{var e;return t(null===(e=i.config)||void 0===e?void 0:e.data)})).catch((t=>e(t)))}))}async saveConfig(t,i){let e={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:i}}};return new Promise(((t,i)=>{I.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(e)).then((i=>t(i))).catch((t=>i(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,i){J.openAppActivity(t,i)}async webConnection(t,i,e){this.getStringParam(t).then((t=>{M.webConnectionCaller(t,i,e)}))}getDuPromissesStack(t){let i;return t&&(i=this._duPromises.get(t),i||(i=[],this._duPromises.set(t,i))),i||[]}async createDataunit(t,i,e,s,n){return null==n&&(n=this.applicationResourceID),new Promise(((r,a)=>{const o=this.getDuPromissesStack(i),h=o.length>0;if(o.push(new et(r,a)),!h){const r=this.dataUnitFetcher.getDataUnit(t,n,e,s);r.loadMetadata().then((()=>{this.processResolveDataUnit(r,i,o)})).catch((t=>{for(;o.length>0;)o.pop().reject(t)}))}}))}processResolveDataUnit(t,i,e){for(i&&this.updateDataunitCache(void 0,i,t);e.length>0;)e.pop().resolve(t)}async updateDataunitCache(t,i,e){t&&this._duCache.delete(t),this._duCache.set(i,e)}async getDataUnit(t,i,e,s,n){return new Promise(((r,a)=>{const o=this._duCache.get(i);o?r(o):this.createDataunit(t,i,e,s,n).then((t=>{r(t)})).catch((t=>a(t)))}))}async addClientEvent(t,i){return new Promise((e=>{I.addClientEvent(t,i),e()}))}async removeClientEvent(t){return new Promise((i=>{I.removeClientEvent(t),i()}))}async hasClientEvent(t){return new Promise((i=>{i(I.hasClientEvent(t))}))}get applicationResourceID(){return this._applicationResourceID||(this._applicationResourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||J.resourceID||"unknown.resource.id"),this._applicationResourceID}async getResourceID(){return Promise.resolve(this.applicationResourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,i,e,s){return k.alert(t,i,e,s)}async error(t,i,e,s){return k.error(t,i,e,s)}async success(t,i,e,s){return k.success(t,i,e,s)}async message(t,i,e,s){return k.message(t,i,e,s)}async confirm(t,i,e,s,n){return k.confirm(t,i,e,s,n)}async info(t,i){return k.info(t,i)}async loadTotals(t,i,e){return this.totalsFetcher.fetchTotals(t,i,e)}async isLoadedByPk(){return Promise.resolve(this._isLoadedByPk)}async preloadMangerRemoveRecord(t,i){const e=i.map((t=>({__record__id__:t})));b.removeRecords(t,e)}getCountSkeleton(t,i,e){e=e||160;const s=window.innerHeight-e;return Math.floor(s/(t+(i||10)))-1||1}getSkeletonRandomWidth(){return`${Math.floor(71*Math.random())+30}%`}async getAuthList(t){return await(new U).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=S.getQueryParams(location.search)),this._urlParams}getMessage(t,i){var e;return null===(e=this.messagesBuilder)||void 0===e?void 0:e.getMessage(t,i)}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new L),this._dataUnitFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new B),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new N),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new C),this._authFetcher}async executeSearch(t,i,e,s){const n=null==e?void 0:e.getField(i);if(n){const{mode:i,argument:r}=t,{ENTITYNAME:a,CODEFIELD:o,DESCRIPTIONFIELD:h,ROOTENTITY:c,DESCRIPTIONENTITY:l,ISHIERARCHYENTITY:d}=n.properties,u=n.dependencies;let m;const g={rootEntity:c,descriptionFieldName:h,codeFieldName:o,showInactives:!1,dataUnitId:e.dataUnitId};return null==u||u.filter((t=>t.masterFields)).forEach((t=>{var i;t.type===p.SEARCHING&&(null===(i=t.masterFields)||void 0===i?void 0:i.length)>0&&(m={expression:t.expression,params:t.masterFields.map((t=>{const i=e.getField(t),s=(null==i?void 0:i.dataType)||f.TEXT,n=e.getFieldValue(t);if(null==n)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${i.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${i.label} para executar a pesquisa.`);return{name:t,value:n,dataType:s}}))})})),this.executePreparedSearch(i,r,{entity:a,entityDescription:l,isHierarchyEntity:d,criteria:m,searchOptions:g,allowsNonAnalytic:null==s?void 0:s.allowsNonAnalytic})}}filterInvalidFields(t,i,e){return t.fieldsMetadata.filter((s=>{let n=!a.isEmpty(i[s.fieldName])&&!1!==s.visible&&"B"!==s.type&&t.pkField!==s.fieldName&&t.descriptionField!==s.fieldName&&(s.isPrimaryKey||!s.isLinkField)&&!("S"===s.type&&"H"===s.presentationType);return n&&(e[s.fieldName]=s),("string"!=typeof i[s.fieldName]||!(i[s.fieldName].indexOf("<img")>-1||i[s.fieldName].indexOf("<svg")>-1))&&n}))}filterMathFields(t,i,e,s){return t&&Array.isArray(t)&&t.forEach((t=>{let e=m.removeReference(i,s[t]);e&&i.unshift(e)})),i=i.slice(0,e)}builOptionItem(t,i,e,s,n){var r;return{value:a.highlightValue(t,i.__matchFields,null===(r=i[n])||void 0===r?void 0:r.toString(),e,!0),label:s?a.highlightValue(t,i.__matchFields,i[s],e,!0):"",details:g.buildDetails(t,e,i)}}async executePreparedSearch(t,i,e){const s={},{entity:n,entityDescription:r,criteria:a,searchOptions:h,isHierarchyEntity:c,allowsNonAnalytic:l}=e;return new Promise("ADVANCED"===t?(t,e)=>{const s=document.createElement("snk-pesquisa");s[w.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${n}`,s.entityName=n,s.argument=i,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(n,t,a,h),s.isHierarchyEntity=c,c&&(s.treeLoader=t=>this.pesquisaFetcher.loadTree(n,t,a,h),s.allowsNonAnalytic=l),s.selectItem=i=>{t(i),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s,void 0,void 0,e)}:(t,e)=>{this.pesquisaFetcher.loadAdvancedSearch(n,i,a,h).then((e=>{let n=(e=o.stringToObject(e.json.$)).descriptionField,r=e.pkField;const a=[];e.data.forEach((t=>{let o=this.filterInvalidFields(e,t,s),h=this.filterMathFields(t.__matchFields,o,6,s);a.push(this.builOptionItem(i,t,h,n,r))})),t(a)})).catch((t=>{e(t)}))})}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return J.getAppLabel(this.applicationResourceID)}addSearchListener(t,i,e){return new Promise((s=>{s(this.pesquisaFetcher.addSearchListener(t,i.dataUnitId,e))}))}importScript(t){return new Promise((i=>{this.getApplicationPath().then((e=>{let s=[];Array.isArray(t)||(s=[t]),s.forEach((t=>{const i=document.createElement("script");i.src=`${e}/${t}`,i.async=!0,document.body.appendChild(i)})),i()}))}))}async getApplicationPath(){return new Promise((t=>{"dev"===window.applicationenv?t(""):t(`/${this.getModuleName()}/labsApps/${window.APPLICATION_NAME}/build`)}))}getModuleName(){return window.MGE_MODULE_NAME||"mgefin-bff"}executeSelectDistinct(t,i,e){return this.dataUnitFetcher.loadSelectDistinct(t,i,e)}getDataFetcher(){return Promise.resolve(I.get())}async whenApplicationReady(){return y.getContextValue("__SNK__APPLICATION__LOADING__")?Promise.resolve(this):new Promise((t=>{this._waitingAppReady.push((()=>t(this)))}))}async setSearchFilterContext(t,i){y.setContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${t})__`,i)}clearContent(t){t&&Array.from(t.children).forEach((i=>{t.removeChild(i)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}async pkChangeListener(){const t=top.window.location.hash.split("/")[2];if(this._currentPkParameter===t)return;const i=this.getResourceIdFromToken(),e=S.getPkObjectFromUrlToken(top.window.location.hash),s=window.redirectFrom;if(void 0===e)return;if((!s||-1===s.split("_")[0].indexOf(i.split("_")[0]))&&i!==this.applicationResourceID)return;const n={pk:e};if(this._isLoadedByPk=!0,this.loadByPK)return this.loadByPK(n,s),void(this._currentPkParameter=t);this._loadPkParameter={pk:n,redirect:s},this.defaultLoadByPK(n,t)}getResourceIdFromToken(){return top.window.location.pathname.indexOf("tabContent.jsp")>-1?S.getResourceIdFromUrlToken(window.location.generateHash(window.location.hash)):S.getResourceIdFromUrlToken(top.window.location.hash)}defaultLoadByPK(t,i){if(!(null==t?void 0:t.pk))return;const e=this.getFirstDataUnitFromDOM(),s=e.dataUnit;if(!s)return console.warn("Dataunit não inicializado"),void e.addEventListener("dataUnitReady",(e=>{this.loadDataWithPKFilter(t,e.detail),this._currentPkParameter=i}));this.loadDataWithPKFilter(t,s),this._currentPkParameter=i}loadDataWithPKFilter(t,i){const e={term:"",filter:{name:"LOAD_BY_PK_FILTER",expression:this.buildFilterExpressionByPkObject(t),params:this.getFilterParamsFromPkObject(t,i)}};i.loadData(e)}getFirstDataUnitFromDOM(){let t=this._element.querySelector("snk-data-unit[data-load-by-pk]");if(t||(t=this._element.querySelector("snk-data-unit")),t)return t}getFilterParamsFromPkObject(t,i){var e;const s=[];for(const n in t.pk)t.pk.hasOwnProperty(n)&&!Array.isArray(t.pk[n])&&s.push({name:n,dataType:(null===(e=i.getField(n))||void 0===e?void 0:e.dataType)||this.getDefaultDataTypeLoadByPK(t.pk[n]),value:t.pk[n]});return s}getDefaultDataTypeLoadByPK(t){return"number"==typeof t||t instanceof Number?f.NUMBER:"boolean"==typeof t||t instanceof Boolean?f.BOOLEAN:t instanceof Date?f.DATE:f.TEXT}buildFilterExpressionByPkObject(t){let i="";for(const e in t.pk)a.isEmpty(i)||(i+=" AND "),Array.isArray(t.pk[e])?i+=`${e} IN (${t.pk[e].toString()})`:i+=`${e} = :${e}`;return i}async showNewVersionPopup(){const t=document.createElement("ez-modal-container"),i=await this.getAppLabel();t.modalTitle=this.getMessage("snkApplication.newVersionPopup.title",{screenName:i}),t.okButtonLabel=this.getMessage("snkApplication.newVersionPopup.okButton"),t.cancelButtonLabel=this.getMessage("snkApplication.newVersionPopup.cancelButton");const e=document.createElement("p");e.innerText=this.getMessage("snkApplication.newVersionPopup.info"),e.className="ez-text",t.appendChild(e),t.addEventListener("ezModalAction",this.newVersionPopupEventListener.bind(this));const s=await k.showPopup({content:t});this._removeVersionLayoutPopup=async()=>{await s(),await this.processPendingActions(this.NEW_VERSION_POPUP_LOCKER)}}async newVersionPopupEventListener(t){"LOAD"!==t.detail&&("OK"===t.detail&&J.setScreenToUseV3Layout(),"CANCEL"===t.detail&&J.setScreenToUseOldLayout(),this._popUp.opened=!1,this._removeVersionLayoutPopup&&await this._removeVersionLayoutPopup())}async handleShowNewVersionPopup(){this.hasToShowNewVersionPopup()&&await this.showNewVersionPopup()}hasToShowNewVersionPopup(){const t=new URLSearchParams(window.location.search).get("firstLoadConv");return t&&"S"===t}registerPkChangeListener(){window.hasOwnProperty("onhashchange")?window.onhashchange=this.pkChangeListener.bind(this):setInterval(this.pkChangeListener.bind(this),100)}componentWillLoad(){y.setContextValue("__SNK__APPLICATION__LOADING__",!0),this._errorHandler=new Y(this),this.messagesBuilder=new E,y.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${S.getUrlBase()}/mge/upload/file`),y.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,i,e,s)=>this.executeSearch(t,i,e,s))),y.setContextValue("__EZUI__GRID_LICENSE__",W),this.registerPkChangeListener(),v.init(),A.preload(this.applicationResourceID,this.configName,{gridLegacyConfig:this.gridLegacyConfigName,formLegacyConfig:this.formLegacyConfigName}),document.addEventListener("click",(()=>J.applicationClick())),this._waitingAppReady.forEach((t=>t())),this.setLayoutFormConfig()}async setLayoutFormConfig(){const t=await this._formConfigFetcher.fetchLayoutFormConfig("formColCfg."+this.applicationResourceID),i=isNaN(Number(null==t?void 0:t.config))?null:Number(null==t?void 0:t.config);this._LayoutFormConfigSingleton.setConfig(i)}connectedCallback(){this._isBrowserTypeElectron=z.isElectron(),y.setContextValue("__SNK__APPLICATION__",this),I.addRequestListener(this._requestListener)}disconnectedCallback(){null==I||I.removeRequestListener(this._requestListener),this.removeShortcuts(),this._lockManagerTimer&&clearTimeout(this._lockManagerTimer),this._scrimWindowTimer&&clearTimeout(this._scrimWindowTimer)}async componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{y.setContextValue("__SNK__APPLICATION__LOADING__",!1),this.applicationLoaded.emit(!0),this.pkChangeListener()})),w.addIDInfo(this._element,`resource_${this.applicationResourceID}`),await this.handleShowNewVersionPopup(),this.initKeyboardManager(),this.enableLockManagerLoadingApp?(P.addLockManagerCtxId(this._element),this.resolveApplicationReady()):this._applicationReady=!0}async showScrimApp(t){if(!this.enableLockManagerLoadingApp||!this._applicationReady||!t)return this._activeScrimWindow=!1,void(this._scrimWindowTimer&&clearTimeout(this._scrimWindowTimer));this._activeScrimWindow=!0,this._scrimWindowTimer=setTimeout((async()=>{this._activeScrimWindow&&(this._activeScrimWindow=!1,clearTimeout(this._scrimWindowTimer))}),this._maxTimerAppLoading)}async changeTemplateSkeleton(t){this._templateSkeleton=t||this._templateSkeleton}async markToReload(t){this.enableLockManagerLoadingApp&&(await this.changeTemplateSkeleton(t),this._applicationReady=!1,await P.resetLocks(this._element,_.APP_LOADING),this.resolveApplicationReady())}async addLoadingLock(t=!1,i){if(this.enableLockManagerLoadingApp)return await this.changeTemplateSkeleton(i),t&&(this._applicationReady=!1,this._activeScrimWindow=!!this._applicationReady,await P.resetLocks(this._element,_.APP_LOADING)),this.resolveApplicationReady(),await P.lock(this._element,_.APP_LOADING)}async resolveApplicationReady(){if(!this._applicationReady)try{await this.checkTimeoutLimitLockManager(),await P.whenHasLock(this._element,_.APP_LOADING),await P.whenResolve(this._element,_.APP_LOADING,200),await P.resetLocks(this._element,_.APP_LOADING),this._applicationReady=!0}catch(t){console.warn(t),this._applicationReady=!0}}stopTimeoutLockManager(){this._lockManagerTimer&&clearTimeout(this._lockManagerTimer)}async checkTimeoutLimitLockManager(){this.stopTimeoutLockManager(),this._applicationReady||(this._lockManagerTimer=setTimeout((async()=>{this._applicationReady||(await P.resetLocks(this._element,_.APP_LOADING),this.stopTimeoutLockManager(),this._applicationReady=!0)}),this._maxTimerAppLoading))}initKeyboardManager(){this._keyboardManager.bind("ctrl + g",J.searchApp.bind(this),{description:"Pesquisar por telas"}).bind("ctrl + d",J.showDesktop.bind(this),{description:"Mostrar o desktop"}).bind("F1",J.openHelp.bind(this),{description:"Abrir ajuda"})}removeShortcuts(){this._keyboardManager.unbind("ctrl + g").unbind("ctrl + d").unbind("F1")}renderLoadingSkeleton(){if(this.enableLockManagerLoadingApp){if(this._isBrowserTypeElectron)return this.getSpinnerLoadingDefault();switch(this._templateSkeleton){case D.CUSTOM_TEMPLATE:case D.GRID:return this.getSkeletonTemplateGrid();case D.GRID_WITH_SIDEBAR:return this.getSkeletonTemplateGridWithSidebar();case D.GRID_WITH_PANEL:return this.getSkeletonTemplateGridWithPanel();case D.FORM_WITH_SIDEBAR:return this.getSkeletonTemplateFormWithSidebar();default:return this.getSkeletonTemplateGrid()}}}getLoadingVisibilityStyle(){return{visibility:this._applicationReady?"hidden":"initial",display:this._applicationReady?"none":"unset"}}getSkeletonTemplateGrid(){return e("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},e("div",{class:"ez-flex ez-flex--column ez-margin--large ez-margin-top--medium"},e("div",{class:"ez-margin-bottom--medium"},e("ez-skeleton",{count:1,variant:"rect",width:"20%",height:"35px",animation:"progress"})),e("div",{class:""},e("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"}))),e("div",{class:"ez-flex ez-flex--justify-start skeleton-content-column ez-margin-horizontal--large",style:{height:"calc(-105px + 100vh)"}},[1,2,3,4].map(((t,i)=>e("div",{class:"ez-margin-right--large",key:i,style:{width:"25%"}},e("ez-skeleton",{count:this.getCountSkeleton(50,10),variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))))}getSkeletonTemplateGridWithSidebar(){return e("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},e("div",{class:"ez-flex ez-flex--column ez-margin--large ez-margin-top--medium"},e("div",{class:"ez-margin-bottom--medium"},e("ez-skeleton",{count:1,variant:"rect",width:"20%",height:"35px",animation:"progress"})),e("div",{class:""},e("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"}))),e("div",{class:"ez-flex ez-flex--justify-start skeleton-content-column ez-margin-horizontal--large",style:{height:"calc(100vh - 160px)"}},e("div",{class:"ez-flex ez-flex--column ez-margin-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(30,6)).fill(null).map(((t,i)=>e("ez-skeleton",{key:i,count:1,variant:"rect",width:this.getSkeletonRandomWidth(),height:"30px",animation:"progress",marginBottom:"10px"})))),e("div",{class:"ez-margin-right--large",style:{width:"75%"}},e("ez-skeleton",{count:this.getCountSkeleton(50,10),variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))}getSkeletonTemplateGridWithPanel(){return e("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},e("div",{class:"ez-margin--medium ez-margin-top--medium ez-padding--medium"},e("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"})),e("div",{class:"ez-flex ez-margin--medium ez-margin-top--medium",style:{maxHeight:"calc(-105px + 100vh)",overflow:"hidden"}},e("div",{class:"",style:{width:"70%",overflow:"hidden"}},e("div",{class:"ez-padding--medium",style:{height:"50%"}},e("ez-skeleton",{count:1,variant:"rect",width:"100%",height:"100%",animation:"progress"})),e("div",{class:"ez-padding--medium",style:{}},e("ez-skeleton",{count:1,variant:"rect",width:"250px",height:"25px",animation:"progress"})),e("div",{class:"ez-flex ez-padding--medium",style:{height:"45%"}},[1,2].map((()=>e("div",{style:{width:"50%"}},e("ez-skeleton",{count:1,variant:"rect",width:"100%",height:"100%",animation:"progress"})))))),e("div",{class:"ez-flex ez-flex--column ez-padding--medium",style:{width:"30%",overflow:"hidden"}},Array(this.getCountSkeleton(30,10)).fill(null).map(((t,i)=>e("ez-skeleton",{key:i,count:1,variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))))}getSkeletonTemplateFormWithSidebar(){return e("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},e("div",{class:"ez-margin--medium ez-margin-top--medium ez-padding--medium"},e("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"})),e("div",{class:"ez-flex ez-margin--medium ez-margin-top--medium",style:{maxHeight:"calc(-105px + 100vh)",overflow:"hidden"}},e("div",{class:"ez-flex ez-flex--column ez-margin-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(30,6)).fill(null).map(((t,i)=>e("ez-skeleton",{key:i,count:1,variant:"rect",width:this.getSkeletonRandomWidth(),height:"30px",animation:"progress",marginBottom:"10px"})))),e("div",{class:"ez-flex ez-flex--column",style:{width:"75%"}},e("div",{class:"ez-padding--medium",style:{width:"100%"}},e("ez-skeleton",{count:1,variant:"rect",width:"30%",height:"25px",animation:"progress"})),e("div",{class:"ez-padding--medium",style:{height:"45%"}},e("div",{class:"ez-flex",style:{width:"100%",height:"100%"}},[1,2,3,4].map(((t,i)=>e("div",{key:i,class:"ez-padding-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(50,20)).fill(null).map(((t,i)=>e("ez-skeleton",{key:i,count:1,variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"})))))))),e("div",{class:"ez-padding--medium",style:{width:"100%"}},e("ez-skeleton",{count:1,variant:"rect",width:"30%",height:"25px",animation:"progress"})),e("div",{class:"ez-padding--medium",style:{height:"45%"}},e("div",{class:"ez-flex",style:{width:"100%",height:"100%"}},[1,2,3,4].map(((t,i)=>e("div",{key:i,class:"ez-padding-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(50,20)).fill(null).map(((t,i)=>e("ez-skeleton",{key:i,count:1,variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"})))))))))))}getSpinnerLoadingDefault(){return e("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},e("div",{class:"ez-flex ez-size-height--full ez-size-width--full ez-flex--justify-center ez-flex--align-items-center spinner"},e("ez-icon",{iconName:"sync",size:"x-large",class:"spin"}),e("span",{class:"ez-title ez-title--secondary ez-title--extra-large"},"Carregando...")))}render(){return e(s,{style:{visibility:!this.enableLockManagerLoadingApp||this._applicationReady?"unset":"hidden",overflow:!this.enableLockManagerLoadingApp||this._applicationReady?"unset":"hidden"}},e("div",null,e("ez-loading-bar",{ref:t=>this._requestListener.ezLoadingBar=t}),e("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),e("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}),this.renderLoadingSkeleton(),this._activeScrimWindow&&e("div",{class:"ez-scrim ez-scrim--light",style:{cursor:"progress",zIndex:"var(--scrim-z-index)"}})))}get _element(){return n(this)}static get watchers(){return{loadByPK:["watchPropHandler"]}}};class et{constructor(t,i){this.resolve=t,this.reject=i}}it.style=".sc-snk-application-h{--scrim-z-index:var(--elevation--100, 100);display:flex;flex-direction:column;height:100%}.sc-snk-application-h>.loading-hidden.sc-snk-application{display:none;pointer-events:none}.skeleton-content-left.sc-snk-application{width:300px;padding-right:5px}.skeleton-content.sc-snk-application{height:calc(100vh - 310px)}.spinner.sc-snk-application{height:100vh;gap:10px}.spinner.sc-snk-application>.spin.sc-snk-application{animation-name:spin;animation-duration:5000ms;animation-iteration-count:infinite;animation-timing-function:linear}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}";export{it as snk_application}
@@ -1 +0,0 @@
1
- import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{StringUtils as n,ApplicationContext as o,ObjectUtils as h,DataType as a,UserInterface as r,JSUtils as d,FloatingManager as l,KeyboardManager as u,ElementIDUtils as c}from"@sankhyalabs/core";import{CSSVarsUtils as m}from"@sankhyalabs/ezui/dist/collection/utils";import{V as p,S as f}from"./p-1d19a5b0.js";import{T as g}from"./p-3fc82614.js";import"./p-5a7e18f4.js";import"./p-108fee57.js";import{S as v,R as C,b,a as k,c as S}from"./p-35fcf37e.js";import{P as y}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as w}from"./p-7e0a0aae.js";import"./p-ff1990ad.js";import{F as E}from"./p-01512409.js";import{T as _,b as T,o as I}from"./p-23736d75.js";import{C as F}from"./p-13f17dab.js";import{S as R}from"./p-cb9d725a.js";import{s as z}from"./p-6dc031de.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"./p-7dd49d15.js";import"./p-8f3f2306.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const M=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],D=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],O=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this._multiSelectionListDataSource=new v,this._keyDownHandler=i=>this.keyDownListener(i),this._formConfigFetcher=new E,this._customEditors=new Map,this._customRenders=new Map,this._taskbarProcessor=new _({"snkSimpleCrudTaskbar.form_regular":this.getButtons(!1,[g.GRID_MODE],!0),"snkSimpleCrudTaskbar.grid_regular":this.getButtons(!1,[g.DATA_EXPORTER,g.FORM_MODE]),"snkSimpleCrudTaskbar.form_selected":this.getButtons(!0,[g.GRID_MODE],!0),"snkSimpleCrudTaskbar.grid_selected":this.getButtons(!0,[g.DATA_EXPORTER,g.FORM_MODE]),"snkSimpleCrudTaskbar.finish_edition":this.getFinishEditionButtonsCallback.bind(this)}),this._showPopUpGridConfig=!1,this._currentViewMode=p.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${n.generateUUID()}`,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=f.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.enableContinuousInsert=!1,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.enableGridInsert=!1,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.layoutFormConfig=!1,this.autoLoad=void 0,this.outlineMode=!1}async addCustomEditor(i,t){if(this._grid&&this._form)return this._grid.addCustomEditor(i,t),void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._grid)return void this._grid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}handleResourceIDChanged(i,t){n.isEmpty(i)||i!==t&&(this.loadFormConfig(!0),this.loadGridConfig(!0))}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){const e=new Map(this._fieldsProps),n=this._fieldsProps.get(i);e.set(i,Object.assign(Object.assign({},n),{[t]:s})),this._fieldsProps=e}getFinishEditionButtonsCallback(){const i=["CANCEL","SAVE"];return this.enableGridInsert&&this._currentViewMode!==p.ATTACHMENT&&i.push(this._currentViewMode===p.GRID?g.FORM_MODE:g.GRID_MODE),i}getButtons(i,t,s){let e=i?D:M;return s&&(e=e.filter((i=>i!==g.REFRESH))),this.addConfigButton(this.resolveInMemoryBtns(e).concat(t))}addConfigButton(i){return void 0===this.configName?i:i.concat(g.CONFIGURATOR)}get application(){return o.getContextValue("__SNK__APPLICATION__")}resolveInMemoryBtns(i){const t=[...i];return this.mode===f.IN_MEMORY&&t.splice(1,1),t}async goToView(i){this._currentViewMode=i,this._viewStack&&this._viewStack.show(i)}actionClickListener(i){const t=i.detail;t===g.CONFIGURATOR?this._snkConfigurator.open():t===g.GRID_MODE?this.goToView(p.GRID):t===g.FORM_MODE&&this.goToView(p.FORM),i.stopPropagation()}async onChangeEntityName(i){if(this.dataUnit)return;const t=o.getContextValue("__SNK__APPLICATION__");this.dataUnit=await t.getDataUnit(i,null,null,this.configName)}onModeChange(){this.mode==f.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){this.handleDataStateChange(i,t)}async observeFormLegacy(i,t){await this.handleUpdateFormLegacyConfig(i,t)}async observeGridLegacy(i,t){await this.handleUpdateGridLegacyConfig(i,t)}async handleDataStateChange(i,t){h.objectToString(t)!=h.objectToString(i)&&this.dataStateChange.emit(i),await this.processRmPrecision()}async processRmPrecision(){var i,t;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(i,t){null!=i&&i!=t&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(i,t){null!=i&&i!=t&&this._formConfigAlreadyLoaded&&this.loadFormConfig(!0)}openConfig(i){this._snkConfigurator.close(),i===p.GRID?this.openGridConfig():i===p.FORM&&this.openFormConfig()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}))}async openFormConfig(){(this.formLegacyConfigName||this.configName)&&await this._snkSimpleFormConfig.show()}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&F.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(i){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||i))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((i,t)=>{F.loadGridConfig(this.configName,this.resolveResourceID()).then((t=>{this.setGridConfig(t),i()})).catch((i=>{t(i)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(i=!1,t=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new R(this.configName,this.resolveResourceID(),void 0,this.dataUnit),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!i)return;this._formConfigAlreadyLoaded=!0;let s=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=s)return this._formConfigManager.setConfig(s),void this.setFormConfig(s,t);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),this.loadGridConfig(),this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new C,this._continuousInsertUtils=new b(this.application,this.resolveResourceID(),this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this.enableContinuousInsert=i))}componentDidLoad(){m.applyVarsGrid(this._element,this._grid),this.initKeyboardManager()}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._grid&&this._form)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t),this._form.addCustomEditor(i,t),this._customEditors.delete(i)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[i,t]of this._fieldsProps){for(const s in t)this._form.setFieldProp(i,s,t[s]);this._fieldsProps.delete(i)}}getTaskBarId(){var i,t;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===p.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===p.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new w(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new R(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:a[i.getAttribute("dataType")]||a.TEXT,userInterface:r[i.getAttribute("userInterface")]||r.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}addGridCustomValueFormattters(){var i,t,s;const e=(null===(i=this._metadata)||void 0===i?void 0:i.fields)||(null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)||void 0===s?void 0:s.fields);if(!e)return;const n=[];e.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&!n.includes(i.name)&&n.push(i.name)})),n.forEach((i=>{this.addCustomValueFormatter(i,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e,n,o;const h=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||h.push(g.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||h.push(g.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&h.push(g.FORM_MODE),(null===(o=null===(n=this.dataState)||void 0===n?void 0:n.selectionInfo)||void 0===o?void 0:o.length)>1&&h.push(g.CLONE),h}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(p.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(i,t){i.stopImmediatePropagation(),"SAVE"!==t?this.configuratorCancel.emit():this.configuratorSave.emit()}getColumnSearch(i,t){return null!=this._columnSearch||(this._moreOptions=i,this._columnSearch=T(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{var s;null!=t&&(this._grid.locateColumn(t.value),null===(s=i.hideActions)||void 0===s||s.call(i))}))),this._columnSearch}onSelectField(i,t){null!=i&&(this._fieldToGetFocus=i.value,t.hideActions())}getFieldSearch(i,t){return null!=this._fieldSearch||(this._moreOptions=i,i.addEventListener("ezPopoverOpen",(()=>this.findField())),this._fieldSearch=T(t,(({argument:i})=>this.fieldsOptionLoader(i)),(t=>this.onSelectField(t,i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){h.equals(this._formFields,i)||(this._formFields=null!=i?i:[])}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}isGridInsertActive(){return this.enableGridInsert&&this.dataUnit.hasNewRecord()}getActionsList(){var i,t;const s=[{value:n.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findColumn",void 0))&&void 0!==t?t:"Buscar",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this._currentViewMode===p.GRID?this.getColumnSearch(i,t):this.getFieldSearch(i,t)}];if(this.enableGridInsert&&s.push(this._continuousInsertUtils.actionContinuousInsert(this.enableContinuousInsert,(()=>{this.enableContinuousInsert=!this.enableContinuousInsert,this._continuousInsertUtils.handleSaveConfig(this.enableContinuousInsert)}))),this.isGridInsertActive())return s;if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const i=this.getTopTaskBarId();return s.concat(this.taskbarManager.getMoreOptions(i,this.configName,this.dataState,this.actionsList))}return this.actionsList?s.concat(this.actionsList):s}getTopTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${y.PRIMARY}`:`snkGridTopTaskbar.regular${y.PRIMARY}`}async keyDownListener(i){i.ctrlKey&&null!=i.key&&"F"===i.key.toUpperCase()&&null!=this._element&&(d.isHiddenElement(this._element)||(l.closeAll(),this._currentViewMode===p.GRID?await this.findColumn():await this.findField(),i.preventDefault()))}async findField(){await this.openSeach(this._fieldSearch)}async findColumn(){await this.openSeach(this._columnSearch)}async openSeach(i){await I(this._moreOptions,i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}disconnectedCallback(){window.removeEventListener("keydown",this._keyDownHandler)}gridConfigChangeHandler(i){i.stopPropagation(),this.configName&&F.saveGridConfig(i.detail,this.configName,this.resolveResourceID())}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const i=new S(this.dataUnit,this._grid);z.set("exporterProviders",Object.assign(Object.assign({},z.get("exporterProviders")),{[this.getDataExporterStoreKey()]:i}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(i){this.gridConfig=i,k.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(i,t){this.formConfig&&!t||(this.formConfig=i)}closeGridConfig(){this._showPopUpGridConfig=!1}getPageSize(){return this.mode===f.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}resolveResourceID(){return n.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var i;const t=null===(i=this._formConfigManager)||void 0===i?void 0:i.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||t?t:this.formConfig}updateFormConfig(){let i=this.formConfig;null==this.formLegacyConfigName&&(i=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields})),this.setFormConfig(i,!0),null==this._formConfigManager&&(this._formConfigManager=new R(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}handleDataUnitOnInsertionMode(){this.enableGridInsert||this.goToView(p.FORM)}async initKeyboardManager(){var i;const t=new u,s=this.dataUnit||await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getDataUnit());null!=s&&t.bind("F7",(()=>s.saveData()),{description:"Salva os dados.",element:this._element}).bind("F8",s.addRecord.bind(s),{description:"Adiciona um novo registro.",element:this._element}).bind("F9",s.removeSelectedRecords.bind(s),{description:"Remove o registro selecionado.",element:this._element}).bind("Escape",(()=>{s.isDirty()&&s.cancelEdition()}),{debounceTime:1e3,description:"Cancela uma ação.",element:this._element})}async handleFormConfigSaved(){await this.loadFormConfig(!0,!0)}renderTaskbarContent(){var i;return s("snk-taskbar",{class:this._currentViewMode===p.FORM&&`ez-box ${this.outlineMode?"ez-box--outline":"ez-box--shadow-xsmall"} ez-padding--small`,dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:y.SECONDARY},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"}))}render(){var i;if(null!=this.dataUnit)return s("snk-data-unit",{ref:i=>this._snkDataUnit=i,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:this.handleDataUnitOnInsertionMode.bind(this),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),ignoreSaveMessage:this._currentViewMode===p.GRID,onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:`ez-box ${this.outlineMode?"ez-box--outline":"ez-box--shadow"} simple-crud__container-section`},s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large",ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(p.FORM),onConfigChange:i=>this.gridConfigChangeHandler(i),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(w.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableContinuousInsert:this.enableContinuousInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,outlineMode:this.outlineMode},this.renderTaskbarContent(),s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,this.renderTaskbarContent(),s("ez-form",{ref:i=>this._form=i,class:"ez-margin-top--large",dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this)}),s("snk-simple-form-config",{ref:i=>this._snkSimpleFormConfig=i,dataUnit:this.dataUnit,onSnkConfigSaved:this.handleFormConfigSaved.bind(this),configName:null!==(i=this.formLegacyConfigName)&&void 0!==i?i:this.configName})),this.messagesBuilder&&s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.goToView(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showConfiguratorButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId,layoutFormConfig:this.layoutFormConfig})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._showPopUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this.gridConfig,"data-element-id":this._element.getAttribute(c.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return e(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};O.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid__container--shadow--outline:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{O as snk_simple_crud}
@@ -1 +0,0 @@
1
- import{C as t}from"./p-13f17dab.js";import{ObjectUtils as i,StringUtils as e}from"@sankhyalabs/core";import{F as s}from"./p-01512409.js";import{c as r}from"./p-1d19a5b0.js";class n{constructor(t,i,e,s){this._resourceID=i,this._configName=t,this._onConfigChange=e,this._dataUnit=s}addFormLegacyConfig(i){this._configName&&t.addFormLegacyConfig(this._configName,i)}async loadConfig(){return new Promise((i=>{t.loadFormConfig(this._configName,this._resourceID).then((t=>{t=this.buildFormMetadataUITabs(t),this.setConfig(t),i(t)})).catch((t=>{console.warn(t)}))}))}getEmptyConfig(){return this.buildFormMetadataUITabs({fields:[],emptyConfig:!0},!0)}saveConfig(e){const s=i.copy(e);return new Promise((i=>{t.saveFormConfig(e,this._configName,this._resourceID).then((t=>{this.setConfig(Object.assign(Object.assign({},s),t)),i(Object.assign(Object.assign({},s),t))}))}))}saveCardState(i,e,s){return new Promise((r=>{var n;const l=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,o=l.get(i);l.set(i,"fixed"===s?this.updateFixSequence(Object.assign(Object.assign({},o),{fixed:e.fixed}),l):Object.assign(Object.assign({},o),{[s]:e[s]})),t.saveCardState(l,this._configName,this._resourceID).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:l}),r(t)}))}))}updateFixSequence(t,i){let e=-1;return Array.from(i.values()).forEach((i=>{i.fixed||delete t.fixSequence,null!=i.fixSequence&&(e=Math.max(e,i.fixSequence))})),t.fixed?t.fixSequence=e+1:delete t.fixSequence,t}hasConfig(t){var i;const e=null!=t?t:this._config;return!(!e||!(null===(i=e.fields)||void 0===i?void 0:i.length))}getFieldsList(t,i=!1){var e;const s=null===(e=this._config)||void 0===e?void 0:e.fields;return this.hasConfig()&&!i?s.map((({label:t,name:i,readOnly:e,visible:s,required:r,tab:n,group:l})=>{var o;if(null==t){const t=null===(o=this._dataUnit)||void 0===o?void 0:o.getField(i);if(!t)return;return Object.assign(Object.assign({},t),{name:null!=i?i:t.name,readOnly:null!=e?e:t.readOnly,visible:null!=s?s:t.visible,required:null!=r?r:t.required,tab:n,group:l})}return{name:i,label:t,readOnly:e,visible:s,required:r,tab:n,group:l}})).filter((i=>this.isFieldVisible(i,t))):this._dataUnit?this._dataUnit.metadata.fields.filter((i=>this.isFieldVisible(i,t))).map((({label:t,name:i,readOnly:e,visible:s,required:r,properties:n})=>({label:t,name:i,readOnly:e,visible:s,required:r,tab:null==n?void 0:n.UITabName}))):[]}isFieldVisible(t,i){if(void 0===t||!1===t.visible)return!1;if(null==i)return!0;const s=e.replaceAccentuatedCharsLower((t.label||t.name).toLocaleLowerCase()),r=e.replaceAccentuatedCharsLower(i.toLocaleLowerCase());return s.includes(r)}getFormConfig(t,i,e=!1){let s=this.getFieldsList(void 0,e);return i&&(s=s.filter((i=>{if(t){const e=t.getField(i.name);if(e&&e.readOnly)return!1}return!i.readOnly}))),Object.assign(Object.assign({},this._config),{fields:s})}setConfig(t){this.isLoaded=!0;const{cardsState:i,summary:e,defaultVars:s}=this._config||{};this._config=Object.assign({},t),i&&(this._config.cardsState=i),e&&(this._config.summary=e),s&&(this._config.defaultVars=s),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,i){return this.getFormConfig(t,null==i||i)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new s),this._formConfigFetcher}async fetchUserAvailableConfigs(){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,this._resourceID)}async fetchLegacyConfig(){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,this._resourceID)}async fetchDefaultConfig(){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,this._resourceID)}parseObjectList(t){return t?Array.isArray(t)?t:[t]:[]}buildFormMetadataUITabs(t,i=!1){var e;const s=this.hasConfig(t);if(!i&&(!this._dataUnit||s))return t;(t=this.getFormConfig(this._dataUnit,!1,!0)).tabs=this.parseObjectList(t.tabs),t.emptyConfig=!1,t.defaultConfiguration=!0;const n=this._dataUnit.metadata.fields;for(const i of n){const s=t.fields.find((t=>t.name===i.name)),n=null===(e=i.properties)||void 0===e?void 0:e.UITabName;n&&n!==r.main&&(t.tabs.some((t=>t.label===n))||t.tabs.push({label:n,name:n,order:0,visible:!0}),s&&(s.tab=n))}return t}}export{n as S}
@@ -1 +0,0 @@
1
- import{r as i,c as e,h as t,F as s}from"./p-d2d301a6.js";import{Action as r,ElementIDUtils as a}from"@sankhyalabs/core";import{S as n}from"./p-cb9d725a.js";import{buildFormMetadata as d,FormMetadata as o}from"@sankhyalabs/ezui/dist/collection/utils/form";import{o as h,T as l,b as u}from"./p-23736d75.js";import{T as c}from"./p-3fc82614.js";import{V as v}from"./p-1d19a5b0.js";import"./p-5a7e18f4.js";import"./p-108fee57.js";import{P as g}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-01512409.js";import{SelectionMode as m}from"@sankhyalabs/core/dist/dataunit/DataUnit";const k="__FORM:",f=class{constructor(t){i(this,t),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this.enableGridInsert=!1,this.ignoreReadOnlyFormFields=void 0,this.getCustomTitle=void 0,this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={}}observeDataUnit(){this.loadGuides(!0)}observeDataState(i,e){const t=null==i?void 0:i.selectedRecord,s=null==e?void 0:e.selectedRecord;(null==t?void 0:t.__record__id__)!==(null==s?void 0:s.__record__id__)&&this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected())}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async findField(){await h(this._moreOptions,this._fieldSearch)}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,t){const s={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:t})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),s)}async setFocus(){this._container.focus()}exitViewer(){!this.enableGridInsert&&this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===c.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=d(this.masterFormConfig,this.dataUnit,!0);const e=this._masterFormMetadata.getAllSheets(),t=this.dataUnit.getSelectedRecord(),s=!t||this.dataUnit.isNewRecord(t.__record__id__),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&s&&(e.tooltip="Para alterar detalhes é necessário estar com um registro selecionado.",e.disabled=!0),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}isDetail(i){return null!=o.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}getTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkGuideViewer.finish_edition":"snkGuideViewer.regular"}loadTaskbarProcessor(){var i;const e=this.getTaskBarId(),t=[];this.dataState&&this.dataState.hasPrevious||t.push("PREVIOUS"),this.dataState&&this.dataState.hasNext||t.push("NEXT"),(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&(this.dataState.selectionInfo.length>1&&t.push("CLONE"),this.dataState.selectionInfo.isAllRecords()&&t.push("REMOVE"));const s=["PREVIOUS","NEXT","DIVIDER","ATTACH","CLONE","REMOVE","MORE_OPTIONS","ACTIONS_BUTTON","DIVIDER","GRID_MODE","CONFIGURATOR"];this.presentationMode==g.SECONDARY?s.unshift("INSERT"):s.push("INSERT");const r=this.getInvisibleButtons();this._taskbarProcessor=new l({"snkGuideViewer.regular":s,"snkGuideViewer.finish_edition":["CANCEL","SAVE",this.handleAddGridMode()]}),this._taskbarProcessor.process(e,this.taskbarManager,this.dataState,t,r)}handleAddGridMode(){return this.enableGridInsert?c.GRID_MODE:""}getInvisibleButtons(){const i=[];return this.dataState&&this.dataState.selectionInfo.mode===m.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}static updateContentCard(i,e,t,s){return s.saveCardState(i,e,t)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return t(s,null,Array.from(r.entries()).filter((([e,t])=>(null==t?void 0:t.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,s])=>{var r,a;const n=i.formMetadata.getSheet(e);if(null!=n)return t("snk-form-view",{levelPath:i.levelPath,label:n.label,name:e,fields:n.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==s?void 0:s.presentation),fixed:null==s?void 0:s.fixed,summaryFields:null===(a=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===a?void 0:a.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps})})))}wrapDetail(i,e){if(0===i.length)return e;const s=i.pop(),r=o.getDetailName(s);return r?this.wrapDetail(i,t("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const t=i.map((i=>o.getDetailName(i)));return`${this.entityPath}/${t.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){var i,e,s,r,a;if(!this.selectedGuide)return;const n=this.selectedGuide.id;let d;const h=n.split("::"),l=h.pop(),u=o.getDetailName(l);let c=n;if(u||h.length>0){let e,s;if(n.includes(k)){[c,e]=n.split(k);const t=(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)||0;s=t>1?this._breadcrumbItems[t-2]:this.selectedGuide}else s=this.selectedGuide;d=this.wrapDetail(h,t("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(h,u),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:u,selectedForm:e,branchGuide:s,guideItemPath:this._breadcrumbItems,key:`detail${c}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders,presentationMode:this.presentationMode}))}else{const i=this.selectedGuide.id,o=this._masterFormMetadata.getSheet(i);if(o){const h=null===(s=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===s?void 0:s.get(i);d=t("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==h?void 0:h.fixed,summaryFields:null===(a=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===a?void 0:a.get(i),name:i,label:o.label,fields:o.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:n,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps},this.presentationMode==g.SECONDARY&&this.buildTaskBar())}}return d}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))]}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}setMasterFormConfig(i){this.masterFormConfig=i}componentWillLoad(){if(null==this.resourceID)throw new Error("Erro interno: resourceID não informado");this._configManager=new n(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}getFieldsSearch(i,e){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._moreOptions=i,i.addEventListener("taskbarActionsButtonDisconnected",(()=>this._hasToCreateFieldSearch=!0)),this._fieldSearch=u(e,(({argument:i})=>this.fieldsOptionLoader(i)),(e=>this.onSelectField(e,i)))),this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}onSelectField(i,e){if(null==i)return;this._fieldToGetFocus=i.value;const t=this.getGuideName(i.value);t!==this.selectedGuide.id&&this.changeGuideHandler(t),e.hideActions()}getActionsList(){return[{value:"",label:this.getMessage("snkCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,e)=>this.getFieldsSearch(i,e)}].concat(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions?this.taskbarManager.getMoreOptions(this.getTaskBarId(),this.configName,this.dataState,this.actionsList):this.actionsList)}buildTaskBar(){var i;return t("div",{class:"snk-guides-viewer__header-taskbar "+(this.presentationMode!=g.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},t("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.getActionsList(),messagesBuilder:this.messagesBuilder,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-taskbar-owner":"master",dataUnit:this.dataUnit,resourceID:this.resourceID,customSlotId:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS",alignRigth:!0},t("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"})))}async dataUnitActionHandler(i){var e;if(i.type===r.FIELD_INVALIDATED){const t=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(t),await this.openGuideNavigator(t)}i.type===r.METADATA_LOADED&&this.loadGuides(this.noGuideSelected())}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var t;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(t=i.badge)&&void 0!==t?t:null}getGuideName(i){var e;for(const t of this._masterFormMetadata.getAllSheets()){const s=null===(e=t[1])||void 0===e?void 0:e.fields;for(const e of s)if(e.name===i)return t[0]}return""}getTitle(){var i,e;return null!==(e=null===(i=this.getCustomTitle)||void 0===i?void 0:i.call(this))&&void 0!==e?e:this.getMessage("snkCrud.title")}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}render(){var i,e;if(null!=this._formEditorConfigManager)return t("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null,ignoreReadOnlyFormFields:this.ignoreReadOnlyFormFields});if(!this.dataUnit||!this._configManager.isLoaded)return;this.loadTaskbarProcessor();const s=this._guides&&this._guides.length>1;return t("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabindex:-1},t("div",{class:"ez-row snk-guides-viewer__header"},t("div",{class:"snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},t("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),t("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},t("h1",{class:"ez-title ez-title--primary ez-title--xlarge"},this.getTitle()),(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)>1&&t("div",{class:"ez-margin-top--extra-small"},t("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=g.SECONDARY&&this.buildTaskBar()),t("div",{class:"snk-guides-viewer__container"},s?t("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):t("div",null),t("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps}),this.getContent())),t("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID}))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-small:var(--space--2xs, 8px);--snk-guides-viewer__header--min-height:68px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-small);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-small));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-small))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
@@ -1 +0,0 @@
1
- import{r as s,h as i,H as e,g as t}from"./p-d2d301a6.js";import{ObjectUtils as a,StringUtils as r,ElementIDUtils as o}from"@sankhyalabs/core";import{P as n,b as l,a as c}from"./p-108fee57.js";import"./p-5a7e18f4.js";import"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-01512409.js";import"./p-1d19a5b0.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const u=class{constructor(i){s(this,i),this._mdByName={},this._startHighlightTag="<span class='card-item__highlight'>",this._endHighlightTag="</span>",this._specialCharsRegex=/[[.\-\$\+\*,_\&\(\)%\/\\#@!:\|\=\'\"]/gim,this._charsWithAccentuation="ÁÉÍÓÚ_ÃÕ_ÂÊÎÔÛ_ÀÈÌÒÙ_Ü_Ç_áéíóú_ãõ_âêîôû_àèìòù_ü_ç",this._charsWithoutAccentuation="AEIOU_AO_AEIOU_AEIOU_U_C_aeiou_ao_aeiou_aeiou_u_c",this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=450,this._gridDataSource=[],this.pesquisaFetcher=new n,this._itemList=void 0,this._startLoading=!1,this._presentationMode="list",this._currentView=void 0,this.searchLoader=void 0,this.treeLoader=void 0,this.selectItem=void 0,this.entityName=void 0,this.argument=void 0,this.isHierarchyEntity=!1,this.allowsNonAnalytic=!1}observeArgument(){this._textInput&&(this._textInput.value=this.argument)}clearSearch(){this.argument="",this._itemList=void 0}buildDetails(s,i){let e={};for(let t=0;t<s.length;t++){const a=s[t],r=i[a.fieldName];e[a.description]=this.highlightValue(i.__matchFields,a.options&&a.options[r]||r,s,!0)}return e}buildFirstFields(s,i,e=6){return s&&Array.isArray(s)&&s.forEach((s=>{let e=this.removeReference(i,this._mdByName[s]);e&&i.unshift(e)})),i=i.slice(0,e)}doSearch(s){this.searchLoader&&"function"==typeof this.searchLoader&&(this._startLoading=!0,this.searchLoader(s).then((s=>{s&&this.processSearchResponse(s)})).finally((()=>{this._startLoading=!1})))}processSearchResponse(s){let i=(s=a.stringToObject(s.json.$)).descriptionField,e=s.pkField;e&&(this._gridMetadata=l(s),this._gridDataSource=[...s.data],this._pkField=e,this._descriptionField=i,this._itemList=this.buildCardItemList(s,e,i))}buildCardItemList(s,i,e){var t;return null===(t=s.data)||void 0===t?void 0:t.map((t=>{var a;let r=this.filterFieldsMetadata(s,t),o=this.buildFirstFields(t.__matchFields,r);return{key:this.highlightValue(t.__matchFields,null===(a=t[i])||void 0===a?void 0:a.toString(),o,!0),title:e?this.highlightValue(t.__matchFields,t[e],o,!0):"",details:this.buildDetails(o,t)}}))}filterFieldsMetadata(s,i){return s.fieldsMetadata.filter((e=>{let t=!r.isEmpty(i[e.fieldName])&&!1!==e.visible&&"B"!==e.type&&s.pkField!==e.fieldName&&s.descriptionField!==e.fieldName&&(e.isPrimaryKey||!e.isLinkField)&&!("S"===e.type&&"H"===e.presentationType);return t&&(this._mdByName[e.fieldName]=e),("string"!=typeof i[e.fieldName]||!(i[e.fieldName].indexOf("<img")>-1||i[e.fieldName].indexOf("<svg")>-1))&&t}))}removeAtIndex(s,i){if(i>=0&&i<s.length)return s.splice(i,1)[0]}removeReference(s,i){let e=this.indexOf(s,i);return this.removeAtIndex(s,e)}indexOf(s,i){let e=-1;return Array.isArray(s)&&this.find(s,((s,t)=>(e=t,this.equals(i,s)))),e}equals(s,i){return a.objectToString(s)===a.objectToString(i)}find(s,i){if(s)for(let e=0,t=s.length;e<t;e++)if(i(s[e],e,s))return s[e]}highlightValue(s,i,e,t){let a=this.replaceHtmlEntities(i);if(this.argument&&(t||this.isIn(s,e.fieldName))){const s=this.getArgumentNumber();let i=(isNaN(s)?this.argument:s.toString()).split(/%|,|\s+/),t=0,r=this.replaceAccentuatedChars(a);i.forEach((s=>{if(s){s=this.replaceAccentuatedChars(s);let i=this.getSpecialCharacters(s);null!=i&&i.length>0&&(s=this.removeSpecialCharacters(s)),(e.mask||"CGC_CPF"===e.uiType||"Phone"===e.uiType)&&(s=s.split("").join("\\.?\\-?\\/?\\(?\\)?"));let o=new RegExp(s,"ig");o.lastIndex=t;let n=o.exec(r);if(n&&n.length>0){t=n.index;let s=n[0].length,i=a.substring(t,t+s),e=(null==i?void 0:i.trim())?this._startHighlightTag+i+this._endHighlightTag:"",o=a.substring(0,t),l=a.substring(t+s);a=o+e+l,t+=e.length,r=this.replaceAccentuatedChars(a)}}}))}return a}replaceHtmlEntities(s){return null==s?s:String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}replaceAccentuatedChars(s){return null==s?s:this.replaceToSpace(s,["&amp;","&lt;","&gt;","&quot;"]).replace(/[^\w ]/g,(s=>{let i=this._charsWithAccentuation.indexOf(s);return i>-1&&(s=this._charsWithoutAccentuation.charAt(i)),s||""}))}replaceToSpace(s,i=[]){return null==s||i.forEach((i=>{const e=new RegExp(i,"g");let t="";for(let s=0;s<i.length;s++)t+=" ";s=String(s).replace(e,t)})),s}isIn(s,i){return this.indexOf(s,i)>-1}getSpecialCharacters(s){let i,e=[];for(;i=this._specialCharsRegex.exec(s);)e.push(s[i.index]);return e}removeSpecialCharacters(s){return this.getSpecialCharacters(s).forEach((i=>{s=this.replaceAll(s,i,"")})),s}replaceAll(s,i,e){let t=(null!=s?s:"").indexOf(i);for(;t>-1;)t=(s=s.replace(i,e)).indexOf(i);return s}getArgumentNumber(){return Number(this.argument||void 0)}createOption(s){let{key:i,title:e}=s;const t=new RegExp(this._startHighlightTag,"g"),a=new RegExp(this._endHighlightTag,"g");e=r.decodeHtmlEntities(e);const o={value:null==i?void 0:i.replace(t,"").replace(a,""),label:null==e?void 0:e.replace(t,"").replace(a,"")};this.selectItem(o)}onChangeValue(s){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=setTimeout((()=>{this.onChangeValue(s)}),this._deboucingTime));if(this.argument=(s.detail||"").trim(),this.isHierarchyEntity&&"list"===this._presentationMode)return void(null===(i=this._pesquisaTree)||void 0===i||i.applyFilter());const e=this.getArgumentNumber();this.argument&&(!isNaN(e)||this.argument.length>=this._limitCharsToSearch)?this._changeDeboucingTimeout=setTimeout((()=>{this.doSearch(isNaN(e)?this.argument:e.toString())}),this._deboucingTime):this._itemList=void 0}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onClickSearch(){this.doSearch((this.argument||"").trim())}getMessageView(){return this._startLoading?"Aguarde, buscando registros...":this._itemList?this._itemList.length>=1?`${this._itemList.length} ${this._itemList.length>1?"registros encontrados":"registro encontrado"}`:"Nenhum registro encontrado":"Os resultados de sua pesquisa aparecerão aqui..."}async componentWillLoad(){const s=await this.pesquisaFetcher.loadPresentationConfig(this.entityName);this._presentationMode="list"===s?"list":"table"}async componentDidLoad(){o.addIDInfo(this._element),await this.chooseViewMode()}async handleChangeViewMode(){this._presentationMode="list"===this._presentationMode?"table":"list",await this.chooseViewMode(),await this.pesquisaFetcher.savePresentationConfig(this.entityName,this._presentationMode)}async chooseViewMode(){var s,i;if("list"!==this._presentationMode)return await(null===(s=this._viewStack)||void 0===s?void 0:s.show(c.GRID)),void(this._currentView=c.GRID);const e=this.isHierarchyEntity?c.TREE:c.CARDS;await(null===(i=this._viewStack)||void 0===i?void 0:i.show(e)),this._currentView=e}hideLimitMessage(){return!this._itemList||this._itemList.length<100}hideRecordsMessage(){return"list"===this._presentationMode&&this.isHierarchyEntity}getButtonModeInfo(){return"list"===this._presentationMode?{iconName:"table",title:"Modo grade"}:this.isHierarchyEntity?{iconName:"hierarchical-tree",title:"Modo árvore hierárquica"}:{iconName:"list",title:"Modo lista"}}render(){var s,t;return i(e,null,i("div",{class:"snk-pesquisa"},i("div",{class:"snk-pesquisa__input"},i("ez-text-input",{label:"Buscar",class:"ez-margin-right--medium",canShowError:!1,ref:s=>this._textInput=s,onEzChange:s=>this.onChangeValue(s),value:this.argument,"data-element-id":"searchInput"},i("ez-icon",{slot:"leftIcon",iconName:"search"}),this.argument&&(null===(s=this._textInput)||void 0===s?void 0:s.value)?i("button",{slot:"rightIcon",class:"snk-pesquisa__btn",onClick:()=>this.clearSearch()},i("ez-icon",{iconName:"close"})):void 0),i("ez-button",{class:"ez-button--primary",label:"Pesquisar",onClick:()=>this.onClickSearch()}),i("ez-button",{class:"ez-margin-left--medium",mode:"icon",iconName:this.getButtonModeInfo().iconName,title:this.getButtonModeInfo().title,onClick:async()=>await this.handleChangeViewMode()})),i("div",{class:"snk-pesquisa__records-label "+(this._currentView===c.TREE?"hidden":"")},i("label",{class:"snk-pesquisa__records "+(this.hideRecordsMessage()?"hidden":"")},this.getMessageView()),i("label",{class:"snk-pesquisa__records-limit "+(this.hideLimitMessage()?"hidden":"")},"Essa pesquisa foi limitada, existem mais resultados.")),i("div",{class:"snk-pesquisa__content"},i("ez-view-stack",{ref:s=>this._viewStack=s,"data-element-id":"simple-crud"},i("stack-item",null,i("pesquisa-grid",{metadata:this._gridMetadata,dataSource:this._gridDataSource,pkField:this._pkField,descriptionField:this._descriptionField,entityName:this.entityName,shouldLoadConfig:this._currentView===c.GRID,onPesquisaGridSelectItem:({detail:s})=>this.selectItem(s)})),i("stack-item",null,i("div",{class:"snk-pesquisa__cards-container"},null===(t=this._itemList)||void 0===t?void 0:t.map((s=>i("ez-card-item",{onEzClick:s=>this.createOption(s.detail),item:s}))))),i("stack-item",null,i("pesquisa-tree",{ref:s=>this._pesquisaTree=s,argument:this.argument,treeLoader:this.treeLoader,allowsNonAnalytic:this.allowsNonAnalytic,shouldLoadTree:this._currentView===c.TREE,onPesquisaTreeSelectItem:({detail:s})=>this.selectItem(s)}))))))}get _element(){return t(this)}static get watchers(){return{argument:["observeArgument"]}}};u.style=".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--color-secondary:var(--text--secondary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);--snk-pesquisa__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-pesquisa__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-pesquisa__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-pesquisa__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-pesquisa__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__scrollbar--width:var(--space--small, 6px);height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;overflow-y:hidden;scrollbar-width:thin;scrollbar-color:var(--snk-pesquisa__scrollbar--color-clicked) var(--snk-pesquisa__scrollbar--color-background);padding-right:var(--snk-pesquisa__content--padding-right);height:100vh}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:var(--snk-pesquisa__scrollbar--color-background);width:var(--snk-pesquisa__scrollbar--width);max-width:var(--snk-pesquisa__scrollbar--width);min-width:var(--snk-pesquisa__scrollbar--width)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:var(--snk-pesquisa__scrollbar--color-background);border-radius:var(--snk-pesquisa__scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__scrollbar--color-default);border-radius:var(--snk-pesquisa__scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:vertical:hover,.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-pesquisa__scrollbar--color-hover)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:vertical:active,.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-pesquisa__scrollbar--color-clicked)}.snk-pesquisa__records-label.sc-snk-pesquisa{display:flex;flex-direction:row;justify-content:space-between;font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__records-label.hidden.sc-snk-pesquisa{display:none}.snk-pesquisa__records.sc-snk-pesquisa{color:var(--snk-pesquisa__records--color)}.snk-pesquisa__records-limit.sc-snk-pesquisa{color:var(--snk-pesquisa__records--color-secondary)}.snk-pesquisa__records-limit.hidden.sc-snk-pesquisa,.snk-pesquisa__records.hidden.sc-snk-pesquisa{visibility:hidden}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}.snk-pesquisa__cards-container.sc-snk-pesquisa{height:100%;overflow-y:auto}";export{u as snk_pesquisa}
@@ -1 +0,0 @@
1
- import{r as t,c as i,f as s,h as e,H as a}from"./p-d2d301a6.js";import{Action as o}from"@sankhyalabs/core";import{S as h}from"./p-cb9d725a.js";import{FormMetadata as n,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-5a7e18f4.js";import"./p-108fee57.js";import{P as d}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-01512409.js";import{V as l}from"./p-1d19a5b0.js";import{T as c}from"./p-3fc82614.js";import{S as u}from"./p-d1f04e2c.js";import{S as m}from"./p-17425c72.js";import"./p-13f17dab.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-6dc031de.js";import"./p-23736d75.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";class v{constructor(t,i,s){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s}get id(){return this._parentGuide.id}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,o=null!=n.getDetailName(s.split("::").pop()),h=o&&e,r=this._parentGuide.id,d=o?`${r}::${s}`:`${r}__FORM:${s}`;return o&&t.has(d)&&!h?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:h,tooltip:h?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),o=a.shift();return o.label=e?"Novo Registro":s.__record__label__,o.children=a,i.children=[o],i}}const p=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formItemsReady=i(this,"formItemsReady",7),this._disabledButtons=void 0,this._currentView=void 0,this.attachmentRegisterKey=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0,this.presentationMode=d.SECONDARY}observeDataUnit(t,i){null==t||t.subscribe(this.dataUnitActionHandler.bind(this)),null==i||i.unsubscribe(this.dataUnitActionHandler)}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,o=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==o?void 0:o.__record__id__)&&this.snkDetailGuidesChange.emit(new v(this.branchGuide,this._formMetadata,this.dataUnit)),s&&setTimeout((()=>{this.changeViewMode(l.FORM)}),0),e&&this.changeViewMode(l.GRID);const h=[];this.dataState.hasPrevious||h.push(c.PREVIOUS),this.dataState.hasNext||h.push(c.NEXT),this.dataState.insertionMode&&h.push(c.INSERT),this._disabledButtons=h}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);this._snkGrid.addCustomEditor(t,i,e),this._snkFormView.addCustomEditor(t,i,e)}async observerPropsCustomEditor(t){for(const i in t)await this.addCustomEditor(i,t[i])}async addGridCustomRender(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);await this._snkGrid.addGridCustomRender(t,i,e)}onContentCardChanged(t){u.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}async observeCustomRenders(t){for(const i in t){const s=t[i];await this.addGridCustomRender(i,s)}}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(p.REGEX_FORM_ID,"")}loadMetadata(){if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const t=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=r(null==t||0===t.fields.length?void 0:t,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){var i,s;this._viewStack=t,this._currentView=this.selectedForm?1:0,null===(s=null===(i=this._viewStack)||void 0===i?void 0:i.show)||void 0===s||s.call(i,this._currentView)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===l.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}handleAttachBack(){this._viewStack.show(l.GRID)}executeActionHandler(t){t.detail===c.GRID_MODE&&(this.emitSwitchEvent(l.GRID),t.stopPropagation()),t.detail!==c.FORM_MODE&&t.detail!==c.UPDATE||(this.emitSwitchEvent(l.FORM),t.stopPropagation()),t.detail===c.ATTACH&&(this._viewStack.show(l.ATTACHMENT),t.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}async handleDataStateChange({detail:t}){this.dataState=t,void 0!==t.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new h(this._configName,this.resourceID,(()=>this.loadMetadata()),this.dataUnit),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new m(this.entityName))}async componentDidLoad(){await this.observerPropsCustomEditor(this.customEditors),await this.observeCustomRenders(this.customRenders)}async dataUnitActionHandler(t){t.type===o.FIELD_INVALIDATED&&this.addErrorBadgeToBranchGuide()}addErrorBadgeToBranchGuide(){this.branchGuide=Object.assign(Object.assign({},this.branchGuide),{badge:"error"}),this.snkDetailGuidesChange.emit(new v(this.branchGuide,this._formMetadata,this.dataUnit))}normalizeBranchGuideId(t){return null==t?void 0:t.replace(/child\[(.*?)\]/g,"$1").replace(/::/g,">")}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{ref:t=>this._snkDataUnit=t,dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===l.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-title--primary ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full",ref:t=>this._snkGrid=t,configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.emitSwitchEvent(l.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:this.presentationMode,canEdit:this.canEdit,isDetail:!0,taskbarCustomContainerId:this.taskbarCustomContainerId,gridHeaderCustomSlotId:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS",topTaskbarCustomSlotId:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS",outlineMode:!1}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath,onFormItemsReady:({detail:t})=>this.formItemsReady.emit(t)},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,messagesBuilder:this.messagesBuilder,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:this.presentationMode,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"},e("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))),e("stack-item",null,e("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this.entityName,onBack:this.handleAttachBack.bind(this)})))))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observerDataState"],customEditors:["observerPropsCustomEditor"],customRenders:["observeCustomRenders"]}}};p.REGEX_FORM_ID=/__FORM:[^:]+/g,p.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px;height:100%}.detail-header.sc-snk-detail-view{padding-bottom:0}snk-data-unit.sc-snk-detail-view{flex:1}snk-grid.sc-snk-detail-view{height:calc(100% - 43px)}";export{p as snk_detail_view}
@@ -1 +0,0 @@
1
- export{S as snk_guides_viewer}from"./p-d1f04e2c.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-cb9d725a.js";import"./p-13f17dab.js";import"./p-01512409.js";import"./p-5a7e18f4.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-1d19a5b0.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-23736d75.js";import"./p-3fc82614.js";import"./p-0f3698af.js";import"./p-6dc031de.js";import"./p-108fee57.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-7e0a0aae.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 +0,0 @@
1
- import{r as t,h as e,H as i,g as s}from"./p-d2d301a6.js";import{ApplicationContext as o,ObjectUtils as r,UserInterface as n,DataType as l,ElementIDUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as h}from"@sankhyalabs/ezui/dist/collection/utils";import{I as c}from"./p-8f3f2306.js";import{D as u,a as p,b as m}from"./p-0f3698af.js";import{R as v}from"./p-1d19a5b0.js";import{D as x}from"./p-5a7e18f4.js";import{S as g}from"./p-abd9681c.js";import"./p-108fee57.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-01512409.js";import"./p-8d884fab.js";import"./p-17425c72.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===u.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===u.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];if(t===u.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===u.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportAllRecords(t,e){var i;const s=[u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS];if(t===u.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===u.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS())}}setExportByEmail(t,e){t===u.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:u.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:u.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getCurrentPage(){return{id:u.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:u.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:u.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:u.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToPDF(){return{id:u.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:u.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:u.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function b(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=860)break;e.push(s)}return e}function E(t){return Object.keys(u).find((e=>u[e]===t))}class w{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async getColumns(t){var e;return(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata()}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=await this.getColumns(t),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),c=this._provider.getSelectedIDs(),p=t.exportOption,m=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];delete t.exportOption;let v=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:c.slice(0,this._provider.getExportLimit())},t);if(m.includes(p)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();v=Object.assign(Object.assign({},v),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(v=Object.assign(Object.assign({},v),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(v)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{x.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class D{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async executeExport(t){var e;const{methodName:i,gridTitle:s}=t,o=await this._provider.getRecords(t.type),r=(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[n,l]=this.getExecutor(i),a={serviceName:n,requestBody:{grid:{gridTitle:s,columns:this.buildColumnsObject(r),rows:this.buildRowsObject(r,o),customOptions:{xlsxExtension:!1}}}};return new Promise(((t,e)=>{x.get().callServiceBroker(n,a).then((e=>t(l(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!0,canExport:!0,canSendEmail:!0,useAppPrint:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},k[r]||{type:"S",align:"left"})}))}}buildRowsObject(t,e){return{row:e.map((e=>{const i={};return t.forEach(((t,s)=>i["c"+(s+1)]={$:this.formatValue(e,t)})),i}))}}formatValue(t,e){return null!=this._provider.formatValue?this._provider.formatValue(t,e):t[e.id]||""}}const k={[n.DATE]:{type:"D",align:"center"},[n.DATETIME]:{type:"H",align:"center"},[n.TIME]:{type:"I",align:"right"},[n.ELAPSEDTIME]:{type:"I",align:"right"},[n.DECIMALNUMBER]:{type:"F",align:"right"},[n.INTEGERNUMBER]:{type:"I",align:"right"},[n.SEARCH]:{type:"S",align:"right"}},y=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[u.EXPORT_TO_PDF,u.EXPORT_TO_XLS,u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS],this._items=[],this._showDropdown=!1,this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=m[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:m.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,gridTitle:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=g.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new w(this.provider):new D(this.provider)}getOptionKey(t){return Object.keys(u).find((e=>u[e]===t))}getExportType(t){return t===u.EXPORT_ALL_RECORDS_TO_PDF||t===u.EXPORT_ALL_RECORDS_TO_XLS?c.ALL:t===u.EXPORT_PAGE_TO_PDF||t===u.EXPORT_PAGE_TO_XLS?c.PAGE:c.SELECTION}async dispatchExporter(t){var e,i,s;const r=this.getOptionKey(t),n=null!==(e=p[r])&&void 0!==e?e:p.EXPORT_TO_PDF,l={methodName:u[`EXPORT_TO_${n}`],fileName:this._appLabel,gridTitle:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t)};await this.resolveExporter(l,(t=>{t.canExport||n===p.EXPORT_TO_PDF?function({fileSessionKey:t,isDownload:e}){const i=o.getContextValue("__SNK__APPLICATION__");window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${e?"&download=S":""}`),d.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(i),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:n})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,c=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS],p=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===u.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),g=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let f=!1;if(c.includes(null==a?void 0:a.id)&&x<=g||p?f=!1:(null==m?void 0:m.length)?f=m.length>g:v>g&&(f=!0),f){const t=g.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(p)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===u.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>x.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${v}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};y.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{y as snk_data_exporter}
@@ -1,15 +0,0 @@
1
- import { FormLayout } from '@sankhyalabs/ezui/dist/collection/utils';
2
- export declare class SnkLayoutFormConfig {
3
- private _formConfigFetcher;
4
- private _LayoutFormConfigSingleton;
5
- private _resourceID;
6
- /**
7
- * Salva o tipo de layout escolhido. Sem retorno.
8
- */
9
- save(): Promise<void>;
10
- layoutType: FormLayout;
11
- componentWillLoad(): Promise<void>;
12
- setLayoutInit(): void;
13
- toggleLayout(key: FormLayout): void;
14
- render(): any;
15
- }
@@ -1,10 +0,0 @@
1
- import { FormLayout } from '@sankhyalabs/ezui/dist/collection/utils';
2
- export declare class SnkViewRepresentation {
3
- /**
4
- * Define o layout do componente: 'CASCADE' ou 'SIDE_BY_SIDE'
5
- */
6
- mode: FormLayout;
7
- renderCascadeLayout(): any;
8
- renderSideBySideLayout(): any;
9
- render(): any;
10
- }
@@ -1,11 +0,0 @@
1
- export declare class LayoutFormConfig {
2
- private static instance;
3
- private _config;
4
- private listeners;
5
- private constructor();
6
- static getInstance(): LayoutFormConfig;
7
- get config(): Number;
8
- setConfig(newConfig: Number): void;
9
- onConfigChange(listener: (config: Number) => void): void;
10
- private notifyListeners;
11
- }