Skip to content

Commit

Permalink
fix: issue with vue v-model
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget committed Jan 16, 2025
1 parent a4cd422 commit 397bf2a
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/components/scripts/post-build/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default (tmp?: boolean) => {
)
)})\n\nconst props =`
});
replacements.push({
from: 'handleFrameworkEventVue(() => {}',
to: 'handleFrameworkEventVue(emit'
});
}

runReplacements(replacements, component, 'vue', vueFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function DBCheckbox(props: DBCheckboxProps) {
useTarget({
angular: () =>
handleFrameworkEventAngular(this, event, 'checked'),
vue: () => handleFrameworkEventVue(this, event, 'checked')
vue: () => handleFrameworkEventVue(() => {}, event, 'checked')
});

/* For a11y reasons we need to map the correct message with the checkbox */
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/input/input.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function DBInput(props: DBInputProps) {

useTarget({
angular: () => handleFrameworkEventAngular(this, event),
vue: () => handleFrameworkEventVue(this, event)
vue: () => handleFrameworkEventVue(() => {}, event)
});

/* For a11y reasons we need to map the correct message with the input */
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/radio/radio.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function DBRadio(props: DBRadioProps) {
useTarget({
angular: () =>
handleFrameworkEventAngular(this, event, 'checked'),
vue: () => handleFrameworkEventVue(this, event, 'checked')
vue: () => handleFrameworkEventVue(() => {}, event, 'checked')
});
},
handleBlur: (event: InteractionEvent<HTMLInputElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/select/select.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function DBSelect(props: DBSelectProps) {

useTarget({
angular: () => handleFrameworkEventAngular(this, event),
vue: () => handleFrameworkEventVue(this, event)
vue: () => handleFrameworkEventVue(() => {}, event)
});

/* For a11y reasons we need to map the correct message with the select */
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/switch/switch.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function DBSwitch(props: DBSwitchProps) {
useTarget({
angular: () =>
handleFrameworkEventAngular(this, event, 'checked'),
vue: () => handleFrameworkEventVue(this, event, 'checked')
vue: () => handleFrameworkEventVue(() => {}, event, 'checked')
});
},
handleBlur: (event: InteractionEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function DBTabItem(props: DBTabItemProps) {
useTarget({
angular: () =>
handleFrameworkEventAngular(this, event, 'checked'),
vue: () => handleFrameworkEventVue(this, event, 'checked')
vue: () => handleFrameworkEventVue(() => {}, event, 'checked')
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function DBTextarea(props: DBTextareaProps) {
}
useTarget({
angular: () => handleFrameworkEventAngular(this, event),
vue: () => handleFrameworkEventVue(this, event)
vue: () => handleFrameworkEventVue(() => {}, event)
});

/* For a11y reasons we need to map the correct message with the textarea */
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/utils/form-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export const handleFrameworkEventAngular = (
};

export const handleFrameworkEventVue = (
component: any,
emit: (event: string, ...args: any[]) => void,
event: any,
modelValue: string = 'value'
): void => {
// TODO: Replace this with the solution out of https://github.com/BuilderIO/mitosis/issues/833 after this has been "solved"
component.emit(`update:${modelValue}`, event.target[modelValue]);
emit(`update:${modelValue}`, event.target[modelValue]);
};
2 changes: 1 addition & 1 deletion showcases/vue-showcase/src/components/section/Section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DBSection, DBCard } from "../../../../../output/vue/src";
#example="{ exampleIndex, variantIndex, exampleName, exampleProps }"
>
<DBSection
className="db-informational-bg-basic-level-2 section-card-container"
class="db-informational-bg-basic-level-2 section-card-container"
:spacing="exampleProps?.spacing"
:width="exampleProps?.width"
>
Expand Down

0 comments on commit 397bf2a

Please sign in to comment.