@sankhyalabs/sankhyablocks 8.1.0 → 8.2.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/cjs/{ConfigStorage-73e7afff.js → ConfigStorage-e9d7fa82.js} +4 -4
  2. package/dist/cjs/{DataFetcher-004811c6.js → DataFetcher-39b63a1e.js} +1 -1
  3. package/dist/cjs/{SnkFormConfigManager-d1f1a222.js → SnkFormConfigManager-2f8eccd9.js} +2 -2
  4. package/dist/cjs/auth-fetcher-d407c31c.js +34 -0
  5. package/dist/cjs/{dataunit-fetcher-029eafbd.js → dataunit-fetcher-15a7cc88.js} +1 -1
  6. package/dist/cjs/{filter-bar-config-fetcher-2b8ed9d0.js → filter-bar-config-fetcher-24548cec.js} +1 -1
  7. package/dist/cjs/{form-config-fetcher-181767c9.js → form-config-fetcher-ab3ce222.js} +2 -2
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/{pesquisa-fetcher-9a97994a.js → pesquisa-fetcher-96c042aa.js} +1 -1
  10. package/dist/cjs/{resource-fetcher-c0332609.js → resource-fetcher-64102551.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-application.cjs.entry.js +10 -37
  14. package/dist/cjs/snk-attach.cjs.entry.js +2 -2
  15. package/dist/cjs/snk-crud.cjs.entry.js +9 -5
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  17. package/dist/cjs/{snk-data-unit-d5109a08.js → snk-data-unit-e89e07bd.js} +4 -3
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +13 -22
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -5
  21. package/dist/cjs/snk-filter-detail.cjs.entry.js +3 -3
  22. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -5
  23. package/dist/cjs/snk-form-config.cjs.entry.js +3 -3
  24. package/dist/cjs/snk-form.cjs.entry.js +6 -6
  25. package/dist/cjs/snk-grid-config.cjs.entry.js +5 -5
  26. package/dist/cjs/snk-grid.cjs.entry.js +9 -6
  27. package/dist/cjs/{snk-guides-viewer-aa3e3bfa.js → snk-guides-viewer-8518c61b.js} +5 -6
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +5 -5
  30. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  31. package/dist/cjs/snk-simple-crud.cjs.entry.js +5 -11
  32. package/dist/collection/components/snk-crud/snk-crud.js +26 -5
  33. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +24 -14
  34. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +20 -3
  35. package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -3
  36. package/dist/collection/components/snk-grid/snk-grid.js +60 -2
  37. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +21 -9
  38. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
  39. package/dist/components/DataFetcher.js +1 -1
  40. package/dist/components/auth-fetcher.js +32 -0
  41. package/dist/components/snk-application2.js +1 -29
  42. package/dist/components/snk-crud.js +8 -3
  43. package/dist/components/snk-data-unit2.js +5 -3
  44. package/dist/components/snk-detail-view2.js +10 -17
  45. package/dist/components/snk-grid2.js +7 -1
  46. package/dist/components/snk-simple-crud2.js +4 -9
  47. package/dist/esm/{ConfigStorage-19a7260b.js → ConfigStorage-1090289a.js} +4 -4
  48. package/dist/esm/{DataFetcher-e0fc5549.js → DataFetcher-a4ed43e7.js} +1 -1
  49. package/dist/esm/{SnkFormConfigManager-1a42eb02.js → SnkFormConfigManager-de537eca.js} +2 -2
  50. package/dist/esm/auth-fetcher-c53e0d6c.js +32 -0
  51. package/dist/esm/{dataunit-fetcher-6a695723.js → dataunit-fetcher-8d0bfa4a.js} +1 -1
  52. package/dist/esm/{filter-bar-config-fetcher-06e02851.js → filter-bar-config-fetcher-2417b8cf.js} +1 -1
  53. package/dist/esm/{form-config-fetcher-9e167008.js → form-config-fetcher-4065db9a.js} +2 -2
  54. package/dist/esm/loader.js +1 -1
  55. package/dist/esm/{pesquisa-fetcher-9118eb7a.js → pesquisa-fetcher-7460b876.js} +1 -1
  56. package/dist/esm/{resource-fetcher-768d5556.js → resource-fetcher-45a70066.js} +1 -1
  57. package/dist/esm/sankhyablocks.js +1 -1
  58. package/dist/esm/snk-actions-button.entry.js +2 -2
  59. package/dist/esm/snk-application.entry.js +8 -35
  60. package/dist/esm/snk-attach.entry.js +2 -2
  61. package/dist/esm/snk-crud.entry.js +9 -5
  62. package/dist/esm/snk-data-exporter.entry.js +2 -2
  63. package/dist/esm/{snk-data-unit-3a0bbfcb.js → snk-data-unit-8c4d944d.js} +4 -3
  64. package/dist/esm/snk-data-unit.entry.js +1 -1
  65. package/dist/esm/snk-detail-view.entry.js +13 -22
  66. package/dist/esm/snk-filter-bar.entry.js +5 -5
  67. package/dist/esm/snk-filter-detail.entry.js +3 -3
  68. package/dist/esm/snk-filter-modal-item.entry.js +5 -5
  69. package/dist/esm/snk-form-config.entry.js +3 -3
  70. package/dist/esm/snk-form.entry.js +6 -6
  71. package/dist/esm/snk-grid-config.entry.js +5 -5
  72. package/dist/esm/snk-grid.entry.js +9 -6
  73. package/dist/esm/{snk-guides-viewer-aa386f6e.js → snk-guides-viewer-cdecff6e.js} +5 -6
  74. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  75. package/dist/esm/snk-personalized-filter.entry.js +5 -5
  76. package/dist/esm/snk-print-selector.entry.js +1 -1
  77. package/dist/esm/snk-simple-crud.entry.js +5 -11
  78. package/dist/sankhyablocks/{p-7c7764bf.entry.js → p-0848ee4d.entry.js} +1 -1
  79. package/dist/sankhyablocks/p-0bd9c412.js +1 -0
  80. package/dist/sankhyablocks/{p-976e56e9.js → p-0fb83448.js} +1 -1
  81. package/dist/sankhyablocks/p-10b2aedc.entry.js +1 -0
  82. package/dist/sankhyablocks/p-1f63dcd4.entry.js +1 -0
  83. package/dist/sankhyablocks/p-216b2102.entry.js +1 -0
  84. package/dist/sankhyablocks/{p-df8621b4.js → p-44e66c8d.js} +1 -1
  85. package/dist/sankhyablocks/{p-6759adae.entry.js → p-4514fc6a.entry.js} +1 -1
  86. package/dist/sankhyablocks/{p-bc735728.entry.js → p-50c13cc8.entry.js} +1 -1
  87. package/dist/sankhyablocks/{p-d1b89765.js → p-52c6b2e7.js} +1 -1
  88. package/dist/sankhyablocks/p-564efc43.js +1 -0
  89. package/dist/sankhyablocks/{p-8f8184ff.js → p-5994af77.js} +1 -1
  90. package/dist/sankhyablocks/{p-0ed0fc02.entry.js → p-6bb904bb.entry.js} +1 -1
  91. package/dist/sankhyablocks/p-6e06175e.entry.js +1 -0
  92. package/dist/sankhyablocks/{p-c0f656af.entry.js → p-6f0795c8.entry.js} +1 -1
  93. package/dist/sankhyablocks/{p-f31bfdee.entry.js → p-7588f006.entry.js} +1 -1
  94. package/dist/sankhyablocks/{p-98f9d076.js → p-847e6c20.js} +2 -2
  95. package/dist/sankhyablocks/p-8f3652bf.entry.js +11 -0
  96. package/dist/sankhyablocks/{p-e28129aa.entry.js → p-9471cbc9.entry.js} +1 -1
  97. package/dist/sankhyablocks/{p-0a4c753d.js → p-9d18017a.js} +1 -1
  98. package/dist/sankhyablocks/{p-815a42c0.entry.js → p-a42dd503.entry.js} +1 -1
  99. package/dist/sankhyablocks/p-b04fb9d4.js +1 -0
  100. package/dist/sankhyablocks/{p-2ac9c585.js → p-b978da60.js} +1 -1
  101. package/dist/sankhyablocks/p-c32b9d7c.entry.js +1 -0
  102. package/dist/sankhyablocks/{p-e7e54737.entry.js → p-c6feb995.entry.js} +1 -1
  103. package/dist/sankhyablocks/{p-8a41172a.entry.js → p-d7c7a289.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-7b8b8ae9.js → p-f3b7b69e.js} +1 -1
  105. package/dist/sankhyablocks/{p-be684b38.entry.js → p-f7eded3a.entry.js} +1 -1
  106. package/dist/sankhyablocks/p-ff7383b0.entry.js +1 -0
  107. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  108. package/dist/types/components/snk-crud/snk-crud.d.ts +5 -0
  109. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +5 -0
  110. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +4 -0
  111. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
  112. package/dist/types/components/snk-grid/snk-grid.d.ts +13 -0
  113. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
  114. package/dist/types/components.d.ts +64 -0
  115. package/package.json +1 -1
  116. package/dist/sankhyablocks/p-0a94fdbd.entry.js +0 -1
  117. package/dist/sankhyablocks/p-1e0189ff.entry.js +0 -1
  118. package/dist/sankhyablocks/p-50d72261.entry.js +0 -1
  119. package/dist/sankhyablocks/p-8fdc3108.js +0 -1
  120. package/dist/sankhyablocks/p-9edad923.js +0 -1
  121. package/dist/sankhyablocks/p-abdcac04.entry.js +0 -1
  122. package/dist/sankhyablocks/p-b0847056.entry.js +0 -1
  123. package/dist/sankhyablocks/p-ccbfb1cf.entry.js +0 -1
  124. package/dist/sankhyablocks/p-f92fda53.entry.js +0 -11
@@ -1 +0,0 @@
1
- import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{ElementIDUtils as d,ApplicationContext as r,DataType as a}from"@sankhyalabs/core";import{UserInterface as n}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{T as o}from"./p-a2493d11.js";import{C as l}from"./p-8f8184ff.js";import{P as h}from"./p-5534e08c.js";import{T as u}from"./p-c2beb95c.js";import{s as c}from"./p-6dc031de.js";import{S as v}from"./p-fa9d3f73.js";import{SelectionMode as g}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-98f9d076.js";import"./p-df8621b4.js";import"./p-112455b1.js";import"./p-7b8b8ae9.js";import"./p-976e56e9.js";import"./p-584d7212.js";const m=class{constructor(s){i(this,s),this.actionClick=t(this,"actionClick",7),this.gridDoubleClick=t(this,"gridDoubleClick",7),this._multiSelectionListDataSource=new v,this._topTaskbarProcessor=new u({"snkGridTopTaskbar.regular":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.secondary":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.finish_edition":["CANCEL","SAVE"],"snkGridTopTaskbar.finish_edition.secondary":[]}),this._headerTaskbarProcessor=new u({"snkGridHeaderTaskbar.unselected":["REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.detail.unselected":["REFRESH"],"snkGridHeaderTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","REFRESH"]}),this._dataUnit=void 0,this._dataState=void 0,this._gridConfig=void 0,this._popUpGridConfig=!1,this.configName=void 0,this.selectionToastConfig=void 0,this.actionsList=void 0,this.isDetail=void 0,this.taskbarManager=void 0,this.statusResolver=void 0,this.multipleSelection=void 0,this.presentationMode=h.PRIMARY,this.messagesBuilder=void 0}async showConfig(){null!=this._grid&&this.openGridConfig()}async hideConfig(){null!=this._grid&&this.closeGridConfig()}async setConfig(i){this.setGridConfig(i)}async reloadFilterBar(){var i;null===(i=this._snkFilterBar)||void 0===i||i.reload()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._popUpGridConfig=!0}))}closeGridConfig(){this._popUpGridConfig=!1}setGridConfig(i){this._gridConfig=i}loadConfig(){l.get().then((i=>{i.loadGridConfig(this.configName).then((i=>{this.setGridConfig(i)})).catch((i=>{console.warn(i)}))}))}gridConfigChangeHandler(i){l.saveGridConfig(i.detail,this.configName),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}buildColumnsMetadata(i){const t=[];return null==i||i.forEach((i=>{var s,e;if(i.hidden&&"RECDESP"!==i.name)return;const d=null===(s=this._dataUnit)||void 0===s?void 0:s.getField(i.name);if(t.push({label:i.label,id:i.name,width:i.width,type:null==d?void 0:d.dataType,userInterface:null==d?void 0:d.userInterface}),null!=(null===(e=null==d?void 0:d.properties)||void 0===e?void 0:e.DESCRIPTIONFIELD)){const i=d.properties.mergedFrom;t.push({label:d.properties.DESCRIPTIONENTITY,id:`${i?i+".":""}${d.properties.ENTITYNAME}.${d.properties.DESCRIPTIONFIELD}`,width:200,type:a.TEXT,userInterface:n.LONGTEXT})}})),t||[]}getPaginationInfo(){var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getPaginationInfo()}getExporterOffset(i){if(null==i)return;const t=i.firstRecord;return t>0?t-1:t}async dataExporterProviderStore(){var i;const t=await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getSelectedRecordsIDsInfo()),s={getFilters:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},getColumnsMetadata:async()=>{var i;const t=await(null===(i=this._grid)||void 0===i?void 0:i.getColumnsState());return this.buildColumnsMetadata(t)},getOrders:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getSort()},getResourceURI:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.name},getSelectedNumber:()=>{var i,t;return null===(t=null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.length},getTotalRecords:()=>{var i,t,s;const{total:e}=(null===(i=this._dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length},getSelectedIDs:()=>t||[],getOffset:()=>this.getExporterOffset(this.getPaginationInfo()),getLimit:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.pageSize},getRecordID:()=>{var i,t,s;return null===(s=null===(t=null===(i=this._dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}};c.set("exporterProviders",Object.assign(Object.assign({},c.get("exporterProviders")),{[this.configName]:s}))}addElementID(){d.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}finshLoading(){this._dataUnitLoadLockerResolver=this._dataUnit.addLoadingLocker(),this.addElementID(),this._multiSelectionListDataSource.setApplication(this._application),this._multiSelectionListDataSource.setDataUnit(this._dataUnit)}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataUnit?this.finshLoading():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.finshLoading()})),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),this._snkDataUnit.addEventListener("dataStateChange",(i=>{this._dataState=i.detail})),this._snkDataUnit.addEventListener("cancelEdition",(()=>{var i;(null===(i=this._dataState)||void 0===i?void 0:i.recordsIsEmpty)&&this._dataUnit.clearSelection()}));break}i=i.parentElement}this.loadConfig()}getHeaderDisabledButtons(){var i;const t=[];return(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)&&(this._dataState.selectionInfo.length>1&&t.push(o.CLONE,"ATTACH"),this._dataState.selectionInfo.isAllRecords()&&t.push("REMOVE")),t}getInvisibleButtons(){let i=[];return this._dataUnit&&0!==this._dataUnit.records.length||i.push("DATA_EXPORTER"),this._dataState&&this._dataState.selectionInfo.mode===g.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}componentWillRender(){var i;const t=this.getInvisibleButtons();let s;s=this._dataState&&(null===(i=this._dataState.selectionInfo)||void 0===i?void 0:i.length)?this.isDetail?"snkGridHeaderTaskbar.detail.selected":"snkGridHeaderTaskbar.selected":this.isDetail?"snkGridHeaderTaskbar.detail.unselected":"snkGridHeaderTaskbar.unselected",this._headerTaskbarProcessor.process(s,this.taskbarManager,this._dataState,this.getHeaderDisabledButtons(),t),this._topTaskbarProcessor.process(this.getTopTaskBarId(this.presentationMode===h.SECONDARY?".secondary":""),this.taskbarManager,this._dataState,void 0,t),this.dataExporterProviderStore()}getTopTaskBarId(i){var t;return(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)?`snkGridTopTaskbar.finish_edition${i}`:`snkGridTopTaskbar.regular${i}`}getPrimaryButton(){return this.presentationMode===h.PRIMARY?"INSERT":""}onEzGridReady(){var i;null===(i=this._dataUnitLoadLockerResolver)||void 0===i||i.call(this),this._dataUnitLoadLockerResolver=void 0}render(){var i,t;if(this._dataUnit)return s("div",{class:"snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large"},s("div",{class:"snk-grid__header ez-margin-bottom--medium"},s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder}),(null===(t=null===(i=this._snkFilterBar)||void 0===i?void 0:i.filterConfig)||void 0===t?void 0:t.length)>0&&s("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider"}),s("snk-taskbar",{class:"ez-padding-left--medium","data-element-id":"grid_top",key:"topTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._topTaskbarProcessor.buttons,disabledButtons:this._topTaskbarProcessor.disabledButtons,customButtons:this._topTaskbarProcessor.customButtons,primaryButton:this.getPrimaryButton()})),s("ez-grid",{ref:i=>this._grid=i,class:(this.presentationMode===h.SECONDARY?"snk-grid-container__without-shadow ":"")+"snk-grid__table","data-element-id":"embedded",dataUnit:this._dataUnit,key:"grid-"+this._snkDataUnit.entityName,config:this._gridConfig,onConfigChange:i=>{this.gridConfigChangeHandler(i)},onEzDoubleClick:()=>this.gridDoubleClick.emit(),statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,onComponentReady:()=>this.onEzGridReady(),columnfilterDataSource:this._multiSelectionListDataSource,selectionToastConfig:this.selectionToastConfig},s("snk-taskbar",{dataUnit:this._dataUnit,configName:this.configName,messagesBuilder:this.messagesBuilder,"data-element-id":"grid_left",buttons:this._headerTaskbarProcessor.buttons,disabledButtons:this._headerTaskbarProcessor.disabledButtons,customButtons:this._headerTaskbarProcessor.customButtons,slot:"leftButtons",actionsList:this.actionsList})),s("div",{class:"ez-col ez-col--sd-12"},s("slot",{name:"SnkGridFooter"})),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._popUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this._gridConfig,"data-element-id":this._element.getAttribute(d.DATA_ELEMENT_ID_ATTRIBUTE_NAME),application:this._application,selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig()})))}get _element(){return e(this)}};m.style=".snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%}.snk-grid__header.sc-snk-grid{display:flex;flex-wrap:nowrap;width:100%}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:300px}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}";export{m as snk_grid}
@@ -1 +0,0 @@
1
- export{S as snk_data_unit}from"./p-9edad923.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"@sankhyalabs/ezui/dist/collection/utils";import"./p-ae6aff81.js";
@@ -1,11 +0,0 @@
1
- import{r as t,c as e,h as s,g as i}from"./p-d2d301a6.js";import{WaitingChangeException as r,WarningException as n,ErrorException as a,ObjectUtils as o,DateUtils as c,StringUtils as h,OnboardingUtils as u,DependencyType as l,ElementIDUtils as p,ApplicationContext as d,ErrorTracking as m,DataType as w}from"@sankhyalabs/core";import{d as f,D as y,U as g}from"./p-df8621b4.js";import{ApplicationUtils as P}from"@sankhyalabs/ezui/dist/collection/utils";import{P as v}from"./p-0a4c753d.js";import{G as I,C as A}from"./p-8f8184ff.js";import{D as S}from"./p-2ac9c585.js";import{R as _}from"./p-7b8b8ae9.js";import{S as E}from"./p-ae6aff81.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-98f9d076.js";import"./p-976e56e9.js";import"./p-584d7212.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";class C{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}rejectionHandler(t){const e=t.reason;e instanceof r||(e?this.processException(e):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 r||t instanceof n?this._app.alert(t.title,t.message):t instanceof a?this._app.error(t.title,t.message):this._app.isDebugMode().then((e=>{if(e)if(t instanceof Error)this._app.error(t.name,t.message);else{const e=(null==t?void 0:t.title)||"Erro detectado",s="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(e,s)}}))}}function D(){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(D=function(){return t})()}const T=b;function b(t,e){const s=D();return(b=function(t){return s[t-=392]})(t,e)}!function(){const t=b,e=D();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;e.push(e.shift())}catch(t){e.push(e.shift())}}();const N=T(396);class j{constructor(){this.templateByQuery=new Map,this.cancel=[],this.buildTemplates()}buildTemplates(){this.templateByQuery.set("fetchTotals",f.gql`query($filters: [InputFilter!] $name: String!) {
2
- $queryAlias$: fetchTotals(name: $name, filters: $filters ){
3
- name
4
- value
5
- }
6
- }`)}fetchTotals(t,e,s=[]){const i=`${t}_${e}`,r=this.cancel.findIndex((t=>t[i]));return r>=0&&(this.cancel[r][i](),this.cancel.splice(r,1)),Promise.race([new Promise((t=>this.cancel.push({[i]:t}))),this.getTotals(t,e,s)]).then((t=>{let e=new Map;if(t){e=t;const s=this.cancel.findIndex((t=>t[i]));s>=0&&this.cancel.splice(s,1)}return e}))}getTotals(t,e,s=[]){return new Promise(((i,r)=>{y.get().callGraphQL({query:this.templateByQuery.get("fetchTotals"),values:{name:`totals://${t}/${e}`,filters:s}}).then((t=>{if(t.length>0){const e=new Map;return t.forEach((t=>e.set(t.name,parseFloat(t.value)))),i(e)}return r("Não foi possível recuperar os totalizadores")})).catch(r)}))}}var k;class O{static openAppActivity(t,e){var s;null===(s=window.workspace)||void 0===s||s.openAppActivity(t,e)}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)}}O.resourceID=null===(k=window.workspace)||void 0===k?void 0:k.resourceID;class L{static webConnectionCaller(t,e,s){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,e,s)}}class U{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",f.gql`query($name: String!) {
7
- $queryAlias$: fetchResource(name: $name){
8
- name
9
- resource
10
- }
11
- }`)}async getParam(t){const e=`param://application?params=${t}`;return y.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return"S"===this.getValue(e)}async asDate(t){const e=await this.getParam(t);return c.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){if(Array.isArray(t)&&t.length>0&&(t=t[0]),h.isEmpty(t.resource))return"";try{const e=o.stringToObject(t.resource),[s]=Object.keys(e);return e[s]}catch(t){console.warn("Erro ao converter string JSON.")}}}const $=R;function R(t,e){const s=M();return(R=function(t){return s[t-=378]})(t,e)}function M(){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(M=function(){return t})()}!function(){const t=R,e=M();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;e.push(e.shift())}catch(t){e.push(e.shift())}}();class F{[$(397)](t){const e=$;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new q("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class q{constructor(t){const e=$;this.isSup=t,this[e(384)]={}}[$(378)](t,e){this[$(384)][t]=e}[$(393)](t){const e=$;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class x extends _{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=o.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var z;!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(z||(z={}));const G=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new H,this.messagesBuilder=void 0,this.configName=void 0}get parameters(){return this._parameters||(this._parameters=new U),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||O.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new J(t,e)),s||this.authFetcher.getData(this.resourceID).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)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}initOnboarding(t){return u.getInstance().init(t,window.envContext),Promise.resolve()}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(z).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).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,e="full",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}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 e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{y.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{y.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){O.openAppActivity(t,e)}async webConnection(t,e,s){this.getStringParam(t).then((t=>{L.webConnectionCaller(t,e,s)}))}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e,s,i){return new Promise(((r,n)=>{const a=this.getDuPromissesStack(e),o=a.length>0;if(a.push(new J(r,n)),!o){const r=this.dataUnitFetcher.getDataUnit(t,this.resourceID,s,i);r.loadMetadata().then((()=>{for(e&&this.updateDataunitCache(void 0,e,r);a.length>0;)a.pop().resolve(r)})).catch((t=>{for(;a.length>0;)a.pop().reject(t)}))}}))}async updateDataunitCache(t,e,s){t&&this._duCache.delete(t),this._duCache.set(e,s)}async getDataUnit(t,e,s,i){return new Promise(((r,n)=>{const a=this._duCache.get(e);a?r(a):this.createDataunit(t,e,s,i).then((t=>{r(t)})).catch((t=>n(t)))}))}async addClientEvent(t,e){return new Promise((s=>{y.addClientEvent(t,e),s()}))}async removeClientEvent(t){return new Promise((e=>{y.removeClientEvent(t),e()}))}async hasClientEvent(t){return new Promise((e=>{e(y.hasClientEvent(t))}))}async callServiceBroker(t,e,s){return y.get().callServiceBroker(t,e,s)}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return P.alert(t,e,s,i)}async error(t,e,s,i){return P.error(t,e,s,i)}async success(t,e,s,i){return P.success(t,e,s,i)}async message(t,e,s,i){return P.message(t,e,s,i)}async confirm(t,e,s,i,r){return P.confirm(t,e,s,i,r)}async info(t,e){return P.info(t,e)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async getAuthList(t){return await(new F).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=g.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new S),this._dataUnitFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new I),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new j),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new v),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new x),this._authFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:c,DESCRIPTIONENTITY:h}=i.properties,u=i.dependencies;let p;const d={rootEntity:c,descriptionFieldName:o,codeFieldName:a,showInactives:!1,dataUnitId:s.dataUnitId};return null==u||u.filter((t=>t.masterFields)).forEach((t=>{var e;t.type===l.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(p={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||w.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:h,criteria:p,searchOptions:d})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s[p.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return O.getAppLabel(this._resourceID)}addSearchListener(t,e,s){return new Promise((i=>{i(this.pesquisaFetcher.addSearchListener(t,e.dataUnitId,s))}))}importScript(t){return new Promise((e=>{this.getApplicationPath().then((s=>{let i=[];Array.isArray(t)||(i=[t]),i.forEach((t=>{const e=document.createElement("script");e.src=`${s}/${t}`,e.async=!0,document.body.appendChild(e)})),e()}))}))}getApplicationPath(){return new Promise((t=>{"dev"!==window.applicationenv&&t(`/${window.MGE_MODULE_NAME}/labsApps/${window.APPLICATION_NAME}/build`),t("")}))}executeSelectDistinct(t,e,s){return this.dataUnitFetcher.loadSelectDistinct(t,e,s)}getDataFetcher(){return Promise.resolve(y.get())}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new C(this),this.messagesBuilder=new E,d.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${g.getUrlBase()}/mge/upload/file`),d.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),d.setContextValue("__EZUI__GRID_LICENSE__",N),m.init(),A.get()}connectedCallback(){d.setContextValue("__SNK__APPLICATION__",this),y.addRequestListener(this._requestListener)}disconnectedCallback(){y.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),p.addIDInfo(this._element,`resource_${this._resourceID}`)}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}get _element(){return i(this)}};class H{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class J{constructor(t,e){this.resolve=t,this.reject=e}}G.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{G as snk_application}