├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── .prettierrc.yaml
├── README.md
├── package.json
├── packages
├── app
│ ├── .gitignore
│ ├── README.md
│ ├── package.json
│ ├── public
│ │ ├── global.css
│ │ └── index.html
│ ├── rollup.config.js
│ ├── src
│ │ ├── App.svelte
│ │ ├── main.ts
│ │ ├── samples
│ │ │ ├── array.ts
│ │ │ ├── simple.ts
│ │ │ └── single.ts
│ │ └── schema.json
│ ├── svelte.config.js
│ └── tsconfig.json
├── common
│ ├── .editorconfig
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── code-of-conduct.md
│ ├── package.json
│ ├── rollup.config.ts
│ ├── src
│ │ └── svelte-form-common.ts
│ ├── test
│ │ └── svelte-form-common.test.ts
│ ├── tools
│ │ ├── gh-pages-publish.ts
│ │ └── semantic-release-prepare.ts
│ ├── tsconfig.json
│ └── tslint.json
├── lib
│ ├── .editorconfig
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── code-of-conduct.md
│ ├── package.json
│ ├── rollup.config.ts
│ ├── src
│ │ ├── components
│ │ │ ├── AddItem.svelte
│ │ │ ├── Form.svelte
│ │ │ ├── ItemCtrl.svelte
│ │ │ ├── ItemWrapper.svelte
│ │ │ ├── Layout.svelte
│ │ │ ├── Wrapper.svelte
│ │ │ ├── fields
│ │ │ │ ├── ArrayField.svelte
│ │ │ │ ├── BooleanField.svelte
│ │ │ │ ├── NullField.svelte
│ │ │ │ ├── NumberField.svelte
│ │ │ │ ├── ObjectField.svelte
│ │ │ │ ├── StringField.svelte
│ │ │ │ ├── extra
│ │ │ │ │ ├── TextareaField.svelte
│ │ │ │ │ └── index.ts
│ │ │ │ └── index.ts
│ │ │ ├── helpers
│ │ │ │ └── Wrap.svelte
│ │ │ └── index.ts
│ │ ├── helpers.ts
│ │ ├── index.ts
│ │ └── types.ts
│ ├── test
│ │ └── svelte-form.test.ts
│ ├── tools
│ │ ├── gh-pages-publish.ts
│ │ └── semantic-release-prepare.ts
│ ├── tsconfig.json
│ └── tslint.json
└── validators
│ └── ajv
│ ├── .editorconfig
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── code-of-conduct.md
│ ├── package.json
│ ├── rollup.config.ts
│ ├── src
│ └── svelte-form-ajv.ts
│ ├── test
│ └── svelte-form-ajv.test.ts
│ ├── tools
│ ├── gh-pages-publish.ts
│ └── semantic-release-prepare.ts
│ ├── tsconfig.json
│ └── tslint.json
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
└── tsconfig.json
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: Build and Deploy
2 | on: [push]
3 | jobs:
4 | build-and-deploy:
5 | concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
6 | runs-on: ubuntu-latest
7 | steps:
8 | - name: Checkout 🛎️
9 | uses: actions/checkout@v2
10 |
11 | - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
12 | run: |
13 | npm install --no-save pnpm
14 | $(npm bin)/pnpm i -r --frozen-lockfile
15 | $(npm bin)/pnpm run build -r
16 | $(npm bin)/pnpm run build --filter ./packages/app
17 |
18 | - name: Deploy 🚀
19 | uses: JamesIves/github-pages-deploy-action@v4.2.2
20 | with:
21 | branch: gh-pages # The branch the action should deploy to.
22 | folder: packages/app/public # The folder the action should deploy.
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .nyc_output
4 | .DS_Store
5 | *.log
6 | .vscode
7 | .idea
8 | dist
9 | compiled
10 | .awcache
11 | .rpt2_cache
12 | docs
13 | packages/lib/public
14 |
--------------------------------------------------------------------------------
/.prettierrc.yaml:
--------------------------------------------------------------------------------
1 | pluginSearchDirs:
2 | - ./node_modules
3 | plugins:
4 | - ./node_modules/prettier-plugin-svelte
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JSON Schema form for Svelte v3
2 |
3 | This monorepo includes packages:
4 |
5 | * [App](packages/app)
6 | * [Library](packages/lib)
7 | * [Common](packages/common)
8 | * [Ajv Validator](packages/validators/ajv)
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "name": "@pyoner/svelte-form-monorepo",
4 | "version": "1.0.0",
5 | "description": "This monorepo includes packages:",
6 | "main": "index.js",
7 | "scripts": {
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/pyoner/svelte-form.git"
13 | },
14 | "author": "",
15 | "license": "MIT",
16 | "bugs": {
17 | "url": "https://github.com/pyoner/svelte-form/issues"
18 | },
19 | "homepage": "https://github.com/pyoner/svelte-form#readme",
20 | "devDependencies": {
21 | "@rollup/plugin-commonjs": "^13.0.0",
22 | "@wessberg/rollup-plugin-ts": "^1.2.25",
23 | "prettier": "^2.0.5",
24 | "prettier-plugin-svelte": "^1.1.0",
25 | "rollup": "^2.19.0",
26 | "typescript": "^3.9.5"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/app/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | public/bundle.*
4 | package-lock.json
5 | yarn.lock
6 | .rpt2_cache
--------------------------------------------------------------------------------
/packages/app/README.md:
--------------------------------------------------------------------------------
1 | # Svelte Form Application
2 |
3 | See details in the file [App.svelte](src/App.svelte)
4 |
--------------------------------------------------------------------------------
/packages/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "name": "app",
4 | "version": "1.0.0",
5 | "devDependencies": {
6 | "@pyoner/svelte-ts-preprocess": "^1.3.0",
7 | "@rollup/plugin-commonjs": "^13.0.0",
8 | "@rollup/plugin-json": "^4.0.2",
9 | "@rollup/plugin-node-resolve": "^7.1.1",
10 | "@wessberg/rollup-plugin-ts": "^1.2.25",
11 | "npm-run-all": "^4.1.5",
12 | "pretty-quick": "^2.0.1",
13 | "rollup": "2.19.0",
14 | "rollup-plugin-analyzer": "^3.2.2",
15 | "rollup-plugin-livereload": "^1.0.4",
16 | "rollup-plugin-svelte": "^5.1.1",
17 | "rollup-plugin-terser": "^5.2.0",
18 | "sirv-cli": "^0.4.5",
19 | "svelte": "^3.17.1"
20 | },
21 | "scripts": {
22 | "build": "rollup -c",
23 | "autobuild": "rollup -c -w",
24 | "dev": "run-p start:dev autobuild",
25 | "start": "sirv public",
26 | "start:dev": "sirv public --dev",
27 | "format": "prettier --write 'src/**/*' 'test/**/*'"
28 | },
29 | "dependencies": {
30 | "@pyoner/svelte-form": "workspace:^1.0.1",
31 | "@pyoner/svelte-form-ajv": "workspace:^0.1.0",
32 | "ajv": "^6.12.0"
33 | },
34 | "peerDependencies": {
35 | "typescript": "^3.9"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/packages/app/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | padding: 0.4em;
36 | margin: 0 0 0.5em 0;
37 | box-sizing: border-box;
38 | border: 1px solid #ccc;
39 | border-radius: 2px;
40 | }
41 |
42 | input:disabled {
43 | color: #ccc;
44 | }
45 |
46 | input[type="range"] {
47 | height: 0;
48 | }
49 |
50 | button {
51 | background-color: #f4f4f4;
52 | outline: none;
53 | }
54 |
55 | button:active {
56 | background-color: #ddd;
57 | }
58 |
59 | button:focus {
60 | border-color: #666;
61 | }
62 |
63 | form .field {
64 | margin: 0px 10px 20px;
65 | }
66 |
67 | form .item {
68 | display: flex;
69 | align-items: center;
70 | }
71 |
--------------------------------------------------------------------------------
/packages/app/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/app/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from "rollup-plugin-svelte";
2 | import resolve from "@rollup/plugin-node-resolve";
3 | import commonjs from "@rollup/plugin-commonjs";
4 | import json from "@rollup/plugin-json";
5 | import livereload from "rollup-plugin-livereload";
6 | import { terser } from "rollup-plugin-terser";
7 | import typescript from "@wessberg/rollup-plugin-ts";
8 |
9 | import analyze from "rollup-plugin-analyzer";
10 |
11 | const svelteOptions = require("./svelte.config");
12 |
13 | const production = !process.env.ROLLUP_WATCH;
14 |
15 | export default {
16 | input: "src/main.ts",
17 | output: {
18 | sourcemap: true,
19 | format: "iife",
20 | name: "app",
21 | file: "public/bundle.js",
22 | },
23 | plugins: [
24 | analyze({ summaryOnly: true }),
25 | json(),
26 | svelte({
27 | ...svelteOptions,
28 | // enable run-time checks when not in production
29 | dev: !production,
30 | // we'll extract any component CSS out into
31 | // a separate file — better for performance
32 | css: (css) => {
33 | css.write("public/bundle.css");
34 | },
35 | }),
36 |
37 | // If you have external dependencies installed from
38 | // npm, you'll most likely need these plugins. In
39 | // some cases you'll need additional configuration —
40 | // consult the documentation for details:
41 | // https://github.com/rollup/rollup-plugin-commonjs
42 | resolve({
43 | browser: true,
44 | dedupe: (importee) =>
45 | importee === "svelte" || importee.startsWith("svelte/"),
46 | }),
47 | commonjs(),
48 | typescript(),
49 |
50 | // Watch the `public` directory and refresh the
51 | // browser on changes when not in production
52 | !production && livereload("public"),
53 |
54 | // If we're building for production (npm run build
55 | // instead of npm run dev), minify
56 | production && terser(),
57 | ],
58 | watch: {
59 | clearScreen: false,
60 | },
61 | };
62 |
--------------------------------------------------------------------------------
/packages/app/src/App.svelte:
--------------------------------------------------------------------------------
1 |
30 |
31 |
45 |
46 | {#if schema}
47 | Form
48 |
63 |
64 | Result
65 |
66 | {/if}
67 |
--------------------------------------------------------------------------------
/packages/app/src/main.ts:
--------------------------------------------------------------------------------
1 | import App from "./App.svelte";
2 |
3 | const app = new App({
4 | target: document.body,
5 | props: {
6 | name: "world"
7 | }
8 | });
9 |
10 | export default app;
11 |
--------------------------------------------------------------------------------
/packages/app/src/samples/array.ts:
--------------------------------------------------------------------------------
1 | export const schema = {
2 | type: "array",
3 | title: "Profiles",
4 | description: "Specify any number of social networks that you participate in",
5 | additionalItems: false,
6 | items: {
7 | type: "object",
8 | title: "Profile",
9 | additionalProperties: true,
10 | properties: {
11 | network: {
12 | type: "string",
13 | title: "Network",
14 | description: "e.g. Facebook or Twitter"
15 | },
16 | username: {
17 | type: "string",
18 | title: "Username",
19 | description: "e.g. neutralthoughts"
20 | },
21 | url: {
22 | type: "string",
23 | title: "URL",
24 | description: "e.g. http://twitter.example.com/neutralthoughts"
25 | }
26 | }
27 | }
28 | };
29 |
30 | export const value = [];
31 |
--------------------------------------------------------------------------------
/packages/app/src/samples/simple.ts:
--------------------------------------------------------------------------------
1 | import { extra } from "@pyoner/svelte-form";
2 |
3 | export const schema = {
4 | title: "A registration form",
5 | description: "A simple form example.",
6 | type: "object",
7 | required: ["firstName", "lastName"],
8 | properties: {
9 | firstName: {
10 | type: "string",
11 | title: "First name",
12 | default: "Chuck",
13 | $svelte: {
14 | field: {
15 | props: {
16 | autofocus: true,
17 | },
18 | },
19 | },
20 | },
21 | lastName: {
22 | type: "string",
23 | title: "Last name",
24 | },
25 | age: {
26 | type: "integer",
27 | title: "Age",
28 | },
29 | bio: {
30 | type: "string",
31 | title: "Bio",
32 | $svelte: {
33 | field: {
34 | component: extra.TextareaField,
35 | },
36 | },
37 | },
38 | password: {
39 | type: "string",
40 | title: "Password",
41 | minLength: 3,
42 | $svelte: {
43 | field: {
44 | props: {
45 | type: "password",
46 | },
47 | },
48 | },
49 | },
50 | telephone: {
51 | type: "string",
52 | title: "Telephone",
53 | minLength: 10,
54 | },
55 | random: {
56 | type: "number",
57 | title: "Random number",
58 | },
59 | },
60 | };
61 |
62 | export const value = {
63 | lastName: "Norris",
64 | age: 75,
65 | bio: "Roundhouse kicking asses since 1940",
66 | password: "noneed",
67 | };
68 |
--------------------------------------------------------------------------------
/packages/app/src/samples/single.ts:
--------------------------------------------------------------------------------
1 | export const schema = {
2 | title: "A single-field form",
3 | type: "string"
4 | };
5 |
6 | export const value = "initial value";
7 |
--------------------------------------------------------------------------------
/packages/app/src/schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "Resume Schema",
4 | "type": "object",
5 | "additionalProperties": false,
6 | "properties": {
7 | "basics": {
8 | "type": "object",
9 | "title": "Basics",
10 | "additionalProperties": true,
11 | "properties": {
12 | "name": {
13 | "type": "string",
14 | "title": "Name"
15 | },
16 | "label": {
17 | "type": "string",
18 | "title": "Label",
19 | "description": "e.g. Web Developer"
20 | },
21 | "image": {
22 | "type": "string",
23 | "title": "Image",
24 | "description": "URL (as per RFC 3986) to a image in JPEG or PNG format"
25 | },
26 | "email": {
27 | "type": "string",
28 | "title": "Email",
29 | "description": "e.g. thomas@gmail.com",
30 | "format": "email"
31 | },
32 | "phone": {
33 | "type": "string",
34 | "title": "Phone",
35 | "description": "Phone numbers are stored as strings so use any format you like, e.g. 712-117-2923"
36 | },
37 | "url": {
38 | "type": "string",
39 | "title": "URL",
40 | "description": "URL (as per RFC 3986) to your website, e.g. personal homepage",
41 | "format": "uri"
42 | },
43 | "summary": {
44 | "type": "string",
45 | "title": "Summary",
46 | "description": "Write a short 2-3 sentence biography about yourself"
47 | },
48 | "location": {
49 | "type": "object",
50 | "title": "Location",
51 | "additionalProperties": true,
52 | "properties": {
53 | "address": {
54 | "type": "string",
55 | "title": "Address",
56 | "description": "To add multiple address lines, use \n. For example, 1234 Glücklichkeit Straße\nHinterhaus 5. Etage li."
57 | },
58 | "postalCode": {
59 | "type": "string",
60 | "title": "Postal Code"
61 | },
62 | "city": {
63 | "type": "string",
64 | "title": "City"
65 | },
66 | "countryCode": {
67 | "type": "string",
68 | "title": "Country Code",
69 | "description": "code as per ISO-3166-1 ALPHA-2, e.g. US, AU, IN"
70 | },
71 | "region": {
72 | "type": "string",
73 | "title": "Region",
74 | "description": "The general region where you live. Can be a US state, or a province, for instance."
75 | }
76 | }
77 | },
78 | "profiles": {
79 | "type": "array",
80 | "title": "Profiles",
81 | "description": "Specify any number of social networks that you participate in",
82 | "additionalItems": false,
83 | "items": {
84 | "type": "object",
85 | "title": "Profile",
86 | "additionalProperties": true,
87 | "properties": {
88 | "network": {
89 | "type": "string",
90 | "title": "Network",
91 | "description": "e.g. Facebook or Twitter"
92 | },
93 | "username": {
94 | "type": "string",
95 | "title": "Username",
96 | "description": "e.g. neutralthoughts"
97 | },
98 | "url": {
99 | "type": "string",
100 | "title": "URL",
101 | "description": "e.g. http://twitter.example.com/neutralthoughts"
102 | }
103 | }
104 | }
105 | }
106 | }
107 | },
108 | "work": {
109 | "type": "array",
110 | "title": "Work List",
111 | "additionalItems": false,
112 | "items": {
113 | "type": "object",
114 | "title": "Work",
115 | "additionalProperties": true,
116 | "properties": {
117 | "name": {
118 | "type": "string",
119 | "title": "Name",
120 | "description": "e.g. Facebook"
121 | },
122 | "location": {
123 | "type": "string",
124 | "title": "Location",
125 | "description": "e.g. Menlo Park, CA"
126 | },
127 | "description": {
128 | "type": "string",
129 | "title": "Description",
130 | "description": "e.g. Social Media Company"
131 | },
132 | "position": {
133 | "type": "string",
134 | "title": "Position",
135 | "description": "e.g. Software Engineer"
136 | },
137 | "url": {
138 | "type": "string",
139 | "title": "URL",
140 | "description": "e.g. http://facebook.example.com",
141 | "format": "uri"
142 | },
143 | "startDate": {
144 | "type": "string",
145 | "title": "Start Date",
146 | "description": "resume.json uses the ISO 8601 date standard e.g. 2014-06-29",
147 | "format": "date"
148 | },
149 | "endDate": {
150 | "type": "string",
151 | "title": "End Date",
152 | "description": "e.g. 2012-06-29",
153 | "format": "date"
154 | },
155 | "summary": {
156 | "type": "string",
157 | "title": "Summary",
158 | "description": "Give an overview of your responsibilities at the company"
159 | },
160 | "highlights": {
161 | "type": "array",
162 | "title": "Highlights",
163 | "description": "Specify multiple accomplishments",
164 | "additionalItems": false,
165 | "items": {
166 | "type": "string",
167 | "title": "Highlight",
168 | "description": "e.g. Increased profits by 20% from 2011-2012 through viral advertising"
169 | }
170 | }
171 | }
172 | }
173 | },
174 | "volunteer": {
175 | "type": "array",
176 | "title": "Volunteers",
177 | "additionalItems": false,
178 | "items": {
179 | "type": "object",
180 | "title": "Volunteer",
181 | "additionalProperties": true,
182 | "properties": {
183 | "organization": {
184 | "type": "string",
185 | "title": "Organization",
186 | "description": "e.g. Facebook"
187 | },
188 | "position": {
189 | "type": "string",
190 | "title": "Position",
191 | "description": "e.g. Software Engineer"
192 | },
193 | "url": {
194 | "type": "string",
195 | "title": "URL",
196 | "description": "e.g. http://facebook.example.com",
197 | "format": "uri"
198 | },
199 | "startDate": {
200 | "type": "string",
201 | "title": "Start Date",
202 | "description": "resume.json uses the ISO 8601 date standard e.g. 2014-06-29",
203 | "format": "date"
204 | },
205 | "endDate": {
206 | "type": "string",
207 | "title": "End Date",
208 | "description": "e.g. 2012-06-29",
209 | "format": "date"
210 | },
211 | "summary": {
212 | "type": "string",
213 | "title": "Summary",
214 | "description": "Give an overview of your responsibilities at the company"
215 | },
216 | "highlights": {
217 | "type": "array",
218 | "title": "Highlights",
219 | "description": "Specify accomplishments and achievements",
220 | "additionalItems": false,
221 | "items": {
222 | "type": "string",
223 | "title": "Highlight",
224 | "description": "e.g. Increased profits by 20% from 2011-2012 through viral advertising"
225 | }
226 | }
227 | }
228 | }
229 | },
230 | "education": {
231 | "type": "array",
232 | "title": "Education List",
233 | "additionalItems": false,
234 | "items": {
235 | "type": "object",
236 | "title": "Education",
237 | "additionalProperties": true,
238 | "properties": {
239 | "institution": {
240 | "type": "string",
241 | "title": "Institution",
242 | "description": "e.g. Massachusetts Institute of Technology"
243 | },
244 | "area": {
245 | "type": "string",
246 | "title": "Area",
247 | "description": "e.g. Arts"
248 | },
249 | "studyType": {
250 | "type": "string",
251 | "title": "Study Type",
252 | "description": "e.g. Bachelor"
253 | },
254 | "startDate": {
255 | "type": "string",
256 | "title": "Start Date",
257 | "description": "e.g. 2014-06-29",
258 | "format": "date"
259 | },
260 | "endDate": {
261 | "type": "string",
262 | "title": "End Date",
263 | "description": "e.g. 2012-06-29",
264 | "format": "date"
265 | },
266 | "gpa": {
267 | "type": "string",
268 | "title": "Grade Poin Average (GPA)",
269 | "description": "grade point average, e.g. 3.67/4.0"
270 | },
271 | "courses": {
272 | "type": "array",
273 | "title": "Courses",
274 | "description": "List notable courses/subjects",
275 | "additionalItems": false,
276 | "items": {
277 | "type": "string",
278 | "title": "Course",
279 | "description": "e.g. H1302 - Introduction to American history"
280 | }
281 | }
282 | }
283 | }
284 | },
285 | "awards": {
286 | "type": "array",
287 | "title": "Awards",
288 | "description": "Specify any awards you have received throughout your professional career",
289 | "additionalItems": false,
290 | "items": {
291 | "type": "object",
292 | "title": "Award",
293 | "additionalProperties": true,
294 | "properties": {
295 | "title": {
296 | "type": "string",
297 | "title": "Title",
298 | "description": "e.g. One of the 100 greatest minds of the century"
299 | },
300 | "date": {
301 | "type": "string",
302 | "title": "Date",
303 | "description": "e.g. 1989-06-12",
304 | "format": "date"
305 | },
306 | "awarder": {
307 | "type": "string",
308 | "title": "Awarder",
309 | "description": "e.g. Time Magazine"
310 | },
311 | "summary": {
312 | "type": "string",
313 | "title": "Summary",
314 | "description": "e.g. Received for my work with Quantum Physics"
315 | }
316 | }
317 | }
318 | },
319 | "publications": {
320 | "type": "array",
321 | "title": "Publications",
322 | "description": "Specify your publications through your career",
323 | "additionalItems": false,
324 | "items": {
325 | "type": "object",
326 | "title": "Publication",
327 | "additionalProperties": true,
328 | "properties": {
329 | "name": {
330 | "type": "string",
331 | "title": "Name",
332 | "description": "e.g. The World Wide Web"
333 | },
334 | "publisher": {
335 | "type": "string",
336 | "title": "Publisher",
337 | "description": "e.g. IEEE, Computer Magazine"
338 | },
339 | "releaseDate": {
340 | "type": "string",
341 | "title": "Release Date",
342 | "description": "e.g. 1990-08-01"
343 | },
344 | "url": {
345 | "type": "string",
346 | "title": "URL",
347 | "description": "e.g. http://www.computer.org.example.com/csdl/mags/co/1996/10/rx069-abs.html"
348 | },
349 | "summary": {
350 | "type": "string",
351 | "title": "Summary",
352 | "description": "Short summary of publication. e.g. Discussion of the World Wide Web, HTTP, HTML."
353 | }
354 | }
355 | }
356 | },
357 | "skills": {
358 | "type": "array",
359 | "title": "Skills",
360 | "description": "List out your professional skill-set",
361 | "additionalItems": false,
362 | "items": {
363 | "type": "object",
364 | "title": "Skill",
365 | "additionalProperties": true,
366 | "properties": {
367 | "name": {
368 | "type": "string",
369 | "title": "Name",
370 | "description": "e.g. Web Development"
371 | },
372 | "level": {
373 | "type": "string",
374 | "title": "Level",
375 | "description": "e.g. Master"
376 | },
377 | "keywords": {
378 | "type": "array",
379 | "title": "Keywords",
380 | "description": "List some keywords pertaining to this skill",
381 | "additionalItems": false,
382 | "items": {
383 | "type": "string",
384 | "title": "Keyword",
385 | "description": "e.g. HTML"
386 | }
387 | }
388 | }
389 | }
390 | },
391 | "languages": {
392 | "type": "array",
393 | "title": "Languages",
394 | "description": "List any other languages you speak",
395 | "additionalItems": false,
396 | "items": {
397 | "type": "object",
398 | "title": "Language",
399 | "additionalProperties": true,
400 | "properties": {
401 | "language": {
402 | "type": "string",
403 | "title": "Language",
404 | "description": "e.g. English, Spanish"
405 | },
406 | "fluency": {
407 | "type": "string",
408 | "title": "Fluency",
409 | "description": "e.g. Fluent, Beginner"
410 | }
411 | }
412 | }
413 | },
414 | "interests": {
415 | "type": "array",
416 | "title": "Interests",
417 | "additionalItems": false,
418 | "items": {
419 | "type": "object",
420 | "title": "Interest",
421 | "additionalProperties": true,
422 | "properties": {
423 | "name": {
424 | "type": "string",
425 | "title": "Name",
426 | "description": "e.g. Philosophy"
427 | },
428 | "keywords": {
429 | "type": "array",
430 | "title": "Keywords",
431 | "additionalItems": false,
432 | "items": {
433 | "type": "string",
434 | "title": "Keyword",
435 | "description": "e.g. Friedrich Nietzsche"
436 | }
437 | }
438 | }
439 | }
440 | },
441 | "references": {
442 | "type": "array",
443 | "title": "References",
444 | "description": "List references you have received",
445 | "additionalItems": false,
446 | "items": {
447 | "type": "object",
448 | "title": "Reference",
449 | "additionalProperties": true,
450 | "properties": {
451 | "name": {
452 | "type": "string",
453 | "title": "Name",
454 | "description": "e.g. Timothy Cook"
455 | },
456 | "reference": {
457 | "type": "string",
458 | "title": "Reference",
459 | "description": "e.g. Joe blogs was a great employee, who turned up to work at least once a week. He exceeded my expectations when it came to doing nothing."
460 | }
461 | }
462 | }
463 | },
464 | "projects": {
465 | "type": "array",
466 | "title": "Projects",
467 | "description": "Specify career projects",
468 | "additionalItems": false,
469 | "items": {
470 | "type": "object",
471 | "title": "Project",
472 | "additionalProperties": true,
473 | "properties": {
474 | "name": {
475 | "type": "string",
476 | "title": "Name",
477 | "description": "e.g. The World Wide Web"
478 | },
479 | "description": {
480 | "type": "string",
481 | "title": "Description",
482 | "description": "Short summary of project. e.g. Collated works of 2017."
483 | },
484 | "highlights": {
485 | "type": "array",
486 | "title": "Highlights",
487 | "description": "Specify multiple features",
488 | "additionalItems": false,
489 | "items": {
490 | "type": "string",
491 | "title": "Highlight",
492 | "description": "e.g. Directs you close but not quite there"
493 | }
494 | },
495 | "keywords": {
496 | "type": "array",
497 | "title": "Keywords",
498 | "description": "Specify special elements involved",
499 | "additionalItems": false,
500 | "items": {
501 | "type": "string",
502 | "title": "Keyword",
503 | "description": "e.g. AngularJS"
504 | }
505 | },
506 | "startDate": {
507 | "type": "string",
508 | "title": "Start Date",
509 | "description": "resume.json uses the ISO 8601 date standard e.g. 2014-06-29",
510 | "format": "date"
511 | },
512 | "endDate": {
513 | "type": "string",
514 | "title": "End Date",
515 | "description": "e.g. 2012-06-29",
516 | "format": "date"
517 | },
518 | "url": {
519 | "type": "string",
520 | "title": "URL",
521 | "format": "uri",
522 | "description": "e.g. http://www.computer.org/csdl/mags/co/1996/10/rx069-abs.html"
523 | },
524 | "roles": {
525 | "type": "array",
526 | "title": "Roles",
527 | "description": "Specify your role on this project or in company",
528 | "additionalItems": false,
529 | "items": {
530 | "type": "string",
531 | "title": "Role",
532 | "description": "e.g. Team Lead, Speaker, Writer"
533 | }
534 | },
535 | "entity": {
536 | "type": "string",
537 | "title": "Entity",
538 | "description": "Specify the relevant company/entity affiliations e.g. 'greenpeace', 'corporationXYZ'"
539 | },
540 | "type": {
541 | "type": "string",
542 | "title": "Type",
543 | "description": " e.g. 'volunteering', 'presentation', 'talk', 'application', 'conference'"
544 | }
545 | }
546 | }
547 | },
548 | "meta": {
549 | "type": "object",
550 | "title": "Meta",
551 | "description": "The schema version and any other tooling configuration lives here",
552 | "additionalProperties": true,
553 | "properties": {
554 | "canonical": {
555 | "type": "string",
556 | "title": "Canonical",
557 | "description": "URL (as per RFC 3986) to latest version of this document"
558 | },
559 | "version": {
560 | "type": "string",
561 | "title": "Version",
562 | "description": "A version field which follows semver - e.g. v1.0.0"
563 | },
564 | "lastModified": {
565 | "type": "string",
566 | "title": "Last Modified",
567 | "description": "Using ISO 8601 with YYYY-MM-DDThh:mm:ss"
568 | }
569 | }
570 | }
571 | }
572 | }
573 |
--------------------------------------------------------------------------------
/packages/app/svelte.config.js:
--------------------------------------------------------------------------------
1 | // svelte options exported for svelte-vscode
2 |
3 | const {
4 | preprocess: makeTsPreprocess,
5 | createEnv,
6 | readConfigFile,
7 | } = require("@pyoner/svelte-ts-preprocess");
8 |
9 | const env = createEnv();
10 | const compilerOptions = readConfigFile(env);
11 | const preprocessOptions = {
12 | env,
13 | compilerOptions: {
14 | ...compilerOptions,
15 | allowNonTsExtensions: true,
16 | },
17 | };
18 | const preprocess = makeTsPreprocess(preprocessOptions);
19 |
20 | module.exports = {
21 | dev: process.env.NODE_ENV !== "development",
22 | preprocess,
23 | };
24 |
--------------------------------------------------------------------------------
/packages/app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "resolveJsonModule": true,
4 | /* Basic Options */
5 | "target": "ES2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
6 | "module": "ESNEXT" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
7 | "lib": [
8 | "esnext",
9 | "dom"
10 | ] /* Specify library files to be included in the compilation. */,
11 | // "allowJs": true, /* Allow javascript files to be compiled. */
12 | // "checkJs": true, /* Report errors in .js files. */
13 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14 | // "declaration": true, /* Generates corresponding '.d.ts' file. */
15 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16 | // "sourceMap": true, /* Generates corresponding '.map' file. */
17 | // "outFile": "./", /* Concatenate and emit output to single file. */
18 | // "outDir": "./", /* Redirect output structure to the directory. */
19 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20 | // "composite": true, /* Enable project compilation */
21 | // "removeComments": true, /* Do not emit comments to output. */
22 | // "noEmit": true, /* Do not emit outputs. */
23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26 |
27 | /* Strict Type-Checking Options */
28 | "strict": true /* Enable all strict type-checking options. */,
29 | "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
30 | // "strictNullChecks": true, /* Enable strict null checks. */
31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36 |
37 | /* Additional Checks */
38 | // "noUnusedLocals": true, /* Report errors on unused locals. */
39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42 |
43 | /* Module Resolution Options */
44 | "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
48 | // "typeRoots": [], /* List of folders to include type definitions from. */
49 | "types": [
50 | "svelte"
51 | ] /* Type declaration files to be included in compilation. */,
52 | "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
53 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
54 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
55 |
56 | /* Source Map Options */
57 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
58 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
60 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
61 |
62 | /* Experimental Options */
63 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
64 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/packages/common/.editorconfig:
--------------------------------------------------------------------------------
1 | #root = true
2 |
3 | [*]
4 | indent_style = space
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 | max_line_length = 100
10 | indent_size = 2
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/packages/common/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .nyc_output
4 | .DS_Store
5 | *.log
6 | .vscode
7 | .idea
8 | dist
9 | compiled
10 | .awcache
11 | .rpt2_cache
12 | docs
13 |
--------------------------------------------------------------------------------
/packages/common/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - ~/.npm
5 | notifications:
6 | email: false
7 | node_js:
8 | - '10'
9 | - '11'
10 | - '8'
11 | - '6'
12 | script:
13 | - npm run test:prod && npm run build
14 | after_success:
15 | - npm run travis-deploy-once "npm run report-coverage"
16 | - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run deploy-docs"; fi
17 | - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi
18 | branches:
19 | except:
20 | - /^v\d+\.\d+\.\d+$/
21 |
--------------------------------------------------------------------------------
/packages/common/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | We're really glad you're reading this, because we need volunteer developers to help this project come to fruition. 👏
2 |
3 | ## Instructions
4 |
5 | These steps will guide you through contributing to this project:
6 |
7 | - Fork the repo
8 | - Clone it and install dependencies
9 |
10 | git clone https://github.com/YOUR-USERNAME/typescript-library-starter
11 | npm install
12 |
13 | Keep in mind that after running `npm install` the git repo is reset. So a good way to cope with this is to have a copy of the folder to push the changes, and the other to try them.
14 |
15 | Make and commit your changes. Make sure the commands npm run build and npm run test:prod are working.
16 |
17 | Finally send a [GitHub Pull Request](https://github.com/alexjoverm/typescript-library-starter/compare?expand=1) with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit).
18 |
--------------------------------------------------------------------------------
/packages/common/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017 Jungle
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/packages/common/README.md:
--------------------------------------------------------------------------------
1 | # Svelte Form (Common)
2 | Shared library for the Svelte Form ecosystem
3 |
4 | ### Install
5 |
6 | ```bash
7 | npm install @pyoner/svelte-form-common
8 | ```
9 |
--------------------------------------------------------------------------------
/packages/common/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at alexjovermorales@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/packages/common/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@pyoner/svelte-form-common",
3 | "version": "0.1.2",
4 | "description": "Shared library for the Svelte Form ecosystem",
5 | "keywords": [
6 | "svelte",
7 | "form",
8 | "validate",
9 | "validator",
10 | "validation",
11 | "json",
12 | "schema",
13 | "json-schema"
14 | ],
15 | "main": "dist/svelte-form-common.umd.js",
16 | "module": "dist/svelte-form-common.es5.js",
17 | "typings": "dist/types/svelte-form-common.d.ts",
18 | "files": [
19 | "dist"
20 | ],
21 | "author": "Jungle ",
22 | "homepage": "https://github.com/pyoner/svelte-form/tree/master/packages/common#readme",
23 | "repository": {
24 | "type": "git",
25 | "url": "https://github.com/pyoner/svelte-form"
26 | },
27 | "bugs": {
28 | "url": "https://github.com/pyoner/svelte-form/issues"
29 | },
30 | "license": "MIT",
31 | "engines": {
32 | "node": ">=6.0.0"
33 | },
34 | "scripts": {
35 | "lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
36 | "prebuild": "rimraf dist",
37 | "build": "tsc --emitDeclarationOnly -d --declarationDir ./dist/types && rollup -c rollup.config.ts",
38 | "start": "rollup -c rollup.config.ts -w",
39 | "test": "jest --coverage",
40 | "test:watch": "jest --coverage --watch",
41 | "test:prod": "npm run lint && npm run test -- --no-cache",
42 | "deploy-docs": "ts-node tools/gh-pages-publish",
43 | "report-coverage": "cat ./coverage/lcov.info | coveralls",
44 | "commit": "git-cz",
45 | "semantic-release": "semantic-release",
46 | "semantic-release-prepare": "ts-node tools/semantic-release-prepare",
47 | "precommit": "lint-staged",
48 | "travis-deploy-once": "travis-deploy-once"
49 | },
50 | "lint-staged": {
51 | "{src,test}/**/*.ts": [
52 | "prettier --write",
53 | "git add"
54 | ]
55 | },
56 | "config": {
57 | "commitizen": {
58 | "path": "node_modules/cz-conventional-changelog"
59 | }
60 | },
61 | "jest": {
62 | "transform": {
63 | ".(ts|tsx)": "ts-jest"
64 | },
65 | "testEnvironment": "node",
66 | "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
67 | "moduleFileExtensions": [
68 | "ts",
69 | "tsx",
70 | "js"
71 | ],
72 | "coveragePathIgnorePatterns": [
73 | "/node_modules/",
74 | "/test/"
75 | ],
76 | "coverageThreshold": {
77 | "global": {
78 | "branches": 90,
79 | "functions": 95,
80 | "lines": 95,
81 | "statements": 95
82 | }
83 | },
84 | "collectCoverageFrom": [
85 | "src/*.{js,ts}"
86 | ]
87 | },
88 | "commitlint": {
89 | "extends": [
90 | "@commitlint/config-conventional"
91 | ]
92 | },
93 | "devDependencies": {
94 | "@commitlint/cli": "^7.1.2",
95 | "@commitlint/config-conventional": "^7.1.2",
96 | "@rollup/plugin-commonjs": "^13.0.0",
97 | "@rollup/plugin-json": "^4.0.2",
98 | "@rollup/plugin-node-resolve": "^7.1.1",
99 | "@types/jest": "^23.3.2",
100 | "@types/node": "^10.11.0",
101 | "@wessberg/rollup-plugin-ts": "^1.2.25",
102 | "colors": "^1.3.2",
103 | "commitizen": "^3.0.0",
104 | "coveralls": "^3.0.2",
105 | "cross-env": "^5.2.0",
106 | "cz-conventional-changelog": "^2.1.0",
107 | "husky": "^1.0.1",
108 | "jest": "^23.6.0",
109 | "jest-config": "^23.6.0",
110 | "lint-staged": "^8.0.0",
111 | "lodash.camelcase": "^4.3.0",
112 | "pretty-quick": "^2.0.1",
113 | "prompt": "^1.0.0",
114 | "replace-in-file": "^3.4.2",
115 | "rimraf": "^2.6.2",
116 | "rollup": "^2.19.0",
117 | "rollup-plugin-analyzer": "^3.2.2",
118 | "rollup-plugin-sourcemaps": "^0.4.2",
119 | "semantic-release": "^17.4.4",
120 | "shelljs": "^0.8.3",
121 | "travis-deploy-once": "^5.0.9",
122 | "ts-jest": "^23.10.2",
123 | "ts-node": "^7.0.1",
124 | "tslint": "^5.11.0",
125 | "tslint-config-prettier": "^1.15.0",
126 | "tslint-config-standard": "^8.0.1"
127 | },
128 | "dependencies": {
129 | "json-schema-typed": "^7.0.3"
130 | },
131 | "peerDependencies": {
132 | "typescript": "^3.9"
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/packages/common/rollup.config.ts:
--------------------------------------------------------------------------------
1 | import resolve from "@rollup/plugin-node-resolve";
2 | import commonjs from "@rollup/plugin-commonjs";
3 | import sourceMaps from "rollup-plugin-sourcemaps";
4 | import camelCase from "lodash.camelcase";
5 | import typescript from "@wessberg/rollup-plugin-ts";
6 | import json from "@rollup/plugin-json";
7 | import analyze from "rollup-plugin-analyzer";
8 |
9 | const pkg = require("./package.json");
10 |
11 | const libraryName = "svelte-form-common";
12 |
13 | export default {
14 | input: `src/${libraryName}.ts`,
15 | output: [
16 | { file: pkg.main, name: camelCase(libraryName), format: "umd", sourcemap: true },
17 | { file: pkg.module, format: "es", sourcemap: true },
18 | ],
19 | // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
20 | external: [],
21 | watch: {
22 | include: "src/**",
23 | },
24 | plugins: [
25 | analyze({ summaryOnly: true }),
26 | // Allow json resolution
27 | json(),
28 | // Compile TypeScript files
29 | typescript(),
30 | // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
31 | commonjs(),
32 | // Allow node_modules resolution, so you can use 'external' to control
33 | // which external modules to include in the bundle
34 | // https://github.com/rollup/rollup-plugin-node-resolve#usage
35 | resolve(),
36 |
37 | // Resolve source maps to the original source
38 | sourceMaps(),
39 | ],
40 | };
41 |
--------------------------------------------------------------------------------
/packages/common/src/svelte-form-common.ts:
--------------------------------------------------------------------------------
1 | import type { JSONSchema } from "json-schema-typed";
2 |
3 | export type { JSONSchema };
4 |
5 | export const supportedTypes = ["array", "boolean", "null", "number", "integer", "object", "string"];
6 |
7 | export type JSONObject = Record;
8 |
9 | export interface ErrorRecord {
10 | [k: string]: Error[] | ErrorRecord;
11 | }
12 |
13 | export type Errors = ErrorRecord | Error[];
14 |
15 | export type Validator = (schema: JSONSchema, data: any) => Errors | null;
16 |
--------------------------------------------------------------------------------
/packages/common/test/svelte-form-common.test.ts:
--------------------------------------------------------------------------------
1 | import DummyClass from "../src/svelte-form-common"
2 |
3 | /**
4 | * Dummy test
5 | */
6 | describe("Dummy test", () => {
7 | it("works if true is truthy", () => {
8 | expect(true).toBeTruthy()
9 | })
10 |
11 | it("DummyClass is instantiable", () => {
12 | expect(new DummyClass()).toBeInstanceOf(DummyClass)
13 | })
14 | })
15 |
--------------------------------------------------------------------------------
/packages/common/tools/gh-pages-publish.ts:
--------------------------------------------------------------------------------
1 | const { cd, exec, echo, touch } = require("shelljs")
2 | const { readFileSync } = require("fs")
3 | const url = require("url")
4 |
5 | let repoUrl
6 | let pkg = JSON.parse(readFileSync("package.json") as any)
7 | if (typeof pkg.repository === "object") {
8 | if (!pkg.repository.hasOwnProperty("url")) {
9 | throw new Error("URL does not exist in repository section")
10 | }
11 | repoUrl = pkg.repository.url
12 | } else {
13 | repoUrl = pkg.repository
14 | }
15 |
16 | let parsedUrl = url.parse(repoUrl)
17 | let repository = (parsedUrl.host || "") + (parsedUrl.path || "")
18 | let ghToken = process.env.GH_TOKEN
19 |
20 | echo("Deploying docs!!!")
21 | cd("docs")
22 | touch(".nojekyll")
23 | exec("git init")
24 | exec("git add .")
25 | exec('git config user.name "Jungle"')
26 | exec('git config user.email "devex.soft@gmail.com"')
27 | exec('git commit -m "docs(docs): update gh-pages"')
28 | exec(
29 | `git push --force --quiet "https://${ghToken}@${repository}" master:gh-pages`
30 | )
31 | echo("Docs deployed!!")
32 |
--------------------------------------------------------------------------------
/packages/common/tools/semantic-release-prepare.ts:
--------------------------------------------------------------------------------
1 | const path = require("path")
2 | const { fork } = require("child_process")
3 | const colors = require("colors")
4 |
5 | const { readFileSync, writeFileSync } = require("fs")
6 | const pkg = JSON.parse(
7 | readFileSync(path.resolve(__dirname, "..", "package.json"))
8 | )
9 |
10 | pkg.scripts.prepush = "npm run test:prod && npm run build"
11 | pkg.scripts.commitmsg = "commitlint -E HUSKY_GIT_PARAMS"
12 |
13 | writeFileSync(
14 | path.resolve(__dirname, "..", "package.json"),
15 | JSON.stringify(pkg, null, 2)
16 | )
17 |
18 | // Call husky to set up the hooks
19 | fork(path.resolve(__dirname, "..", "node_modules", "husky", "lib", "installer", 'bin'), ['install'])
20 |
21 | console.log()
22 | console.log(colors.green("Done!!"))
23 | console.log()
24 |
25 | if (pkg.repository.url.trim()) {
26 | console.log(colors.cyan("Now run:"))
27 | console.log(colors.cyan(" npm install -g semantic-release-cli"))
28 | console.log(colors.cyan(" semantic-release-cli setup"))
29 | console.log()
30 | console.log(
31 | colors.cyan('Important! Answer NO to "Generate travis.yml" question')
32 | )
33 | console.log()
34 | console.log(
35 | colors.gray(
36 | 'Note: Make sure "repository.url" in your package.json is correct before'
37 | )
38 | )
39 | } else {
40 | console.log(
41 | colors.red(
42 | 'First you need to set the "repository.url" property in package.json'
43 | )
44 | )
45 | console.log(colors.cyan("Then run:"))
46 | console.log(colors.cyan(" npm install -g semantic-release-cli"))
47 | console.log(colors.cyan(" semantic-release-cli setup"))
48 | console.log()
49 | console.log(
50 | colors.cyan('Important! Answer NO to "Generate travis.yml" question')
51 | )
52 | }
53 |
54 | console.log()
55 |
--------------------------------------------------------------------------------
/packages/common/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "moduleResolution": "node",
4 | "target": "es5",
5 | "module":"es2015",
6 | "lib": ["es2015", "es2016", "es2017", "dom"],
7 | "strict": true,
8 | "sourceMap": true,
9 | "allowSyntheticDefaultImports": true,
10 | "experimentalDecorators": true,
11 | "emitDecoratorMetadata": true,
12 | },
13 | "include": [
14 | "src"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/common/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "tslint-config-standard",
4 | "tslint-config-prettier"
5 | ]
6 | }
--------------------------------------------------------------------------------
/packages/lib/.editorconfig:
--------------------------------------------------------------------------------
1 | #root = true
2 |
3 | [*]
4 | indent_style = space
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 | max_line_length = 100
10 | indent_size = 2
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/packages/lib/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .nyc_output
4 | .DS_Store
5 | *.log
6 | .vscode
7 | .idea
8 | dist
9 | compiled
10 | .awcache
11 | .rpt2_cache
12 | docs
13 |
--------------------------------------------------------------------------------
/packages/lib/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - ~/.npm
5 | notifications:
6 | email: false
7 | node_js:
8 | - '10'
9 | - '11'
10 | - '8'
11 | - '6'
12 | script:
13 | - npm run test:prod && npm run build
14 | after_success:
15 | - npm run travis-deploy-once "npm run report-coverage"
16 | - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run deploy-docs"; fi
17 | - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi
18 | branches:
19 | except:
20 | - /^v\d+\.\d+\.\d+$/
21 |
--------------------------------------------------------------------------------
/packages/lib/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | We're really glad you're reading this, because we need volunteer developers to help this project come to fruition. 👏
2 |
3 | ## Instructions
4 |
5 | These steps will guide you through contributing to this project:
6 |
7 | - Fork the repo
8 | - Clone it and install dependencies
9 |
10 | git clone https://github.com/YOUR-USERNAME/typescript-library-starter
11 | npm install
12 |
13 | Keep in mind that after running `npm install` the git repo is reset. So a good way to cope with this is to have a copy of the folder to push the changes, and the other to try them.
14 |
15 | Make and commit your changes. Make sure the commands npm run build and npm run test:prod are working.
16 |
17 | Finally send a [GitHub Pull Request](https://github.com/alexjoverm/typescript-library-starter/compare?expand=1) with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit).
18 |
--------------------------------------------------------------------------------
/packages/lib/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017 Jungle
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/packages/lib/README.md:
--------------------------------------------------------------------------------
1 | # Svelte JSON Schema Form library
2 |
3 | A library that helps you build a HTML form from a JSON Schema
4 |
5 | ## Note
6 |
7 | **(WIP) This library is currently under heavy development and isn't ready for production**
8 |
9 | ### Usage
10 |
11 | Install the library:
12 |
13 | ```bash
14 | npm install @pyoner/svelte-form
15 | ```
16 |
17 | Install a validator:
18 |
19 | ```bash
20 | npm install @pyoner/svelte-form-ajv
21 | ```
22 |
23 | Create App component:
24 |
25 | ```svelte
26 |
43 |
44 | {#if schema}
45 |
59 | {/if}
60 | ```
61 |
--------------------------------------------------------------------------------
/packages/lib/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at alexjovermorales@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/packages/lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@pyoner/svelte-form",
3 | "version": "1.0.2",
4 | "description": "A library that helps you build a HTML form from a JSON Schema",
5 | "keywords": [
6 | "svelte",
7 | "form",
8 | "validate",
9 | "validator",
10 | "validation",
11 | "json",
12 | "schema",
13 | "json-schema"
14 | ],
15 | "main": "dist/index.js",
16 | "module": "dist/index.es5.js",
17 | "svelte": "src/index.ts",
18 | "typings": "dist/types/index.d.ts",
19 | "files": [
20 | "src",
21 | "dist"
22 | ],
23 | "author": "Jungle ",
24 | "homepage": "https://github.com/pyoner/svelte-form/tree/master/packages/lib#readme",
25 | "repository": {
26 | "type": "git",
27 | "url": "https://github.com/pyoner/svelte-form"
28 | },
29 | "bugs": {
30 | "url": "https://github.com/pyoner/svelte-form/issues"
31 | },
32 | "license": "MIT",
33 | "engines": {
34 | "node": ">=6.0.0"
35 | },
36 | "scripts": {
37 | "lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
38 | "prebuild": "rimraf dist",
39 | "build": "tsc --emitDeclarationOnly -d --declarationDir ./dist/types && rollup -c rollup.config.ts",
40 | "start": "rollup -c rollup.config.ts -w",
41 | "test": "jest --coverage",
42 | "test:watch": "jest --coverage --watch",
43 | "test:prod": "npm run lint && npm run test -- --no-cache",
44 | "deploy-docs": "ts-node tools/gh-pages-publish",
45 | "report-coverage": "cat ./coverage/lcov.info | coveralls",
46 | "commit": "git-cz",
47 | "semantic-release": "semantic-release",
48 | "semantic-release-prepare": "ts-node tools/semantic-release-prepare",
49 | "travis-deploy-once": "travis-deploy-once",
50 | "format": "prettier --plugin-search-dir=. --write 'src/**/*' 'test/**/*'"
51 | },
52 | "lint-staged": {
53 | "{src,test}/**/*.ts": [
54 | "prettier --write",
55 | "git add"
56 | ]
57 | },
58 | "config": {
59 | "commitizen": {
60 | "path": "node_modules/cz-conventional-changelog"
61 | }
62 | },
63 | "jest": {
64 | "transform": {
65 | ".(ts|tsx)": "ts-jest"
66 | },
67 | "testEnvironment": "node",
68 | "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
69 | "moduleFileExtensions": [
70 | "ts",
71 | "tsx",
72 | "js"
73 | ],
74 | "coveragePathIgnorePatterns": [
75 | "/node_modules/",
76 | "/test/"
77 | ],
78 | "coverageThreshold": {
79 | "global": {
80 | "branches": 90,
81 | "functions": 95,
82 | "lines": 95,
83 | "statements": 95
84 | }
85 | },
86 | "collectCoverageFrom": [
87 | "src/*.{js,ts}"
88 | ]
89 | },
90 | "commitlint": {
91 | "extends": [
92 | "@commitlint/config-conventional"
93 | ]
94 | },
95 | "devDependencies": {
96 | "@commitlint/cli": "^8.3.5",
97 | "@commitlint/config-conventional": "^8.3.4",
98 | "@pyoner/svelte-ts-preprocess": "^1.3.0",
99 | "@rollup/plugin-commonjs": "^13.0.0",
100 | "@rollup/plugin-json": "^4.0.2",
101 | "@rollup/plugin-node-resolve": "^7.1.1",
102 | "@types/jest": "^24.9.0",
103 | "@types/node": "^13.1.8",
104 | "@types/type-detect": "^4.0.1",
105 | "@wessberg/rollup-plugin-ts": "^1.2.25",
106 | "camelcase": "^5.3.1",
107 | "colors": "^1.4.0",
108 | "commitizen": "^4.0.3",
109 | "coveralls": "^3.0.9",
110 | "cross-env": "^6.0.3",
111 | "cz-conventional-changelog": "^3.0.2",
112 | "husky": "^4.0.10",
113 | "jest": "^24.9.0",
114 | "jest-config": "^24.9.0",
115 | "json-schema-typed": "^7.0.3",
116 | "lint-staged": "^10.0.0",
117 | "pretty-quick": "^2.0.1",
118 | "prompt": "^1.0.0",
119 | "replace-in-file": "^5.0.2",
120 | "rimraf": "^3.0.0",
121 | "rollup": "^2.19.0",
122 | "rollup-plugin-analyzer": "^3.2.2",
123 | "rollup-plugin-sourcemaps": "^0.5.0",
124 | "rollup-plugin-svelte": "^5.1.1",
125 | "semantic-release": "^17.4.4",
126 | "shelljs": "^0.8.3",
127 | "svelte": "^3.17.1",
128 | "travis-deploy-once": "^5.0.11",
129 | "ts-jest": "^24.3.0",
130 | "ts-node": "^8.6.2",
131 | "tslib": "^1.10.0",
132 | "tslint": "^5.20.1",
133 | "tslint-config-prettier": "^1.18.0",
134 | "tslint-config-standard": "^9.0.0"
135 | },
136 | "dependencies": {
137 | "@pyoner/svelte-form-common": "workspace:^0.1.2",
138 | "is-what": "^3.7.1"
139 | },
140 | "peerDependencies": {
141 | "typescript": "^3.9"
142 | },
143 | "husky": {
144 | "hooks": {
145 | "pre-commit": "pretty-quick --staged"
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/packages/lib/rollup.config.ts:
--------------------------------------------------------------------------------
1 | import resolve from "@rollup/plugin-node-resolve";
2 | import commonjs from "@rollup/plugin-commonjs";
3 | import json from "@rollup/plugin-json";
4 |
5 | import sourceMaps from "rollup-plugin-sourcemaps";
6 | import typescript from "@wessberg/rollup-plugin-ts";
7 |
8 | import camelCase from "camelcase";
9 |
10 | import analyze from "rollup-plugin-analyzer";
11 | import svelte from "rollup-plugin-svelte";
12 | import { preprocess, createEnv, readConfigFile } from "@pyoner/svelte-ts-preprocess";
13 |
14 | const production = !process.env.ROLLUP_WATCH;
15 |
16 | const env = createEnv();
17 | const compilerOptions = readConfigFile(env);
18 | const opts = {
19 | env,
20 | compilerOptions: {
21 | ...compilerOptions,
22 | allowNonTsExtensions: true,
23 | },
24 | };
25 |
26 | const pkg = require("./package.json");
27 |
28 | const libraryName = "svelte-form";
29 |
30 | export default {
31 | input: `src/index.ts`,
32 | output: [
33 | { file: pkg.main, name: camelCase(libraryName), format: "umd", sourcemap: true },
34 | { file: pkg.module, format: "es", sourcemap: true },
35 | ],
36 | // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
37 | external: [],
38 | watch: {
39 | include: "src/**",
40 | },
41 | plugins: [
42 | analyze({ summaryOnly: true }),
43 | svelte({
44 | // enable run-time checks when not in production
45 | dev: !production,
46 | // we'll extract any component CSS out into
47 | // a separate file — better for performance
48 | css: (css) => {
49 | css.write("public/bundle.css");
50 | },
51 | preprocess: preprocess(opts),
52 | }),
53 | // Allow json resolution
54 | json(),
55 | // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
56 | commonjs(),
57 | // Allow node_modules resolution, so you can use 'external' to control
58 | // which external modules to include in the bundle
59 | // https://github.com/rollup/rollup-plugin-node-resolve#usage
60 | resolve(),
61 | // Compile TypeScript files
62 | typescript(),
63 |
64 | // Resolve source maps to the original source
65 | sourceMaps(),
66 | ],
67 | };
68 |
--------------------------------------------------------------------------------
/packages/lib/src/components/AddItem.svelte:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/lib/src/components/Form.svelte:
--------------------------------------------------------------------------------
1 |
58 |
59 |
77 |
--------------------------------------------------------------------------------
/packages/lib/src/components/ItemCtrl.svelte:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/packages/lib/src/components/ItemWrapper.svelte:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/packages/lib/src/components/Layout.svelte:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/packages/lib/src/components/Wrapper.svelte:
--------------------------------------------------------------------------------
1 |
7 |
8 |
13 |
14 | {#if schema}
15 | {#if schema.type == 'object' || schema.type == 'array'}
16 |
31 | {:else}
32 |
33 | {#if schema.title}
34 |
35 | {/if}
36 |
37 |
A field is not implemented
38 |
39 | {#if errors && errors.length}
40 | {#each errors as error}
41 |
{error.message}
42 | {/each}
43 | {/if}
44 |
45 | {#if schema.description}
46 |
{schema.description}
47 | {/if}
48 |
49 | {/if}
50 | {/if}
51 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/ArrayField.svelte:
--------------------------------------------------------------------------------
1 |
63 |
64 | {#if components && schema && schema.items && schema.items.type}
65 |
66 | {#if value}
67 | {#each value as v, i (i)}
68 |
72 |
73 |
80 |
81 |
82 | {
87 | removeItem(i);
88 | }}
89 | moveUp={() => {
90 | moveItem(i, i - 1);
91 | }}
92 | moveDown={() => {
93 | moveItem(i, i + 1);
94 | }}
95 | position={i}
96 | length={value.length} />
97 |
98 |
99 |
100 | {/each}
101 | {/if}
102 |
103 |
107 |
108 | {/if}
109 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/BooleanField.svelte:
--------------------------------------------------------------------------------
1 |
18 |
19 | {#if schema && components}
20 |
21 |
22 |
23 | {/if}
24 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/NullField.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 | {#if schema && components}
16 |
17 |
18 |
19 | {/if}
20 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/NumberField.svelte:
--------------------------------------------------------------------------------
1 |
18 |
19 | {#if schema && components}
20 |
21 |
22 |
23 | {/if}
24 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/ObjectField.svelte:
--------------------------------------------------------------------------------
1 |
18 |
19 | {#if schema && components}
20 |
21 | {#each Object.entries(schema.properties) as [key, propSchema] (key)}
22 |
29 | {/each}
30 |
31 | {/if}
32 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/StringField.svelte:
--------------------------------------------------------------------------------
1 |
21 |
22 | {#if schema && components}
23 |
24 | {#if format == 'date-time'}
25 |
26 | {:else if format == 'date'}
27 |
28 | {:else if format == 'time'}
29 |
30 | {:else}
31 |
32 | {/if}
33 |
34 | {/if}
35 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/extra/TextareaField.svelte:
--------------------------------------------------------------------------------
1 |
18 |
19 | {#if schema && components}
20 |
21 |
22 |
23 | {/if}
24 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/extra/index.ts:
--------------------------------------------------------------------------------
1 | import TextareaField from './TextareaField.svelte'
2 | export { TextareaField }
3 |
--------------------------------------------------------------------------------
/packages/lib/src/components/fields/index.ts:
--------------------------------------------------------------------------------
1 | import type { FieldComponents } from "../../types";
2 |
3 | import BooleanField from "./BooleanField.svelte";
4 | import NullField from "./NullField.svelte";
5 | import NumberField from "./NumberField.svelte";
6 | import StringField from "./StringField.svelte";
7 | import ObjectField from "./ObjectField.svelte";
8 | import ArrayField from "./ArrayField.svelte";
9 |
10 | export const defaultFieldComponents: FieldComponents = {
11 | boolean: BooleanField,
12 | null: NullField,
13 | number: NumberField,
14 | integer: [NumberField, { step: 1 }],
15 | string: StringField,
16 | object: ObjectField,
17 | array: ArrayField,
18 | };
19 |
20 | export { BooleanField, NullField, NumberField, StringField, ObjectField, ArrayField };
21 |
--------------------------------------------------------------------------------
/packages/lib/src/components/helpers/Wrap.svelte:
--------------------------------------------------------------------------------
1 |
10 |
11 | {#if schema && component}
12 |
17 |
18 |
19 | {/if}
20 |
--------------------------------------------------------------------------------
/packages/lib/src/components/index.ts:
--------------------------------------------------------------------------------
1 | import type { FormComponents } from "../types";
2 | import Wrapper from "./Wrapper.svelte";
3 | import Layout from "./Layout.svelte";
4 | import Form from "./Form.svelte";
5 | import ItemWrapper from "./ItemWrapper.svelte";
6 | import ItemCtrl from "./ItemCtrl.svelte";
7 | import AddItem from "./AddItem.svelte";
8 | import { defaultFieldComponents as fields } from "./fields";
9 |
10 | export const defaultFormComponents: FormComponents = {
11 | layout: Layout,
12 | wrapper: Wrapper,
13 | form: Form,
14 | itemWrapper: ItemWrapper,
15 | itemCtrl: ItemCtrl,
16 | addItem: AddItem,
17 | fields: fields,
18 | };
19 |
20 | export { Wrapper, Layout, Form, ItemWrapper, ItemCtrl, AddItem, fields };
21 |
--------------------------------------------------------------------------------
/packages/lib/src/helpers.ts:
--------------------------------------------------------------------------------
1 | import { isObject } from "is-what";
2 | import { SvelteComponent } from "svelte";
3 | import { SvelteComponent as InternalSvelteComponent } from "svelte/internal";
4 |
5 | import type { JSONObject, JSONSchema } from "@pyoner/svelte-form-common";
6 |
7 | import type {
8 | FieldProps,
9 | Errors,
10 | Props,
11 | SvelteComponentProps,
12 | SvelteSchema,
13 | SvelteSchemaKeys,
14 | FuncProps,
15 | FuncComponent,
16 | } from "./types";
17 |
18 | export function createProps(
19 | value: T | null = null
20 | ): FieldProps {
21 | const props: FieldProps = {
22 | value,
23 | errors: null,
24 | };
25 |
26 | return props;
27 | }
28 |
29 | export function objectDefaultValue(schema: JSONSchema, value: JSONObject | null): JSONObject {
30 | const v: JSONObject = {};
31 | const { properties } = schema;
32 | if (properties) {
33 | for (let k in properties) {
34 | const propSchema = properties[k];
35 |
36 | if (typeof propSchema !== "boolean") {
37 | const item = value && value[k];
38 | v[k] = defaultValue(propSchema, item);
39 | }
40 | }
41 | }
42 | return v;
43 | }
44 |
45 | export function defaultValue(schema: JSONSchema, value: T | null): T | null {
46 | if (value === undefined) {
47 | value = null;
48 | }
49 |
50 | if (value == null && schema.default !== undefined) {
51 | value = schema.default as T;
52 | }
53 |
54 | switch (schema.type) {
55 | case "object":
56 | return objectDefaultValue(schema, value) as T;
57 |
58 | case "array":
59 | return (value || []) as T;
60 | }
61 |
62 | return value;
63 | }
64 |
65 | export function normalizeObject(value: JSONObject, isRoot = true): JSONObject | null {
66 | const obj: JSONObject = {};
67 | for (const k in value) {
68 | let v = value[k];
69 | v = isObject(v) ? normalizeObject(v as JSONObject, false) : v;
70 | if (!(v === null || v === undefined)) {
71 | obj[k] = v;
72 | }
73 | }
74 | return Object.keys(obj).length ? obj : isRoot ? {} : null;
75 | }
76 |
77 | export function normalizeValue(value: any): any {
78 | return isObject(value) ? normalizeObject(value as JSONObject) : value;
79 | }
80 |
81 | export function getComponentFromSchema(
82 | schema: SvelteSchema,
83 | key: SvelteSchemaKeys
84 | ): typeof SvelteComponent | FuncComponent | undefined {
85 | const obj = schema.$svelte && schema.$svelte[key];
86 |
87 | if (obj?.component) {
88 | return obj.component;
89 | }
90 | }
91 |
92 | export function getPropsFromSchema(
93 | schema: SvelteSchema,
94 | key: SvelteSchemaKeys
95 | ): Props | FuncProps | undefined {
96 | const obj = schema.$svelte && schema.$svelte[key];
97 |
98 | if (obj?.props) {
99 | return obj.props;
100 | }
101 | }
102 |
103 | export function getComponentFromContainer(container: SvelteComponentProps): typeof SvelteComponent {
104 | return Array.isArray(container) ? container[0] : container;
105 | }
106 |
107 | export function getPropsFromContainer(container: SvelteComponentProps): Props {
108 | return Array.isArray(container) ? container[1] : {};
109 | }
110 |
111 | export function getProps(
112 | schema: SvelteSchema,
113 | container: SvelteComponentProps,
114 | key: SvelteSchemaKeys
115 | ): Props {
116 | const component = getComponentFromSchema(schema, key);
117 |
118 | const props = getPropsFromSchema(schema, key);
119 | if (props) {
120 | return props;
121 | }
122 |
123 | if (component) {
124 | return {};
125 | }
126 |
127 | return getPropsFromContainer(container);
128 | }
129 |
130 | export function isSvelteComponent(obj: any): obj is typeof SvelteComponent {
131 | const cls = Object.getPrototypeOf(obj);
132 | return cls === SvelteComponent || cls === InternalSvelteComponent;
133 | }
134 |
135 | export function getComponent(
136 | schema: SvelteSchema,
137 | container: SvelteComponentProps,
138 | key: SvelteSchemaKeys
139 | ): typeof SvelteComponent {
140 | const defaultComponent = getComponentFromContainer(container);
141 | const component = getComponentFromSchema(schema, key);
142 |
143 | if (component) {
144 | if (!isSvelteComponent(component)) {
145 | return component(defaultComponent);
146 | }
147 | return component;
148 | }
149 |
150 | return defaultComponent;
151 | }
152 |
--------------------------------------------------------------------------------
/packages/lib/src/index.ts:
--------------------------------------------------------------------------------
1 | import { Form, defaultFormComponents as components } from './components'
2 | import * as helpers from './helpers'
3 | import * as extra from './components/fields/extra'
4 |
5 | export { Form, components, helpers, extra }
6 |
--------------------------------------------------------------------------------
/packages/lib/src/types.ts:
--------------------------------------------------------------------------------
1 | import type { SvelteComponent } from "svelte";
2 | import type { JSONSchema } from "@pyoner/svelte-form-common";
3 |
4 | export interface FieldComponents {
5 | boolean: SvelteComponentProps;
6 | null: SvelteComponentProps;
7 | integer: SvelteComponentProps;
8 | number: SvelteComponentProps;
9 | string: SvelteComponentProps;
10 | array: SvelteComponentProps;
11 | object: SvelteComponentProps;
12 | }
13 |
14 | export interface FieldProps {
15 | value: T | null;
16 | errors: E | null;
17 | schema?: SvelteSchema;
18 | components?: FormComponents;
19 | props?: Props;
20 | }
21 |
22 | export type Props = Record;
23 |
24 | export type SvelteComponentProps = typeof SvelteComponent | [typeof SvelteComponent, Props];
25 |
26 | export interface FormComponents {
27 | layout: SvelteComponentProps;
28 | wrapper: SvelteComponentProps;
29 | form: SvelteComponentProps;
30 | itemWrapper: SvelteComponentProps;
31 | itemCtrl: SvelteComponentProps;
32 | addItem: SvelteComponentProps;
33 | fields: FieldComponents;
34 | }
35 |
36 | export interface FormProps {
37 | value: T;
38 | schema: SvelteSchema;
39 | components: FormComponents;
40 | validator: Validator;
41 | }
42 |
43 | export interface ErrorRecord {
44 | [k: string]: Error[] | ErrorRecord;
45 | }
46 |
47 | export type Errors = ErrorRecord | Error[];
48 |
49 | export type FuncProps = (props: Props) => Props;
50 | export type FuncComponent = (component: typeof SvelteComponent) => typeof SvelteComponent;
51 |
52 | export type SvelteSchemaKeys =
53 | | "field"
54 | | "wrapper"
55 | | "ctrl"
56 | | "itemWrapper"
57 | | "itemCtrl"
58 | | "addItem";
59 |
60 | export interface SvelteSchema extends JSONSchema {
61 | $svelte?: {
62 | [P in SvelteSchemaKeys]: {
63 | component?: typeof SvelteComponent | FuncComponent;
64 | props?: Props | FuncProps;
65 | };
66 | };
67 | }
68 |
69 | export type Validator = (schema: JSONSchema, data: any) => Errors | null;
70 |
--------------------------------------------------------------------------------
/packages/lib/test/svelte-form.test.ts:
--------------------------------------------------------------------------------
1 | import { GenericField } from '../src/svelte-form'
2 |
3 | describe('GenericField test', () => {
4 | it('exists', () => {
5 | expect(GenericField).toBeTruthy()
6 | })
7 | })
8 |
--------------------------------------------------------------------------------
/packages/lib/tools/gh-pages-publish.ts:
--------------------------------------------------------------------------------
1 | const { cd, exec, echo, touch } = require("shelljs")
2 | const { readFileSync } = require("fs")
3 | const url = require("url")
4 |
5 | let repoUrl
6 | let pkg = JSON.parse(readFileSync("package.json") as any)
7 | if (typeof pkg.repository === "object") {
8 | if (!pkg.repository.hasOwnProperty("url")) {
9 | throw new Error("URL does not exist in repository section")
10 | }
11 | repoUrl = pkg.repository.url
12 | } else {
13 | repoUrl = pkg.repository
14 | }
15 |
16 | let parsedUrl = url.parse(repoUrl)
17 | let repository = (parsedUrl.host || "") + (parsedUrl.path || "")
18 | let ghToken = process.env.GH_TOKEN
19 |
20 | echo("Deploying docs!!!")
21 | cd("docs")
22 | touch(".nojekyll")
23 | exec("git init")
24 | exec("git add .")
25 | exec('git config user.name "Jungle"')
26 | exec('git config user.email "devex.soft@gmail.com"')
27 | exec('git commit -m "docs(docs): update gh-pages"')
28 | exec(
29 | `git push --force --quiet "https://${ghToken}@${repository}" master:gh-pages`
30 | )
31 | echo("Docs deployed!!")
32 |
--------------------------------------------------------------------------------
/packages/lib/tools/semantic-release-prepare.ts:
--------------------------------------------------------------------------------
1 | const path = require("path")
2 | const { fork } = require("child_process")
3 | const colors = require("colors")
4 |
5 | const { readFileSync, writeFileSync } = require("fs")
6 | const pkg = JSON.parse(
7 | readFileSync(path.resolve(__dirname, "..", "package.json"))
8 | )
9 |
10 | pkg.scripts.prepush = "npm run test:prod && npm run build"
11 | pkg.scripts.commitmsg = "commitlint -E HUSKY_GIT_PARAMS"
12 |
13 | writeFileSync(
14 | path.resolve(__dirname, "..", "package.json"),
15 | JSON.stringify(pkg, null, 2)
16 | )
17 |
18 | // Call husky to set up the hooks
19 | fork(path.resolve(__dirname, "..", "node_modules", "husky", "lib", "installer", 'bin'), ['install'])
20 |
21 | console.log()
22 | console.log(colors.green("Done!!"))
23 | console.log()
24 |
25 | if (pkg.repository.url.trim()) {
26 | console.log(colors.cyan("Now run:"))
27 | console.log(colors.cyan(" npm install -g semantic-release-cli"))
28 | console.log(colors.cyan(" semantic-release-cli setup"))
29 | console.log()
30 | console.log(
31 | colors.cyan('Important! Answer NO to "Generate travis.yml" question')
32 | )
33 | console.log()
34 | console.log(
35 | colors.gray(
36 | 'Note: Make sure "repository.url" in your package.json is correct before'
37 | )
38 | )
39 | } else {
40 | console.log(
41 | colors.red(
42 | 'First you need to set the "repository.url" property in package.json'
43 | )
44 | )
45 | console.log(colors.cyan("Then run:"))
46 | console.log(colors.cyan(" npm install -g semantic-release-cli"))
47 | console.log(colors.cyan(" semantic-release-cli setup"))
48 | console.log()
49 | console.log(
50 | colors.cyan('Important! Answer NO to "Generate travis.yml" question')
51 | )
52 | }
53 |
54 | console.log()
55 |
--------------------------------------------------------------------------------
/packages/lib/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "resolveJsonModule": true,
4 | "esModuleInterop": true,
5 | "moduleResolution": "node",
6 | "target": "es5",
7 | "module": "es2015",
8 | "lib": ["es2015", "es2016", "es2017", "dom"],
9 | "strict": true,
10 | "sourceMap": true,
11 | "allowSyntheticDefaultImports": true,
12 | "experimentalDecorators": true,
13 | "emitDecoratorMetadata": true,
14 | "types": ["svelte"]
15 | },
16 | "include": ["src"]
17 | }
18 |
--------------------------------------------------------------------------------
/packages/lib/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "tslint-config-standard",
4 | "tslint-config-prettier"
5 | ]
6 | }
--------------------------------------------------------------------------------
/packages/validators/ajv/.editorconfig:
--------------------------------------------------------------------------------
1 | #root = true
2 |
3 | [*]
4 | indent_style = space
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 | max_line_length = 100
10 | indent_size = 2
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/packages/validators/ajv/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .nyc_output
4 | .DS_Store
5 | *.log
6 | .vscode
7 | .idea
8 | dist
9 | compiled
10 | .awcache
11 | .rpt2_cache
12 | docs
13 |
--------------------------------------------------------------------------------
/packages/validators/ajv/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - ~/.npm
5 | notifications:
6 | email: false
7 | node_js:
8 | - '10'
9 | - '11'
10 | - '8'
11 | - '6'
12 | script:
13 | - npm run test:prod && npm run build
14 | after_success:
15 | - npm run travis-deploy-once "npm run report-coverage"
16 | - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run deploy-docs"; fi
17 | - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi
18 | branches:
19 | except:
20 | - /^v\d+\.\d+\.\d+$/
21 |
--------------------------------------------------------------------------------
/packages/validators/ajv/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | We're really glad you're reading this, because we need volunteer developers to help this project come to fruition. 👏
2 |
3 | ## Instructions
4 |
5 | These steps will guide you through contributing to this project:
6 |
7 | - Fork the repo
8 | - Clone it and install dependencies
9 |
10 | git clone https://github.com/YOUR-USERNAME/typescript-library-starter
11 | npm install
12 |
13 | Keep in mind that after running `npm install` the git repo is reset. So a good way to cope with this is to have a copy of the folder to push the changes, and the other to try them.
14 |
15 | Make and commit your changes. Make sure the commands npm run build and npm run test:prod are working.
16 |
17 | Finally send a [GitHub Pull Request](https://github.com/alexjoverm/typescript-library-starter/compare?expand=1) with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit).
18 |
--------------------------------------------------------------------------------
/packages/validators/ajv/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017 Jungle
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/packages/validators/ajv/README.md:
--------------------------------------------------------------------------------
1 | # Ajv Validator
2 |
3 | ### Install
4 |
5 | ```bash
6 | npm install @pyoner/svelte-form-ajv
7 | ```
8 |
9 | ### Usage
10 |
11 | ```svelte
12 |
29 |
30 | {#if schema}
31 |
45 | {/if}
46 | ```
47 |
--------------------------------------------------------------------------------
/packages/validators/ajv/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at alexjovermorales@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/packages/validators/ajv/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@pyoner/svelte-form-ajv",
3 | "version": "0.1.3",
4 | "description": "Ajv validator for @pyoner/svelte-form",
5 | "keywords": [
6 | "svelte",
7 | "form",
8 | "validate",
9 | "validator",
10 | "validation",
11 | "json",
12 | "schema",
13 | "json-schema"
14 | ],
15 | "main": "dist/svelte-form-ajv.umd.js",
16 | "module": "dist/svelte-form-ajv.es5.js",
17 | "typings": "dist/types/svelte-form-ajv.d.ts",
18 | "files": [
19 | "dist"
20 | ],
21 | "author": "Jungle ",
22 | "homepage": "https://github.com/pyoner/svelte-form/tree/master/packages/validators/ajv#readme",
23 | "repository": {
24 | "type": "git",
25 | "url": "https://github.com/pyoner/svelte-form"
26 | },
27 | "bugs": {
28 | "url": "https://github.com/pyoner/svelte-form/issues"
29 | },
30 | "license": "MIT",
31 | "engines": {
32 | "node": ">=6.0.0"
33 | },
34 | "scripts": {
35 | "lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
36 | "prebuild": "rimraf dist",
37 | "build": "tsc --emitDeclarationOnly -d --declarationDir ./dist/types && rollup -c rollup.config.ts",
38 | "start": "rollup -c rollup.config.ts -w",
39 | "test": "jest --coverage",
40 | "test:watch": "jest --coverage --watch",
41 | "test:prod": "npm run lint && npm run test -- --no-cache",
42 | "deploy-docs": "ts-node tools/gh-pages-publish",
43 | "report-coverage": "cat ./coverage/lcov.info | coveralls",
44 | "commit": "git-cz",
45 | "semantic-release": "semantic-release",
46 | "semantic-release-prepare": "ts-node tools/semantic-release-prepare",
47 | "precommit": "lint-staged",
48 | "travis-deploy-once": "travis-deploy-once"
49 | },
50 | "lint-staged": {
51 | "{src,test}/**/*.ts": [
52 | "prettier --write",
53 | "git add"
54 | ]
55 | },
56 | "config": {
57 | "commitizen": {
58 | "path": "node_modules/cz-conventional-changelog"
59 | }
60 | },
61 | "jest": {
62 | "transform": {
63 | ".(ts|tsx)": "ts-jest"
64 | },
65 | "testEnvironment": "node",
66 | "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
67 | "moduleFileExtensions": [
68 | "ts",
69 | "tsx",
70 | "js"
71 | ],
72 | "coveragePathIgnorePatterns": [
73 | "/node_modules/",
74 | "/test/"
75 | ],
76 | "coverageThreshold": {
77 | "global": {
78 | "branches": 90,
79 | "functions": 95,
80 | "lines": 95,
81 | "statements": 95
82 | }
83 | },
84 | "collectCoverageFrom": [
85 | "src/*.{js,ts}"
86 | ]
87 | },
88 | "commitlint": {
89 | "extends": [
90 | "@commitlint/config-conventional"
91 | ]
92 | },
93 | "devDependencies": {
94 | "@commitlint/cli": "^7.1.2",
95 | "@commitlint/config-conventional": "^7.1.2",
96 | "@rollup/plugin-commonjs": "^13.0.0",
97 | "@rollup/plugin-json": "^4.0.2",
98 | "@rollup/plugin-node-resolve": "^7.1.1",
99 | "@types/jest": "^23.3.2",
100 | "@types/node": "^10.11.0",
101 | "@types/ramda": "^0.26.43",
102 | "@wessberg/rollup-plugin-ts": "^1.2.25",
103 | "colors": "^1.3.2",
104 | "commitizen": "^3.0.0",
105 | "coveralls": "^3.0.2",
106 | "cross-env": "^5.2.0",
107 | "cz-conventional-changelog": "^2.1.0",
108 | "husky": "^1.0.1",
109 | "jest": "^23.6.0",
110 | "jest-config": "^23.6.0",
111 | "lint-staged": "^8.0.0",
112 | "lodash.camelcase": "^4.3.0",
113 | "pretty-quick": "^2.0.1",
114 | "prompt": "^1.0.0",
115 | "replace-in-file": "^3.4.2",
116 | "rimraf": "^2.6.2",
117 | "rollup": "^2.19.0",
118 | "rollup-plugin-analyzer": "^3.2.2",
119 | "rollup-plugin-sourcemaps": "^0.4.2",
120 | "semantic-release": "^17.4.4",
121 | "shelljs": "^0.8.3",
122 | "travis-deploy-once": "^5.0.9",
123 | "ts-jest": "^23.10.2",
124 | "ts-node": "^7.0.1",
125 | "ts-toolbelt": "^6.3.5",
126 | "tslint": "^5.11.0",
127 | "tslint-config-prettier": "^1.15.0",
128 | "tslint-config-standard": "^8.0.1"
129 | },
130 | "dependencies": {
131 | "@pyoner/svelte-form-common": "workspace:^0.1.2",
132 | "ajv": "^6.12.0",
133 | "ramda": "^0.27.0"
134 | },
135 | "peerDependencies": {
136 | "typescript": "^3.9"
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/packages/validators/ajv/rollup.config.ts:
--------------------------------------------------------------------------------
1 | import resolve from "@rollup/plugin-node-resolve";
2 | import commonjs from "@rollup/plugin-commonjs";
3 | import sourceMaps from "rollup-plugin-sourcemaps";
4 | import camelCase from "lodash.camelcase";
5 | import typescript from "@wessberg/rollup-plugin-ts";
6 | import json from "@rollup/plugin-json";
7 | import analyze from "rollup-plugin-analyzer";
8 |
9 | const pkg = require("./package.json");
10 |
11 | const libraryName = "svelte-form-ajv";
12 |
13 | export default {
14 | input: `src/${libraryName}.ts`,
15 | output: [
16 | { file: pkg.main, name: camelCase(libraryName), format: "umd", sourcemap: true },
17 | { file: pkg.module, format: "es", sourcemap: true },
18 | ],
19 | // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
20 | external: [],
21 | watch: {
22 | include: "src/**",
23 | },
24 | plugins: [
25 | analyze({ summaryOnly: true }),
26 | // Allow json resolution
27 | json(),
28 | // Compile TypeScript files
29 | typescript(),
30 | // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
31 | commonjs(),
32 | // Allow node_modules resolution, so you can use 'external' to control
33 | // which external modules to include in the bundle
34 | // https://github.com/rollup/rollup-plugin-node-resolve#usage
35 | resolve(),
36 |
37 | // Resolve source maps to the original source
38 | sourceMaps(),
39 | ],
40 | };
41 |
--------------------------------------------------------------------------------
/packages/validators/ajv/src/svelte-form-ajv.ts:
--------------------------------------------------------------------------------
1 | import Ajv, { ErrorObject } from "ajv";
2 |
3 | import type { JSONSchema, ErrorRecord, Validator } from "@pyoner/svelte-form-common";
4 | import { lensPath, over, append } from "ramda";
5 |
6 | export const options = {
7 | schemaId: "auto",
8 | jsonPointers: true,
9 | allErrors: true,
10 | };
11 |
12 | export function createAjvValidator(ajv: Ajv.Ajv): Validator {
13 | return (schema: JSONSchema, data: any) => {
14 | const valid = ajv.validate(schema, data) as boolean;
15 | if (!valid) {
16 | return errorsToMap(ajv.errors as Ajv.ErrorObject[]);
17 | }
18 | return null;
19 | };
20 | }
21 |
22 | export function errorsToMap(errors: ErrorObject[]): ErrorRecord {
23 | const errorMap: ErrorRecord = {};
24 | return errors
25 | .map((error): [string[], ErrorObject] => {
26 | const path = error.dataPath ? error.dataPath.replace(/^\//, "").split("/") : [];
27 | const propName =
28 | error.keyword === "required" ? (error.params).missingProperty : "";
29 | if (propName) {
30 | path.push(propName);
31 | }
32 | return [path, error];
33 | })
34 | .reduce((acc, [path, error]) => {
35 | const lens = lensPath(path);
36 | return over(lens, (list = []) => append(error, list), acc);
37 | }, errorMap);
38 | }
39 |
--------------------------------------------------------------------------------
/packages/validators/ajv/test/svelte-form-ajv.test.ts:
--------------------------------------------------------------------------------
1 | import DummyClass from "../src/svelte-form-ajv"
2 |
3 | /**
4 | * Dummy test
5 | */
6 | describe("Dummy test", () => {
7 | it("works if true is truthy", () => {
8 | expect(true).toBeTruthy()
9 | })
10 |
11 | it("DummyClass is instantiable", () => {
12 | expect(new DummyClass()).toBeInstanceOf(DummyClass)
13 | })
14 | })
15 |
--------------------------------------------------------------------------------
/packages/validators/ajv/tools/gh-pages-publish.ts:
--------------------------------------------------------------------------------
1 | const { cd, exec, echo, touch } = require("shelljs")
2 | const { readFileSync } = require("fs")
3 | const url = require("url")
4 |
5 | let repoUrl
6 | let pkg = JSON.parse(readFileSync("package.json") as any)
7 | if (typeof pkg.repository === "object") {
8 | if (!pkg.repository.hasOwnProperty("url")) {
9 | throw new Error("URL does not exist in repository section")
10 | }
11 | repoUrl = pkg.repository.url
12 | } else {
13 | repoUrl = pkg.repository
14 | }
15 |
16 | let parsedUrl = url.parse(repoUrl)
17 | let repository = (parsedUrl.host || "") + (parsedUrl.path || "")
18 | let ghToken = process.env.GH_TOKEN
19 |
20 | echo("Deploying docs!!!")
21 | cd("docs")
22 | touch(".nojekyll")
23 | exec("git init")
24 | exec("git add .")
25 | exec('git config user.name "Jungle"')
26 | exec('git config user.email "devex.soft@gmail.com"')
27 | exec('git commit -m "docs(docs): update gh-pages"')
28 | exec(
29 | `git push --force --quiet "https://${ghToken}@${repository}" master:gh-pages`
30 | )
31 | echo("Docs deployed!!")
32 |
--------------------------------------------------------------------------------
/packages/validators/ajv/tools/semantic-release-prepare.ts:
--------------------------------------------------------------------------------
1 | const path = require("path")
2 | const { fork } = require("child_process")
3 | const colors = require("colors")
4 |
5 | const { readFileSync, writeFileSync } = require("fs")
6 | const pkg = JSON.parse(
7 | readFileSync(path.resolve(__dirname, "..", "package.json"))
8 | )
9 |
10 | pkg.scripts.prepush = "npm run test:prod && npm run build"
11 | pkg.scripts.commitmsg = "commitlint -E HUSKY_GIT_PARAMS"
12 |
13 | writeFileSync(
14 | path.resolve(__dirname, "..", "package.json"),
15 | JSON.stringify(pkg, null, 2)
16 | )
17 |
18 | // Call husky to set up the hooks
19 | fork(path.resolve(__dirname, "..", "node_modules", "husky", "lib", "installer", 'bin'), ['install'])
20 |
21 | console.log()
22 | console.log(colors.green("Done!!"))
23 | console.log()
24 |
25 | if (pkg.repository.url.trim()) {
26 | console.log(colors.cyan("Now run:"))
27 | console.log(colors.cyan(" npm install -g semantic-release-cli"))
28 | console.log(colors.cyan(" semantic-release-cli setup"))
29 | console.log()
30 | console.log(
31 | colors.cyan('Important! Answer NO to "Generate travis.yml" question')
32 | )
33 | console.log()
34 | console.log(
35 | colors.gray(
36 | 'Note: Make sure "repository.url" in your package.json is correct before'
37 | )
38 | )
39 | } else {
40 | console.log(
41 | colors.red(
42 | 'First you need to set the "repository.url" property in package.json'
43 | )
44 | )
45 | console.log(colors.cyan("Then run:"))
46 | console.log(colors.cyan(" npm install -g semantic-release-cli"))
47 | console.log(colors.cyan(" semantic-release-cli setup"))
48 | console.log()
49 | console.log(
50 | colors.cyan('Important! Answer NO to "Generate travis.yml" question')
51 | )
52 | }
53 |
54 | console.log()
55 |
--------------------------------------------------------------------------------
/packages/validators/ajv/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "esModuleInterop": true,
4 | "moduleResolution": "node",
5 | "target": "es5",
6 | "module":"es2015",
7 | "lib": ["es2015", "es2016", "es2017", "dom"],
8 | "strict": true,
9 | "sourceMap": true,
10 | "allowSyntheticDefaultImports": true,
11 | "experimentalDecorators": true,
12 | "emitDecoratorMetadata": true
13 | },
14 | "include": [
15 | "src"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/packages/validators/ajv/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "tslint-config-standard",
4 | "tslint-config-prettier"
5 | ]
6 | }
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - packages/**
3 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */
4 |
5 | /* Basic Options */
6 | "incremental": true, /* Enable incremental compilation */
7 | "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9 | // "lib": [], /* Specify library files to be included in the compilation. */
10 | // "allowJs": true, /* Allow javascript files to be compiled. */
11 | // "checkJs": true, /* Report errors in .js files. */
12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */
14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15 | // "sourceMap": true, /* Generates corresponding '.map' file. */
16 | // "outFile": "./", /* Concatenate and emit output to single file. */
17 | // "outDir": "./", /* Redirect output structure to the directory. */
18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19 | // "composite": true, /* Enable project compilation */
20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21 | // "removeComments": true, /* Do not emit comments to output. */
22 | // "noEmit": true, /* Do not emit outputs. */
23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26 |
27 | /* Strict Type-Checking Options */
28 | "strict": true, /* Enable all strict type-checking options. */
29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30 | // "strictNullChecks": true, /* Enable strict null checks. */
31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36 |
37 | /* Additional Checks */
38 | // "noUnusedLocals": true, /* Report errors on unused locals. */
39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42 |
43 | /* Module Resolution Options */
44 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
48 | // "typeRoots": [], /* List of folders to include type definitions from. */
49 | // "types": [], /* Type declaration files to be included in compilation. */
50 | "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
54 |
55 | /* Source Map Options */
56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
60 |
61 | /* Experimental Options */
62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
64 |
65 | /* Advanced Options */
66 | "skipLibCheck": true, /* Skip type checking of declaration files. */
67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
68 | }
69 | }
70 |
--------------------------------------------------------------------------------