datocms-react-ui 0.3.6 → 0.3.10

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 (61) hide show
  1. package/dist/cjs/Button/index.js +65 -4
  2. package/dist/cjs/Button/index.js.map +1 -1
  3. package/dist/cjs/Button/styles.module.css.json +1 -1
  4. package/dist/cjs/Canvas/index.js +487 -7
  5. package/dist/cjs/Canvas/index.js.map +1 -1
  6. package/dist/cjs/Canvas/styles.module.css.json +1 -1
  7. package/dist/cjs/ContextInspector/styles.module.css.json +1 -1
  8. package/dist/cjs/Form/index.js +72 -0
  9. package/dist/cjs/Form/index.js.map +1 -1
  10. package/dist/cjs/Section/index.js +70 -0
  11. package/dist/cjs/Section/index.js.map +1 -0
  12. package/dist/cjs/Section/styles.module.css.json +1 -0
  13. package/dist/cjs/SelectField/index.js +56 -0
  14. package/dist/cjs/SelectField/index.js.map +1 -0
  15. package/dist/cjs/SelectInput/index.js +135 -0
  16. package/dist/cjs/SelectInput/index.js.map +1 -0
  17. package/dist/cjs/SwitchInput/index.js +1 -1
  18. package/dist/cjs/SwitchInput/index.js.map +1 -1
  19. package/dist/cjs/TextInput/styles.module.css.json +1 -1
  20. package/dist/cjs/index.js +3 -0
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/esm/Button/index.d.ts +62 -1
  23. package/dist/esm/Button/index.js +65 -4
  24. package/dist/esm/Button/index.js.map +1 -1
  25. package/dist/esm/Button/styles.module.css.json +1 -1
  26. package/dist/esm/Canvas/index.d.ts +479 -1
  27. package/dist/esm/Canvas/index.js +487 -7
  28. package/dist/esm/Canvas/index.js.map +1 -1
  29. package/dist/esm/Canvas/styles.module.css.json +1 -1
  30. package/dist/esm/ContextInspector/styles.module.css.json +1 -1
  31. package/dist/esm/Form/index.d.ts +72 -0
  32. package/dist/esm/Form/index.js +72 -0
  33. package/dist/esm/Form/index.js.map +1 -1
  34. package/dist/esm/Section/index.d.ts +63 -0
  35. package/dist/esm/Section/index.js +63 -0
  36. package/dist/esm/Section/index.js.map +1 -0
  37. package/dist/esm/Section/styles.module.css.json +1 -0
  38. package/dist/esm/SelectField/index.d.ts +60 -0
  39. package/dist/esm/SelectField/index.js +46 -0
  40. package/dist/esm/SelectField/index.js.map +1 -0
  41. package/dist/esm/SelectInput/index.d.ts +17 -0
  42. package/dist/esm/SelectInput/index.js +106 -0
  43. package/dist/esm/SelectInput/index.js.map +1 -0
  44. package/dist/esm/SwitchInput/index.d.ts +1 -1
  45. package/dist/esm/SwitchInput/index.js +1 -1
  46. package/dist/esm/SwitchInput/index.js.map +1 -1
  47. package/dist/esm/TextInput/styles.module.css.json +1 -1
  48. package/dist/esm/index.d.ts +3 -0
  49. package/dist/esm/index.js +3 -0
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/types/Button/index.d.ts +62 -1
  52. package/dist/types/Canvas/index.d.ts +479 -1
  53. package/dist/types/Form/index.d.ts +72 -0
  54. package/dist/types/Section/index.d.ts +63 -0
  55. package/dist/types/SelectField/index.d.ts +60 -0
  56. package/dist/types/SelectInput/index.d.ts +17 -0
  57. package/dist/types/SwitchInput/index.d.ts +1 -1
  58. package/dist/types/index.d.ts +3 -0
  59. package/package.json +4 -6
  60. package/styles.css +1 -1
  61. package/types.json +1533 -132
@@ -17,6 +17,484 @@ function camelToDash(str) {
17
17
  }
18
18
  return str;
