@nvidia-elements/forms 0.0.0

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.
Files changed (38) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +26 -0
  3. package/dist/custom-elements-jsx.d.ts +76 -0
  4. package/dist/custom-elements-vue.d.ts +15 -0
  5. package/dist/custom-elements.json +560 -0
  6. package/dist/data.snippets.json +1 -0
  7. package/dist/examples/csv.examples.js +6 -0
  8. package/dist/examples/csv.examples.js.map +1 -0
  9. package/dist/examples/csv.examples.json +17 -0
  10. package/dist/examples/light.examples.js +6 -0
  11. package/dist/examples/light.examples.js.map +1 -0
  12. package/dist/examples/light.examples.json +27 -0
  13. package/dist/examples/simple.examples.js +6 -0
  14. package/dist/examples/simple.examples.js.map +1 -0
  15. package/dist/examples/simple.examples.json +27 -0
  16. package/dist/examples/visualization.examples.js +6 -0
  17. package/dist/examples/visualization.examples.js.map +1 -0
  18. package/dist/examples/visualization.examples.json +25 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +6 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/internal/errors.d.ts +3 -0
  23. package/dist/internal/errors.js +10 -0
  24. package/dist/internal/errors.js.map +1 -0
  25. package/dist/internal/schema.d.ts +9 -0
  26. package/dist/internal/schema.js +98 -0
  27. package/dist/internal/schema.js.map +1 -0
  28. package/dist/internal/types.d.ts +77 -0
  29. package/dist/internal/utils.d.ts +1 -0
  30. package/dist/internal/utils.js +10 -0
  31. package/dist/internal/utils.js.map +1 -0
  32. package/dist/mixin/index.d.ts +453 -0
  33. package/dist/mixin/index.js +182 -0
  34. package/dist/mixin/index.js.map +1 -0
  35. package/dist/validators/index.d.ts +18 -0
  36. package/dist/validators/index.js +22 -0
  37. package/dist/validators/index.js.map +1 -0
  38. package/package.json +228 -0
