vanjs-jsf 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,79 @@
1
- .jsf-hidden { display: none; }
2
-
3
- .jsf-dropzone {
4
- border: 2px dashed #ccc;
5
- border-radius: 8px;
6
- padding: 24px;
7
- text-align: center;
8
- cursor: pointer;
9
- transition: border-color 0.2s;
10
- }
11
- .jsf-dropzone-active {
12
- border-color: #4a90d9;
13
- background: #f0f7ff;
14
- }
15
- .jsf-dropzone-text {
16
- margin: 0;
17
- color: #666;
18
- }
19
- .jsf-file-info {
20
- margin-top: 8px;
21
- display: flex;
22
- align-items: center;
23
- gap: 8px;
24
- }
25
- .jsf-file-size {
26
- color: #888;
27
- }
28
- .jsf-file-clear {
29
- cursor: pointer;
30
- background: none;
31
- border: 1px solid #ccc;
32
- border-radius: 4px;
33
- padding: 2px 8px;
34
- font-size: 0.85em;
35
- }
36
- .jsf-file-clear:hover {
37
- background: #f0f0f0;
38
- }
39
- .jsf-file-reading {
40
- margin-top: 8px;
41
- color: #666;
42
- }
1
+ .jsf-hidden { display: none; }
2
+
3
+ .jsf-dropzone {
4
+ border: 2px dashed #ccc;
5
+ border-radius: 8px;
6
+ padding: 24px;
7
+ text-align: center;
8
+ cursor: pointer;
9
+ transition: border-color 0.2s;
10
+ }
11
+ .jsf-dropzone-active {
12
+ border-color: #4a90d9;
13
+ background: #f0f7ff;
14
+ }
15
+ .jsf-dropzone-text {
16
+ margin: 0;
17
+ color: #666;
18
+ }
19
+ .jsf-file-info {
20
+ margin-top: 8px;
21
+ display: flex;
22
+ align-items: center;
23
+ gap: 8px;
24
+ }
25
+ .jsf-file-size {
26
+ color: #888;
27
+ }
28
+ .jsf-file-clear {
29
+ cursor: pointer;
30
+ background: none;
31
+ border: 1px solid #ccc;
32
+ border-radius: 4px;
33
+ padding: 2px 8px;
34
+ font-size: 0.85em;
35
+ }
36
+ .jsf-file-clear:hover {
37
+ background: #f0f0f0;
38
+ }
39
+ .jsf-file-reading {
40
+ margin-top: 8px;
41
+ color: #666;
42
+ }
43
+
44
+ /* Array field (repeatable list of scalar items) */
45
+ .jsf-array-items {
46
+ display: flex;
47
+ flex-direction: column;
48
+ gap: 6px;
49
+ }
50
+ .jsf-array-row {
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 6px;
54
+ }
55
+ .jsf-array-remove {
56
+ cursor: pointer;
57
+ background: none;
58
+ border: 1px solid #ccc;
59
+ border-radius: 4px;
60
+ padding: 2px 8px;
61
+ }
62
+ .jsf-array-remove:hover:not(:disabled) {
63
+ background: #f0f0f0;
64
+ }
65
+ .jsf-array-remove:disabled {
66
+ opacity: 0.4;
67
+ cursor: not-allowed;
68
+ }
69
+ .jsf-array-add {
70
+ margin-top: 6px;
71
+ cursor: pointer;
72
+ background: none;
73
+ border: 1px solid #ccc;
74
+ border-radius: 4px;
75
+ padding: 4px 10px;
76
+ }
77
+ .jsf-array-add:hover {
78
+ background: #f0f0f0;
79
+ }
package/dist/theme.d.ts CHANGED
@@ -12,6 +12,10 @@ export interface JsfTheme {
12
12
  radioInput?: string;
13
13
  fieldset?: string;
14
14
  legend?: string;
15
+ arrayItems?: string;
16
+ arrayRow?: string;
17
+ arrayAddButton?: string;
18
+ arrayRemoveButton?: string;
15
19
  dropZone?: string;
16
20
  dropZoneActive?: string;
17
21
  dropZoneText?: string;
package/dist/theme.js CHANGED
@@ -1,2 +1,3 @@
1
1
  /** Resolve a class: field class > theme class > empty string */
2
2
  export const resolve = (fieldClass, themeClass) => fieldClass || themeClass || "";
3
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../lib/theme.ts"],"names":[],"mappings":"AA6CA,gEAAgE;AAChE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,UAA8B,EAAE,UAA8B,EAAU,EAAE,CAChG,UAAU,IAAI,UAAU,IAAI,EAAE,CAAC","sourcesContent":["export interface JsfTheme {\n // Structure\n container?: string;\n label?: string;\n description?: string;\n error?: string;\n\n // Inputs\n input?: string;\n textarea?: string;\n select?: string;\n option?: string;\n\n // Radio\n radioGroup?: string;\n radioLabel?: string;\n radioInput?: string;\n\n // Fieldset\n fieldset?: string;\n legend?: string;\n\n // Array (repeatable list of scalar items)\n arrayItems?: string;\n arrayRow?: string;\n arrayAddButton?: string;\n arrayRemoveButton?: string;\n\n // File upload\n dropZone?: string;\n dropZoneActive?: string;\n dropZoneText?: string;\n fileInfoBar?: string;\n fileName?: string;\n fileSize?: string;\n fileClearButton?: string;\n fileReading?: string;\n\n // Required\n requiredIndicator?: string;\n}\n\n/** Maps field names to extra CSS classes for their container div */\nexport type JsfLayout = Record<string, string>;\n\n/** Resolve a class: field class > theme class > empty string */\nexport const resolve = (fieldClass: string | undefined, themeClass: string | undefined): string =>\n fieldClass || themeClass || \"\";\n"]}
package/package.json CHANGED
@@ -1,56 +1,53 @@
1
- {
2
- "name": "vanjs-jsf",
3
- "description": "A JSON Schema Form UI Library for VanJS",
4
- "keywords": [
5
- "vanjs",
6
- "json",
7
- "schema",
8
- "form",
9
- "ui-library"
10
- ],
11
- "version": "0.4.0",
12
- "author": {
13
- "name": "Carlos Prados",
14
- "email": "carlos.prados@gmail.com"
15
- },
16
- "license": "Apache-2.0",
17
- "main": "./dist/index.js",
18
- "module": "./dist/index.js",
19
- "types": "./dist/index.d.ts",
20
- "type": "module",
21
- "files": [
22
- "dist",
23
- "README.md"
24
- ],
25
- "scripts": {
26
- "build": "node build.js",
27
- "types": "tsc",
28
- "dev": "vite",
29
- "lint": "eslint lib/",
30
- "lint:fix": "eslint lib/ --fix"
31
- },
32
- "peerDependencies": {
33
- "esbuild": "^0.25.0",
34
- "typescript": "^5.7.3"
35
- },
36
- "dependencies": {
37
- "@codemirror/lang-javascript": "^6.2.3",
38
- "@codemirror/lang-json": "^6.0.1",
39
- "@remoteoss/json-schema-form": "^0.11.9-beta.0",
40
- "codemirror": "^6.0.1",
41
- "codemirror-json5": "^1.0.3",
42
- "eslint-linter-browserify": "^9.20.1",
43
- "eslint4b-prebuilt": "^6.7.2",
44
- "globals": "^15.15.0",
45
- "pikaday": "^1.8.2",
46
- "vanjs-core": "^1.5.3",
47
- "vanjs-ext": "^0.6.2"
48
- },
49
- "devDependencies": {
50
- "@eslint/js": "^10.0.1",
51
- "@types/pikaday": "^1.7.9",
52
- "eslint": "^10.2.0",
53
- "typescript-eslint": "^8.58.0",
54
- "vite": "^6.0.9"
55
- }
56
- }
1
+ {
2
+ "name": "vanjs-jsf",
3
+ "description": "A JSON Schema Form UI Library for VanJS",
4
+ "keywords": [
5
+ "vanjs",
6
+ "json",
7
+ "schema",
8
+ "form",
9
+ "ui-library"
10
+ ],
11
+ "version": "0.5.1",
12
+ "author": {
13
+ "name": "Carlos Prados",
14
+ "email": "carlos.prados@gmail.com"
15
+ },
16
+ "license": "Apache-2.0",
17
+ "main": "./dist/index.js",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "type": "module",
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.build.json && cp lib/jsf-defaults.css dist/jsf-defaults.css",
27
+ "dev": "vite",
28
+ "lint": "eslint lib/",
29
+ "lint:fix": "eslint lib/ --fix"
30
+ },
31
+ "peerDependencies": {
32
+ "typescript": "^5.7.3"
33
+ },
34
+ "dependencies": {
35
+ "@codemirror/lang-javascript": "^6.2.3",
36
+ "@codemirror/lang-json": "^6.0.1",
37
+ "@codemirror/lint": "^6.0.0",
38
+ "@remoteoss/json-schema-form": "^0.11.9-beta.0",
39
+ "codemirror": "^6.0.1",
40
+ "eslint-linter-browserify": "^9.20.1",
41
+ "globals": "^17.0.0",
42
+ "pikaday": "^1.8.2",
43
+ "thememirror": "^2.0.1",
44
+ "vanjs-core": "^1.5.3"
45
+ },
46
+ "devDependencies": {
47
+ "@eslint/js": "^10.0.1",
48
+ "@types/pikaday": "^1.7.9",
49
+ "eslint": "^10.2.0",
50
+ "typescript-eslint": "^8.58.0",
51
+ "vite": "^6.0.9"
52
+ }
53
+ }
package/dist/main.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/main.js DELETED
@@ -1,78 +0,0 @@
1
- import van from "vanjs-core";
2
- import { jsform } from "./index";
3
- const { div, p, h1, button } = van.tags;
4
- const jsonSchemaDemo = {
5
- type: "object",
6
- additionalProperties: false,
7
- properties: {
8
- has_pet: {
9
- title: "Has Pet",
10
- description: "Do you have a pet?",
11
- oneOf: [
12
- { title: "Yes", const: "yes" },
13
- { title: "No", const: "no" },
14
- ],
15
- "x-jsf-presentation": { inputType: "radio" },
16
- type: "string",
17
- },
18
- pet_name: {
19
- title: "Pet's name",
20
- description: "What's your pet's name?",
21
- "x-jsf-presentation": { inputType: "text" },
22
- type: "string",
23
- },
24
- pet_age: {
25
- title: "Pet's age",
26
- description: "What's your pet's age? With more than 5 years, we need to know more about your pet.",
27
- "x-jsf-presentation": { inputType: "number" },
28
- type: "number",
29
- default: 1,
30
- },
31
- dietary_needs: {
32
- title: "Dietary needs",
33
- description: "What are your pet's dietary needs?",
34
- "x-jsf-presentation": { inputType: "textarea", rows: 15, columns: 50 },
35
- type: "string",
36
- },
37
- },
38
- required: ["has_pet"],
39
- "x-jsf-order": ["has_pet", "pet_name", "pet_age", "dietary_needs"],
40
- allOf: [
41
- {
42
- if: { properties: { has_pet: { const: "yes" } }, required: ["has_pet"] },
43
- then: { required: ["pet_age", "pet_name"] },
44
- else: { properties: { pet_age: false, pet_name: false } },
45
- },
46
- {
47
- if: {
48
- properties: { has_pet: { const: "yes" }, pet_age: { minimum: 5 } },
49
- required: ["pet_age"],
50
- },
51
- then: { required: ["dietary_needs"] },
52
- else: { properties: { dietary_needs: false } },
53
- },
54
- ],
55
- };
56
- // App
57
- const App = () => {
58
- const initialValues = { pet_name: "Simon" };
59
- const jsfConfig = {
60
- strictInputType: false,
61
- initialValues: initialValues,
62
- formValues: initialValues,
63
- };
64
- const handleOnSubmit = (e) => {
65
- e.preventDefault();
66
- const values = jsfConfig.formValues;
67
- alert(`Submitted successfully: ${JSON.stringify(values, null, 2)}`);
68
- console.log("Submitted!", values);
69
- };
70
- return div(h1("json-schema-form + VanJS"), p("This demo uses VanJS without any other form library."), jsform({
71
- name: "my-jsf-form",
72
- schema: jsonSchemaDemo,
73
- config: jsfConfig,
74
- onsubmit: handleOnSubmit,
75
- }, button({ type: "submit" }, "Submit")));
76
- };
77
- // Render the app
78
- van.add(document.body, App());