diff --git a/src/Field.astro b/src/Field.astro
new file mode 100644
index 0000000..1b6e571
--- /dev/null
+++ b/src/Field.astro
@@ -0,0 +1,31 @@
+---
+import { FormControl } from './core/form-control';
+
+export interface Props {
+ control: FormControl;
+}
+
+const { control } = Astro.props;
+---
+
+
+ {
+ control.label && (!control.labelPosition || control.labelPosition === 'left') ? (
+
+ ) : null
+ }
+
+
+
+ {
+ control.label && control.labelPosition === 'right' ? (
+
+ ) : null
+ }
+
diff --git a/src/FieldSet.astro b/src/FieldSet.astro
new file mode 100644
index 0000000..0147631
--- /dev/null
+++ b/src/FieldSet.astro
@@ -0,0 +1,15 @@
+---
+import Field from './Field.astro';
+import { FormGroup } from './core/form-group';
+
+export interface Props {
+ group: FormGroup;
+}
+
+const { group } = Astro.props;
+---
+
+
diff --git a/src/Form.astro b/src/Form.astro
index 4c81034..0dd02a5 100644
--- a/src/Form.astro
+++ b/src/Form.astro
@@ -1,32 +1,13 @@
---
-import { FormGroup } from './form-group';
+import { FormGroup } from './core/form-group';
+import FieldSet from './FieldSet.astro';
export interface Props {
- formGroup: FormGroup;
+ formGroups: FormGroup[];
}
-const form: FormGroup = Astro.props.formGroup;
+const { formGroups } = Astro.props;
---
diff --git a/src/form-control.ts b/src/core/form-control.ts
similarity index 100%
rename from src/form-control.ts
rename to src/core/form-control.ts
diff --git a/src/form-group.ts b/src/core/form-group.ts
similarity index 69%
rename from src/form-group.ts
rename to src/core/form-group.ts
index 8671bd1..92a3286 100644
--- a/src/form-group.ts
+++ b/src/core/form-group.ts
@@ -2,8 +2,10 @@ import { FormControl } from './form-control';
export class FormGroup {
controls: FormControl[];
+ name?: string;
- constructor(controls: FormControl[]) {
+ constructor(controls: FormControl[], name?: string) {
+ this.name = name || null;
this.controls = controls.map((control) => ({
...control,
labelPosition: control.labelPosition || 'left',
diff --git a/src/index.ts b/src/index.ts
index 819beea..9530b6b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,3 +1,3 @@
export * from './Form.astro';
-export * from './form-group';
-export * from './form-control';
+export * from './core/form-group';
+export * from './core/form-control';