@panneau/forms 5.0.0-alpha.17 → 5.0.0-alpha.19
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 +2 -1
- package/dist/Form.css +10 -2
- package/dist/Form.module.js +5 -3
- package/dist/Form.module.js.map +1 -1
- package/dist/FormBinding.d.ts.map +1 -1
- package/dist/FormBinding.js +5 -8
- package/dist/FormBinding.js.map +1 -1
- package/dist/FormSkeleton.d.ts.map +1 -1
- package/dist/FormSkeleton.js +0 -1
- package/dist/FormSkeleton.js.map +1 -1
- package/dist/FormView.d.ts +15 -2
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +221 -182
- package/dist/FormView.js.map +1 -1
- package/dist/context.d.ts +7 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +8 -2
- package/dist/context.js.map +1 -1
- package/dist/formatError.d.ts.map +1 -1
- package/dist/formatError.js +2 -2
- package/dist/formatError.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/layout/Layout.d.ts +10 -0
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +126 -86
- package/dist/layout/Layout.js.map +1 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +2 -1
- package/dist/paths.js.map +1 -1
- package/dist/publication/Publication.d.ts +33 -0
- package/dist/publication/Publication.d.ts.map +1 -0
- package/dist/publication/Publication.js +218 -0
- package/dist/publication/Publication.js.map +1 -0
- package/dist/publication/index.d.ts +3 -0
- package/dist/publication/index.d.ts.map +1 -0
- package/dist/publication/index.js +1 -0
- package/package.json +14 -7
package/dist/layout/Layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { messages } from "../messages.js";
|
|
2
2
|
import Form_module_default from "../Form.module.js";
|
|
3
|
-
import { RevealContext, useFormContext, useFormState } from "../context.js";
|
|
3
|
+
import { ErrorSectionsContext, RevealContext, useFormContext, useFormState } from "../context.js";
|
|
4
4
|
import { cx } from "../cx.js";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { getLayoutFieldNames, selectErrorCount, selectVisible, usePlugins } from "@panneau/core";
|
|
@@ -109,10 +109,11 @@ function _temp(tab) {
|
|
|
109
109
|
return getLayoutFieldNames(tab.children ?? []);
|
|
110
110
|
}
|
|
111
111
|
function SectionNode(t0) {
|
|
112
|
-
const $ = c(
|
|
112
|
+
const $ = c(38);
|
|
113
113
|
const { node, fields } = t0;
|
|
114
114
|
const form = useFormContext();
|
|
115
115
|
const registry = use(RevealContext);
|
|
116
|
+
const errorSections = use(ErrorSectionsContext);
|
|
116
117
|
const titleId = useId();
|
|
117
118
|
let t1;
|
|
118
119
|
if ($[0] !== node.children) {
|
|
@@ -130,37 +131,50 @@ function SectionNode(t0) {
|
|
|
130
131
|
const [expanded, setExpanded] = useState(node.collapsed !== true);
|
|
131
132
|
let t3;
|
|
132
133
|
let t4;
|
|
133
|
-
if ($[4] !==
|
|
134
|
-
t3 = () =>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
if ($[4] !== errorSections || $[5] !== names || $[6] !== registry) {
|
|
135
|
+
t3 = () => {
|
|
136
|
+
const open = (path) => {
|
|
137
|
+
if (containsPath(names, path)) setExpanded(true);
|
|
138
|
+
};
|
|
139
|
+
const removeRevealer = registry.add(open);
|
|
140
|
+
const removeOpener = errorSections.add(open);
|
|
141
|
+
return () => {
|
|
142
|
+
removeRevealer();
|
|
143
|
+
removeOpener();
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
t4 = [
|
|
147
|
+
registry,
|
|
148
|
+
errorSections,
|
|
149
|
+
names
|
|
150
|
+
];
|
|
151
|
+
$[4] = errorSections;
|
|
152
|
+
$[5] = names;
|
|
153
|
+
$[6] = registry;
|
|
154
|
+
$[7] = t3;
|
|
155
|
+
$[8] = t4;
|
|
142
156
|
} else {
|
|
143
|
-
t3 = $[
|
|
144
|
-
t4 = $[
|
|
157
|
+
t3 = $[7];
|
|
158
|
+
t4 = $[8];
|
|
145
159
|
}
|
|
146
160
|
useEffect(t3, t4);
|
|
147
161
|
let t5;
|
|
148
|
-
if ($[
|
|
162
|
+
if ($[9] !== node.description) {
|
|
149
163
|
t5 = node.description !== void 0 ? /* @__PURE__ */ jsx("p", {
|
|
150
164
|
className: Form_module_default.sectionDescription,
|
|
151
165
|
children: node.description
|
|
152
166
|
}) : null;
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
} else t5 = $[
|
|
167
|
+
$[9] = node.description;
|
|
168
|
+
$[10] = t5;
|
|
169
|
+
} else t5 = $[10];
|
|
156
170
|
let t6;
|
|
157
|
-
if ($[
|
|
171
|
+
if ($[11] !== node.children) {
|
|
158
172
|
t6 = node.children ?? [];
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
} else t6 = $[
|
|
173
|
+
$[11] = node.children;
|
|
174
|
+
$[12] = t6;
|
|
175
|
+
} else t6 = $[12];
|
|
162
176
|
let t7;
|
|
163
|
-
if ($[
|
|
177
|
+
if ($[13] !== fields || $[14] !== t6) {
|
|
164
178
|
t7 = /* @__PURE__ */ jsx("div", {
|
|
165
179
|
className: Form_module_default.stack,
|
|
166
180
|
children: /* @__PURE__ */ jsx(LayoutNodes, {
|
|
@@ -168,40 +182,40 @@ function SectionNode(t0) {
|
|
|
168
182
|
fields
|
|
169
183
|
})
|
|
170
184
|
});
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
} else t7 = $[
|
|
185
|
+
$[13] = fields;
|
|
186
|
+
$[14] = t6;
|
|
187
|
+
$[15] = t7;
|
|
188
|
+
} else t7 = $[15];
|
|
175
189
|
let t8;
|
|
176
|
-
if ($[
|
|
190
|
+
if ($[16] !== t5 || $[17] !== t7) {
|
|
177
191
|
t8 = /* @__PURE__ */ jsxs(Fragment, { children: [t5, t7] });
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
} else t8 = $[
|
|
192
|
+
$[16] = t5;
|
|
193
|
+
$[17] = t7;
|
|
194
|
+
$[18] = t8;
|
|
195
|
+
} else t8 = $[18];
|
|
182
196
|
const content = t8;
|
|
183
197
|
if (node.collapsible === true) {
|
|
184
198
|
let t9;
|
|
185
|
-
if ($[
|
|
199
|
+
if ($[19] !== form || $[20] !== names) {
|
|
186
200
|
t9 = /* @__PURE__ */ jsx(ErrorBadge, {
|
|
187
201
|
form,
|
|
188
202
|
names
|
|
189
203
|
});
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
} else t9 = $[
|
|
204
|
+
$[19] = form;
|
|
205
|
+
$[20] = names;
|
|
206
|
+
$[21] = t9;
|
|
207
|
+
} else t9 = $[21];
|
|
194
208
|
let t10;
|
|
195
|
-
if ($[
|
|
209
|
+
if ($[22] !== content) {
|
|
196
210
|
t10 = /* @__PURE__ */ jsx("div", {
|
|
197
211
|
className: Form_module_default.stack,
|
|
198
212
|
children: content
|
|
199
213
|
});
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
} else t10 = $[
|
|
214
|
+
$[22] = content;
|
|
215
|
+
$[23] = t10;
|
|
216
|
+
} else t10 = $[23];
|
|
203
217
|
let t11;
|
|
204
|
-
if ($[
|
|
218
|
+
if ($[24] !== expanded || $[25] !== node.label || $[26] !== t10 || $[27] !== t9) {
|
|
205
219
|
t11 = /* @__PURE__ */ jsx("div", {
|
|
206
220
|
className: Form_module_default.section,
|
|
207
221
|
children: /* @__PURE__ */ jsx(Disclosure, {
|
|
@@ -212,17 +226,17 @@ function SectionNode(t0) {
|
|
|
212
226
|
children: t10
|
|
213
227
|
})
|
|
214
228
|
});
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
} else t11 = $[
|
|
229
|
+
$[24] = expanded;
|
|
230
|
+
$[25] = node.label;
|
|
231
|
+
$[26] = t10;
|
|
232
|
+
$[27] = t9;
|
|
233
|
+
$[28] = t11;
|
|
234
|
+
} else t11 = $[28];
|
|
221
235
|
return t11;
|
|
222
236
|
}
|
|
223
237
|
const t9 = node.label !== void 0 ? titleId : void 0;
|
|
224
238
|
let t10;
|
|
225
|
-
if ($[
|
|
239
|
+
if ($[29] !== form || $[30] !== names || $[31] !== node.label || $[32] !== titleId) {
|
|
226
240
|
t10 = node.label !== void 0 ? /* @__PURE__ */ jsx("div", {
|
|
227
241
|
className: Form_module_default.sectionHeader,
|
|
228
242
|
children: /* @__PURE__ */ jsxs("h3", {
|
|
@@ -238,61 +252,83 @@ function SectionNode(t0) {
|
|
|
238
252
|
]
|
|
239
253
|
})
|
|
240
254
|
}) : null;
|
|
241
|
-
$[
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
} else t10 = $[
|
|
255
|
+
$[29] = form;
|
|
256
|
+
$[30] = names;
|
|
257
|
+
$[31] = node.label;
|
|
258
|
+
$[32] = titleId;
|
|
259
|
+
$[33] = t10;
|
|
260
|
+
} else t10 = $[33];
|
|
247
261
|
let t11;
|
|
248
|
-
if ($[
|
|
262
|
+
if ($[34] !== content || $[35] !== t10 || $[36] !== t9) {
|
|
249
263
|
t11 = /* @__PURE__ */ jsxs("section", {
|
|
250
264
|
className: Form_module_default.section,
|
|
251
265
|
"aria-labelledby": t9,
|
|
252
266
|
children: [t10, content]
|
|
253
267
|
});
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
258
|
-
} else t11 = $[
|
|
268
|
+
$[34] = content;
|
|
269
|
+
$[35] = t10;
|
|
270
|
+
$[36] = t9;
|
|
271
|
+
$[37] = t11;
|
|
272
|
+
} else t11 = $[37];
|
|
259
273
|
return t11;
|
|
260
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* A `component` node: the plugin's component, with the node's children rendered. Without the
|
|
277
|
+
* plugin, the children show as in a column, so that the fields the node frames stay in the form
|
|
278
|
+
* (decision 0065).
|
|
279
|
+
*/
|
|
261
280
|
function ComponentNode(t0) {
|
|
262
|
-
const $ = c(
|
|
263
|
-
const { node } = t0;
|
|
281
|
+
const $ = c(9);
|
|
282
|
+
const { node, fields } = t0;
|
|
264
283
|
const form = useFormContext();
|
|
265
284
|
const { components } = usePlugins();
|
|
266
285
|
let t1;
|
|
267
286
|
let t2;
|
|
268
|
-
if ($[0] !== components || $[1] !==
|
|
287
|
+
if ($[0] !== components || $[1] !== fields || $[2] !== form || $[3] !== node) {
|
|
269
288
|
t2 = Symbol.for("react.early_return_sentinel");
|
|
270
289
|
bb0: {
|
|
271
290
|
const Component = node.component !== void 0 ? components.get(node.component) : void 0;
|
|
291
|
+
let t3;
|
|
292
|
+
if ($[6] !== fields || $[7] !== node.children) {
|
|
293
|
+
t3 = node.children !== void 0 && node.children.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
294
|
+
className: Form_module_default.stack,
|
|
295
|
+
children: /* @__PURE__ */ jsx(LayoutNodes, {
|
|
296
|
+
nodes: node.children,
|
|
297
|
+
fields
|
|
298
|
+
})
|
|
299
|
+
}) : null;
|
|
300
|
+
$[6] = fields;
|
|
301
|
+
$[7] = node.children;
|
|
302
|
+
$[8] = t3;
|
|
303
|
+
} else t3 = $[8];
|
|
304
|
+
const children = t3;
|
|
272
305
|
if (Component === void 0) {
|
|
273
|
-
t2 =
|
|
306
|
+
t2 = children;
|
|
274
307
|
break bb0;
|
|
275
308
|
}
|
|
276
309
|
t1 = createElement(Component, {
|
|
277
310
|
...node.props,
|
|
278
311
|
node,
|
|
279
|
-
form
|
|
312
|
+
form,
|
|
313
|
+
fields,
|
|
314
|
+
children
|
|
280
315
|
});
|
|
281
316
|
}
|
|
282
317
|
$[0] = components;
|
|
283
|
-
$[1] =
|
|
284
|
-
$[2] =
|
|
285
|
-
$[3] =
|
|
286
|
-
$[4] =
|
|
318
|
+
$[1] = fields;
|
|
319
|
+
$[2] = form;
|
|
320
|
+
$[3] = node;
|
|
321
|
+
$[4] = t1;
|
|
322
|
+
$[5] = t2;
|
|
287
323
|
} else {
|
|
288
|
-
t1 = $[
|
|
289
|
-
t2 = $[
|
|
324
|
+
t1 = $[4];
|
|
325
|
+
t2 = $[5];
|
|
290
326
|
}
|
|
291
327
|
if (t2 !== Symbol.for("react.early_return_sentinel")) return t2;
|
|
292
328
|
return t1;
|
|
293
329
|
}
|
|
294
330
|
function LayoutNodeView(t0) {
|
|
295
|
-
const $ = c(
|
|
331
|
+
const $ = c(31);
|
|
296
332
|
const { node, fields } = t0;
|
|
297
333
|
const form = useFormContext();
|
|
298
334
|
const state = useFormState(form);
|
|
@@ -399,22 +435,26 @@ function LayoutNodeView(t0) {
|
|
|
399
435
|
}
|
|
400
436
|
case "component": {
|
|
401
437
|
let t1;
|
|
402
|
-
if ($[23] !== node) {
|
|
403
|
-
t1 = /* @__PURE__ */ jsx(ComponentNode, {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
438
|
+
if ($[23] !== fields || $[24] !== node) {
|
|
439
|
+
t1 = /* @__PURE__ */ jsx(ComponentNode, {
|
|
440
|
+
node,
|
|
441
|
+
fields
|
|
442
|
+
});
|
|
443
|
+
$[23] = fields;
|
|
444
|
+
$[24] = node;
|
|
445
|
+
$[25] = t1;
|
|
446
|
+
} else t1 = $[25];
|
|
407
447
|
return t1;
|
|
408
448
|
}
|
|
409
449
|
default: {
|
|
410
450
|
let t1;
|
|
411
|
-
if ($[
|
|
451
|
+
if ($[26] !== node.children) {
|
|
412
452
|
t1 = node.children ?? [];
|
|
413
|
-
$[
|
|
414
|
-
$[
|
|
415
|
-
} else t1 = $[
|
|
453
|
+
$[26] = node.children;
|
|
454
|
+
$[27] = t1;
|
|
455
|
+
} else t1 = $[27];
|
|
416
456
|
let t2;
|
|
417
|
-
if ($[
|
|
457
|
+
if ($[28] !== fields || $[29] !== t1) {
|
|
418
458
|
t2 = /* @__PURE__ */ jsx("div", {
|
|
419
459
|
className: Form_module_default.stack,
|
|
420
460
|
children: /* @__PURE__ */ jsx(LayoutNodes, {
|
|
@@ -422,10 +462,10 @@ function LayoutNodeView(t0) {
|
|
|
422
462
|
fields
|
|
423
463
|
})
|
|
424
464
|
});
|
|
425
|
-
$[
|
|
426
|
-
$[
|
|
427
|
-
$[
|
|
428
|
-
} else t2 = $[
|
|
465
|
+
$[28] = fields;
|
|
466
|
+
$[29] = t1;
|
|
467
|
+
$[30] = t2;
|
|
468
|
+
} else t2 = $[30];
|
|
429
469
|
return t2;
|
|
430
470
|
}
|
|
431
471
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","names":["CSSProperties","ReactNode","createElement","use","useEffect","useId","useState","Form","getLayoutFieldNames","selectErrorCount","selectVisible","usePlugins","NestedField","isWideField","Field","LayoutNode","Badge","Disclosure","Tab","TabList","TabPanel","Tabs","usePanneauIntl","styles","RevealContext","useFormContext","useFormState","cx","messages","LayoutProps","nodes","fields","ReadonlyMap","containsPath","names","path","name","split","undefined","includes","ErrorBadge","t0","$","_c","form","intl","count","T0","t1","t2","formatMessage","errorCount","t3","TabsNode","node","state","registry","id","child","type","tabs","children","filter","map","_temp","selected","setSelected","add","index","findIndex","tabNames","Symbol","for","key","String","tab_2","index_1","stack","tab","label","_temp2","join","tab_1","index_0","tab_0","SectionNode","titleId","expanded","setExpanded","collapsed","t4","t5","description","sectionDescription","t6","t7","t8","content","collapsible","t9","t10","t11","section","sectionHeader","sectionTitle","ComponentNode","components","bb0","Component","component","get","props","LayoutNodeView","field","values","cell","width","row","text","LayoutNodes","FieldFlow","flowCell","flowWide","flow","_c","styles","_Fragment"],"sources":["../../src/layout/Layout.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n createElement,\n use,\n useEffect,\n useId,\n useState,\n} from 'react';\n\nimport {\n type Form,\n getLayoutFieldNames,\n selectErrorCount,\n selectVisible,\n usePlugins,\n} from '@panneau/core';\nimport { NestedField, isWideField } from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport { Badge, Disclosure, Tab, TabList, TabPanel, Tabs, usePanneauIntl } from '@panneau/ui';\n\nimport styles from '../Form.module.css';\nimport { RevealContext, useFormContext, useFormState } from '../context';\nimport { cx } from '../cx';\nimport { messages } from '../messages';\n\nexport interface LayoutProps {\n nodes: readonly LayoutNode[];\n fields: ReadonlyMap<string, Field>;\n}\n\n/** Whether a path belongs to one of the field names (`title.fr` to `title`). */\nfunction containsPath(names: readonly string[], path: string): boolean {\n const name = path.split('.')[0];\n return name !== undefined && names.includes(name);\n}\n\nfunction ErrorBadge({ form, names }: { form: Form; names: readonly string[] }) {\n const intl = usePanneauIntl();\n const count = selectErrorCount(useFormState(form), names);\n if (count === 0) {\n return null;\n }\n return (\n <Badge tone=\"danger\" label={intl.formatMessage(messages.errorCount, { count })}>\n {count}\n </Badge>\n );\n}\n\nfunction TabsNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const state = useFormState(form);\n const registry = use(RevealContext);\n const id = useId();\n const tabs = (node.children ?? []).filter(\n (child) => child.type === 'tab' && selectVisible(state, child),\n );\n const names = tabs.map((tab) => getLayoutFieldNames(tab.children ?? []));\n const [selected, setSelected] = useState<string>(`${id}-0`);\n\n useEffect(\n () =>\n registry.add((path) => {\n const index = names.findIndex((tabNames) => containsPath(tabNames, path));\n if (index !== -1) {\n setSelected(`${id}-${index}`);\n }\n }),\n [registry, names, id],\n );\n\n return (\n <Tabs selectedKey={selected} onSelectionChange={(key) => setSelected(String(key))}>\n <TabList aria-label={node.label ?? tabs.map((tab) => tab.label ?? '').join(', ')}>\n {tabs.map((tab, index) => (\n <Tab key={index} id={`${id}-${index}`}>\n {tab.label} <ErrorBadge form={form} names={names[index] ?? []} />\n </Tab>\n ))}\n </TabList>\n {tabs.map((tab, index) => (\n // Panels stay mounted: fields keep their state, and errors can be revealed.\n <TabPanel key={index} id={`${id}-${index}`} shouldForceMount>\n <div className={styles.stack}>\n <LayoutNodes nodes={tab.children ?? []} fields={fields} />\n </div>\n </TabPanel>\n ))}\n </Tabs>\n );\n}\n\nfunction SectionNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const registry = use(RevealContext);\n const titleId = useId();\n const names = getLayoutFieldNames(node.children ?? []);\n const [expanded, setExpanded] = useState(node.collapsed !== true);\n\n useEffect(\n () =>\n registry.add((path) => {\n if (containsPath(names, path)) {\n setExpanded(true);\n }\n }),\n [registry, names],\n );\n\n const content = (\n <>\n {node.description !== undefined ? (\n <p className={styles.sectionDescription}>{node.description}</p>\n ) : null}\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n </>\n );\n if (node.collapsible === true) {\n return (\n <div className={styles.section}>\n <Disclosure\n title={node.label}\n titleEnd={<ErrorBadge form={form} names={names} />}\n isExpanded={expanded}\n onExpandedChange={setExpanded}\n >\n <div className={styles.stack}>{content}</div>\n </Disclosure>\n </div>\n );\n }\n return (\n <section\n className={styles.section}\n aria-labelledby={node.label !== undefined ? titleId : undefined}\n >\n {node.label !== undefined ? (\n <div className={styles.sectionHeader}>\n <h3 id={titleId} className={styles.sectionTitle}>\n {node.label} <ErrorBadge form={form} names={names} />\n </h3>\n </div>\n ) : null}\n {content}\n </section>\n );\n}\n\nfunction ComponentNode({ node }: { node: LayoutNode }) {\n const form = useFormContext();\n const { components } = usePlugins();\n const Component = node.component !== undefined ? components.get(node.component) : undefined;\n if (Component === undefined) {\n return null;\n }\n // A component of the plugin registry, looked up by name: not created during render.\n return createElement(Component, { ...node.props, node, form });\n}\n\nfunction LayoutNodeView({\n node,\n fields,\n}: {\n node: LayoutNode;\n fields: ReadonlyMap<string, Field>;\n}) {\n const form = useFormContext();\n const state = useFormState(form);\n if (!selectVisible(state, node)) {\n return null;\n }\n switch (node.type) {\n case 'field': {\n const field = node.name !== undefined ? fields.get(node.name) : undefined;\n return field !== undefined ? (\n <NestedField field={field} path={field.name} parentValue={state.values} />\n ) : null;\n }\n case 'row':\n return (\n <div className={styles.row}>\n {(node.children ?? []).map((child, index) => (\n <div\n key={index}\n className={styles.cell}\n style={{ '--panneau-span': child.width ?? 12 } as CSSProperties}\n >\n <LayoutNodeView node={child} fields={fields} />\n </div>\n ))}\n </div>\n );\n case 'tabs':\n return <TabsNode node={node} fields={fields} />;\n case 'section':\n return <SectionNode node={node} fields={fields} />;\n case 'text':\n return <p className={styles.text}>{node.text ?? node.label}</p>;\n case 'component':\n return <ComponentNode node={node} />;\n default:\n // `column`, a `tab` or a `sidebar` out of place, and unknown containers.\n return (\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n );\n }\n}\n\n/** Renders layout nodes in order. */\nexport function LayoutNodes({ nodes, fields }: LayoutProps): ReactNode {\n return nodes.map((node, index) => <LayoutNodeView key={index} node={node} fields={fields} />);\n}\n\n/**\n * Fields that the layout doesn't place, in columns: short fields side by side, wide ones\n * (`isWideField()`) on their own row.\n */\nexport function FieldFlow({ nodes, fields }: LayoutProps): ReactNode {\n return (\n <div className={styles.flow}>\n {nodes.map((node, index) => {\n const field = node.name !== undefined ? fields.get(node.name) : undefined;\n return (\n <div\n key={index}\n className={cx(\n styles.flowCell,\n (field === undefined || isWideField(field)) && styles.flowWide,\n )}\n >\n <LayoutNodeView node={node} fields={fields} />\n </div>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAASiC,aAAaC,OAA0BC,MAAuB;CACnE,MAAMC,OAAOD,KAAKE,MAAM,GAAG,CAAC,CAAC;CAC7B,OAAOD,SAASE,KAAAA,KAAaJ,MAAMK,SAASH,IAAI;AACpD;AAEA,SAAAI,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAoB,MAAA,EAAAC,MAAAV,U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AAA;GAEb1B,EAAA,KAAAX;GAAAW,EAAA,KAAAO;EAAA,OAAAA,KAAAP,EAAA;EAbAM,KAAAlB,MAAKiC,IAAKd,EAaV;EAACP,EAAA,KAAAX;EAAAW,EAAA,KAAAZ;EAAAY,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAM,IAAA;EAdNC,KAAA,oBAAA,OAAA;GAAgB,WAAA1B,oBAAMoG;GACjB3E,UAAAA;EAcC,CAAA;EAAAN,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAfNO;AAeM"}
|
|
1
|
+
{"version":3,"file":"Layout.js","names":["CSSProperties","ReactNode","createElement","use","useEffect","useId","useState","Form","getLayoutFieldNames","selectErrorCount","selectVisible","usePlugins","NestedField","isWideField","Field","LayoutNode","Badge","Disclosure","Tab","TabList","TabPanel","Tabs","usePanneauIntl","styles","ErrorSectionsContext","RevealContext","useFormContext","useFormState","cx","messages","LayoutProps","nodes","fields","ReadonlyMap","containsPath","names","path","name","split","undefined","includes","ErrorBadge","t0","$","_c","form","intl","count","T0","t1","t2","formatMessage","errorCount","t3","TabsNode","node","state","registry","id","child","type","tabs","children","filter","map","_temp","selected","setSelected","add","index","findIndex","tabNames","Symbol","for","key","String","tab_2","index_1","stack","tab","label","_temp2","join","tab_1","index_0","tab_0","SectionNode","errorSections","titleId","expanded","setExpanded","collapsed","t4","open","removeRevealer","removeOpener","t5","description","sectionDescription","t6","t7","t8","content","collapsible","t9","t10","t11","section","sectionHeader","sectionTitle","LayoutComponentProps","ComponentNode","components","bb0","Component","component","get","length","props","LayoutNodeView","field","values","cell","width","row","text","LayoutNodes","FieldFlow","flowCell","flowWide","flow","_c","styles","_Fragment"],"sources":["../../src/layout/Layout.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n createElement,\n use,\n useEffect,\n useId,\n useState,\n} from 'react';\n\nimport {\n type Form,\n getLayoutFieldNames,\n selectErrorCount,\n selectVisible,\n usePlugins,\n} from '@panneau/core';\nimport { NestedField, isWideField } from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport { Badge, Disclosure, Tab, TabList, TabPanel, Tabs, usePanneauIntl } from '@panneau/ui';\n\nimport styles from '../Form.module.css';\nimport { ErrorSectionsContext, RevealContext, useFormContext, useFormState } from '../context';\nimport { cx } from '../cx';\nimport { messages } from '../messages';\n\nexport interface LayoutProps {\n nodes: readonly LayoutNode[];\n fields: ReadonlyMap<string, Field>;\n}\n\n/** Whether a path belongs to one of the field names (`title.fr` to `title`). */\nfunction containsPath(names: readonly string[], path: string): boolean {\n const name = path.split('.')[0];\n return name !== undefined && names.includes(name);\n}\n\nfunction ErrorBadge({ form, names }: { form: Form; names: readonly string[] }) {\n const intl = usePanneauIntl();\n const count = selectErrorCount(useFormState(form), names);\n if (count === 0) {\n return null;\n }\n return (\n <Badge tone=\"danger\" label={intl.formatMessage(messages.errorCount, { count })}>\n {count}\n </Badge>\n );\n}\n\nfunction TabsNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const state = useFormState(form);\n const registry = use(RevealContext);\n const id = useId();\n const tabs = (node.children ?? []).filter(\n (child) => child.type === 'tab' && selectVisible(state, child),\n );\n const names = tabs.map((tab) => getLayoutFieldNames(tab.children ?? []));\n const [selected, setSelected] = useState<string>(`${id}-0`);\n\n useEffect(\n () =>\n registry.add((path) => {\n const index = names.findIndex((tabNames) => containsPath(tabNames, path));\n if (index !== -1) {\n setSelected(`${id}-${index}`);\n }\n }),\n [registry, names, id],\n );\n\n return (\n <Tabs selectedKey={selected} onSelectionChange={(key) => setSelected(String(key))}>\n <TabList aria-label={node.label ?? tabs.map((tab) => tab.label ?? '').join(', ')}>\n {tabs.map((tab, index) => (\n <Tab key={index} id={`${id}-${index}`}>\n {tab.label} <ErrorBadge form={form} names={names[index] ?? []} />\n </Tab>\n ))}\n </TabList>\n {tabs.map((tab, index) => (\n // Panels stay mounted: fields keep their state, and errors can be revealed.\n <TabPanel key={index} id={`${id}-${index}`} shouldForceMount>\n <div className={styles.stack}>\n <LayoutNodes nodes={tab.children ?? []} fields={fields} />\n </div>\n </TabPanel>\n ))}\n </Tabs>\n );\n}\n\nfunction SectionNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const registry = use(RevealContext);\n const errorSections = use(ErrorSectionsContext);\n const titleId = useId();\n const names = getLayoutFieldNames(node.children ?? []);\n const [expanded, setExpanded] = useState(node.collapsed !== true);\n\n // Opens to reveal a field, and after a failed save when it holds an error\n useEffect(() => {\n const open = (path: string) => {\n if (containsPath(names, path)) {\n setExpanded(true);\n }\n };\n const removeRevealer = registry.add(open);\n const removeOpener = errorSections.add(open);\n return () => {\n removeRevealer();\n removeOpener();\n };\n }, [registry, errorSections, names]);\n\n const content = (\n <>\n {node.description !== undefined ? (\n <p className={styles.sectionDescription}>{node.description}</p>\n ) : null}\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n </>\n );\n if (node.collapsible === true) {\n return (\n <div className={styles.section}>\n <Disclosure\n title={node.label}\n titleEnd={<ErrorBadge form={form} names={names} />}\n isExpanded={expanded}\n onExpandedChange={setExpanded}\n >\n <div className={styles.stack}>{content}</div>\n </Disclosure>\n </div>\n );\n }\n return (\n <section\n className={styles.section}\n aria-labelledby={node.label !== undefined ? titleId : undefined}\n >\n {node.label !== undefined ? (\n <div className={styles.sectionHeader}>\n <h3 id={titleId} className={styles.sectionTitle}>\n {node.label} <ErrorBadge form={form} names={names} />\n </h3>\n </div>\n ) : null}\n {content}\n </section>\n );\n}\n\n/** What the component of a `component` node of a form layout gets, with the node's `props`. */\nexport interface LayoutComponentProps {\n node: LayoutNode;\n form: Form;\n /** The fields of the form, by name. */\n fields: ReadonlyMap<string, Field>;\n /** The node's children, rendered: the fields a component frames (decision 0065). */\n children: ReactNode;\n}\n\n/**\n * A `component` node: the plugin's component, with the node's children rendered. Without the\n * plugin, the children show as in a column, so that the fields the node frames stay in the form\n * (decision 0065).\n */\nfunction ComponentNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const { components } = usePlugins();\n const Component = node.component !== undefined ? components.get(node.component) : undefined;\n const children =\n node.children !== undefined && node.children.length > 0 ? (\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children} fields={fields} />\n </div>\n ) : null;\n if (Component === undefined) {\n return children;\n }\n // A component of the plugin registry, looked up by name: not created during render.\n return createElement(Component, { ...node.props, node, form, fields, children });\n}\n\nfunction LayoutNodeView({\n node,\n fields,\n}: {\n node: LayoutNode;\n fields: ReadonlyMap<string, Field>;\n}) {\n const form = useFormContext();\n const state = useFormState(form);\n if (!selectVisible(state, node)) {\n return null;\n }\n switch (node.type) {\n case 'field': {\n const field = node.name !== undefined ? fields.get(node.name) : undefined;\n return field !== undefined ? (\n <NestedField field={field} path={field.name} parentValue={state.values} />\n ) : null;\n }\n case 'row':\n return (\n <div className={styles.row}>\n {(node.children ?? []).map((child, index) => (\n <div\n key={index}\n className={styles.cell}\n style={{ '--panneau-span': child.width ?? 12 } as CSSProperties}\n >\n <LayoutNodeView node={child} fields={fields} />\n </div>\n ))}\n </div>\n );\n case 'tabs':\n return <TabsNode node={node} fields={fields} />;\n case 'section':\n return <SectionNode node={node} fields={fields} />;\n case 'text':\n return <p className={styles.text}>{node.text ?? node.label}</p>;\n case 'component':\n return <ComponentNode node={node} fields={fields} />;\n default:\n // `column`, a `tab` or a `sidebar` out of place, and unknown containers.\n return (\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n );\n }\n}\n\n/** Renders layout nodes in order. */\nexport function LayoutNodes({ nodes, fields }: LayoutProps): ReactNode {\n return nodes.map((node, index) => <LayoutNodeView key={index} node={node} fields={fields} />);\n}\n\n/**\n * Fields that the layout doesn't place, in columns: short fields side by side, wide ones\n * (`isWideField()`) on their own row.\n */\nexport function FieldFlow({ nodes, fields }: LayoutProps): ReactNode {\n return (\n <div className={styles.flow}>\n {nodes.map((node, index) => {\n const field = node.name !== undefined ? fields.get(node.name) : undefined;\n return (\n <div\n key={index}\n className={cx(\n styles.flowCell,\n (field === undefined || isWideField(field)) && styles.flowWide,\n )}\n >\n <LayoutNodeView node={node} fields={fields} />\n </div>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAASkC,aAAaC,OAA0BC,MAAuB;CACnE,MAAMC,OAAOD,KAAKE,MAAM,GAAG,CAAC,CAAC;CAC7B,OAAOD,SAASE,KAAAA,KAAaJ,MAAMK,SAASH,IAAI;AACpD;AAEA,SAAAI,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAoB,MAAA,EAAAC,MAAAV,UAAAO;CAChB,MAAAI,OAAaxB,eAAe;CAC5B,MAAAyB,QAActC,iBAAiBkB,aAAakB,IAAI,GAAGV,KAAK;CACxD,IAAIY,UAAU,GAAC,OACJ;CAGN,MAAAC,KAAAhC;CAAW,MAAAiC,KAAA;CAAgB,MAAAC,KAAAJ,KAAIK,cAAetB,SAAQuB,YAAa,EAAAL,MAAQ,CAAC;CAAC,IAAAM;CAAA,IAAAV,EAAA,OAAAK,MAAAL,EAAA,OAAAI,SAAAJ,EAAA,OAAAO,IAAA;EAA9EG,KAAA,oBAAC,IAAD;GAAY,MAAAJ;GAAgB,OAAAC;GACvBH,UAAAA;EADC,CAAA;EAEEJ,EAAA,KAAAK;EAAAL,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;EAAAP,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFRU;AAEQ;AAIhB,SAAAC,SAAAZ,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAkB,MAAA,EAAAW,MAAAvB,WAAAU;CACd,MAAAG,OAAanB,eAAe;CAC5B,MAAA8B,QAAc7B,aAAakB,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AAC,gBAAD;MAAsB1E;MAAcvB;KAAM,CAAA;IACxC,GAPGqC,KAOH;GAAA;GAEb1B,EAAA,KAAAX;GAAAW,EAAA,KAAAO;EAAA,OAAAA,KAAAP,EAAA;EAbAM,KAAAlB,MAAKiC,IAAKd,EAaV;EAACP,EAAA,KAAAX;EAAAW,EAAA,KAAAZ;EAAAY,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAM,IAAA;EAdNC,KAAA,oBAAA,OAAA;GAAgB,WAAA3B,oBAAM2G;GACjBjF,UAAAA;EAcC,CAAA;EAAAN,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAfNO;AAeM"}
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,4FAA4F;AAC5F,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CA2B/E;AAED,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAExF"}
|
package/dist/paths.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getNestedShape } from "@panneau/protocol/runtime";
|
|
1
2
|
//#region src/paths.ts
|
|
2
3
|
function nested(field) {
|
|
3
4
|
return [...field.fields ?? [], ...(field.types ?? []).flatMap((type) => type.fields)];
|
|
@@ -20,7 +21,7 @@ function getPathSteps(fields, path) {
|
|
|
20
21
|
step.locale = next;
|
|
21
22
|
index += 1;
|
|
22
23
|
}
|
|
23
|
-
if (field
|
|
24
|
+
if (getNestedShape(field) === "repeater" && next !== void 0 && /^\d+$/.test(segments[index + 1] ?? "")) {
|
|
24
25
|
step.index = Number(segments[index + 1]);
|
|
25
26
|
index += 1;
|
|
26
27
|
}
|
package/dist/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","names":["Field","PathStep","field","locale","index","nested","fields","types","flatMap","type","getPathSteps","path","steps","segments","split","candidates","length","find","candidate","name","undefined","step","push","next","localized","test","Number","getFieldAtPath","at"],"sources":["../src/paths.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\n/** A step from a field to the value at a path: the field, and a locale or an item index. */\nexport interface PathStep {\n field: Field;\n locale?: string;\n index?: number;\n}\n\nfunction nested(field: Field): Field[] {\n return [...(field.fields ?? []), ...(field.types ?? []).flatMap((type) => type.fields)];\n}\n\n/**\n * The fields that a dot path goes through (`blocks.2.body.fr`: `blocks`, item 3, `body` in\n * French). Typed blocks are searched in all their types. Returns `[]` for an unknown path.\n */\nexport function getPathSteps(fields: readonly Field[], path: string): PathStep[] {\n const steps: PathStep[] = [];\n const segments = path.split('.');\n let candidates: readonly Field[] = fields;\n for (let index = 0; index < segments.length; index += 1) {\n const field = candidates.find((candidate) => candidate.name === segments[index]);\n if (field === undefined) {\n return [];\n }\n const step: PathStep = { field };\n steps.push(step);\n const next = segments[index + 1];\n if (field.localized === true && next !== undefined) {\n step.locale = next;\n index += 1;\n }\n if (\n field
|
|
1
|
+
{"version":3,"file":"paths.js","names":["Field","getNestedShape","PathStep","field","locale","index","nested","fields","types","flatMap","type","getPathSteps","path","steps","segments","split","candidates","length","find","candidate","name","undefined","step","push","next","localized","test","Number","getFieldAtPath","at"],"sources":["../src/paths.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\nimport { getNestedShape } from '@panneau/protocol/runtime';\n\n/** A step from a field to the value at a path: the field, and a locale or an item index. */\nexport interface PathStep {\n field: Field;\n locale?: string;\n index?: number;\n}\n\nfunction nested(field: Field): Field[] {\n return [...(field.fields ?? []), ...(field.types ?? []).flatMap((type) => type.fields)];\n}\n\n/**\n * The fields that a dot path goes through (`blocks.2.body.fr`: `blocks`, item 3, `body` in\n * French). Typed blocks are searched in all their types. Returns `[]` for an unknown path.\n */\nexport function getPathSteps(fields: readonly Field[], path: string): PathStep[] {\n const steps: PathStep[] = [];\n const segments = path.split('.');\n let candidates: readonly Field[] = fields;\n for (let index = 0; index < segments.length; index += 1) {\n const field = candidates.find((candidate) => candidate.name === segments[index]);\n if (field === undefined) {\n return [];\n }\n const step: PathStep = { field };\n steps.push(step);\n const next = segments[index + 1];\n if (field.localized === true && next !== undefined) {\n step.locale = next;\n index += 1;\n }\n if (\n getNestedShape(field) === 'repeater' &&\n next !== undefined &&\n /^\\d+$/.test(segments[index + 1] ?? '')\n ) {\n step.index = Number(segments[index + 1]);\n index += 1;\n }\n candidates = nested(field);\n }\n return steps;\n}\n\n/** The field a path ends on, if the path is known. */\nexport function getFieldAtPath(fields: readonly Field[], path: string): Field | undefined {\n return getPathSteps(fields, path).at(-1)?.field;\n}\n"],"mappings":";;AAUA,SAASM,OAAOH,OAAuB;CACnC,OAAO,CAAC,GAAIA,MAAMI,UAAU,CAAA,GAAK,IAAIJ,MAAMK,SAAS,CAAA,EAAA,CAAIC,SAASC,SAASA,KAAKH,MAAM,CAAC;AAC1F;;;;;AAMA,SAAgBI,aAAaJ,QAA0BK,MAA0B;CAC7E,MAAMC,QAAoB,CAAA;CAC1B,MAAMC,WAAWF,KAAKG,MAAM,GAAG;CAC/B,IAAIC,aAA+BT;CACnC,KAAK,IAAIF,QAAQ,GAAGA,QAAQS,SAASG,QAAQZ,SAAS,GAAG;EACrD,MAAMF,QAAQa,WAAWE,MAAMC,cAAcA,UAAUC,SAASN,SAAST,MAAM;EAC/E,IAAIF,UAAUkB,KAAAA,GACV,OAAO,CAAA;EAEX,MAAMC,OAAiB,EAAEnB,MAAM;EAC/BU,MAAMU,KAAKD,IAAI;EACf,MAAME,OAAOV,SAAST,QAAQ;EAC9B,IAAIF,MAAMsB,cAAc,QAAQD,SAASH,KAAAA,GAAW;GAChDC,KAAKlB,SAASoB;GACdnB,SAAS;EACb;EACA,IACIJ,eAAeE,KAAK,MAAM,cAC1BqB,SAASH,KAAAA,KACT,QAAQK,KAAKZ,SAAST,QAAQ,MAAM,EAAE,GACxC;GACEiB,KAAKjB,QAAQsB,OAAOb,SAAST,QAAQ,EAAE;GACvCA,SAAS;EACb;EACAW,aAAaV,OAAOH,KAAK;CAC7B;CACA,OAAOU;AACX"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { LayoutComponentProps } from '../layout/Layout.js';
|
|
2
|
+
export interface PublicationProps extends LayoutComponentProps {
|
|
3
|
+
/** The field that says whether the item is published, a `boolean`. Defaults to `published`. */
|
|
4
|
+
published?: string;
|
|
5
|
+
/** The field of the publication date, a `date` or a `datetime`. Defaults to `published_at`. */
|
|
6
|
+
publishedAt?: string;
|
|
7
|
+
/** The field of the status, a `select` whose options have tones. Defaults to `status`. */
|
|
8
|
+
status?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The publication of an item (decision 0065): a `component` node of the form layout that frames
|
|
12
|
+
* the fields of its children (whether it is published, its date, its status) under a summary of
|
|
13
|
+
* the state, `Published`, `Scheduled` or `Not published`, with its date. A status with an option
|
|
14
|
+
* gives the state its label and tone. The fields stay at the top of the resource, where lists can
|
|
15
|
+
* filter and sort them.
|
|
16
|
+
*
|
|
17
|
+
* ```jsonc
|
|
18
|
+
* { "type": "component", "component": "publication", "children": [
|
|
19
|
+
* { "type": "field", "name": "published" },
|
|
20
|
+
* { "type": "field", "name": "published_at" },
|
|
21
|
+
* { "type": "field", "name": "status" }
|
|
22
|
+
* ] }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function Publication({ node, form, fields, children, published, publishedAt, status, }: PublicationProps): import("react").JSX.Element;
|
|
26
|
+
/** The `publication` layout component, as a `@panneau/core` plugin. */
|
|
27
|
+
export declare const publicationPlugin: {
|
|
28
|
+
id: string;
|
|
29
|
+
components: {
|
|
30
|
+
publication: typeof Publication;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Publication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Publication.d.ts","sourceRoot":"","sources":["../../src/publication/Publication.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC1D,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAiBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,EACxB,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,SAAuB,EACvB,WAA4B,EAC5B,MAAiB,GACpB,EAAE,gBAAgB,+BA8DlB;AAED,uEAAuE;AACvE,eAAO,MAAM,iBAAiB;;;;;CAG7B,CAAC"}
|