@factorialco/rjsf-f0 2.2.0 → 2.3.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.
@@ -2,4 +2,6 @@ export { default as Form, generateForm } from './form';
2
2
  export { Templates, Theme, Widgets, generateTheme } from './theme';
3
3
  export type { F0RjsfTheme } from './theme';
4
4
  export { Multistep } from './multistep';
5
+ export { Oauth } from './oauth';
6
+ export type { OauthConnectControlProps, OauthConnectStatus } from './oauth';
5
7
  export { markdownComponents } from './markdown/markdown-components';
@@ -0,0 +1,9 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ import { OauthConnectControlProps } from './types';
3
+ /**
4
+ * The connect button of an `oauth` field. The SDK owns the flow (popup,
5
+ * completion, form reaction); this only draws the control for each status.
6
+ * F0Button renders a `<button>` with no `type`, so the click must prevent the
7
+ * default or it would submit the form.
8
+ */
9
+ export declare const OauthConnectControl: ({ id, status, label, disabled, errorMessage, onClick, }: OauthConnectControlProps) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare const Oauth: {
2
+ ConnectControl: ({ id, status, label, disabled, errorMessage, onClick, }: import('./types').OauthConnectControlProps) => import("react").JSX.Element;
3
+ };
4
+ export type { OauthConnectControlProps, OauthConnectStatus } from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { default as React } from '../../node_modules/@types/react';
2
+ /**
3
+ * Structural copies of the OAuth connect contract in
4
+ * `@factorialco/fcode-react-forms` (`FcodeJsonSchemaForm`'s `rjsfTheme.oauth`).
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 OauthConnectStatus = 'idle' | 'pending' | 'connected';
9
+ export interface OauthConnectControlProps {
10
+ id: string;
11
+ status: OauthConnectStatus;
12
+ label: string;
13
+ disabled: boolean;
14
+ errorMessage?: string;
15
+ /** Must be called synchronously from the click, or popup blockers step in. */
16
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
17
+ }
@@ -5,11 +5,13 @@ export declare function TitleFieldTemplate({ id, title, uiSchema, optionalDataCo
5
5
  /** Section (object/array level) description. */
6
6
  export declare function DescriptionFieldTemplate({ id, description, }: DescriptionFieldProps): React.JSX.Element | null;
7
7
  /**
8
- * Per-field errors.
8
+ * Every error message RJSF has for a field, and the only place they render.
9
9
  *
10
- * f0 controls render their own error message, so this only covers the cases f0
11
- * cannot show inline (multiple messages, and controls rendered as raw
12
- * primitives).
10
+ * f0 form fields are told they are in an error state but not what to say
11
+ * (`f0-field.tsx`), because half of what this theme renders is not an f0 form
12
+ * field at all — checkboxes, file inputs, the SDK's own fields, and the object
13
+ * and array levels a global form error lands on — and each of those swallowed
14
+ * its message when the control was trusted to show it.
13
15
  */
14
16
  export declare function FieldErrorTemplate({ errors, fieldPathId, }: FieldErrorProps): React.JSX.Element | null;
15
17
  /** Renders a `ui:help` directive under the control. */
@@ -6,6 +6,7 @@ import { BaseInputTemplate, TextareaWidget } from './widgets/input-widgets';
6
6
  import { FileWidget } from './widgets/file-widget';
7
7
  import { CheckboxWidget, CheckboxesWidget, RadioWidget, SelectWidget } from './widgets/choice-widgets';
8
8
  import { Multistep } from './multistep';
9
+ import { Oauth } from './oauth';
9
10
  export declare const Templates: {
10
11
  ArrayFieldItemButtonsTemplate: typeof ArrayFieldItemButtonsTemplate;
11
12
  ArrayFieldItemTemplate: typeof ArrayFieldItemTemplate;
@@ -41,10 +42,12 @@ export declare const Widgets: {
41
42
  };
42
43
  /**
43
44
  * `ThemeProps` plus the `multistep` components `FcodeJsonSchemaForm` uses to
44
- * render a `ui:steps` form's navigation. RJSF itself ignores the extra key.
45
+ * render a `ui:steps` form's navigation and the `oauth` control it uses for
46
+ * `ui:widget: "oauth"` fields. RJSF itself ignores the extra keys.
45
47
  */
46
48
  export type F0RjsfTheme = ThemeProps & {
47
49
  multistep: typeof Multistep;
50
+ oauth: typeof Oauth;
48
51
  };
49
52
  /**
50
53
  * Builds the theme. Present for parity with the official RJSF theme packages,
@@ -3,11 +3,13 @@ import { WidgetProps } from '@rjsf/utils';
3
3
  /**
4
4
  * Shared bridge from an RJSF widget to `F0FormField`.
5
5
  *
6
- * RJSF keeps ownership of validation: the messages it produces are passed down
7
- * as `error`/`errorMessage` rather than letting f0 (which validates with zod)
8
- * derive its own. The label is hidden because `FieldTemplate` renders it above
9
- * the control to support markdown; the plain-text label is still handed to f0 so
10
- * the control keeps an accessible name.
6
+ * RJSF keeps ownership of validation: the control is told it is in an error
7
+ * state rather than letting f0 (which validates with zod) derive its own, and
8
+ * the messages themselves are rendered by `FieldErrorTemplate`, the one place
9
+ * that also covers the controls f0 does not render. The label is hidden because
10
+ * `FieldTemplate` renders it above the control to support markdown; the
11
+ * plain-text label is still handed to f0 so the control keeps an accessible
12
+ * name.
11
13
  */
12
14
  export interface F0FieldBridgeProps extends WidgetProps {
13
15
  /** The f0 field descriptor minus the parts derived from the RJSF props. */
package/dist/styles.css CHANGED
@@ -135,14 +135,26 @@
135
135
  margin-top: 0.125rem;
136
136
  }
137
137
 
138
+ /*
139
+ * Matches what f0 draws under a field in error (`text-base font-medium
140
+ * text-f1-foreground-critical`), minus its icon: this list carries the single
141
+ * message of an ordinary invalid field, not just the rare pile-up, so a marker
142
+ * and its indent would set it apart from every f0 field error on the page.
143
+ */
138
144
  .rjsf-f0-errors {
139
145
  margin: 0;
140
- /* f0 `5`; 1.1rem was not on the spacing scale. Matches the help lists. */
141
- padding-left: 1.25rem;
146
+ padding-left: 0;
147
+ list-style: none;
142
148
  font-size: 0.875rem;
149
+ font-weight: 500;
143
150
  color: hsl(var(--critical-70, 3 71% 41%));
144
151
  }
145
152
 
153
+ .rjsf-f0-errors li + li {
154
+ /* f0 `0.5`. */
155
+ margin-top: 0.125rem;
156
+ }
157
+
146
158
  .rjsf-f0-object,
147
159
  .rjsf-f0-array {
148
160
  display: flex;
@@ -208,6 +220,24 @@
208
220
  margin-top: 1.5rem;
209
221
  }
210
222
 
223
+ /* The OAuth connect control: button and, when the flow failed, its message. */
224
+ .rjsf-f0-oauth {
225
+ display: flex;
226
+ flex-wrap: wrap;
227
+ align-items: center;
228
+ gap: 0.75rem;
229
+ }
230
+
231
+ /* f0's `text-base font-medium` in the critical foreground colour. */
232
+ .rjsf-f0-oauth-error {
233
+ flex-basis: 100%;
234
+ margin: 0;
235
+ font-size: 0.875rem;
236
+ line-height: 1.25rem;
237
+ font-weight: 500;
238
+ color: hsl(var(--critical-70, 3 71% 41%));
239
+ }
240
+
211
241
  /*
212
242
  * `gap` matches the `pl-2.5` f0 puts between a checkbox and its own label, so a
213
243
  * markdown label (rendered here) lines up with a plain one (rendered by f0).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/rjsf-f0",
3
- "version": "2.2.0",
3
+ "version": "2.3.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/",