@factorialco/rjsf-f0 2.0.0 → 2.2.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/dist/styles.css CHANGED
@@ -8,6 +8,53 @@
8
8
  *
9
9
  * There is deliberately no `all: revert` reset here: unlike the SDK's standalone
10
10
  * stylesheet, this theme renders inside an app that already owns its styles.
11
+ *
12
+ * ── Colour variables ─────────────────────────────────────────────────────────
13
+ * Read f0's NUMBERED scales — `--neutral-50`, `--critical-70`, `--warning-50` —
14
+ * never an `--f1-*` name. f0 names its semantic tokens `f1-foreground-secondary`
15
+ * and so on, but exposes them as Tailwind classes built ON TOP of the numbered
16
+ * scales; there is no `--f1-foreground-secondary` CSS variable to read. Rules
17
+ * here once did, and because every one carried a fallback they failed silently:
18
+ * `var(--f1-foreground-secondary, inherit)` simply resolved to `inherit`, so
19
+ * "secondary" text was never dimmed and the error colour never applied.
20
+ *
21
+ * The mapping, from f0's `packages/core/src/tokens/colors.ts`:
22
+ *
23
+ * f1-foreground -> --neutral-100
24
+ * f1-foreground-secondary -> --neutral-50
25
+ * f1-foreground-critical -> --critical-70
26
+ * f1-border-secondary -> --neutral-20
27
+ * f1-background-secondary -> --neutral-10
28
+ *
29
+ * Every `var()` below still carries f0's light-mode value as its fallback, for
30
+ * the (unsupported) case of rendering without f0's stylesheet. Keep them: they
31
+ * are the reason a missing variable degrades instead of rendering transparent
32
+ * text — but pick the fallback so the rule still LOOKS right, since a wrong
33
+ * variable name can no longer be spotted by the page looking broken.
34
+ *
35
+ * ── Type scale ───────────────────────────────────────────────────────────────
36
+ * f0 REDEFINES Tailwind's scale, shifted one step down. `text-base` is 14px
37
+ * here, where stock Tailwind makes it 16px. Writing `1rem` for "base" is
38
+ * therefore a step too large, and it is the mistake this file already made
39
+ * once: `.rjsf-f0-label` shipped at `text-lg`, rendering a field label larger
40
+ * than the `###` section heading above it.
41
+ *
42
+ * text-xs 0.625rem / 0.75rem
43
+ * text-sm 0.75rem / 1rem
44
+ * text-base 0.875rem / 1.25rem letter-spacing -0.005em <- body, labels, help
45
+ * text-lg 1rem / 1.5rem letter-spacing -0.01em <- headings
46
+ * text-xl 1.125rem / 1.75rem letter-spacing -0.01em
47
+ * text-2xl 1.375rem / 1.75rem letter-spacing -0.01em
48
+ *
49
+ * Take the line-height with the size — f0 pairs a rem value with each step, not
50
+ * a ratio, so `line-height: 1.5` beside a 14px font is 1px off its step.
51
+ * `letter-spacing` needs no declaring: it inherits, f0's container sets the
52
+ * `text-base` value, and it is only ever wrong on a rule whose size is wrong.
53
+ *
54
+ * The values must stay hardcoded — this package cannot use the classes, because
55
+ * the host's Tailwind `content` globs do not include it and the utilities would
56
+ * arrive inert. They just have to be f0's values. `styles.test.ts` fails on a
57
+ * `font-size` that is not one of the steps above.
11
58
  */
12
59
 
