From 2c0c7697d48c3dea1a755e5666cb716978e65a27 Mon Sep 17 00:00:00 2001 From: Igor Vinicius Date: Mon, 11 May 2026 16:10:39 -0300 Subject: [PATCH 1/6] =?UTF-8?q?chore:=20Atualiza=20vers=C3=A3o=20do=20cuid?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 28399dd2..3a5fb6d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sysvale/cuida", - "version": "3.156.1", + "version": "3.158.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@sysvale/cuida", - "version": "3.156.1", + "version": "3.158.1", "dependencies": { "@popperjs/core": "^2.11.6", "@sysvale/cuida-icons": "^1.18.0", diff --git a/package.json b/package.json index 9100fbf6..57f3aae2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sysvale/cuida", - "version": "3.158.0", + "version": "3.158.1", "description": "A design system built by Sysvale, using storybook and Vue components", "repository": { "type": "git", From 48b1d9258bac90f5ea57a0ebfb22905c5ea83ef9 Mon Sep 17 00:00:00 2001 From: Igor Vinicius Date: Mon, 11 May 2026 16:11:11 -0300 Subject: [PATCH 2/6] feat: Adiciona safe guards no componente para evitar que tente acessar propriedades sem que exista --- src/components/Multiselect.vue | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/Multiselect.vue b/src/components/Multiselect.vue index f52c70e4..98a64306 100644 --- a/src/components/Multiselect.vue +++ b/src/components/Multiselect.vue @@ -126,7 +126,7 @@ :option="option" :option-field="optionsField" > - {{ option[optionsField] }} + {{ option?.[optionsField] }} @@ -312,7 +312,7 @@ export default { selectedFancyMessage() { return (qty) => { if (qty === 1) { - return this.selectedValue[0][this.optionsField]; + return this.selectedValue?.[0]?.[this.optionsField]; } return `${qty} opções selecionadas`; }; @@ -366,6 +366,8 @@ export default { }, watch: { selectedValue(values) { + if (!Array.isArray(values)) return; + const cleanedValues = clone(values); cleanedValues.forEach((val) => delete val.isSelected); this.indeterminate = values.length > 0 && values.length < this.options.length; @@ -400,12 +402,28 @@ export default { const input = document.getElementById(`select-all-input-id-${this.uniqueKey}`); input.indeterminate = newValue; }, + + options: { + handler(newOptions) { + this.internalOptions = clone(newOptions || []); + + if (this.selectedValue?.length) { + this.updateRenderOptions(); + } + }, + deep: true, + immediate: true, + }, }, mounted() { + console.log('entrou no mounted'); if (!this.modelValue || this.modelValue.length === 0) return; - this.selectedValue = this.modelValue; + this.selectedValue = Array.isArray(this.modelValue) + ? this.modelValue + : []; + this.updateRenderOptions(); this.indeterminate = this.hasSelectedValues && this.selectedValue.length < this.options.length; }, From 03bbcdc28fbccedffda9c41907eda1864597dbb5 Mon Sep 17 00:00:00 2001 From: Igor Vinicius Date: Mon, 11 May 2026 16:21:59 -0300 Subject: [PATCH 3/6] fix: Remove console.log --- src/components/Multiselect.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Multiselect.vue b/src/components/Multiselect.vue index 98a64306..6bae059f 100644 --- a/src/components/Multiselect.vue +++ b/src/components/Multiselect.vue @@ -417,7 +417,6 @@ export default { }, mounted() { - console.log('entrou no mounted'); if (!this.modelValue || this.modelValue.length === 0) return; this.selectedValue = Array.isArray(this.modelValue) From 2c9de69733cc5260f6d23f5516d58fb556803ea8 Mon Sep 17 00:00:00 2001 From: Igor Vinicius Date: Tue, 12 May 2026 08:29:43 -0300 Subject: [PATCH 4/6] =?UTF-8?q?refactor:=20Ajusta=20checagem=20de=20campo?= =?UTF-8?q?=20selecionado=20via=20emiss=C3=A3o=20de=20clique=20pelo=20cust?= =?UTF-8?q?om=20check=20box?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Multiselect.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/Multiselect.vue b/src/components/Multiselect.vue index 6bae059f..fc952009 100644 --- a/src/components/Multiselect.vue +++ b/src/components/Multiselect.vue @@ -501,10 +501,19 @@ export default { addItemViaCustomCheckbox(option) { option.isSelected = !option.isSelected; - this.selectedValue = [ - ...this.selectedValue, - option, - ]; + + const isAlreadySelected = this.selectedValue.some( + item => item[this.optionsField] === option[this.optionsField] + ); + + if (isAlreadySelected) { + this.selectedValue = this.selectedValue.filter( + item => item[this.optionsField] !== option[this.optionsField] + ); + return; + } + + this.selectedValue = [...this.selectedValue, option]; }, handleClose() { From 98a13a0c1248972bb3b19a2e5e7e9c4e2fbce93e Mon Sep 17 00:00:00 2001 From: Igor Vinicius Date: Tue, 12 May 2026 11:52:56 -0300 Subject: [PATCH 5/6] =?UTF-8?q?refactor:=20Adapta=20l=C3=B3gica=20do=20sel?= =?UTF-8?q?ectedValue=20para=20atuar=20como=20two=20way=20binding=20e=20aj?= =?UTF-8?q?ustar=20l=C3=B3gicas=20de=20remo=C3=A7=C3=A3o=20de=20itens=20se?= =?UTF-8?q?lecionados,=20como=20tamb=C3=A9m=20checkbox=20customizado=20qua?= =?UTF-8?q?ndo=20=C3=A9=20limpo=20o=20modelValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Multiselect.vue | 57 ++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/components/Multiselect.vue b/src/components/Multiselect.vue index fc952009..488e2335 100644 --- a/src/components/Multiselect.vue +++ b/src/components/Multiselect.vue @@ -288,7 +288,6 @@ export default { data() { return { - selectedValue: this.$attrs.modelValue || [], internalOptions: clone(this.options), groupValues: null, groupLabel: null, @@ -301,6 +300,33 @@ export default { }, computed: { + selectedValue: { + get() { + return this.modelValue || []; + }, + set(value) { + if (!Array.isArray(value)) return; + + const cleaned = clone(value); + cleaned.forEach(val => delete val.isSelected); + this.indeterminate = value.length > 0 && value.length < this.options.length; + + /** + * Evento utilizado para implementar o v-model. + * @event input + * @type {Event} + */ + this.$emit('input', cleaned); + + /** + * Evento que indica que o valor do Multiselect foi alterado + * @event update:modelValue + * @type {Event} + */ + this.$emit('update:modelValue', cleaned); + } + }, + hasSlots() { return !!Object.keys(this.$slots).length; }, @@ -365,25 +391,13 @@ export default { }, }, watch: { - selectedValue(values) { - if (!Array.isArray(values)) return; - - const cleanedValues = clone(values); - cleanedValues.forEach((val) => delete val.isSelected); - this.indeterminate = values.length > 0 && values.length < this.options.length; - /** - * Evento utilizado para implementar o v-model. - * @event input - * @type {Event} - */ - this.$emit('input', cleanedValues); - - /** - * Evento que indica que o valor do Multiselect foi alterado - * @event update:modelValue - * @type {Event} - */ - this.$emit('update:modelValue', cleanedValues); + modelValue: { + handler(newValue) { + if (!newValue || newValue.length === 0) { + this.updateRenderOptions(); + } + }, + deep: true }, isAllItemsSelected(newValue) { @@ -536,6 +550,9 @@ export default { this.groupValues = null; this.groupLabel = null; + + this.selectAllValue = false; + this.indeterminate = false; return; } From 8be3d9d27371b29271b6c5f60b25f15bbb9dda81 Mon Sep 17 00:00:00 2001 From: Igor Vinicius Date: Tue, 12 May 2026 13:22:47 -0300 Subject: [PATCH 6/6] =?UTF-8?q?refactor:=20Ajusta=20reatividade=20da=20doc?= =?UTF-8?q?umenta=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/forms/multiselect.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/components/forms/multiselect.md b/docs/components/forms/multiselect.md index 846cd4ff..17aa8b6f 100644 --- a/docs/components/forms/multiselect.md +++ b/docs/components/forms/multiselect.md @@ -43,6 +43,7 @@ leitura da documentação. :args :events :component="CdsMultiselect" + @update:modelValue="handleUpdate" /> --- @@ -101,4 +102,8 @@ const args = ref({ trackBy: 'title', variant: 'green', }); + +const handleUpdate = (value) => { + args.value.modelValue = value; +};