@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-71072.0 → 0.0.0-bugfix-dev-KB-76362.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/cjs/{SnkMessageBuilder-bae64d0d.js → SnkMessageBuilder-7691a2c1.js} +10 -0
  2. package/dist/cjs/index-f9e81701.js +8 -0
  3. package/dist/cjs/input-distinct-search_2.cjs.entry.js +471 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_4.cjs.entry.js +22 -25
  7. package/dist/cjs/snk-application.cjs.entry.js +2 -18
  8. package/dist/cjs/snk-config-options_3.cjs.entry.js +5 -17
  9. package/dist/cjs/snk-crud.cjs.entry.js +2 -8
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -5
  11. package/dist/cjs/{snk-data-unit-3d9b6ed4.js → snk-data-unit-7dbdad0e.js} +14 -26
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
  14. package/dist/cjs/snk-distinct-search.cjs.entry.js +123 -0
  15. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +0 -9
  16. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -2
  17. package/dist/cjs/snk-grid.cjs.entry.js +2 -10
  18. package/dist/cjs/{snk-guides-viewer-2139481c.js → snk-guides-viewer-eee43c8b.js} +1 -1
  19. package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -1
  20. package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -7
  21. package/dist/cjs/snk-taskbar.cjs.entry.js +37 -40
  22. package/dist/collection/collection-manifest.json +3 -0
  23. package/dist/collection/components/snk-actions-button/snk-actions-button.js +26 -27
  24. package/dist/collection/components/snk-application/snk-application.js +1 -41
  25. package/dist/collection/components/snk-crud/snk-crud.js +2 -26
  26. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +1 -1
  27. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +3 -3
  28. package/dist/collection/components/snk-data-unit/snk-data-unit.js +13 -25
  29. package/dist/collection/components/snk-distinct-search/snk-distinct-search.css +4 -0
  30. package/dist/collection/components/snk-distinct-search/snk-distinct-search.js +372 -0
  31. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.css +110 -0
  32. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.js +544 -0
  33. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.css +28 -0
  34. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js +593 -0
  35. package/dist/collection/components/snk-distinct-search/utils/filter-distinct-search.js +15 -0
  36. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +1 -2
  37. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +1 -5
  38. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +0 -20
  39. package/dist/collection/components/snk-form-config/snk-form-config.js +5 -17
  40. package/dist/collection/components/snk-grid/snk-grid.js +2 -28
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +4 -25
  42. package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -41
  43. package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +25 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +1 -7
  45. package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
  46. package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +9 -0
  47. package/dist/components/SnkMessageBuilder.js +10 -0
  48. package/dist/components/filter-distinct-search.js +17 -0
  49. package/dist/components/index.d.ts +3 -0
  50. package/dist/components/index.js +3 -0
  51. package/dist/components/input-distinct-search.d.ts +11 -0
  52. package/dist/components/input-distinct-search.js +6 -0
  53. package/dist/components/input-distinct-search2.js +264 -0
  54. package/dist/components/search-modal.d.ts +11 -0
  55. package/dist/components/search-modal.js +6 -0
  56. package/dist/components/search-modal2.js +264 -0
  57. package/dist/components/snk-actions-button2.js +26 -27
  58. package/dist/components/snk-application2.js +2 -19
  59. package/dist/components/snk-crud.js +2 -9
  60. package/dist/components/snk-data-exporter2.js +3 -3
  61. package/dist/components/snk-data-unit2.js +13 -25
  62. package/dist/components/snk-detail-view2.js +1 -1
  63. package/dist/components/snk-distinct-search.d.ts +11 -0
  64. package/dist/components/snk-distinct-search.js +163 -0
  65. package/dist/components/snk-filter-bar2.js +0 -6
  66. package/dist/components/snk-filter-item2.js +1 -5
  67. package/dist/components/snk-filter-text.js +1 -2
  68. package/dist/components/snk-form-config2.js +5 -17
  69. package/dist/components/snk-grid2.js +2 -11
  70. package/dist/components/snk-simple-crud2.js +4 -8
  71. package/dist/components/snk-taskbar2.js +38 -41
  72. package/dist/esm/{SnkMessageBuilder-6fff4a4c.js → SnkMessageBuilder-7ace6803.js} +10 -0
  73. package/dist/esm/index-a7d3d3f1.js +8 -0
  74. package/dist/esm/input-distinct-search_2.entry.js +466 -0
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/sankhyablocks.js +1 -1
  77. package/dist/esm/snk-actions-button_4.entry.js +23 -26
  78. package/dist/esm/snk-application.entry.js +3 -19
  79. package/dist/esm/snk-config-options_3.entry.js +5 -17
  80. package/dist/esm/snk-crud.entry.js +2 -8
  81. package/dist/esm/snk-data-exporter.entry.js +5 -5
  82. package/dist/esm/{snk-data-unit-9fa7d2b9.js → snk-data-unit-7a579dbd.js} +14 -26
  83. package/dist/esm/snk-data-unit.entry.js +2 -2
  84. package/dist/esm/snk-detail-view.entry.js +2 -2
  85. package/dist/esm/snk-distinct-search.entry.js +119 -0
  86. package/dist/esm/snk-filter-bar_4.entry.js +1 -10
  87. package/dist/esm/snk-filter-text.entry.js +1 -2
  88. package/dist/esm/snk-grid.entry.js +2 -10
  89. package/dist/esm/{snk-guides-viewer-b7ed39eb.js → snk-guides-viewer-e8ca764a.js} +1 -1
  90. package/dist/esm/snk-guides-viewer.entry.js +1 -1
  91. package/dist/esm/snk-simple-crud.entry.js +4 -7
  92. package/dist/esm/snk-taskbar.entry.js +38 -41
  93. package/dist/sankhyablocks/{p-483ef1fa.entry.js → p-00f9fe5c.entry.js} +1 -1
  94. package/dist/sankhyablocks/p-0e250436.entry.js +1 -0
  95. package/dist/sankhyablocks/p-154aa2a6.entry.js +11 -0
  96. package/dist/sankhyablocks/p-18cb1acb.entry.js +1 -0
  97. package/dist/sankhyablocks/p-1dbd5c18.entry.js +1 -0
  98. package/dist/sankhyablocks/p-2aae03a1.entry.js +1 -0
  99. package/dist/sankhyablocks/p-30ebcbe0.entry.js +1 -0
  100. package/dist/sankhyablocks/p-3858a2e4.entry.js +1 -0
  101. package/dist/sankhyablocks/{p-4138da61.entry.js → p-42130213.entry.js} +1 -1
  102. package/dist/sankhyablocks/p-563b7c28.entry.js +1 -0
  103. package/dist/sankhyablocks/p-96a89d58.entry.js +1 -0
  104. package/dist/sankhyablocks/p-987c7328.entry.js +1 -0
  105. package/dist/sankhyablocks/{p-e390641b.entry.js → p-b389ed49.entry.js} +1 -1
  106. package/dist/sankhyablocks/p-c75fae8e.js +1 -0
  107. package/dist/sankhyablocks/p-d8665750.js +1 -0
  108. package/dist/sankhyablocks/{p-e97be1c8.js → p-e3a285a2.js} +1 -1
  109. package/dist/sankhyablocks/p-f0aaad2b.entry.js +1 -0
  110. package/dist/sankhyablocks/{p-0d2a2e9e.entry.js → p-f4e221b2.entry.js} +1 -1
  111. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  112. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +2 -3
  113. package/dist/types/components/snk-application/snk-application.d.ts +1 -6
  114. package/dist/types/components/snk-crud/snk-crud.d.ts +0 -4
  115. package/dist/types/components/snk-distinct-search/snk-distinct-search.d.ts +83 -0
  116. package/dist/types/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.d.ts +105 -0
  117. package/dist/types/components/snk-distinct-search/subcomponents/search-modal/search-modal.d.ts +127 -0
  118. package/dist/types/components/snk-distinct-search/types/index.d.ts +12 -0
  119. package/dist/types/components/snk-distinct-search/utils/filter-distinct-search.d.ts +4 -0
  120. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +0 -2
  121. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -4
  122. package/dist/types/components/snk-grid/snk-grid.d.ts +0 -4
  123. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -2
  124. package/dist/types/components.d.ts +393 -31
  125. package/dist/types/lib/http/data-fetcher/fetchers/distinct-search-fetcher.d.ts +6 -0
  126. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +0 -1
  127. package/dist/types/lib/message/resources/snk-distinct-search.msg.d.ts +2 -0
  128. package/package.json +1 -1
  129. package/react/components.d.ts +3 -0
  130. package/react/components.js +3 -0
  131. package/react/components.js.map +1 -1
  132. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.js +0 -8
  133. package/dist/sankhyablocks/p-0387d9d7.entry.js +0 -1
  134. package/dist/sankhyablocks/p-17425c72.js +0 -1
  135. package/dist/sankhyablocks/p-1d3ce0d9.entry.js +0 -1
  136. package/dist/sankhyablocks/p-342eeb3b.js +0 -1
  137. package/dist/sankhyablocks/p-3728d2aa.entry.js +0 -11
  138. package/dist/sankhyablocks/p-4e1f992e.entry.js +0 -1
  139. package/dist/sankhyablocks/p-619aeac8.entry.js +0 -1
  140. package/dist/sankhyablocks/p-89c92727.entry.js +0 -1
  141. package/dist/sankhyablocks/p-a3fadd0b.entry.js +0 -1
  142. package/dist/sankhyablocks/p-af7f7b3e.entry.js +0 -1
  143. package/dist/sankhyablocks/p-ec43fcc8.entry.js +0 -1
  144. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +0 -3
  145. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.d.ts +0 -7
  146. /package/dist/collection/components/{snk-actions-button/interfaces → snk-distinct-search/types}/index.js +0 -0
