@factorialco/rjsf-f0 3.4.0 → 3.9.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.
@@ -0,0 +1,14 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ import { ActionButtonControlProps } from './types';
3
+ /**
4
+ * The drawing of the Forms SDK's `ui:field: "button"`: an `F0Button` in the
5
+ * variant the schema asked for (the SDK already validated it; `outline` when
6
+ * absent, as f0 forms draw a secondary action next to their primary one) and
7
+ * the description under it. The SDK sets the value and submits the form; this
8
+ * button must not submit it by itself, so it is a `type="button"` and also
9
+ * prevents the default, for f0 versions that drop the `type`. While the SDK
10
+ * holds it disabled for `enabledWhen`, the reason is `F0Button`'s own tooltip,
11
+ * which f0 opens on pointer hover even on a disabled button, and visually
12
+ * hidden text after it for a screen reader (`DisabledReason`).
13
+ */
14
+ export declare const ActionButtonControl: ({ id, label, description, variant, disabled, disabledReason, onClick, }: ActionButtonControlProps) => React.JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const Button: {
2
+ Control: ({ id, label, description, variant, disabled, disabledReason, onClick, }: import('./types').ActionButtonControlProps) => import('../../node_modules/@types/react').JSX.Element;
3
+ };
4
+ export { BUTTON_VARIANTS } from './types';
5
+ export type { ActionButtonControlProps, ButtonVariant } from './types';
@@ -0,0 +1,46 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ /**
3
+ * Structural copies of the action button contract in
4
+ * `@factorialco/fcode-react-forms` (`FcodeJsonSchemaForm`'s `rjsfTheme.button`).
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
+ /** The `F0Button` variants a schema may ask for. */
9
+ export declare const BUTTON_VARIANTS: readonly ["default", "outline", "neutral", "critical", "ghost"];
10
+ export type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
11
+ export interface ActionButtonControlProps {
12
+ id: string;
13
+ label: string;
14
+ /** Markdown shown under the button; `null` for none. */
15
+ description: string | null;
16
+ variant: ButtonVariant;
17
+ disabled: boolean;
18
+ /**
19
+ * Why the button is disabled, set by the SDK only while
20
+ * `ui:options.enabledWhen` holds it disabled; drawn as its tooltip.
21
+ */
22
+ disabledReason?: string | null;
23
+ /** Sets the property and submits the form; the button must not submit. */
24
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
25
+ }
26
+ declare module '@rjsf/utils' {
27
+ interface UISchemaSubmitButtonOptions {
28
+ /**
29
+ * The submit button's look; `"default"` (the primary button) when absent.
30
+ * Read by the Forms SDK's themes; RJSF's own templates ignore it.
31
+ */
32
+ variant?: 'default' | 'outline' | 'neutral' | 'critical' | 'ghost';
33
+ /**
34
+ * A property at the root of the form data: the submit button stays
35
+ * disabled until it holds exactly `true`. Resolved by the Forms SDK
36
+ * against the live form data; this theme never reads it.
37
+ */
38
+ enabledWhen?: string;
39
+ /**
40
+ * Why the submit button is disabled: drawn as its tooltip while
41
+ * `props.disabled` is set (the Forms SDK sets both while `enabledWhen`
42
+ * holds the button disabled).
43
+ */
44
+ disabledReason?: string;
45
+ }
46
+ }
@@ -0,0 +1,12 @@
1
+ import { ButtonVariant } from './types';
2
+ /**
3
+ * The rule for a schema-authored button variant, byte-duplicated in
4
+ * @factorialco/fcode-react-forms and @factorialco/rjsf-f0 (separate npm
5
+ * publishes, no shared package; `variant-rule.twin.test.ts` pins the copies
6
+ * equal: edit one, copy it over the other). No value is the fallback, an
7
+ * unknown one too, with the warning each package reports once.
8
+ */
9
+ export declare const variantOrFallback: (raw: unknown, fallback: ButtonVariant, where: string) => {
10
+ variant: ButtonVariant;
11
+ warning: string | null;
12
+ };
@@ -0,0 +1,11 @@
1
+ import { UiSchema } from '@rjsf/utils';
2
+ import { ButtonVariant } from './types';
3
+ /**
4
+ * The submit button's `F0Button` variant, from
5
+ * `ui:submitButtonOptions.variant`: `default` (primary) when absent, and when
6
+ * unknown too, with a warning (once: the submit button re-renders on every
7
+ * keystroke). This theme renders standalone as well, so it reads the option
8
+ * itself rather than relying on the Forms SDK; the rule is the SDK's own
9
+ * (`variant-rule.ts`).
10
+ */
11
+ export declare const submitVariant: (uiSchema: UiSchema | undefined) => ButtonVariant;
@@ -11,3 +11,5 @@ export type { LaunchButtonProps, LaunchButtonToggle } from './assistant';
11
11
  export type { PairingLabels, PairingOption, PairingRowStatus, PairingSuggestion, PairingSuggestionSource, PairingTableProps, PairingTableRow, } from './pairing';
