swoop-common 2.2.182 → 2.2.184
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.
|
@@ -6,6 +6,7 @@ import type { ComponentInstanceId } from './ComponentInstanceId';
|
|
|
6
6
|
import type { CreditEntry } from './CreditEntry';
|
|
7
7
|
import type { Field } from './Field';
|
|
8
8
|
import type { Flag } from './Flag';
|
|
9
|
+
import type { InfoNote } from './InfoNote';
|
|
9
10
|
import type { InternalSwoopId } from './InternalSwoopId';
|
|
10
11
|
import type { Price } from './Price';
|
|
11
12
|
import type { UserComponentInstanceField } from './UserComponentInstanceField';
|
|
@@ -35,4 +36,5 @@ export type ComponentInstance = {
|
|
|
35
36
|
isCancellationFee?: boolean;
|
|
36
37
|
sortOrder?: number;
|
|
37
38
|
creditEntries?: Array<CreditEntry>;
|
|
39
|
+
topLevelNotes?: Array<InfoNote>;
|
|
38
40
|
};
|
|
@@ -162,6 +162,8 @@ export default function ComponentPickerModal({ open, onClose, onSelect, selected
|
|
|
162
162
|
};
|
|
163
163
|
const handleClearSearch = () => setSearchTerm("");
|
|
164
164
|
const handleSelect = (component) => {
|
|
165
|
+
if (!component)
|
|
166
|
+
return;
|
|
165
167
|
onSelect(component);
|
|
166
168
|
onClose();
|
|
167
169
|
};
|
|
@@ -235,8 +237,5 @@ export default function ComponentPickerModal({ open, onClose, onSelect, selected
|
|
|
235
237
|
components.length > 0 && (React.createElement(Box, { display: "flex", justifyContent: "center", mt: 2 },
|
|
236
238
|
React.createElement(Pagination, { count: Math.ceil(totalCount / pageSize), page: page, onChange: (_, newPage) => setPage(newPage), color: "primary" })))),
|
|
237
239
|
React.createElement(DialogActions, null,
|
|
238
|
-
React.createElement(Button, { onClick: onClose }, "Cancel")
|
|
239
|
-
selectedComponent && (React.createElement(Button, { variant: "contained", onClick: () => handleSelect(selectedComponent) },
|
|
240
|
-
"Select ",
|
|
241
|
-
selectedComponent.name)))));
|
|
240
|
+
React.createElement(Button, { onClick: onClose }, "Cancel"))));
|
|
242
241
|
}
|
|
@@ -8,14 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import React, { useEffect, useMemo, useState } from "react";
|
|
11
|
-
import { Paper, Button, } from "@mui/material";
|
|
11
|
+
import { Paper, Box, Button, IconButton } from "@mui/material";
|
|
12
|
+
import ClearIcon from "@mui/icons-material/Clear";
|
|
12
13
|
import { useLocalErrors } from "../hooks/errors";
|
|
13
14
|
import { ComponentPool } from "../registry/types";
|
|
14
15
|
import { registerComponent } from "../registry/components";
|
|
15
16
|
import { CoreService } from "../../api/generated/core";
|
|
16
17
|
import { useComponentPicker } from "../contexts/ComponentPickerContext";
|
|
17
18
|
import { InternalServices } from "../../api/init";
|
|
18
|
-
import { getComponentDataByTemplateName, TEMPLATE_NAMES } from "../../lib/config/templateStructure";
|
|
19
|
+
import { getComponentDataByTemplateName, TEMPLATE_NAMES, } from "../../lib/config/templateStructure";
|
|
19
20
|
export const FormComponentPicker = ({ selectedComponent, onChange, templateIds, getError, label, enabled, }) => {
|
|
20
21
|
const [selected, setSelected] = useState();
|
|
21
22
|
const { get } = useComponentPicker();
|
|
@@ -37,30 +38,42 @@ export const FormComponentPicker = ({ selectedComponent, onChange, templateIds,
|
|
|
37
38
|
: selected.name;
|
|
38
39
|
}, [selected, selectedComponent, label]);
|
|
39
40
|
return (React.createElement(Paper, { component: "form", sx: { display: "flex", flexDirection: "column", gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
40
|
-
React.createElement(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
borderColor: !selectedComponent ? "error.
|
|
59
|
-
|
|
60
|
-
? "
|
|
61
|
-
:
|
|
62
|
-
|
|
63
|
-
|
|
41
|
+
React.createElement(Box, { sx: { position: "relative" } },
|
|
42
|
+
React.createElement(Button, { disabled: !enabled, onClick: () => {
|
|
43
|
+
get(templateIds)
|
|
44
|
+
.then((comp) => {
|
|
45
|
+
onChange(comp.id);
|
|
46
|
+
})
|
|
47
|
+
.catch(() => { });
|
|
48
|
+
}, variant: "outlined", fullWidth: true, sx: {
|
|
49
|
+
height: 56,
|
|
50
|
+
fontSize: "1rem",
|
|
51
|
+
fontWeight: 500,
|
|
52
|
+
borderRadius: 1,
|
|
53
|
+
textTransform: "none",
|
|
54
|
+
justifyContent: "flex-start",
|
|
55
|
+
px: 2,
|
|
56
|
+
pr: selectedComponent ? 6 : 2,
|
|
57
|
+
// Red if not selected
|
|
58
|
+
color: !selectedComponent ? "error.main" : "text.primary",
|
|
59
|
+
borderColor: !selectedComponent ? "error.main" : "divider",
|
|
60
|
+
"&:hover": {
|
|
61
|
+
borderColor: !selectedComponent ? "error.dark" : undefined,
|
|
62
|
+
backgroundColor: !selectedComponent
|
|
63
|
+
? "rgba(211, 47, 47, 0.04)"
|
|
64
|
+
: undefined,
|
|
65
|
+
},
|
|
66
|
+
} }, displayLabel),
|
|
67
|
+
selectedComponent && (React.createElement(IconButton, { disabled: !enabled, size: "small", onClick: (e) => {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
onChange("");
|
|
70
|
+
}, sx: {
|
|
71
|
+
position: "absolute",
|
|
72
|
+
right: 8,
|
|
73
|
+
top: "50%",
|
|
74
|
+
transform: "translateY(-50%)",
|
|
75
|
+
} },
|
|
76
|
+
React.createElement(ClearIcon, { fontSize: "small" }))))));
|
|
64
77
|
};
|
|
65
78
|
const FormRendererComponentPicker = ({ data, handleChange, path, label, enabled, schema, }) => {
|
|
66
79
|
const getError = useLocalErrors(path);
|