@judo/components 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +277 -0
- package/README.md +200 -0
- package/dist/FlexRenderer-0KCxU9QU.js +1612 -0
- package/dist/FlexRenderer-0KCxU9QU.js.map +1 -0
- package/dist/FormContainerRenderer-B8H4kyz0.js +67 -0
- package/dist/FormContainerRenderer-B8H4kyz0.js.map +1 -0
- package/dist/FormContainerRenderer-CtuXP8jP.js +3 -0
- package/dist/TableContainerRenderer-gKBlsD4S.js +127 -0
- package/dist/TableContainerRenderer-gKBlsD4S.js.map +1 -0
- package/dist/TableContainerRenderer-qbzKI1Cd.js +2 -0
- package/dist/ViewContainerRenderer-7Cx4fcLp.js +3 -0
- package/dist/ViewContainerRenderer-DCRaE_dq.js +132 -0
- package/dist/ViewContainerRenderer-DCRaE_dq.js.map +1 -0
- package/dist/containers/FormContainerRenderer.d.ts +11 -0
- package/dist/containers/FormContainerRenderer.d.ts.map +1 -0
- package/dist/containers/PageRenderer.d.ts +9 -0
- package/dist/containers/PageRenderer.d.ts.map +1 -0
- package/dist/containers/TableContainerRenderer.d.ts +11 -0
- package/dist/containers/TableContainerRenderer.d.ts.map +1 -0
- package/dist/containers/ViewContainerRenderer.d.ts +12 -0
- package/dist/containers/ViewContainerRenderer.d.ts.map +1 -0
- package/dist/dialogs/LinkSelectorDialog.d.ts +21 -0
- package/dist/dialogs/LinkSelectorDialog.d.ts.map +1 -0
- package/dist/errors/ContainerErrorBoundary.d.ts +42 -0
- package/dist/errors/ContainerErrorBoundary.d.ts.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/find-on-init-action-C5CqxQaH.js +7727 -0
- package/dist/find-on-init-action-C5CqxQaH.js.map +1 -0
- package/dist/hooks/use-file-handling.d.ts +79 -0
- package/dist/hooks/use-file-handling.d.ts.map +1 -0
- package/dist/hooks/use-page-title.d.ts +23 -0
- package/dist/hooks/use-page-title.d.ts.map +1 -0
- package/dist/hooks/use-table-data.d.ts +77 -0
- package/dist/hooks/use-table-data.d.ts.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +296 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs/BinaryInputComponent.d.ts +15 -0
- package/dist/inputs/BinaryInputComponent.d.ts.map +1 -0
- package/dist/inputs/CheckboxComponent.d.ts +14 -0
- package/dist/inputs/CheckboxComponent.d.ts.map +1 -0
- package/dist/inputs/DateInputComponent.d.ts +14 -0
- package/dist/inputs/DateInputComponent.d.ts.map +1 -0
- package/dist/inputs/DateTimeInputComponent.d.ts +14 -0
- package/dist/inputs/DateTimeInputComponent.d.ts.map +1 -0
- package/dist/inputs/EnumerationComboComponent.d.ts +20 -0
- package/dist/inputs/EnumerationComboComponent.d.ts.map +1 -0
- package/dist/inputs/EnumerationRadioComponent.d.ts +22 -0
- package/dist/inputs/EnumerationRadioComponent.d.ts.map +1 -0
- package/dist/inputs/EnumerationToggleButtonbarComponent.d.ts +23 -0
- package/dist/inputs/EnumerationToggleButtonbarComponent.d.ts.map +1 -0
- package/dist/inputs/InputRenderer.d.ts +11 -0
- package/dist/inputs/InputRenderer.d.ts.map +1 -0
- package/dist/inputs/NumericInputComponent.d.ts +14 -0
- package/dist/inputs/NumericInputComponent.d.ts.map +1 -0
- package/dist/inputs/PasswordInputComponent.d.ts +14 -0
- package/dist/inputs/PasswordInputComponent.d.ts.map +1 -0
- package/dist/inputs/SwitchComponent.d.ts +14 -0
- package/dist/inputs/SwitchComponent.d.ts.map +1 -0
- package/dist/inputs/TextAreaComponent.d.ts +14 -0
- package/dist/inputs/TextAreaComponent.d.ts.map +1 -0
- package/dist/inputs/TextInputComponent.d.ts +19 -0
- package/dist/inputs/TextInputComponent.d.ts.map +1 -0
- package/dist/inputs/TimeInputComponent.d.ts +14 -0
- package/dist/inputs/TimeInputComponent.d.ts.map +1 -0
- package/dist/renderers/ButtonGroupRenderer.d.ts +10 -0
- package/dist/renderers/ButtonGroupRenderer.d.ts.map +1 -0
- package/dist/renderers/FlexRenderer.d.ts +13 -0
- package/dist/renderers/FlexRenderer.d.ts.map +1 -0
- package/dist/renderers/FormattedRenderer.d.ts +12 -0
- package/dist/renderers/FormattedRenderer.d.ts.map +1 -0
- package/dist/renderers/FrameRenderer.d.ts +17 -0
- package/dist/renderers/FrameRenderer.d.ts.map +1 -0
- package/dist/renderers/IconRenderer.d.ts +41 -0
- package/dist/renderers/IconRenderer.d.ts.map +1 -0
- package/dist/renderers/InlineButtonGroupRenderer.d.ts +22 -0
- package/dist/renderers/InlineButtonGroupRenderer.d.ts.map +1 -0
- package/dist/renderers/LinkRenderer.d.ts +17 -0
- package/dist/renderers/LinkRenderer.d.ts.map +1 -0
- package/dist/renderers/PageHeader.d.ts +13 -0
- package/dist/renderers/PageHeader.d.ts.map +1 -0
- package/dist/renderers/RowActionCell.d.ts +28 -0
- package/dist/renderers/RowActionCell.d.ts.map +1 -0
- package/dist/renderers/StandaloneButtonRenderer.d.ts +16 -0
- package/dist/renderers/StandaloneButtonRenderer.d.ts.map +1 -0
- package/dist/renderers/SubThemeWrapper.d.ts +22 -0
- package/dist/renderers/SubThemeWrapper.d.ts.map +1 -0
- package/dist/renderers/TabControllerRenderer.d.ts +10 -0
- package/dist/renderers/TabControllerRenderer.d.ts.map +1 -0
- package/dist/renderers/TableRenderer.d.ts +10 -0
- package/dist/renderers/TableRenderer.d.ts.map +1 -0
- package/dist/renderers/TableToolbar.d.ts +47 -0
- package/dist/renderers/TableToolbar.d.ts.map +1 -0
- package/dist/renderers/VisualElementRenderer.d.ts +17 -0
- package/dist/renderers/VisualElementRenderer.d.ts.map +1 -0
- package/dist/utils/alignment-mappers.d.ts +17 -0
- package/dist/utils/alignment-mappers.d.ts.map +1 -0
- package/dist/utils/build-mask-string.d.ts +31 -0
- package/dist/utils/build-mask-string.d.ts.map +1 -0
- package/dist/utils/build-query-customizer.d.ts +35 -0
- package/dist/utils/build-query-customizer.d.ts.map +1 -0
- package/dist/utils/destructive-action-utils.d.ts +17 -0
- package/dist/utils/destructive-action-utils.d.ts.map +1 -0
- package/dist/utils/find-action-by-definition.d.ts +26 -0
- package/dist/utils/find-action-by-definition.d.ts.map +1 -0
- package/dist/utils/find-on-init-action.d.ts +12 -0
- package/dist/utils/find-on-init-action.d.ts.map +1 -0
- package/dist/utils/find-visual-element.d.ts +18 -0
- package/dist/utils/find-visual-element.d.ts.map +1 -0
- package/dist/utils/flex-layout.d.ts +104 -0
- package/dist/utils/flex-layout.d.ts.map +1 -0
- package/dist/utils/get-visible-buttons.d.ts +33 -0
- package/dist/utils/get-visible-buttons.d.ts.map +1 -0
- package/dist/utils/icon-adornment.d.ts +13 -0
- package/dist/utils/icon-adornment.d.ts.map +1 -0
- package/dist/utils/mdi-alias-map.d.ts +44 -0
- package/dist/utils/mdi-alias-map.d.ts.map +1 -0
- package/dist/utils/mdi-alias-map.generated.d.ts +10 -0
- package/dist/utils/mdi-alias-map.generated.d.ts.map +1 -0
- package/dist/utils/resolve-container-type.d.ts +11 -0
- package/dist/utils/resolve-container-type.d.ts.map +1 -0
- package/dist/utils/singleton-access.d.ts +25 -0
- package/dist/utils/singleton-access.d.ts.map +1 -0
- package/dist/utils/table-column-utils.d.ts +75 -0
- package/dist/utils/table-column-utils.d.ts.map +1 -0
- package/dist/utils/table-filter-utils.d.ts +14 -0
- package/dist/utils/table-filter-utils.d.ts.map +1 -0
- package/dist/utils/table-sort-utils.d.ts +24 -0
- package/dist/utils/table-sort-utils.d.ts.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,1612 @@
|
|
|
1
|
+
import { d as findActionByDefinition, f as getDestructiveConfirmationOptions, l as IconRenderer, n as TableRenderer, p as isDestructiveAction, u as getVisibleButtons } from "./find-on-init-action-C5CqxQaH.js";
|
|
2
|
+
import { Autocomplete, Box, Button, ButtonGroup, Checkbox, CircularProgress, ClickAwayListener, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormControlLabel, FormHelperText, FormLabel, Grow, IconButton, InputAdornment, InputLabel, ListItemIcon, ListItemText, Menu, MenuItem, MenuList, Paper, Popper, Radio, RadioGroup, Select, Switch, Tab, Tabs, TextField, ToggleButton, ToggleButtonGroup, Tooltip, Typography } from "@mui/material";
|
|
3
|
+
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Alignment, Axis, CrossAxisAlignment, MainAxisAlignment } from "@judo/model-api";
|
|
6
|
+
import { getActionHandler, useActionDispatcher, useApi } from "@judo/actions";
|
|
7
|
+
import { useApplication, useComponentInterceptor, useComponentOverride, useDataSelector, useDataStore, useDateValidationProps, useDebouncedCallback, useDispatchOptional, useEditMode, useElementDisabled, useElementVisibility, useEnumOptionFilter, useMuiProOptional, useNavigation, usePageContextOptional, useResolvedPageActionOverrides, useRuntimeConfigOptional, useSubThemeProvider, useTypeaheadProvider, useVisualBinding } from "@judo/core";
|
|
8
|
+
import { useConfirmation, useNotifications } from "@judo/feedback";
|
|
9
|
+
import { useModelLabel } from "@judo/i18n";
|
|
10
|
+
import { getButtonGroupTestId, getButtonTestId, getInputTestId, getLinkTestId, getTabControllerTestId, getTabListTestId, getTabPanelTestId, getTabTestId } from "@judo/test-ids";
|
|
11
|
+
import { DataGrid } from "@mui/x-data-grid";
|
|
12
|
+
import Grid$1 from "@mui/material/Grid";
|
|
13
|
+
import Stack$1 from "@mui/material/Stack";
|
|
14
|
+
import DeleteIcon from "@mui/icons-material/Delete";
|
|
15
|
+
import UploadIcon from "@mui/icons-material/Upload";
|
|
16
|
+
import InputAdornment$1 from "@mui/material/InputAdornment";
|
|
17
|
+
import { format, parseISO } from "date-fns";
|
|
18
|
+
import VisibilityIcon from "@mui/icons-material/Visibility";
|
|
19
|
+
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
|
|
20
|
+
import Typography$1 from "@mui/material/Typography";
|
|
21
|
+
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
22
|
+
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
23
|
+
import { ThemeProvider, createTheme } from "@mui/material/styles";
|
|
24
|
+
function mapMainAxisAlignment(e) {
|
|
25
|
+
switch (e) {
|
|
26
|
+
case MainAxisAlignment.START: return "flex-start";
|
|
27
|
+
case MainAxisAlignment.END: return "flex-end";
|
|
28
|
+
case MainAxisAlignment.CENTER: return "center";
|
|
29
|
+
case MainAxisAlignment.SPACEBETWEEN: return "space-between";
|
|
30
|
+
case MainAxisAlignment.SPACEAROUND: return "space-around";
|
|
31
|
+
case MainAxisAlignment.SPACEEVENLY: return "space-evenly";
|
|
32
|
+
default: return "flex-start";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function mapCrossAxisAlignment(e) {
|
|
36
|
+
switch (e) {
|
|
37
|
+
case CrossAxisAlignment.START: return "flex-start";
|
|
38
|
+
case CrossAxisAlignment.END: return "flex-end";
|
|
39
|
+
case CrossAxisAlignment.CENTER: return "center";
|
|
40
|
+
case CrossAxisAlignment.STRETCH: return "stretch";
|
|
41
|
+
case CrossAxisAlignment.BASELINE: return "baseline";
|
|
42
|
+
default: return "stretch";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function mapAlignment(e) {
|
|
46
|
+
switch (e) {
|
|
47
|
+
case Alignment.TOP_LEFT: return {
|
|
48
|
+
justifyContent: "flex-start",
|
|
49
|
+
alignItems: "flex-start"
|
|
50
|
+
};
|
|
51
|
+
case Alignment.TOP_CENTER: return {
|
|
52
|
+
justifyContent: "center",
|
|
53
|
+
alignItems: "flex-start"
|
|
54
|
+
};
|
|
55
|
+
case Alignment.TOP_RIGHT: return {
|
|
56
|
+
justifyContent: "flex-end",
|
|
57
|
+
alignItems: "flex-start"
|
|
58
|
+
};
|
|
59
|
+
case Alignment.CENTER_LEFT: return {
|
|
60
|
+
justifyContent: "flex-start",
|
|
61
|
+
alignItems: "center"
|
|
62
|
+
};
|
|
63
|
+
case Alignment.CENTER: return {
|
|
64
|
+
justifyContent: "center",
|
|
65
|
+
alignItems: "center"
|
|
66
|
+
};
|
|
67
|
+
case Alignment.CENTER_RIGHT: return {
|
|
68
|
+
justifyContent: "flex-end",
|
|
69
|
+
alignItems: "center"
|
|
70
|
+
};
|
|
71
|
+
case Alignment.BOTTOM_LEFT: return {
|
|
72
|
+
justifyContent: "flex-start",
|
|
73
|
+
alignItems: "flex-end"
|
|
74
|
+
};
|
|
75
|
+
case Alignment.BOTTOM_CENTER: return {
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
alignItems: "flex-end"
|
|
78
|
+
};
|
|
79
|
+
case Alignment.BOTTOM_RIGHT: return {
|
|
80
|
+
justifyContent: "flex-end",
|
|
81
|
+
alignItems: "flex-end"
|
|
82
|
+
};
|
|
83
|
+
default: return {
|
|
84
|
+
justifyContent: "flex-start",
|
|
85
|
+
alignItems: "flex-start"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const DEFAULT_COL = 4, FULL_GRID_WIDTH = 12;
|
|
90
|
+
function calculateScaledSize(e, t) {
|
|
91
|
+
return e === 12 ? t : 12 / e * t;
|
|
92
|
+
}
|
|
93
|
+
function calculateHorizontalGridSize(e, t) {
|
|
94
|
+
let n = calculateScaledSize(e, t);
|
|
95
|
+
return n === 12 ? {
|
|
96
|
+
xs: 12,
|
|
97
|
+
sm: 12
|
|
98
|
+
} : {
|
|
99
|
+
xs: 12,
|
|
100
|
+
sm: 12,
|
|
101
|
+
md: n
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function calculateVerticalGridSize() {
|
|
105
|
+
return {
|
|
106
|
+
xs: 12,
|
|
107
|
+
sm: 12
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function isVerticalLayout(e) {
|
|
111
|
+
return e === Axis.VERTICAL;
|
|
112
|
+
}
|
|
113
|
+
function calculateChildGridSize(e, t, n) {
|
|
114
|
+
return isVerticalLayout(e) ? calculateVerticalGridSize() : calculateHorizontalGridSize(t, n);
|
|
115
|
+
}
|
|
116
|
+
function FrameRenderer({ frame: e, children: t, label: r, icon: i }) {
|
|
117
|
+
let a = r || i;
|
|
118
|
+
return /* @__PURE__ */ jsxs(Paper, {
|
|
119
|
+
sx: {
|
|
120
|
+
p: 2,
|
|
121
|
+
animation: "judoFadeInUp 0.35s cubic-bezier(0.4,0,0.2,1) both",
|
|
122
|
+
"&:hover": {
|
|
123
|
+
borderColor: "rgba(0, 0, 0, 0.15)",
|
|
124
|
+
boxShadow: (e) => e.palette.mode === "light" ? "0 4px 20px rgba(0,0,0,0.06)" : "0 4px 20px rgba(0,0,0,0.3)",
|
|
125
|
+
transform: "translateY(-1px)"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"data-testid": `frame::${e["xmi:id"]}`,
|
|
129
|
+
children: [a && /* @__PURE__ */ jsxs(Box, {
|
|
130
|
+
sx: {
|
|
131
|
+
display: "flex",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
gap: 1,
|
|
134
|
+
mb: 2,
|
|
135
|
+
pl: 1.5,
|
|
136
|
+
borderLeft: 3,
|
|
137
|
+
borderColor: "primary.main"
|
|
138
|
+
},
|
|
139
|
+
"data-testid": `frame::${e["xmi:id"]}::header`,
|
|
140
|
+
children: [i && /* @__PURE__ */ jsx(IconRenderer, { icon: i }), r && /* @__PURE__ */ jsx(Typography, {
|
|
141
|
+
variant: "h6",
|
|
142
|
+
component: "h3",
|
|
143
|
+
children: r
|
|
144
|
+
})]
|
|
145
|
+
}), t]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function BinaryInputComponent({ element: e, readOnly: t, value: n, onChange: r, error: i, disabled: a, fileName: o }) {
|
|
149
|
+
let l = getInputTestId(e), { label: u } = useModelLabel(e), [d, f] = useState(o ?? ""), p = (e) => {
|
|
150
|
+
let t = e.target.files?.[0];
|
|
151
|
+
if (t) {
|
|
152
|
+
f(t.name);
|
|
153
|
+
let e = new FileReader();
|
|
154
|
+
e.addEventListener("load", () => {
|
|
155
|
+
let t = e.result.split(",")[1];
|
|
156
|
+
r?.(t);
|
|
157
|
+
}), e.readAsDataURL(t);
|
|
158
|
+
}
|
|
159
|
+
}, m = () => {
|
|
160
|
+
f(""), r?.(null);
|
|
161
|
+
}, h = a ?? e.disabled, g = t ?? e.isReadOnly;
|
|
162
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
163
|
+
"data-testid": l,
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsxs(Typography, {
|
|
166
|
+
variant: "body2",
|
|
167
|
+
gutterBottom: !0,
|
|
168
|
+
children: [u, e.required && " *"]
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
171
|
+
display: "flex",
|
|
172
|
+
alignItems: "center",
|
|
173
|
+
gap: 1,
|
|
174
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
175
|
+
component: "label",
|
|
176
|
+
variant: "outlined",
|
|
177
|
+
startIcon: /* @__PURE__ */ jsx(UploadIcon, {}),
|
|
178
|
+
disabled: h || g,
|
|
179
|
+
children: ["Upload", /* @__PURE__ */ jsx("input", {
|
|
180
|
+
type: "file",
|
|
181
|
+
hidden: !0,
|
|
182
|
+
onChange: p,
|
|
183
|
+
"data-testid": `${l}::file-input`
|
|
184
|
+
})]
|
|
185
|
+
}), d && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Typography, {
|
|
186
|
+
variant: "body2",
|
|
187
|
+
sx: { flexGrow: 1 },
|
|
188
|
+
children: d
|
|
189
|
+
}), !g && /* @__PURE__ */ jsx(IconButton, {
|
|
190
|
+
onClick: m,
|
|
191
|
+
disabled: h,
|
|
192
|
+
size: "small",
|
|
193
|
+
"data-testid": `${l}::clear`,
|
|
194
|
+
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
195
|
+
})] })]
|
|
196
|
+
}),
|
|
197
|
+
i && /* @__PURE__ */ jsx(Typography, {
|
|
198
|
+
variant: "caption",
|
|
199
|
+
color: "error",
|
|
200
|
+
children: i
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function CheckboxComponent({ element: e, readOnly: t, value: n = !1, onChange: r, error: i, disabled: a }) {
|
|
206
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = `${s}${e.required ? " *" : ""}`;
|
|
207
|
+
return /* @__PURE__ */ jsxs(FormControl, {
|
|
208
|
+
error: !!i,
|
|
209
|
+
disabled: a ?? e.disabled,
|
|
210
|
+
required: e.required,
|
|
211
|
+
children: [/* @__PURE__ */ jsx(FormControlLabel, {
|
|
212
|
+
control: /* @__PURE__ */ jsx(Checkbox, {
|
|
213
|
+
checked: n,
|
|
214
|
+
onChange: (e) => r?.(e.target.checked),
|
|
215
|
+
disabled: t ?? e.isReadOnly,
|
|
216
|
+
"data-testid": o
|
|
217
|
+
}),
|
|
218
|
+
label: c
|
|
219
|
+
}), i && /* @__PURE__ */ jsx(FormHelperText, { children: i })]
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function buildIconAdornment(e) {
|
|
223
|
+
if (e?.iconName) return /* @__PURE__ */ jsx(InputAdornment$1, {
|
|
224
|
+
position: "start",
|
|
225
|
+
children: /* @__PURE__ */ jsx(IconRenderer, {
|
|
226
|
+
icon: e,
|
|
227
|
+
size: "small",
|
|
228
|
+
color: "action"
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function formatDateForInput(e) {
|
|
233
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
234
|
+
}
|
|
235
|
+
function parseDateInputValue(e) {
|
|
236
|
+
let [t, n, r] = e.split("-").map(Number);
|
|
237
|
+
return new Date(t, n - 1, r);
|
|
238
|
+
}
|
|
239
|
+
function toInputValue(e) {
|
|
240
|
+
return e == null ? "" : e instanceof Date ? formatDateForInput(e) : e;
|
|
241
|
+
}
|
|
242
|
+
function DateInputComponent({ element: e, readOnly: t, value: n, onChange: r, error: i, disabled: a }) {
|
|
243
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = useDateValidationProps(e["xmi:id"]), l = buildIconAdornment(e.icon), u, d;
|
|
244
|
+
if (c) {
|
|
245
|
+
let e = /* @__PURE__ */ new Date();
|
|
246
|
+
c.disablePast && (u = formatDateForInput(e)), c.minDate && (u = formatDateForInput(c.minDate)), c.disableFuture && (d = formatDateForInput(e)), c.maxDate && (d = formatDateForInput(c.maxDate));
|
|
247
|
+
}
|
|
248
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
249
|
+
type: "date",
|
|
250
|
+
label: s,
|
|
251
|
+
value: toInputValue(n),
|
|
252
|
+
onChange: (e) => {
|
|
253
|
+
let t = e.target.value;
|
|
254
|
+
r?.(t ? parseDateInputValue(t) : null);
|
|
255
|
+
},
|
|
256
|
+
error: !!i,
|
|
257
|
+
helperText: i,
|
|
258
|
+
disabled: a ?? e.disabled,
|
|
259
|
+
required: e.required,
|
|
260
|
+
fullWidth: !0,
|
|
261
|
+
"data-testid": o,
|
|
262
|
+
slotProps: {
|
|
263
|
+
input: {
|
|
264
|
+
readOnly: t ?? e.isReadOnly,
|
|
265
|
+
startAdornment: l,
|
|
266
|
+
...u !== void 0 || d !== void 0 ? { inputProps: {
|
|
267
|
+
...u !== void 0 && { min: u },
|
|
268
|
+
...d !== void 0 && { max: d }
|
|
269
|
+
} } : {}
|
|
270
|
+
},
|
|
271
|
+
inputLabel: { shrink: !0 }
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function toDateTimeLocalFormat(e) {
|
|
276
|
+
if (!e) return "";
|
|
277
|
+
try {
|
|
278
|
+
let t = parseISO(e);
|
|
279
|
+
return Number.isNaN(t.getTime()) ? "" : format(t, "yyyy-MM-dd'T'HH:mm");
|
|
280
|
+
} catch {
|
|
281
|
+
return "";
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function formatDateTimeForInput(e) {
|
|
285
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}T${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}`;
|
|
286
|
+
}
|
|
287
|
+
function DateTimeInputComponent({ element: e, readOnly: t, value: n, onChange: r, error: i, disabled: a }) {
|
|
288
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = useDateValidationProps(e["xmi:id"]), l = buildIconAdornment(e.icon), u = n instanceof Date ? formatDateTimeForInput(n) : toDateTimeLocalFormat(n), d, f;
|
|
289
|
+
if (c) {
|
|
290
|
+
let e = /* @__PURE__ */ new Date();
|
|
291
|
+
c.disablePast && (d = formatDateTimeForInput(e)), c.minDate && (d = formatDateTimeForInput(c.minDate)), c.disableFuture && (f = formatDateTimeForInput(e)), c.maxDate && (f = formatDateTimeForInput(c.maxDate));
|
|
292
|
+
}
|
|
293
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
294
|
+
type: "datetime-local",
|
|
295
|
+
label: s,
|
|
296
|
+
value: u,
|
|
297
|
+
onChange: (e) => {
|
|
298
|
+
let t = e.target.value;
|
|
299
|
+
if (!t) r?.(null);
|
|
300
|
+
else {
|
|
301
|
+
let e = parseISO(t);
|
|
302
|
+
r?.(Number.isNaN(e.getTime()) ? null : e);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
error: !!i,
|
|
306
|
+
helperText: i,
|
|
307
|
+
disabled: a ?? e.disabled,
|
|
308
|
+
required: e.required,
|
|
309
|
+
fullWidth: !0,
|
|
310
|
+
"data-testid": o,
|
|
311
|
+
slotProps: {
|
|
312
|
+
input: {
|
|
313
|
+
readOnly: t ?? e.isReadOnly,
|
|
314
|
+
startAdornment: l,
|
|
315
|
+
...d !== void 0 || f !== void 0 ? { inputProps: {
|
|
316
|
+
...d !== void 0 && { min: d },
|
|
317
|
+
...f !== void 0 && { max: f }
|
|
318
|
+
} } : {}
|
|
319
|
+
},
|
|
320
|
+
inputLabel: { shrink: !0 }
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function EnumerationComboComponent({ element: e, readOnly: t, value: n = "", onChange: r, error: i, disabled: a, options: o = [], nullable: s = !1 }) {
|
|
325
|
+
let c = getInputTestId(e), { label: l } = useModelLabel(e), u = `${c}-label`;
|
|
326
|
+
return /* @__PURE__ */ jsxs(FormControl, {
|
|
327
|
+
fullWidth: !0,
|
|
328
|
+
error: !!i,
|
|
329
|
+
disabled: a ?? e.disabled,
|
|
330
|
+
required: e.required,
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ jsx(InputLabel, {
|
|
333
|
+
id: u,
|
|
334
|
+
shrink: !0,
|
|
335
|
+
children: l
|
|
336
|
+
}),
|
|
337
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
338
|
+
labelId: u,
|
|
339
|
+
value: n,
|
|
340
|
+
onChange: (e) => r?.(e.target.value),
|
|
341
|
+
label: l,
|
|
342
|
+
readOnly: t ?? e.isReadOnly,
|
|
343
|
+
"data-testid": c,
|
|
344
|
+
displayEmpty: s,
|
|
345
|
+
children: [s && /* @__PURE__ */ jsx(MenuItem, {
|
|
346
|
+
value: "",
|
|
347
|
+
children: /* @__PURE__ */ jsx("em", { children: "—" })
|
|
348
|
+
}), o.map((e) => /* @__PURE__ */ jsx(MenuItem, {
|
|
349
|
+
value: e.value,
|
|
350
|
+
children: e.label
|
|
351
|
+
}, e.value))]
|
|
352
|
+
}),
|
|
353
|
+
i && /* @__PURE__ */ jsx(FormHelperText, { children: i })
|
|
354
|
+
]
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
function EnumerationRadioComponent({ element: e, readOnly: t, value: n = "", onChange: r, error: i, disabled: a, options: o = [], orientation: s = "vertical", nullable: c = !1 }) {
|
|
358
|
+
let l = getInputTestId(e), { label: u } = useModelLabel(e), d = (e) => {
|
|
359
|
+
c && n === e ? r?.("") : r?.(e);
|
|
360
|
+
};
|
|
361
|
+
return /* @__PURE__ */ jsxs(FormControl, {
|
|
362
|
+
error: !!i,
|
|
363
|
+
disabled: a ?? e.disabled,
|
|
364
|
+
required: e.required,
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ jsx(FormLabel, { children: u }),
|
|
367
|
+
/* @__PURE__ */ jsx(RadioGroup, {
|
|
368
|
+
value: n,
|
|
369
|
+
row: s === "horizontal",
|
|
370
|
+
"data-testid": l,
|
|
371
|
+
children: o.map((n) => /* @__PURE__ */ jsx(FormControlLabel, {
|
|
372
|
+
value: n.value,
|
|
373
|
+
control: /* @__PURE__ */ jsx(Radio, {
|
|
374
|
+
disabled: t ?? e.isReadOnly,
|
|
375
|
+
onClick: () => d(n.value)
|
|
376
|
+
}),
|
|
377
|
+
label: n.label
|
|
378
|
+
}, n.value))
|
|
379
|
+
}),
|
|
380
|
+
i && /* @__PURE__ */ jsx(FormHelperText, { children: i })
|
|
381
|
+
]
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function EnumerationToggleButtonbarComponent({ element: e, readOnly: t, value: n = "", onChange: r, error: i, disabled: a, options: o = [], orientation: s = "horizontal", nullable: c = !1 }) {
|
|
385
|
+
let l = getInputTestId(e), { label: u } = useModelLabel(e), d = a ?? e.disabled, f = t ?? e.isReadOnly;
|
|
386
|
+
return /* @__PURE__ */ jsxs(FormControl, {
|
|
387
|
+
error: !!i,
|
|
388
|
+
disabled: d,
|
|
389
|
+
required: e.required,
|
|
390
|
+
children: [
|
|
391
|
+
/* @__PURE__ */ jsx(InputLabel, {
|
|
392
|
+
shrink: !0,
|
|
393
|
+
children: u
|
|
394
|
+
}),
|
|
395
|
+
/* @__PURE__ */ jsx(ToggleButtonGroup, {
|
|
396
|
+
value: n || null,
|
|
397
|
+
exclusive: !0,
|
|
398
|
+
onChange: (e, t) => {
|
|
399
|
+
f || (t === null ? c && r?.("") : r?.(t));
|
|
400
|
+
},
|
|
401
|
+
orientation: s,
|
|
402
|
+
"data-testid": l,
|
|
403
|
+
disabled: d || f,
|
|
404
|
+
sx: { mt: 1.25 },
|
|
405
|
+
children: o.map((e) => /* @__PURE__ */ jsx(ToggleButton, {
|
|
406
|
+
value: e.value,
|
|
407
|
+
children: e.label
|
|
408
|
+
}, e.value))
|
|
409
|
+
}),
|
|
410
|
+
i && /* @__PURE__ */ jsx(FormHelperText, { children: i })
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function NumericInputComponent({ element: e, readOnly: t, value: n, onChange: r, error: i, disabled: a }) {
|
|
415
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = e, l = buildIconAdornment(e.icon);
|
|
416
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
417
|
+
type: "number",
|
|
418
|
+
label: s,
|
|
419
|
+
value: n ?? "",
|
|
420
|
+
onChange: (e) => {
|
|
421
|
+
let t = e.target.value;
|
|
422
|
+
if (t === "") r?.(null);
|
|
423
|
+
else {
|
|
424
|
+
let e = Number.parseFloat(t);
|
|
425
|
+
Number.isNaN(e) || r?.(e);
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
error: !!i,
|
|
429
|
+
helperText: i,
|
|
430
|
+
disabled: a ?? e.disabled,
|
|
431
|
+
required: e.required,
|
|
432
|
+
fullWidth: !0,
|
|
433
|
+
"data-testid": o,
|
|
434
|
+
slotProps: {
|
|
435
|
+
input: {
|
|
436
|
+
readOnly: t ?? e.isReadOnly,
|
|
437
|
+
startAdornment: l
|
|
438
|
+
},
|
|
439
|
+
htmlInput: { step: c.scale ? 10 ** -c.scale : void 0 },
|
|
440
|
+
inputLabel: { shrink: !0 }
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function PasswordInputComponent({ element: e, readOnly: t, value: n = "", onChange: r, error: i, disabled: a }) {
|
|
445
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), [c, l] = useState(!1), u = buildIconAdornment(e.icon);
|
|
446
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
447
|
+
type: c ? "text" : "password",
|
|
448
|
+
label: s,
|
|
449
|
+
value: n,
|
|
450
|
+
onChange: (e) => r?.(e.target.value),
|
|
451
|
+
error: !!i,
|
|
452
|
+
helperText: i,
|
|
453
|
+
disabled: a ?? e.disabled,
|
|
454
|
+
required: e.required,
|
|
455
|
+
fullWidth: !0,
|
|
456
|
+
"data-testid": o,
|
|
457
|
+
slotProps: {
|
|
458
|
+
input: {
|
|
459
|
+
readOnly: t ?? e.isReadOnly,
|
|
460
|
+
startAdornment: u,
|
|
461
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, {
|
|
462
|
+
position: "end",
|
|
463
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
464
|
+
onClick: () => l(!c),
|
|
465
|
+
edge: "end",
|
|
466
|
+
"data-testid": `${o}::toggle-visibility`,
|
|
467
|
+
children: jsx(c ? VisibilityOffIcon : VisibilityIcon, {})
|
|
468
|
+
})
|
|
469
|
+
})
|
|
470
|
+
},
|
|
471
|
+
inputLabel: { shrink: !0 }
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function SwitchComponent({ element: e, readOnly: t, value: n = !1, onChange: r, error: i, disabled: a }) {
|
|
476
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = `${s}${e.required ? " *" : ""}`;
|
|
477
|
+
return /* @__PURE__ */ jsxs(FormControl, {
|
|
478
|
+
error: !!i,
|
|
479
|
+
disabled: a ?? e.disabled,
|
|
480
|
+
required: e.required,
|
|
481
|
+
children: [/* @__PURE__ */ jsx(FormControlLabel, {
|
|
482
|
+
control: /* @__PURE__ */ jsx(Switch, {
|
|
483
|
+
checked: n,
|
|
484
|
+
onChange: (e) => r?.(e.target.checked),
|
|
485
|
+
disabled: t ?? e.isReadOnly,
|
|
486
|
+
"data-testid": o
|
|
487
|
+
}),
|
|
488
|
+
label: c
|
|
489
|
+
}), i && /* @__PURE__ */ jsx(FormHelperText, { children: i })]
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
function TextAreaComponent({ element: e, readOnly: t, value: n = "", onChange: r, error: i, disabled: a }) {
|
|
493
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = e, l = buildIconAdornment(e.icon);
|
|
494
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
495
|
+
multiline: !0,
|
|
496
|
+
minRows: c.lines,
|
|
497
|
+
maxRows: 20,
|
|
498
|
+
label: s,
|
|
499
|
+
value: n,
|
|
500
|
+
onChange: (e) => r?.(e.target.value),
|
|
501
|
+
error: !!i,
|
|
502
|
+
helperText: i ?? (c.countCharacters ? `${n.length}${c.maxLength ? `/${c.maxLength}` : ""}` : void 0),
|
|
503
|
+
disabled: a ?? e.disabled,
|
|
504
|
+
required: e.required,
|
|
505
|
+
fullWidth: !0,
|
|
506
|
+
"data-testid": o,
|
|
507
|
+
slotProps: {
|
|
508
|
+
input: {
|
|
509
|
+
readOnly: t ?? e.isReadOnly,
|
|
510
|
+
startAdornment: l
|
|
511
|
+
},
|
|
512
|
+
htmlInput: { maxLength: c.maxLength },
|
|
513
|
+
inputLabel: { shrink: !0 }
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function TextInputComponent({ element: e, readOnly: t, value: n = "", onChange: r, error: i, disabled: a }) {
|
|
518
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = e, l = buildIconAdornment(e.icon), u = useTypeaheadProvider(String(c.isTypeAheadField) === "true" ? e["xmi:id"] : void 0);
|
|
519
|
+
return u ? /* @__PURE__ */ jsx(TypeaheadInput, {
|
|
520
|
+
label: s,
|
|
521
|
+
testId: o,
|
|
522
|
+
value: n,
|
|
523
|
+
onChange: r,
|
|
524
|
+
error: i,
|
|
525
|
+
disabled: a ?? e.disabled,
|
|
526
|
+
required: e.required,
|
|
527
|
+
readOnly: t ?? e.isReadOnly,
|
|
528
|
+
maxLength: c.maxLength,
|
|
529
|
+
regexp: c.regexp,
|
|
530
|
+
provider: u,
|
|
531
|
+
startAdornment: l
|
|
532
|
+
}) : /* @__PURE__ */ jsx(TextField, {
|
|
533
|
+
label: s,
|
|
534
|
+
value: n,
|
|
535
|
+
onChange: (e) => r?.(e.target.value),
|
|
536
|
+
error: !!i,
|
|
537
|
+
helperText: i,
|
|
538
|
+
disabled: a ?? e.disabled,
|
|
539
|
+
required: e.required,
|
|
540
|
+
fullWidth: !0,
|
|
541
|
+
"data-testid": o,
|
|
542
|
+
slotProps: {
|
|
543
|
+
input: {
|
|
544
|
+
readOnly: t ?? e.isReadOnly,
|
|
545
|
+
startAdornment: l
|
|
546
|
+
},
|
|
547
|
+
htmlInput: {
|
|
548
|
+
maxLength: c.maxLength,
|
|
549
|
+
pattern: c.regexp
|
|
550
|
+
},
|
|
551
|
+
inputLabel: { shrink: !0 }
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
function TypeaheadInput({ label: e, testId: t, value: n, onChange: r, error: i, disabled: a, required: s, readOnly: c, maxLength: l, regexp: u, provider: f, startAdornment: p }) {
|
|
556
|
+
let [m, h] = useState([]), [g, _] = useState(!1), v = useDebouncedCallback(async (e) => {
|
|
557
|
+
_(!0);
|
|
558
|
+
try {
|
|
559
|
+
h(await f(e));
|
|
560
|
+
} catch {
|
|
561
|
+
h([]);
|
|
562
|
+
} finally {
|
|
563
|
+
_(!1);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
return /* @__PURE__ */ jsx(Autocomplete, {
|
|
567
|
+
freeSolo: !0,
|
|
568
|
+
options: m,
|
|
569
|
+
loading: g,
|
|
570
|
+
value: n,
|
|
571
|
+
inputValue: n,
|
|
572
|
+
onInputChange: (e, t, n) => {
|
|
573
|
+
n === "input" && (r?.(t), v(t));
|
|
574
|
+
},
|
|
575
|
+
onChange: (e, t) => {
|
|
576
|
+
r?.(typeof t == "string" ? t : "");
|
|
577
|
+
},
|
|
578
|
+
disabled: a,
|
|
579
|
+
readOnly: c,
|
|
580
|
+
fullWidth: !0,
|
|
581
|
+
"data-testid": t,
|
|
582
|
+
renderInput: (n) => /* @__PURE__ */ jsx(TextField, {
|
|
583
|
+
...n,
|
|
584
|
+
label: e,
|
|
585
|
+
error: !!i,
|
|
586
|
+
helperText: i,
|
|
587
|
+
required: s,
|
|
588
|
+
slotProps: {
|
|
589
|
+
input: {
|
|
590
|
+
...n.InputProps,
|
|
591
|
+
readOnly: c,
|
|
592
|
+
startAdornment: p ? /* @__PURE__ */ jsxs(Fragment, { children: [p, n.InputProps.startAdornment] }) : n.InputProps.startAdornment,
|
|
593
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [g && /* @__PURE__ */ jsx(CircularProgress, {
|
|
594
|
+
color: "inherit",
|
|
595
|
+
size: 20,
|
|
596
|
+
"data-testid": `${t}::loading`
|
|
597
|
+
}), n.InputProps.endAdornment] })
|
|
598
|
+
},
|
|
599
|
+
htmlInput: {
|
|
600
|
+
...n.inputProps,
|
|
601
|
+
maxLength: l,
|
|
602
|
+
pattern: u
|
|
603
|
+
},
|
|
604
|
+
inputLabel: { shrink: !0 }
|
|
605
|
+
}
|
|
606
|
+
})
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
function TimeInputComponent({ element: e, readOnly: t, value: n, onChange: r, error: i, disabled: a }) {
|
|
610
|
+
let o = getInputTestId(e), { label: s } = useModelLabel(e), c = buildIconAdornment(e.icon);
|
|
611
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
612
|
+
type: "time",
|
|
613
|
+
label: s,
|
|
614
|
+
value: n ?? "",
|
|
615
|
+
onChange: (e) => r?.(e.target.value || null),
|
|
616
|
+
error: !!i,
|
|
617
|
+
helperText: i,
|
|
618
|
+
disabled: a ?? e.disabled,
|
|
619
|
+
required: e.required,
|
|
620
|
+
fullWidth: !0,
|
|
621
|
+
"data-testid": o,
|
|
622
|
+
slotProps: {
|
|
623
|
+
input: {
|
|
624
|
+
readOnly: t ?? e.isReadOnly,
|
|
625
|
+
startAdornment: c
|
|
626
|
+
},
|
|
627
|
+
inputLabel: { shrink: !0 }
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
function convertEnumOptions(e) {
|
|
632
|
+
return (e.options ?? []).map((e) => ({
|
|
633
|
+
value: e.enumerationMember?.name ?? e.name,
|
|
634
|
+
label: e.label ?? e.enumerationMember?.name ?? e.name
|
|
635
|
+
}));
|
|
636
|
+
}
|
|
637
|
+
function InputRenderer({ element: e, readOnly: t }) {
|
|
638
|
+
let n = useVisualBinding(e), r = useEnumOptionFilter(e["xmi:id"]);
|
|
639
|
+
if (n.hidden) return null;
|
|
640
|
+
let i = t ?? n.readOnly ?? e.isReadOnly ?? !1, a = n.required || e.required === !0 || e.attributeType?.isRequired === !0, o = {
|
|
641
|
+
...e,
|
|
642
|
+
label: n.label || e.label,
|
|
643
|
+
required: a
|
|
644
|
+
}, s = {
|
|
645
|
+
value: n.value,
|
|
646
|
+
onChange: n.onChange,
|
|
647
|
+
error: n.error ?? void 0,
|
|
648
|
+
disabled: n.disabled
|
|
649
|
+
};
|
|
650
|
+
switch (e["@type"]) {
|
|
651
|
+
case "TextInput": return /* @__PURE__ */ jsx(TextInputComponent, {
|
|
652
|
+
element: o,
|
|
653
|
+
readOnly: i,
|
|
654
|
+
...s
|
|
655
|
+
});
|
|
656
|
+
case "NumericInput": return /* @__PURE__ */ jsx(NumericInputComponent, {
|
|
657
|
+
element: o,
|
|
658
|
+
readOnly: i,
|
|
659
|
+
...s
|
|
660
|
+
});
|
|
661
|
+
case "DateInput": return /* @__PURE__ */ jsx(DateInputComponent, {
|
|
662
|
+
element: o,
|
|
663
|
+
readOnly: i,
|
|
664
|
+
...s
|
|
665
|
+
});
|
|
666
|
+
case "DateTimeInput": return /* @__PURE__ */ jsx(DateTimeInputComponent, {
|
|
667
|
+
element: o,
|
|
668
|
+
readOnly: i,
|
|
669
|
+
...s
|
|
670
|
+
});
|
|
671
|
+
case "TimeInput": return /* @__PURE__ */ jsx(TimeInputComponent, {
|
|
672
|
+
element: o,
|
|
673
|
+
readOnly: i,
|
|
674
|
+
...s
|
|
675
|
+
});
|
|
676
|
+
case "TextArea": return /* @__PURE__ */ jsx(TextAreaComponent, {
|
|
677
|
+
element: o,
|
|
678
|
+
readOnly: i,
|
|
679
|
+
...s
|
|
680
|
+
});
|
|
681
|
+
case "Checkbox": return /* @__PURE__ */ jsx(CheckboxComponent, {
|
|
682
|
+
element: o,
|
|
683
|
+
readOnly: i,
|
|
684
|
+
...s
|
|
685
|
+
});
|
|
686
|
+
case "Switch": return /* @__PURE__ */ jsx(SwitchComponent, {
|
|
687
|
+
element: o,
|
|
688
|
+
readOnly: i,
|
|
689
|
+
...s
|
|
690
|
+
});
|
|
691
|
+
case "EnumerationCombo": {
|
|
692
|
+
let e = o, t = !e.required && !e.attributeType?.isRequired, n = convertEnumOptions(e);
|
|
693
|
+
return /* @__PURE__ */ jsx(EnumerationComboComponent, {
|
|
694
|
+
element: o,
|
|
695
|
+
readOnly: i,
|
|
696
|
+
options: r ? r(n) : n,
|
|
697
|
+
nullable: t,
|
|
698
|
+
...s
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
case "EnumerationRadio": {
|
|
702
|
+
let e = o, t = !e.required && !e.attributeType?.isRequired, n = e.stretch === "HORIZONTAL" || e.stretch === "BOTH" ? "horizontal" : "vertical", a = convertEnumOptions(e);
|
|
703
|
+
return /* @__PURE__ */ jsx(EnumerationRadioComponent, {
|
|
704
|
+
element: o,
|
|
705
|
+
readOnly: i,
|
|
706
|
+
options: r ? r(a) : a,
|
|
707
|
+
nullable: t,
|
|
708
|
+
orientation: n,
|
|
709
|
+
...s
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
case "EnumerationToggleButtonbar": {
|
|
713
|
+
let e = o, t = !e.required && !e.attributeType?.isRequired, n = e.stretch === "VERTICAL" ? "vertical" : "horizontal", a = convertEnumOptions(e);
|
|
714
|
+
return /* @__PURE__ */ jsx(EnumerationToggleButtonbarComponent, {
|
|
715
|
+
element: o,
|
|
716
|
+
readOnly: i,
|
|
717
|
+
options: r ? r(a) : a,
|
|
718
|
+
nullable: t,
|
|
719
|
+
orientation: n,
|
|
720
|
+
...s
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
case "BinaryTypeInput": return /* @__PURE__ */ jsx(BinaryInputComponent, {
|
|
724
|
+
element: o,
|
|
725
|
+
readOnly: i,
|
|
726
|
+
...s
|
|
727
|
+
});
|
|
728
|
+
case "PasswordInput": return /* @__PURE__ */ jsx(PasswordInputComponent, {
|
|
729
|
+
element: o,
|
|
730
|
+
readOnly: i,
|
|
731
|
+
...s
|
|
732
|
+
});
|
|
733
|
+
default: return /* @__PURE__ */ jsx(TextInputComponent, {
|
|
734
|
+
element: o,
|
|
735
|
+
readOnly: i,
|
|
736
|
+
...s
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function applyFormat(e, t) {
|
|
741
|
+
return t == null ? "" : e ? e.replace(/%([%sdf])/g, (e, n) => {
|
|
742
|
+
if (n === "%") return "%";
|
|
743
|
+
if (n === "d") {
|
|
744
|
+
let e = Number(t);
|
|
745
|
+
return Number.isNaN(e) ? String(t) : String(Math.trunc(e));
|
|
746
|
+
}
|
|
747
|
+
if (n === "f") {
|
|
748
|
+
let e = Number(t);
|
|
749
|
+
return Number.isNaN(e) ? String(t) : String(e);
|
|
750
|
+
}
|
|
751
|
+
return String(t);
|
|
752
|
+
}) : String(t);
|
|
753
|
+
}
|
|
754
|
+
function FormattedRenderer({ element: e }) {
|
|
755
|
+
let t = useVisualBinding(e);
|
|
756
|
+
if (t.hidden) return null;
|
|
757
|
+
let n = applyFormat(e.format, t.value), r = `formatted::${e.sourceId ?? e["xmi:id"]}`;
|
|
758
|
+
return e.isMultiLine ? /* @__PURE__ */ jsx(Typography$1, {
|
|
759
|
+
component: "div",
|
|
760
|
+
"data-testid": r,
|
|
761
|
+
sx: {
|
|
762
|
+
whiteSpace: "pre-wrap",
|
|
763
|
+
wordBreak: "break-word"
|
|
764
|
+
},
|
|
765
|
+
children: n
|
|
766
|
+
}) : /* @__PURE__ */ jsx(Typography$1, {
|
|
767
|
+
"data-testid": r,
|
|
768
|
+
children: n
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
function InlineButtonGroupRenderer({ element: t, page: r, editMode: i, onDispatch: o }) {
|
|
772
|
+
let s = useElementVisibility(t), u = usePageContextOptional(), d = useDispatchOptional(), { isEditMode: f } = useEditMode(), p = r ?? u?.pageDefinition, m = o ?? d?.dispatch, h = i ?? f, [g, _] = useState(null), v = !!g, y = (e) => {
|
|
773
|
+
_(e.currentTarget);
|
|
774
|
+
}, b = () => {
|
|
775
|
+
_(null);
|
|
776
|
+
}, x = (t) => {
|
|
777
|
+
let n = p ? findActionByDefinition(p, t.actionDefinition) : void 0;
|
|
778
|
+
n && m && m(n).catch((e) => {
|
|
779
|
+
console.error("Button action failed:", e);
|
|
780
|
+
});
|
|
781
|
+
}, S = (e) => {
|
|
782
|
+
x(e);
|
|
783
|
+
}, C = (e) => {
|
|
784
|
+
b(), x(e);
|
|
785
|
+
}, w = getVisibleButtons(t.buttons, p?.actions);
|
|
786
|
+
if (s || w.length === 0) return null;
|
|
787
|
+
let T = getButtonGroupTestId(t), { label: E } = useModelLabel(t), O = t.featuredActions ?? 0, Ot = O > 0 ? w.slice(0, O) : [], k = O > 0 ? w.slice(O) : w;
|
|
788
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(ButtonGroup, {
|
|
789
|
+
"data-testid": T,
|
|
790
|
+
children: [Ot.map((e) => /* @__PURE__ */ jsx(InlineFeaturedButton, {
|
|
791
|
+
button: e,
|
|
792
|
+
onClick: () => S(e),
|
|
793
|
+
disabled: e.disabled === !0 || h === !0
|
|
794
|
+
}, e["xmi:id"])), k.length > 0 && /* @__PURE__ */ jsx(Button, {
|
|
795
|
+
variant: "outlined",
|
|
796
|
+
onClick: y,
|
|
797
|
+
disabled: h === !0,
|
|
798
|
+
"data-testid": `${T}::dropdown`,
|
|
799
|
+
startIcon: t.icon ? /* @__PURE__ */ jsx(IconRenderer, { icon: t.icon }) : void 0,
|
|
800
|
+
endIcon: /* @__PURE__ */ jsx(KeyboardArrowDownIcon, {}),
|
|
801
|
+
"aria-controls": v ? `${T}-menu` : void 0,
|
|
802
|
+
"aria-haspopup": "true",
|
|
803
|
+
"aria-expanded": v ? "true" : void 0,
|
|
804
|
+
children: E
|
|
805
|
+
})]
|
|
806
|
+
}), k.length > 0 && /* @__PURE__ */ jsx(Menu, {
|
|
807
|
+
id: `${T}-menu`,
|
|
808
|
+
anchorEl: g,
|
|
809
|
+
open: v,
|
|
810
|
+
onClose: b,
|
|
811
|
+
MenuListProps: { "aria-labelledby": `${T}::dropdown` },
|
|
812
|
+
children: k.map((e) => /* @__PURE__ */ jsx(InlineOverflowItem, {
|
|
813
|
+
button: e,
|
|
814
|
+
onClick: () => C(e),
|
|
815
|
+
disabled: e.disabled === !0 || h === !0
|
|
816
|
+
}, e["xmi:id"]))
|
|
817
|
+
})] });
|
|
818
|
+
}
|
|
819
|
+
function InlineFeaturedButton({ button: e, onClick: t, disabled: r }) {
|
|
820
|
+
let i = useElementVisibility(e), a = useElementDisabled(e), { label: o } = useModelLabel(e), s = getButtonTestId(e);
|
|
821
|
+
return i ? null : /* @__PURE__ */ jsx(Button, {
|
|
822
|
+
variant: "outlined",
|
|
823
|
+
onClick: t,
|
|
824
|
+
disabled: r || a,
|
|
825
|
+
"data-testid": s,
|
|
826
|
+
startIcon: e.icon ? /* @__PURE__ */ jsx(IconRenderer, { icon: e.icon }) : void 0,
|
|
827
|
+
children: o
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
function InlineOverflowItem({ button: e, onClick: t, disabled: r }) {
|
|
831
|
+
let i = useElementVisibility(e), a = useElementDisabled(e), { label: o } = useModelLabel(e), s = getButtonTestId(e);
|
|
832
|
+
return i ? null : /* @__PURE__ */ jsxs(MenuItem, {
|
|
833
|
+
onClick: t,
|
|
834
|
+
disabled: r || a,
|
|
835
|
+
"data-testid": s,
|
|
836
|
+
children: [e.icon && /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(IconRenderer, { icon: e.icon }) }), /* @__PURE__ */ jsx(ListItemText, { children: o })]
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
function LinkSelectorDialog({ open: e, element: t, relationType: n, api: r, transfer: i, onConfirm: a, onCancel: o }) {
|
|
840
|
+
let l = `${getLinkTestId(t)}::selector`, { label: u } = useModelLabel(t), d = useMuiProOptional()?.getComponent("DataGrid") ?? DataGrid, [f, _] = useState([]), [v, y] = useState(!1), [b, x] = useState(0), [S, C] = useState(""), [w, T] = useState(null), [E, D] = useState({
|
|
841
|
+
page: 0,
|
|
842
|
+
pageSize: t.selectorRowsPerPage ?? 10
|
|
843
|
+
});
|
|
844
|
+
useRef(!1);
|
|
845
|
+
let O = useMemo(() => {
|
|
846
|
+
if (n?.target?.attributes) return n.target.attributes.find((e) => e.dataType?.["@type"] === "StringType")?.name;
|
|
847
|
+
}, [n]), Ot = useMemo(() => t.parts.map((e) => ({
|
|
848
|
+
field: e.attributeType?.name ?? e.name,
|
|
849
|
+
headerName: e.label ?? e.name,
|
|
850
|
+
renderHeader: () => /* @__PURE__ */ jsx(TranslatedColumnHeader, { column: e }),
|
|
851
|
+
width: e.width ? Number.parseInt(e.width, 10) : 150,
|
|
852
|
+
sortable: !0,
|
|
853
|
+
filterable: !1
|
|
854
|
+
})), [t.parts]), k = useCallback(async (e, t, a) => {
|
|
855
|
+
y(!0);
|
|
856
|
+
try {
|
|
857
|
+
let o = { _seek: {
|
|
858
|
+
limit: t,
|
|
859
|
+
offset: e * t
|
|
860
|
+
} };
|
|
861
|
+
a && O && (o[O] = [{
|
|
862
|
+
operator: "like",
|
|
863
|
+
value: `%${a}%`
|
|
864
|
+
}]);
|
|
865
|
+
let s = await r.getRelationRange(n, i, o);
|
|
866
|
+
_(s.data), typeof s.totalCount == "number" ? x(s.totalCount) : x(s.data.length < t ? e * t + s.data.length : (e + 1) * t + 1);
|
|
867
|
+
} catch (e) {
|
|
868
|
+
console.error("Failed to fetch selector data:", e), _([]), x(0);
|
|
869
|
+
} finally {
|
|
870
|
+
y(!1);
|
|
871
|
+
}
|
|
872
|
+
}, [
|
|
873
|
+
r,
|
|
874
|
+
n,
|
|
875
|
+
i,
|
|
876
|
+
O
|
|
877
|
+
]);
|
|
878
|
+
useEffect(() => {
|
|
879
|
+
e && k(E.page, E.pageSize, S);
|
|
880
|
+
}, [
|
|
881
|
+
e,
|
|
882
|
+
E.page,
|
|
883
|
+
E.pageSize,
|
|
884
|
+
S,
|
|
885
|
+
k
|
|
886
|
+
]);
|
|
887
|
+
let A = useRef(null), j = useCallback((e) => {
|
|
888
|
+
let t = e.target.value;
|
|
889
|
+
A.current && clearTimeout(A.current), A.current = setTimeout(() => {
|
|
890
|
+
C(t), D((e) => ({
|
|
891
|
+
...e,
|
|
892
|
+
page: 0
|
|
893
|
+
}));
|
|
894
|
+
}, 300);
|
|
895
|
+
}, []), M = useCallback((e) => {
|
|
896
|
+
let t = e.type === "include" ? Array.from(e.ids) : [];
|
|
897
|
+
t.length > 0 ? T(f.find((e) => (e.__signedIdentifier ?? e.__identifier ?? e.__tempId ?? e.id) === t[0]) ?? null) : T(null);
|
|
898
|
+
}, [f]), N = useCallback(() => {
|
|
899
|
+
w && a(w);
|
|
900
|
+
}, [w, a]), P = useMemo(() => {
|
|
901
|
+
let e = [
|
|
902
|
+
5,
|
|
903
|
+
10,
|
|
904
|
+
25,
|
|
905
|
+
50
|
|
906
|
+
], n = t.selectorRowsPerPage ?? 10;
|
|
907
|
+
return e.includes(n) ? e : [...e, n].toSorted((e, t) => e - t);
|
|
908
|
+
}, [t.selectorRowsPerPage]);
|
|
909
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
910
|
+
open: e,
|
|
911
|
+
onClose: o,
|
|
912
|
+
maxWidth: "md",
|
|
913
|
+
fullWidth: !0,
|
|
914
|
+
"data-testid": l,
|
|
915
|
+
children: [
|
|
916
|
+
/* @__PURE__ */ jsx(DialogTitle, {
|
|
917
|
+
"data-testid": `${l}::title`,
|
|
918
|
+
children: u
|
|
919
|
+
}),
|
|
920
|
+
/* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(Box, {
|
|
921
|
+
sx: {
|
|
922
|
+
mb: 2,
|
|
923
|
+
mt: 1
|
|
924
|
+
},
|
|
925
|
+
children: /* @__PURE__ */ jsx(TextField, {
|
|
926
|
+
fullWidth: !0,
|
|
927
|
+
size: "small",
|
|
928
|
+
placeholder: `Filter by ${O ?? "name"}...`,
|
|
929
|
+
onChange: j,
|
|
930
|
+
"data-testid": `${l}::filter`,
|
|
931
|
+
slotProps: { inputLabel: { shrink: !0 } }
|
|
932
|
+
})
|
|
933
|
+
}), /* @__PURE__ */ jsx(Box, {
|
|
934
|
+
sx: { height: 400 },
|
|
935
|
+
children: /* @__PURE__ */ jsx(d, {
|
|
936
|
+
columns: Ot,
|
|
937
|
+
rows: f,
|
|
938
|
+
rowCount: b,
|
|
939
|
+
loading: v,
|
|
940
|
+
paginationModel: E,
|
|
941
|
+
onPaginationModelChange: D,
|
|
942
|
+
paginationMode: "server",
|
|
943
|
+
pageSizeOptions: P,
|
|
944
|
+
getRowId: (e) => e.__signedIdentifier ?? e.__identifier ?? e.__tempId ?? e.id,
|
|
945
|
+
onRowSelectionModelChange: M,
|
|
946
|
+
"data-testid": `${l}::grid`,
|
|
947
|
+
sx: { height: "100%" }
|
|
948
|
+
})
|
|
949
|
+
})] }),
|
|
950
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
951
|
+
onClick: o,
|
|
952
|
+
"data-testid": `${l}::cancel`,
|
|
953
|
+
children: "Cancel"
|
|
954
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
955
|
+
onClick: N,
|
|
956
|
+
variant: "contained",
|
|
957
|
+
disabled: !w,
|
|
958
|
+
"data-testid": `${l}::confirm`,
|
|
959
|
+
children: "Confirm"
|
|
960
|
+
})] })
|
|
961
|
+
]
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
function TranslatedColumnHeader({ column: e }) {
|
|
965
|
+
let { label: t } = useModelLabel(e);
|
|
966
|
+
return /* @__PURE__ */ jsx(Fragment, { children: t });
|
|
967
|
+
}
|
|
968
|
+
function buildMaskString(e) {
|
|
969
|
+
let { attributes: t = [], relations: n = [] } = e, r = [];
|
|
970
|
+
for (let e of t) e.name && r.push(e.name);
|
|
971
|
+
for (let e of n) if (e.name) {
|
|
972
|
+
let t = (e.target?.attributes ?? []).map((e) => e.name).filter(Boolean);
|
|
973
|
+
t.length > 0 ? r.push(`${e.name}{${t.join(",")}}`) : r.push(`${e.name}{}`);
|
|
974
|
+
}
|
|
975
|
+
return `{${r.join(",")}}`;
|
|
976
|
+
}
|
|
977
|
+
function LinkRenderer({ element: n, page: r, readOnly: i }) {
|
|
978
|
+
let c = getLinkTestId(n), { label: l } = useModelLabel(n), u = buildIconAdornment(n.icon), d = usePageContextOptional(), p = r ?? d?.pageDefinition, m = useNavigation(), h = useDataStore(), g = useApplication(), _ = useApi(), v = useNotifications(), { confirm: y } = useConfirmation(), b = useRuntimeConfigOptional()?.config?.density ?? "compact", C = useMemo(() => {
|
|
979
|
+
let e = {
|
|
980
|
+
compact: {
|
|
981
|
+
top: 1.33333334,
|
|
982
|
+
bottom: .66666667
|
|
983
|
+
},
|
|
984
|
+
comfortable: {
|
|
985
|
+
top: 0,
|
|
986
|
+
bottom: 0
|
|
987
|
+
},
|
|
988
|
+
standard: {
|
|
989
|
+
top: 1.63333332,
|
|
990
|
+
bottom: .8
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
return e[b] ?? e.comfortable;
|
|
994
|
+
}, [b]), [w, T] = useState([]), [E, D] = useState(!1), [O, j] = useState(!1), M = useMemo(() => {
|
|
995
|
+
if (n.dataElement && typeof n.dataElement == "object" && n.dataElement["@type"] === "RelationType") return n.dataElement;
|
|
996
|
+
}, [n.dataElement]), N = useDataSelector(useCallback((e) => {
|
|
997
|
+
let t = d?.transferId;
|
|
998
|
+
if (!t) return null;
|
|
999
|
+
let r = e.transfers.get(t);
|
|
1000
|
+
return r?.data ? r.data[n.relationName] ?? null : null;
|
|
1001
|
+
}, [d?.transferId, n.relationName]));
|
|
1002
|
+
useDataSelector(useCallback((e) => {
|
|
1003
|
+
let t = d?.transferId;
|
|
1004
|
+
return t ? e.transfers.get(t)?.isLoading ?? !1 : !1;
|
|
1005
|
+
}, [d?.transferId]));
|
|
1006
|
+
let P = useDataSelector(useCallback((e) => {
|
|
1007
|
+
let t = d?.transferId;
|
|
1008
|
+
return t ? e.transfers.get(t)?.data : void 0;
|
|
1009
|
+
}, [d?.transferId])), F = useMemo(() => {
|
|
1010
|
+
let e = d?.params?.signedIdentifier;
|
|
1011
|
+
if (e && d?.transferId) return {
|
|
1012
|
+
__identifier: d.transferId,
|
|
1013
|
+
__signedIdentifier: e
|
|
1014
|
+
};
|
|
1015
|
+
if (P) return P;
|
|
1016
|
+
}, [
|
|
1017
|
+
P,
|
|
1018
|
+
d?.transferId,
|
|
1019
|
+
d?.params
|
|
1020
|
+
]), I = i ?? n.isReadOnly ?? M?.isReadOnly ?? !1, kt = useResolvedPageActionOverrides(), L = useMemo(() => ({
|
|
1021
|
+
navigation: m,
|
|
1022
|
+
data: h,
|
|
1023
|
+
registry: g,
|
|
1024
|
+
api: _,
|
|
1025
|
+
transfer: F,
|
|
1026
|
+
notifications: v,
|
|
1027
|
+
actionOverrides: kt,
|
|
1028
|
+
additionalContext: {
|
|
1029
|
+
isEager: n.isEager,
|
|
1030
|
+
relationName: n.relationName,
|
|
1031
|
+
pageTransferId: d?.transferId,
|
|
1032
|
+
...n.isEager && { parentTransferId: d?.transferId }
|
|
1033
|
+
}
|
|
1034
|
+
}), [
|
|
1035
|
+
m,
|
|
1036
|
+
h,
|
|
1037
|
+
g,
|
|
1038
|
+
_,
|
|
1039
|
+
F,
|
|
1040
|
+
v,
|
|
1041
|
+
n.isEager,
|
|
1042
|
+
n.relationName,
|
|
1043
|
+
d?.transferId,
|
|
1044
|
+
kt
|
|
1045
|
+
]), { dispatch: R } = useActionDispatcher(L), z = useCallback((e) => e ? n.parts.map((t) => e[t.name]).filter(Boolean).join(" ") : "", [n.parts]), B = useMemo(() => {
|
|
1046
|
+
if (M?.target?.attributes) return M.target.attributes.find((e) => e.dataType?.["@type"] === "StringType")?.name;
|
|
1047
|
+
}, [M]), V = useCallback(async (e) => {
|
|
1048
|
+
if (!(!M || !_)) {
|
|
1049
|
+
D(!0);
|
|
1050
|
+
try {
|
|
1051
|
+
let t = {
|
|
1052
|
+
_seek: { limit: n.autoCompleteRows ?? 10 },
|
|
1053
|
+
_mask: buildMaskString({
|
|
1054
|
+
attributes: [...M.target.attributes ?? [], ...n.additionalMaskAttributes ?? []],
|
|
1055
|
+
relations: n.additionalMaskRelations
|
|
1056
|
+
})
|
|
1057
|
+
};
|
|
1058
|
+
e && B && (t[B] = [{
|
|
1059
|
+
operator: "like",
|
|
1060
|
+
value: `%${e}%`
|
|
1061
|
+
}]), T((await _.getRelationRange(M, P ?? F, t)).data);
|
|
1062
|
+
} catch (e) {
|
|
1063
|
+
console.error("Failed to load autocomplete options:", e), T([]);
|
|
1064
|
+
} finally {
|
|
1065
|
+
D(!1);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}, [
|
|
1069
|
+
n.autoCompleteRows,
|
|
1070
|
+
n.additionalMaskAttributes,
|
|
1071
|
+
n.additionalMaskRelations,
|
|
1072
|
+
M,
|
|
1073
|
+
_,
|
|
1074
|
+
P,
|
|
1075
|
+
F,
|
|
1076
|
+
B
|
|
1077
|
+
]), At = useCallback(() => {
|
|
1078
|
+
V();
|
|
1079
|
+
}, [V]), jt = useDebouncedCallback((e) => {
|
|
1080
|
+
V(e);
|
|
1081
|
+
}), Mt = useCallback((e, t, r) => {
|
|
1082
|
+
r === "input" && (!n.autocompleteRangeActionDefinition || !M || jt(t));
|
|
1083
|
+
}, [
|
|
1084
|
+
n.autocompleteRangeActionDefinition,
|
|
1085
|
+
M,
|
|
1086
|
+
jt
|
|
1087
|
+
]), Nt = useMemo(() => !N || w.some((e) => e.__identifier && N.__identifier ? e.__identifier === N.__identifier : e.__signedIdentifier && N.__signedIdentifier ? e.__signedIdentifier === N.__signedIdentifier : e === N) ? w : [N, ...w], [w, N]), Pt = useCallback(async (t, r) => {
|
|
1088
|
+
if (!r) {
|
|
1089
|
+
if (n.isEager && d?.transferId) h.updateTransferField(d.transferId, n.relationName, null);
|
|
1090
|
+
else {
|
|
1091
|
+
let t = n.actionButtonGroup?.buttons?.find((e) => e.actionDefinition?.["@type"] === "UnsetActionDefinition")?.actionDefinition, r = t ? findActionByDefinition(p, t) : void 0;
|
|
1092
|
+
if (r) try {
|
|
1093
|
+
let e = getActionHandler(r);
|
|
1094
|
+
e && await e(r)({
|
|
1095
|
+
navigation: m,
|
|
1096
|
+
data: h,
|
|
1097
|
+
registry: g,
|
|
1098
|
+
api: _,
|
|
1099
|
+
transfer: N ?? F,
|
|
1100
|
+
notifications: v,
|
|
1101
|
+
...L.additionalContext
|
|
1102
|
+
});
|
|
1103
|
+
} catch (e) {
|
|
1104
|
+
console.error("Failed to unset autocomplete value:", e);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
let i = n.autocompleteSetActionDefinition ? findActionByDefinition(p, n.autocompleteSetActionDefinition) : void 0;
|
|
1110
|
+
if (i) try {
|
|
1111
|
+
await R(i, { selectedItem: r }), n.isEager && d?.transferId && h.updateTransferField(d.transferId, n.relationName, r);
|
|
1112
|
+
} catch (e) {
|
|
1113
|
+
console.error("Failed to set autocomplete value:", e);
|
|
1114
|
+
}
|
|
1115
|
+
}, [
|
|
1116
|
+
n.autocompleteSetActionDefinition,
|
|
1117
|
+
n.actionButtonGroup,
|
|
1118
|
+
n.isEager,
|
|
1119
|
+
n.relationName,
|
|
1120
|
+
p,
|
|
1121
|
+
R,
|
|
1122
|
+
h,
|
|
1123
|
+
d?.transferId,
|
|
1124
|
+
m,
|
|
1125
|
+
g,
|
|
1126
|
+
_,
|
|
1127
|
+
F,
|
|
1128
|
+
N,
|
|
1129
|
+
v,
|
|
1130
|
+
L.additionalContext
|
|
1131
|
+
]), Ft = useMemo(() => getVisibleButtons(n.actionButtonGroup?.buttons ?? [], p?.actions), [n.actionButtonGroup, p?.actions]), H = useMemo(() => {
|
|
1132
|
+
let e = {};
|
|
1133
|
+
for (let t of Ft) {
|
|
1134
|
+
let n = t.actionDefinition?.["@type"];
|
|
1135
|
+
n && (e[n] = t);
|
|
1136
|
+
}
|
|
1137
|
+
return e;
|
|
1138
|
+
}, [Ft]), U = M?.isOptional !== !1, W = H.OpenPageActionDefinition ?? H.RowOpenPageActionDefinition ?? void 0, G = I ? void 0 : H.OpenSetSelectorActionDefinition, K = !I && U ? H.UnsetActionDefinition : void 0, q = I ? void 0 : H.OpenCreateFormActionDefinition ?? void 0, J = U ? H.RowDeleteActionDefinition : void 0, Y = !!N, It = useMemo(() => {
|
|
1139
|
+
if (Y) return W ? [W] : [];
|
|
1140
|
+
let e = [];
|
|
1141
|
+
return G && e.push(G), q && e.push(q), e;
|
|
1142
|
+
}, [
|
|
1143
|
+
Y,
|
|
1144
|
+
W,
|
|
1145
|
+
G,
|
|
1146
|
+
q
|
|
1147
|
+
]), X = useMemo(() => {
|
|
1148
|
+
if (!Y) return [];
|
|
1149
|
+
let e = [];
|
|
1150
|
+
return G && e.push(G), K && N && e.push(K), q && e.push(q), J && N?.__deleteable === !0 && e.push(J), e;
|
|
1151
|
+
}, [
|
|
1152
|
+
Y,
|
|
1153
|
+
G,
|
|
1154
|
+
K,
|
|
1155
|
+
q,
|
|
1156
|
+
J,
|
|
1157
|
+
N
|
|
1158
|
+
]), [Lt, Z] = useState(!1), Q = useRef(null), Rt = useCallback(() => {
|
|
1159
|
+
Z((e) => !e);
|
|
1160
|
+
}, []), zt = useCallback((e) => {
|
|
1161
|
+
Q.current?.contains(e.target) || Z(!1);
|
|
1162
|
+
}, []), $ = useCallback(async (t, n) => {
|
|
1163
|
+
let r = p ? findActionByDefinition(p, t.actionDefinition) : void 0;
|
|
1164
|
+
if (r) try {
|
|
1165
|
+
let e = getActionHandler(r);
|
|
1166
|
+
if (!e) throw Error(`No handler for action type: ${t.actionDefinition?.["@type"]}`);
|
|
1167
|
+
await e(r)({
|
|
1168
|
+
navigation: m,
|
|
1169
|
+
data: h,
|
|
1170
|
+
registry: g,
|
|
1171
|
+
api: _,
|
|
1172
|
+
transfer: n?.transfer ?? N ?? F,
|
|
1173
|
+
notifications: v,
|
|
1174
|
+
...L.additionalContext,
|
|
1175
|
+
...n
|
|
1176
|
+
});
|
|
1177
|
+
} catch (e) {
|
|
1178
|
+
console.error("Button action failed:", e);
|
|
1179
|
+
}
|
|
1180
|
+
}, [
|
|
1181
|
+
p,
|
|
1182
|
+
m,
|
|
1183
|
+
h,
|
|
1184
|
+
g,
|
|
1185
|
+
_,
|
|
1186
|
+
F,
|
|
1187
|
+
N,
|
|
1188
|
+
v,
|
|
1189
|
+
L.additionalContext
|
|
1190
|
+
]), Bt = useCallback(() => {
|
|
1191
|
+
W && N && $(W, { transfer: N });
|
|
1192
|
+
}, [
|
|
1193
|
+
W,
|
|
1194
|
+
N,
|
|
1195
|
+
$
|
|
1196
|
+
]), Vt = useCallback(() => {
|
|
1197
|
+
j(!0);
|
|
1198
|
+
}, []), Ht = useCallback(async () => {
|
|
1199
|
+
if (K) {
|
|
1200
|
+
if (!await y(getDestructiveConfirmationOptions("UnsetActionDefinition"))) return;
|
|
1201
|
+
n.isEager && d?.transferId ? h.updateTransferField(d.transferId, n.relationName, null) : $(K);
|
|
1202
|
+
}
|
|
1203
|
+
}, [
|
|
1204
|
+
K,
|
|
1205
|
+
$,
|
|
1206
|
+
n.isEager,
|
|
1207
|
+
n.relationName,
|
|
1208
|
+
h,
|
|
1209
|
+
d?.transferId,
|
|
1210
|
+
y
|
|
1211
|
+
]), Ut = useCallback(() => {
|
|
1212
|
+
q && $(q);
|
|
1213
|
+
}, [q, $]), Wt = useCallback(async () => {
|
|
1214
|
+
if (J && N) {
|
|
1215
|
+
if (!await y(getDestructiveConfirmationOptions("RowDeleteActionDefinition"))) return;
|
|
1216
|
+
$(J, { transfer: N });
|
|
1217
|
+
}
|
|
1218
|
+
}, [
|
|
1219
|
+
J,
|
|
1220
|
+
N,
|
|
1221
|
+
$,
|
|
1222
|
+
y
|
|
1223
|
+
]), Gt = useCallback((e) => {
|
|
1224
|
+
switch (e.actionDefinition?.["@type"]) {
|
|
1225
|
+
case "OpenPageActionDefinition":
|
|
1226
|
+
case "RowOpenPageActionDefinition": return Bt;
|
|
1227
|
+
case "OpenSetSelectorActionDefinition": return Vt;
|
|
1228
|
+
case "UnsetActionDefinition": return Ht;
|
|
1229
|
+
case "OpenCreateFormActionDefinition": return Ut;
|
|
1230
|
+
case "RowDeleteActionDefinition": return Wt;
|
|
1231
|
+
default: return () => {};
|
|
1232
|
+
}
|
|
1233
|
+
}, [
|
|
1234
|
+
Bt,
|
|
1235
|
+
Vt,
|
|
1236
|
+
Ht,
|
|
1237
|
+
Ut,
|
|
1238
|
+
Wt
|
|
1239
|
+
]);
|
|
1240
|
+
useCallback((e) => {
|
|
1241
|
+
switch (e.actionDefinition?.["@type"]) {
|
|
1242
|
+
case "OpenPageActionDefinition":
|
|
1243
|
+
case "RowOpenPageActionDefinition": return "View";
|
|
1244
|
+
case "OpenSetSelectorActionDefinition": return "Set";
|
|
1245
|
+
case "UnsetActionDefinition": return "Unset";
|
|
1246
|
+
case "OpenCreateFormActionDefinition": return "Create";
|
|
1247
|
+
case "RowDeleteActionDefinition": return "Delete";
|
|
1248
|
+
default: return "Action";
|
|
1249
|
+
}
|
|
1250
|
+
}, []);
|
|
1251
|
+
let Kt = useCallback(async (t) => {
|
|
1252
|
+
if (j(!1), !G) return;
|
|
1253
|
+
let r = p ? findActionByDefinition(p, G.actionDefinition) : void 0;
|
|
1254
|
+
if (r) try {
|
|
1255
|
+
await R(r, { selectedItem: t }), n.isEager && d?.transferId && h.updateTransferField(d.transferId, n.relationName, t);
|
|
1256
|
+
} catch (e) {
|
|
1257
|
+
console.error("Failed to set from selector:", e);
|
|
1258
|
+
}
|
|
1259
|
+
}, [
|
|
1260
|
+
G,
|
|
1261
|
+
p,
|
|
1262
|
+
R,
|
|
1263
|
+
n.isEager,
|
|
1264
|
+
n.relationName,
|
|
1265
|
+
h,
|
|
1266
|
+
d?.transferId
|
|
1267
|
+
]), qt = useCallback(() => {
|
|
1268
|
+
j(!1);
|
|
1269
|
+
}, []), Jt = useCallback((e, t) => e.__identifier && t.__identifier ? e.__identifier === t.__identifier : e.__signedIdentifier && t.__signedIdentifier ? e.__signedIdentifier === t.__signedIdentifier : e === t, []), Yt = It.length > 0 || X.length > 0;
|
|
1270
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
1271
|
+
"data-testid": c,
|
|
1272
|
+
sx: {
|
|
1273
|
+
display: "flex",
|
|
1274
|
+
alignItems: "stretch"
|
|
1275
|
+
},
|
|
1276
|
+
children: [
|
|
1277
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1278
|
+
sx: { flexGrow: 1 },
|
|
1279
|
+
children: /* @__PURE__ */ jsx(Autocomplete, {
|
|
1280
|
+
value: N,
|
|
1281
|
+
onChange: Pt,
|
|
1282
|
+
onInputChange: Mt,
|
|
1283
|
+
onOpen: At,
|
|
1284
|
+
options: Nt,
|
|
1285
|
+
getOptionLabel: z,
|
|
1286
|
+
filterOptions: (e) => e,
|
|
1287
|
+
isOptionEqualToValue: Jt,
|
|
1288
|
+
loading: E,
|
|
1289
|
+
disabled: I,
|
|
1290
|
+
freeSolo: !1,
|
|
1291
|
+
"data-testid": `${c}::autocomplete`,
|
|
1292
|
+
...Yt && { sx: { "& .MuiOutlinedInput-root": {
|
|
1293
|
+
borderTopRightRadius: 0,
|
|
1294
|
+
borderBottomRightRadius: 0
|
|
1295
|
+
} } },
|
|
1296
|
+
renderOption: ({ key: e, ...t }, n) => {
|
|
1297
|
+
let r = String(n.__identifier ?? n.__signedIdentifier ?? z(n));
|
|
1298
|
+
return /* @__PURE__ */ createElement("li", {
|
|
1299
|
+
...t,
|
|
1300
|
+
key: r
|
|
1301
|
+
}, z(n));
|
|
1302
|
+
},
|
|
1303
|
+
renderInput: ({ inputProps: e, InputProps: t, ...n }) => /* @__PURE__ */ jsx(TextField, {
|
|
1304
|
+
...n,
|
|
1305
|
+
label: l,
|
|
1306
|
+
required: !U,
|
|
1307
|
+
fullWidth: !0,
|
|
1308
|
+
slotProps: {
|
|
1309
|
+
input: {
|
|
1310
|
+
...t,
|
|
1311
|
+
startAdornment: u ? /* @__PURE__ */ jsxs(Fragment, { children: [u, t.startAdornment] }) : t.startAdornment
|
|
1312
|
+
},
|
|
1313
|
+
inputLabel: { shrink: !0 },
|
|
1314
|
+
htmlInput: {
|
|
1315
|
+
...e,
|
|
1316
|
+
"data-testid": `${c}::autocomplete::input`
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
})
|
|
1320
|
+
})
|
|
1321
|
+
}),
|
|
1322
|
+
Yt && /* @__PURE__ */ jsxs(Box, {
|
|
1323
|
+
ref: Q,
|
|
1324
|
+
"data-testid": `${c}::actions`,
|
|
1325
|
+
"aria-label": "link actions",
|
|
1326
|
+
role: "group",
|
|
1327
|
+
sx: (e) => {
|
|
1328
|
+
let t = e.shape.borderRadius;
|
|
1329
|
+
return {
|
|
1330
|
+
display: "flex",
|
|
1331
|
+
alignItems: "center",
|
|
1332
|
+
marginTop: C.top,
|
|
1333
|
+
marginBottom: C.bottom,
|
|
1334
|
+
border: `1px solid ${e.palette.mode === "light" ? "rgba(0, 0, 0, 0.15)" : "rgba(255, 255, 255, 0.15)"}`,
|
|
1335
|
+
borderLeft: "none",
|
|
1336
|
+
borderRadius: `0 ${t}px ${t}px 0`,
|
|
1337
|
+
"&:hover": { borderColor: e.palette.text.primary }
|
|
1338
|
+
};
|
|
1339
|
+
},
|
|
1340
|
+
children: [It.map((e) => /* @__PURE__ */ jsx(LinkActionButton, {
|
|
1341
|
+
button: e,
|
|
1342
|
+
onClick: Gt(e)
|
|
1343
|
+
}, e["xmi:id"])), X.length > 0 && /* @__PURE__ */ jsx(IconButton, {
|
|
1344
|
+
size: "small",
|
|
1345
|
+
onClick: Rt,
|
|
1346
|
+
"data-testid": `${c}::actions::dropdown`,
|
|
1347
|
+
"aria-label": "more actions",
|
|
1348
|
+
sx: {
|
|
1349
|
+
borderRadius: 0,
|
|
1350
|
+
px: .5
|
|
1351
|
+
},
|
|
1352
|
+
children: /* @__PURE__ */ jsx(ArrowDropDownIcon, { fontSize: "small" })
|
|
1353
|
+
})]
|
|
1354
|
+
}),
|
|
1355
|
+
/* @__PURE__ */ jsx(Popper, {
|
|
1356
|
+
open: Lt,
|
|
1357
|
+
anchorEl: Q.current,
|
|
1358
|
+
transition: !0,
|
|
1359
|
+
placement: "bottom-end",
|
|
1360
|
+
sx: { zIndex: 1 },
|
|
1361
|
+
"data-testid": `${c}::actions::menu`,
|
|
1362
|
+
children: ({ TransitionProps: e, placement: t }) => /* @__PURE__ */ jsx(Grow, {
|
|
1363
|
+
...e,
|
|
1364
|
+
style: { transformOrigin: t === "bottom-end" ? "right top" : "right bottom" },
|
|
1365
|
+
children: /* @__PURE__ */ jsx(Paper, { children: /* @__PURE__ */ jsx(ClickAwayListener, {
|
|
1366
|
+
onClickAway: zt,
|
|
1367
|
+
children: /* @__PURE__ */ jsx(MenuList, {
|
|
1368
|
+
autoFocusItem: Lt,
|
|
1369
|
+
children: X.map((e) => /* @__PURE__ */ jsx(LinkDropdownItem, {
|
|
1370
|
+
button: e,
|
|
1371
|
+
onClick: () => {
|
|
1372
|
+
Z(!1), Gt(e)();
|
|
1373
|
+
}
|
|
1374
|
+
}, e["xmi:id"]))
|
|
1375
|
+
})
|
|
1376
|
+
}) })
|
|
1377
|
+
})
|
|
1378
|
+
}),
|
|
1379
|
+
O && M && /* @__PURE__ */ jsx(LinkSelectorDialog, {
|
|
1380
|
+
open: O,
|
|
1381
|
+
element: n,
|
|
1382
|
+
relationType: M,
|
|
1383
|
+
api: _,
|
|
1384
|
+
transfer: F,
|
|
1385
|
+
onConfirm: Kt,
|
|
1386
|
+
onCancel: qt
|
|
1387
|
+
})
|
|
1388
|
+
]
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
function LinkActionButton({ button: e, onClick: t }) {
|
|
1392
|
+
let { label: r } = useModelLabel(e);
|
|
1393
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
1394
|
+
title: r,
|
|
1395
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1396
|
+
size: "small",
|
|
1397
|
+
onClick: t,
|
|
1398
|
+
"data-testid": getButtonTestId(e),
|
|
1399
|
+
"aria-label": r,
|
|
1400
|
+
sx: {
|
|
1401
|
+
borderRadius: 0,
|
|
1402
|
+
px: 1
|
|
1403
|
+
},
|
|
1404
|
+
children: e.icon ? /* @__PURE__ */ jsx(IconRenderer, { icon: e.icon }) : /* @__PURE__ */ jsx("span", {
|
|
1405
|
+
style: { fontSize: "0.875rem" },
|
|
1406
|
+
children: r
|
|
1407
|
+
})
|
|
1408
|
+
})
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
function LinkDropdownItem({ button: e, onClick: t }) {
|
|
1412
|
+
let { label: r } = useModelLabel(e);
|
|
1413
|
+
return /* @__PURE__ */ jsxs(MenuItem, {
|
|
1414
|
+
onClick: t,
|
|
1415
|
+
"data-testid": getButtonTestId(e),
|
|
1416
|
+
children: [e.icon && /* @__PURE__ */ jsx(IconRenderer, { icon: e.icon }), /* @__PURE__ */ jsx("span", {
|
|
1417
|
+
style: { marginLeft: e.icon ? 8 : 0 },
|
|
1418
|
+
children: r
|
|
1419
|
+
})]
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
function StandaloneButtonRenderer({ element: r, page: a, onDispatch: o }) {
|
|
1423
|
+
let s = useElementVisibility(r), l = useElementDisabled(r), u = usePageContextOptional(), d = useDispatchOptional(), f = a ?? u?.pageDefinition, p = o ?? d?.dispatch, { confirm: m } = useConfirmation(), h = async () => {
|
|
1424
|
+
let n = f ? findActionByDefinition(f, r.actionDefinition) : void 0;
|
|
1425
|
+
if (n && p) {
|
|
1426
|
+
let e = r.actionDefinition?.["@type"];
|
|
1427
|
+
if (isDestructiveAction(e) && !await m(getDestructiveConfirmationOptions(e))) return;
|
|
1428
|
+
p(n).catch((e) => {
|
|
1429
|
+
console.error("Button action failed:", e);
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
}, g = getButtonTestId(r), { label: _ } = useModelLabel(r);
|
|
1433
|
+
return s ? null : /* @__PURE__ */ jsx(Button, {
|
|
1434
|
+
variant: (() => {
|
|
1435
|
+
let e = r.buttonStyle;
|
|
1436
|
+
return e === "outlined" ? "outlined" : e === "text" ? "text" : "contained";
|
|
1437
|
+
})(),
|
|
1438
|
+
onClick: h,
|
|
1439
|
+
disabled: l,
|
|
1440
|
+
"data-testid": g,
|
|
1441
|
+
startIcon: r.icon ? /* @__PURE__ */ jsx(IconRenderer, { icon: r.icon }) : void 0,
|
|
1442
|
+
children: _
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
function SubThemeWrapper({ element: e, data: t, children: n }) {
|
|
1446
|
+
let r = useSubThemeProvider(e);
|
|
1447
|
+
return r ? /* @__PURE__ */ jsx(ThemeProvider, {
|
|
1448
|
+
theme: (e) => createTheme(e, r(e, t)),
|
|
1449
|
+
children: n
|
|
1450
|
+
}) : /* @__PURE__ */ jsx(Fragment, { children: n });
|
|
1451
|
+
}
|
|
1452
|
+
function TabControllerRenderer({ element: e, readOnly: t }) {
|
|
1453
|
+
let [n, r] = useState(0), i = getTabControllerTestId(e), a = e.sourceId ?? e["xmi:id"] ?? "unknown", o = getTabListTestId(a);
|
|
1454
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
1455
|
+
"data-testid": i,
|
|
1456
|
+
children: [/* @__PURE__ */ jsx(Tabs, {
|
|
1457
|
+
value: n,
|
|
1458
|
+
onChange: (e, t) => r(t),
|
|
1459
|
+
orientation: e.orientation === "VERTICAL" ? "vertical" : "horizontal",
|
|
1460
|
+
"data-testid": o,
|
|
1461
|
+
children: e.tabs.map((e, t) => /* @__PURE__ */ jsx(TranslatedTab, {
|
|
1462
|
+
tab: e,
|
|
1463
|
+
testId: getTabTestId(a, e, t)
|
|
1464
|
+
}, e["xmi:id"] ?? t))
|
|
1465
|
+
}), e.tabs.map((e, r) => {
|
|
1466
|
+
let i = getTabPanelTestId(a, e, r);
|
|
1467
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
1468
|
+
role: "tabpanel",
|
|
1469
|
+
hidden: n !== r,
|
|
1470
|
+
p: 2,
|
|
1471
|
+
"data-testid": i,
|
|
1472
|
+
children: n === r && e.element && /* @__PURE__ */ jsx(VisualElementRenderer, {
|
|
1473
|
+
element: e.element,
|
|
1474
|
+
readOnly: t
|
|
1475
|
+
})
|
|
1476
|
+
}, e["xmi:id"] ?? r);
|
|
1477
|
+
})]
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
function TranslatedTab({ tab: e, testId: t }) {
|
|
1481
|
+
let { label: n } = useModelLabel(e);
|
|
1482
|
+
return /* @__PURE__ */ jsx(Tab, {
|
|
1483
|
+
label: n,
|
|
1484
|
+
"data-testid": t
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
function VisualElementRenderer({ element: e, readOnly: t }) {
|
|
1488
|
+
if (useElementVisibility(e)) return null;
|
|
1489
|
+
let n = useComponentOverride(e), r = usePageContextOptional();
|
|
1490
|
+
if (n) {
|
|
1491
|
+
let t = r?.pageDefinition;
|
|
1492
|
+
return t ? /* @__PURE__ */ jsx(SubThemeWrapper, {
|
|
1493
|
+
element: e,
|
|
1494
|
+
children: /* @__PURE__ */ jsx(n, {
|
|
1495
|
+
element: e,
|
|
1496
|
+
page: t
|
|
1497
|
+
})
|
|
1498
|
+
}) : null;
|
|
1499
|
+
}
|
|
1500
|
+
let i = useComponentInterceptor(e);
|
|
1501
|
+
if (i) {
|
|
1502
|
+
let t = r?.pageDefinition;
|
|
1503
|
+
return t ? /* @__PURE__ */ jsx(SubThemeWrapper, {
|
|
1504
|
+
element: e,
|
|
1505
|
+
children: /* @__PURE__ */ jsx(i, {
|
|
1506
|
+
element: e,
|
|
1507
|
+
page: t
|
|
1508
|
+
})
|
|
1509
|
+
}) : null;
|
|
1510
|
+
}
|
|
1511
|
+
let a = renderByType(e, t);
|
|
1512
|
+
return a ? /* @__PURE__ */ jsx(SubThemeWrapper, {
|
|
1513
|
+
element: e,
|
|
1514
|
+
children: a
|
|
1515
|
+
}) : null;
|
|
1516
|
+
}
|
|
1517
|
+
function renderByType(e, t) {
|
|
1518
|
+
switch (e["@type"]) {
|
|
1519
|
+
case "Flex":
|
|
1520
|
+
case "PageContainer": return /* @__PURE__ */ jsx(FlexRenderer, {
|
|
1521
|
+
element: e,
|
|
1522
|
+
readOnly: t
|
|
1523
|
+
});
|
|
1524
|
+
case "Table": return /* @__PURE__ */ jsx(TableRenderer, { element: e });
|
|
1525
|
+
case "Link": return /* @__PURE__ */ jsx(LinkRenderer, {
|
|
1526
|
+
element: e,
|
|
1527
|
+
readOnly: t
|
|
1528
|
+
});
|
|
1529
|
+
case "ButtonGroup": return /* @__PURE__ */ jsx(InlineButtonGroupRenderer, { element: e });
|
|
1530
|
+
case "Button": return /* @__PURE__ */ jsx(StandaloneButtonRenderer, { element: e });
|
|
1531
|
+
case "TabController": return /* @__PURE__ */ jsx(TabControllerRenderer, {
|
|
1532
|
+
element: e,
|
|
1533
|
+
readOnly: t
|
|
1534
|
+
});
|
|
1535
|
+
case "TextInput":
|
|
1536
|
+
case "NumericInput":
|
|
1537
|
+
case "DateInput":
|
|
1538
|
+
case "DateTimeInput":
|
|
1539
|
+
case "TimeInput":
|
|
1540
|
+
case "EnumerationCombo":
|
|
1541
|
+
case "EnumerationRadio":
|
|
1542
|
+
case "EnumerationToggleButtonbar":
|
|
1543
|
+
case "Checkbox":
|
|
1544
|
+
case "Switch":
|
|
1545
|
+
case "TrinaryLogicCombo":
|
|
1546
|
+
case "TextArea":
|
|
1547
|
+
case "BinaryTypeInput":
|
|
1548
|
+
case "PasswordInput": return /* @__PURE__ */ jsx(InputRenderer, {
|
|
1549
|
+
element: e,
|
|
1550
|
+
readOnly: t
|
|
1551
|
+
});
|
|
1552
|
+
case "Spacer": return /* @__PURE__ */ jsx("div", {
|
|
1553
|
+
style: { flex: 1 },
|
|
1554
|
+
"data-testid": `spacer::${e["xmi:id"]}`
|
|
1555
|
+
});
|
|
1556
|
+
case "Divider": return /* @__PURE__ */ jsx("hr", { "data-testid": `divider::${e["xmi:id"]}` });
|
|
1557
|
+
case "Formatted": return /* @__PURE__ */ jsx(FormattedRenderer, { element: e });
|
|
1558
|
+
default: return console.warn(`Unknown element type: ${e["@type"]}`), null;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
function FlexRenderer({ element: e, readOnly: t }) {
|
|
1562
|
+
let n = isVerticalLayout(e.direction), r = mapMainAxisAlignment(e.mainAxisAlignment), i = mapCrossAxisAlignment(e.crossAxisAlignment), a = e.col ?? 4, o = {
|
|
1563
|
+
width: e.size?.width ?? "100%",
|
|
1564
|
+
height: e.size?.height,
|
|
1565
|
+
minWidth: e.sizeConstraint?.minWidth,
|
|
1566
|
+
minHeight: e.sizeConstraint?.minHeight,
|
|
1567
|
+
maxWidth: e.sizeConstraint?.maxWidth ?? "100%",
|
|
1568
|
+
maxHeight: e.sizeConstraint?.maxHeight
|
|
1569
|
+
}, s = e.children?.map((n) => /* @__PURE__ */ jsx(FlexChild, {
|
|
1570
|
+
child: n,
|
|
1571
|
+
gridSize: calculateChildGridSize(e.direction, a, n.col ?? 4),
|
|
1572
|
+
readOnly: t
|
|
1573
|
+
}, n["xmi:id"])), c = n ? /* @__PURE__ */ jsx(Stack$1, {
|
|
1574
|
+
spacing: 2,
|
|
1575
|
+
className: "force-full-width",
|
|
1576
|
+
"data-testid": `flex::${e.sourceId ?? e["xmi:id"]}`,
|
|
1577
|
+
sx: o,
|
|
1578
|
+
children: s
|
|
1579
|
+
}) : /* @__PURE__ */ jsx(Grid$1, {
|
|
1580
|
+
container: !0,
|
|
1581
|
+
justifyContent: r,
|
|
1582
|
+
alignItems: i,
|
|
1583
|
+
spacing: 2,
|
|
1584
|
+
"data-testid": `flex::${e.sourceId ?? e["xmi:id"]}`,
|
|
1585
|
+
sx: o,
|
|
1586
|
+
children: s
|
|
1587
|
+
});
|
|
1588
|
+
return e.frame ? /* @__PURE__ */ jsx(TranslatedFrame, {
|
|
1589
|
+
element: e,
|
|
1590
|
+
children: c
|
|
1591
|
+
}) : c;
|
|
1592
|
+
}
|
|
1593
|
+
function TranslatedFrame({ element: e, children: t }) {
|
|
1594
|
+
let { label: n } = useModelLabel(e);
|
|
1595
|
+
return /* @__PURE__ */ jsx(FrameRenderer, {
|
|
1596
|
+
frame: e.frame,
|
|
1597
|
+
label: n,
|
|
1598
|
+
icon: e.icon,
|
|
1599
|
+
children: t
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
function FlexChild({ child: e, gridSize: t, readOnly: n }) {
|
|
1603
|
+
return useElementVisibility(e) ? null : /* @__PURE__ */ jsx(Grid$1, {
|
|
1604
|
+
size: t,
|
|
1605
|
+
sx: { minWidth: 0 },
|
|
1606
|
+
children: /* @__PURE__ */ jsx(VisualElementRenderer, {
|
|
1607
|
+
element: e,
|
|
1608
|
+
readOnly: n
|
|
1609
|
+
})
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
export { calculateVerticalGridSize as A, BinaryInputComponent as C, calculateChildGridSize as D, FULL_GRID_WIDTH as E, mapAlignment as M, mapCrossAxisAlignment as N, calculateHorizontalGridSize as O, mapMainAxisAlignment as P, CheckboxComponent as S, DEFAULT_COL as T, EnumerationToggleButtonbarComponent as _, StandaloneButtonRenderer as a, DateTimeInputComponent as b, LinkSelectorDialog as c, TimeInputComponent as d, TextInputComponent as f, NumericInputComponent as g, PasswordInputComponent as h, SubThemeWrapper as i, isVerticalLayout as j, calculateScaledSize as k, InlineButtonGroupRenderer as l, SwitchComponent as m, VisualElementRenderer as n, LinkRenderer as o, TextAreaComponent as p, TabControllerRenderer as r, buildMaskString as s, FlexRenderer as t, InputRenderer as u, EnumerationRadioComponent as v, FrameRenderer as w, DateInputComponent as x, EnumerationComboComponent as y };
|