19
19
  }
20
+ /**
21
+ * @example Color variables
22
+ *
23
+ * ```js
24
+ * <Canvas ctx={ctx}>
25
+ * <Section title="Text colors">
26
+ * <table>
27
+ * <tbody>
28
+ * <tr>
29
+ * <td>
30
+ * <code>--base-body-color</code>
31
+ * </td>
32
+ * <td width="30%">
33
+ * <div
34
+ * style={{
35
+ * width: '30px',
36
+ * height: '30px',
37
+ * background: 'var(--base-body-color)',
38
+ * }}
39
+ * />
40
+ * </td>
41
+ * </tr>
42
+ * <tr>
43
+ * <td>
44
+ * <code>--light-body-color</code>
45
+ * </td>
46
+ * <td width="30%">
47
+ * <div
48
+ * style={{
49
+ * width: '30px',
50
+ * height: '30px',
51
+ * background: 'var(--light-body-color)',
52
+ * }}
53
+ * />
54
+ * </td>
55
+ * </tr>
56
+ * <tr>
57
+ * <td>
58
+ * <code>--placeholder-body-color</code>
59
+ * </td>
60
+ * <td width="30%">
61
+ * <div
62
+ * style={{
63
+ * width: '30px',
64
+ * height: '30px',
65
+ * background: 'var(--placeholder-body-color)',
66
+ * }}
67
+ * />
68
+ * </td>
69
+ * </tr>
70
+ * </tbody>
71
+ * </table>
72
+ * </Section>
73
+ * <Section title="UI colors">
74
+ * <table>
75
+ * <tbody>
76
+ * <tr>
77
+ * <td>
78
+ * <code>--light-bg-color</code>
79
+ * </td>
80
+ * <td width="30%">
81
+ * <div
82
+ * style={{
83
+ * width: '30px',
84
+ * height: '30px',
85
+ * background: 'var(--light-bg-color)',
86
+ * }}
87
+ * />
88
+ * </td>
89
+ * </tr>
90
+ * <tr>
91
+ * <td>
92
+ * <code>--lighter-bg-color</code>
93
+ * </td>
94
+ * <td width="30%">
95
+ * <div
96
+ * style={{
97
+ * width: '30px',
98
+ * height: '30px',
99
+ * background: 'var(--lighter-bg-color)',
100
+ * }}
101
+ * />
102
+ * </td>
103
+ * </tr>
104
+ * <tr>
105
+ * <td>
106
+ * <code>--disabled-bg-color</code>
107
+ * </td>
108
+ * <td width="30%">
109
+ * <div
110
+ * style={{
111
+ * width: '30px',
112
+ * height: '30px',
113
+ * background: 'var(--disabled-bg-color)',
114
+ * }}
115
+ * />
116
+ * </td>
117
+ * </tr>
118
+ * <tr>
119
+ * <td>
120
+ * <code>--border-color</code>
121
+ * </td>
122
+ * <td width="30%">
123
+ * <div
124
+ * style={{
125
+ * width: '30px',
126
+ * height: '30px',
127
+ * background: 'var(--border-color)',
128
+ * }}
129
+ * />
130
+ * </td>
131
+ * </tr>
132
+ * <tr>
133
+ * <td>
134
+ * <code>--darker-border-color</code>
135
+ * </td>
136
+ * <td width="30%">
137
+ * <div
138
+ * style={{
139
+ * width: '30px',
140
+ * height: '30px',
141
+ * background: 'var(--darker-border-color)',
142
+ * }}
143
+ * />
144
+ * </td>
145
+ * </tr>
146
+ * <tr>
147
+ * <td>
148
+ * <code>--alert-color</code>
149
+ * </td>
150
+ * <td width="30%">
151
+ * <div
152
+ * style={{
153
+ * width: '30px',
154
+ * height: '30px',
155
+ * background: 'var(--alert-color)',
156
+ * }}
157
+ * />
158
+ * </td>
159
+ * </tr>
160
+ * <tr>
161
+ * <td>
162
+ * <code>--warning-color</code>
163
+ * </td>
164
+ * <td width="30%">
165
+ * <div
166
+ * style={{
167
+ * width: '30px',
168
+ * height: '30px',
169
+ * background: 'var(--warning-color)',
170
+ * }}
171
+ * />
172
+ * </td>
173
+ * </tr>
174
+ * <tr>
175
+ * <td>
176
+ * <code>--notice-color</code>
177
+ * </td>
178
+ * <td width="30%">
179
+ * <div
180
+ * style={{
181
+ * width: '30px',
182
+ * height: '30px',
183
+ * background: 'var(--notice-color)',
184
+ * }}
185
+ * />
186
+ * </td>
187
+ * </tr>
188
+ * <tr>
189
+ * <td>
190
+ * <code>--warning-bg-color</code>
191
+ * </td>
192
+ * <td width="30%">
193
+ * <div
194
+ * style={{
195
+ * width: '30px',
196
+ * height: '30px',
197
+ * background: 'var(--warning-bg-color)',
198
+ * }}
199
+ * />
200
+ * </td>
201
+ * </tr>
202
+ * <tr>
203
+ * <td>
204
+ * <code>--add-color</code>
205
+ * </td>
206
+ * <td width="30%">
207
+ * <div
208
+ * style={{
209
+ * width: '30px',
210
+ * height: '30px',
211
+ * background: 'var(--add-color)',
212
+ * }}
213
+ * />
214
+ * </td>
215
+ * </tr>
216
+ * <tr>
217
+ * <td>
218
+ * <code>--remove-color</code>
219
+ * </td>
220
+ * <td width="30%">
221
+ * <div
222
+ * style={{
223
+ * width: '30px',
224
+ * height: '30px',
225
+ * background: 'var(--remove-color)',
226
+ * }}
227
+ * />
228
+ * </td>
229
+ * </tr>
230
+ * </tbody>
231
+ * </table>
232
+ * </Section>
233
+ * <Section title="Project-specific colors">
234
+ * <table>
235
+ * <tbody>
236
+ * <tr>
237
+ * <td>
238
+ * <code>--accent-color</code>
239
+ * </td>
240
+ * <td width="30%">
241
+ * <div
242
+ * style={{
243
+ * width: '30px',
244
+ * height: '30px',
245
+ * background: 'var(--accent-color)',
246
+ * }}
247
+ * />
248
+ * </td>
249
+ * </tr>
250
+ * <tr>
251
+ * <td>
252
+ * <code>--primary-color</code>
253
+ * </td>
254
+ * <td width="30%">
255
+ * <div
256
+ * style={{
257
+ * width: '30px',
258
+ * height: '30px',
259
+ * background: 'var(--primary-color)',
260
+ * }}
261
+ * />
262
+ * </td>
263
+ * </tr>
264
+ * <tr>
265
+ * <td>
266
+ * <code>--light-color</code>
267
+ * </td>
268
+ * <td width="30%">
269
+ * <div
270
+ * style={{
271
+ * width: '30px',
272
+ * height: '30px',
273
+ * background: 'var(--light-color)',
274
+ * }}
275
+ * />
276
+ * </td>
277
+ * </tr>
278
+ * <tr>
279
+ * <td>
280
+ * <code>--dark-color</code>
281
+ * </td>
282
+ * <td width="30%">
283
+ * <div
284
+ * style={{
285
+ * width: '30px',
286
+ * height: '30px',
287
+ * background: 'var(--dark-color)',
288
+ * }}
289
+ * />
290
+ * </td>
291
+ * </tr>
292
+ * </tbody>
293
+ * </table>
294
+ * </Section>
295
+ * </Canvas>;
296
+ * ```
297
+ *
298
+ * @example Typography variables
299
+ *
300
+ * ```js
301
+ * <Canvas ctx={ctx}>
302
+ * <table>
303
+ * <tbody>
304
+ * <tr>
305
+ * <td>
306
+ * <code>--font-size-xxs</code>
307
+ * </td>
308
+ * <td>
309
+ * <div style={{ fontSize: 'var(--font-size-xxs)' }}>
310
+ * Size XXS
311
+ * </div>
312
+ * </td>
313
+ * </tr>
314
+ * <tr>
315
+ * <td>
316
+ * <code>--font-size-xs</code>
317
+ * </td>
318
+ * <td>
319
+ * <div style={{ fontSize: 'var(--font-size-xs)' }}>Size XS</div>
320
+ * </td>
321
+ * </tr>
322
+ * <tr>
323
+ * <td>
324
+ * <code>--font-size-s</code>
325
+ * </td>
326
+ * <td>
327
+ * <div style={{ fontSize: 'var(--font-size-s)' }}>Size S</div>
328
+ * </td>
329
+ * </tr>
330
+ * <tr>
331
+ * <td>
332
+ * <code>--font-size-m</code>
333
+ * </td>
334
+ * <td>
335
+ * <div style={{ fontSize: 'var(--font-size-m)' }}>Size M</div>
336
+ * </td>
337
+ * </tr>
338
+ * <tr>
339
+ * <td>
340
+ * <code>--font-size-l</code>
341
+ * </td>
342
+ * <td>
343
+ * <div
344
+ * style={{
345
+ * fontSize: 'var(--font-size-l)',
346
+ * fontWeight: 'var(--font-weight-bold)',
347
+ * }}
348
+ * >
349
+ * Size L
350
+ * </div>
351
+ * </td>
352
+ * </tr>
353
+ * <tr>
354
+ * <td>
355
+ * <code>--font-size-xl</code>
356
+ * </td>
357
+ * <td>
358
+ * <div
359
+ * style={{
360
+ * fontSize: 'var(--font-size-xl)',
361
+ * fontWeight: 'var(--font-weight-bold)',
362
+ * }}
363
+ * >
364
+ * Size XL
365
+ * </div>
366
+ * </td>
367
+ * </tr>
368
+ * <tr>
369
+ * <td>
370
+ * <code>--font-size-xxl</code>
371
+ * </td>
372
+ * <td>
373
+ * <div
374
+ * style={{
375
+ * fontSize: 'var(--font-size-xxl)',
376
+ * fontWeight: 'var(--font-weight-bold)',
377
+ * }}
378
+ * >
379
+ * Size XXL
380
+ * </div>
381
+ * </td>
382
+ * </tr>
383
+ * <tr>
384
+ * <td>
385
+ * <code>--font-size-xxxl</code>
386
+ * </td>
387
+ * <td>
388
+ * <div
389
+ * style={{
390
+ * fontSize: 'var(--font-size-xxxl)',
391
+ * fontWeight: 'var(--font-weight-bold)',
392
+ * }}
393
+ * >
394
+ * Size XXXL
395
+ * </div>
396
+ * </td>
397
+ * </tr>
398
+ * </tbody>
399
+ * </table>
400
+ * </Canvas>;
401
+ * ```
402
+ *
403
+ * @example Spacing variables
404
+ *
405
+ * ```js
406
+ * <Canvas ctx={ctx}>
407
+ * <table>
408
+ * <tbody>
409
+ * <tr>
410
+ * <td>
411
+ * <code>--spacing-s</code>
412
+ * </td>
413
+ * <td>
414
+ * <div
415
+ * style={{
416
+ * background: 'var(--accent-color)',
417
+ * width: 'var(--spacing-s)',
418
+ * height: 'var(--spacing-s)',
419
+ * }}
420
+ * />
421
+ * </td>
422
+ * </tr>
423
+ * <tr>
424
+ * <td>
425
+ * <code>--spacing-m</code>
426
+ * </td>
427
+ * <td>
428
+ * <div
429
+ * style={{
430
+ * background: 'var(--accent-color)',
431
+ * width: 'var(--spacing-m)',
432
+ * height: 'var(--spacing-m)',
433
+ * }}
434
+ * />
435
+ * </td>
436
+ * </tr>
437
+ * <tr>
438
+ * <td>
439
+ * <code>--spacing-l</code>
440
+ * </td>
441
+ * <td>
442
+ * <div
443
+ * style={{
444
+ * background: 'var(--accent-color)',
445
+ * width: 'var(--spacing-l)',
446
+ * height: 'var(--spacing-l)',
447
+ * }}
448
+ * />
449
+ * </td>
450
+ * </tr>
451
+ * <tr>
452
+ * <td>
453
+ * <code>--spacing-xl</code>
454
+ * </td>
455
+ * <td>
456
+ * <div
457
+ * style={{
458
+ * background: 'var(--accent-color)',
459
+ * width: 'var(--spacing-xl)',
460
+ * height: 'var(--spacing-xl)',
461
+ * }}
462
+ * />
463
+ * </td>
464
+ * </tr>
465
+ * <tr>
466
+ * <td>
467
+ * <code>--spacing-xxl</code>
468
+ * </td>
469
+ * <td>
470
+ * <div
471
+ * style={{
472
+ * background: 'var(--accent-color)',
473
+ * width: 'var(--spacing-xxl)',
474
+ * height: 'var(--spacing-xxl)',
475
+ * }}
476
+ * />
477
+ * </td>
478
+ * </tr>
479
+ * <tr>
480
+ * <td>
481
+ * <code>--spacing-xxxl</code>
482
+ * </td>
483
+ * <td>
484
+ * <div
485
+ * style={{
486
+ * background: 'var(--accent-color)',
487
+ * width: 'var(--spacing-xxxl)',
488
+ * height: 'var(--spacing-xxxl)',
489
+ * }}
490
+ * />
491
+ * </td>
492
+ * </tr>
493
+ * </tbody>
494
+ * </table>
495
+ * </Canvas>;
496
+ * ```
497
+ */
20
498
  export function Canvas(_a) {
21
499
  var ctx = _a.ctx, children = _a.children, noAutoResizer = _a.noAutoResizer;
22
500
  var mode = ctx.mode;
@@ -29,12 +507,14 @@ export function Canvas(_a) {
29
507
  });
