@factorialco/rjsf-f0 3.3.0 → 3.4.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/README.md +18 -2
- package/dist/rjsf-f0.cjs.js +11 -11
- package/dist/rjsf-f0.cjs.js.map +1 -1
- package/dist/rjsf-f0.es.js +2307 -2085
- package/dist/rjsf-f0.es.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/pairing/pairing-render.test.d.ts +1 -0
- package/dist/src/pairing/test-fixtures.d.ts +14 -0
- package/dist/src/table/form-table.d.ts +13 -0
- package/dist/src/table/index.d.ts +4 -0
- package/dist/src/table/table.test.d.ts +1 -0
- package/dist/src/table/types.d.ts +139 -0
- package/dist/src/theme.d.ts +6 -3
- package/dist/styles.css +34 -2
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export { Pairing } from './pairing';
|
|
|
9
9
|
export { Assistant } from './assistant';
|
|
10
10
|
export type { LaunchButtonProps, LaunchButtonToggle } from './assistant';
|
|
11
11
|
export type { PairingLabels, PairingOption, PairingRowStatus, PairingSuggestion, PairingSuggestionSource, PairingTableProps, PairingTableRow, } from './pairing';
|
|
12
|
+
export { Table } from './table';
|
|
13
|
+
export type { FormTableBadgeVariant, FormTableCell, FormTableCellValue, FormTableColumn, FormTableLabels, FormTableOption, FormTableProps, FormTableRow, FormTableSelectAll, } from './table';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from '../../node_modules/@types/react';
|
|
2
|
+
import { PairingLabels, PairingTableRow } from './types';
|
|
3
|
+
/** The labels, choices and rows the pairing table tests share. */
|
|
4
|
+
export declare const labels: PairingLabels;
|
|
5
|
+
export declare const options: {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
/** A row as the SDK hands it, needing a choice unless `extra` says otherwise. */
|
|
10
|
+
export declare const row: (id: string, extra?: Partial<PairingTableRow>) => PairingTableRow;
|
|
11
|
+
/** f0 draws nothing without its provider. */
|
|
12
|
+
export declare const InF0: ({ children }: {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from '../../node_modules/@types/react';
|
|
2
|
+
import { FormTableProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The f0 drawing of a `ui:field: "table"` section. The SDK owns the columns,
|
|
5
|
+
* the rows and the submitted values; this only lays them out on f0's
|
|
6
|
+
* experimental `F0FormEditableTable`: one column per schema column (after the
|
|
7
|
+
* row-title column, when the section asks for one), each cell drawn by its own
|
|
8
|
+
* kind, and the table's own controls to add, remove and reorder rows when the
|
|
9
|
+
* SDK allows them. f0 has no yes/no cell, so a boolean is a two-choice select;
|
|
10
|
+
* the column the section selects as a whole gets a "select all" checkbox in
|
|
11
|
+
* its header.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FormTable: (props: FormTableProps) => React.JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Table: {
|
|
2
|
+
Table: (props: import('./types').FormTableProps) => import('../../node_modules/@types/react').JSX.Element;
|
|
3
|
+
};
|
|
4
|
+
export type { FormTableBadgeVariant, FormTableCell, FormTableCellValue, FormTableColumn, FormTableLabels, FormTableOption, FormTableProps, FormTableRow, FormTableSelectAll, } from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural copies of the table contract in `@factorialco/fcode-react-forms`
|
|
3
|
+
* (`FcodeJsonSchemaForm`'s `rjsfTheme.table`). This package does not depend on
|
|
4
|
+
* that one, so the types are duplicated here; TypeScript's structural typing
|
|
5
|
+
* keeps them interchangeable.
|
|
6
|
+
*/
|
|
7
|
+
/** A choice of a select cell. */
|
|
8
|
+
export interface FormTableOption {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const FORM_TABLE_BADGE_VARIANTS: readonly ["neutral", "info", "positive", "warning", "critical"];
|
|
13
|
+
export type FormTableBadgeVariant = (typeof FORM_TABLE_BADGE_VARIANTS)[number];
|
|
14
|
+
/** A column of the table, from `ui:options.columns` or the rows' properties. */
|
|
15
|
+
export interface FormTableColumn {
|
|
16
|
+
/** The property of each row this column shows. */
|
|
17
|
+
key: string;
|
|
18
|
+
title: string;
|
|
19
|
+
/** Fixed width in pixels; without it the column shares what is left. */
|
|
20
|
+
width: number | null;
|
|
21
|
+
/** Every row that has this cell requires it. */
|
|
22
|
+
required: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What one cell holds. The kind comes from the schema of that row's property,
|
|
26
|
+
* so two rows may hold different kinds in the same column.
|
|
27
|
+
*/
|
|
28
|
+
export type FormTableCell = ({
|
|
29
|
+
kind: 'text';
|
|
30
|
+
value: string;
|
|
31
|
+
inputType: FormTableInputType;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'number';
|
|
34
|
+
value: number | null;
|
|
35
|
+
/** Shown beside the number ("€", "%", "h"); `null` for none. */
|
|
36
|
+
units: string | null;
|
|
37
|
+
unitsPosition: 'before' | 'after';
|
|
38
|
+
/** `null` leaves the decimals to the theme; `0` for an integer. */
|
|
39
|
+
maxDecimals: number | null;
|
|
40
|
+
min: number | null;
|
|
41
|
+
max: number | null;
|
|
42
|
+
}
|
|
43
|
+
/** A day, as `yyyy-mm-dd`. */
|
|
44
|
+
| {
|
|
45
|
+
kind: 'date';
|
|
46
|
+
value: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** `null` while nothing is chosen; `""` is a choice when the options list it. */
|
|
49
|
+
| {
|
|
50
|
+
kind: 'select';
|
|
51
|
+
value: string | null;
|
|
52
|
+
options: FormTableOption[];
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'multiselect';
|
|
55
|
+
value: string[];
|
|
56
|
+
options: FormTableOption[];
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'boolean';
|
|
59
|
+
value: boolean | null;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'badge';
|
|
62
|
+
label: string;
|
|
63
|
+
variant: FormTableBadgeVariant;
|
|
64
|
+
}
|
|
65
|
+
/** A read-only value. */
|
|
66
|
+
| {
|
|
67
|
+
kind: 'display';
|
|
68
|
+
text: string;
|
|
69
|
+
}
|
|
70
|
+
/** The row has no property for this column. */
|
|
71
|
+
| {
|
|
72
|
+
kind: 'empty';
|
|
73
|
+
}) & {
|
|
74
|
+
/** The validation message for the cell, once the form has been validated. */
|
|
75
|
+
error: string | null;
|
|
76
|
+
/** Help for the cell (the property's `description`), shown on demand. */
|
|
77
|
+
hint: string | null;
|
|
78
|
+
};
|
|
79
|
+
export declare const FORM_TABLE_INPUT_TYPES: readonly ["text", "email", "url", "tel"];
|
|
80
|
+
/** What a text cell asks the keyboard and the browser for. */
|
|
81
|
+
export type FormTableInputType = (typeof FORM_TABLE_INPUT_TYPES)[number];
|
|
82
|
+
export type FormTableCellValue = string | number | boolean | string[] | null;
|
|
83
|
+
export interface FormTableRow {
|
|
84
|
+
/** The property name of a fixed row; a stable key for a row of a list. */
|
|
85
|
+
id: string;
|
|
86
|
+
/** The row's own title, shown in the row header column when there is one. */
|
|
87
|
+
label: string | null;
|
|
88
|
+
/** One cell per column, by column key. */
|
|
89
|
+
cells: Record<string, FormTableCell>;
|
|
90
|
+
}
|
|
91
|
+
/** The "select all" checkbox of a yes/no column. */
|
|
92
|
+
export interface FormTableSelectAll {
|
|
93
|
+
/** The key of the column it selects. */
|
|
94
|
+
column: string;
|
|
95
|
+
/**
|
|
96
|
+
* Whether every row is selected, only some, or none: checked,
|
|
97
|
+
* indeterminate or empty.
|
|
98
|
+
*/
|
|
99
|
+
state: 'all' | 'some' | 'none';
|
|
100
|
+
/** `true` selects the column on every row, `false` deselects it. */
|
|
101
|
+
onChange: (selected: boolean) => void;
|
|
102
|
+
}
|
|
103
|
+
/** The table's own text, overridable from `ui:options.labels`. */
|
|
104
|
+
export interface FormTableLabels {
|
|
105
|
+
addRow: string;
|
|
106
|
+
removeRow: string;
|
|
107
|
+
/** The accessible name of the checkbox that selects a whole column. */
|
|
108
|
+
selectAll: string;
|
|
109
|
+
/** How a boolean cell reads. */
|
|
110
|
+
yes: string;
|
|
111
|
+
no: string;
|
|
112
|
+
/** The placeholder of an empty select cell. */
|
|
113
|
+
placeholder: string;
|
|
114
|
+
/** Shown instead of the table while it has no rows and none can be added. */
|
|
115
|
+
empty: string;
|
|
116
|
+
}
|
|
117
|
+
/** What the SDK hands the theme's table. */
|
|
118
|
+
export interface FormTableProps {
|
|
119
|
+
id: string;
|
|
120
|
+
columns: FormTableColumn[];
|
|
121
|
+
/** Header of the leading row-title column; `null` when there is none. */
|
|
122
|
+
rowHeader: string | null;
|
|
123
|
+
rows: FormTableRow[];
|
|
124
|
+
labels: FormTableLabels;
|
|
125
|
+
disabled: boolean;
|
|
126
|
+
/** `null` clears the cell. */
|
|
127
|
+
onChange: (rowId: string, columnKey: string, value: FormTableCellValue) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Present when the section names a yes/no column to select as a whole, for
|
|
130
|
+
* a checkbox in that column's header.
|
|
131
|
+
*/
|
|
132
|
+
selectAll: FormTableSelectAll | null;
|
|
133
|
+
/** Present when the user may add a row now. */
|
|
134
|
+
onAdd: (() => void) | null;
|
|
135
|
+
/** Present when the user may remove a row now. */
|
|
136
|
+
onRemove: ((rowId: string) => void) | null;
|
|
137
|
+
/** Present when rows can be dragged to a new position. */
|
|
138
|
+
onReorder: ((from: number, to: number) => void) | null;
|
|
139
|
+
}
|
package/dist/src/theme.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Multistep } from './multistep';
|
|
|
9
9
|
import { Oauth } from './oauth';
|
|
10
10
|
import { Pairing } from './pairing';
|
|
11
11
|
import { Assistant } from './assistant';
|
|
12
|
+
import { Table } from './table';
|
|
12
13
|
export declare const Templates: {
|
|
13
14
|
ArrayFieldItemButtonsTemplate: typeof ArrayFieldItemButtonsTemplate;
|
|
14
15
|
ArrayFieldItemTemplate: typeof ArrayFieldItemTemplate;
|
|
@@ -45,15 +46,17 @@ export declare const Widgets: {
|
|
|
45
46
|
/**
|
|
46
47
|
* `ThemeProps` plus the `multistep` components `FcodeJsonSchemaForm` uses to
|
|
47
48
|
* render a `ui:steps` form's navigation, the `oauth` control it uses for
|
|
48
|
-
* `ui:widget: "oauth"` fields
|
|
49
|
-
* `ui:field: "pairing"` objects,
|
|
50
|
-
* `ui:field: "launch-one"`.
|
|
49
|
+
* `ui:widget: "oauth"` fields, the `pairing` table it uses for
|
|
50
|
+
* `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
|
+
* RJSF itself ignores the extra keys.
|
|
51
53
|
*/
|
|
52
54
|
export type F0RjsfTheme = ThemeProps & {
|
|
53
55
|
multistep: typeof Multistep;
|
|
54
56
|
oauth: typeof Oauth;
|
|
55
57
|
pairing: typeof Pairing;
|
|
56
58
|
assistant: typeof Assistant;
|
|
59
|
+
table: typeof Table;
|
|
57
60
|
};
|
|
58
61
|
/**
|
|
59
62
|
* Builds the theme. Present for parity with the official RJSF theme packages,
|
package/dist/styles.css
CHANGED
|
@@ -1059,8 +1059,9 @@
|
|
|
1059
1059
|
|
|
1060
1060
|
/*
|
|
1061
1061
|
* The pairing table (`ui:field: "pairing"`): a header with the counts and the
|
|
1062
|
-
* bulk actions,
|
|
1063
|
-
* adds rows not
|
|
1062
|
+
* bulk actions, the package's own table (`.rjsf-f0-pairing-table`, or the
|
|
1063
|
+
* empty note in its place), and a footer with the select that adds rows not
|
|
1064
|
+
* listed beside the optional in-use note.
|
|
1064
1065
|
*/
|
|
1065
1066
|
/* `margin-top` parts the table from the section description above it. */
|
|
1066
1067
|
.rjsf-f0-pairing {
|
|
@@ -1183,6 +1184,13 @@
|
|
|
1183
1184
|
cursor: help;
|
|
1184
1185
|
}
|
|
1185
1186
|
|
|
1187
|
+
/* The hint takes focus so the keyboard opens its tooltip too. */
|
|
1188
|
+
.rjsf-f0-pairing-hint:focus-visible {
|
|
1189
|
+
outline: 2px solid hsl(var(--selected-50, 184 92% 35%));
|
|
1190
|
+
outline-offset: 1px;
|
|
1191
|
+
border-radius: 0.25rem;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1186
1194
|
.rjsf-f0-pairing-input {
|
|
1187
1195
|
flex: 1 1 auto;
|
|
1188
1196
|
min-width: 0;
|
|
@@ -1248,3 +1256,27 @@
|
|
|
1248
1256
|
outline-offset: 2px;
|
|
1249
1257
|
border-radius: 0.25rem;
|
|
1250
1258
|
}
|
|
1259
|
+
|
|
1260
|
+
/*
|
|
1261
|
+
* The table (`ui:field: "table"`): the f0 editable table, or a note while it
|
|
1262
|
+
* has no rows and none can be added.
|
|
1263
|
+
*/
|
|
1264
|
+
/* `margin-top` parts the table from the section description above it. */
|
|
1265
|
+
.rjsf-f0-table {
|
|
1266
|
+
margin-top: 0.75rem;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* The "select all" checkbox of a column, before the column's title. */
|
|
1270
|
+
.rjsf-f0-table-select-all {
|
|
1271
|
+
display: inline-flex;
|
|
1272
|
+
align-items: center;
|
|
1273
|
+
gap: 0.5rem;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/* f0's `text-base` in the secondary foreground colour. */
|
|
1277
|
+
.rjsf-f0-table-empty {
|
|
1278
|
+
margin: 0.75rem 0 0;
|
|
1279
|
+
font-size: 0.875rem;
|
|
1280
|
+
line-height: 1.25rem;
|
|
1281
|
+
color: hsl(var(--neutral-50, 217 96% 11% / 0.61));
|
|
1282
|
+
}
|
package/package.json
CHANGED