@@ -123,7 +123,6 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
123
123
  this.mode = SIMPLE_CRUD_MODE.SERVER;
124
124
  this.gridConfig = undefined;
125
125
  this.formConfig = undefined;
126
- this.enableLockManger = false;
127
126
  this._formFields = [];
128
127
  this._fieldsProps = new Map();
129
128
  this._enableContinuousInsert = true;
@@ -808,18 +807,16 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
808
807
  return;
809
808
  this.goToView(VIEW_MODE.FORM);
810
809
  }
811
- renderTaskbarContent() {
812
- var _a;
813
- return (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "ez-box ez-box--shadow ez-padding--small", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
814
- }
815
810
  /* istanbul ignore next */
816
811
  render() {
812
+ var _a;
817
813
  if (this.dataUnit == undefined) {
818
814
  return;
819
815
  }
820
- return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
816
+ const taskbarContent = (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "ez-box ez-box--shadow ez-padding--small", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
817
+ return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID && !this.enableGridInsert, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, this._currentViewMode === VIEW_MODE.FORM && taskbarContent, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
821
818
  ? undefined
822
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, this.renderTaskbarContent(), h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, this.renderTaskbarContent(), h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
819
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert }, this._currentViewMode === VIEW_MODE.GRID && taskbarContent, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
823
820
  }
824
821
  get _element() { return this; }
825
822
  static get watchers() { return {
@@ -838,7 +835,6 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
838
835
  "mode": [2],
839
836
  "gridConfig": [1040],
840
837
  "formConfig": [1040],
841
- "enableLockManger": [4, "enable-lock-manger"],
842
838
  "multipleSelection": [4, "multiple-selection"],
843
839
  "useCancelConfirm": [4, "use-cancel-confirm"],
844
840
  "pageSize": [2, "page-size"],
@@ -1,5 +1,5 @@
1
1
  import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
2
- import { Action, LockManager, LockManagerOperation, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
2
+ import { Action, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { A as AuthorizationConfig } from './AuthorizationConfig.js';
4
4
  import { P as PresentationMode } from './ISave.js';
5
5
  import { s as store } from './index2.js';
@@ -273,44 +273,42 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
273
273
  return key ? (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, {}) : "";
274
274
  }
275
275
  elementClick(elem) {
276
- LockManager.whenResolve(this._element, LockManagerOperation.TASKBAR_CLICK).then(() => {
277
- if (this.dataUnit) {
278
- switch (elem) {
279
- case TaskbarElement.PREVIOUS:
280
- this.dataUnit.previousRecord();
281
- break;
282
- case TaskbarElement.NEXT:
283
- this.dataUnit.nextRecord();
284
- break;
285
- case TaskbarElement.REFRESH:
286
- this.dataUnit.loadData();
287
- break;
288
- case TaskbarElement.CLONE:
289
- this.dataUnit.copySelected();
290
- break;
291
- case TaskbarElement.REMOVE:
292
- this.dataUnit.removeSelectedRecords();
293
- break;
294
- case TaskbarElement.INSERT:
295
- this.dataUnit.addRecord();
296
- break;
297
- case TaskbarElement.CANCEL:
298
- this.dataUnit.cancelEdition();
299
- break;
300
- case TaskbarElement.SAVE:
301
- if (!this._isWaitingForSave) {
302
- this._isWaitingForSave = true;
303
- this.dataUnit.saveData()
304
- .finally(() => {
305
- this._isWaitingForSave = false;
306
- });
307
- }
308
- break;
309
- }
276
+ if (this.dataUnit) {
277
+ switch (elem) {
278
+ case TaskbarElement.PREVIOUS:
279
+ this.dataUnit.previousRecord();
280
+ break;
281
+ case TaskbarElement.NEXT:
282
+ this.dataUnit.nextRecord();
283
+ break;
284
+ case TaskbarElement.REFRESH:
285
+ this.dataUnit.loadData();
286
+ break;
287
+ case TaskbarElement.CLONE:
288
+ this.dataUnit.copySelected();
289
+ break;
290
+ case TaskbarElement.REMOVE:
291
+ this.dataUnit.removeSelectedRecords();
292
+ break;
293
+ case TaskbarElement.INSERT:
294
+ this.dataUnit.addRecord();
295
+ break;
296
+ case TaskbarElement.CANCEL:
297
+ this.dataUnit.cancelEdition();
298
+ break;
299
+ case TaskbarElement.SAVE:
300
+ if (!this._isWaitingForSave) {
301
+ this._isWaitingForSave = true;
302
+ this.dataUnit.saveData()
303
+ .finally(() => {
304
+ this._isWaitingForSave = false;
305
+ });
306
+ }
307
+ break;
310
308
  }
311
- if (this.isEnabled(elem))
312
- this.actionClick.emit(elem);
313
- });
309
+ }
310
+ if (this.isEnabled(elem))
311
+ this.actionClick.emit(elem);
314
312
  }
315
313
  isEnabled(elem) {
316
314
  if (!this.isAllowed(elem)) {
@@ -514,10 +512,9 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
514
512
  this._lastWidth = this._element.getBoundingClientRect().width;
515
513
  }
516
514
  disconnectedCallback() {
517
- var _a, _b;
518
- (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.unsubscribe(this.onSaveEvent);
515
+ var _a;
519
516
  this.unlinkAllCustomElements();
520
- (_b = this._overFlowWatcher) === null || _b === void 0 ? void 0 : _b.destroy();
517
+ (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.destroy();
521
518
  }
522
519
  unlinkAllCustomElements() {
523
520
  var _a;
@@ -172,6 +172,15 @@ const snkAttachMessages$1 = {
172
172
  }
173
173
  };
174
174
 
175
+ const snkDistinctSearchMessages = {
176
+ titleBadgeNew: "novo",
177
+ titleAdd: "Adicionar",
178
+ availableResults: "resultados disponíveis",
179
+ availableResult: "resultado disponível",
180
+ limitResult: "Esta pesquisa foi limitada, existem mais resultados",
181
+ emptyResult: "Nenhum resultado disponível. <br/>Você pode adicionar um novo termo",
182
+ };
183
+
175
184
  const snkConfigOptionsMessages = {
176
185
  label: {
177
186
  nameField: "Nome do Campo *",
@@ -552,6 +561,7 @@ class SnkMessageBuilder {
552
561
  snkEntityList: snkEntityListMessages,
553
562
  snkActionsButton: snkActionsButtonMessages,
554
563
  snkPrintSelector: snkPrintSelectorMessages,
564
+ snkDistinctSearch: snkDistinctSearchMessages,
555
565
  };
556
566
  this._currentOperation = OperationMap.CLEAN;
557
567
  this._domainName = domainName;
@@ -2110,6 +2110,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2110
2110
  return import(
2111
2111
  /* webpackMode: "lazy" */
2112
2112
  './snk-custom-slot-elements.entry.js').then(processMod, consoleError);
2113
+ case 'snk-distinct-search':
2114
+ return import(
2115
+ /* webpackMode: "lazy" */
2116
+ './snk-distinct-search.entry.js').then(processMod, consoleError);
2113
2117
  case 'snk-entity-list':
2114
2118
  return import(
2115
2119
  /* webpackMode: "lazy" */
@@ -2154,6 +2158,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2154
2158
  return import(
2155
2159
  /* webpackMode: "lazy" */
2156
2160
  './teste-pesquisa.entry.js').then(processMod, consoleError);
2161
+ case 'input-distinct-search_2':
2162
+ return import(
2163
+ /* webpackMode: "lazy" */
2164
+ './input-distinct-search_2.entry.js').then(processMod, consoleError);
2157
2165
  case 'snk-filter-modal-item':
2158
2166
  return import(
2159
2167
  /* webpackMode: "lazy" */
@@ -0,0 +1,466 @@
1
+ import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host, g as getElement } from './index-a7d3d3f1.js';
2
+ import { KeyboardManager } from '@sankhyalabs/core';
3
+ import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
4
+
5
+ function normalizeString(text = "") {
6
+ return text.normalize('NFD').replace(/[\u0300-\u036f/\s'"&.-]/g, "").toUpperCase();
7
+ }
8
+ function filterItems(searchArgument, distinctItems, maxItems) {
9
+ const normalizedSearch = normalizeString(searchArgument);
10
+ const filteredDistincts = distinctItems.filter((item) => normalizeString(item).includes(normalizedSearch));
11
+ const isLimited = filteredDistincts.length > maxItems;
12
+ const items = filteredDistincts.slice(0, maxItems);
13
+ return { items, isLimited };
14
+ }
15
+ function getMatchOption(value, distinctItems) {
16
+ const normalizedSearch = normalizeString(value);
17
+ const item = distinctItems.find((item) => normalizeString(item) === normalizedSearch);
18
+ return item;
19
+ }
20
+
21
+ const inputDistinctSearchCss = ":host{--max-height-popover:180px;--scrollbar--color-default:var(--scrollbar--default, #626e82);--scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--scrollbar--border-radius:var(--border--radius-small, 6px);--scrollbar--width:var(--space--medium, 12px)}.divider{margin:var(--space--extra-small, 3px) 0;border:var(--border--small, 1px solid) var(--color--disable-secondary, #F2F5F8)}.new-value{color:var(--text--primary, #626e82);padding:var(--space--2xs, 8px) var(--space--3xs, 4px);font-size:var(--text--medium, 14px);font-family:var(--font-pattern, Roboto);cursor:pointer;border-radius:var(--border--radius-small, 6px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:none;background:none;width:100%;display:flex;min-height:max-content}.new-value-selected{background-color:var(--color--primary-300, #E2F4EF)}.new-value:hover{background-color:var(--background--medium, #e0e0e0)}.popover-content{margin:var(--space--small, 6px);max-height:calc(var(--max-height-popover) - (2 * var(--space--small, 6px)));display:flex;flex-direction:column}.list-container{overflow:auto;scrollbar-width:thin;scrollbar-color:var(--scrollbar--color-clicked) var(--scrollbar--color-background);padding-right:var(--space--small, 6px)}.list-container::-webkit-scrollbar{background-color:var(--scrollbar--color-background);width:var(--scrollbar--width);max-width:var(--scrollbar--width);min-width:var(--scrollbar--width)}.list-container::-webkit-scrollbar-track{background-color:var(--scrollbar--color-background);border-radius:var(--scrollbar--border-radius)}.list-container::-webkit-scrollbar-thumb{background-color:var(--scrollbar--color-default);border-radius:var(--scrollbar--border-radius)}.list-container::-webkit-scrollbar-thumb:vertical:hover,.list-container::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--scrollbar--color-hover)}.list-container::-webkit-scrollbar-thumb:vertical:active,.list-container::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--scrollbar--color-clicked)}ez-popover{--ez-popover__box--z-index:15}.space-error{--ez-popover__margin:-19px 0 0 0}ez-list{--ez-list__item--margin:0}ez-text-input{--ez-text-input__icon--margin:var(--space--xs, 12px)}.badge-primary{--ez-badge--background-color:var(--color--primary-300);--ez-badge--color:var(--color--primary)}";
22
+
23
+ const InputDistinctSearch = class {
24
+ constructor(hostRef) {
25
+ registerInstance(this, hostRef);
26
+ this.changeValue = createEvent(this, "changeValue", 7);
27
+ this.iconClick = createEvent(this, "iconClick", 7);
28
+ this.textValue = "";
29
+ this.isNewItem = false;
30
+ this.filteredItems = [];
31
+ this.isNewItemSelected = false;
32
+ this.application = undefined;
33
+ this.distinctItems = [];
34
+ this.label = "";
35
+ this.value = "";
36
+ this.maxItems = 100;
37
+ this.debounceTime = 300;
38
+ this.canShowError = false;
39
+ this.mode = 'regular';
40
+ this.restrict = undefined;
41
+ this.errorMessage = undefined;
42
+ }
43
+ async observerValue(newValue) {
44
+ await this.selectedNewItem(newValue, true);
45
+ }
46
+ /**
47
+ * Seleciona um item
48
+ */
49
+ async selectValue(value, isNewItem = false) {
50
+ this.isNewItem = isNewItem;
51
+ this.textValue = value;
52
+ await this._refFilterInput.setValue(value);
53
+ }
54
+ /**
55
+ * Método para limpa o campo de entrada de pesquisa
56
+ */
57
+ clearInput() {
58
+ this._refFilterInput.setValue("");
59
+ }
60
+ /**
61
+ * Retorna se o conteúdo é inválido.
62
+ */
63
+ isInvalid() {
64
+ return this._refFilterInput.isInvalid();
65
+ }
66
+ /**
67
+ * Remove o foco do campo
68
+ */
69
+ setBlur() {
70
+ this._refFilterInput.setBlur();
71
+ }
72
+ /**
73
+ * Aplica o foco do campo
74
+ */
75
+ setFocus() {
76
+ this._refFilterInput.setFocus();
77
+ }
78
+ getMessage(key) {
79
+ return this.application.messagesBuilder.getMessage(key, null);
80
+ }
81
+ async optionLoader(searchArgument) {
82
+ return new Promise((resolve) => {
83
+ if (this._debounceTimeout) {
84
+ clearTimeout(this._debounceTimeout);
85
+ }
86
+ this._debounceTimeout = setTimeout(() => {
87
+ const { items } = filterItems(searchArgument, this.distinctItems, this.maxItems);
88
+ this.filteredItems = items;
89
+ resolve();
90
+ }, this.debounceTime);
91
+ });
92
+ }
93
+ async openPopOver() {
94
+ var _a;
95
+ await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.showUnder(this._refFilterInput));
96
+ }
97
+ async closePopOver() {
98
+ var _a;
99
+ this.isNewItemSelected = false;
100
+ await ((_a = this._refPopOver) === null || _a === void 0 ? void 0 : _a.hide());
101
+ await this._refList.removeSelection();
102
+ }
103
+ async onTextChange(event) {
104
+ this.textValue = event.detail;
105
+ await this.optionLoader(event.detail);
106
+ await this.selectFirstItem();
107
+ }
108
+ onIconClick() {
109
+ this.iconClick.emit();
110
+ }
111
+ buidItems() {
112
+ var _a;
113
+ const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
114
+ label: item,
115
+ id: normalizeString(item),
116
+ }));
117
+ return items;
118
+ }
119
+ async setValue(value, isNewItem = false, preventEventEmit = false) {
120
+ this.isNewItem = isNewItem;
121
+ this.textValue = value;
122
+ await this._refFilterInput.setValue(value);
123
+ await this.closePopOver();
124
+ if (!preventEventEmit) {
125
+ this.changeValue.emit({
126
+ value,
127
+ isNewItem,
128
+ });
129
+ }
130
+ }
131
+ async selectedNewItem(value, preventEventEmit = false) {
132
+ if (!this.textValue && !value) {
133
+ await this.setValue("", false, preventEventEmit);
134
+ return;
135
+ }
136
+ const item = getMatchOption(value !== null && value !== void 0 ? value : this.textValue, this.distinctItems);
137
+ if (item) {
138
+ await this.setValue(item, false, preventEventEmit);
139
+ return;
140
+ }
141
+ await this.setValue(this.textValue || value, true, preventEventEmit);
142
+ }
143
+ async setSelectedValue() {
144
+ const selectedValue = await this._refList.getSelection();
145
+ await this.selectedNewItem((selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.label) || this.textValue, true);
146
+ await this._refFilterInput.setBlur();
147
+ this._element.focus();
148
+ }
149
+ async selectNextItem() {
150
+ if (this.isNewItemSelected) {
151
+ return;
152
+ }
153
+ const itemSelected = await this._refList.getSelection();
154
+ const itemsAmount = this.filteredItems.length;
155
+ const indexSelected = this.filteredItems.findIndex((item) => item === (itemSelected === null || itemSelected === void 0 ? void 0 : itemSelected.label));
156
+ const isLastItemSelected = indexSelected === (itemsAmount - 1);
157
+ const optionNewItemIsAvailable = !!this.textValue;
158
+ if (!isLastItemSelected || !optionNewItemIsAvailable) {
159
+ this.isNewItemSelected = false;
160
+ await this._refList.selectNextItem();
161
+ return;
162
+ }
163
+ this.isNewItemSelected = true;
164
+ await this._refList.removeSelection();
165
+ }
166
+ async selectPreviousItem() {
167
+ const itemsAmount = this.filteredItems.length;
168
+ const lastItem = this.filteredItems[itemsAmount - 1];
169
+ if (this.isNewItemSelected && lastItem) {
170
+ this.isNewItemSelected = false;
171
+ await this._refList.setSelection({
172
+ id: normalizeString(lastItem),
173
+ label: lastItem
174
+ });
175
+ return;
176
+ }
177
+ await this._refList.selectPreviousItem();
178
+ }
179
+ bindKeyboardManager() {
180
+ this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
181
+ this._keyboardManager
182
+ .bind("ArrowDown", () => { this.selectNextItem(); })
183
+ .bind("ArrowUp", () => { this.selectPreviousItem(); })
184
+ .bind("Enter", () => { this.setSelectedValue(); })
185
+ .bind("Tab", () => { this.setSelectedValue(); });
186
+ }
187
+ unbindKeyboardManager() {
188
+ this._keyboardManager
189
+ .unbind("ArrowDown")
190
+ .unbind("ArrowUp")
191
+ .unbind("Enter")
192
+ .unbind("Tab");
193
+ }
194
+ async selectFirstItem() {
195
+ if (!this.filteredItems.length) {
196
+ await this._refList.removeSelection();
197
+ this.isNewItemSelected = true;
198
+ return;
199
+ }
200
+ const firstItem = this.filteredItems[0];
201
+ this.isNewItemSelected = false;
202
+ await this._refList.setSelection({
203
+ id: normalizeString(firstItem),
204
+ label: firstItem,
205
+ });
206
+ }
207
+ initializeComponent() {
208
+ const { items } = filterItems("", this.distinctItems, this.maxItems);
209
+ this.filteredItems = items;
210
+ }
211
+ componentWillLoad() {
212
+ this.initializeComponent();
213
+ }
214
+ async componentDidLoad() {
215
+ this.bindKeyboardManager();
216
+ this.selectFirstItem();
217
+ await this.selectedNewItem(this.value, true);
218
+ }
219
+ disconnectedCallback() {
220
+ this.unbindKeyboardManager();
221
+ }
222
+ buildNewItemOption() {
223
+ if (!this.textValue) {
224
+ return;
225
+ }
226
+ return (h(Fragment, null, !!this.filteredItems.length &&
227
+ h("hr", { class: "divider" }), h("button", { slot: "bottomSlot", class: {
228
+ "new-value": true,
229
+ "new-value-selected": this.isNewItemSelected,
230
+ }, title: `${this.getMessage("snkDistinctSearch.titleAdd")} '${this.textValue}'`, onClick: () => this.selectedNewItem.bind(this)(undefined, true) }, this.getMessage("snkDistinctSearch.titleAdd"), " '", this.textValue, "'")));
231
+ }
232
+ render() {
233
+ return (h(Host, { onBlur: () => this.selectedNewItem.bind(this)() }, h("ez-filter-input", { ref: (ref) => this._refFilterInput = ref, label: this.label, value: this.textValue, onEzChange: this.onTextChange.bind(this), onEzIconClick: this.onIconClick.bind(this), onEzFocusIn: this.openPopOver.bind(this), canShowError: this.canShowError, mode: this.mode, restrict: this.restrict, errorMessage: this.errorMessage, enabledIconClick: true }, this.isNewItem &&
234
+ h("ez-badge", { slot: "right", label: this.getMessage("snkDistinctSearch.titleBadgeNew"), size: "small-medium", class: "badge-primary" })), h("ez-popover", { ref: (ref) => this._refPopOver = ref, boxWidth: "full-width", autoClose: false, overlayType: "none", class: {
235
+ 'space-error': this.canShowError,
236
+ } }, h("div", { class: "popover-content" }, h("section", { class: "list-container" }, h("ez-list", { ref: (ref) => this._refList = ref, dataSource: this.buidItems(), onEzClickItem: ({ detail }) => this.setValue.bind(this)(detail.label, false, true), ezSelectable: true, hoverFeedback: true, disableShortcuts: true })), this.buildNewItemOption()))));
237
+ }
238
+ get _element() { return getElement(this); }
239
+ static get watchers() { return {
240
+ "value": ["observerValue"]
241
+ }; }
242
+ };
243
+ InputDistinctSearch.style = inputDistinctSearchCss;
244
+
245
+ const searchModalCss = ".sc-search-modal-h{display:block}ez-popup.sc-search-modal{--ez-popup__title--font-size:var(--title--large, 20px);--ez-popup__container--height:380px}.search-modal-scroller.sc-search-modal{height:174px}.search-modal-text.sc-search-modal{font-family:var(--font-pattern);color:var(--text--primary);font-size:var(--text--medium)}ez-filter-input.sc-search-modal>input.sc-search-modal{text-overflow:ellipsis}.ez-content.sc-search-modal{height:190px;display:flex;align-items:center;justify-content:center}";
246
+
247
+ const SearchModal = class {
248
+ constructor(hostRef) {
249
+ registerInstance(this, hostRef);
250
+ this.popupClose = createEvent(this, "popupClose", 7);
251
+ this.changeValue = createEvent(this, "changeValue", 7);
252
+ this.debounceTimeout = null;
253
+ this.filteredItems = [];
254
+ this.searchFocus = false;
255
+ this.isLimited = false;
256
+ this.application = undefined;
257
+ this.listItens = [];
258
+ this.opened = false;
259
+ this.value = undefined;
260
+ this.canShowError = false;
261
+ this.emptyMessage = undefined;
262
+ this.debounceTime = 300;
263
+ this.maxItens = 100;
264
+ this.label = 'Pesquisar';
265
+ this.mode = 'regular';
266
+ this.restrict = undefined;
267
+ this.errorMessage = undefined;
268
+ }
269
+ /**
270
+ * Método para adicionar a nova palavra e chamar o método closeModal() para fechar o modal
271
+ */
272
+ addNewItem() {
273
+ this.closeModal();
274
+ this.changeValue.emit({ isNewItem: true, value: this.value });
275
+ }
276
+ /**
277
+ * Método para limpa o campo de entrada de pesquisa
278
+ */
279
+ clearInput() {
280
+ this._refFilterInput.setValue("");
281
+ }
282
+ /**
283
+ * Método para fechar o modal
284
+ */
285
+ closeModal() {
286
+ this._popupElement.opened = false;
287
+ this.popupClose.emit(false);
288
+ }
289
+ /**
290
+ * Método para abrir o modal
291
+ */
292
+ openModal() {
293
+ this._popupElement.opened = true;
294
+ setTimeout(() => this.setFocus(), 100);
295
+ }
296
+ /**
297
+ * Retorna se o conteúdo é inválido.
298
+ */
299
+ isInvalid() {
300
+ this._refFilterInput.isInvalid();
301
+ }
302
+ /**
303
+ * Remove o foco do campo
304
+ */
305
+ setBlur() {
306
+ this._refFilterInput.setBlur();
307
+ this.searchFocus = false;
308
+ }
309
+ /**
310
+ * Aplica o foco do campo
311
+ */
312
+ setFocus() {
313
+ this._refFilterInput.setFocus();
314
+ this.searchFocus = true;
315
+ }
316
+ /**
317
+ * Método para tratar a mensagem de erro
318
+ */
319
+ watchPropErrorMessage() {
320
+ this._refFilterInput.errorMessage = this.errorMessage;
321
+ }
322
+ /**
323
+ * Método para tratar o value do input
324
+ */
325
+ watchPropValue() {
326
+ this._refFilterInput.value = this.value;
327
+ }
328
+ /**
329
+ * Atualiza a lista de itens à medida que o usuário digita no campo de pesquisa.
330
+ */
331
+ async handleInput(event) {
332
+ if (this.debounceTimeout) {
333
+ clearTimeout(this.debounceTimeout);
334
+ }
335
+ this.value = event.detail;
336
+ this.debounceTimeout = setTimeout(async () => {
337
+ var _a;
338
+ const { isLimited, items } = filterItems(event.detail, this.listItens, this.maxItens);
339
+ this.filteredItems = items;
340
+ this.isLimited = isLimited;
341
+ await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.removeSelection());
342
+ }, this.debounceTime);
343
+ }
344
+ initializeComponent() {
345
+ this.filteredItems = this.listItens;
346
+ }
347
+ getMessage(key) {
348
+ return this.application.messagesBuilder.getMessage(key, null);
349
+ }
350
+ componentWillLoad() {
351
+ this.initializeComponent();
352
+ }
353
+ componentDidLoad() {
354
+ this.bindKeyboardManager();
355
+ this._refFilterInput.value = this.value;
356
+ const { isLimited, items } = filterItems(this.value, this.listItens, this.maxItens);
357
+ this.filteredItems = items;
358
+ this.isLimited = isLimited;
359
+ }
360
+ disconnectedCallback() {
361
+ this.unbindKeyboardManager();
362
+ }
363
+ buildItems() {
364
+ var _a;
365
+ const items = (_a = this.filteredItems) === null || _a === void 0 ? void 0 : _a.map((item) => ({
366
+ label: item,
367
+ id: normalizeString(item),
368
+ }));
369
+ return items;
370
+ }
371
+ async tabSelect() {
372
+ var _a;
373
+ const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
374
+ if (this.searchFocus && this._refList) {
375
+ this.searchFocus = false;
376
+ this._refList.focus();
377
+ await this.selectFirstItem();
378
+ }
379
+ else if (selectedValue) {
380
+ await this._refList.removeSelection();
381
+ await this._refButton.setFocus();
382
+ }
383
+ else {
384
+ await this._refButton.setBlur();
385
+ this.setFocus();
386
+ }
387
+ }
388
+ bindKeyboardManager() {
389
+ this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
390
+ this._keyboardManager
391
+ .bind("ArrowDown", () => { this.selectNextItem(); })
392
+ .bind("ArrowUp", () => { this.selectPreviousItem(); })
393
+ .bind("Enter", () => { this.setSelectedValue(); })
394
+ .bind("Tab", () => { this.tabSelect(); });
395
+ }
396
+ unbindKeyboardManager() {
397
+ this._keyboardManager
398
+ .unbind("ArrowDown")
399
+ .unbind("ArrowUp")
400
+ .unbind("Enter")
401
+ .unbind("Tab");
402
+ }
403
+ async setSelectedValue() {
404
+ var _a;
405
+ const selectedValue = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
406
+ if (selectedValue) {
407
+ this.changeValue.emit({ isNewItem: false, value: selectedValue.label });
408
+ this.closeModal();
409
+ }
410
+ else if (this.searchFocus && this.enabledButtonNewItem()) {
411
+ this.addNewItem();
412
+ }
413
+ }
414
+ async selectNextItem() {
415
+ var _a;
416
+ const itemSelected = await ((_a = this._refList) === null || _a === void 0 ? void 0 : _a.getSelection());
417
+ if (this.searchFocus && !itemSelected) {
418
+ this.setBlur();
419
+ await this.selectFirstItem();
420
+ return;
421
+ }
422
+ await this._refList.selectNextItem();
423
+ }
424
+ async selectPreviousItem() {
425
+ const itemSelected = await this._refList.getSelection();
426
+ if (itemSelected === undefined)
427
+ return;
428
+ await this._refList.selectPreviousItem();
429
+ }
430
+ async selectFirstItem() {
431
+ if (!this.filteredItems.length) {
432
+ await this._refList.removeSelection();
433
+ return;
434
+ }
435
+ const firstItem = this.filteredItems[0];
436
+ await this._refList.setSelection({
437
+ id: normalizeString(firstItem),
438
+ label: firstItem,
439
+ });
440
+ }
441
+ enabledButtonNewItem() {
442
+ if (this.value === undefined)
443
+ return false;
444
+ if (getMatchOption(this.value, this.listItens))
445
+ return false;
446
+ return this.value.trim().length === 0 ? false : true;
447
+ }
448
+ buildMessage() {
449
+ if (this.isLimited) {
450
+ return this.getMessage("snkDistinctSearch.limitResult");
451
+ }
452
+ return `${this.filteredItems.length} ${this.filteredItems.length > 1 ? this.getMessage("snkDistinctSearch.availableResults") : this.getMessage("snkDistinctSearch.availableResult")}`;
453
+ }
454
+ render() {
455
+ var _a;
456
+ return (h(Host, null, h("ez-popup", { ref: (ref) => this._popupElement = ref, size: "x-small", "ez-title": this.label, onEzClosePopup: () => this.popupClose.emit(false), "height-mode": "auto" }, h("div", null, h("ez-filter-input", { ref: (ref) => this._refFilterInput = ref, label: "Pesquisar", onEzChange: this.handleInput.bind(this), onBlur: () => this.searchFocus = false, onEzFocusIn: () => this.searchFocus = true, errorMessage: this.errorMessage, canShowError: this.canShowError, mode: this.mode, value: this.value, restrict: this.restrict }), this.filteredItems.length === 0 ? (h("div", { class: "ez-content" }, h("div", { class: "ez-text--center search-modal-text" }, this.emptyMessage))) : (h("div", null, h("div", { class: "search-modal-text ez-padding-vertical--medium" }, this.buildMessage()), h("ez-scroller", { class: "search-modal-scroller", direction: EzScrollDirection.VERTICAL }, h("ez-list", { ref: (ref) => this._refList = ref, dataSource: this.buildItems(), onEzClickItem: ({ label }) => this.setSelectedValue.bind(this)(label), ezSelectable: true, hoverFeedback: true, disableShortcuts: true })))), h("div", { class: "ez-flex ez-flex--justify-end" }, h("ez-button", { ref: (ref) => this._refButton = ref, class: "ez-button--tertiary", enabled: this.enabledButtonNewItem(), label: `${this.getMessage("snkDistinctSearch.titleAdd")} ${(_a = this.label) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()}`, onClick: () => this.addNewItem() }))))));
457
+ }
458
+ get _element() { return getElement(this); }
459
+ static get watchers() { return {
460
+ "errorMessage": ["watchPropErrorMessage"],
461
+ "value": ["watchPropValue"]
462
+ }; }
463
+ };
464
+ SearchModal.style = searchModalCss;
465
+
466
+ export { InputDistinctSearch as input_distinct_search, SearchModal as search_modal };