@sankhyalabs/sankhyablocks 10.1.0-dev.14 → 10.1.0-dev.16

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 (175) hide show
  1. package/dist/cjs/{SnkMultiSelectionListDataSource-3f561345.js → SnkMultiSelectionListDataSource-72925620.js} +1 -1
  2. package/dist/cjs/config-header.cjs.entry.js +1 -1
  3. package/dist/cjs/configs-button.cjs.entry.js +1 -1
  4. package/dist/cjs/field-config_2.cjs.entry.js +2 -2
  5. package/dist/cjs/fields-layout.cjs.entry.js +1 -1
  6. package/dist/cjs/fields-selector.cjs.entry.js +1 -1
  7. package/dist/cjs/guides-configurator.cjs.entry.js +1 -1
  8. package/dist/cjs/{index-13d05f03.js → index-516250fa.js} +1 -1
  9. package/dist/cjs/{index-1cf293c1.js → index-dc83c596.js} +0 -17
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
  12. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  13. package/dist/cjs/snk-actions-button_9.cjs.entry.js +1 -1
  14. package/dist/cjs/snk-actions-form.cjs.entry.js +1 -1
  15. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  16. package/dist/cjs/snk-attach.cjs.entry.js +3 -3
  17. package/dist/cjs/snk-client-confirm.cjs.entry.js +1 -1
  18. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-crud.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-custom-slot-guide.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  23. package/dist/cjs/{snk-data-unit-b8ea81e1.js → snk-data-unit-47f02b9e.js} +1 -1
  24. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  25. package/dist/cjs/snk-default-filter.cjs.entry.js +1 -1
  26. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
  27. package/dist/cjs/snk-entity-list.cjs.entry.js +1 -1
  28. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  29. package/dist/cjs/snk-expression-group_2.cjs.entry.js +2 -2
  30. package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +1 -1
  31. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +1 -1
  32. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  34. package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
  35. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +1 -1
  36. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
  37. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  38. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  39. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  40. package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
  41. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  42. package/dist/cjs/snk-form-summary.cjs.entry.js +1 -1
  43. package/dist/cjs/snk-form-view.cjs.entry.js +1 -1
  44. package/dist/cjs/snk-form_2.cjs.entry.js +1 -1
  45. package/dist/cjs/snk-grid.cjs.entry.js +15 -9
  46. package/dist/cjs/{snk-guides-viewer-61701970.js → snk-guides-viewer-41c22d96.js} +2 -2
  47. package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
  48. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
  49. package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -2
  50. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  51. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  52. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  53. package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -4
  54. package/dist/cjs/snk-taskbar.cjs.entry.js +3 -3
  55. package/dist/cjs/{taskbar-elements-fb5d1e08.js → taskbar-elements-756fcbe7.js} +2 -2
  56. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  57. package/dist/collection/components/snk-form-config/field-item/field-config/field-config.css +1 -0
  58. package/dist/collection/components/snk-grid/snk-grid.js +12 -7
  59. package/dist/components/field-config2.js +1 -1
  60. package/dist/components/snk-grid2.js +12 -6
  61. package/dist/esm/{SnkMultiSelectionListDataSource-2d1ea0c5.js → SnkMultiSelectionListDataSource-493ae8c8.js} +1 -1
  62. package/dist/esm/config-header.entry.js +1 -1
  63. package/dist/esm/configs-button.entry.js +1 -1
  64. package/dist/esm/field-config_2.entry.js +2 -2
  65. package/dist/esm/fields-layout.entry.js +1 -1
  66. package/dist/esm/fields-selector.entry.js +1 -1
  67. package/dist/esm/guides-configurator.entry.js +1 -1
  68. package/dist/esm/{index-446f9341.js → index-3355bd17.js} +1 -1
  69. package/dist/esm/{index-479e1293.js → index-7fd74680.js} +0 -17
  70. package/dist/esm/loader.js +2 -2
  71. package/dist/esm/pesquisa-grid_2.entry.js +1 -1
  72. package/dist/esm/sankhyablocks.js +2 -2
  73. package/dist/esm/snk-actions-button_9.entry.js +1 -1
  74. package/dist/esm/snk-actions-form.entry.js +1 -1
  75. package/dist/esm/snk-application.entry.js +1 -1
  76. package/dist/esm/snk-attach.entry.js +3 -3
  77. package/dist/esm/snk-client-confirm.entry.js +1 -1
  78. package/dist/esm/snk-configurator.entry.js +1 -1
  79. package/dist/esm/snk-crud.entry.js +3 -3
  80. package/dist/esm/snk-custom-slot-elements.entry.js +1 -1
  81. package/dist/esm/snk-custom-slot-guide.entry.js +1 -1
  82. package/dist/esm/snk-data-exporter.entry.js +2 -2
  83. package/dist/esm/{snk-data-unit-6f31ec56.js → snk-data-unit-9e9d9d46.js} +1 -1
  84. package/dist/esm/snk-data-unit.entry.js +2 -2
  85. package/dist/esm/snk-default-filter.entry.js +1 -1
  86. package/dist/esm/snk-detail-view.entry.js +4 -4
  87. package/dist/esm/snk-entity-list.entry.js +1 -1
  88. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  89. package/dist/esm/snk-expression-group_2.entry.js +2 -2
  90. package/dist/esm/snk-filter-advanced-mode_2.entry.js +1 -1
  91. package/dist/esm/snk-filter-bar_4.entry.js +1 -1
  92. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  93. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  94. package/dist/esm/snk-filter-detail.entry.js +1 -1
  95. package/dist/esm/snk-filter-field-search_2.entry.js +1 -1
  96. package/dist/esm/snk-filter-modal-item.entry.js +1 -1
  97. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  98. package/dist/esm/snk-filter-number.entry.js +1 -1
  99. package/dist/esm/snk-filter-period.entry.js +1 -1
  100. package/dist/esm/snk-filter-search.entry.js +1 -1
  101. package/dist/esm/snk-filter-text.entry.js +1 -1
  102. package/dist/esm/snk-form-summary.entry.js +1 -1
  103. package/dist/esm/snk-form-view.entry.js +1 -1
  104. package/dist/esm/snk-form_2.entry.js +1 -1
  105. package/dist/esm/snk-grid.entry.js +15 -9
  106. package/dist/esm/{snk-guides-viewer-c31259f0.js → snk-guides-viewer-31ef5fc6.js} +2 -2
  107. package/dist/esm/snk-guides-viewer.entry.js +4 -4
  108. package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
  109. package/dist/esm/snk-personalized-filter.entry.js +2 -2
  110. package/dist/esm/snk-pesquisa.entry.js +1 -1
  111. package/dist/esm/snk-print-selector.entry.js +1 -1
  112. package/dist/esm/snk-simple-bar.entry.js +1 -1
  113. package/dist/esm/snk-simple-crud.entry.js +4 -4
  114. package/dist/esm/snk-taskbar.entry.js +3 -3
  115. package/dist/esm/{taskbar-elements-faaf5d8f.js → taskbar-elements-bf5b73f1.js} +2 -2
  116. package/dist/esm/teste-pesquisa.entry.js +1 -1
  117. package/dist/sankhyablocks/{p-6b9833c7.entry.js → p-02cb4829.entry.js} +1 -1
  118. package/dist/sankhyablocks/{p-af3aface.entry.js → p-0893a694.entry.js} +1 -1
  119. package/dist/sankhyablocks/{p-fa8c2485.entry.js → p-0da30fd9.entry.js} +1 -1
  120. package/dist/sankhyablocks/{p-4b1c26ae.js → p-156c9f38.js} +1 -1
  121. package/dist/sankhyablocks/{p-b987e15d.js → p-1be69fd4.js} +1 -1
  122. package/dist/sankhyablocks/{p-f35f2eb3.entry.js → p-1c31f314.entry.js} +1 -1
  123. package/dist/sankhyablocks/{p-e679c75a.entry.js → p-1dba30c9.entry.js} +1 -1
  124. package/dist/sankhyablocks/{p-21107f0d.entry.js → p-1e469905.entry.js} +1 -1
  125. package/dist/sankhyablocks/{p-96d45943.entry.js → p-227e82b2.entry.js} +1 -1
  126. package/dist/sankhyablocks/{p-7af6e6b8.entry.js → p-2624dfd2.entry.js} +1 -1
  127. package/dist/sankhyablocks/{p-99a11017.entry.js → p-301baf9c.entry.js} +1 -1
  128. package/dist/sankhyablocks/{p-52c0cade.entry.js → p-357e10e0.entry.js} +1 -1
  129. package/dist/sankhyablocks/{p-987cd79d.entry.js → p-35a26068.entry.js} +1 -1
  130. package/dist/sankhyablocks/{p-180716b2.entry.js → p-3671cdd4.entry.js} +1 -1
  131. package/dist/sankhyablocks/{p-27482793.entry.js → p-4575c4aa.entry.js} +1 -1
  132. package/dist/sankhyablocks/{p-3d41f5a8.entry.js → p-497ece60.entry.js} +1 -1
  133. package/dist/sankhyablocks/{p-5fd4f0f6.entry.js → p-4deb7f46.entry.js} +1 -1
  134. package/dist/sankhyablocks/{p-bdd4f02c.entry.js → p-4e9e570c.entry.js} +1 -1
  135. package/dist/sankhyablocks/{p-3b167a03.entry.js → p-516411de.entry.js} +1 -1
  136. package/dist/sankhyablocks/{p-162bddae.entry.js → p-522d36aa.entry.js} +1 -1
  137. package/dist/sankhyablocks/{p-825098c1.entry.js → p-56b1b397.entry.js} +1 -1
  138. package/dist/sankhyablocks/{p-3f68a254.js → p-59158ba4.js} +1 -1
  139. package/dist/sankhyablocks/{p-c98c79c3.entry.js → p-5c9bea92.entry.js} +1 -1
  140. package/dist/sankhyablocks/{p-91a9abb6.entry.js → p-613eb22e.entry.js} +1 -1
  141. package/dist/sankhyablocks/{p-49ddc27a.entry.js → p-670b8802.entry.js} +1 -1
  142. package/dist/sankhyablocks/{p-60dd1d27.entry.js → p-67137d7c.entry.js} +1 -1
  143. package/dist/sankhyablocks/{p-a5e0a780.entry.js → p-7375bf6a.entry.js} +1 -1
  144. package/dist/sankhyablocks/{p-b7e891cc.entry.js → p-7961c550.entry.js} +1 -1
  145. package/dist/sankhyablocks/{p-75af335e.entry.js → p-82b59a45.entry.js} +1 -1
  146. package/dist/sankhyablocks/p-82bb3eda.js +2 -0
  147. package/dist/sankhyablocks/{p-55798617.js → p-8336900b.js} +1 -1
  148. package/dist/sankhyablocks/{p-74389ec4.entry.js → p-8488fa7e.entry.js} +1 -1
  149. package/dist/sankhyablocks/{p-cb4343c4.entry.js → p-8783d550.entry.js} +1 -1
  150. package/dist/sankhyablocks/{p-471b34f4.entry.js → p-8d76a0ca.entry.js} +1 -1
  151. package/dist/sankhyablocks/{p-9a63f3f7.entry.js → p-8d84d6ab.entry.js} +1 -1
  152. package/dist/sankhyablocks/{p-8027f732.js → p-907e96eb.js} +1 -1
  153. package/dist/sankhyablocks/{p-e258de96.entry.js → p-939523b3.entry.js} +1 -1
  154. package/dist/sankhyablocks/{p-a9b16874.entry.js → p-959fe522.entry.js} +1 -1
  155. package/dist/sankhyablocks/{p-7e250432.entry.js → p-98c70173.entry.js} +1 -1
  156. package/dist/sankhyablocks/{p-2d133b6e.entry.js → p-98e3d0a1.entry.js} +1 -1
  157. package/dist/sankhyablocks/{p-2fdac5e6.entry.js → p-abfc9880.entry.js} +1 -1
  158. package/dist/sankhyablocks/{p-728959a6.entry.js → p-b5832fa0.entry.js} +1 -1
  159. package/dist/sankhyablocks/{p-04bbdf6f.entry.js → p-c2bb0659.entry.js} +1 -1
  160. package/dist/sankhyablocks/{p-7f7fe6c4.entry.js → p-c60d864f.entry.js} +1 -1
  161. package/dist/sankhyablocks/{p-8ce94b62.entry.js → p-cb7c592f.entry.js} +1 -1
  162. package/dist/sankhyablocks/{p-f3027bc9.entry.js → p-cc68a0c1.entry.js} +1 -1
  163. package/dist/sankhyablocks/{p-c3dbf441.entry.js → p-ce207f2a.entry.js} +1 -1
  164. package/dist/sankhyablocks/{p-c4fcf1fb.entry.js → p-cfa4c183.entry.js} +1 -1
  165. package/dist/sankhyablocks/{p-20349480.entry.js → p-d5d7fe52.entry.js} +1 -1
  166. package/dist/sankhyablocks/{p-b47acee0.entry.js → p-dd89bc02.entry.js} +1 -1
  167. package/dist/sankhyablocks/{p-667cab42.entry.js → p-def17f0e.entry.js} +1 -1
  168. package/dist/sankhyablocks/p-e41c86b2.entry.js +1 -0
  169. package/dist/sankhyablocks/{p-4c2e2767.entry.js → p-e47d6f17.entry.js} +1 -1
  170. package/dist/sankhyablocks/{p-7345782c.entry.js → p-fd1a5a61.entry.js} +1 -1
  171. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  172. package/dist/types/components/snk-grid/snk-grid.d.ts +1 -0
  173. package/package.json +1 -1
  174. package/dist/sankhyablocks/p-0814b16c.entry.js +0 -1
  175. package/dist/sankhyablocks/p-d8d8169b.js +0 -2
