@panneau/forms 5.0.0-alpha.0 → 5.0.0-alpha.10
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 +11 -10
- package/dist/ConflictDialog.css +15 -10
- package/dist/ConflictDialog.js +201 -61
- package/dist/ConflictDialog.js.map +1 -1
- package/dist/ConflictDialog.module.js +11 -9
- package/dist/ConflictDialog.module.js.map +1 -1
- package/dist/ErrorSummary.js.map +1 -1
- package/dist/FieldErrorBoundary.js.map +1 -1
- package/dist/Form.css +52 -22
- package/dist/Form.d.ts +3 -2
- package/dist/Form.d.ts.map +1 -1
- package/dist/Form.js +122 -21
- package/dist/Form.js.map +1 -1
- package/dist/Form.module.js +29 -21
- package/dist/Form.module.js.map +1 -1
- package/dist/FormBinding.js.map +1 -1
- package/dist/FormSkeleton.d.ts +21 -0
- package/dist/FormSkeleton.d.ts.map +1 -0
- package/dist/FormSkeleton.js +402 -0
- package/dist/FormSkeleton.js.map +1 -0
- package/dist/FormView.d.ts +22 -3
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +234 -92
- package/dist/FormView.js.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/cx.js.map +1 -1
- package/dist/describe.js.map +1 -1
- package/dist/formatError.d.ts +2 -2
- package/dist/formatError.d.ts.map +1 -1
- package/dist/formatError.js +10 -2
- package/dist/formatError.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/layout/Layout.js.map +1 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/paths.js.map +1 -1
- package/dist/unsaved.js.map +1 -1
- package/package.json +9 -9
package/dist/Form.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.panneau-form
|
|
1
|
+
.panneau-form {
|
|
2
2
|
container: panneau-form / inline-size;
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -6,46 +6,46 @@
|
|
|
6
6
|
min-width: 0;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.panneau-layout
|
|
9
|
+
.panneau-form-layout {
|
|
10
10
|
display: grid;
|
|
11
11
|
gap: var(--panneau-space-6);
|
|
12
12
|
min-width: 0;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@container panneau-form (min-width: 56rem) {
|
|
16
|
-
.panneau-
|
|
16
|
+
.panneau-form-with-sidebar {
|
|
17
17
|
grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
|
|
18
18
|
align-items: start;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.panneau-stack
|
|
22
|
+
.panneau-form-stack {
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
25
25
|
gap: var(--panneau-space-5);
|
|
26
26
|
min-width: 0;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.panneau-row
|
|
29
|
+
.panneau-form-row {
|
|
30
30
|
display: grid;
|
|
31
31
|
grid-template-columns: repeat(12, minmax(0, 1fr));
|
|
32
32
|
gap: var(--panneau-space-5) var(--panneau-space-4);
|
|
33
33
|
min-width: 0;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.panneau-cell
|
|
36
|
+
.panneau-form-cell {
|
|
37
37
|
grid-column: span var(--panneau-span, 12);
|
|
38
38
|
min-width: 0;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/* Narrow containers (phones, side panels): every cell takes the full width. */
|
|
42
42
|
@container panneau-form (max-width: 36rem) {
|
|
43
|
-
.panneau-cell
|
|
43
|
+
.panneau-form-cell {
|
|
44
44
|
grid-column: 1 / -1;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.panneau-section
|
|
48
|
+
.panneau-form-section {
|
|
49
49
|
display: flex;
|
|
50
50
|
flex-direction: column;
|
|
51
51
|
gap: var(--panneau-space-4);
|
|
@@ -57,45 +57,51 @@
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
@container panneau-form (max-width: 36rem) {
|
|
60
|
-
.panneau-section
|
|
60
|
+
.panneau-form-section {
|
|
61
61
|
padding: var(--panneau-space-3);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.panneau-
|
|
65
|
+
.panneau-form-section-header {
|
|
66
66
|
display: flex;
|
|
67
67
|
flex-direction: column;
|
|
68
68
|
gap: var(--panneau-space-1);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.panneau-
|
|
71
|
+
.panneau-form-section-description {
|
|
72
|
+
margin: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.panneau-form-section-title {
|
|
72
76
|
display: flex;
|
|
73
77
|
align-items: center;
|
|
74
78
|
gap: var(--panneau-space-2);
|
|
75
79
|
font-size: var(--panneau-font-size-lg);
|
|
76
80
|
font-weight: var(--panneau-font-weight-bold);
|
|
77
81
|
line-height: var(--panneau-line-height-tight);
|
|
82
|
+
margin: 0;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
.panneau-
|
|
81
|
-
.panneau-text
|
|
85
|
+
.panneau-form-section-description,
|
|
86
|
+
.panneau-form-text {
|
|
82
87
|
font-size: var(--panneau-font-size-md);
|
|
83
88
|
color: var(--panneau-color-text-muted);
|
|
89
|
+
margin: 0;
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
.panneau-sidebar
|
|
92
|
+
.panneau-form-sidebar {
|
|
87
93
|
display: flex;
|
|
88
94
|
flex-direction: column;
|
|
89
95
|
gap: var(--panneau-space-5);
|
|
90
96
|
min-width: 0;
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
.panneau-field
|
|
99
|
+
.panneau-form-field {
|
|
94
100
|
min-width: 0;
|
|
95
101
|
scroll-margin: var(--panneau-space-10);
|
|
96
102
|
}
|
|
97
103
|
|
|
98
|
-
.panneau-footer
|
|
104
|
+
.panneau-form-footer {
|
|
99
105
|
position: sticky;
|
|
100
106
|
bottom: 0;
|
|
101
107
|
z-index: 1;
|
|
@@ -109,18 +115,18 @@
|
|
|
109
115
|
border-top: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
110
116
|
}
|
|
111
117
|
|
|
112
|
-
.panneau-dirty
|
|
118
|
+
.panneau-form-dirty {
|
|
113
119
|
margin-inline-end: auto;
|
|
114
120
|
font-size: var(--panneau-font-size-sm);
|
|
115
121
|
color: var(--panneau-color-text-muted);
|
|
116
122
|
}
|
|
117
123
|
|
|
118
|
-
.panneau-summary
|
|
124
|
+
.panneau-form-summary:focus {
|
|
119
125
|
outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
|
|
120
126
|
outline-offset: 2px;
|
|
121
127
|
}
|
|
122
128
|
|
|
123
|
-
.panneau-
|
|
129
|
+
.panneau-form-summary-list {
|
|
124
130
|
display: flex;
|
|
125
131
|
flex-direction: column;
|
|
126
132
|
gap: var(--panneau-space-1);
|
|
@@ -128,7 +134,7 @@
|
|
|
128
134
|
padding-inline-start: var(--panneau-space-5);
|
|
129
135
|
}
|
|
130
136
|
|
|
131
|
-
.panneau-
|
|
137
|
+
.panneau-form-summary-link {
|
|
132
138
|
padding: 0;
|
|
133
139
|
font: inherit;
|
|
134
140
|
color: inherit;
|
|
@@ -139,13 +145,37 @@
|
|
|
139
145
|
border: 0;
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
.panneau-
|
|
148
|
+
.panneau-form-summary-link:focus-visible {
|
|
143
149
|
outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
|
|
144
150
|
outline-offset: 2px;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
@container panneau-form (max-width: 36rem) {
|
|
148
|
-
.panneau-footer
|
|
154
|
+
.panneau-form-footer > :not(.panneau-form-dirty) {
|
|
149
155
|
flex: 1 1 auto;
|
|
150
156
|
}
|
|
151
157
|
}
|
|
158
|
+
|
|
159
|
+
/* The skeleton of a form whose values load. */
|
|
160
|
+
.panneau-form-skeleton-field {
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-direction: column;
|
|
163
|
+
gap: var(--panneau-space-1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.panneau-form-skeleton-inline {
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
gap: var(--panneau-space-2);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.panneau-form-skeleton-label {
|
|
173
|
+
font-size: var(--panneau-font-size-sm);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.panneau-form-skeleton-tabs {
|
|
177
|
+
display: flex;
|
|
178
|
+
gap: var(--panneau-space-5);
|
|
179
|
+
padding-block: var(--panneau-space-2);
|
|
180
|
+
border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
181
|
+
}
|
package/dist/Form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FormOptions } from '@panneau/core';
|
|
2
2
|
import type { Field, LayoutNode } from '@panneau/protocol';
|
|
3
|
-
import { type FormViewProps } from './FormView';
|
|
3
|
+
import { type FormViewProps } from './FormView.js';
|
|
4
4
|
export interface FormProps extends Omit<FormViewProps, 'form' | 'fields' | 'layout'>, Pick<FormOptions, 'values' | 'version' | 'mode' | 'store' | 'formatError' | 'onSubmit'> {
|
|
5
5
|
/** The fields of the form. Without a layout, they are rendered in order. */
|
|
6
6
|
fields: readonly Field[];
|
|
@@ -14,7 +14,8 @@ export interface FormProps extends Omit<FormViewProps, 'form' | 'fields' | 'layo
|
|
|
14
14
|
* translated with react-intl.
|
|
15
15
|
*
|
|
16
16
|
* Initial values and the version are read once: give the form a new `key` to start from another
|
|
17
|
-
* item, or use `useForm()` and `FormView`.
|
|
17
|
+
* item, or use `useForm()` and `FormView`. While the item loads, `isLoading` draws a skeleton of
|
|
18
|
+
* the form, and a new `key` once it is there starts the form from its values.
|
|
18
19
|
*/
|
|
19
20
|
export declare function Form({ fields, layout, values, version, mode, store, formatError, onSubmit, locales, ...props }: FormProps): import("react").JSX.Element;
|
|
20
21
|
//# sourceMappingURL=Form.d.ts.map
|
package/dist/Form.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../src/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,WAAW,SACb,SACI,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC,EACjD,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,CAAC;IAC3F,4EAA4E;IAC5E,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CAClC;AAED
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../src/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,WAAW,SACb,SACI,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC,EACjD,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,CAAC;IAC3F,4EAA4E;IAC5E,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,EACjB,MAAM,EACN,MAAW,EACX,MAAM,EACN,OAAO,EACP,IAAI,EACJ,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,GAAG,KAAK,EACX,EAAE,SAAS,+BA0BX"}
|
package/dist/Form.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FormView } from "./FormView.js";
|
|
2
2
|
import { useFormatRuleFailure } from "./formatError.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { resolveFields, useForm, usePanneau } from "@panneau/core";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/Form.tsx
|
|
@@ -10,30 +11,130 @@ import { jsx } from "react/jsx-runtime";
|
|
|
10
11
|
* translated with react-intl.
|
|
11
12
|
*
|
|
12
13
|
* Initial values and the version are read once: give the form a new `key` to start from another
|
|
13
|
-
* item, or use `useForm()` and `FormView`.
|
|
14
|
+
* item, or use `useForm()` and `FormView`. While the item loads, `isLoading` draws a skeleton of
|
|
15
|
+
* the form, and a new `key` once it is there starts the form from its values.
|
|
14
16
|
*/
|
|
15
|
-
function Form(
|
|
17
|
+
function Form(t0) {
|
|
18
|
+
const $ = c(39);
|
|
19
|
+
let fields;
|
|
20
|
+
let formatError;
|
|
21
|
+
let locales;
|
|
22
|
+
let mode;
|
|
23
|
+
let onSubmit;
|
|
24
|
+
let props;
|
|
25
|
+
let store;
|
|
26
|
+
let t1;
|
|
27
|
+
let values;
|
|
28
|
+
let version;
|
|
29
|
+
if ($[0] !== t0) {
|
|
30
|
+
({fields, layout: t1, values, version, mode, store, formatError, onSubmit, locales, ...props} = t0);
|
|
31
|
+
$[0] = t0;
|
|
32
|
+
$[1] = fields;
|
|
33
|
+
$[2] = formatError;
|
|
34
|
+
$[3] = locales;
|
|
35
|
+
$[4] = mode;
|
|
36
|
+
$[5] = onSubmit;
|
|
37
|
+
$[6] = props;
|
|
38
|
+
$[7] = store;
|
|
39
|
+
$[8] = t1;
|
|
40
|
+
$[9] = values;
|
|
41
|
+
$[10] = version;
|
|
42
|
+
} else {
|
|
43
|
+
fields = $[1];
|
|
44
|
+
formatError = $[2];
|
|
45
|
+
locales = $[3];
|
|
46
|
+
mode = $[4];
|
|
47
|
+
onSubmit = $[5];
|
|
48
|
+
props = $[6];
|
|
49
|
+
store = $[7];
|
|
50
|
+
t1 = $[8];
|
|
51
|
+
values = $[9];
|
|
52
|
+
version = $[10];
|
|
53
|
+
}
|
|
54
|
+
const layout = t1 === void 0 ? [] : t1;
|
|
16
55
|
const { definition } = usePanneau();
|
|
17
|
-
const
|
|
56
|
+
const formMode = mode ?? (version !== void 0 && version !== null ? "update" : "create");
|
|
57
|
+
const resolved = resolveFields(fields, layout, { mode: formMode });
|
|
18
58
|
const formatRuleFailure = useFormatRuleFailure(resolved.fields);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
59
|
+
let t2;
|
|
60
|
+
if ($[11] !== definition?.locales || $[12] !== locales) {
|
|
61
|
+
t2 = locales ?? definition?.locales ?? [];
|
|
62
|
+
$[11] = definition?.locales;
|
|
63
|
+
$[12] = locales;
|
|
64
|
+
$[13] = t2;
|
|
65
|
+
} else t2 = $[13];
|
|
66
|
+
const formLocales = t2;
|
|
67
|
+
let t3;
|
|
68
|
+
if ($[14] !== formLocales) {
|
|
69
|
+
t3 = [...formLocales];
|
|
70
|
+
$[14] = formLocales;
|
|
71
|
+
$[15] = t3;
|
|
72
|
+
} else t3 = $[15];
|
|
73
|
+
const t4 = formatError ?? formatRuleFailure;
|
|
74
|
+
let t5;
|
|
75
|
+
if ($[16] !== values) {
|
|
76
|
+
t5 = values !== void 0 ? { values } : {};
|
|
77
|
+
$[16] = values;
|
|
78
|
+
$[17] = t5;
|
|
79
|
+
} else t5 = $[17];
|
|
80
|
+
let t6;
|
|
81
|
+
if ($[18] !== version) {
|
|
82
|
+
t6 = version !== void 0 ? { version } : {};
|
|
83
|
+
$[18] = version;
|
|
84
|
+
$[19] = t6;
|
|
85
|
+
} else t6 = $[19];
|
|
86
|
+
let t7;
|
|
87
|
+
if ($[20] !== store) {
|
|
88
|
+
t7 = store !== void 0 ? { store } : {};
|
|
89
|
+
$[20] = store;
|
|
90
|
+
$[21] = t7;
|
|
91
|
+
} else t7 = $[21];
|
|
92
|
+
let t8;
|
|
93
|
+
if ($[22] !== onSubmit) {
|
|
94
|
+
t8 = onSubmit !== void 0 ? { onSubmit } : {};
|
|
95
|
+
$[22] = onSubmit;
|
|
96
|
+
$[23] = t8;
|
|
97
|
+
} else t8 = $[23];
|
|
98
|
+
let t9;
|
|
99
|
+
if ($[24] !== formMode || $[25] !== resolved.fields || $[26] !== t3 || $[27] !== t4 || $[28] !== t5 || $[29] !== t6 || $[30] !== t7 || $[31] !== t8) {
|
|
100
|
+
t9 = {
|
|
101
|
+
fields: resolved.fields,
|
|
102
|
+
locales: t3,
|
|
103
|
+
formatError: t4,
|
|
104
|
+
...t5,
|
|
105
|
+
...t6,
|
|
106
|
+
mode: formMode,
|
|
107
|
+
...t7,
|
|
108
|
+
...t8
|
|
109
|
+
};
|
|
110
|
+
$[24] = formMode;
|
|
111
|
+
$[25] = resolved.fields;
|
|
112
|
+
$[26] = t3;
|
|
113
|
+
$[27] = t4;
|
|
114
|
+
$[28] = t5;
|
|
115
|
+
$[29] = t6;
|
|
116
|
+
$[30] = t7;
|
|
117
|
+
$[31] = t8;
|
|
118
|
+
$[32] = t9;
|
|
119
|
+
} else t9 = $[32];
|
|
120
|
+
const { form } = useForm(t9);
|
|
121
|
+
let t10;
|
|
122
|
+
if ($[33] !== form || $[34] !== formLocales || $[35] !== props || $[36] !== resolved.fields || $[37] !== resolved.layout) {
|
|
123
|
+
t10 = /* @__PURE__ */ jsx(FormView, {
|
|
124
|
+
...props,
|
|
125
|
+
form,
|
|
126
|
+
fields: resolved.fields,
|
|
127
|
+
layout: resolved.layout,
|
|
128
|
+
locales: formLocales
|
|
129
|
+
});
|
|
130
|
+
$[33] = form;
|
|
131
|
+
$[34] = formLocales;
|
|
132
|
+
$[35] = props;
|
|
133
|
+
$[36] = resolved.fields;
|
|
134
|
+
$[37] = resolved.layout;
|
|
135
|
+
$[38] = t10;
|
|
136
|
+
} else t10 = $[38];
|
|
137
|
+
return t10;
|
|
37
138
|
}
|
|
38
139
|
//#endregion
|
|
39
140
|
export { Form };
|
package/dist/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","names":[],"sources":["../src/Form.tsx"],"sourcesContent":["import { type FormOptions, resolveFields, useForm, usePanneau } from '@panneau/core';\nimport type { Field, LayoutNode } from '@panneau/protocol';\n\nimport { FormView, type FormViewProps } from './FormView';\nimport { useFormatRuleFailure } from './formatError';\n\nexport interface FormProps\n extends\n Omit<FormViewProps, 'form' | 'fields' | 'layout'>,\n Pick<FormOptions, 'values' | 'version' | 'mode' | 'store' | 'formatError' | 'onSubmit'> {\n /** The fields of the form. Without a layout, they are rendered in order. */\n fields: readonly Field[];\n /** The layout tree. Fields that no node references are added at the end. */\n layout?: readonly LayoutNode[];\n}\n\n/**\n * A form from a list of fields and an `onSubmit`, with or without a definition. It creates its\n * state with `useForm()` of `@panneau/core`: values, validation with the portable rules, server\n * errors (`422`) and version conflicts (`412`) from what `onSubmit` throws. Rule messages are\n * translated with react-intl.\n *\n * Initial values and the version are read once: give the form a new `key` to start from another\n * item, or use `useForm()` and `FormView
|
|
1
|
+
{"version":3,"file":"Form.js","names":["FormOptions","resolveFields","useForm","usePanneau","Field","LayoutNode","FormView","FormViewProps","useFormatRuleFailure","FormProps","Omit","Pick","fields","layout","Form","t0","$","_c","formatError","locales","mode","onSubmit","props","store","t1","values","version","undefined","definition","formMode","resolved","formatRuleFailure","t2","formLocales","t3","t4","t5","t6","t7","t8","t9","form","t10","_c"],"sources":["../src/Form.tsx"],"sourcesContent":["import { type FormOptions, resolveFields, useForm, usePanneau } from '@panneau/core';\nimport type { Field, LayoutNode } from '@panneau/protocol';\n\nimport { FormView, type FormViewProps } from './FormView';\nimport { useFormatRuleFailure } from './formatError';\n\nexport interface FormProps\n extends\n Omit<FormViewProps, 'form' | 'fields' | 'layout'>,\n Pick<FormOptions, 'values' | 'version' | 'mode' | 'store' | 'formatError' | 'onSubmit'> {\n /** The fields of the form. Without a layout, they are rendered in order. */\n fields: readonly Field[];\n /** The layout tree. Fields that no node references are added at the end. */\n layout?: readonly LayoutNode[];\n}\n\n/**\n * A form from a list of fields and an `onSubmit`, with or without a definition. It creates its\n * state with `useForm()` of `@panneau/core`: values, validation with the portable rules, server\n * errors (`422`) and version conflicts (`412`) from what `onSubmit` throws. Rule messages are\n * translated with react-intl.\n *\n * Initial values and the version are read once: give the form a new `key` to start from another\n * item, or use `useForm()` and `FormView`. While the item loads, `isLoading` draws a skeleton of\n * the form, and a new `key` once it is there starts the form from its values.\n */\nexport function Form({\n fields,\n layout = [],\n values,\n version,\n mode,\n store,\n formatError,\n onSubmit,\n locales,\n ...props\n}: FormProps) {\n const { definition } = usePanneau();\n // The mode `useForm()` would infer: rules limited to a mode are resolved in it\n const formMode = mode ?? (version !== undefined && version !== null ? 'update' : 'create');\n const resolved = resolveFields(fields, layout, { mode: formMode });\n const formatRuleFailure = useFormatRuleFailure(resolved.fields);\n const formLocales = locales ?? definition?.locales ?? [];\n const { form } = useForm({\n fields: resolved.fields,\n locales: [...formLocales],\n formatError: formatError ?? formatRuleFailure,\n ...(values !== undefined ? { values } : {}),\n ...(version !== undefined ? { version } : {}),\n mode: formMode,\n ...(store !== undefined ? { store } : {}),\n ...(onSubmit !== undefined ? { onSubmit } : {}),\n });\n return (\n <FormView\n {...props}\n form={form}\n fields={resolved.fields}\n lay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AA,QAAAuB,IAAA;EARzBC,KAAA;GAAA5B,QACbkB,SAAQlB;GAAOO,SACde;GAAgBhB,aACZiB;GAAgC,GACzCC;GAAsC,GACtCC;GAAwCjB,MACtCS;GAAQ,GACVS;GAAoC,GACpCC;EACR;EAACvB,EAAA,MAAAa;EAAAb,EAAA,MAAAc,SAAAlB;EAAAI,EAAA,MAAAkB;EAAAlB,EAAA,MAAAmB;EAAAnB,EAAA,MAAAoB;EAAApB,EAAA,MAAAqB;EAAArB,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;EAAAvB,EAAA,MAAAwB;CAAA,OAAAA,KAAAxB,EAAA;CATD,MAAA,EAAAyB,SAAiBvC,QAAQsC,EASxB;CAAE,IAAAE;CAAA,IAAA1B,EAAA,QAAAyB,QAAAzB,EAAA,QAAAiB,eAAAjB,EAAA,QAAAM,SAAAN,EAAA,QAAAc,SAAAlB,UAAAI,EAAA,QAAAc,SAAAjB,QAAA;EAEC6B,MAAA,oBAAC,UAAD;GAAS,GACDpB;GACEmB;GACE,QAAAX,SAAQlB;GACR,QAAAkB,SAAQjB;GACPoB,SAAAA;EAAW,CAAA;EACtBjB,EAAA,MAAAyB;EAAAzB,EAAA,MAAAiB;EAAAjB,EAAA,MAAAM;EAAAN,EAAA,MAAAc,SAAAlB;EAAAI,EAAA,MAAAc,SAAAjB;EAAAG,EAAA,MAAA0B;CAAA,OAAAA,MAAA1B,EAAA;CAAA,OANF0B;AAME"}
|
package/dist/Form.module.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import "./Form.css";
|
|
2
2
|
//#region src/Form.module.css
|
|
3
|
-
var form = "panneau-form
|
|
4
|
-
var layout = "panneau-layout
|
|
5
|
-
var withSidebar = "panneau-
|
|
6
|
-
var stack = "panneau-stack
|
|
7
|
-
var row = "panneau-row
|
|
8
|
-
var cell = "panneau-cell
|
|
9
|
-
var section = "panneau-section
|
|
10
|
-
var sectionHeader = "panneau-
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var text = "panneau-text
|
|
14
|
-
var sidebar = "panneau-sidebar
|
|
15
|
-
var field = "panneau-field
|
|
16
|
-
var footer = "panneau-footer
|
|
17
|
-
var dirty = "panneau-dirty
|
|
18
|
-
var summary = "panneau-summary
|
|
19
|
-
var summaryList = "panneau-
|
|
20
|
-
var summaryLink = "panneau-
|
|
3
|
+
var form = "panneau-form";
|
|
4
|
+
var layout = "panneau-form-layout";
|
|
5
|
+
var withSidebar = "panneau-form-with-sidebar";
|
|
6
|
+
var stack = "panneau-form-stack";
|
|
7
|
+
var row = "panneau-form-row";
|
|
8
|
+
var cell = "panneau-form-cell";
|
|
9
|
+
var section = "panneau-form-section";
|
|
10
|
+
var sectionHeader = "panneau-form-section-header";
|
|
11
|
+
var sectionDescription = "panneau-form-section-description";
|
|
12
|
+
var sectionTitle = "panneau-form-section-title";
|
|
13
|
+
var text = "panneau-form-text";
|
|
14
|
+
var sidebar = "panneau-form-sidebar";
|
|
15
|
+
var field = "panneau-form-field";
|
|
16
|
+
var footer = "panneau-form-footer";
|
|
17
|
+
var dirty = "panneau-form-dirty";
|
|
18
|
+
var summary = "panneau-form-summary";
|
|
19
|
+
var summaryList = "panneau-form-summary-list";
|
|
20
|
+
var summaryLink = "panneau-form-summary-link";
|
|
21
|
+
var skeletonField = "panneau-form-skeleton-field";
|
|
22
|
+
var skeletonInline = "panneau-form-skeleton-inline";
|
|
23
|
+
var skeletonLabel = "panneau-form-skeleton-label";
|
|
24
|
+
var skeletonTabs = "panneau-form-skeleton-tabs";
|
|
21
25
|
var Form_module_default = {
|
|
22
26
|
form,
|
|
23
27
|
layout,
|
|
@@ -27,8 +31,8 @@ var Form_module_default = {
|
|
|
27
31
|
cell,
|
|
28
32
|
section,
|
|
29
33
|
sectionHeader,
|
|
30
|
-
sectionTitle,
|
|
31
34
|
sectionDescription,
|
|
35
|
+
sectionTitle,
|
|
32
36
|
text,
|
|
33
37
|
sidebar,
|
|
34
38
|
field,
|
|
@@ -36,9 +40,13 @@ var Form_module_default = {
|
|
|
36
40
|
dirty,
|
|
37
41
|
summary,
|
|
38
42
|
summaryList,
|
|
39
|
-
summaryLink
|
|
43
|
+
summaryLink,
|
|
44
|
+
skeletonField,
|
|
45
|
+
skeletonInline,
|
|
46
|
+
skeletonLabel,
|
|
47
|
+
skeletonTabs
|
|
40
48
|
};
|
|
41
49
|
//#endregion
|
|
42
|
-
export { cell, Form_module_default as default, dirty, field, footer, form, layout, row, section, sectionDescription, sectionHeader, sectionTitle, sidebar, stack, summary, summaryLink, summaryList, text, withSidebar };
|
|
50
|
+
export { cell, Form_module_default as default, dirty, field, footer, form, layout, row, section, sectionDescription, sectionHeader, sectionTitle, sidebar, skeletonField, skeletonInline, skeletonLabel, skeletonTabs, stack, summary, summaryLink, summaryList, text, withSidebar };
|
|
43
51
|
|
|
44
52
|
//# sourceMappingURL=Form.module.js.map
|
package/dist/Form.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.module.js","names":[],"sources":["../src/Form.module.css"],"sourcesContent":[".form {\n container: panneau-form / inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n.layout {\n display: grid;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n@container panneau-form (min-width: 56rem) {\n .withSidebar {\n grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);\n align-items: start;\n }\n}\n\n.stack {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.row {\n display: grid;\n grid-template-columns: repeat(12, minmax(0, 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.cell {\n grid-column: span var(--panneau-span, 12);\n min-width: 0;\n}\n\n/* Narrow containers (phones, side panels): every cell takes the full width. */\n@container panneau-form (max-width: 36rem) {\n .cell {\n grid-column: 1 / -1;\n }\n}\n\n.section {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-4);\n min-width: 0;\n padding: var(--panneau-space-4) var(--panneau-space-5);\n background-color: var(--panneau-color-surface);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n}\n\n@container panneau-form (max-width: 36rem) {\n .section {\n padding: var(--panneau-space-3);\n }\n}\n\n.sectionHeader {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n}\n\n.sectionTitle {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n font-size: var(--panneau-font-size-lg);\n font-weight: var(--panneau-font-weight-bold);\n line-height: var(--panneau-line-height-tight);\n}\n\n.sectionDescription,\n.text {\n font-size: var(--panneau-font-size-md);\n color: var(--panneau-color-text-muted);\n}\n\n.sidebar {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.field {\n min-width: 0;\n scroll-margin: var(--panneau-space-10);\n}\n\n.footer {\n position: sticky;\n bottom: 0;\n z-index: 1;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--panneau-space-2) var(--panneau-space-3);\n padding: var(--panneau-space-3) 0;\n background-color: var(--panneau-color-bg);\n border-top: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.dirty {\n margin-inline-end: auto;\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.summary:focus {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n.summaryList {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n margin: 0;\n padding-inline-start: var(--panneau-space-5);\n}\n\n.summaryLink {\n padding: 0;\n font: inherit;\n color: inherit;\n text-align: start;\n text-decoration: underline;\n cursor: pointer;\n background: none;\n border: 0;\n}\n\n.summaryLink:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n@container panneau-form (max-width: 36rem) {\n .footer > :not(.dirty) {\n flex: 1 1 auto;\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Form.module.js","names":[],"sources":["../src/Form.module.css"],"sourcesContent":[".form {\n container: panneau-form / inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n.layout {\n display: grid;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n@container panneau-form (min-width: 56rem) {\n .withSidebar {\n grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);\n align-items: start;\n }\n}\n\n.stack {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.row {\n display: grid;\n grid-template-columns: repeat(12, minmax(0, 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.cell {\n grid-column: span var(--panneau-span, 12);\n min-width: 0;\n}\n\n/* Narrow containers (phones, side panels): every cell takes the full width. */\n@container panneau-form (max-width: 36rem) {\n .cell {\n grid-column: 1 / -1;\n }\n}\n\n.section {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-4);\n min-width: 0;\n padding: var(--panneau-space-4) var(--panneau-space-5);\n background-color: var(--panneau-color-surface);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n}\n\n@container panneau-form (max-width: 36rem) {\n .section {\n padding: var(--panneau-space-3);\n }\n}\n\n.sectionHeader {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n}\n\n.sectionDescription {\n margin: 0;\n}\n\n.sectionTitle {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n font-size: var(--panneau-font-size-lg);\n font-weight: var(--panneau-font-weight-bold);\n line-height: var(--panneau-line-height-tight);\n margin: 0;\n}\n\n.sectionDescription,\n.text {\n font-size: var(--panneau-font-size-md);\n color: var(--panneau-color-text-muted);\n margin: 0;\n}\n\n.sidebar {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.field {\n min-width: 0;\n scroll-margin: var(--panneau-space-10);\n}\n\n.footer {\n position: sticky;\n bottom: 0;\n z-index: 1;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--panneau-space-2) var(--panneau-space-3);\n padding: var(--panneau-space-3) 0;\n background-color: var(--panneau-color-bg);\n border-top: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.dirty {\n margin-inline-end: auto;\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.summary:focus {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n.summaryList {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n margin: 0;\n padding-inline-start: var(--panneau-space-5);\n}\n\n.summaryLink {\n padding: 0;\n font: inherit;\n color: inherit;\n text-align: start;\n text-decoration: underline;\n cursor: pointer;\n background: none;\n border: 0;\n}\n\n.summaryLink:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n@container panneau-form (max-width: 36rem) {\n .footer > :not(.dirty) {\n flex: 1 1 auto;\n }\n}\n\n/* The skeleton of a form whose values load. */\n.skeletonField {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n}\n\n.skeletonInline {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n}\n\n.skeletonLabel {\n font-size: var(--panneau-font-size-sm);\n}\n\n.skeletonTabs {\n display: flex;\n gap: var(--panneau-space-5);\n padding-block: var(--panneau-space-2);\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n"],"mappings":""}
|
package/dist/FormBinding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBinding.js","names":["path","retry","_c","styles"],"sources":["../src/FormBinding.tsx"],"sourcesContent":["import { selectErrors, selectValue, selectVisible } from '@panneau/core';\nimport type { FieldBindingProps } from '@panneau/fields';\nimport { Alert, Button, usePanneauIntl } from '@panneau/ui';\n\nimport { FieldErrorBoundary } from './FieldErrorBoundary';\nimport styles from './Form.module.css';\nimport { useFormContext, useFormState } from './context';\nimport { messages } from './messages';\n\n/** Fields that show the errors of their nested fields themselves. */\nfunction rendersNestedFields(field: FieldBindingProps['field']): boolean {\n return field.localized === true || field.type === 'group' || field.type === 'repeater';\n}\n\n/**\n * Binds a field to the form by path: value, change, blur and errors. It hides fields whose\n * `visibleWhen` is false, marks the field's element with its path for the error summary, and\n * keeps a field that throws from breaking the form.\n */\nexport function FormBinding({ field, path, parentPath, render }: FieldBindingProps) {\n const form = useFormContext();\n const intl = usePanneauIntl();\n const state = useFormState(form);\n if (!selectVisible(state, field, parentPath)) {\n return null;\n }\n const errors = selectErrors(state, path, { nested: !rendersNestedFields(field) });\n return (\n <div className={styles.field} data-panneau-path={path}>\n <FieldErrorBoundary\n fallback={(retry) => (\n <Alert\n tone=\"danger\"\n actions={\n <Button size=\"sm\" onPress={retry}>\n {intl.formatMessage(messages.retry)}\n </Button>\n }\n >\n {intl.formatMessage(messages.fieldCrashed, {\n field: field.label ?? field.name,\n })}\n </Alert>\n )}\n >\n {render({\n value: selectValue(state, path),\n onChange: (value) => form.setValue(path, value),\n onBlur: () => form.blur(path),\n errors,\n })}\n </FieldErrorBoundary>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAUA,
|
|
1
|
+
{"version":3,"file":"FormBinding.js","names":["selectErrors","selectValue","selectVisible","FieldBindingProps","Alert","Button","usePanneauIntl","FieldErrorBoundary","styles","useFormContext","useFormState","messages","rendersNestedFields","field","localized","type","FormBinding","t0","$","_c","path","parentPath","render","form","intl","state","T0","t1","t2","t3","t4","t5","errors","nested","label","name","retry","formatMessage","fieldCrashed","t6","t7","value","setValue","blur","onChange","onBlur","_c","styles"],"sources":["../src/FormBinding.tsx"],"sourcesContent":["import { selectErrors, selectValue, selectVisible } from '@panneau/core';\nimport type { FieldBindingProps } from '@panneau/fields';\nimport { Alert, Button, usePanneauIntl } from '@panneau/ui';\n\nimport { FieldErrorBoundary } from './FieldErrorBoundary';\nimport styles from './Form.module.css';\nimport { useFormContext, useFormState } from './context';\nimport { messages } from './messages';\n\n/** Fields that show the errors of their nested fields themselves. */\nfunction rendersNestedFields(field: FieldBindingProps['field']): boolean {\n return field.localized === true || field.type === 'group' || field.type === 'repeater';\n}\n\n/**\n * Binds a field to the form by path: value, change, blur and errors. It hides fields whose\n * `visibleWhen` is false, marks the field's element with its path for the error summary, and\n * keeps a field that throws from breaking the form.\n */\nexport function FormBinding({ field, path, parentPath, render }: FieldBindingProps) {\n const form = useFormContext();\n const intl = usePanneauIntl();\n const state = useFormState(form);\n if (!selectVisible(state, field, parentPath)) {\n return null;\n }\n const errors = selectErrors(state, path, { nested: !rendersNestedFields(field) });\n return (\n <div className={styles.field} data-panneau-path={path}>\n <FieldErrorBoundary\n fallback={(retry) => (\n <Alert\n tone=\"danger\"\n actions={\n <Button size=\"sm\" onPress={retry}>\n {intl.formatMessage(messages.retry)}\n </Button>\n }\n >\n {intl.formatMessage(messages.fieldCrashed, {\n field: field.label ?? field.name,\n })}\n </Alert>\n )}\n >\n {render({\n value: selectValue(state, path),\n onChange: (value) => form.setValue(path, value),\n onBlur: () => form.blur(path),\n errors,\n })}\n </FieldErrorBoundary>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAUA,SAASY,oBAAoBC,OAA4C;CACrE,OAAOA,MAAMC,cAAc,QAAQD,MAAME,SAAS,WAAWF,MAAME,SAAS;AAChF;;;;;;AAOA,SAAOC,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqB,MAAA,EAAAN,OAAAO,MAAAC,YAAAC,WAAAL;CACxB,MAAAM,OAAad,eAAe;CAC5B,MAAAe,OAAalB,eAAe;CAC5B,MAAAmB,QAAcf,aAAaa,IAAI;CAC/B,IAAI,CAACrB,cAAcuB,OAAOZ,OAAOQ,UAAU,GAAC,OACjC;CACV,IAAAK;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAA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;EAHhCU,KAAAN,OAAO;GAAAmB,OACGxC,YAAYwB,OAAOL,IAAI;GAACwB,UACrBL;GAAqCM,QACvCL;GAAqBR;EAEjC,CAAC;EAACd,EAAA,KAAAL;EAAAK,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;EAAAT,EAAA,KAAAU;EAAAV,EAAA,KAAAW;EAAAX,EAAA,MAAAY;CAAA,OAAA;EAAAJ,KAAAR,EAAA;EAAAS,KAAAT,EAAA;EAAAU,KAAAV,EAAA;EAAAW,KAAAX,EAAA;EAAAY,KAAAZ,EAAA;CAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAQ,MAAAR,EAAA,QAAAS,MAAAT,EAAA,QAAAU,IAAA;EArBNG,KAAA,oBAAC,IAAD;GACc,UAAAJ;GAeTC,UAAAA;EAhBc,CAAA;EAsBEV,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,IAAAqB;CAAA,IAAArB,EAAA,QAAAW,MAAAX,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,IAAA;EAvBzBQ,KAAA,oBAAA,OAAA;GAAgB,WAAAV;GAAiCT,qBAAAA;GAC7CW,UAAAA;EAuBE,CAAA;EAAAb,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,OAxBNqB;AAwBM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Field, LayoutNode } from '@panneau/protocol';
|
|
2
|
+
export interface FormSkeletonProps {
|
|
3
|
+
/** The main nodes of the layout, resolved: every field has a node. */
|
|
4
|
+
main: readonly LayoutNode[];
|
|
5
|
+
/** The sidebars of the layout. */
|
|
6
|
+
sidebar: readonly LayoutNode[];
|
|
7
|
+
fields: ReadonlyMap<string, Field>;
|
|
8
|
+
/** Draws the footer, with its button. */
|
|
9
|
+
footer: boolean;
|
|
10
|
+
className?: string | undefined;
|
|
11
|
+
layoutClassName?: string | undefined;
|
|
12
|
+
sidebarClassName?: string | undefined;
|
|
13
|
+
footerClassName?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A form whose values load (decision 0034): its layout, and for each field its label and a block
|
|
17
|
+
* of the field's height, from its type. The fields of the first tab are drawn, and conditions are
|
|
18
|
+
* not checked, since there are no values yet.
|
|
19
|
+
*/
|
|
20
|
+
export declare function FormSkeleton({ main, sidebar, fields, footer, className, layoutClassName, sidebarClassName, footerClassName, }: FormSkeletonProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=FormSkeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSkeleton.d.ts","sourceRoot":"","sources":["../src/FormSkeleton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA8H3D,MAAM,WAAW,iBAAiB;IAC9B,sEAAsE;IACtE,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5B,kCAAkC;IAClC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EACzB,IAAI,EACJ,OAAO,EACP,MAAM,EACN,MAAM,EACN,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,eAAe,GAClB,EAAE,iBAAiB,+BAkCnB"}
|