@tduniec/plugin-template-designer 0.3.7 → 0.4.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/CHANGELOG.md +42 -39
- package/README.md +8 -130
- package/dist/alpha.esm.js +1 -1
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/TemplateDesigner.esm.js +14 -12
- package/dist/components/TemplateDesigner/TemplateDesigner.esm.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.esm.js +3 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/package.json.esm.js +53 -92
- package/dist/package.json.esm.js.map +1 -1
- package/dist/plugin.esm.js +1 -2
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +46 -77
- package/LICENSE +0 -201
- package/dist/api/mockScaffolderActions.esm.js +0 -85
- package/dist/api/mockScaffolderActions.esm.js.map +0 -1
- package/dist/api/scaffolderActions.esm.js +0 -57
- package/dist/api/scaffolderActions.esm.js.map +0 -1
- package/dist/components/DesignerFlow/DesignerFlow.esm.js +0 -431
- package/dist/components/DesignerFlow/DesignerFlow.esm.js.map +0 -1
- package/dist/components/DesignerFlow/flowConfig.esm.js +0 -21
- package/dist/components/DesignerFlow/flowConfig.esm.js.map +0 -1
- package/dist/components/DesignerFlow/handlers.esm.js +0 -322
- package/dist/components/DesignerFlow/handlers.esm.js.map +0 -1
- package/dist/components/DesignerFlow/model.esm.js +0 -185
- package/dist/components/DesignerFlow/model.esm.js.map +0 -1
- package/dist/components/DesignerFlow/nodeLayout.esm.js +0 -138
- package/dist/components/DesignerFlow/nodeLayout.esm.js.map +0 -1
- package/dist/components/DesignerFlow/parameterTransforms.esm.js +0 -184
- package/dist/components/DesignerFlow/parameterTransforms.esm.js.map +0 -1
- package/dist/components/Nodes/ActionNode.esm.js +0 -602
- package/dist/components/Nodes/ActionNode.esm.js.map +0 -1
- package/dist/components/Nodes/OutputNode.esm.js +0 -370
- package/dist/components/Nodes/OutputNode.esm.js.map +0 -1
- package/dist/components/Nodes/ParameterInputNode.esm.js +0 -310
- package/dist/components/Nodes/ParameterInputNode.esm.js.map +0 -1
- package/dist/components/Nodes/ParameterTitlesNode.esm.js +0 -251
- package/dist/components/Nodes/ParameterTitlesNode.esm.js.map +0 -1
- package/dist/components/Nodes/ParametersNode.esm.js +0 -144
- package/dist/components/Nodes/ParametersNode.esm.js.map +0 -1
- package/dist/components/Nodes/action/schema.esm.js +0 -144
- package/dist/components/Nodes/action/schema.esm.js.map +0 -1
- package/dist/components/Nodes/action/useActionInputs.esm.js +0 -84
- package/dist/components/Nodes/action/useActionInputs.esm.js.map +0 -1
- package/dist/components/Nodes/common/AutoWidthPopper.esm.js +0 -22
- package/dist/components/Nodes/common/AutoWidthPopper.esm.js.map +0 -1
- package/dist/components/Nodes/common/nodeInteraction.esm.js +0 -9
- package/dist/components/Nodes/common/nodeInteraction.esm.js.map +0 -1
- package/dist/components/Nodes/output/useOutputController.esm.js +0 -191
- package/dist/components/Nodes/output/useOutputController.esm.js.map +0 -1
- package/dist/components/Nodes/parameters/useParameterSections.esm.js +0 -162
- package/dist/components/Nodes/parameters/useParameterSections.esm.js.map +0 -1
- package/dist/components/Nodes/types.esm.js +0 -8
- package/dist/components/Nodes/types.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/components/FieldEditorDialog.esm.js +0 -55
- package/dist/components/TemplateDesigner/components/FieldEditorDialog.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/components/TemplateLanding.esm.js +0 -157
- package/dist/components/TemplateDesigner/components/TemplateLanding.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/components/TemplateWorkspace.esm.js +0 -302
- package/dist/components/TemplateDesigner/components/TemplateWorkspace.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/components/codemirrorTheme.esm.js +0 -30
- package/dist/components/TemplateDesigner/components/codemirrorTheme.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/useFieldEditor.esm.js +0 -95
- package/dist/components/TemplateDesigner/useFieldEditor.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/useTemplateState.esm.js +0 -627
- package/dist/components/TemplateDesigner/useTemplateState.esm.js.map +0 -1
- package/dist/components/TemplateDesigner/utils.esm.js +0 -46
- package/dist/components/TemplateDesigner/utils.esm.js.map +0 -1
- package/dist/components/TemplateDesignerIcon.esm.js +0 -33
- package/dist/components/TemplateDesignerIcon.esm.js.map +0 -1
- package/dist/utils/createSequentialEdges.esm.js +0 -15
- package/dist/utils/createSequentialEdges.esm.js.map +0 -1
- package/dist/utils/sampleTemplate.esm.js +0 -40
- package/dist/utils/sampleTemplate.esm.js.map +0 -1
- package/dist/utils/yamlJsonConversion.esm.js +0 -47
- package/dist/utils/yamlJsonConversion.esm.js.map +0 -1
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { NodeToolbar, Position, Handle } from '@xyflow/react';
|
|
3
|
-
import { memo } from 'react';
|
|
4
|
-
import { useTheme, styled, alpha } from '@material-ui/core/styles';
|
|
5
|
-
import { Box, Typography, Chip, Button } from '@material-ui/core';
|
|
6
|
-
import SettingsIcon from '@material-ui/icons/Settings';
|
|
7
|
-
import AddIcon from '@material-ui/icons/Add';
|
|
8
|
-
import { ParameterTitlesNode } from './ParameterTitlesNode.esm.js';
|
|
9
|
-
import { createStopNodeInteraction } from './common/nodeInteraction.esm.js';
|
|
10
|
-
import { useParameterSectionsController } from './parameters/useParameterSections.esm.js';
|
|
11
|
-
|
|
12
|
-
const resolvePaletteMode = (theme) => theme.palette.mode ?? theme.palette.type ?? "light";
|
|
13
|
-
const Card = styled(Box)(({ theme }) => {
|
|
14
|
-
const paletteMode = resolvePaletteMode(theme);
|
|
15
|
-
return {
|
|
16
|
-
position: "relative",
|
|
17
|
-
background: alpha(
|
|
18
|
-
theme.palette.warning.main,
|
|
19
|
-
paletteMode === "dark" ? 0.18 : 0.12
|
|
20
|
-
),
|
|
21
|
-
border: `1px solid ${alpha(theme.palette.warning.main, 0.35)}`,
|
|
22
|
-
borderRadius: 12,
|
|
23
|
-
width: 760,
|
|
24
|
-
padding: theme.spacing(1.5),
|
|
25
|
-
boxShadow: theme.shadows[2],
|
|
26
|
-
color: theme.palette.text.primary,
|
|
27
|
-
overflow: "hidden",
|
|
28
|
-
"&::before": {
|
|
29
|
-
content: '""',
|
|
30
|
-
position: "absolute",
|
|
31
|
-
inset: 0,
|
|
32
|
-
background: `linear-gradient(135deg, ${alpha(
|
|
33
|
-
theme.palette.warning.light,
|
|
34
|
-
paletteMode === "dark" ? 0.28 : 0.18
|
|
35
|
-
)}, transparent 65%)`,
|
|
36
|
-
pointerEvents: "none",
|
|
37
|
-
zIndex: 0
|
|
38
|
-
},
|
|
39
|
-
"& > *": {
|
|
40
|
-
position: "relative",
|
|
41
|
-
zIndex: 1
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
const Header = styled(Box)(({ theme }) => {
|
|
46
|
-
const paletteMode = resolvePaletteMode(theme);
|
|
47
|
-
return {
|
|
48
|
-
display: "flex",
|
|
49
|
-
alignItems: "center",
|
|
50
|
-
justifyContent: "space-between",
|
|
51
|
-
padding: theme.spacing(1),
|
|
52
|
-
marginBottom: theme.spacing(1),
|
|
53
|
-
borderRadius: 8,
|
|
54
|
-
backgroundColor: alpha(
|
|
55
|
-
theme.palette.warning.main,
|
|
56
|
-
paletteMode === "dark" ? 0.24 : 0.14
|
|
57
|
-
),
|
|
58
|
-
border: `1px solid ${alpha(theme.palette.warning.main, 0.4)}`
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
const ParametersNodeComponent = ({
|
|
62
|
-
data
|
|
63
|
-
}) => {
|
|
64
|
-
const theme = useTheme();
|
|
65
|
-
const paletteMode = resolvePaletteMode(theme);
|
|
66
|
-
const {
|
|
67
|
-
sections,
|
|
68
|
-
handleSectionUpdate,
|
|
69
|
-
handleFieldUpdate,
|
|
70
|
-
handleAddSection,
|
|
71
|
-
handleMoveSection,
|
|
72
|
-
handleAddField,
|
|
73
|
-
handleMoveField
|
|
74
|
-
} = useParameterSectionsController(data);
|
|
75
|
-
const stopAll = createStopNodeInteraction();
|
|
76
|
-
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
77
|
-
/* @__PURE__ */ jsxs(Header, { children: [
|
|
78
|
-
/* @__PURE__ */ jsxs(
|
|
79
|
-
Box,
|
|
80
|
-
{
|
|
81
|
-
display: "flex",
|
|
82
|
-
alignItems: "center",
|
|
83
|
-
style: { gap: theme.spacing(1) },
|
|
84
|
-
children: [
|
|
85
|
-
/* @__PURE__ */ jsx(
|
|
86
|
-
SettingsIcon,
|
|
87
|
-
{
|
|
88
|
-
fontSize: "small",
|
|
89
|
-
htmlColor: theme.palette.warning.dark
|
|
90
|
-
}
|
|
91
|
-
),
|
|
92
|
-
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", noWrap: true, children: "Parameters" })
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
),
|
|
96
|
-
/* @__PURE__ */ jsx(
|
|
97
|
-
Chip,
|
|
98
|
-
{
|
|
99
|
-
size: "small",
|
|
100
|
-
variant: "outlined",
|
|
101
|
-
label: "parameters",
|
|
102
|
-
style: {
|
|
103
|
-
borderColor: theme.palette.warning.dark,
|
|
104
|
-
color: paletteMode === "dark" ? theme.palette.warning.light : theme.palette.warning.dark,
|
|
105
|
-
textTransform: "uppercase"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
] }),
|
|
110
|
-
/* @__PURE__ */ jsx(Box, { mt: 2, children: /* @__PURE__ */ jsx(
|
|
111
|
-
ParameterTitlesNode,
|
|
112
|
-
{
|
|
113
|
-
sections,
|
|
114
|
-
onSectionUpdate: handleSectionUpdate,
|
|
115
|
-
onFieldUpdate: handleFieldUpdate,
|
|
116
|
-
onAddSection: handleAddSection,
|
|
117
|
-
onMoveSection: handleMoveSection,
|
|
118
|
-
onAddField: handleAddField,
|
|
119
|
-
onMoveField: handleMoveField
|
|
120
|
-
}
|
|
121
|
-
) }),
|
|
122
|
-
/* @__PURE__ */ jsx(NodeToolbar, { position: Position.Bottom, children: /* @__PURE__ */ jsx(
|
|
123
|
-
Button,
|
|
124
|
-
{
|
|
125
|
-
variant: "outlined",
|
|
126
|
-
size: "small",
|
|
127
|
-
startIcon: /* @__PURE__ */ jsx(AddIcon, { fontSize: "small" }),
|
|
128
|
-
onClick: () => data.onAddNode?.({
|
|
129
|
-
afterRfId: data.rfId,
|
|
130
|
-
type: "actionNode"
|
|
131
|
-
}),
|
|
132
|
-
className: "nodrag nowheel",
|
|
133
|
-
onPointerDown: stopAll.onPointerDown,
|
|
134
|
-
onKeyDown: stopAll.onKeyDown,
|
|
135
|
-
children: "Add First Action"
|
|
136
|
-
}
|
|
137
|
-
) }),
|
|
138
|
-
/* @__PURE__ */ jsx(Handle, { type: "source", position: Position.Bottom })
|
|
139
|
-
] });
|
|
140
|
-
};
|
|
141
|
-
const ParametersNode = memo(ParametersNodeComponent);
|
|
142
|
-
|
|
143
|
-
export { ParametersNode };
|
|
144
|
-
//# sourceMappingURL=ParametersNode.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParametersNode.esm.js","sources":["../../../src/components/Nodes/ParametersNode.tsx"],"sourcesContent":["import { Handle, NodeToolbar, Position } from \"@xyflow/react\";\nimport { memo } from \"react\";\nimport { alpha, styled, useTheme } from \"@material-ui/core/styles\";\nimport { Box, Button, Chip, Typography } from \"@material-ui/core\";\nimport SettingsIcon from \"@material-ui/icons/Settings\";\nimport AddIcon from \"@material-ui/icons/Add\";\nimport type { ParametersNodeData } from \"./types\";\nimport { ParameterTitlesNode } from \"./ParameterTitlesNode\";\nimport { createStopNodeInteraction } from \"./common/nodeInteraction\";\nimport { useParameterSectionsController } from \"./parameters/useParameterSections\";\n\nconst resolvePaletteMode = (theme: { palette: { type?: string } }) =>\n (theme.palette as { mode?: \"light\" | \"dark\" }).mode ??\n theme.palette.type ??\n \"light\";\n\nconst Card = styled(Box)(({ theme }) => {\n const paletteMode = resolvePaletteMode(theme);\n return {\n position: \"relative\",\n background: alpha(\n theme.palette.warning.main,\n paletteMode === \"dark\" ? 0.18 : 0.12\n ),\n border: `1px solid ${alpha(theme.palette.warning.main, 0.35)}`,\n borderRadius: 12,\n width: 760,\n padding: theme.spacing(1.5),\n boxShadow: theme.shadows[2],\n color: theme.palette.text.primary,\n overflow: \"hidden\",\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n inset: 0,\n background: `linear-gradient(135deg, ${alpha(\n theme.palette.warning.light,\n paletteMode === \"dark\" ? 0.28 : 0.18\n )}, transparent 65%)`,\n pointerEvents: \"none\",\n zIndex: 0,\n },\n \"& > *\": {\n position: \"relative\",\n zIndex: 1,\n },\n };\n});\n\nconst Header = styled(Box)(({ theme }) => {\n const paletteMode = resolvePaletteMode(theme);\n return {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n padding: theme.spacing(1),\n marginBottom: theme.spacing(1),\n borderRadius: 8,\n backgroundColor: alpha(\n theme.palette.warning.main,\n paletteMode === \"dark\" ? 0.24 : 0.14\n ),\n border: `1px solid ${alpha(theme.palette.warning.main, 0.4)}`,\n };\n});\n\nconst ParametersNodeComponent: React.FC<{ data: ParametersNodeData }> = ({\n data,\n}) => {\n const theme = useTheme();\n const paletteMode = resolvePaletteMode(theme);\n const {\n sections,\n handleSectionUpdate,\n handleFieldUpdate,\n handleAddSection,\n handleMoveSection,\n handleAddField,\n handleMoveField,\n } = useParameterSectionsController(data);\n\n const stopAll = createStopNodeInteraction();\n\n return (\n <Card>\n <Header>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n style={{ gap: theme.spacing(1) }}\n >\n <SettingsIcon\n fontSize=\"small\"\n htmlColor={theme.palette.warning.dark}\n />\n <Typography variant=\"subtitle2\" noWrap>\n Parameters\n </Typography>\n </Box>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label=\"parameters\"\n style={{\n borderColor: theme.palette.warning.dark,\n color:\n paletteMode === \"dark\"\n ? theme.palette.warning.light\n : theme.palette.warning.dark,\n textTransform: \"uppercase\",\n }}\n />\n </Header>\n\n <Box mt={2}>\n <ParameterTitlesNode\n sections={sections}\n onSectionUpdate={handleSectionUpdate}\n onFieldUpdate={handleFieldUpdate}\n onAddSection={handleAddSection}\n onMoveSection={handleMoveSection}\n onAddField={handleAddField}\n onMoveField={handleMoveField}\n />\n </Box>\n\n <NodeToolbar position={Position.Bottom}>\n <Button\n variant=\"outlined\"\n size=\"small\"\n startIcon={<AddIcon fontSize=\"small\" />}\n onClick={() =>\n data.onAddNode?.({\n afterRfId: data.rfId,\n type: \"actionNode\",\n })\n }\n className=\"nodrag nowheel\"\n onPointerDown={stopAll.onPointerDown}\n onKeyDown={stopAll.onKeyDown}\n >\n Add First Action\n </Button>\n </NodeToolbar>\n\n <Handle type=\"source\" position={Position.Bottom} />\n </Card>\n );\n};\n\nexport const ParametersNode = memo(ParametersNodeComponent);\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,MAAM,kBAAA,GAAqB,CAAC,KAAA,KACzB,KAAA,CAAM,QAAwC,IAAA,IAC/C,KAAA,CAAM,QAAQ,IAAA,IACd,OAAA;AAEF,MAAM,OAAO,MAAA,CAAO,GAAG,EAAE,CAAC,EAAE,OAAM,KAAM;AACtC,EAAA,MAAM,WAAA,GAAc,mBAAmB,KAAK,CAAA;AAC5C,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,UAAA;AAAA,IACV,UAAA,EAAY,KAAA;AAAA,MACV,KAAA,CAAM,QAAQ,OAAA,CAAQ,IAAA;AAAA,MACtB,WAAA,KAAgB,SAAS,IAAA,GAAO;AAAA,KAClC;AAAA,IACA,MAAA,EAAQ,aAAa,KAAA,CAAM,KAAA,CAAM,QAAQ,OAAA,CAAQ,IAAA,EAAM,IAAI,CAAC,CAAA,CAAA;AAAA,IAC5D,YAAA,EAAc,EAAA;AAAA,IACd,KAA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AA,GAAA,EACnD,CAAA;AAEJ,CAAA;AAEO,MAAM,cAAA,GAAiB,KAAK,uBAAuB;;;;"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
const capitalize = (value) => value.length > 0 ? value[0].toUpperCase() + value.slice(1) : value;
|
|
2
|
-
const getFirstType = (type) => {
|
|
3
|
-
if (!type) {
|
|
4
|
-
return void 0;
|
|
5
|
-
}
|
|
6
|
-
const values = Array.isArray(type) ? type : [type];
|
|
7
|
-
const match = values.find(
|
|
8
|
-
(value) => value === "string" || value === "number" || value === "integer" || value === "boolean" || value === "array" || value === "object"
|
|
9
|
-
);
|
|
10
|
-
return match;
|
|
11
|
-
};
|
|
12
|
-
const inferTypeFromValue = (value) => {
|
|
13
|
-
if (value === null || value === void 0) {
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
return "array";
|
|
18
|
-
}
|
|
19
|
-
if (typeof value === "object") {
|
|
20
|
-
return "object";
|
|
21
|
-
}
|
|
22
|
-
if (typeof value === "boolean") {
|
|
23
|
-
return "boolean";
|
|
24
|
-
}
|
|
25
|
-
if (typeof value === "number") {
|
|
26
|
-
return Number.isInteger(value) ? "integer" : "number";
|
|
27
|
-
}
|
|
28
|
-
return void 0;
|
|
29
|
-
};
|
|
30
|
-
const normalizeSchemaType = (schema, value) => {
|
|
31
|
-
if (!schema || typeof schema !== "object") {
|
|
32
|
-
const inferred2 = inferTypeFromValue(value);
|
|
33
|
-
return inferred2 ?? "string";
|
|
34
|
-
}
|
|
35
|
-
const schemaType = getFirstType(schema.type);
|
|
36
|
-
if (schemaType) {
|
|
37
|
-
return schemaType;
|
|
38
|
-
}
|
|
39
|
-
const inferred = inferTypeFromValue(value);
|
|
40
|
-
if (inferred) {
|
|
41
|
-
return inferred;
|
|
42
|
-
}
|
|
43
|
-
return "string";
|
|
44
|
-
};
|
|
45
|
-
const getArrayItemTypeLabel = (schema) => {
|
|
46
|
-
if (!schema) {
|
|
47
|
-
return "";
|
|
48
|
-
}
|
|
49
|
-
const items = schema.items;
|
|
50
|
-
if (!items) {
|
|
51
|
-
return "";
|
|
52
|
-
}
|
|
53
|
-
if (Array.isArray(items)) {
|
|
54
|
-
const [first] = items;
|
|
55
|
-
if (!first) {
|
|
56
|
-
return "";
|
|
57
|
-
}
|
|
58
|
-
return capitalize(normalizeSchemaType(first));
|
|
59
|
-
}
|
|
60
|
-
return capitalize(normalizeSchemaType(items));
|
|
61
|
-
};
|
|
62
|
-
const buildTypeLabel = (schema) => {
|
|
63
|
-
const normalized = normalizeSchemaType(schema);
|
|
64
|
-
if (normalized === "array") {
|
|
65
|
-
const itemsLabel = getArrayItemTypeLabel(schema);
|
|
66
|
-
return itemsLabel ? `Array<${itemsLabel}>` : "Array";
|
|
67
|
-
}
|
|
68
|
-
if (normalized === "integer") {
|
|
69
|
-
return "Integer";
|
|
70
|
-
}
|
|
71
|
-
if (normalized === "unknown") {
|
|
72
|
-
return "Unknown";
|
|
73
|
-
}
|
|
74
|
-
return capitalize(normalized);
|
|
75
|
-
};
|
|
76
|
-
const stringifyValueForDisplay = (value, type) => {
|
|
77
|
-
if (value === void 0 || value === null) {
|
|
78
|
-
return "";
|
|
79
|
-
}
|
|
80
|
-
if (type === "array" || type === "object" || Array.isArray(value) || typeof value === "object") {
|
|
81
|
-
if (typeof value === "string") {
|
|
82
|
-
return value;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
return JSON.stringify(value, null, 2);
|
|
86
|
-
} catch {
|
|
87
|
-
return String(value);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (typeof value === "boolean") {
|
|
91
|
-
return value ? "true" : "false";
|
|
92
|
-
}
|
|
93
|
-
return String(value);
|
|
94
|
-
};
|
|
95
|
-
const coerceValueForType = (raw, type) => {
|
|
96
|
-
if (raw === "") {
|
|
97
|
-
return "";
|
|
98
|
-
}
|
|
99
|
-
if (type === "boolean") {
|
|
100
|
-
if (raw === "true") {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
if (raw === "false") {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return raw;
|
|
107
|
-
}
|
|
108
|
-
if (type === "number" || type === "integer") {
|
|
109
|
-
const num = Number(raw);
|
|
110
|
-
if (!Number.isNaN(num)) {
|
|
111
|
-
return num;
|
|
112
|
-
}
|
|
113
|
-
return raw;
|
|
114
|
-
}
|
|
115
|
-
if (type === "array" || type === "object") {
|
|
116
|
-
try {
|
|
117
|
-
return JSON.parse(raw);
|
|
118
|
-
} catch {
|
|
119
|
-
return raw;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return raw;
|
|
123
|
-
};
|
|
124
|
-
const extractEnumOptions = (schema) => {
|
|
125
|
-
if (!schema || !Array.isArray(schema.enum)) {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
return schema.enum.map((option) => {
|
|
129
|
-
if (option === void 0 || option === null) {
|
|
130
|
-
return "";
|
|
131
|
-
}
|
|
132
|
-
if (typeof option === "object") {
|
|
133
|
-
try {
|
|
134
|
-
return JSON.stringify(option);
|
|
135
|
-
} catch {
|
|
136
|
-
return String(option);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return String(option);
|
|
140
|
-
}).filter((option) => option !== "");
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export { buildTypeLabel, coerceValueForType, extractEnumOptions, normalizeSchemaType, stringifyValueForDisplay };
|
|
144
|
-
//# sourceMappingURL=schema.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.esm.js","sources":["../../../../src/components/Nodes/action/schema.ts"],"sourcesContent":["export type JsonSchemaProperty = {\n type?: string | string[];\n enum?: unknown[];\n items?: JsonSchemaProperty | JsonSchemaProperty[];\n} & Record<string, unknown>;\n\nexport type NormalizedSchemaType =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"array\"\n | \"object\"\n | \"unknown\";\n\nconst capitalize = (value: string) =>\n value.length > 0 ? value[0].toUpperCase() + value.slice(1) : value;\n\nconst getFirstType = (\n type: string | string[] | undefined\n): NormalizedSchemaType | undefined => {\n if (!type) {\n return undefined;\n }\n const values = Array.isArray(type) ? type : [type];\n const match = values.find(\n (value): value is NormalizedSchemaType =>\n value === \"string\" ||\n value === \"number\" ||\n value === \"integer\" ||\n value === \"boolean\" ||\n value === \"array\" ||\n value === \"object\"\n );\n return match;\n};\n\nconst inferTypeFromValue = (\n value: unknown\n): NormalizedSchemaType | undefined => {\n if (value === null || value === undefined) {\n return undefined;\n }\n if (Array.isArray(value)) {\n return \"array\";\n }\n if (typeof value === \"object\") {\n return \"object\";\n }\n if (typeof value === \"boolean\") {\n return \"boolean\";\n }\n if (typeof value === \"number\") {\n return Number.isInteger(value) ? \"integer\" : \"number\";\n }\n return undefined;\n};\n\nexport const normalizeSchemaType = (\n schema: JsonSchemaProperty | undefined,\n value?: unknown\n): NormalizedSchemaType => {\n if (!schema || typeof schema !== \"object\") {\n const inferred = inferTypeFromValue(value);\n return inferred ?? \"string\";\n }\n const schemaType = getFirstType(schema.type);\n if (schemaType) {\n return schemaType;\n }\n const inferred = inferTypeFromValue(value);\n if (inferred) {\n return inferred;\n }\n return \"string\";\n};\n\nconst getArrayItemTypeLabel = (schema: JsonSchemaProperty | undefined) => {\n if (!schema) {\n return \"\";\n }\n const items = schema.items;\n if (!items) {\n return \"\";\n }\n if (Array.isArray(items)) {\n const [first] = items;\n if (!first) {\n return \"\";\n }\n return capitalize(normalizeSchemaType(first));\n }\n return capitalize(normalizeSchemaType(items));\n};\n\nexport const buildTypeLabel = (schema: JsonSchemaProperty | undefined) => {\n const normalized = normalizeSchemaType(schema);\n if (normalized === \"array\") {\n const itemsLabel = getArrayItemTypeLabel(schema);\n return itemsLabel ? `Array<${itemsLabel}>` : \"Array\";\n }\n if (normalized === \"integer\") {\n return \"Integer\";\n }\n if (normalized === \"unknown\") {\n return \"Unknown\";\n }\n return capitalize(normalized);\n};\n\nexport const stringifyValueForDisplay = (\n value: unknown,\n type: NormalizedSchemaType\n) => {\n if (value === undefined || value === null) {\n return \"\";\n }\n\n if (\n type === \"array\" ||\n type === \"object\" ||\n Array.isArray(value) ||\n typeof value === \"object\"\n ) {\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n }\n\n if (typeof value === \"boolean\") {\n return value ? \"true\" : \"false\";\n }\n\n return String(value);\n};\n\nexport const coerceValueForType = (\n raw: string,\n type: NormalizedSchemaType\n): unknown => {\n if (raw === \"\") {\n return \"\";\n }\n\n if (type === \"boolean\") {\n if (raw === \"true\") {\n return true;\n }\n if (raw === \"false\") {\n return false;\n }\n return raw;\n }\n\n if (type === \"number\" || type === \"integer\") {\n const num = Number(raw);\n if (!Number.isNaN(num)) {\n return num;\n }\n return raw;\n }\n\n if (type === \"array\" || type === \"object\") {\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n\n return raw;\n};\n\nexport const extractEnumOptions = (schema: JsonSchemaProperty | undefined) => {\n if (!schema || !Array.isArray(schema.enum)) {\n return [] as string[];\n }\n return schema.enum\n .map((option): string => {\n if (option === undefined || option === null) {\n return \"\";\n }\n if (typeof option === \"object\") {\n try {\n return JSON.stringify(option);\n } catch {\n return String(option);\n }\n }\n return String(option);\n })\n .filter((option) => option !== \"\");\n};\n"],"names":["inferred"],"mappings":"AAeA,MAAM,UAAA,GAAa,CAAC,KAAA,KAClB,KAAA,CAAM,SAAS,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,CAAE,WAAA,EAAY,GAAI,KAAA,CAAM,KAAA,CAAM,CAAC,CAAA,GAAI,KAAA;AAE/D,MAAM,YAAA,GAAe,CACnB,IAAA,KACqC;AACrC,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,SAAS,KAAA,CAAM,OAAA,CAAQ,IAAI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S,QAAA,EAAU;AACzC,IAAA,IAAI;AACF,MAAA,OAAO,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,IACvB,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,EACF;AAEA,EAAA,OAAO,GAAA;AACT;AAEO,MAAM,kBAAA,GAAqB,CAAC,MAAA,KAA2C;AAC5E,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,MAAM,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,EAAG;AAC1C,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,MAAA,CAAO,IAAA,CACX,GAAA,CAAI,CAAC,MAAA,KAAmB;AACvB,IAAA,IAAI,MAAA,KAAW,MAAA,IAAa,MAAA,KAAW,IAAA,EAAM;AAC3C,MAAA,OAAO,EAAA;AAAA,IACT;AACA,IAAA,IAAI,OAAO,WAAW,QAAA,EAAU;AAC9B,MAAA,IAAI;AACF,QAAA,OAAO,IAAA,CAAK,UAAU,MAAM,CAAA;AAAA,MAC9B,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,OAAO,MAAM,CAAA;AAAA,MACtB;AAAA,IACF;AACA,IAAA,OAAO,OAAO,MAAM,CAAA;AAAA,EACtB,CAAC,CAAA,CACA,MAAA,CAAO,CAAC,MAAA,KAAW,WAAW,EAAE,CAAA;AACrC;;;;"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { normalizeSchemaType, buildTypeLabel, extractEnumOptions } from './schema.esm.js';
|
|
3
|
-
|
|
4
|
-
const useActionInputs = ({
|
|
5
|
-
data,
|
|
6
|
-
step,
|
|
7
|
-
actionId,
|
|
8
|
-
newKey
|
|
9
|
-
}) => {
|
|
10
|
-
const actionInputSchema = useMemo(() => {
|
|
11
|
-
if (!actionId) {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
const inputs = data.scaffolderActionInputsById?.[actionId] ?? {};
|
|
15
|
-
return inputs;
|
|
16
|
-
}, [actionId, data.scaffolderActionInputsById]);
|
|
17
|
-
const requiredInputKeys = useMemo(() => {
|
|
18
|
-
if (!actionId) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
const rawKeys = data.scaffolderActionInputRequiredById?.[actionId];
|
|
22
|
-
if (!Array.isArray(rawKeys)) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
return rawKeys;
|
|
26
|
-
}, [actionId, data.scaffolderActionInputRequiredById]);
|
|
27
|
-
const actionInputOptions = useMemo(() => {
|
|
28
|
-
return Object.entries(actionInputSchema).map(([key, schema]) => {
|
|
29
|
-
const normalized = normalizeSchemaType(schema);
|
|
30
|
-
const label = buildTypeLabel(schema);
|
|
31
|
-
return {
|
|
32
|
-
key,
|
|
33
|
-
label: label ? `${key} (${label})` : key,
|
|
34
|
-
schema,
|
|
35
|
-
type: normalized
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
}, [actionInputSchema]);
|
|
39
|
-
const inputEntries = useMemo(
|
|
40
|
-
() => Object.entries(step.input ?? {}),
|
|
41
|
-
[step.input]
|
|
42
|
-
);
|
|
43
|
-
const usedInputKeys = useMemo(
|
|
44
|
-
() => new Set(inputEntries.map(([key]) => key)),
|
|
45
|
-
[inputEntries]
|
|
46
|
-
);
|
|
47
|
-
const availableInputOptions = useMemo(
|
|
48
|
-
() => actionInputOptions.filter((option) => !usedInputKeys.has(option.key)),
|
|
49
|
-
[actionInputOptions, usedInputKeys]
|
|
50
|
-
);
|
|
51
|
-
const trimmedNewKey = newKey.trim();
|
|
52
|
-
const selectedNewKeyOption = useMemo(
|
|
53
|
-
() => availableInputOptions.find((option) => option.key === trimmedNewKey) ?? null,
|
|
54
|
-
[availableInputOptions, trimmedNewKey]
|
|
55
|
-
);
|
|
56
|
-
const newKeySchema = selectedNewKeyOption?.schema ?? (trimmedNewKey ? actionInputSchema?.[trimmedNewKey] : void 0);
|
|
57
|
-
const newKeyNormalizedType = normalizeSchemaType(newKeySchema);
|
|
58
|
-
const newKeyTypeLabel = buildTypeLabel(newKeySchema) || "String";
|
|
59
|
-
const newKeyEnumOptions = extractEnumOptions(newKeySchema);
|
|
60
|
-
const missingRequiredInputKeys = useMemo(
|
|
61
|
-
() => requiredInputKeys.filter(
|
|
62
|
-
(key) => typeof key === "string" && !usedInputKeys.has(key)
|
|
63
|
-
),
|
|
64
|
-
[requiredInputKeys, usedInputKeys]
|
|
65
|
-
);
|
|
66
|
-
return {
|
|
67
|
-
actionInputSchema,
|
|
68
|
-
actionInputOptions,
|
|
69
|
-
inputEntries,
|
|
70
|
-
usedInputKeys,
|
|
71
|
-
requiredInputKeys,
|
|
72
|
-
missingRequiredInputKeys,
|
|
73
|
-
availableInputOptions,
|
|
74
|
-
trimmedNewKey,
|
|
75
|
-
selectedNewKeyOption,
|
|
76
|
-
newKeySchema,
|
|
77
|
-
newKeyNormalizedType,
|
|
78
|
-
newKeyTypeLabel,
|
|
79
|
-
newKeyEnumOptions
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { useActionInputs };
|
|
84
|
-
//# sourceMappingURL=useActionInputs.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useActionInputs.esm.js","sources":["../../../../src/components/Nodes/action/useActionInputs.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { TaskStep } from \"@backstage/plugin-scaffolder-common\";\nimport type { ActionNodeData } from \"../types\";\nimport type { JsonSchemaProperty, NormalizedSchemaType } from \"./schema\";\nimport {\n buildTypeLabel,\n extractEnumOptions,\n normalizeSchemaType,\n} from \"./schema\";\n\ntype ActionInputOption = {\n key: string;\n label: string;\n schema?: JsonSchemaProperty;\n type: NormalizedSchemaType;\n};\n\ntype UseActionInputsArgs = {\n data: ActionNodeData;\n step: TaskStep;\n actionId: string;\n newKey: string;\n};\n\nexport const useActionInputs = ({\n data,\n step,\n actionId,\n newKey,\n}: UseActionInputsArgs) => {\n const actionInputSchema = useMemo(() => {\n if (!actionId) {\n return {} as Record<string, JsonSchemaProperty>;\n }\n const inputs = (data.scaffolderActionInputsById?.[actionId] ??\n {}) as Record<string, JsonSchemaProperty>;\n return inputs;\n }, [actionId, data.scaffolderActionInputsById]);\n\n const requiredInputKeys = useMemo(() => {\n if (!actionId) {\n return [] as string[];\n }\n const rawKeys = data.scaffolderActionInputRequiredById?.[actionId];\n if (!Array.isArray(rawKeys)) {\n return [];\n }\n return rawKeys;\n }, [actionId, data.scaffolderActionInputRequiredById]);\n\n const actionInputOptions = useMemo<ActionInputOption[]>(() => {\n return Object.entries(actionInputSchema).map(([key, schema]) => {\n const normalized = normalizeSchemaType(schema);\n const label = buildTypeLabel(schema);\n return {\n key,\n label: label ? `${key} (${label})` : key,\n schema,\n type: normalized,\n };\n });\n }, [actionInputSchema]);\n\n const inputEntries = useMemo(\n () => Object.entries(step.input ?? {}),\n [step.input]\n );\n const usedInputKeys = useMemo(\n () => new Set(inputEntries.map(([key]) => key)),\n [inputEntries]\n );\n const availableInputOptions = useMemo(\n () => actionInputOptions.filter((option) => !usedInputKeys.has(option.key)),\n [actionInputOptions, usedInputKeys]\n );\n const trimmedNewKey = newKey.trim();\n const selectedNewKeyOption = useMemo(\n () =>\n availableInputOptions.find((option) => option.key === trimmedNewKey) ??\n null,\n [availableInputOptions, trimmedNewKey]\n );\n\n const newKeySchema =\n selectedNewKeyOption?.schema ??\n (trimmedNewKey ? actionInputSchema?.[trimmedNewKey] : undefined);\n const newKeyNormalizedType = normalizeSchemaType(newKeySchema);\n const newKeyTypeLabel = buildTypeLabel(newKeySchema) || \"String\";\n const newKeyEnumOptions = extractEnumOptions(newKeySchema);\n\n const missingRequiredInputKeys = useMemo(\n () =>\n requiredInputKeys.filter(\n (key) => typeof key === \"string\" && !usedInputKeys.has(key)\n ),\n [requiredInputKeys, usedInputKeys]\n );\n\n return {\n actionInputSchema,\n actionInputOptions,\n inputEntries,\n usedInputKeys,\n requiredInputKeys,\n missingRequiredInputKeys,\n availableInputOptions,\n trimmedNewKey,\n selectedNewKeyOption,\n newKeySchema,\n newKeyNormalizedType,\n newKeyTypeLabel,\n newKeyEnumOptions,\n };\n};\n"],"names":[],"mappings":";;;AAwBO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,KAA2B;AACzB,EAAA,MAAM,iBAAA,GAAoB,QAAQ,MAAM;AACtC,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,OAAO,EAAC;AAAA,IACV;AACA,IAAA,MAAM,MAAA,GAAU,IAAA,CAAK,0BAAA,GAA6B,QAAQ,KACxD,EAAC;AACH,IAAA,OAAO,MAAA;AAAA,EACT,CAAA,EAAG,CAAC,QAAA,EAAU,IAAA,CAAK,0BAA0B,CAAC,CAAA;AAE9C,EAAA,MAAM,iBAAA,GAAoB,QAAQ,MAAM;AACtC,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,OAAO,EAAC;AAAA,IACV;AACA,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,iCAAA,GAAoC,QAAQ,CAAA;AACjE,IAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC3B,MAAA,OAAO,EAAC;AAAA,IACV;AACA,IAAA,OAAO,OAAA;AAAA,EACT,CAAA,EAAG,CAAC,QAAA,EAAU,IAAA,CAAK,iCAAiC,CAAC,CAAA;AAErD,EAAA,MAAM,kBAAA,GAAqB,QAA6B,MAAM;AAC5D,IAAA,OAAO,MAAA,CAAO,QAAQ,iBAAiB,CAAA,CAAE,IAAI,CAAC,CAAC,GAAA,EAAK,MAAM,CAAA,KAAM;AAC9D,MAAA,MAAM,UAAA,GAAa,oBAAoB,MAAM,CAAA;AAC7C,MAAA,MAAM,KAAA,GAAQ,eAAe,MAAM,CAAA;AACnC,MAAA,OAAO;AAAA,QACL,GAAA;AAAA,QACA,O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AAM,iBAAA,GAAoB,mBAAmB,YAAY,CAAA;AAEzD,EAAA,MAAM,wBAAA,GAA2B,OAAA;AAAA,IAC/B,MACE,iBAAA,CAAkB,MAAA;AAAA,MAChB,CAAC,QAAQ,OAAO,GAAA,KAAQ,YAAY,CAAC,aAAA,CAAc,IAAI,GAAG;AAAA,KAC5D;AAAA,IACF,CAAC,mBAAmB,aAAa;AAAA,GACnC;AAEA,EAAA,OAAO;AAAA,IACL,iBAAA;AAAA,IACA,kBAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,iBAAA;AAAA,IACA,wBAAA;AAAA,IACA,qBAAA;AAAA,IACA,aAAA;AAAA,IACA,oBAAA;AAAA,IACA,YAAA;AAAA,IACA,oBAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import Popper from '@material-ui/core/Popper';
|
|
3
|
-
|
|
4
|
-
const AutoWidthPopper = (props) => {
|
|
5
|
-
const { style, anchorEl, ...restProps } = props;
|
|
6
|
-
const anchorWidth = anchorEl && "clientWidth" in anchorEl ? anchorEl.clientWidth : void 0;
|
|
7
|
-
return /* @__PURE__ */ jsx(
|
|
8
|
-
Popper,
|
|
9
|
-
{
|
|
10
|
-
...restProps,
|
|
11
|
-
anchorEl,
|
|
12
|
-
style: {
|
|
13
|
-
...style,
|
|
14
|
-
width: "auto",
|
|
15
|
-
minWidth: anchorWidth ?? style?.minWidth
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { AutoWidthPopper };
|
|
22
|
-
//# sourceMappingURL=AutoWidthPopper.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AutoWidthPopper.esm.js","sources":["../../../../src/components/Nodes/common/AutoWidthPopper.tsx"],"sourcesContent":["import Popper from \"@material-ui/core/Popper\";\nimport type { PopperProps } from \"@material-ui/core/Popper\";\n\n// Popper that allows Autocomplete dropdowns to expand beyond the input width while\n// keeping a minimum width equal to the anchor element.\nexport const AutoWidthPopper = (props: PopperProps) => {\n const { style, anchorEl, ...restProps } = props;\n\n const anchorWidth =\n anchorEl && \"clientWidth\" in anchorEl\n ? (anchorEl as HTMLElement).clientWidth\n : undefined;\n\n return (\n <Popper\n {...restProps}\n anchorEl={anchorEl}\n style={{\n ...style,\n width: \"auto\",\n minWidth: anchorWidth ?? style?.minWidth,\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;AAKO,MAAM,eAAA,GAAkB,CAAC,KAAA,KAAuB;AACrD,EAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAU,GAAG,WAAU,GAAI,KAAA;AAE1C,EAAA,MAAM,WAAA,GACJ,QAAA,IAAY,aAAA,IAAiB,QAAA,GACxB,SAAyB,WAAA,GAC1B,MAAA;AAEN,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACE,GAAG,SAAA;AAAA,MACJ,QAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACL,GAAG,KAAA;AAAA,QACH,KAAA,EAAO,MAAA;AAAA,QACP,QAAA,EAAU,eAAe,KAAA,EAAO;AAAA;AAClC;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const createStopNodeInteraction = () => ({
|
|
2
|
-
onPointerDown: (event) => event.stopPropagation(),
|
|
3
|
-
onKeyDown: (event) => event.stopPropagation(),
|
|
4
|
-
className: "nodrag nowheel",
|
|
5
|
-
inputProps: { "data-nodrag": true }
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export { createStopNodeInteraction };
|
|
9
|
-
//# sourceMappingURL=nodeInteraction.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeInteraction.esm.js","sources":["../../../../src/components/Nodes/common/nodeInteraction.ts"],"sourcesContent":["import type { KeyboardEvent, SyntheticEvent } from \"react\";\n\nexport type StopNodeInteraction = {\n onPointerDown: (event: SyntheticEvent) => void;\n onKeyDown: (event: KeyboardEvent) => void;\n className: string;\n inputProps: { [key: string]: unknown };\n};\n\nexport const createStopNodeInteraction = (): StopNodeInteraction => ({\n onPointerDown: (event: SyntheticEvent) => event.stopPropagation(),\n onKeyDown: (event: KeyboardEvent) => event.stopPropagation(),\n className: \"nodrag nowheel\",\n inputProps: { \"data-nodrag\": true },\n});\n"],"names":[],"mappings":"AASO,MAAM,4BAA4B,OAA4B;AAAA,EACnE,aAAA,EAAe,CAAC,KAAA,KAA0B,KAAA,CAAM,eAAA,EAAgB;AAAA,EAChE,SAAA,EAAW,CAAC,KAAA,KAAyB,KAAA,CAAM,eAAA,EAAgB;AAAA,EAC3D,SAAA,EAAW,gBAAA;AAAA,EACX,UAAA,EAAY,EAAE,aAAA,EAAe,IAAA;AAC/B,CAAA;;;;"}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
const BUILTIN_KEYS = /* @__PURE__ */ new Set(["links", "text"]);
|
|
4
|
-
const useOutputController = (data) => {
|
|
5
|
-
const { rfId, output } = data;
|
|
6
|
-
const [newCustomKey, setNewCustomKey] = useState("");
|
|
7
|
-
const [newCustomValue, setNewCustomValue] = useState("");
|
|
8
|
-
const stepOutputReferences = useMemo(
|
|
9
|
-
() => data.stepOutputReferences ?? [],
|
|
10
|
-
[data.stepOutputReferences]
|
|
11
|
-
);
|
|
12
|
-
const referenceOptions = useMemo(
|
|
13
|
-
() => Array.from(new Set(stepOutputReferences.filter(Boolean))),
|
|
14
|
-
[stepOutputReferences]
|
|
15
|
-
);
|
|
16
|
-
const links = useMemo(
|
|
17
|
-
() => Array.isArray(output?.links) ? [...output.links] : [],
|
|
18
|
-
[output?.links]
|
|
19
|
-
);
|
|
20
|
-
const textEntries = useMemo(
|
|
21
|
-
() => Array.isArray(output?.text) ? [...output.text] : [],
|
|
22
|
-
[output?.text]
|
|
23
|
-
);
|
|
24
|
-
const customEntries = useMemo(() => {
|
|
25
|
-
if (!output || typeof output !== "object") {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
return Object.entries(output).filter(([key]) => !BUILTIN_KEYS.has(key));
|
|
29
|
-
}, [output]);
|
|
30
|
-
const updateOutput = useCallback(
|
|
31
|
-
(updater) => {
|
|
32
|
-
data.onUpdateOutput?.(rfId, updater);
|
|
33
|
-
},
|
|
34
|
-
[data, rfId]
|
|
35
|
-
);
|
|
36
|
-
const handleCustomValueChange = useCallback(
|
|
37
|
-
(key) => (event) => {
|
|
38
|
-
const raw = event.target.value;
|
|
39
|
-
updateOutput((prev) => ({
|
|
40
|
-
...prev ?? {},
|
|
41
|
-
[key]: raw
|
|
42
|
-
}));
|
|
43
|
-
},
|
|
44
|
-
[updateOutput]
|
|
45
|
-
);
|
|
46
|
-
const handleRemoveCustom = useCallback(
|
|
47
|
-
(key) => {
|
|
48
|
-
updateOutput((prev) => {
|
|
49
|
-
const next = { ...prev ?? {} };
|
|
50
|
-
delete next[key];
|
|
51
|
-
return next;
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
[updateOutput]
|
|
55
|
-
);
|
|
56
|
-
const handleAddCustom = useCallback(() => {
|
|
57
|
-
const trimmedKey = newCustomKey.trim();
|
|
58
|
-
if (!trimmedKey || BUILTIN_KEYS.has(trimmedKey)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
updateOutput((prev) => {
|
|
62
|
-
if (prev && Object.prototype.hasOwnProperty.call(prev, trimmedKey)) {
|
|
63
|
-
return prev;
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
...prev ?? {},
|
|
67
|
-
[trimmedKey]: newCustomValue
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
setNewCustomKey("");
|
|
71
|
-
setNewCustomValue("");
|
|
72
|
-
}, [newCustomKey, newCustomValue, updateOutput]);
|
|
73
|
-
const setLinkFieldValue = useCallback(
|
|
74
|
-
(index, field, value) => {
|
|
75
|
-
const normalized = value ?? "";
|
|
76
|
-
updateOutput((prev) => {
|
|
77
|
-
const currentLinks = Array.isArray(prev?.links) ? [...prev.links] : [];
|
|
78
|
-
const target = { ...currentLinks[index] ?? {} };
|
|
79
|
-
target[field] = normalized;
|
|
80
|
-
currentLinks[index] = target;
|
|
81
|
-
return { ...prev ?? {}, links: currentLinks };
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
[updateOutput]
|
|
85
|
-
);
|
|
86
|
-
const handleLinkChange = useCallback(
|
|
87
|
-
(index, field) => (event) => {
|
|
88
|
-
setLinkFieldValue(index, field, event.target.value);
|
|
89
|
-
},
|
|
90
|
-
[setLinkFieldValue]
|
|
91
|
-
);
|
|
92
|
-
const handleRemoveLink = useCallback(
|
|
93
|
-
(index) => {
|
|
94
|
-
updateOutput((prev) => {
|
|
95
|
-
const currentLinks = Array.isArray(prev?.links) ? [...prev.links] : [];
|
|
96
|
-
currentLinks.splice(index, 1);
|
|
97
|
-
if (!currentLinks.length) {
|
|
98
|
-
const { links: _omit, ...rest } = prev ?? {};
|
|
99
|
-
return rest;
|
|
100
|
-
}
|
|
101
|
-
return { ...prev ?? {}, links: currentLinks };
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
[updateOutput]
|
|
105
|
-
);
|
|
106
|
-
const handleAddLink = useCallback(() => {
|
|
107
|
-
updateOutput((prev) => {
|
|
108
|
-
const currentLinks = Array.isArray(prev?.links) ? [...prev.links] : [];
|
|
109
|
-
currentLinks.push({ title: "", url: "" });
|
|
110
|
-
return { ...prev ?? {}, links: currentLinks };
|
|
111
|
-
});
|
|
112
|
-
}, [updateOutput]);
|
|
113
|
-
const setTextFieldValue = useCallback(
|
|
114
|
-
(index, field, value) => {
|
|
115
|
-
const normalized = value ?? "";
|
|
116
|
-
updateOutput((prev) => {
|
|
117
|
-
const currentText = Array.isArray(prev?.text) ? [...prev.text] : [];
|
|
118
|
-
const target = { ...currentText[index] ?? {} };
|
|
119
|
-
target[field] = normalized;
|
|
120
|
-
currentText[index] = target;
|
|
121
|
-
return { ...prev ?? {}, text: currentText };
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
[updateOutput]
|
|
125
|
-
);
|
|
126
|
-
const handleTextChange = useCallback(
|
|
127
|
-
(index, field) => (event) => {
|
|
128
|
-
setTextFieldValue(index, field, event.target.value);
|
|
129
|
-
},
|
|
130
|
-
[setTextFieldValue]
|
|
131
|
-
);
|
|
132
|
-
const handleTextDefaultToggle = useCallback(
|
|
133
|
-
(index) => {
|
|
134
|
-
updateOutput((prev) => {
|
|
135
|
-
const currentText = Array.isArray(prev?.text) ? [...prev.text] : [];
|
|
136
|
-
const target = { ...currentText[index] ?? {} };
|
|
137
|
-
target.default = !target.default;
|
|
138
|
-
currentText[index] = target;
|
|
139
|
-
return { ...prev ?? {}, text: currentText };
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
[updateOutput]
|
|
143
|
-
);
|
|
144
|
-
const handleRemoveText = useCallback(
|
|
145
|
-
(index) => {
|
|
146
|
-
updateOutput((prev) => {
|
|
147
|
-
const currentText = Array.isArray(prev?.text) ? [...prev.text] : [];
|
|
148
|
-
currentText.splice(index, 1);
|
|
149
|
-
if (!currentText.length) {
|
|
150
|
-
const { text: _omit, ...rest } = prev ?? {};
|
|
151
|
-
return rest;
|
|
152
|
-
}
|
|
153
|
-
return { ...prev ?? {}, text: currentText };
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
[updateOutput]
|
|
157
|
-
);
|
|
158
|
-
const handleAddText = useCallback(() => {
|
|
159
|
-
updateOutput((prev) => {
|
|
160
|
-
const currentText = Array.isArray(prev?.text) ? [...prev.text] : [];
|
|
161
|
-
currentText.push({ title: "", content: "" });
|
|
162
|
-
return { ...prev ?? {}, text: currentText };
|
|
163
|
-
});
|
|
164
|
-
}, [updateOutput]);
|
|
165
|
-
return {
|
|
166
|
-
stepOutputReferences,
|
|
167
|
-
referenceOptions,
|
|
168
|
-
links,
|
|
169
|
-
textEntries,
|
|
170
|
-
customEntries,
|
|
171
|
-
newCustomKey,
|
|
172
|
-
setNewCustomKey,
|
|
173
|
-
newCustomValue,
|
|
174
|
-
setNewCustomValue,
|
|
175
|
-
handleAddCustom,
|
|
176
|
-
handleCustomValueChange,
|
|
177
|
-
handleRemoveCustom,
|
|
178
|
-
setLinkFieldValue,
|
|
179
|
-
handleLinkChange,
|
|
180
|
-
handleAddLink,
|
|
181
|
-
handleRemoveLink,
|
|
182
|
-
setTextFieldValue,
|
|
183
|
-
handleTextChange,
|
|
184
|
-
handleTextDefaultToggle,
|
|
185
|
-
handleAddText,
|
|
186
|
-
handleRemoveText
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export { useOutputController };
|
|
191
|
-
//# sourceMappingURL=useOutputController.esm.js.map
|