13
60
  /*
@@ -28,11 +75,23 @@
28
75
  gap: 0.5rem;
29
76
  }
30
77
 
78
+ /*
79
+ * f0's `label-input`: `text-base font-medium text-f1-foreground-secondary`.
80
+ *
81
+ * This declared `1rem`/`1.5`, which is f0's `text-lg` — a step up, and the
82
+ * whole recipe, so it was written against stock Tailwind where `text-base` is
83
+ * 1rem. It made a field label render LARGER than a `###` section heading above
84
+ * it, which is what flattened the hierarchy on a form.
85
+ *
86
+ * No `letter-spacing` here on purpose: it inherits, f0's container sets
87
+ * `-0.005em`, and at 14px that is already the right value. It was only wrong
88
+ * before because the size was — a 16px label inherited 14px's tracking.
89
+ */
31
90
  .rjsf-f0-label {
32
- font-size: 1rem;
91
+ font-size: 0.875rem;
33
92
  font-weight: 500;
34
- line-height: 1.5;
35
- color: var(--f1-foreground-secondary, inherit);
93
+ line-height: 1.25rem;
94
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
36
95
  }
37
96
 
38
97
  .rjsf-f0-label p,
@@ -44,7 +103,7 @@
44
103
  .rjsf-f0-help,
45
104
  .rjsf-f0-section-description {
46
105
  font-size: 0.875rem;
47
- color: var(--f1-foreground-secondary, inherit);
106
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
48
107
  }
49
108
 
50
109
  /*
@@ -78,9 +137,10 @@
78
137
 
79
138
  .rjsf-f0-errors {
80
139
  margin: 0;
81
- padding-left: 1.1rem;
140
+ /* f0 `5`; 1.1rem was not on the spacing scale. Matches the help lists. */
141
+ padding-left: 1.25rem;
82
142
  font-size: 0.875rem;
83
- color: var(--f1-foreground-critical, #b3261e);
143
+ color: hsl(var(--critical-70, 3 71% 41%));
84
144
  }
85
145
 
86
146
  .rjsf-f0-object,
@@ -186,26 +246,166 @@
186
246
  }
187
247
 
188
248
  /*
189
- * The file widget stays a native `<input type="file">` (f0's file field wants
190
- * an upload hook, the SDK wants `data:` URLs), so unlike every other control it
191
- * gets its box from here rather than from f0. The browse button is drawn as an
192
- * f0 neutral button (md: h-8, 10px radius, 14px/500 text) via
193
- * `::file-selector-button`, using the `--neutral-*` variables f0's stylesheet
194
- * defines — they flip in dark mode. The fallbacks are the light-mode values,
195
- * for the (unsupported) case of rendering without f0's stylesheet.
249
+ * The file control.
250
+ *
251
+ * Unlike every other control this one gets its box from here rather than from
252
+ * f0: f0's file field is driven by an upload hook returning an opaque id, while
253
+ * the SDK exchanges uploads as `data:` URLs and its `accept` is a raw HTML
254
+ * accept string (`.msj`), which f0's `MimeType` allowlist cannot express. So the
255
+ * box is drawn against f0's variables instead — they flip in dark mode, and the
256
+ * fallbacks are the light-mode values for the (unsupported) case of rendering
257
+ * without f0's stylesheet.
196
258
  */
197
259
  .rjsf-f0-file {
260
+ display: flex;
261
+ flex-direction: column;
262
+ gap: 0.5rem;
198
263
  font-size: 0.875rem;
199
- color: var(--f1-foreground-secondary, inherit);
200
264
  }
201
265
 
