@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.
- package/LICENSE +202 -0
- package/README.md +26 -0
- package/dist/custom-elements-jsx.d.ts +76 -0
- package/dist/custom-elements-vue.d.ts +15 -0
- package/dist/custom-elements.json +560 -0
- package/dist/data.snippets.json +1 -0
- package/dist/examples/csv.examples.js +6 -0
- package/dist/examples/csv.examples.js.map +1 -0
- package/dist/examples/csv.examples.json +17 -0
- package/dist/examples/light.examples.js +6 -0
- package/dist/examples/light.examples.js.map +1 -0
- package/dist/examples/light.examples.json +27 -0
- package/dist/examples/simple.examples.js +6 -0
- package/dist/examples/simple.examples.js.map +1 -0
- package/dist/examples/simple.examples.json +27 -0
- package/dist/examples/visualization.examples.js +6 -0
- package/dist/examples/visualization.examples.js.map +1 -0
- package/dist/examples/visualization.examples.json +25 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/errors.d.ts +3 -0
- package/dist/internal/errors.js +10 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/schema.d.ts +9 -0
- package/dist/internal/schema.js +98 -0
- package/dist/internal/schema.js.map +1 -0
- package/dist/internal/types.d.ts +77 -0
- package/dist/internal/utils.d.ts +1 -0
- package/dist/internal/utils.js +10 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/mixin/index.d.ts +453 -0
- package/dist/mixin/index.js +182 -0
- package/dist/mixin/index.js.map +1 -0
- package/dist/validators/index.d.ts +18 -0
- package/dist/validators/index.js +22 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +228 -0
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "/src/index.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "variable",
|
|
11
|
+
"name": "VERSION",
|
|
12
|
+
"type": {
|
|
13
|
+
"text": "string"
|
|
14
|
+
},
|
|
15
|
+
"default": "'0.0.0'"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"exports": [
|
|
19
|
+
{
|
|
20
|
+
"kind": "js",
|
|
21
|
+
"name": "VERSION",
|
|
22
|
+
"declaration": {
|
|
23
|
+
"name": "VERSION",
|
|
24
|
+
"module": "/src/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"kind": "js",
|
|
29
|
+
"name": "*",
|
|
30
|
+
"declaration": {
|
|
31
|
+
"name": "*",
|
|
32
|
+
"module": "Users/crylan/dev/github-migration/repos/elements-github/projects/forms/src/internal/types.js"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"kind": "javascript-module",
|
|
39
|
+
"path": "/src/internal/errors.js",
|
|
40
|
+
"declarations": [
|
|
41
|
+
{
|
|
42
|
+
"kind": "class",
|
|
43
|
+
"description": "",
|
|
44
|
+
"name": "FormControlError",
|
|
45
|
+
"members": [
|
|
46
|
+
{
|
|
47
|
+
"kind": "field",
|
|
48
|
+
"name": "name",
|
|
49
|
+
"type": {
|
|
50
|
+
"text": "string",
|
|
51
|
+
"_sourceAliases": [],
|
|
52
|
+
"values": [
|
|
53
|
+
{
|
|
54
|
+
"value": "string",
|
|
55
|
+
"description": ""
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"default": "'FormControlError'"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"superclass": {
|
|
63
|
+
"name": "Error",
|
|
64
|
+
"module": "/src/internal/errors.js"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"exports": [
|
|
69
|
+
{
|
|
70
|
+
"kind": "js",
|
|
71
|
+
"name": "FormControlError",
|
|
72
|
+
"declaration": {
|
|
73
|
+
"name": "FormControlError",
|
|
74
|
+
"module": "/src/internal/errors.js"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"kind": "javascript-module",
|
|
81
|
+
"path": "/src/internal/schema.js",
|
|
82
|
+
"declarations": [
|
|
83
|
+
{
|
|
84
|
+
"kind": "function",
|
|
85
|
+
"name": "parseValueSchema",
|
|
86
|
+
"return": {
|
|
87
|
+
"type": {
|
|
88
|
+
"text": "T"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"parameters": [
|
|
92
|
+
{
|
|
93
|
+
"name": "formControlName",
|
|
94
|
+
"type": {
|
|
95
|
+
"text": "string",
|
|
96
|
+
"_sourceAliases": []
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "value",
|
|
101
|
+
"type": {
|
|
102
|
+
"text": "string",
|
|
103
|
+
"_sourceAliases": []
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "schema",
|
|
108
|
+
"type": {
|
|
109
|
+
"text": "StringSchema | NumberSchema | BooleanSchema | ArraySchema | ObjectSchema | EnumSchema",
|
|
110
|
+
"_sourceAliases": [
|
|
111
|
+
"Schema"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"kind": "function",
|
|
119
|
+
"name": "validateSchema",
|
|
120
|
+
"return": {
|
|
121
|
+
"type": {
|
|
122
|
+
"text": "ValidationResult"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"parameters": [
|
|
126
|
+
{
|
|
127
|
+
"name": "schema",
|
|
128
|
+
"type": {
|
|
129
|
+
"text": "StringSchema | NumberSchema | BooleanSchema | ArraySchema | ObjectSchema | EnumSchema",
|
|
130
|
+
"_sourceAliases": [
|
|
131
|
+
"Schema"
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "value",
|
|
137
|
+
"type": {
|
|
138
|
+
"text": "unknown",
|
|
139
|
+
"_sourceAliases": []
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"kind": "function",
|
|
146
|
+
"name": "parseControlValue",
|
|
147
|
+
"return": {
|
|
148
|
+
"type": {
|
|
149
|
+
"text": "T | undefined"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"parameters": [
|
|
153
|
+
{
|
|
154
|
+
"name": "value",
|
|
155
|
+
"type": {
|
|
156
|
+
"text": "string",
|
|
157
|
+
"_sourceAliases": []
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "schema",
|
|
162
|
+
"type": {
|
|
163
|
+
"text": "StringSchema | NumberSchema | BooleanSchema | ArraySchema | ObjectSchema | EnumSchema",
|
|
164
|
+
"_sourceAliases": [
|
|
165
|
+
"Schema"
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"exports": [
|
|
173
|
+
{
|
|
174
|
+
"kind": "js",
|
|
175
|
+
"name": "parseValueSchema",
|
|
176
|
+
"declaration": {
|
|
177
|
+
"name": "parseValueSchema",
|
|
178
|
+
"module": "/src/internal/schema.js"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"kind": "js",
|
|
183
|
+
"name": "validateSchema",
|
|
184
|
+
"declaration": {
|
|
185
|
+
"name": "validateSchema",
|
|
186
|
+
"module": "/src/internal/schema.js"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"kind": "js",
|
|
191
|
+
"name": "parseControlValue",
|
|
192
|
+
"declaration": {
|
|
193
|
+
"name": "parseControlValue",
|
|
194
|
+
"module": "/src/internal/schema.js"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"kind": "javascript-module",
|
|
201
|
+
"path": "/src/internal/types.js",
|
|
202
|
+
"declarations": [],
|
|
203
|
+
"exports": []
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"kind": "javascript-module",
|
|
207
|
+
"path": "/src/internal/utils.js",
|
|
208
|
+
"declarations": [
|
|
209
|
+
{
|
|
210
|
+
"kind": "function",
|
|
211
|
+
"name": "isObjectLiteral",
|
|
212
|
+
"parameters": [
|
|
213
|
+
{
|
|
214
|
+
"name": "item",
|
|
215
|
+
"type": {
|
|
216
|
+
"text": "unknown",
|
|
217
|
+
"_sourceAliases": []
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"exports": [
|
|
224
|
+
{
|
|
225
|
+
"kind": "js",
|
|
226
|
+
"name": "isObjectLiteral",
|
|
227
|
+
"declaration": {
|
|
228
|
+
"name": "isObjectLiteral",
|
|
229
|
+
"module": "/src/internal/utils.js"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"kind": "javascript-module",
|
|
236
|
+
"path": "/src/mixin/index.js",
|
|
237
|
+
"declarations": [
|
|
238
|
+
{
|
|
239
|
+
"kind": "mixin",
|
|
240
|
+
"description": "",
|
|
241
|
+
"name": "FormControlMixin",
|
|
242
|
+
"members": [
|
|
243
|
+
{
|
|
244
|
+
"kind": "field",
|
|
245
|
+
"name": "formAssociated",
|
|
246
|
+
"type": {
|
|
247
|
+
"text": "boolean"
|
|
248
|
+
},
|
|
249
|
+
"static": true,
|
|
250
|
+
"default": "true"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"kind": "field",
|
|
254
|
+
"name": "metadata",
|
|
255
|
+
"type": {
|
|
256
|
+
"text": "FormControlMetadata"
|
|
257
|
+
},
|
|
258
|
+
"static": true
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"kind": "field",
|
|
262
|
+
"name": "readOnly",
|
|
263
|
+
"type": {
|
|
264
|
+
"text": "boolean"
|
|
265
|
+
},
|
|
266
|
+
"description": "determine if component is in readonly/non-editable state"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"kind": "field",
|
|
270
|
+
"name": "disabled",
|
|
271
|
+
"type": {
|
|
272
|
+
"text": "boolean"
|
|
273
|
+
},
|
|
274
|
+
"description": "determine if component is in disabled state"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"kind": "field",
|
|
278
|
+
"name": "required",
|
|
279
|
+
"type": {
|
|
280
|
+
"text": "boolean"
|
|
281
|
+
},
|
|
282
|
+
"description": "determine if the component value requires input"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"kind": "field",
|
|
286
|
+
"name": "name",
|
|
287
|
+
"description": "name associated to parent form"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"kind": "field",
|
|
291
|
+
"name": "noValidate",
|
|
292
|
+
"type": {
|
|
293
|
+
"text": "boolean"
|
|
294
|
+
},
|
|
295
|
+
"description": "set determine if component is in no validation state"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"kind": "field",
|
|
299
|
+
"name": "value",
|
|
300
|
+
"description": "value state of the component",
|
|
301
|
+
"type": {
|
|
302
|
+
"text": "T | undefined"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"kind": "method",
|
|
307
|
+
"name": "updateValue",
|
|
308
|
+
"parameters": [
|
|
309
|
+
{
|
|
310
|
+
"name": "value",
|
|
311
|
+
"type": {
|
|
312
|
+
"text": "T"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
"privacy": "protected"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"kind": "field",
|
|
320
|
+
"name": "form",
|
|
321
|
+
"description": "associated parent form",
|
|
322
|
+
"readonly": true
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"kind": "field",
|
|
326
|
+
"name": "willValidate",
|
|
327
|
+
"description": "determine if the component is a candidate for constraint checking",
|
|
328
|
+
"readonly": true
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"kind": "field",
|
|
332
|
+
"name": "validity",
|
|
333
|
+
"description": "validity state of the component",
|
|
334
|
+
"readonly": true
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"kind": "field",
|
|
338
|
+
"name": "validationMessage",
|
|
339
|
+
"description": "validation message of the component",
|
|
340
|
+
"readonly": true
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"kind": "field",
|
|
344
|
+
"name": "valueAsString",
|
|
345
|
+
"description": "stringified value of the component",
|
|
346
|
+
"readonly": true
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"kind": "field",
|
|
350
|
+
"name": "valueAsNumber",
|
|
351
|
+
"type": {
|
|
352
|
+
"text": "number"
|
|
353
|
+
},
|
|
354
|
+
"description": "parsed number value of the component"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"kind": "field",
|
|
358
|
+
"name": "type",
|
|
359
|
+
"readonly": true
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"kind": "field",
|
|
363
|
+
"name": "_internals",
|
|
364
|
+
"privacy": "protected",
|
|
365
|
+
"readonly": true
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"kind": "method",
|
|
369
|
+
"name": "formResetCallback",
|
|
370
|
+
"privacy": "protected"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"kind": "method",
|
|
374
|
+
"name": "formStateRestoreCallback",
|
|
375
|
+
"parameters": [
|
|
376
|
+
{
|
|
377
|
+
"name": "state",
|
|
378
|
+
"type": {
|
|
379
|
+
"text": "T"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"name": "_reason",
|
|
384
|
+
"type": {
|
|
385
|
+
"text": "string"
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
"privacy": "protected"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"kind": "method",
|
|
393
|
+
"name": "reportValidity",
|
|
394
|
+
"description": "report validity of the component"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"kind": "method",
|
|
398
|
+
"name": "checkValidity",
|
|
399
|
+
"description": "check validity of the component"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"kind": "method",
|
|
403
|
+
"name": "setValidity",
|
|
404
|
+
"parameters": [
|
|
405
|
+
{
|
|
406
|
+
"name": "validity",
|
|
407
|
+
"type": {
|
|
408
|
+
"text": "Partial<ValidityState>"
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"name": "message",
|
|
413
|
+
"optional": true,
|
|
414
|
+
"type": {
|
|
415
|
+
"text": "string"
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
"privacy": "protected"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"kind": "method",
|
|
423
|
+
"name": "dispatchInputEvent",
|
|
424
|
+
"privacy": "protected"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"kind": "method",
|
|
428
|
+
"name": "dispatchChangeEvent",
|
|
429
|
+
"privacy": "protected"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"kind": "method",
|
|
433
|
+
"name": "dispatchUpdateEvent",
|
|
434
|
+
"parameters": [
|
|
435
|
+
{
|
|
436
|
+
"name": "type",
|
|
437
|
+
"type": {
|
|
438
|
+
"text": "'input' | 'change'"
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
],
|
|
442
|
+
"privacy": "protected"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"kind": "field",
|
|
446
|
+
"name": "_initialValue"
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
"events": [
|
|
450
|
+
{
|
|
451
|
+
"name": "input",
|
|
452
|
+
"type": {
|
|
453
|
+
"text": "InputEvent"
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"name": "change",
|
|
458
|
+
"type": {
|
|
459
|
+
"text": "Event"
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
],
|
|
463
|
+
"parameters": [
|
|
464
|
+
{
|
|
465
|
+
"name": "SuperClass",
|
|
466
|
+
"type": {
|
|
467
|
+
"text": "TBase"
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
]
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
"exports": [
|
|
474
|
+
{
|
|
475
|
+
"kind": "js",
|
|
476
|
+
"name": "FormControlMixin",
|
|
477
|
+
"declaration": {
|
|
478
|
+
"name": "FormControlMixin",
|
|
479
|
+
"module": "/src/mixin/index.js"
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"kind": "javascript-module",
|
|
486
|
+
"path": "/src/validators/index.js",
|
|
487
|
+
"declarations": [
|
|
488
|
+
{
|
|
489
|
+
"kind": "function",
|
|
490
|
+
"name": "valueSchemaValidator",
|
|
491
|
+
"return": {
|
|
492
|
+
"type": {
|
|
493
|
+
"text": "ValidatorResult"
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
"parameters": [
|
|
497
|
+
{
|
|
498
|
+
"name": "value",
|
|
499
|
+
"type": {
|
|
500
|
+
"text": "unknown",
|
|
501
|
+
"_sourceAliases": []
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
"name": "element",
|
|
506
|
+
"type": {
|
|
507
|
+
"text": "FormControl",
|
|
508
|
+
"_sourceAliases": []
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
],
|
|
512
|
+
"description": "Given a json schema, check the value against the schema\nJSON Schema follows the OpenAI JSON Schema for structured outputs\nhttps://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"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"kind": "function",
|
|
516
|
+
"name": "requiredValidator",
|
|
517
|
+
"return": {
|
|
518
|
+
"type": {
|
|
519
|
+
"text": "ValidatorResult"
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
"parameters": [
|
|
523
|
+
{
|
|
524
|
+
"name": "value",
|
|
525
|
+
"type": {
|
|
526
|
+
"text": "unknown",
|
|
527
|
+
"_sourceAliases": []
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"name": "element",
|
|
532
|
+
"type": {
|
|
533
|
+
"text": "FormControl",
|
|
534
|
+
"_sourceAliases": []
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
],
|
|
540
|
+
"exports": [
|
|
541
|
+
{
|
|
542
|
+
"kind": "js",
|
|
543
|
+
"name": "valueSchemaValidator",
|
|
544
|
+
"declaration": {
|
|
545
|
+
"name": "valueSchemaValidator",
|
|
546
|
+
"module": "/src/validators/index.js"
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"kind": "js",
|
|
551
|
+
"name": "requiredValidator",
|
|
552
|
+
"declaration": {
|
|
553
|
+
"name": "requiredValidator",
|
|
554
|
+
"module": "/src/validators/index.js"
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
]
|
|
558
|
+
}
|
|
559
|
+
]
|
|
560
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv.examples.js","names":["#getCSV"],"sources":["../../src/examples/csv.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html, LitElement, nothing } from 'lit';\nimport type { ValidatorResult } from '@nvidia-elements/forms';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixin';\nimport '@nvidia-elements/core/textarea/define.js';\nimport '@nvidia-elements/core/dropdown/define.js';\nimport '@nvidia-elements/core/checkbox/define.js';\nimport '@nvidia-elements/core/grid/define.js';\nimport './csv.examples.js';\n\nexport default {\n title: 'Labs/Forms/Examples',\n component: ['forms']\n};\n\n/**\n * @summary CSV grid form control with input validation and editable textarea.\n * @tags test-case\n */\nexport const CSV = {\n render: () => html`\n <style>\n ui-csv-grid:invalid {\n outline: 2px dashed red;\n }\n </style>\n <form nve-layout=\"grid span:6 gap:lg pad:lg align:stretch align:center\" style=\"min-width: 1000px;\">\n <nve-textarea style=\"width: max-content\">\n <label>CSV</label>\n <textarea name=\"input\" rows=\"20\" cols=\"50\">${csv}</textarea>\n </nve-textarea>\n <nve-divider orientation=\"vertical\"></nve-divider>\n <ui-csv-grid name=\"csv\"></ui-csv-grid>\n </form>\n <script type=\"module\">\n const form = document.querySelector('form');\n form.elements.csv.value = form.elements.input.value;\n form.addEventListener('input', (e) => {\n form.elements.csv.value = form.elements.input.value;\n });\n </script>\n `\n};\n\nconst csv = `\nresource_id,cpu_usage_percent,memory_usage_gb,storage_used_tb,network_traffic_gb\ninstance-001,45.2,8.5,2.3,156.7\ninstance-002,78.9,12.3,4.1,289.4\ninstance-003,23.4,4.2,1.5,89.3\ninstance-004,92.1,16.7,5.8,412.6\ninstance-005,34.7,6.8,2.9,178.2\ninstance-006,67.8,10.1,3.7,256.9\ninstance-007,12.5,2.9,0.8,45.6\ninstance-008,88.3,14.5,4.9,378.1\ninstance-009,56.4,9.2,3.2,198.5\ninstance-010,41.2,7.6,2.5,167.8`.trim();\n\nexport type CSVValue = string;\n\nexport class CSVExample extends FormControlMixin<typeof LitElement, CSVValue>(LitElement) {\n static readonly metadata = {\n tag: 'ui-csv-grid',\n version: '0.0.0',\n validators: [csvStringValidator],\n valueSchema: {\n type: 'string' as const\n },\n };\n\n static styles = [\n css`:host {\n display: block;\n width: 100%;\n }`\n ];\n\n get #getCSV() {\n const rows = this.value!.trim().split('\\n');\n return {\n columns: rows[0]!.split(','),\n rows: rows.slice(1).map(row => row.split(','))\n };\n }\n\n render() {\n return this.value\n ? html`\n <nve-grid>\n <nve-grid-header>\n ${this.#getCSV.columns.map(column => html`<nve-grid-column>${column}</nve-grid-column>`)}\n </nve-grid-header>\n ${this.#getCSV.rows.map(row => html`<nve-grid-row>${row.map(cell => html`<nve-grid-cell>${cell}</nve-grid-cell>`)}</nve-grid-row>`)}\n </nve-grid>\n `\n : nothing;\n }\n}\n\ncustomElements.get('ui-csv-grid') || customElements.define('ui-csv-grid', CSVExample);\n\nfunction csvStringValidator(value: unknown): ValidatorResult {\n const message = isValidCSV(value as string);\n if (message !== true) {\n return { validity: { badInput: true }, message };\n } else {\n return { validity: {} };\n }\n}\n\nfunction hasUnclosedQuotes(line: string): boolean {\n let inQuotes = false;\n for (let j = 0; j < line.length; j++) {\n if (line[j] === '\"' && !(j > 0 && line[j - 1] === '\\\\')) {\n inQuotes = !inQuotes;\n }\n }\n return inQuotes;\n}\n\nfunction countColumns(line: string): number {\n return (line.match(/,/g) || []).length + 1;\n}\n\nfunction validateLine(line: string, expectedColumns: number): true | string {\n if (hasUnclosedQuotes(line)) {\n return 'csv contains unclosed quotes';\n }\n\n if (countColumns(line) !== expectedColumns) {\n return 'csv contains invalid column count';\n }\n\n return true;\n}\n\nfunction isValidCSV(csvString: string): true | string {\n if (!csvString || csvString.trim().length === 0) {\n return 'empty';\n }\n\n const lines = csvString.split('\\n');\n const columnCount = countColumns(lines[0]!);\n\n for (const line of lines) {\n if (line.trim().length === 0) {\n continue;\n }\n\n const result = validateLine(line, columnCount);\n if (result !== true) {\n return result;\n }\n }\n\n return true;\n}\n"],"mappings":";AAGA,IAAA,IAAc"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"element": "[forms]",
|
|
3
|
+
"entrypoint": "@nvidia-elements/forms/examples/csv.examples.json",
|
|
4
|
+
"items": [
|
|
5
|
+
{
|
|
6
|
+
"id": "forms-examples-csv_csv",
|
|
7
|
+
"name": "CSV",
|
|
8
|
+
"template": "<style>\n ui-csv-grid:invalid {\n outline: 2px dashed red;\n }\n</style>\n<form nve-layout=\"grid span:6 gap:lg pad:lg align:stretch align:center\" style=\"min-width: 1000px\">\n <nve-textarea style=\"width: max-content\">\n <label>CSV</label>\n <textarea name=\"input\" rows=\"20\" cols=\"50\">${csv}</textarea>\n </nve-textarea>\n <nve-divider orientation=\"vertical\"></nve-divider>\n <ui-csv-grid name=\"csv\"></ui-csv-grid>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n form.elements.csv.value = form.elements.input.value;\n form.addEventListener(\"input\", (e) => {\n form.elements.csv.value = form.elements.input.value;\n });\n</script>\n",
|
|
9
|
+
"summary": "CSV grid form control with input validation and editable textarea.",
|
|
10
|
+
"description": "",
|
|
11
|
+
"composition": false,
|
|
12
|
+
"tags": [
|
|
13
|
+
"test-case"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.examples.js","names":["#updateValue"],"sources":["../../src/examples/light.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement, nothing, unsafeCSS } from 'lit';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixin';\nimport './light.examples.js';\n\nexport default {\n title: 'Labs/Forms/Examples'\n};\n\n/**\n * @summary Light card form control with toggle and dim range inputs.\n * @tags test-case\n */\nexport const CardToggle = {\n render: () => html`\n<form nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card value='{\"status\": \"on\", \"dim\": 75}' name=\"office-light\"></ui-light-card>\n <pre id=\"light-card-value\"></pre>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector('form');\n const pre = document.querySelector('#light-card-value');\n const lightCard = document.querySelector('ui-light-card[name=\"office-light\"]');\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n\n form.addEventListener('change', (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log('change', e.target.value, Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener('input', (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log('input', e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n`\n};\n\n/**\n * @summary Light card form events including submit, reset, and invalid state handling.\n * @tags test-case\n */\nexport const Events = {\n render: () => html`\n<form id=\"novalidate-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card novalidate name=\"novalidate-light\" value='{\"status\": \"on\", \"dim\": 75}'></ui-light-card>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n </div>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector('#novalidate-form');\n const pre = form.querySelector('pre');\n const button = form.querySelector('button');\n const light = form.querySelector('[name=\"novalidate-light\"]');\n pre.textContent = JSON.stringify(light.value, null, 2);\n\n button.addEventListener('click', () => {\n light.value = { status: 'invalid', dim: -1 };\n });\n\n form.addEventListener('change', (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('change', e.target.value);\n });\n\n form.addEventListener('input', (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('input', e.target.value);\n });\n\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('submit', Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener('reset', (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('reset', Object.fromEntries(new FormData(form)));\n });\n });\n\n light.addEventListener('invalid', (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('invalid', Object.fromEntries(new FormData(form)));\n });\n</script>\n`\n};\n\nconst styles = /* css */ `\n:host,\n*,\n*:before,\n*:after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n max-width: 240px;\n}\n\n:host(:invalid) {\n outline: 2px dashed red;\n}\n\nform {\n position: relative;\n min-width: 50px;\n min-height: 50px;\n display: flex;\n align-items: center;\n gap: var(--nve-ref-space-xs);\n background: var(--nve-sys-interaction-background-200);\n padding: var(--nve-ref-size-300);\n border-radius: var(--nve-ref-border-radius-lg);\n}\n\nnve-icon {\n position: absolute;\n top: 16px;\n left: 16px;\n pointer-events: none;\n z-index: 99;\n}\n\ninput[name='status'] {\n opacity: 0;\n height: 20px;\n width: 20px;\n}\n`;\n\nexport interface LightCardValue {\n status: 'off' | 'on';\n dim: number;\n}\n\n/**\n * Custom element integrating the FormControlMixin with LitElement for form validation.\n */\nexport class LightCard extends FormControlMixin<typeof LitElement, LightCardValue>(LitElement) {\n static readonly metadata = {\n tag: 'ui-light-card',\n version: '0.0.0',\n strict: false,\n valueSchema: {\n type: 'object' as const,\n properties: {\n status: {\n type: 'enum' as const,\n enum: ['off', 'on']\n },\n dim: {\n type: 'number' as const,\n minimum: 0,\n maximum: 100\n }\n },\n required: ['status', 'dim']\n }\n };\n\n static styles = unsafeCSS(styles);\n\n render() {\n return this.value\n ? html`\n <form @input=${this.#updateValue} @change=${this.#updateValue}>\n <nve-icon size=\"lg\" name=\"lightbulb\" style=\"--color: ${this.value.status === 'on' ? 'var(--nve-ref-color-yellow-nova-900)' : 'initial'}; opacity: ${this.value.status === 'on' ? this.value.dim / 100 + 0.3 : 0.5};\"></nve-icon>\n ${\n this.readOnly\n ? nothing\n : html`\n <input type=\"checkbox\" name=\"status\" .checked=${this.value.status === 'on'} ?disabled=${this.readOnly} aria-label=\"Light Status\">\n <input type=\"range\" name=\"dim\" .valueAsNumber=${this.value.dim} ?disabled=${this.readOnly} min=${LightCard.metadata.valueSchema.properties.dim.minimum ?? 0} max=${LightCard.metadata.valueSchema.properties.dim.maximum ?? 100} aria-label=\"Light Dim\">\n `\n }\n </form>`\n : nothing;\n }\n\n constructor() {\n super();\n this.value = { status: 'off', dim: 50 };\n }\n\n #updateValue(event: Event) {\n const form = this.shadowRoot?.querySelector('form') as HTMLFormElement;\n this.value = { status: form.status.checked ? 'on' : 'off', dim: form.dim.valueAsNumber };\n this.dispatchUpdateEvent(event.type as 'input' | 'change');\n }\n}\n\ncustomElements.get('ui-light-card') ?? customElements.define('ui-light-card', LightCard);"],"mappings":";AAGA,IAAA,IAAe"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entrypoint": "@nvidia-elements/forms/examples/light.examples.json",
|
|
3
|
+
"items": [
|
|
4
|
+
{
|
|
5
|
+
"id": "forms-examples-light_card-toggle",
|
|
6
|
+
"name": "CardToggle",
|
|
7
|
+
"template": "<form nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card value='{\"status\": \"on\", \"dim\": 75}' name=\"office-light\"></ui-light-card>\n <pre id=\"light-card-value\"></pre>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n const pre = document.querySelector(\"#light-card-value\");\n const lightCard = document.querySelector('ui-light-card[name=\"office-light\"]');\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log(\"change\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log(\"input\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
8
|
+
"summary": "Light card form control with toggle and dim range inputs.",
|
|
9
|
+
"description": "",
|
|
10
|
+
"composition": false,
|
|
11
|
+
"tags": [
|
|
12
|
+
"test-case"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "forms-examples-light_events",
|
|
17
|
+
"name": "Events",
|
|
18
|
+
"template": "<form id=\"novalidate-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card novalidate name=\"novalidate-light\" value='{\"status\": \"on\", \"dim\": 75}'></ui-light-card>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n </div>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"#novalidate-form\");\n const pre = form.querySelector(\"pre\");\n const button = form.querySelector(\"button\");\n const light = form.querySelector('[name=\"novalidate-light\"]');\n pre.textContent = JSON.stringify(light.value, null, 2);\n button.addEventListener(\"click\", () => {\n light.value = { status: \"invalid\", dim: -1 };\n });\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"change\", e.target.value);\n });\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"input\", e.target.value);\n });\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"submit\", Object.fromEntries(new FormData(form)));\n });\n form.addEventListener(\"reset\", (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"reset\", Object.fromEntries(new FormData(form)));\n });\n });\n light.addEventListener(\"invalid\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"invalid\", Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
19
|
+
"summary": "Light card form events including submit, reset, and invalid state handling.",
|
|
20
|
+
"description": "",
|
|
21
|
+
"composition": false,
|
|
22
|
+
"tags": [
|
|
23
|
+
"test-case"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|