@panneau/forms 5.0.0-alpha.2 → 5.0.0-alpha.20
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 +12 -10
- package/dist/ConflictDialog.js +200 -63
- package/dist/ConflictDialog.js.map +1 -1
- package/dist/ErrorSummary.js.map +1 -1
- package/dist/FieldErrorBoundary.js.map +1 -1
- package/dist/Form.css +55 -2
- 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 +20 -4
- package/dist/Form.module.js.map +1 -1
- package/dist/FormBinding.d.ts.map +1 -1
- package/dist/FormBinding.js +78 -67
- package/dist/FormBinding.js.map +1 -1
- package/dist/FormSkeleton.d.ts +23 -0
- package/dist/FormSkeleton.d.ts.map +1 -0
- package/dist/FormSkeleton.js +438 -0
- package/dist/FormSkeleton.js.map +1 -0
- package/dist/FormView.d.ts +36 -4
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +313 -115
- package/dist/FormView.js.map +1 -1
- package/dist/context.d.ts +8 -8
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +8 -16
- 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 +31 -5
- package/dist/formatError.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/layout/Layout.d.ts +15 -0
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +169 -88
- package/dist/layout/Layout.js.map +1 -1
- package/dist/locales/index.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/dist/unsaved.js.map +1 -1
- package/package.json +16 -9
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { messages } from "../messages.js";
|
|
2
|
+
import Form_module_default from "../Form.module.js";
|
|
3
|
+
import { useFormState } from "../context.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { selectValue } from "@panneau/core";
|
|
6
|
+
import { Badge, usePanneauIntl } from "@panneau/ui";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useId, useState } from "react";
|
|
9
|
+
//#region src/publication/Publication.tsx
|
|
10
|
+
function toDate(value) {
|
|
11
|
+
if (typeof value !== "string" || value === "") return null;
|
|
12
|
+
const date = new Date(value);
|
|
13
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The publication of an item (decision 0065): a `component` node of the form layout that frames
|
|
17
|
+
* the fields of its children (whether it is published, its date, its status) under a summary of
|
|
18
|
+
* the state, `Published`, `Scheduled` or `Not published`, with its date. A status with an option
|
|
19
|
+
* gives the state its label and tone. The fields stay at the top of the resource, where lists can
|
|
20
|
+
* filter and sort them.
|
|
21
|
+
*
|
|
22
|
+
* ```jsonc
|
|
23
|
+
* { "type": "component", "component": "publication", "children": [
|
|
24
|
+
* { "type": "field", "name": "published" },
|
|
25
|
+
* { "type": "field", "name": "published_at" },
|
|
26
|
+
* { "type": "field", "name": "status" }
|
|
27
|
+
* ] }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function Publication(t0) {
|
|
31
|
+
const $ = c(51);
|
|
32
|
+
const { node, form, fields, children, published: t1, publishedAt: t2, status: t3 } = t0;
|
|
33
|
+
const published = t1 === void 0 ? "published" : t1;
|
|
34
|
+
const publishedAt = t2 === void 0 ? "published_at" : t2;
|
|
35
|
+
const status = t3 === void 0 ? "status" : t3;
|
|
36
|
+
const intl = usePanneauIntl();
|
|
37
|
+
const state = useFormState(form);
|
|
38
|
+
const titleId = useId();
|
|
39
|
+
const [now] = useState(_temp);
|
|
40
|
+
let t4;
|
|
41
|
+
if ($[0] !== published || $[1] !== state) {
|
|
42
|
+
t4 = selectValue(state, published);
|
|
43
|
+
$[0] = published;
|
|
44
|
+
$[1] = state;
|
|
45
|
+
$[2] = t4;
|
|
46
|
+
} else t4 = $[2];
|
|
47
|
+
const isPublished = t4;
|
|
48
|
+
let option;
|
|
49
|
+
let summary;
|
|
50
|
+
if ($[3] !== fields || $[4] !== intl || $[5] !== isPublished || $[6] !== now || $[7] !== publishedAt || $[8] !== state || $[9] !== status) {
|
|
51
|
+
const date = toDate(selectValue(state, publishedAt));
|
|
52
|
+
let t5;
|
|
53
|
+
if ($[12] !== state || $[13] !== status) {
|
|
54
|
+
t5 = selectValue(state, status);
|
|
55
|
+
$[12] = state;
|
|
56
|
+
$[13] = status;
|
|
57
|
+
$[14] = t5;
|
|
58
|
+
} else t5 = $[14];
|
|
59
|
+
const statusValue = t5;
|
|
60
|
+
let t6;
|
|
61
|
+
if ($[15] !== fields || $[16] !== status || $[17] !== statusValue) {
|
|
62
|
+
t6 = fields.get(status)?.options?.find((candidate) => String(candidate.value) === String(statusValue));
|
|
63
|
+
$[15] = fields;
|
|
64
|
+
$[16] = status;
|
|
65
|
+
$[17] = statusValue;
|
|
66
|
+
$[18] = t6;
|
|
67
|
+
} else t6 = $[18];
|
|
68
|
+
option = t6;
|
|
69
|
+
const formatted = date !== null ? intl.formatDate(date, { dateStyle: "medium" }) : null;
|
|
70
|
+
const scheduled = date !== null && date.getTime() > now;
|
|
71
|
+
const live = isPublished === true || isPublished === void 0 && date !== null;
|
|
72
|
+
if (live && scheduled) summary = {
|
|
73
|
+
label: intl.formatMessage(messages.publication.scheduled),
|
|
74
|
+
tone: "info",
|
|
75
|
+
detail: formatted !== null ? intl.formatMessage(messages.publication.scheduledFor, { date: formatted }) : null
|
|
76
|
+
};
|
|
77
|
+
else if (live) {
|
|
78
|
+
let t7;
|
|
79
|
+
if ($[19] !== intl) {
|
|
80
|
+
t7 = intl.formatMessage(messages.publication.published);
|
|
81
|
+
$[19] = intl;
|
|
82
|
+
$[20] = t7;
|
|
83
|
+
} else t7 = $[20];
|
|
84
|
+
const t8 = formatted !== null ? intl.formatMessage(messages.publication.publishedOn, { date: formatted }) : null;
|
|
85
|
+
let t9;
|
|
86
|
+
if ($[21] !== t7 || $[22] !== t8) {
|
|
87
|
+
t9 = {
|
|
88
|
+
label: t7,
|
|
89
|
+
tone: "success",
|
|
90
|
+
detail: t8
|
|
91
|
+
};
|
|
92
|
+
$[21] = t7;
|
|
93
|
+
$[22] = t8;
|
|
94
|
+
$[23] = t9;
|
|
95
|
+
} else t9 = $[23];
|
|
96
|
+
summary = t9;
|
|
97
|
+
} else {
|
|
98
|
+
let t7;
|
|
99
|
+
if ($[24] !== intl) {
|
|
100
|
+
t7 = intl.formatMessage(messages.publication.unpublished);
|
|
101
|
+
$[24] = intl;
|
|
102
|
+
$[25] = t7;
|
|
103
|
+
} else t7 = $[25];
|
|
104
|
+
let t8;
|
|
105
|
+
if ($[26] !== t7) {
|
|
106
|
+
t8 = {
|
|
107
|
+
label: t7,
|
|
108
|
+
tone: "neutral",
|
|
109
|
+
detail: null
|
|
110
|
+
};
|
|
111
|
+
$[26] = t7;
|
|
112
|
+
$[27] = t8;
|
|
113
|
+
} else t8 = $[27];
|
|
114
|
+
summary = t8;
|
|
115
|
+
}
|
|
116
|
+
$[3] = fields;
|
|
117
|
+
$[4] = intl;
|
|
118
|
+
$[5] = isPublished;
|
|
119
|
+
$[6] = now;
|
|
120
|
+
$[7] = publishedAt;
|
|
121
|
+
$[8] = state;
|
|
122
|
+
$[9] = status;
|
|
123
|
+
$[10] = option;
|
|
124
|
+
$[11] = summary;
|
|
125
|
+
} else {
|
|
126
|
+
option = $[10];
|
|
127
|
+
summary = $[11];
|
|
128
|
+
}
|
|
129
|
+
if (option !== void 0) {
|
|
130
|
+
const t5 = option.tone ?? "neutral";
|
|
131
|
+
let t6;
|
|
132
|
+
if ($[28] !== option.label || $[29] !== summary || $[30] !== t5) {
|
|
133
|
+
t6 = {
|
|
134
|
+
...summary,
|
|
135
|
+
label: option.label,
|
|
136
|
+
tone: t5
|
|
137
|
+
};
|
|
138
|
+
$[28] = option.label;
|
|
139
|
+
$[29] = summary;
|
|
140
|
+
$[30] = t5;
|
|
141
|
+
$[31] = t6;
|
|
142
|
+
} else t6 = $[31];
|
|
143
|
+
summary = t6;
|
|
144
|
+
}
|
|
145
|
+
let t5;
|
|
146
|
+
if ($[32] !== intl || $[33] !== node.label) {
|
|
147
|
+
t5 = node.label ?? intl.formatMessage(messages.publication.title);
|
|
148
|
+
$[32] = intl;
|
|
149
|
+
$[33] = node.label;
|
|
150
|
+
$[34] = t5;
|
|
151
|
+
} else t5 = $[34];
|
|
152
|
+
let t6;
|
|
153
|
+
if ($[35] !== summary.label || $[36] !== summary.tone) {
|
|
154
|
+
t6 = /* @__PURE__ */ jsx(Badge, {
|
|
155
|
+
tone: summary.tone,
|
|
156
|
+
children: summary.label
|
|
157
|
+
});
|
|
158
|
+
$[35] = summary.label;
|
|
159
|
+
$[36] = summary.tone;
|
|
160
|
+
$[37] = t6;
|
|
161
|
+
} else t6 = $[37];
|
|
162
|
+
let t7;
|
|
163
|
+
if ($[38] !== t5 || $[39] !== t6 || $[40] !== titleId) {
|
|
164
|
+
t7 = /* @__PURE__ */ jsxs("h3", {
|
|
165
|
+
id: titleId,
|
|
166
|
+
className: Form_module_default.sectionTitle,
|
|
167
|
+
children: [t5, t6]
|
|
168
|
+
});
|
|
169
|
+
$[38] = t5;
|
|
170
|
+
$[39] = t6;
|
|
171
|
+
$[40] = titleId;
|
|
172
|
+
$[41] = t7;
|
|
173
|
+
} else t7 = $[41];
|
|
174
|
+
let t8;
|
|
175
|
+
if ($[42] !== summary.detail) {
|
|
176
|
+
t8 = summary.detail !== null ? /* @__PURE__ */ jsx("p", {
|
|
177
|
+
className: Form_module_default.sectionDescription,
|
|
178
|
+
children: summary.detail
|
|
179
|
+
}) : null;
|
|
180
|
+
$[42] = summary.detail;
|
|
181
|
+
$[43] = t8;
|
|
182
|
+
} else t8 = $[43];
|
|
183
|
+
let t9;
|
|
184
|
+
if ($[44] !== t7 || $[45] !== t8) {
|
|
185
|
+
t9 = /* @__PURE__ */ jsxs("div", {
|
|
186
|
+
className: Form_module_default.sectionHeader,
|
|
187
|
+
children: [t7, t8]
|
|
188
|
+
});
|
|
189
|
+
$[44] = t7;
|
|
190
|
+
$[45] = t8;
|
|
191
|
+
$[46] = t9;
|
|
192
|
+
} else t9 = $[46];
|
|
193
|
+
let t10;
|
|
194
|
+
if ($[47] !== children || $[48] !== t9 || $[49] !== titleId) {
|
|
195
|
+
t10 = /* @__PURE__ */ jsxs("section", {
|
|
196
|
+
className: Form_module_default.section,
|
|
197
|
+
"aria-labelledby": titleId,
|
|
198
|
+
children: [t9, children]
|
|
199
|
+
});
|
|
200
|
+
$[47] = children;
|
|
201
|
+
$[48] = t9;
|
|
202
|
+
$[49] = titleId;
|
|
203
|
+
$[50] = t10;
|
|
204
|
+
} else t10 = $[50];
|
|
205
|
+
return t10;
|
|
206
|
+
}
|
|
207
|
+
/** The `publication` layout component, as a `@panneau/core` plugin. */
|
|
208
|
+
function _temp() {
|
|
209
|
+
return Date.now();
|
|
210
|
+
}
|
|
211
|
+
var publicationPlugin = {
|
|
212
|
+
id: "panneau.publication",
|
|
213
|
+
components: { publication: Publication }
|
|
214
|
+
};
|
|
215
|
+
//#endregion
|
|
216
|
+
export { Publication, publicationPlugin };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=Publication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Publication.js","names":["useId","useState","selectValue","Option","Badge","Tone","usePanneauIntl","styles","useFormState","LayoutComponentProps","messages","PublicationProps","published","publishedAt","status","PublicationState","label","tone","detail","toDate","value","Date","date","Number","isNaN","getTime","Publication","t0","$","_c","node","form","fields","children","t1","t2","t3","undefined","intl","state","titleId","now","_temp","t4","isPublished","option","summary","t5","statusValue","t6","get","options","find","candidate","String","formatted","formatDate","dateStyle","scheduled","live","formatMessage","publication","scheduledFor","t7","t8","publishedOn","t9","unpublished","title","sectionTitle","sectionDescription","sectionHeader","t10","section","publicationPlugin","id","components","_c","styles"],"sources":["../../src/publication/Publication.tsx"],"sourcesContent":["import { useId, useState } from 'react';\n\nimport { selectValue } from '@panneau/core';\nimport type { Option } from '@panneau/protocol';\nimport { Badge, type Tone, usePanneauIntl } from '@panneau/ui';\n\nimport styles from '../Form.module.css';\nimport { useFormState } from '../context';\nimport type { LayoutComponentProps } from '../layout/Layout';\nimport { messages } from '../messages';\n\nexport interface PublicationProps extends LayoutComponentProps {\n /** The field that says whether the item is published, a `boolean`. Defaults to `published`. */\n published?: string;\n /** The field of the publication date, a `date` or a `datetime`. Defaults to `published_at`. */\n publishedAt?: string;\n /** The field of the status, a `select` whose options have tones. Defaults to `status`. */\n status?: string;\n}\n\ninterface PublicationState {\n label: string;\n tone: Tone;\n /** \"Published on Nov 3, 2026\", or `null` without a date. */\n detail: string | null;\n}\n\nfunction toDate(value: unknown): Date | null {\n if (typeof value !== 'string' || value === '') {\n return null;\n }\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\n/**\n * The publication of an item (decision 0065): a `component` node of the form layout that frames\n * the fields of its children (whether it is published, its date, its status) under a summary of\n * the state, `Published`, `Scheduled` or `Not published`, with its date. A status with an option\n * gives the state its label and tone. The fields stay at the top of the resource, where lists can\n * filter and sort them.\n *\n * ```jsonc\n * { \"type\": \"component\", \"component\": \"publication\", \"children\": [\n * { \"type\": \"field\", \"name\": \"published\" },\n * { \"type\": \"field\", \"name\": \"published_at\" },\n * { \"type\": \"field\", \"name\": \"status\" }\n * ] }\n * ```\n */\nexport function Publication({\n node,\n form,\n fields,\n children,\n published = 'published',\n publishedAt = 'published_at',\n status = 'status',\n}: PublicationProps) {\n const intl = usePanneauIntl();\n const state = useFormState(form);\n const titleId = useId();\n const [now] = useState(() => Date.now());\n const isPublished = selectValue(state, published);\n const date = toDate(selectValue(state, publishedAt));\n const statusValue = selectValue(state, status);\n const option: Option | undefined = fields\n .get(status)\n ?.options?.find((candidate) => String(candidate.value) === String(statusValue));\n const formatted = date !== null ? intl.formatDate(date, { dateStyle: 'medium' }) : null;\n const scheduled = date !== null && date.getTime() > now;\n const live = isPublished === true || (isPublished === undefined && date !== null);\n let summary: PublicationState;\n if (live && scheduled) {\n summary = {\n label: intl.formatMessage(messages.publication.scheduled),\n tone: 'info',\n detail:\n formatted !== null\n ? intl.formatMessage(messages.publication.scheduledFor, { date: formatted })\n : null,\n };\n } else if (live) {\n summary = {\n label: intl.formatMessage(messages.publication.published),\n tone: 'success',\n detail:\n formatted !== null\n ? intl.formatMessage(messages.publication.publishedOn, { date: formatted })\n : null,\n };\n } else {\n summary = {\n label: intl.formatMessage(messages.publication.unpublished),\n tone: 'neutral',\n detail: null,\n };\n }\n if (option !== undefined) {\n // The status of the site says more than the published flag: \"Draft\", \"In review\".\n summary = {\n ...summary,\n label: option.label,\n tone: (option.tone as Tone | undefined) ?? 'neutral',\n };\n }\n return (\n <section className={styles.section} aria-labelledby={titleId}>\n <div className={styles.sectionHeader}>\n <h3 id={titleId} className={styles.sectionTitle}>\n {node.label ?? intl.formatMessage(messages.publication.title)}\n <Badge tone={summary.tone}>{summary.label}</Badge>\n </h3>\n {summary.detail !== null ? (\n <p className={styles.sectionDescription}>{summary.detail}</p>\n ) : null}\n </div>\n {children}\n </section>\n );\n}\n\n/** The `publication` layout component, as a `@panneau/core` plugin. */\nexport const publicationPlugin = {\n id: 'panneau.publication',\n components: { publication: Publication },\n};\n"],"mappings":";;;;;;;;;AA2BA,SAASmB,OAAOC,OAA6B;CACzC,IAAI,OAAOA,UAAU,YAAYA,UAAU,IACvC,OAA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AAA,IAAA4C;CAAA,IAAA5C,EAAA,QAAAK,YAAAL,EAAA,QAAAsC,MAAAtC,EAAA,QAAAY,SAAA;EATVgC,MAAA,qBAAA,WAAA;GAAoB,WAAAjE,oBAAMkE;GAA2BjC,mBAAAA;GAArD,UAAA,CACI0B,IASCjC,QACK;;EAAAL,EAAA,MAAAK;EAAAL,EAAA,MAAAsC;EAAAtC,EAAA,MAAAY;EAAAZ,EAAA,MAAA4C;CAAA,OAAAA,MAAA5C,EAAA;CAAA,OAXV4C;AAWU;;AApEX,SAAA9B,QAAA;CAAA,OAY0BrB,KAAIoB,IAAK;AAAC;AA6D3C,IAAaiC,oBAAoB;CAC7BC,IAAI;CACJC,YAAY,EAAEf,aAAanC,YAAY;AAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/publication/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACtF,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Publication, publicationPlugin } from "./Publication.js";
|
package/dist/unsaved.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsaved.js","names":["open","_c","_Fragment"],"sources":["../src/unsaved.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useRef, useState } from 'react';\n\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\n\n/**\n * Asks the browser to confirm before the page is closed or reloaded while `dirty` is true. Forms\n * use it by default.\n */\nexport function useBeforeUnloadGuard(dirty: boolean): void {\n useEffect(() => {\n if (!dirty) {\n return undefined;\n }\n const listener = (event: BeforeUnloadEvent) => {\n event.preventDefault();\n // Older browsers show the dialog only with a return value.\n event.returnValue = '';\n };\n window.addEventListener('beforeunload', listener);\n return () => window.removeEventListener('beforeunload', listener);\n }, [dirty]);\n}\n\nexport interface LeaveConfirmation {\n /**\n * Resolves `true` when leaving is fine: right away without unsaved changes, or once the user\n * chose to leave in the dialog.\n */\n confirmLeave: () => Promise<boolean>;\n /** The dialog to render, while it is open. */\n dialog: ReactNode;\n}\n\n/**\n * Guards in-app navigation while a form has unsaved changes. Call `confirmLeave()` from the\n * router's navigation guard (or before closing a panel), and render `dialog`. The page itself is\n * guarded by `useBeforeUnloadGuard()`.\n */\nexport function useLeaveConfirmation(dirty: boolean): LeaveConfirmation {\n const intl = usePanneauIntl();\n const [open, setOpen] = useState(false);\n const resolver = useRef<((leave: boolean) => void) | null>(null);\n const answer = (leave: boolean) => {\n resolver.current?.(leave);\n resolver.current = null;\n setOpen(false);\n };\n return {\n confirmLeave: () => {\n if (!dirty) {\n return Promise.resolve(true);\n }\n resolver.current?.(false);\n setOpen(true);\n return new Promise<boolean>((resolve) => {\n resolver.current = resolve;\n });\n },\n dialog: (\n <Dialog\n isOpen={open}\n onOpenChange={(isOpen) => {\n if (!isOpen) {\n answer(false);\n }\n }}\n role=\"alertdialog\"\n size=\"sm\"\n title={intl.formatMessage(messages.leaveTitle)}\n footer={\n <>\n <Button onPress={() => answer(false)} autoFocus>\n {intl.formatMessage(messages.stay)}\n </Button>\n <Button variant=\"danger\" onPress={() => answer(true)}>\n {intl.formatMessage(messages.leave)}\n </Button>\n </>\n }\n >\n {intl.formatMessage(messages.leaveMessage)}\n </Dialog>\n ),\n };\n}\n"],"mappings":";;;;;;;;;;AAUA,
|
|
1
|
+
{"version":3,"file":"unsaved.js","names":["ReactNode","useEffect","useRef","useState","Button","Dialog","usePanneauIntl","messages","useBeforeUnloadGuard","dirty","$","_c","t0","t1","listener","_temp","window","addEventListener","removeEventListener","event","preventDefault","returnValue","LeaveConfirmation","confirmLeave","Promise","dialog","useLeaveConfirmation","intl","open","setOpen","resolver","Symbol","for","leave","current","answer","resolve","t2","isOpen","t3","formatMessage","leaveTitle","t4","t5","stay","t6","t7","t8","t9","t10","t11","leaveMessage","t12","t13","_c","_Fragment"],"sources":["../src/unsaved.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useRef, useState } from 'react';\n\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\n\n/**\n * Asks the browser to confirm before the page is closed or reloaded while `dirty` is true. Forms\n * use it by default.\n */\nexport function useBeforeUnloadGuard(dirty: boolean): void {\n useEffect(() => {\n if (!dirty) {\n return undefined;\n }\n const listener = (event: BeforeUnloadEvent) => {\n event.preventDefault();\n // Older browsers show the dialog only with a return value.\n event.returnValue = '';\n };\n window.addEventListener('beforeunload', listener);\n return () => window.removeEventListener('beforeunload', listener);\n }, [dirty]);\n}\n\nexport interface LeaveConfirmation {\n /**\n * Resolves `true` when leaving is fine: right away without unsaved changes, or once the user\n * chose to leave in the dialog.\n */\n confirmLeave: () => Promise<boolean>;\n /** The dialog to render, while it is open. */\n dialog: ReactNode;\n}\n\n/**\n * Guards in-app navigation while a form has unsaved changes. Call `confirmLeave()` from the\n * router's navigation guard (or before closing a panel), and render `dialog`. The page itself is\n * guarded by `useBeforeUnloadGuard()`.\n */\nexport function useLeaveConfirmation(dirty: boolean): LeaveConfirmation {\n const intl = usePanneauIntl();\n const [open, setOpen] = useState(false);\n const resolver = useRef<((leave: boolean) => void) | null>(null);\n const answer = (leave: boolean) => {\n resolver.current?.(leave);\n resolver.current = null;\n setOpen(false);\n };\n return {\n confirmLeave: () => {\n if (!dirty) {\n return Promise.resolve(true);\n }\n resolver.current?.(false);\n setOpen(true);\n return new Promise<boolean>((resolve) => {\n resolver.current = resolve;\n });\n },\n dialog: (\n <Dialog\n isOpen={open}\n onOpenChange={(isOpen) => {\n if (!isOpen) {\n answer(false);\n }\n }}\n role=\"alertdialog\"\n size=\"sm\"\n title={intl.formatMessage(messages.leaveTitle)}\n footer={\n <>\n <Button onPress={() => answer(false)} autoFocus>\n {intl.formatMessage(messages.stay)}\n </Button>\n <Button variant=\"danger\" onPress={() => answer(true)}>\n {intl.formatMessage(messages.leave)}\n </Button>\n </>\n }\n >\n {intl.formatMessage(messages.leaveMessage)}\n </Dialog>\n ),\n };\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAOQ,qBAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAD,OAAA;EACOG,WAAA;GACN,IAAI,CAACH,OAAK;GAGV,MAAAK,WAAiBC;GAKjBC,OAAMC,iBAAkB,gBAAgBH,QAAQ;GAAC,aACpCE,OAAME,oBAAqB,gBAAgBJ,QAAQ;EAAC;EAClED,KAAA,CAACJ,KAAK;EAACC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAD,KAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAXVT,UAAUW,IAWPC,EAAO;AAAC;AAZR,SAAAE,MAAAI,OAAA;CAMKA,MAAKC,eAAgB;CAErBD,MAAKE,cAAe;AAAH;;;;;;AAsB7B,SAAOK,qBAAAjB,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACH,MAAAgB,OAAarB,eAAe;CAC5B,MAAA,CAAAsB,MAAAC,WAAwB1B,SAAS,KAAK;CACtC,MAAA2B,WAAiB5B,OAA0C,IAAI;CAAE,IAAAU;CAAA,IAAAF,EAAA,OAAAqB,OAAAC,IAAA,2BAAA,GAAA;EAClDpB,MAAAqB,UAAA;GACXH,SAAQI,UAAWD,KAAK;GACxBH,SAAQI,UAAW;GACnBL,QAAQ,KAAK;EAAC;EACjBnB,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAJD,MAAAyB,SAAevB;CAIb,IAAAC;CAAA,IAAAH,EAAA,OAAAD,OAAA;EAEgBI,WAAA;GACV,IAAI,CAACJ,OAAK,OACCe,QAAOY,QAAS,IAAI;GAE/BN,SAAQI,UAAW,KAAK;GACxBL,QAAQ,IA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AA,MAAA0C;EAAA1C,EAAA,MAAA2C;CAAA,OAAAA,MAAA3C,EAAA;CAAA,OApCM2C;AAoCN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/forms",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.20",
|
|
4
4
|
"description": "Forms of Panneau: fields in a layout, driven by the form state of @panneau/core, with errors, unsaved changes and version conflicts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"default": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
+
"./publication": {
|
|
22
|
+
"@panneau/source": "./src/publication/index.ts",
|
|
23
|
+
"types": "./dist/publication/index.d.ts",
|
|
24
|
+
"default": "./dist/publication/index.js"
|
|
25
|
+
},
|
|
21
26
|
"./locales": {
|
|
22
27
|
"@panneau/source": "./src/locales/index.ts",
|
|
23
28
|
"types": "./dist/locales/index.d.ts",
|
|
@@ -29,9 +34,9 @@
|
|
|
29
34
|
"dist"
|
|
30
35
|
],
|
|
31
36
|
"scripts": {
|
|
32
|
-
"build": "vite build &&
|
|
37
|
+
"build": "vite build && node ../../scripts/declarations.js",
|
|
33
38
|
"typecheck": "tsc --noEmit",
|
|
34
|
-
"api": "
|
|
39
|
+
"api": "node ../../scripts/declarations.js && node ../../scripts/api-report.js"
|
|
35
40
|
},
|
|
36
41
|
"publishConfig": {
|
|
37
42
|
"access": "public"
|
|
@@ -41,13 +46,15 @@
|
|
|
41
46
|
"react-intl": "^12.0.0"
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
44
|
-
"@panneau/core": "5.0.0-alpha.
|
|
45
|
-
"@panneau/fields": "5.0.0-alpha.
|
|
46
|
-
"@panneau/intl": "5.0.0-alpha.
|
|
47
|
-
"@panneau/protocol": "5.0.0-alpha.
|
|
48
|
-
"@panneau/ui": "5.0.0-alpha.
|
|
49
|
+
"@panneau/core": "5.0.0-alpha.20",
|
|
50
|
+
"@panneau/fields": "5.0.0-alpha.20",
|
|
51
|
+
"@panneau/intl": "5.0.0-alpha.20",
|
|
52
|
+
"@panneau/protocol": "5.0.0-alpha.20",
|
|
53
|
+
"@panneau/ui": "5.0.0-alpha.20",
|
|
54
|
+
"lucide-react": "^1.57.0"
|
|
49
55
|
},
|
|
50
56
|
"devDependencies": {
|
|
51
|
-
"@panneau/data": "5.0.0-alpha.
|
|
57
|
+
"@panneau/data": "5.0.0-alpha.20",
|
|
58
|
+
"@panneau/editor": "5.0.0-alpha.20"
|
|
52
59
|
}
|
|
53
60
|
}
|