Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit fde7395

Browse files
committed
Merge branch 'next' into feature/vue-demi-test
2 parents 4bce236 + a557fd0 commit fde7395

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

dev/typescript/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<div class="relative card p-6 bg-white">
1010
<h1 class="title mb-16 text-bg">{{ title }}</h1>
1111
<dynamic-form
12+
class="awiwi"
1213
:form="form"
1314
@submitted="handleSubmit"
1415
@change="valueChanged"
@@ -245,6 +246,9 @@ export default defineComponent({
245246
readonly: true,
246247
}),
247248
},
249+
options: {
250+
customClass: 'mandalorian',
251+
},
248252
}));
249253
250254
function handleSubmit(values) {

src/components/dynamic-form/DynamicForm.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const components = {
8282
*/
8383
export default defineComponent({
8484
name: 'asDynamicForm',
85-
inheritAttrs: false,
8685
props,
8786
components,
8887
setup(props, ctx) {
@@ -141,15 +140,20 @@ export default defineComponent({
141140
});
142141
143142
const formattedOptions = computed(() => {
144-
if (options?.form) {
143+
let opts = {
144+
...options?.form,
145+
...props.form?.options,
146+
};
147+
148+
if (opts) {
145149
const {
146150
customClass,
147151
customStyles,
148152
method,
149153
netlify,
150154
netlifyHoneypot,
151155
autocomplete,
152-
} = options?.form;
156+
} = opts;
153157
return {
154158
class: customClass,
155159
style: customStyles,

src/core/models.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface DynamicForm {
2626
id: string;
2727
fields: FormFields;
2828
fieldOrder?: string[];
29+
options?: FormOptions;
2930
}
3031

3132
export interface ErrorMessage {
@@ -151,8 +152,8 @@ export type FormControl<T extends InputType> = T & {
151152
};
152153

153154
export interface FormOptions {
154-
customClass?: string | string[] | BindingObject | BindingObject[];
155-
customStyles?: string | string[] | BindingObject | BindingObject[];
155+
customClass?: string | string[] | BindingObject | BindingObject[] | unknown;
156+
customStyles?: string | string[] | BindingObject | BindingObject[] | unknown;
156157
method?: string;
157158
netlify?: boolean;
158159
netlifyHoneypot?: string;

src/dynamicForms.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App } from 'vue-demi';
1+
import { App, isVue2 } from 'vue-demi';
22
import { dynamicFormsSymbol } from './useApi';
33
import DynamicForm from './components/dynamic-form/DynamicForm.vue';
44
import { FormOptions } from './core/models';
@@ -20,6 +20,15 @@ export function createDynamicForms(
2020
options,
2121
install(app: App) {
2222
const self = this;
23+
24+
if (isVue2) {
25+
// Vue 2 only
26+
console.log('IS VUEEEE 222');
27+
} else {
28+
// Vue 3 only
29+
console.log('IS VUEEEE 333');
30+
}
31+
2332
app.component('dynamic-form', DynamicForm);
2433
app.provide(dynamicFormsSymbol, self);
2534
},

0 commit comments

Comments
 (0)