@chobantonov/jsonforms-react-extended-renderers 0.0.0-stage → 0.1.0
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/LICENSE +22 -0
- package/README.md +17 -2
- package/lib/AgGridControlRenderer.impl-BO-Z1x0Y.js +2 -0
- package/lib/AgGridControlRenderer.impl-BO-Z1x0Y.js.map +1 -0
- package/lib/AgGridControlRenderer.impl-BZS8_ocu.mjs +429 -0
- package/lib/AgGridControlRenderer.impl-BZS8_ocu.mjs.map +1 -0
- package/lib/DynamicJSXRenderer-Cyw40Kz0.js +2 -0
- package/lib/DynamicJSXRenderer-Cyw40Kz0.js.map +1 -0
- package/lib/DynamicJSXRenderer-DyB3ZpZV.mjs +109 -0
- package/lib/DynamicJSXRenderer-DyB3ZpZV.mjs.map +1 -0
- package/lib/MarkupLabelRenderer.impl-CWfdcUuH.mjs +12 -0
- package/lib/MarkupLabelRenderer.impl-CWfdcUuH.mjs.map +1 -0
- package/lib/MarkupLabelRenderer.impl-DnuzIPQg.js +2 -0
- package/lib/MarkupLabelRenderer.impl-DnuzIPQg.js.map +1 -0
- package/lib/MonacoControlRenderer.impl-BwgLGNMK.js +3 -0
- package/lib/MonacoControlRenderer.impl-BwgLGNMK.js.map +1 -0
- package/lib/MonacoControlRenderer.impl-CyjMHbOd.mjs +186 -0
- package/lib/MonacoControlRenderer.impl-CyjMHbOd.mjs.map +1 -0
- package/lib/RactiveTemplate-7L44A38e.js +2 -0
- package/lib/RactiveTemplate-7L44A38e.js.map +1 -0
- package/lib/RactiveTemplate-Cat7CxUp.mjs +74 -0
- package/lib/RactiveTemplate-Cat7CxUp.mjs.map +1 -0
- package/lib/ajv-localizers.cjs.js +2 -0
- package/lib/ajv-localizers.cjs.js.map +1 -0
- package/lib/ajv-localizers.esm.js +7 -0
- package/lib/ajv-localizers.esm.js.map +1 -0
- package/lib/ajvI18n-2UTyJv5g.js +2 -0
- package/lib/ajvI18n-2UTyJv5g.js.map +1 -0
- package/lib/ajvI18n-DO8FFvx1.mjs +227 -0
- package/lib/ajvI18n-DO8FFvx1.mjs.map +1 -0
- package/lib/celTemplate-Cl0alaCz.js +3 -0
- package/lib/celTemplate-Cl0alaCz.js.map +1 -0
- package/lib/celTemplate-D_AGhaIL.mjs +137 -0
- package/lib/celTemplate-D_AGhaIL.mjs.map +1 -0
- package/lib/components/DynamicJSXRenderer.d.ts +7 -0
- package/lib/components/ExtendedJsonForms.d.ts +80 -0
- package/lib/components/GenericAdditionalProperties.d.ts +4 -0
- package/lib/components/InterpolatedText.d.ts +34 -0
- package/lib/components/RactiveTemplate.d.ts +37 -0
- package/lib/components/editorRendererTypes.d.ts +139 -0
- package/lib/components/elementRender.d.ts +15 -0
- package/lib/configNamespaces-BFclHtB8.mjs +1 -0
- package/lib/configNamespaces-sboXDudL.js +1 -0
- package/lib/core/ajv.d.ts +82 -0
- package/lib/core/ajvI18n/bg.d.ts +2 -0
- package/lib/core/ajvI18n/index.d.ts +118 -0
- package/lib/core/ajvI18n/localizers.d.ts +20 -0
- package/lib/core/dynamicDefaults.d.ts +34 -0
- package/lib/core/keywords.d.ts +24 -0
- package/lib/core/transform.d.ts +29 -0
- package/lib/core/uiSchema.d.ts +48 -0
- package/lib/elementRender-Dbp2e-Cc.js +2 -0
- package/lib/elementRender-Dbp2e-Cc.js.map +1 -0
- package/lib/elementRender-y8MK9CCE.mjs +5 -0
- package/lib/elementRender-y8MK9CCE.mjs.map +1 -0
- package/lib/index.d.ts +41 -0
- package/lib/jsonforms-react-extended.cjs.js +16 -0
- package/lib/jsonforms-react-extended.cjs.js.map +1 -0
- package/lib/jsonforms-react-extended.esm.js +2335 -0
- package/lib/jsonforms-react-extended.esm.js.map +1 -0
- package/lib/locale/bg.d.ts +14 -0
- package/lib/markdown-C_y73Q0w.mjs +123 -0
- package/lib/markdown-C_y73Q0w.mjs.map +1 -0
- package/lib/markdown-CuqtpGVd.js +2 -0
- package/lib/markdown-CuqtpGVd.js.map +1 -0
- package/lib/objectWithoutProperties-6zedhz76.js +2 -0
- package/lib/objectWithoutProperties-6zedhz76.js.map +1 -0
- package/lib/objectWithoutProperties-yjQMyZ0y.mjs +58 -0
- package/lib/objectWithoutProperties-yjQMyZ0y.mjs.map +1 -0
- package/lib/renderers/AgGridControlRenderer.d.ts +10 -0
- package/lib/renderers/AgGridControlRenderer.impl.d.ts +4 -0
- package/lib/renderers/ButtonRenderer.d.ts +83 -0
- package/lib/renderers/GenericMixedRenderer.d.ts +9 -0
- package/lib/renderers/HorizontalLayoutRenderer.d.ts +5 -0
- package/lib/renderers/ImageViewRenderer.d.ts +48 -0
- package/lib/renderers/LinkRenderer.d.ts +23 -0
- package/lib/renderers/MarkupLabelRenderer.d.ts +35 -0
- package/lib/renderers/MarkupLabelRenderer.impl.d.ts +17 -0
- package/lib/renderers/MonacoControlRenderer.d.ts +8 -0
- package/lib/renderers/MonacoControlRenderer.impl.d.ts +4 -0
- package/lib/renderers/RactiveTemplateLayoutRenderer.d.ts +6 -0
- package/lib/renderers/SeparatorRenderer.d.ts +17 -0
- package/lib/renderers/SlotRenderer.d.ts +5 -0
- package/lib/renderers/SpacerRenderer.d.ts +5 -0
- package/lib/renderers/SplitLayoutRenderer.d.ts +18 -0
- package/lib/renderers/TemplateLayoutRenderer.d.ts +13 -0
- package/lib/renderers/TemplateRenderer.d.ts +17 -0
- package/lib/renderers/TsxTemplateLayoutRenderer.d.ts +111 -0
- package/lib/renderers/index.d.ts +13 -0
- package/lib/renderers/templateEngines.d.ts +43 -0
- package/lib/util/actionContext.d.ts +23 -0
- package/lib/util/additionalErrors.d.ts +77 -0
- package/lib/util/celEnvironment.d.ts +23 -0
- package/lib/util/celTemplate.d.ts +47 -0
- package/lib/util/childNames.d.ts +46 -0
- package/lib/util/configNamespaces.d.ts +1 -0
- package/lib/util/cron.d.ts +122 -0
- package/lib/util/editorControls.d.ts +8 -0
- package/lib/util/editorDiagnostics.d.ts +56 -0
- package/lib/util/extendedControls.d.ts +4 -0
- package/lib/util/extendedLocale.d.ts +32 -0
- package/lib/util/fileFilterValue.d.ts +3 -0
- package/lib/util/formContext.d.ts +54 -0
- package/lib/util/gridColumns.d.ts +6 -0
- package/lib/util/horizontalLayout.d.ts +10 -0
- package/lib/util/i18nDefaults.d.ts +45 -0
- package/lib/util/interpolate.d.ts +105 -0
- package/lib/util/labelFilterValue.d.ts +2 -0
- package/lib/util/lazyControl.d.ts +36 -0
- package/lib/util/lazyTemplate.d.ts +18 -0
- package/lib/util/markdown.d.ts +55 -0
- package/lib/util/markdownEscape.d.ts +27 -0
- package/lib/util/markup.d.ts +74 -0
- package/lib/util/maskControls.d.ts +2 -0
- package/lib/util/templateLang.d.ts +87 -0
- package/lib/util/templateUrls.d.ts +40 -0
- package/lib/util/urlPolicy.d.ts +42 -0
- package/lib/util/useCronPicker.d.ts +24 -0
- package/lib/util/useDurationControl.d.ts +99 -0
- package/lib/util/useEditorAppearance.d.ts +21 -0
- package/lib/util/useExtendedTranslator.d.ts +10 -0
- package/lib/util/useMonacoShadowStyles.d.ts +2 -0
- package/package.json +110 -3
- package/src/components/DynamicJSXRenderer.tsx +274 -0
- package/src/components/ExtendedJsonForms.tsx +329 -0
- package/src/components/GenericAdditionalProperties.tsx +362 -0
- package/src/components/InterpolatedText.tsx +114 -0
- package/src/components/RactiveTemplate.tsx +161 -0
- package/src/components/editorRendererTypes.ts +135 -0
- package/src/components/elementRender.ts +15 -0
- package/src/core/ajv.ts +177 -0
- package/src/core/ajvI18n/bg.ts +203 -0
- package/src/core/ajvI18n/index.ts +267 -0
- package/src/core/ajvI18n/localizers.ts +25 -0
- package/src/core/dynamicDefaults.ts +170 -0
- package/src/core/keywords.ts +71 -0
- package/src/core/transform.ts +137 -0
- package/src/core/uiSchema.ts +53 -0
- package/src/index.tsx +196 -0
- package/src/locale/bg.ts +51 -0
- package/src/renderers/AgGridControlRenderer.impl.tsx +788 -0
- package/src/renderers/AgGridControlRenderer.tsx +24 -0
- package/src/renderers/ButtonRenderer.tsx +328 -0
- package/src/renderers/GenericMixedRenderer.tsx +224 -0
- package/src/renderers/HorizontalLayoutRenderer.tsx +93 -0
- package/src/renderers/ImageViewRenderer.tsx +328 -0
- package/src/renderers/LinkRenderer.tsx +92 -0
- package/src/renderers/MarkupLabelRenderer.impl.tsx +26 -0
- package/src/renderers/MarkupLabelRenderer.tsx +327 -0
- package/src/renderers/MonacoControlRenderer.impl.tsx +351 -0
- package/src/renderers/MonacoControlRenderer.tsx +24 -0
- package/src/renderers/RactiveTemplateLayoutRenderer.tsx +172 -0
- package/src/renderers/SeparatorRenderer.tsx +55 -0
- package/src/renderers/SlotRenderer.tsx +34 -0
- package/src/renderers/SpacerRenderer.tsx +69 -0
- package/src/renderers/SplitLayoutRenderer.tsx +220 -0
- package/src/renderers/TemplateLayoutRenderer.tsx +394 -0
- package/src/renderers/TemplateRenderer.tsx +71 -0
- package/src/renderers/TsxTemplateLayoutRenderer.tsx +258 -0
- package/src/renderers/index.ts +14 -0
- package/src/renderers/templateEngines.tsx +100 -0
- package/src/util/actionContext.ts +29 -0
- package/src/util/additionalErrors.tsx +391 -0
- package/src/util/celEnvironment.ts +300 -0
- package/src/util/celTemplate.ts +267 -0
- package/src/util/childNames.ts +135 -0
- package/src/util/configNamespaces.ts +6 -0
- package/src/util/cron.ts +433 -0
- package/src/util/editorControls.ts +58 -0
- package/src/util/editorDiagnostics.ts +103 -0
- package/src/util/extendedControls.ts +34 -0
- package/src/util/extendedLocale.ts +67 -0
- package/src/util/fileFilterValue.ts +28 -0
- package/src/util/formContext.ts +74 -0
- package/src/util/gridColumns.ts +80 -0
- package/src/util/horizontalLayout.ts +59 -0
- package/src/util/i18nDefaults.ts +80 -0
- package/src/util/interpolate.ts +218 -0
- package/src/util/labelFilterValue.ts +49 -0
- package/src/util/lazyControl.tsx +66 -0
- package/src/util/lazyTemplate.tsx +110 -0
- package/src/util/markdown.tsx +345 -0
- package/src/util/markdownEscape.ts +29 -0
- package/src/util/markup.ts +144 -0
- package/src/util/maskControls.ts +6 -0
- package/src/util/templateLang.ts +145 -0
- package/src/util/templateUrls.ts +274 -0
- package/src/util/urlPolicy.ts +115 -0
- package/src/util/useCronPicker.ts +102 -0
- package/src/util/useDurationControl.ts +272 -0
- package/src/util/useEditorAppearance.ts +86 -0
- package/src/util/useExtendedTranslator.ts +25 -0
- package/src/util/useMonacoShadowStyles.ts +47 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JsonSchema, Resolve } from '@jsonforms/core';
|
|
2
|
+
import {
|
|
3
|
+
attachmentName,
|
|
4
|
+
fileItemSchema,
|
|
5
|
+
isFileString,
|
|
6
|
+
} from '@chobantonov/jsonforms-react-renderer-common/controls/FileArrayInput';
|
|
7
|
+
|
|
8
|
+
/** Undefined means this is not a file column; nameless files have no search text. */
|
|
9
|
+
export const fileFilterValue = (
|
|
10
|
+
value: unknown,
|
|
11
|
+
schema: JsonSchema,
|
|
12
|
+
rootSchema: JsonSchema,
|
|
13
|
+
): string | undefined => {
|
|
14
|
+
const resolved = schema.$ref
|
|
15
|
+
? Resolve.schema(rootSchema, schema.$ref, rootSchema)
|
|
16
|
+
: schema;
|
|
17
|
+
if (!resolved) return undefined;
|
|
18
|
+
if (isFileString(resolved)) return attachmentName(value) ?? '';
|
|
19
|
+
if (fileItemSchema(resolved, rootSchema)) {
|
|
20
|
+
return Array.isArray(value)
|
|
21
|
+
? value
|
|
22
|
+
.map((item) => attachmentName(item) ?? '')
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.join(' ')
|
|
25
|
+
: '';
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { JsonSchema, UISchemaElement } from '@jsonforms/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `context` binding every template profile exposes.
|
|
5
|
+
*
|
|
6
|
+
* Section 3 declares the shape, and section 13 says the Ractive profile
|
|
7
|
+
* "exposes data…, errors…, **context (extended FormContext)**, elements, and
|
|
8
|
+
* translate", adding that "context may expose additionalErrors and
|
|
9
|
+
* application capabilities".
|
|
10
|
+
*
|
|
11
|
+
* All three profiles used to pass something different and smaller - the JSX
|
|
12
|
+
* engine a flat `locale` and no `context` at all, Ractive a `context` holding
|
|
13
|
+
* only `{ locale }`. So `readonly` was unreachable from a template, which
|
|
14
|
+
* matters as soon as a template draws its own widget: **readonly and disabled
|
|
15
|
+
* are different states**, and a widget that wants to render as text rather
|
|
16
|
+
* than as a greyed-out input has to be able to tell them apart.
|
|
17
|
+
*/
|
|
18
|
+
export interface FormContext {
|
|
19
|
+
external?: Readonly<Record<string, unknown>>;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
config?: unknown;
|
|
22
|
+
readonly?: boolean;
|
|
23
|
+
locale?: string;
|
|
24
|
+
translate?: unknown;
|
|
25
|
+
data?: unknown;
|
|
26
|
+
schema?: JsonSchema;
|
|
27
|
+
uischema?: UISchemaElement;
|
|
28
|
+
errors?: unknown[];
|
|
29
|
+
additionalErrors?: unknown[];
|
|
30
|
+
fireActionEvent?: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface FormContextSources {
|
|
34
|
+
external?: Readonly<Record<string, unknown>>;
|
|
35
|
+
/** `useJsonForms()`. */
|
|
36
|
+
ctx: {
|
|
37
|
+
core?: {
|
|
38
|
+
data?: unknown;
|
|
39
|
+
schema?: JsonSchema;
|
|
40
|
+
errors?: unknown[];
|
|
41
|
+
additionalErrors?: unknown[];
|
|
42
|
+
};
|
|
43
|
+
i18n?: { locale?: string; translate?: unknown };
|
|
44
|
+
readonly?: boolean;
|
|
45
|
+
config?: unknown;
|
|
46
|
+
};
|
|
47
|
+
/** The schema at this element's path, which is narrower than the root. */
|
|
48
|
+
schema?: JsonSchema;
|
|
49
|
+
uischema?: UISchemaElement;
|
|
50
|
+
/** The host's action handler, where one is registered. */
|
|
51
|
+
fireActionEvent?: unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const buildFormContext = ({
|
|
55
|
+
ctx,
|
|
56
|
+
schema,
|
|
57
|
+
uischema,
|
|
58
|
+
fireActionEvent,
|
|
59
|
+
external,
|
|
60
|
+
}: FormContextSources): FormContext => ({
|
|
61
|
+
external,
|
|
62
|
+
config: ctx.config,
|
|
63
|
+
readonly: ctx.readonly === true,
|
|
64
|
+
locale: ctx.i18n?.locale,
|
|
65
|
+
translate: ctx.i18n?.translate,
|
|
66
|
+
data: ctx.core?.data,
|
|
67
|
+
// The schema *here*, not the root - a template is usually interested in the
|
|
68
|
+
// part of the model it is rendering.
|
|
69
|
+
schema: schema ?? ctx.core?.schema,
|
|
70
|
+
uischema,
|
|
71
|
+
errors: ctx.core?.errors ?? [],
|
|
72
|
+
additionalErrors: ctx.core?.additionalErrors ?? [],
|
|
73
|
+
fireActionEvent,
|
|
74
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ColDef, ColGroupDef } from 'ag-grid-community';
|
|
2
|
+
import type { JsonSchema } from '@jsonforms/core';
|
|
3
|
+
import {
|
|
4
|
+
tableColumnFields,
|
|
5
|
+
tableColumnStyle,
|
|
6
|
+
type TableColumnDefinition,
|
|
7
|
+
} from '@chobantonov/jsonforms-react-renderer-common/collections/tableColumns';
|
|
8
|
+
|
|
9
|
+
type GridColumn = ColDef | ColGroupDef;
|
|
10
|
+
|
|
11
|
+
function isColumnGroup(column: GridColumn): column is ColGroupDef {
|
|
12
|
+
return 'children' in column && Array.isArray(column.children);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function resolveGridColumns(
|
|
16
|
+
columns: ColDef[],
|
|
17
|
+
portable: TableColumnDefinition[] | undefined,
|
|
18
|
+
nativeDefinitions: GridColumn[] | undefined,
|
|
19
|
+
items: JsonSchema | undefined,
|
|
20
|
+
cellOptions: Record<string, Record<string, unknown>>,
|
|
21
|
+
hideRequiredAsterisk: boolean,
|
|
22
|
+
) {
|
|
23
|
+
const portableFields = tableColumnFields(
|
|
24
|
+
Object.fromEntries(columns.map((column) => [column.colId!, true])),
|
|
25
|
+
portable,
|
|
26
|
+
columns.map((column) => column.colId!),
|
|
27
|
+
);
|
|
28
|
+
const mergeColumn = (definition: ColDef): ColDef => {
|
|
29
|
+
const generated = columns.find(
|
|
30
|
+
(column) => column.colId === (definition.field ?? definition.colId),
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
...generated,
|
|
34
|
+
...(definition.width !== undefined && definition.flex === undefined
|
|
35
|
+
? { flex: 0 }
|
|
36
|
+
: {}),
|
|
37
|
+
...definition,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
// Native definitions replace the portable list as a whole, including groups
|
|
41
|
+
// and computed columns. Known fields retain their JSON Forms cell editor.
|
|
42
|
+
const nativeColumns = (definitions: GridColumn[]): GridColumn[] =>
|
|
43
|
+
definitions.map((definition) =>
|
|
44
|
+
isColumnGroup(definition)
|
|
45
|
+
? { ...definition, children: nativeColumns(definition.children) }
|
|
46
|
+
: mergeColumn(definition),
|
|
47
|
+
);
|
|
48
|
+
const resolvedColumns: GridColumn[] =
|
|
49
|
+
nativeDefinitions !== undefined
|
|
50
|
+
? nativeColumns(nativeDefinitions)
|
|
51
|
+
: portableFields.map((field) => {
|
|
52
|
+
const definition = portable?.find((column) => column.field === field);
|
|
53
|
+
return mergeColumn({
|
|
54
|
+
field,
|
|
55
|
+
...(definition?.headerName
|
|
56
|
+
? { headerName: definition.headerName }
|
|
57
|
+
: {}),
|
|
58
|
+
...tableColumnStyle(definition),
|
|
59
|
+
} as ColDef);
|
|
60
|
+
});
|
|
61
|
+
const markRequiredHeaders = (definitions: GridColumn[]) => {
|
|
62
|
+
definitions.forEach((definition) => {
|
|
63
|
+
if (isColumnGroup(definition)) markRequiredHeaders(definition.children);
|
|
64
|
+
else if (
|
|
65
|
+
definition.field !== undefined &&
|
|
66
|
+
items?.required?.includes(definition.field) &&
|
|
67
|
+
!(
|
|
68
|
+
cellOptions?.[definition.field]?.hideRequiredAsterisk ??
|
|
69
|
+
hideRequiredAsterisk
|
|
70
|
+
)
|
|
71
|
+
) {
|
|
72
|
+
definition.headerName = `${
|
|
73
|
+
definition.headerName ?? definition.field
|
|
74
|
+
} *`;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
markRequiredHeaders(resolvedColumns);
|
|
79
|
+
return resolvedColumns;
|
|
80
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export const HORIZONTAL_COLUMNS = 16;
|
|
4
|
+
|
|
5
|
+
export const isValidColumns = (value: unknown): boolean =>
|
|
6
|
+
value === undefined ||
|
|
7
|
+
value === null ||
|
|
8
|
+
value === 'auto' ||
|
|
9
|
+
(typeof value === 'number' &&
|
|
10
|
+
Number.isInteger(value) &&
|
|
11
|
+
value >= 2 &&
|
|
12
|
+
value <= HORIZONTAL_COLUMNS);
|
|
13
|
+
|
|
14
|
+
/** Allocate direct, visible children without changing their UI schemas. */
|
|
15
|
+
export const horizontalLayoutWidths = (
|
|
16
|
+
values: readonly unknown[],
|
|
17
|
+
gap = '1rem',
|
|
18
|
+
) => {
|
|
19
|
+
const fixed = values.map((value) =>
|
|
20
|
+
typeof value === 'number' && isValidColumns(value) ? value : undefined,
|
|
21
|
+
);
|
|
22
|
+
const rows: number[][] = [[]];
|
|
23
|
+
const allAuto = fixed.every((value) => value === undefined);
|
|
24
|
+
let used = 0;
|
|
25
|
+
fixed.forEach((value, index) => {
|
|
26
|
+
const minimum = value ?? 2;
|
|
27
|
+
if (!allAuto && used + minimum > HORIZONTAL_COLUMNS) {
|
|
28
|
+
rows.push([]);
|
|
29
|
+
used = 0;
|
|
30
|
+
}
|
|
31
|
+
rows[rows.length - 1].push(index);
|
|
32
|
+
used += minimum;
|
|
33
|
+
});
|
|
34
|
+
return rows.flatMap((indices, row) => {
|
|
35
|
+
const reserved = indices.reduce(
|
|
36
|
+
(sum, index) => sum + (fixed[index] ?? 0),
|
|
37
|
+
0,
|
|
38
|
+
);
|
|
39
|
+
const autos = indices.filter((index) => fixed[index] === undefined).length;
|
|
40
|
+
return indices.map((index) => {
|
|
41
|
+
const columns = fixed[index] ?? (HORIZONTAL_COLUMNS - reserved) / autos;
|
|
42
|
+
const fraction = columns / HORIZONTAL_COLUMNS;
|
|
43
|
+
const style: CSSProperties = {
|
|
44
|
+
flex: `0 0 calc(${fraction * 100}% - ${gap} * ${
|
|
45
|
+
(indices.length - 1) * fraction
|
|
46
|
+
})`,
|
|
47
|
+
minWidth: 0,
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
row,
|
|
51
|
+
columns,
|
|
52
|
+
style,
|
|
53
|
+
diagnostic: isValidColumns(values[index])
|
|
54
|
+
? undefined
|
|
55
|
+
: 'Columns must be Auto or an integer from 2 through 16.',
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default messages for strings this package renders. Every one goes through the
|
|
3
|
+
* JSON Forms translator, so a host can override any of them per locale.
|
|
4
|
+
*/
|
|
5
|
+
export const extendedI18nDefaults = {
|
|
6
|
+
'array.addRow': 'Add row',
|
|
7
|
+
'array.removeSelected': 'Remove selected',
|
|
8
|
+
'grid.loading': 'Loading data grid...',
|
|
9
|
+
'grid.loadError': 'Unable to load the data grid.',
|
|
10
|
+
'editor.loading': 'Loading editor...',
|
|
11
|
+
'editor.loadError': 'Unable to load the editor.',
|
|
12
|
+
'editor.maximize': 'Maximize editor',
|
|
13
|
+
'editor.restore': 'Restore editor',
|
|
14
|
+
'editor.invalidJson': 'Enter valid JSON.',
|
|
15
|
+
// `{count}` is substituted by the caller, the way the composite summaries do.
|
|
16
|
+
'editor.languageErrors':
|
|
17
|
+
'Code contains {count} errors. Review the marked locations in the editor.',
|
|
18
|
+
'editor.languageError':
|
|
19
|
+
'Code contains 1 error. Review the marked location in the editor.',
|
|
20
|
+
'editor.chooseColor': 'Choose a color',
|
|
21
|
+
'editor.chooseDuration': 'Choose a duration',
|
|
22
|
+
// The color control's entry hint must "reflect the configured
|
|
23
|
+
// representation" (spec section 18), so there is one per save format rather
|
|
24
|
+
// than a single `#RRGGBB`. They are syntax rather than prose, but they go
|
|
25
|
+
// through the translator like every other rendered string (Adjustment 6) so
|
|
26
|
+
// a locale that writes its channel names differently can say so. There is no
|
|
27
|
+
// `hsl` entry because there is no `hsl` output; see Adjustment 8.1.
|
|
28
|
+
'color.placeholder.hex': '#RRGGBB',
|
|
29
|
+
'color.placeholder.hex3': '#RGB',
|
|
30
|
+
'color.placeholder.rgb': 'rgb(r, g, b)',
|
|
31
|
+
'color.placeholder.hsb': 'hsb(h, s%, b%)',
|
|
32
|
+
// Named by the specification itself: the guidance shown when three-digit hex
|
|
33
|
+
// output is selected and the edit would carry transparency.
|
|
34
|
+
'color.hex3Transparency':
|
|
35
|
+
'Three-digit hex cannot store transparency. Enter an opaque color, or clear the value.',
|
|
36
|
+
|
|
37
|
+
// Generic additional-properties editor. The antd package has its own
|
|
38
|
+
// `additionalProperties.*` keys for the renderer it draws; these are the
|
|
39
|
+
// same strings for the unstyled fallback, and are separate because neither
|
|
40
|
+
// package depends on the other.
|
|
41
|
+
'additionalProperties.add': 'Add',
|
|
42
|
+
'additionalProperties.addLabel': 'Add property',
|
|
43
|
+
'additionalProperties.addTo': 'Add property to {label}',
|
|
44
|
+
'additionalProperties.namePlaceholder': 'Property name',
|
|
45
|
+
'additionalProperties.rename': 'Rename',
|
|
46
|
+
'additionalProperties.renameNamed': 'Rename {name}',
|
|
47
|
+
'additionalProperties.save': 'Save',
|
|
48
|
+
'additionalProperties.cancel': 'Cancel',
|
|
49
|
+
'additionalProperties.delete': 'Delete',
|
|
50
|
+
'additionalProperties.nameTaken': "Property '{name}' already defined",
|
|
51
|
+
'additionalProperties.nameInvalid': "Property name '{name}' is invalid",
|
|
52
|
+
'additionalProperties.namePattern':
|
|
53
|
+
'Property name must match pattern: {pattern}',
|
|
54
|
+
|
|
55
|
+
// Template engines, which arrive in their own chunk. Loading and the two
|
|
56
|
+
// failures are separate keys because they send the reader to different
|
|
57
|
+
// places: a chunk that never arrived, or a template that threw.
|
|
58
|
+
'template.loading': 'Loading template engine…',
|
|
59
|
+
'template.loadError': 'The template engine could not be loaded.',
|
|
60
|
+
'template.renderError': 'The template could not be rendered.',
|
|
61
|
+
// The Monaco control's accessible name when the control has no label.
|
|
62
|
+
'editor.ariaLabel': 'Code editor',
|
|
63
|
+
// Shown under the duration control for text that is not a duration. Names
|
|
64
|
+
// both spellings, since the picker can produce either.
|
|
65
|
+
'duration.invalid': 'Enter an ISO 8601 duration, for example P2DT3H or P2W.',
|
|
66
|
+
// Shown beside the text when a markup request cannot be honoured. The text
|
|
67
|
+
// is still rendered, so these explain why it looks unformatted rather than
|
|
68
|
+
// standing in for it. `{markup}` is substituted by the caller.
|
|
69
|
+
'markup.markdownDisabled':
|
|
70
|
+
'Markdown is turned off for this form, so this text is shown as written.',
|
|
71
|
+
'markup.unsupported':
|
|
72
|
+
'Unsupported markup {markup}. This renderer set implements "plain" and "markdown".',
|
|
73
|
+
// An expression that could not be resolved. `{detail}` carries the
|
|
74
|
+
// evaluator's own message, which names the cause - an unknown identifier, a
|
|
75
|
+
// missing key, a type mismatch - better than anything this layer could
|
|
76
|
+
// invent. Developer-facing, shown beside the text rather than instead of it.
|
|
77
|
+
'markup.interpolationFailed': 'Could not resolve: {detail}',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type ExtendedI18nKey = keyof typeof extendedI18nDefaults;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { JSONFORMS_EXTENDED_CONFIG_KEY } from './configNamespaces';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The template grammar, and what an expression is allowed to see.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately free of any CEL import. Splitting a template is pure string
|
|
7
|
+
* work, and doing it here means two things: the grammar can be tested without
|
|
8
|
+
* the evaluator, and a label whose text turns out to contain **no**
|
|
9
|
+
* placeholders never downloads one.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** One piece of a split template. */
|
|
13
|
+
export type TemplateSegment =
|
|
14
|
+
| { kind: 'literal'; text: string }
|
|
15
|
+
| { kind: 'expression'; source: string };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Splits a template into literals and expressions.
|
|
19
|
+
*
|
|
20
|
+
* The grammar is section 11.4's, unchanged, because a second convention in
|
|
21
|
+
* the same document is the thing worth avoiding: a **single** `{` opens a
|
|
22
|
+
* placeholder, `{{` emits a literal `{`, and `}}` emits a literal `}`.
|
|
23
|
+
*
|
|
24
|
+
* This is inverted from Mustache and friends, so `{{data.firstName}}` is
|
|
25
|
+
* literal text rather than a binding. That trap is the reason
|
|
26
|
+
* {@link looksLikeMustache} exists.
|
|
27
|
+
*
|
|
28
|
+
* The scan is quote-aware: a `}` inside a quoted string does not close the
|
|
29
|
+
* placeholder, so `{data.m['}']}` is one expression rather than a truncated
|
|
30
|
+
* one. Quotes are tracked only to find the closing brace - what is inside
|
|
31
|
+
* them is the evaluator's business.
|
|
32
|
+
*
|
|
33
|
+
* An unterminated placeholder is returned as a literal, so the author sees
|
|
34
|
+
* their source text rather than losing the rest of the line.
|
|
35
|
+
*/
|
|
36
|
+
export const splitTemplate = (text: string): TemplateSegment[] => {
|
|
37
|
+
const segments: TemplateSegment[] = [];
|
|
38
|
+
let literal = '';
|
|
39
|
+
let i = 0;
|
|
40
|
+
|
|
41
|
+
const flush = () => {
|
|
42
|
+
if (literal) {
|
|
43
|
+
segments.push({ kind: 'literal', text: literal });
|
|
44
|
+
literal = '';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
while (i < text.length) {
|
|
49
|
+
const char = text[i];
|
|
50
|
+
if (char === '{' && text[i + 1] === '{') {
|
|
51
|
+
literal += '{';
|
|
52
|
+
i += 2;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (char === '}' && text[i + 1] === '}') {
|
|
56
|
+
literal += '}';
|
|
57
|
+
i += 2;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (char !== '{') {
|
|
61
|
+
literal += char;
|
|
62
|
+
i += 1;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
// A placeholder. Find its closing brace, ignoring quoted content.
|
|
66
|
+
let j = i + 1;
|
|
67
|
+
let quote: string | undefined;
|
|
68
|
+
let closed = false;
|
|
69
|
+
while (j < text.length) {
|
|
70
|
+
const c = text[j];
|
|
71
|
+
if (quote) {
|
|
72
|
+
// A backslash escapes the next character inside a quoted string.
|
|
73
|
+
if (c === '\\') {
|
|
74
|
+
j += 2;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (c === quote) {
|
|
78
|
+
quote = undefined;
|
|
79
|
+
}
|
|
80
|
+
} else if (c === '"' || c === "'") {
|
|
81
|
+
quote = c;
|
|
82
|
+
} else if (c === '}') {
|
|
83
|
+
closed = true;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
j += 1;
|
|
87
|
+
}
|
|
88
|
+
if (!closed) {
|
|
89
|
+
// Unterminated: the rest is text, which is more use than nothing.
|
|
90
|
+
literal += text.slice(i);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
flush();
|
|
94
|
+
segments.push({ kind: 'expression', source: text.slice(i + 1, j) });
|
|
95
|
+
i = j + 1;
|
|
96
|
+
}
|
|
97
|
+
flush();
|
|
98
|
+
return segments;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** Whether a split template has anything to evaluate. */
|
|
102
|
+
export const hasExpressions = (segments: TemplateSegment[]): boolean =>
|
|
103
|
+
segments.some((segment) => segment.kind === 'expression');
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Whether the text looks like it expected Mustache's convention.
|
|
107
|
+
*
|
|
108
|
+
* `{{data.firstName}}` splits into the literal `{data.firstName}` - correct
|
|
109
|
+
* per the grammar, and almost certainly not what the author meant. Section
|
|
110
|
+
* 11.4 asks an implementation to warn about exactly this shape.
|
|
111
|
+
*/
|
|
112
|
+
export const looksLikeMustache = (text: string): boolean =>
|
|
113
|
+
/\{\{\s*[A-Za-z_$][\w$]*(\.[\w$]+|\[[^\]]*\])*\s*\}\}/.test(text);
|
|
114
|
+
|
|
115
|
+
// ------------------------------------------------------------- the scope
|
|
116
|
+
|
|
117
|
+
const namespaced = (config: unknown): Record<string, unknown> | undefined =>
|
|
118
|
+
(config as Record<string, unknown> | undefined)?.[
|
|
119
|
+
JSONFORMS_EXTENDED_CONFIG_KEY
|
|
120
|
+
] as Record<string, unknown> | undefined;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Whether the host permits an expression to read the form's data.
|
|
124
|
+
*
|
|
125
|
+
* Section 12's gate, and it defaults **closed** like the others - unlike the
|
|
126
|
+
* Markdown gate, which opens a parser rather than a reader. What this opens
|
|
127
|
+
* is exactly what section 11 calls dynamic resolution: values out of the
|
|
128
|
+
* form's data and the host's context, into the UI.
|
|
129
|
+
*/
|
|
130
|
+
export const dynamicValuesEnabled = (config: unknown): boolean =>
|
|
131
|
+
(
|
|
132
|
+
namespaced(config)?.['dynamicValues'] as Record<string, unknown> | undefined
|
|
133
|
+
)?.['enabled'] === true;
|
|
134
|
+
|
|
135
|
+
/** The namespaces that only dynamic resolution may expose. */
|
|
136
|
+
export const DYNAMIC_NAMESPACES = ['data', 'item', 'config', 'context'];
|
|
137
|
+
|
|
138
|
+
export interface NamespaceScopeInput {
|
|
139
|
+
data?: unknown;
|
|
140
|
+
item?: unknown;
|
|
141
|
+
locale?: string;
|
|
142
|
+
config?: unknown;
|
|
143
|
+
context?: unknown;
|
|
144
|
+
dynamicAllowed: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* What a **`textParams` value** may reference.
|
|
149
|
+
*
|
|
150
|
+
* This is the only place the form's data is reachable. A parameter's value is
|
|
151
|
+
* the right-hand side of a declaration the author wrote in the UI schema, and
|
|
152
|
+
* the UI schema is where knowledge of the data model belongs.
|
|
153
|
+
*
|
|
154
|
+
* The four namespaces appear only when the gate is open, so a parameter that
|
|
155
|
+
* reaches for `data` while it is shut fails with an unknown identifier rather
|
|
156
|
+
* than quietly resolving.
|
|
157
|
+
*/
|
|
158
|
+
export const buildNamespaceScope = (
|
|
159
|
+
input: NamespaceScopeInput,
|
|
160
|
+
): Record<string, unknown> => {
|
|
161
|
+
const scope: Record<string, unknown> = { locale: input.locale ?? 'en' };
|
|
162
|
+
if (input.dynamicAllowed) {
|
|
163
|
+
scope.data = input.data ?? {};
|
|
164
|
+
Object.defineProperty(scope, 'item', {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: () => input.item,
|
|
167
|
+
});
|
|
168
|
+
scope.config = input.config ?? {};
|
|
169
|
+
scope.context = input.context ?? {};
|
|
170
|
+
}
|
|
171
|
+
return scope;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Names the text scope keeps for itself.
|
|
176
|
+
*
|
|
177
|
+
* `locale` lets a message choose a word by language without a parameter for
|
|
178
|
+
* it. A `textParams` entry of the same name would silently do nothing, so it
|
|
179
|
+
* is reported rather than dropped - see {@link reservedParamNames}.
|
|
180
|
+
*/
|
|
181
|
+
export const RESERVED_TEXT_NAMES = ['locale'];
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* What the **text** may reference: the declared parameters, and nothing else.
|
|
185
|
+
*
|
|
186
|
+
* Deliberately **not** the namespaces. A translated string that reads
|
|
187
|
+
* `{data.customerName}` couples the catalog to the schema: renaming a field
|
|
188
|
+
* invalidates every translation of every language, and a translator is shown
|
|
189
|
+
* a data path instead of a name for the thing. Restricting the text to
|
|
190
|
+
* declared parameters is what makes `You are subscribed to {product}.` the
|
|
191
|
+
* unit of translation.
|
|
192
|
+
*
|
|
193
|
+
* Expressions still work here, over those parameters. That is what keeps a
|
|
194
|
+
* plural in the catalog where each language can write its own
|
|
195
|
+
* (`{seats == 1 ? "seat" : "seats"}`) rather than in the UI schema where only
|
|
196
|
+
* the authoring language can.
|
|
197
|
+
*/
|
|
198
|
+
export const buildTextScope = (
|
|
199
|
+
params: Record<string, unknown>,
|
|
200
|
+
locale: string | undefined,
|
|
201
|
+
): Record<string, unknown> => ({
|
|
202
|
+
...params,
|
|
203
|
+
// Assigned last: a reserved name is not shadowed by a parameter.
|
|
204
|
+
locale: locale ?? 'en',
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
/** `textParams` entries that collide with a reserved name, so they can be reported. */
|
|
208
|
+
export const reservedParamNames = (
|
|
209
|
+
textParams: Record<string, unknown> | undefined,
|
|
210
|
+
): string[] =>
|
|
211
|
+
Object.keys(textParams ?? {}).filter((name) =>
|
|
212
|
+
RESERVED_TEXT_NAMES.includes(name),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
/** Whether an element asks for interpolation at all. */
|
|
216
|
+
export const wantsInterpolation = (
|
|
217
|
+
options: Record<string, unknown> | undefined,
|
|
218
|
+
): boolean => options?.['interpolate'] === true;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildNamespaceScope,
|
|
3
|
+
buildTextScope,
|
|
4
|
+
dynamicValuesEnabled,
|
|
5
|
+
splitTemplate,
|
|
6
|
+
} from './interpolate';
|
|
7
|
+
import { renderTemplate, resolveTextParams } from './celTemplate';
|
|
8
|
+
import { markdownPlainText } from './markdown';
|
|
9
|
+
import { escapeMarkdown } from './markdownEscape';
|
|
10
|
+
import { markdownProfile, resolveMarkup } from './markup';
|
|
11
|
+
|
|
12
|
+
/** Resolve the authored Label text without exposing data beyond the Label's own gates. */
|
|
13
|
+
export const labelFilterValue = (
|
|
14
|
+
label: any,
|
|
15
|
+
data: unknown,
|
|
16
|
+
item: unknown,
|
|
17
|
+
config: unknown,
|
|
18
|
+
locale?: string,
|
|
19
|
+
translate?: (key: string, fallback?: string) => string | undefined,
|
|
20
|
+
): string => {
|
|
21
|
+
const text = label.i18n
|
|
22
|
+
? (translate?.(label.i18n + '.text', label.text ?? '') ?? label.text ?? '')
|
|
23
|
+
: (label.text ?? '');
|
|
24
|
+
const markup = resolveMarkup(label.options, config);
|
|
25
|
+
const plain = (value: string) =>
|
|
26
|
+
markup.markdown ? markdownPlainText(value, markdownProfile(config)) : value;
|
|
27
|
+
if (!markup.interpolate) return plain(text);
|
|
28
|
+
const params = resolveTextParams(
|
|
29
|
+
label.options?.textParams,
|
|
30
|
+
buildNamespaceScope({
|
|
31
|
+
data,
|
|
32
|
+
item,
|
|
33
|
+
config,
|
|
34
|
+
locale,
|
|
35
|
+
dynamicAllowed: dynamicValuesEnabled(config),
|
|
36
|
+
}),
|
|
37
|
+
locale,
|
|
38
|
+
translate,
|
|
39
|
+
);
|
|
40
|
+
return plain(
|
|
41
|
+
renderTemplate(
|
|
42
|
+
splitTemplate(text),
|
|
43
|
+
buildTextScope(params.params, locale),
|
|
44
|
+
markup.markdown ? escapeMarkdown : undefined,
|
|
45
|
+
locale,
|
|
46
|
+
translate,
|
|
47
|
+
).text,
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { Suspense, lazy } from 'react';
|
|
2
|
+
import { ControlProps } from '@jsonforms/core';
|
|
3
|
+
import { EditorRendererComponents } from '../components/editorRendererTypes';
|
|
4
|
+
import { ExtendedI18nKey } from './i18nDefaults';
|
|
5
|
+
import { useExtendedTranslator } from './useExtendedTranslator';
|
|
6
|
+
|
|
7
|
+
const DefaultLoading = ({ label }: { label?: string }) => (
|
|
8
|
+
<div aria-busy='true' aria-live='polite' style={{ minHeight: '4rem' }}>
|
|
9
|
+
{label}
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
const DefaultLoadError = ({ label }: { label?: string }) => (
|
|
13
|
+
<div role='alert'>{label}</div>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Suspense has no error path of its own, so a boundary catches import
|
|
18
|
+
* failures.
|
|
19
|
+
*
|
|
20
|
+
* Exported because every lazily-loaded renderer needs one, not only the ones
|
|
21
|
+
* built by `createLazyControl`. Without it a chunk that fails to arrive - an
|
|
22
|
+
* offline reload, a stale hash after a deploy - throws past Suspense and
|
|
23
|
+
* takes the whole form down rather than degrading to whatever the caller
|
|
24
|
+
* chose as a fallback.
|
|
25
|
+
*/
|
|
26
|
+
export class LoadBoundary extends React.Component<
|
|
27
|
+
React.PropsWithChildren<{ fallback: React.ReactNode }>,
|
|
28
|
+
{ failed: boolean }
|
|
29
|
+
> {
|
|
30
|
+
state = { failed: false };
|
|
31
|
+
static getDerivedStateFromError() {
|
|
32
|
+
return { failed: true };
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Defers a renderer's heavy dependency until the control is actually rendered.
|
|
41
|
+
* The import lives behind React.lazy so bundlers split it into its own chunk -
|
|
42
|
+
* a form with no code editor or data grid never downloads them.
|
|
43
|
+
*/
|
|
44
|
+
export const createLazyControl = (
|
|
45
|
+
load: () => Promise<React.ComponentType<ControlProps>>,
|
|
46
|
+
components: EditorRendererComponents,
|
|
47
|
+
labels: { loading: ExtendedI18nKey; error: ExtendedI18nKey },
|
|
48
|
+
): React.ComponentType<ControlProps> => {
|
|
49
|
+
const Loading = components.Loading ?? DefaultLoading;
|
|
50
|
+
const LoadError = components.LoadError ?? DefaultLoadError;
|
|
51
|
+
// Created once per renderer set, not per render, so the chunk is fetched once.
|
|
52
|
+
const Lazy = lazy(async () => ({ default: await load() }));
|
|
53
|
+
const Deferred = (props: ControlProps) => {
|
|
54
|
+
// translated here so the fallbacks are localised like everything else
|
|
55
|
+
const t = useExtendedTranslator();
|
|
56
|
+
return (
|
|
57
|
+
<LoadBoundary fallback={<LoadError label={t(labels.error)} />}>
|
|
58
|
+
<Suspense fallback={<Loading label={t(labels.loading)} />}>
|
|
59
|
+
<Lazy {...props} />
|
|
60
|
+
</Suspense>
|
|
61
|
+
</LoadBoundary>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
Deferred.displayName = `LazyControl(${labels.loading})`;
|
|
65
|
+
return Deferred;
|
|
66
|
+
};
|