@factorialco/rjsf-f0 1.1.2 → 2.1.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.
@@ -1,2 +1,5 @@
1
1
  export { default as Form, generateForm } from './form';
2
2
  export { Templates, Theme, Widgets, generateTheme } from './theme';
3
+ export type { F0RjsfTheme } from './theme';
4
+ export { Multistep } from './multistep';
5
+ export { markdownComponents } from './markdown/markdown-components';
@@ -0,0 +1,2 @@
1
+ import { Options as ReactMarkdownOptions } from 'react-markdown';
2
+ export declare const markdownComponents: ReactMarkdownOptions["components"];
@@ -0,0 +1,8 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ import { StepBackButtonProps } from './types';
3
+ /**
4
+ * Sits inside the <form> next to the submit button, and F0Button renders a
5
+ * `<button>` with no explicit `type` — i.e. a submit button — so the click
6
+ * must prevent the default or going back would post the form.
7
+ */
8
+ export declare const StepBackButton: ({ label, onClick, disabled, }: StepBackButtonProps) => React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const Multistep: {
2
+ StepsNavigation: ({ layout, items, currentIndex, onNavigate, children, }: import('./types').StepsNavigationProps) => import("react").JSX.Element;
3
+ BackButton: ({ label, onClick, disabled, }: import('./types').StepBackButtonProps) => import("react").JSX.Element;
4
+ };
5
+ export type { StepBackButtonProps, StepsLayout, StepsNavigationItem, StepsNavigationProps, StepStatus, } from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ import { StepsNavigationProps } from './types';
3
+ export declare const StepsNavigation: ({ layout, items, currentIndex, onNavigate, children, }: StepsNavigationProps) => React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ /**
3
+ * Structural copies of the multistep contract in
4
+ * `@factorialco/fcode-react-forms` (`FcodeJsonSchemaForm`'s `rjsfTheme.multistep`).
5
+ * This package does not depend on that one, so the types are duplicated here;
6
+ * TypeScript's structural typing keeps them interchangeable.
7
+ */
8
+ export type StepsLayout = 'tabs' | 'sidebar';
9
+ export type StepStatus = 'completed' | 'current' | 'upcoming';
10
+ export interface StepsNavigationItem {
11
+ index: number;
12
+ title: string;
13
+ description?: string;
14
+ status: StepStatus;
15
+ clickable: boolean;
16
+ hasErrors: boolean;
17
+ }
18
+ export interface StepsNavigationProps {
19
+ layout: StepsLayout;
20
+ items: StepsNavigationItem[];
21
+ currentIndex: number;
22
+ onNavigate: (index: number) => void;
23
+ children: React.ReactNode;
24
+ }
25
+ export interface StepBackButtonProps {
26
+ label: string;
27
+ onClick: () => void;
28
+ disabled?: boolean;
29
+ }
@@ -1,5 +1,11 @@
1
1
  import { default as React } from '../../node_modules/@types/react';
2
2
  import { IconButtonProps, SubmitButtonProps, TemplatesType } from '@rjsf/utils';
3
+ /**
4
+ * `F0Button` renders a `<button>` without an explicit `type`, which inside a
5
+ * `<form>` means "submit". Every button that is not the submit button therefore
6
+ * has to stop the event itself.
7
+ */
8
+ export declare function useNonSubmittingClick(onClick: IconButtonProps['onClick']): (event: React.MouseEvent<HTMLElement>) => void;
3
9
  export declare function CopyButton(props: IconButtonProps): React.JSX.Element;
4
10
  export declare function MoveUpButton(props: IconButtonProps): React.JSX.Element;
5
11
  export declare function MoveDownButton(props: IconButtonProps): React.JSX.Element;
@@ -8,8 +8,7 @@ import { FieldTemplateProps } from '@rjsf/utils';
8
8
  * therefore hide the f0 label and keep the plain text only as the control's
9
9
  * accessible name.
10
10
  *
