1.1.4 • Published 10 months ago
@creatiwity/formbuilder v1.1.4
Creat formbuilder
:warning: This package is under development stay tuned. :warning:
Nuxt3 Typescript Simple formbuilder
Features
Quick Setup
- Add
@creatiwity/formbuilder
dependency to your project
# Using pnpm
pnpm add @creatiwity/formbuilder
# Using yarn
yarn add @creatiwity/formbuilder
# Using npm
npm install @creatiwity/formbuilder
- Add
@creatiwity/formbuilder
to themodules
section ofnuxt.config.ts
export default defineNuxtConfig({
modules: ["@creatiwity/formbuilder"],
});
That's it! You can now use Creat formbuilder in your Nuxt app ✨
Recommended Usage
- First define one or multiple factories in which you'll specify a component of your own to be instantiate in the formbuilder.
- Ignore layouts for now as this is not ready yet
- Use your factories to construct your form 'elements'
- Validation is based on Vuelidate
- Errors can be customized
export interface FieldInputData extends CommonFieldData {
key: string;
label: string;
type: string;
disabled?: boolean;
}
function useInputField(data: FieldInputData): FormElementItem {
return {
key: data.key,
props: <FieldInputData>() =>
({
key: data.key,
name: data.key,
label: data.label,
type: data.type,
isReadOnly: data.isReadOnly,
isHidden: data.isHidden,
mandatory: data.mandatory,
} as FieldInputData),
component: FormInput as DefineComponent<{}, {}, any>,
validation: data.validation,
};
}
const MyForm = (): FormElement => ({
layouts: [],
elements: [
useInputField({
key: "name",
label: "Nom",
type: "text",
isReadOnly: (data) => data === "test",
validation: () => {
return { required, minLength: minLength(3) };
},
}),
],
});
const myForm: MyFormType = ref({
name: "aaaa",
});
const myFormElement = MyForm();
const errors: FormElementError = {
name: {
required: "Le nom est requis",
},
};
<div>
<CreatFormBuilder
id="myForm"
v-model="myForm"
:form-element="myFormElement"
:errors="errors"
/>
</div>
Options
props | type | optional | usage |
---|---|---|---|
readOnly | boolean | yes | will make all the form readonly |
ctaLabel | string | yes | Label for the submit button |
ctaClass | string | yes | class for the submit button |
errors | FormElementError | yes | Your custom errors |
1.1.1
10 months ago
1.0.19
10 months ago
1.1.0
10 months ago
1.0.18
10 months ago
1.0.17
10 months ago
1.0.16
10 months ago
1.1.4
10 months ago
1.1.3
10 months ago
1.1.2
10 months ago
1.0.15
11 months ago
1.0.14
11 months ago
1.0.13
11 months ago
1.0.12
11 months ago
1.0.11
11 months ago
1.0.10
11 months ago
1.0.9
11 months ago
1.0.8
11 months ago
1.0.7
11 months ago
1.0.6
11 months ago