30
508
  }
31
509
  }, [mode, noAutoResizer]);
32
- return (React.createElement("div", { className: styles.canvas, style: Object.entries(ctx.theme).reduce(function (acc, _a) {
33
- var _b;
34
- var k = _a[0], v = _a[1];
35
- return (__assign(__assign({}, acc), (_b = {}, _b["--" + camelToDash(k)] = v, _b)));
36
- }, {
37
- padding: ctx.bodyPadding.map(function (p) { return p + "px"; }).join(' '),
38
- }) }, children));
510
+ var style = Object.entries(ctx.theme).reduce(function (acc, _a) {
511
+ var _b;
512
+ var _c;
513
+ var k = _a[0], v = _a[1];
514
+ return __assign(__assign({}, acc), (_b = {}, _b["--" + camelToDash(k)] = v, _b["--" + camelToDash(k + "RgbComponents")] = ((_c = v.match(/rgb\((\d+, \d+, \d+)\)/)) === null || _c === void 0 ? void 0 : _c[1]) || undefined, _b));
515
+ }, {
516
+ padding: ctx.bodyPadding.map(function (p) { return p + "px"; }).join(' '),
517
+ });
518
+ return (React.createElement("div", { className: styles.canvas, style: style }, children));
39
519
  }
40
520
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Canvas/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAE9C,SAAS,WAAW,CAAC,GAAW;IAC9B,IAAI,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE;QAC5B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAC,CAAC,IAAK,OAAA,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,EAArB,CAA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,IAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAC5C,UAAC,GAAG,EAAE,EAAM;;;YAAL,CAAC,QAAA,EAAE,CAAC,QAAA;QACT,6BACK,GAAG,gBACL,OAAK,WAAW,CAAC,CAAC,CAAG,IAAG,CAAC,KACzB,OAAK,WAAW,CAAI,CAAC,kBAAe,CAAG,IACtC,CAAA,MAAA,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,0CAAG,CAAC,CAAC,KAAI,SAAS,OACrD;IACJ,CAAC,EACD;QACE,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAG,CAAC,OAAI,EAAR,CAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;KACxD,CACF,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IACxC,QAAQ,CACL,CACP,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- { "canvas": "_canvas_1kptt_1" }
1
+ { "canvas": "_canvas_1es76_1" }
@@ -1 +1 @@
1
- { "inspector": "_inspector_1n8fb_1", "panel": "_panel_1n8fb_5", "panelHandle": "_panelHandle_1n8fb_9", "panelBody": "_panelBody_1n8fb_25", "groupDescription": "_groupDescription_1n8fb_31", "propertyGroup": "_propertyGroup_1n8fb_37", "propertyOrMethod": "_propertyOrMethod_1n8fb_42", "propertyOrMethodBody": "_propertyOrMethodBody_1n8fb_51", "propertyOrMethodExample": "_propertyOrMethodExample_1n8fb_55", "propertyOrMethodName": "_propertyOrMethodName_1n8fb_68", "propertyOrMethodExampleActions": "_propertyOrMethodExampleActions_1n8fb_82" }
1
+ { "inspector": "_inspector_u6041_1", "panel": "_panel_u6041_5", "panelHandle": "_panelHandle_u6041_9", "panelBody": "_panelBody_u6041_25", "groupDescription": "_groupDescription_u6041_31", "propertyGroup": "_propertyGroup_u6041_37", "propertyOrMethod": "_propertyOrMethod_u6041_42", "propertyOrMethodBody": "_propertyOrMethodBody_u6041_51", "propertyOrMethodExample": "_propertyOrMethodExample_u6041_55", "propertyOrMethodName": "_propertyOrMethodName_u6041_68", "propertyOrMethodExampleActions": "_propertyOrMethodExampleActions_u6041_82" }
@@ -6,4 +6,76 @@ export interface FormProps {
6
6
  className?: string;
7
7
  children: ReactNode;
8
8
  }
