@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.
Files changed (193) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +17 -2
  3. package/lib/AgGridControlRenderer.impl-BO-Z1x0Y.js +2 -0
  4. package/lib/AgGridControlRenderer.impl-BO-Z1x0Y.js.map +1 -0
  5. package/lib/AgGridControlRenderer.impl-BZS8_ocu.mjs +429 -0
  6. package/lib/AgGridControlRenderer.impl-BZS8_ocu.mjs.map +1 -0
  7. package/lib/DynamicJSXRenderer-Cyw40Kz0.js +2 -0
  8. package/lib/DynamicJSXRenderer-Cyw40Kz0.js.map +1 -0
  9. package/lib/DynamicJSXRenderer-DyB3ZpZV.mjs +109 -0
  10. package/lib/DynamicJSXRenderer-DyB3ZpZV.mjs.map +1 -0
  11. package/lib/MarkupLabelRenderer.impl-CWfdcUuH.mjs +12 -0
  12. package/lib/MarkupLabelRenderer.impl-CWfdcUuH.mjs.map +1 -0
  13. package/lib/MarkupLabelRenderer.impl-DnuzIPQg.js +2 -0
  14. package/lib/MarkupLabelRenderer.impl-DnuzIPQg.js.map +1 -0
  15. package/lib/MonacoControlRenderer.impl-BwgLGNMK.js +3 -0
  16. package/lib/MonacoControlRenderer.impl-BwgLGNMK.js.map +1 -0
  17. package/lib/MonacoControlRenderer.impl-CyjMHbOd.mjs +186 -0
  18. package/lib/MonacoControlRenderer.impl-CyjMHbOd.mjs.map +1 -0
  19. package/lib/RactiveTemplate-7L44A38e.js +2 -0
  20. package/lib/RactiveTemplate-7L44A38e.js.map +1 -0
  21. package/lib/RactiveTemplate-Cat7CxUp.mjs +74 -0
  22. package/lib/RactiveTemplate-Cat7CxUp.mjs.map +1 -0
  23. package/lib/ajv-localizers.cjs.js +2 -0
  24. package/lib/ajv-localizers.cjs.js.map +1 -0
  25. package/lib/ajv-localizers.esm.js +7 -0
  26. package/lib/ajv-localizers.esm.js.map +1 -0
  27. package/lib/ajvI18n-2UTyJv5g.js +2 -0
  28. package/lib/ajvI18n-2UTyJv5g.js.map +1 -0
  29. package/lib/ajvI18n-DO8FFvx1.mjs +227 -0
  30. package/lib/ajvI18n-DO8FFvx1.mjs.map +1 -0
  31. package/lib/celTemplate-Cl0alaCz.js +3 -0
  32. package/lib/celTemplate-Cl0alaCz.js.map +1 -0
  33. package/lib/celTemplate-D_AGhaIL.mjs +137 -0
  34. package/lib/celTemplate-D_AGhaIL.mjs.map +1 -0
  35. package/lib/components/DynamicJSXRenderer.d.ts +7 -0
  36. package/lib/components/ExtendedJsonForms.d.ts +80 -0
  37. package/lib/components/GenericAdditionalProperties.d.ts +4 -0
  38. package/lib/components/InterpolatedText.d.ts +34 -0
  39. package/lib/components/RactiveTemplate.d.ts +37 -0
  40. package/lib/components/editorRendererTypes.d.ts +139 -0
  41. package/lib/components/elementRender.d.ts +15 -0
  42. package/lib/configNamespaces-BFclHtB8.mjs +1 -0
  43. package/lib/configNamespaces-sboXDudL.js +1 -0
  44. package/lib/core/ajv.d.ts +82 -0
  45. package/lib/core/ajvI18n/bg.d.ts +2 -0
  46. package/lib/core/ajvI18n/index.d.ts +118 -0
  47. package/lib/core/ajvI18n/localizers.d.ts +20 -0
  48. package/lib/core/dynamicDefaults.d.ts +34 -0
  49. package/lib/core/keywords.d.ts +24 -0
  50. package/lib/core/transform.d.ts +29 -0
  51. package/lib/core/uiSchema.d.ts +48 -0
  52. package/lib/elementRender-Dbp2e-Cc.js +2 -0
  53. package/lib/elementRender-Dbp2e-Cc.js.map +1 -0
  54. package/lib/elementRender-y8MK9CCE.mjs +5 -0
  55. package/lib/elementRender-y8MK9CCE.mjs.map +1 -0
  56. package/lib/index.d.ts +41 -0
  57. package/lib/jsonforms-react-extended.cjs.js +16 -0
  58. package/lib/jsonforms-react-extended.cjs.js.map +1 -0
  59. package/lib/jsonforms-react-extended.esm.js +2335 -0
  60. package/lib/jsonforms-react-extended.esm.js.map +1 -0
  61. package/lib/locale/bg.d.ts +14 -0
  62. package/lib/markdown-C_y73Q0w.mjs +123 -0
  63. package/lib/markdown-C_y73Q0w.mjs.map +1 -0
  64. package/lib/markdown-CuqtpGVd.js +2 -0
  65. package/lib/markdown-CuqtpGVd.js.map +1 -0
  66. package/lib/objectWithoutProperties-6zedhz76.js +2 -0
  67. package/lib/objectWithoutProperties-6zedhz76.js.map +1 -0
  68. package/lib/objectWithoutProperties-yjQMyZ0y.mjs +58 -0
  69. package/lib/objectWithoutProperties-yjQMyZ0y.mjs.map +1 -0
  70. package/lib/renderers/AgGridControlRenderer.d.ts +10 -0
  71. package/lib/renderers/AgGridControlRenderer.impl.d.ts +4 -0
  72. package/lib/renderers/ButtonRenderer.d.ts +83 -0
  73. package/lib/renderers/GenericMixedRenderer.d.ts +9 -0
  74. package/lib/renderers/HorizontalLayoutRenderer.d.ts +5 -0
  75. package/lib/renderers/ImageViewRenderer.d.ts +48 -0
  76. package/lib/renderers/LinkRenderer.d.ts +23 -0
  77. package/lib/renderers/MarkupLabelRenderer.d.ts +35 -0
  78. package/lib/renderers/MarkupLabelRenderer.impl.d.ts +17 -0
  79. package/lib/renderers/MonacoControlRenderer.d.ts +8 -0
  80. package/lib/renderers/MonacoControlRenderer.impl.d.ts +4 -0
  81. package/lib/renderers/RactiveTemplateLayoutRenderer.d.ts +6 -0
  82. package/lib/renderers/SeparatorRenderer.d.ts +17 -0
  83. package/lib/renderers/SlotRenderer.d.ts +5 -0
  84. package/lib/renderers/SpacerRenderer.d.ts +5 -0
  85. package/lib/renderers/SplitLayoutRenderer.d.ts +18 -0
  86. package/lib/renderers/TemplateLayoutRenderer.d.ts +13 -0
  87. package/lib/renderers/TemplateRenderer.d.ts +17 -0
  88. package/lib/renderers/TsxTemplateLayoutRenderer.d.ts +111 -0
  89. package/lib/renderers/index.d.ts +13 -0
  90. package/lib/renderers/templateEngines.d.ts +43 -0
  91. package/lib/util/actionContext.d.ts +23 -0
  92. package/lib/util/additionalErrors.d.ts +77 -0
  93. package/lib/util/celEnvironment.d.ts +23 -0
  94. package/lib/util/celTemplate.d.ts +47 -0
  95. package/lib/util/childNames.d.ts +46 -0
  96. package/lib/util/configNamespaces.d.ts +1 -0
  97. package/lib/util/cron.d.ts +122 -0
  98. package/lib/util/editorControls.d.ts +8 -0
  99. package/lib/util/editorDiagnostics.d.ts +56 -0
  100. package/lib/util/extendedControls.d.ts +4 -0
  101. package/lib/util/extendedLocale.d.ts +32 -0
  102. package/lib/util/fileFilterValue.d.ts +3 -0
  103. package/lib/util/formContext.d.ts +54 -0
  104. package/lib/util/gridColumns.d.ts +6 -0
  105. package/lib/util/horizontalLayout.d.ts +10 -0
  106. package/lib/util/i18nDefaults.d.ts +45 -0
  107. package/lib/util/interpolate.d.ts +105 -0
  108. package/lib/util/labelFilterValue.d.ts +2 -0
  109. package/lib/util/lazyControl.d.ts +36 -0
  110. package/lib/util/lazyTemplate.d.ts +18 -0
  111. package/lib/util/markdown.d.ts +55 -0
  112. package/lib/util/markdownEscape.d.ts +27 -0
  113. package/lib/util/markup.d.ts +74 -0
  114. package/lib/util/maskControls.d.ts +2 -0
  115. package/lib/util/templateLang.d.ts +87 -0
  116. package/lib/util/templateUrls.d.ts +40 -0
  117. package/lib/util/urlPolicy.d.ts +42 -0
  118. package/lib/util/useCronPicker.d.ts +24 -0
  119. package/lib/util/useDurationControl.d.ts +99 -0
  120. package/lib/util/useEditorAppearance.d.ts +21 -0
  121. package/lib/util/useExtendedTranslator.d.ts +10 -0
  122. package/lib/util/useMonacoShadowStyles.d.ts +2 -0
  123. package/package.json +110 -3
  124. package/src/components/DynamicJSXRenderer.tsx +274 -0
  125. package/src/components/ExtendedJsonForms.tsx +329 -0
  126. package/src/components/GenericAdditionalProperties.tsx +362 -0
  127. package/src/components/InterpolatedText.tsx +114 -0
  128. package/src/components/RactiveTemplate.tsx +161 -0
  129. package/src/components/editorRendererTypes.ts +135 -0
  130. package/src/components/elementRender.ts +15 -0
  131. package/src/core/ajv.ts +177 -0
  132. package/src/core/ajvI18n/bg.ts +203 -0
  133. package/src/core/ajvI18n/index.ts +267 -0
  134. package/src/core/ajvI18n/localizers.ts +25 -0
  135. package/src/core/dynamicDefaults.ts +170 -0
  136. package/src/core/keywords.ts +71 -0
  137. package/src/core/transform.ts +137 -0
  138. package/src/core/uiSchema.ts +53 -0
  139. package/src/index.tsx +196 -0
  140. package/src/locale/bg.ts +51 -0
  141. package/src/renderers/AgGridControlRenderer.impl.tsx +788 -0
  142. package/src/renderers/AgGridControlRenderer.tsx +24 -0
  143. package/src/renderers/ButtonRenderer.tsx +328 -0
  144. package/src/renderers/GenericMixedRenderer.tsx +224 -0
  145. package/src/renderers/HorizontalLayoutRenderer.tsx +93 -0
  146. package/src/renderers/ImageViewRenderer.tsx +328 -0
  147. package/src/renderers/LinkRenderer.tsx +92 -0
  148. package/src/renderers/MarkupLabelRenderer.impl.tsx +26 -0
  149. package/src/renderers/MarkupLabelRenderer.tsx +327 -0
  150. package/src/renderers/MonacoControlRenderer.impl.tsx +351 -0
  151. package/src/renderers/MonacoControlRenderer.tsx +24 -0
  152. package/src/renderers/RactiveTemplateLayoutRenderer.tsx +172 -0
  153. package/src/renderers/SeparatorRenderer.tsx +55 -0
  154. package/src/renderers/SlotRenderer.tsx +34 -0
  155. package/src/renderers/SpacerRenderer.tsx +69 -0
  156. package/src/renderers/SplitLayoutRenderer.tsx +220 -0
  157. package/src/renderers/TemplateLayoutRenderer.tsx +394 -0
  158. package/src/renderers/TemplateRenderer.tsx +71 -0
  159. package/src/renderers/TsxTemplateLayoutRenderer.tsx +258 -0
  160. package/src/renderers/index.ts +14 -0
  161. package/src/renderers/templateEngines.tsx +100 -0
  162. package/src/util/actionContext.ts +29 -0
  163. package/src/util/additionalErrors.tsx +391 -0
  164. package/src/util/celEnvironment.ts +300 -0
  165. package/src/util/celTemplate.ts +267 -0
  166. package/src/util/childNames.ts +135 -0
  167. package/src/util/configNamespaces.ts +6 -0
  168. package/src/util/cron.ts +433 -0
  169. package/src/util/editorControls.ts +58 -0
  170. package/src/util/editorDiagnostics.ts +103 -0
  171. package/src/util/extendedControls.ts +34 -0
  172. package/src/util/extendedLocale.ts +67 -0
  173. package/src/util/fileFilterValue.ts +28 -0
  174. package/src/util/formContext.ts +74 -0
  175. package/src/util/gridColumns.ts +80 -0
  176. package/src/util/horizontalLayout.ts +59 -0
  177. package/src/util/i18nDefaults.ts +80 -0
  178. package/src/util/interpolate.ts +218 -0
  179. package/src/util/labelFilterValue.ts +49 -0
  180. package/src/util/lazyControl.tsx +66 -0
  181. package/src/util/lazyTemplate.tsx +110 -0
  182. package/src/util/markdown.tsx +345 -0
  183. package/src/util/markdownEscape.ts +29 -0
  184. package/src/util/markup.ts +144 -0
  185. package/src/util/maskControls.ts +6 -0
  186. package/src/util/templateLang.ts +145 -0
  187. package/src/util/templateUrls.ts +274 -0
  188. package/src/util/urlPolicy.ts +115 -0
  189. package/src/util/useCronPicker.ts +102 -0
  190. package/src/util/useDurationControl.ts +272 -0
  191. package/src/util/useEditorAppearance.ts +86 -0
  192. package/src/util/useExtendedTranslator.ts +25 -0
  193. package/src/util/useMonacoShadowStyles.ts +47 -0