12
12
  export { Table } from './table';
13
13
  export type { FormTableBadgeVariant, FormTableCell, FormTableCellValue, FormTableColumn, FormTableLabels, FormTableOption, FormTableProps, FormTableRow, FormTableSelectAll, } from './table';
14
+ export { Button } from './button';
15
+ export type { ActionButtonControlProps, ButtonVariant } from './button';
@@ -1,6 +1,6 @@
1
1
  export declare const Multistep: {
2
- StepsNavigation: ({ layout, items, currentIndex, onNavigate, children, }: import('./types').StepsNavigationProps) => import('../../node_modules/@types/react').JSX.Element;
2
+ StepsNavigation: ({ layout, navigation, items, currentIndex, onNavigate, children, }: import('./types').StepsNavigationProps) => import('../../node_modules/@types/react').JSX.Element;
3
3
  BackButton: ({ label, onClick, disabled, }: import('./types').StepBackButtonProps) => import('../../node_modules/@types/react').JSX.Element;
4
4
  LeaveConfirm: ({ open, title, message, confirmLabel, cancelLabel, onConfirm, onCancel, }: import('./types').LeaveConfirmProps) => import('../../node_modules/@types/react').JSX.Element;
5
5
  };
6
- export type { LeaveConfirmProps, StepBackButtonProps, StepsLayout, StepsNavigationItem, StepsNavigationProps, StepStatus, } from './types';
6
+ export type { LeaveConfirmProps, StepBackButtonProps, StepsLayout, StepsNavigationMode, StepsNavigationItem, StepsNavigationProps, StepStatus, } from './types';
@@ -1,3 +1,3 @@
1
1
  import { default as React } from '../../node_modules/@types/react';
2
2
  import { StepsNavigationProps } from './types';
3
- export declare const StepsNavigation: ({ layout, items, currentIndex, onNavigate, children, }: StepsNavigationProps) => React.JSX.Element;
3
+ export declare const StepsNavigation: ({ layout, navigation, items, currentIndex, onNavigate, children, }: StepsNavigationProps) => React.JSX.Element;
@@ -6,6 +6,7 @@ import { default as React } from '../../node_modules/@types/react';
6
6
  * TypeScript's structural typing keeps them interchangeable.
7
7
  */
8
8
  export type StepsLayout = 'tabs' | 'sidebar';
9
+ export type StepsNavigationMode = 'linear' | 'free';
9
10
  export type StepStatus = 'completed' | 'current' | 'upcoming' | 'skipped';
