@gravity-ui/dynamic-forms 5.23.1 → 5.25.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/build/cjs/lib/kit/i18n/en.json +34 -0
- package/build/cjs/lib/kit/i18n/ru.json +34 -0
- package/build/cjs/lib/unstable/core/SchemaRendererNode/SchemaRendererNode.js +25 -19
- package/build/cjs/lib/unstable/core/SchemaRendererNode/utils.d.ts +3 -0
- package/build/cjs/lib/unstable/core/SchemaRendererNode/utils.js +25 -1
- package/build/cjs/lib/unstable/core/types/components.d.ts +3 -13
- package/build/cjs/lib/unstable/core/types/schema.d.ts +14 -7
- package/build/cjs/lib/unstable/core/types/validation.d.ts +1 -1
- package/build/cjs/lib/unstable/core/useSchemaRenderer/types/state.d.ts +3 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +1 -1
- package/build/cjs/lib/unstable/core/utils/definers.d.ts +27 -13
- package/build/cjs/lib/unstable/kit/components/HTMLContent/HTMLContent.d.ts +2 -1
- package/build/cjs/lib/unstable/kit/components/HTMLContent/HTMLContent.js +12 -2
- package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +3 -0
- package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.d.ts +1 -0
- package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.js +2 -2
- package/build/cjs/lib/unstable/kit/constants/index.d.ts +1 -0
- package/build/cjs/lib/unstable/kit/constants/index.js +3 -1
- package/build/cjs/lib/unstable/kit/constants/messages.d.ts +2 -0
- package/build/cjs/lib/unstable/kit/constants/messages.js +89 -0
- package/build/cjs/lib/unstable/kit/entities/Alert/Alert.css +16 -0
- package/build/cjs/lib/unstable/kit/entities/Alert/Alert.js +26 -7
- package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.d.ts +0 -1
- package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +4 -2
- package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.d.ts +0 -1
- package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +7 -5
- package/build/cjs/lib/unstable/kit/entities/FewOfNested/FewOfNested.css +3 -0
- package/build/cjs/lib/unstable/kit/entities/Label/Label.js +4 -4
- package/build/cjs/lib/unstable/kit/entities/Monaco/Monaco.js +3 -1
- package/build/cjs/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.d.ts +0 -1
- package/build/cjs/lib/unstable/kit/entities/ObjectInline/ObjectInline.d.ts +0 -1
- package/build/cjs/lib/unstable/kit/entities/OneOfNested/OneOfNested.css +3 -0
- package/build/cjs/lib/unstable/kit/entities/TextContent/TextContent.js +4 -4
- package/build/cjs/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.d.ts +0 -1
- package/build/cjs/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/CheckboxInput/CheckboxInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/ColorPickerInput/ColorPickerInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/DateInput/DateInput.js +3 -2
- package/build/cjs/lib/unstable/kit/form-entities/FileInput/FileInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/MultiSelectInput/MultiSelectInput.js +4 -2
- package/build/cjs/lib/unstable/kit/form-entities/NumberInput/NumberInput.js +3 -2
- package/build/cjs/lib/unstable/kit/form-entities/NumberWithScaleInput/NumberWithScaleInput.js +3 -2
- package/build/cjs/lib/unstable/kit/form-entities/PasswordInput/PasswordInput.js +3 -2
- package/build/cjs/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/RangeSliderInput/RangeSliderInput.js +9 -8
- package/build/cjs/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.css +4 -0
- package/build/cjs/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.d.ts +1 -1
- package/build/cjs/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.js +30 -3
- package/build/cjs/lib/unstable/kit/form-entities/SelectInput/SelectInput.d.ts +1 -2
- package/build/cjs/lib/unstable/kit/form-entities/SelectInput/SelectInput.js +4 -2
- package/build/cjs/lib/unstable/kit/form-entities/SliderInput/SliderInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/StringInput/StringInput.js +3 -2
- package/build/cjs/lib/unstable/kit/form-entities/StringNumberWithScaleInput/StringNumberWithScaleInput.js +4 -3
- package/build/cjs/lib/unstable/kit/form-entities/SwitchInput/SwitchInput.js +3 -1
- package/build/cjs/lib/unstable/kit/form-entities/TextAreaInput/TextAreaInput.js +3 -2
- package/build/cjs/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +8 -6
- package/build/cjs/lib/unstable/kit/form-layouts/FormRow/FormRow.css +3 -0
- package/build/cjs/lib/unstable/kit/form-layouts/FormRow/FormRow.js +8 -6
- package/build/cjs/lib/unstable/kit/index.d.ts +1 -0
- package/build/cjs/lib/unstable/kit/index.js +1 -0
- package/build/cjs/lib/unstable/kit/layouts/Accordeon/Accordeon.js +33 -29
- package/build/cjs/lib/unstable/kit/layouts/Card/Card.js +8 -6
- package/build/cjs/lib/unstable/kit/layouts/Section/Section.js +8 -6
- package/build/cjs/lib/unstable/kit/layouts/Transparent/Transparent.js +5 -3
- package/build/cjs/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +7 -5
- package/build/cjs/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +7 -5
- package/build/cjs/lib/unstable/kit/utils/index.d.ts +1 -1
- package/build/cjs/lib/unstable/kit/utils/index.js +1 -7
- package/build/cjs/lib/unstable/kit/utils/transformer.d.ts +10 -17
- package/build/cjs/lib/unstable/kit/utils/transformer.js +543 -2773
- package/build/esm/lib/kit/i18n/en.json +34 -0
- package/build/esm/lib/kit/i18n/ru.json +34 -0
- package/build/esm/lib/unstable/core/SchemaRendererNode/SchemaRendererNode.js +26 -20
- package/build/esm/lib/unstable/core/SchemaRendererNode/utils.d.ts +3 -0
- package/build/esm/lib/unstable/core/SchemaRendererNode/utils.js +22 -0
- package/build/esm/lib/unstable/core/types/components.d.ts +3 -13
- package/build/esm/lib/unstable/core/types/schema.d.ts +14 -7
- package/build/esm/lib/unstable/core/types/validation.d.ts +1 -1
- package/build/esm/lib/unstable/core/useSchemaRenderer/types/state.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +1 -1
- package/build/esm/lib/unstable/core/utils/definers.d.ts +27 -13
- package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.d.ts +2 -1
- package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.js +12 -2
- package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +3 -0
- package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.js +2 -2
- package/build/esm/lib/unstable/kit/constants/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/constants/index.js +1 -0
- package/build/esm/lib/unstable/kit/constants/messages.d.ts +2 -0
- package/build/esm/lib/unstable/kit/constants/messages.js +85 -0
- package/build/esm/lib/unstable/kit/entities/Alert/Alert.css +16 -0
- package/build/esm/lib/unstable/kit/entities/Alert/Alert.d.ts +1 -0
- package/build/esm/lib/unstable/kit/entities/Alert/Alert.js +29 -9
- package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.d.ts +0 -1
- package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +4 -2
- package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.d.ts +0 -1
- package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +7 -5
- package/build/esm/lib/unstable/kit/entities/FewOfNested/FewOfNested.css +3 -0
- package/build/esm/lib/unstable/kit/entities/Label/Label.js +5 -5
- package/build/esm/lib/unstable/kit/entities/Monaco/Monaco.js +3 -1
- package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.d.ts +0 -1
- package/build/esm/lib/unstable/kit/entities/ObjectInline/ObjectInline.d.ts +0 -1
- package/build/esm/lib/unstable/kit/entities/OneOfNested/OneOfNested.css +3 -0
- package/build/esm/lib/unstable/kit/entities/TextContent/TextContent.js +5 -5
- package/build/esm/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.d.ts +0 -1
- package/build/esm/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/CheckboxInput/CheckboxInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/ColorPickerInput/ColorPickerInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/DateInput/DateInput.js +3 -2
- package/build/esm/lib/unstable/kit/form-entities/FileInput/FileInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/MultiSelectInput/MultiSelectInput.js +4 -2
- package/build/esm/lib/unstable/kit/form-entities/NumberInput/NumberInput.js +3 -2
- package/build/esm/lib/unstable/kit/form-entities/NumberWithScaleInput/NumberWithScaleInput.js +3 -2
- package/build/esm/lib/unstable/kit/form-entities/PasswordInput/PasswordInput.js +3 -2
- package/build/esm/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/RangeSliderInput/RangeSliderInput.js +9 -8
- package/build/esm/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.css +4 -0
- package/build/esm/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.d.ts +1 -1
- package/build/esm/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.js +30 -3
- package/build/esm/lib/unstable/kit/form-entities/SelectInput/SelectInput.d.ts +1 -2
- package/build/esm/lib/unstable/kit/form-entities/SelectInput/SelectInput.js +4 -2
- package/build/esm/lib/unstable/kit/form-entities/SliderInput/SliderInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/StringInput/StringInput.js +3 -2
- package/build/esm/lib/unstable/kit/form-entities/StringNumberWithScaleInput/StringNumberWithScaleInput.js +4 -3
- package/build/esm/lib/unstable/kit/form-entities/SwitchInput/SwitchInput.js +3 -1
- package/build/esm/lib/unstable/kit/form-entities/TextAreaInput/TextAreaInput.js +3 -2
- package/build/esm/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +8 -6
- package/build/esm/lib/unstable/kit/form-layouts/FormRow/FormRow.css +3 -0
- package/build/esm/lib/unstable/kit/form-layouts/FormRow/FormRow.js +8 -6
- package/build/esm/lib/unstable/kit/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/index.js +1 -0
- package/build/esm/lib/unstable/kit/layouts/Accordeon/Accordeon.js +33 -29
- package/build/esm/lib/unstable/kit/layouts/Card/Card.js +8 -6
- package/build/esm/lib/unstable/kit/layouts/Section/Section.js +8 -6
- package/build/esm/lib/unstable/kit/layouts/Transparent/Transparent.js +5 -3
- package/build/esm/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +7 -5
- package/build/esm/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +7 -5
- package/build/esm/lib/unstable/kit/utils/index.d.ts +1 -1
- package/build/esm/lib/unstable/kit/utils/index.js +1 -1
- package/build/esm/lib/unstable/kit/utils/transformer.d.ts +10 -17
- package/build/esm/lib/unstable/kit/utils/transformer.js +544 -2773
- package/package.json +1 -1
|
@@ -35,6 +35,40 @@
|
|
|
35
35
|
"Value can't be longer than {{count}} items",
|
|
36
36
|
"Value can't be longer than {{count}} items"
|
|
37
37
|
],
|
|
38
|
+
"label-sr_error-additional-items": "Maximum allowed number of items is {{count}}",
|
|
39
|
+
"label-sr_error-additional-properties": "Maximum allowed number of properties is {{count}}",
|
|
40
|
+
"label-sr_error-any-of": "Incorrect value in field",
|
|
41
|
+
"label-sr_error-const": "Value must be {{expected}}",
|
|
42
|
+
"label-sr_error-contains": "At least one item must be added",
|
|
43
|
+
"label-sr_error-contains-min": "At least one item matching the condition must be added",
|
|
44
|
+
"label-sr_error-dependencies": "Field \"{{property}}\" is required",
|
|
45
|
+
"label-sr_error-enum": "Value {{value}} cannot be used",
|
|
46
|
+
"label-sr_error-exclusive-maximum": "Value must be less than {{count}}",
|
|
47
|
+
"label-sr_error-exclusive-minimum": "Value must be greater than {{count}}",
|
|
48
|
+
"label-sr_error-max-items": "Maximum allowed number of items is {{count}}",
|
|
49
|
+
"label-sr_error-max-length": "Maximum allowed number of characters is {{count}}",
|
|
50
|
+
"label-sr_error-max-properties": "Maximum allowed number of properties is {{count}}",
|
|
51
|
+
"label-sr_error-maximum": "Value must be less than or equal to {{count}}",
|
|
52
|
+
"label-sr_error-min-items": "Minimum allowed number of items is {{count}}",
|
|
53
|
+
"label-sr_error-min-length": "Minimum allowed number of characters is {{count}}",
|
|
54
|
+
"label-sr_error-min-properties": "Minimum allowed number of properties is {{count}}",
|
|
55
|
+
"label-sr_error-minimum": "Value must be greater than or equal to {{count}}",
|
|
56
|
+
"label-sr_error-multiple-of": "Value must be a multiple of {{count}}",
|
|
57
|
+
"label-sr_error-not": "Value cannot be used",
|
|
58
|
+
"label-sr_error-one-of": "Incorrect value in field",
|
|
59
|
+
"label-sr_error-pattern": "Value must match the pattern - {{pattern}}",
|
|
60
|
+
"label-sr_error-property-names": "Invalid property name \"{{property}}\"",
|
|
61
|
+
"label-sr_error-required": "Empty field",
|
|
62
|
+
"label-sr_error-type": "Value must be {{expected}}",
|
|
63
|
+
"label-sr_error-type-or": " or {{type}}",
|
|
64
|
+
"label-sr_error-unique-items": "Values must be unique",
|
|
65
|
+
"label-sr_type-array": "an array",
|
|
66
|
+
"label-sr_type-boolean": "a boolean",
|
|
67
|
+
"label-sr_type-integer": "an integer",
|
|
68
|
+
"label-sr_type-null": "null",
|
|
69
|
+
"label-sr_type-number": "a number",
|
|
70
|
+
"label-sr_type-object": "an object",
|
|
71
|
+
"label-sr_type-string": "a string",
|
|
38
72
|
"label_error-min-number": "Value must be an integer no less than {{count}}",
|
|
39
73
|
"label_error-max-number": "Value must not be greater than {{count}}",
|
|
40
74
|
"label_error-min-number-with-scale": "Value must be no less than {{count}} {{scale}}",
|
|
@@ -35,6 +35,40 @@
|
|
|
35
35
|
"Значение не может быть длиннее {{count}} элементов",
|
|
36
36
|
"Значение не может быть длиннее {{count}} элементов"
|
|
37
37
|
],
|
|
38
|
+
"label-sr_error-additional-items": "Максимальное допустимое количество элементов: {{count}}",
|
|
39
|
+
"label-sr_error-additional-properties": "Максимальное допустимое количество свойств: {{count}}",
|
|
40
|
+
"label-sr_error-any-of": "Поле заполнено неправильно",
|
|
41
|
+
"label-sr_error-const": "Значение должно быть равно {{expected}}",
|
|
42
|
+
"label-sr_error-contains": "Необходимо добавить хотя бы один элемент",
|
|
43
|
+
"label-sr_error-contains-min": "Необходимо добавить хотя бы один элемент, удовлетворяющий условию",
|
|
44
|
+
"label-sr_error-dependencies": "Необходимо заполнить поле \"{{property}}\"",
|
|
45
|
+
"label-sr_error-enum": "Значение {{value}} не допустимо к использованию",
|
|
46
|
+
"label-sr_error-exclusive-maximum": "Значение должно быть меньше {{count}}",
|
|
47
|
+
"label-sr_error-exclusive-minimum": "Значение должно быть больше {{count}}",
|
|
48
|
+
"label-sr_error-max-items": "Максимальное допустимое количество элементов: {{count}}",
|
|
49
|
+
"label-sr_error-max-length": "Максимальное допустимое количество символов: {{count}}",
|
|
50
|
+
"label-sr_error-max-properties": "Максимальное допустимое количество свойств: {{count}}",
|
|
51
|
+
"label-sr_error-maximum": "Значение должно быть меньше или равно {{count}}",
|
|
52
|
+
"label-sr_error-min-items": "Минимальное допустимое количество элементов: {{count}}",
|
|
53
|
+
"label-sr_error-min-length": "Минимальное допустимое количество символов: {{count}}",
|
|
54
|
+
"label-sr_error-min-properties": "Минимальное допустимое количество свойств: {{count}}",
|
|
55
|
+
"label-sr_error-minimum": "Значение должно быть больше или равно {{count}}",
|
|
56
|
+
"label-sr_error-multiple-of": "Значение должно быть кратно {{count}}",
|
|
57
|
+
"label-sr_error-not": "Значение не допустимо к использованию",
|
|
58
|
+
"label-sr_error-one-of": "Поле заполнено неправильно",
|
|
59
|
+
"label-sr_error-pattern": "Значение должно удовлетворять шаблону - {{pattern}}",
|
|
60
|
+
"label-sr_error-property-names": "Недопустимое имя свойства \"{{property}}\"",
|
|
61
|
+
"label-sr_error-required": "Поле не заполнено",
|
|
62
|
+
"label-sr_error-type": "Значение должно быть {{expected}}",
|
|
63
|
+
"label-sr_error-type-or": " или {{type}}",
|
|
64
|
+
"label-sr_error-unique-items": "Значения должны быть уникальными",
|
|
65
|
+
"label-sr_type-array": "массивом",
|
|
66
|
+
"label-sr_type-boolean": "булевым значением",
|
|
67
|
+
"label-sr_type-integer": "целым числом",
|
|
68
|
+
"label-sr_type-null": "null",
|
|
69
|
+
"label-sr_type-number": "числом",
|
|
70
|
+
"label-sr_type-object": "объектом",
|
|
71
|
+
"label-sr_type-string": "строкой",
|
|
38
72
|
"label_error-min-number": "Значение должно быть числом не меньше {{count}}",
|
|
39
73
|
"label_error-max-number": "Значение должно быть числом не больше {{count}}",
|
|
40
74
|
"label_error-min-number-with-scale": "Значение должно быть не меньше {{count}} {{scale}}",
|
|
@@ -13,8 +13,7 @@ const utils_2 = require("./utils");
|
|
|
13
13
|
const SchemaRendererNodeComponent = ({ headName, modeOverride, name, schemaOverride, schemaPath, }) => {
|
|
14
14
|
var _a;
|
|
15
15
|
const form = (0, react_final_form_1.useForm)();
|
|
16
|
-
const
|
|
17
|
-
const pendingTicksRef = react_1.default.useRef({ input: 0, meta: 0 });
|
|
16
|
+
const compareValuesRef = react_1.default.useRef((0, utils_2.getCompareValues)());
|
|
18
17
|
const fieldRef = react_1.default.useRef(null);
|
|
19
18
|
const unsubscribeRef = react_1.default.useRef(null);
|
|
20
19
|
const [ticks, setTicks] = react_1.default.useState({ input: 0, meta: 0 });
|
|
@@ -39,6 +38,17 @@ const SchemaRendererNodeComponent = ({ headName, modeOverride, name, schemaOverr
|
|
|
39
38
|
const kit = react_1.default.useMemo(() => (0, utils_2.getRenderKit)({ config: srState === null || srState === void 0 ? void 0 : srState.config, schema }), [schema, srState === null || srState === void 0 ? void 0 : srState.config]);
|
|
40
39
|
react_1.default.useMemo(() => {
|
|
41
40
|
var _a;
|
|
41
|
+
if (compareValuesRef.current({
|
|
42
|
+
form,
|
|
43
|
+
jsonDefaultValues,
|
|
44
|
+
headName,
|
|
45
|
+
name,
|
|
46
|
+
default: schema === null || schema === void 0 ? void 0 : schema.default,
|
|
47
|
+
type: schema === null || schema === void 0 ? void 0 : schema.type,
|
|
48
|
+
schemaPath,
|
|
49
|
+
})) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
42
52
|
(_a = unsubscribeRef.current) === null || _a === void 0 ? void 0 : _a.call(unsubscribeRef);
|
|
43
53
|
const initialState = { schemaPath };
|
|
44
54
|
let defaultValue = schema === null || schema === void 0 ? void 0 : schema.default;
|
|
@@ -48,7 +58,7 @@ const SchemaRendererNodeComponent = ({ headName, modeOverride, name, schemaOverr
|
|
|
48
58
|
}
|
|
49
59
|
catch (_b) { }
|
|
50
60
|
}
|
|
51
|
-
|
|
61
|
+
const unsubscribe = form.registerField(name, (f) => {
|
|
52
62
|
const prevF = fieldRef.current;
|
|
53
63
|
if (prevF) {
|
|
54
64
|
let inputTick = 0;
|
|
@@ -62,23 +72,26 @@ const SchemaRendererNodeComponent = ({ headName, modeOverride, name, schemaOverr
|
|
|
62
72
|
metaTick = 1;
|
|
63
73
|
}
|
|
64
74
|
if (inputTick + metaTick) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
setTicks((t) => ({
|
|
70
|
-
input: t.input + inputTick,
|
|
71
|
-
meta: t.meta + metaTick,
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
75
|
+
setTicks((t) => ({
|
|
76
|
+
input: t.input + inputTick,
|
|
77
|
+
meta: t.meta + metaTick,
|
|
78
|
+
}));
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
fieldRef.current = f;
|
|
77
82
|
}, { submitFailed: true, touched: true, validating: true, value: true }, {
|
|
78
83
|
data: { state: initialState },
|
|
79
84
|
defaultValue,
|
|
85
|
+
silent: true,
|
|
80
86
|
validateFields: [(0, utils_1.getServiceFieldName)(useSchemaRenderer_1.SCHEMA_RENDERER_SERVICE_FIELD, headName)],
|
|
81
87
|
});
|
|
88
|
+
if (defaultValue !== undefined) {
|
|
89
|
+
(0, utils_2.scheduleFlush)(form);
|
|
90
|
+
}
|
|
91
|
+
unsubscribeRef.current = () => {
|
|
92
|
+
unsubscribe();
|
|
93
|
+
(0, utils_2.scheduleFlush)(form);
|
|
94
|
+
};
|
|
82
95
|
}, [form, jsonDefaultValues, headName, name, schema === null || schema === void 0 ? void 0 : schema.default, schema === null || schema === void 0 ? void 0 : schema.type, schemaPath]);
|
|
83
96
|
const input = react_1.default.useMemo(() => {
|
|
84
97
|
var _a;
|
|
@@ -103,13 +116,6 @@ const SchemaRendererNodeComponent = ({ headName, modeOverride, name, schemaOverr
|
|
|
103
116
|
};
|
|
104
117
|
}, [error, form, name, ticks.meta]);
|
|
105
118
|
react_1.default.useEffect(() => {
|
|
106
|
-
firstRenderRef.current = false;
|
|
107
|
-
if (pendingTicksRef.current.input || pendingTicksRef.current.meta) {
|
|
108
|
-
setTicks((t) => ({
|
|
109
|
-
input: t.input + pendingTicksRef.current.input,
|
|
110
|
-
meta: t.meta + pendingTicksRef.current.meta,
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
119
|
return () => {
|
|
114
120
|
var _a;
|
|
115
121
|
(_a = unsubscribeRef.current) === null || _a === void 0 ? void 0 : _a.call(unsubscribeRef);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FormApi } from 'final-form';
|
|
1
2
|
import { SchemaRendererMode } from '../constants';
|
|
2
3
|
import type { JsonSchema, NodeEntity, NodeLayout, NodesConfig } from '../types';
|
|
3
4
|
type GetRenderKitParams<Schema extends JsonSchema> = {
|
|
@@ -22,4 +23,6 @@ type GetRenderKitReturn<Schema extends JsonSchema> = {
|
|
|
22
23
|
};
|
|
23
24
|
export declare const getRenderKit: <Schema extends JsonSchema>({ config, schema, }: GetRenderKitParams<Schema>) => GetRenderKitReturn<Schema>;
|
|
24
25
|
export declare const getAccumulatedSchema: (schemaPath: string, rootSchema?: JsonSchema, override?: JsonSchema, collectedPaths?: Set<string>) => JsonSchema;
|
|
26
|
+
export declare const scheduleFlush: (form: FormApi) => void;
|
|
27
|
+
export declare const getCompareValues: () => (currentValues: Record<string, unknown>) => boolean;
|
|
25
28
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccumulatedSchema = exports.getRenderKit = void 0;
|
|
3
|
+
exports.getCompareValues = exports.scheduleFlush = exports.getAccumulatedSchema = exports.getRenderKit = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
6
6
|
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
@@ -160,3 +160,27 @@ const getAccumulatedSchema = (schemaPath, rootSchema, override, collectedPaths =
|
|
|
160
160
|
return accumulatedSchema;
|
|
161
161
|
};
|
|
162
162
|
exports.getAccumulatedSchema = getAccumulatedSchema;
|
|
163
|
+
const flushes = new WeakMap();
|
|
164
|
+
const scheduleFlush = (form) => {
|
|
165
|
+
if (flushes.get(form)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
flushes.set(form, true);
|
|
169
|
+
queueMicrotask(() => {
|
|
170
|
+
flushes.delete(form);
|
|
171
|
+
form.batch(() => { });
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
exports.scheduleFlush = scheduleFlush;
|
|
175
|
+
const getCompareValues = () => {
|
|
176
|
+
let cachedValues;
|
|
177
|
+
return (currentValues) => {
|
|
178
|
+
if (!cachedValues ||
|
|
179
|
+
[...Object.keys(cachedValues), ...Object.keys(currentValues)].some((key) => cachedValues[key] !== currentValues[key])) {
|
|
180
|
+
cachedValues = Object.assign({}, currentValues);
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
exports.getCompareValues = getCompareValues;
|
|
@@ -3,31 +3,21 @@ import type { FieldRenderProps } from 'react-final-form';
|
|
|
3
3
|
import type { SchemaRendererMode } from '../constants';
|
|
4
4
|
import type { SchemaToValueType } from './helpers';
|
|
5
5
|
import type { JsonSchema } from './schema';
|
|
6
|
-
export interface DefaultNodeLayoutProps {
|
|
7
|
-
copy?: boolean;
|
|
8
|
-
hidden?: boolean;
|
|
9
|
-
open?: boolean;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
}
|
|
12
6
|
export interface NodeLayoutProps<Schema extends JsonSchema, Props extends Record<string, any> = {}, Value extends SchemaToValueType<Schema> = SchemaToValueType<Schema>> extends FieldRenderProps<Value | null | undefined> {
|
|
13
7
|
children: React.ReactNode;
|
|
14
8
|
headName: string;
|
|
15
9
|
mode: SchemaRendererMode;
|
|
16
|
-
props:
|
|
10
|
+
props: Partial<Props>;
|
|
17
11
|
schema: Schema;
|
|
18
12
|
schemaPath: string;
|
|
19
13
|
}
|
|
20
14
|
export type NodeLayout<Schema extends JsonSchema, Props extends Record<string, any> = {}, Value extends SchemaToValueType<Schema> = SchemaToValueType<Schema>> = React.FC<NodeLayoutProps<Schema, Props, Value>>;
|
|
21
|
-
export interface DefaultNodeEntityProps {
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
}
|
|
25
15
|
export interface NodeEntityProps<Schema extends JsonSchema, Props extends Record<string, any> = {}, LayoutProps extends Record<string, any> = {}, Value extends SchemaToValueType<Schema> = SchemaToValueType<Schema>> extends FieldRenderProps<Value | null | undefined> {
|
|
26
16
|
Layout?: NodeLayout<Schema, LayoutProps>;
|
|
27
17
|
headName: string;
|
|
28
|
-
layoutProps?:
|
|
18
|
+
layoutProps?: Partial<LayoutProps>;
|
|
29
19
|
mode: SchemaRendererMode;
|
|
30
|
-
props:
|
|
20
|
+
props: Partial<Props>;
|
|
31
21
|
schema: Schema;
|
|
32
22
|
schemaPath: string;
|
|
33
23
|
}
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import type { JsonSchemaType, NodeType } from '../constants';
|
|
2
|
-
import type {
|
|
2
|
+
import type { NodeEntity, NodeLayout } from './components';
|
|
3
3
|
import type { ErrorMessages, Validator } from './validation';
|
|
4
4
|
import type { ArrayValue, FieldValue, ObjectValue } from './values';
|
|
5
5
|
interface NodeParameters<Type extends NodeType, Schema extends JsonSchema> {
|
|
6
6
|
nodeParameters?: {
|
|
7
7
|
entity?: string | NodeEntity<Schema>;
|
|
8
|
-
entityProps?:
|
|
8
|
+
entityProps?: Record<string, any>;
|
|
9
9
|
errorMessages?: Omit<ErrorMessages, 'dependencies' | 'required'> & {
|
|
10
10
|
dependencies?: ErrorMessages['dependencies'] | Record<string, ErrorMessages['dependencies']>;
|
|
11
11
|
required?: ErrorMessages['required'] | Record<string, ErrorMessages['required']>;
|
|
12
12
|
};
|
|
13
|
+
flags?: {
|
|
14
|
+
copy?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
open?: boolean;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
};
|
|
13
20
|
formEntity?: string | NodeEntity<Schema>;
|
|
14
|
-
formEntityProps?:
|
|
21
|
+
formEntityProps?: Record<string, any>;
|
|
15
22
|
formLayout?: string | NodeLayout<Schema>;
|
|
16
|
-
formLayoutProps?:
|
|
23
|
+
formLayoutProps?: Record<string, any>;
|
|
17
24
|
layout?: string | NodeLayout<Schema>;
|
|
18
|
-
layoutProps?:
|
|
25
|
+
layoutProps?: Record<string, any>;
|
|
19
26
|
overviewEntity?: string | NodeEntity<Schema>;
|
|
20
|
-
overviewEntityProps?:
|
|
27
|
+
overviewEntityProps?: Record<string, any>;
|
|
21
28
|
overviewLayout?: string | NodeLayout<Schema>;
|
|
22
|
-
overviewLayoutProps?:
|
|
29
|
+
overviewLayoutProps?: Record<string, any>;
|
|
23
30
|
type?: Type;
|
|
24
31
|
validator?: string | Validator<Schema>;
|
|
25
32
|
};
|
|
@@ -12,7 +12,7 @@ export interface ErrorMessages {
|
|
|
12
12
|
additionalProperties?: ((e: JSLErrors.AdditionalProperties) => string) | string;
|
|
13
13
|
anyOf?: ((e: JSLErrors.AnyOf) => string) | string;
|
|
14
14
|
const?: ((e: JSLErrors.Const) => string) | string;
|
|
15
|
-
contains?: ((e: JSLErrors.ContainsAny) => string) | string;
|
|
15
|
+
contains?: ((e: JSLErrors.ContainsAny | JSLErrors.ContainsMin) => string) | string;
|
|
16
16
|
dependencies?: ((e: JSLErrors.Dependencies) => string) | string;
|
|
17
17
|
enum?: ((e: JSLErrors.Enum) => string) | string;
|
|
18
18
|
exclusiveMaximum?: ((e: JSLErrors.ExclusiveMaximum) => string) | string;
|
|
@@ -29,6 +29,9 @@ export interface SchemaRendererState<UserContext extends Record<string, unknown>
|
|
|
29
29
|
unsubscribe: (id: string) => void;
|
|
30
30
|
userContext: {
|
|
31
31
|
MonacoEditor?: React.ComponentType<MonacoEditorProps>;
|
|
32
|
+
RenderHTMLOrMD?: React.ComponentType<{
|
|
33
|
+
content: string;
|
|
34
|
+
}>;
|
|
32
35
|
} & UserContext;
|
|
33
36
|
waiters: Record<string, ValidationWaiter | undefined>;
|
|
34
37
|
}
|
|
@@ -72,7 +72,7 @@ const useSchemaRenderer = ({ config, connectValidate = true, errorMessages, json
|
|
|
72
72
|
state.dispatchEvent(initialEvents);
|
|
73
73
|
initialEvents = [];
|
|
74
74
|
}
|
|
75
|
-
}, { data: true }, { data: { state: initialState }, getValidator, validateFields: [headName] });
|
|
75
|
+
}, { data: true }, { data: { state: initialState }, getValidator, silent: true, validateFields: [headName] });
|
|
76
76
|
prevParamsRef.current = {
|
|
77
77
|
config,
|
|
78
78
|
errorMessages,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeType } from '../constants';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ErrorMessages, NodeEntity, NodeLayout, NodesConfig, Validator } from '../types';
|
|
3
3
|
import type { EntityKind, ExtractNodeEntityProps, ExtractNodeLayoutProps, LayoutKind, NodeComponentProps, NodeTypeConfigKey, SchemaOfNodeType } from '../types/helpers';
|
|
4
4
|
export declare const defineNodeEntityConfig: <Component extends NodeEntity<any>>(nodeEntityConfig: {
|
|
5
5
|
Component: Component;
|
|
@@ -20,39 +20,53 @@ export declare const defineNodeLayoutConfig: <Component extends NodeLayout<any>>
|
|
|
20
20
|
export declare const createNodeParametersDefiner: <Config extends NodesConfig>(_config: Config) => <Type extends NodeType, const Entity extends NodeTypeConfigKey<Config, Type, "formEntities"> | NodeTypeConfigKey<Config, Type, "overviewEntities"> | NodeEntity<SchemaOfNodeType<Type>> | undefined = undefined, const FormEntity extends NodeTypeConfigKey<Config, Type, "formEntities"> | NodeEntity<SchemaOfNodeType<Type>> | undefined = undefined, const OverviewEntity extends NodeTypeConfigKey<Config, Type, "overviewEntities"> | NodeEntity<SchemaOfNodeType<Type>> | undefined = undefined, const Layout extends NodeTypeConfigKey<Config, Type, "formLayouts"> | NodeTypeConfigKey<Config, Type, "overviewLayouts"> | NodeLayout<SchemaOfNodeType<Type>> | undefined = undefined, const FormLayout extends NodeTypeConfigKey<Config, Type, "formLayouts"> | NodeLayout<SchemaOfNodeType<Type>> | undefined = undefined, const OverviewLayout extends NodeTypeConfigKey<Config, Type, "overviewLayouts"> | NodeLayout<SchemaOfNodeType<Type>> | undefined = undefined, const ValidatorRef extends NodeTypeConfigKey<Config, Type, "validators"> | Validator<SchemaOfNodeType<Type>> | undefined = undefined>(nodeParameters: {
|
|
21
21
|
type: Type;
|
|
22
22
|
entity?: NoInfer<NodeTypeConfigKey<Config, Type, "formEntities">> | NoInfer<NodeTypeConfigKey<Config, Type, "overviewEntities">> | NodeEntity<SchemaOfNodeType<Type>> | Entity;
|
|
23
|
-
entityProps?:
|
|
23
|
+
entityProps?: NodeComponentProps<Config, Type, EntityKind, Entity>;
|
|
24
24
|
formEntity?: NoInfer<NodeTypeConfigKey<Config, Type, "formEntities">> | NodeEntity<SchemaOfNodeType<Type>> | FormEntity;
|
|
25
|
-
formEntityProps?:
|
|
25
|
+
formEntityProps?: NodeComponentProps<Config, Type, "formEntities", FormEntity>;
|
|
26
26
|
overviewEntity?: NoInfer<NodeTypeConfigKey<Config, Type, "overviewEntities">> | NodeEntity<SchemaOfNodeType<Type>> | OverviewEntity;
|
|
27
|
-
overviewEntityProps?:
|
|
27
|
+
overviewEntityProps?: NodeComponentProps<Config, Type, "overviewEntities", OverviewEntity>;
|
|
28
28
|
layout?: NoInfer<NodeTypeConfigKey<Config, Type, "formLayouts">> | NoInfer<NodeTypeConfigKey<Config, Type, "overviewLayouts">> | NodeLayout<SchemaOfNodeType<Type>> | Layout;
|
|
29
|
-
layoutProps?:
|
|
29
|
+
layoutProps?: NodeComponentProps<Config, Type, LayoutKind, Layout>;
|
|
30
30
|
formLayout?: NoInfer<NodeTypeConfigKey<Config, Type, "formLayouts">> | NodeLayout<SchemaOfNodeType<Type>> | FormLayout;
|
|
31
|
-
formLayoutProps?:
|
|
31
|
+
formLayoutProps?: NodeComponentProps<Config, Type, "formLayouts", FormLayout>;
|
|
32
32
|
overviewLayout?: NoInfer<NodeTypeConfigKey<Config, Type, "overviewLayouts">> | NodeLayout<SchemaOfNodeType<Type>> | OverviewLayout;
|
|
33
|
-
overviewLayoutProps?:
|
|
33
|
+
overviewLayoutProps?: NodeComponentProps<Config, Type, "overviewLayouts", OverviewLayout>;
|
|
34
34
|
errorMessages?: Omit<ErrorMessages, "dependencies" | "required"> & {
|
|
35
35
|
dependencies?: ErrorMessages["dependencies"] | Record<string, ErrorMessages["dependencies"]>;
|
|
36
36
|
required?: ErrorMessages["required"] | Record<string, ErrorMessages["required"]>;
|
|
37
37
|
};
|
|
38
38
|
validator?: NoInfer<NodeTypeConfigKey<Config, Type, "validators">> | Validator<SchemaOfNodeType<Type>> | ValidatorRef;
|
|
39
|
+
flags?: {
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
copy?: boolean;
|
|
42
|
+
hidden?: boolean;
|
|
43
|
+
open?: boolean;
|
|
44
|
+
required?: boolean;
|
|
45
|
+
};
|
|
39
46
|
}) => {
|
|
40
47
|
type: Type;
|
|
41
48
|
entity?: NoInfer<NodeTypeConfigKey<Config, Type, "formEntities">> | NoInfer<NodeTypeConfigKey<Config, Type, "overviewEntities">> | NodeEntity<SchemaOfNodeType<Type>> | Entity;
|
|
42
|
-
entityProps?:
|
|
49
|
+
entityProps?: NodeComponentProps<Config, Type, EntityKind, Entity>;
|
|
43
50
|
formEntity?: NoInfer<NodeTypeConfigKey<Config, Type, "formEntities">> | NodeEntity<SchemaOfNodeType<Type>> | FormEntity;
|
|
44
|
-
formEntityProps?:
|
|
51
|
+
formEntityProps?: NodeComponentProps<Config, Type, "formEntities", FormEntity>;
|
|
45
52
|
overviewEntity?: NoInfer<NodeTypeConfigKey<Config, Type, "overviewEntities">> | NodeEntity<SchemaOfNodeType<Type>> | OverviewEntity;
|
|
46
|
-
overviewEntityProps?:
|
|
53
|
+
overviewEntityProps?: NodeComponentProps<Config, Type, "overviewEntities", OverviewEntity>;
|
|
47
54
|
layout?: NoInfer<NodeTypeConfigKey<Config, Type, "formLayouts">> | NoInfer<NodeTypeConfigKey<Config, Type, "overviewLayouts">> | NodeLayout<SchemaOfNodeType<Type>> | Layout;
|
|
48
|
-
layoutProps?:
|
|
55
|
+
layoutProps?: NodeComponentProps<Config, Type, LayoutKind, Layout>;
|
|
49
56
|
formLayout?: NoInfer<NodeTypeConfigKey<Config, Type, "formLayouts">> | NodeLayout<SchemaOfNodeType<Type>> | FormLayout;
|
|
50
|
-
formLayoutProps?:
|
|
57
|
+
formLayoutProps?: NodeComponentProps<Config, Type, "formLayouts", FormLayout>;
|
|
51
58
|
overviewLayout?: NoInfer<NodeTypeConfigKey<Config, Type, "overviewLayouts">> | NodeLayout<SchemaOfNodeType<Type>> | OverviewLayout;
|
|
52
|
-
overviewLayoutProps?:
|
|
59
|
+
overviewLayoutProps?: NodeComponentProps<Config, Type, "overviewLayouts", OverviewLayout>;
|
|
53
60
|
errorMessages?: Omit<ErrorMessages, "dependencies" | "required"> & {
|
|
54
61
|
dependencies?: ErrorMessages["dependencies"] | Record<string, ErrorMessages["dependencies"]>;
|
|
55
62
|
required?: ErrorMessages["required"] | Record<string, ErrorMessages["required"]>;
|
|
56
63
|
};
|
|
57
64
|
validator?: NoInfer<NodeTypeConfigKey<Config, Type, "validators">> | Validator<SchemaOfNodeType<Type>> | ValidatorRef;
|
|
65
|
+
flags?: {
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
copy?: boolean;
|
|
68
|
+
hidden?: boolean;
|
|
69
|
+
open?: boolean;
|
|
70
|
+
required?: boolean;
|
|
71
|
+
};
|
|
58
72
|
};
|
|
@@ -4,8 +4,18 @@ exports.HTMLContent = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
+
const core_1 = require("../../../core");
|
|
7
8
|
const HTMLContent = (_a) => {
|
|
8
|
-
var
|
|
9
|
-
|
|
9
|
+
var _b;
|
|
10
|
+
var { content, headName = '___stub-name' } = _a, restProps = tslib_1.__rest(_a, ["content", "headName"]);
|
|
11
|
+
const state = (0, core_1.useSchemaRendererState)({
|
|
12
|
+
headName,
|
|
13
|
+
subscriptions: [core_1.SchemaRendererEventType.UserContext],
|
|
14
|
+
});
|
|
15
|
+
const RenderHTMLOrMD = (_b = state === null || state === void 0 ? void 0 : state.userContext) === null || _b === void 0 ? void 0 : _b.RenderHTMLOrMD;
|
|
16
|
+
if (RenderHTMLOrMD) {
|
|
17
|
+
return react_1.default.createElement(RenderHTMLOrMD, { content: content });
|
|
18
|
+
}
|
|
19
|
+
return react_1.default.createElement(uikit_1.Text, Object.assign({}, restProps, { dangerouslySetInnerHTML: { __html: content } }));
|
|
10
20
|
};
|
|
11
21
|
exports.HTMLContent = HTMLContent;
|
|
@@ -7,7 +7,7 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const b = (0, utils_1.block)('layout-container');
|
|
9
9
|
const LayoutContainer = (_a) => {
|
|
10
|
-
var { className, children, hideEmpty = false } = _a, restProps = tslib_1.__rest(_a, ["className", "children", "hideEmpty"]);
|
|
11
|
-
return (react_1.default.createElement(uikit_1.Flex, Object.assign({ className: b({ 'hide-empty': hideEmpty }, className), direction: "column" }, restProps), children));
|
|
10
|
+
var { className, children, hideEmpty = false, hidden = false } = _a, restProps = tslib_1.__rest(_a, ["className", "children", "hideEmpty", "hidden"]);
|
|
11
|
+
return (react_1.default.createElement(uikit_1.Flex, Object.assign({ className: b({ 'hide-empty': hideEmpty, hidden }, className), direction: "column" }, restProps), children));
|
|
12
12
|
};
|
|
13
13
|
exports.LayoutContainer = LayoutContainer;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.untypedConfig = exports.config = exports.DEFAULT_DATE_FORMAT = exports.DASH = void 0;
|
|
3
|
+
exports.errorMessages = exports.untypedConfig = exports.config = exports.DEFAULT_DATE_FORMAT = exports.DASH = void 0;
|
|
4
4
|
var common_1 = require("./common");
|
|
5
5
|
Object.defineProperty(exports, "DASH", { enumerable: true, get: function () { return common_1.DASH; } });
|
|
6
6
|
Object.defineProperty(exports, "DEFAULT_DATE_FORMAT", { enumerable: true, get: function () { return common_1.DEFAULT_DATE_FORMAT; } });
|
|
7
7
|
var config_1 = require("./config");
|
|
8
8
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
|
|
9
9
|
Object.defineProperty(exports, "untypedConfig", { enumerable: true, get: function () { return config_1.untypedConfig; } });
|
|
10
|
+
var messages_1 = require("./messages");
|
|
11
|
+
Object.defineProperty(exports, "errorMessages", { enumerable: true, get: function () { return messages_1.errorMessages; } });
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorMessages = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
6
|
+
const i18n_1 = tslib_1.__importDefault(require("../../../kit/i18n"));
|
|
7
|
+
const configure_1 = require("../../../kit/i18n/configure");
|
|
8
|
+
const TYPE_I18N_KEYS = {
|
|
9
|
+
array: 'label-sr_type-array',
|
|
10
|
+
boolean: 'label-sr_type-boolean',
|
|
11
|
+
integer: 'label-sr_type-integer',
|
|
12
|
+
null: 'label-sr_type-null',
|
|
13
|
+
number: 'label-sr_type-number',
|
|
14
|
+
object: 'label-sr_type-object',
|
|
15
|
+
string: 'label-sr_type-string',
|
|
16
|
+
};
|
|
17
|
+
const getErrorMessages = () => ({
|
|
18
|
+
additionalItems: (e) => {
|
|
19
|
+
const schema = e.data.schema;
|
|
20
|
+
if (Array.isArray(schema.items)) {
|
|
21
|
+
return (0, i18n_1.default)('label-sr_error-additional-items', { count: schema.items.length });
|
|
22
|
+
}
|
|
23
|
+
return e.message;
|
|
24
|
+
},
|
|
25
|
+
additionalProperties: (e) => {
|
|
26
|
+
const schema = e.data.schema;
|
|
27
|
+
if (schema.properties) {
|
|
28
|
+
return (0, i18n_1.default)('label-sr_error-additional-properties', {
|
|
29
|
+
count: Object.keys(schema.properties).length,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return e.message;
|
|
33
|
+
},
|
|
34
|
+
anyOf: (0, i18n_1.default)('label-sr_error-any-of'),
|
|
35
|
+
const: (e) => (0, i18n_1.default)('label-sr_error-const', { expected: JSON.stringify(e.data.expected) }),
|
|
36
|
+
contains: (e) => e.code === 'contains-min-error'
|
|
37
|
+
? (0, i18n_1.default)('label-sr_error-contains-min')
|
|
38
|
+
: (0, i18n_1.default)('label-sr_error-contains'),
|
|
39
|
+
dependencies: (e) => {
|
|
40
|
+
let property = e.data.missingProperty;
|
|
41
|
+
const title = (0, get_1.default)(e, `data.schema.properties.${property}.title`);
|
|
42
|
+
if (typeof title === 'string') {
|
|
43
|
+
property = title;
|
|
44
|
+
}
|
|
45
|
+
return (0, i18n_1.default)('label-sr_error-dependencies', { property });
|
|
46
|
+
},
|
|
47
|
+
enum: (e) => (0, i18n_1.default)('label-sr_error-enum', { value: JSON.stringify(e.data.value) }),
|
|
48
|
+
exclusiveMaximum: (e) => (0, i18n_1.default)('label-sr_error-exclusive-maximum', { count: e.data.maximum }),
|
|
49
|
+
exclusiveMinimum: (e) => (0, i18n_1.default)('label-sr_error-exclusive-minimum', { count: e.data.minimum }),
|
|
50
|
+
maxItems: (e) => (0, i18n_1.default)('label-sr_error-max-items', { count: e.data.maximum }),
|
|
51
|
+
maxLength: (e) => (0, i18n_1.default)('label-sr_error-max-length', { count: e.data.maxLength }),
|
|
52
|
+
maxProperties: (e) => (0, i18n_1.default)('label-sr_error-max-properties', { count: e.data.maxProperties }),
|
|
53
|
+
maximum: (e) => (0, i18n_1.default)('label-sr_error-maximum', { count: e.data.maximum }),
|
|
54
|
+
minItems: (e) => (0, i18n_1.default)('label-sr_error-min-items', { count: e.data.minItems }),
|
|
55
|
+
minLength: (e) => (0, i18n_1.default)('label-sr_error-min-length', { count: e.data.minLength }),
|
|
56
|
+
minProperties: (e) => (0, i18n_1.default)('label-sr_error-min-properties', { count: e.data.minProperties }),
|
|
57
|
+
minimum: (e) => (0, i18n_1.default)('label-sr_error-minimum', { count: e.data.minimum }),
|
|
58
|
+
multipleOf: (e) => (0, i18n_1.default)('label-sr_error-multiple-of', { count: e.data.multipleOf }),
|
|
59
|
+
not: (0, i18n_1.default)('label-sr_error-not'),
|
|
60
|
+
oneOf: (0, i18n_1.default)('label-sr_error-one-of'),
|
|
61
|
+
pattern: (e) => (0, i18n_1.default)('label-sr_error-pattern', { pattern: e.data.pattern }),
|
|
62
|
+
propertyNames: (e) => (0, i18n_1.default)('label-sr_error-property-names', { property: e.data.property }),
|
|
63
|
+
required: (0, i18n_1.default)('label-sr_error-required'),
|
|
64
|
+
type: (e) => {
|
|
65
|
+
const types = e.data.expected.split(',');
|
|
66
|
+
let expected = '';
|
|
67
|
+
types.forEach((t, i, arr) => {
|
|
68
|
+
let type = t.trim();
|
|
69
|
+
if (TYPE_I18N_KEYS[type]) {
|
|
70
|
+
type = (0, i18n_1.default)(TYPE_I18N_KEYS[type]);
|
|
71
|
+
}
|
|
72
|
+
if (i === 0) {
|
|
73
|
+
expected += type;
|
|
74
|
+
}
|
|
75
|
+
else if (i === arr.length - 1) {
|
|
76
|
+
expected += (0, i18n_1.default)('label-sr_error-type-or', { type });
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
expected += `, ${type}`;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return (0, i18n_1.default)('label-sr_error-type', { expected });
|
|
83
|
+
},
|
|
84
|
+
uniqueItems: (0, i18n_1.default)('label-sr_error-unique-items'),
|
|
85
|
+
});
|
|
86
|
+
exports.errorMessages = getErrorMessages();
|
|
87
|
+
(0, configure_1.subscribeConfigure)(() => {
|
|
88
|
+
exports.errorMessages = getErrorMessages();
|
|
89
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.sr-alert .g-alert__text-content > div {
|
|
2
|
+
gap: 0 !important;
|
|
3
|
+
}
|
|
4
|
+
.sr-alert_expanded .g-alert__text-content > div {
|
|
5
|
+
gap: calc(var(--g-spacing-base) * 2) !important;
|
|
6
|
+
}
|
|
7
|
+
.sr-alert__title {
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
}
|
|
10
|
+
.sr-alert__message {
|
|
11
|
+
height: 0;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
.sr-alert__message_expanded {
|
|
15
|
+
height: unset;
|
|
16
|
+
}
|