@@ -0,0 +1,71 @@
1
+ import type Ajv from 'ajv';
2
+ import keywords from 'ajv-keywords';
3
+ import dynamicDefaults from 'ajv-keywords/dist/definitions/dynamicDefaults';
4
+ import transform from './transform';
5
+ import {
6
+ dateOffset,
7
+ dateUnit,
8
+ datetimeOffset,
9
+ makeDynamic,
10
+ searchParams,
11
+ timeOffset,
12
+ } from './dynamicDefaults';
13
+
14
+ /**
15
+ * `ajv-keywords`, plus the extensions the Vue 2 `common` package added.
16
+ *
17
+ * Two of the three registrations here are **global mutations of the
18
+ * `ajv-keywords` module**, not of the Ajv instance: `dynamicDefaults.DEFAULTS`
19
+ * is a module-level table, so a generator registered for one validator is
20
+ * registered for every validator in the process. That is how the original
21
+ * works and it cannot be made per-instance without forking the plugin, so it
22
+ * is written down rather than hidden - and it is why {@link registerAjvKeywords}
23
+ * is idempotent instead of assuming it runs once.
24
+ */
25
+
26
+ export interface AjvKeywordOptions {
27
+ /**
28
+ * Whether the `dynamic` default - which compiles a function from the schema
29
+ * - is permitted. Read when a schema compiles, so one validator can answer
30
+ * differently for different forms.
31
+ *
32
+ * Off by default. Section 14: "String evaluation requires
33
+ * `jsonformsExtended.security.allowScriptEvaluation=true`."
34
+ */
35
+ allowScriptEvaluation?: () => boolean;
36
+ }
37
+
38
+ export const registerAjvKeywords = (
39
+ ajv: Ajv,
40
+ options: AjvKeywordOptions = {},
41
+ ): Ajv => {
42
+ keywords(ajv);
43
+
44
+ /*
45
+ `ajv-keywords`' own `transform` has a fixed transformation table with no
46
+ registration hook, so adding `capitalize` and `startCase` means replacing
47
+ the keyword outright. Removing first, because `addKeyword` on an existing
48
+ keyword throws.
49
+ */
50
+ if (ajv.getKeyword('transform')) {
51
+ ajv.removeKeyword('transform');
52
+ }
53
+ ajv.addKeyword(transform());
54
+
55
+ const defaults = dynamicDefaults.DEFAULTS as Record<string, unknown>;
56
+ defaults.dynamic = makeDynamic(
57
+ options.allowScriptEvaluation ?? (() => false),
58
+ );
59
+ defaults.searchParams = searchParams;
60
+ /*
61
+ These three **replace** `ajv-keywords`' own `datetime`, `date` and `time`,
62
+ which take no arguments. The replacements accept an offset, and with no
63
+ arguments behave as the originals did.
64
+ */
65
+ defaults.datetime = datetimeOffset;
66
+ defaults.date = dateOffset;
67
+ defaults.time = timeOffset;
68
+ defaults.dateUnit = dateUnit;
69
+
70
+ return ajv;
71
+ };
@@ -0,0 +1,137 @@
1
+ import type {
2
+ CodeKeywordDefinition,
3
+ AnySchemaObject,
4
+ KeywordCxt,
5
+ Code,
6
+ Name,
7
+ } from 'ajv';
8
+ import { _, stringify, getProperty } from 'ajv/dist/compile/codegen';
9
+ import capitalizeFn from 'lodash/capitalize';
10
+ import startCaseFn from 'lodash/startCase';
11
+
12
+ /**
13
+ * `transform`, with more transformations than `ajv-keywords` defines.
14
+ *
15
+ * Ported from the Vue 2 `common` package, which is the reference for what
16
+ * forms in this organisation already author against. `ajv-keywords`' own
17
+ * `transform` is **not extensible** - its transformation table is a module
18
+ * constant with no registration hook - so the only way to add `capitalize`
19
+ * and `startCase` is to remove its keyword and register this one in its place.
20
+ * That is what `registerAjvKeywords` does, and it is why this file exists
21
+ * rather than a three-line plugin.
22
+ *
23
+ * Note that `transform` **mutates the data** as a side effect of validation,
24
+ * which is unusual for a validator and deliberate here: the legacy forms rely
25
+ * on it to normalise input. It runs `before: 'enum'` so a transformed value is
26
+ * what `enum` and `toEnumCase` compare against.
27
+ */
28
+
29
+ type TransformName =
30
+ | 'trimStart'
31
+ | 'trimEnd'
32
+ | 'trimLeft'
33
+ | 'trimRight'
34
+ | 'trim'
35
+ | 'toLowerCase'
36
+ | 'toUpperCase'
37
+ | 'toEnumCase'
38
+ | 'capitalize'
39
+ | 'startCase';
40
+
41
+ interface TransformConfig {
42
+ hash: Record<string, string | undefined>;
43
+ }
44
+
45
+ type Transform = (s: string, cfg?: TransformConfig) => string;
46
+
47
+ const transform: { [key in TransformName]: Transform } = {
48
+ trimStart: (s) => s.trimStart(),
49
+ trimEnd: (s) => s.trimEnd(),
50
+ trimLeft: (s) => s.trimStart(),
51
+ trimRight: (s) => s.trimEnd(),
52
+ trim: (s) => s.trim(),
53
+ toLowerCase: (s) => s.toLowerCase(),
54
+ toUpperCase: (s) => s.toUpperCase(),
55
+ toEnumCase: (s, cfg) => cfg?.hash[configKey(s)] || s,
56
+ capitalize: (s) => capitalizeFn(s),
57
+ startCase: (s) => startCaseFn(s),
58
+ };
59
+
60
+ const getDef: (() => CodeKeywordDefinition) & {
61
+ transform: typeof transform;
62
+ } = Object.assign(_getDef, { transform });
63
+
64
+ function _getDef(): CodeKeywordDefinition {
65
+ return {
66
+ keyword: 'transform',
67
+ schemaType: 'array',
68
+ before: 'enum',
69
+ code(cxt: KeywordCxt) {
70
+ const { gen, data, schema, parentSchema, it } = cxt;
71
+ const { parentData, parentDataProperty } = it;
72
+ const tNames: string[] = schema;
73
+ if (!tNames.length) return;
74
+ let cfg: Name | undefined;
75
+ if (tNames.includes('toEnumCase')) {
76
+ const config = getEnumCaseCfg(parentSchema);
77
+ cfg = gen.scopeValue('obj', { ref: config, code: stringify(config) });
78
+ }
79
+ gen.if(
80
+ _`typeof ${data} == "string" && ${parentData} !== undefined`,
81
+ () => {
82
+ gen.assign(data, transformExpr(tNames.slice()));
83
+ gen.assign(_`${parentData}[${parentDataProperty}]`, data);
84
+ },
85
+ );
86
+
87
+ function transformExpr(ts: string[]): Code {
88
+ if (!ts.length) return data;
89
+ const t = ts.pop() as string;
90
+ if (!(t in transform))
91
+ throw new Error(`transform: unknown transformation ${t}`);
92
+ const func = gen.scopeValue('func', {
93
+ ref: transform[t as TransformName],
94
+ code: _`require("ajv-keywords/dist/definitions/transform").transform${getProperty(
95
+ t,
96
+ )}`,
97
+ });
98
+ const arg = transformExpr(ts);
99
+ return cfg && t === 'toEnumCase'
100
+ ? _`${func}(${arg}, ${cfg})`
101
+ : _`${func}(${arg})`;
102
+ }
103
+ },
104
+ metaSchema: {
105
+ type: 'array',
106
+ items: { type: 'string', enum: Object.keys(transform) },
107
+ },
108
+ };
109
+ }
110
+
111
+ function getEnumCaseCfg(parentSchema: AnySchemaObject): TransformConfig {
112
+ // build hash table to enum values
113
+ const cfg: TransformConfig = { hash: {} };
114
+
115
+ // requires `enum` in the same schema as transform
116
+ if (!parentSchema.enum)
117
+ throw new Error('transform: "toEnumCase" requires "enum"');
118
+ for (const v of parentSchema.enum) {
119
+ if (typeof v !== 'string') continue;
120
+ const k = configKey(v);
121
+ // requires all `enum` values have unique keys
122
+ if (cfg.hash[k]) {
123
+ throw new Error(
124
+ 'transform: "toEnumCase" requires all lowercased "enum" values to be unique',
125
+ );
126
+ }
127
+ cfg.hash[k] = v;
128
+ }
129
+
130
+ return cfg;
131
+ }
132
+
133
+ function configKey(s: string): string {
134
+ return s.toLowerCase();
135
+ }
136
+
137
+ export default getDef;
@@ -0,0 +1,53 @@
1
+ import type { Layout, UISchemaElement } from '@jsonforms/core';
2
+
3
+ /**
4
+ * What this project's UI model adds to core's element types.
5
+ *
6
+ * Section 2 lists the core types a TypeScript implementation may import, and
7
+ * then declares one of its own:
8
+ *
9
+ * ```ts
10
+ * export type NamedUISchemaElement = UISchemaElement & { name: string };
11
+ * ```
12
+ *
13
+ * with "`name` is used where an element must be referenced, for example
14
+ * Categorization initial selection". Core does not declare `name` on
15
+ * `UISchemaElement` and this project does not control core, so the addition
16
+ * lives here - once, rather than as a cast at each of the half-dozen places
17
+ * that read it.
18
+ *
19
+ * **`name` is general, not a feature of any one element.** It is read by the
20
+ * `Template` registry lookup, `Slot` resolution, a Ractive partial, a
21
+ * `Button`'s action name and `Categorization.options.initial`. Any element in
22
+ * this set may carry one.
23
+ */
24
+
25
+ /**
26
+ * An element that **has** a name, as section 2 declares it.
27
+ *
28
+ * Use it where a name is required for the element to mean anything - a
29
+ * `Template` invocation, a `Slot`, a registry entry looked up by name. `name`
30
+ * is required here on purpose: the type is the guarantee.
31
+ */
32
+ export type NamedUISchemaElement = UISchemaElement & { name: string };
33
+
34
+ /**
35
+ * Any element of this project's UI model: core's, plus an optional name.
36
+ *
37
+ * This is the type to read an arbitrary element through. It says what is true
38
+ * of every element here - that it *may* carry a name - without claiming one
39
+ * is present.
40
+ */
41
+ export type ExtendedUISchemaElement = UISchemaElement & { name?: string };
42
+
43
+ /** A layout whose children may be named. */
44
+ export type ExtendedLayout = Omit<Layout, 'elements'> & {
45
+ elements: ExtendedUISchemaElement[];
46
+ };
47
+
48
+ /** Whether an element carries a usable name. */
49
+ export const isNamedUISchemaElement = (
50
+ uischema: UISchemaElement | undefined,
51
+ ): uischema is NamedUISchemaElement =>
52
+ typeof (uischema as ExtendedUISchemaElement | undefined)?.name === 'string' &&
53
+ (uischema as NamedUISchemaElement).name !== '';
package/src/index.tsx ADDED
@@ -0,0 +1,196 @@
1
+ import {
2
+ SharedSplitLayoutRenderer,
3
+ sharedSplitLayoutTester,
4
+ } from './renderers/SplitLayoutRenderer';
5
+ import { JsonFormsRendererRegistryEntry } from '@jsonforms/core';
6
+ import { withJsonFormsLayoutProps } from '@jsonforms/react';
7
+ import React from 'react';
8
+ import {
9
+ TemplateLayoutProps,
10
+ TemplateLayoutRenderer,
11
+ } from './renderers/TemplateLayoutRenderer';
12
+ import { RactiveTemplateLayoutRenderer } from './renderers/RactiveTemplateLayoutRenderer';
13
+ import {
14
+ TsxTemplateLayoutRenderer,
15
+ tsxTemplateLayoutTester,
16
+ } from './renderers/TsxTemplateLayoutRenderer';
17
+ import {
18
+ TemplateDiagnostic,
19
+ templateLangTester,
20
+ unsupportedTemplateLangTester,
21
+ } from './renderers/templateEngines';
22
+ import {
23
+ ButtonRenderer,
24
+ buttonRendererTester,
25
+ } from './renderers/ButtonRenderer';
26
+ import {
27
+ TemplateRenderer,
28
+ namedTemplateTester,
29
+ } from './renderers/TemplateRenderer';
30
+ import { SlotRenderer, slotRendererTester } from './renderers/SlotRenderer';
31
+ import {
32
+ SpacerRenderer,
33
+ spacerRendererTester,
34
+ } from './renderers/SpacerRenderer';
35
+ import {
36
+ ImageViewRenderer,
37
+ imageViewRendererTester,
38
+ } from './renderers/ImageViewRenderer';
39
+ import {
40
+ SeparatorRenderer,
41
+ separatorRendererTester,
42
+ } from './renderers/SeparatorRenderer';
43
+ import { LinkRenderer, linkRendererTester } from './renderers/LinkRenderer';
44
+ import {
45
+ MarkupLabelRenderer,
46
+ markupLabelTester,
47
+ } from './renderers/MarkupLabelRenderer';
48
+
49
+ export type CreateExtendedRenderersOptions = {
50
+ components?: Record<string, React.ComponentType<any>>;
51
+ includeButtonRenderer?: boolean;
52
+ };
53
+
54
+ export const createExtendedRenderers = (
55
+ componentsOrOptions?:
56
+ | Record<string, React.ComponentType<any>>
57
+ | CreateExtendedRenderersOptions,
58
+ ): JsonFormsRendererRegistryEntry[] => {
59
+ const options: CreateExtendedRenderersOptions =
60
+ componentsOrOptions && 'components' in componentsOrOptions
61
+ ? (componentsOrOptions as CreateExtendedRenderersOptions)
62
+ : {
63
+ components: componentsOrOptions as
64
+ | Record<string, React.ComponentType<any>>
65
+ | undefined,
66
+ };
67
+ const components = options.components;
68
+ const includeButtonRenderer = options.includeButtonRenderer ?? true;
69
+
70
+ // Wrap the TemplateLayoutRenderer with JSON Forms props
71
+ const WrappedTemplateLayoutRenderer = withJsonFormsLayoutProps(
72
+ (props: TemplateLayoutProps) => (
73
+ <TemplateLayoutRenderer {...props} components={components} />
74
+ ),
75
+ );
76
+
77
+ return [
78
+ { tester: sharedSplitLayoutTester, renderer: SharedSplitLayoutRenderer },
79
+ /*
80
+ The `columns` layout renderer is no longer registered. It encoded child
81
+ width as `options.columns`, an integer from 2 to 16 against a fixed
82
+ 16-column grid - the encoding the Svelte and Vuetify renderer families
83
+ use, and one the portable contract replaces with `options.layout.span`
84
+ against a configurable `gridColumns`.
85
+
86
+ Registering it would have kept overriding the base HorizontalLayout at
87
+ rank 3, so the sizing model could never take effect. The renderer and its
88
+ tester are still exported for a host that wants the old behaviour back;
89
+ a `columns` option now draws a diagnostic instead of silently sizing
90
+ nothing. See Adjustment 21.
91
+ */
92
+ { tester: spacerRendererTester, renderer: SpacerRenderer },
93
+ { tester: imageViewRendererTester, renderer: ImageViewRenderer },
94
+ { tester: separatorRendererTester, renderer: SeparatorRenderer },
95
+ { tester: linkRendererTester, renderer: LinkRenderer },
96
+ /*
97
+ A `Label` that asks for markup. Registered without typography slots: a
98
+ renderer set that has them binds its own entry ahead of this one, and
99
+ ties go to the earlier registration.
100
+ */
101
+ { tester: markupLabelTester, renderer: MarkupLabelRenderer },
102
+ ...(includeButtonRenderer
103
+ ? [
104
+ {
105
+ tester: buttonRendererTester,
106
+ renderer: ButtonRenderer,
107
+ },
108
+ ]
109
+ : []),
110
+ /*
111
+ One entry per template language. The engine is chosen in the **tester**,
112
+ which sees the form-wide `config` and therefore `defaultTemplateLang`;
113
+ resolution is explicit `lang`, then that config key, then `ractive`.
114
+ */
115
+ /*
116
+ Above the string engines: a function template is selected by the shape
117
+ of `template`, not by `lang`, and must win over them.
118
+ */
119
+ {
120
+ tester: tsxTemplateLayoutTester,
121
+ renderer: TsxTemplateLayoutRenderer,
122
+ },
123
+ {
124
+ tester: templateLangTester('jsx'),
125
+ renderer: WrappedTemplateLayoutRenderer,
126
+ },
127
+ {
128
+ tester: templateLangTester('ractive'),
129
+ renderer: withJsonFormsLayoutProps(RactiveTemplateLayoutRenderer),
130
+ },
131
+ /*
132
+ Lower-ranked, so it only wins when neither engine claimed the element:
133
+ "unknown or unsupported languages must be diagnosed rather than
134
+ interpreted as another engine".
135
+ */
136
+ {
137
+ tester: unsupportedTemplateLangTester,
138
+ renderer: withJsonFormsLayoutProps(TemplateDiagnostic as any),
139
+ },
140
+ {
141
+ tester: namedTemplateTester,
142
+ renderer: TemplateRenderer,
143
+ },
144
+ {
145
+ tester: slotRendererTester,
146
+ renderer: SlotRenderer,
147
+ },
148
+ ];
149
+ };
150
+ export * from './renderers';
151
+ export * from './components/GenericAdditionalProperties';
152
+ export * from './util/actionContext';
153
+ export * from './util/horizontalLayout';
154
+
155
+ export * from './core/ajv';
156
+ export * from './core/keywords';
157
+ export * from './core/dynamicDefaults';
158
+ export * from './core/ajvI18n';
159
+ export { default as extendedTransformKeyword } from './core/transform';
160
+ /*
161
+ `./core/ajvI18n/localizers` is deliberately **not** re-exported: it imports
162
+ every language `ajv-i18n` ships, and re-exporting it here would put them in
163
+ the bundle of every form that touches this package. It is imported by path.
164
+ */
165
+ export * from './core/uiSchema';
166
+ export * from './util/configNamespaces';
167
+ export * from './util/urlPolicy';
168
+ export * from './util/templateUrls';
169
+ export * from './util/additionalErrors';
170
+ export * from './components/ExtendedJsonForms';
171
+ export * from './util/editorDiagnostics';
172
+ export * from './util/extendedControls';
173
+ export * from './util/maskControls';
174
+ export * from './util/cron';
175
+ export * from './util/useCronPicker';
176
+ export * from './util/useDurationControl';
177
+ export * from './util/editorControls';
178
+ export * from './components/editorRendererTypes';
179
+ export * from './util/useEditorAppearance';
180
+ export * from './util/i18nDefaults';
181
+ export * from './util/useExtendedTranslator';
182
+ export * from './util/extendedLocale';
183
+ export * from './util/markup';
184
+ export * from './util/interpolate';
185
+ export * from './util/markdownEscape';
186
+ /*
187
+ `./util/markdown` is deliberately **not** re-exported, for the same reason
188
+ as `./core/ajvI18n/localizers` above: it imports markdown-it statically, so
189
+ naming it here would put the parser in the entry chunk of every form and
190
+ undo the dynamic import in `MarkupLabelRenderer`. It is imported by path.
191
+ */
192
+ export * from './locale/bg';
193
+ export * from './renderers/MonacoControlRenderer';
194
+ export * from './renderers/AgGridControlRenderer';
195
+
196
+ export { TRUST_DYNAMIC_FUNCTIONS } from '@chobantonov/jsonforms-react-renderer-common/dynamic/dynamicConfig';
@@ -0,0 +1,51 @@
1
+ import type { ExtendedLocaleCatalog } from '../util/extendedLocale';
2
+
3
+ /**
4
+ * Bulgarian for this package's own strings.
5
+ *
6
+ * ```ts
7
+ * import { registerExtendedLocale, bgExtendedLocale } from '@chobantonov/jsonforms-react-extended-renderers';
8
+ * registerExtendedLocale('bg', bgExtendedLocale);
9
+ * ```
10
+ *
11
+ * The `color.placeholder.*` keys are deliberately absent: they are notations
12
+ * (`#RRGGBB`, `rgb(r, g, b)`), not prose, and translating them would show a
13
+ * pattern the control does not accept.
14
+ */
15
+ export const bgExtendedLocale: ExtendedLocaleCatalog = {
16
+ 'array.addRow': 'Добавяне на ред',
17
+ 'array.removeSelected': 'Премахване на избраните',
18
+ 'grid.loading': 'Таблицата се зарежда...',
19
+ 'grid.loadError': 'Таблицата не може да бъде заредена.',
20
+ 'editor.loading': 'Редакторът се зарежда...',
21
+ 'editor.loadError': 'Редакторът не може да бъде зареден.',
22
+ 'editor.maximize': 'Максимизиране на редактора',
23
+ 'editor.restore': 'Възстановяване на редактора',
24
+ 'editor.invalidJson': 'Въведете валиден JSON.',
25
+ 'editor.chooseColor': 'Изберете цвят',
26
+ 'editor.chooseDuration': 'Изберете продължителност',
27
+ 'template.loading': 'Шаблонният механизъм се зарежда…',
28
+ 'template.loadError': 'Шаблонният механизъм не може да бъде зареден.',
29
+ 'template.renderError': 'Шаблонът не може да бъде изобразен.',
30
+ 'editor.ariaLabel': 'Редактор на код',
31
+ 'duration.invalid':
32
+ 'Въведете продължителност по ISO 8601, например P2DT3H или P2W.',
33
+ 'additionalProperties.add': 'Добавяне',
34
+ 'additionalProperties.addLabel': 'Добавяне на свойство',
35
+ 'additionalProperties.addTo': 'Добавяне на свойство към {label}',
36
+ 'additionalProperties.namePlaceholder': 'Име на свойството',
37
+ 'additionalProperties.rename': 'Преименуване',
38
+ 'additionalProperties.renameNamed': 'Преименуване на {name}',
39
+ 'additionalProperties.save': 'Запазване',
40
+ 'additionalProperties.cancel': 'Отказ',
41
+ 'additionalProperties.delete': 'Изтриване',
42
+ 'additionalProperties.nameTaken': 'Свойството „{name}“ вече е дефинирано',
43
+ 'additionalProperties.nameInvalid': 'Името „{name}“ не е допустимо',
44
+ 'additionalProperties.namePattern':
45
+ 'Името на свойството трябва да съответства на шаблона: {pattern}',
46
+ 'markup.markdownDisabled':
47
+ 'Markdown е изключен за тази форма, затова текстът се показва както е написан.',
48
+ 'markup.unsupported':
49
+ 'Неподдържано маркиране {markup}. Този набор от рендери поддържа „plain“ и „markdown“.',
50
+ 'markup.interpolationFailed': 'Неуспешно изчисляване: {detail}',
51
+ };