@parallelworks/ui 0.20.0 → 0.21.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/dist/ai/adapter/openai/createOpenAIStream.js +3 -2
- package/dist/ai/agent/diff.d.ts +0 -1
- package/dist/ai/agent/diff.js +3 -2
- package/dist/ai/agent/toolfmt.js +2 -3
- package/dist/ai/ai.css +5 -0
- package/dist/ai/components/AllocationSelector.js +3 -2
- package/dist/ai/components/AttachmentManager.js +1 -1
- package/dist/ai/components/BranchNavigator.js +4 -2
- package/dist/ai/components/ChatInput.d.ts +2 -5
- package/dist/ai/components/ChatInput.js +10 -7
- package/dist/ai/components/ChatMessage.js +7 -7
- package/dist/ai/components/ChatSidebar.d.ts +0 -1
- package/dist/ai/components/ChatSidebar.js +4 -6
- package/dist/ai/components/ChatThread.js +5 -8
- package/dist/ai/components/ModelSelector.js +3 -2
- package/dist/ai/components/ShareDialog.js +6 -3
- package/dist/ai/components/SlashMenu.d.ts +0 -1
- package/dist/ai/components/agent/ActivityLine.d.ts +0 -1
- package/dist/ai/components/agent/ActivityLine.js +2 -2
- package/dist/ai/components/agent/AgentMessageParts.d.ts +1 -26
- package/dist/ai/components/agent/AgentMessageParts.js +4 -5
- package/dist/ai/core/ChatProvider.d.ts +2 -6
- package/dist/ai/core/ChatProvider.js +42 -67
- package/dist/ai/core/KeyboardShortcutsProvider.js +1 -1
- package/dist/ai/core/chatReducer.d.ts +0 -6
- package/dist/ai/core/chatReducer.js +1 -15
- package/dist/ai/core/useKeyboardShortcuts.d.ts +3 -1
- package/dist/ai/core/useKeyboardShortcuts.js +9 -11
- package/dist/ai/core/useSSEStream.d.ts +0 -1
- package/dist/ai/core/useSSEStream.js +5 -17
- package/dist/ai/strings.d.ts +0 -1
- package/dist/ai/strings.js +0 -1
- package/dist/ai/types.d.ts +1 -1
- package/dist/ai/ui/Avatar.d.ts +1 -2
- package/dist/ai/ui/Avatar.js +7 -18
- package/dist/ai/ui/Markdown.d.ts +1 -3
- package/dist/ai/ui/Markdown.js +1 -2
- package/dist/ai/ui/sidebar.d.ts +0 -1
- package/dist/ai/ui/sidebar.js +3 -1
- package/dist/ai/utils.js +1 -1
- package/dist/components/Avatar.js +4 -2
- package/dist/components/BareModal.js +1 -5
- package/dist/components/Breadcrumbs.js +21 -14
- package/dist/components/CollapsiblePanel.d.ts +1 -3
- package/dist/components/CollapsiblePanel.js +5 -5
- package/dist/components/Dropdown.d.ts +0 -4
- package/dist/components/Dropdown.js +5 -6
- package/dist/components/Listbox.js +14 -18
- package/dist/components/MultiSelect.js +5 -8
- package/dist/components/Pagination.js +1 -1
- package/dist/components/Provider.d.ts +0 -8
- package/dist/components/SwitchToggle.js +3 -5
- package/dist/components/Table.d.ts +1 -3
- package/dist/components/dropdownUtils.js +5 -6
- package/dist/components/relativeTime.d.ts +0 -7
- package/dist/components/relativeTime.js +1 -1
- package/dist/duration.js +1 -1
- package/dist/editor/Editor.d.ts +1 -1
- package/dist/editor/Editor.js +1 -1
- package/dist/editor/EditorField.d.ts +0 -1
- package/dist/editor/EditorField.js +8 -8
- package/dist/editor/FormCodePanel.js +14 -20
- package/dist/editor/yamlLanguage.js +2 -2
- package/dist/file-explorer/FileExplorer.js +56 -59
- package/dist/file-explorer/FileExplorerContext.d.ts +1 -2
- package/dist/file-explorer/FileExplorerContext.js +92 -125
- package/dist/file-explorer/FilePreview/Inline.d.ts +1 -2
- package/dist/file-explorer/FilePreview/Inline.js +2 -2
- package/dist/file-explorer/FilePreview/Viewer.js +0 -4
- package/dist/file-explorer/FilePreview/index.d.ts +1 -2
- package/dist/file-explorer/FilePreview/index.js +3 -3
- package/dist/file-explorer/FilePreview/parse.d.ts +2 -1
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.d.ts +5 -4
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +23 -36
- package/dist/file-explorer/FilePreview/useObjectText.d.ts +1 -2
- package/dist/file-explorer/FilePreview/useObjectText.js +5 -7
- package/dist/file-explorer/FileRow.js +1 -1
- package/dist/file-explorer/FileRowsWindow.d.ts +5 -12
- package/dist/file-explorer/FileTable.d.ts +2 -6
- package/dist/file-explorer/LoadMoreRow.d.ts +8 -0
- package/dist/file-explorer/TreeView.d.ts +0 -1
- package/dist/file-explorer/TreeView.js +6 -6
- package/dist/file-explorer/helpers.js +2 -4
- package/dist/file-explorer/lib/fileExplorer.d.ts +0 -2
- package/dist/file-explorer/lib/types.d.ts +0 -1
- package/dist/file-explorer/lib/utils.js +15 -20
- package/dist/file-explorer/toasts.js +36 -34
- package/dist/form/Fields/BooleanField.js +5 -4
- package/dist/form/Fields/CheckboxGroupField.js +5 -4
- package/dist/form/Fields/ColorField.js +5 -4
- package/dist/form/Fields/DropdownField.d.ts +0 -1
- package/dist/form/Fields/DropdownField.js +10 -13
- package/dist/form/Fields/DurationField.js +2 -2
- package/dist/form/Fields/LabelField.js +5 -5
- package/dist/form/Fields/MultiDropdownField.d.ts +1 -1
- package/dist/form/Fields/MultiDropdownField.js +8 -11
- package/dist/form/Fields/NumberField.js +6 -5
- package/dist/form/Fields/ObjectField.d.ts +1 -2
- package/dist/form/Fields/ObjectField.js +22 -21
- package/dist/form/Fields/RadioField.js +4 -3
- package/dist/form/Fields/RangeField.js +7 -6
- package/dist/form/Fields/StringField.js +2 -1
- package/dist/form/Fields/TextAreaField.js +2 -1
- package/dist/form/Form.d.ts +7 -8
- package/dist/form/Form.js +52 -78
- package/dist/form/SpecialTypes/DropdownWrapper.d.ts +0 -2
- package/dist/form/SpecialTypes/DropdownWrapper.js +1 -3
- package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +1 -3
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +4 -7
- package/dist/form/SpecialTypes/FormikCustomInput.js +13 -11
- package/dist/form/Wizard/WizardContainer.js +8 -25
- package/dist/form/Wizard/WizardNavigation.d.ts +1 -1
- package/dist/form/Wizard/WizardNavigation.js +5 -6
- package/dist/form/Wizard/WizardStepContent.d.ts +1 -1
- package/dist/form/Wizard/WizardStepContent.js +2 -2
- package/dist/form/Wizard/WizardStepIndicator.js +7 -17
- package/dist/form/Wizard/types.d.ts +4 -46
- package/dist/form/Wizard/useWizardState.d.ts +2 -10
- package/dist/form/Wizard/useWizardState.js +42 -92
- package/dist/form/Wizard/utils.js +6 -11
- package/dist/form/lib.js +28 -54
- package/dist/form/types/fieldTypes.d.ts +4 -5
- package/dist/form/utils/dependentOptions.d.ts +6 -0
- package/dist/form/utils/dependentOptions.js +21 -0
- package/dist/form/utils/getParentValue.d.ts +2 -1
- package/dist/form/utils/getParentValue.js +10 -15
- package/dist/form/utils/getValueUsingPath.js +1 -1
- package/dist/graph/AnnotationBanner.d.ts +1 -1
- package/dist/graph/AnnotationBanner.js +1 -1
- package/dist/graph/Collapse.d.ts +3 -3
- package/dist/graph/Collapse.js +3 -8
- package/dist/graph/DependencyGraph.d.ts +5 -4
- package/dist/graph/DependencyGraph.js +172 -222
- package/dist/graph/JobSummary.d.ts +10 -8
- package/dist/graph/JobSummary.js +13 -13
- package/dist/graph/MatrixGroup.d.ts +5 -17
- package/dist/graph/MatrixGroup.js +11 -22
- package/dist/graph/TreeView.d.ts +1 -3
- package/dist/graph/TreeView.js +104 -491
- package/dist/graph/types.d.ts +3 -2
- package/dist/graph/util.d.ts +5 -0
- package/dist/graph/util.js +18 -0
- package/dist/icons.d.ts +2 -2
- package/dist/icons.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/list/ListViewControls.js +17 -35
- package/dist/list/RowContextMenu.js +7 -7
- package/dist/logviewer/LogViewer.js +7 -9
- package/dist/logviewer/segments.js +2 -2
- package/dist/styles/theme.css +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme/index.js +5 -5
- package/package.json +28 -30
- package/dist/ai/ui/buttons.d.ts +0 -1
|
@@ -2,7 +2,7 @@ import { useStrings } from "../components/Provider.js";
|
|
|
2
2
|
import { AlertIcon, AngleDownIcon, AngleUpIcon, CloseIcon, CloudUploadIcon, ExpandVerticalIcon, MinimizeIcon, SuccessIcon } from "../icons.js";
|
|
3
3
|
import { formatETA, formatFileSize } from "./lib/utils.js";
|
|
4
4
|
import cx from "classnames";
|
|
5
|
-
import {
|
|
5
|
+
import { useState } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/file-explorer/toasts.tsx
|
|
8
8
|
function getSessionStatusInfo(session, queueLength, strings) {
|
|
@@ -39,19 +39,24 @@ function getSessionStatusInfo(session, queueLength, strings) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function barColor({ isCompleted, isCancelled, isFailed }) {
|
|
43
|
+
if (isCompleted) return "bg-green-600";
|
|
44
|
+
if (isCancelled) return "bg-(--theme-muted-text-color)";
|
|
45
|
+
return isFailed ? "bg-red-600" : "theme-element";
|
|
46
|
+
}
|
|
47
|
+
function FileProgressBar({ fileProgress, fileName, onCancelFile }) {
|
|
43
48
|
const strings = useStrings().fileExplorer.upload;
|
|
44
49
|
const [isHovered, setIsHovered] = useState(false);
|
|
45
50
|
const [showCancelConfirm, setShowCancelConfirm] = useState(false);
|
|
46
|
-
const percentage = fileProgress
|
|
47
|
-
const loadedBytes = fileProgress
|
|
48
|
-
const totalBytes = fileProgress.fileSizeBytes || fileProgress
|
|
51
|
+
const percentage = fileProgress.percentage || 0;
|
|
52
|
+
const loadedBytes = fileProgress.loadedBytes || 0;
|
|
53
|
+
const totalBytes = fileProgress.fileSizeBytes || fileProgress.totalBytes || 0;
|
|
49
54
|
const isCompleted = percentage === 100 || fileProgress.status === "completed";
|
|
50
55
|
const isCancelled = fileProgress.status === "cancelled";
|
|
51
56
|
const isFailed = fileProgress.status === "failed";
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
57
|
+
const isSettled = isCompleted || isCancelled || isFailed;
|
|
58
|
+
const isUploading = fileProgress.status === "uploading" || !isSettled;
|
|
59
|
+
const canCancel = !!fileProgress.abortController && !isSettled;
|
|
55
60
|
const handleCancelClick = (e) => {
|
|
56
61
|
e.stopPropagation();
|
|
57
62
|
setShowCancelConfirm(true);
|
|
@@ -92,7 +97,11 @@ function FileProgressBar({ fileProgress, fileName, progressBarColorScheme, onCan
|
|
|
92
97
|
children: /* @__PURE__ */ jsxs("div", {
|
|
93
98
|
className: cx("w-full bg-(--theme-border) rounded-full overflow-hidden transition-all duration-300 ease-in-out flex items-center", isHovered && !isCompleted ? "h-6" : "h-2"),
|
|
94
99
|
children: [/* @__PURE__ */ jsx("div", {
|
|
95
|
-
className: cx("h-full transition-all duration-300 relative flex items-center justify-center", barColor
|
|
100
|
+
className: cx("h-full transition-all duration-300 relative flex items-center justify-center", barColor({
|
|
101
|
+
isCompleted,
|
|
102
|
+
isCancelled,
|
|
103
|
+
isFailed
|
|
104
|
+
}), isHovered && "opacity-80"),
|
|
96
105
|
style: { width: `${percentage}%` }
|
|
97
106
|
}), isHovered && !isCompleted && totalBytes > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
98
107
|
className: "absolute inset-0 flex items-center justify-center text-xs whitespace-nowrap p-0.5 z-10",
|
|
@@ -157,29 +166,24 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
157
166
|
const [isToastExpanded, setIsToastExpanded] = useState(false);
|
|
158
167
|
const [isFileListExpanded, setIsExpanded] = useState(session.uploadNodes.length <= 3);
|
|
159
168
|
const [showCancelConfirm, setShowCancelConfirm] = useState(false);
|
|
160
|
-
const statusInfo =
|
|
161
|
-
session,
|
|
162
|
-
queueLength,
|
|
163
|
-
strings
|
|
164
|
-
]);
|
|
169
|
+
const statusInfo = getSessionStatusInfo(session, queueLength, strings);
|
|
165
170
|
const targetPath = `${session.targetPath}/`;
|
|
166
|
-
const isQueued = session.status === "queued";
|
|
167
171
|
const isCompleted = session.status === "completed";
|
|
168
172
|
const isCancelled = session.status === "cancelled";
|
|
169
173
|
const isFailed = session.status === "failed";
|
|
170
|
-
const isUploading =
|
|
174
|
+
const isUploading = !isCompleted && !isCancelled && !isFailed;
|
|
171
175
|
const totalProgress = session.progress?.overallProgress || 0;
|
|
172
176
|
const totalSize = session.progress?.totalSizeBytes || 0;
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
179
|
-
const barColor = isCompleted ? progressBarColorScheme.completed : isCancelled ? progressBarColorScheme.cancelled : isFailed ? progressBarColorScheme.failed : progressBarColorScheme.uploading;
|
|
177
|
+
const sessionBarColor = barColor({
|
|
178
|
+
isCompleted,
|
|
179
|
+
isCancelled,
|
|
180
|
+
isFailed
|
|
181
|
+
});
|
|
180
182
|
const allFiles = session.progress?.allFiles ? Array.from(session.progress.allFiles.values()) : [];
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
+
const singleFile = allFiles[0];
|
|
184
|
+
const singleNode = session.uploadNodes.length === 1 ? session.uploadNodes[0] : void 0;
|
|
185
|
+
const uploadingFiles = allFiles.filter((file) => (file.percentage ?? 0) > 0 && (file.percentage ?? 0) < 100);
|
|
186
|
+
const shouldShowSessionCancelButton = !showCancelConfirm && isUploading && session.uploadNodes.length > 1;
|
|
183
187
|
const estimatedSecondsLeft = session.progress?.estimatedSecondsLeft;
|
|
184
188
|
const showETA = isUploading && estimatedSecondsLeft && estimatedSecondsLeft > 0;
|
|
185
189
|
const handleExpandClick = (e) => {
|
|
@@ -251,7 +255,7 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
251
255
|
children: /* @__PURE__ */ jsx("div", {
|
|
252
256
|
className: "flex-1 h-1.5 bg-(--theme-border) rounded-full overflow-hidden",
|
|
253
257
|
children: /* @__PURE__ */ jsx("div", {
|
|
254
|
-
className: cx("h-full transition-all duration-300",
|
|
258
|
+
className: cx("h-full transition-all duration-300", sessionBarColor),
|
|
255
259
|
style: { width: `${totalProgress}%` }
|
|
256
260
|
})
|
|
257
261
|
})
|
|
@@ -323,7 +327,7 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
323
327
|
})]
|
|
324
328
|
})
|
|
325
329
|
}),
|
|
326
|
-
session.uploadNodes.length > 1 &&
|
|
330
|
+
session.uploadNodes.length > 1 && isUploading && /* @__PURE__ */ jsxs("div", {
|
|
327
331
|
className: "space-y-2",
|
|
328
332
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
329
333
|
className: "flex items-center justify-between text-xs theme-muted-text",
|
|
@@ -331,7 +335,7 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
331
335
|
}), /* @__PURE__ */ jsx("div", {
|
|
332
336
|
className: "h-2 w-full bg-(--theme-border) rounded-full overflow-hidden",
|
|
333
337
|
children: /* @__PURE__ */ jsx("div", {
|
|
334
|
-
className: cx("h-full transition-all duration-300",
|
|
338
|
+
className: cx("h-full transition-all duration-300", sessionBarColor),
|
|
335
339
|
style: { width: `${totalProgress}%` }
|
|
336
340
|
})
|
|
337
341
|
})]
|
|
@@ -351,17 +355,15 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
351
355
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(FileProgressBar, {
|
|
352
356
|
fileProgress,
|
|
353
357
|
fileName: node.name,
|
|
354
|
-
progressBarColorScheme,
|
|
355
358
|
onCancelFile: () => onCancelFile?.(node.relativePath)
|
|
356
359
|
}) }, node.relativePath);
|
|
357
360
|
})
|
|
358
361
|
})]
|
|
359
362
|
}),
|
|
360
|
-
|
|
361
|
-
fileProgress:
|
|
362
|
-
fileName:
|
|
363
|
-
|
|
364
|
-
onCancelFile: () => onCancelFile?.(session.uploadNodes[0].relativePath)
|
|
363
|
+
singleNode && singleFile && /* @__PURE__ */ jsx(FileProgressBar, {
|
|
364
|
+
fileProgress: singleFile,
|
|
365
|
+
fileName: singleNode.name,
|
|
366
|
+
onCancelFile: () => onCancelFile?.(singleNode.relativePath)
|
|
365
367
|
}),
|
|
366
368
|
/* @__PURE__ */ jsxs("div", {
|
|
367
369
|
className: "flex items-center justify-end",
|
|
@@ -5,13 +5,14 @@ import { useField, useFormikContext } from "formik";
|
|
|
5
5
|
//#region src/form/Fields/BooleanField.tsx
|
|
6
6
|
function BooleanField(props) {
|
|
7
7
|
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
|
|
8
|
-
const
|
|
8
|
+
const fieldName = field.name ?? "";
|
|
9
|
+
const [fieldState] = useField(fieldName);
|
|
9
10
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
10
11
|
const handleChange = (val) => {
|
|
11
12
|
if (disabled) return;
|
|
12
|
-
|
|
13
|
-
setFieldTouched(
|
|
14
|
-
setFieldValue(
|
|
13
|
+
onChange?.(val);
|
|
14
|
+
setFieldTouched(fieldName, true);
|
|
15
|
+
setFieldValue(fieldName, val);
|
|
15
16
|
setFormDirty(true);
|
|
16
17
|
};
|
|
17
18
|
const value = fieldState.value;
|
|
@@ -13,7 +13,8 @@ function union(manual, forced) {
|
|
|
13
13
|
return [...manual, ...[...forced].filter((v) => !manual.includes(v))];
|
|
14
14
|
}
|
|
15
15
|
function CheckboxGroupField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty }) {
|
|
16
|
-
const
|
|
16
|
+
const fieldName = field.name ?? "";
|
|
17
|
+
const [fieldState] = useField(fieldName);
|
|
17
18
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
18
19
|
const implies = field.implies;
|
|
19
20
|
const [manual, setManual] = useState(() => {
|
|
@@ -27,9 +28,9 @@ function CheckboxGroupField({ field, label, labelPosition, missing, disabled, on
|
|
|
27
28
|
const nextManual = manual.includes(value) ? manual.filter((v) => v !== value) : [...manual, value];
|
|
28
29
|
const next = union(nextManual, impliedFrom(nextManual, implies));
|
|
29
30
|
setManual(nextManual);
|
|
30
|
-
setFieldTouched(
|
|
31
|
-
setFieldValue(
|
|
32
|
-
|
|
31
|
+
setFieldTouched(fieldName, true);
|
|
32
|
+
setFieldValue(fieldName, next);
|
|
33
|
+
onChange?.(next);
|
|
33
34
|
setFormDirty(true);
|
|
34
35
|
};
|
|
35
36
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
@@ -4,13 +4,14 @@ import { Field, useField, useFormikContext } from "formik";
|
|
|
4
4
|
//#region src/form/Fields/ColorField.tsx
|
|
5
5
|
function ColorField(props) {
|
|
6
6
|
const { field, label, labelPosition, onChange, tooltipComponent, spaceCompact } = props;
|
|
7
|
-
const
|
|
7
|
+
const fieldName = field.name ?? "";
|
|
8
|
+
const [fieldState] = useField(fieldName);
|
|
8
9
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
9
10
|
const handleChange = (e) => {
|
|
10
11
|
const val = e.target.value;
|
|
11
|
-
|
|
12
|
-
setFieldTouched(
|
|
13
|
-
setFieldValue(
|
|
12
|
+
onChange?.(val);
|
|
13
|
+
setFieldTouched(fieldName, true);
|
|
14
|
+
setFieldValue(fieldName, val);
|
|
14
15
|
};
|
|
15
16
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
16
17
|
optional: field.optional,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
2
|
import FormikCustomDropdown_default from "../SpecialTypes/FormikCustomDropdown.js";
|
|
3
3
|
import { getPlaceholder } from "../utils/getPlaceholder.js";
|
|
4
|
+
import { dependentOptions } from "../utils/dependentOptions.js";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/form/Fields/DropdownField.tsx
|
|
7
|
+
var missingSetter = () => {
|
|
8
|
+
throw new Error("DropdownField needs setFieldValue and setFieldTouched");
|
|
9
|
+
};
|
|
6
10
|
function DropdownField(props) {
|
|
7
|
-
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFieldValue, setFieldTouched, currentValue } = props;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (field.depends_on) {
|
|
11
|
-
parentValue = field.depends_on;
|
|
12
|
-
if (!Array.isArray(field.options)) options = field.options[parentValue] ?? [];
|
|
13
|
-
}
|
|
11
|
+
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFieldValue, setFieldTouched, currentValue, values } = props;
|
|
12
|
+
const fieldName = field.name ?? "";
|
|
13
|
+
const { options } = dependentOptions(field.options, field.depends_on, values);
|
|
14
14
|
const secondaryField = Array.isArray(field.secondaryField) ? field.secondaryField[0] : field.secondaryField;
|
|
15
15
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
16
16
|
optional: field.optional,
|
|
@@ -24,23 +24,20 @@ function DropdownField(props) {
|
|
|
24
24
|
children: /* @__PURE__ */ jsx(FormikCustomDropdown_default, {
|
|
25
25
|
invalid: missing,
|
|
26
26
|
className: "w-full",
|
|
27
|
-
name:
|
|
27
|
+
name: fieldName,
|
|
28
28
|
ariaLabel: label,
|
|
29
29
|
options,
|
|
30
30
|
setFormDirty: props.setFormDirty,
|
|
31
|
-
parentValue,
|
|
32
31
|
onChange,
|
|
33
32
|
secondaryField,
|
|
34
33
|
disabled,
|
|
35
|
-
resetOnChange: field.resetOnChange ? field.name : "",
|
|
36
|
-
loading: false,
|
|
37
34
|
autoselect: field.autoselect,
|
|
38
35
|
allowCustomValue: field.allowCustomValue,
|
|
39
36
|
customValueLabel: field.customValueLabel,
|
|
40
37
|
placeholder: getPlaceholder(field.placeholder, typeof field.default === "string" ? field.default : void 0),
|
|
41
38
|
currentValue,
|
|
42
|
-
setFieldValue,
|
|
43
|
-
setFieldTouched
|
|
39
|
+
setFieldValue: setFieldValue ?? missingSetter,
|
|
40
|
+
setFieldTouched: setFieldTouched ?? missingSetter
|
|
44
41
|
}, field.name)
|
|
45
42
|
})
|
|
46
43
|
});
|
|
@@ -15,7 +15,7 @@ var toDisplay = (value) => {
|
|
|
15
15
|
};
|
|
16
16
|
var DurationField_default = memo(function DurationField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty, currentValue, setFieldValue, setFieldTouched }) {
|
|
17
17
|
const { form: t } = useStrings();
|
|
18
|
-
const name = field.name;
|
|
18
|
+
const name = field.name ?? "";
|
|
19
19
|
const min = field.min !== void 0 ? Number(field.min) : Number.NEGATIVE_INFINITY;
|
|
20
20
|
const max = field.max !== void 0 ? Number(field.max) : Number.POSITIVE_INFINITY;
|
|
21
21
|
const disableValue = field.disableValue;
|
|
@@ -57,7 +57,7 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
57
57
|
setFormDirty(true);
|
|
58
58
|
if (checked) {
|
|
59
59
|
setText("");
|
|
60
|
-
flushToFormik(disableValue);
|
|
60
|
+
if (disableValue !== void 0) flushToFormik(disableValue);
|
|
61
61
|
} else flushToFormik(typeof field.default === "number" ? field.default : "");
|
|
62
62
|
};
|
|
63
63
|
const handleChange = (e) => {
|
|
@@ -6,12 +6,12 @@ function LabelField(props) {
|
|
|
6
6
|
return /* @__PURE__ */ jsx("div", {
|
|
7
7
|
className: "flex items-center w-full",
|
|
8
8
|
children: /* @__PURE__ */ jsx("h3", {
|
|
9
|
-
style:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
9
|
+
style: {
|
|
10
|
+
whiteSpace: "pre-wrap",
|
|
11
|
+
...field.size ? { fontSize: `${field.size}px` } : {}
|
|
12
|
+
},
|
|
13
13
|
className: cx("relative", "text-md", field.bold !== false ? "font-bold" : ""),
|
|
14
|
-
children: field.text
|
|
14
|
+
children: field.text?.toString().replace(/(\r)/g, "").replace(/(\\n)/g, "\n") || label
|
|
15
15
|
})
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -15,4 +15,4 @@ export interface IMultiDropdownField extends BaseField {
|
|
|
15
15
|
}>>;
|
|
16
16
|
parentValue?: string | boolean | number;
|
|
17
17
|
}
|
|
18
|
-
export default function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, setFormDirty, onChange, }: FieldComponentProps<IMultiDropdownField>): import("react").JSX.Element;
|
|
18
|
+
export default function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, setFormDirty, onChange, values, }: FieldComponentProps<IMultiDropdownField>): import("react").JSX.Element;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
+
import { dependentOptions } from "../utils/dependentOptions.js";
|
|
2
3
|
import { MultiSelectionDropdown } from "../Form.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { Field } from "formik";
|
|
5
6
|
//#region src/form/Fields/MultiDropdownField.tsx
|
|
6
|
-
function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, setFormDirty, onChange }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!Array.isArray(field.options)) options = field.options[parentValue] || [];
|
|
12
|
-
}
|
|
7
|
+
function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, setFormDirty, onChange, values }) {
|
|
8
|
+
const fieldName = field.name ?? "";
|
|
9
|
+
const dependent = dependentOptions(field.options, field.depends_on, values);
|
|
10
|
+
const { options } = dependent;
|
|
11
|
+
const parentValue = field.depends_on ? dependent.parentValue : field.parentValue;
|
|
13
12
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
14
13
|
optional: field.optional,
|
|
15
14
|
label,
|
|
@@ -24,14 +23,12 @@ function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spa
|
|
|
24
23
|
disabled: true,
|
|
25
24
|
onChange
|
|
26
25
|
}, field.name) : /* @__PURE__ */ jsx(MultiSelectionDropdown, {
|
|
27
|
-
|
|
28
|
-
name: field.name,
|
|
26
|
+
name: fieldName,
|
|
29
27
|
label: field.label || label,
|
|
30
|
-
options
|
|
28
|
+
options,
|
|
31
29
|
setFormDirty,
|
|
32
30
|
parentValue,
|
|
33
31
|
onChange,
|
|
34
|
-
secondaryField: typeof field.secondaryField === "string" ? field.secondaryField : void 0,
|
|
35
32
|
invalid: missing
|
|
36
33
|
}, field.name)
|
|
37
34
|
});
|
|
@@ -8,14 +8,15 @@ import { useField, useFormikContext } from "formik";
|
|
|
8
8
|
//#region src/form/Fields/NumberField.tsx
|
|
9
9
|
function NumberField(props) {
|
|
10
10
|
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact } = props;
|
|
11
|
-
const
|
|
11
|
+
const fieldName = field.name ?? "";
|
|
12
|
+
const [fieldState] = useField(fieldName);
|
|
12
13
|
const { setFieldValue } = useFormikContext();
|
|
13
14
|
useEffect(() => {
|
|
14
|
-
if (field.prefillDefault && field.default !== void 0 && (fieldState.value === void 0 || fieldState.value === null || fieldState.value === "")) setFieldValue(
|
|
15
|
+
if (field.prefillDefault && field.default !== void 0 && (fieldState.value === void 0 || fieldState.value === null || fieldState.value === "")) setFieldValue(fieldName, field.default);
|
|
15
16
|
}, [
|
|
16
17
|
field.prefillDefault,
|
|
17
18
|
field.default,
|
|
18
|
-
|
|
19
|
+
fieldName,
|
|
19
20
|
fieldState.value,
|
|
20
21
|
setFieldValue
|
|
21
22
|
]);
|
|
@@ -27,7 +28,7 @@ function NumberField(props) {
|
|
|
27
28
|
spaceCompact,
|
|
28
29
|
children: field.thousandsSeparator ? /* @__PURE__ */ jsx(FormikNumericInput, {
|
|
29
30
|
invalid: missing,
|
|
30
|
-
name:
|
|
31
|
+
name: fieldName,
|
|
31
32
|
placeholder: getPlaceholder(field.placeholder, field.default),
|
|
32
33
|
disabled,
|
|
33
34
|
min: field.min,
|
|
@@ -35,7 +36,7 @@ function NumberField(props) {
|
|
|
35
36
|
...onChange && { onChange }
|
|
36
37
|
}, field.name) : /* @__PURE__ */ jsx(FormikCustomInput, {
|
|
37
38
|
invalid: missing,
|
|
38
|
-
name:
|
|
39
|
+
name: fieldName,
|
|
39
40
|
type: "number",
|
|
40
41
|
placeholder: getPlaceholder(field.placeholder, field.default),
|
|
41
42
|
disabled,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { FieldComponentProps } from '../types/fieldComponentTypes.js';
|
|
3
2
|
import type { BaseField, DynamicFormSchema } from '../types/fieldTypes.js';
|
|
4
3
|
export interface IObjectField extends BaseField {
|
|
5
4
|
type: 'object';
|
|
6
5
|
options: DynamicFormSchema;
|
|
7
6
|
}
|
|
8
|
-
export default function ObjectField({ field, label, tooltipComponent, missingFields, setFormDirty, workflowForm, labelPosition, spaceCompact, }: FieldComponentProps<IObjectField>):
|
|
7
|
+
export default function ObjectField({ field, label, tooltipComponent, missingFields, setFormDirty, workflowForm, labelPosition, spaceCompact, }: FieldComponentProps<IObjectField>): import("react").JSX.Element;
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { ControlledCollapsiblePanel } from "../../components/CollapsiblePanel.js";
|
|
2
2
|
import { FieldsFromOptions, GroupHeader, resolveMetaOverrides } from "../Form.js";
|
|
3
|
-
import
|
|
3
|
+
import { useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useFormikContext } from "formik";
|
|
6
6
|
//#region src/form/Fields/ObjectField.tsx
|
|
7
7
|
function ObjectField({ field, label, tooltipComponent, missingFields, setFormDirty, workflowForm, labelPosition, spaceCompact }) {
|
|
8
|
+
const fieldName = field.name ?? "";
|
|
8
9
|
const [open, setOpen] = useState(field.collapsed !== void 0 ? !field.collapsed : true);
|
|
9
10
|
const { values, setFieldValue, setFieldTouched } = useFormikContext();
|
|
10
11
|
const meta = resolveMetaOverrides(field.options, labelPosition, spaceCompact ?? false);
|
|
11
|
-
const
|
|
12
|
+
const body = /* @__PURE__ */ jsx("div", {
|
|
13
|
+
className: "w-full",
|
|
14
|
+
children: /* @__PURE__ */ jsx(FieldsFromOptions, {
|
|
15
|
+
options: field.options,
|
|
16
|
+
values,
|
|
17
|
+
setFormDirty,
|
|
18
|
+
setFieldValue,
|
|
19
|
+
setFieldTouched,
|
|
20
|
+
missingFields,
|
|
21
|
+
workflowForm,
|
|
22
|
+
labelPosition: meta.labelPosition,
|
|
23
|
+
spaceCompact: meta.spaceCompact,
|
|
24
|
+
parentInfo: {
|
|
25
|
+
parentName: fieldName,
|
|
26
|
+
fieldNamePrefix: `${fieldName}.`
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
});
|
|
12
30
|
return /* @__PURE__ */ jsxs("div", {
|
|
13
31
|
className: "flex flex-col w-full",
|
|
14
32
|
children: [field.noCollapse && /* @__PURE__ */ jsx("div", {
|
|
@@ -21,7 +39,7 @@ function ObjectField({ field, label, tooltipComponent, missingFields, setFormDir
|
|
|
21
39
|
tooltipComponent
|
|
22
40
|
]
|
|
23
41
|
})
|
|
24
|
-
}), /* @__PURE__ */ jsx(
|
|
42
|
+
}), field.noCollapse ? body : /* @__PURE__ */ jsx(ControlledCollapsiblePanel, {
|
|
25
43
|
open,
|
|
26
44
|
setOpen,
|
|
27
45
|
title: /* @__PURE__ */ jsx(GroupHeader, {
|
|
@@ -29,24 +47,7 @@ function ObjectField({ field, label, tooltipComponent, missingFields, setFormDir
|
|
|
29
47
|
setOpen,
|
|
30
48
|
title: field.label || label
|
|
31
49
|
}),
|
|
32
|
-
children:
|
|
33
|
-
className: "w-full",
|
|
34
|
-
children: /* @__PURE__ */ jsx(FieldsFromOptions, {
|
|
35
|
-
options: field.options,
|
|
36
|
-
values,
|
|
37
|
-
setFormDirty,
|
|
38
|
-
setFieldValue,
|
|
39
|
-
setFieldTouched,
|
|
40
|
-
missingFields,
|
|
41
|
-
workflowForm,
|
|
42
|
-
labelPosition: meta.labelPosition,
|
|
43
|
-
spaceCompact: meta.spaceCompact,
|
|
44
|
-
parentInfo: {
|
|
45
|
-
parentName: field.name,
|
|
46
|
-
fieldNamePrefix: `${field.name}.`
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
+
children: body
|
|
50
51
|
})]
|
|
51
52
|
});
|
|
52
53
|
}
|
|
@@ -6,13 +6,14 @@ import { Field, useFormikContext } from "formik";
|
|
|
6
6
|
//#region src/form/Fields/RadioField.tsx
|
|
7
7
|
function RadioField(props) {
|
|
8
8
|
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
|
|
9
|
+
const fieldName = field.name ?? "";
|
|
9
10
|
const uid = useId();
|
|
10
11
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
11
12
|
const handleChange = (val) => {
|
|
12
13
|
if (disabled) return;
|
|
13
|
-
|
|
14
|
-
setFieldTouched(
|
|
15
|
-
setFieldValue(
|
|
14
|
+
onChange?.(val);
|
|
15
|
+
setFieldTouched(fieldName, true);
|
|
16
|
+
setFieldValue(fieldName, val);
|
|
16
17
|
setFormDirty(true);
|
|
17
18
|
};
|
|
18
19
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
@@ -5,20 +5,21 @@ import { Field, useField, useFormikContext } from "formik";
|
|
|
5
5
|
//#region src/form/Fields/RangeField.tsx
|
|
6
6
|
function RangeField(props) {
|
|
7
7
|
const { field, label, labelPosition, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
|
|
8
|
-
const
|
|
8
|
+
const fieldName = field.name ?? "";
|
|
9
|
+
const [fieldState] = useField(fieldName);
|
|
9
10
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
10
11
|
const handleChange = (e) => {
|
|
11
12
|
let val = e.target.valueAsNumber;
|
|
12
|
-
if (!isNaN(val)) {
|
|
13
|
+
if (!Number.isNaN(val)) {
|
|
13
14
|
val = Math.max(field.min, Math.min(field.max, val));
|
|
14
|
-
setFieldValue(
|
|
15
|
-
|
|
16
|
-
setFieldTouched(
|
|
15
|
+
setFieldValue(fieldName, val);
|
|
16
|
+
onChange?.(val);
|
|
17
|
+
setFieldTouched(fieldName, true);
|
|
17
18
|
setFormDirty(true);
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
const seedValue = field.default ?? field.min;
|
|
21
|
-
if ((fieldState.value === void 0 || fieldState.value === null) && seedValue !== void 0) setFieldValue(
|
|
22
|
+
if ((fieldState.value === void 0 || fieldState.value === null) && seedValue !== void 0) setFieldValue(fieldName, seedValue);
|
|
22
23
|
const currentValue = fieldState.value !== void 0 ? fieldState.value : seedValue;
|
|
23
24
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
24
25
|
optional: field.optional,
|
|
@@ -6,6 +6,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
//#region src/form/Fields/StringField.tsx
|
|
7
7
|
var StringField_default = memo(function StringField(props) {
|
|
8
8
|
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, currentValue } = props;
|
|
9
|
+
const fieldName = field.name ?? "";
|
|
9
10
|
const value = field.prefillDefault ? currentValue : void 0;
|
|
10
11
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
11
12
|
optional: field.optional,
|
|
@@ -16,7 +17,7 @@ var StringField_default = memo(function StringField(props) {
|
|
|
16
17
|
spaceCompact,
|
|
17
18
|
children: /* @__PURE__ */ jsx(FormikCustomInput, {
|
|
18
19
|
invalid: missing,
|
|
19
|
-
name:
|
|
20
|
+
name: fieldName,
|
|
20
21
|
type: field.type,
|
|
21
22
|
lowercase: field.lowercase,
|
|
22
23
|
placeholder: field.type === "password" && field.placeholder === void 0 ? "•".repeat((field.default ?? "").toString().length > 0 ? 16 : 0) : getPlaceholder(field.placeholder, field.default),
|
|
@@ -6,6 +6,7 @@ import { Field } from "formik";
|
|
|
6
6
|
//#region src/form/Fields/TextAreaField.tsx
|
|
7
7
|
function TextAreaField(props) {
|
|
8
8
|
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact } = props;
|
|
9
|
+
const fieldName = field.name ?? "";
|
|
9
10
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
10
11
|
optional: field.optional,
|
|
11
12
|
label,
|
|
@@ -19,7 +20,7 @@ function TextAreaField(props) {
|
|
|
19
20
|
id,
|
|
20
21
|
"aria-describedby": describedBy,
|
|
21
22
|
"aria-required": field.optional ? void 0 : true,
|
|
22
|
-
name:
|
|
23
|
+
name: fieldName,
|
|
23
24
|
type: "search",
|
|
24
25
|
placeholder: getPlaceholder(field.placeholder, field.default),
|
|
25
26
|
disabled,
|
package/dist/form/Form.d.ts
CHANGED
|
@@ -41,21 +41,20 @@ export declare function GroupHeader({ children, open, setOpen, title, }: {
|
|
|
41
41
|
title: React.ReactNode;
|
|
42
42
|
}): React.JSX.Element;
|
|
43
43
|
export type TSetFormDirty = (dirty: boolean) => void;
|
|
44
|
+
interface MultiSelectOption {
|
|
45
|
+
label: string;
|
|
46
|
+
secondaryLabel?: string;
|
|
47
|
+
value: string | boolean | number;
|
|
48
|
+
selected?: boolean;
|
|
49
|
+
}
|
|
44
50
|
export declare function MultiSelectionDropdown({ name, label, invalid, options: initialOptions, setFormDirty, onChange, parentValue, }: {
|
|
45
51
|
name: string;
|
|
46
52
|
label: string;
|
|
47
53
|
invalid?: boolean;
|
|
48
|
-
options?:
|
|
49
|
-
label: string;
|
|
50
|
-
secondaryLabel?: string;
|
|
51
|
-
value: string;
|
|
52
|
-
selected: boolean;
|
|
53
|
-
}[];
|
|
54
|
+
options?: (string | MultiSelectOption)[];
|
|
54
55
|
setFormDirty: TSetFormDirty;
|
|
55
56
|
onChange?: ((val: unknown) => void) | undefined;
|
|
56
57
|
parentValue?: unknown;
|
|
57
|
-
className?: string;
|
|
58
|
-
secondaryField?: string | undefined;
|
|
59
58
|
}): React.JSX.Element;
|
|
60
59
|
export declare function FieldsFromOptions({ options, values, setFormDirty, setFieldValue, setFieldTouched, parentInfo, labelPosition, missingFields, spaceCompact, workflowForm, }: {
|
|
61
60
|
options: Record<string, unknown>;
|