202
- .rjsf-f0-file:focus-visible {
266
+ /*
267
+ * The dropzone stacks the native input on top of the decorative body, so the
268
+ * platform keeps ownership of click, keyboard and drag-and-drop. `isolation`
269
+ * keeps that stacking out of the host app's z-index space.
270
+ */
271
+ .rjsf-f0-dropzone {
272
+ position: relative;
273
+ isolation: isolate;
274
+ display: flex;
275
+ align-items: center;
276
+ justify-content: center;
277
+ min-height: 6rem;
278
+ padding: 1.25rem 1rem;
279
+ border: 1px dashed hsl(var(--neutral-30, 213 87% 15% / 0.2));
280
+ border-radius: 0.625rem;
281
+ background-color: hsl(var(--neutral-3, 219 88% 17% / 0.02));
282
+ transition:
283
+ border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
284
+ background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
285
+ }
286
+
287
+ .rjsf-f0-dropzone:not([data-disabled]):hover,
288
+ .rjsf-f0-dropzone[data-dragging] {
289
+ border-color: hsl(var(--ring, 184 92% 35%));
290
+ background-color: hsl(var(--neutral-10, 216 89% 18% / 0.06));
291
+ }
292
+
293
+ /*
294
+ * Focus is shown by turning the box's own dashed border into a solid accent
295
+ * one, not by drawing a ring outside it.
296
+ *
297
+ * An `outline` with an offset paints beyond the element — the previous rule
298
+ * bled 4px, twice what f0's own fields do (`ring-1`/`ring-2` at
299
+ * `ring-offset-0`/`1`) — and anything painted outside can be clipped by an
300
+ * ancestor that scrolls or hides its overflow, which is what a dialog body is.
301
+ * Recolouring the border cannot be clipped, because it is inside the box.
302
+ *
303
+ * `focus-within`, not `focus-visible`: the input is the first focusable element
304
+ * in a dialog, so it receives focus programmatically when one opens.
305
+ */
306
+ .rjsf-f0-dropzone:focus-within {
307
+ border-style: solid;
308
+ border-color: hsl(var(--ring, 184 92% 35%));
309
+ }
310
+
311
+ /*
312
+ * Stretched over the whole box and transparent — not `display: none`, which
313
+ * would take the control out of the accessibility tree and off the tab order.
314
+ *
315
+ * `-1px`, not `0`: an absolutely positioned box resolves `inset` against its
316
+ * container's *padding* box, so `inset: 0` stopped inside the 1px border and
317
+ * left a dead ring around the perimeter where a click landed on nothing.
318
+ */
319
+ .rjsf-f0-dropzone-input {
320
+ position: absolute;
321
+ inset: -1px;
322
+ z-index: 1;
323
+ opacity: 0;
324
+ cursor: pointer;
325
+ }
326
+
327
+ .rjsf-f0-dropzone-input:disabled {
328
+ cursor: default;
329
+ }
330
+
331
+ .rjsf-f0-dropzone-body {
332
+ display: flex;
333
+ flex-direction: column;
334
+ align-items: center;
335
+ gap: 0.25rem;
336
+ text-align: center;
337
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
338
+ }
339
+
340
+ .rjsf-f0-dropzone-text {
341
+ font-weight: 500;
342
+ }
343
+
344
+ .rjsf-f0-dropzone-hint {
345
+ font-size: 0.75rem;
346
+ opacity: 0.7;
347
+ }
348
+
349
+ .rjsf-f0-dropzone[data-disabled] .rjsf-f0-dropzone-body {
350
+ opacity: 0.5;
351
+ }
352
+
353
+ /* The picked files, one f0-styled chip per file. */
354
+ .rjsf-f0-files {
355
+ display: flex;
356
+ flex-direction: column;
357
+ gap: 0.25rem;
358
+ margin: 0;
359
+ padding: 0;
360
+ list-style: none;
361
+ }
362
+
363
+ .rjsf-f0-file-chip {
364
+ display: flex;
365
+ align-items: center;
366
+ gap: 0.5rem;
367
+ padding: 0.375rem 0.5rem;
368
+ border: 1px solid hsl(var(--neutral-10, 216 89% 18% / 0.06));
369
+ border-radius: 0.625rem;
370
+ background-color: hsl(var(--neutral-3, 219 88% 17% / 0.02));
371
+ }
372
+
373
+ /* Long names truncate rather than pushing the remove button out of the row. */
374
+ .rjsf-f0-file-name {
375
+ flex: 1;
376
+ min-width: 0;
377
+ overflow: hidden;
378
+ font-weight: 500;
379
+ text-overflow: ellipsis;
380
+ white-space: nowrap;
381
+ }
382
+
383
+ .rjsf-f0-file-size {
384
+ flex-shrink: 0;
385
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
386
+ font-variant-numeric: tabular-nums;
387
+ opacity: 0.7;
388
+ }
389
+
390
+ /*
391
+ * The fallback native input kept by `BaseInputTemplate` for anything still
392
+ * rendering core's `FileWidget`. Its browse button is drawn as an f0 neutral
393
+ * button (md: h-8, 10px radius, 14px/500 text); the "No file chosen" text
394
+ * beside it is browser chrome and cannot be reached from here — which is why
395
+ * the theme's own `FileWidget` above replaces the control outright.
396
+ */
397
+ .rjsf-f0-native-file {
398
+ font-size: 0.875rem;
399
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
400
+ }
401
+
402
+ .rjsf-f0-native-file:focus-visible {
203
403
  outline: 2px solid hsl(var(--ring, 184 92% 35%));
204
404
  outline-offset: 2px;
205
405
  border-radius: 0.625rem;
206
406
  }
207
407
 
208
- .rjsf-f0-file::file-selector-button {
408
+ .rjsf-f0-native-file::file-selector-button {
209
409
  height: 2rem;
210
410
  margin-right: 0.75rem;
211
411
  padding: 0 1rem;
@@ -220,19 +420,19 @@
220
420
  transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
221
421
  }
222
422
 
223
- .rjsf-f0-file:not(:disabled)::file-selector-button:hover {
423
+ .rjsf-f0-native-file:not(:disabled)::file-selector-button:hover {
224
424
  background-color: hsl(var(--neutral-20, 214 70% 20% / 0.1));
225
425
  }
226
426
 
227
- .rjsf-f0-file:disabled::file-selector-button {
427
+ .rjsf-f0-native-file:disabled::file-selector-button {
228
428
  background-color: hsl(var(--neutral-3, 219 88% 17% / 0.02));
229
429
  color: hsl(var(--neutral-30, 213 87% 15% / 0.2));
230
430
  cursor: default;
231
431
  }
232
432
 
233
433
  /*
234
- * The list of picked files, rendered by core's `FileWidget` (its class name is
235
- * core's, so it can only be scoped by nesting under the theme's field row).
434
+ * The list core's `FileWidget` renders under that fallback input (its class
435
+ * name is core's, so it can only be scoped by nesting under the theme's row).
236
436
  */
237
437
  .rjsf-f0-field .file-info {
238
438
  display: flex;
@@ -401,24 +601,154 @@
401
601
  display: flex;
402
602
  flex-direction: column;
403
603
  gap: 0.75rem;
404
- color: var(--f1-foreground, inherit);
604
+ color: hsl(var(--neutral-100, 218 48% 10%));
605
+ }
606
+
607
+ /*
608
+ * A `markdown.before` / `markdown.after` block and the field it belongs to are
609
+ * siblings inside one `.rjsf-f0-row` — `FieldTemplate` returns them as a
610
+ * fragment and `ObjectFieldTemplate` wraps the lot. That row is a plain block
611
+ * box with no gap of its own, so the two rendered flush against each other: a
612
+ * section heading sat directly on top of the control below it, with the 16px
613
+ * field-to-field gap above it and nothing at all beneath.
614
+ *
615
+ * 8px is f0's label-to-control gap (`gap-2`), used here for the same reason: a
616
+ * `before` block introduces the field under it the way a label introduces its
617
+ * control. What communicates the grouping is the ratio, not the number — 16
618
+ * above against 8 below reads as "this belongs to what follows", where 16/0
619
+ * read as one glued lump.
620
+ *
621
+ * Scoped to `.rjsf-f0-row >` rather than set on the class: the submit result
622
+ * message carries `.fcode-form-markdown` too (`fcode-form.tsx`), and it is not
623
+ * a field row — a margin there would be arbitrary.
624
+ *
625
+ * Margins rather than making the row a flex container with a gap: the row is a
626
+ * flex *item* of `.rjsf-f0-object`, so it establishes a block formatting
627
+ * context and these cannot collapse out of it. Changing the row's layout model
628
+ * would touch every field in every form to fix a rule that applies to few.
629
+ */
630
+ .rjsf-f0-row > .fcode-form-markdown:first-child {
631
+ margin-bottom: 0.5rem;
632
+ }
633
+
634
+ .rjsf-f0-row > .fcode-form-markdown:last-child {
635
+ margin-top: 0.5rem;
405
636
  }
406
637
 
407
638
  .fcode-form-markdown p {
408
639
  margin: 0;
409
640
  }
410
641
 
642
+ /*
643
+ * f0 renders `h1`–`h3` itself; `h4`–`h6` arrive as plain tags (see
644
+ * `markdown/markdown-components.ts` for why they are not given renderers) and
645
+ * get the f0 scale here, continuing below f0's `h3` (`text-base`/600) at
646
+ * `text-sm`. The three used to be identical, which flattened every level past
647
+ * `###` into one — the weight and colour steps below are what separates them,
648
+ * since f0 does not shrink headings past the body size.
649
+ */
411
650
  .fcode-form-markdown h4,
412
651
  .fcode-form-markdown h5,
413
652
  .fcode-form-markdown h6 {
414
653
  margin: 0;
415
654
  font-size: 0.875rem;
655
+ /* f0 pairs `text-base` with a 1.25rem line-height, not a 1.5 ratio. */
656
+ line-height: 1.25rem;
657
+ }
658
+
659
+ .fcode-form-markdown h4 {
416
660
  font-weight: 600;
417
- line-height: 1.5;
661
+ }
662
+
663
+ .fcode-form-markdown h5 {
664
+ font-weight: 500;
665
+ }
666
+
667
+ .fcode-form-markdown h6 {
668
+ font-weight: 500;
669
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
418
670
  }
419
671
 
420
672
  .fcode-form-markdown del {
421
- color: var(--f1-foreground-secondary, inherit);
673
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
674
+ }
675
+
676
+ /*
677
+ * The callout a GitHub alert blockquote (`> [!NOTE]`) renders as.
678
+ *
679
+ * Not `F0Alert`: its `title`/`description` are plain strings, so routing a
680
+ * markdown blockquote through it would flatten the body and drop the bold,
681
+ * links and lists an author may put there. This keeps the real markdown
682
+ * children and borrows f0's semantic colour scale instead — `--<variant>-50`
683
+ * tinted for the surface, `--<variant>-70` for the icon, both of which f0's
684
+ * stylesheet flips in dark mode. The fallbacks are f0's light-mode values, for
685
+ * the (unsupported) case of rendering without that stylesheet.
686
+ */
687
+ .rjsf-f0-callout {
688
+ display: flex;
689
+ align-items: flex-start;
690
+ gap: 0.625rem;
691
+ padding: 0.75rem;
692
+ border-radius: 0.625rem;
693
+ font-size: 0.875rem;
694
+ /* f0 pairs `text-base` with a 1.25rem line-height, not a 1.5 ratio. */
695
+ line-height: 1.25rem;
696
+ color: hsl(var(--neutral-100, 218 48% 10%));
697
+ }
698
+
699
+ .rjsf-f0-callout-body {
700
+ display: flex;
701
+ min-width: 0;
702
+ flex: 1;
703
+ flex-direction: column;
704
+ gap: 0.5rem;
705
+ }
706
+
707
+ .rjsf-f0-callout-body > :first-child {
708
+ margin-top: 0;
709
+ }
710
+
711
+ .rjsf-f0-callout-body > :last-child {
712
+ margin-bottom: 0;
713
+ }
714
+
715
+ /* Authored content can carry lists; hosts on Tailwind reset their padding. */
716
+ .rjsf-f0-callout-body ul,
717
+ .rjsf-f0-callout-body ol {
718
+ margin: 0;
719
+ padding-left: 1.25rem;
720
+ }
721
+
722
+ .rjsf-f0-callout[data-variant='info'] {
723
+ background-color: hsl(var(--info-50, 216 90% 65%) / 0.1);
724
+ }
725
+
726
+ .rjsf-f0-callout[data-variant='info'] svg {
727
+ color: hsl(var(--info-70, 216 48% 44%));
728
+ }
729
+
730
+ .rjsf-f0-callout[data-variant='warning'] {
731
+ background-color: hsl(var(--warning-50, 25 95% 53%) / 0.1);
732
+ }
733
+
734
+ .rjsf-f0-callout[data-variant='warning'] svg {
735
+ color: hsl(var(--warning-70, 24 69% 40%));
736
+ }
737
+
738
+ .rjsf-f0-callout[data-variant='critical'] {
739
+ background-color: hsl(var(--critical-50, 5 100% 65%) / 0.1);
740
+ }
741
+
742
+ .rjsf-f0-callout[data-variant='critical'] svg {
743
+ color: hsl(var(--critical-70, 3 71% 41%));
744
+ }
745
+
746
+ .rjsf-f0-callout[data-variant='positive'] {
747
+ background-color: hsl(var(--positive-50, 160 84% 39%) / 0.1);
748
+ }
749
+
750
+ .rjsf-f0-callout[data-variant='positive'] svg {
751
+ color: hsl(var(--positive-70, 161 84% 27%));
422
752
  }
423
753
 
424
754
  .fcode-form-markdown img {
@@ -461,7 +791,8 @@
461
791
  padding: 0.5rem 0.75rem;
462
792
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
463
793
  font-size: 0.875rem;
464
- line-height: 1.5;
794
+ /* f0 pairs `text-base` with a 1.25rem line-height, not a 1.5 ratio. */
795
+ line-height: 1.25rem;
465
796
  white-space: pre;
466
797
  }
467
798
 
@@ -489,3 +820,66 @@
489
820
  pointer-events: none;
490
821
  overflow: hidden;
491
822
  }
823
+
824
+ /*
825
+ * Multistep (`ui:steps`) navigation. Colours and controls come from f0
826
+ * (`F0Button`, `F0TableOfContent`); these rules only lay the pieces out.
827
+ */
828
+
829
+ .rjsf-f0-steps-tabs {
830
+ display: flex;
831
+ flex-wrap: wrap;
832
+ gap: 0.25rem;
833
+ margin-bottom: 1.5rem;
834
+ padding-bottom: 0.5rem;
835
+ border-bottom: 1px solid hsl(var(--neutral-20, 214 70% 20% / 0.1));
836
+ }
837
+
838
+ /* Wraps to a stacked layout on narrow widths via the main column's min-width. */
839
+ .rjsf-f0-steps-layout-sidebar {
840
+ display: flex;
841
+ flex-wrap: wrap;
842
+ gap: 1rem 2rem;
843
+ align-items: flex-start;
844
+ }
845
+
846
+ .rjsf-f0-steps-nav {
847
+ flex: 1 0 13rem;
848
+ max-width: 16rem;
849
+ }
850
+
851
+ .rjsf-f0-steps-layout-sidebar .rjsf-f0-steps-main {
852
+ flex: 1 1 24rem;
853
+ min-width: 0;
854
+ }
855
+
856
+ .rjsf-f0-steps-header {
857
+ margin-bottom: 1rem;
858
+ }
859
+
860
+ .rjsf-f0-steps-title {
861
+ margin: 0 0 0.25rem;
862
+ font-size: 1.125rem;
863
+ font-weight: 600;
864
+ }
865
+
866
+ .rjsf-f0-steps-description {
867
+ margin: 0;
868
+ font-size: 0.875rem;
869
+ color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
870
+ }
871
+
872
+ /*
873
+ * The actions row (rendered by the SDK's step engine) holds Back and
874
+ * Next/Submit; it takes over the submit button's usual top margin.
875
+ */
876
+ .fcode-steps-actions {
877
+ display: flex;
878
+ align-items: center;
879
+ gap: 0.75rem;
880
+ margin-top: 1.5rem;
881
+ }
882
+
883
+ .fcode-steps-actions .rjsf-f0-submit {
884
+ margin-top: 0;
885
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/rjsf-f0",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Factorial f0 theme for react-jsonschema-form: renders RJSF forms with f0 components.",
5
5
  "type": "module",
6
6
  "homepage": "https://code.factorialhr.com/docs/forms/",