feat: initial FormControl, FormGroup, Form.astro
This commit is contained in:
parent
4a9653d3a5
commit
70599b48bf
8 changed files with 41 additions and 7 deletions
3
index.ts
3
index.ts
|
@ -3,3 +3,6 @@
|
||||||
// What you should do here is re-exports all the things you want your user to access, ex:
|
// What you should do here is re-exports all the things you want your user to access, ex:
|
||||||
// export { HelloWorld } from "./src/main.ts"
|
// export { HelloWorld } from "./src/main.ts"
|
||||||
// export type { HelloWorldResult } from "./src/types.ts"
|
// export type { HelloWorldResult } from "./src/types.ts"
|
||||||
|
import Form from './src/Form.astro';
|
||||||
|
export default Form;
|
||||||
|
export {FormGroup, FormControl} from './src/index';
|
||||||
|
|
15
package.json
15
package.json
|
@ -1,16 +1,25 @@
|
||||||
{
|
{
|
||||||
"name": "astro-component-name",
|
"name": "astro-reactive-form",
|
||||||
"version": "0.1.0",
|
"version": "0.0.0",
|
||||||
|
"repository": "https://github.com/ayoayco/astro-reactive-form",
|
||||||
|
"homepage": "https://github.com/ayoayco/astro-reactive-form",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.ts"
|
".": "./index.ts"
|
||||||
},
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Ayo Ayco",
|
||||||
|
"email": "ramon.aycojr@gmail.com",
|
||||||
|
"url": "https://ayco.io"
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"index.ts"
|
"index.ts"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"astro-component"
|
"astro-component",
|
||||||
|
"css",
|
||||||
|
"ui"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --parallel --timeout 15000",
|
"test": "mocha --parallel --timeout 15000",
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
// Write your component code in this file!
|
|
||||||
---
|
|
8
src/Form.astro
Normal file
8
src/Form.astro
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import {FormGroup} from './form-group';
|
||||||
|
const form: FormGroup = Astro.props.formGroup;
|
||||||
|
---
|
||||||
|
<form>
|
||||||
|
<label>{form.controls[0].label}</label>
|
||||||
|
<input type={form.controls[0].type} value={form.controls[0].value} />
|
||||||
|
</form>
|
6
src/form-control.ts
Normal file
6
src/form-control.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export class FormControl {
|
||||||
|
name: string;
|
||||||
|
type?: 'text' | 'checkbox' | 'radio' = 'text'; // add more
|
||||||
|
value?: string | number | null | string[];
|
||||||
|
label?: string;
|
||||||
|
}
|
9
src/form-group.ts
Normal file
9
src/form-group.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { FormControl } from "./form-control";
|
||||||
|
|
||||||
|
export class FormGroup {
|
||||||
|
controls: FormControl[];
|
||||||
|
|
||||||
|
constructor(controls: FormControl[]) {
|
||||||
|
this.controls = controls;
|
||||||
|
}
|
||||||
|
}
|
3
src/index.ts
Normal file
3
src/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export * from './Form.astro';
|
||||||
|
export * from './form-group';
|
||||||
|
export * from './form-control';
|
|
@ -1 +0,0 @@
|
||||||
// Write your component's code here!
|
|
Loading…
Reference in a new issue