tsondb 0.5.19 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/bin/tsondb.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/node/config.d.ts +20 -0
- package/dist/src/node/config.js +5 -0
- package/dist/src/node/index.d.ts +3 -2
- package/dist/src/node/index.js +13 -8
- package/dist/src/node/renderers/jsonschema/render.d.ts +1 -1
- package/dist/src/node/renderers/jsonschema/render.js +12 -7
- package/dist/src/node/renderers/ts/render.d.ts +1 -1
- package/dist/src/node/renderers/ts/render.js +12 -6
- package/dist/src/node/schema/Node.d.ts +100 -29
- package/dist/src/node/schema/Node.js +268 -61
- package/dist/src/node/schema/Schema.js +96 -1
- package/dist/src/node/schema/TypeParameter.d.ts +7 -9
- package/dist/src/node/schema/TypeParameter.js +7 -5
- package/dist/src/node/schema/declarations/Declaration.d.ts +10 -28
- package/dist/src/node/schema/declarations/Declaration.js +8 -110
- package/dist/src/node/schema/declarations/EntityDecl.d.ts +48 -48
- package/dist/src/node/schema/declarations/EntityDecl.js +15 -12
- package/dist/src/node/schema/declarations/EnumDecl.d.ts +14 -17
- package/dist/src/node/schema/declarations/EnumDecl.js +12 -12
- package/dist/src/node/schema/declarations/TypeAliasDecl.d.ts +8 -14
- package/dist/src/node/schema/declarations/TypeAliasDecl.js +10 -11
- package/dist/src/node/schema/index.d.ts +0 -2
- package/dist/src/node/schema/index.js +0 -1
- package/dist/src/node/schema/types/Type.d.ts +19 -42
- package/dist/src/node/schema/types/Type.js +29 -167
- package/dist/src/node/schema/types/generic/ArrayType.d.ts +5 -14
- package/dist/src/node/schema/types/generic/ArrayType.js +15 -20
- package/dist/src/node/schema/types/generic/EnumType.d.ts +5 -17
- package/dist/src/node/schema/types/generic/EnumType.js +12 -20
- package/dist/src/node/schema/types/generic/ObjectType.d.ts +5 -19
- package/dist/src/node/schema/types/generic/ObjectType.js +11 -15
- package/dist/src/node/schema/types/primitives/BooleanType.d.ts +7 -8
- package/dist/src/node/schema/types/primitives/BooleanType.js +5 -4
- package/dist/src/node/schema/types/primitives/DateType.d.ts +6 -8
- package/dist/src/node/schema/types/primitives/DateType.js +5 -4
- package/dist/src/node/schema/types/primitives/FloatType.d.ts +9 -21
- package/dist/src/node/schema/types/primitives/FloatType.js +5 -4
- package/dist/src/node/schema/types/primitives/IntegerType.d.ts +9 -21
- package/dist/src/node/schema/types/primitives/IntegerType.js +5 -4
- package/dist/src/node/schema/types/primitives/StringType.d.ts +6 -10
- package/dist/src/node/schema/types/primitives/StringType.js +5 -4
- package/dist/src/node/schema/types/references/ChildEntitiesType.d.ts +18 -0
- package/dist/src/node/schema/types/references/ChildEntitiesType.js +18 -0
- package/dist/src/node/schema/types/references/IncludeIdentifierType.d.ts +7 -13
- package/dist/src/node/schema/types/references/IncludeIdentifierType.js +12 -12
- package/dist/src/node/schema/types/references/NestedEntityMapType.d.ts +7 -17
- package/dist/src/node/schema/types/references/NestedEntityMapType.js +11 -13
- package/dist/src/node/schema/types/references/ReferenceIdentifierType.d.ts +4 -10
- package/dist/src/node/schema/types/references/ReferenceIdentifierType.js +3 -5
- package/dist/src/node/schema/types/references/TypeArgumentType.d.ts +5 -10
- package/dist/src/node/schema/types/references/TypeArgumentType.js +10 -5
- package/dist/src/node/server/api/declarations.js +24 -6
- package/dist/src/node/server/api/index.js +11 -0
- package/dist/src/node/server/api/instances.js +9 -6
- package/dist/src/node/server/index.d.ts +6 -1
- package/dist/src/node/server/index.js +7 -3
- package/dist/src/node/server/init.d.ts +2 -1
- package/dist/src/node/server/init.js +11 -11
- package/dist/src/node/server/utils/childInstances.d.ts +4 -0
- package/dist/src/node/server/utils/childInstances.js +41 -0
- package/dist/src/node/server/utils/instanceOperations.d.ts +8 -0
- package/dist/src/node/server/utils/instanceOperations.js +107 -0
- package/dist/src/node/server/utils/locales.d.ts +2 -0
- package/dist/src/node/server/utils/locales.js +8 -0
- package/dist/src/node/utils/childInstances.d.ts +32 -0
- package/dist/src/node/utils/childInstances.js +164 -0
- package/dist/src/node/utils/displayName.d.ts +2 -1
- package/dist/src/node/utils/displayName.js +5 -4
- package/dist/src/node/utils/files.d.ts +5 -0
- package/dist/src/node/utils/files.js +9 -0
- package/dist/src/node/utils/instanceOperations.d.ts +14 -0
- package/dist/src/node/utils/instanceOperations.js +88 -0
- package/dist/src/node/utils/instances.d.ts +1 -1
- package/dist/src/node/utils/instances.js +12 -6
- package/dist/src/node/utils/references.d.ts +3 -1
- package/dist/src/node/utils/references.js +43 -18
- package/dist/src/node/utils/referencesWorker.d.ts +5 -0
- package/dist/src/node/utils/referencesWorker.js +22 -0
- package/dist/src/node/utils/workers.d.ts +15 -0
- package/dist/src/node/utils/workers.js +90 -0
- package/dist/src/shared/api.d.ts +14 -1
- package/dist/src/shared/schema/Node.d.ts +63 -0
- package/dist/src/shared/schema/Node.js +128 -0
- package/dist/src/shared/schema/TypeParameter.d.ts +9 -0
- package/dist/src/shared/schema/TypeParameter.js +2 -0
- package/dist/src/shared/schema/declarations/Declaration.d.ts +21 -0
- package/dist/src/shared/schema/declarations/Declaration.js +4 -0
- package/dist/src/shared/schema/declarations/EntityDecl.d.ts +32 -0
- package/dist/src/shared/schema/declarations/EntityDecl.js +8 -0
- package/dist/src/shared/schema/declarations/EnumDecl.d.ts +11 -0
- package/dist/src/shared/schema/declarations/EnumDecl.js +9 -0
- package/dist/src/shared/schema/declarations/TypeAliasDecl.d.ts +11 -0
- package/dist/src/shared/schema/declarations/TypeAliasDecl.js +7 -0
- package/dist/src/shared/schema/types/ArrayType.d.ts +11 -0
- package/dist/src/shared/schema/types/ArrayType.js +8 -0
- package/dist/src/shared/schema/types/BooleanType.d.ts +7 -0
- package/dist/src/shared/schema/types/BooleanType.js +2 -0
- package/dist/src/shared/schema/types/ChildEntitiesType.d.ts +8 -0
- package/dist/src/shared/schema/types/ChildEntitiesType.js +2 -0
- package/dist/src/shared/schema/types/DateType.d.ts +8 -0
- package/dist/src/shared/schema/types/DateType.js +2 -0
- package/dist/src/shared/schema/types/EnumType.d.ts +14 -0
- package/dist/src/shared/schema/types/EnumType.js +28 -0
- package/dist/src/shared/schema/types/FloatType.d.ts +11 -0
- package/dist/src/shared/schema/types/FloatType.js +2 -0
- package/dist/src/shared/schema/types/IncludeIdentifierType.d.ts +11 -0
- package/dist/src/shared/schema/types/IncludeIdentifierType.js +13 -0
- package/dist/src/shared/schema/types/IntegerType.d.ts +11 -0
- package/dist/src/shared/schema/types/IntegerType.js +2 -0
- package/dist/src/shared/schema/types/NestedEntityMapType.d.ts +17 -0
- package/dist/src/shared/schema/types/NestedEntityMapType.js +14 -0
- package/dist/src/shared/schema/types/ObjectType.d.ts +19 -0
- package/dist/src/shared/schema/types/ObjectType.js +14 -0
- package/dist/src/shared/schema/types/ReferenceIdentifierType.d.ts +8 -0
- package/dist/src/shared/schema/types/ReferenceIdentifierType.js +2 -0
- package/dist/src/shared/schema/types/StringType.d.ts +10 -0
- package/dist/src/shared/schema/types/StringType.js +2 -0
- package/dist/src/shared/schema/types/Type.d.ts +20 -0
- package/dist/src/shared/schema/types/TypeArgumentType.d.ts +12 -0
- package/dist/src/shared/schema/types/TypeArgumentType.js +7 -0
- package/dist/src/shared/utils/array.d.ts +4 -0
- package/dist/src/shared/utils/array.js +30 -0
- package/dist/src/shared/utils/async.d.ts +8 -0
- package/dist/src/shared/utils/async.js +35 -0
- package/dist/src/shared/utils/compare.js +3 -3
- package/dist/src/shared/utils/displayName.d.ts +6 -2
- package/dist/src/shared/utils/displayName.js +21 -8
- package/dist/src/shared/utils/instances.d.ts +2 -3
- package/dist/src/shared/utils/instances.js +3 -1
- package/dist/src/shared/utils/markdown.d.ts +4 -0
- package/dist/src/shared/utils/markdown.js +91 -4
- package/dist/src/shared/utils/object.d.ts +2 -0
- package/dist/src/shared/utils/object.js +2 -0
- package/dist/src/shared/utils/result.d.ts +8 -2
- package/dist/src/shared/utils/result.js +1 -1
- package/dist/src/web/api/declarations.d.ts +26 -0
- package/dist/src/web/api/declarations.js +51 -0
- package/dist/src/web/api/git.d.ts +14 -0
- package/dist/src/web/api/git.js +20 -0
- package/dist/src/web/api/index.d.ts +1 -0
- package/dist/src/web/api/index.js +2 -0
- package/dist/src/web/api/instances.d.ts +2 -0
- package/dist/src/web/api/instances.js +2 -0
- package/dist/src/web/components/Git.js +19 -16
- package/dist/src/web/components/InstanceRouteSkeleton.d.ts +42 -0
- package/dist/src/web/components/InstanceRouteSkeleton.js +114 -0
- package/dist/src/web/components/Layout.js +3 -2
- package/dist/src/web/components/ModalDialog.d.ts +2 -0
- package/dist/src/web/components/ModalDialog.js +16 -0
- package/dist/src/web/components/Select.d.ts +1 -2
- package/dist/src/web/components/Settings.d.ts +2 -0
- package/dist/src/web/components/Settings.js +47 -0
- package/dist/src/web/components/typeInputs/ArrayTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/ArrayTypeInput.js +5 -4
- package/dist/src/web/components/typeInputs/BooleanTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/BooleanTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.d.ts +6 -0
- package/dist/src/web/components/typeInputs/ChildEntitiesTypeInput.js +27 -0
- package/dist/src/web/components/typeInputs/DateTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/DateTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/EnumTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/EnumTypeInput.js +55 -22
- package/dist/src/web/components/typeInputs/FloatTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/FloatTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/GenericTypeArgumentIdentifierTypeInput.d.ts +3 -4
- package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/IncludeIdentifierTypeInput.js +3 -2
- package/dist/src/web/components/typeInputs/IntegerTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/IntegerTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/NestedEntityMapTypeInput.js +5 -4
- package/dist/src/web/components/typeInputs/ObjectTypeInput.d.ts +3 -11
- package/dist/src/web/components/typeInputs/ObjectTypeInput.js +8 -5
- package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.d.ts +3 -8
- package/dist/src/web/components/typeInputs/ReferenceIdentifierTypeInput.js +2 -2
- package/dist/src/web/components/typeInputs/StringTypeInput.d.ts +3 -6
- package/dist/src/web/components/typeInputs/StringTypeInput.js +3 -3
- package/dist/src/web/components/typeInputs/TypeInput.d.ts +12 -4
- package/dist/src/web/components/typeInputs/TypeInput.js +22 -17
- package/dist/src/web/components/typeInputs/utils/ValidationErrors.d.ts +1 -0
- package/dist/src/web/components/typeInputs/utils/ValidationErrors.js +1 -3
- package/dist/src/web/context/config.d.ts +11 -0
- package/dist/src/web/context/config.js +6 -0
- package/dist/src/web/context/entities.d.ts +8 -5
- package/dist/src/web/context/entities.js +1 -1
- package/dist/src/web/context/settings.d.ts +8 -0
- package/dist/src/web/context/settings.js +10 -0
- package/dist/src/web/hooks/useEntityFromRoute.d.ts +1 -1
- package/dist/src/web/hooks/useEntityFromRoute.js +2 -2
- package/dist/src/web/hooks/useInstanceNamesByEntity.d.ts +1 -1
- package/dist/src/web/hooks/useInstanceNamesByEntity.js +4 -2
- package/dist/src/web/hooks/useMappedAPIResource.js +2 -4
- package/dist/src/web/hooks/useSecondaryDeclarations.d.ts +1 -1
- package/dist/src/web/hooks/useSecondaryDeclarations.js +8 -4
- package/dist/src/web/hooks/useSettings.d.ts +10 -0
- package/dist/src/web/hooks/useSettings.js +51 -0
- package/dist/src/web/index.js +11 -5
- package/dist/src/web/routes/CreateInstance.js +40 -79
- package/dist/src/web/routes/Entity.js +42 -19
- package/dist/src/web/routes/Home.js +24 -5
- package/dist/src/web/routes/Instance.js +34 -85
- package/dist/src/web/utils/InlineMarkdown.d.ts +1 -1
- package/dist/src/web/utils/InlineMarkdown.js +13 -1
- package/dist/src/web/utils/api.d.ts +25 -0
- package/dist/src/web/utils/api.js +34 -0
- package/dist/src/web/utils/typeSkeleton.d.ts +1 -1
- package/dist/src/web/utils/typeSkeleton.js +2 -0
- package/package.json +14 -13
- package/public/css/styles.css +171 -12
- package/dist/src/node/schema/types/primitives/NumericType.d.ts +0 -6
- package/dist/src/node/schema/types/primitives/NumericType.js +0 -2
- package/dist/src/node/schema/types/primitives/PrimitiveType.d.ts +0 -6
- package/dist/src/node/schema/validation/type.d.ts +0 -4
- package/dist/src/node/schema/validation/type.js +0 -1
- package/dist/src/node/server/api/instanceOperations.d.ts +0 -6
- package/dist/src/node/server/api/instanceOperations.js +0 -93
- package/dist/src/shared/config.d.ts +0 -11
- package/dist/src/shared/config.js +0 -1
- package/dist/src/web/api.d.ts +0 -24
- package/dist/src/web/api.js +0 -201
- /package/dist/src/{node/schema/types/primitives/PrimitiveType.js → shared/schema/types/Type.js} +0 -0
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
2
|
import { discriminatorKey } from "../../../shared/enum.js";
|
|
3
3
|
import { toTitleCase } from "../../../shared/utils/string.js";
|
|
4
|
+
import { assertExhaustive } from "../../../shared/utils/typeSafety.js";
|
|
5
|
+
import { useSetting } from "../../hooks/useSettings.js";
|
|
6
|
+
import { Markdown } from "../../utils/Markdown.js";
|
|
4
7
|
import { createTypeSkeleton } from "../../utils/typeSkeleton.js";
|
|
5
8
|
import { Select } from "../Select.js";
|
|
6
9
|
import { TypeInput } from "./TypeInput.js";
|
|
7
10
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
8
|
-
export const EnumTypeInput =
|
|
11
|
+
export const EnumTypeInput = props => {
|
|
12
|
+
const { type, path, value, disabled, getDeclFromDeclName, onChange } = props;
|
|
13
|
+
const [enumDisplay] = useSetting("enumDisplay");
|
|
9
14
|
if (typeof value !== "object" ||
|
|
10
15
|
value === null ||
|
|
11
16
|
Array.isArray(value) ||
|
|
@@ -13,26 +18,54 @@ export const EnumTypeInput = ({ type, path, value, instanceNamesByEntity, getDec
|
|
|
13
18
|
typeof value[discriminatorKey] !== "string") {
|
|
14
19
|
return _jsx(MismatchingTypeError, { expected: "enumeration value", actual: value });
|
|
15
20
|
}
|
|
16
|
-
const enumValues = Object.
|
|
21
|
+
const enumValues = Object.entries(type.values);
|
|
17
22
|
const activeEnumCase = value[discriminatorKey];
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
const activeCaseMember = type.values[activeEnumCase];
|
|
24
|
+
switch (enumDisplay) {
|
|
25
|
+
case "select":
|
|
26
|
+
return (_jsxs("div", { class: "field field--enum", children: [_jsx(Select, { value: activeEnumCase, onInput: event => {
|
|
27
|
+
const caseMember = type.values[event.currentTarget.value];
|
|
28
|
+
if (caseMember?.type == null) {
|
|
29
|
+
onChange({
|
|
30
|
+
[discriminatorKey]: event.currentTarget.value,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
onChange({
|
|
35
|
+
[discriminatorKey]: event.currentTarget.value,
|
|
36
|
+
[event.currentTarget.value]: createTypeSkeleton(getDeclFromDeclName, caseMember.type),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, disabled: disabled, children: enumValues.map(([enumValue]) => (_jsx("option", { value: enumValue, selected: enumValue === activeEnumCase, children: toTitleCase(enumValue) }, enumValue))) }), activeCaseMember?.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: activeCaseMember.comment })), activeCaseMember?.type == null ? null : (_jsx("div", { className: "associated-type", children: _jsx(TypeInput, { ...props, parentKey: undefined, type: activeCaseMember.type, path: path === undefined ? `{${activeEnumCase}}` : `${path}.{${activeEnumCase}}`, value: value[activeEnumCase], onChange: newValue => {
|
|
40
|
+
onChange({
|
|
41
|
+
[discriminatorKey]: activeEnumCase,
|
|
42
|
+
[activeEnumCase]: newValue,
|
|
43
|
+
});
|
|
44
|
+
} }) }))] }));
|
|
45
|
+
case "radio":
|
|
46
|
+
return (_jsx("div", { class: "field field--enum", children: enumValues.map(([enumValue, caseMember]) => (_jsxs("div", { class: "field--option", children: [_jsx("input", { type: "radio", name: path, value: enumValue, id: path === undefined ? enumValue : `${path}-${enumValue}`, checked: enumValue === activeEnumCase, onInput: () => {
|
|
47
|
+
if (caseMember.type == null) {
|
|
48
|
+
onChange({
|
|
49
|
+
[discriminatorKey]: enumValue,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
onChange({
|
|
54
|
+
[discriminatorKey]: enumValue,
|
|
55
|
+
[enumValue]: createTypeSkeleton(getDeclFromDeclName, caseMember.type),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}, disabled: disabled }), _jsxs("div", { children: [_jsx("label", { htmlFor: path === undefined ? enumValue : `${path}-${enumValue}`, children: toTitleCase(enumValue) }), caseMember.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: caseMember.comment })), caseMember.type == null ? null : (_jsx("div", { className: "associated-type", children: _jsx(TypeInput, { ...props, parentKey: undefined, type: caseMember.type, path: path === undefined ? `{${activeEnumCase}}` : `${path}.{${activeEnumCase}}`, value: enumValue === activeEnumCase
|
|
59
|
+
? value[activeEnumCase]
|
|
60
|
+
: createTypeSkeleton(getDeclFromDeclName, caseMember.type), disabled: disabled || enumValue !== activeEnumCase, onChange: disabled
|
|
61
|
+
? () => { }
|
|
62
|
+
: newValue => {
|
|
63
|
+
onChange({
|
|
64
|
+
[discriminatorKey]: activeEnumCase,
|
|
65
|
+
[activeEnumCase]: newValue,
|
|
66
|
+
});
|
|
67
|
+
} }) }))] })] }, enumValue))) }));
|
|
68
|
+
default:
|
|
69
|
+
return assertExhaustive(enumDisplay);
|
|
70
|
+
}
|
|
38
71
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedFloatType } from "../../../
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
value: unknown;
|
|
6
|
-
onChange: (value: number) => void;
|
|
7
|
-
};
|
|
2
|
+
import type { SerializedFloatType } from "../../../shared/schema/types/FloatType.ts";
|
|
3
|
+
import type { TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedFloatType, number>;
|
|
8
5
|
export declare const FloatTypeInput: FunctionComponent<Props>;
|
|
9
6
|
export {};
|
|
@@ -3,7 +3,7 @@ import { useState } from "preact/hooks";
|
|
|
3
3
|
import { validateNumberConstraints } from "../../../shared/validation/number.js";
|
|
4
4
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
5
5
|
import { ValidationErrors } from "./utils/ValidationErrors.js";
|
|
6
|
-
export const FloatTypeInput = ({ type, value, onChange }) => {
|
|
6
|
+
export const FloatTypeInput = ({ type, value, disabled, onChange }) => {
|
|
7
7
|
const [stringValue, setStringValue] = useState(typeof value === "number" ? value.toString() : "");
|
|
8
8
|
if (typeof value !== "number") {
|
|
9
9
|
return _jsx(MismatchingTypeError, { expected: "float", actual: value });
|
|
@@ -15,5 +15,5 @@ export const FloatTypeInput = ({ type, value, onChange }) => {
|
|
|
15
15
|
if (!Number.isNaN(numericValue)) {
|
|
16
16
|
onChange(numericValue);
|
|
17
17
|
}
|
|
18
|
-
}, step: 0.01, "aria-invalid": errors.length > 0 }), _jsx(ValidationErrors, { errors: errors })] }));
|
|
18
|
+
}, step: 0.01, "aria-invalid": errors.length > 0, disabled: disabled }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }));
|
|
19
19
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedTypeArgumentType } from "../../../
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
};
|
|
2
|
+
import type { SerializedTypeArgumentType } from "../../../shared/schema/types/TypeArgumentType.ts";
|
|
3
|
+
import type { TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedTypeArgumentType>;
|
|
6
5
|
export declare const TypeArgumentTypeInput: FunctionComponent<Props>;
|
|
7
6
|
export {};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedIncludeIdentifierType } from "../../../
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
type: SerializedIncludeIdentifierType;
|
|
7
|
-
path: string | undefined;
|
|
8
|
-
value: unknown;
|
|
9
|
-
instanceNamesByEntity: InstanceNamesByEntity;
|
|
10
|
-
getDeclFromDeclName: GetDeclFromDeclName;
|
|
11
|
-
onChange: (value: unknown) => void;
|
|
12
|
-
};
|
|
2
|
+
import type { SerializedIncludeIdentifierType } from "../../../shared/schema/types/IncludeIdentifierType.ts";
|
|
3
|
+
import { type TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedIncludeIdentifierType>;
|
|
13
5
|
export declare const IncludeIdentifierTypeInput: FunctionComponent<Props>;
|
|
14
6
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
2
|
import { TypeInput } from "./TypeInput.js";
|
|
3
|
-
export const IncludeIdentifierTypeInput =
|
|
3
|
+
export const IncludeIdentifierTypeInput = props => {
|
|
4
|
+
const { type, getDeclFromDeclName } = props;
|
|
4
5
|
const decl = getDeclFromDeclName(type.reference);
|
|
5
6
|
if (decl === undefined) {
|
|
6
7
|
return (_jsxs("div", { role: "alert", children: ["Unresolved declaration identifier ", _jsx("code", { children: type.reference })] }));
|
|
7
8
|
}
|
|
8
|
-
return
|
|
9
|
+
return _jsx(TypeInput, { ...props, parentKey: undefined, type: decl.type });
|
|
9
10
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedIntegerType } from "../../../
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
value: unknown;
|
|
6
|
-
onChange: (value: number) => void;
|
|
7
|
-
};
|
|
2
|
+
import type { SerializedIntegerType } from "../../../shared/schema/types/IntegerType.ts";
|
|
3
|
+
import type { TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedIntegerType, number>;
|
|
8
5
|
export declare const IntegerTypeInput: FunctionComponent<Props>;
|
|
9
6
|
export {};
|
|
@@ -3,7 +3,7 @@ import { useState } from "preact/hooks";
|
|
|
3
3
|
import { validateNumberConstraints } from "../../../shared/validation/number.js";
|
|
4
4
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
5
5
|
import { ValidationErrors } from "./utils/ValidationErrors.js";
|
|
6
|
-
export const IntegerTypeInput = ({ type, value, onChange }) => {
|
|
6
|
+
export const IntegerTypeInput = ({ type, value, disabled, onChange }) => {
|
|
7
7
|
const [stringValue, setStringValue] = useState(typeof value === "number" ? value.toString() : "");
|
|
8
8
|
if (typeof value !== "number") {
|
|
9
9
|
return _jsx(MismatchingTypeError, { expected: "float", actual: value });
|
|
@@ -15,5 +15,5 @@ export const IntegerTypeInput = ({ type, value, onChange }) => {
|
|
|
15
15
|
if (!Number.isNaN(numericValue)) {
|
|
16
16
|
onChange(numericValue);
|
|
17
17
|
}
|
|
18
|
-
}, step: 0.01, "aria-invalid": errors.length > 0 }), _jsx(ValidationErrors, { errors: errors })] }));
|
|
18
|
+
}, step: 0.01, "aria-invalid": errors.length > 0, disabled: disabled }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }));
|
|
19
19
|
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedNestedEntityMapType } from "../../../
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
type: SerializedNestedEntityMapType;
|
|
7
|
-
path: string | undefined;
|
|
8
|
-
value: unknown;
|
|
9
|
-
instanceNamesByEntity: InstanceNamesByEntity;
|
|
10
|
-
getDeclFromDeclName: GetDeclFromDeclName;
|
|
11
|
-
onChange: (value: Record<string, unknown>) => void;
|
|
12
|
-
};
|
|
2
|
+
import type { SerializedNestedEntityMapType } from "../../../shared/schema/types/NestedEntityMapType.ts";
|
|
3
|
+
import { type TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedNestedEntityMapType, Record<string, unknown>>;
|
|
13
5
|
export declare const NestedEntityMapTypeInput: FunctionComponent<Props>;
|
|
14
6
|
export {};
|
|
@@ -6,7 +6,8 @@ import { createTypeSkeleton } from "../../utils/typeSkeleton.js";
|
|
|
6
6
|
import { Select } from "../Select.js";
|
|
7
7
|
import { TypeInput } from "./TypeInput.js";
|
|
8
8
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
9
|
-
export const NestedEntityMapTypeInput =
|
|
9
|
+
export const NestedEntityMapTypeInput = props => {
|
|
10
|
+
const { type, path, value, instanceNamesByEntity, disabled, getDeclFromDeclName, onChange } = props;
|
|
10
11
|
const [newKey, setNewKey] = useState("");
|
|
11
12
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
12
13
|
return _jsx(MismatchingTypeError, { expected: "object", actual: value });
|
|
@@ -24,16 +25,16 @@ export const NestedEntityMapTypeInput = ({ type, path, value, instanceNamesByEnt
|
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
25
26
|
delete newObj[key];
|
|
26
27
|
onChange(newObj);
|
|
27
|
-
}, children: ["Delete ", name] }) })] }), _jsx(TypeInput, { type: type.type, path: path === undefined ? key : `${path}.${key}`, value: item,
|
|
28
|
+
}, disabled: disabled, children: ["Delete ", name] }) })] }), _jsx(TypeInput, { ...props, parentKey: undefined, type: type.type, path: path === undefined ? key : `${path}.${key}`, value: item, onChange: newItem => {
|
|
28
29
|
onChange(sortObjectKeysAlphabetically({ ...value, [key]: newItem }));
|
|
29
30
|
} })] }, key));
|
|
30
31
|
}) })), _jsxs("div", { class: "add-item-container", children: [_jsxs(Select, { value: newKey, onInput: event => {
|
|
31
32
|
setNewKey(event.currentTarget.value);
|
|
32
|
-
}, disabled: secondaryInstances.length === 0, children: [secondaryInstances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), secondaryInstances.map(instance => (_jsx("option", { value: instance.id, children: instance.name }, instance.id)))] }), _jsxs("button", { onClick: () => {
|
|
33
|
+
}, disabled: disabled || secondaryInstances.length === 0, children: [secondaryInstances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), secondaryInstances.map(instance => (_jsx("option", { value: instance.id, children: instance.name }, instance.id)))] }), _jsxs("button", { onClick: () => {
|
|
33
34
|
onChange(sortObjectKeysAlphabetically({
|
|
34
35
|
...value,
|
|
35
36
|
[newKey]: createTypeSkeleton(getDeclFromDeclName, type.type),
|
|
36
37
|
}));
|
|
37
38
|
setNewKey("");
|
|
38
|
-
}, disabled: newKey === "", children: ["Add ", newKey === "" ? "Key" : toTitleCase(newKey)] })] })] }));
|
|
39
|
+
}, disabled: disabled || newKey === "", children: ["Add ", newKey === "" ? "Key" : toTitleCase(newKey)] })] })] }));
|
|
39
40
|
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedObjectType } from "../../../
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
type: SerializedObjectType;
|
|
7
|
-
path: string | undefined;
|
|
8
|
-
value: unknown;
|
|
9
|
-
instanceNamesByEntity: InstanceNamesByEntity;
|
|
10
|
-
getDeclFromDeclName: GetDeclFromDeclName;
|
|
11
|
-
onChange: (value: Record<string, unknown>) => void;
|
|
12
|
-
};
|
|
2
|
+
import type { SerializedObjectType } from "../../../shared/schema/types/ObjectType.ts";
|
|
3
|
+
import { type TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedObjectType, Record<string, unknown>>;
|
|
13
5
|
export declare const ObjectTypeInput: FunctionComponent<Props>;
|
|
14
6
|
export {};
|
|
@@ -7,23 +7,26 @@ import { createTypeSkeleton } from "../../utils/typeSkeleton.js";
|
|
|
7
7
|
import { TypeInput } from "./TypeInput.js";
|
|
8
8
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
9
9
|
import { ValidationErrors } from "./utils/ValidationErrors.js";
|
|
10
|
-
export const ObjectTypeInput =
|
|
10
|
+
export const ObjectTypeInput = props => {
|
|
11
|
+
const { type, path, value, parentKey, disabled, getDeclFromDeclName, onChange } = props;
|
|
11
12
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
12
13
|
return _jsx(MismatchingTypeError, { expected: "object", actual: value });
|
|
13
14
|
}
|
|
14
15
|
const errors = validateObjectConstraints(type, Object.keys(type.properties), value);
|
|
15
|
-
return (_jsxs("div", { class: "field field--container field--object"
|
|
16
|
+
return (_jsxs("div", { class: "field field--container field--object" + (disabled ? " field--disabled" : ""), children: [_jsx("ul", { children: Object.entries(type.properties)
|
|
17
|
+
.filter(([key]) => key !== parentKey)
|
|
18
|
+
.map(([key, memberDecl]) => (_jsxs("li", { class: "container-item object-item", children: [_jsxs("div", { className: "container-item-header", children: [_jsxs("div", { className: "container-item-title", children: [_jsx("strong", { children: toTitleCase(key) }), memberDecl.comment === undefined ? null : (_jsx(Markdown, { class: "comment", string: memberDecl.comment }))] }), memberDecl.isRequired ? null : value[key] ===
|
|
16
19
|
undefined ? (_jsxs("button", { onClick: () => {
|
|
17
20
|
onChange(sortObjectKeys({
|
|
18
21
|
...value,
|
|
19
22
|
[key]: createTypeSkeleton(getDeclFromDeclName, memberDecl.type),
|
|
20
23
|
}, Object.keys(type.properties)));
|
|
21
|
-
}, children: ["Add ", toTitleCase(key)] })) : (_jsxs("button", { class: "destructive", onClick: () => {
|
|
24
|
+
}, disabled: disabled, children: ["Add ", toTitleCase(key)] })) : (_jsxs("button", { class: "destructive", onClick: () => {
|
|
22
25
|
const newObj = { ...value };
|
|
23
26
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
24
27
|
delete newObj[key];
|
|
25
28
|
onChange(newObj);
|
|
26
|
-
}, children: ["Remove ", toTitleCase(key)] }))] }), memberDecl.isRequired || value[key] !== undefined ? (_jsx(TypeInput, { type: memberDecl.type, path: path === undefined ? key : `${path}.${key}`, value: value[key],
|
|
29
|
+
}, disabled: disabled, children: ["Remove ", toTitleCase(key)] }))] }), memberDecl.isRequired || value[key] !== undefined ? (_jsx(TypeInput, { ...props, parentKey: undefined, type: memberDecl.type, path: path === undefined ? key : `${path}.${key}`, value: value[key], onChange: newItem => {
|
|
27
30
|
onChange(sortObjectKeys({ ...value, [key]: newItem }, Object.keys(type.properties)));
|
|
28
|
-
} })) : null] }, key))) }), _jsx(ValidationErrors, { errors: errors })] }));
|
|
31
|
+
} })) : null] }, key))) }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }));
|
|
29
32
|
};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedReferenceIdentifierType } from "../../../
|
|
3
|
-
import type {
|
|
4
|
-
type Props =
|
|
5
|
-
type: SerializedReferenceIdentifierType;
|
|
6
|
-
value: unknown;
|
|
7
|
-
instanceNamesByEntity: InstanceNamesByEntity;
|
|
8
|
-
onChange: (value: string) => void;
|
|
9
|
-
};
|
|
2
|
+
import type { SerializedReferenceIdentifierType } from "../../../shared/schema/types/ReferenceIdentifierType.ts";
|
|
3
|
+
import type { TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedReferenceIdentifierType, string>;
|
|
10
5
|
export declare const ReferenceIdentifierTypeInput: FunctionComponent<Props>;
|
|
11
6
|
export {};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
|
2
2
|
import { Select } from "../Select.js";
|
|
3
3
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
4
4
|
import { ValidationErrors } from "./utils/ValidationErrors.js";
|
|
5
|
-
export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntity, onChange, }) => {
|
|
5
|
+
export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntity, disabled, onChange, }) => {
|
|
6
6
|
if (typeof value !== "string") {
|
|
7
7
|
return _jsx(MismatchingTypeError, { expected: "string identifier", actual: value });
|
|
8
8
|
}
|
|
@@ -11,5 +11,5 @@ export const ReferenceIdentifierTypeInput = ({ type, value, instanceNamesByEntit
|
|
|
11
11
|
.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
|
|
12
12
|
return (_jsxs("div", { class: "field", children: [_jsxs(Select, { value: value, onInput: event => {
|
|
13
13
|
onChange(event.currentTarget.value);
|
|
14
|
-
}, disabled: instances.length === 0, "aria-invalid": !value, children: [instances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), instances.map(instance => (_jsx("option", { value: instance.id, children: instance.name }, instance.id)))] }), _jsx(ValidationErrors, { errors: !value ? [ReferenceError("no reference provided")] : [] })] }));
|
|
14
|
+
}, disabled: disabled || instances.length === 0, "aria-invalid": !value, children: [instances.length === 0 ? (_jsx("option", { value: "", disabled: true, children: "No instances available" })) : (_jsx("option", { value: "", disabled: true, children: "No selected instance" })), instances.map(instance => (_jsx("option", { value: instance.id, children: instance.name }, instance.id)))] }), _jsx(ValidationErrors, { disabled: disabled, errors: !value ? [ReferenceError("no reference provided")] : [] })] }));
|
|
15
15
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type { SerializedStringType } from "../../../
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
value: unknown;
|
|
6
|
-
onChange: (value: string) => void;
|
|
7
|
-
};
|
|
2
|
+
import type { SerializedStringType } from "../../../shared/schema/types/StringType.ts";
|
|
3
|
+
import type { TypeInputProps } from "./TypeInput.tsx";
|
|
4
|
+
type Props = TypeInputProps<SerializedStringType, string>;
|
|
8
5
|
export declare const StringTypeInput: FunctionComponent<Props>;
|
|
9
6
|
export {};
|
|
@@ -4,7 +4,7 @@ import { Markdown } from "../../utils/Markdown.js";
|
|
|
4
4
|
import { MarkdownHighlighting } from "../../utils/MarkdownHighlighting.js";
|
|
5
5
|
import { MismatchingTypeError } from "./utils/MismatchingTypeError.js";
|
|
6
6
|
import { ValidationErrors } from "./utils/ValidationErrors.js";
|
|
7
|
-
export const StringTypeInput = ({ type, value, onChange }) => {
|
|
7
|
+
export const StringTypeInput = ({ type, value, disabled, onChange }) => {
|
|
8
8
|
if (typeof value !== "string") {
|
|
9
9
|
return _jsx(MismatchingTypeError, { expected: "string", actual: value });
|
|
10
10
|
}
|
|
@@ -12,11 +12,11 @@ export const StringTypeInput = ({ type, value, onChange }) => {
|
|
|
12
12
|
const errors = validateStringConstraints(type, value);
|
|
13
13
|
return (_jsx("div", { class: "field field--string", children: isMarkdown ? (_jsxs(_Fragment, { children: [_jsxs("div", { class: "editor editor--markdown", children: [_jsxs("div", { class: "textarea-grow-wrap", children: [_jsx("textarea", { value: value, minLength: minLength, maxLength: maxLength, onInput: event => {
|
|
14
14
|
onChange(event.currentTarget.value);
|
|
15
|
-
}, "aria-invalid": errors.length > 0 }), _jsxs("p", { class: "help", children: ["This textarea supports", " ", _jsx("a", { href: "https://www.markdownguide.org/getting-started/", target: "_blank", rel: "noreferrer", children: "Markdown" }), "."] }), _jsx(MarkdownHighlighting, { class: "textarea-grow-wrap__mirror editor-highlighting", string: value })] }), _jsx(ValidationErrors, { errors: errors })] }), _jsx("div", { class: "preview", children: _jsx(Markdown, { string: value }) })] })) : (_jsxs("div", { class: "editor", children: [_jsx("input", { type: "text", value: value, minLength: minLength, maxLength: maxLength, pattern: pattern === undefined
|
|
15
|
+
}, "aria-invalid": errors.length > 0, disabled: disabled }), _jsxs("p", { class: "help", children: ["This textarea supports", " ", _jsx("a", { href: "https://www.markdownguide.org/getting-started/", target: "_blank", rel: "noreferrer", children: "Markdown" }), "."] }), _jsx(MarkdownHighlighting, { class: "textarea-grow-wrap__mirror editor-highlighting", string: value })] }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] }), _jsx("div", { class: "preview", children: _jsx(Markdown, { string: value }) })] })) : (_jsxs("div", { class: "editor", children: [_jsx("input", { type: "text", value: value, minLength: minLength, maxLength: maxLength, pattern: pattern === undefined
|
|
16
16
|
? undefined
|
|
17
17
|
: pattern.startsWith("^(?:") && pattern.endsWith(")$")
|
|
18
18
|
? pattern.slice(4, -2)
|
|
19
19
|
: `.*${pattern}.*`, onInput: event => {
|
|
20
20
|
onChange(event.currentTarget.value);
|
|
21
|
-
}, "aria-invalid": errors.length > 0 }), _jsx(ValidationErrors, { errors: errors })] })) }));
|
|
21
|
+
}, "aria-invalid": errors.length > 0, disabled: disabled }), _jsx(ValidationErrors, { disabled: disabled, errors: errors })] })) }));
|
|
22
22
|
};
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import type { FunctionComponent } from "preact";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnsafeEntityTaggedInstanceContainerWithChildInstances } from "../../../node/utils/childInstances.ts";
|
|
3
|
+
import type { SerializedType } from "../../../shared/schema/types/Type.ts";
|
|
3
4
|
import type { InstanceNamesByEntity } from "../../hooks/useInstanceNamesByEntity.ts";
|
|
4
5
|
import type { GetDeclFromDeclName } from "../../hooks/useSecondaryDeclarations.ts";
|
|
5
|
-
type
|
|
6
|
-
type:
|
|
6
|
+
export type TypeInputProps<T, V = unknown> = {
|
|
7
|
+
type: T;
|
|
7
8
|
path: string | undefined;
|
|
8
9
|
value: unknown;
|
|
9
10
|
instanceNamesByEntity: InstanceNamesByEntity;
|
|
11
|
+
parentKey?: string;
|
|
12
|
+
childInstances: UnsafeEntityTaggedInstanceContainerWithChildInstances[];
|
|
13
|
+
disabled?: boolean;
|
|
10
14
|
getDeclFromDeclName: GetDeclFromDeclName;
|
|
11
|
-
onChange: (value:
|
|
15
|
+
onChange: (value: V) => void;
|
|
16
|
+
onChildChange: (index: number, value: unknown) => void;
|
|
17
|
+
onChildAdd: (entityName: string, value: unknown) => void;
|
|
18
|
+
onChildRemove: (index: number) => void;
|
|
12
19
|
};
|
|
20
|
+
type Props = TypeInputProps<SerializedType>;
|
|
13
21
|
declare const MemoizedTypeInput: FunctionComponent<Props>;
|
|
14
22
|
export { MemoizedTypeInput as TypeInput };
|
|
@@ -3,6 +3,7 @@ import { memo } from "preact/compat";
|
|
|
3
3
|
import { assertExhaustive } from "../../../shared/utils/typeSafety.js";
|
|
4
4
|
import { ArrayTypeInput } from "./ArrayTypeInput.js";
|
|
5
5
|
import { BooleanTypeInput } from "./BooleanTypeInput.js";
|
|
6
|
+
import { ChildEntitiesTypeInput } from "./ChildEntitiesTypeInput.js";
|
|
6
7
|
import { DateTypeInput } from "./DateTypeInput.js";
|
|
7
8
|
import { EnumTypeInput } from "./EnumTypeInput.js";
|
|
8
9
|
import { FloatTypeInput } from "./FloatTypeInput.js";
|
|
@@ -13,36 +14,40 @@ import { NestedEntityMapTypeInput } from "./NestedEntityMapTypeInput.js";
|
|
|
13
14
|
import { ObjectTypeInput } from "./ObjectTypeInput.js";
|
|
14
15
|
import { ReferenceIdentifierTypeInput } from "./ReferenceIdentifierTypeInput.js";
|
|
15
16
|
import { StringTypeInput } from "./StringTypeInput.js";
|
|
16
|
-
const TypeInput =
|
|
17
|
-
// console.log("rendering node at path ", path ?? "<root>")
|
|
18
|
-
switch (type.kind) {
|
|
17
|
+
const TypeInput = props => {
|
|
18
|
+
// console.log("rendering node at path ", props.path ?? "<root>")
|
|
19
|
+
switch (props.type.kind) {
|
|
19
20
|
case "BooleanType":
|
|
20
|
-
return _jsx(BooleanTypeInput, { type: type
|
|
21
|
+
return _jsx(BooleanTypeInput, { ...props, type: props.type });
|
|
21
22
|
case "DateType":
|
|
22
|
-
return _jsx(DateTypeInput, { type: type
|
|
23
|
+
return _jsx(DateTypeInput, { ...props, type: props.type });
|
|
23
24
|
case "FloatType":
|
|
24
|
-
return _jsx(FloatTypeInput, { type: type
|
|
25
|
+
return _jsx(FloatTypeInput, { ...props, type: props.type });
|
|
25
26
|
case "IntegerType":
|
|
26
|
-
return _jsx(IntegerTypeInput, { type: type
|
|
27
|
+
return _jsx(IntegerTypeInput, { ...props, type: props.type });
|
|
27
28
|
case "StringType":
|
|
28
|
-
return _jsx(StringTypeInput, { type: type
|
|
29
|
+
return _jsx(StringTypeInput, { ...props, type: props.type });
|
|
29
30
|
case "ArrayType":
|
|
30
|
-
return
|
|
31
|
+
return _jsx(ArrayTypeInput, { ...props, type: props.type });
|
|
31
32
|
case "ObjectType":
|
|
32
|
-
return
|
|
33
|
+
return _jsx(ObjectTypeInput, { ...props, type: props.type });
|
|
33
34
|
case "TypeArgumentType":
|
|
34
|
-
return _jsx(TypeArgumentTypeInput, { type: type });
|
|
35
|
+
return _jsx(TypeArgumentTypeInput, { ...props, type: props.type });
|
|
35
36
|
case "ReferenceIdentifierType":
|
|
36
|
-
return
|
|
37
|
+
return _jsx(ReferenceIdentifierTypeInput, { ...props, type: props.type });
|
|
37
38
|
case "IncludeIdentifierType":
|
|
38
|
-
return
|
|
39
|
+
return _jsx(IncludeIdentifierTypeInput, { ...props, type: props.type });
|
|
39
40
|
case "NestedEntityMapType":
|
|
40
|
-
return
|
|
41
|
+
return _jsx(NestedEntityMapTypeInput, { ...props, type: props.type });
|
|
41
42
|
case "EnumType":
|
|
42
|
-
return
|
|
43
|
+
return _jsx(EnumTypeInput, { ...props, type: props.type });
|
|
44
|
+
case "ChildEntitiesType":
|
|
45
|
+
return _jsx(ChildEntitiesTypeInput, { ...props, type: props.type });
|
|
43
46
|
default:
|
|
44
|
-
return assertExhaustive(type);
|
|
47
|
+
return assertExhaustive(props.type);
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
|
-
const MemoizedTypeInput = memo(TypeInput, (prevProps, nextProps) => prevProps.value === nextProps.value &&
|
|
50
|
+
const MemoizedTypeInput = memo(TypeInput, (prevProps, nextProps) => prevProps.value === nextProps.value &&
|
|
51
|
+
prevProps.onChange === nextProps.onChange &&
|
|
52
|
+
prevProps.childInstances === nextProps.childInstances);
|
|
48
53
|
export { MemoizedTypeInput as TypeInput };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
-
export const ValidationErrors = ({ errors }) => {
|
|
3
|
-
return errors.length === 0 ? null : (_jsx("div", { role: "alert", class: "validation-errors", children: _jsx("ul", { children: errors.map((error, i) => (_jsx("li", { children: error.message }, i))) }) }));
|
|
4
|
-
};
|
|
2
|
+
export const ValidationErrors = ({ disabled, errors }) => disabled || errors.length === 0 ? null : (_jsx("div", { role: "alert", class: "validation-errors", children: _jsx("ul", { children: errors.map((error, i) => (_jsx("li", { children: error.message }, i))) }) }));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type WebConfig = {
|
|
2
|
+
localeEntityName: string | undefined;
|
|
3
|
+
defaultLocales: string[];
|
|
4
|
+
homeLayoutSections?: {
|
|
5
|
+
title: string;
|
|
6
|
+
comment?: string;
|
|
7
|
+
entities: string[];
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export declare const defaultWebConfig: WebConfig;
|
|
11
|
+
export declare const ConfigContext: import("preact").Context<WebConfig>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { SerializedEntityDecl } from "../../
|
|
1
|
+
import type { SerializedEntityDecl } from "../../shared/schema/declarations/EntityDecl.ts";
|
|
2
2
|
export declare const EntitiesContext: import("preact").Context<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
entities: {
|
|
4
|
+
declaration: SerializedEntityDecl;
|
|
5
|
+
instanceCount: number;
|
|
6
|
+
isLocaleEntity: boolean;
|
|
7
|
+
}[];
|
|
8
|
+
reloadEntities: () => Promise<void>;
|
|
9
|
+
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createContext } from "preact";
|
|
2
|
-
export const EntitiesContext = createContext([]);
|
|
2
|
+
export const EntitiesContext = createContext({ entities: [], reloadEntities: async () => { } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SetStateAction } from "preact/compat";
|
|
2
|
+
import { type UserSettings } from "../hooks/useSettings.ts";
|
|
3
|
+
export declare const defaultSettings: UserSettings;
|
|
4
|
+
export type SettingsContext = {
|
|
5
|
+
settings: UserSettings;
|
|
6
|
+
setSetting: <K extends keyof UserSettings>(key: K, value: SetStateAction<UserSettings[K]>) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const SettingsContext: import("preact").Context<SettingsContext>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext } from "preact";
|
|
2
|
+
import {} from "../hooks/useSettings.js";
|
|
3
|
+
export const defaultSettings = {
|
|
4
|
+
displayedLocales: [],
|
|
5
|
+
enumDisplay: "select",
|
|
6
|
+
};
|
|
7
|
+
export const SettingsContext = createContext({
|
|
8
|
+
settings: defaultSettings,
|
|
9
|
+
setSetting: () => { },
|
|
10
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SerializedEntityDecl } from "../../
|
|
1
|
+
import type { SerializedEntityDecl } from "../../shared/schema/declarations/EntityDecl.ts";
|
|
2
2
|
export declare const useEntityFromRoute: () => {
|
|
3
3
|
declaration: SerializedEntityDecl;
|
|
4
4
|
isLocaleEntity: boolean;
|
|
@@ -3,7 +3,7 @@ import { useContext, useMemo } from "preact/hooks";
|
|
|
3
3
|
import { EntitiesContext } from "../context/entities.js";
|
|
4
4
|
export const useEntityFromRoute = () => {
|
|
5
5
|
const { params: { name }, } = useRoute();
|
|
6
|
-
const entities = useContext(EntitiesContext);
|
|
7
|
-
const entityObj = useMemo(() => entities.find(e => e.declaration.name === name), [entities, name]);
|
|
6
|
+
const { entities } = useContext(EntitiesContext);
|
|
7
|
+
const entityObj = useMemo(() => entities.find(e => e.declaration.name === name && e.declaration.parentReferenceKey === undefined), [entities, name]);
|
|
8
8
|
return entityObj;
|
|
9
9
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { GetAllInstancesResponseBody } from "../../shared/api.ts";
|
|
2
2
|
export type InstanceNamesByEntity = GetAllInstancesResponseBody["instances"];
|
|
3
|
-
export declare const useInstanceNamesByEntity: (
|
|
3
|
+
export declare const useInstanceNamesByEntity: () => [InstanceNamesByEntity | undefined, () => void];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from "preact/hooks";
|
|
2
|
-
import { getAllInstances } from "../api.js";
|
|
3
|
-
|
|
2
|
+
import { getAllInstances } from "../api/instances.js";
|
|
3
|
+
import { useSetting } from "./useSettings.js";
|
|
4
|
+
export const useInstanceNamesByEntity = () => {
|
|
5
|
+
const [locales] = useSetting("displayedLocales");
|
|
4
6
|
const [instanceNamesByEntity, setInstanceNamesByEntity] = useState();
|
|
5
7
|
const updateInstanceNamesByEntity = useCallback(() => {
|
|
6
8
|
getAllInstances(locales)
|