11
- * `schema.rawHtml.before/after` is a Factorial Code schema extension that lets a
12
- * form author wrap a field in their own markup; it is sanitized before render
13
- * and simply absent for schemas that do not use it.
11
+ * `schema.markdown.before/after` is a Factorial Code schema extension that lets
12
+ * a form author put markdown content around a field; HTML is never rendered.
14
13
  */
15
14
  export declare function FieldTemplate(props: FieldTemplateProps): React.JSX.Element;
@@ -4,6 +4,7 @@ import { DescriptionFieldTemplate, ErrorListTemplate, FieldErrorTemplate, FieldH
4
4
  import { ArrayFieldItemButtonsTemplate, ArrayFieldItemTemplate, ArrayFieldTemplate, GridTemplate, MultiSchemaFieldTemplate, ObjectFieldTemplate } from './templates/layout-templates';
5
5
  import { BaseInputTemplate, TextareaWidget } from './widgets/input-widgets';
6
6
  import { CheckboxWidget, CheckboxesWidget, RadioWidget, SelectWidget } from './widgets/choice-widgets';
7
+ import { Multistep } from './multistep';
7
8
  export declare const Templates: {
8
9
  ArrayFieldItemButtonsTemplate: typeof ArrayFieldItemButtonsTemplate;
9
10
  ArrayFieldItemTemplate: typeof ArrayFieldItemTemplate;
@@ -36,13 +37,20 @@ export declare const Widgets: {
36
37
  SelectWidget: typeof SelectWidget;
37
38
  TextareaWidget: typeof TextareaWidget;
38
39
  };
40
+ /**
41
+ * `ThemeProps` plus the `multistep` components `FcodeJsonSchemaForm` uses to
42
+ * render a `ui:steps` form's navigation. RJSF itself ignores the extra key.
43
+ */
44
+ export type F0RjsfTheme = ThemeProps & {
45
+ multistep: typeof Multistep;
46
+ };
39
47
  /**
40
48
  * Builds the theme. Present for parity with the official RJSF theme packages,
41
49
  * whose `generateTheme()` exists so the theme can be typed against a specific
42
50
  * schema; here the templates are not schema-generic, so it returns the same
43
51
  * object every time.
44
52
  */
45
- export declare function generateTheme(): ThemeProps;
53
+ export declare function generateTheme(): F0RjsfTheme;
46
54
  /**
47
55
  * The f0 theme for react-jsonschema-form.
48
56
  *
@@ -53,4 +61,4 @@ export declare function generateTheme(): ThemeProps;
53
61
  * exchanges uploads as `data:` URLs, and f0's file field is built around an
54
62
  * upload hook instead.
55
63
  */
56
- export declare const Theme: ThemeProps;
64
+ export declare const Theme: F0RjsfTheme;
@@ -1,2 +1,8 @@
1
1
  import { Options as ReactMarkdownProps } from 'react-markdown';
2
2
  export declare function MarkdownContent(props: ReactMarkdownProps): import("react").JSX.Element;
3
+ /**
4
+ * Block-level markdown (GFM) for standalone content: execution result
5
+ * messages and `schema.markdown.before/after`. `MarkdownContent` above stays
6
+ * intentionally narrow for inline field text.
7
+ */
8
+ export declare function MarkdownBlock(props: ReactMarkdownProps): import("react").JSX.Element;
package/dist/styles.css CHANGED
@@ -388,6 +388,47 @@
388
388
  }
389
389
  }
390
390
 
