move astro-reactive-form to separate workspace

This commit is contained in:
Ayo 2022-10-01 14:18:16 +02:00
parent 5caf3d9cde
commit c1f9716d8b
18 changed files with 163 additions and 81 deletions

View file

@ -11,11 +11,11 @@
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"astro": "^1.4.2" "astro": "^1.4.2",
"astro-reactive-form": "^0.1.1"
}, },
"description": "``` npm create astro@latest -- --template minimal ```", "description": "``` npm create astro@latest -- --template minimal ```",
"main": "index.js", "main": "index.js",
"devDependencies": {},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/ayoayco/astro-reactive-form.git" "url": "git+https://github.com/ayoayco/astro-reactive-form.git"

View file

@ -1,5 +1,7 @@
--- ---
import Form, { FormGroup } from '../../../'; import { FormGroup, Submit } from 'astro-reactive-form/core';
import Form from 'astro-reactive-form';
const form = new FormGroup([ const form = new FormGroup([
{ {
name: 'username', name: 'username',
@ -19,6 +21,13 @@ form.controls.push({
name: 'is-awesome', name: 'is-awesome',
label: 'is Awesome?', label: 'is Awesome?',
}); });
form.controls.push({
type: 'submit',
name: 'submit',
value: 'Submit',
callBack: () => console.log('hey'),
} as Submit);
--- ---
<html lang="en"> <html lang="en">

View file

@ -1,3 +0,0 @@
import Form from './src/Form.astro';
export default Form;
export * from './src/index';

93
package-lock.json generated
View file

@ -1,45 +1,25 @@
{ {
"name": "astro-reactive-form", "name": "astro-reactive-form-workspace",
"version": "0.1.1", "version": "0.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "astro-reactive-form", "name": "astro-reactive-form-workspace",
"version": "0.1.1", "version": "0.0.0",
"license": "ISC", "license": "ISC",
"workspaces": [ "workspaces": [
"demo" "demo",
], "packages/astro-reactive-form"
"devDependencies": { ]
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.0.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.5.4",
"typescript": "^4.8.3"
},
"peerDependencies": {
"astro": "^1.0.0"
}
}, },
"demo": { "demo": {
"name": "@example/minimal", "name": "@example/minimal",
"version": "0.0.1", "version": "0.0.1",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"astro": "^1.4.2" "astro": "^1.4.2",
"astro-reactive-form": "^0.1.1"
}, },
"devDependencies": {} "devDependencies": {}
}, },
@ -1408,6 +1388,10 @@
"astro": "^1.0.0-rc.1" "astro": "^1.0.0-rc.1"
} }
}, },
"node_modules/astro-reactive-form": {
"resolved": "packages/astro-reactive-form",
"link": true
},
"node_modules/bail": { "node_modules/bail": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
@ -7938,6 +7922,32 @@
"type": "github", "type": "github",
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
},
"packages/astro-reactive-form": {
"version": "0.1.1",
"license": "ISC",
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.0.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.5.4",
"typescript": "^4.8.3"
},
"peerDependencies": {
"astro": "^1.0.0"
}
} }
}, },
"dependencies": { "dependencies": {
@ -8376,7 +8386,8 @@
"@example/minimal": { "@example/minimal": {
"version": "file:demo", "version": "file:demo",
"requires": { "requires": {
"astro": "^1.4.2" "astro": "^1.4.2",
"astro-reactive-form": "*"
} }
}, },
"@humanwhocodes/config-array": { "@humanwhocodes/config-array": {
@ -8984,6 +8995,28 @@
"dev": true, "dev": true,
"requires": {} "requires": {}
}, },
"astro-reactive-form": {
"version": "file:packages/astro-reactive-form",
"requires": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.0.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.5.4",
"typescript": "^4.8.3"
}
},
"bail": { "bail": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",

View file

@ -1,7 +1,7 @@
{ {
"name": "astro-reactive-form", "name": "astro-reactive-form-workspace",
"description": "The Reactive Form component for Astro 🔥", "description": "Astro Reactive Form Workspace",
"version": "0.1.1", "version": "0.0.0",
"repository": "https://github.com/ayoayco/astro-reactive-form", "repository": "https://github.com/ayoayco/astro-reactive-form",
"homepage": "https://ayco.io/showcase/astro-reactive-form", "homepage": "https://ayco.io/showcase/astro-reactive-form",
"type": "module", "type": "module",
@ -13,15 +13,6 @@
"email": "ramon.aycojr@gmail.com", "email": "ramon.aycojr@gmail.com",
"url": "https://ayco.io" "url": "https://ayco.io"
}, },
"files": [
"src",
"index.ts"
],
"keywords": [
"astro-component",
"css",
"ui"
],
"scripts": { "scripts": {
"test": "mocha --parallel --timeout 15000", "test": "mocha --parallel --timeout 15000",
"test:watch": "mocha --watch --parallel --timeout 15000", "test:watch": "mocha --watch --parallel --timeout 15000",
@ -30,30 +21,9 @@
"lint:fix": "eslint --fix . --ext .ts,.js", "lint:fix": "eslint --fix . --ext .ts,.js",
"demo": "npm run dev -w demo" "demo": "npm run dev -w demo"
}, },
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.0.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.5.4",
"typescript": "^4.8.3"
},
"peerDependencies": {
"astro": "^1.0.0"
},
"license": "ISC", "license": "ISC",
"workspaces": [ "workspaces": [
"demo" "demo",
"packages/astro-reactive-form"
] ]
} }