@@ -0,0 +1,18 @@
1
+ import { FormControl, ValidatorResult } from '../internal/types.js';
2
+ /**
3
+ * Given a json schema, check the value against the schema
4
+ * JSON Schema follows the OpenAI JSON Schema for structured outputs
5
+ * https://platform.openai.com/docs/guides/structured-outputs
6
+ *
7
+ * - All fields or function parameters must specify required
8
+ * - Require additionalProperties: false on all objects
9
+ * - Structured Outputs support the following types:
10
+ * - String
11
+ * - Number
12
+ * - Boolean
13
+ * - Object
14
+ * - Array
15
+ * - Enum
16
+ */
17
+ export declare function valueSchemaValidator(value: unknown, element: FormControl): ValidatorResult;
18
+ export declare function requiredValidator(value: unknown, element: FormControl): ValidatorResult;
@@ -0,0 +1,22 @@
1
+ import { validateSchema as e } from "../internal/schema.js";
2
+ //#region src/validators/index.ts
3
+ function t(t, n) {
4
+ let r = n.constructor.metadata;
5
+ return e(r.valueSchema, t);
6
+ }
7
+ function n(e, t) {
8
+ return t.required && (e == null || e === "") ? {
9
+ validity: {
10
+ valueMissing: !0,
11
+ valid: !1
12
+ },
13
+ message: "This field is required"
14
+ } : {
15
+ validity: { valid: !0 },
16
+ message: ""
17
+ };
18
+ }
19
+ //#endregion
20
+ export { n as requiredValidator, t as valueSchemaValidator };
21
+
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/validators/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { validateSchema } from '../internal/schema.js';\nimport type { FormControl, ValidatorResult } from '../internal/types.js';\n\n/**\n * Given a json schema, check the value against the schema\n * JSON Schema follows the OpenAI JSON Schema for structured outputs\n * https://platform.openai.com/docs/guides/structured-outputs\n *\n * - All fields or function parameters must specify required\n * - Require additionalProperties: false on all objects\n * - Structured Outputs support the following types:\n * - String\n * - Number\n * - Boolean\n * - Object\n * - Array\n * - Enum\n */\nexport function valueSchemaValidator(value: unknown, element: FormControl): ValidatorResult {\n const metadata = (element as any).constructor.metadata; // eslint-disable-line @typescript-eslint/no-explicit-any\n return validateSchema(metadata.valueSchema, value);\n}\n\nexport function requiredValidator(value: unknown, element: FormControl): ValidatorResult {\n if (\n (element as unknown as { required: boolean }).required &&\n (value === undefined || value === null || value === '')\n ) {\n return { validity: { valueMissing: true, valid: false }, message: 'This field is required' };\n }\n return { validity: { valid: true }, message: '' };\n}\n"],"mappings":";;AAqBA,SAAgB,EAAqB,GAAgB,GAAuC;CAC1F,IAAM,IAAY,EAAgB,YAAY;AAC9C,QAAO,EAAe,EAAS,aAAa,EAAM;;AAGpD,SAAgB,EAAkB,GAAgB,GAAuC;AAOvF,QALG,EAA6C,aAC7C,KAAiC,QAAQ,MAAU,MAE7C;EAAE,UAAU;GAAE,cAAc;GAAM,OAAO;GAAO;EAAE,SAAS;EAA0B,GAEvF;EAAE,UAAU,EAAE,OAAO,IAAM;EAAE,SAAS;EAAI"}
package/package.json ADDED
@@ -0,0 +1,228 @@
1
+ {
2
+ "name": "@nvidia-elements/forms",
3
+ "version": "0.0.0",
4
+ "release": {
5
+ "extends": "../../release.config.js"
6
+ },
7
+ "description": "Form control utilities and validation providing mixins, validators, and schema-based validation. Includes form association, event handling, and support for complex data types.",
8
+ "homepage": "https://NVIDIA.github.io/elements/",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/NVIDIA/elements.git"
12
+ },
13
+ "type": "module",
14
+ "customElements": "dist/custom-elements.json",
15
+ "contributes": {
16
+ "html": {
17
+ "customData": [
18
+ "./dist/data.html.json"
19
+ ]
20
+ },
21
+ "snippets": [
22
+ {
23
+ "language": "html",
24
+ "path": "./dist/data.snippets.json"
25
+ }
26
+ ]
27
+ },
28
+ "files": [
29
+ "README.md",
30
+ "package.json",
31
+ "dist/**/*"
32
+ ],
33
+ "exports": {
34
+ "./package.json": "./package.json",
35
+ "./custom-elements.json": "./dist/custom-elements.json",
36
+ "./*.examples.json": "./dist/*.examples.json",
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./index.js": {
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.js"
44
+ },
45
+ "./mixin": {
46
+ "types": "./dist/mixin/index.d.ts",
47
+ "default": "./dist/mixin/index.js"
48
+ },
49
+ "./mixin/index.js": {
50
+ "types": "./dist/mixin/index.d.ts",
51
+ "default": "./dist/mixin/index.js"
52
+ },
53
+ "./validators": {
54
+ "types": "./dist/validators/index.d.ts",
55
+ "default": "./dist/validators/index.js"
56
+ },
57
+ "./validators/index.js": {
58
+ "types": "./dist/validators/index.d.ts",
59
+ "default": "./dist/validators/index.js"
60
+ }
61
+ },
62
+ "sideEffects": [],
63
+ "dependencies": {
64
+ "lit": "^3.3.2"
65
+ },
66
+ "devDependencies": {
67
+ "@eslint/js": "9.39.2",
68
+ "@vitest/browser": "4.1.0",
69
+ "@vitest/coverage-istanbul": "4.1.0",
70
+ "axe-core": "4.11.0",
71
+ "eslint": "9.39.2",
72
+ "publint": "0.3.15",
73
+ "typescript": "6.0.2",
74
+ "vite": "8.0.0",
75
+ "vitest": "4.1.0",
76
+ "@internals/vite": "0.0.0",
77
+ "@nvidia-elements/styles": "0.0.0",
78
+ "@internals/testing": "0.0.0",
79
+ "@internals/eslint": "0.0.0",
80
+ "@nvidia-elements/lint": "0.0.0"
81
+ },
82
+ "wireit": {
83
+ "dev": {
84
+ "command": "NODE_ENV=development vite build --watch",
85
+ "service": true
86
+ },
87
+ "ci": {
88
+ "dependencies": [
89
+ "build",
90
+ "lint",
91
+ "publint",
92
+ "test:coverage"
93
+ ]
94
+ },
95
+ "publint": {
96
+ "command": "publint",
97
+ "dependencies": [
98
+ "build"
99
+ ],
100
+ "files": [
101
+ "package.json"
102
+ ],
103
+ "output": []
104
+ },
105
+ "build": {
106
+ "command": "NODE_ENV=production vite build",
107
+ "files": [
108
+ "src/**",
109
+ "!src/**/*.examples.ts",
110
+ "!src/**/*.test.ts",
111
+ "!src/**/*.test.lighthouse.ts",
112
+ "!src/**/*.test.axe.ts",
113
+ "!src/**/*.test.ssr.ts",
114
+ "!src/**/__screenshots__/**",
115
+ "package.json",
116
+ "tsconfig.json",
117
+ "tsconfig.lib.json",
118
+ "vite.config.ts"
119
+ ],
120
+ "output": [
121
+ "dist/**"
122
+ ],
123
+ "dependencies": [
124
+ "../internals/vite:ci"
125
+ ]
126
+ },
127
+ "build:watch": {
128
+ "command": "vite build --watch",
129
+ "service": true,
130
+ "dependencies": [
131
+ "build"
132
+ ]
133
+ },
134
+ "test": {
135
+ "command": "vitest run",
136
+ "files": [
137
+ "src/**",
138
+ "!src/**/*.test.axe.ts",
139
+ "!src/**/*.test.lighthouse.ts",
140
+ "!src/**/*.test.ssr.ts",
141
+ "!src/**/*.test.visual.ts",
142
+ "!src/**/__screenshots__/**",
143
+ "tsconfig.json",
144
+ "vite.config.ts",
145
+ "vitest.config.ts"
146
+ ],
147
+ "output": [],
148
+ "dependencies": [
149
+ "../internals/testing:build",
150
+ "../internals/vite:ci",
151
+ "../core:build"
152
+ ]
153
+ },
154
+ "test:coverage": {
155
+ "command": "vitest run --coverage",
156
+ "files": [
157
+ "src/**",
158
+ "!src/**/*.test.axe.ts",
159
+ "!src/**/*.test.lighthouse.ts",
160
+ "!src/**/*.test.ssr.ts",
161
+ "!src/**/*.test.visual.ts",
162
+ "!src/**/__screenshots__/**",
163
+ "tsconfig.json",
164
+ "vite.config.ts",
165
+ "vitest.config.ts"
166
+ ],
167
+ "output": [],
168
+ "dependencies": [
169
+ "../internals/testing:build",
170
+ "../internals/vite:ci",
171
+ "../core:build"
172
+ ]
173
+ },
174
+ "test:watch": {
175
+ "command": "vitest --watch",
176
+ "service": true
177
+ },
178
+ "test:lighthouse": {
179
+ "command": "playwright-lock 'vitest run --config=vitest.lighthouse.ts'",
180
+ "files": [
181
+ "src/index.test.lighthouse.ts",
182
+ "src/**/*.test.lighthouse.ts",
183
+ "vitest.lighthouse.html",
184
+ "vitest.lighthouse.ts"
185
+ ],
186
+ "output": [
187
+ ".lighthouse"
188
+ ],
189
+ "dependencies": [
190
+ "build",
191
+ "../internals/vite:ci"
192
+ ],
193
+ "env": {
194
+ "NODE_ENV": "production"
195
+ }
196
+ },
197
+ "lint": {
198
+ "command": "eslint -c ./eslint.config.js --color --cache --cache-location .eslintcache/",
199
+ "files": [
200
+ "src/**/*.ts",
201
+ "eslint.config.js"
202
+ ],
203
+ "output": [],
204
+ "dependencies": [
205
+ "../internals/eslint:ci",
206
+ "../lint:build"
207
+ ]
208
+ },
209
+ "lint:fix": {
210
+ "command": "eslint -c ./eslint.config.js --fix",
211
+ "dependencies": [
212
+ "../internals/eslint:ci",
213
+ "../lint:build"
214
+ ]
215
+ }
216
+ },
217
+ "scripts": {
218
+ "ci": "wireit",
219
+ "dev": "wireit",
220
+ "build": "wireit",
221
+ "build:watch": "wireit",
222
+ "lint": "wireit",
223
+ "test": "wireit",
224
+ "test:coverage": "wireit",
225
+ "test:watch": "wireit",
226
+ "test:lighthouse": "wireit"
227
+ }
228
+ }