@@ -1 +1 @@
1
- import{r as t,h as e,H as i,g as s}from"./p-d8d8169b.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-9019a32f.js";import{D as x}from"./p-6768f176.js";import{S as f}from"./p-4b1c26ae.js";import"./p-48a5c311.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-8d884fab.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 g{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=f.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),f=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let g=!1;if(c.includes(null==a?void 0:a.id)&&x<=f||p?g=!1:(null==m?void 0:m.length)?g=m.length>f:v>f&&(g=!0),g){const t=f.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 g(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
+ import{r as t,h as e,H as i,g as s}from"./p-82bb3eda.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-9019a32f.js";import{D as x}from"./p-6768f176.js";import{S as f}from"./p-156c9f38.js";import"./p-48a5c311.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-8d884fab.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 g{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=f.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),f=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let g=!1;if(c.includes(null==a?void 0:a.id)&&x<=f||p?g=!1:(null==m?void 0:m.length)?g=m.length>f:v>f&&(g=!0),g){const t=f.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 g(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 +1 @@
1
- import{r as i,c as e,h as t,g as s}from"./p-d8d8169b.js";import{ObjectUtils as o,ArrayUtils as n}from"@sankhyalabs/core";import{ApplicationUtils as a}from"@sankhyalabs/ezui/dist/collection/utils";import{S as r}from"./p-51833248.js";import{a as d}from"./p-9019a32f.js";const l=class{constructor(t){i(this,t),this.guideSelected=e(this,"guideSelected",7),this.guideListChanged=e(this,"guideListChanged",7),this.guideDeleted=e(this,"guideDeleted",7),this.createNewGuide=e(this,"createNewGuide",7),this.ID_VISIBLE_GUIDES="container-visible-guides",this.ID_HIDDEN_GUIDES="container-hidden-guides",this.sortLogic=(i,e)=>{var t,s;return(null!==(t=i.order)&&void 0!==t?t:Number.MAX_VALUE)-(null!==(s=e.order)&&void 0!==s?s:Number.MAX_VALUE)},this.mainGuide=void 0,this.filterTerm="",this.visibleGuides=[],this.hiddenGuides=[],this.guidesList=[],this.selectedGuide=void 0,this.messagesBuilder=void 0}onMessagesBuilderChange(){this.setCustomCSSProperties()}observeVisibleGuides(i){this.initGuidesConfig(i)}observeSelectedGuide(i){this.guideSelected.emit(i)}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}initGuidesConfig(i){const e=[...i.filter((i=>i.visible&&i.name!==d.main))],t=[...i.filter((i=>!i.visible&&i.name!==d.main))];this.visibleGuides=[...e.sort(this.sortLogic)],this.hiddenGuides=[...t.sort(this.sortLogic)],this.mainGuide=i.find((i=>i.name===d.main))}handleAddGuide(){this.createNewGuide.emit()}handleSelectGuide(i,e){e.stopPropagation(),this.selectedGuide=i}toggleGuideVisibility(i,e){e.stopPropagation();const t=Object.assign(Object.assign({},i),{visible:!i.visible});let s,o;i.visible?(s=[...this.visibleGuides.filter((e=>e.name!==i.name))],o=[...this.hiddenGuides,t]):(s=[...this.visibleGuides,t],o=[...this.hiddenGuides.filter((e=>e.name!==i.name))]);const n=[...s,...o];this.applyGuidesUpdate(n)}adjustListOrder(i){return i.map(((i,e)=>Object.assign(Object.assign({},i),{order:e})))}applyGuidesUpdate(i){let e=this.adjustListOrder(i);e=[this.mainGuide,...e],o.equals(e,this.guidesList)||this.guideListChanged.emit(e)}async handleDeleteGuide(i,e){e.stopPropagation();const t=this.getMessage("snkFormConfig.confirm.title"),s=this.getMessage("snkFormConfig.confirm.deleteGuide").replace("{0}",i.label);if(!await a.confirm(t,s))return;this.guideDeleted.emit(i);const o=this.getMessage("snkFormConfig.info.successfullyGuideDeleted").replace("{0}",i.label);a.info(o)}renderItems(i){return n.applyStringFilter(this.filterTerm,i).map((i=>{var e;return t("div",{key:i.name,"data-guide-name":i.name,title:i.label,class:`guide-item ${(null===(e=this.selectedGuide)||void 0===e?void 0:e.label)===i.label?"selected":""} ${this.filterTerm.length?"disable-sort":""}`,onClick:e=>this.handleSelectGuide(i,e)},t("span",null,t("ez-icon",{iconName:"drag-indicator",class:"ez-margin-right--small"})),t("span",{class:"item-label"},i.label),t("div",{class:"actions"},t("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:e=>this.toggleGuideVisibility(i,e),size:"medium",iconName:i.visible?"eye-off":"eye",title:this.getMessage(i.visible?"snkFormConfig.guidesConfigurator.actions.hide":"snkFormConfig.guidesConfigurator.actions.show")}),t("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:e=>this.handleDeleteGuide(i,e),size:"medium",isDisabled:i.isCustom||i.isDetail,iconName:"delete",title:this.getMessage(i.isCustom||i.isDetail?"snkFormConfig.guidesConfigurator.canNotDeleteCustomGuide":"snkFormConfig.guidesConfigurator.actions.delete")})))}))}getContainerElement(i){return this.el.querySelector(`[id="${i}"]`)}handleSortGuide(){const i=[...this.getGuidesFromStatus(!0),...this.getGuidesFromStatus(!1)];this.applyGuidesUpdate(i)}getGuidesFromStatus(i){let e=[];return this.getOrderedGuideNames(i?this.ID_VISIBLE_GUIDES:this.ID_HIDDEN_GUIDES).forEach((t=>{const s=this.guidesList.find((i=>i.name===t));s&&e.push(Object.assign(Object.assign({},s),{visible:i}))})),e}getOrderedGuideNames(i){var e;const t=null===(e=this.getContainerElement(i))||void 0===e?void 0:e.children;return Array.from(t).map((i=>i.getAttribute("data-guide-name")))}initializeDraggableContainers(){this._sortableVisibleGuides=new r(this.getContainerElement(this.ID_VISIBLE_GUIDES),{group:"guides",ghostClass:"ghost",direction:"vertical",filter:".disable-sort",animation:15,onSort:()=>this.handleSortGuide()}),this._sortableInvisibleGuides=new r(this.getContainerElement(this.ID_HIDDEN_GUIDES),{group:"guides",ghostClass:"ghost",animation:15,filter:".disable-sort",onSort:()=>this.handleSortGuide()})}handleSelectMainGuide(){this.guideSelected.emit(this.mainGuide)}setCustomCSSProperties(){document.documentElement.style.setProperty("--no-hidden-guides-message",`"${this.getMessage("snkFormConfig.guidesConfigurator.noHiddenGuides")}"`),document.documentElement.style.setProperty("--no-visible-guides-message",`"${this.getMessage("snkFormConfig.guidesConfigurator.noVisibleGuides")}"`)}componentDidLoad(){this.initializeDraggableContainers(),this.initGuidesConfig(this.guidesList),this.setCustomCSSProperties()}render(){var i,e,s;return t("ez-sidebar-navigator",{class:"ezSidebarNavigator",type:"fixed",size:"md",titleMenu:this.getMessage("snkFormConfig.guidesConfigurator.title")},t("div",{class:"navigator-container"},t("ez-filter-input",{slot:"content",mode:"slim",label:this.getMessage("snkFormConfig.guidesConfigurator.searchGuide"),onEzChange:i=>this.filterTerm=i.detail}),t("div",{onClick:this.handleSelectMainGuide.bind(this),class:"main-guide "+((null===(i=this.selectedGuide)||void 0===i?void 0:i.name)===(null===(e=this.mainGuide)||void 0===e?void 0:e.name)?"selected":"")},t("span",null,null===(s=this.mainGuide)||void 0===s?void 0:s.label)),t("div",{class:"collapsible-container"},t("div",{class:"collapsible-item"},t("ez-collapsible-box",{label:this.getMessage("snkFormConfig.guidesConfigurator.visibleGuides"),headerSize:"large"},t("div",{id:this.ID_VISIBLE_GUIDES,class:"guide-list "+(this.visibleGuides.length?"":"visible-empty-content")},this.renderItems(this.visibleGuides)))),t("div",{class:"collapsible-item"},t("ez-collapsible-box",{label:this.getMessage("snkFormConfig.guidesConfigurator.hiddenGuides"),headerSize:"large"},t("div",{id:this.ID_HIDDEN_GUIDES,class:"guide-list "+(this.hiddenGuides.length?"":"hidden-empty-content")},this.renderItems(this.hiddenGuides))))),t("div",{class:"add-button-container",onClick:this.handleAddGuide.bind(this)},t("ez-icon",{slot:"leftIcon",iconName:"plus"}),t("span",null,this.getMessage("snkFormConfig.guidesConfigurator.createNewGuide")))))}get el(){return s(this)}static get watchers(){return{messagesBuilder:["onMessagesBuilderChange"],guidesList:["observeVisibleGuides"],selectedGuide:["observeSelectedGuide"]}}};l.style='.ezSidebarNavigator.sc-guides-configurator{--ez-sidebar-navigator--height:calc(100vh - 118px)}.navigator-container.sc-guides-configurator{height:calc(100vh - 175px);display:flex;flex-direction:column;justify-content:space-between}.collapsible-container.sc-guides-configurator{display:flex;flex-direction:column;gap:12px;flex-grow:1;max-height:calc(100vh - 240px);overflow:auto}.collapsible-item.sc-guides-configurator{padding:6px;border-radius:6px;border:1px solid #dce0e8}.add-button-container.sc-guides-configurator{display:flex;align-items:center;border-top:1px solid #dce0e8;padding-top:22px;gap:6px;cursor:pointer;justify-content:center}.add-button-container.sc-guides-configurator span.sc-guides-configurator{display:block}.guide-list.sc-guides-configurator{display:flex;flex-direction:column;width:100%;min-height:10px}.guide-list.hidden-empty-content.sc-guides-configurator::before{content:var(--no-hidden-guides-message, "Nenhuma guia oculta");display:block;font-size:16px;font-weight:400;color:#AFB6C0;margin:auto;padding:8px}.guide-list.visible-empty-content.sc-guides-configurator::before{content:var(--no-visible-guides-message, "Nenhuma guia visível");display:block;font-size:16px;font-weight:400;color:#AFB6C0;margin:auto;padding:8px}.item-label.sc-guides-configurator{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-grow:1}.guide-item.sc-guides-configurator{margin:0 3px;display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:5px 10px;border-radius:6px;transition:all 0.2s ease-in-out;height:32px}.guide-item.sc-guides-configurator .actions.sc-guides-configurator{display:flex;gap:8px;transition:opacity 0.2s ease-in-out;display:none;opacity:0}.guide-item.sc-guides-configurator:hover .actions.sc-guides-configurator{display:flex;opacity:1}ez-button.sc-guides-configurator{width:24px;align-items:center;justify-content:center;display:flex}.ghost.sc-guides-configurator{opacity:.5;background:#e2eaf4}.main-guide.sc-guides-configurator{padding:12px;margin:12px 0;border:1px solid #dce0e8;border-radius:6px;transition:all 0.2s ease-in-out}.guide-item.selected.sc-guides-configurator,.main-guide.selected.sc-guides-configurator{background:#E2F4EF}.guide-item.sc-guides-configurator:hover,.main-guide.sc-guides-configurator:hover{background:#f5fcfa}';export{l as guides_configurator}
1
+ import{r as i,c as e,h as t,g as s}from"./p-82bb3eda.js";import{ObjectUtils as o,ArrayUtils as n}from"@sankhyalabs/core";import{ApplicationUtils as a}from"@sankhyalabs/ezui/dist/collection/utils";import{S as r}from"./p-51833248.js";import{a as d}from"./p-9019a32f.js";const l=class{constructor(t){i(this,t),this.guideSelected=e(this,"guideSelected",7),this.guideListChanged=e(this,"guideListChanged",7),this.guideDeleted=e(this,"guideDeleted",7),this.createNewGuide=e(this,"createNewGuide",7),this.ID_VISIBLE_GUIDES="container-visible-guides",this.ID_HIDDEN_GUIDES="container-hidden-guides",this.sortLogic=(i,e)=>{var t,s;return(null!==(t=i.order)&&void 0!==t?t:Number.MAX_VALUE)-(null!==(s=e.order)&&void 0!==s?s:Number.MAX_VALUE)},this.mainGuide=void 0,this.filterTerm="",this.visibleGuides=[],this.hiddenGuides=[],this.guidesList=[],this.selectedGuide=void 0,this.messagesBuilder=void 0}onMessagesBuilderChange(){this.setCustomCSSProperties()}observeVisibleGuides(i){this.initGuidesConfig(i)}observeSelectedGuide(i){this.guideSelected.emit(i)}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}initGuidesConfig(i){const e=[...i.filter((i=>i.visible&&i.name!==d.main))],t=[...i.filter((i=>!i.visible&&i.name!==d.main))];this.visibleGuides=[...e.sort(this.sortLogic)],this.hiddenGuides=[...t.sort(this.sortLogic)],this.mainGuide=i.find((i=>i.name===d.main))}handleAddGuide(){this.createNewGuide.emit()}handleSelectGuide(i,e){e.stopPropagation(),this.selectedGuide=i}toggleGuideVisibility(i,e){e.stopPropagation();const t=Object.assign(Object.assign({},i),{visible:!i.visible});let s,o;i.visible?(s=[...this.visibleGuides.filter((e=>e.name!==i.name))],o=[...this.hiddenGuides,t]):(s=[...this.visibleGuides,t],o=[...this.hiddenGuides.filter((e=>e.name!==i.name))]);const n=[...s,...o];this.applyGuidesUpdate(n)}adjustListOrder(i){return i.map(((i,e)=>Object.assign(Object.assign({},i),{order:e})))}applyGuidesUpdate(i){let e=this.adjustListOrder(i);e=[this.mainGuide,...e],o.equals(e,this.guidesList)||this.guideListChanged.emit(e)}async handleDeleteGuide(i,e){e.stopPropagation();const t=this.getMessage("snkFormConfig.confirm.title"),s=this.getMessage("snkFormConfig.confirm.deleteGuide").replace("{0}",i.label);if(!await a.confirm(t,s))return;this.guideDeleted.emit(i);const o=this.getMessage("snkFormConfig.info.successfullyGuideDeleted").replace("{0}",i.label);a.info(o)}renderItems(i){return n.applyStringFilter(this.filterTerm,i).map((i=>{var e;return t("div",{key:i.name,"data-guide-name":i.name,title:i.label,class:`guide-item ${(null===(e=this.selectedGuide)||void 0===e?void 0:e.label)===i.label?"selected":""} ${this.filterTerm.length?"disable-sort":""}`,onClick:e=>this.handleSelectGuide(i,e)},t("span",null,t("ez-icon",{iconName:"drag-indicator",class:"ez-margin-right--small"})),t("span",{class:"item-label"},i.label),t("div",{class:"actions"},t("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:e=>this.toggleGuideVisibility(i,e),size:"medium",iconName:i.visible?"eye-off":"eye",title:this.getMessage(i.visible?"snkFormConfig.guidesConfigurator.actions.hide":"snkFormConfig.guidesConfigurator.actions.show")}),t("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:e=>this.handleDeleteGuide(i,e),size:"medium",isDisabled:i.isCustom||i.isDetail,iconName:"delete",title:this.getMessage(i.isCustom||i.isDetail?"snkFormConfig.guidesConfigurator.canNotDeleteCustomGuide":"snkFormConfig.guidesConfigurator.actions.delete")})))}))}getContainerElement(i){return this.el.querySelector(`[id="${i}"]`)}handleSortGuide(){const i=[...this.getGuidesFromStatus(!0),...this.getGuidesFromStatus(!1)];this.applyGuidesUpdate(i)}getGuidesFromStatus(i){let e=[];return this.getOrderedGuideNames(i?this.ID_VISIBLE_GUIDES:this.ID_HIDDEN_GUIDES).forEach((t=>{const s=this.guidesList.find((i=>i.name===t));s&&e.push(Object.assign(Object.assign({},s),{visible:i}))})),e}getOrderedGuideNames(i){var e;const t=null===(e=this.getContainerElement(i))||void 0===e?void 0:e.children;return Array.from(t).map((i=>i.getAttribute("data-guide-name")))}initializeDraggableContainers(){this._sortableVisibleGuides=new r(this.getContainerElement(this.ID_VISIBLE_GUIDES),{group:"guides",ghostClass:"ghost",direction:"vertical",filter:".disable-sort",animation:15,onSort:()=>this.handleSortGuide()}),this._sortableInvisibleGuides=new r(this.getContainerElement(this.ID_HIDDEN_GUIDES),{group:"guides",ghostClass:"ghost",animation:15,filter:".disable-sort",onSort:()=>this.handleSortGuide()})}handleSelectMainGuide(){this.guideSelected.emit(this.mainGuide)}setCustomCSSProperties(){document.documentElement.style.setProperty("--no-hidden-guides-message",`"${this.getMessage("snkFormConfig.guidesConfigurator.noHiddenGuides")}"`),document.documentElement.style.setProperty("--no-visible-guides-message",`"${this.getMessage("snkFormConfig.guidesConfigurator.noVisibleGuides")}"`)}componentDidLoad(){this.initializeDraggableContainers(),this.initGuidesConfig(this.guidesList),this.setCustomCSSProperties()}render(){var i,e,s;return t("ez-sidebar-navigator",{class:"ezSidebarNavigator",type:"fixed",size:"md",titleMenu:this.getMessage("snkFormConfig.guidesConfigurator.title")},t("div",{class:"navigator-container"},t("ez-filter-input",{slot:"content",mode:"slim",label:this.getMessage("snkFormConfig.guidesConfigurator.searchGuide"),onEzChange:i=>this.filterTerm=i.detail}),t("div",{onClick:this.handleSelectMainGuide.bind(this),class:"main-guide "+((null===(i=this.selectedGuide)||void 0===i?void 0:i.name)===(null===(e=this.mainGuide)||void 0===e?void 0:e.name)?"selected":"")},t("span",null,null===(s=this.mainGuide)||void 0===s?void 0:s.label)),t("div",{class:"collapsible-container"},t("div",{class:"collapsible-item"},t("ez-collapsible-box",{label:this.getMessage("snkFormConfig.guidesConfigurator.visibleGuides"),headerSize:"large"},t("div",{id:this.ID_VISIBLE_GUIDES,class:"guide-list "+(this.visibleGuides.length?"":"visible-empty-content")},this.renderItems(this.visibleGuides)))),t("div",{class:"collapsible-item"},t("ez-collapsible-box",{label:this.getMessage("snkFormConfig.guidesConfigurator.hiddenGuides"),headerSize:"large"},t("div",{id:this.ID_HIDDEN_GUIDES,class:"guide-list "+(this.hiddenGuides.length?"":"hidden-empty-content")},this.renderItems(this.hiddenGuides))))),t("div",{class:"add-button-container",onClick:this.handleAddGuide.bind(this)},t("ez-icon",{slot:"leftIcon",iconName:"plus"}),t("span",null,this.getMessage("snkFormConfig.guidesConfigurator.createNewGuide")))))}get el(){return s(this)}static get watchers(){return{messagesBuilder:["onMessagesBuilderChange"],guidesList:["observeVisibleGuides"],selectedGuide:["observeSelectedGuide"]}}};l.style='.ezSidebarNavigator.sc-guides-configurator{--ez-sidebar-navigator--height:calc(100vh - 118px)}.navigator-container.sc-guides-configurator{height:calc(100vh - 175px);display:flex;flex-direction:column;justify-content:space-between}.collapsible-container.sc-guides-configurator{display:flex;flex-direction:column;gap:12px;flex-grow:1;max-height:calc(100vh - 240px);overflow:auto}.collapsible-item.sc-guides-configurator{padding:6px;border-radius:6px;border:1px solid #dce0e8}.add-button-container.sc-guides-configurator{display:flex;align-items:center;border-top:1px solid #dce0e8;padding-top:22px;gap:6px;cursor:pointer;justify-content:center}.add-button-container.sc-guides-configurator span.sc-guides-configurator{display:block}.guide-list.sc-guides-configurator{display:flex;flex-direction:column;width:100%;min-height:10px}.guide-list.hidden-empty-content.sc-guides-configurator::before{content:var(--no-hidden-guides-message, "Nenhuma guia oculta");display:block;font-size:16px;font-weight:400;color:#AFB6C0;margin:auto;padding:8px}.guide-list.visible-empty-content.sc-guides-configurator::before{content:var(--no-visible-guides-message, "Nenhuma guia visível");display:block;font-size:16px;font-weight:400;color:#AFB6C0;margin:auto;padding:8px}.item-label.sc-guides-configurator{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-grow:1}.guide-item.sc-guides-configurator{margin:0 3px;display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:5px 10px;border-radius:6px;transition:all 0.2s ease-in-out;height:32px}.guide-item.sc-guides-configurator .actions.sc-guides-configurator{display:flex;gap:8px;transition:opacity 0.2s ease-in-out;display:none;opacity:0}.guide-item.sc-guides-configurator:hover .actions.sc-guides-configurator{display:flex;opacity:1}ez-button.sc-guides-configurator{width:24px;align-items:center;justify-content:center;display:flex}.ghost.sc-guides-configurator{opacity:.5;background:#e2eaf4}.main-guide.sc-guides-configurator{padding:12px;margin:12px 0;border:1px solid #dce0e8;border-radius:6px;transition:all 0.2s ease-in-out}.guide-item.selected.sc-guides-configurator,.main-guide.selected.sc-guides-configurator{background:#E2F4EF}.guide-item.sc-guides-configurator:hover,.main-guide.sc-guides-configurator:hover{background:#f5fcfa}';export{l as guides_configurator}
@@ -1 +1 @@
1
- import{r as e,c as i,h as t,F as s,H as l,g as r}from"./p-d8d8169b.js";import{ElementIDUtils as a,UserInterface as n,ApplicationContext as o}from"@sankhyalabs/core";import{F as d}from"./p-ff1990ad.js";import{E as c}from"./p-1a68fb59.js";import{EzScrollDirection as h}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{CheckMode as z}from"@sankhyalabs/ezui/dist/collection/utils";const u=class{constructor(t){e(this,t),this.deleteFilter=i(this,"deleteFilter",7),this.editFilter=i(this,"editFilter",7),this.addFilter=i(this,"addFilter",7),this.valueChanged=i(this,"valueChanged",7),this.originalItems=[],this.messagesBuilder=void 0,this.presentationMode=c.MODAL,this.config=void 0,this.value=void 0,this.items=[]}async show(){const e=document.querySelector("#param_0");e&&e.setFocus()}configWatcher(e){this.items=this.originalItems=e.groupedItems||[]}getMessage(e,i){var t;return this.messagesBuilder?this.messagesBuilder.getMessage(e,i):(null===(t=this._application)||void 0===t?void 0:t.messagesBuilder)?this._application.messagesBuilder.getMessage(e,i):void 0}getItemContent(e){var i,s;const l=!!(null===(s=null===(i=e.props)||void 0===i?void 0:i.personalizedFilter)||void 0===s?void 0:s.parameters.length);return t("div",{class:this.isModalMode()?"":"SnkFilterPersonalized_list-item--chip"},t("li",{class:this.isModalMode()?"SnkFilterPersonalized_list-item--modal":""},t("div",{class:"ez-flex ez-flex--align-items-center ez-flex--justify-between ez-size-width--full"},t((()=>t("ez-check",Object.assign({class:"SnkFilterPersonalized_checkbox",id:`param_${e.id}`,key:e.id,value:e.visible,label:e.label,onEzChange:({detail:i})=>this.handleItemChange.bind(this)(i,e.id)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo(`checkboxFilter_${e.id}`)}`}))),null),this.buildModalListActions(e,l))),e.visible&&l&&t("div",{class:"ez-row ez-padding--small"},this.getFormField(e)))}buildModalListActions(e,i){if(this.isModalMode())return this.isModalMode()?t("div",{class:"SnkFilterPersonalized_list-actions"},t("ez-icon",{class:"SnkFilterPersonalized_list-icon",iconName:"edit",title:this.getMessage("snkPersonalizedFilter.listActions.edit"),onClick:()=>this.editFilter.emit(e.id)}),t("ez-icon",{class:"SnkFilterPersonalized_list-icon",iconName:"delete",title:this.getMessage("snkPersonalizedFilter.listActions.delete"),onClick:this.handleDeleteFilter.bind(this,e)})):i&&t("ez-badge",Object.assign({class:"ez-badge--warning-subtle ez-margin-right--small",label:this.getMessage("snkPersonalizedFilter.info.badgeVariable"),size:"medium"},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo(`variableBadge_${e.id}`)}`}))}isModalMode(){return this.presentationMode===c.MODAL}doSearch(e,i,t){const s=Object.assign({},t.searchContext);return s.searchOptions=Object.assign(Object.assign({},s.searchOptions),{showInactives:"true"}),new Promise(((t,l)=>{this._application.executePreparedSearch(e,i,s).then((e=>{t(e)})).catch((e=>{l(e)}))}))}getFormField(e){var i,s;return(null===(s=null===(i=null==e?void 0:e.props)||void 0===i?void 0:i.personalizedFilter)||void 0===s?void 0:s.parameters).map(((i,s)=>{var l,r,a,o;const d=Object.assign(Object.assign({},i),{id:e.id}),c=null===(l=e.value)||void 0===l?void 0:l[s],h="param_"+s;switch(i.userInterface){case n.SEARCH:const e=1==(null===(r=this.config.props)||void 0===r?void 0:r.useSearchPlus);return t(e?"ez-search-plus":"ez-search",{id:h,suppressEmptyOption:!0,value:c,onEzChange:e=>this.handleFilterItemChange(e.detail,d),label:i.label,optionLoader:({mode:e,argument:t})=>this.doSearch(e,t,i)});case n.SWITCH:case n.CHECKBOX:return t("ez-check",{id:h,class:"ez-padding-bottom--medium",mode:n.SWITCH===i.userInterface?z.SWITCH:z.REGULAR,value:c,label:i.label,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.DECIMALNUMBER:return t("ez-number-input",{id:h,label:i.label,value:c,precision:(null===(a=i.props)||void 0===a?void 0:a.precision)||2,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.INTEGERNUMBER:return t("ez-number-input",{id:h,label:i.label,value:c,precision:null===(o=i.props)||void 0===o?void 0:o.precision,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.OPTIONSELECTOR:return t("ez-combo-box",{id:h,label:i.label,value:c,options:i.options,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.DATE:return t("ez-date-input",{id:h,label:i.label,value:this.parseDate(c),onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.DATETIME:return t("ez-date-time-input",{id:h,label:i.label,value:this.parseDate(c),onEzChange:e=>this.handleFilterItemChange(e.detail,d)});default:return t("ez-text-input",{id:h,label:i.label,value:c,onEzChange:e=>this.handleFilterItemChange(e.detail,d)})}}))}parseDate(e){if("string"==typeof e){let i=new Date(e);return i.setMinutes(i.getMinutes()+i.getTimezoneOffset()),i}return e}getVisibleCount(e){return e.reduce(((e,i)=>i.visible?e+1:e),0)}handleItemChange(e,i){this.items=this.originalItems=this.originalItems.map((t=>{const s=t.id===i?e:t.visible;return Object.assign(Object.assign({},t),{visible:s,active:s})})),this.emitChange()}handleSearchFilterList({detail:e=""}){this.items=e?this.originalItems.filter((i=>i.label.toLowerCase().includes(e.toLowerCase()))):this.originalItems}handleFilterItemChange(e,i){var t;const s=this.items.find((({id:e})=>e===i.id)),{parameters:l=[]}=(null===(t=s.props)||void 0===t?void 0:t.personalizedFilter)||{},r=l.findIndex((e=>e.name===i.name));l[r]=i,s.props.personalizedFilter.parameters=l,s.value||(s.value=[]),s.value[r]=e;const a=[...this.items,s];this.items=Array.from(new Set(a)),this.emitChange()}handleClearFilters(){this.emitChange(!0)}emitChange(e=!1){e&&(this.items=this.originalItems);const i=this.items.map((i=>Object.assign(Object.assign({},i),{visible:!e&&i.visible}))),t=this.getVisibleCount(i);this.valueChanged.emit({value:t,items:i})}handleDeleteFilter(e){this._application.confirm(this.getMessage("snkPersonalizedFilter.deleteConfirm.title"),this.getMessage("snkPersonalizedFilter.deleteConfirm.message",{filterName:e.label})).then((i=>{i&&(this.deleteFilter.emit(e),this.items=this.originalItems=this.originalItems.filter((i=>i.id!==e.id)),this.emitChange())}))}componentDidLoad(){this._element&&a.addIDInfoIfNotExists(this._element,"filterContentEditor")}componentWillLoad(){var e;this._application=o.getContextValue("__SNK__APPLICATION__"),this.items=this.originalItems=(null===(e=this.config)||void 0===e?void 0:e.groupedItems)||[]}buildModeModalHeader(){if(this.presentationMode===c.MODAL)return t("div",{class:"ez-margin-bottom--medium"},t(s,null,t("ez-filter-input",Object.assign({label:this.config.label,onEzChange:this.handleSearchFilterList.bind(this)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("filterSearch")}`})),t("span",{class:"ez-text ez-title--small ez-title--primary"}," ",this.config.detailTitle," ")))}buildModeModalFooter(){if(this.presentationMode===c.MODAL)return t("div",{class:"ez-flex ez-flex--justify-end grow ez-margin-top--medium ez-margin-bottom--small"},t("ez-button",{class:"ez-button--tertiary ez-margin-right--small",size:"medium",label:this.getMessage("snkPersonalizedFilter.footerActions.clear"),onClick:this.handleClearFilters.bind(this)}),t("ez-button",{class:"ez-button--secondary ez-margin-right--small",size:"medium",label:this.getMessage("snkPersonalizedFilter.footerActions.create"),onClick:()=>this.addFilter.emit()}))}buildContainerFiltersCreated(){return this.items.length?t("ez-scroller",{class:"SnkFilterPersonalized_list-scroller",direction:h.VERTICAL},t("ul",{class:"SnkFilterPersonalized_list-container "+(this.isModalMode()?"":"SnkFilterPersonalized_list-container-chip")},this.items.map((e=>this.getItemContent(e))))):t("div",{class:"ez-margin--auto"},t("span",{class:"ez-text ez-text--secondary ez-text--small"},this.getMessage("snkPersonalizedFilter.info.noDataFound")))}render(){if(this.config&&this.config.type===d.PERSONALIZED)return t(l,null,this.buildModeModalHeader(),this.buildContainerFiltersCreated(),this.buildModeModalFooter())}get _element(){return r(this)}static get watchers(){return{config:["configWatcher"]}}};u.style=".sc-snk-personalized-filter-editor-h{--snk-filter-personalized__max-height:21;--snk-filter-personalized__max-width:21.5}.SnkFilterPersonalized_list-container.sc-snk-personalized-filter-editor{margin:0;padding:0;list-style:none;display:flex;flex-direction:column}.SnkFilterPersonalized_list-container-chip.sc-snk-personalized-filter-editor{width:400px}.SnkFilterPersonalized_list-scroller.sc-snk-personalized-filter-editor{display:block;max-height:calc(var(--space--2xl) * var(--snk-filter-personalized__max-height));cursor:auto;--ez-scroller__max-height:300px}.SnkFilterPersonalized_checkbox.sc-snk-personalized-filter-editor{display:grid;grid-template-columns:auto auto;justify-content:start}.SnkFilterPersonalized_list-container.sc-snk-personalized-filter-editor:has(.SnkFilterPersonalized_list-item--chip){gap:var(--space--small, 6px);max-width:calc(var(--space--md) * var(--snk-filter-personalized__max-width))}.SnkFilterPersonalized_list-item--modal.sc-snk-personalized-filter-editor{display:flex;border-radius:var(--border--radius-regular)}.SnkFilterPersonalized_list-item--modal.sc-snk-personalized-filter-editor:hover{background-color:var(--background--medium, #f0f3f7)}.SnkFilterPersonalized_list-actions.sc-snk-personalized-filter-editor{display:none;align-items:center;gap:var(--space--3xs)}.SnkFilterPersonalized_list-item--modal.sc-snk-personalized-filter-editor:hover .SnkFilterPersonalized_list-actions.sc-snk-personalized-filter-editor{display:flex}.SnkFilterPersonalized_list-item--chip.sc-snk-personalized-filter-editor{display:flex;flex-direction:column;border:var(--border--small, 1px solid) var(--color-strokes, #DCE0E8);border-radius:var(--border--radius-regular)}.SnkFilterPersonalized_list-item--chip.sc-snk-personalized-filter-editor .sc-snk-personalized-filter-editor:first-of-type{gap:var(--space--3xs)}.SnkFilterPersonalized_list-icon.sc-snk-personalized-filter-editor{--ez-icon--color:var(--title--primary, #2B3A54);cursor:pointer}.SnkFilterPersonalized_list-icon.sc-snk-personalized-filter-editor:hover{outline:none;color:var(--color--primary-600, #007a5a);fill:var(--color--primary-600, #007a5a);--ez-icon--color:var(--color--primary-600, #007a5a)}";export{u as snk_personalized_filter_editor}
1
+ import{r as e,c as i,h as t,F as s,H as l,g as r}from"./p-82bb3eda.js";import{ElementIDUtils as a,UserInterface as n,ApplicationContext as o}from"@sankhyalabs/core";import{F as d}from"./p-ff1990ad.js";import{E as c}from"./p-1a68fb59.js";import{EzScrollDirection as h}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{CheckMode as z}from"@sankhyalabs/ezui/dist/collection/utils";const u=class{constructor(t){e(this,t),this.deleteFilter=i(this,"deleteFilter",7),this.editFilter=i(this,"editFilter",7),this.addFilter=i(this,"addFilter",7),this.valueChanged=i(this,"valueChanged",7),this.originalItems=[],this.messagesBuilder=void 0,this.presentationMode=c.MODAL,this.config=void 0,this.value=void 0,this.items=[]}async show(){const e=document.querySelector("#param_0");e&&e.setFocus()}configWatcher(e){this.items=this.originalItems=e.groupedItems||[]}getMessage(e,i){var t;return this.messagesBuilder?this.messagesBuilder.getMessage(e,i):(null===(t=this._application)||void 0===t?void 0:t.messagesBuilder)?this._application.messagesBuilder.getMessage(e,i):void 0}getItemContent(e){var i,s;const l=!!(null===(s=null===(i=e.props)||void 0===i?void 0:i.personalizedFilter)||void 0===s?void 0:s.parameters.length);return t("div",{class:this.isModalMode()?"":"SnkFilterPersonalized_list-item--chip"},t("li",{class:this.isModalMode()?"SnkFilterPersonalized_list-item--modal":""},t("div",{class:"ez-flex ez-flex--align-items-center ez-flex--justify-between ez-size-width--full"},t((()=>t("ez-check",Object.assign({class:"SnkFilterPersonalized_checkbox",id:`param_${e.id}`,key:e.id,value:e.visible,label:e.label,onEzChange:({detail:i})=>this.handleItemChange.bind(this)(i,e.id)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo(`checkboxFilter_${e.id}`)}`}))),null),this.buildModalListActions(e,l))),e.visible&&l&&t("div",{class:"ez-row ez-padding--small"},this.getFormField(e)))}buildModalListActions(e,i){if(this.isModalMode())return this.isModalMode()?t("div",{class:"SnkFilterPersonalized_list-actions"},t("ez-icon",{class:"SnkFilterPersonalized_list-icon",iconName:"edit",title:this.getMessage("snkPersonalizedFilter.listActions.edit"),onClick:()=>this.editFilter.emit(e.id)}),t("ez-icon",{class:"SnkFilterPersonalized_list-icon",iconName:"delete",title:this.getMessage("snkPersonalizedFilter.listActions.delete"),onClick:this.handleDeleteFilter.bind(this,e)})):i&&t("ez-badge",Object.assign({class:"ez-badge--warning-subtle ez-margin-right--small",label:this.getMessage("snkPersonalizedFilter.info.badgeVariable"),size:"medium"},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo(`variableBadge_${e.id}`)}`}))}isModalMode(){return this.presentationMode===c.MODAL}doSearch(e,i,t){const s=Object.assign({},t.searchContext);return s.searchOptions=Object.assign(Object.assign({},s.searchOptions),{showInactives:"true"}),new Promise(((t,l)=>{this._application.executePreparedSearch(e,i,s).then((e=>{t(e)})).catch((e=>{l(e)}))}))}getFormField(e){var i,s;return(null===(s=null===(i=null==e?void 0:e.props)||void 0===i?void 0:i.personalizedFilter)||void 0===s?void 0:s.parameters).map(((i,s)=>{var l,r,a,o;const d=Object.assign(Object.assign({},i),{id:e.id}),c=null===(l=e.value)||void 0===l?void 0:l[s],h="param_"+s;switch(i.userInterface){case n.SEARCH:const e=1==(null===(r=this.config.props)||void 0===r?void 0:r.useSearchPlus);return t(e?"ez-search-plus":"ez-search",{id:h,suppressEmptyOption:!0,value:c,onEzChange:e=>this.handleFilterItemChange(e.detail,d),label:i.label,optionLoader:({mode:e,argument:t})=>this.doSearch(e,t,i)});case n.SWITCH:case n.CHECKBOX:return t("ez-check",{id:h,class:"ez-padding-bottom--medium",mode:n.SWITCH===i.userInterface?z.SWITCH:z.REGULAR,value:c,label:i.label,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.DECIMALNUMBER:return t("ez-number-input",{id:h,label:i.label,value:c,precision:(null===(a=i.props)||void 0===a?void 0:a.precision)||2,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.INTEGERNUMBER:return t("ez-number-input",{id:h,label:i.label,value:c,precision:null===(o=i.props)||void 0===o?void 0:o.precision,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.OPTIONSELECTOR:return t("ez-combo-box",{id:h,label:i.label,value:c,options:i.options,onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.DATE:return t("ez-date-input",{id:h,label:i.label,value:this.parseDate(c),onEzChange:e=>this.handleFilterItemChange(e.detail,d)});case n.DATETIME:return t("ez-date-time-input",{id:h,label:i.label,value:this.parseDate(c),onEzChange:e=>this.handleFilterItemChange(e.detail,d)});default:return t("ez-text-input",{id:h,label:i.label,value:c,onEzChange:e=>this.handleFilterItemChange(e.detail,d)})}}))}parseDate(e){if("string"==typeof e){let i=new Date(e);return i.setMinutes(i.getMinutes()+i.getTimezoneOffset()),i}return e}getVisibleCount(e){return e.reduce(((e,i)=>i.visible?e+1:e),0)}handleItemChange(e,i){this.items=this.originalItems=this.originalItems.map((t=>{const s=t.id===i?e:t.visible;return Object.assign(Object.assign({},t),{visible:s,active:s})})),this.emitChange()}handleSearchFilterList({detail:e=""}){this.items=e?this.originalItems.filter((i=>i.label.toLowerCase().includes(e.toLowerCase()))):this.originalItems}handleFilterItemChange(e,i){var t;const s=this.items.find((({id:e})=>e===i.id)),{parameters:l=[]}=(null===(t=s.props)||void 0===t?void 0:t.personalizedFilter)||{},r=l.findIndex((e=>e.name===i.name));l[r]=i,s.props.personalizedFilter.parameters=l,s.value||(s.value=[]),s.value[r]=e;const a=[...this.items,s];this.items=Array.from(new Set(a)),this.emitChange()}handleClearFilters(){this.emitChange(!0)}emitChange(e=!1){e&&(this.items=this.originalItems);const i=this.items.map((i=>Object.assign(Object.assign({},i),{visible:!e&&i.visible}))),t=this.getVisibleCount(i);this.valueChanged.emit({value:t,items:i})}handleDeleteFilter(e){this._application.confirm(this.getMessage("snkPersonalizedFilter.deleteConfirm.title"),this.getMessage("snkPersonalizedFilter.deleteConfirm.message",{filterName:e.label})).then((i=>{i&&(this.deleteFilter.emit(e),this.items=this.originalItems=this.originalItems.filter((i=>i.id!==e.id)),this.emitChange())}))}componentDidLoad(){this._element&&a.addIDInfoIfNotExists(this._element,"filterContentEditor")}componentWillLoad(){var e;this._application=o.getContextValue("__SNK__APPLICATION__"),this.items=this.originalItems=(null===(e=this.config)||void 0===e?void 0:e.groupedItems)||[]}buildModeModalHeader(){if(this.presentationMode===c.MODAL)return t("div",{class:"ez-margin-bottom--medium"},t(s,null,t("ez-filter-input",Object.assign({label:this.config.label,onEzChange:this.handleSearchFilterList.bind(this)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("filterSearch")}`})),t("span",{class:"ez-text ez-title--small ez-title--primary"}," ",this.config.detailTitle," ")))}buildModeModalFooter(){if(this.presentationMode===c.MODAL)return t("div",{class:"ez-flex ez-flex--justify-end grow ez-margin-top--medium ez-margin-bottom--small"},t("ez-button",{class:"ez-button--tertiary ez-margin-right--small",size:"medium",label:this.getMessage("snkPersonalizedFilter.footerActions.clear"),onClick:this.handleClearFilters.bind(this)}),t("ez-button",{class:"ez-button--secondary ez-margin-right--small",size:"medium",label:this.getMessage("snkPersonalizedFilter.footerActions.create"),onClick:()=>this.addFilter.emit()}))}buildContainerFiltersCreated(){return this.items.length?t("ez-scroller",{class:"SnkFilterPersonalized_list-scroller",direction:h.VERTICAL},t("ul",{class:"SnkFilterPersonalized_list-container "+(this.isModalMode()?"":"SnkFilterPersonalized_list-container-chip")},this.items.map((e=>this.getItemContent(e))))):t("div",{class:"ez-margin--auto"},t("span",{class:"ez-text ez-text--secondary ez-text--small"},this.getMessage("snkPersonalizedFilter.info.noDataFound")))}render(){if(this.config&&this.config.type===d.PERSONALIZED)return t(l,null,this.buildModeModalHeader(),this.buildContainerFiltersCreated(),this.buildModeModalFooter())}get _element(){return r(this)}static get watchers(){return{config:["configWatcher"]}}};u.style=".sc-snk-personalized-filter-editor-h{--snk-filter-personalized__max-height:21;--snk-filter-personalized__max-width:21.5}.SnkFilterPersonalized_list-container.sc-snk-personalized-filter-editor{margin:0;padding:0;list-style:none;display:flex;flex-direction:column}.SnkFilterPersonalized_list-container-chip.sc-snk-personalized-filter-editor{width:400px}.SnkFilterPersonalized_list-scroller.sc-snk-personalized-filter-editor{display:block;max-height:calc(var(--space--2xl) * var(--snk-filter-personalized__max-height));cursor:auto;--ez-scroller__max-height:300px}.SnkFilterPersonalized_checkbox.sc-snk-personalized-filter-editor{display:grid;grid-template-columns:auto auto;justify-content:start}.SnkFilterPersonalized_list-container.sc-snk-personalized-filter-editor:has(.SnkFilterPersonalized_list-item--chip){gap:var(--space--small, 6px);max-width:calc(var(--space--md) * var(--snk-filter-personalized__max-width))}.SnkFilterPersonalized_list-item--modal.sc-snk-personalized-filter-editor{display:flex;border-radius:var(--border--radius-regular)}.SnkFilterPersonalized_list-item--modal.sc-snk-personalized-filter-editor:hover{background-color:var(--background--medium, #f0f3f7)}.SnkFilterPersonalized_list-actions.sc-snk-personalized-filter-editor{display:none;align-items:center;gap:var(--space--3xs)}.SnkFilterPersonalized_list-item--modal.sc-snk-personalized-filter-editor:hover .SnkFilterPersonalized_list-actions.sc-snk-personalized-filter-editor{display:flex}.SnkFilterPersonalized_list-item--chip.sc-snk-personalized-filter-editor{display:flex;flex-direction:column;border:var(--border--small, 1px solid) var(--color-strokes, #DCE0E8);border-radius:var(--border--radius-regular)}.SnkFilterPersonalized_list-item--chip.sc-snk-personalized-filter-editor .sc-snk-personalized-filter-editor:first-of-type{gap:var(--space--3xs)}.SnkFilterPersonalized_list-icon.sc-snk-personalized-filter-editor{--ez-icon--color:var(--title--primary, #2B3A54);cursor:pointer}.SnkFilterPersonalized_list-icon.sc-snk-personalized-filter-editor:hover{outline:none;color:var(--color--primary-600, #007a5a);fill:var(--color--primary-600, #007a5a);--ez-icon--color:var(--color--primary-600, #007a5a)}";export{u as snk_personalized_filter_editor}
@@ -1 +1 @@
1
- import{r as i,c as t,h as s,H as l}from"./p-d8d8169b.js";import{ObjectUtils as e,ApplicationContext as o}from"@sankhyalabs/core";const n=class{constructor(s){i(this,s),this.valueChanged=t(this,"valueChanged",7),this._ezListSource=[],this.config=void 0,this.rightListSlotBuilder=void 0,this.maxHeightList="",this.value=void 0,this.errorMessage=void 0}async reloadList(){this.loadListSource()}observeConfig(){var i,t;null===(t=null===(i=this._searchElement)||void 0===i?void 0:i.clearValue)||void 0===t||t.call(i)}ezListChangeListener(i){var t,s;this.errorMessage=void 0;const l=e.copy(this.config);null===(t=this.getListConfigValue(l))||void 0===t||t.forEach((t=>{var s,l;t&&t.id===(null===(s=i.detail)||void 0===s?void 0:s.id)&&(t.check=null===(l=i.detail)||void 0===l?void 0:l.check)})),this.config=e.copy(l),this.valueChanged.emit(null===(s=this.config)||void 0===s?void 0:s.value)}loadListSource(){var i;this._ezListSource=[],null===(i=this.getListConfigValue(this.config))||void 0===i||i.forEach((i=>{i&&this._ezListSource.push({label:`${i.id} - ${i.label}`,check:i.check,id:i.id})}))}componentDidLoad(){var i,t,s,l,e;let n=this.getListConfigValue(this.config),a=[];Array.isArray(n)?a=n:a.push(null===(t=null===(i=this.config)||void 0===i?void 0:i.value)||void 0===t?void 0:t.members),this.config.value=a,this._entityName=null===(e=null===(l=null===(s=this.config)||void 0===s?void 0:s.props)||void 0===l?void 0:l.searchContext)||void 0===e?void 0:e.entity,this._application=o.getContextValue("__SNK__APPLICATION__"),this.loadListSource()}optionLoader(i){var t,s,l,e,o,n,a;const{mode:d,argument:v}=i;if(void 0===this._application)return;const r=null!==(l=null===(s=null===(t=this.config)||void 0===t?void 0:t.props)||void 0===s?void 0:s.searchContext)&&void 0!==l?l:{},h=null===(o=null===(e=this.config)||void 0===e?void 0:e.props)||void 0===o?void 0:o.criteria,u=Object.assign(Object.assign({criteria:h},r),{entityDescription:null===(n=this.config)||void 0===n?void 0:n.label,entity:this._entityName,useSearchPlus:null===(a=this.config.props)||void 0===a?void 0:a.useSearchPlus});return this._application.executePreparedSearch(d,v,u)}onEzSearchChange(i){var t,s,l,o;const n=e.isEmptySafetyCheck(i.detail),a=null===(t=this.getListConfigValue(this.config))||void 0===t?void 0:t.find((t=>{var s;return("number"==typeof t.id?String(t.id):t.id)===(null===(s=i.detail)||void 0===s?void 0:s.value)}));n||a||(this.config=Object.assign(Object.assign({},this.config),{value:[...null!==(l=null===(s=this.config)||void 0===s?void 0:s.value)&&void 0!==l?l:[],{id:i.detail.value,check:!0,label:i.detail.label}]}),this.loadListSource(),this.value=this.config.value,this.valueChanged.emit(null===(o=this.config)||void 0===o?void 0:o.value))}getMessage(i,t){var s;return null===(s=this._application)||void 0===s?void 0:s.messagesBuilder.getMessage(i,t)}getListConfigValue(i){var t,s,l,e;return null!==(e=null!==(s=null===(t=i.value)||void 0===t?void 0:t.elements)&&void 0!==s?s:null===(l=null==i?void 0:i.value)||void 0===l?void 0:l.members)&&void 0!==e?e:null==i?void 0:i.value}render(){var i,t,e,o,n;const a=1==(null===(i=this.config.props)||void 0===i?void 0:i.useSearchPlus);return s(l,null,s("ez-tooltip",{active:!this.config.enabled,message:this.config.disabledMessage,type:"warning"},s(a?"ez-search-plus":"ez-search",{ref:i=>this._searchElement=i,optionLoader:i=>this.optionLoader(i),label:null===(t=this.config)||void 0===t?void 0:t.label,enabled:null===(e=this.config)||void 0===e?void 0:e.enabled,onEzChange:i=>this.onEzSearchChange(i),suppressEmptyOption:!0,stopPropagateEnterKeyEvent:!0}),(null===(o=this._ezListSource)||void 0===o?void 0:o.length)>0&&s("label",{class:"label"},this.getMessage("snkEntityList.selected")),s("div",{style:this.maxHeightList?{"max-height":this.maxHeightList}:{},class:{"snk-entity-list--overflow":!!this.maxHeightList}},s("ez-list",{ref:i=>this._ezList=i,id:"snkEntityList",enabled:null===(n=this.config)||void 0===n?void 0:n.enabled,listMode:"check",dataSource:this._ezListSource,hoverFeedback:!0,itemSlotBuilder:this.rightListSlotBuilder,onEzCheckChange:i=>this.ezListChangeListener(i)})),this.errorMessage&&s("span",{class:"ez-text ez-text--small ez-text--error ez-margin-horizontal--medium"},this.errorMessage)))}static get watchers(){return{config:["observeConfig"]}}};n.style=".sc-snk-entity-list-h{--snk-entity-list--label--font-size:var(--text--medium, 14px);--snk-entity-list--label--font-family:var(--font-pattern, Arial);--snk-entity-list--label--color:var(--title--primary, #000);--snk-entity-list--label--disabled--color:var(--text--disable, #AFB6C0)}.label.sc-snk-entity-list{flex-shrink:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--snk-entity-list--label--color);font-size:var(--snk-entity-list--label--font-size);font-family:var(--snk-entity-list--label--font-family);cursor:default;padding-left:var(--space--small);padding-bottom:var(--space--extra-small)}.snk-entity-list--overflow.sc-snk-entity-list{overflow:auto}.snk-entity-list--overflow.sc-snk-entity-list::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";export{n as snk_entity_list}
1
+ import{r as i,c as t,h as s,H as l}from"./p-82bb3eda.js";import{ObjectUtils as e,ApplicationContext as o}from"@sankhyalabs/core";const n=class{constructor(s){i(this,s),this.valueChanged=t(this,"valueChanged",7),this._ezListSource=[],this.config=void 0,this.rightListSlotBuilder=void 0,this.maxHeightList="",this.value=void 0,this.errorMessage=void 0}async reloadList(){this.loadListSource()}observeConfig(){var i,t;null===(t=null===(i=this._searchElement)||void 0===i?void 0:i.clearValue)||void 0===t||t.call(i)}ezListChangeListener(i){var t,s;this.errorMessage=void 0;const l=e.copy(this.config);null===(t=this.getListConfigValue(l))||void 0===t||t.forEach((t=>{var s,l;t&&t.id===(null===(s=i.detail)||void 0===s?void 0:s.id)&&(t.check=null===(l=i.detail)||void 0===l?void 0:l.check)})),this.config=e.copy(l),this.valueChanged.emit(null===(s=this.config)||void 0===s?void 0:s.value)}loadListSource(){var i;this._ezListSource=[],null===(i=this.getListConfigValue(this.config))||void 0===i||i.forEach((i=>{i&&this._ezListSource.push({label:`${i.id} - ${i.label}`,check:i.check,id:i.id})}))}componentDidLoad(){var i,t,s,l,e;let n=this.getListConfigValue(this.config),a=[];Array.isArray(n)?a=n:a.push(null===(t=null===(i=this.config)||void 0===i?void 0:i.value)||void 0===t?void 0:t.members),this.config.value=a,this._entityName=null===(e=null===(l=null===(s=this.config)||void 0===s?void 0:s.props)||void 0===l?void 0:l.searchContext)||void 0===e?void 0:e.entity,this._application=o.getContextValue("__SNK__APPLICATION__"),this.loadListSource()}optionLoader(i){var t,s,l,e,o,n,a;const{mode:v,argument:d}=i;if(void 0===this._application)return;const r=null!==(l=null===(s=null===(t=this.config)||void 0===t?void 0:t.props)||void 0===s?void 0:s.searchContext)&&void 0!==l?l:{},h=null===(o=null===(e=this.config)||void 0===e?void 0:e.props)||void 0===o?void 0:o.criteria,u=Object.assign(Object.assign({criteria:h},r),{entityDescription:null===(n=this.config)||void 0===n?void 0:n.label,entity:this._entityName,useSearchPlus:null===(a=this.config.props)||void 0===a?void 0:a.useSearchPlus});return this._application.executePreparedSearch(v,d,u)}onEzSearchChange(i){var t,s,l,o;const n=e.isEmptySafetyCheck(i.detail),a=null===(t=this.getListConfigValue(this.config))||void 0===t?void 0:t.find((t=>{var s;return("number"==typeof t.id?String(t.id):t.id)===(null===(s=i.detail)||void 0===s?void 0:s.value)}));n||a||(this.config=Object.assign(Object.assign({},this.config),{value:[...null!==(l=null===(s=this.config)||void 0===s?void 0:s.value)&&void 0!==l?l:[],{id:i.detail.value,check:!0,label:i.detail.label}]}),this.loadListSource(),this.value=this.config.value,this.valueChanged.emit(null===(o=this.config)||void 0===o?void 0:o.value))}getMessage(i,t){var s;return null===(s=this._application)||void 0===s?void 0:s.messagesBuilder.getMessage(i,t)}getListConfigValue(i){var t,s,l,e;return null!==(e=null!==(s=null===(t=i.value)||void 0===t?void 0:t.elements)&&void 0!==s?s:null===(l=null==i?void 0:i.value)||void 0===l?void 0:l.members)&&void 0!==e?e:null==i?void 0:i.value}render(){var i,t,e,o,n;const a=1==(null===(i=this.config.props)||void 0===i?void 0:i.useSearchPlus);return s(l,null,s("ez-tooltip",{active:!this.config.enabled,message:this.config.disabledMessage,type:"warning"},s(a?"ez-search-plus":"ez-search",{ref:i=>this._searchElement=i,optionLoader:i=>this.optionLoader(i),label:null===(t=this.config)||void 0===t?void 0:t.label,enabled:null===(e=this.config)||void 0===e?void 0:e.enabled,onEzChange:i=>this.onEzSearchChange(i),suppressEmptyOption:!0,stopPropagateEnterKeyEvent:!0}),(null===(o=this._ezListSource)||void 0===o?void 0:o.length)>0&&s("label",{class:"label"},this.getMessage("snkEntityList.selected")),s("div",{style:this.maxHeightList?{"max-height":this.maxHeightList}:{},class:{"snk-entity-list--overflow":!!this.maxHeightList}},s("ez-list",{ref:i=>this._ezList=i,id:"snkEntityList",enabled:null===(n=this.config)||void 0===n?void 0:n.enabled,listMode:"check",dataSource:this._ezListSource,hoverFeedback:!0,itemSlotBuilder:this.rightListSlotBuilder,onEzCheckChange:i=>this.ezListChangeListener(i)})),this.errorMessage&&s("span",{class:"ez-text ez-text--small ez-text--error ez-margin-horizontal--medium"},this.errorMessage)))}static get watchers(){return{config:["observeConfig"]}}};n.style=".sc-snk-entity-list-h{--snk-entity-list--label--font-size:var(--text--medium, 14px);--snk-entity-list--label--font-family:var(--font-pattern, Arial);--snk-entity-list--label--color:var(--title--primary, #000);--snk-entity-list--label--disabled--color:var(--text--disable, #AFB6C0)}.label.sc-snk-entity-list{flex-shrink:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--snk-entity-list--label--color);font-size:var(--snk-entity-list--label--font-size);font-family:var(--snk-entity-list--label--font-family);cursor:default;padding-left:var(--space--small);padding-bottom:var(--space--extra-small)}.snk-entity-list--overflow.sc-snk-entity-list{overflow:auto}.snk-entity-list--overflow.sc-snk-entity-list::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";export{n as snk_entity_list}
@@ -1 +1 @@
1
- import{D as t}from"./p-6768f176.js";import"./p-48a5c311.js";import{SortMode as i,ApplicationContext as s,ObjectUtils as e,StringUtils as r,NumberUtils as n,DataType as o,UserInterface as l,DateUtils as a}from"@sankhyalabs/core";import{D as u}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as d}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as c}from"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-9019a32f.js";import{h}from"./p-d8d8169b.js";import{g as v}from"./p-7dd49d15.js";import{I as f}from"./p-8f3f2306.js";import m from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class p{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).map((({name:t,ascending:e})=>{const{dataType:r}=s.getField(t);return{field:t,dataType:r,mode:e?i.ASC:i.DESC}})))}static parseCrudResults(t,i){Array.isArray(t)||(t=[t]);const s=[];for(const e of t){let t={fields:new Map};for(let s in e){let r=e[s];if(r.hasOwnProperty("$")&&t.fields.set(s,r.$),i)break}s.push(t)}return s.length>1?s:s[0]}static find(i,e,r,n=!0,o,l){let a=[],u=[],d={},c=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(c.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{a.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&u.push({nome:t,valor:r[t]});o&&(d={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:u,fields:{field:a},literalCriteria:d,orderby:l}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;e||i(null);const r=this.parseCrudResults(e,n);i(r)}))}))}}class b{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&e.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(r.isEmpty(t))return t;const o=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),l=null==o?void 0:o.getProp("rm_precision",i.name);if(l||0===l)return n.format(t,l,l);if(null==i?void 0:i.props){const s=null==i?void 0:i.props.get("precision"),e=null==i?void 0:i.props.get("prettyPrecision");if(void 0!==s&&void 0!==e)return n.format(t,s,e)}return t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class g{constructor(t,i,s){this.snkApplication=t,this.keyConfigEnableContinuousInsert=`${i}enableContinuousInsert${s||""}`}handleSaveConfig(t){return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert,t)}getConfig(){return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then((t=>!!t&&"true"==t)).catch((()=>!1))}getMessage(t,i){var s,e;return null===(e=null===(s=this.snkApplication)||void 0===s?void 0:s.messagesBuilder)||void 0===e?void 0:e.getMessage(t,i)}actionContinuousInsert(t,i){return{value:r.generateUUID(),label:this.getMessage(t?"continuousInsertUtils.actions.disable":"continuousInsertUtils.actions.enable"),enabled:!0,itemBuilder:()=>h("div",{class:"ez-dropdown__item-wrapper",onClick:i},h("span",{class:"ez-dropdown__item-label"},this.getMessage(t?"continuousInsertUtils.actions.disable":"continuousInsertUtils.actions.enable")))}}}class y{constructor(t,i){this.MAX_WIDTH_COD=60,this.MIN_WIDTH_COD=10,this.DEFAULT_FONT_SIZE=13,this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i,s,e;const r=[];for(const n of t){if(n.hidden&&"RECDESP"!==n.name)continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(n.name),l=await this.grid.getCustomValueFormatter(n.name),a=(null==t?void 0:t.userInterface)===d.SEARCH,u=a?"Cód. ":n.label;let c,h={id:n.name,label:u,width:a?u.length*this.DEFAULT_FONT_SIZE:n.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:l};if(a&&null!=(null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONFIELD)){const i=null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.DESCRIPTIONENTITY,s=t.properties.mergedFrom;c={id:`${s?s+".":""}${t.properties.ENTITYNAME}.${t.properties.DESCRIPTIONFIELD}`,label:i,width:a&&i?i.length*this.DEFAULT_FONT_SIZE-60:n.width,type:o.TEXT,userInterface:d.LONGTEXT,descriptionFrom:t.name};const r=this.getWidthByMetaData(null==n?void 0:n.width,null==h?void 0:h.width,null==c?void 0:c.width);h=Object.assign(Object.assign({},h),{width:null==r?void 0:r.codWidth}),c=Object.assign(Object.assign({},c),{width:null==r?void 0:r.descWidth,label:(null==c?void 0:c.label)||(null==n?void 0:n.label)})}r.push(h),c&&r.push(c)}return r||[]}getWidthByMetaData(t,i,s){const e=i+s,r=s/e;let n=Math.round(t*(i/e)),o=Math.round(t*r);return n>this.MAX_WIDTH_COD?(n=this.MAX_WIDTH_COD,o=t-this.MAX_WIDTH_COD):n<this.MIN_WIDTH_COD&&(n=this.MIN_WIDTH_COD,o=t-this.MIN_WIDTH_COD),{codWidth:n,descWidth:o}}}class w extends y{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var t,i,s;const{total:e}=(null===(t=this.dataUnit)||void 0===t?void 0:t.getPaginationInfo())||{};return null!=e?e:null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length}getSelectedIDs(){return v(this.dataUnit)}getRecordID(){var t,i,s;return null===(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===i?void 0:i[0])||void 0===s?void 0:s.__record__id__}async getRecords(t){if(0===this.dataUnit.records.length)return[];switch(t){case f.ALL:return this.dataUnit.getSelectionInfo().getAllRecords();case f.SELECTION:return this.resolveRecordsFromSelection();case f.PAGE:return this.dataUnit.records;default:return this.resolveRecordsFromSelection()}}resolveRecordsFromSelection(){const t=this.dataUnit.getSelectionInfo();if(t.isEmpty())return this.dataUnit.records;const i=t.isAllRecords()?t.getAllRecords():t.records;return i.length?i:this.dataUnit.records}getHiddenOptions(){return[u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS]}formatValue(t,i){const{id:s,descriptionFrom:e}=i,r=t[e||s];if(null==r)return"";if(null!=e)return r.label;if(this.dataUnit.getField(s).userInterface===l.SEARCH)return r.value;if(i.customFormatter){const s=this.getColumnsState().find((t=>i.id===t.name));return i.customFormatter.format(r,s,t.__record__id__)}return this.dataUnit.getFormattedValue(s,r)}}class I{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===l.DATETIME?a.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t,i){return Promise.resolve(null==t?void 0:await c.getDistinct(this._dataUnit,t,null==i?void 0:i.onlyLabel))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===l.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return m.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}export{y as C,b as R,I as S,p as a,g as b,w as c}
1
+ import{D as t}from"./p-6768f176.js";import"./p-48a5c311.js";import{SortMode as i,ApplicationContext as s,ObjectUtils as e,StringUtils as r,NumberUtils as n,DataType as o,UserInterface as l,DateUtils as a}from"@sankhyalabs/core";import{D as u}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as d}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as c}from"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-9019a32f.js";import{h}from"./p-82bb3eda.js";import{g as v}from"./p-7dd49d15.js";import{I as f}from"./p-8f3f2306.js";import m from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class p{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).map((({name:t,ascending:e})=>{const{dataType:r}=s.getField(t);return{field:t,dataType:r,mode:e?i.ASC:i.DESC}})))}static parseCrudResults(t,i){Array.isArray(t)||(t=[t]);const s=[];for(const e of t){let t={fields:new Map};for(let s in e){let r=e[s];if(r.hasOwnProperty("$")&&t.fields.set(s,r.$),i)break}s.push(t)}return s.length>1?s:s[0]}static find(i,e,r,n=!0,o,l){let a=[],u=[],d={},c=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(c.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{a.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&u.push({nome:t,valor:r[t]});o&&(d={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:u,fields:{field:a},literalCriteria:d,orderby:l}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;e||i(null);const r=this.parseCrudResults(e,n);i(r)}))}))}}class b{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&e.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(r.isEmpty(t))return t;const o=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),l=null==o?void 0:o.getProp("rm_precision",i.name);if(l||0===l)return n.format(t,l,l);if(null==i?void 0:i.props){const s=null==i?void 0:i.props.get("precision"),e=null==i?void 0:i.props.get("prettyPrecision");if(void 0!==s&&void 0!==e)return n.format(t,s,e)}return t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class g{constructor(t,i,s){this.snkApplication=t,this.keyConfigEnableContinuousInsert=`${i}enableContinuousInsert${s||""}`}handleSaveConfig(t){return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert,t)}getConfig(){return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then((t=>!!t&&"true"==t)).catch((()=>!1))}getMessage(t,i){var s,e;return null===(e=null===(s=this.snkApplication)||void 0===s?void 0:s.messagesBuilder)||void 0===e?void 0:e.getMessage(t,i)}actionContinuousInsert(t,i){return{value:r.generateUUID(),label:this.getMessage(t?"continuousInsertUtils.actions.disable":"continuousInsertUtils.actions.enable"),enabled:!0,itemBuilder:()=>h("div",{class:"ez-dropdown__item-wrapper",onClick:i},h("span",{class:"ez-dropdown__item-label"},this.getMessage(t?"continuousInsertUtils.actions.disable":"continuousInsertUtils.actions.enable")))}}}class y{constructor(t,i){this.MAX_WIDTH_COD=60,this.MIN_WIDTH_COD=10,this.DEFAULT_FONT_SIZE=13,this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i,s,e;const r=[];for(const n of t){if(n.hidden&&"RECDESP"!==n.name)continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(n.name),l=await this.grid.getCustomValueFormatter(n.name),a=(null==t?void 0:t.userInterface)===d.SEARCH,u=a?"Cód. ":n.label;let c,h={id:n.name,label:u,width:a?u.length*this.DEFAULT_FONT_SIZE:n.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:l};if(a&&null!=(null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONFIELD)){const i=null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.DESCRIPTIONENTITY,s=t.properties.mergedFrom;c={id:`${s?s+".":""}${t.properties.ENTITYNAME}.${t.properties.DESCRIPTIONFIELD}`,label:i,width:a&&i?i.length*this.DEFAULT_FONT_SIZE-60:n.width,type:o.TEXT,userInterface:d.LONGTEXT,descriptionFrom:t.name};const r=this.getWidthByMetaData(null==n?void 0:n.width,null==h?void 0:h.width,null==c?void 0:c.width);h=Object.assign(Object.assign({},h),{width:null==r?void 0:r.codWidth}),c=Object.assign(Object.assign({},c),{width:null==r?void 0:r.descWidth,label:(null==c?void 0:c.label)||(null==n?void 0:n.label)})}r.push(h),c&&r.push(c)}return r||[]}getWidthByMetaData(t,i,s){const e=i+s,r=s/e;let n=Math.round(t*(i/e)),o=Math.round(t*r);return n>this.MAX_WIDTH_COD?(n=this.MAX_WIDTH_COD,o=t-this.MAX_WIDTH_COD):n<this.MIN_WIDTH_COD&&(n=this.MIN_WIDTH_COD,o=t-this.MIN_WIDTH_COD),{codWidth:n,descWidth:o}}}class w extends y{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var t,i,s;const{total:e}=(null===(t=this.dataUnit)||void 0===t?void 0:t.getPaginationInfo())||{};return null!=e?e:null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length}getSelectedIDs(){return v(this.dataUnit)}getRecordID(){var t,i,s;return null===(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===i?void 0:i[0])||void 0===s?void 0:s.__record__id__}async getRecords(t){if(0===this.dataUnit.records.length)return[];switch(t){case f.ALL:return this.dataUnit.getSelectionInfo().getAllRecords();case f.SELECTION:return this.resolveRecordsFromSelection();case f.PAGE:return this.dataUnit.records;default:return this.resolveRecordsFromSelection()}}resolveRecordsFromSelection(){const t=this.dataUnit.getSelectionInfo();if(t.isEmpty())return this.dataUnit.records;const i=t.isAllRecords()?t.getAllRecords():t.records;return i.length?i:this.dataUnit.records}getHiddenOptions(){return[u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS]}formatValue(t,i){const{id:s,descriptionFrom:e}=i,r=t[e||s];if(null==r)return"";if(null!=e)return r.label;if(this.dataUnit.getField(s).userInterface===l.SEARCH)return r.value;if(i.customFormatter){const s=this.getColumnsState().find((t=>i.id===t.name));return i.customFormatter.format(r,s,t.__record__id__)}return this.dataUnit.getFormattedValue(s,r)}}class I{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===l.DATETIME?a.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t,i){return Promise.resolve(null==t?void 0:await c.getDistinct(this._dataUnit,t,null==i?void 0:i.onlyLabel))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===l.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return m.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}export{y as C,b as R,I as S,p as a,g as b,w as c}
@@ -1 +1 @@
1
- import{r as t,c as s,h as i,H as e,g as a}from"./p-d8d8169b.js";import{Action as h,ElementIDUtils as n,LockManager as r,LockManagerOperation as o,SilentException as l,StringUtils as d,ApplicationContext as v,OVERFLOWED_CLASS_NAME as u,OverflowWatcher as c,OverflowDirection as k}from"@sankhyalabs/core";import{P as b}from"./p-0f3698af.js";import{A as m}from"./p-dc36cfbf.js";import{T as p,V as T,A as f,b as g,a as w}from"./p-b987e15d.js";import"./p-55798617.js";const A=class{constructor(i){t(this,i),this.actionClick=s(this,"actionClick",7),this.taskbarSaveLocker=s(this,"taskbarSaveLocker",7),this.taskbarSaveUnlocker=s(this,"taskbarSaveUnlocker",7),this.TASKBAR_ITEM_ID_PREFIX="TASKBAR_ITEM_",this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME="taskbar-custom-elements-container",this.NOT_OVERFLOW_ELEMENTS=["moreOptions","dataExporter_snkDataExporter","actionsButton_snkActionsButton"],this.TASKBAR_CUSTOM_ELEMENTS="taskbar-custom-elements-container",this.TASKBAR_ADDITIONAL_SLOT_CONTAINER_CLASS_NAME="taskbar-additional-slot-container",this.TASKBAR_ADDITIONAL_SLOT="taskbar-additional-slot-container",this._dataUnitInitialized=!1,this._titleKeyByElement={[p.UPDATE_MULTIPLE]:"snkTaskbar.titleUpdateMultiple",[p.UPDATE]:"snkTaskbar.titleUpdate",[p.PREVIOUS]:"snkTaskbar.titlePrevious",[p.NEXT]:"snkTaskbar.titleNext",[p.REFRESH]:"snkTaskbar.titleRefresh",[p.CLONE]:"snkTaskbar.titleClone",[p.REMOVE]:"snkTaskbar.titleRemove",[p.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[p.INSERT]:"snkTaskbar.titleInsert",[p.CANCEL]:"snkTaskbar.titleCancel",[p.SAVE]:"snkTaskbar.titleSave",[p.GRID_MODE]:"snkTaskbar.titleGridMode",[p.FORM_MODE]:"snkTaskbar.titleFormMode",[p.CONFIGURATOR]:"snkTaskbar.titleConfigurator",[p.ATTACH]:"snkTaskbar.titleAttach"},this.onSaveEvent=t=>{switch(t.type){case h.FIELD_INVALIDATED:case h.INVALIDATE_CLEAN:case h.DATA_SAVED:case h.SAVING_ERROR:case h.SAVING_CANCELED:this._isWaitingForSave=!1;break;case h.SAVING_DATA:this._isWaitingForSave=!0}},this._permissions=void 0,this._overFlowedElements=[],this._customElements=void 0,this._customElementsId=void 0,this._slotContainer=void 0,this._hiddenActionsList=[],this._lastWidth=void 0,this._hasToUpdateOverFlow=!1,this._isWaitingForSave=!1,this.alignRigth=!1,this.customSlotId="TASKBAR_CUSTOM_ELEMENTS",this.additionalSlotId="TASKBAR_ADDITIONAL_SLOT",this.customContainerId=void 0,this.overflowStrategy="hiddenItems",this.configName=void 0,this.resourceID=void 0,this.buttons=void 0,this.customButtons=void 0,this.actionsList=void 0,this.actionsSettingsList=void 0,this.primaryButton=void 0,this.disabledButtons=void 0,this.dataUnit=void 0,this.presentationMode=b.PRIMARY,this.messagesBuilder=void 0}handleCustomSlotElementsLoaded(t){this.hasToSearchCustomElements(t)&&this.getCustomElements(!0)}handleTaskbarSaveLocker(){!0!==this._isWaitingForSave&&(this._isWaitingForSave=!0)}handleTaskbarSaveUnlocker(){!0===this._isWaitingForSave&&(this._isWaitingForSave=!1)}hasToSearchCustomElements(t){return this.customSlotId===t.detail&&!this._slotContainer}observeButtons(){this._definitions=void 0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()}))}))}observeDisabledButtons(){var t;null===(t=this._overFlowWatcher)||void 0===t||t.forceUpdate()}observeLastWidth(t,s){0===s&&0!==t&&(this._hasToUpdateOverFlow=!0)}observeIsWaitingForSave(t,s){1==t&&0==s&&this.taskbarSaveLocker.emit(),0==t&&1==s&&this.taskbarSaveUnlocker.emit()}observeDataUnit(t){this.initializeDataUnit(t)}initializeDataUnit(t){t&&!this._dataUnitInitialized&&(this._dataUnitInitialized=!0,n.addIDInfo(this._element,null,{dataUnit:this.dataUnit}),this.dataUnit.subscribe(this.onSaveEvent))}elementsFromString(t){const s=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(T[t]||this.isAllowed(t))&&s.push(t.trim())})),s}isAllowed(t){return t===f.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[m.CONFIG_GRID]||this._permissions[m.CONFIG]):!f[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){var s;let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,{}):""}elementClick(t){r.whenResolve(this._element,o.TASKBAR_CLICK).then((()=>{if(this.dataUnit){switch(t){case p.PREVIOUS:this.dataUnit.previousRecord();break;case p.NEXT:this.dataUnit.nextRecord();break;case p.REFRESH:this.dataUnit.loadData();break;case p.CLONE:this.dataUnit.copySelected();break;case p.REMOVE:this.dataUnit.removeSelectedRecords();break;case p.INSERT:this.dataUnit.addRecord();break;case p.CANCEL:this.dataUnit.cancelEdition();break;case p.SAVE:this._isWaitingForSave||(this._isWaitingForSave=!0,this.dataUnit.saveData().catch((t=>{if(!(t instanceof l))throw t})).finally((()=>{this._isWaitingForSave=!1})))}this.isEnabled(t)&&this.actionClick.emit(t)}}))}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}validatePresentationMode(){Object.values(b).includes(this.presentationMode)||(this.presentationMode=b.PRIMARY)}getElement(t,s){let i=s===this.primaryButton?"ez-button--primary ":"";t>1&&(i+="ez-padding-left--medium");const e=p[s.toString()],a=this._element.dataset.exporterStoreKey||this.configName;return e?g(s,i,this.getIdElemBtnNative(s),(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),s!==p.CONFIGURATOR?this.buildDynamicActionsList():this.buildActionsSettingsList(),a,this.presentationMode):w(s,i,this.getIdElemBtnCustom(s),(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}buildDynamicActionsList(){var t;return this._hiddenActionsList.length?[...null!==(t=this.actionsList)&&void 0!==t?t:[],...this._hiddenActionsList]:this.actionsList}buildActionsSettingsList(){return this.actionsSettingsList}getIdElemBtnNative(t){return d.toCamelCase(t)}getIdElemBtnCustom(t){return d.toCamelCase(t.name)}isDivider(t){var s;return void 0!==t&&(null===(s=t.t)||void 0===s?void 0:s["data-taskbar-divider"])}removeEmpty(t){let s;return t.filter((t=>!(null==t||this.isDivider(s)&&this.isDivider(t)||(s=t,0))))}appendCustomElementsInTaskbar(){this._customElementsId.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s),e=this._element.querySelector(`#${t}`);e?null==e||e.appendChild(i):this.unlinkCustomElementFromTaskbar(i)}))}addCustomElementContainer(t){var s;const e=`${this.TASKBAR_ITEM_ID_PREFIX}${t}`;return this._customElementsId.includes(e)||(this._customElementsId.push(e),null===(s=this._overFlowWatcher)||void 0===s||s.addNotOverFlowElement(e)),i("span",{class:"ez-padding-left--medium",key:e,id:e})}getCustomElements(t){var s,i;this._customElementsId=[],this._customElements=new Map,this._slotContainer=this.buildSlotContainer(t),Array.from(null!==(i=null===(s=this._slotContainer)||void 0===s?void 0:s.children)&&void 0!==i?i:[]).forEach((t=>this._customElements.set(t.id,t)))}buildSlotContainer(t){let s;if(this.customContainerId){const t=document.querySelector(`#${this.customContainerId}`);s=null==t?void 0:t.querySelector(`#${this.customSlotId}`)}else s=this._element.querySelector(`#${this.customSlotId}`);return t&&!s&&(s=document.querySelector(`#${this.customSlotId}`)),s}componentWillLoad(){this._application=v.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)):this._permissions={},this.getCustomElements()}componentWillRender(){this.handleDefinitions(),this.validatePresentationMode(),this.updateOverFlowIfNeeded()}handleDefinitions(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}updateOverFlowIfNeeded(){this._hasToUpdateOverFlow&&(requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()})),this._hasToUpdateOverFlow=!1)}handleOverFlow(t){const s=t.filter((t=>!this.hasToIgnoreOverFlow(t)));this.resetOverFlowedElements(),this.doOverFlowElements(s)}resetOverFlowedElements(){this._overFlowedElements.forEach((t=>{t.classList.remove(u)})),this._hiddenActionsList=[],this._overFlowedElements=[]}doOverFlowElements(t){t.forEach((t=>{t.classList.add(u),this._overFlowedElements.push(t),this.addItemToActionList(t)}))}addItemToActionList(t){const s=this.getTaskbarElementName(t);if(s&&this.isEnabled(s)&&this.isAllowed(s)){const i={value:s,label:this.getTaskbarElementLabel(t),iconName:this.getTaskbarElementIcon(t)};this._hiddenActionsList.push(i)}}getTaskbarElementName(t){var s;return null!==(s=t.getAttribute("data-taskbar-element"))&&void 0!==s?s:""}getTaskbarElementIcon(t){var s;return null!==(s=t.getAttribute("data-taskbar-icon"))&&void 0!==s?s:""}getTaskbarElementLabel(t){var s;return null!==(s=t.getAttribute("data-taskbar-label"))&&void 0!==s?s:""}hasToIgnoreOverFlow(t){return t.classList.contains(this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME)||t.classList.contains(this.TASKBAR_ADDITIONAL_SLOT_CONTAINER_CLASS_NAME)}handleOverFlowStrategy(){"hiddenItems"===this.overflowStrategy&&(this._overFlowWatcher=new c(this.buildOverFlowWatcherParams()))}buildOverFlowWatcherParams(){return{element:this._element,callback:this.handleOverFlow.bind(this),overFlowDirection:k.HORIZONTAL,notOverFlow:this.NOT_OVERFLOW_ELEMENTS}}componentDidLoad(){this.initializeDataUnit(this.dataUnit),this.handleOverFlowStrategy()}componentDidRender(){this.appendCustomElementsInTaskbar(),this.updateLastWidth()}updateLastWidth(){this._lastWidth=this._element.getBoundingClientRect().width}disconnectedCallback(){var t,s;null===(t=this.dataUnit)||void 0===t||t.unsubscribe(this.onSaveEvent),this.unlinkAllCustomElements(),null===(s=this._overFlowWatcher)||void 0===s||s.destroy()}unlinkAllCustomElements(){var t;null===(t=this._customElementsId)||void 0===t||t.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s);this.unlinkCustomElementFromTaskbar(i)}))}unlinkCustomElementFromTaskbar(t){this._slotContainer.appendChild(t)}render(){var t,s;if(void 0===this._definitions)return;let a=0;return i(e,{class:this.getHostClasses()},this.removeEmpty(this._definitions.map((t=>{var s,e;return a++,p[t]?this.getElement(a,p[t]):(null===(s=this.customButtons)||void 0===s?void 0:s.has(t))?this.getElement(a,this.customButtons.get(t)):this._customElements.has(t)?this.addCustomElementContainer(t):(null===(e=this._overFlowWatcher)||void 0===e||e.addNotOverFlowElement(t),i("slot",{name:t}))}))),i("div",{id:this.TASKBAR_CUSTOM_ELEMENTS,class:this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME},i("slot",{name:this.customSlotId}),null===(t=this._overFlowWatcher)||void 0===t?void 0:t.addNotOverFlowElement(this.TASKBAR_CUSTOM_ELEMENTS)),i("div",{id:this.TASKBAR_ADDITIONAL_SLOT,class:this.TASKBAR_ADDITIONAL_SLOT_CONTAINER_CLASS_NAME},i("slot",{name:this.additionalSlotId}),null===(s=this._overFlowWatcher)||void 0===s?void 0:s.addNotOverFlowElement(this.TASKBAR_ADDITIONAL_SLOT)))}getHostClasses(){return"hiddenItems"!==this.overflowStrategy?"no-wrap":"full-width "+(this.alignRigth?"align-right":"")}get _element(){return a(this)}static get watchers(){return{buttons:["observeButtons"],disabledButtons:["observeDisabledButtons"],_lastWidth:["observeLastWidth"],_isWaitingForSave:["observeIsWaitingForSave"],dataUnit:["observeDataUnit"]}}};A.style=".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";export{A as snk_taskbar}
1
+ import{r as t,c as s,h as i,H as e,g as a}from"./p-82bb3eda.js";import{Action as h,ElementIDUtils as n,LockManager as r,LockManagerOperation as o,SilentException as l,StringUtils as d,ApplicationContext as v,OVERFLOWED_CLASS_NAME as u,OverflowWatcher as c,OverflowDirection as k}from"@sankhyalabs/core";import{P as b}from"./p-0f3698af.js";import{A as m}from"./p-dc36cfbf.js";import{T as p,V as T,A as f,b as g,a as w}from"./p-1be69fd4.js";import"./p-8336900b.js";const A=class{constructor(i){t(this,i),this.actionClick=s(this,"actionClick",7),this.taskbarSaveLocker=s(this,"taskbarSaveLocker",7),this.taskbarSaveUnlocker=s(this,"taskbarSaveUnlocker",7),this.TASKBAR_ITEM_ID_PREFIX="TASKBAR_ITEM_",this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME="taskbar-custom-elements-container",this.NOT_OVERFLOW_ELEMENTS=["moreOptions","dataExporter_snkDataExporter","actionsButton_snkActionsButton"],this.TASKBAR_CUSTOM_ELEMENTS="taskbar-custom-elements-container",this.TASKBAR_ADDITIONAL_SLOT_CONTAINER_CLASS_NAME="taskbar-additional-slot-container",this.TASKBAR_ADDITIONAL_SLOT="taskbar-additional-slot-container",this._dataUnitInitialized=!1,this._titleKeyByElement={[p.UPDATE_MULTIPLE]:"snkTaskbar.titleUpdateMultiple",[p.UPDATE]:"snkTaskbar.titleUpdate",[p.PREVIOUS]:"snkTaskbar.titlePrevious",[p.NEXT]:"snkTaskbar.titleNext",[p.REFRESH]:"snkTaskbar.titleRefresh",[p.CLONE]:"snkTaskbar.titleClone",[p.REMOVE]:"snkTaskbar.titleRemove",[p.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[p.INSERT]:"snkTaskbar.titleInsert",[p.CANCEL]:"snkTaskbar.titleCancel",[p.SAVE]:"snkTaskbar.titleSave",[p.GRID_MODE]:"snkTaskbar.titleGridMode",[p.FORM_MODE]:"snkTaskbar.titleFormMode",[p.CONFIGURATOR]:"snkTaskbar.titleConfigurator",[p.ATTACH]:"snkTaskbar.titleAttach"},this.onSaveEvent=t=>{switch(t.type){case h.FIELD_INVALIDATED:case h.INVALIDATE_CLEAN:case h.DATA_SAVED:case h.SAVING_ERROR:case h.SAVING_CANCELED:this._isWaitingForSave=!1;break;case h.SAVING_DATA:this._isWaitingForSave=!0}},this._permissions=void 0,this._overFlowedElements=[],this._customElements=void 0,this._customElementsId=void 0,this._slotContainer=void 0,this._hiddenActionsList=[],this._lastWidth=void 0,this._hasToUpdateOverFlow=!1,this._isWaitingForSave=!1,this.alignRigth=!1,this.customSlotId="TASKBAR_CUSTOM_ELEMENTS",this.additionalSlotId="TASKBAR_ADDITIONAL_SLOT",this.customContainerId=void 0,this.overflowStrategy="hiddenItems",this.configName=void 0,this.resourceID=void 0,this.buttons=void 0,this.customButtons=void 0,this.actionsList=void 0,this.actionsSettingsList=void 0,this.primaryButton=void 0,this.disabledButtons=void 0,this.dataUnit=void 0,this.presentationMode=b.PRIMARY,this.messagesBuilder=void 0}handleCustomSlotElementsLoaded(t){this.hasToSearchCustomElements(t)&&this.getCustomElements(!0)}handleTaskbarSaveLocker(){!0!==this._isWaitingForSave&&(this._isWaitingForSave=!0)}handleTaskbarSaveUnlocker(){!0===this._isWaitingForSave&&(this._isWaitingForSave=!1)}hasToSearchCustomElements(t){return this.customSlotId===t.detail&&!this._slotContainer}observeButtons(){this._definitions=void 0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()}))}))}observeDisabledButtons(){var t;null===(t=this._overFlowWatcher)||void 0===t||t.forceUpdate()}observeLastWidth(t,s){0===s&&0!==t&&(this._hasToUpdateOverFlow=!0)}observeIsWaitingForSave(t,s){1==t&&0==s&&this.taskbarSaveLocker.emit(),0==t&&1==s&&this.taskbarSaveUnlocker.emit()}observeDataUnit(t){this.initializeDataUnit(t)}initializeDataUnit(t){t&&!this._dataUnitInitialized&&(this._dataUnitInitialized=!0,n.addIDInfo(this._element,null,{dataUnit:this.dataUnit}),this.dataUnit.subscribe(this.onSaveEvent))}elementsFromString(t){const s=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(T[t]||this.isAllowed(t))&&s.push(t.trim())})),s}isAllowed(t){return t===f.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[m.CONFIG_GRID]||this._permissions[m.CONFIG]):!f[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){var s;let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,{}):""}elementClick(t){r.whenResolve(this._element,o.TASKBAR_CLICK).then((()=>{if(this.dataUnit){switch(t){case p.PREVIOUS:this.dataUnit.previousRecord();break;case p.NEXT:this.dataUnit.nextRecord();break;case p.REFRESH:this.dataUnit.loadData();break;case p.CLONE:this.dataUnit.copySelected();break;case p.REMOVE:this.dataUnit.removeSelectedRecords();break;case p.INSERT:this.dataUnit.addRecord();break;case p.CANCEL:this.dataUnit.cancelEdition();break;case p.SAVE:this._isWaitingForSave||(this._isWaitingForSave=!0,this.dataUnit.saveData().catch((t=>{if(!(t instanceof l))throw t})).finally((()=>{this._isWaitingForSave=!1})))}this.isEnabled(t)&&this.actionClick.emit(t)}}))}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}validatePresentationMode(){Object.values(b).includes(this.presentationMode)||(this.presentationMode=b.PRIMARY)}getElement(t,s){let i=s===this.primaryButton?"ez-button--primary ":"";t>1&&(i+="ez-padding-left--medium");const e=p[s.toString()],a=this._element.dataset.exporterStoreKey||this.configName;return e?g(s,i,this.getIdElemBtnNative(s),(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),s!==p.CONFIGURATOR?this.buildDynamicActionsList():this.buildActionsSettingsList(),a,this.presentationMode):w(s,i,this.getIdElemBtnCustom(s),(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}buildDynamicActionsList(){var t;return this._hiddenActionsList.length?[...null!==(t=this.actionsList)&&void 0!==t?t:[],...this._hiddenActionsList]:this.actionsList}buildActionsSettingsList(){return this.actionsSettingsList}getIdElemBtnNative(t){return d.toCamelCase(t)}getIdElemBtnCustom(t){return d.toCamelCase(t.name)}isDivider(t){var s;return void 0!==t&&(null===(s=t.t)||void 0===s?void 0:s["data-taskbar-divider"])}removeEmpty(t){let s;return t.filter((t=>!(null==t||this.isDivider(s)&&this.isDivider(t)||(s=t,0))))}appendCustomElementsInTaskbar(){this._customElementsId.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s),e=this._element.querySelector(`#${t}`);e?null==e||e.appendChild(i):this.unlinkCustomElementFromTaskbar(i)}))}addCustomElementContainer(t){var s;const e=`${this.TASKBAR_ITEM_ID_PREFIX}${t}`;return this._customElementsId.includes(e)||(this._customElementsId.push(e),null===(s=this._overFlowWatcher)||void 0===s||s.addNotOverFlowElement(e)),i("span",{class:"ez-padding-left--medium",key:e,id:e})}getCustomElements(t){var s,i;this._customElementsId=[],this._customElements=new Map,this._slotContainer=this.buildSlotContainer(t),Array.from(null!==(i=null===(s=this._slotContainer)||void 0===s?void 0:s.children)&&void 0!==i?i:[]).forEach((t=>this._customElements.set(t.id,t)))}buildSlotContainer(t){let s;if(this.customContainerId){const t=document.querySelector(`#${this.customContainerId}`);s=null==t?void 0:t.querySelector(`#${this.customSlotId}`)}else s=this._element.querySelector(`#${this.customSlotId}`);return t&&!s&&(s=document.querySelector(`#${this.customSlotId}`)),s}componentWillLoad(){this._application=v.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)):this._permissions={},this.getCustomElements()}componentWillRender(){this.handleDefinitions(),this.validatePresentationMode(),this.updateOverFlowIfNeeded()}handleDefinitions(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}updateOverFlowIfNeeded(){this._hasToUpdateOverFlow&&(requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()})),this._hasToUpdateOverFlow=!1)}handleOverFlow(t){const s=t.filter((t=>!this.hasToIgnoreOverFlow(t)));this.resetOverFlowedElements(),this.doOverFlowElements(s)}resetOverFlowedElements(){this._overFlowedElements.forEach((t=>{t.classList.remove(u)})),this._hiddenActionsList=[],this._overFlowedElements=[]}doOverFlowElements(t){t.forEach((t=>{t.classList.add(u),this._overFlowedElements.push(t),this.addItemToActionList(t)}))}addItemToActionList(t){const s=this.getTaskbarElementName(t);if(s&&this.isEnabled(s)&&this.isAllowed(s)){const i={value:s,label:this.getTaskbarElementLabel(t),iconName:this.getTaskbarElementIcon(t)};this._hiddenActionsList.push(i)}}getTaskbarElementName(t){var s;return null!==(s=t.getAttribute("data-taskbar-element"))&&void 0!==s?s:""}getTaskbarElementIcon(t){var s;return null!==(s=t.getAttribute("data-taskbar-icon"))&&void 0!==s?s:""}getTaskbarElementLabel(t){var s;return null!==(s=t.getAttribute("data-taskbar-label"))&&void 0!==s?s:""}hasToIgnoreOverFlow(t){return t.classList.contains(this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME)||t.classList.contains(this.TASKBAR_ADDITIONAL_SLOT_CONTAINER_CLASS_NAME)}handleOverFlowStrategy(){"hiddenItems"===this.overflowStrategy&&(this._overFlowWatcher=new c(this.buildOverFlowWatcherParams()))}buildOverFlowWatcherParams(){return{element:this._element,callback:this.handleOverFlow.bind(this),overFlowDirection:k.HORIZONTAL,notOverFlow:this.NOT_OVERFLOW_ELEMENTS}}componentDidLoad(){this.initializeDataUnit(this.dataUnit),this.handleOverFlowStrategy()}componentDidRender(){this.appendCustomElementsInTaskbar(),this.updateLastWidth()}updateLastWidth(){this._lastWidth=this._element.getBoundingClientRect().width}disconnectedCallback(){var t,s;null===(t=this.dataUnit)||void 0===t||t.unsubscribe(this.onSaveEvent),this.unlinkAllCustomElements(),null===(s=this._overFlowWatcher)||void 0===s||s.destroy()}unlinkAllCustomElements(){var t;null===(t=this._customElementsId)||void 0===t||t.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s);this.unlinkCustomElementFromTaskbar(i)}))}unlinkCustomElementFromTaskbar(t){this._slotContainer.appendChild(t)}render(){var t,s;if(void 0===this._definitions)return;let a=0;return i(e,{class:this.getHostClasses()},this.removeEmpty(this._definitions.map((t=>{var s,e;return a++,p[t]?this.getElement(a,p[t]):(null===(s=this.customButtons)||void 0===s?void 0:s.has(t))?this.getElement(a,this.customButtons.get(t)):this._customElements.has(t)?this.addCustomElementContainer(t):(null===(e=this._overFlowWatcher)||void 0===e||e.addNotOverFlowElement(t),i("slot",{name:t}))}))),i("div",{id:this.TASKBAR_CUSTOM_ELEMENTS,class:this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME},i("slot",{name:this.customSlotId}),null===(t=this._overFlowWatcher)||void 0===t?void 0:t.addNotOverFlowElement(this.TASKBAR_CUSTOM_ELEMENTS)),i("div",{id:this.TASKBAR_ADDITIONAL_SLOT,class:this.TASKBAR_ADDITIONAL_SLOT_CONTAINER_CLASS_NAME},i("slot",{name:this.additionalSlotId}),null===(s=this._overFlowWatcher)||void 0===s?void 0:s.addNotOverFlowElement(this.TASKBAR_ADDITIONAL_SLOT)))}getHostClasses(){return"hiddenItems"!==this.overflowStrategy?"no-wrap":"full-width "+(this.alignRigth?"align-right":"")}get _element(){return a(this)}static get watchers(){return{buttons:["observeButtons"],disabledButtons:["observeDisabledButtons"],_lastWidth:["observeLastWidth"],_isWaitingForSave:["observeIsWaitingForSave"],dataUnit:["observeDataUnit"]}}};A.style=".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";export{A as snk_taskbar}
@@ -1 +1 @@
1
- import{r as i,c as s,h as e,g as t}from"./p-d8d8169b.js";import{ElementIDUtils as l,ApplicationContext as a}from"@sankhyalabs/core";const r=class{constructor(e){i(this,e),this.clickBreadcrumbItem=s(this,"clickBreadcrumbItem",3),this.exit=s(this,"exit",3),this.label=void 0,this.breadcrumbItens=void 0,this.messagesBuilder=void 0}getMessage(i,s){var e;return this.messagesBuilder?this.messagesBuilder.getMessage(i,s):(null===(e=this._application)||void 0===e?void 0:e.messagesBuilder)?this._application.messagesBuilder.getMessage(i,s):void 0}componentDidLoad(){this._element&&(l.addIDInfo(this._element),this._application=a.getContextValue("__SNK__APPLICATION__"))}render(){return e("div",{class:"simple-bar__container ez-margin-vertical--small ez-padding--extra-small"},e("div",{class:"simple-bar__left-slot"},e("ez-button",{class:"ez-padding-right--medium",title:this.getMessage("snkSimpleBar.backTitle"),mode:"icon",iconName:"arrow_back",size:"medium",onClick:()=>this.exit.emit()}),e("div",{class:"simple-bar__column"},e("h1",{class:"ez-title ez-title--primary ez-title--extra-large"},this.label),e("ez-breadcrumb",{items:this.breadcrumbItens,onSelectedItem:({detail:i})=>this.clickBreadcrumbItem.emit(i)}))),e("div",{class:"simple-bar__right-slot"},e("slot",{name:"rightSlot"})))}get _element(){return t(this)}};r.style=".sc-snk-simple-bar-h{display:flex;height:100%;width:100%}.simple-bar__container.sc-snk-simple-bar{flex:1;display:flex;align-items:stretch;gap:var(--space--small)}.simple-bar__left-slot.sc-snk-simple-bar{min-width:280px;flex:1;display:flex;align-items:center}.simple-bar__right-slot.sc-snk-simple-bar{flex:1;display:flex;align-items:center;justify-content:flex-end}.simple-bar__column.sc-snk-simple-bar{flex:1;display:flex;flex-direction:column}";export{r as snk_simple_bar}
1
+ import{r as i,c as s,h as e,g as t}from"./p-82bb3eda.js";import{ElementIDUtils as l,ApplicationContext as a}from"@sankhyalabs/core";const r=class{constructor(e){i(this,e),this.clickBreadcrumbItem=s(this,"clickBreadcrumbItem",3),this.exit=s(this,"exit",3),this.label=void 0,this.breadcrumbItens=void 0,this.messagesBuilder=void 0}getMessage(i,s){var e;return this.messagesBuilder?this.messagesBuilder.getMessage(i,s):(null===(e=this._application)||void 0===e?void 0:e.messagesBuilder)?this._application.messagesBuilder.getMessage(i,s):void 0}componentDidLoad(){this._element&&(l.addIDInfo(this._element),this._application=a.getContextValue("__SNK__APPLICATION__"))}render(){return e("div",{class:"simple-bar__container ez-margin-vertical--small ez-padding--extra-small"},e("div",{class:"simple-bar__left-slot"},e("ez-button",{class:"ez-padding-right--medium",title:this.getMessage("snkSimpleBar.backTitle"),mode:"icon",iconName:"arrow_back",size:"medium",onClick:()=>this.exit.emit()}),e("div",{class:"simple-bar__column"},e("h1",{class:"ez-title ez-title--primary ez-title--extra-large"},this.label),e("ez-breadcrumb",{items:this.breadcrumbItens,onSelectedItem:({detail:i})=>this.clickBreadcrumbItem.emit(i)}))),e("div",{class:"simple-bar__right-slot"},e("slot",{name:"rightSlot"})))}get _element(){return t(this)}};r.style=".sc-snk-simple-bar-h{display:flex;height:100%;width:100%}.simple-bar__container.sc-snk-simple-bar{flex:1;display:flex;align-items:stretch;gap:var(--space--small)}.simple-bar__left-slot.sc-snk-simple-bar{min-width:280px;flex:1;display:flex;align-items:center}.simple-bar__right-slot.sc-snk-simple-bar{flex:1;display:flex;align-items:center;justify-content:flex-end}.simple-bar__column.sc-snk-simple-bar{flex:1;display:flex;flex-direction:column}";export{r as snk_simple_bar}
@@ -1 +1 @@
1
- import{r as t,c as i,h as e,F as s,H as l,g as r}from"./p-d8d8169b.js";import{ElementIDUtils as n,ObjectUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as h}from"@sankhyalabs/ezui/dist/collection/utils";import{P as o}from"./p-988afe78.js";import{E as c}from"./p-1a68fb59.js";import{F as d}from"./p-ff1990ad.js";import"./p-84345e7a.js";const u=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0,this.showHardFixed=!0,this.removalBlocked=!1}async setFocusField(){var t,i,e,s;this._editor&&(this._editor.setFocus?null===(i=null===(t=this._editor)||void 0===t?void 0:t.setFocus)||void 0===i||i.call(t):this._editor.focus&&(null===(s=null===(e=this._editor)||void 0===e?void 0:e.focus)||void 0===s||s.call(e)))}async clearValue(){this._editor&&this._editor.clearValue&&await this._editor.clearValue()}observeConfig(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i),this._customElementObject=this.getContentEditor()}componentDidLoad(){if(this._element){n.addIDInfo(this._element);const t=this._element.getAttribute(n.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case d.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case d.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case d.PERIOD:return{tag:"snk-filter-period"};case d.SEARCH:return{tag:"snk-filter-search"};case d.NUMBER:return{tag:"snk-filter-number"};case d.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:c.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case d.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}};case d.MULTI_LIST:return{tag:"snk-entity-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===d.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return e(s,null,!this.removalBlocked&&!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),this.showHardFixed&&!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,s){return e("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},e("ez-icon",Object.assign({title:t,iconName:i},{[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${n.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const e={id:i};t.removeAttribute(n.DATA_ELEMENT_ID_ATTRIBUTE_NAME),n.addIDInfoIfNotExists(t,"button",e)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=a.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!o.validateVariableValues(this.config,this._editor.value))return h.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==d.BINARY_SELECT){if(d.MULTI_LIST===this.config.type){const i=a.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=a.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==d.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e;if(this.config){const s=a.copy(this.config),l=null===(i=s.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(e=s.value)||void 0===e||e.splice(l,1),this.config=a.copy(s)}}componentWillLoad(){this.originalConfig=a.copy(this.config),this._customElementObject=this.getContentEditor()}render(){const{tag:t,props:i}=this._customElementObject;return e(l,null,e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),e(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),e("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&e("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),e("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};export{u as snk_filter_detail}
1
+ import{r as t,c as i,h as e,F as s,H as l,g as r}from"./p-82bb3eda.js";import{ElementIDUtils as n,ObjectUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as h}from"@sankhyalabs/ezui/dist/collection/utils";import{P as o}from"./p-988afe78.js";import{E as c}from"./p-1a68fb59.js";import{F as d}from"./p-ff1990ad.js";import"./p-84345e7a.js";const u=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0,this.showHardFixed=!0,this.removalBlocked=!1}async setFocusField(){var t,i,e,s;this._editor&&(this._editor.setFocus?null===(i=null===(t=this._editor)||void 0===t?void 0:t.setFocus)||void 0===i||i.call(t):this._editor.focus&&(null===(s=null===(e=this._editor)||void 0===e?void 0:e.focus)||void 0===s||s.call(e)))}async clearValue(){this._editor&&this._editor.clearValue&&await this._editor.clearValue()}observeConfig(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i),this._customElementObject=this.getContentEditor()}componentDidLoad(){if(this._element){n.addIDInfo(this._element);const t=this._element.getAttribute(n.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case d.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case d.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case d.PERIOD:return{tag:"snk-filter-period"};case d.SEARCH:return{tag:"snk-filter-search"};case d.NUMBER:return{tag:"snk-filter-number"};case d.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:c.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case d.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}};case d.MULTI_LIST:return{tag:"snk-entity-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===d.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return e(s,null,!this.removalBlocked&&!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),this.showHardFixed&&!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,s){return e("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},e("ez-icon",Object.assign({title:t,iconName:i},{[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${n.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const e={id:i};t.removeAttribute(n.DATA_ELEMENT_ID_ATTRIBUTE_NAME),n.addIDInfoIfNotExists(t,"button",e)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=a.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!o.validateVariableValues(this.config,this._editor.value))return h.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==d.BINARY_SELECT){if(d.MULTI_LIST===this.config.type){const i=a.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=a.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==d.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e;if(this.config){const s=a.copy(this.config),l=null===(i=s.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(e=s.value)||void 0===e||e.splice(l,1),this.config=a.copy(s)}}componentWillLoad(){this.originalConfig=a.copy(this.config),this._customElementObject=this.getContentEditor()}render(){const{tag:t,props:i}=this._customElementObject;return e(l,null,e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),e(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),e("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&e("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),e("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};export{u as snk_filter_detail}
@@ -1 +1 @@
1
- import{r as t,c as e,h as i,H as s}from"./p-d8d8169b.js";import{A as r}from"./p-6a4b21dd.js";const l=class{constructor(i){t(this,i),this.actionSelected=e(this,"actionSelected",7),this.OFFSET_HEIGHT=5,this.getMessage=void 0,this.hasDefaultFilter=!1,this._opened=!1}repositionDropDown(){if(!this._refIcon||!this._refDropdown)return;const t=this._refIcon.getBoundingClientRect(),e=this._refDropdown.getBoundingClientRect();this._refDropdown.style.top=t.y+t.height+this.OFFSET_HEIGHT+"px",this._refDropdown.style.left=t.x+t.width/2-e.width+"px"}toggleDropdown(){this._opened=!this._opened}closeDropdown(t){const e=null==t?void 0:t.target;e&&(e.closest("#dropdown-parent-demo")||(this._opened=!1))}buildItems(){return[{id:r.EDIT,label:this.getMessage("defaultFilter.edit")},{id:r.REMOVE,label:this.getMessage("defaultFilter.remove")}]}onValueSelected({detail:t}){this._opened=!1,this.actionSelected.emit(t.id)}openCreateNewFilter(){this.actionSelected.emit(r.CREATE)}componentDidRender(){this.repositionDropDown()}componentWillLoad(){this._items=this.buildItems(),document.removeEventListener("scroll",this.repositionDropDown.bind(this)),document.addEventListener("scroll",this.repositionDropDown.bind(this))}render(){return this.hasDefaultFilter?i(s,null,i("button",{class:"default_container",onClick:this.toggleDropdown.bind(this)},i("span",null,this.getMessage("defaultFilter.title")),i("ez-icon",{ref:t=>this._refIcon=t,iconName:"dots-vertical"})),this._opened&&i("ez-dropdown",{ref:t=>this._refDropdown=t,items:this._items,onEzClick:this.onValueSelected.bind(this),onEzOutsideClick:this.closeDropdown.bind(this)})):i(s,null,i("button",{class:"default_container new_filter",onClick:this.openCreateNewFilter.bind(this)},i("span",null,this.getMessage("defaultFilter.create"))))}};l.style=".sc-snk-default-filter-h{display:flex;justify-content:flex-end}.default_container.sc-snk-default-filter{border:none;background:none;display:flex;align-items:center;gap:var(--space--3xs, 4px);font-family:var(--font-pattern);color:var(--title--primary, #2b3a54);font-size:var(--text--medium, 14px);padding:0;outline:none}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter{cursor:pointer}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter:hover{color:var(--color--primary-600)}.new_filter.sc-snk-default-filter{cursor:pointer;margin:0 var(--space--3xs, 4px)}.new_filter.sc-snk-default-filter:hover{color:var(--color--primary-600)}";export{l as snk_default_filter}
1
+ import{r as t,c as e,h as i,H as s}from"./p-82bb3eda.js";import{A as r}from"./p-6a4b21dd.js";const l=class{constructor(i){t(this,i),this.actionSelected=e(this,"actionSelected",7),this.OFFSET_HEIGHT=5,this.getMessage=void 0,this.hasDefaultFilter=!1,this._opened=!1}repositionDropDown(){if(!this._refIcon||!this._refDropdown)return;const t=this._refIcon.getBoundingClientRect(),e=this._refDropdown.getBoundingClientRect();this._refDropdown.style.top=t.y+t.height+this.OFFSET_HEIGHT+"px",this._refDropdown.style.left=t.x+t.width/2-e.width+"px"}toggleDropdown(){this._opened=!this._opened}closeDropdown(t){const e=null==t?void 0:t.target;e&&(e.closest("#dropdown-parent-demo")||(this._opened=!1))}buildItems(){return[{id:r.EDIT,label:this.getMessage("defaultFilter.edit")},{id:r.REMOVE,label:this.getMessage("defaultFilter.remove")}]}onValueSelected({detail:t}){this._opened=!1,this.actionSelected.emit(t.id)}openCreateNewFilter(){this.actionSelected.emit(r.CREATE)}componentDidRender(){this.repositionDropDown()}componentWillLoad(){this._items=this.buildItems(),document.removeEventListener("scroll",this.repositionDropDown.bind(this)),document.addEventListener("scroll",this.repositionDropDown.bind(this))}render(){return this.hasDefaultFilter?i(s,null,i("button",{class:"default_container",onClick:this.toggleDropdown.bind(this)},i("span",null,this.getMessage("defaultFilter.title")),i("ez-icon",{ref:t=>this._refIcon=t,iconName:"dots-vertical"})),this._opened&&i("ez-dropdown",{ref:t=>this._refDropdown=t,items:this._items,onEzClick:this.onValueSelected.bind(this),onEzOutsideClick:this.closeDropdown.bind(this)})):i(s,null,i("button",{class:"default_container new_filter",onClick:this.openCreateNewFilter.bind(this)},i("span",null,this.getMessage("defaultFilter.create"))))}};l.style=".sc-snk-default-filter-h{display:flex;justify-content:flex-end}.default_container.sc-snk-default-filter{border:none;background:none;display:flex;align-items:center;gap:var(--space--3xs, 4px);font-family:var(--font-pattern);color:var(--title--primary, #2b3a54);font-size:var(--text--medium, 14px);padding:0;outline:none}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter{cursor:pointer}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter:hover{color:var(--color--primary-600)}.new_filter.sc-snk-default-filter{cursor:pointer;margin:0 var(--space--3xs, 4px)}.new_filter.sc-snk-default-filter:hover{color:var(--color--primary-600)}";export{l as snk_default_filter}
@@ -1 +1 @@
1
- import{r as i,c as t,h as e,F as s,H as n}from"./p-d8d8169b.js";import{StringUtils as l,ObjectUtils as a,ApplicationContext as r,ElementIDUtils as o}from"@sankhyalabs/core";import{P as h}from"./p-988afe78.js";import{P as d,C as c}from"./p-1f310bc6.js";import{ApplicationUtils as f}from"@sankhyalabs/ezui/dist/collection/utils";import{a as p,D as z}from"./p-84345e7a.js";import{s as u}from"./p-55798617.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const m=class{constructor(e){i(this,e),this.ezCancel=t(this,"ezCancel",7),this.ezSave=t(this,"ezSave",7),this.ezAfterSave=t(this,"ezAfterSave",7),this._personalizedFilterFetcher=new d,this._filterMetadataStorage=new Map,this._dataSourceFetcher={fetchData:async i=>{let t=null==i?void 0:i.uri;if(l.isEmpty(t)&&(t=this.entityUri),!this._filterMetadataStorage.has(t)){const i=await this._personalizedFilterFetcher.loadFields(t);this._filterMetadataStorage.set(t,i)}return this._filterMetadataStorage.get(t)}},this._filterAssistentMode=!0,this._filterAssistent=void 0,this.messagesBuilder=void 0,this.entityUri=void 0,this.filterId=void 0,this.configName=void 0,this.resourceID=void 0,this.isDefaultFilter=!1}async createPersonalizedFilter(){const i={name:"",active:!0,expression:"",parameters:[],assistent:{id:l.generateUUID(),items:[{id:l.generateUUID(),entityName:"",fieldName:"",description:"",fieldLabel:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:p.AND}};this.isDefaultFilter&&this.buildDataDefaultFilter(i),this._originalFilterAssistent=a.copy(i),this._filterAssistent=a.copy(i)}loadFilter(i,t){null!=i&&t!=i&&null!=this.resourceID&&(i!==z.id?c.loadPersonalizedFilter(i,this.resourceID,this.configName).then((i=>{const t=this.applyDefaultValues(i);this._filterAssistent=t,this._originalFilterAssistent=a.copy(t),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})):c.loadDefaultFilter(i,this.resourceID,this.configName).then((i=>{const t=this.applyDefaultValues(i);this._filterAssistent=t,this._originalFilterAssistent=a.copy(t),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})))}componentWillLoad(){var i;null==u.get(`filterFieldsDataSource.${this.entityUri}`)&&u.set(`filterFieldsDataSource.${this.entityUri}`,this._dataSourceFetcher),this.messagesBuilder||(this._application=r.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder=null===(i=this._application)||void 0===i?void 0:i.messagesBuilder),this.loadFilter(this.filterId,void 0)}componentDidRender(){var i;null===(i=this._viewStackRef)||void 0===i||i.show(this._filterAssistentMode?0:1),this._elButtonMode&&this._elButtonMode.setAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME,o.getInternalIDInfo(this._filterAssistentMode?"advancedMode_ezButton":"assistentMode_ezButton"))}buildDataDefaultFilter(i){i.name=z.name,i.id=z.id}getMessage(i,t){return this._application.messagesBuilder.getMessage(i,t)}async saveFilter(){let i;i=this.isDefaultFilter?await c.saveDefaultFilter(this._filterAssistent,this.resourceID,this.configName):await c.savePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName),this._elButtonSave.enabled=!1,f.info(this.getMessage(`snkPersonalizedFilter.${this._filterAssistent.id?"confirmEdit":"confirmSave"}.title`),{iconName:"check"});const t=Object.assign(Object.assign({},i),this._filterAssistent);t.parameters=h.buildVariableParameters(this._filterAssistent.assistent),this._originalFilterAssistent=a.copy(t),this._filterAssistent=a.copy(t),this.ezAfterSave.emit()}removeFilter(){c.removePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName)}hasChangesToSave(){return JSON.stringify(this._filterAssistent)===JSON.stringify(this._originalFilterAssistent)}async handleSave(){if(this._filterAssistentMode){if(!h.validateFields(this._filterAssistent.assistent)||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));this.saveAssistentMode()}else{if(!this._filterAssistent.expression||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));if(!await this.validateExpressionBeforeSaving())return;this.saveAdvancedMode()}}saveAssistentMode(){const{assistent:i,expression:t}=this._filterAssistent,e=i?h.buildGroupExpression(i):t;this._filterAssistent.expression=e,this.ezSave.emit(e),this.saveFilter()}saveAdvancedMode(){this._originalFilterAssistent.expression!==this._filterAssistent.expression&&this._filterAssistent.assistent?f.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description")).then((i=>{i&&this.saveAndTransformToAdvancedMode()})):this._filterAssistent.assistent?this.saveAssistentMode():this.saveAndTransformToAdvancedMode()}saveAndTransformToAdvancedMode(){this._filterAssistent.assistent=void 0,this.ezSave.emit(this._filterAssistent.expression),this.saveFilter()}async validateExpressionBeforeSaving(){const{valid:i,message:t=""}=await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri,this._filterAssistent.expression);return i||this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"),t.replace(/.*Exception: /,"")),i}handleCancel(){if(this.hasChangesToSave())return this.ezCancel.emit();f.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"),this.getMessage("snkPersonalizedFilter.confirmCancel.description")).then((i=>{var t;i&&(this._filterAssistent=a.copy(null!==(t=this._originalFilterAssistent)&&void 0!==t?t:{}),this.ezCancel.emit(),this._elButtonSave.enabled=!1)}))}handleTitleChange(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{name:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}applyDefaultValues(i){return this.addLabelToItems(i),this.addFilterGroupCondition(i),i}addFilterGroupCondition(i){i.assistent&&!i.assistent.operand&&(i.assistent.operand=p.AND)}addLabelToItems(i){i.assistent&&i.assistent.items&&i.assistent.items.length>0&&i.assistent.items.forEach((t=>{if(null==t.fieldLabel){const e=(i.parameters||[]).find((i=>i.fieldName===t.fieldName));e&&(t.fieldLabel=e.label)}}))}handleExpressionChangeAdvancedMode(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}handleChangeFilterAssistentMode(i){this._elButtonSave.enabled=!this.hasChangesToSave(),this._filterAssistent=Object.assign({},i)}selectField(i){if(!("name"in i))return;const t=this.buildExpression(i.entityName,i.name,i.entityPath);this._elAdvancedMode.querySelector("ez-text-area").appendTextToSelection(t)}buildExpression(i,t,e){return e.length>0&&e.shift(),e.length>0?`${e.join("->")}->${t}`:`${i}.${t}`}onAddField(i){this._elAdvancedMode.querySelector("ez-text-area").setFocus(),i.setBlur(),this._elFilterFieldSearch&&this._elFilterFieldSearch.show(i,{horizontalGap:0,verticalGap:12,fromRight:!0})}renderButtonAddField(){if(!this._filterAssistentMode)return e(s,null,e("ez-button",{class:"snk-personalized-filter__button-mode",label:this.getMessage("snkPersonalizedFilter.info.addField"),enabled:!0,onClick:i=>this.onAddField(i.target)},e("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),e("snk-filter-field-search",{class:"ez-padding-left--medium",ref:i=>this._elFilterFieldSearch=i,onEzSelectFilterItem:i=>this.selectField(i.detail),fieldsDataSource:this._dataSourceFetcher}))}buildContainerPersonalizedFilter(){return e("ez-view-stack",{ref:i=>this._viewStackRef=i},e("stack-item",null,this._filterAssistentMode&&e("snk-filter-assistent-mode",{filterAssistent:this._filterAssistent,messagesBuilder:this.messagesBuilder,filterId:this.filterId,entityUri:this.entityUri,application:this._application,onEzChangeFilter:i=>this.handleChangeFilterAssistentMode(i.detail),isDefaultFilter:this.isDefaultFilter})),e("stack-item",null,e("snk-filter-advanced-mode",{ref:i=>this._elAdvancedMode=i,filterAssistent:this._filterAssistent,application:this._application,onEzExpressionChange:i=>this.handleExpressionChangeAdvancedMode(i.detail)})))}handleModeChange(){var i,t;if(this._filterAssistentMode)f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description")).then((i=>{if(i&&(this._filterAssistentMode=!this._filterAssistentMode,!this.hasChangesToSave())){const i=h.buildGroupExpression(this._filterAssistent.assistent);this._filterAssistent.expression=i,this._elButtonSave.enabled=!this.hasChangesToSave()}}));else if((null===(i=this._filterAssistent)||void 0===i?void 0:i.expression)===(null===(t=this._originalFilterAssistent)||void 0===t?void 0:t.expression))this._filterAssistentMode=!this._filterAssistentMode;else{const i=this._filterAssistent.expression,t=h.buildGroupExpression(this._filterAssistent.assistent);i!==t?f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description")).then((i=>{i&&(this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:t}),this._filterAssistentMode=!this._filterAssistentMode)})):this._filterAssistentMode=!this._filterAssistentMode}}buildTitle(){return this.getMessage(this.isDefaultFilter&&!this.filterId?"snkPersonalizedFilter.info.titleCreateDefault":this.isDefaultFilter&&this.filterId?"snkPersonalizedFilter.info.titleEditDefault":this.filterId?"snkPersonalizedFilter.info.titleEdit":"snkPersonalizedFilter.info.titleAdd")}render(){var i,t,s,l;if((null===(i=this._filterAssistent)||void 0===i?void 0:i.assistent)||!this._filterAssistentMode)return e(n,null,e("div",{class:"snk-personalized-filter"},e("div",null,e("snk-simple-bar",{label:this.buildTitle(),onExit:()=>this.handleCancel()},e("div",{class:"snk-personalized-filter__header-actions",slot:"rightSlot"},e("ez-button",{size:"small",label:this.getMessage("snkPersonalizedFilter.info.labelCancel"),onClick:()=>this.handleCancel()}),e("ez-button",{size:"small",ref:i=>this._elButtonSave=i,enabled:!1,class:"ez-button--primary",label:this.getMessage("snkPersonalizedFilter.info.labelSave"),onClick:this.handleSave.bind(this)})))),e("div",{class:"ez-box ez-margin-bottom--medium ez-box__main"},e("div",{class:"ez-box__container"},e("div",{class:"ez-flex ez-flex--column ez-size-width--full"},e("div",{class:"ez-flex"},e("ez-tooltip",{message:this.getMessage("snkPersonalizedFilter.info.textInputDisabled"),active:this.isDefaultFilter},e("ez-text-input",{class:"ez-padding-right--medium",label:this.getMessage("snkPersonalizedFilter.info.labelNameFilter"),value:null===(t=this._filterAssistent)||void 0===t?void 0:t.name,onEzChange:i=>this.handleTitleChange(i.detail),enabled:!this.isDefaultFilter})),this.renderButtonAddField(),e("ez-button",{ref:i=>this._elButtonMode=i,class:"snk-personalized-filter__button-mode",label:this.getMessage(this._filterAssistentMode?"snkPersonalizedFilter.info.activeModeAdvanced":"snkPersonalizedFilter.info.activeModeAssistent"),onClick:()=>this.handleModeChange(),"data-tooltip":this._filterAssistentMode||(null===(s=this._filterAssistent)||void 0===s?void 0:s.assistent)?void 0:this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode"),"data-flow":"bottom",enabled:!this._filterAssistent.name||Boolean(this._filterAssistentMode||(null===(l=this._filterAssistent)||void 0===l?void 0:l.assistent))})),this.buildContainerPersonalizedFilter())))))}static get watchers(){return{filterId:["loadFilter"]}}};m.style=".sc-snk-personalized-filter-h{display:flex;height:100%;padding:var(--space--large, 24px);--snk-personalized-filter--width:100%;--snk-personalized-filter--height:100%;--snk-personalized-filter--background-color-line:var(--color--disable-secondary);--snk-personalized-filter--margin-line:var(--border--radius-medium, 12px)}.snk-personalized-filter.sc-snk-personalized-filter{height:var(--snk-personalized-filter--width);width:var(--snk-personalized-filter--height)}.snk-personalized-filter__header-actions.sc-snk-personalized-filter{display:flex;gap:var(--space--medium)}.snk-personalized-filter__group.sc-snk-personalized-filter{flex:1}.snk-personalized-filter__expression-input--line.sc-snk-personalized-filter{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}.ez-box__main.sc-snk-personalized-filter{height:90%}.snk-personalized-filter__button-mode.sc-snk-personalized-filter{height:35px}";export{m as snk_personalized_filter}
1
+ import{r as i,c as t,h as e,F as s,H as n}from"./p-82bb3eda.js";import{StringUtils as l,ObjectUtils as a,ApplicationContext as r,ElementIDUtils as o}from"@sankhyalabs/core";import{P as h}from"./p-988afe78.js";import{P as d,C as c}from"./p-1f310bc6.js";import{ApplicationUtils as f}from"@sankhyalabs/ezui/dist/collection/utils";import{a as p,D as z}from"./p-84345e7a.js";import{s as u}from"./p-8336900b.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const m=class{constructor(e){i(this,e),this.ezCancel=t(this,"ezCancel",7),this.ezSave=t(this,"ezSave",7),this.ezAfterSave=t(this,"ezAfterSave",7),this._personalizedFilterFetcher=new d,this._filterMetadataStorage=new Map,this._dataSourceFetcher={fetchData:async i=>{let t=null==i?void 0:i.uri;if(l.isEmpty(t)&&(t=this.entityUri),!this._filterMetadataStorage.has(t)){const i=await this._personalizedFilterFetcher.loadFields(t);this._filterMetadataStorage.set(t,i)}return this._filterMetadataStorage.get(t)}},this._filterAssistentMode=!0,this._filterAssistent=void 0,this.messagesBuilder=void 0,this.entityUri=void 0,this.filterId=void 0,this.configName=void 0,this.resourceID=void 0,this.isDefaultFilter=!1}async createPersonalizedFilter(){const i={name:"",active:!0,expression:"",parameters:[],assistent:{id:l.generateUUID(),items:[{id:l.generateUUID(),entityName:"",fieldName:"",description:"",fieldLabel:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:p.AND}};this.isDefaultFilter&&this.buildDataDefaultFilter(i),this._originalFilterAssistent=a.copy(i),this._filterAssistent=a.copy(i)}loadFilter(i,t){null!=i&&t!=i&&null!=this.resourceID&&(i!==z.id?c.loadPersonalizedFilter(i,this.resourceID,this.configName).then((i=>{const t=this.applyDefaultValues(i);this._filterAssistent=t,this._originalFilterAssistent=a.copy(t),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})):c.loadDefaultFilter(i,this.resourceID,this.configName).then((i=>{const t=this.applyDefaultValues(i);this._filterAssistent=t,this._originalFilterAssistent=a.copy(t),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})))}componentWillLoad(){var i;null==u.get(`filterFieldsDataSource.${this.entityUri}`)&&u.set(`filterFieldsDataSource.${this.entityUri}`,this._dataSourceFetcher),this.messagesBuilder||(this._application=r.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder=null===(i=this._application)||void 0===i?void 0:i.messagesBuilder),this.loadFilter(this.filterId,void 0)}componentDidRender(){var i;null===(i=this._viewStackRef)||void 0===i||i.show(this._filterAssistentMode?0:1),this._elButtonMode&&this._elButtonMode.setAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME,o.getInternalIDInfo(this._filterAssistentMode?"advancedMode_ezButton":"assistentMode_ezButton"))}buildDataDefaultFilter(i){i.name=z.name,i.id=z.id}getMessage(i,t){return this._application.messagesBuilder.getMessage(i,t)}async saveFilter(){let i;i=this.isDefaultFilter?await c.saveDefaultFilter(this._filterAssistent,this.resourceID,this.configName):await c.savePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName),this._elButtonSave.enabled=!1,f.info(this.getMessage(`snkPersonalizedFilter.${this._filterAssistent.id?"confirmEdit":"confirmSave"}.title`),{iconName:"check"});const t=Object.assign(Object.assign({},i),this._filterAssistent);t.parameters=h.buildVariableParameters(this._filterAssistent.assistent),this._originalFilterAssistent=a.copy(t),this._filterAssistent=a.copy(t),this.ezAfterSave.emit()}removeFilter(){c.removePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName)}hasChangesToSave(){return JSON.stringify(this._filterAssistent)===JSON.stringify(this._originalFilterAssistent)}async handleSave(){if(this._filterAssistentMode){if(!h.validateFields(this._filterAssistent.assistent)||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));this.saveAssistentMode()}else{if(!this._filterAssistent.expression||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));if(!await this.validateExpressionBeforeSaving())return;this.saveAdvancedMode()}}saveAssistentMode(){const{assistent:i,expression:t}=this._filterAssistent,e=i?h.buildGroupExpression(i):t;this._filterAssistent.expression=e,this.ezSave.emit(e),this.saveFilter()}saveAdvancedMode(){this._originalFilterAssistent.expression!==this._filterAssistent.expression&&this._filterAssistent.assistent?f.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description")).then((i=>{i&&this.saveAndTransformToAdvancedMode()})):this._filterAssistent.assistent?this.saveAssistentMode():this.saveAndTransformToAdvancedMode()}saveAndTransformToAdvancedMode(){this._filterAssistent.assistent=void 0,this.ezSave.emit(this._filterAssistent.expression),this.saveFilter()}async validateExpressionBeforeSaving(){const{valid:i,message:t=""}=await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri,this._filterAssistent.expression);return i||this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"),t.replace(/.*Exception: /,"")),i}handleCancel(){if(this.hasChangesToSave())return this.ezCancel.emit();f.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"),this.getMessage("snkPersonalizedFilter.confirmCancel.description")).then((i=>{var t;i&&(this._filterAssistent=a.copy(null!==(t=this._originalFilterAssistent)&&void 0!==t?t:{}),this.ezCancel.emit(),this._elButtonSave.enabled=!1)}))}handleTitleChange(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{name:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}applyDefaultValues(i){return this.addLabelToItems(i),this.addFilterGroupCondition(i),i}addFilterGroupCondition(i){i.assistent&&!i.assistent.operand&&(i.assistent.operand=p.AND)}addLabelToItems(i){i.assistent&&i.assistent.items&&i.assistent.items.length>0&&i.assistent.items.forEach((t=>{if(null==t.fieldLabel){const e=(i.parameters||[]).find((i=>i.fieldName===t.fieldName));e&&(t.fieldLabel=e.label)}}))}handleExpressionChangeAdvancedMode(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}handleChangeFilterAssistentMode(i){this._elButtonSave.enabled=!this.hasChangesToSave(),this._filterAssistent=Object.assign({},i)}selectField(i){if(!("name"in i))return;const t=this.buildExpression(i.entityName,i.name,i.entityPath);this._elAdvancedMode.querySelector("ez-text-area").appendTextToSelection(t)}buildExpression(i,t,e){return e.length>0&&e.shift(),e.length>0?`${e.join("->")}->${t}`:`${i}.${t}`}onAddField(i){this._elAdvancedMode.querySelector("ez-text-area").setFocus(),i.setBlur(),this._elFilterFieldSearch&&this._elFilterFieldSearch.show(i,{horizontalGap:0,verticalGap:12,fromRight:!0})}renderButtonAddField(){if(!this._filterAssistentMode)return e(s,null,e("ez-button",{class:"snk-personalized-filter__button-mode",label:this.getMessage("snkPersonalizedFilter.info.addField"),enabled:!0,onClick:i=>this.onAddField(i.target)},e("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),e("snk-filter-field-search",{class:"ez-padding-left--medium",ref:i=>this._elFilterFieldSearch=i,onEzSelectFilterItem:i=>this.selectField(i.detail),fieldsDataSource:this._dataSourceFetcher}))}buildContainerPersonalizedFilter(){return e("ez-view-stack",{ref:i=>this._viewStackRef=i},e("stack-item",null,this._filterAssistentMode&&e("snk-filter-assistent-mode",{filterAssistent:this._filterAssistent,messagesBuilder:this.messagesBuilder,filterId:this.filterId,entityUri:this.entityUri,application:this._application,onEzChangeFilter:i=>this.handleChangeFilterAssistentMode(i.detail),isDefaultFilter:this.isDefaultFilter})),e("stack-item",null,e("snk-filter-advanced-mode",{ref:i=>this._elAdvancedMode=i,filterAssistent:this._filterAssistent,application:this._application,onEzExpressionChange:i=>this.handleExpressionChangeAdvancedMode(i.detail)})))}handleModeChange(){var i,t;if(this._filterAssistentMode)f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description")).then((i=>{if(i&&(this._filterAssistentMode=!this._filterAssistentMode,!this.hasChangesToSave())){const i=h.buildGroupExpression(this._filterAssistent.assistent);this._filterAssistent.expression=i,this._elButtonSave.enabled=!this.hasChangesToSave()}}));else if((null===(i=this._filterAssistent)||void 0===i?void 0:i.expression)===(null===(t=this._originalFilterAssistent)||void 0===t?void 0:t.expression))this._filterAssistentMode=!this._filterAssistentMode;else{const i=this._filterAssistent.expression,t=h.buildGroupExpression(this._filterAssistent.assistent);i!==t?f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description")).then((i=>{i&&(this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:t}),this._filterAssistentMode=!this._filterAssistentMode)})):this._filterAssistentMode=!this._filterAssistentMode}}buildTitle(){return this.getMessage(this.isDefaultFilter&&!this.filterId?"snkPersonalizedFilter.info.titleCreateDefault":this.isDefaultFilter&&this.filterId?"snkPersonalizedFilter.info.titleEditDefault":this.filterId?"snkPersonalizedFilter.info.titleEdit":"snkPersonalizedFilter.info.titleAdd")}render(){var i,t,s,l;if((null===(i=this._filterAssistent)||void 0===i?void 0:i.assistent)||!this._filterAssistentMode)return e(n,null,e("div",{class:"snk-personalized-filter"},e("div",null,e("snk-simple-bar",{label:this.buildTitle(),onExit:()=>this.handleCancel()},e("div",{class:"snk-personalized-filter__header-actions",slot:"rightSlot"},e("ez-button",{size:"small",label:this.getMessage("snkPersonalizedFilter.info.labelCancel"),onClick:()=>this.handleCancel()}),e("ez-button",{size:"small",ref:i=>this._elButtonSave=i,enabled:!1,class:"ez-button--primary",label:this.getMessage("snkPersonalizedFilter.info.labelSave"),onClick:this.handleSave.bind(this)})))),e("div",{class:"ez-box ez-margin-bottom--medium ez-box__main"},e("div",{class:"ez-box__container"},e("div",{class:"ez-flex ez-flex--column ez-size-width--full"},e("div",{class:"ez-flex"},e("ez-tooltip",{message:this.getMessage("snkPersonalizedFilter.info.textInputDisabled"),active:this.isDefaultFilter},e("ez-text-input",{class:"ez-padding-right--medium",label:this.getMessage("snkPersonalizedFilter.info.labelNameFilter"),value:null===(t=this._filterAssistent)||void 0===t?void 0:t.name,onEzChange:i=>this.handleTitleChange(i.detail),enabled:!this.isDefaultFilter})),this.renderButtonAddField(),e("ez-button",{ref:i=>this._elButtonMode=i,class:"snk-personalized-filter__button-mode",label:this.getMessage(this._filterAssistentMode?"snkPersonalizedFilter.info.activeModeAdvanced":"snkPersonalizedFilter.info.activeModeAssistent"),onClick:()=>this.handleModeChange(),"data-tooltip":this._filterAssistentMode||(null===(s=this._filterAssistent)||void 0===s?void 0:s.assistent)?void 0:this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode"),"data-flow":"bottom",enabled:!this._filterAssistent.name||Boolean(this._filterAssistentMode||(null===(l=this._filterAssistent)||void 0===l?void 0:l.assistent))})),this.buildContainerPersonalizedFilter())))))}static get watchers(){return{filterId:["loadFilter"]}}};m.style=".sc-snk-personalized-filter-h{display:flex;height:100%;padding:var(--space--large, 24px);--snk-personalized-filter--width:100%;--snk-personalized-filter--height:100%;--snk-personalized-filter--background-color-line:var(--color--disable-secondary);--snk-personalized-filter--margin-line:var(--border--radius-medium, 12px)}.snk-personalized-filter.sc-snk-personalized-filter{height:var(--snk-personalized-filter--width);width:var(--snk-personalized-filter--height)}.snk-personalized-filter__header-actions.sc-snk-personalized-filter{display:flex;gap:var(--space--medium)}.snk-personalized-filter__group.sc-snk-personalized-filter{flex:1}.snk-personalized-filter__expression-input--line.sc-snk-personalized-filter{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}.ez-box__main.sc-snk-personalized-filter{height:90%}.snk-personalized-filter__button-mode.sc-snk-personalized-filter{height:35px}";export{m as snk_personalized_filter}
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,H as e}from"./p-d8d8169b.js";import{ApplicationContext as o,ElementIDUtils as r}from"@sankhyalabs/core";import{DataBinder as h}from"@sankhyalabs/ezui/dist/collection/utils/form";import{focusOnFieldSerch as a,SEARCH_FIELD_FULL_WIDTH as n,FormLayout as l}from"@sankhyalabs/ezui/dist/collection/utils";const d=class{constructor(s){t(this,s),this.snkContentCardChanged=i(this,"snkContentCardChanged",7),this.snkRequestClearFieldToFocus=i(this,"snkRequestClearFieldToFocus",7),this.formItemsReady=i(this,"formItemsReady",7),this._customEditors=new Map,this._fieldProps=new Map,this._singleColumn=!1,this.levelPath=void 0,this.fieldSearch=void 0,this.label=void 0,this.name=void 0,this.fields=void 0,this.formMetadata=void 0,this.dataUnit=void 0,this.contracted=void 0,this.fixed=!1,this.summaryFields=void 0,this.canExpand=!0,this.canFix=!0,this.recordsValidator=void 0,this.fieldToFocus=void 0,this.customEditors=void 0,this.fieldsProps=void 0}async showUp(){this._formView&&this._formView.showUp()}async addCustomEditor(t,i,s){if(this._formView)return void this._formView.addCustomEditor(t,i,s);const e=new Map(this._customEditors);e.set(t,{customEditor:i,detailContext:s}),this._customEditors=e}async setFieldProp(t,i,s){const e=this._fieldProps.get(t)||[];this._fieldProps.set(t,[...e,{propName:i,value:s}])}async showSearchField(){if(!this._headerContainer||!this._ezPopoverFieldColumn)return;const t=this._headerContainer.getBoundingClientRect();await a(this.fieldSearch),this._ezPopoverFieldColumn.showUnder(this._headerContainer,{horizontalGap:t.width-n,verticalGap:-1*t.height})}observePropsCustomEditor(t){for(const i in t)this.addCustomEditor(i,t[i])}async observeFieldsProps(t){for(const i in t){const s=t[i],e=Object.keys(s);for(const t of e)await this.setFieldProp(i,t,s[t])}}changeFix(){this.fixed=!this.fixed,this.emitEvent("fixed")}changeContracted(){this.contracted=!this.contracted,this.emitEvent("presentation")}emitEvent(t){this.snkContentCardChanged.emit({formName:this.name,cardConfig:{fixed:this.fixed,presentation:this.contracted?"CONTRACTED":"EXPANDED"},propertyChanged:t})}getCardSummary(){const t={};return this.getSummaryFields().forEach((({field:i,label:s})=>{var e;const o=this.dataUnit.getFormattedValue(i);""!==o&&(null==s&&(s=null===(e=this.dataUnit.getField(i))||void 0===e?void 0:e.label),t[s]=o)})),t}getSummaryFields(){return null==this.summaryFields?this.fields.map((t=>{const i=this.dataUnit.getField(t.name);return{field:t.name,label:t.label||(null==i?void 0:i.label)}})):this.summaryFields}bindFields(t){null==this._dataBinder&&null!=this.dataUnit&&(this._dataBinder=new h(this.dataUnit)),this._dataBinder&&this._dataBinder.bind(t,this.dataUnit.dataUnitId,this.formMetadata,this.recordsValidator)}handleFormItemsReady(t){t.stopPropagation(),this.formItemsReady.emit(Object.assign(Object.assign({},t.detail),{formId:this.name}))}disconnectedCallback(){null!=this._dataBinder&&this._dataBinder.onDisconnectedCallback()}componentDidLoad(){this.observePropsCustomEditor(this.customEditors),this.observeFieldsProps(this.fieldsProps),this.initLayoutFormConfig()}async initLayoutFormConfig(){const t=o.getContextValue("__SNK__APPLICATION__"),i=await(null==t?void 0:t.getLayoutFormConfig());i&&(this.setSingleColumn(i),this.registerNotifyListeners(i))}setSingleColumn(t){this._singleColumn=(null==t?void 0:t.config)===l.CASCADE}registerNotifyListeners(t){t&&t.onConfigChange((t=>{this._singleColumn=t===l.CASCADE}))}componentDidRender(){this.setCustomEditors(),this.setFieldProps(),null!=this.fieldToFocus&&this.fields.some((t=>t.name===this.fieldToFocus))&&requestAnimationFrame((()=>{this._dataBinder.setFocus(this.fieldToFocus),this.snkRequestClearFieldToFocus.emit()}))}setCustomEditors(){if(this._formView)for(const[t,i]of this._customEditors)this._formView.addCustomEditor(t,i.customEditor,i.detailContext),this._customEditors.delete(t)}setFieldProps(){if(this._formView)for(const[t,i]of this._fieldProps)i.forEach((i=>{this._formView.setFieldProp(t,i.propName,i.value),this._fieldProps.delete(t)}))}render(){return s(e,{class:"ez-box__container"},s("div",{class:"summary-header ez-flex ez-size-width--full",ref:t=>this._headerContainer=t},s("div",{class:"ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9"},this.levelPath?s("span",{class:"level-path"},this.levelPath+" /"):void 0,this.label),s("div",{class:"ez-flex ez-flex--justify-end ez-col--sd-3"},this.canFix&&s("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.fixed?"un-pin":"push-pin","data-element-id":r.getInternalIDInfo("toggleFixed_ezFormCard"),onClick:()=>this.changeFix(),title:this.fixed?"Desafixar":"Fixar"}),this.canExpand&&s("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.contracted?"chevron-down":"chevron-up","data-element-id":r.getInternalIDInfo("toggleExpand_ezFormCard"),onClick:()=>this.changeContracted(),title:this.contracted?"Expandir":"Resumir"}))),s("slot",null),this.contracted?s("snk-form-summary",{summary:this.getCardSummary()}):s("ez-form-view",{ref:t=>this._formView=t,fields:this.fields,onEzContentReady:t=>this.bindFields(t.detail),onFormItemsReady:t=>this.handleFormItemsReady(t),singleColumn:this._singleColumn}),this.fieldSearch&&s("ez-popover",{ref:t=>this._ezPopoverFieldColumn=t,overlayType:"none"},this.fieldSearch))}static get watchers(){return{customEditors:["observePropsCustomEditor"],fieldsProps:["observeFieldsProps"]}}};d.style=".sc-snk-form-view-h{display:flex;width:100%;--ez-form-card-summary-field-content-weight:700}.level-path.sc-snk-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-form-view{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";export{d as snk_form_view}
1
+ import{r as t,c as i,h as s,H as e}from"./p-82bb3eda.js";import{ApplicationContext as o,ElementIDUtils as r}from"@sankhyalabs/core";import{DataBinder as h}from"@sankhyalabs/ezui/dist/collection/utils/form";import{focusOnFieldSerch as a,SEARCH_FIELD_FULL_WIDTH as n,FormLayout as l}from"@sankhyalabs/ezui/dist/collection/utils";const d=class{constructor(s){t(this,s),this.snkContentCardChanged=i(this,"snkContentCardChanged",7),this.snkRequestClearFieldToFocus=i(this,"snkRequestClearFieldToFocus",7),this.formItemsReady=i(this,"formItemsReady",7),this._customEditors=new Map,this._fieldProps=new Map,this._singleColumn=!1,this.levelPath=void 0,this.fieldSearch=void 0,this.label=void 0,this.name=void 0,this.fields=void 0,this.formMetadata=void 0,this.dataUnit=void 0,this.contracted=void 0,this.fixed=!1,this.summaryFields=void 0,this.canExpand=!0,this.canFix=!0,this.recordsValidator=void 0,this.fieldToFocus=void 0,this.customEditors=void 0,this.fieldsProps=void 0}async showUp(){this._formView&&this._formView.showUp()}async addCustomEditor(t,i,s){if(this._formView)return void this._formView.addCustomEditor(t,i,s);const e=new Map(this._customEditors);e.set(t,{customEditor:i,detailContext:s}),this._customEditors=e}async setFieldProp(t,i,s){const e=this._fieldProps.get(t)||[];this._fieldProps.set(t,[...e,{propName:i,value:s}])}async showSearchField(){if(!this._headerContainer||!this._ezPopoverFieldColumn)return;const t=this._headerContainer.getBoundingClientRect();await a(this.fieldSearch),this._ezPopoverFieldColumn.showUnder(this._headerContainer,{horizontalGap:t.width-n,verticalGap:-1*t.height})}observePropsCustomEditor(t){for(const i in t)this.addCustomEditor(i,t[i])}async observeFieldsProps(t){for(const i in t){const s=t[i],e=Object.keys(s);for(const t of e)await this.setFieldProp(i,t,s[t])}}changeFix(){this.fixed=!this.fixed,this.emitEvent("fixed")}changeContracted(){this.contracted=!this.contracted,this.emitEvent("presentation")}emitEvent(t){this.snkContentCardChanged.emit({formName:this.name,cardConfig:{fixed:this.fixed,presentation:this.contracted?"CONTRACTED":"EXPANDED"},propertyChanged:t})}getCardSummary(){const t={};return this.getSummaryFields().forEach((({field:i,label:s})=>{var e;const o=this.dataUnit.getFormattedValue(i);""!==o&&(null==s&&(s=null===(e=this.dataUnit.getField(i))||void 0===e?void 0:e.label),t[s]=o)})),t}getSummaryFields(){return null==this.summaryFields?this.fields.map((t=>{const i=this.dataUnit.getField(t.name);return{field:t.name,label:t.label||(null==i?void 0:i.label)}})):this.summaryFields}bindFields(t){null==this._dataBinder&&null!=this.dataUnit&&(this._dataBinder=new h(this.dataUnit)),this._dataBinder&&this._dataBinder.bind(t,this.dataUnit.dataUnitId,this.formMetadata,this.recordsValidator)}handleFormItemsReady(t){t.stopPropagation(),this.formItemsReady.emit(Object.assign(Object.assign({},t.detail),{formId:this.name}))}disconnectedCallback(){null!=this._dataBinder&&this._dataBinder.onDisconnectedCallback()}componentDidLoad(){this.observePropsCustomEditor(this.customEditors),this.observeFieldsProps(this.fieldsProps),this.initLayoutFormConfig()}async initLayoutFormConfig(){const t=o.getContextValue("__SNK__APPLICATION__"),i=await(null==t?void 0:t.getLayoutFormConfig());i&&(this.setSingleColumn(i),this.registerNotifyListeners(i))}setSingleColumn(t){this._singleColumn=(null==t?void 0:t.config)===l.CASCADE}registerNotifyListeners(t){t&&t.onConfigChange((t=>{this._singleColumn=t===l.CASCADE}))}componentDidRender(){this.setCustomEditors(),this.setFieldProps(),null!=this.fieldToFocus&&this.fields.some((t=>t.name===this.fieldToFocus))&&requestAnimationFrame((()=>{this._dataBinder.setFocus(this.fieldToFocus),this.snkRequestClearFieldToFocus.emit()}))}setCustomEditors(){if(this._formView)for(const[t,i]of this._customEditors)this._formView.addCustomEditor(t,i.customEditor,i.detailContext),this._customEditors.delete(t)}setFieldProps(){if(this._formView)for(const[t,i]of this._fieldProps)i.forEach((i=>{this._formView.setFieldProp(t,i.propName,i.value),this._fieldProps.delete(t)}))}render(){return s(e,{class:"ez-box__container"},s("div",{class:"summary-header ez-flex ez-size-width--full",ref:t=>this._headerContainer=t},s("div",{class:"ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9"},this.levelPath?s("span",{class:"level-path"},this.levelPath+" /"):void 0,this.label),s("div",{class:"ez-flex ez-flex--justify-end ez-col--sd-3"},this.canFix&&s("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.fixed?"un-pin":"push-pin","data-element-id":r.getInternalIDInfo("toggleFixed_ezFormCard"),onClick:()=>this.changeFix(),title:this.fixed?"Desafixar":"Fixar"}),this.canExpand&&s("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.contracted?"chevron-down":"chevron-up","data-element-id":r.getInternalIDInfo("toggleExpand_ezFormCard"),onClick:()=>this.changeContracted(),title:this.contracted?"Expandir":"Resumir"}))),s("slot",null),this.contracted?s("snk-form-summary",{summary:this.getCardSummary()}):s("ez-form-view",{ref:t=>this._formView=t,fields:this.fields,onEzContentReady:t=>this.bindFields(t.detail),onFormItemsReady:t=>this.handleFormItemsReady(t),singleColumn:this._singleColumn}),this.fieldSearch&&s("ez-popover",{ref:t=>this._ezPopoverFieldColumn=t,overlayType:"none"},this.fieldSearch))}static get watchers(){return{customEditors:["observePropsCustomEditor"],fieldsProps:["observeFieldsProps"]}}};d.style=".sc-snk-form-view-h{display:flex;width:100%;--ez-form-card-summary-field-content-weight:700}.level-path.sc-snk-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-form-view{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";export{d as snk_form_view}
@@ -1 +1 @@
1
- import{r as i,c as t,h as s,H as n}from"./p-d8d8169b.js";import{ApplicationUtils as e}from"@sankhyalabs/ezui/dist/collection/utils";const o=class{constructor(s){i(this,s),this.configClose=t(this,"configClose",7),this.saveConfig=t(this,"saveConfig",7),this.isEditingGuide=!1,this.isEditingGroup=!1,this.configOptions=[],this.selectedConfig=void 0,this.messagesBuilder=void 0,this.hasChanges=!1,this.optionConfigChanged=!1}handleIsEditingGuideName({detail:i}){this.isEditingGuide=i}handleIsEditingGroupName({detail:i}){this.isEditingGroup=i}saveFormConfig(){if(this.isEditingGuide||this.isEditingGroup){const i=this.getMessage("snkFormConfig.confirm.title"),t=this.getMessage(this.isEditingGuide?"snkFormConfig.alert.titleGuideEditing":"snkFormConfig.alert.titleGroupEditing");e.alert(i,t)}else this.saveConfig.emit()}async closeFormConfig(){if(this.hasChanges){const i=this.getMessage("snkFormConfig.confirm.title"),t=this.getMessage("snkFormConfig.confirm.cancel");if(!await e.confirm(i,t))return}this.configClose.emit()}getMessage(i,t){return this.messagesBuilder.getMessage(i,t)}openConfirmDialog(i="",t=this.getMessage("snkFormConfig.confirm.title")){return e.confirm(t,i)}async applyOptionConfig(){var i,t;const s=null!==(t=null===(i=this.selectedConfig)||void 0===i?void 0:i.name)&&void 0!==t?t:this.getMessage("snkFormConfig.configs.selectedConfig"),n=this.getMessage("snkFormConfig.confirm.apply").replace("{0}",s);await this.openConfirmDialog(n)&&this.saveConfig.emit()}renderSaveActions(){if(this.hasChanges||this.optionConfigChanged)return s("div",{class:"right-group"},s("ez-button",{title:this.getMessage("snkFormConfig.actions.cancel"),label:this.getMessage("snkFormConfig.actions.cancel"),onClick:this.closeFormConfig.bind(this),size:"medium"}),s("ez-button",this.hasChanges?{title:this.getMessage("snkFormConfig.actions.save"),label:this.getMessage("snkFormConfig.actions.save"),class:"ez-button--primary ez-padding-left--medium",onClick:()=>this.saveFormConfig(),size:"medium"}:{title:this.getMessage("snkFormConfig.actions.save"),label:this.getMessage("snkFormConfig.applyConfig"),class:"ez-button--primary ez-padding-left--medium",onClick:async()=>await this.applyOptionConfig(),size:"medium"}))}render(){return s(n,null,s("div",{class:"left-group"},s("ez-button",{mode:"icon",title:this.getMessage("snkFormConfig.goBackTitle"),iconName:"arrow_back",class:"ez-padding--small",size:"small",onClick:this.closeFormConfig.bind(this),id:"formConfigToBack"}),s("h1",{class:"ez-title ez-title--primary ez-title--extra-large ez-padding--small"},this.getMessage("snkFormConfig.title")),s("configs-button",{hasChanges:this.hasChanges,configOptions:this.configOptions,selectedConfig:this.selectedConfig,messagesBuilder:this.messagesBuilder})),this.renderSaveActions())}};o.style=".sc-config-header-h{display:flex;padding-top:12px;padding-left:12px;align-items:center;width:100%;justify-content:space-between}.left-group.sc-config-header{display:flex;gap:8px}.right-group.sc-config-header{padding-right:18px;display:flex}";export{o as config_header}
1
+ import{r as i,c as t,h as s,H as n}from"./p-82bb3eda.js";import{ApplicationUtils as e}from"@sankhyalabs/ezui/dist/collection/utils";const o=class{constructor(s){i(this,s),this.configClose=t(this,"configClose",7),this.saveConfig=t(this,"saveConfig",7),this.isEditingGuide=!1,this.isEditingGroup=!1,this.configOptions=[],this.selectedConfig=void 0,this.messagesBuilder=void 0,this.hasChanges=!1,this.optionConfigChanged=!1}handleIsEditingGuideName({detail:i}){this.isEditingGuide=i}handleIsEditingGroupName({detail:i}){this.isEditingGroup=i}saveFormConfig(){if(this.isEditingGuide||this.isEditingGroup){const i=this.getMessage("snkFormConfig.confirm.title"),t=this.getMessage(this.isEditingGuide?"snkFormConfig.alert.titleGuideEditing":"snkFormConfig.alert.titleGroupEditing");e.alert(i,t)}else this.saveConfig.emit()}async closeFormConfig(){if(this.hasChanges){const i=this.getMessage("snkFormConfig.confirm.title"),t=this.getMessage("snkFormConfig.confirm.cancel");if(!await e.confirm(i,t))return}this.configClose.emit()}getMessage(i,t){return this.messagesBuilder.getMessage(i,t)}openConfirmDialog(i="",t=this.getMessage("snkFormConfig.confirm.title")){return e.confirm(t,i)}async applyOptionConfig(){var i,t;const s=null!==(t=null===(i=this.selectedConfig)||void 0===i?void 0:i.name)&&void 0!==t?t:this.getMessage("snkFormConfig.configs.selectedConfig"),n=this.getMessage("snkFormConfig.confirm.apply").replace("{0}",s);await this.openConfirmDialog(n)&&this.saveConfig.emit()}renderSaveActions(){if(this.hasChanges||this.optionConfigChanged)return s("div",{class:"right-group"},s("ez-button",{title:this.getMessage("snkFormConfig.actions.cancel"),label:this.getMessage("snkFormConfig.actions.cancel"),onClick:this.closeFormConfig.bind(this),size:"medium"}),s("ez-button",this.hasChanges?{title:this.getMessage("snkFormConfig.actions.save"),label:this.getMessage("snkFormConfig.actions.save"),class:"ez-button--primary ez-padding-left--medium",onClick:()=>this.saveFormConfig(),size:"medium"}:{title:this.getMessage("snkFormConfig.actions.save"),label:this.getMessage("snkFormConfig.applyConfig"),class:"ez-button--primary ez-padding-left--medium",onClick:async()=>await this.applyOptionConfig(),size:"medium"}))}render(){return s(n,null,s("div",{class:"left-group"},s("ez-button",{mode:"icon",title:this.getMessage("snkFormConfig.goBackTitle"),iconName:"arrow_back",class:"ez-padding--small",size:"small",onClick:this.closeFormConfig.bind(this),id:"formConfigToBack"}),s("h1",{class:"ez-title ez-title--primary ez-title--extra-large ez-padding--small"},this.getMessage("snkFormConfig.title")),s("configs-button",{hasChanges:this.hasChanges,configOptions:this.configOptions,selectedConfig:this.selectedConfig,messagesBuilder:this.messagesBuilder})),this.renderSaveActions())}};o.style=".sc-config-header-h{display:flex;padding-top:12px;padding-left:12px;align-items:center;width:100%;justify-content:space-between}.left-group.sc-config-header{display:flex;gap:8px}.right-group.sc-config-header{padding-right:18px;display:flex}";export{o as config_header}
@@ -0,0 +1,2 @@
1
+ let e,t,n,l=!1,o=!1,s=!1,c=null,i=!1;const r="http://www.w3.org/1999/xlink",f={},u=e=>"object"==(e=typeof e)||"function"===e,a=(e,t,...n)=>{let l=null,o=null,s=null,c=!1,i=!1;const r=[],f=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?f(l):null!=l&&"boolean"!=typeof l&&((c="function"!=typeof e&&!u(l))&&(l+=""),c&&i?r[r.length-1].t+=l:r.push(c?d(null,l):l),i=c)};if(f(n),t){t.key&&(o=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,r,$);const a=d(e,null);return a.l=t,r.length>0&&(a.o=r),a.i=o,a.u=s,a},d=(e,t)=>({p:0,$:e,t,m:null,o:null,l:null,i:null,u:null}),p={},$={forEach:(e,t)=>e.map(m).forEach(t),map:(e,t)=>e.map(m).map(t).map(h)},m=e=>({vattrs:e.l,vchildren:e.o,vkey:e.i,vname:e.u,vtag:e.$,vtext:e.t}),h=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),a(e.vtag,t,...e.vchildren||[])}const t=d(e.vtag,e.vtext);return t.l=e.vattrs,t.o=e.vchildren,t.i=e.vkey,t.u=e.vname,t},y=e=>ie(e).h,b=(e,t,n)=>{const l=y(e);return{emit:e=>w(l,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},w=(e,t,n)=>{const l=ye.ce(t,n);return e.dispatchEvent(l),l},v=new WeakMap,k=e=>"sc-"+e.v,g=(e,t,n,l,o,s)=>{if(n!==l){let c=ue(e,t),i=t.toLowerCase();if("class"===t){const t=e.classList,o=j(n),s=j(l);t.remove(...o.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!o.includes(e))))}else if("style"===t){for(const t in n)l&&null!=l[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in l)n&&l[t]===n[t]||(t.includes("-")?e.style.setProperty(t,l[t]):e.style[t]=l[t])}else if("key"===t);else if("ref"===t)l&&l(e);else if(c||"o"!==t[0]||"n"!==t[1]){const f=u(l);if((c||f&&null!==l)&&!o)try{if(e.tagName.includes("-"))e[t]=l;else{const o=null==l?"":l;"list"===t?c=!1:null!=n&&e[t]==o||(e[t]=o)}}catch(e){}let a=!1;i!==(i=i.replace(/^xlink\:?/,""))&&(t=i,a=!0),null==l||!1===l?!1===l&&""!==e.getAttribute(t)||(a?e.removeAttributeNS(r,t):e.removeAttribute(t)):(!c||4&s||o)&&!f&&(l=!0===l?"":l,a?e.setAttributeNS(r,t,l):e.setAttribute(t,l))}else t="-"===t[2]?t.slice(3):ue(me,i)?i.slice(2):i[2]+t.slice(3),n&&ye.rel(e,t,n,!1),l&&ye.ael(e,t,l,!1)}},S=/\s/,j=e=>e?e.split(S):[],C=(e,t,n,l)=>{const o=11===t.m.nodeType&&t.m.host?t.m.host:t.m,s=e&&e.l||f,c=t.l||f;for(l in s)l in c||g(o,l,s[l],void 0,n,t.p);for(l in c)g(o,l,s[l],c[l],n,t.p)},M=(o,c,i,r)=>{const f=c.o[i];let u,a,d,p=0;if(l||(s=!0,"slot"===f.$&&(e&&r.classList.add(e+"-s"),f.p|=f.o?2:1)),null!==f.t)u=f.m=he.createTextNode(f.t);else if(1&f.p)u=f.m=he.createTextNode("");else if(u=f.m=he.createElement(2&f.p?"slot-fb":f.$),C(null,f,!1),null!=e&&u["s-si"]!==e&&u.classList.add(u["s-si"]=e),f.o)for(p=0;p<f.o.length;++p)a=M(o,f,p,u),a&&u.appendChild(a);return u["s-hn"]=n,3&f.p&&(u["s-sr"]=!0,u["s-cr"]=t,u["s-sn"]=f.u||"",d=o&&o.o&&o.o[i],d&&d.$===f.$&&o.m&&O(o.m,!1)),u},O=(e,t)=>{ye.p|=1;const l=e.childNodes;for(let e=l.length-1;e>=0;e--){const o=l[e];o["s-hn"]!==n&&o["s-ol"]&&(W(o).insertBefore(o,T(o)),o["s-ol"].remove(),o["s-ol"]=void 0,s=!0),t&&O(o,t)}ye.p&=-2},R=(e,t,l,o,s,c)=>{let i,r=e["s-cr"]&&e["s-cr"].parentNode||e;for(r.shadowRoot&&r.tagName===n&&(r=r.shadowRoot);s<=c;++s)o[s]&&(i=M(null,l,s,e),i&&(o[s].m=i,r.insertBefore(i,T(t))))},x=(e,t,n,l,s)=>{for(;t<=n;++t)(l=e[t])&&(s=l.m,F(l),o=!0,s["s-ol"]?s["s-ol"].remove():O(s,!0),s.remove())},P=(e,t)=>e.$===t.$&&("slot"===e.$?e.u===t.u:e.i===t.i),T=e=>e&&e["s-ol"]||e,W=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,E=(e,t)=>{const n=t.m=e.m,l=e.o,o=t.o,s=t.t;let c;null===s?("slot"===t.$||C(e,t,!1),null!==l&&null!==o?((e,t,n,l)=>{let o,s,c=0,i=0,r=0,f=0,u=t.length-1,a=t[0],d=t[u],p=l.length-1,$=l[0],m=l[p];for(;c<=u&&i<=p;)if(null==a)a=t[++c];else if(null==d)d=t[--u];else if(null==$)$=l[++i];else if(null==m)m=l[--p];else if(P(a,$))E(a,$),a=t[++c],$=l[++i];else if(P(d,m))E(d,m),d=t[--u],m=l[--p];else if(P(a,m))"slot"!==a.$&&"slot"!==m.$||O(a.m.parentNode,!1),E(a,m),e.insertBefore(a.m,d.m.nextSibling),a=t[++c],m=l[--p];else if(P(d,$))"slot"!==a.$&&"slot"!==m.$||O(d.m.parentNode,!1),E(d,$),e.insertBefore(d.m,a.m),d=t[--u],$=l[++i];else{for(r=-1,f=c;f<=u;++f)if(t[f]&&null!==t[f].i&&t[f].i===$.i){r=f;break}r>=0?(s=t[r],s.$!==$.$?o=M(t&&t[i],n,r,e):(E(s,$),t[r]=void 0,o=s.m),$=l[++i]):(o=M(t&&t[i],n,i,e),$=l[++i]),o&&W(a.m).insertBefore(o,T(a.m))}c>u?R(e,null==l[p+1]?null:l[p+1].m,n,l,i,p):i>p&&x(t,c,u)})(n,l,t,o):null!==o?(null!==e.t&&(n.textContent=""),R(n,null,t,o,0,o.length-1)):null!==l&&x(l,0,l.length-1)):(c=n["s-cr"])?c.parentNode.textContent=s:e.t!==s&&(n.data=s)},L=e=>{const t=e.childNodes;let n,l,o,s,c,i;for(l=0,o=t.length;l<o;l++)if(n=t[l],1===n.nodeType){if(n["s-sr"])for(c=n["s-sn"],n.hidden=!1,s=0;s<o;s++)if(i=t[s].nodeType,t[s]["s-hn"]!==n["s-hn"]||""!==c){if(1===i&&c===t[s].getAttribute("slot")){n.hidden=!0;break}}else if(1===i||3===i&&""!==t[s].textContent.trim()){n.hidden=!0;break}L(n)}},N=[],U=e=>{let t,n,l,s,c,i,r=0;const f=e.childNodes,u=f.length;for(;r<u;r++){if(t=f[r],t["s-sr"]&&(n=t["s-cr"])&&n.parentNode)for(l=n.parentNode.childNodes,s=t["s-sn"],i=l.length-1;i>=0;i--)n=l[i],n["s-cn"]||n["s-nr"]||n["s-hn"]===t["s-hn"]||(D(n,s)?(c=N.find((e=>e.k===n)),o=!0,n["s-sn"]=n["s-sn"]||s,c?c.g=t:N.push({g:t,k:n}),n["s-sr"]&&N.map((e=>{D(e.k,n["s-sn"])&&(c=N.find((e=>e.k===n)),c&&!e.g&&(e.g=c.g))}))):N.some((e=>e.k===n))||N.push({k:n}));1===t.nodeType&&U(t)}},D=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,F=e=>{e.l&&e.l.ref&&e.l.ref(null),e.o&&e.o.map(F)},A=(e,t)=>{t&&!e.S&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.S=t)))},H=(e,t)=>{if(e.p|=16,!(4&e.p))return A(e,e.j),Me((()=>q(e,t)));e.p|=512},q=(e,t)=>{const n=e.C;let l;return t?(e.p|=256,e.M&&(e.M.map((([e,t])=>J(n,e,t))),e.M=null),l=J(n,"componentWillLoad")):l=J(n,"componentWillUpdate"),l=K(l,(()=>J(n,"componentWillRender"))),K(l,(()=>V(e,n,t)))},V=async(e,t,n)=>{const l=e.h,o=l["s-rc"];n&&(e=>{const t=e.O,n=e.h,l=t.p,o=((e,t)=>{var n;let l=k(t);const o=$e.get(l);if(e=11===e.nodeType?e:he,o)if("string"==typeof o){let t,s=v.get(e=e.head||e);if(s||v.set(e,s=new Set),!s.has(l)){{t=he.createElement("style"),t.innerHTML=o;const l=null!==(n=ye.R)&&void 0!==n?n:function(e){var t,n,l;return null!==(l=null===(n=null===(t=e.head)||void 0===t?void 0:t.querySelector('meta[name="csp-nonce"]'))||void 0===n?void 0:n.getAttribute("content"))&&void 0!==l?l:void 0}(he);null!=l&&t.setAttribute("nonce",l),e.insertBefore(t,e.querySelector("link"))}s&&s.add(l)}}else e.adoptedStyleSheets.includes(o)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,o]);return l})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"),2&l&&n.classList.add(o+"-s"))})(e);_(e,t),o&&(o.map((e=>e())),l["s-rc"]=void 0);{const t=l["s-p"],n=()=>B(e);0===t.length?n():(Promise.all(t).then(n),e.p|=4,t.length=0)}},_=(i,r)=>{try{c=r,r=r.render(),i.p&=-17,i.p|=2,((c,i)=>{const r=c.h,f=c.O,u=c.P||d(null,null),$=(e=>e&&e.$===p)(i)?i:a(null,null,i);if(n=r.tagName,f.T&&($.l=$.l||{},f.T.map((([e,t])=>$.l[t]=r[e]))),$.$=null,$.p|=4,c.P=$,$.m=u.m=r.shadowRoot||r,e=r["s-sc"],t=r["s-cr"],l=0!=(1&f.p),o=!1,E(u,$),ye.p|=1,s){let e,t,n,l,o,s;U($.m);let c=0;for(;c<N.length;c++)e=N[c],t=e.k,t["s-ol"]||(n=he.createTextNode(""),n["s-nr"]=t,t.parentNode.insertBefore(t["s-ol"]=n,t));for(c=0;c<N.length;c++)if(e=N[c],t=e.k,e.g){for(l=e.g.parentNode,o=e.g.nextSibling,n=t["s-ol"];n=n.previousSibling;)if(s=n["s-nr"],s&&s["s-sn"]===t["s-sn"]&&l===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&l!==t.parentNode||t.nextSibling!==o)&&t!==o&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),l.insertBefore(t,o))}else 1===t.nodeType&&(t.hidden=!0)}o&&L($.m),ye.p&=-2,N.length=0})(i,r)}catch(e){ae(e,i.h)}return c=null,null},z=()=>c,B=e=>{const t=e.h,n=e.C,l=e.j;J(n,"componentDidRender"),64&e.p?J(n,"componentDidUpdate"):(e.p|=64,Q(t),J(n,"componentDidLoad"),e.W(t),l||I()),e.L(t),e.S&&(e.S(),e.S=void 0),512&e.p&&Ce((()=>H(e,!1))),e.p&=-517},G=e=>{{const t=ie(e),n=t.h.isConnected;return n&&2==(18&t.p)&&H(t,!1),n}},I=()=>{Q(he.documentElement),Ce((()=>w(me,"appload",{detail:{namespace:"sankhyablocks"}})))},J=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){ae(e)}},K=(e,t)=>e&&e.then?e.then(t):t(),Q=e=>e.classList.add("hydrated"),X=(e,t,n)=>{if(t.N){e.watchers&&(t.U=e.watchers);const l=Object.entries(t.N),o=e.prototype;if(l.map((([e,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(o,e,{get(){return((e,t)=>ie(this).D.get(t))(0,e)},set(n){((e,t,n,l)=>{const o=ie(e),s=o.h,c=o.D.get(t),i=o.p,r=o.C;if(n=((e,t)=>null==e||u(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(n,l.N[t][0]),(!(8&i)||void 0===c)&&n!==c&&(!Number.isNaN(c)||!Number.isNaN(n))&&(o.D.set(t,n),r)){if(l.U&&128&i){const e=l.U[t];e&&e.map((e=>{try{r[e](n,c,t)}catch(e){ae(e,s)}}))}if(2==(18&i)){if(r.componentShouldUpdate&&!1===r.componentShouldUpdate(n,c,t))return;H(o,!1)}}})(this,e,n,t)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(o,e,{value(...t){const n=ie(this);return n.F.then((()=>n.C[e](...t)))}})})),1&n){const n=new Map;o.attributeChangedCallback=function(e,t,l){ye.jmp((()=>{const t=n.get(e);if(this.hasOwnProperty(t))l=this[t],delete this[t];else if(o.hasOwnProperty(t)&&"number"==typeof this[t]&&this[t]==l)return;this[t]=(null!==l||"boolean"!=typeof this[t])&&l}))},e.observedAttributes=l.filter((([e,t])=>15&t[0])).map((([e,l])=>{const o=l[1]||e;return n.set(o,e),512&l[0]&&t.T.push([e,o]),o}))}}return e},Y=e=>{J(e,"connectedCallback")},Z=(e,t={})=>{const n=t.exclude||[],l=me.customElements,o=[];let s,c=!0;Object.assign(ye,t),ye.A=new URL(t.resourcesUrl||"./",he.baseURI).href,e.map((e=>{e[1].map((t=>{const i={p:t[0],v:t[1],N:t[2],H:t[3]};i.N=t[2],i.H=t[3],i.T=[],i.U={};const r=i.v,f=class extends HTMLElement{constructor(e){super(e),fe(e=this,i),1&i.p&&e.attachShadow({mode:"open"})}connectedCallback(){s&&(clearTimeout(s),s=null),c?o.push(this):ye.jmp((()=>(e=>{if(0==(1&ye.p)){const t=ie(e),n=t.O,l=()=>{};if(1&t.p)te(e,t,n.H),Y(t.C);else{t.p|=1,12&n.p&&(e=>{const t=e["s-cr"]=he.createComment("");t["s-cn"]=!0,e.insertBefore(t,e.firstChild)})(e);{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){A(t,t.j=n);break}}n.N&&Object.entries(n.N).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,l,o)=>{if(0==(32&t.p)){{if(t.p|=32,(o=pe(n)).then){const e=()=>{};o=await o,e()}o.isProxied||(n.U=o.watchers,X(o,n,2),o.isProxied=!0);const e=()=>{};t.p|=8;try{new o(t)}catch(e){ae(e)}t.p&=-9,t.p|=128,e(),Y(t.C)}if(o.style){let e=o.style;const t=k(n);if(!$e.has(t)){const l=()=>{};((e,t,n)=>{let l=$e.get(e);we&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=t:l.replaceSync(t)):l=t,$e.set(e,l)})(t,e,!!(1&n.p)),l()}}}const s=t.j,c=()=>H(t,!0);s&&s["s-rc"]?s["s-rc"].push(c):c()})(0,t,n)}l()}})(this)))}disconnectedCallback(){ye.jmp((()=>(()=>{if(0==(1&ye.p)){const e=ie(this),t=e.C;e.q&&(e.q.map((e=>e())),e.q=void 0),J(t,"disconnectedCallback")}})()))}componentOnReady(){return ie(this).V}};i._=e[0],n.includes(r)||l.get(r)||l.define(r,X(f,i,1))}))})),c=!1,o.length?o.map((e=>e.connectedCallback())):ye.jmp((()=>s=setTimeout(I,30)))},ee=(e,t)=>t,te=(e,t,n)=>{n&&n.map((([n,l,o])=>{const s=le(e,n),c=ne(t,o),i=oe(n);ye.ael(s,l,c,i),(t.q=t.q||[]).push((()=>ye.rel(s,l,c,i)))}))},ne=(e,t)=>n=>{try{256&e.p?e.C[t](n):(e.M=e.M||[]).push([t,n])}catch(e){ae(e)}},le=(e,t)=>8&t?me:16&t?he.body:e,oe=e=>0!=(2&e),se=e=>ye.R=e,ce=new WeakMap,ie=e=>ce.get(e),re=(e,t)=>ce.set(t.C=e,t),fe=(e,t)=>{const n={p:0,h:e,O:t,D:new Map};return n.F=new Promise((e=>n.L=e)),n.V=new Promise((e=>n.W=e)),e["s-p"]=[],e["s-rc"]=[],te(e,n,t.H),ce.set(e,n)},ue=(e,t)=>t in e,ae=(e,t)=>(0,console.error)(e,t),de=new Map,pe=e=>{const t=e.v.replace(/-/g,"_"),n=e._,l=de.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(de.set(n,e),e[t])),ae)
2
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/},$e=new Map,me="undefined"!=typeof window?window:{},he=me.document||{head:{}},ye={p:0,A:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},be=e=>Promise.resolve(e),we=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),ve=[],ke=[],ge=(e,t)=>n=>{e.push(n),i||(i=!0,t&&4&ye.p?Ce(je):ye.raf(je))},Se=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){ae(e)}e.length=0},je=()=>{Se(ve),Se(ke),(i=ve.length>0)&&ye.raf(je)},Ce=e=>be().then(e),Me=ge(ke,!0);export{ee as F,p as H,z as a,Z as b,b as c,G as f,y as g,a as h,be as p,re as r,se as s}
@@ -1 +1 @@
1
- import{a as e,f as t}from"./p-d8d8169b.js";const s=e=>!("isConnected"in e)||e.isConnected,o=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys())e.set(t,e.get(t).filter(s))})(...t)}),2e3)}})(),r=e=>"function"==typeof e?e():e,n=(e,t)=>{const s=e.indexOf(t);s>=0&&(e[s]=e[e.length-1],e.length--)},c=(()=>{const s=((e,t=((e,t)=>e!==t))=>{const s=r(e);let o=new Map(Object.entries(s??{}));const c={dispose:[],get:[],set:[],reset:[]},a=new Map,i=()=>{o=new Map(Object.entries(r(e)??{})),c.reset.forEach((e=>e()))},p=e=>(c.get.forEach((t=>t(e))),o.get(e)),d=(e,s)=>{const r=o.get(e);t(s,r,e)&&(o.set(e,s),c.set.forEach((t=>t(e,s,r))))},u="undefined"==typeof Proxy?{}:new Proxy(s,{get:(e,t)=>p(t),ownKeys:()=>Array.from(o.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>o.has(t),set:(e,t,s)=>(d(t,s),!0)}),f=(e,t)=>(c[e].push(t),()=>{n(c[e],t)});return{state:u,get:p,set:d,on:f,onChange:(t,s)=>{const o=(e,o)=>{e===t&&s(o)},n=()=>s(r(e)[t]),c=f("set",o),i=f("reset",n);return a.set(s,{setHandler:o,resetHandler:n,propName:t}),()=>{c(),i(),a.delete(s)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(f("set",t.set)),t.get&&e.push(f("get",t.get)),t.reset&&e.push(f("reset",t.reset)),t.dispose&&e.push(f("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{c.dispose.forEach((e=>e())),i()},reset:i,forceUpdate:e=>{const t=o.get(e);c.set.forEach((s=>s(e,t,t)))},removeListener:(e,t)=>{const s=a.get(t);s&&s.propName===e&&(n(c.set,s.setHandler),n(c.reset,s.resetHandler),a.delete(t))}}})({exporterProviders:{},filterFieldsDataSource:void 0},void 0);return s.use((()=>{if("function"!=typeof e)return{};const s=new Map;return{dispose:()=>s.clear(),get:t=>{const o=e();o&&((e,t,s)=>{const o=e.get(t);o?o.includes(s)||o.push(s):e.set(t,[s])})(s,t,o)},set:e=>{const r=s.get(e);r&&s.set(e,r.filter(t)),o(s)},reset:()=>{s.forEach((e=>e.forEach(t))),o(s)}}})()),s})();export{c as s}
1
+ import{a as e,f as t}from"./p-82bb3eda.js";const s=e=>!("isConnected"in e)||e.isConnected,o=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys())e.set(t,e.get(t).filter(s))})(...t)}),2e3)}})(),r=e=>"function"==typeof e?e():e,n=(e,t)=>{const s=e.indexOf(t);s>=0&&(e[s]=e[e.length-1],e.length--)},c=(()=>{const s=((e,t=((e,t)=>e!==t))=>{const s=r(e);let o=new Map(Object.entries(s??{}));const c={dispose:[],get:[],set:[],reset:[]},a=new Map,i=()=>{o=new Map(Object.entries(r(e)??{})),c.reset.forEach((e=>e()))},p=e=>(c.get.forEach((t=>t(e))),o.get(e)),u=(e,s)=>{const r=o.get(e);t(s,r,e)&&(o.set(e,s),c.set.forEach((t=>t(e,s,r))))},d="undefined"==typeof Proxy?{}:new Proxy(s,{get:(e,t)=>p(t),ownKeys:()=>Array.from(o.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>o.has(t),set:(e,t,s)=>(u(t,s),!0)}),f=(e,t)=>(c[e].push(t),()=>{n(c[e],t)});return{state:d,get:p,set:u,on:f,onChange:(t,s)=>{const o=(e,o)=>{e===t&&s(o)},n=()=>s(r(e)[t]),c=f("set",o),i=f("reset",n);return a.set(s,{setHandler:o,resetHandler:n,propName:t}),()=>{c(),i(),a.delete(s)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(f("set",t.set)),t.get&&e.push(f("get",t.get)),t.reset&&e.push(f("reset",t.reset)),t.dispose&&e.push(f("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{c.dispose.forEach((e=>e())),i()},reset:i,forceUpdate:e=>{const t=o.get(e);c.set.forEach((s=>s(e,t,t)))},removeListener:(e,t)=>{const s=a.get(t);s&&s.propName===e&&(n(c.set,s.setHandler),n(c.reset,s.resetHandler),a.delete(t))}}})({exporterProviders:{},filterFieldsDataSource:void 0},void 0);return s.use((()=>{if("function"!=typeof e)return{};const s=new Map;return{dispose:()=>s.clear(),get:t=>{const o=e();o&&((e,t,s)=>{const o=e.get(t);o?o.includes(s)||o.push(s):e.set(t,[s])})(s,t,o)},set:e=>{const r=s.get(e);r&&s.set(e,r.filter(t)),o(s)},reset:()=>{s.forEach((e=>e.forEach(t))),o(s)}}})()),s})();export{c as s}