391
+ /*
392
+ * Markdown blocks: the result message and `schema.markdown.before/after`.
393
+ *
394
+ * Most tags come styled from f0's `markdownRenderers` (headings h1-h3, links,
395
+ * lists, code, blockquote, tables). These rules only cover what falls through
396
+ * to native elements — h4-h6, `del`, task-list checkboxes and image sizing —
397
+ * plus the spacing between stacked blocks, using the same f1 variables as the
398
+ * rest of this sheet.
399
+ */
400
+ .fcode-form-markdown {
401
+ display: flex;
402
+ flex-direction: column;
403
+ gap: 0.75rem;
404
+ color: var(--f1-foreground, inherit);
405
+ }
406
+
407
+ .fcode-form-markdown p {
408
+ margin: 0;
409
+ }
410
+
411
+ .fcode-form-markdown h4,
412
+ .fcode-form-markdown h5,
413
+ .fcode-form-markdown h6 {
414
+ margin: 0;
415
+ font-size: 0.875rem;
416
+ font-weight: 600;
417
+ line-height: 1.5;
418
+ }
419
+
420
+ .fcode-form-markdown del {
421
+ color: var(--f1-foreground-secondary, inherit);
422
+ }
423
+
424
+ .fcode-form-markdown img {
425
+ max-width: 100%;
426
+ }
427
+
428
+ .fcode-form-markdown li > input[type='checkbox'] {
429
+ margin-right: 0.5rem;
430
+ }
431
+
391
432
  /*
392
433
  * The SDK's `json` field.
393
434
  *
@@ -448,3 +489,66 @@
448
489
  pointer-events: none;
449
490
  overflow: hidden;
450
491
  }
492
+
493
+ /*
494
+ * Multistep (`ui:steps`) navigation. Colours and controls come from f0
495
+ * (`F0Button`, `F0TableOfContent`); these rules only lay the pieces out.
496
+ */
497
+
498
+ .rjsf-f0-steps-tabs {
499
+ display: flex;
500
+ flex-wrap: wrap;
501
+ gap: 0.25rem;
502
+ margin-bottom: 1.5rem;
503
+ padding-bottom: 0.5rem;
504
+ border-bottom: 1px solid var(--f1-border-secondary, rgb(0 0 0 / 0.1));
505
+ }
506
+
507
+ /* Wraps to a stacked layout on narrow widths via the main column's min-width. */
508
+ .rjsf-f0-steps-layout-sidebar {
509
+ display: flex;
510
+ flex-wrap: wrap;
511
+ gap: 1rem 2rem;
512
+ align-items: flex-start;
513
+ }
514
+
515
+ .rjsf-f0-steps-nav {
516
+ flex: 1 0 13rem;
517
+ max-width: 16rem;
518
+ }
519
+
520
+ .rjsf-f0-steps-layout-sidebar .rjsf-f0-steps-main {
521
+ flex: 1 1 24rem;
522
+ min-width: 0;
523
+ }
524
+
525
+ .rjsf-f0-steps-header {
526
+ margin-bottom: 1rem;
527
+ }
528
+
529
+ .rjsf-f0-steps-title {
530
+ margin: 0 0 0.25rem;
531
+ font-size: 1.125rem;
532
+ font-weight: 600;
533
+ }
534
+
535
+ .rjsf-f0-steps-description {
536
+ margin: 0;
537
+ font-size: 0.875rem;
538
+ color: var(--f1-foreground-secondary, inherit);
539
+ }
540
+
541
+ /*
542
+ * The actions row (rendered by the SDK's step engine) holds Back and
543
+ * Next/Submit; it takes over the submit button's usual top margin.
544
+ */
545
+ .fcode-steps-actions {
546
+ display: flex;
547
+ align-items: center;
548
+ gap: 0.75rem;
549
+ margin-top: 1.5rem;
550
+ }
551
+
552
+ .fcode-steps-actions .rjsf-f0-submit {
553
+ margin-top: 0;
554
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/rjsf-f0",
3
- "version": "1.1.2",
3
+ "version": "2.1.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/",
@@ -47,8 +47,8 @@
47
47
  "react-dom": "^18.3.1 || ^19.0.0"
48
48
  },
49
49
  "dependencies": {
50
- "dompurify": "3.4.12",
51
- "react-markdown": "^10.1.0"
50
+ "react-markdown": "^10.1.0",
51
+ "remark-gfm": "^4.0.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@factorialco/f0-react": "6.8.3",
@@ -1,8 +0,0 @@
1
- /**
2
- * Sanitizes authored HTML so it can be rendered without executing scripts.
3
- *
4
- * @param dirty - The HTML string as authored in the schema or returned by a
5
- * process execution.
6
- * @returns The same markup with every script-execution vector removed.
7
- */
8
- export declare function sanitizeHtml(dirty: string): string;