diff --git a/demo/src/pages/index.astro b/demo/src/pages/index.astro index 783f577..4824091 100644 --- a/demo/src/pages/index.astro +++ b/demo/src/pages/index.astro @@ -27,14 +27,6 @@ form.controls.push( }) ); -//insert submit button -form.controls.push( - new FormControl({ - type: "submit", - name: "submit", - }) -); - // get the FormControl object const userNameControl = form.get("username"); diff --git a/packages/astro-reactive-form/client/controls.ts b/packages/astro-reactive-form/client/controls.ts index a73c4f5..227e034 100644 --- a/packages/astro-reactive-form/client/controls.ts +++ b/packages/astro-reactive-form/client/controls.ts @@ -41,7 +41,16 @@ const getFormControl = (name: string) => { value = formControl.value === 'checked' ? '' : 'checked'; } formControl.setValue(value); - formControl.setIsPristine(false); + formControl.isPristine = false; }); - return formControl; + + const controlProxy = new Proxy(formControl, { + set() { + //prevent any setter to be able to work in client; + console.error('Setting this property manually is prohibited!'); + return true; + }, + }); + + return controlProxy; }; diff --git a/packages/astro-reactive-form/core/form-control.ts b/packages/astro-reactive-form/core/form-control.ts index b427470..cd66881 100644 --- a/packages/astro-reactive-form/core/form-control.ts +++ b/packages/astro-reactive-form/core/form-control.ts @@ -55,6 +55,10 @@ export class FormControl { return this._isPristine; } + set isPristine(value: boolean) { + this._isPristine = value; + } + get isValid() { return this._isValid; } diff --git a/packages/astro-reactive-form/index.ts b/packages/astro-reactive-form/index.ts index 0c9b0b8..080add5 100644 --- a/packages/astro-reactive-form/index.ts +++ b/packages/astro-reactive-form/index.ts @@ -1,5 +1,3 @@ import Form from './Form.astro'; export default Form; -export * from './core/form-control-types'; -export * from './client'; export * from './Form.astro';