View file

@ -1,6 +1,7 @@
--- ---
import { FormGroup } from './core/form-group'; import type { FormGroup } from './core';
import FieldSet from './FieldSet.astro'; import FieldSet from './components/FieldSet.astro';
export interface Props { export interface Props {
formGroups: FormGroup[]; formGroups: FormGroup[];
} }

View file

@ -1,5 +1,5 @@
--- ---
import { FormControl } from './core/form-control'; import { FormControl } from '../core/form-control';
export interface Props { export interface Props {
control: FormControl; control: FormControl;
@ -10,9 +10,9 @@ const { control } = Astro.props;
<div> <div>
{ {
control.label && (!control.labelPosition || control.labelPosition === 'left') ? ( control.label && (!control.labelPosition || control.labelPosition === 'left') && (
<label for={control.name}>{control.label}</label> <label for={control.name}>{control.label}</label>
) : null )
} }
<input <input

View file

@ -1,6 +1,6 @@
--- ---
import Field from './Field.astro'; import Field from './Field.astro';
import { FormGroup } from './core/form-group'; import { FormGroup } from '../core/form-group';
export interface Props { export interface Props {
group: FormGroup; group: FormGroup;

View file

@ -1,3 +1,7 @@
/**
* FormControlType - determines the type of form control
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types
*/
type FormControlType = type FormControlType =
| 'text' | 'text'
| 'checkbox' | 'checkbox'
@ -42,3 +46,8 @@ export class Radio extends FormControl {
type: 'checkbox'; type: 'checkbox';
checked: boolean; checked: boolean;
} }
export class Submit extends FormControl {
type: 'submit';
callBack: () => void;
}

View file

@ -0,0 +1,2 @@
export * from './form-control';
export * from './form-group';

View file

@ -0,0 +1,2 @@
import Form from './Form.astro';
export default Form;

View file

@ -0,0 +1,58 @@
{
"name": "astro-reactive-form",
"description": "The Reactive Form component for Astro 🔥",
"version": "0.1.1",
"repository": "https://github.com/ayoayco/astro-reactive-form",
"homepage": "https://ayco.io/showcase/astro-reactive-form",
"type": "module",
"exports": {
".": "./index.ts",
"./core": "./core/index.ts"
},
"author": {
"name": "Ayo Ayco",
"email": "ramon.aycojr@gmail.com",
"url": "https://ayco.io"
},
"files": [
"core/",
"components/",
"Form.astro",
"index.ts"
],
"keywords": [
"astro-component",
"css",
"ui"
],
"scripts": {
"test": "mocha --parallel --timeout 15000",
"test:watch": "mocha --watch --parallel --timeout 15000",
"format": "prettier -w .",
"lint": "eslint . --ext .ts,.js",
"lint:fix": "eslint --fix . --ext .ts,.js"
},
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.0.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.5.4",
"typescript": "^4.8.3"
},
"peerDependencies": {
"astro": "^1.0.0"
},
"license": "ISC"
}

View file

@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/strictest"
}

View file

@ -1,3 +0,0 @@
export * from './Form.astro';
export * from './core/form-group';
export * from './core/form-control';

View file

@ -5,5 +5,6 @@
"allowJs": true, "allowJs": true,
"noEmit": true "noEmit": true
}, },
"include": ["index.ts", "src"] "include": ["index.ts", "src"],
"extends": "astro/tsconfigs/strictest"
} }