@panneau/forms 5.0.0-alpha.10 → 5.0.0-alpha.12
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/dist/Form.css +21 -0
- package/dist/Form.d.ts.map +1 -1
- package/dist/Form.js +5 -5
- package/dist/Form.js.map +1 -1
- package/dist/Form.module.js +7 -1
- package/dist/Form.module.js.map +1 -1
- package/dist/FormBinding.d.ts.map +1 -1
- package/dist/FormBinding.js +70 -65
- package/dist/FormBinding.js.map +1 -1
- package/dist/FormSkeleton.d.ts +4 -2
- package/dist/FormSkeleton.d.ts.map +1 -1
- package/dist/FormSkeleton.js +106 -69
- package/dist/FormSkeleton.js.map +1 -1
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +117 -100
- package/dist/FormView.js.map +1 -1
- package/dist/context.d.ts +1 -8
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -15
- package/dist/context.js.map +1 -1
- package/dist/layout/Layout.d.ts +5 -0
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +43 -2
- package/dist/layout/Layout.js.map +1 -1
- package/package.json +7 -7
package/dist/Form.css
CHANGED
|
@@ -38,6 +38,27 @@
|
|
|
38
38
|
min-width: 0;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/* Fields that the layout doesn't place: short ones side by side, in columns of at least 16rem. */
|
|
42
|
+
.panneau-form-flow {
|
|
43
|
+
display: grid;
|
|
44
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
|
|
45
|
+
gap: var(--panneau-space-5) var(--panneau-space-4);
|
|
46
|
+
min-width: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.panneau-form-flow-cell {
|
|
50
|
+
min-width: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* A field hidden by its condition renders nothing: its cell takes no column. */
|
|
54
|
+
.panneau-form-flow-cell:empty {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.panneau-form-flow-wide {
|
|
59
|
+
grid-column: 1 / -1;
|
|
60
|
+
}
|
|
61
|
+
|
|
41
62
|
/* Narrow containers (phones, side panels): every cell takes the full width. */
|
|
42
63
|
@container panneau-form (max-width: 36rem) {
|
|
43
64
|
.panneau-form-cell {
|
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;;;;;;;;;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,+
|
|
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,+BA2BX"}
|
package/dist/Form.js
CHANGED
|
@@ -119,19 +119,19 @@ function Form(t0) {
|
|
|
119
119
|
} else t9 = $[32];
|
|
120
120
|
const { form } = useForm(t9);
|
|
121
121
|
let t10;
|
|
122
|
-
if ($[33] !== form || $[34] !== formLocales || $[35] !==
|
|
122
|
+
if ($[33] !== form || $[34] !== formLocales || $[35] !== layout || $[36] !== props || $[37] !== resolved.fields) {
|
|
123
123
|
t10 = /* @__PURE__ */ jsx(FormView, {
|
|
124
124
|
...props,
|
|
125
125
|
form,
|
|
126
126
|
fields: resolved.fields,
|
|
127
|
-
layout
|
|
127
|
+
layout,
|
|
128
128
|
locales: formLocales
|
|
129
129
|
});
|
|
130
130
|
$[33] = form;
|
|
131
131
|
$[34] = formLocales;
|
|
132
|
-
$[35] =
|
|
133
|
-
$[36] =
|
|
134
|
-
$[37] = resolved.
|
|
132
|
+
$[35] = layout;
|
|
133
|
+
$[36] = props;
|
|
134
|
+
$[37] = resolved.fields;
|
|
135
135
|
$[38] = t10;
|
|
136
136
|
} else t10 = $[38];
|
|
137
137
|
return t10;
|
package/dist/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 layout={
|
|
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 // The layout as given: fields it doesn't place flow in columns at the end\n layout={layout}\n locales={formLocales}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,SAAOc,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAL;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAV,EAAA,OAAAD,IAAA;EAAc,CAAA,CAAAH,QAAAC,QAAAW,IAAAC,QAAAC,SAAAN,MAAAG,OAAAL,aAAAG,UAAAF,SAAA,GAAAG,SAAAP;EAWTC,EAAA,KAAAD;EAAAC,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAA;EAAAd,SAAAI,EAAA;EAAAE,cAAAF,EAAA;EAAAG,UAAAH,EAAA;EAAAI,OAAAJ,EAAA;EAAAK,WAAAL,EAAA;EAAAM,QAAAN,EAAA;EAAAO,QAAAP,EAAA;EAAAQ,KAAAR,EAAA;EAAAS,SAAAT,EAAA;EAAAU,UAAAV,EAAA;CAAA;CATR,MA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OAPF0B;AAOE"}
|
package/dist/Form.module.js
CHANGED
|
@@ -6,6 +6,9 @@ var withSidebar = "panneau-form-with-sidebar";
|
|
|
6
6
|
var stack = "panneau-form-stack";
|
|
7
7
|
var row = "panneau-form-row";
|
|
8
8
|
var cell = "panneau-form-cell";
|
|
9
|
+
var flow = "panneau-form-flow";
|
|
10
|
+
var flowCell = "panneau-form-flow-cell";
|
|
11
|
+
var flowWide = "panneau-form-flow-wide";
|
|
9
12
|
var section = "panneau-form-section";
|
|
10
13
|
var sectionHeader = "panneau-form-section-header";
|
|
11
14
|
var sectionDescription = "panneau-form-section-description";
|
|
@@ -29,6 +32,9 @@ var Form_module_default = {
|
|
|
29
32
|
stack,
|
|
30
33
|
row,
|
|
31
34
|
cell,
|
|
35
|
+
flow,
|
|
36
|
+
flowCell,
|
|
37
|
+
flowWide,
|
|
32
38
|
section,
|
|
33
39
|
sectionHeader,
|
|
34
40
|
sectionDescription,
|
|
@@ -47,6 +53,6 @@ var Form_module_default = {
|
|
|
47
53
|
skeletonTabs
|
|
48
54
|
};
|
|
49
55
|
//#endregion
|
|
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 };
|
|
56
|
+
export { cell, Form_module_default as default, dirty, field, flow, flowCell, flowWide, footer, form, layout, row, section, sectionDescription, sectionHeader, sectionTitle, sidebar, skeletonField, skeletonInline, skeletonLabel, skeletonTabs, stack, summary, summaryLink, summaryList, text, withSidebar };
|
|
51
57
|
|
|
52
58
|
//# 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.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":""}
|
|
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/* Fields that the layout doesn't place: short ones side by side, in columns of at least 16rem. */\n.flow {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.flowCell {\n min-width: 0;\n}\n\n/* A field hidden by its condition renders nothing: its cell takes no column. */\n.flowCell:empty {\n display: none;\n}\n\n.flowWide {\n grid-column: 1 / -1;\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":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBinding.d.ts","sourceRoot":"","sources":["../src/FormBinding.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAazD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"FormBinding.d.ts","sourceRoot":"","sources":["../src/FormBinding.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAazD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,iBAAiB,sCAwCjF"}
|
package/dist/FormBinding.js
CHANGED
|
@@ -17,30 +17,32 @@ function rendersNestedFields(field) {
|
|
|
17
17
|
* keeps a field that throws from breaking the form.
|
|
18
18
|
*/
|
|
19
19
|
function FormBinding(t0) {
|
|
20
|
-
const $ = c(
|
|
20
|
+
const $ = c(31);
|
|
21
21
|
const { field, path, parentPath, render } = t0;
|
|
22
22
|
const form = useFormContext();
|
|
23
23
|
const intl = usePanneauIntl();
|
|
24
24
|
const state = useFormState(form);
|
|
25
25
|
if (!selectVisible(state, field, parentPath)) return null;
|
|
26
|
-
let T0;
|
|
27
26
|
let t1;
|
|
27
|
+
if ($[0] !== field) {
|
|
28
|
+
t1 = rendersNestedFields(field);
|
|
29
|
+
$[0] = field;
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else t1 = $[1];
|
|
32
|
+
const nested = t1;
|
|
33
|
+
let T0;
|
|
28
34
|
let t2;
|
|
29
35
|
let t3;
|
|
30
36
|
let t4;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else t5 = $[12];
|
|
38
|
-
const errors = selectErrors(state, path, { nested: !t5 });
|
|
39
|
-
t3 = Form_module_default.field;
|
|
40
|
-
t4 = path;
|
|
37
|
+
let t5;
|
|
38
|
+
if ($[2] !== field.label || $[3] !== field.name || $[4] !== form || $[5] !== intl || $[6] !== nested || $[7] !== path || $[8] !== render || $[9] !== state) {
|
|
39
|
+
const errors = selectErrors(state, path, { nested: !nested });
|
|
40
|
+
const invalidPaths = nested ? Object.keys(state.errors).filter((key) => key.startsWith(`${path}.`)) : [];
|
|
41
|
+
t4 = Form_module_default.field;
|
|
42
|
+
t5 = path;
|
|
41
43
|
T0 = FieldErrorBoundary;
|
|
42
|
-
if ($[
|
|
43
|
-
|
|
44
|
+
if ($[15] !== field.label || $[16] !== field.name || $[17] !== intl) {
|
|
45
|
+
t2 = (retry) => /* @__PURE__ */ jsx(Alert, {
|
|
44
46
|
tone: "danger",
|
|
45
47
|
actions: /* @__PURE__ */ jsx(Button, {
|
|
46
48
|
size: "sm",
|
|
@@ -49,72 +51,75 @@ function FormBinding(t0) {
|
|
|
49
51
|
}),
|
|
50
52
|
children: intl.formatMessage(messages.fieldCrashed, { field: field.label ?? field.name })
|
|
51
53
|
});
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
} else
|
|
54
|
+
$[15] = field.label;
|
|
55
|
+
$[16] = field.name;
|
|
56
|
+
$[17] = intl;
|
|
57
|
+
$[18] = t2;
|
|
58
|
+
} else t2 = $[18];
|
|
57
59
|
let t6;
|
|
58
60
|
let t7;
|
|
59
|
-
if ($[
|
|
61
|
+
if ($[19] !== form || $[20] !== path) {
|
|
60
62
|
t6 = (value) => form.setValue(path, value);
|
|
61
63
|
t7 = () => form.blur(path);
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
64
|
+
$[19] = form;
|
|
65
|
+
$[20] = path;
|
|
66
|
+
$[21] = t6;
|
|
67
|
+
$[22] = t7;
|
|
66
68
|
} else {
|
|
67
|
-
t6 = $[
|
|
68
|
-
t7 = $[
|
|
69
|
+
t6 = $[21];
|
|
70
|
+
t7 = $[22];
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
t3 = render({
|
|
71
73
|
value: selectValue(state, path),
|
|
72
74
|
onChange: t6,
|
|
73
75
|
onBlur: t7,
|
|
74
|
-
errors
|
|
76
|
+
errors,
|
|
77
|
+
...invalidPaths.length > 0 ? { invalidPaths } : {}
|
|
75
78
|
});
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
$[
|
|
79
|
+
$[2] = field.label;
|
|
80
|
+
$[3] = field.name;
|
|
81
|
+
$[4] = form;
|
|
82
|
+
$[5] = intl;
|
|
83
|
+
$[6] = nested;
|
|
84
|
+
$[7] = path;
|
|
85
|
+
$[8] = render;
|
|
86
|
+
$[9] = state;
|
|
87
|
+
$[10] = T0;
|
|
88
|
+
$[11] = t2;
|
|
89
|
+
$[12] = t3;
|
|
90
|
+
$[13] = t4;
|
|
91
|
+
$[14] = t5;
|
|
87
92
|
} else {
|
|
88
|
-
T0 = $[
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
T0 = $[10];
|
|
94
|
+
t2 = $[11];
|
|
95
|
+
t3 = $[12];
|
|
96
|
+
t4 = $[13];
|
|
97
|
+
t5 = $[14];
|
|
93
98
|
}
|
|
94
|
-
let t5;
|
|
95
|
-
if ($[21] !== T0 || $[22] !== t1 || $[23] !== t2) {
|
|
96
|
-
t5 = /* @__PURE__ */ jsx(T0, {
|
|
97
|
-
fallback: t1,
|
|
98
|
-
children: t2
|
|
99
|
-
});
|
|
100
|
-
$[21] = T0;
|
|
101
|
-
$[22] = t1;
|
|
102
|
-
$[23] = t2;
|
|
103
|
-
$[24] = t5;
|
|
104
|
-
} else t5 = $[24];
|
|
105
99
|
let t6;
|
|
106
|
-
if ($[
|
|
107
|
-
t6 = /* @__PURE__ */ jsx(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
children: t5
|
|
100
|
+
if ($[23] !== T0 || $[24] !== t2 || $[25] !== t3) {
|
|
101
|
+
t6 = /* @__PURE__ */ jsx(T0, {
|
|
102
|
+
fallback: t2,
|
|
103
|
+
children: t3
|
|
111
104
|
});
|
|
105
|
+
$[23] = T0;
|
|
106
|
+
$[24] = t2;
|
|
112
107
|
$[25] = t3;
|
|
113
|
-
$[26] =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
$[26] = t6;
|
|
109
|
+
} else t6 = $[26];
|
|
110
|
+
let t7;
|
|
111
|
+
if ($[27] !== t4 || $[28] !== t5 || $[29] !== t6) {
|
|
112
|
+
t7 = /* @__PURE__ */ jsx("div", {
|
|
113
|
+
className: t4,
|
|
114
|
+
"data-panneau-path": t5,
|
|
115
|
+
children: t6
|
|
116
|
+
});
|
|
117
|
+
$[27] = t4;
|
|
118
|
+
$[28] = t5;
|
|
119
|
+
$[29] = t6;
|
|
120
|
+
$[30] = t7;
|
|
121
|
+
} else t7 = $[30];
|
|
122
|
+
return t7;
|
|
118
123
|
}
|
|
119
124
|
//#endregion
|
|
120
125
|
export { FormBinding };
|
package/dist/FormBinding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","t1","nested","T0","t2","t3","t4","t5","label","name","errors","invalidPaths","Object","keys","filter","key","startsWith","retry","formatMessage","fieldCrashed","t6","t7","value","setValue","blur","onChange","onBlur","length","_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 nested = rendersNestedFields(field);\n const errors = selectErrors(state, path, { nested: !nested });\n const invalidPaths = nested\n ? Object.keys(state.errors).filter((key) => key.startsWith(`${path}.`))\n : [];\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 ...(invalidPaths.length > 0 ? { invalidPaths } : {}),\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,IAAA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,WAAAf;GAAiCX,qBAAAA;GAC7CyB,UAAAA;EAwBE,CAAA;EAAA3B,EAAA,MAAAa;EAAAb,EAAA,MAAAc;EAAAd,EAAA,MAAA2B;EAAA3B,EAAA,MAAA4B;CAAA,OAAAA,KAAA5B,EAAA;CAAA,OAzBN4B;AAyBM"}
|
package/dist/FormSkeleton.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Field, LayoutNode } from '@panneau/protocol';
|
|
2
2
|
export interface FormSkeletonProps {
|
|
3
|
-
/** The main nodes of the layout
|
|
3
|
+
/** The main nodes of the layout. */
|
|
4
4
|
main: readonly LayoutNode[];
|
|
5
|
+
/** The fields that the layout doesn't place, which flow in columns after it. */
|
|
6
|
+
flow?: readonly LayoutNode[];
|
|
5
7
|
/** The sidebars of the layout. */
|
|
6
8
|
sidebar: readonly LayoutNode[];
|
|
7
9
|
fields: ReadonlyMap<string, Field>;
|
|
@@ -17,5 +19,5 @@ export interface FormSkeletonProps {
|
|
|
17
19
|
* of the field's height, from its type. The fields of the first tab are drawn, and conditions are
|
|
18
20
|
* not checked, since there are no values yet.
|
|
19
21
|
*/
|
|
20
|
-
export declare function FormSkeleton({ main, sidebar, fields, footer, className, layoutClassName, sidebarClassName, footerClassName, }: FormSkeletonProps): import("react").JSX.Element;
|
|
22
|
+
export declare function FormSkeleton({ main, flow, sidebar, fields, footer, className, layoutClassName, sidebarClassName, footerClassName, }: FormSkeletonProps): import("react").JSX.Element;
|
|
21
23
|
//# sourceMappingURL=FormSkeleton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormSkeleton.d.ts","sourceRoot":"","sources":["../src/FormSkeleton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormSkeleton.d.ts","sourceRoot":"","sources":["../src/FormSkeleton.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA8H3D,MAAM,WAAW,iBAAiB;IAC9B,oCAAoC;IACpC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5B,gFAAgF;IAChF,IAAI,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,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,IAAS,EACT,OAAO,EACP,MAAM,EACN,MAAM,EACN,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,eAAe,GAClB,EAAE,iBAAiB,+BAwDnB"}
|
package/dist/FormSkeleton.js
CHANGED
|
@@ -4,6 +4,7 @@ import { cx } from "./cx.js";
|
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
5
|
import { LoadingRegion, Skeleton, usePanneauIntl } from "@panneau/ui";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { isWideField } from "@panneau/fields";
|
|
7
8
|
//#region src/FormSkeleton.tsx
|
|
8
9
|
/** The height of a field's control, by type: one line, unless the type says otherwise. */
|
|
9
10
|
var HEIGHTS = {
|
|
@@ -309,67 +310,103 @@ function NodesSkeleton(t0) {
|
|
|
309
310
|
* not checked, since there are no values yet.
|
|
310
311
|
*/
|
|
311
312
|
function FormSkeleton(t0) {
|
|
312
|
-
const $ = c(
|
|
313
|
-
const { main, sidebar, fields, footer, className, layoutClassName, sidebarClassName, footerClassName } = t0;
|
|
314
|
-
const intl = usePanneauIntl();
|
|
315
|
-
let t1;
|
|
316
|
-
if ($[0] !== intl) {
|
|
317
|
-
t1 = intl.formatMessage(messages.loading);
|
|
318
|
-
$[0] = intl;
|
|
319
|
-
$[1] = t1;
|
|
320
|
-
} else t1 = $[1];
|
|
313
|
+
const $ = c(34);
|
|
314
|
+
const { main, flow: t1, sidebar, fields, footer, className, layoutClassName, sidebarClassName, footerClassName } = t0;
|
|
321
315
|
let t2;
|
|
322
|
-
if ($[
|
|
323
|
-
t2 =
|
|
324
|
-
$[
|
|
325
|
-
$[
|
|
326
|
-
} else t2 = $[
|
|
327
|
-
const
|
|
316
|
+
if ($[0] !== t1) {
|
|
317
|
+
t2 = t1 === void 0 ? [] : t1;
|
|
318
|
+
$[0] = t1;
|
|
319
|
+
$[1] = t2;
|
|
320
|
+
} else t2 = $[1];
|
|
321
|
+
const flow = t2;
|
|
322
|
+
const intl = usePanneauIntl();
|
|
323
|
+
let t3;
|
|
324
|
+
if ($[2] !== intl) {
|
|
325
|
+
t3 = intl.formatMessage(messages.loading);
|
|
326
|
+
$[2] = intl;
|
|
327
|
+
$[3] = t3;
|
|
328
|
+
} else t3 = $[3];
|
|
328
329
|
let t4;
|
|
329
|
-
if ($[4] !==
|
|
330
|
-
t4 = cx(Form_module_default.
|
|
331
|
-
$[4] =
|
|
332
|
-
$[5] =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
let
|
|
336
|
-
if ($[
|
|
337
|
-
|
|
330
|
+
if ($[4] !== className) {
|
|
331
|
+
t4 = cx(Form_module_default.form, className);
|
|
332
|
+
$[4] = className;
|
|
333
|
+
$[5] = t4;
|
|
334
|
+
} else t4 = $[5];
|
|
335
|
+
const t5 = sidebar.length > 0 && Form_module_default.withSidebar;
|
|
336
|
+
let t6;
|
|
337
|
+
if ($[6] !== layoutClassName || $[7] !== t5) {
|
|
338
|
+
t6 = cx(Form_module_default.layout, t5, layoutClassName);
|
|
339
|
+
$[6] = layoutClassName;
|
|
340
|
+
$[7] = t5;
|
|
341
|
+
$[8] = t6;
|
|
342
|
+
} else t6 = $[8];
|
|
343
|
+
let t7;
|
|
344
|
+
if ($[9] !== fields || $[10] !== main) {
|
|
345
|
+
t7 = /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
338
346
|
nodes: main,
|
|
339
347
|
fields
|
|
340
348
|
});
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
} else
|
|
345
|
-
let
|
|
346
|
-
if ($[
|
|
347
|
-
|
|
349
|
+
$[9] = fields;
|
|
350
|
+
$[10] = main;
|
|
351
|
+
$[11] = t7;
|
|
352
|
+
} else t7 = $[11];
|
|
353
|
+
let t8;
|
|
354
|
+
if ($[12] !== fields || $[13] !== flow) {
|
|
355
|
+
t8 = flow.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
356
|
+
className: Form_module_default.flow,
|
|
357
|
+
children: flow.map((node, index) => {
|
|
358
|
+
const field = node.name !== void 0 ? fields.get(node.name) : void 0;
|
|
359
|
+
return /* @__PURE__ */ jsx("div", {
|
|
360
|
+
className: cx(Form_module_default.flowCell, (field === void 0 || isWideField(field)) && Form_module_default.flowWide),
|
|
361
|
+
children: /* @__PURE__ */ jsx(NodeSkeleton, {
|
|
362
|
+
node,
|
|
363
|
+
fields
|
|
364
|
+
})
|
|
365
|
+
}, index);
|
|
366
|
+
})
|
|
367
|
+
}) : null;
|
|
368
|
+
$[12] = fields;
|
|
369
|
+
$[13] = flow;
|
|
370
|
+
$[14] = t8;
|
|
371
|
+
} else t8 = $[14];
|
|
372
|
+
let t9;
|
|
373
|
+
if ($[15] !== t7 || $[16] !== t8) {
|
|
374
|
+
t9 = /* @__PURE__ */ jsxs("div", {
|
|
375
|
+
className: Form_module_default.stack,
|
|
376
|
+
children: [t7, t8]
|
|
377
|
+
});
|
|
378
|
+
$[15] = t7;
|
|
379
|
+
$[16] = t8;
|
|
380
|
+
$[17] = t9;
|
|
381
|
+
} else t9 = $[17];
|
|
382
|
+
let t10;
|
|
383
|
+
if ($[18] !== fields || $[19] !== sidebar || $[20] !== sidebarClassName) {
|
|
384
|
+
t10 = sidebar.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
348
385
|
className: cx(Form_module_default.sidebar, sidebarClassName),
|
|
349
|
-
children: sidebar.map((
|
|
350
|
-
nodes:
|
|
386
|
+
children: sidebar.map((node_0, index_0) => /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
387
|
+
nodes: node_0.children ?? [],
|
|
351
388
|
fields
|
|
352
|
-
},
|
|
389
|
+
}, index_0))
|
|
353
390
|
}) : null;
|
|
354
|
-
$[
|
|
355
|
-
$[
|
|
356
|
-
$[
|
|
357
|
-
$[
|
|
358
|
-
} else
|
|
359
|
-
let
|
|
360
|
-
if ($[
|
|
361
|
-
|
|
362
|
-
className:
|
|
363
|
-
children: [
|
|
391
|
+
$[18] = fields;
|
|
392
|
+
$[19] = sidebar;
|
|
393
|
+
$[20] = sidebarClassName;
|
|
394
|
+
$[21] = t10;
|
|
395
|
+
} else t10 = $[21];
|
|
396
|
+
let t11;
|
|
397
|
+
if ($[22] !== t10 || $[23] !== t6 || $[24] !== t9) {
|
|
398
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
399
|
+
className: t6,
|
|
400
|
+
children: [t9, t10]
|
|
364
401
|
});
|
|
365
|
-
$[
|
|
366
|
-
$[
|
|
367
|
-
$[
|
|
368
|
-
$[
|
|
369
|
-
} else
|
|
370
|
-
let
|
|
371
|
-
if ($[
|
|
372
|
-
|
|
402
|
+
$[22] = t10;
|
|
403
|
+
$[23] = t6;
|
|
404
|
+
$[24] = t9;
|
|
405
|
+
$[25] = t11;
|
|
406
|
+
} else t11 = $[25];
|
|
407
|
+
let t12;
|
|
408
|
+
if ($[26] !== footer || $[27] !== footerClassName) {
|
|
409
|
+
t12 = footer ? /* @__PURE__ */ jsx("div", {
|
|
373
410
|
className: cx(Form_module_default.footer, footerClassName),
|
|
374
411
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
375
412
|
shape: "rect",
|
|
@@ -377,24 +414,24 @@ function FormSkeleton(t0) {
|
|
|
377
414
|
height: "var(--panneau-control-height)"
|
|
378
415
|
})
|
|
379
416
|
}) : null;
|
|
380
|
-
$[
|
|
381
|
-
$[
|
|
382
|
-
$[
|
|
383
|
-
} else
|
|
384
|
-
let
|
|
385
|
-
if ($[
|
|
386
|
-
|
|
387
|
-
label:
|
|
388
|
-
className:
|
|
389
|
-
children: [
|
|
417
|
+
$[26] = footer;
|
|
418
|
+
$[27] = footerClassName;
|
|
419
|
+
$[28] = t12;
|
|
420
|
+
} else t12 = $[28];
|
|
421
|
+
let t13;
|
|
422
|
+
if ($[29] !== t11 || $[30] !== t12 || $[31] !== t3 || $[32] !== t4) {
|
|
423
|
+
t13 = /* @__PURE__ */ jsxs(LoadingRegion, {
|
|
424
|
+
label: t3,
|
|
425
|
+
className: t4,
|
|
426
|
+
children: [t11, t12]
|
|
390
427
|
});
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
} else
|
|
397
|
-
return
|
|
428
|
+
$[29] = t11;
|
|
429
|
+
$[30] = t12;
|
|
430
|
+
$[31] = t3;
|
|
431
|
+
$[32] = t4;
|
|
432
|
+
$[33] = t13;
|
|
433
|
+
} else t13 = $[33];
|
|
434
|
+
return t13;
|
|
398
435
|
}
|
|
399
436
|
//#endregion
|
|
400
437
|
export { FormSkeleton };
|