@sankhyalabs/ezui 7.1.0-dev.20 → 7.1.0-dev.21

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 (162) hide show
  1. package/dist/cjs/{ApplicationUtils-d04f5c94.js → ApplicationUtils-4fb87a9e.js} +1 -1
  2. package/dist/cjs/{app-globals-c128c97e.js → app-globals-cb31a206.js} +1 -1
  3. package/dist/cjs/ez-actions-button.cjs.entry.js +2 -2
  4. package/dist/cjs/ez-alert-list.cjs.entry.js +1 -1
  5. package/dist/cjs/ez-avatar.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-calendar.cjs.entry.js +1 -1
  7. package/dist/cjs/ez-collapsible-box.cjs.entry.js +2 -2
  8. package/dist/cjs/{ez-combo-box-list_4.cjs.entry.js → ez-combo-box-list_5.cjs.entry.js} +149 -2
  9. package/dist/cjs/ez-combo-box.cjs.entry.js +2 -2
  10. package/dist/cjs/ez-date-input.cjs.entry.js +1 -1
  11. package/dist/cjs/ez-date-time-input.cjs.entry.js +1 -1
  12. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-double-list.cjs.entry.js +1 -1
  14. package/dist/cjs/ez-file-item.cjs.entry.js +1 -1
  15. package/dist/cjs/ez-form-view.cjs.entry.js +12 -5
  16. package/dist/cjs/ez-form.cjs.entry.js +5 -4
  17. package/dist/cjs/ez-grid.cjs.entry.js +6 -3
  18. package/dist/cjs/ez-guide-navigator.cjs.entry.js +1 -1
  19. package/dist/cjs/ez-link-builder_6.cjs.entry.js +1 -1
  20. package/dist/cjs/ez-list.cjs.entry.js +1 -1
  21. package/dist/cjs/ez-modal-container.cjs.entry.js +1 -1
  22. package/dist/cjs/ez-modal.cjs.entry.js +1 -1
  23. package/dist/cjs/ez-multi-selection-list.cjs.entry.js +1 -1
  24. package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
  25. package/dist/cjs/ez-pagination.cjs.entry.js +1 -1
  26. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  27. package/dist/cjs/ez-search-plus.cjs.entry.js +2 -2
  28. package/dist/cjs/ez-search-result-list.cjs.entry.js +1 -1
  29. package/dist/cjs/ez-search.cjs.entry.js +2 -2
  30. package/dist/cjs/ez-sidebar-navigator.cjs.entry.js +1 -1
  31. package/dist/cjs/ez-skeleton.cjs.entry.js +1 -1
  32. package/dist/cjs/ez-sortable-list.cjs.entry.js +1 -1
  33. package/dist/cjs/ez-spinner.cjs.entry.js +1 -1
  34. package/dist/cjs/ez-split-button.cjs.entry.js +1 -1
  35. package/dist/cjs/ez-split-item.cjs.entry.js +2 -2
  36. package/dist/cjs/ez-time-input.cjs.entry.js +1 -1
  37. package/dist/cjs/ez-tree.cjs.entry.js +1 -1
  38. package/dist/cjs/ez-upload.cjs.entry.js +2 -2
  39. package/dist/cjs/ezui.cjs.js +3 -3
  40. package/dist/cjs/filter-column.cjs.entry.js +1 -1
  41. package/dist/cjs/index-a7b0c73d.js +2 -2
  42. package/dist/cjs/{index-00d0166b.js → index-e61642ff.js} +24 -0
  43. package/dist/cjs/loader.cjs.js +3 -3
  44. package/dist/cjs/{search-column-8bfee733.js → search-column-51e50b59.js} +2 -2
  45. package/dist/collection/collection-manifest.json +1 -0
  46. package/dist/collection/components/ez-form/ez-form.js +23 -1
  47. package/dist/collection/components/ez-form-view/ez-form-view.js +24 -2
  48. package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +4 -2
  49. package/dist/collection/components/ez-form-view/fieldbuilder/templates/ImageInput.tpl.js +4 -0
  50. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +3 -0
  51. package/dist/collection/components/ez-image-input/ez-image-input.css +173 -0
  52. package/dist/collection/components/ez-image-input/ez-image-input.js +324 -0
  53. package/dist/collection/utils/i18n/locales/en-us.js +8 -0
  54. package/dist/collection/utils/i18n/locales/es-es.js +8 -0
  55. package/dist/collection/utils/i18n/locales/pt-br.js +8 -0
  56. package/dist/custom-elements/index.d.ts +6 -0
  57. package/dist/custom-elements/index.js +193 -8
  58. package/dist/esm/{ApplicationUtils-12768f5a.js → ApplicationUtils-985c24ae.js} +1 -1
  59. package/dist/esm/{app-globals-9507c20e.js → app-globals-75f8a758.js} +1 -1
  60. package/dist/esm/ez-actions-button.entry.js +2 -2
  61. package/dist/esm/ez-alert-list.entry.js +1 -1
  62. package/dist/esm/ez-avatar.entry.js +1 -1
  63. package/dist/esm/ez-calendar.entry.js +1 -1
  64. package/dist/esm/ez-collapsible-box.entry.js +2 -2
  65. package/dist/esm/{ez-combo-box-list_4.entry.js → ez-combo-box-list_5.entry.js} +149 -3
  66. package/dist/esm/ez-combo-box.entry.js +2 -2
  67. package/dist/esm/ez-date-input.entry.js +1 -1
  68. package/dist/esm/ez-date-time-input.entry.js +1 -1
  69. package/dist/esm/ez-dialog.entry.js +1 -1
  70. package/dist/esm/ez-double-list.entry.js +1 -1
  71. package/dist/esm/ez-file-item.entry.js +1 -1
  72. package/dist/esm/ez-form-view.entry.js +12 -5
  73. package/dist/esm/ez-form.entry.js +5 -4
  74. package/dist/esm/ez-grid.entry.js +6 -3
  75. package/dist/esm/ez-guide-navigator.entry.js +1 -1
  76. package/dist/esm/ez-link-builder_6.entry.js +1 -1
  77. package/dist/esm/ez-list.entry.js +1 -1
  78. package/dist/esm/ez-modal-container.entry.js +1 -1
  79. package/dist/esm/ez-modal.entry.js +1 -1
  80. package/dist/esm/ez-multi-selection-list.entry.js +1 -1
  81. package/dist/esm/ez-number-input.entry.js +1 -1
  82. package/dist/esm/ez-pagination.entry.js +1 -1
  83. package/dist/esm/ez-popup.entry.js +1 -1
  84. package/dist/esm/ez-search-plus.entry.js +2 -2
  85. package/dist/esm/ez-search-result-list.entry.js +1 -1
  86. package/dist/esm/ez-search.entry.js +2 -2
  87. package/dist/esm/ez-sidebar-navigator.entry.js +1 -1
  88. package/dist/esm/ez-skeleton.entry.js +1 -1
  89. package/dist/esm/ez-sortable-list.entry.js +1 -1
  90. package/dist/esm/ez-spinner.entry.js +1 -1
  91. package/dist/esm/ez-split-button.entry.js +1 -1
  92. package/dist/esm/ez-split-item.entry.js +2 -2
  93. package/dist/esm/ez-time-input.entry.js +1 -1
  94. package/dist/esm/ez-tree.entry.js +1 -1
  95. package/dist/esm/ez-upload.entry.js +2 -2
  96. package/dist/esm/ezui.js +3 -3
  97. package/dist/esm/filter-column.entry.js +1 -1
  98. package/dist/esm/{index-62fc771e.js → index-a3b24b5d.js} +24 -0
  99. package/dist/esm/index-baa5e267.js +2 -2
  100. package/dist/esm/loader.js +3 -3
  101. package/dist/esm/{search-column-c00119ae.js → search-column-0c42248b.js} +2 -2
  102. package/dist/ezui/ezui.esm.js +1 -1
  103. package/dist/ezui/{p-e882635e.entry.js → p-0aafbc30.entry.js} +1 -1
  104. package/dist/ezui/{p-0c0eb410.entry.js → p-0e325699.entry.js} +1 -1
  105. package/dist/ezui/{p-5a11cf56.js → p-0ec5c128.js} +1 -1
  106. package/dist/ezui/{p-ff4bde07.entry.js → p-1bf40959.entry.js} +1 -1
  107. package/dist/ezui/{p-7b999377.entry.js → p-1c3f43e8.entry.js} +1 -1
  108. package/dist/ezui/{p-1cde96f9.entry.js → p-2676e2a3.entry.js} +1 -1
  109. package/dist/ezui/{p-e27d7dc2.entry.js → p-28af6826.entry.js} +1 -1
  110. package/dist/ezui/{p-1adf7139.entry.js → p-2b23906a.entry.js} +1 -1
  111. package/dist/ezui/{p-1730ee24.entry.js → p-2e5de2a7.entry.js} +1 -1
  112. package/dist/ezui/{p-5ab08b60.entry.js → p-2fd16ff2.entry.js} +1 -1
  113. package/dist/ezui/{p-377768bd.entry.js → p-3d71e8e1.entry.js} +2 -2
  114. package/dist/ezui/{p-6f119d5f.entry.js → p-3fcf79c7.entry.js} +1 -1
  115. package/dist/ezui/{p-4f0632b4.js → p-474076b3.js} +1 -1
  116. package/dist/ezui/{p-a401041c.entry.js → p-47d9256e.entry.js} +1 -1
  117. package/dist/ezui/{p-124699e0.entry.js → p-4ea5c8a7.entry.js} +1 -1
  118. package/dist/ezui/{p-da585ff3.entry.js → p-582c3f90.entry.js} +1 -1
  119. package/dist/ezui/{p-6a9a20a0.entry.js → p-5e6de2c1.entry.js} +1 -1
  120. package/dist/ezui/{p-2a70f094.entry.js → p-6570ca10.entry.js} +1 -1
  121. package/dist/ezui/{p-e99cbb51.entry.js → p-67f9fadb.entry.js} +1 -1
  122. package/dist/ezui/p-6a982147.js +1 -0
  123. package/dist/ezui/{p-2854f087.entry.js → p-6c484770.entry.js} +1 -1
  124. package/dist/ezui/{p-1266fe78.entry.js → p-6d7f2fdc.entry.js} +1 -1
  125. package/dist/ezui/{p-df316d40.entry.js → p-6f466aec.entry.js} +1 -1
  126. package/dist/ezui/{p-3fe05d6b.entry.js → p-714452c7.entry.js} +1 -1
  127. package/dist/ezui/{p-957d08cd.entry.js → p-7624767b.entry.js} +1 -1
  128. package/dist/ezui/{p-294f54fe.entry.js → p-782fe2e3.entry.js} +1 -1
  129. package/dist/ezui/p-8709c4f6.entry.js +1 -0
  130. package/dist/ezui/{p-8dc267ff.entry.js → p-8a8006e6.entry.js} +1 -1
  131. package/dist/ezui/{p-79277e43.entry.js → p-9568a93d.entry.js} +1 -1
  132. package/dist/ezui/{p-19cf13bc.entry.js → p-9771ea3c.entry.js} +1 -1
  133. package/dist/ezui/p-98218fbc.js +1 -0
  134. package/dist/ezui/p-9d004e22.entry.js +1 -0
  135. package/dist/ezui/{p-eee3c7ff.entry.js → p-a13e65a4.entry.js} +1 -1
  136. package/dist/ezui/{p-e8c6c973.entry.js → p-a1a63294.entry.js} +1 -1
  137. package/dist/ezui/{p-eca050b4.entry.js → p-c711900a.entry.js} +1 -1
  138. package/dist/ezui/{p-a7eab406.entry.js → p-dc192d01.entry.js} +1 -1
  139. package/dist/ezui/{p-59a98e31.entry.js → p-e2e0dd76.entry.js} +1 -1
  140. package/dist/ezui/{p-44ad16df.entry.js → p-e4a579f2.entry.js} +1 -1
  141. package/dist/ezui/{p-59092a66.entry.js → p-e82a12c6.entry.js} +1 -1
  142. package/dist/ezui/p-f1bbf23f.entry.js +1 -0
  143. package/dist/ezui/{p-cd6f5783.entry.js → p-f45ddc1f.entry.js} +1 -1
  144. package/dist/types/components/ez-form/ez-form.d.ts +5 -0
  145. package/dist/types/components/ez-form-view/ez-form-view.d.ts +4 -0
  146. package/dist/types/components/ez-form-view/fieldbuilder/FieldBuilder.d.ts +3 -1
  147. package/dist/types/components/ez-form-view/fieldbuilder/templates/ImageInput.tpl.d.ts +2 -0
  148. package/dist/types/components/ez-image-input/ez-image-input.d.ts +42 -0
  149. package/dist/types/components.d.ts +98 -0
  150. package/dist/types/utils/i18n/locales/en-us.d.ts +8 -0
  151. package/dist/types/utils/i18n/locales/es-es.d.ts +8 -0
  152. package/dist/types/utils/i18n/locales/pt-br.d.ts +8 -0
  153. package/dist/types/utils/i18n/translations.d.ts +24 -0
  154. package/package.json +1 -1
  155. package/react/components.d.ts +1 -0
  156. package/react/components.js +1 -0
  157. package/react/components.js.map +1 -1
  158. package/dist/ezui/p-14807f4e.js +0 -1
  159. package/dist/ezui/p-641ee538.js +0 -1
  160. package/dist/ezui/p-96b33264.entry.js +0 -1
  161. package/dist/ezui/p-adaa2a81.entry.js +0 -1
  162. package/dist/ezui/p-c82acfc6.entry.js +0 -1
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,H as e,g as h}from"./p-23a36bb6.js";import{C as o}from"./p-ec7db713.js";import{ObjectUtils as r,StringUtils as n,ElementIDUtils as a}from"@sankhyalabs/core";import{A as l}from"./p-5a11cf56.js";import"./p-ab574d59.js";import"./p-b853763b.js";import{i as c}from"./p-641ee538.js";import{S as d}from"./p-30ffb9ed.js";import{r as u,a as v}from"./p-40a60148.js";const p=class{constructor(s){t(this,s),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._startHighlightTag="<span class='card-item__highlight'>",this._endHighlightTag="</span>",this._preSelection=void 0,this._visibleOptions=void 0,this._startLoading=!1,this._showLoading=!0,this._showLoadingDescription=!1,this._criteria=void 0,this.value=void 0,this.label=void 0,this.enabled=!0,this.errorMessage=void 0,this.optionLoader=void 0,this.contextProperties=void 0,this.showSelectedValue=!0,this.showOptionValue=!0,this.suppressEmptyOption=!1,this.stopPropagateEnterKeyEvent=!1,this.mode="regular",this.canShowError=!0,this.hideErrorOnFocusOut=!0,this.listOptionsPosition=void 0,this.isTextSearch=!1,this.ignoreLimitCharsToSearch=!1,this.options=void 0,this.suppressSearch=!1,this.ensureClearButtonVisible=!1,this.suppressPreLoad=!0,this.autoFocus=!1,this.alternativePlaceholder=void 0,this.showMore=void 0,this.suppressInputPersist=!1,this.hideDescriptionInput=!1}observeErrorMessage(){var t;this._textInput&&(this._textInput.errorMessage=this.errorMessage,!(null===(t=this.errorMessage)||void 0===t?void 0:t.trim())&&this.errorMessage&&this.setInputValue())}getValue(t){return"object"==typeof t?null==t?void 0:t.value:t}validateNewValue(t,i){const s=this.getValue(t),e=this.getValue(i);return!("[object Object]"===s||s===e)}async observeValue(t,i){if(this._textInput&&this.validateNewValue(t,i)){if("string"==typeof t)return void await this.handleValueAsString(t);const i=this.getSelectedOption(t),s=this.getSelectedOption(this._currentValue);this.isDifferentValues(s,i)&&(this._currentValue=i,this.setInputValue(),this.ezChange.emit(null!=i?i:void 0)),this.resetOptions()}}observeOptions(t,i){!t.length&&this.suppressPreLoad||(null==t?void 0:t.join(""))!==(null==i?void 0:i.join(""))&&this.loadOptions(d.PRELOAD)}async getValueAsync(){return new Promise(this._showLoading?t=>{let i=setInterval((()=>{this._showLoading||(clearInterval(i),t(this.value))}),100)}:t=>t(this.value))}async setFocus(t){this._textInput&&this._textInput.setFocus(t)}async setBlur(){this._textInput&&this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}async clearValue(){this.clearSearch()}async handleValueAsString(t){this.getSelectedOption(t)?this.setInputValue():(await this.loadDescriptionValue(t),this._currentValue&&(this.setInputValue(),this.ezChange.emit(this.value),this._currentValue=this.value))}isDifferentValues(t,i){return r.objectToString(t||{})!==r.objectToString(i||{})}getFormattedText(t){if(null==t)return;let i=this.showSelectedValue&&null!=t.value?t.label?`${t.value} - ${t.label}`:t.value:t.label;return i=null==i?void 0:i.replace(new RegExp(this._startHighlightTag,"g"),"").replace(new RegExp(this._endHighlightTag,"g"),""),i}getText(){const t=this.getSelectedOption(this._currentValue),i=this.getFormattedText(t);return u(i)}getSelectedOption(t){return"string"==typeof t||t instanceof String?this._visibleOptions.find((i=>i.value===t)):t?Object.assign(Object.assign({},t),{value:v(null==t?void 0:t.value),label:v(null==t?void 0:t.label)}):t}updateVisibleOptions(){let t=this._source||[];this._visibleOptions=this.suppressEmptyOption?t:[{value:void 0,label:""}].concat(t),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var t;const i=[];return null===(t=this._visibleOptions)||void 0===t||t.forEach((t=>{const s=this.getWidthValue(t.value);i.includes(s)||i.push(s)})),i.length>1?Math.max(...i):0}getWidthValue(t){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=t)return i.innerHTML=t,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}showOptions(){this.enabled&&(this.isOptionsVisible()||this._ezPopOverPlusElement.showUnder(this._textInput))}hideOptions(){this._ezPopOverPlusElement.hide()}isOptionsVisible(){return this._ezPopOverPlusElement.opened}selectCurrentOption(t=!0){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection],t),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(t){this._startLoading=!1,t instanceof Promise?(this._showLoading=!0,this._showLoadingDescription=!0,t.then((t=>{this.updateSource(t)})).finally((()=>{this._showLoading=!1,this._showLoadingDescription=!1})),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(t)?(this._source=t,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch(!1))):this.selectOption(t))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(t,i=!0){var s,e;const h=this.getSelectedOption(this.value),o=Object.assign(Object.assign({},t),{value:v(null==t?void 0:t.value),label:v(null==t?void 0:t.label)}),r=Object.assign(Object.assign({},o),{value:u(null==o?void 0:o.value),label:u(null==o?void 0:o.label)});if((null===(s=null==h?void 0:h.value)||void 0===s?void 0:s.toString())!==(null===(e=null==r?void 0:r.value)||void 0===e?void 0:e.toString())||null==h&&null!=r&&"value"in r){const t=(null==r?void 0:r.value)?r:void 0;this.value=t,this._currentValue=t}else this.setInputValue(),this.resetOptions();this._visibleOptions=[],this.clearSource(),i&&setTimeout((()=>{this.setFocus()}),0)}loadOptions(t,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:t,argument:i},this.contextProperties):this.options)}cancelPreselection(){!this._textInput.value&&this._currentValue&&this._source.length>0?this.selectOption(void 0):window.setTimeout((()=>{this.setInputValue()}),this._deboucingTime),this.resetOptions()}setInputValue(t=!0){if(this.suppressInputPersist)return void this.clearSearch();const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,t&&(this.errorMessage=null))}clearSearch(){this.value=null,this._currentValue=null,this._textInput.value=""}controlListWithOnlyOne(t=!0){var i,s;const e=null===(i=this._visibleOptions)||void 0===i?void 0:i.filter((t=>""!==t.label&&null!=t.value));if((null==e?void 0:e.length)>0){const i=new RegExp(this._startHighlightTag,"g"),h=new RegExp(this._endHighlightTag,"g");let o=n.decodeHtmlEntities(e[0].label);const r={value:null===(s=e[0].value)||void 0===s?void 0:s.replace(i,"").replace(h,""),label:null==o?void 0:o.replace(i,"").replace(h,"")};this.selectOption(r,t)}}controlEmptySearch(t=!0){var i;(null===(i=this._visibleOptions)||void 0===i?void 0:i.length)?this.controlListWithOnlyOne(t):(this.clearSearch(),l.info(this.i18n("ez-search.emptyList")))}async loadDescriptionValue(t){var i,s,e;if(null==t)return;if((null===(i=this.options)||void 0===i?void 0:i.length)>0)return void this.loadOptionValue(t);const h={mode:this.hideDescriptionInput?d.LOAD_DESCRIPTION:d.PREDICTIVE,argument:t};try{const t=await(null===(s=this.optionLoader)||void 0===s?void 0:s.call(this,h,this.contextProperties));if(null==t)return;t instanceof Promise?t.then((t=>{this.setDescriptionValue(t)})):this.setDescriptionValue(t)}catch(t){throw"WarningException"===(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e.name)&&(this.errorMessage=t.message),t}}setDescriptionValue(t){const i=(null==t?void 0:t[0])||t;null!=i&&Object.keys(i).length?(this._currentValue=i?Object.assign(Object.assign({},i),{value:v(i.value),label:v(i.label)}):i,this.value=this._currentValue,this.setTextInputValue()):this.showNoResultMessage()}setTextInputValue(){if(this._textInput&&null==this._textInput.value){if(null==this.value)return;const t="string"==typeof this.value?this.value:this.getFormattedText(this.value);this._textInput.value=u(t)}}loadOptionValue(t){var i;const s=null===(i=this.options)||void 0===i?void 0:i.find((i=>i.value===t));null!=s?this.selectOption(s):this.showNoResultMessage()}async showNoResultMessage(){this.clearSearch(),l.info(this.i18n("ez-search.emptySearch",{field:this.getFieldLabel()}))}getFieldLabel(){var t;return null===(t=this.label)||void 0===t?void 0:t.replace(this.i18n("app.requiredInfo"),"").toUpperCase()}resetOptions(){this.showMore?this.handleResetOptionsWithShowMoreVisible():(this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions())}handleResetOptionsWithShowMoreVisible(){setTimeout((()=>{this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}),100)}async handleInitialValue(){if(!this.getValue(this.value))return;if("string"==typeof this.value)return void await this.handleValueAsString(this.value);let t=this.getFormattedText(this.value);t=u(t),this._textInput.value=t}async componentWillLoad(){if(this.i18n=await c(),void 0===this.options){this.options=[];const t=this.el.querySelectorAll("option");t&&t.forEach((t=>{let i=t.innerText,s=t.getAttribute("value"),e=t.getAttribute("details");s||(s=i),this.options.push({label:i,value:s,details:e}),t.hidden=!0}))}this.updateSource([])}componentDidRender(){var t;null===(t=this._optionsList)||void 0===t||t.querySelectorAll(".item").forEach((t=>{a.addIDInfoIfNotExists(t,"itemSearch")}))}async componentDidLoad(){this._currentValue=this.value,o.applyVarsTextInput(this.el,this._textInput),this._resizeObserver=new ResizeObserver((t=>{window.requestAnimationFrame((()=>{Array.isArray(t)}))})),this._intersectionObserver=new IntersectionObserver((t=>{t.forEach((t=>{!t.isIntersecting&&this._ezPopOverPlusElement&&this._ezPopOverPlusElement.hide()}))}),{threshold:.1}),this._textInput&&this._intersectionObserver.observe(this._textInput),await this.handleInitialValue(),this.autoFocus&&requestAnimationFrame((()=>{this.setFocus({selectText:!0})}))}disconnectedCallback(){var t,i;null===(t=this._resizeObserver)||void 0===t||t.disconnect(),null===(i=this._intersectionObserver)||void 0===i||i.disconnect()}handlerIconClick(){this.loadOptions(d.ADVANCED)}buildNumberArgument(t){return this.isTextSearch?NaN:Number(t||void 0)}onTextInputChangeHandler(t){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(t)}),this._deboucingTime));const s=null===(i=t.target.value)||void 0===i?void 0:i.trim(),e=this.buildNumberArgument(s);this._criteria||(this._textInput.value=t.data||s),this._criteria=s,s?(this._showLoading=!1,this.clearSource(),this.ignoreLimitCharsToSearch||!isNaN(e)||s.length>=this._limitCharsToSearch?(this._showLoading=!0,this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions(d.PREDICTIVE,isNaN(e)?s:e.toString())}),this._deboucingTime),this.showOptions()):this.hideOptions()):(this.hideOptions(),this._showLoading=!1,this.clearSource())}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=null)}async keyDownHandler(t){switch(this._tabPressed=!1,t.ctrlKey&&("f"!==t.key&&"F"!==t.key||(this.loadOptions(d.ADVANCED),t.stopPropagation(),t.stopImmediatePropagation(),t.preventDefault())),t.key){case"ArrowDown":t.stopPropagation(),this.canShowListOptions()&&t.preventDefault(),this.isOptionsVisible()||this.showOptions(),await this._searchList.nextOption();break;case"ArrowUp":t.stopPropagation(),this.canShowListOptions()&&t.preventDefault(),await this._searchList.previousOption();break;case"Enter":this.handleEventPropagation(t),this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.selectCurrentOption(!1)}}handleEventPropagation(t){this._ezPopOverPlusElement.opened&&this.stopPropagateEnterKeyEvent&&t.stopPropagation()}onTextInputFocusOutHandler(){this.hideErrorOnFocusOut&&this.cancelPreselection()}canShowListOptions(){return!this._showLoading&&this._visibleOptions.length>0}canShowLoadSpinDescription(){return this._showLoadingDescription&&!this._ezPopOverPlusElement.opened}onChangePreSelection(t){this._preSelection=t}async handleClickShowMore(){var t,i;if(!this.optionLoader)return;const s=null!==(i=null===(t=this._textInput)||void 0===t?void 0:t.value)&&void 0!==i?i:"",e={mode:d.ADVANCED,argument:s},h=await this.optionLoader(e,this.contextProperties);h&&!Array.isArray(h)&&this.selectOption(h)}renderShowMore(){if(this.showMore&&!this._showLoading)return s("div",{style:{display:"flex",justifyContent:"center"},"data-element-id":a.getInternalIDInfo("showMore")},s("ez-button",{onClick:async()=>await this.handleClickShowMore(),variant:"tertiary",style:{width:"100%",justifyContent:"center"},label:this.i18n("ez-search.showMore")}))}render(){var t;return a.addIDInfoIfNotExists(this.el,"input"),s(e,null,s("ez-text-input",{"data-element-id":a.getInternalIDInfo("textInput"),class:this.suppressSearch?"suppressed-search-input":"",ref:t=>this._textInput=t,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:t=>this.onTextInputChangeHandler(t),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:t=>this.keyDownHandler(t),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode,alternativePlaceholder:this.alternativePlaceholder},s("button",{class:"btn",slot:"leftIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},this.canShowLoadSpinDescription()?s("div",{class:"message__loading"}):s("ez-icon",{iconName:"search"})),(null===(t=this._textInput)||void 0===t?void 0:t.value)&&(this._criteria||this.value)||this.ensureClearButtonVisible?s("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},s("ez-icon",{iconName:"close"})):void 0),s("ez-popover-plus",{ref:t=>this._ezPopOverPlusElement=t,autoClose:!1,overlayType:"none",useAnchorSize:!0,anchorElement:[this._textInput,this.el],"data-element-id":this.el.getAttribute("data-element-id"),onEzVisibilityChange:t=>t.stopPropagation()},s("div",null,s("search-list",{ref:t=>this._searchList=t,showLoading:this._showLoading,visibleOptions:this._visibleOptions,textEmptyList:this.i18n("ez-search.emptyList"),canShowListOptions:this.canShowListOptions(),value:this.value,showOptionValue:this.showOptionValue,preSelection:this._preSelection,onChangeValue:({detail:t})=>this.selectOption(t),onChangePreSelection:({detail:t})=>this.onChangePreSelection(t)}),this.renderShowMore())))}get el(){return h(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"],options:["observeOptions"]}}};p.style=":host{--ez-search--height:42px;--ez-search--width:100%;--ez-search__icon--width:48px;--ez-search--border-radius:var(--border--radius-medium, 12px);--ez-search--border-radius-small:var(--border--radius-small, 6px);--ez-search--font-size:var(--text--medium, 14px);--ez-search--font-family:var(--font-pattern, Arial);--ez-search--font-weight--large:var(--text-weight--large, 500);--ez-search--font-weight--medium:var(--text-weight--medium, 400);--ez-search--background-color--xlight:var(--background--xlight, #fff);--ez-search--background-medium:var(--background--medium, #f0f3f7);--ez-search--line-height:calc(var(--text--medium, 14px) + 4px);--ez-search__input--background-color:var(--background--medium, #e0e0e0);--ez-search__input--border:var(--border--medium, 2px solid);--ez-search__input--border-color:var(--ez-search__input--background-color);--ez-search__input--focus--border-color:var(--color--primary, #008561);--ez-search__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-search__input--disabled--color:var(--text--disable, #AFB6C0);--ez-search__input--error--border-color:#CC2936;--ez-search__btn--color:var(--title--primary, #2B3A54);--ez-search__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-search__btn-hover--color:var(--color--primary, #4e4e4e);--ez-search__label--color:var(--title--primary, #2B3A54);--ez-search--space--medium:var(--space--medium, 12px);--ez-search--space--small:var(--space--small, 6px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-search--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-search__btn--color)}.btn:disabled{cursor:not-allowed;color:var(--ez-search__btn-disabled--color)}.btn:disabled:hover{cursor:not-allowed;color:var(--ez-search__btn-disabled--color)}.btn:hover{color:var(--ez-search__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}";export{p as ez_search}
1
+ import{r as t,c as i,h as s,H as e,g as h}from"./p-23a36bb6.js";import{C as o}from"./p-ec7db713.js";import{ObjectUtils as r,StringUtils as n,ElementIDUtils as a}from"@sankhyalabs/core";import{A as l}from"./p-0ec5c128.js";import"./p-ab574d59.js";import"./p-b853763b.js";import{i as c}from"./p-98218fbc.js";import{S as d}from"./p-30ffb9ed.js";import{r as u,a as v}from"./p-40a60148.js";const p=class{constructor(s){t(this,s),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._startHighlightTag="<span class='card-item__highlight'>",this._endHighlightTag="</span>",this._preSelection=void 0,this._visibleOptions=void 0,this._startLoading=!1,this._showLoading=!0,this._showLoadingDescription=!1,this._criteria=void 0,this.value=void 0,this.label=void 0,this.enabled=!0,this.errorMessage=void 0,this.optionLoader=void 0,this.contextProperties=void 0,this.showSelectedValue=!0,this.showOptionValue=!0,this.suppressEmptyOption=!1,this.stopPropagateEnterKeyEvent=!1,this.mode="regular",this.canShowError=!0,this.hideErrorOnFocusOut=!0,this.listOptionsPosition=void 0,this.isTextSearch=!1,this.ignoreLimitCharsToSearch=!1,this.options=void 0,this.suppressSearch=!1,this.ensureClearButtonVisible=!1,this.suppressPreLoad=!0,this.autoFocus=!1,this.alternativePlaceholder=void 0,this.showMore=void 0,this.suppressInputPersist=!1,this.hideDescriptionInput=!1}observeErrorMessage(){var t;this._textInput&&(this._textInput.errorMessage=this.errorMessage,!(null===(t=this.errorMessage)||void 0===t?void 0:t.trim())&&this.errorMessage&&this.setInputValue())}getValue(t){return"object"==typeof t?null==t?void 0:t.value:t}validateNewValue(t,i){const s=this.getValue(t),e=this.getValue(i);return!("[object Object]"===s||s===e)}async observeValue(t,i){if(this._textInput&&this.validateNewValue(t,i)){if("string"==typeof t)return void await this.handleValueAsString(t);const i=this.getSelectedOption(t),s=this.getSelectedOption(this._currentValue);this.isDifferentValues(s,i)&&(this._currentValue=i,this.setInputValue(),this.ezChange.emit(null!=i?i:void 0)),this.resetOptions()}}observeOptions(t,i){!t.length&&this.suppressPreLoad||(null==t?void 0:t.join(""))!==(null==i?void 0:i.join(""))&&this.loadOptions(d.PRELOAD)}async getValueAsync(){return new Promise(this._showLoading?t=>{let i=setInterval((()=>{this._showLoading||(clearInterval(i),t(this.value))}),100)}:t=>t(this.value))}async setFocus(t){this._textInput&&this._textInput.setFocus(t)}async setBlur(){this._textInput&&this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}async clearValue(){this.clearSearch()}async handleValueAsString(t){this.getSelectedOption(t)?this.setInputValue():(await this.loadDescriptionValue(t),this._currentValue&&(this.setInputValue(),this.ezChange.emit(this.value),this._currentValue=this.value))}isDifferentValues(t,i){return r.objectToString(t||{})!==r.objectToString(i||{})}getFormattedText(t){if(null==t)return;let i=this.showSelectedValue&&null!=t.value?t.label?`${t.value} - ${t.label}`:t.value:t.label;return i=null==i?void 0:i.replace(new RegExp(this._startHighlightTag,"g"),"").replace(new RegExp(this._endHighlightTag,"g"),""),i}getText(){const t=this.getSelectedOption(this._currentValue),i=this.getFormattedText(t);return u(i)}getSelectedOption(t){return"string"==typeof t||t instanceof String?this._visibleOptions.find((i=>i.value===t)):t?Object.assign(Object.assign({},t),{value:v(null==t?void 0:t.value),label:v(null==t?void 0:t.label)}):t}updateVisibleOptions(){let t=this._source||[];this._visibleOptions=this.suppressEmptyOption?t:[{value:void 0,label:""}].concat(t),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var t;const i=[];return null===(t=this._visibleOptions)||void 0===t||t.forEach((t=>{const s=this.getWidthValue(t.value);i.includes(s)||i.push(s)})),i.length>1?Math.max(...i):0}getWidthValue(t){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=t)return i.innerHTML=t,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}showOptions(){this.enabled&&(this.isOptionsVisible()||this._ezPopOverPlusElement.showUnder(this._textInput))}hideOptions(){this._ezPopOverPlusElement.hide()}isOptionsVisible(){return this._ezPopOverPlusElement.opened}selectCurrentOption(t=!0){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection],t),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(t){this._startLoading=!1,t instanceof Promise?(this._showLoading=!0,this._showLoadingDescription=!0,t.then((t=>{this.updateSource(t)})).finally((()=>{this._showLoading=!1,this._showLoadingDescription=!1})),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(t)?(this._source=t,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch(!1))):this.selectOption(t))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(t,i=!0){var s,e;const h=this.getSelectedOption(this.value),o=Object.assign(Object.assign({},t),{value:v(null==t?void 0:t.value),label:v(null==t?void 0:t.label)}),r=Object.assign(Object.assign({},o),{value:u(null==o?void 0:o.value),label:u(null==o?void 0:o.label)});if((null===(s=null==h?void 0:h.value)||void 0===s?void 0:s.toString())!==(null===(e=null==r?void 0:r.value)||void 0===e?void 0:e.toString())||null==h&&null!=r&&"value"in r){const t=(null==r?void 0:r.value)?r:void 0;this.value=t,this._currentValue=t}else this.setInputValue(),this.resetOptions();this._visibleOptions=[],this.clearSource(),i&&setTimeout((()=>{this.setFocus()}),0)}loadOptions(t,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:t,argument:i},this.contextProperties):this.options)}cancelPreselection(){!this._textInput.value&&this._currentValue&&this._source.length>0?this.selectOption(void 0):window.setTimeout((()=>{this.setInputValue()}),this._deboucingTime),this.resetOptions()}setInputValue(t=!0){if(this.suppressInputPersist)return void this.clearSearch();const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,t&&(this.errorMessage=null))}clearSearch(){this.value=null,this._currentValue=null,this._textInput.value=""}controlListWithOnlyOne(t=!0){var i,s;const e=null===(i=this._visibleOptions)||void 0===i?void 0:i.filter((t=>""!==t.label&&null!=t.value));if((null==e?void 0:e.length)>0){const i=new RegExp(this._startHighlightTag,"g"),h=new RegExp(this._endHighlightTag,"g");let o=n.decodeHtmlEntities(e[0].label);const r={value:null===(s=e[0].value)||void 0===s?void 0:s.replace(i,"").replace(h,""),label:null==o?void 0:o.replace(i,"").replace(h,"")};this.selectOption(r,t)}}controlEmptySearch(t=!0){var i;(null===(i=this._visibleOptions)||void 0===i?void 0:i.length)?this.controlListWithOnlyOne(t):(this.clearSearch(),l.info(this.i18n("ez-search.emptyList")))}async loadDescriptionValue(t){var i,s,e;if(null==t)return;if((null===(i=this.options)||void 0===i?void 0:i.length)>0)return void this.loadOptionValue(t);const h={mode:this.hideDescriptionInput?d.LOAD_DESCRIPTION:d.PREDICTIVE,argument:t};try{const t=await(null===(s=this.optionLoader)||void 0===s?void 0:s.call(this,h,this.contextProperties));if(null==t)return;t instanceof Promise?t.then((t=>{this.setDescriptionValue(t)})):this.setDescriptionValue(t)}catch(t){throw"WarningException"===(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e.name)&&(this.errorMessage=t.message),t}}setDescriptionValue(t){const i=(null==t?void 0:t[0])||t;null!=i&&Object.keys(i).length?(this._currentValue=i?Object.assign(Object.assign({},i),{value:v(i.value),label:v(i.label)}):i,this.value=this._currentValue,this.setTextInputValue()):this.showNoResultMessage()}setTextInputValue(){if(this._textInput&&null==this._textInput.value){if(null==this.value)return;const t="string"==typeof this.value?this.value:this.getFormattedText(this.value);this._textInput.value=u(t)}}loadOptionValue(t){var i;const s=null===(i=this.options)||void 0===i?void 0:i.find((i=>i.value===t));null!=s?this.selectOption(s):this.showNoResultMessage()}async showNoResultMessage(){this.clearSearch(),l.info(this.i18n("ez-search.emptySearch",{field:this.getFieldLabel()}))}getFieldLabel(){var t;return null===(t=this.label)||void 0===t?void 0:t.replace(this.i18n("app.requiredInfo"),"").toUpperCase()}resetOptions(){this.showMore?this.handleResetOptionsWithShowMoreVisible():(this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions())}handleResetOptionsWithShowMoreVisible(){setTimeout((()=>{this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}),100)}async handleInitialValue(){if(!this.getValue(this.value))return;if("string"==typeof this.value)return void await this.handleValueAsString(this.value);let t=this.getFormattedText(this.value);t=u(t),this._textInput.value=t}async componentWillLoad(){if(this.i18n=await c(),void 0===this.options){this.options=[];const t=this.el.querySelectorAll("option");t&&t.forEach((t=>{let i=t.innerText,s=t.getAttribute("value"),e=t.getAttribute("details");s||(s=i),this.options.push({label:i,value:s,details:e}),t.hidden=!0}))}this.updateSource([])}componentDidRender(){var t;null===(t=this._optionsList)||void 0===t||t.querySelectorAll(".item").forEach((t=>{a.addIDInfoIfNotExists(t,"itemSearch")}))}async componentDidLoad(){this._currentValue=this.value,o.applyVarsTextInput(this.el,this._textInput),this._resizeObserver=new ResizeObserver((t=>{window.requestAnimationFrame((()=>{Array.isArray(t)}))})),this._intersectionObserver=new IntersectionObserver((t=>{t.forEach((t=>{!t.isIntersecting&&this._ezPopOverPlusElement&&this._ezPopOverPlusElement.hide()}))}),{threshold:.1}),this._textInput&&this._intersectionObserver.observe(this._textInput),await this.handleInitialValue(),this.autoFocus&&requestAnimationFrame((()=>{this.setFocus({selectText:!0})}))}disconnectedCallback(){var t,i;null===(t=this._resizeObserver)||void 0===t||t.disconnect(),null===(i=this._intersectionObserver)||void 0===i||i.disconnect()}handlerIconClick(){this.loadOptions(d.ADVANCED)}buildNumberArgument(t){return this.isTextSearch?NaN:Number(t||void 0)}onTextInputChangeHandler(t){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(t)}),this._deboucingTime));const s=null===(i=t.target.value)||void 0===i?void 0:i.trim(),e=this.buildNumberArgument(s);this._criteria||(this._textInput.value=t.data||s),this._criteria=s,s?(this._showLoading=!1,this.clearSource(),this.ignoreLimitCharsToSearch||!isNaN(e)||s.length>=this._limitCharsToSearch?(this._showLoading=!0,this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions(d.PREDICTIVE,isNaN(e)?s:e.toString())}),this._deboucingTime),this.showOptions()):this.hideOptions()):(this.hideOptions(),this._showLoading=!1,this.clearSource())}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=null)}async keyDownHandler(t){switch(this._tabPressed=!1,t.ctrlKey&&("f"!==t.key&&"F"!==t.key||(this.loadOptions(d.ADVANCED),t.stopPropagation(),t.stopImmediatePropagation(),t.preventDefault())),t.key){case"ArrowDown":t.stopPropagation(),this.canShowListOptions()&&t.preventDefault(),this.isOptionsVisible()||this.showOptions(),await this._searchList.nextOption();break;case"ArrowUp":t.stopPropagation(),this.canShowListOptions()&&t.preventDefault(),await this._searchList.previousOption();break;case"Enter":this.handleEventPropagation(t),this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.selectCurrentOption(!1)}}handleEventPropagation(t){this._ezPopOverPlusElement.opened&&this.stopPropagateEnterKeyEvent&&t.stopPropagation()}onTextInputFocusOutHandler(){this.hideErrorOnFocusOut&&this.cancelPreselection()}canShowListOptions(){return!this._showLoading&&this._visibleOptions.length>0}canShowLoadSpinDescription(){return this._showLoadingDescription&&!this._ezPopOverPlusElement.opened}onChangePreSelection(t){this._preSelection=t}async handleClickShowMore(){var t,i;if(!this.optionLoader)return;const s=null!==(i=null===(t=this._textInput)||void 0===t?void 0:t.value)&&void 0!==i?i:"",e={mode:d.ADVANCED,argument:s},h=await this.optionLoader(e,this.contextProperties);h&&!Array.isArray(h)&&this.selectOption(h)}renderShowMore(){if(this.showMore&&!this._showLoading)return s("div",{style:{display:"flex",justifyContent:"center"},"data-element-id":a.getInternalIDInfo("showMore")},s("ez-button",{onClick:async()=>await this.handleClickShowMore(),variant:"tertiary",style:{width:"100%",justifyContent:"center"},label:this.i18n("ez-search.showMore")}))}render(){var t;return a.addIDInfoIfNotExists(this.el,"input"),s(e,null,s("ez-text-input",{"data-element-id":a.getInternalIDInfo("textInput"),class:this.suppressSearch?"suppressed-search-input":"",ref:t=>this._textInput=t,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:t=>this.onTextInputChangeHandler(t),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:t=>this.keyDownHandler(t),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode,alternativePlaceholder:this.alternativePlaceholder},s("button",{class:"btn",slot:"leftIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},this.canShowLoadSpinDescription()?s("div",{class:"message__loading"}):s("ez-icon",{iconName:"search"})),(null===(t=this._textInput)||void 0===t?void 0:t.value)&&(this._criteria||this.value)||this.ensureClearButtonVisible?s("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},s("ez-icon",{iconName:"close"})):void 0),s("ez-popover-plus",{ref:t=>this._ezPopOverPlusElement=t,autoClose:!1,overlayType:"none",useAnchorSize:!0,anchorElement:[this._textInput,this.el],"data-element-id":this.el.getAttribute("data-element-id"),onEzVisibilityChange:t=>t.stopPropagation()},s("div",null,s("search-list",{ref:t=>this._searchList=t,showLoading:this._showLoading,visibleOptions:this._visibleOptions,textEmptyList:this.i18n("ez-search.emptyList"),canShowListOptions:this.canShowListOptions(),value:this.value,showOptionValue:this.showOptionValue,preSelection:this._preSelection,onChangeValue:({detail:t})=>this.selectOption(t),onChangePreSelection:({detail:t})=>this.onChangePreSelection(t)}),this.renderShowMore())))}get el(){return h(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"],options:["observeOptions"]}}};p.style=":host{--ez-search--height:42px;--ez-search--width:100%;--ez-search__icon--width:48px;--ez-search--border-radius:var(--border--radius-medium, 12px);--ez-search--border-radius-small:var(--border--radius-small, 6px);--ez-search--font-size:var(--text--medium, 14px);--ez-search--font-family:var(--font-pattern, Arial);--ez-search--font-weight--large:var(--text-weight--large, 500);--ez-search--font-weight--medium:var(--text-weight--medium, 400);--ez-search--background-color--xlight:var(--background--xlight, #fff);--ez-search--background-medium:var(--background--medium, #f0f3f7);--ez-search--line-height:calc(var(--text--medium, 14px) + 4px);--ez-search__input--background-color:var(--background--medium, #e0e0e0);--ez-search__input--border:var(--border--medium, 2px solid);--ez-search__input--border-color:var(--ez-search__input--background-color);--ez-search__input--focus--border-color:var(--color--primary, #008561);--ez-search__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-search__input--disabled--color:var(--text--disable, #AFB6C0);--ez-search__input--error--border-color:#CC2936;--ez-search__btn--color:var(--title--primary, #2B3A54);--ez-search__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-search__btn-hover--color:var(--color--primary, #4e4e4e);--ez-search__label--color:var(--title--primary, #2B3A54);--ez-search--space--medium:var(--space--medium, 12px);--ez-search--space--small:var(--space--small, 6px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-search--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-search__btn--color)}.btn:disabled{cursor:not-allowed;color:var(--ez-search__btn-disabled--color)}.btn:disabled:hover{cursor:not-allowed;color:var(--ez-search__btn-disabled--color)}.btn:hover{color:var(--ez-search__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}";export{p as ez_search}
@@ -1 +1 @@
1
- import{r as t,c as e,h as i,H as s}from"./p-23a36bb6.js";import{ObjectUtils as o}from"@sankhyalabs/core";import{i as l}from"./p-80dfc50b.js";import{i as n}from"./p-641ee538.js";function h(t,e,i){if(!t.length)return[...e];if(!e.length)return[];const s=function(t,e){return t.map((t=>e.findIndex((e=>e.id===t))))}(t,e),o=0===(l=s).length?0:l.reduce(((t,e)=>e<t?e:t),l[0]);var l;const n=function(t){return 0===t.length?0:t.reduce(((t,e)=>e>t?e:t),t[0])}(s);return function(t,e,i,s){return t<0||e>=s.length||t>e?s:i?function(t,e,i){if(t===i.length-1)return i;const s=i.slice(0,e),o=i.slice(e,t+1),l=i.slice(t+1),n=l.shift();return n?[...s,n,...o,...l]:i}(e,t,s):function(t,e,i){if(0===t)return i;const s=i.slice(0,t-1),o=i.slice(t,e+1),l=i.slice(e+1);return[...s,...o,i[t-1],...l]}(t,e,s)}(o,n,i,e)}function r({from:t,to:e,selectedFrom:i,selectedTo:s}){return e=[...e.map((t=>d(t,!1))),...t.map((t=>d(t,!0)))],i=[],s=[...t.map((({id:t})=>t))],{from:t=[],to:e,selectedFrom:i,selectedTo:s}}function a({from:t,to:e,selectedFrom:i,selectedTo:s,insertIndex:o=e.length}){if(!t.length)return{from:t,to:e,selectedFrom:i,selectedTo:s};const l=function(t,e,i){const s=t.map((t=>t.id)),o=e.filter((t=>!s.includes(t)));return i.filter((({id:t})=>o.includes(t)))}(e,i,t);if(!l.length)return{from:t,to:e,selectedFrom:i,selectedTo:s};let n=e.map((t=>d(t,!1)));return n.splice(o,0,...l.map((t=>d(t,!0)))),{from:t.filter((t=>!i.includes(t.id))),to:n,selectedFrom:[],selectedTo:[...i]}}function d(t,e){return Object.assign(Object.assign({},t),{selected:e})}const c=class{constructor(i){t(this,i),this.ezLeftListChanged=e(this,"ezLeftListChanged",7),this.ezRightListChanged=e(this,"ezRightListChanged",7),this.LEFT_LIST_ID="LEFT-LIST-ID",this.RIGHT_LIST_ID="RIGHT-LIST-ID",this.leftList=[],this.leftTitle=void 0,this.rightList=[],this.entityLabel="item",this.entityLabelPlural="itens",this.leftListLabel="disponíveis",this.rightListLabel="selecionados",this.useOnlyRightList=!1,this.rightTitle=void 0,this.emptyMessage=void 0,this.slotsListBuilder=void 0,this.leftFilteredList=[],this.rightFilteredList=[],this.selectedLeftList=[],this.selectedRightList=[],this.isFilteringLeft=!1,this.isFilteringRight=!1}async resetSelectedLists(){this.selectedLeftList=[],this.selectedRightList=[]}observeLeftList(t,e){o.equals(t,e)||this.ezLeftListChanged.emit(t)}observeRightList(t,e){o.equals(t,e)||this.ezRightListChanged.emit(t)}async componentWillLoad(){this.i18n=await n()}async handleChangeLeft({detail:t}){t.to.getAttribute("id")&&t.to.getAttribute("id")===this.RIGHT_LIST_ID?(t.selectItens=t.selectItens.filter((t=>this.rightList.every((e=>e.id!==t)))),this.leftList=[...t.dataSource],this.selectedLeftList=[...t.selectItens],this.transferToRight(null==t?void 0:t.newIndex)):this.leftList=[...this.reorderArray(t.dataSource,t.selectItens,t.newIndex)]}async handleChangeRight({detail:t}){t.to.getAttribute("id")&&t.to.getAttribute("id")===this.LEFT_LIST_ID?(t.selectItens=t.selectItens.filter((t=>this.leftList.every((e=>e.id!==t)))),this.rightList=[...t.dataSource],this.selectedRightList=[...t.selectItens],this.transferToLeft(null==t?void 0:t.newIndex)):this.rightList=[...this.reorderArray(t.dataSource,t.selectItens,t.newIndex)]}reorderArray(t,e,i){const s=t.filter((t=>!e.includes(t.id))),o=t.filter((t=>e.includes(t.id)));return s.splice(i,0,...o),s}enableTransferAllToRight(){return this.leftList.length>0}enableTransferAllToLeft(){return this.rightList.length>0}enableTransferToRight(){return this.selectedLeftList.length>0}enableTransferToLeft(){return this.selectedRightList.length>0}enableMoveUp(t){if(this.isFilteringRight)return!1;const e=this.getRightSelectedItemsIndex();return this.selectedRightList.length>0&&!e.includes(0)&&(!!t||l(e))}enableMoveDown(t){if(this.isFilteringRight)return!1;const e=this.getRightSelectedItemsIndex();return this.selectedRightList.length>0&&!e.includes(this.rightList.length-1)&&(!!t||l(e))}getRightSelectedItemsIndex(){return this.selectedRightList.map((t=>this.rightList.findIndex((e=>e.id===t))))}transferToRight(t){const{from:e,to:i,selectedFrom:s,selectedTo:o}=a(Object.assign(Object.assign({},this.buildTransferToRightConfig()),{insertIndex:null!=t?t:0}));this.leftList=[],requestAnimationFrame((()=>this.leftList=[...e])),this.rightList=[...i],this.selectedLeftList=[...s],this.selectedRightList=[...o]}transferToLeft(t){const{from:e,to:i,selectedFrom:s,selectedTo:o}=a(Object.assign(Object.assign({},this.buildTransferToLeftConfig()),{insertIndex:null!=t?t:0}));this.rightList=[],requestAnimationFrame((()=>this.rightList=[...e])),this.leftList=[...i],this.selectedRightList=[...s],this.selectedLeftList=[...o]}async handleTransferAllToRight(){const{from:t,to:e,selectedFrom:i,selectedTo:s}=r(this.buildTransferToRightConfig());this.leftList=[...t],this.rightList=[...e],this.selectedLeftList=[...i],this.selectedRightList=[...s],requestAnimationFrame((async()=>{await this.clearSelectionAll()}))}async handleTransferAllToLeft(){const{from:t,to:e,selectedFrom:i,selectedTo:s}=r(this.buildTransferToLeftConfig());this.rightList=[...t],this.leftList=[...e],this.selectedRightList=[...i],this.selectedLeftList=[...s],requestAnimationFrame((async()=>{await this.clearSelectionAll()}))}buildTransferToRightConfig(){return{from:this.leftList,to:this.rightList,selectedFrom:this.selectedLeftList,selectedTo:this.selectedRightList}}buildTransferToLeftConfig(){return{from:this.rightList,to:this.leftList,selectedFrom:this.selectedRightList,selectedTo:this.selectedLeftList}}handleMoveUp(){this.rightList=[...h(this.selectedRightList,this.rightList,!1)]}handleMoveDown(){this.rightList=[...h(this.selectedRightList,this.rightList,!0)]}handleMoveToTop(){const{itemsToKeep:t,itemsToMove:e}=this.getItemsToKeepAndToMove();this.rightList=[...e,...t]}handleMoveToBottom(){const{itemsToKeep:t,itemsToMove:e}=this.getItemsToKeepAndToMove();this.rightList=[...t,...e]}handleSelectLeftItem({detail:t}){this.selectedLeftList=[...t.map((({id:t})=>t))]}handleSelectRightItem({detail:t}){this.selectedRightList=[...t.map((({id:t})=>t))]}getItemsToKeepAndToMove(){return{itemsToKeep:this.rightList.filter((t=>!this.selectedRightList.includes(t.id))),itemsToMove:this.rightList.filter((t=>this.selectedRightList.includes(t.id)))}}async handleTransferToRight(){this.transferToRight(),this.leftFilteredList=[],await this.leftEzListInstance.clearSelection()}async handleTransferToLeft(){this.transferToLeft(),this.rightFilteredList=[],await this.rightEzListInstance.clearSelection()}async clearSelectionAll(){await this.rightEzListInstance.clearSelection(),await this.leftEzListInstance.clearSelection()}handleChooseLeft(){requestAnimationFrame((async()=>{await this.rightEzListInstance.clearSelection()}))}handleChooseRight(){this.useOnlyRightList||requestAnimationFrame((async()=>{await this.leftEzListInstance.clearSelection()}))}renderList(t){const{idSortableList:e,list:s,isFiltering:o,filteredList:l,emptyMessage:n,slotConfig:h,callbacks:r,title:a}=t;return i("ez-sortable-list",{ref:null==r?void 0:r.setRef,title:a,idSortableList:e,emptyMessage:n,class:"ez-size-height--full",dataSource:o?l:s,hoverFeedback:!0,enableMultipleSelection:!0,removeItensMoved:!0,entityLabel:this.entityLabel,entityLabelPlural:this.entityLabelPlural,itemRightSlotBuilder:null==h?void 0:h.itemRightSlotBuilder,itemLeftSlotBuilder:null==h?void 0:h.itemLeftSlotBuilder,onItemsReordered:null==r?void 0:r.onChange.bind(this),onEzSelectItens:null==r?void 0:r.onSelect.bind(this),onEzDoubleClick:null==r?void 0:r.onDoubleClick.bind(this),onEzChoose:null==r?void 0:r.onChoose.bind(this)})}render(){var t,e,o,l,n,h,r,a,d,c;return i(s,null,!this.useOnlyRightList&&i("div",{class:"list__container"},this.leftList&&this.renderList({idSortableList:this.LEFT_LIST_ID,list:this.leftList,title:this.leftTitle,isFiltering:this.isFilteringLeft,filteredList:this.leftFilteredList,emptyMessage:(null===(t=this.emptyMessage)||void 0===t?void 0:t.LEFT_LIST)?this.emptyMessage.LEFT_LIST:this.i18n("ez-double-list.noItemsAvailable",{entity:this.entityLabel}),slotConfig:{itemRightSlotBuilder:null===(o=null===(e=this.slotsListBuilder)||void 0===e?void 0:e.LEFT_LIST)||void 0===o?void 0:o.itemRightSlotBuilder,itemLeftSlotBuilder:null===(n=null===(l=this.slotsListBuilder)||void 0===l?void 0:l.LEFT_LIST)||void 0===n?void 0:n.itemLeftSlotBuilder},callbacks:{setRef:t=>this.leftEzListInstance=t,onChange:t=>this.handleChangeLeft(t),onSelect:this.handleSelectLeftItem.bind(this),onDoubleClick:this.handleTransferToRight.bind(this),onChoose:this.handleChooseLeft.bind(this)}})),!this.useOnlyRightList&&i("div",{class:"actions__column"},i("ez-button",{mode:"icon",iconName:"dual-chevron-right",enabled:this.enableTransferAllToRight(),title:this.i18n("ez-double-list.moveAllTo",{list:this.rightListLabel}),size:"small",onClick:this.handleTransferAllToRight.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-right",enabled:this.enableTransferToRight(),title:this.i18n("ez-double-list.moveTo",{list:this.rightListLabel}),size:"small",onClick:this.handleTransferToRight.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-left",enabled:this.enableTransferToLeft(),title:this.i18n("ez-double-list.moveTo",{list:this.leftListLabel}),size:"small",onClick:this.handleTransferToLeft.bind(this)}),i("ez-button",{mode:"icon",iconName:"dual-chevron-left",enabled:this.enableTransferAllToLeft(),title:this.i18n("ez-double-list.moveAllTo",{list:this.leftListLabel}),size:"small",onClick:this.handleTransferAllToLeft.bind(this)})),i("div",{class:"list__container"},this.rightList&&this.renderList({idSortableList:this.RIGHT_LIST_ID,list:this.rightList,title:this.rightTitle,isFiltering:this.isFilteringRight,filteredList:this.rightFilteredList,emptyMessage:(null===(h=this.emptyMessage)||void 0===h?void 0:h.RIGHT_LIST)?this.emptyMessage.RIGHT_LIST:this.i18n("ez-double-list.noItemsSelected",{entity:this.entityLabel}),slotConfig:{itemRightSlotBuilder:null===(a=null===(r=this.slotsListBuilder)||void 0===r?void 0:r.RIGHT_LIST)||void 0===a?void 0:a.itemRightSlotBuilder,itemLeftSlotBuilder:null===(c=null===(d=this.slotsListBuilder)||void 0===d?void 0:d.RIGHT_LIST)||void 0===c?void 0:c.itemLeftSlotBuilder},callbacks:{setRef:t=>this.rightEzListInstance=t,onChange:t=>this.handleChangeRight(t),onSelect:this.handleSelectRightItem.bind(this),onDoubleClick:this.handleTransferToLeft.bind(this),onChoose:this.handleChooseRight.bind(this)}})),i("div",{class:"actions__column"},i("ez-button",{mode:"icon",iconName:"dual-chevron-up",enabled:this.enableMoveUp(!0),title:this.i18n("ez-double-list.moveToFirstPosition"),size:"small",onClick:this.handleMoveToTop.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-up",enabled:this.enableMoveUp(),title:this.i18n("ez-double-list.moveUp"),size:"small",onClick:this.handleMoveUp.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-down",enabled:this.enableMoveDown(),title:this.i18n("ez-double-list.moveDown"),size:"small",onClick:this.handleMoveDown.bind(this)}),i("ez-button",{mode:"icon",iconName:"dual-chevron-down",enabled:this.enableMoveDown(!0),title:this.i18n("ez-double-list.moveToLastPosition"),size:"small",onClick:this.handleMoveToBottom.bind(this)})))}static get watchers(){return{leftList:["observeLeftList"],rightList:["observeRightList"]}}};c.style='.sc-ez-double-list-h{display:flex;flex-direction:row;gap:8px;align-items:center;font-family:var(--font-pattern, "Roboto");width:100%}@media screen and (max-width: 1366px){.group.sc-ez-double-list{height:350px}}.list__container.sc-ez-double-list{height:100%;width:100%;min-height:150px;overflow:auto;display:flex}.actions__column.sc-ez-double-list{display:flex;flex-direction:column;gap:4px}';export{c as ez_double_list}
1
+ import{r as t,c as e,h as i,H as s}from"./p-23a36bb6.js";import{ObjectUtils as o}from"@sankhyalabs/core";import{i as l}from"./p-80dfc50b.js";import{i as n}from"./p-98218fbc.js";function h(t,e,i){if(!t.length)return[...e];if(!e.length)return[];const s=function(t,e){return t.map((t=>e.findIndex((e=>e.id===t))))}(t,e),o=0===(l=s).length?0:l.reduce(((t,e)=>e<t?e:t),l[0]);var l;const n=function(t){return 0===t.length?0:t.reduce(((t,e)=>e>t?e:t),t[0])}(s);return function(t,e,i,s){return t<0||e>=s.length||t>e?s:i?function(t,e,i){if(t===i.length-1)return i;const s=i.slice(0,e),o=i.slice(e,t+1),l=i.slice(t+1),n=l.shift();return n?[...s,n,...o,...l]:i}(e,t,s):function(t,e,i){if(0===t)return i;const s=i.slice(0,t-1),o=i.slice(t,e+1),l=i.slice(e+1);return[...s,...o,i[t-1],...l]}(t,e,s)}(o,n,i,e)}function r({from:t,to:e,selectedFrom:i,selectedTo:s}){return e=[...e.map((t=>d(t,!1))),...t.map((t=>d(t,!0)))],i=[],s=[...t.map((({id:t})=>t))],{from:t=[],to:e,selectedFrom:i,selectedTo:s}}function a({from:t,to:e,selectedFrom:i,selectedTo:s,insertIndex:o=e.length}){if(!t.length)return{from:t,to:e,selectedFrom:i,selectedTo:s};const l=function(t,e,i){const s=t.map((t=>t.id)),o=e.filter((t=>!s.includes(t)));return i.filter((({id:t})=>o.includes(t)))}(e,i,t);if(!l.length)return{from:t,to:e,selectedFrom:i,selectedTo:s};let n=e.map((t=>d(t,!1)));return n.splice(o,0,...l.map((t=>d(t,!0)))),{from:t.filter((t=>!i.includes(t.id))),to:n,selectedFrom:[],selectedTo:[...i]}}function d(t,e){return Object.assign(Object.assign({},t),{selected:e})}const c=class{constructor(i){t(this,i),this.ezLeftListChanged=e(this,"ezLeftListChanged",7),this.ezRightListChanged=e(this,"ezRightListChanged",7),this.LEFT_LIST_ID="LEFT-LIST-ID",this.RIGHT_LIST_ID="RIGHT-LIST-ID",this.leftList=[],this.leftTitle=void 0,this.rightList=[],this.entityLabel="item",this.entityLabelPlural="itens",this.leftListLabel="disponíveis",this.rightListLabel="selecionados",this.useOnlyRightList=!1,this.rightTitle=void 0,this.emptyMessage=void 0,this.slotsListBuilder=void 0,this.leftFilteredList=[],this.rightFilteredList=[],this.selectedLeftList=[],this.selectedRightList=[],this.isFilteringLeft=!1,this.isFilteringRight=!1}async resetSelectedLists(){this.selectedLeftList=[],this.selectedRightList=[]}observeLeftList(t,e){o.equals(t,e)||this.ezLeftListChanged.emit(t)}observeRightList(t,e){o.equals(t,e)||this.ezRightListChanged.emit(t)}async componentWillLoad(){this.i18n=await n()}async handleChangeLeft({detail:t}){t.to.getAttribute("id")&&t.to.getAttribute("id")===this.RIGHT_LIST_ID?(t.selectItens=t.selectItens.filter((t=>this.rightList.every((e=>e.id!==t)))),this.leftList=[...t.dataSource],this.selectedLeftList=[...t.selectItens],this.transferToRight(null==t?void 0:t.newIndex)):this.leftList=[...this.reorderArray(t.dataSource,t.selectItens,t.newIndex)]}async handleChangeRight({detail:t}){t.to.getAttribute("id")&&t.to.getAttribute("id")===this.LEFT_LIST_ID?(t.selectItens=t.selectItens.filter((t=>this.leftList.every((e=>e.id!==t)))),this.rightList=[...t.dataSource],this.selectedRightList=[...t.selectItens],this.transferToLeft(null==t?void 0:t.newIndex)):this.rightList=[...this.reorderArray(t.dataSource,t.selectItens,t.newIndex)]}reorderArray(t,e,i){const s=t.filter((t=>!e.includes(t.id))),o=t.filter((t=>e.includes(t.id)));return s.splice(i,0,...o),s}enableTransferAllToRight(){return this.leftList.length>0}enableTransferAllToLeft(){return this.rightList.length>0}enableTransferToRight(){return this.selectedLeftList.length>0}enableTransferToLeft(){return this.selectedRightList.length>0}enableMoveUp(t){if(this.isFilteringRight)return!1;const e=this.getRightSelectedItemsIndex();return this.selectedRightList.length>0&&!e.includes(0)&&(!!t||l(e))}enableMoveDown(t){if(this.isFilteringRight)return!1;const e=this.getRightSelectedItemsIndex();return this.selectedRightList.length>0&&!e.includes(this.rightList.length-1)&&(!!t||l(e))}getRightSelectedItemsIndex(){return this.selectedRightList.map((t=>this.rightList.findIndex((e=>e.id===t))))}transferToRight(t){const{from:e,to:i,selectedFrom:s,selectedTo:o}=a(Object.assign(Object.assign({},this.buildTransferToRightConfig()),{insertIndex:null!=t?t:0}));this.leftList=[],requestAnimationFrame((()=>this.leftList=[...e])),this.rightList=[...i],this.selectedLeftList=[...s],this.selectedRightList=[...o]}transferToLeft(t){const{from:e,to:i,selectedFrom:s,selectedTo:o}=a(Object.assign(Object.assign({},this.buildTransferToLeftConfig()),{insertIndex:null!=t?t:0}));this.rightList=[],requestAnimationFrame((()=>this.rightList=[...e])),this.leftList=[...i],this.selectedRightList=[...s],this.selectedLeftList=[...o]}async handleTransferAllToRight(){const{from:t,to:e,selectedFrom:i,selectedTo:s}=r(this.buildTransferToRightConfig());this.leftList=[...t],this.rightList=[...e],this.selectedLeftList=[...i],this.selectedRightList=[...s],requestAnimationFrame((async()=>{await this.clearSelectionAll()}))}async handleTransferAllToLeft(){const{from:t,to:e,selectedFrom:i,selectedTo:s}=r(this.buildTransferToLeftConfig());this.rightList=[...t],this.leftList=[...e],this.selectedRightList=[...i],this.selectedLeftList=[...s],requestAnimationFrame((async()=>{await this.clearSelectionAll()}))}buildTransferToRightConfig(){return{from:this.leftList,to:this.rightList,selectedFrom:this.selectedLeftList,selectedTo:this.selectedRightList}}buildTransferToLeftConfig(){return{from:this.rightList,to:this.leftList,selectedFrom:this.selectedRightList,selectedTo:this.selectedLeftList}}handleMoveUp(){this.rightList=[...h(this.selectedRightList,this.rightList,!1)]}handleMoveDown(){this.rightList=[...h(this.selectedRightList,this.rightList,!0)]}handleMoveToTop(){const{itemsToKeep:t,itemsToMove:e}=this.getItemsToKeepAndToMove();this.rightList=[...e,...t]}handleMoveToBottom(){const{itemsToKeep:t,itemsToMove:e}=this.getItemsToKeepAndToMove();this.rightList=[...t,...e]}handleSelectLeftItem({detail:t}){this.selectedLeftList=[...t.map((({id:t})=>t))]}handleSelectRightItem({detail:t}){this.selectedRightList=[...t.map((({id:t})=>t))]}getItemsToKeepAndToMove(){return{itemsToKeep:this.rightList.filter((t=>!this.selectedRightList.includes(t.id))),itemsToMove:this.rightList.filter((t=>this.selectedRightList.includes(t.id)))}}async handleTransferToRight(){this.transferToRight(),this.leftFilteredList=[],await this.leftEzListInstance.clearSelection()}async handleTransferToLeft(){this.transferToLeft(),this.rightFilteredList=[],await this.rightEzListInstance.clearSelection()}async clearSelectionAll(){await this.rightEzListInstance.clearSelection(),await this.leftEzListInstance.clearSelection()}handleChooseLeft(){requestAnimationFrame((async()=>{await this.rightEzListInstance.clearSelection()}))}handleChooseRight(){this.useOnlyRightList||requestAnimationFrame((async()=>{await this.leftEzListInstance.clearSelection()}))}renderList(t){const{idSortableList:e,list:s,isFiltering:o,filteredList:l,emptyMessage:n,slotConfig:h,callbacks:r,title:a}=t;return i("ez-sortable-list",{ref:null==r?void 0:r.setRef,title:a,idSortableList:e,emptyMessage:n,class:"ez-size-height--full",dataSource:o?l:s,hoverFeedback:!0,enableMultipleSelection:!0,removeItensMoved:!0,entityLabel:this.entityLabel,entityLabelPlural:this.entityLabelPlural,itemRightSlotBuilder:null==h?void 0:h.itemRightSlotBuilder,itemLeftSlotBuilder:null==h?void 0:h.itemLeftSlotBuilder,onItemsReordered:null==r?void 0:r.onChange.bind(this),onEzSelectItens:null==r?void 0:r.onSelect.bind(this),onEzDoubleClick:null==r?void 0:r.onDoubleClick.bind(this),onEzChoose:null==r?void 0:r.onChoose.bind(this)})}render(){var t,e,o,l,n,h,r,a,d,c;return i(s,null,!this.useOnlyRightList&&i("div",{class:"list__container"},this.leftList&&this.renderList({idSortableList:this.LEFT_LIST_ID,list:this.leftList,title:this.leftTitle,isFiltering:this.isFilteringLeft,filteredList:this.leftFilteredList,emptyMessage:(null===(t=this.emptyMessage)||void 0===t?void 0:t.LEFT_LIST)?this.emptyMessage.LEFT_LIST:this.i18n("ez-double-list.noItemsAvailable",{entity:this.entityLabel}),slotConfig:{itemRightSlotBuilder:null===(o=null===(e=this.slotsListBuilder)||void 0===e?void 0:e.LEFT_LIST)||void 0===o?void 0:o.itemRightSlotBuilder,itemLeftSlotBuilder:null===(n=null===(l=this.slotsListBuilder)||void 0===l?void 0:l.LEFT_LIST)||void 0===n?void 0:n.itemLeftSlotBuilder},callbacks:{setRef:t=>this.leftEzListInstance=t,onChange:t=>this.handleChangeLeft(t),onSelect:this.handleSelectLeftItem.bind(this),onDoubleClick:this.handleTransferToRight.bind(this),onChoose:this.handleChooseLeft.bind(this)}})),!this.useOnlyRightList&&i("div",{class:"actions__column"},i("ez-button",{mode:"icon",iconName:"dual-chevron-right",enabled:this.enableTransferAllToRight(),title:this.i18n("ez-double-list.moveAllTo",{list:this.rightListLabel}),size:"small",onClick:this.handleTransferAllToRight.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-right",enabled:this.enableTransferToRight(),title:this.i18n("ez-double-list.moveTo",{list:this.rightListLabel}),size:"small",onClick:this.handleTransferToRight.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-left",enabled:this.enableTransferToLeft(),title:this.i18n("ez-double-list.moveTo",{list:this.leftListLabel}),size:"small",onClick:this.handleTransferToLeft.bind(this)}),i("ez-button",{mode:"icon",iconName:"dual-chevron-left",enabled:this.enableTransferAllToLeft(),title:this.i18n("ez-double-list.moveAllTo",{list:this.leftListLabel}),size:"small",onClick:this.handleTransferAllToLeft.bind(this)})),i("div",{class:"list__container"},this.rightList&&this.renderList({idSortableList:this.RIGHT_LIST_ID,list:this.rightList,title:this.rightTitle,isFiltering:this.isFilteringRight,filteredList:this.rightFilteredList,emptyMessage:(null===(h=this.emptyMessage)||void 0===h?void 0:h.RIGHT_LIST)?this.emptyMessage.RIGHT_LIST:this.i18n("ez-double-list.noItemsSelected",{entity:this.entityLabel}),slotConfig:{itemRightSlotBuilder:null===(a=null===(r=this.slotsListBuilder)||void 0===r?void 0:r.RIGHT_LIST)||void 0===a?void 0:a.itemRightSlotBuilder,itemLeftSlotBuilder:null===(c=null===(d=this.slotsListBuilder)||void 0===d?void 0:d.RIGHT_LIST)||void 0===c?void 0:c.itemLeftSlotBuilder},callbacks:{setRef:t=>this.rightEzListInstance=t,onChange:t=>this.handleChangeRight(t),onSelect:this.handleSelectRightItem.bind(this),onDoubleClick:this.handleTransferToLeft.bind(this),onChoose:this.handleChooseRight.bind(this)}})),i("div",{class:"actions__column"},i("ez-button",{mode:"icon",iconName:"dual-chevron-up",enabled:this.enableMoveUp(!0),title:this.i18n("ez-double-list.moveToFirstPosition"),size:"small",onClick:this.handleMoveToTop.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-up",enabled:this.enableMoveUp(),title:this.i18n("ez-double-list.moveUp"),size:"small",onClick:this.handleMoveUp.bind(this)}),i("ez-button",{mode:"icon",iconName:"chevron-down",enabled:this.enableMoveDown(),title:this.i18n("ez-double-list.moveDown"),size:"small",onClick:this.handleMoveDown.bind(this)}),i("ez-button",{mode:"icon",iconName:"dual-chevron-down",enabled:this.enableMoveDown(!0),title:this.i18n("ez-double-list.moveToLastPosition"),size:"small",onClick:this.handleMoveToBottom.bind(this)})))}static get watchers(){return{leftList:["observeLeftList"],rightList:["observeRightList"]}}};c.style='.sc-ez-double-list-h{display:flex;flex-direction:row;gap:8px;align-items:center;font-family:var(--font-pattern, "Roboto");width:100%}@media screen and (max-width: 1366px){.group.sc-ez-double-list{height:350px}}.list__container.sc-ez-double-list{height:100%;width:100%;min-height:150px;overflow:auto;display:flex}.actions__column.sc-ez-double-list{display:flex;flex-direction:column;gap:4px}';export{c as ez_double_list}
@@ -1 +1 @@
1
- import{r as t,h as e,H as i,g as n}from"./p-23a36bb6.js";import{FloatingManager as a,ElementIDUtils as o}from"@sankhyalabs/core";import{i as l}from"./p-641ee538.js";const r=class{constructor(e){t(this,e),this._container=void 0,this.alerts=[],this.enableDragAndDrop=void 0,this.enableExpand=!0,this.itemRightSlotBuilder=void 0,this.opened=!0,this.expanded=!1}observeOpened(){this.opened&&this.manageOverlay()}alertId(t,e){return`alert-${e}-${(t=>{var e;return null!==(e=null==t?void 0:t.split(" ").join("-"))&&void 0!==e?e:""})(t)}`}getAlertTitle(t){var e;return null===(e=this.alerts.find(((e,i)=>this.alertId(e.title,i)===t)))||void 0===e?void 0:e.title}getLinkActionClick(t){var e;return(null===(e=this.alerts.find(((e,i)=>this.alertId(e.title,i)===t.id)))||void 0===e?void 0:e.onClickLink)||(()=>{})}getTitleText(t){var e;const i=null!==(e=this.getAlertTitle(t.id))&&void 0!==e?e:"";return`${i}${i&&t.label?":":""}`}toggleExpandContainer(){this.enableExpand&&(this.expanded=!this.expanded,this._container.classList.toggle("expanded",this.expanded),this.expanded?this.updatePosition(this.getBoundingRight(),this.getBoundingBottom()):this.updatePosition("10px","10px"))}manageOverlay(){if(this.opened&&this._container)this._overlayId=a.float(this._container,this._overlayRef,this.getFloatOptions());else{if(void 0===this._overlayId)return;a.close(this._overlayId),this._overlayId=void 0}}updatePosition(t,e){this.opened&&a.updateFloatPosition(this._container,this._overlayRef,Object.assign(Object.assign({},this.getFloatOptions()),{right:t,bottom:e}))}getFloatOptions(){return{autoClose:!1,isFixed:!0,bottom:"10px",right:"10px"}}getBoundingRight(){return(document.body.clientWidth-this._container.getBoundingClientRect().width)/2+"px"}getBoundingBottom(){return(document.body.clientHeight-this._container.getBoundingClientRect().height)/2+"px"}componentDidLoad(){this.manageOverlay(),this.opened&&this._container&&this._container.focus()}async componentWillLoad(){this.dataElementId=o.addIDInfo(this._element,"EzAlertList"),this.i18n=await l()}render(){return e(i,Object.assign({},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:this.dataElementId}),this.opened?e("div",{ref:t=>this._overlayRef=t},e("div",{class:"alert-list__container "+(this.expanded?"expanded":""),ref:t=>this._container=t},e("div",{class:"alert-list__content"},e("div",{class:"alert-list__header"},e("div",{class:"alert-list__title"},`${this.i18n("app.alerts")} (${this.alerts.length})`),e("div",{class:"alert-list__header__buttons"},this.enableExpand&&e("ez-button",{mode:"icon",size:"small",iconName:"expand",onClick:()=>this.toggleExpandContainer(),"data-element-id":o.getInternalIDInfo("expandButton"),title:this.i18n(this.expanded?"app.collapse":"app.expand")}),e("ez-button",{mode:"icon",size:"small",iconName:"close","data-element-id":o.getInternalIDInfo("closeButton"),onClick:()=>{this.opened=!1},title:this.i18n("app.close")}))),e("div",{class:"alert-list__expandable-content"},e("ez-list",{itemSlotBuilder:this.itemRightSlotBuilder,hoverFeedback:!0,itemLeftSlotBuilder:t=>e("a",{onClick:this.getLinkActionClick(t),style:{fontFamily:"var(--font-pattern, 'Roboto')",fontSize:"var(--text--medium, 14px)",fontWeight:"var(--text-weight--medium, 400)",color:"var(--color--primary, #008561)",marginRight:"4px",cursor:"pointer",display:"flex",width:"max-content",textDecoration:"none"}},this.getTitleText(t)),dataSource:this.alerts.map(((t,e)=>{var i;return{id:this.alertId(t.title,e),label:null!==(i=t.detail)&&void 0!==i?i:""}}))}))))):null)}get _element(){return n(this)}static get watchers(){return{_container:["observeOpened"]}}};r.style=':host {\n display: flex;\n\n /* Alert List */\n \n /*@doc Define a largura da lista minimizado */\n --ez-alert-list__container--width: 680px;\n /*@doc Define a altura da lista minimizado */\n --ez-alert-list__container--height: 220px;\n \n /*@doc Define a largura da lista maximizada */\n --ez-alert-list__container--width--expanded: 920px;\n /*@doc Define a altura da lista maximizada */\n --ez-alert-list__container--height--expanded: 540px;\n\n /* Title */\n /*@doc Define a fonte do título do componente */\n --ez-alert-list__title--font-family: var(--font-pattern, "Roboto");\n /*@doc Define o tamanho da fonte do título do popup.*/\n --ez-alert-list__title--font-size: var(--title--large, 20px);\n /*@doc Define a cor da fonte do título do popup.*/\n --ez-alert-list__title--color: var(--title--primary, #2b3a54);\n /*@doc Define o peso da fonte do título do popup.*/\n --ez-alert-list__title--font-weight: var(--text-weight--extra-large, 700);\n\n /* @doc Define a borda inferior do item da lista. */\n --ez-list__item--border-bottom: var(--border--small, 1px solid);\n\n /* @doc Define a cor da borda inferior do item da lista. */\n --ez-list__item--border-bottom-color: var(--color--strokes, #DCE0E8);\n\n /* @doc Define o tipo da quebra de linha do item da lista. */\n --ez-list__item--white-space: break-space;\n}\n\n.alert-list__content {\n display: flex;\n flex-direction: column;\n \n gap: var(--space--xs);\n margin: var(--space--large, 24px);\n width: 100%;\n}\n\n.alert-list__container {\n z-index: var(--ez-elevation--8, 8);\n display: flex;\n height: var(--ez-alert-list__container--height);\n width: var(--ez-alert-list__container--width);\n border-radius: var(--border--radius-medium);\n background-color: var(--background--xlight);\n box-shadow: var(--shadow--medium);\n\n &.expanded {\n height: var(--ez-alert-list__container--height--expanded);\n width: var(--ez-alert-list__container--width--expanded);\n }\n\n @media (max-height: 640px) {\n max-height: calc(100vh - var(--space--3xl));\n } \n}\n\n.alert-list__header {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.alert-list__title {\n font-family: var(--ez-alert-list__title--font-family);\n font-size: var(--ez-alert-list__title--font-size);\n font-weight: var(--ez-alert-list__title--font-weight);\n color: var(--ez-alert-list__title--color);\n}\n\n.alert-list__header__buttons {\n display: flex;\n gap: var(--space--xs);\n}\n\n.alert-list__expandable-content {\n overflow-y: auto;\n scrollbar-width: thin;\n}\n\n';export{r as ez_alert_list}
1
+ import{r as t,h as e,H as i,g as n}from"./p-23a36bb6.js";import{FloatingManager as a,ElementIDUtils as o}from"@sankhyalabs/core";import{i as l}from"./p-98218fbc.js";const r=class{constructor(e){t(this,e),this._container=void 0,this.alerts=[],this.enableDragAndDrop=void 0,this.enableExpand=!0,this.itemRightSlotBuilder=void 0,this.opened=!0,this.expanded=!1}observeOpened(){this.opened&&this.manageOverlay()}alertId(t,e){return`alert-${e}-${(t=>{var e;return null!==(e=null==t?void 0:t.split(" ").join("-"))&&void 0!==e?e:""})(t)}`}getAlertTitle(t){var e;return null===(e=this.alerts.find(((e,i)=>this.alertId(e.title,i)===t)))||void 0===e?void 0:e.title}getLinkActionClick(t){var e;return(null===(e=this.alerts.find(((e,i)=>this.alertId(e.title,i)===t.id)))||void 0===e?void 0:e.onClickLink)||(()=>{})}getTitleText(t){var e;const i=null!==(e=this.getAlertTitle(t.id))&&void 0!==e?e:"";return`${i}${i&&t.label?":":""}`}toggleExpandContainer(){this.enableExpand&&(this.expanded=!this.expanded,this._container.classList.toggle("expanded",this.expanded),this.expanded?this.updatePosition(this.getBoundingRight(),this.getBoundingBottom()):this.updatePosition("10px","10px"))}manageOverlay(){if(this.opened&&this._container)this._overlayId=a.float(this._container,this._overlayRef,this.getFloatOptions());else{if(void 0===this._overlayId)return;a.close(this._overlayId),this._overlayId=void 0}}updatePosition(t,e){this.opened&&a.updateFloatPosition(this._container,this._overlayRef,Object.assign(Object.assign({},this.getFloatOptions()),{right:t,bottom:e}))}getFloatOptions(){return{autoClose:!1,isFixed:!0,bottom:"10px",right:"10px"}}getBoundingRight(){return(document.body.clientWidth-this._container.getBoundingClientRect().width)/2+"px"}getBoundingBottom(){return(document.body.clientHeight-this._container.getBoundingClientRect().height)/2+"px"}componentDidLoad(){this.manageOverlay(),this.opened&&this._container&&this._container.focus()}async componentWillLoad(){this.dataElementId=o.addIDInfo(this._element,"EzAlertList"),this.i18n=await l()}render(){return e(i,Object.assign({},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:this.dataElementId}),this.opened?e("div",{ref:t=>this._overlayRef=t},e("div",{class:"alert-list__container "+(this.expanded?"expanded":""),ref:t=>this._container=t},e("div",{class:"alert-list__content"},e("div",{class:"alert-list__header"},e("div",{class:"alert-list__title"},`${this.i18n("app.alerts")} (${this.alerts.length})`),e("div",{class:"alert-list__header__buttons"},this.enableExpand&&e("ez-button",{mode:"icon",size:"small",iconName:"expand",onClick:()=>this.toggleExpandContainer(),"data-element-id":o.getInternalIDInfo("expandButton"),title:this.i18n(this.expanded?"app.collapse":"app.expand")}),e("ez-button",{mode:"icon",size:"small",iconName:"close","data-element-id":o.getInternalIDInfo("closeButton"),onClick:()=>{this.opened=!1},title:this.i18n("app.close")}))),e("div",{class:"alert-list__expandable-content"},e("ez-list",{itemSlotBuilder:this.itemRightSlotBuilder,hoverFeedback:!0,itemLeftSlotBuilder:t=>e("a",{onClick:this.getLinkActionClick(t),style:{fontFamily:"var(--font-pattern, 'Roboto')",fontSize:"var(--text--medium, 14px)",fontWeight:"var(--text-weight--medium, 400)",color:"var(--color--primary, #008561)",marginRight:"4px",cursor:"pointer",display:"flex",width:"max-content",textDecoration:"none"}},this.getTitleText(t)),dataSource:this.alerts.map(((t,e)=>{var i;return{id:this.alertId(t.title,e),label:null!==(i=t.detail)&&void 0!==i?i:""}}))}))))):null)}get _element(){return n(this)}static get watchers(){return{_container:["observeOpened"]}}};r.style=':host {\n display: flex;\n\n /* Alert List */\n \n /*@doc Define a largura da lista minimizado */\n --ez-alert-list__container--width: 680px;\n /*@doc Define a altura da lista minimizado */\n --ez-alert-list__container--height: 220px;\n \n /*@doc Define a largura da lista maximizada */\n --ez-alert-list__container--width--expanded: 920px;\n /*@doc Define a altura da lista maximizada */\n --ez-alert-list__container--height--expanded: 540px;\n\n /* Title */\n /*@doc Define a fonte do título do componente */\n --ez-alert-list__title--font-family: var(--font-pattern, "Roboto");\n /*@doc Define o tamanho da fonte do título do popup.*/\n --ez-alert-list__title--font-size: var(--title--large, 20px);\n /*@doc Define a cor da fonte do título do popup.*/\n --ez-alert-list__title--color: var(--title--primary, #2b3a54);\n /*@doc Define o peso da fonte do título do popup.*/\n --ez-alert-list__title--font-weight: var(--text-weight--extra-large, 700);\n\n /* @doc Define a borda inferior do item da lista. */\n --ez-list__item--border-bottom: var(--border--small, 1px solid);\n\n /* @doc Define a cor da borda inferior do item da lista. */\n --ez-list__item--border-bottom-color: var(--color--strokes, #DCE0E8);\n\n /* @doc Define o tipo da quebra de linha do item da lista. */\n --ez-list__item--white-space: break-space;\n}\n\n.alert-list__content {\n display: flex;\n flex-direction: column;\n \n gap: var(--space--xs);\n margin: var(--space--large, 24px);\n width: 100%;\n}\n\n.alert-list__container {\n z-index: var(--ez-elevation--8, 8);\n display: flex;\n height: var(--ez-alert-list__container--height);\n width: var(--ez-alert-list__container--width);\n border-radius: var(--border--radius-medium);\n background-color: var(--background--xlight);\n box-shadow: var(--shadow--medium);\n\n &.expanded {\n height: var(--ez-alert-list__container--height--expanded);\n width: var(--ez-alert-list__container--width--expanded);\n }\n\n @media (max-height: 640px) {\n max-height: calc(100vh - var(--space--3xl));\n } \n}\n\n.alert-list__header {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.alert-list__title {\n font-family: var(--ez-alert-list__title--font-family);\n font-size: var(--ez-alert-list__title--font-size);\n font-weight: var(--ez-alert-list__title--font-weight);\n color: var(--ez-alert-list__title--color);\n}\n\n.alert-list__header__buttons {\n display: flex;\n gap: var(--space--xs);\n}\n\n.alert-list__expandable-content {\n overflow-y: auto;\n scrollbar-width: thin;\n}\n\n';export{r as ez_alert_list}
@@ -1 +1 @@
1
- import{h as e,r as t,c as i,f as r,H as s,g as o}from"./p-23a36bb6.js";import{ElementIDUtils as n,StringUtils as l,ObjectUtils as a}from"@sankhyalabs/core";import{i as h}from"./p-641ee538.js";const c=(e,t)=>t?e.iconExpanded||"chevron-down":e.iconContracted||"chevron-right",d=e=>e.tooltip||e.label,u=t=>{const{node:i,selectedId:r,itemClick:s,iconClick:o,iconResolver:l,tooltipResolver:a,itemsList:h,itemDoubleClick:c}=t;if(!i.visible)return;const d=i.item,v=t.level||1,m=i.isDisabled(),b=!m&&d.expanded,g=i.isExpandable(),f=!m&&!i.isPlaceHolder;return f&&h.push(d),e("ul",{class:1===v?"first-level":void 0},e("li",Object.assign({title:a(d,!m,v),class:"tree-item "+(d.id!==r?"tree-item-error":""),onClick:()=>f&&s(d),onDblClick:()=>f&&c(d)},{disabled:m,selected:d.id===r,[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:n.getInternalIDInfo(`ezTreeItem_${d.id}`)}),e("div",{class:"item-label-container"},e("div",{class:"item-icon-box"},g&&e("ez-icon",{id:d.id,class:"item-icon",size:"small",iconName:l(d,b,v),onClick:e=>function(e){e.stopPropagation(),f&&o(d)}(e),onDblClick:e=>function(e){e.stopPropagation()}(e)})),e("label",{class:"item-label "+(d.bold?"item-label--bold":"")},d.label)),function(t,i,r){if(null!=i)return"string"==typeof i?e("div",{class:`tree-item-badge ${r?null:i}`},"error"===i&&e("ez-icon",{id:`${t}-badge-error`,class:"tree-item-badge-error-icon",size:"x-small",style:{color:"white"},iconName:"alert-circle"})):"text"===i.type?e("div",{id:`${t}-badge-text`,class:"tree-item-badge-text"},i.text):e("div",null,e("ez-icon",{id:`${t}-badge-icon`,class:"tree-item-badge-icon",style:{"--ez-icon--color":`var(--ez-tree__badge--icon-color--${i.iconColor||"default"})`},iconName:i.iconName}))}(d.id,d.badge,d.id===r)),b&&i.getChildren().map((t=>e(u,{selectedId:r,node:t,itemClick:s,iconClick:o,level:v+1,iconResolver:l,tooltipResolver:a,itemsList:h,itemDoubleClick:c}))))};class v{constructor(e,t,i,r=!1){this.children=new Map,this.visible=!0,this.item=t,this.parent=i,this._tree=e,this.isPlaceHolder=r,t&&!r?(this._isLazyLoad="function"==typeof t.children||t.childrenCount>0,Array.isArray(t.children)&&(Array.from(t.children).forEach((e=>this.addChild(this._tree,e))),this._childrenLoaded=!0)):(this._isLazyLoad=!1,this._childrenLoaded=!0)}refresh(e){if(this.isPlaceHolder)return;this.item=Object.assign({},e),this._isLazyLoad="function"==typeof this.item.children||this.item.childrenCount>0;const t=this.children;this.children=new Map,Array.isArray(this.item.children)?(void 0===this.item.expanded&&(this.item.expanded=!0),Array.from(this.item.children).forEach((e=>{const i=t.get(e.id);i?(void 0===e.expanded&&(e.expanded=i.item.expanded),i.refresh(e),this.children.set(e.id,i)):(void 0===e.expanded&&(e.expanded=!0),this.addChild(this._tree,Object.assign({},e)))})),this._childrenLoaded=!0):this._childrenLoaded=!1}isDisabled(){return!this.isPlaceHolder&&this._tree.isNodeDisabled(this.item.id,this.item.disabled)}updateChildren(e){this.isPlaceHolder||this.refresh(Object.assign(Object.assign({},this.item),{children:e}))}addChild(e,t){this.children.has(t.id)||this.children.set(t.id,new v(e,t,this))}removeChild(e){return!!this.children.has(e)&&(this.children.delete(e),!0)}addPlaceHolder(){this.children.clear();const e=this.item.id;this.children.set(e,new v(void 0,{id:`placeholder_${e}`,label:"Carregando..."},this,!0))}getNode(e){if(this.children.has(e))return this.children.get(e);const t=Array.from(this.children.values());for(const i of t){const t=i.getNode(e);if(t)return t}}needLoad(){return this._isLazyLoad&&!this._childrenLoaded}isExpandable(){return!!this._isLazyLoad||this.children.size>0}getChildren(){return this.isPlaceHolder?[]:(this.needLoad()&&this._tree.loadChildren(this),Array.from(this.children.values()))}}class m extends v{constructor(e){super(void 0),this._disabledValues=new Map,this._changeCallback=e}async addChildAt(e,t){const i=this.getNode(e);if(null==i)return this.addChild(this,t),void this._changeCallback();i.addChild(this,t),this._changeCallback()}setDisabled(e,t){this._disabledValues.set(e,t),this._changeCallback()}isNodeDisabled(e,t){return this._disabledValues.has(e)?this._disabledValues.get(e):t}load(e){if(e===this._currentItems)return;this._currentItems=e;const t=this.children;this.children=new Map,this._disabledValues.clear(),e.forEach((e=>{const i=t.get(e.id);i?(i.refresh(e),this.children.set(e.id,i)):this.addChild(this,Object.assign({},e))}))}async setFilterPattern(e,t=!0){if(e&&t&&e.includes(".")){const t=e.split(".").map((e=>l.replaceAccentuatedCharsKeepSymbols(e.trim())));await this.applyLayeredFilter(this,t,0)}else this._filterPattern=l.replaceAccentuatedCharsKeepSymbols(e),this.setAllChildrenExpanded(this,!1),this.applyFilter(this);this._changeCallback()}updateItem(e){if(null==e)return;const t=this.getNode(e.id);null!=t&&(Object.keys(e).forEach((i=>t.item[i]=e[i])),null==e.children?t.children.clear():Array.isArray(e.children)&&t.updateChildren(e.children),this._changeCallback())}removeItem(e){if(!e)return;const t=this.getNode(e);t&&(t.parent?t.parent.removeChild(e):this.children.delete(e),this._disabledValues.delete(e),this._changeCallback())}async open(e){return new Promise((async t=>{await this.walkPath(this,e,(e=>e.item.expanded=!0)),t()}))}setAllChildrenVisible(e){e.children.forEach((e=>{e.visible=!0,this.setAllChildrenVisible(e)}))}applyFilter(e){if(!this._filterPattern)return e.visible=!0,void this.setAllChildrenVisible(e);if(e.children.forEach((e=>{this.applyFilter(e)})),null==e.item)return;let t=!1;if(l.replaceAccentuatedCharsKeepSymbols(e.item.label).includes(this._filterPattern))t=!0,e.item.expanded=!0,this.setAllChildrenVisible(e);else{const i=Array.from(e.children.values());for(let r=0;r<i.length;r++)if(i[r].visible){t=!0,e.item.expanded=!0;break}}e.visible=t}async applyLayeredFilter(e,t,i){if(!e.item){const r=(await Promise.all(Array.from(e.children.values()).map((e=>this.applyLayeredFilter(e,t,i))))).some(Boolean);return e.visible=r,r}if(!l.replaceAccentuatedCharsKeepSymbols(e.item.label).includes(t[i])){const r=(await Promise.all(Array.from(e.children.values()).map((e=>this.applyLayeredFilter(e,t,i))))).some(Boolean);return r&&(e.item.expanded=!0),e.visible=r,r}if(i===t.length-1)return e.visible=!0,this.setAllChildrenVisible(e),!0;const r=(await Promise.all(Array.from(e.children.values()).map((e=>this.applyLayeredFilter(e,t,i+1))))).some(Boolean);return r&&(e.item.expanded=!0),e.visible=r,r}async walkPath(e,t,i,r=0){return new Promise((async s=>{const o=t.split(">>").map((e=>e.trim()));if(o.length>r){const s=e.getNode(o[r]);s&&(s.needLoad()&&await this.loadLevel(s),i(s),await this.walkPath(s,t,i,r+1))}s()}))}async loadChildren(e){return new Promise((t=>{this.loadLevel(e).then((()=>{t(),this._changeCallback()}))}))}expandAll(){this.setAllChildrenExpanded(this,!0),this._changeCallback()}collapseAll(){this.setAllChildrenExpanded(this,!1),this._changeCallback()}setAllChildrenExpanded(e,t){e.item&&!e.isPlaceHolder&&(e.item.expanded=t),e.children.forEach((e=>{this.setAllChildrenExpanded(e,t)}))}async loadLevel(e){return new Promise((t=>{e.addPlaceHolder(),(0,e.item.children)(e.item).then((i=>{e.updateChildren(i),t()}))}))}}const b=class{constructor(e){t(this,e),this.ezChange=i(this,"ezChange",7),this.ezOpenItem=i(this,"ezOpenItem",7),this.ezDbClickItem=i(this,"ezDbClickItem",7),this.ezRemoveItem=i(this,"ezRemoveItem",7),this._onItemClick=e=>{this.selectable?this.value=this.value&&this.value.id===e.id?void 0:e:this.openClose(e)},this._onIconClick=e=>{this.openClose(e)},this._tree=new m((()=>r(this))),this._waintingForLoad=void 0,this.items=[],this.value=void 0,this.selectedId=void 0,this.iconResolver=c,this.tooltipResolver=void 0,this.enableHierarchicalFilter=!0,this.selectable=!0}async selectItem(e){const t=this._tree.getNode(e);this.value=t?t.item:void 0}async openItem(e){this._waintingForLoad=!0,await this._tree.open(e),this._waintingForLoad=!1}async disableItem(e){[].concat(e).forEach((e=>this._tree.setDisabled(e,!0)))}async enableItem(e){[].concat(e).forEach((e=>this._tree.setDisabled(e,!1)))}async addChild(e,t){var i;null==t&&(t=null===(i=this.value)||void 0===i?void 0:i.id),this._tree.addChildAt(t,e),this.addItemInIndexedList(t,e);const r=this._tree.getNode(t);r?r.item.expanded=!0:this.collapseAll()}async applyFilter(e){await this._tree.setFilterPattern(e,this.enableHierarchicalFilter)}async expandAll(){this._tree.expandAll()}async collapseAll(){this._tree.collapseAll()}async updateItem(e,t){var i,r,s;if(Array.isArray(e))return void e.forEach((e=>this.updateItem(e,t)));if((null==t?void 0:t.updatedBySelectedId)&&Object.assign(e,{id:this.selectedId}),this._tree.updateItem((null==t?void 0:t.forceDefaultValues)?this.applyDefaultValues(e):e),this.updateItemInIndexedList(e,null==t?void 0:t.forceDefaultValues),null==(null===(i=this._tree)||void 0===i?void 0:i.getNode(this.selectedId))&&(this.value=this._visibleItems?this._visibleItems[0]:void 0,this._tree.collapseAll()),(null===(r=this.value)||void 0===r?void 0:r.id)===e.id)return this.value=e,void this.ezChange.emit(this.value);const o=this.getItemById(null===(s=this.value)||void 0===s?void 0:s.id,[e]);o&&(this.value=o,this.ezChange.emit(this.value))}async removeItem(e){var t;(e=null!=e?e:this.selectedId)&&(this._tree.removeItem(e),this.removeItemFromIndexedList(e),this.ezRemoveItem.emit(e),(null===(t=this.value)||void 0===t?void 0:t.id)===e&&(this.value=void 0))}async getItem(e){return new Promise((t=>{const i=this._tree.getNode(e);t(null==i?void 0:i.item)}))}async getCurrentPath(){var e,t,i;const r=null===(e=this._tree)||void 0===e?void 0:e.getNode(this.selectedId);if(null==r)return;const s=[];let o,n=null===(t=r.parent)||void 0===t?void 0:t.item;for(s.push(this.getItemPathAttrs(r.item));null!=n;)s.unshift(this.getItemPathAttrs(n)),o=this._tree.getNode(n.id),n=null===(i=null==o?void 0:o.parent)||void 0===i?void 0:i.item;return s}async getParent(e){return new Promise((t=>{var i;const r=this._tree.getNode(e);r&&t(null===(i=r.parent)||void 0===i?void 0:i.item),t(void 0)}))}observeItems(e,t){a.objectToString(e)!==a.objectToString(t)&&this._tree.load(this.items||[])}observeValue(){var e;this.ezChange.emit(this.value),this.selectedId=null===(e=this.value)||void 0===e?void 0:e.id}onKeyDownListener(e){if(!this.value)return;let t=!1;switch(e.key){case"ArrowUp":this.previousItem(),t=!0;break;case"ArrowDown":this.nextItem(),t=!0;break;case"ArrowLeft":this.previousLevel(),t=!0;break;case"ArrowRight":this.nextLevel(),t=!0;break;case" ":this.openClose(this.value),t=!0}t&&(e.stopPropagation(),e.preventDefault())}getItemById(e,t){for(const i of t){if(i.id===e)return i;if(i.children&&Array.isArray(i.children)){const t=this.getItemById(e,i.children);if(t)return t}}}addItemInIndexedList(e,t,i){var r,s;i=null!==(r=null!=i?i:this.items)&&void 0!==r?r:[],e||i.push(t);const o=this.getItemById(e,i);o.children=null!==(s=o.children)&&void 0!==s?s:[],o.children.push(t),o.childrenCount=o.children.length}applyDefaultValues(e){return void 0===e.disabled&&(e.disabled=!1),void 0===e.expanded&&(e.expanded=!1),e}updateItemInIndexedList(e,t=!1){if(!e||!this.items)return;const i=this.getItemById(e.id,this.items);i&&Object.assign(i,t?this.applyDefaultValues(e):e)}removeItemFromIndexedList(e,t){var i;if(t=null!==(i=null!=t?t:this.items)&&void 0!==i?i:[],!e)return!1;const r=t.findIndex((t=>t.id===e));if(-1!==r)return t.splice(r,1),!0;for(const i of t)if(i.children&&Array.isArray(i.children)){const t=i.children.findIndex((t=>t.id===e));if(-1!==t)return i.children.splice(t,1),i.childrenCount=i.children.length,!0;if(this.removeItemFromIndexedList(e,i.children))return!0}return!1}getItemPathAttrs({id:e,label:t}){return{id:e,label:t}}openClose(e){if(null==e)return;const t=!e.expanded;e.expanded=t,t&&this.ezOpenItem.emit(e),this._tree.updateItem(e)}previousLevel(){var e;if(this.value)if(this.value.expanded)this.value.expanded=!1,this._tree.updateItem(this.value);else{const t=null===(e=this._tree.getNode(this.value.id).parent)||void 0===e?void 0:e.item;t&&(this.value=t)}}nextLevel(){this.value&&this._tree.getNode(this.value.id).isExpandable()&&(this.value.expanded?this.nextItem():(this.value.expanded=!0,this._tree.updateItem(this.value)))}indexOf(e){if(null==e)return-1;for(let t=0;t<this._visibleItems.length;t++)if(this._visibleItems[t].id===e)return t;return-1}selectNextItem(e){var t;const i=this.indexOf(null===(t=this.value)||void 0===t?void 0:t.id)+e;i>-1&&i<this._visibleItems.length&&(this.value=this._visibleItems[i])}nextItem(){this.selectNextItem(1)}previousItem(){this.selectNextItem(-1)}connectedCallback(){this.items&&this._tree.load(this.items)}async componentWillLoad(){this.i18n=await h()}componentWillRender(){var e;if(!this.selectedId||(null===(e=this.value)||void 0===e?void 0:e.id)===this.selectedId)return;const t=this._tree.getNode(this.selectedId);t&&(this.value=t.item)}render(){if(n.addIDInfoIfNotExists(this._element,"ezTree"),null!=this.items)return this._visibleItems=[],e(s,{tabindex:"-1"},this._waintingForLoad?e("label",null,this.i18n("app.loading"),"..."):this._tree.getChildren().map((t=>{var i;return e(u,{selectedId:null===(i=this.value)||void 0===i?void 0:i.id,node:t,itemClick:this._onItemClick,iconClick:this._onIconClick,iconResolver:this.iconResolver,tooltipResolver:this.tooltipResolver||d,itemsList:this._visibleItems,itemDoubleClick:e=>this.ezDbClickItem.emit(e)})})))}get _element(){return o(this)}static get watchers(){return{items:["observeItems"],value:["observeValue"]}}};b.style=":host{--ez-tree--border-radius:var(--border--radius-small, 8px);--ez-tree--padding-inline-start:20px;--ez-tree--margin:var(--space--extra-small, 3px);--ez-tree--margin-right:0px;--ez-tree--user-select:auto;--ez-tree--font-family:var(--font-pattern, Arial);--ez-tree--font-size:var(--text--medium, 14px);--ez-tree--selected--font-weight:var(--text-weight--large, 600);--ez-tree--font-weight:var(--text-weight--small, 400);--ez-tree--color:var(--title--primary, #2B3A54);--ez-tree--selected--color:var(--color--primary, #008561);--ez-tree--disabled--color:var(--text--disable, #AFB6C0);--ez-tree--font-weight--bold:var(--text-weight--large, 600);--ez-tree__tree-item--height:var(--size-medium, 18px);--ez-tree__tree-item--padding:var(--space--small, 6px);--ez-tree__tree-item--background-color:var(--background--xlight, #FFFFFF);--ez-tree__tree-item--selected--background-color:var(--color--primary-300, #E2F4EF);--ez-tree__tree-item--hover--background-color:var(--background--medium, #F0F3F7);--ez-tree__tree-item--disabled--background-color:var(--ez-tree__tree-Item--background-color);--ez-tree__item-icon-box--height:var(--ez-tree__tree-item--height);--ez-tree__item-icon-box--width:var(--size-medium, 18px);--ez-tree__item-icon-box--padding:var(--ez-tree__tree-item--padding);--ez-tree__badge--icon-color--default:var(--title--primary, #2B3A54);--ez-tree__badge--icon-color--error:var(--color--error, #da4453);--ez-tree__badge--icon-color--success:var(--color-alert--success-800, #157a00);--ez-tree__badge--icon-color--warning:var(--color--warning, #f2d410);--ez-tree__badge--icon-color--disabled:var(--text--disable, #AFB6C0);display:flex;flex-direction:column;margin:0 var(--ez-tree--margin) var(--ez-tree--margin) var(--ez-tree--margin);outline:none}ul{list-style-type:none;margin:0;cursor:default;padding-inline-start:var(--ez-tree--padding-inline-start)}ul.first-level{padding-inline-start:0}.tree-item-badge{width:16px;height:16px;background:transparent;border-radius:50%;transition:all 300ms ease-in-out;display:flex;align-items:center;justify-content:center}.tree-item-badge-error-icon{--ez-icon--color:white}.tree-item-badge-text{font-family:var(--ez-tree--font-family);font-size:var(--ez-tree--font-size);font-weight:var(--ez-tree--font-weight);color:var(--ez-tree--color)}.tree-item-badge.error{background:var(--color--error)}.tree-item-badge.warning{background:var(--color--warning)}.tree-item-badge.success{background:var(--color--success)}.item-label-container{display:flex;align-items:center;overflow:hidden}.tree-item{display:flex;align-items:center;cursor:pointer;margin-top:var(--ez-tree--margin);margin-right:var(--ez-tree--margin-right);border-radius:var(--ez-tree--border-radius);height:var(--ez-tree__tree-item--height);padding:var(--ez-tree__tree-item--padding);justify-content:space-between}.tree-item[selected]{background-color:var(--ez-tree__tree-item--selected--background-color)}.tree-item:hover{background-color:var(--ez-tree__tree-item--hover--background-color)}.tree-item[disabled],.tree-item[disabled]:hover{background-color:var(--ez-tree__tree-item--disabled--background-color)}.item-icon-box{display:flex;align-items:center;justify-content:center;width:var(--ez-tree__item-icon-box--width);height:var(--ez-tree__item-icon-box--height);padding:var(--ez-tree__item-icon-box--padding) var(--ez-tree__item-icon-box--padding) var(--ez-tree__item-icon-box--padding) 0}.item-icon{--ez-icon--color:var(--ez-tree--color)}.item-icon:hover{cursor:pointer}.tree-item[selected] .item-icon{--ez-icon--color:var(--ez-tree--selected--color)}.tree-item[disabled] .item-icon{cursor:unset;--ez-icon--color:var(--ez-tree--disabled--color)}.item-label{cursor:inherit;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;user-select:var(--ez-tree--user-select);font-family:var(--ez-tree--font-family);font-size:var(--ez-tree--font-size);font-weight:var(--ez-tree--font-weight);color:var(--ez-tree--color)}.item-label--bold{font-weight:var(--ez-tree--font-weight--bold)}.tree-item[selected] .item-label{color:var(--ez-tree--selected--color);font-weight:var(--ez-tree--selected--font-weight)}.tree-item[disabled] .item-label{color:var(--ez-tree--disabled--color)}";export{b as ez_tree}
1
+ import{h as e,r as t,c as i,f as r,H as s,g as o}from"./p-23a36bb6.js";import{ElementIDUtils as n,StringUtils as l,ObjectUtils as a}from"@sankhyalabs/core";import{i as h}from"./p-98218fbc.js";const c=(e,t)=>t?e.iconExpanded||"chevron-down":e.iconContracted||"chevron-right",d=e=>e.tooltip||e.label,u=t=>{const{node:i,selectedId:r,itemClick:s,iconClick:o,iconResolver:l,tooltipResolver:a,itemsList:h,itemDoubleClick:c}=t;if(!i.visible)return;const d=i.item,v=t.level||1,m=i.isDisabled(),b=!m&&d.expanded,g=i.isExpandable(),f=!m&&!i.isPlaceHolder;return f&&h.push(d),e("ul",{class:1===v?"first-level":void 0},e("li",Object.assign({title:a(d,!m,v),class:"tree-item "+(d.id!==r?"tree-item-error":""),onClick:()=>f&&s(d),onDblClick:()=>f&&c(d)},{disabled:m,selected:d.id===r,[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:n.getInternalIDInfo(`ezTreeItem_${d.id}`)}),e("div",{class:"item-label-container"},e("div",{class:"item-icon-box"},g&&e("ez-icon",{id:d.id,class:"item-icon",size:"small",iconName:l(d,b,v),onClick:e=>function(e){e.stopPropagation(),f&&o(d)}(e),onDblClick:e=>function(e){e.stopPropagation()}(e)})),e("label",{class:"item-label "+(d.bold?"item-label--bold":"")},d.label)),function(t,i,r){if(null!=i)return"string"==typeof i?e("div",{class:`tree-item-badge ${r?null:i}`},"error"===i&&e("ez-icon",{id:`${t}-badge-error`,class:"tree-item-badge-error-icon",size:"x-small",style:{color:"white"},iconName:"alert-circle"})):"text"===i.type?e("div",{id:`${t}-badge-text`,class:"tree-item-badge-text"},i.text):e("div",null,e("ez-icon",{id:`${t}-badge-icon`,class:"tree-item-badge-icon",style:{"--ez-icon--color":`var(--ez-tree__badge--icon-color--${i.iconColor||"default"})`},iconName:i.iconName}))}(d.id,d.badge,d.id===r)),b&&i.getChildren().map((t=>e(u,{selectedId:r,node:t,itemClick:s,iconClick:o,level:v+1,iconResolver:l,tooltipResolver:a,itemsList:h,itemDoubleClick:c}))))};class v{constructor(e,t,i,r=!1){this.children=new Map,this.visible=!0,this.item=t,this.parent=i,this._tree=e,this.isPlaceHolder=r,t&&!r?(this._isLazyLoad="function"==typeof t.children||t.childrenCount>0,Array.isArray(t.children)&&(Array.from(t.children).forEach((e=>this.addChild(this._tree,e))),this._childrenLoaded=!0)):(this._isLazyLoad=!1,this._childrenLoaded=!0)}refresh(e){if(this.isPlaceHolder)return;this.item=Object.assign({},e),this._isLazyLoad="function"==typeof this.item.children||this.item.childrenCount>0;const t=this.children;this.children=new Map,Array.isArray(this.item.children)?(void 0===this.item.expanded&&(this.item.expanded=!0),Array.from(this.item.children).forEach((e=>{const i=t.get(e.id);i?(void 0===e.expanded&&(e.expanded=i.item.expanded),i.refresh(e),this.children.set(e.id,i)):(void 0===e.expanded&&(e.expanded=!0),this.addChild(this._tree,Object.assign({},e)))})),this._childrenLoaded=!0):this._childrenLoaded=!1}isDisabled(){return!this.isPlaceHolder&&this._tree.isNodeDisabled(this.item.id,this.item.disabled)}updateChildren(e){this.isPlaceHolder||this.refresh(Object.assign(Object.assign({},this.item),{children:e}))}addChild(e,t){this.children.has(t.id)||this.children.set(t.id,new v(e,t,this))}removeChild(e){return!!this.children.has(e)&&(this.children.delete(e),!0)}addPlaceHolder(){this.children.clear();const e=this.item.id;this.children.set(e,new v(void 0,{id:`placeholder_${e}`,label:"Carregando..."},this,!0))}getNode(e){if(this.children.has(e))return this.children.get(e);const t=Array.from(this.children.values());for(const i of t){const t=i.getNode(e);if(t)return t}}needLoad(){return this._isLazyLoad&&!this._childrenLoaded}isExpandable(){return!!this._isLazyLoad||this.children.size>0}getChildren(){return this.isPlaceHolder?[]:(this.needLoad()&&this._tree.loadChildren(this),Array.from(this.children.values()))}}class m extends v{constructor(e){super(void 0),this._disabledValues=new Map,this._changeCallback=e}async addChildAt(e,t){const i=this.getNode(e);if(null==i)return this.addChild(this,t),void this._changeCallback();i.addChild(this,t),this._changeCallback()}setDisabled(e,t){this._disabledValues.set(e,t),this._changeCallback()}isNodeDisabled(e,t){return this._disabledValues.has(e)?this._disabledValues.get(e):t}load(e){if(e===this._currentItems)return;this._currentItems=e;const t=this.children;this.children=new Map,this._disabledValues.clear(),e.forEach((e=>{const i=t.get(e.id);i?(i.refresh(e),this.children.set(e.id,i)):this.addChild(this,Object.assign({},e))}))}async setFilterPattern(e,t=!0){if(e&&t&&e.includes(".")){const t=e.split(".").map((e=>l.replaceAccentuatedCharsKeepSymbols(e.trim())));await this.applyLayeredFilter(this,t,0)}else this._filterPattern=l.replaceAccentuatedCharsKeepSymbols(e),this.setAllChildrenExpanded(this,!1),this.applyFilter(this);this._changeCallback()}updateItem(e){if(null==e)return;const t=this.getNode(e.id);null!=t&&(Object.keys(e).forEach((i=>t.item[i]=e[i])),null==e.children?t.children.clear():Array.isArray(e.children)&&t.updateChildren(e.children),this._changeCallback())}removeItem(e){if(!e)return;const t=this.getNode(e);t&&(t.parent?t.parent.removeChild(e):this.children.delete(e),this._disabledValues.delete(e),this._changeCallback())}async open(e){return new Promise((async t=>{await this.walkPath(this,e,(e=>e.item.expanded=!0)),t()}))}setAllChildrenVisible(e){e.children.forEach((e=>{e.visible=!0,this.setAllChildrenVisible(e)}))}applyFilter(e){if(!this._filterPattern)return e.visible=!0,void this.setAllChildrenVisible(e);if(e.children.forEach((e=>{this.applyFilter(e)})),null==e.item)return;let t=!1;if(l.replaceAccentuatedCharsKeepSymbols(e.item.label).includes(this._filterPattern))t=!0,e.item.expanded=!0,this.setAllChildrenVisible(e);else{const i=Array.from(e.children.values());for(let r=0;r<i.length;r++)if(i[r].visible){t=!0,e.item.expanded=!0;break}}e.visible=t}async applyLayeredFilter(e,t,i){if(!e.item){const r=(await Promise.all(Array.from(e.children.values()).map((e=>this.applyLayeredFilter(e,t,i))))).some(Boolean);return e.visible=r,r}if(!l.replaceAccentuatedCharsKeepSymbols(e.item.label).includes(t[i])){const r=(await Promise.all(Array.from(e.children.values()).map((e=>this.applyLayeredFilter(e,t,i))))).some(Boolean);return r&&(e.item.expanded=!0),e.visible=r,r}if(i===t.length-1)return e.visible=!0,this.setAllChildrenVisible(e),!0;const r=(await Promise.all(Array.from(e.children.values()).map((e=>this.applyLayeredFilter(e,t,i+1))))).some(Boolean);return r&&(e.item.expanded=!0),e.visible=r,r}async walkPath(e,t,i,r=0){return new Promise((async s=>{const o=t.split(">>").map((e=>e.trim()));if(o.length>r){const s=e.getNode(o[r]);s&&(s.needLoad()&&await this.loadLevel(s),i(s),await this.walkPath(s,t,i,r+1))}s()}))}async loadChildren(e){return new Promise((t=>{this.loadLevel(e).then((()=>{t(),this._changeCallback()}))}))}expandAll(){this.setAllChildrenExpanded(this,!0),this._changeCallback()}collapseAll(){this.setAllChildrenExpanded(this,!1),this._changeCallback()}setAllChildrenExpanded(e,t){e.item&&!e.isPlaceHolder&&(e.item.expanded=t),e.children.forEach((e=>{this.setAllChildrenExpanded(e,t)}))}async loadLevel(e){return new Promise((t=>{e.addPlaceHolder(),(0,e.item.children)(e.item).then((i=>{e.updateChildren(i),t()}))}))}}const b=class{constructor(e){t(this,e),this.ezChange=i(this,"ezChange",7),this.ezOpenItem=i(this,"ezOpenItem",7),this.ezDbClickItem=i(this,"ezDbClickItem",7),this.ezRemoveItem=i(this,"ezRemoveItem",7),this._onItemClick=e=>{this.selectable?this.value=this.value&&this.value.id===e.id?void 0:e:this.openClose(e)},this._onIconClick=e=>{this.openClose(e)},this._tree=new m((()=>r(this))),this._waintingForLoad=void 0,this.items=[],this.value=void 0,this.selectedId=void 0,this.iconResolver=c,this.tooltipResolver=void 0,this.enableHierarchicalFilter=!0,this.selectable=!0}async selectItem(e){const t=this._tree.getNode(e);this.value=t?t.item:void 0}async openItem(e){this._waintingForLoad=!0,await this._tree.open(e),this._waintingForLoad=!1}async disableItem(e){[].concat(e).forEach((e=>this._tree.setDisabled(e,!0)))}async enableItem(e){[].concat(e).forEach((e=>this._tree.setDisabled(e,!1)))}async addChild(e,t){var i;null==t&&(t=null===(i=this.value)||void 0===i?void 0:i.id),this._tree.addChildAt(t,e),this.addItemInIndexedList(t,e);const r=this._tree.getNode(t);r?r.item.expanded=!0:this.collapseAll()}async applyFilter(e){await this._tree.setFilterPattern(e,this.enableHierarchicalFilter)}async expandAll(){this._tree.expandAll()}async collapseAll(){this._tree.collapseAll()}async updateItem(e,t){var i,r,s;if(Array.isArray(e))return void e.forEach((e=>this.updateItem(e,t)));if((null==t?void 0:t.updatedBySelectedId)&&Object.assign(e,{id:this.selectedId}),this._tree.updateItem((null==t?void 0:t.forceDefaultValues)?this.applyDefaultValues(e):e),this.updateItemInIndexedList(e,null==t?void 0:t.forceDefaultValues),null==(null===(i=this._tree)||void 0===i?void 0:i.getNode(this.selectedId))&&(this.value=this._visibleItems?this._visibleItems[0]:void 0,this._tree.collapseAll()),(null===(r=this.value)||void 0===r?void 0:r.id)===e.id)return this.value=e,void this.ezChange.emit(this.value);const o=this.getItemById(null===(s=this.value)||void 0===s?void 0:s.id,[e]);o&&(this.value=o,this.ezChange.emit(this.value))}async removeItem(e){var t;(e=null!=e?e:this.selectedId)&&(this._tree.removeItem(e),this.removeItemFromIndexedList(e),this.ezRemoveItem.emit(e),(null===(t=this.value)||void 0===t?void 0:t.id)===e&&(this.value=void 0))}async getItem(e){return new Promise((t=>{const i=this._tree.getNode(e);t(null==i?void 0:i.item)}))}async getCurrentPath(){var e,t,i;const r=null===(e=this._tree)||void 0===e?void 0:e.getNode(this.selectedId);if(null==r)return;const s=[];let o,n=null===(t=r.parent)||void 0===t?void 0:t.item;for(s.push(this.getItemPathAttrs(r.item));null!=n;)s.unshift(this.getItemPathAttrs(n)),o=this._tree.getNode(n.id),n=null===(i=null==o?void 0:o.parent)||void 0===i?void 0:i.item;return s}async getParent(e){return new Promise((t=>{var i;const r=this._tree.getNode(e);r&&t(null===(i=r.parent)||void 0===i?void 0:i.item),t(void 0)}))}observeItems(e,t){a.objectToString(e)!==a.objectToString(t)&&this._tree.load(this.items||[])}observeValue(){var e;this.ezChange.emit(this.value),this.selectedId=null===(e=this.value)||void 0===e?void 0:e.id}onKeyDownListener(e){if(!this.value)return;let t=!1;switch(e.key){case"ArrowUp":this.previousItem(),t=!0;break;case"ArrowDown":this.nextItem(),t=!0;break;case"ArrowLeft":this.previousLevel(),t=!0;break;case"ArrowRight":this.nextLevel(),t=!0;break;case" ":this.openClose(this.value),t=!0}t&&(e.stopPropagation(),e.preventDefault())}getItemById(e,t){for(const i of t){if(i.id===e)return i;if(i.children&&Array.isArray(i.children)){const t=this.getItemById(e,i.children);if(t)return t}}}addItemInIndexedList(e,t,i){var r,s;i=null!==(r=null!=i?i:this.items)&&void 0!==r?r:[],e||i.push(t);const o=this.getItemById(e,i);o.children=null!==(s=o.children)&&void 0!==s?s:[],o.children.push(t),o.childrenCount=o.children.length}applyDefaultValues(e){return void 0===e.disabled&&(e.disabled=!1),void 0===e.expanded&&(e.expanded=!1),e}updateItemInIndexedList(e,t=!1){if(!e||!this.items)return;const i=this.getItemById(e.id,this.items);i&&Object.assign(i,t?this.applyDefaultValues(e):e)}removeItemFromIndexedList(e,t){var i;if(t=null!==(i=null!=t?t:this.items)&&void 0!==i?i:[],!e)return!1;const r=t.findIndex((t=>t.id===e));if(-1!==r)return t.splice(r,1),!0;for(const i of t)if(i.children&&Array.isArray(i.children)){const t=i.children.findIndex((t=>t.id===e));if(-1!==t)return i.children.splice(t,1),i.childrenCount=i.children.length,!0;if(this.removeItemFromIndexedList(e,i.children))return!0}return!1}getItemPathAttrs({id:e,label:t}){return{id:e,label:t}}openClose(e){if(null==e)return;const t=!e.expanded;e.expanded=t,t&&this.ezOpenItem.emit(e),this._tree.updateItem(e)}previousLevel(){var e;if(this.value)if(this.value.expanded)this.value.expanded=!1,this._tree.updateItem(this.value);else{const t=null===(e=this._tree.getNode(this.value.id).parent)||void 0===e?void 0:e.item;t&&(this.value=t)}}nextLevel(){this.value&&this._tree.getNode(this.value.id).isExpandable()&&(this.value.expanded?this.nextItem():(this.value.expanded=!0,this._tree.updateItem(this.value)))}indexOf(e){if(null==e)return-1;for(let t=0;t<this._visibleItems.length;t++)if(this._visibleItems[t].id===e)return t;return-1}selectNextItem(e){var t;const i=this.indexOf(null===(t=this.value)||void 0===t?void 0:t.id)+e;i>-1&&i<this._visibleItems.length&&(this.value=this._visibleItems[i])}nextItem(){this.selectNextItem(1)}previousItem(){this.selectNextItem(-1)}connectedCallback(){this.items&&this._tree.load(this.items)}async componentWillLoad(){this.i18n=await h()}componentWillRender(){var e;if(!this.selectedId||(null===(e=this.value)||void 0===e?void 0:e.id)===this.selectedId)return;const t=this._tree.getNode(this.selectedId);t&&(this.value=t.item)}render(){if(n.addIDInfoIfNotExists(this._element,"ezTree"),null!=this.items)return this._visibleItems=[],e(s,{tabindex:"-1"},this._waintingForLoad?e("label",null,this.i18n("app.loading"),"..."):this._tree.getChildren().map((t=>{var i;return e(u,{selectedId:null===(i=this.value)||void 0===i?void 0:i.id,node:t,itemClick:this._onItemClick,iconClick:this._onIconClick,iconResolver:this.iconResolver,tooltipResolver:this.tooltipResolver||d,itemsList:this._visibleItems,itemDoubleClick:e=>this.ezDbClickItem.emit(e)})})))}get _element(){return o(this)}static get watchers(){return{items:["observeItems"],value:["observeValue"]}}};b.style=":host{--ez-tree--border-radius:var(--border--radius-small, 8px);--ez-tree--padding-inline-start:20px;--ez-tree--margin:var(--space--extra-small, 3px);--ez-tree--margin-right:0px;--ez-tree--user-select:auto;--ez-tree--font-family:var(--font-pattern, Arial);--ez-tree--font-size:var(--text--medium, 14px);--ez-tree--selected--font-weight:var(--text-weight--large, 600);--ez-tree--font-weight:var(--text-weight--small, 400);--ez-tree--color:var(--title--primary, #2B3A54);--ez-tree--selected--color:var(--color--primary, #008561);--ez-tree--disabled--color:var(--text--disable, #AFB6C0);--ez-tree--font-weight--bold:var(--text-weight--large, 600);--ez-tree__tree-item--height:var(--size-medium, 18px);--ez-tree__tree-item--padding:var(--space--small, 6px);--ez-tree__tree-item--background-color:var(--background--xlight, #FFFFFF);--ez-tree__tree-item--selected--background-color:var(--color--primary-300, #E2F4EF);--ez-tree__tree-item--hover--background-color:var(--background--medium, #F0F3F7);--ez-tree__tree-item--disabled--background-color:var(--ez-tree__tree-Item--background-color);--ez-tree__item-icon-box--height:var(--ez-tree__tree-item--height);--ez-tree__item-icon-box--width:var(--size-medium, 18px);--ez-tree__item-icon-box--padding:var(--ez-tree__tree-item--padding);--ez-tree__badge--icon-color--default:var(--title--primary, #2B3A54);--ez-tree__badge--icon-color--error:var(--color--error, #da4453);--ez-tree__badge--icon-color--success:var(--color-alert--success-800, #157a00);--ez-tree__badge--icon-color--warning:var(--color--warning, #f2d410);--ez-tree__badge--icon-color--disabled:var(--text--disable, #AFB6C0);display:flex;flex-direction:column;margin:0 var(--ez-tree--margin) var(--ez-tree--margin) var(--ez-tree--margin);outline:none}ul{list-style-type:none;margin:0;cursor:default;padding-inline-start:var(--ez-tree--padding-inline-start)}ul.first-level{padding-inline-start:0}.tree-item-badge{width:16px;height:16px;background:transparent;border-radius:50%;transition:all 300ms ease-in-out;display:flex;align-items:center;justify-content:center}.tree-item-badge-error-icon{--ez-icon--color:white}.tree-item-badge-text{font-family:var(--ez-tree--font-family);font-size:var(--ez-tree--font-size);font-weight:var(--ez-tree--font-weight);color:var(--ez-tree--color)}.tree-item-badge.error{background:var(--color--error)}.tree-item-badge.warning{background:var(--color--warning)}.tree-item-badge.success{background:var(--color--success)}.item-label-container{display:flex;align-items:center;overflow:hidden}.tree-item{display:flex;align-items:center;cursor:pointer;margin-top:var(--ez-tree--margin);margin-right:var(--ez-tree--margin-right);border-radius:var(--ez-tree--border-radius);height:var(--ez-tree__tree-item--height);padding:var(--ez-tree__tree-item--padding);justify-content:space-between}.tree-item[selected]{background-color:var(--ez-tree__tree-item--selected--background-color)}.tree-item:hover{background-color:var(--ez-tree__tree-item--hover--background-color)}.tree-item[disabled],.tree-item[disabled]:hover{background-color:var(--ez-tree__tree-item--disabled--background-color)}.item-icon-box{display:flex;align-items:center;justify-content:center;width:var(--ez-tree__item-icon-box--width);height:var(--ez-tree__item-icon-box--height);padding:var(--ez-tree__item-icon-box--padding) var(--ez-tree__item-icon-box--padding) var(--ez-tree__item-icon-box--padding) 0}.item-icon{--ez-icon--color:var(--ez-tree--color)}.item-icon:hover{cursor:pointer}.tree-item[selected] .item-icon{--ez-icon--color:var(--ez-tree--selected--color)}.tree-item[disabled] .item-icon{cursor:unset;--ez-icon--color:var(--ez-tree--disabled--color)}.item-label{cursor:inherit;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;user-select:var(--ez-tree--user-select);font-family:var(--ez-tree--font-family);font-size:var(--ez-tree--font-size);font-weight:var(--ez-tree--font-weight);color:var(--ez-tree--color)}.item-label--bold{font-weight:var(--ez-tree--font-weight--bold)}.tree-item[selected] .item-label{color:var(--ez-tree--selected--color);font-weight:var(--ez-tree--selected--font-weight)}.tree-item[disabled] .item-label{color:var(--ez-tree--disabled--color)}";export{b as ez_tree}
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as e,f as n,H as s,g as r}from"./p-23a36bb6.js";import{DateUtils as o,ApplicationContext as l,Action as a,StringUtils as u,KeyboardManager as h,DataUnit as c,ElementIDUtils as d}from"@sankhyalabs/core";import{b as f,a as v,S as m,f as p,c as b,D as y}from"./p-474076b3.js";import{g as w,i as g}from"./p-98218fbc.js";import{F as _}from"./p-30ffb9ed.js";import"./p-0ec5c128.js";import"./p-ab574d59.js";import"./p-b853763b.js";const O=/child\[([^\]]+)\]/,C=/\$\{.+\}/;class E{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const i=O.exec(t);return i?i[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([i,e])=>{if("string"==typeof e){const t=C.exec(e);t&&(e=this.getDefaultVar(t[0]))}t[i]=e})),t}getDefaultVar(t){return"${data}"===t?o.getToday():"${datahora}"===t?o.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const j=(t,i)=>{var e;if(i)return null===(e=i.tabs)||void 0===e?void 0:e.find((i=>i.label===t))},F=(t,i,e)=>{if("string"!=typeof t)return t;if(e){const i=j(t,e);if(i)return i}return Array.from(i.keys()).find((i=>i.label===t))||{label:t,visible:!0}};function z(t,i){var e,n;return"__main"===t[0].label&&"__main"!==i[0].label?-1:"__main"!==t[0].label&&"__main"===i[0].label?1:(null!==(e=t[0].order)&&void 0!==e?e:Number.MAX_VALUE)-(null!==(n=i[0].order)&&void 0!==n?n:Number.MAX_VALUE)}const x=t=>`child[${t.name}]`,A=t=>({name:x(t),label:t.label,fields:[]});function N(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var S="function"==typeof Symbol&&Symbol.observable||"@@observable",M=function(){return Math.random().toString(36).substring(7).split("").join(".")},D={INIT:"@@redux/INIT"+M(),REPLACE:"@@redux/REPLACE"+M(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+M()}};function R(t){if("object"!=typeof t||null===t)return!1;for(var i=t;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return Object.getPrototypeOf(t)===i}function T(t,i,e){var n;if("function"==typeof i&&"function"==typeof e||"function"==typeof e&&"function"==typeof arguments[3])throw new Error(N(0));if("function"==typeof i&&void 0===e&&(e=i,i=void 0),void 0!==e){if("function"!=typeof e)throw new Error(N(1));return e(T)(t,i)}if("function"!=typeof t)throw new Error(N(2));var s=t,r=i,o=[],l=o,a=!1;function u(){l===o&&(l=o.slice())}function h(){if(a)throw new Error(N(3));return r}function c(t){if("function"!=typeof t)throw new Error(N(4));if(a)throw new Error(N(5));var i=!0;return u(),l.push(t),function(){if(i){if(a)throw new Error(N(6));i=!1,u();var e=l.indexOf(t);l.splice(e,1),o=null}}}function d(t){if(!R(t))throw new Error(N(7));if(void 0===t.type)throw new Error(N(8));if(a)throw new Error(N(9));try{a=!0,r=s(r,t)}finally{a=!1}for(var i=o=l,e=0;e<i.length;e++)(0,i[e])();return t}function f(t){if("function"!=typeof t)throw new Error(N(10));s=t,d({type:D.REPLACE})}function v(){var t,i=c;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(N(11));function e(){t.next&&t.next(h())}return e(),{unsubscribe:i(e)}}})[S]=function(){return this},t}return d({type:D.INIT}),(n={dispatch:d,subscribe:c,getState:h,replaceReducer:f})[S]=v,n}const P={};function I(t=P,i){switch(i.type){case K.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:i.payload,currentSheet:void 0});case K.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:i.payload});default:return t}}function L(t){return t.formMetadata}function V(t){const i=function(t){return t.currentSheet}(t);return i?t.formMetadata.getSheet(i):Array.from(t.formMetadata.getAllSheets().values())[0]}var K;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(K||(K={}));const $=class{constructor(e){t(this,e),this.ezFormRequestClearFieldToFocus=i(this,"ezFormRequestClearFieldToFocus",7),this.ezFormSetFields=i(this,"ezFormSetFields",7),this.ezReady=i(this,"ezReady",7),this.formItemsReady=i(this,"formItemsReady",7),this._customEditors=new Map,this._application=l.getContextValue("__SNK__APPLICATION__"),this.onDataUnitAction=t=>{t.type===a.METADATA_LOADED&&this.processMetadata()},this._fieldsProps=new Map,this._singleColumn=!1,this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0,this.fieldToFocus=void 0,this.onlyStaticFields=!1,this.useSearchField=!0,this.elementFocusSearchField=void 0,this.customUiBuilders=new Map}validate(){return this._dataBinder.validate()}async addCustomEditor(t,i,e){if(this._formView)return void this._formView.addCustomEditor(t,i,e);const n=new Map(this._customEditors);n.set(t,{customEditor:i,detailContext:e}),this._customEditors=n}observeConfig(){this.processMetadata()}async setFieldProp(t,i,e){const n=new Map(this._fieldsProps),s=this._fieldsProps.get(t);n.set(t,Object.assign(Object.assign({},s),{[i]:e})),this._fieldsProps=n}getDynamicContent(){var t;const i=L(this._store.getState());if(!i)return null;const n=Array.from(i.getAllSheets().values()),s=V(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(n.length>1){const t=n.map(((t,i)=>({tabKey:t.name,label:t.label,index:i}))),i="selector";r.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:K.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:s.name,"data-element-id":i}))}return r=r.concat(this.buildFormContent(s)),r}buildFormContent(t){const i=null==t?void 0:t.fields;if(null==t)return;this.ezFormSetFields.emit(i);const n=`${u.replaceAccentuatedChars(u.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return e("div",{class:"dynamic-content ez-box--no-outline","data-element-id":n,ref:t=>this._container=t,tabindex:"0"},e("ez-popover",{ref:t=>this._ezPopoverSearchField=t,overlayType:"none"},this.renderFieldColumn()),e("ez-form-view",{ref:t=>this._formView=t,class:"ez-row ez-padding-vertical--small",fields:i,singleColumn:this._singleColumn,selectedRecord:this.dataUnit.getSelectedRecord(),customUiBuilders:this.customUiBuilders}))}renderFieldColumn(){return null!=this._fieldSearch||(this._fieldSearch=v({value:u.generateUUID(),label:this._i18n("ez-form.labelSearchField")},(({argument:t})=>this.fieldsOptionLoader(t)),(t=>this.onSelectField(t)))),this._fieldSearch}getFormFields(){var t;return null===(t=this.config)||void 0===t?void 0:t.fields}fieldsOptionLoader(t){const i=null==t?void 0:t.toLowerCase(),e=this.getFormFields().map((t=>{var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getField(t.name)})).filter((t=>{var e,n;return(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes(i))||(null===(n=t.label)||void 0===n?void 0:n.toLowerCase().includes(i))})).map((t=>({value:t.name,label:t.label})));return Promise.resolve(e)}onSelectField(t){null!=t&&null!=t.value?(this.fieldToFocus=t.value,this._ezPopoverSearchField.hide()):this.fieldToFocus=""}async initKeyboardManager(){var t,i;this._keyboardManager=new h({propagate:!1,element:null!==(t=this.elementFocusSearchField)&&void 0!==t?t:this._element}),this.useSearchField&&this._keyboardManager.bind(m,(async()=>{if(!this._container||!this._ezPopoverSearchField)return;const t=this._container.getBoundingClientRect();await p(this._fieldSearch),this._ezPopoverSearchField.showUnder(this._container,{horizontalGap:t.width-b,verticalGap:-1*t.height})}),{description:this._i18n("ez-form.labelSearchField"),element:null!==(i=this.elementFocusSearchField)&&void 0!==i?i:this._element})}componentDidLoad(){this.initKeyboardManager()}processMetadata(){if(this.bindFields()&&this.dataUnit&&this._store){const t=((t,i,e=!1,n)=>{var s;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const i=t.metadata;let e;return i&&(e=i.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:e}})(i));const r=new Map,o=new Map,l=[],a=[],u={};(null!==(s=null==t?void 0:t.tabs)&&void 0!==s?s:[]).forEach((t=>{o.has(t.label)||!1!==t.visible||o.set(t.label,t)})),function(t,i,e,n,s,r,o){var l;null===(l=null==t?void 0:t.fields)||void 0===l||l.forEach((l=>{var a,u,h;if(!1!==l.visible){const c=F(l.tab||"__main",i,t);if(e.has(c.label))return;const d=n.getField(l.name);if(d&&(null==(null==d?void 0:d.visible)||!0===(null==d?void 0:d.visible))&&c.visible){i.has(c)||i.set(c,[]);const t=f(d,l);i.get(c).push(t),t.required&&s.push(l.name),((null==l.cleanOnCopy?null===(a=d.properties)||void 0===a?void 0:a.cleanOnCopy:l.cleanOnCopy)||(null===(u=d.properties)||void 0===u?void 0:u.cleanOnCopy))&&r.push(l.name);let e=null==l.defaultValue?null===(h=d.properties)||void 0===h?void 0:h.defaultValue:l.defaultValue;if(e&&null!=e.value){const{type:t,value:i}=e;if(t)if("V"===t)e=i;else try{const t=JSON.parse(i);e=t&&"value"in t?t:i}catch(t){}o[l.name]=e}}}}))}(t,r,o,i,l,a,u);const h=new E;return h.setDefaultVars(t.defaultVars),e&&function(t,i,e){const n=t.metadata;void 0!==n&&void 0!==n.children&&n.children.forEach((t=>{const n=j(t.label,i);if(n)return void e.set(Object.assign(n,{name:x(t),isDetail:!0}),[]);const{label:s,name:r,fields:o}=A(t);e.set({name:r,label:s,isDetail:!0},o)}))}(i,t,r),n&&function(t,i,e){t.forEach((t=>{const n=j(t.label,i),s={};Object.entries(t).forEach((([t,i])=>{(function(t){return["id","label"].includes(t)})(t)||(s[t]=i)})),e.set(n?Object.assign(n,{name:t.id,isCustom:!0,ctxProps:s}):{label:t.label,name:t.id,isCustom:!0,visible:!0,ctxProps:s},[])}))}(n,t,r),Array.from(r.entries()).sort(z).forEach((([t,i])=>{o.has(t.label)||h.addSheet(function(t,i){const e=w();return{label:"__main"===t.label?e("ez-form.mainTab"):t.label,name:t.name||t.label,isCustom:t.isCustom,isDetail:t.isDetail,ctxProps:t.ctxProps,fields:i}}(t,i))})),h.addRequiredFields(l),h.addCleanOnCopyFields(a),h.addDefaultValues(u),h})(this.config,this.dataUnit);this._store.dispatch({type:K.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}bindFields(){return!this.isStatic()||!1===this.onlyStaticFields}async componentWillLoad(){var t;void 0===this.dataUnit&&(this.dataUnit=new c("ez-form")),this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new y(this.dataUnit),this._store=T(I),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),d.addIDInfo(this._element,null,{dataUnit:this.dataUnit});const i=await(null===(t=this._application)||void 0===t?void 0:t.getLayoutFormConfig());this.setSingleColumn(i),this.registerNotifyListeners(i),this._i18n=await g()}async setSingleColumn(t){this._singleColumn=(null==t?void 0:t.config)===_.CASCADE}async registerNotifyListeners(t){t&&t.onConfigChange((t=>{this._singleColumn=t===_.CASCADE}))}componentDidRender(){const t=L(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit(),this.handleFieldToFocus(),this.setCustomEditors(),this.setFieldsProps()}setCustomEditors(){if(this._formView)for(const[t,i]of this._customEditors)this._formView.addCustomEditor(t,i.customEditor,i.detailContext),this._customEditors.delete(t)}handleFieldToFocus(){var t;if(null==this.fieldToFocus)return;const i=V(null===(t=this._store)||void 0===t?void 0:t.getState());(null==i?void 0:i.fields).some((t=>t.name===this.fieldToFocus))&&requestAnimationFrame((()=>{this._dataBinder.setFocus(this.fieldToFocus),this.ezFormRequestClearFieldToFocus.emit(),this.fieldToFocus=null}))}setFieldsProps(){if(this._formView)for(const[t,i]of this._fieldsProps){for(const e in i)this._formView.setFieldProp(t,e,i[e]);this._fieldsProps.delete(t)}}disconnectedCallback(){var t;this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback(),null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}buildIdTabSelector(t){return t&&t.forEach((t=>t[d.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=u.toCamelCase(t.label))),t}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};$.style=".sc-ez-form-h{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{$ as ez_form}
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,H as o,g as e}from"./p-23a36bb6.js";import{ObjectUtils as h,ElementIDUtils as r}from"@sankhyalabs/core";import"./p-5a11cf56.js";import{C as n}from"./p-ec7db713.js";import"./p-ab574d59.js";import"./p-b853763b.js";import{i as a}from"./p-641ee538.js";import"./p-30ffb9ed.js";const l=class{constructor(s){t(this,s),this.ezChange=i(this,"ezChange",7),this.ezVisibilityChange=i(this,"ezVisibilityChange",7),this._changeDeboucingTimeout=null,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._lookupMode=!1,this.isOpen=!1,this._preSelection=void 0,this._visibleOptions=void 0,this._startLoading=!1,this._showLoading=!0,this._criteria=void 0,this.limitCharsToSearch=3,this.value=void 0,this.label=void 0,this.enabled=!0,this.options=void 0,this.errorMessage=void 0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.optionLoader=void 0,this.suppressEmptyOption=!1,this.stopPropagateEnterKeyEvent=!0,this.canShowError=!0,this.mode="regular",this.hideErrorOnFocusOut=!0,this.listOptionsPosition=void 0,this.isTextSearch=!1,this.autoFocus=!1,this.preventAutoFocus=!1,this.alternativePlaceholder=void 0,this.textEmptyOption=void 0}observeErrorMessage(){var t;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(t=this.errorMessage)||void 0===t?void 0:t.trim())||this.setInputValue())}observeValue(t,i){if(this._textInput&&t!=i)try{if("string"==typeof t)return void this.setInputValue();const s=this.getSelectedOption(t),o=this.getSelectedOption(i),e=this.getSelectedOption(this.value);this.isDifferentValues(e,s)&&(this.value=s),this.isDifferentValues(s,o)&&(this.setInputValue(),this._lookupMode||this.ezChange.emit(null===s?void 0:s)),this.resetOptions()}finally{this._lookupMode=!1}}observeOptions(t,i){h.equals(t,i)||this.loadOptions(d.PRELOAD)}async getValueAsync(){return new Promise(this._showLoading?t=>{let i=setInterval((()=>{this._showLoading||(clearInterval(i),t(this.sanitizeValue(this.value)))}),100)}:t=>t(this.sanitizeValue(this.value)))}async setFocus(t){this._textInput&&this._textInput.setFocus(t)}async setBlur(){this._textInput&&this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}async clearValue(){this.clearSearch()}isDifferentValues(t,i){return h.objectToString(t||{})!==h.objectToString(i||{})}getFormattedText(t){if(null!=t)return this.showSelectedValue&&null!=t.value?t.label?`${t.value} - ${t.label}`:t.value:t.label}getText(){const t=this.getSelectedOption(this.sanitizeValue(this.value)),i=this.getFormattedText(t);if(null!=i)return String(i).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')}getSelectedOption(t){return"string"==typeof t||t instanceof String?this._visibleOptions.find((i=>i.value===t)):t}updateVisibleOptions(){let t=this._source||[];if(this._criteria){const i=this._criteria.toUpperCase();t=t.filter((t=>t.label.toLocaleUpperCase().indexOf(i)>-1))}this.hasToAddEmptyoption(t)&&(t=[{value:void 0,label:this.textEmptyOption||this.i18n("ez-combo-box.placeholder")}].concat(t)),this._visibleOptions=t,this._maxWidthValue=this.getMaxWidthValue()}hasToAddEmptyoption(t){return!this.suppressEmptyOption&&!t.filter((t=>!t.value)).length}getMaxWidthValue(){var t;if(this.showOptionValue){const i=[];return null===(t=this._visibleOptions)||void 0===t||t.forEach((t=>{const s=this.getWidthValue(t.value);i.includes(s)||i.push(s)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(t){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=t)return i.innerHTML=t,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}async showOptions(){var t,i;if(!this.enabled)return;await this.openPopover();const s=null!==(i=null===(t=this.value)||void 0===t?void 0:t.value)&&void 0!==i?i:this.value,o=this._visibleOptions.findIndex((t=>t.value===s));this._preSelection=-1===o?0:o,this._resizeObserver&&this._resizeObserver.observe(this._textInput),this.preventAutoFocus||await this.setFocus()}hideOptions(){var t;null===(t=this._popover)||void 0===t||t.hide(),this._resizeObserver&&this._resizeObserver.unobserve(this._textInput)}updateSource(t){this._startLoading=!1,t instanceof Promise?(this._showLoading=!0,t.then((t=>{this._showLoading=!1,this.updateSource(t)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(t)?(this._source=t,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1)):this.selectOption(t))}selectOption(t,i=!0){var s,o,e;const h=this.getSelectedOption(this.value);(null===(s=null==h?void 0:h.value)||void 0===s?void 0:s.toString())!==(null===(o=null==t?void 0:t.value)||void 0===o?void 0:o.toString())||null==h&&null!=t&&"value"in t?(this.value=(null==t?void 0:t.value)?t:void 0,null===(e=this._popover)||void 0===e||e.hide()):this.resetOptions(),i&&setTimeout((()=>{this.setFocus()}),0)}loadOptions(t,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:t,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.sanitizeValue(this.value)?this.selectOption(void 0):window.setTimeout((()=>{this.setInputValue(!1)}),this._deboucingTime)}setInputValue(t=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,t&&(this.errorMessage=null))}clearSearch(){this.value=null}resetOptions(){this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}sanitizeValue(t){if("undefined"!==t&&"null"!==t)return t}async componentWillLoad(){if(this.i18n=await a(),void 0===this.options){this.options=[];const t=this.el.querySelectorAll("option");t&&t.forEach((t=>{let i=t.innerText,s=t.getAttribute("value");s||(s=i),this.options.push({label:i,value:s}),t.hidden=!0}))}this.loadOptions(d.PRELOAD)}setResizeObserver(){this._resizeObserver=new ResizeObserver((t=>{window.requestAnimationFrame((()=>{Array.isArray(t)&&t.length&&this._textInput&&this._comboBoxList&&(this._comboBoxList.width=this._textInput.clientWidth)}))}))}connectedCallback(){this._resizeObserver||this.setResizeObserver()}componentDidLoad(){n.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1),this.setResizeObserver(),this.autoFocus&&requestAnimationFrame((()=>{this.setFocus({selectText:!0})}))}disconnectedCallback(){var t;null===(t=this._popover)||void 0===t||t.remove(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null)}handlerIconClick(){this.showOptions()}onTextInputChangeHandler(t){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(t)}),this._deboucingTime));const s=null===(i=t.target.value)||void 0===i?void 0:i.trim();this._criteria||(this._textInput.value=t.data||s),this._criteria=s,s?(this.updateVisibleOptions(),this.showOptions()):(this._preSelection=void 0,this.updateVisibleOptions())}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=null)}onTextInputClickHandler(){this.showOptions()}keyDownHandler(t){var i,s,o,e,h,r;if(t.ctrlKey&&("f"===t.key||"F"===t.key))return this.loadOptions(d.ADVANCED),t.preventDefault(),void t.stopPropagation();switch(t.key){case"ArrowDown":t.preventDefault(),this.canShowListOptions()&&(this.showOptions(),null===(i=this._comboBoxList)||void 0===i||i.nextOption());break;case"ArrowUp":t.preventDefault(),this.canShowListOptions()&&(this.showOptions(),null===(s=this._comboBoxList)||void 0===s||s.previousOption());break;case"Enter":this.isOpen&&(t.preventDefault(),null===(o=this._comboBoxList)||void 0===o||o.selectCurrentOption());break;case"Escape":this.isOpen&&(t.preventDefault(),null===(e=this._popover)||void 0===e||e.hide());break;case"Tab":this._tabPressed=!0,this.isOpen&&(null===(h=this._comboBoxList)||void 0===h||h.selectCurrentOption(),null===(r=this._popover)||void 0===r||r.hide())}}onTextInputFocusOutHandler(){this.hideErrorOnFocusOut&&this.cancelPreselection()}canShowListOptions(){return!this._showLoading&&this._visibleOptions.length>0}async openPopover(){var t;this.isOpen=!0,await(null===(t=this._popover)||void 0===t?void 0:t.showUnder(this._textInput))}render(){var t;return r.addIDInfoIfNotExists(this.el,"input"),s(o,null,s("ez-text-input",{"data-element-id":r.getInternalIDInfo("textInput"),class:"text-input-slot-container "+(this.suppressSearch?"suppressed-search-input":""),ref:t=>this._textInput=t,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:t=>this.onTextInputChangeHandler(t),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:t=>this.keyDownHandler(t),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode,alternativePlaceholder:this.alternativePlaceholder||this.i18n("ez-combo-box.placeholder")},s("button",{class:"btn",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},s("ez-icon",{iconName:"chevron-down"}))),s("ez-popover-plus",{ref:t=>this._popover=t,anchorElement:this._textInput,autoClose:!0,boxWidth:"fit-content",overlayType:"none",onEzVisibilityChange:t=>this.isOpen=t.detail,"data-element-id":this.el.getAttribute("data-element-id")},s("ez-combo-box-list",{ref:t=>this._comboBoxList=t,showLoading:this._showLoading,visibleOptions:this._visibleOptions,textEmptyList:this.i18n("ez-combo-box.noResults"),showOptionValue:this.showOptionValue,preSelection:this._preSelection,maxWidth:this._maxWidthValue,width:null===(t=this._textInput)||void 0===t?void 0:t.clientWidth,onOptionSelect:t=>this.selectOption(t),onOptionHover:t=>this._preSelection=t})))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"],options:["observeOptions"]}}};var d;!function(t){t.ADVANCED="ADVANCED",t.PRELOAD="PRELOAD",t.PREDICTIVE="PREDICTIVE"}(d||(d={})),l.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.btn{outline:none;border:none;background:none;cursor:pointer;padding:0px;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:not-allowed;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}.text-input-slot-container{--ez-text-input__icon--width:32px;--ez-text-input__min-width:var(--ez-combo-box__min-width);--ez-text-input__max-width:var(--ez-combo-box__max-width)}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{l as ez_combo_box}
1
+ import{r as t,c as i,h as s,H as o,g as e}from"./p-23a36bb6.js";import{ObjectUtils as h,ElementIDUtils as r}from"@sankhyalabs/core";import"./p-0ec5c128.js";import{C as n}from"./p-ec7db713.js";import"./p-ab574d59.js";import"./p-b853763b.js";import{i as a}from"./p-98218fbc.js";import"./p-30ffb9ed.js";const l=class{constructor(s){t(this,s),this.ezChange=i(this,"ezChange",7),this.ezVisibilityChange=i(this,"ezVisibilityChange",7),this._changeDeboucingTimeout=null,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._lookupMode=!1,this.isOpen=!1,this._preSelection=void 0,this._visibleOptions=void 0,this._startLoading=!1,this._showLoading=!0,this._criteria=void 0,this.limitCharsToSearch=3,this.value=void 0,this.label=void 0,this.enabled=!0,this.options=void 0,this.errorMessage=void 0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.optionLoader=void 0,this.suppressEmptyOption=!1,this.stopPropagateEnterKeyEvent=!0,this.canShowError=!0,this.mode="regular",this.hideErrorOnFocusOut=!0,this.listOptionsPosition=void 0,this.isTextSearch=!1,this.autoFocus=!1,this.preventAutoFocus=!1,this.alternativePlaceholder=void 0,this.textEmptyOption=void 0}observeErrorMessage(){var t;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(t=this.errorMessage)||void 0===t?void 0:t.trim())||this.setInputValue())}observeValue(t,i){if(this._textInput&&t!=i)try{if("string"==typeof t)return void this.setInputValue();const s=this.getSelectedOption(t),o=this.getSelectedOption(i),e=this.getSelectedOption(this.value);this.isDifferentValues(e,s)&&(this.value=s),this.isDifferentValues(s,o)&&(this.setInputValue(),this._lookupMode||this.ezChange.emit(null===s?void 0:s)),this.resetOptions()}finally{this._lookupMode=!1}}observeOptions(t,i){h.equals(t,i)||this.loadOptions(d.PRELOAD)}async getValueAsync(){return new Promise(this._showLoading?t=>{let i=setInterval((()=>{this._showLoading||(clearInterval(i),t(this.sanitizeValue(this.value)))}),100)}:t=>t(this.sanitizeValue(this.value)))}async setFocus(t){this._textInput&&this._textInput.setFocus(t)}async setBlur(){this._textInput&&this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}async clearValue(){this.clearSearch()}isDifferentValues(t,i){return h.objectToString(t||{})!==h.objectToString(i||{})}getFormattedText(t){if(null!=t)return this.showSelectedValue&&null!=t.value?t.label?`${t.value} - ${t.label}`:t.value:t.label}getText(){const t=this.getSelectedOption(this.sanitizeValue(this.value)),i=this.getFormattedText(t);if(null!=i)return String(i).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')}getSelectedOption(t){return"string"==typeof t||t instanceof String?this._visibleOptions.find((i=>i.value===t)):t}updateVisibleOptions(){let t=this._source||[];if(this._criteria){const i=this._criteria.toUpperCase();t=t.filter((t=>t.label.toLocaleUpperCase().indexOf(i)>-1))}this.hasToAddEmptyoption(t)&&(t=[{value:void 0,label:this.textEmptyOption||this.i18n("ez-combo-box.placeholder")}].concat(t)),this._visibleOptions=t,this._maxWidthValue=this.getMaxWidthValue()}hasToAddEmptyoption(t){return!this.suppressEmptyOption&&!t.filter((t=>!t.value)).length}getMaxWidthValue(){var t;if(this.showOptionValue){const i=[];return null===(t=this._visibleOptions)||void 0===t||t.forEach((t=>{const s=this.getWidthValue(t.value);i.includes(s)||i.push(s)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(t){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=t)return i.innerHTML=t,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}async showOptions(){var t,i;if(!this.enabled)return;await this.openPopover();const s=null!==(i=null===(t=this.value)||void 0===t?void 0:t.value)&&void 0!==i?i:this.value,o=this._visibleOptions.findIndex((t=>t.value===s));this._preSelection=-1===o?0:o,this._resizeObserver&&this._resizeObserver.observe(this._textInput),this.preventAutoFocus||await this.setFocus()}hideOptions(){var t;null===(t=this._popover)||void 0===t||t.hide(),this._resizeObserver&&this._resizeObserver.unobserve(this._textInput)}updateSource(t){this._startLoading=!1,t instanceof Promise?(this._showLoading=!0,t.then((t=>{this._showLoading=!1,this.updateSource(t)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(t)?(this._source=t,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1)):this.selectOption(t))}selectOption(t,i=!0){var s,o,e;const h=this.getSelectedOption(this.value);(null===(s=null==h?void 0:h.value)||void 0===s?void 0:s.toString())!==(null===(o=null==t?void 0:t.value)||void 0===o?void 0:o.toString())||null==h&&null!=t&&"value"in t?(this.value=(null==t?void 0:t.value)?t:void 0,null===(e=this._popover)||void 0===e||e.hide()):this.resetOptions(),i&&setTimeout((()=>{this.setFocus()}),0)}loadOptions(t,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:t,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.sanitizeValue(this.value)?this.selectOption(void 0):window.setTimeout((()=>{this.setInputValue(!1)}),this._deboucingTime)}setInputValue(t=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,t&&(this.errorMessage=null))}clearSearch(){this.value=null}resetOptions(){this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}sanitizeValue(t){if("undefined"!==t&&"null"!==t)return t}async componentWillLoad(){if(this.i18n=await a(),void 0===this.options){this.options=[];const t=this.el.querySelectorAll("option");t&&t.forEach((t=>{let i=t.innerText,s=t.getAttribute("value");s||(s=i),this.options.push({label:i,value:s}),t.hidden=!0}))}this.loadOptions(d.PRELOAD)}setResizeObserver(){this._resizeObserver=new ResizeObserver((t=>{window.requestAnimationFrame((()=>{Array.isArray(t)&&t.length&&this._textInput&&this._comboBoxList&&(this._comboBoxList.width=this._textInput.clientWidth)}))}))}connectedCallback(){this._resizeObserver||this.setResizeObserver()}componentDidLoad(){n.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1),this.setResizeObserver(),this.autoFocus&&requestAnimationFrame((()=>{this.setFocus({selectText:!0})}))}disconnectedCallback(){var t;null===(t=this._popover)||void 0===t||t.remove(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null)}handlerIconClick(){this.showOptions()}onTextInputChangeHandler(t){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(t)}),this._deboucingTime));const s=null===(i=t.target.value)||void 0===i?void 0:i.trim();this._criteria||(this._textInput.value=t.data||s),this._criteria=s,s?(this.updateVisibleOptions(),this.showOptions()):(this._preSelection=void 0,this.updateVisibleOptions())}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=null)}onTextInputClickHandler(){this.showOptions()}keyDownHandler(t){var i,s,o,e,h,r;if(t.ctrlKey&&("f"===t.key||"F"===t.key))return this.loadOptions(d.ADVANCED),t.preventDefault(),void t.stopPropagation();switch(t.key){case"ArrowDown":t.preventDefault(),this.canShowListOptions()&&(this.showOptions(),null===(i=this._comboBoxList)||void 0===i||i.nextOption());break;case"ArrowUp":t.preventDefault(),this.canShowListOptions()&&(this.showOptions(),null===(s=this._comboBoxList)||void 0===s||s.previousOption());break;case"Enter":this.isOpen&&(t.preventDefault(),null===(o=this._comboBoxList)||void 0===o||o.selectCurrentOption());break;case"Escape":this.isOpen&&(t.preventDefault(),null===(e=this._popover)||void 0===e||e.hide());break;case"Tab":this._tabPressed=!0,this.isOpen&&(null===(h=this._comboBoxList)||void 0===h||h.selectCurrentOption(),null===(r=this._popover)||void 0===r||r.hide())}}onTextInputFocusOutHandler(){this.hideErrorOnFocusOut&&this.cancelPreselection()}canShowListOptions(){return!this._showLoading&&this._visibleOptions.length>0}async openPopover(){var t;this.isOpen=!0,await(null===(t=this._popover)||void 0===t?void 0:t.showUnder(this._textInput))}render(){var t;return r.addIDInfoIfNotExists(this.el,"input"),s(o,null,s("ez-text-input",{"data-element-id":r.getInternalIDInfo("textInput"),class:"text-input-slot-container "+(this.suppressSearch?"suppressed-search-input":""),ref:t=>this._textInput=t,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:t=>this.onTextInputChangeHandler(t),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:t=>this.keyDownHandler(t),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode,alternativePlaceholder:this.alternativePlaceholder||this.i18n("ez-combo-box.placeholder")},s("button",{class:"btn",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},s("ez-icon",{iconName:"chevron-down"}))),s("ez-popover-plus",{ref:t=>this._popover=t,anchorElement:this._textInput,autoClose:!0,boxWidth:"fit-content",overlayType:"none",onEzVisibilityChange:t=>this.isOpen=t.detail,"data-element-id":this.el.getAttribute("data-element-id")},s("ez-combo-box-list",{ref:t=>this._comboBoxList=t,showLoading:this._showLoading,visibleOptions:this._visibleOptions,textEmptyList:this.i18n("ez-combo-box.noResults"),showOptionValue:this.showOptionValue,preSelection:this._preSelection,maxWidth:this._maxWidthValue,width:null===(t=this._textInput)||void 0===t?void 0:t.clientWidth,onOptionSelect:t=>this.selectOption(t),onOptionHover:t=>this._preSelection=t})))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"],options:["observeOptions"]}}};var d;!function(t){t.ADVANCED="ADVANCED",t.PRELOAD="PRELOAD",t.PREDICTIVE="PREDICTIVE"}(d||(d={})),l.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.btn{outline:none;border:none;background:none;cursor:pointer;padding:0px;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:not-allowed;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}.text-input-slot-container{--ez-text-input__icon--width:32px;--ez-text-input__min-width:var(--ez-combo-box__min-width);--ez-text-input__max-width:var(--ez-combo-box__max-width)}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{l as ez_combo_box}
@@ -1 +1 @@
1
- import{r as n,h as i}from"./p-23a36bb6.js";import{i as e}from"./p-641ee538.js";import"@sankhyalabs/core";const r=["progress","pulse","false"],t=["circle","rect","text"],a="text",o="progress",s="circle",g=class{constructor(i){n(this,i),this.items=[],this.template=void 0,this.count=1,this.variant=a,this.width=null,this.height=null,this.marginTop=null,this.marginRight=null,this.marginBottom=null,this.marginLeft=null,this.animation=o}async componentWillLoad(){this.i18n=await e(),this.initializeItems()}componentWillUpdate(){this.initializeItems()}initializeItems(){this.items=Array(this.count).fill(1)}getSkeletonConfig(n){if(n)return(null==n?void 0:n.variant)==s?(n.width=n.width||"var(--skeleton-width, 40px)",n.height=n.height||"var(--skeleton-height, 40px)"):n.width=n.width||"var(--skeleton-width, 100%)",{skeletonClasses:{skeleton:!0,circle:n.variant===s,rect:"rect"===n.variant,progress:"progress"===n.animation,pulse:"pulse"===n.animation},styles:{width:(n.marginRight||n.marginLeft)&&n.width&&n.variant!=s?`calc(${n.width} ${n.marginRight?`- ${n.marginRight}`:""} ${n.marginLeft?`- ${n.marginLeft}`:""})`:n.width,height:n.height,marginTop:n.marginTop,marginRight:n.marginRight,marginBottom:n.marginBottom,marginLeft:n.marginLeft}}}validateVariant(n){return t.includes(n)?n:a}validateAnimation(n){return r.includes(n)?n:o}renderSkeletonTemplate(n){var e;const r=(null===(e=n.$attrs)||void 0===e?void 0:e.innerHTML)||n;if("string"==typeof r){const n=document.createElement("div");n.innerHTML=r;const e=(null==n?void 0:n.querySelectorAll(":not(.skeleton) > *"))||[];return Array.from(e).map((n=>{var e,r,t,a,o,s,g,l,d,p;if(null===(e=null==n?void 0:n.classList)||void 0===e?void 0:e.contains("skeleton")){const i=this.getSkeletonConfig({variant:this.validateVariant((null===(r=n.getAttribute("variant"))||void 0===r?void 0:r.replace(/[{}]/g,""))||this.variant),width:(null===(t=n.getAttribute("width"))||void 0===t?void 0:t.replace(/[{}]/g,""))||this.width,height:(null===(a=n.getAttribute("height"))||void 0===a?void 0:a.replace(/[{}]/g,""))||this.height,marginTop:(null===(o=n.getAttribute("marginTop"))||void 0===o?void 0:o.replace(/[{}]/g,""))||this.marginTop,marginLeft:(null===(s=n.getAttribute("marginLeft"))||void 0===s?void 0:s.replace(/[{}]/g,""))||this.marginLeft,marginRight:(null===(g=n.getAttribute("marginRight"))||void 0===g?void 0:g.replace(/[{}]/g,""))||this.marginRight,marginBottom:(null===(l=n.getAttribute("marginBottom"))||void 0===l?void 0:l.replace(/[{}]/g,""))||this.marginBottom,animation:this.validateAnimation((null===(d=n.getAttribute("animation"))||void 0===d?void 0:d.replace(/[{}]/g,""))||this.animation)}),e=Number(null===(p=n.getAttribute("count"))||void 0===p?void 0:p.replace(/[{}]/g,""))||1;return Array(e).fill(1).map(((n,e)=>this.renderSkeletonItem(e,i)))}return i("div",{innerHTML:n.outerHTML})}))}return n}renderSkeletonItem(n,i){const e=i||this.getSkeletonConfig({variant:this.validateVariant(this.variant),animation:this.validateAnimation(this.animation),width:this.width,height:this.height,marginTop:this.marginTop,marginRight:this.marginRight,marginBottom:this.marginBottom,marginLeft:this.marginLeft});return this.renderSkeletonSpan(n,e)}renderSkeletonSpan(n,e){return i("span",{key:n,class:null==e?void 0:e.skeletonClasses,style:null==e?void 0:e.styles,"data-busy":"true","data-valuemin":"0","data-valuemax":"100","data-valuetext":this.i18n("app.loading"),role:"progressbar",tabindex:"0"})}render(){return this.template?this.renderSkeletonTemplate(this.template):this.items.map(((n,i)=>this.renderSkeletonItem(i)))}};g.style=".skeleton {\n background: var(--skeleton-background, #f0f3f7) no-repeat;\n border-radius: var(--skeleton-border-radius, 12px);\n width: var(--skeleton-width, 100%);\n height: var(--skeleton-height, 20px);\n display: inline-block;\n margin-bottom: var(--skeleton-margin-bottom, 0px);\n\tmargin-top: var(--skeleton-margin-top, 0px);\n\tmargin-right: var(--skeleton-margin-right, 0px);\n\tmargin-left: var(--skeleton-margin-left, 0px);\n box-sizing: border-box;\n outline: none;\n overflow: hidden;\n position: relative;\n -webkit-will-change: transform;\n -moz-will-change: transform;\n will-change: transform;\n\n &:after,\n &:before {\n box-sizing: border-box;\n }\n\n &.circle {\n width: var(--skeleton-width, 40px);\n height: var(--skeleton-height, 40px);\n margin-bottom: var(--skeleton-margin-bottom, 0px);\n border-radius: var(--skeleton-border-radius, 50%);\n }\n\n &.rect {\n border-radius: var(--skeleton-border-radius, 0px);\n }\n\n &.progress,\n &.progress-dark {\n -webkit-animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -moz-animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -ms-animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n background-size: 200px 100%;\n }\n\n &.progress {\n background-image: -webkit-linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n background-image: -moz-linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n background-image: -ms-linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n background-image: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n }\n\n &.progress-dark {\n background-image: -webkit-linear-gradient(90deg, transparent, hsla(0, 0%, 0%, 0.2), transparent);\n background-image: -moz-linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);\n background-image: -ms-linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);\n background-image: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);\n }\n\n &.pulse {\n -webkit-animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -moz-animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -ms-animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n animation-delay: 0.5s;\n }\n\n @media (prefers-reduced-motion: reduce) {\n &.pulse,\n &.progress-dark,\n &.progress {\n animation: none;\n }\n\n &.progress,\n &.progress-dark {\n background-image: none;\n }\n }\n}\n\n@-webkit-keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n@-moz-keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n@-ms-keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n@keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n\n@-webkit-keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n@-moz-keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n@-ms-keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n@keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n";export{g as ez_skeleton}
1
+ import{r as n,h as i}from"./p-23a36bb6.js";import{i as e}from"./p-98218fbc.js";import"@sankhyalabs/core";const r=["progress","pulse","false"],t=["circle","rect","text"],a="text",o="progress",s="circle",g=class{constructor(i){n(this,i),this.items=[],this.template=void 0,this.count=1,this.variant=a,this.width=null,this.height=null,this.marginTop=null,this.marginRight=null,this.marginBottom=null,this.marginLeft=null,this.animation=o}async componentWillLoad(){this.i18n=await e(),this.initializeItems()}componentWillUpdate(){this.initializeItems()}initializeItems(){this.items=Array(this.count).fill(1)}getSkeletonConfig(n){if(n)return(null==n?void 0:n.variant)==s?(n.width=n.width||"var(--skeleton-width, 40px)",n.height=n.height||"var(--skeleton-height, 40px)"):n.width=n.width||"var(--skeleton-width, 100%)",{skeletonClasses:{skeleton:!0,circle:n.variant===s,rect:"rect"===n.variant,progress:"progress"===n.animation,pulse:"pulse"===n.animation},styles:{width:(n.marginRight||n.marginLeft)&&n.width&&n.variant!=s?`calc(${n.width} ${n.marginRight?`- ${n.marginRight}`:""} ${n.marginLeft?`- ${n.marginLeft}`:""})`:n.width,height:n.height,marginTop:n.marginTop,marginRight:n.marginRight,marginBottom:n.marginBottom,marginLeft:n.marginLeft}}}validateVariant(n){return t.includes(n)?n:a}validateAnimation(n){return r.includes(n)?n:o}renderSkeletonTemplate(n){var e;const r=(null===(e=n.$attrs)||void 0===e?void 0:e.innerHTML)||n;if("string"==typeof r){const n=document.createElement("div");n.innerHTML=r;const e=(null==n?void 0:n.querySelectorAll(":not(.skeleton) > *"))||[];return Array.from(e).map((n=>{var e,r,t,a,o,s,g,l,d,p;if(null===(e=null==n?void 0:n.classList)||void 0===e?void 0:e.contains("skeleton")){const i=this.getSkeletonConfig({variant:this.validateVariant((null===(r=n.getAttribute("variant"))||void 0===r?void 0:r.replace(/[{}]/g,""))||this.variant),width:(null===(t=n.getAttribute("width"))||void 0===t?void 0:t.replace(/[{}]/g,""))||this.width,height:(null===(a=n.getAttribute("height"))||void 0===a?void 0:a.replace(/[{}]/g,""))||this.height,marginTop:(null===(o=n.getAttribute("marginTop"))||void 0===o?void 0:o.replace(/[{}]/g,""))||this.marginTop,marginLeft:(null===(s=n.getAttribute("marginLeft"))||void 0===s?void 0:s.replace(/[{}]/g,""))||this.marginLeft,marginRight:(null===(g=n.getAttribute("marginRight"))||void 0===g?void 0:g.replace(/[{}]/g,""))||this.marginRight,marginBottom:(null===(l=n.getAttribute("marginBottom"))||void 0===l?void 0:l.replace(/[{}]/g,""))||this.marginBottom,animation:this.validateAnimation((null===(d=n.getAttribute("animation"))||void 0===d?void 0:d.replace(/[{}]/g,""))||this.animation)}),e=Number(null===(p=n.getAttribute("count"))||void 0===p?void 0:p.replace(/[{}]/g,""))||1;return Array(e).fill(1).map(((n,e)=>this.renderSkeletonItem(e,i)))}return i("div",{innerHTML:n.outerHTML})}))}return n}renderSkeletonItem(n,i){const e=i||this.getSkeletonConfig({variant:this.validateVariant(this.variant),animation:this.validateAnimation(this.animation),width:this.width,height:this.height,marginTop:this.marginTop,marginRight:this.marginRight,marginBottom:this.marginBottom,marginLeft:this.marginLeft});return this.renderSkeletonSpan(n,e)}renderSkeletonSpan(n,e){return i("span",{key:n,class:null==e?void 0:e.skeletonClasses,style:null==e?void 0:e.styles,"data-busy":"true","data-valuemin":"0","data-valuemax":"100","data-valuetext":this.i18n("app.loading"),role:"progressbar",tabindex:"0"})}render(){return this.template?this.renderSkeletonTemplate(this.template):this.items.map(((n,i)=>this.renderSkeletonItem(i)))}};g.style=".skeleton {\n background: var(--skeleton-background, #f0f3f7) no-repeat;\n border-radius: var(--skeleton-border-radius, 12px);\n width: var(--skeleton-width, 100%);\n height: var(--skeleton-height, 20px);\n display: inline-block;\n margin-bottom: var(--skeleton-margin-bottom, 0px);\n\tmargin-top: var(--skeleton-margin-top, 0px);\n\tmargin-right: var(--skeleton-margin-right, 0px);\n\tmargin-left: var(--skeleton-margin-left, 0px);\n box-sizing: border-box;\n outline: none;\n overflow: hidden;\n position: relative;\n -webkit-will-change: transform;\n -moz-will-change: transform;\n will-change: transform;\n\n &:after,\n &:before {\n box-sizing: border-box;\n }\n\n &.circle {\n width: var(--skeleton-width, 40px);\n height: var(--skeleton-height, 40px);\n margin-bottom: var(--skeleton-margin-bottom, 0px);\n border-radius: var(--skeleton-border-radius, 50%);\n }\n\n &.rect {\n border-radius: var(--skeleton-border-radius, 0px);\n }\n\n &.progress,\n &.progress-dark {\n -webkit-animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -moz-animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -ms-animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n animation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n background-size: 200px 100%;\n }\n\n &.progress {\n background-image: -webkit-linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n background-image: -moz-linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n background-image: -ms-linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n background-image: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--skeleton-background-image, #e4eaf1), rgba(255, 255, 255, 0));\n }\n\n &.progress-dark {\n background-image: -webkit-linear-gradient(90deg, transparent, hsla(0, 0%, 0%, 0.2), transparent);\n background-image: -moz-linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);\n background-image: -ms-linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);\n background-image: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);\n }\n\n &.pulse {\n -webkit-animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -moz-animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n -ms-animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n animation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n animation-delay: 0.5s;\n }\n\n @media (prefers-reduced-motion: reduce) {\n &.pulse,\n &.progress-dark,\n &.progress {\n animation: none;\n }\n\n &.progress,\n &.progress-dark {\n background-image: none;\n }\n }\n}\n\n@-webkit-keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n@-moz-keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n@-ms-keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n@keyframes progress {\n 0% {\n background-position: -200px 0;\n }\n 100% {\n background-position: calc(200px + 100%) 0;\n }\n}\n\n@-webkit-keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n@-moz-keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n@-ms-keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n@keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n";export{g as ez_skeleton}
@@ -1 +1 @@
1
- import{r as t,c as i,h as o,H as e,g as l}from"./p-23a36bb6.js";import{KeyboardManager as s,FloatingManager as n}from"@sankhyalabs/core";import{i as a}from"./p-641ee538.js";const p=class{constructor(o){t(this,o),this.ezClosePopup=i(this,"ezClosePopup",7),this.ezPopupAction=i(this,"ezPopupAction",7),this.handleFooterSlotChange=t=>{this._hasFooterSlotContent=t.target.assignedElements().length>0},this._hasFooterSlotContent=!1,this.size="medium",this.opened=!1,this.useHeader=!0,this.heightMode="full",this.ezTitle=void 0,this.enabledScroll=!0,this.autoClose=!0,this.footerButtons=[]}observeConfig(){this.manageOverflow()}async componentWillLoad(){this.i18n=await a()}componentDidLoad(){this.popUpFocus(),this._keyboardManager=new s({propagate:!1,element:this._element,enableShadowDom:!0}).bind("Enter",this.ezPopupAction.emit.bind("OK")).bind("Escape",(()=>this.closePopup())).bind("Esc",(()=>this.closePopup()))}disconnectedCallback(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}closePopup(){this.opened=!1,this.manageOverflow(),this.ezClosePopup.emit()}manageOverflow(){window.document.body.style.overflow=this.opened?"hidden":""}manageOverlay(){this.opened?this._overlayId=n.subscribeOverlayControl(this._popupRef):n.unsubscribeOverlayControl(this._popupRef||this._overlayId)}popUpFocus(){this.opened&&this._popupRef&&this._popupRef.focus()}getGridSize(){var t;const i={"x-small":"col--sd-3 ez-popup__size-limit--x-small",small:"col--sd-5",medium:"col--sd-6",large:"col--sd-9","x-large":"col--sd-11",default:"ez-popup__size-limit--x-small",auto:""};return this.size&&i.hasOwnProperty(this.size)&&null!==(t=i[this.size])&&void 0!==t?t:i.medium}getDialogClass(){let t="popup__container";return"auto"===this.heightMode&&(t+=" popup__container--auto"),t+=` ${this.getGridSize()}`,t}componentDidRender(){this.manageOverlay(),this.popUpFocus()}handleAutoClose(t){if(!this.opened||!this._popupRef||!this.autoClose)return;if(this._popupRef.contains(t.target))return;const i=this._popupRef.querySelector("slot");if(i&&i.assignedElements().length>0){const o=i.assignedElements();for(const i of o)if(i.contains(t.target))return}this._popupRef.shadowRoot&&this._popupRef.shadowRoot.contains(t.target)||this.closePopup()}handleDefaultPropsButtonsByIndex(t){switch(t){case 0:return{label:this.i18n?this.i18n("app.confirm"):"Confirmar",variant:"primary",size:"small",onClick:()=>{this.closePopup(),this.ezPopupAction.emit("OK")}};case 1:return{label:this.i18n?this.i18n("app.cancel"):"Cancelar",variant:"secondary",size:"small",onClick:()=>{this.closePopup()}};case 2:return{label:this.i18n?this.i18n("app.close"):"Fechar",variant:"tertiary",size:"small",onClick:()=>{this.closePopup()}}}}renderFooterButtons(){return this.footerButtons.slice(0,3).map(((t,i)=>o("ez-button",Object.assign({key:i},this.handleDefaultPropsButtonsByIndex(i),t))))}render(){return o(e,null,this.opened&&o("div",{class:"overlay",tabIndex:-1,onClick:this.handleAutoClose.bind(this)},o("dialog",{ref:t=>this._popupRef=t,class:this.getDialogClass()},this.useHeader&&o("header",{class:"popup__header"},!!this.ezTitle&&o("h1",{class:"popup__title"},this.ezTitle),o("ez-button",{class:this.ezTitle?"btn-close":"btn-close btn-close--solo",variant:"tertiary",mode:"icon",iconName:"close",size:"small",onClick:this.closePopup.bind(this)})),o("main",{class:{"popup__expandable-content":!0,"popup__overflow-y--auto":this.enabledScroll}},o("slot",null)),o("footer",{class:{popup__footer:!0,"popup_margin-top":this.footerButtons.length>0||this._hasFooterSlotContent}},this.footerButtons.length>0&&this.renderFooterButtons(),o("slot",{name:"footer",onSlotchange:this.handleFooterSlotChange})))))}get _element(){return l(this)}static get watchers(){return{opened:["observeConfig"]}}};p.style=':host{display:flex;width:auto;--ez-popup-z-index:var(--elevation--24, 24);--ez-popup__container--color:var(--title--primary, #2b3a54);--ez-popup__container--padding:var(--space--24, 24px);--ez-popup__title--font-family:var(--font--pattern, "Roboto");--ez-popup__title--font-size:var(--font-size--xxlarge, 22px);--ez-popup__title--color:var(--title--primary, #00281D);--ez-popup__title--font-weight:var(--font-weight--regular, 400)}.overlay{position:fixed;display:flex;top:0px;z-index:var(--ez-popup-z-index, 24);left:0px;width:100%;align-items:center;justify-content:center;box-sizing:border-box;height:100vh;backdrop-filter:blur(4px);background:rgba(0, 4, 12, 0.4)}.popup__container{width:auto;max-height:90%;height:100%;display:flex;flex-direction:column;overflow:hidden;outline:none;background:#FFFF;color:var(--ez-popup__container--color);border-radius:12px;box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122);box-sizing:border-box;padding:var(--ez-popup__container--padding);margin:0;border:none;position:unset}.popup__container--auto{height:auto}.popup__overflow-y--auto{overflow-y:auto}.popup__content{box-sizing:border-box;height:100%;width:100%}.popup__expandable-content{flex-grow:1;box-sizing:border-box;width:100%;font-family:var(--font--pattern, "Roboto");font-size:var(--font-size--default, 14px);color:var(--title--primary, #00281D);font-weight:var(--font-weight--regular, 400)}.popup__header{flex-shrink:0;width:100%;display:flex;align-items:center;margin-bottom:var(--space--16, 16px)}.popup__title{display:flex;margin:0;width:100%;font-family:var(--ez-popup__title--font-family);font-size:var(--ez-popup__title--font-size);font-weight:var(--ez-popup__title--font-weight);color:var(--ez-popup__title--color);line-height:var(--line-height--32, 32px)}.btn-close{justify-content:flex-end;align-self:flex-start;align-items:flex-start;display:flex;outline:none;border:none;background-color:unset;cursor:pointer}.btn-close--solo{width:100%}.popup__footer{flex-shrink:0;display:flex;width:100%;flex-direction:row-reverse;gap:var(--space--8, 8px)}.popup_margin-top{margin-top:var(--space--16, 16px)}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}.ez-popup__size-limit--x-small{min-width:350px;max-width:560px}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}';export{p as ez_popup}
1
+ import{r as t,c as i,h as o,H as e,g as l}from"./p-23a36bb6.js";import{KeyboardManager as s,FloatingManager as n}from"@sankhyalabs/core";import{i as a}from"./p-98218fbc.js";const p=class{constructor(o){t(this,o),this.ezClosePopup=i(this,"ezClosePopup",7),this.ezPopupAction=i(this,"ezPopupAction",7),this.handleFooterSlotChange=t=>{this._hasFooterSlotContent=t.target.assignedElements().length>0},this._hasFooterSlotContent=!1,this.size="medium",this.opened=!1,this.useHeader=!0,this.heightMode="full",this.ezTitle=void 0,this.enabledScroll=!0,this.autoClose=!0,this.footerButtons=[]}observeConfig(){this.manageOverflow()}async componentWillLoad(){this.i18n=await a()}componentDidLoad(){this.popUpFocus(),this._keyboardManager=new s({propagate:!1,element:this._element,enableShadowDom:!0}).bind("Enter",this.ezPopupAction.emit.bind("OK")).bind("Escape",(()=>this.closePopup())).bind("Esc",(()=>this.closePopup()))}disconnectedCallback(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}closePopup(){this.opened=!1,this.manageOverflow(),this.ezClosePopup.emit()}manageOverflow(){window.document.body.style.overflow=this.opened?"hidden":""}manageOverlay(){this.opened?this._overlayId=n.subscribeOverlayControl(this._popupRef):n.unsubscribeOverlayControl(this._popupRef||this._overlayId)}popUpFocus(){this.opened&&this._popupRef&&this._popupRef.focus()}getGridSize(){var t;const i={"x-small":"col--sd-3 ez-popup__size-limit--x-small",small:"col--sd-5",medium:"col--sd-6",large:"col--sd-9","x-large":"col--sd-11",default:"ez-popup__size-limit--x-small",auto:""};return this.size&&i.hasOwnProperty(this.size)&&null!==(t=i[this.size])&&void 0!==t?t:i.medium}getDialogClass(){let t="popup__container";return"auto"===this.heightMode&&(t+=" popup__container--auto"),t+=` ${this.getGridSize()}`,t}componentDidRender(){this.manageOverlay(),this.popUpFocus()}handleAutoClose(t){if(!this.opened||!this._popupRef||!this.autoClose)return;if(this._popupRef.contains(t.target))return;const i=this._popupRef.querySelector("slot");if(i&&i.assignedElements().length>0){const o=i.assignedElements();for(const i of o)if(i.contains(t.target))return}this._popupRef.shadowRoot&&this._popupRef.shadowRoot.contains(t.target)||this.closePopup()}handleDefaultPropsButtonsByIndex(t){switch(t){case 0:return{label:this.i18n?this.i18n("app.confirm"):"Confirmar",variant:"primary",size:"small",onClick:()=>{this.closePopup(),this.ezPopupAction.emit("OK")}};case 1:return{label:this.i18n?this.i18n("app.cancel"):"Cancelar",variant:"secondary",size:"small",onClick:()=>{this.closePopup()}};case 2:return{label:this.i18n?this.i18n("app.close"):"Fechar",variant:"tertiary",size:"small",onClick:()=>{this.closePopup()}}}}renderFooterButtons(){return this.footerButtons.slice(0,3).map(((t,i)=>o("ez-button",Object.assign({key:i},this.handleDefaultPropsButtonsByIndex(i),t))))}render(){return o(e,null,this.opened&&o("div",{class:"overlay",tabIndex:-1,onClick:this.handleAutoClose.bind(this)},o("dialog",{ref:t=>this._popupRef=t,class:this.getDialogClass()},this.useHeader&&o("header",{class:"popup__header"},!!this.ezTitle&&o("h1",{class:"popup__title"},this.ezTitle),o("ez-button",{class:this.ezTitle?"btn-close":"btn-close btn-close--solo",variant:"tertiary",mode:"icon",iconName:"close",size:"small",onClick:this.closePopup.bind(this)})),o("main",{class:{"popup__expandable-content":!0,"popup__overflow-y--auto":this.enabledScroll}},o("slot",null)),o("footer",{class:{popup__footer:!0,"popup_margin-top":this.footerButtons.length>0||this._hasFooterSlotContent}},this.footerButtons.length>0&&this.renderFooterButtons(),o("slot",{name:"footer",onSlotchange:this.handleFooterSlotChange})))))}get _element(){return l(this)}static get watchers(){return{opened:["observeConfig"]}}};p.style=':host{display:flex;width:auto;--ez-popup-z-index:var(--elevation--24, 24);--ez-popup__container--color:var(--title--primary, #2b3a54);--ez-popup__container--padding:var(--space--24, 24px);--ez-popup__title--font-family:var(--font--pattern, "Roboto");--ez-popup__title--font-size:var(--font-size--xxlarge, 22px);--ez-popup__title--color:var(--title--primary, #00281D);--ez-popup__title--font-weight:var(--font-weight--regular, 400)}.overlay{position:fixed;display:flex;top:0px;z-index:var(--ez-popup-z-index, 24);left:0px;width:100%;align-items:center;justify-content:center;box-sizing:border-box;height:100vh;backdrop-filter:blur(4px);background:rgba(0, 4, 12, 0.4)}.popup__container{width:auto;max-height:90%;height:100%;display:flex;flex-direction:column;overflow:hidden;outline:none;background:#FFFF;color:var(--ez-popup__container--color);border-radius:12px;box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122);box-sizing:border-box;padding:var(--ez-popup__container--padding);margin:0;border:none;position:unset}.popup__container--auto{height:auto}.popup__overflow-y--auto{overflow-y:auto}.popup__content{box-sizing:border-box;height:100%;width:100%}.popup__expandable-content{flex-grow:1;box-sizing:border-box;width:100%;font-family:var(--font--pattern, "Roboto");font-size:var(--font-size--default, 14px);color:var(--title--primary, #00281D);font-weight:var(--font-weight--regular, 400)}.popup__header{flex-shrink:0;width:100%;display:flex;align-items:center;margin-bottom:var(--space--16, 16px)}.popup__title{display:flex;margin:0;width:100%;font-family:var(--ez-popup__title--font-family);font-size:var(--ez-popup__title--font-size);font-weight:var(--ez-popup__title--font-weight);color:var(--ez-popup__title--color);line-height:var(--line-height--32, 32px)}.btn-close{justify-content:flex-end;align-self:flex-start;align-items:flex-start;display:flex;outline:none;border:none;background-color:unset;cursor:pointer}.btn-close--solo{width:100%}.popup__footer{flex-shrink:0;display:flex;width:100%;flex-direction:row-reverse;gap:var(--space--8, 8px)}.popup_margin-top{margin-top:var(--space--16, 16px)}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}.ez-popup__size-limit--x-small{min-width:350px;max-width:560px}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}';export{p as ez_popup}