@tagplus/components 4.8.3 → 4.9.0

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.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "email": "bruno@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "4.8.3",
11
+ "version": "4.9.0",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -729,6 +729,57 @@ export default {
729
729
  ) {
730
730
  this.checkDefaultFirstOption()
731
731
  }
732
+ },
733
+
734
+ /**
735
+ * Sobrescreve função do select para apagar a query após a seleção de um item
736
+ * Link para a função original: https://github.com/ElemeFE/element/blob/c345bb453bf11badb4831a6a3f600c9372b3a336/packages/select/src/select.vue#L685
737
+ * Manipula a seleção de uma opção em Multisuggest.
738
+ * @param {Object} option - A opção selecionada.
739
+ * @param {boolean} byClick - Indica se a seleção foi feita por clique.
740
+ * Se o componente permite múltiplas seleções (this.multiple):
741
+ * - Clona o valor atual (this.value) e obtém o index da opção selecionada.
742
+ * - Se a opção já estiver selecionada, a remove das opções selecionadas.
743
+ * - Se a opção não estiver selecionada e o limite de múltiplas seleções não foi atingido, adiciona a opções selecionadas.
744
+ * - Emite o evento 'input' com o novo valor e chama emitChange.
745
+ * - Limpa a query e, se a opção foi criada, redefine a query e o comprimento do input.
746
+ * - Se o componente for filtrável, foca no input.
747
+ * Se o componente não permite múltiplas seleções:
748
+ * - Emite o evento 'input' com o valor da opção e chama emitChange.
749
+ * - Define a visibilidade como falsa.
750
+ * Define isSilentBlur com base no parâmetro byClick e chama setSoftFocus.
751
+ * Se o componente não estiver visível, rola até a opção selecionada no próximo tick.
752
+ */
753
+ handleOptionSelect (option, byClick) {
754
+ if (this.multiple) {
755
+ const value = (this.value || []).slice()
756
+ const optionIndex = this.getValueIndex(value, option.value)
757
+ if (optionIndex > -1) {
758
+ value.splice(optionIndex, 1)
759
+ } else if (this.multipleLimit <= 0 || value.length < this.multipleLimit) {
760
+ value.push(option.value)
761
+ }
762
+ this.$emit('input', value)
763
+ this.emitChange(value)
764
+ this.query = ''
765
+ if (option.created) {
766
+ this.handleQueryChange('')
767
+ this.inputLength = 20
768
+ }
769
+ if (this.filterable) {
770
+ this.$refs.input.focus()
771
+ }
772
+ } else {
773
+ this.$emit('input', option.value)
774
+ this.emitChange(option.value)
775
+ this.visible = false
776
+ }
777
+ this.isSilentBlur = byClick
778
+ this.setSoftFocus()
779
+ if (this.visible) return
780
+ this.$nextTick(() => {
781
+ this.scrollToOption(option)
782
+ })
732
783
  }
733
784
  }
734
785
  }