9
+ /**
10
+ * @example Full example
11
+ *
12
+ * ```js
13
+ * <Canvas ctx={ctx}>
14
+ * <Form onSubmit={() => console.log('onSubmit')}>
15
+ * <FieldGroup>
16
+ * <TextField
17
+ * required
18
+ * name="name"
19
+ * id="name"
20
+ * label="Name"
21
+ * value="Mark Smith"
22
+ * placeholder="Enter full name"
23
+ * hint="Provide a full name"
24
+ * onChange={(newValue) => console.log(newValue)}
25
+ * />
26
+ * <TextField
27
+ * required
28
+ * name="email"
29
+ * id="email"
30
+ * label="Email"
31
+ * type="email"
32
+ * value=""
33
+ * placeholder="your@email.com"
34
+ * error="Please enter an email!"
35
+ * hint="Enter email address"
36
+ * onChange={(newValue) => console.log(newValue)}
37
+ * />
38
+ * <TextField
39
+ * required
40
+ * name="apiToken"
41
+ * id="apiToken"
42
+ * label="API Token"
43
+ * value="XXXYYY123"
44
+ * hint="Enter a valid API token"
45
+ * textInputProps={{ monospaced: true }}
46
+ * onChange={(newValue) => console.log(newValue)}
47
+ * />
48
+ * <SelectField
49
+ * name="option"
50
+ * id="option"
51
+ * label="Option"
52
+ * hint="Select one of the options"
53
+ * value={{ label: 'Option 1', value: 'option1' }}
54
+ * selectInputProps={{
55
+ * options: [
56
+ * { label: 'Option 1', value: 'option1' },
57
+ * { label: 'Option 2', value: 'option2' },
58
+ * { label: 'Option 3', value: 'option3' },
59
+ * ],
60
+ * }}
61
+ * onChange={(newValue) => console.log(newValue)}
62
+ * />
63
+ * <SwitchField
64
+ * name="debugMode"
65
+ * id="debugMode"
66
+ * label="Debug mode active?"
67
+ * hint="Logs messages to console"
68
+ * value={true}
69
+ * onChange={(newValue) => console.log(newValue)}
70
+ * />
71
+ * </FieldGroup>
72
+ * <FieldGroup>
73
+ * <Button fullWidth buttonType="primary">
74
+ * Submit
75
+ * </Button>
76
+ * </FieldGroup>
77
+ * </Form>
78
+ * </Canvas>;
79
+ * ```
80
+ */
9
81
  export declare const Form: ({ children, className, onSubmit, spacing, ...otherProps }: FormProps) => JSX.Element;
