Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dev/vue/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ const data = () => ({
customClass: 'col-6',
options: ['Arduino', 'Pinguino'],
}),
new FormField({
type: 'text',
label: 'Custom Style',
name: 'custom-style',
customStyles: {
boxShadow: '0 0 22px -1px rgba(0,0,0,0.2)',
},
customClass: 'col-12',
}),
],
options: {
autoValidate: true,
Expand Down
2,964 changes: 790 additions & 2,174 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/components/dynamic-form/DynamicForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ const methods = {
};

const computed = {
getClasses() {
return this.options.customClass;
},
getStyles() {
return this.options.customStyles;
},
isValid() {
const control = this.controls.find(control => !control.valid);
return control ? control.valid : true;
Expand Down
2 changes: 2 additions & 0 deletions src/components/dynamic-form/DynamicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
v-if="fields.length > 0 && !showFeedback"
:id="id"
:name="id"
:class="getClasses"
:style="getStyles"
v-bind="formattedOptions"
novalidate
@submit.prevent="handleSubmit()"
Expand Down
3 changes: 3 additions & 0 deletions src/components/dynamic-input/DynamicInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ const computed = {
(this.submited || this.autoValidate)
);
},
getStyles() {
return this.formControl.customStyles;
},
errorMessages() {
const errors = Object.entries(this.formControl.errors);
if (errors.length > 0) {
Expand Down
6 changes: 6 additions & 0 deletions src/components/dynamic-input/DynamicInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,31 @@
"
:formControl="formControl"
@change="valueChange"
:style="getStyles"
/>
<input-textarea
v-if="formControl.type === 'textarea'"
:formControl="formControl"
@change="valueChange"
:style="getStyles"
/>
<input-select
v-if="formControl.type === 'select'"
:formControl="formControl"
@change="valueChange"
:style="getStyles"
/>
<input-checkbox
v-if="formControl.type === 'checkbox'"
:formControl="formControl"
@change="valueChange"
:style="getStyles"
/>
<input-radio
v-if="formControl.type === 'radio'"
:formControl="formControl"
@change="valueChange"
:style="getStyles"
/>
<slot
v-if="formControl.type === 'custom-field'"
Expand All @@ -38,6 +43,7 @@
:valueChange="valueChange"
:onFocus="onFocus"
:onBlur="onBlur"
:style="getStyles"
/>
<label
class="form-label"
Expand Down
6 changes: 6 additions & 0 deletions src/core/utils/form-control.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function FormControl({
form,
name = null,
customClass = null,
customStyles = null,
options = [],
placeholder = null,
rows = null,
Expand All @@ -26,6 +27,7 @@ export function FormControl({
this.label = label;
this.name = name;
this.customClass = customClass;
this.customStyles = customStyles;
this.options = options;
this.placeholder = placeholder;
this.disabled = disabled;
Expand All @@ -46,6 +48,7 @@ export function FormField({
label = null,
name = null,
customClass = null,
customStyles = null,
disabled = false,
options = [],
placeholder = null,
Expand All @@ -61,6 +64,7 @@ export function FormField({
this.label = label;
this.name = name;
this.customClass = customClass;
this.customStyles = customStyles;
this.disabled = disabled;
this.options = options;
this.placeholder = placeholder;
Expand All @@ -80,12 +84,14 @@ export function FormValidation(

export function FormOptions({
customClass = '',
customStyles = '',
method = 'POST',
autoValidate = false,
netlify = false,
netlifyHoneypot = null,
}) {
this.customClass = customClass;
this.customStyles = customStyles;
this.method = method;
this.autoValidate = autoValidate;
this.netlify = netlify;
Expand Down