@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
package/dist/context.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Form, FormState } from '@panneau/core';
|
|
2
|
+
import { type RevealRegistry } from '@panneau/fields';
|
|
2
3
|
export declare const FormContext: import("react").Context<Form | null>;
|
|
3
4
|
/** The form of the closest `FormView`. */
|
|
4
5
|
export declare function useFormContext(): Form;
|
|
5
6
|
/** The state of a form, updated on every change. */
|
|
6
7
|
export declare function useFormState(form: Form): FormState;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare
|
|
14
|
-
export declare const RevealContext: import("react").Context<RevealRegistry>;
|
|
8
|
+
export { RevealContext, createRevealRegistry } from '@panneau/fields';
|
|
9
|
+
/**
|
|
10
|
+
* Where a form asks its sections to open on the paths of its errors after a failed save: every
|
|
11
|
+
* collapsed section that holds one opens. Unlike `RevealContext`, tabs don't follow: one only
|
|
12
|
+
* can show, and each keeps its error count.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ErrorSectionsContext: import("react").Context<RevealRegistry>;
|
|
15
15
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,iBAAiB,CAAC;AAE5E,eAAO,MAAM,WAAW,sCAAmC,CAAC;AAE5D,0CAA0C;AAC1C,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAElD;AAID,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yCAAwD,CAAC"}
|
package/dist/context.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createContext, use, useSyncExternalStore } from "react";
|
|
2
|
+
import { RevealContext, createRevealRegistry, createRevealRegistry as createRevealRegistry$1 } from "@panneau/fields";
|
|
2
3
|
//#region src/context.ts
|
|
3
4
|
var FormContext = createContext(null);
|
|
4
5
|
/** The form of the closest `FormView`. */
|
|
@@ -11,22 +12,13 @@ function useFormContext() {
|
|
|
11
12
|
function useFormState(form) {
|
|
12
13
|
return useSyncExternalStore(form.subscribe, form.getState, form.getState);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
revealers.delete(revealer);
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
reveal(path) {
|
|
24
|
-
revealers.forEach((revealer) => revealer(path));
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
var RevealContext = createContext(createRevealRegistry());
|
|
15
|
+
/**
|
|
16
|
+
* Where a form asks its sections to open on the paths of its errors after a failed save: every
|
|
17
|
+
* collapsed section that holds one opens. Unlike `RevealContext`, tabs don't follow: one only
|
|
18
|
+
* can show, and each keeps its error count.
|
|
19
|
+
*/
|
|
20
|
+
var ErrorSectionsContext = createContext(createRevealRegistry());
|
|
29
21
|
//#endregion
|
|
30
|
-
export { FormContext, RevealContext, createRevealRegistry, useFormContext, useFormState };
|
|
22
|
+
export { ErrorSectionsContext, FormContext, RevealContext, createRevealRegistry$1 as createRevealRegistry, useFormContext, useFormState };
|
|
31
23
|
|
|
32
24
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import { createContext, use, useSyncExternalStore } from 'react';\n\nimport type { Form, FormState } from '@panneau/core';\n\nexport const FormContext = createContext<Form | null>(null);\n\n/** The form of the closest `FormView`. */\nexport function useFormContext(): Form {\n const form = use(FormContext);\n if (form === null) {\n throw new Error('This component must be rendered inside a <Form> or a <FormView>.');\n }\n return form;\n}\n\n/** The state of a form, updated on every change. */\nexport function useFormState(form: Form): FormState {\n return useSyncExternalStore(form.subscribe, form.getState, form.getState);\n}\n\n
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","use","useSyncExternalStore","Form","FormState","RevealRegistry","createRevealRegistry","FormContext","useFormContext","form","Error","useFormState","subscribe","getState","RevealContext","ErrorSectionsContext"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext, use, useSyncExternalStore } from 'react';\n\nimport type { Form, FormState } from '@panneau/core';\nimport { type RevealRegistry, createRevealRegistry } from '@panneau/fields';\n\nexport const FormContext = createContext<Form | null>(null);\n\n/** The form of the closest `FormView`. */\nexport function useFormContext(): Form {\n const form = use(FormContext);\n if (form === null) {\n throw new Error('This component must be rendered inside a <Form> or a <FormView>.');\n }\n return form;\n}\n\n/** The state of a form, updated on every change. */\nexport function useFormState(form: Form): FormState {\n return useSyncExternalStore(form.subscribe, form.getState, form.getState);\n}\n\n// The reveal registry is in `@panneau/fields`, for the fields that hide some of their own (the\n// locales of a localized field).\nexport { RevealContext, createRevealRegistry } from '@panneau/fields';\n\n/**\n * Where a form asks its sections to open on the paths of its errors after a failed save: every\n * collapsed section that holds one opens. Unlike `RevealContext`, tabs don't follow: one only\n * can show, and each keeps its error count.\n */\nexport const ErrorSectionsContext = createContext<RevealRegistry>(createRevealRegistry());\n"],"mappings":";;;AAKA,IAAaO,cAAcP,cAA2B,IAAI;;AAG1D,SAAgBQ,iBAAuB;CACnC,MAAMC,OAAOR,IAAIM,WAAW;CAC5B,IAAIE,SAAS,MACT,MAAM,IAAIC,MAAM,kEAAkE;CAEtF,OAAOD;AACX;;AAGA,SAAOE,aAAAF,MAAA;CAAA,OACIP,qBAAqBO,KAAIG,WAAYH,KAAII,UAAWJ,KAAII,QAAS;AAAC;;;;;;AAY7E,IAAaE,uBAAuBf,cAA8BM,qBAAqB,CAAC"}
|
package/dist/cx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cx.js","names":[],"sources":["../src/cx.ts"],"sourcesContent":["/** Joins class names, skipping empty ones. */\nexport function cx(...classNames: (string | false | null | undefined)[]): string {\n return classNames.filter(Boolean).join(' ');\n}\n"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"cx.js","names":["cx","classNames","filter","Boolean","join"],"sources":["../src/cx.ts"],"sourcesContent":["/** Joins class names, skipping empty ones. */\nexport function cx(...classNames: (string | false | null | undefined)[]): string {\n return classNames.filter(Boolean).join(' ');\n}\n"],"mappings":";;AACA,SAAgBA,GAAG,GAAGC,YAA2D;CAC7E,OAAOA,WAAWC,OAAOC,OAAO,CAAC,CAACC,KAAK,GAAG;AAC9C"}
|
package/dist/describe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","names":[],"sources":["../src/describe.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\nimport { getPathSteps } from './paths';\n\n/**\n * A readable name for the value at a path, from the labels of its fields: `Blocks › 3 › Body`,\n * `Title (fr)`. Unknown paths are returned as is.\n */\nexport function describePath(fields: readonly Field[], path: string): string {\n const steps = getPathSteps(fields, path);\n if (steps.length === 0) {\n return path;\n }\n return steps\n .map((step) => {\n const label = step.field.label ?? step.field.name;\n const locale = step.locale !== undefined ? ` (${step.locale})` : '';\n const index = step.index !== undefined ? ` › ${step.index + 1}` : '';\n return `${label}${locale}${index}`;\n })\n .join(' › ');\n}\n"],"mappings":";;;;;;AAQA,
|
|
1
|
+
{"version":3,"file":"describe.js","names":["Field","getPathSteps","describePath","fields","path","steps","length","map","step","label","field","name","locale","undefined","index","join"],"sources":["../src/describe.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\nimport { getPathSteps } from './paths';\n\n/**\n * A readable name for the value at a path, from the labels of its fields: `Blocks › 3 › Body`,\n * `Title (fr)`. Unknown paths are returned as is.\n */\nexport function describePath(fields: readonly Field[], path: string): string {\n const steps = getPathSteps(fields, path);\n if (steps.length === 0) {\n return path;\n }\n return steps\n .map((step) => {\n const label = step.field.label ?? step.field.name;\n const locale = step.locale !== undefined ? ` (${step.locale})` : '';\n const index = step.index !== undefined ? ` › ${step.index + 1}` : '';\n return `${label}${locale}${index}`;\n })\n .join(' › ');\n}\n"],"mappings":";;;;;;AAQA,SAAgBE,aAAaC,QAA0BC,MAAsB;CACzE,MAAMC,QAAQJ,aAAaE,QAAQC,IAAI;CACvC,IAAIC,MAAMC,WAAW,GACjB,OAAOF;CAEX,OAAOC,MACFE,KAAKC,SAAS;EAIX,OAAO,GAHOA,KAAKE,MAAMD,SAASD,KAAKE,MAAMC,OAC9BH,KAAKI,WAAWC,KAAAA,IAAY,KAAKL,KAAKI,OAAM,KAAM,KACnDJ,KAAKM,UAAUD,KAAAA,IAAY,MAAML,KAAKM,QAAQ,MAAM;CAEtE,CAAC,CAAC,CACDC,KAAK,KAAK;AACnB"}
|
package/dist/formatError.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Field, RuleFailure } from '@panneau/protocol';
|
|
2
2
|
/**
|
|
3
3
|
* Translates the failures of the portable rules with react-intl, for `formatError`. `min` and
|
|
4
|
-
* `max` say "characters" for texts and "items" for lists, from the field at the path
|
|
5
|
-
* `message` wins.
|
|
4
|
+
* `max` say "characters" for texts and "items" for lists, from the field at the path, and `crop`
|
|
5
|
+
* names its ratios. A rule's own `message` wins.
|
|
6
6
|
*/
|
|
7
7
|
export declare function useFormatRuleFailure(fields: readonly Field[]): (failure: RuleFailure, path: string) => string;
|
|
8
8
|
//# sourceMappingURL=formatError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatError.d.ts","sourceRoot":"","sources":["../src/formatError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatError.d.ts","sourceRoot":"","sources":["../src/formatError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAS5D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,SAAS,KAAK,EAAE,GACzB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CA6FhD"}
|
package/dist/formatError.js
CHANGED
|
@@ -2,17 +2,19 @@ import { messages } from "./messages.js";
|
|
|
2
2
|
import { getPathSteps } from "./paths.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { usePanneauIntl } from "@panneau/ui";
|
|
5
|
+
import { getNestedShape } from "@panneau/protocol/runtime";
|
|
6
|
+
import { formatMoney } from "@panneau/fields/money";
|
|
5
7
|
//#region src/formatError.ts
|
|
6
8
|
var COUNTED = /* @__PURE__ */ new Set([
|
|
7
|
-
"repeater",
|
|
8
9
|
"relation",
|
|
9
10
|
"media",
|
|
10
|
-
"select"
|
|
11
|
+
"select",
|
|
12
|
+
"country"
|
|
11
13
|
]);
|
|
12
14
|
/**
|
|
13
15
|
* Translates the failures of the portable rules with react-intl, for `formatError`. `min` and
|
|
14
|
-
* `max` say "characters" for texts and "items" for lists, from the field at the path
|
|
15
|
-
* `message` wins.
|
|
16
|
+
* `max` say "characters" for texts and "items" for lists, from the field at the path, and `crop`
|
|
17
|
+
* names its ratios. A rule's own `message` wins.
|
|
16
18
|
*/
|
|
17
19
|
function useFormatRuleFailure(fields) {
|
|
18
20
|
const $ = c(3);
|
|
@@ -24,12 +26,30 @@ function useFormatRuleFailure(fields) {
|
|
|
24
26
|
const step = getPathSteps(fields, path).at(-1);
|
|
25
27
|
const field = step?.field;
|
|
26
28
|
const value = typeof failure.value === "number" ? failure.value : 0;
|
|
29
|
+
if ((failure.rule === "min" || failure.rule === "max") && field?.type === "money") {
|
|
30
|
+
const currency = field.settings?.currency;
|
|
31
|
+
const amount = formatMoney({
|
|
32
|
+
amount: value,
|
|
33
|
+
currency: typeof currency === "string" ? currency : null
|
|
34
|
+
}, intl.locale) ?? String(value);
|
|
35
|
+
return intl.formatMessage(failure.rule === "min" ? messages.rule.minAmount : messages.rule.maxAmount, { value: amount });
|
|
36
|
+
}
|
|
37
|
+
if (failure.rule === "daterange") return intl.formatMessage(failure.value === "start" ? messages.rule.daterangeStart : failure.value === "end" ? messages.rule.daterangeEnd : messages.rule.daterangeOrder);
|
|
27
38
|
if (failure.rule === "min" || failure.rule === "max") {
|
|
28
|
-
const list = field !== void 0 && step?.index === void 0 &&
|
|
39
|
+
const list = field !== void 0 && step?.index === void 0 && (getNestedShape(field) === "repeater" || COUNTED.has(field.type) && field.multiple === true);
|
|
29
40
|
const numeric = field?.type === "number";
|
|
30
41
|
const key = list ? failure.rule === "min" ? "minItems" : "maxItems" : numeric ? failure.rule : failure.rule === "min" ? "minLength" : "maxLength";
|
|
31
42
|
return intl.formatMessage(messages.rule[key], { value });
|
|
32
43
|
}
|
|
44
|
+
if (failure.rule === "crop") {
|
|
45
|
+
const given = typeof failure.value === "object" && failure.value !== null ? failure.value.ratios : void 0;
|
|
46
|
+
const ratios = Array.isArray(given) ? given.filter(_temp) : [];
|
|
47
|
+
return ratios.length > 0 ? intl.formatMessage(messages.rule.cropRatios, { ratios: intl.formatList(ratios, { type: "disjunction" }) }) : intl.formatMessage(messages.rule.crop);
|
|
48
|
+
}
|
|
49
|
+
if (failure.rule === "providers") {
|
|
50
|
+
const providers = Array.isArray(failure.value) ? failure.value.filter(_temp2) : [];
|
|
51
|
+
return intl.formatMessage(messages.rule.providers, { providers: intl.formatList(providers, { type: "disjunction" }) });
|
|
52
|
+
}
|
|
33
53
|
const rule = failure.rule;
|
|
34
54
|
if (rule in messages.rule && rule !== "min" && rule !== "max") return intl.formatMessage(messages.rule[rule]);
|
|
35
55
|
return intl.formatMessage(messages.rule.invalid);
|
|
@@ -40,6 +60,12 @@ function useFormatRuleFailure(fields) {
|
|
|
40
60
|
} else t0 = $[2];
|
|
41
61
|
return t0;
|
|
42
62
|
}
|
|
63
|
+
function _temp2(name) {
|
|
64
|
+
return typeof name === "string";
|
|
65
|
+
}
|
|
66
|
+
function _temp(ratio) {
|
|
67
|
+
return typeof ratio === "string";
|
|
68
|
+
}
|
|
43
69
|
//#endregion
|
|
44
70
|
export { useFormatRuleFailure };
|
|
45
71
|
|
package/dist/formatError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatError.js","names":["_c"],"sources":["../src/formatError.ts"],"sourcesContent":["import type { Field, RuleFailure } from '@panneau/protocol';\nimport { usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getPathSteps } from './paths';\n\nconst COUNTED = new Set(['
|
|
1
|
+
{"version":3,"file":"formatError.js","names":["formatMoney","Field","RuleFailure","getNestedShape","usePanneauIntl","messages","getPathSteps","COUNTED","Set","useFormatRuleFailure","fields","$","_c","intl","t0","failure","path","message","undefined","step","at","field","value","rule","type","currency","settings","amount","locale","String","formatMessage","minAmount","maxAmount","daterangeStart","daterangeEnd","daterangeOrder","list","index","has","multiple","numeric","key","given","ratios","Array","isArray","filter","_temp","length","cropRatios","formatList","crop","providers","_temp2","Exclude","invalid","name","ratio","_c"],"sources":["../src/formatError.ts"],"sourcesContent":["import { formatMoney } from '@panneau/fields/money';\nimport type { Field, RuleFailure } from '@panneau/protocol';\nimport { getNestedShape } from '@panneau/protocol/runtime';\nimport { usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getPathSteps } from './paths';\n\nconst COUNTED = new Set(['relation', 'media', 'select', 'country']);\n\n/**\n * Translates the failures of the portable rules with react-intl, for `formatError`. `min` and\n * `max` say \"characters\" for texts and \"items\" for lists, from the field at the path, and `crop`\n * names its ratios. A rule's own `message` wins.\n */\nexport function useFormatRuleFailure(\n fields: readonly Field[],\n): (failure: RuleFailure, path: string) => string {\n const intl = usePanneauIntl();\n return (failure, path) => {\n if (failure.message !== undefined) {\n return failure.message;\n }\n const step = getPathSteps(fields, path).at(-1);\n const field = step?.field;\n const value = typeof failure.value === 'number' ? failure.value : 0;\n if ((failure.rule === 'min' || failure.rule === 'max') && field?.type === 'money') {\n // An amount in minor units, in the currency of the field (decision 0053).\n const currency = field.settings?.currency;\n const amount =\n formatMoney(\n { amount: value, currency: typeof currency === 'string' ? currency : null },\n intl.locale,\n ) ?? String(value);\n return intl.formatMessage(\n failure.rule === 'min' ? messages.rule.minAmount : messages.rule.maxAmount,\n { value: amount },\n );\n }\n if (failure.rule === 'daterange') {\n return intl.formatMessage(\n failure.value === 'start'\n ? messages.rule.daterangeStart\n : failure.value === 'end'\n ? messages.rule.daterangeEnd\n : messages.rule.daterangeOrder,\n );\n }\n if (failure.rule === 'min' || failure.rule === 'max') {\n const list =\n field !== undefined &&\n step?.index === undefined &&\n (getNestedShape(field) === 'repeater' ||\n (COUNTED.has(field.type) && field.multiple === true));\n const numeric = field?.type === 'number';\n const key = list\n ? failure.rule === 'min'\n ? 'minItems'\n : 'maxItems'\n : numeric\n ? failure.rule\n : failure.rule === 'min'\n ? 'minLength'\n : 'maxLength';\n return intl.formatMessage(messages.rule[key], { value });\n }\n if (failure.rule === 'crop') {\n const given =\n typeof failure.value === 'object' && failure.value !== null\n ? (failure.value as { ratios?: unknown }).ratios\n : undefined;\n const ratios = Array.isArray(given)\n ? given.filter((ratio): ratio is string => typeof ratio === 'string')\n : [];\n return ratios.length > 0\n ? intl.formatMessage(messages.rule.cropRatios, {\n ratios: intl.formatList(ratios, { type: 'disjunction' }),\n })\n : intl.formatMessage(messages.rule.crop);\n }\n if (failure.rule === 'providers') {\n const providers = Array.isArray(failure.value)\n ? failure.value.filter((name): name is string => typeof name === 'string')\n : [];\n return intl.formatMessage(messages.rule.providers, {\n providers: intl.formatList(providers, { type: 'disjunction' }),\n });\n }\n const rule = failure.rule as keyof typeof messages.rule;\n if (rule in messages.rule && rule !== 'min' && rule !== 'max') {\n return intl.formatMessage(\n messages.rule[\n rule as Exclude<\n typeof rule,\n | 'min'\n | 'max'\n | 'minLength'\n | 'maxLength'\n | 'minItems'\n | 'maxItems'\n | 'cropRatios'\n | 'providers'\n | 'minAmount'\n | 'maxAmount'\n >\n ],\n );\n }\n return intl.formatMessage(messages.rule.invalid);\n };\n}\n"],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { ConflictDialog, type ConflictDialogProps } from './ConflictDialog';
|
|
2
|
-
export { describePath } from './describe';
|
|
3
|
-
export { ErrorSummary, type ErrorSummaryProps } from './ErrorSummary';
|
|
4
|
-
export { Form, type FormProps } from './Form';
|
|
5
|
-
export { FormBinding } from './FormBinding';
|
|
6
|
-
export { FormView, type FormViewProps } from './FormView';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
1
|
+
export { ConflictDialog, type ConflictDialogProps } from './ConflictDialog.js';
|
|
2
|
+
export { describePath } from './describe.js';
|
|
3
|
+
export { ErrorSummary, type ErrorSummaryProps } from './ErrorSummary.js';
|
|
4
|
+
export { Form, type FormProps } from './Form.js';
|
|
5
|
+
export { FormBinding } from './FormBinding.js';
|
|
6
|
+
export { FormView, type FormViewProps } from './FormView.js';
|
|
7
|
+
export type { LayoutComponentProps } from './layout/Layout.js';
|
|
8
|
+
export { useFormContext, useFormState } from './context.js';
|
|
9
|
+
export { useFormatRuleFailure } from './formatError.js';
|
|
10
|
+
export { type LeaveConfirmation, useBeforeUnloadGuard, useLeaveConfirmation } from './unsaved.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/layout/Layout.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Form } from '@panneau/core';
|
|
2
3
|
import type { Field, LayoutNode } from '@panneau/protocol';
|
|
3
4
|
export interface LayoutProps {
|
|
4
5
|
nodes: readonly LayoutNode[];
|
|
5
6
|
fields: ReadonlyMap<string, Field>;
|
|
6
7
|
}
|
|
8
|
+
/** What the component of a `component` node of a form layout gets, with the node's `props`. */
|
|
9
|
+
export interface LayoutComponentProps {
|
|
10
|
+
node: LayoutNode;
|
|
11
|
+
form: Form;
|
|
12
|
+
/** The fields of the form, by name. */
|
|
13
|
+
fields: ReadonlyMap<string, Field>;
|
|
14
|
+
/** The node's children, rendered: the fields a component frames (decision 0065). */
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
7
17
|
/** Renders layout nodes in order. */
|
|
8
18
|
export declare function LayoutNodes({ nodes, fields }: LayoutProps): ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Fields that the layout doesn't place, in columns: short fields side by side, wide ones
|
|
21
|
+
* (`isWideField()`) on their own row.
|
|
22
|
+
*/
|
|
23
|
+
export declare function FieldFlow({ nodes, fields }: LayoutProps): ReactNode;
|
|
9
24
|
//# sourceMappingURL=Layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/layout/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,SAAS,EAMjB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/layout/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,SAAS,EAMjB,MAAM,OAAO,CAAC;AAEf,OAAO,EACH,KAAK,IAAI,EAKZ,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ3D,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACtC;AAgID,+FAA+F;AAC/F,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,uCAAuC;IACvC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,oFAAoF;IACpF,QAAQ,EAAE,SAAS,CAAC;CACvB;AA2ED,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,GAAG,SAAS,CAErE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,GAAG,SAAS,CAmBnE"}
|