Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Apr 27, 2022
0 parents commit 63eee96
Show file tree
Hide file tree
Showing 18 changed files with 2,199 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
playground
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"parser": "@typescript-eslint/parser",
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"eol-last": ["error", "always"],
// "no-console": ["error"],

// typescript
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist

.DS_STORE

4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/playground
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"trailingComma": "all"
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Quickstart

```vue
<script setup lang="ts">
import { useForm } from '@vue-composable-form/core'
const {
values
} = useForm({
initialValues: {
firstName: '',
lastName: ''
}
onSubmit(data) {
console.log(data)
}
})
</script>
<template>
<form @submit="handleSubmit">
<input type="text" v-model="values.firstName">
<input type="text" v-model="values.lastName">
<button type="submit">
submit
</button>
</form>
</template>
```
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "vue-composable-form",
"workspaces": [
"packages/*"
],
"description": "vue fome validate",
"scripts": {
"dev": "pnpm -r --parallel run dev",
"build": "pnpm -r --parallel run build",
"lint": "eslint './packages/**/*.{js,ts}'",
"lint:fix": "pnpm lint -- --fix",
"prepare": "husky install"
},
"lint-staged": {
"{packages}/**/*.{js,ts}": [
"pnpm lint:fix"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"author": "Alex Liu <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/mini-ghost/vue-composable-form"
},
"dependencies": {
"typescript": "^4.6.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.0",
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
"vue": "^3.0.0"
}
}
29 changes: 29 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@vue-composable-form/core",
"version": "0.0.0",
"description": "vue fome validate",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"exports": {
".": "./dist/index.mjs"
},
"scripts": {
"build": "rollup -c ./scripts/rollup/rollup.config.js",
"dev": "pnpm build -- -w"
},
"author": "Alex Liu <[email protected]>",
"license": "MIT",
"peerDependencies": {
"vue": "^3.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"@types/node": "^16.11.0",
"rollup": "^2.70.2",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2"
}
}
44 changes: 44 additions & 0 deletions packages/core/scripts/rollup/createRollupConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';

export function createRollupConfig(options, callback) {
const name = options.name;

// A file with the extension ".mjs" will always be treated as ESM, even when pkg.type is "commonjs" (the default)
// https://nodejs.org/docs/latest/api/packages.html#packages_determining_module_system
const ext = options.format === 'esm' ? 'mjs' : 'js';
const output = 'dist/' + [name, options.format, ext].join('.');

const config = {
input: options.input,
external: ['vue'],
output: {
file: output,
format: options.format,
name: 'VueComposableForm',
sourcemap: true,
globals: {
vue: 'Vue',
},
},
plugins: [
typescript({
tsconfig: options.tsconfig,
clean: true,
}),
resolve({}),
commonjs(),
options.format !== 'esm' &&
terser({
output: { comments: false },
compress: {
drop_console: true,
},
}),
],
};

return callback ? callback(config) : config;
}
24 changes: 24 additions & 0 deletions packages/core/scripts/rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pkg from '../../package.json';

import { createRollupConfig } from './createRollupConfig';

const name = 'index';
const options = [
{
name,
format: 'esm',
input: pkg.source,
},
{
name,
format: 'cjs',
input: pkg.source,
},
{
name,
format: 'umd',
input: pkg.source,
},
];

export default options.map((option) => createRollupConfig(option));
Empty file added packages/core/src/index.ts
Empty file.
24 changes: 24 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"sourceMap": true,
"module": "es2015",
"target": "es2018",
"moduleResolution": "node",
"outDir": "./dist",
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"noEmit": true,
"esModuleInterop": true,
"lib": ["dom", "dom.iterable", "esnext"],
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"exclude": [
"node_modules",
]
}
Loading

0 comments on commit 63eee96

Please sign in to comment.