10
11
  export interface StepsNavigationItem {
11
12
  index: number;
@@ -19,6 +20,8 @@ export interface StepsNavigationItem {
19
20
  }
20
21
  export interface StepsNavigationProps {
21
22
  layout: StepsLayout;
23
+ /** `free`: every step reachable at any time; absent means `linear`. */
24
+ navigation?: StepsNavigationMode;
22
25
  items: StepsNavigationItem[];
23
26
  currentIndex: number;
24
27
  onNavigate: (index: number) => void;
@@ -12,6 +12,24 @@ export declare function MoveDownButton(props: IconButtonProps): React.JSX.Elemen
12
12
  export declare function RemoveButton(props: IconButtonProps): React.JSX.Element;
13
13
  export declare function ClearButton(props: IconButtonProps): React.JSX.Element;
14
14
  export declare function AddButton(props: IconButtonProps): React.JSX.Element;
15
- /** The form's submit button. Relies on the native submit behaviour. */
15
+ /**
16
+ * The form's submit button. Relies on the native submit behaviour. Its
17
+ * `F0Button` variant comes from `ui:submitButtonOptions.variant` (`default`,
18
+ * the primary button, when absent). While it is disabled, a
19
+ * `ui:submitButtonOptions.disabledReason` is `F0Button`'s own tooltip, which
20
+ * f0 opens on pointer hover even on a disabled button; the Forms SDK sets both
21
+ * while `enabledWhen` holds the button disabled. A disabled button takes no
22
+ * focus, so the reason is also written, visually hidden, right after it
23
+ * (`DisabledReason`), where a screen reader reads it.
24
+ */
16
25
  export declare function SubmitButton({ uiSchema }: SubmitButtonProps): React.JSX.Element | null;
26
+ /**
27
+ * Why a button is disabled, for a screen reader: visually hidden (the
28
+ * tooltip shows it on hover) and placed right after the button. `F0Button`
29
+ * takes no `aria-describedby`, and a disabled button cannot be focused to
30
+ * open its tooltip, so this is how keyboard and screen-reader users get it.
31
+ */
32
+ export declare const DisabledReason: ({ reason }: {
33
+ reason?: string | null;
34
+ }) => React.JSX.Element | null;
17
35
  export declare const ButtonTemplates: TemplatesType['ButtonTemplates'];
@@ -10,6 +10,7 @@ import { Oauth } from './oauth';
10
10
  import { Pairing } from './pairing';
11
11
  import { Assistant } from './assistant';
12
12
  import { Table } from './table';
13
+ import { Button } from './button';
13
14
  export declare const Templates: {
14
15
  ArrayFieldItemButtonsTemplate: typeof ArrayFieldItemButtonsTemplate;
15
16
  ArrayFieldItemTemplate: typeof ArrayFieldItemTemplate;
@@ -48,7 +49,8 @@ export declare const Widgets: {
48
49
  * render a `ui:steps` form's navigation, the `oauth` control it uses for
49
50
  * `ui:widget: "oauth"` fields, the `pairing` table it uses for
50
51
  * `ui:field: "pairing"` objects, the `table` it uses for `ui:field: "table"`
51
- * sections and the `assistant` button it uses for `ui:field: "launch-one"`.
52
+ * sections, the `button` it uses for `ui:field: "button"` action buttons and
53
+ * the `assistant` button it uses for `ui:field: "launch-one"`.
52
54
  * RJSF itself ignores the extra keys.
53
55
  */
54
56
  export type F0RjsfTheme = ThemeProps & {
@@ -57,6 +59,7 @@ export type F0RjsfTheme = ThemeProps & {
57
59
  pairing: typeof Pairing;
58
60
  assistant: typeof Assistant;
59
61
  table: typeof Table;
62
+ button: typeof Button;
60
63
  };
61
64
  /**
62
65
  * Builds the theme. Present for parity with the official RJSF theme packages,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `console.warn` once per message. Schema options are parsed again on every
3
+ * render, so a problem is reported once instead of once per keystroke.
4
+ */
5
+ export declare const warnOnce: (message: string) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -5,10 +5,20 @@ export declare function SelectWidget(props: WidgetProps): React.JSX.Element;
5
5
  /**
6
6
  * A labelled checkbox. Uses the `F0Checkbox` primitive rather than an
7
7
  * `F0FormField` so a markdown label can sit beside the box.
8
+ *
9
+ * With `ui:options.display: "switch"` it is f0's `Switch` instead, with the
10
+ * label beside it the same way. Not `F0FormField`'s `switch` field: that one
11
+ * always hides the switch's own label and puts the field label above the
12
+ * control, where this theme keeps a boolean's label beside it.
13
+ */
14
+ export declare function CheckboxWidget({ id, schema, uiSchema, value, label, hideLabel, disabled, readonly, onChange, }: WidgetProps): React.JSX.Element;
15
+ /**
16
+ * Checkbox group for an array of enum values.
17
+ *
18
+ * With `ui:options.display: "cards"` it is a set of selectable cards instead
19
+ * (`CheckboxCards`).
8
20
  */
9
- export declare function CheckboxWidget({ id, value, label, hideLabel, disabled, readonly, onChange, }: WidgetProps): React.JSX.Element;
10
- /** Checkbox group for an array of enum values. */
11
- export declare function CheckboxesWidget({ id, disabled, readonly, options, value, onChange, }: WidgetProps): React.JSX.Element;
21
+ export declare function CheckboxesWidget(props: WidgetProps): React.JSX.Element;
12
22
  /**
13
23
  * Radio group.
14
24
  *
@@ -0,0 +1,14 @@
1
+ import { RJSFSchema, UiSchema } from '@rjsf/utils';
2
+ import { FieldDisplay } from './display-rule';
3
+ export type { FieldDisplay } from './display-rule';
4
+ /**
5
+ * How a field is drawn when `ui:options.display` asks for something else than
6
+ * its widget's usual look: `"switch"`, f0's `Switch`, on a boolean drawn by
7
+ * the checkbox widget; `"cards"`, one selectable card per option (f0's
8
+ * `CardSelectableContainer`, `multiple`), on an array drawn by `checkboxes`.
9
+ * The rule is the Forms SDK's own (`display-rule.ts`, duplicated in both
10
+ * packages): this theme renders standalone too, so it reads the option
11
+ * itself. Called by `FieldTemplate` (every field, for the warnings),
12
+ * `CheckboxWidget` and `CheckboxesWidget`.
13
+ */
14
+ export declare const fieldDisplay: (id: string, schema: RJSFSchema, uiSchema?: UiSchema) => FieldDisplay | undefined;
@@ -0,0 +1,23 @@
1
+ import { RJSFSchema, UiSchema } from '@rjsf/utils';
2
+ /** The drawings `ui:options.display` can ask for, one per kind of field. */
3
+ export type FieldDisplay = 'switch' | 'cards';
4
+ /**
5
+ * The rule for `ui:options.display`, byte-duplicated in
6
+ * @factorialco/fcode-react-forms and @factorialco/rjsf-f0 (separate npm
7
+ * publishes, no shared package; `display-rule.twin.test.ts` pins the copies
8
+ * equal: edit one, copy it over the other):
9
+ *
10
+ * - `"switch"` on a boolean drawn by the checkbox widget;
11
+ * - `"cards"` on an array drawn by the `checkboxes` widget (only the f0 theme
12
+ * draws them; the hosted theme keeps its checkboxes).
13
+ *
14
+ * It is an option, not a `ui:widget`, so an older theme or SDK keeps the
15
+ * checkbox(es) instead of failing the whole form with `No widget "switch"`.
16
+ * Anything else is warn-and-degrade: a value that does not fit the field keeps
17
+ * its usual widget, and on any other field the option is ignored, with the
18
+ * warning each package reports once.
19
+ */
20
+ export declare const displayRule: (id: string, schema: RJSFSchema, uiSchema?: UiSchema) => {
21
+ display: FieldDisplay | undefined;
22
+ warning: string | null;
23
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/styles.css CHANGED
@@ -242,6 +242,14 @@
242
242
  color: hsl(var(--critical-70, 3 71% 41%));
243
243
  }
244
244
 
245
+ /* An action button (`ui:field: "button"`) with its description under it. */
246
+ .rjsf-f0-action-button {
247
+ display: flex;
248
+ flex-direction: column;
249
+ align-items: flex-start;
250
+ gap: 0.25rem;
251
+ }
252
+
245
253
  /*
246
254
  * `gap` matches the `pl-2.5` f0 puts between a checkbox and its own label, so a
247
255
  * markdown label (rendered here) lines up with a plain one (rendered by f0).
@@ -891,6 +899,24 @@
891
899
  margin-left: 0;
892
900
  }
893
901
 
902
+ /*
903
+ * A `navigation: "free"` form in the tabs layout: f0's own `Tabs`, drawn as
904
+ * f0 draws them. Its tabs take text only, so a step with errors gets a
905
+ * critical dot after its label.
906
+ */
907
+ .rjsf-f0-steps-free-tabs {
908
+ margin-bottom: 1.5rem;
909
+ }
910
+
911
+ .rjsf-f0-steps-free-tabs [data-fcode-errors] > span::after {
912
+ content: '';
913
+ width: 0.375rem;
914
+ height: 0.375rem;
915
+ margin-left: 0.375rem;
916
+ border-radius: 50%;
917
+ background-color: hsl(var(--critical-50, 4 84% 60%));
918
+ }
919
+
894
920
  /* Wraps to a stacked layout on narrow widths via the main column's min-width. */
895
921
  .rjsf-f0-steps-layout-sidebar {
896
922
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/rjsf-f0",
3
- "version": "3.4.0",
3
+ "version": "3.9.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/",