@@ -23,6 +23,78 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import React, { Children, useCallback, } from 'react';
24
24
  import cn from 'classnames';
25
25
  import styles from './styles.module.css.json';
26
+ /**
27
+ * @example Full example
28
+ *
29
+ * ```js
30
+ * <Canvas ctx={ctx}>
31
+ * <Form onSubmit={() => console.log('onSubmit')}>
32
+ * <FieldGroup>
33
+ * <TextField
34
+ * required
35
+ * name="name"
36
+ * id="name"
37
+ * label="Name"
38
+ * value="Mark Smith"
39
+ * placeholder="Enter full name"
40
+ * hint="Provide a full name"
41
+ * onChange={(newValue) => console.log(newValue)}
42
+ * />
43
+ * <TextField
44
+ * required
45
+ * name="email"
46
+ * id="email"
47
+ * label="Email"
48
+ * type="email"
49
+ * value=""
50
+ * placeholder="your@email.com"
51
+ * error="Please enter an email!"
52
+ * hint="Enter email address"
53
+ * onChange={(newValue) => console.log(newValue)}
54
+ * />
55
+ * <TextField
56
+ * required
57
+ * name="apiToken"
58
+ * id="apiToken"
59
+ * label="API Token"
60
+ * value="XXXYYY123"
61
+ * hint="Enter a valid API token"
62
+ * textInputProps={{ monospaced: true }}
63
+ * onChange={(newValue) => console.log(newValue)}
64
+ * />
65
+ * <SelectField
66
+ * name="option"
67
+ * id="option"
68
+ * label="Option"
69
+ * hint="Select one of the options"
70
+ * value={{ label: 'Option 1', value: 'option1' }}
71
+ * selectInputProps={{
72
+ * options: [
73
+ * { label: 'Option 1', value: 'option1' },
74
+ * { label: 'Option 2', value: 'option2' },
75
+ * { label: 'Option 3', value: 'option3' },
76
+ * ],
77
+ * }}
78
+ * onChange={(newValue) => console.log(newValue)}
79
+ * />
80
+ * <SwitchField
81
+ * name="debugMode"
82
+ * id="debugMode"
83
+ * label="Debug mode active?"
84
+ * hint="Logs messages to console"
85
+ * value={true}
86
+ * onChange={(newValue) => console.log(newValue)}
87
+ * />
88
+ * </FieldGroup>
89
+ * <FieldGroup>
90
+ * <Button fullWidth buttonType="primary">
91
+ * Submit
92
+ * </Button>
93
+ * </FieldGroup>
94
+ * </Form>
95
+ * </Canvas>;
96
+ * ```
97
+ */
26
98
  export var Form = function (_a) {
27
99
  var children = _a.children, className = _a.className, onSubmit = _a.onSubmit, _b = _a.spacing, spacing = _b === void 0 ? 'default' : _b, otherProps = __rest(_a, ["children", "className", "onSubmit", "spacing"]);
28
100
  var classNames = cn(styles.Form, className);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Form/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,WAAW,GAKZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAU9C,MAAM,CAAC,IAAM,IAAI,GAAG,UAAC,EAMT;IALV,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,eAAmB,EAAnB,OAAO,mBAAG,SAAS,KAAA,EAChB,UAAU,cALM,gDAMpB,CADc;IAEb,IAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAE9C,IAAM,kBAAkB,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,iBAAe,OAAS,CAAC,CAAC,CAAC;IAEnF,IAAM,YAAY,GAAG,WAAW,CAC9B,UAAC,KAAgB;QACf,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,QAAQ,EAAE;YAC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