@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.
@@ -1,3 +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';
3
5
  export { markdownComponents } from './markdown/markdown-components';
@@ -0,0 +1,18 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ export interface AlertBlockquoteProps {
3
+ children?: React.ReactNode;
4
+ /** f0's own blockquote renderer, used when this is an ordinary quote. */
5
+ fallback?: React.ComponentType<any>;
6
+ [key: string]: unknown;
7
+ }
8
+ /**
9
+ * Renders a GitHub-style alert as an f0-toned callout, and anything else as
10
+ * f0's ordinary blockquote.
11
+ *
12
+ * Deliberately *not* `F0Alert`: its `title` and `description` are plain
13
+ * `string`s, so routing a blockquote through it would flatten the body and
14
+ * silently drop the bold, links, lists and code an author is free to put in a
15
+ * markdown block. The callout below keeps the real markdown children and
16
+ * borrows f0's semantic colour scale instead, so it still flips in dark mode.
17
+ */
18
+ export declare function AlertBlockquote({ children, fallback: Fallback, node: _node, ...rest }: AlertBlockquoteProps): React.JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -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;
@@ -3,7 +3,9 @@ import { FieldTemplate } from './templates/field-template';
3
3
  import { DescriptionFieldTemplate, ErrorListTemplate, FieldErrorTemplate, FieldHelpTemplate, TitleFieldTemplate, WrapIfAdditionalTemplate } from './templates/misc-templates';
4
4
  import { ArrayFieldItemButtonsTemplate, ArrayFieldItemTemplate, ArrayFieldTemplate, GridTemplate, MultiSchemaFieldTemplate, ObjectFieldTemplate } from './templates/layout-templates';
5
5
  import { BaseInputTemplate, TextareaWidget } from './widgets/input-widgets';
6
+ import { FileWidget } from './widgets/file-widget';
6
7
  import { CheckboxWidget, CheckboxesWidget, RadioWidget, SelectWidget } from './widgets/choice-widgets';
8
+ import { Multistep } from './multistep';
7
9
  export declare const Templates: {
8
10
  ArrayFieldItemButtonsTemplate: typeof ArrayFieldItemButtonsTemplate;
9
11
  ArrayFieldItemTemplate: typeof ArrayFieldItemTemplate;
@@ -32,25 +34,29 @@ export declare const Templates: {
32
34
  export declare const Widgets: {
33
35
  CheckboxWidget: typeof CheckboxWidget;
34
36
  CheckboxesWidget: typeof CheckboxesWidget;
37
+ FileWidget: typeof FileWidget;
35
38
  RadioWidget: typeof RadioWidget;
36
39
  SelectWidget: typeof SelectWidget;
37
40
  TextareaWidget: typeof TextareaWidget;
38
41
  };
42
+ /**
43
+ * `ThemeProps` plus the `multistep` components `FcodeJsonSchemaForm` uses to
44
+ * render a `ui:steps` form's navigation. RJSF itself ignores the extra key.
45
+ */
46
+ export type F0RjsfTheme = ThemeProps & {
47
+ multistep: typeof Multistep;
48
+ };
39
49
  /**
40
50
  * Builds the theme. Present for parity with the official RJSF theme packages,
41
51
  * whose `generateTheme()` exists so the theme can be typed against a specific
42
52
  * schema; here the templates are not schema-generic, so it returns the same
43
53
  * object every time.
44
54
  */
45
- export declare function generateTheme(): ThemeProps;
55
+ export declare function generateTheme(): F0RjsfTheme;
46
56
  /**
47
57
  * The f0 theme for react-jsonschema-form.
48
58
  *
49
59
  * Anything not listed in `Templates`/`Widgets` falls through to `@rjsf/core`'s
50
- * own implementation. The file widget is core's, but core renders it through
51
- * this theme's `BaseInputTemplate`, which keeps a native `<input type="file">`
52
- * for it (see `FileInput` in `widgets/input-widgets.tsx`): the surrounding SDK
53
- * exchanges uploads as `data:` URLs, and f0's file field is built around an
54
- * upload hook instead.
60
+ * own implementation.
55
61
  */
56
- export declare const Theme: ThemeProps;
62
+ export declare const Theme: F0RjsfTheme;
@@ -0,0 +1,38 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ import { WidgetProps } from '@rjsf/utils';
3
+ /**
4
+ * Bytes as a short human-readable size.
5
+ *
6
+ * Deliberately not `toLocaleString`: that formats against the *browser's*
7
+ * locale, which is exactly the mismatch this widget exists to remove (a form
8
+ * rendered in Spanish must not pick up separators from an English browser).
9
+ * Sizes are rendered with a plain decimal point until a form-level locale is
10
+ * available to this package.
11
+ */
12
+ export declare function formatFileSize(bytes: number): string;
13
+ /**
14
+ * The f0 file control.
15
+ *
16
+ * Replaces core's `FileWidget`, which renders a bare `<input type="file">`
17
+ * through `BaseInputTemplate`. That input is unfixable by CSS in two ways that
18
+ * both give away a non-native dialog: its "No file chosen" text cannot be
19
+ * removed, and its button label is drawn by the *browser* in the browser's
20
+ * locale — English chrome inside a Spanish form, which no amount of locale
21
+ * propagation on our side can reach.
22
+ *
23
+ * The file/`data:` URL exchange is untouched: `useFileWidgetProps` (core's own
24
+ * hook) still owns reading the `File`, encoding it and accumulating the list,
25
+ * so the value RJSF sees is byte-identical to before.
26
+ *
27
+ * The native input is kept — transparent, stretched over the whole dropzone —
28
+ * rather than hidden behind a JS click handler. It stays the labelled control
29
+ * (`FieldTemplate` renders `<label htmlFor>`), it keeps `accept` as the raw
30
+ * HTML string the schema authored, and click and keyboard stay the platform's.
31
+ *
32
+ * Drag-and-drop is NOT the platform's, and assuming it was is what broke it
33
+ * once: a file input accepts a dropped file by itself only while no handler
34
+ * claims the drag, and the `dragover` handler that highlights the box does
35
+ * exactly that. Highlighting and handling the drop are therefore one decision —
36
+ * see `handleDrop`.
37
+ */
38
+ export declare function FileWidget(props: WidgetProps): React.JSX.Element;