swoop-common 2.2.152 → 2.2.154
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/api/generated/core/services/ComponentService.d.ts +8 -0
- package/dist/api/generated/core/services/ComponentService.js +21 -0
- package/dist/api/generated/core/services/CoreService.d.ts +8 -0
- package/dist/api/generated/core/services/CoreService.js +21 -0
- package/dist/rendering/prebuild/generated/import_generated.d.ts +1 -0
- package/dist/rendering/prebuild/generated/import_generated.js +1 -0
- package/dist/rendering/renderers/ComponentPicker.d.ts +9 -0
- package/dist/rendering/renderers/ComponentPicker.js +1 -1
- package/dist/rendering/renderers/ComponentPickerArray.d.ts +1 -0
- package/dist/rendering/renderers/ComponentPickerArray.js +42 -0
- package/package.json +1 -1
|
@@ -49,6 +49,14 @@ export declare class ComponentService {
|
|
|
49
49
|
* @throws ApiError
|
|
50
50
|
*/
|
|
51
51
|
static componentBatchGet(requestBody: ComponentBatchRequest): CancelablePromise<ComponentBatchResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* List Component Types
|
|
54
|
+
* Returns a deduplicated list of type strings from componentFields for all components matching the given templateId.
|
|
55
|
+
* @param templateId The template ID to filter components and componentFields by.
|
|
56
|
+
* @returns string A deduplicated list of type strings
|
|
57
|
+
* @throws ApiError
|
|
58
|
+
*/
|
|
59
|
+
static componentListTypes(templateId: string): CancelablePromise<Array<string>>;
|
|
52
60
|
/**
|
|
53
61
|
* Get Component
|
|
54
62
|
* Get Component via ID
|
|
@@ -84,6 +84,27 @@ export class ComponentService {
|
|
|
84
84
|
},
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* List Component Types
|
|
89
|
+
* Returns a deduplicated list of type strings from componentFields for all components matching the given templateId.
|
|
90
|
+
* @param templateId The template ID to filter components and componentFields by.
|
|
91
|
+
* @returns string A deduplicated list of type strings
|
|
92
|
+
* @throws ApiError
|
|
93
|
+
*/
|
|
94
|
+
static componentListTypes(templateId) {
|
|
95
|
+
return __request(OpenAPI, {
|
|
96
|
+
method: 'GET',
|
|
97
|
+
url: '/component/types',
|
|
98
|
+
query: {
|
|
99
|
+
'templateId': templateId,
|
|
100
|
+
},
|
|
101
|
+
errors: {
|
|
102
|
+
400: `If the templateId parameter is missing or malformed`,
|
|
103
|
+
401: `When the client is not authorised`,
|
|
104
|
+
500: `When an unexpected error occurs`,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
87
108
|
/**
|
|
88
109
|
* Get Component
|
|
89
110
|
* Get Component via ID
|
|
@@ -287,6 +287,14 @@ export declare class CoreService {
|
|
|
287
287
|
* @throws ApiError
|
|
288
288
|
*/
|
|
289
289
|
componentBatchGet(requestBody: ComponentBatchRequest): CancelablePromise<ComponentBatchResponse>;
|
|
290
|
+
/**
|
|
291
|
+
* List Component Types
|
|
292
|
+
* Returns a deduplicated list of type strings from componentFields for all components matching the given templateId.
|
|
293
|
+
* @param templateId The template ID to filter components and componentFields by.
|
|
294
|
+
* @returns string A deduplicated list of type strings
|
|
295
|
+
* @throws ApiError
|
|
296
|
+
*/
|
|
297
|
+
componentListTypes(templateId: string): CancelablePromise<Array<string>>;
|
|
290
298
|
/**
|
|
291
299
|
* Get Component
|
|
292
300
|
* Get Component via ID
|
|
@@ -628,6 +628,27 @@ export class CoreService {
|
|
|
628
628
|
},
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
|
+
/**
|
|
632
|
+
* List Component Types
|
|
633
|
+
* Returns a deduplicated list of type strings from componentFields for all components matching the given templateId.
|
|
634
|
+
* @param templateId The template ID to filter components and componentFields by.
|
|
635
|
+
* @returns string A deduplicated list of type strings
|
|
636
|
+
* @throws ApiError
|
|
637
|
+
*/
|
|
638
|
+
componentListTypes(templateId) {
|
|
639
|
+
return __request(OpenAPI, {
|
|
640
|
+
method: 'GET',
|
|
641
|
+
url: '/component/types',
|
|
642
|
+
query: {
|
|
643
|
+
'templateId': templateId,
|
|
644
|
+
},
|
|
645
|
+
errors: {
|
|
646
|
+
400: `If the templateId parameter is missing or malformed`,
|
|
647
|
+
401: `When the client is not authorised`,
|
|
648
|
+
500: `When an unexpected error occurs`,
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
}
|
|
631
652
|
/**
|
|
632
653
|
* Get Component
|
|
633
654
|
* Get Component via ID
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../type_registration/register";
|
|
2
2
|
import "../../renderers/Address";
|
|
3
3
|
import "../../renderers/ComponentPicker";
|
|
4
|
+
import "../../renderers/ComponentPickerArray";
|
|
4
5
|
import "../../renderers/Debug";
|
|
5
6
|
import "../../renderers/Example";
|
|
6
7
|
import "../../renderers/Image/ImageForm";
|
|
@@ -3,6 +3,7 @@ import "../../type_registration/register";
|
|
|
3
3
|
// Custom component renderers
|
|
4
4
|
import "../../renderers/Address";
|
|
5
5
|
import "../../renderers/ComponentPicker";
|
|
6
|
+
import "../../renderers/ComponentPickerArray";
|
|
6
7
|
import "../../renderers/Debug";
|
|
7
8
|
import "../../renderers/Example";
|
|
8
9
|
import "../../renderers/Image/ImageForm";
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { DTOComponentRead } from "../../api/generated/core/exports";
|
|
3
|
+
export declare const FormComponentPicker: React.FC<{
|
|
4
|
+
selectedComponent: string | null;
|
|
5
|
+
onChange: (componentId: string | null) => void;
|
|
6
|
+
templateIds: string[];
|
|
7
|
+
getError?: (field: string) => any;
|
|
8
|
+
label: string;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
}>;
|
|
2
11
|
export declare const fetchComponents: () => Promise<{
|
|
3
12
|
data: {
|
|
4
13
|
revisions: DTOComponentRead[];
|
|
@@ -15,7 +15,7 @@ import { registerComponent } from "../registry/components";
|
|
|
15
15
|
import { CoreService } from "../../api/generated/core";
|
|
16
16
|
import { useComponentPicker } from "../contexts/ComponentPickerContext";
|
|
17
17
|
import { InternalServices } from "../../api/init";
|
|
18
|
-
const FormComponentPicker = ({ selectedComponent, onChange, templateIds, getError, label, enabled, }) => {
|
|
18
|
+
export const FormComponentPicker = ({ selectedComponent, onChange, templateIds, getError, label, enabled, }) => {
|
|
19
19
|
const [selected, setSelected] = useState();
|
|
20
20
|
const { get } = useComponentPicker();
|
|
21
21
|
useEffect(() => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolveSchema } from "@jsonforms/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Box, Button, IconButton } from "@mui/material";
|
|
4
|
+
import DeleteIcon from "@mui/icons-material/Delete";
|
|
5
|
+
import { ComponentPool } from "../registry/types";
|
|
6
|
+
import { registerComponent } from "../registry/components";
|
|
7
|
+
import { getXType } from "../util/xtype";
|
|
8
|
+
import { FormComponentPicker } from "./ComponentPicker";
|
|
9
|
+
// Matches arrays whose items have x-type: "component"
|
|
10
|
+
// Rank 11 — beats isXType (10) and material array controls
|
|
11
|
+
const componentPickerArrayTester = (uischema, schema) => {
|
|
12
|
+
const ui = uischema;
|
|
13
|
+
if (!ui.scope)
|
|
14
|
+
return -1;
|
|
15
|
+
const scoped = resolveSchema(schema, ui.scope, schema);
|
|
16
|
+
if (!scoped || scoped.type !== "array")
|
|
17
|
+
return -1;
|
|
18
|
+
const items = scoped.items;
|
|
19
|
+
if (!items || getXType(items) !== "component")
|
|
20
|
+
return -1;
|
|
21
|
+
return 11;
|
|
22
|
+
};
|
|
23
|
+
const FormRendererComponentPickerArray = ({ data, handleChange, path, schema, label, enabled, }) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const items = (Array.isArray(data) ? data : []);
|
|
26
|
+
const templateIds = (_b = (_a = schema.items) === null || _a === void 0 ? void 0 : _a["x-templateIds"]) !== null && _b !== void 0 ? _b : [];
|
|
27
|
+
const handleItemChange = (index, value) => {
|
|
28
|
+
const next = [...items];
|
|
29
|
+
next[index] = value;
|
|
30
|
+
handleChange(path, next);
|
|
31
|
+
};
|
|
32
|
+
const addItem = () => handleChange(path, [...items, null]);
|
|
33
|
+
const removeItem = (index) => handleChange(path, items.filter((_, i) => i !== index));
|
|
34
|
+
return (React.createElement(Box, { sx: { display: "flex", flexDirection: "column", gap: 1 } },
|
|
35
|
+
items.map((item, index) => (React.createElement(Box, { key: index, sx: { display: "flex", alignItems: "flex-start", gap: 1 } },
|
|
36
|
+
React.createElement(Box, { sx: { flex: 1 } },
|
|
37
|
+
React.createElement(FormComponentPicker, { selectedComponent: typeof item === "string" ? item : null, onChange: (id) => handleItemChange(index, id), templateIds: templateIds, label: label !== null && label !== void 0 ? label : "Component", enabled: enabled !== null && enabled !== void 0 ? enabled : true })),
|
|
38
|
+
React.createElement(IconButton, { onClick: () => removeItem(index), disabled: !(enabled !== null && enabled !== void 0 ? enabled : true) },
|
|
39
|
+
React.createElement(DeleteIcon, null))))),
|
|
40
|
+
React.createElement(Button, { onClick: addItem, disabled: !(enabled !== null && enabled !== void 0 ? enabled : true), variant: "outlined" }, "Add Component")));
|
|
41
|
+
};
|
|
42
|
+
registerComponent("component-array", FormRendererComponentPickerArray, ComponentPool.FORM, componentPickerArrayTester);
|