@parallelworks/ui 0.40.1 → 0.42.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/README.md +25 -0
- package/dist/ai/adapter/memoryStore.js +7 -0
- package/dist/ai/adapter/mock/mockAdapter.js +52 -17
- package/dist/ai/adapter/openai/createOpenAIStream.js +1 -1
- package/dist/ai/adapter/openai/index.d.ts +1 -1
- package/dist/ai/adapter/openai/sse.d.ts +8 -2
- package/dist/ai/adapter/openai/sse.js +40 -4
- package/dist/ai/adapter/openai/wire.d.ts +6 -0
- package/dist/ai/components/AllocationSelector.d.ts +3 -4
- package/dist/ai/components/AllocationSelector.js +37 -33
- package/dist/ai/components/AttachmentManager.js +7 -7
- package/dist/ai/components/AttachmentUpload.js +5 -5
- package/dist/ai/components/BranchNavigator.js +1 -1
- package/dist/ai/components/ChatEmptyState.js +2 -2
- package/dist/ai/components/ChatInput.js +10 -8
- package/dist/ai/components/ChatLayout.js +4 -5
- package/dist/ai/components/ChatMessage.js +12 -12
- package/dist/ai/components/ChatMessageList.js +9 -9
- package/dist/ai/components/ChatSidebar.js +8 -9
- package/dist/ai/components/ChatThread.js +4 -4
- package/dist/ai/components/ComposerChrome.d.ts +2 -2
- package/dist/ai/components/ComposerChrome.js +3 -6
- package/dist/ai/components/DragOverlay.js +2 -2
- package/dist/ai/components/ModelSelector.d.ts +5 -3
- package/dist/ai/components/ModelSelector.js +102 -339
- package/dist/ai/components/PastedText.js +11 -11
- package/dist/ai/components/ProviderIssueBanner.d.ts +2 -0
- package/dist/ai/components/ProviderIssueBanner.js +34 -16
- package/dist/ai/components/Reasoning.js +4 -4
- package/dist/ai/components/ShareDialog.js +43 -35
- package/dist/ai/components/SlashMenu.d.ts +12 -2
- package/dist/ai/components/SlashMenu.js +29 -13
- package/dist/ai/components/agent/ActivityLine.js +3 -3
- package/dist/ai/components/agent/AgentMessageParts.js +20 -20
- package/dist/ai/components/agent/PermissionPicker.js +13 -11
- package/dist/ai/components/conversationActions.d.ts +4 -6
- package/dist/ai/components/conversationActions.js +9 -13
- package/dist/ai/core/ChatProvider.js +4 -4
- package/dist/ai/core/config.js +1 -1
- package/dist/ai/core/parts.d.ts +5 -0
- package/dist/ai/core/parts.js +28 -1
- package/dist/ai/core/providerIssues.d.ts +7 -0
- package/dist/ai/core/providerIssues.js +9 -1
- package/dist/ai/core/useKeyboardShortcuts.d.ts +4 -0
- package/dist/ai/core/useKeyboardShortcuts.js +8 -2
- package/dist/ai/index.d.ts +0 -1
- package/dist/ai/index.js +1 -2
- package/dist/ai/strings.d.ts +19 -0
- package/dist/ai/strings.js +18 -1
- package/dist/ai/ui/Avatar.js +5 -5
- package/dist/ai/ui/ConversationSidebar.d.ts +0 -1
- package/dist/ai/ui/ConversationSidebar.js +6 -7
- package/dist/ai/ui/Markdown.js +3 -3
- package/dist/ai/ui/Notice.js +6 -6
- package/dist/ai/ui/chip.d.ts +4 -0
- package/dist/ai/ui/chip.js +8 -0
- package/dist/ai/ui/sidebar.d.ts +6 -5
- package/dist/ai/ui/sidebar.js +39 -43
- package/dist/components/ActionMenu.d.ts +13 -0
- package/dist/components/ActionMenu.js +30 -0
- package/dist/components/Avatar.js +6 -6
- package/dist/components/Breadcrumbs.js +1 -1
- package/dist/components/Button.js +10 -10
- package/dist/components/Callout.js +2 -2
- package/dist/components/Card.js +3 -3
- package/dist/components/Combobox.d.ts +66 -0
- package/dist/components/Combobox.js +393 -0
- package/dist/components/ConfirmModal.js +11 -11
- package/dist/components/ContextMenu.d.ts +23 -0
- package/dist/components/ContextMenu.js +89 -0
- package/dist/components/CopyToClipboard.js +2 -2
- package/dist/components/CreateModal.d.ts +17 -36
- package/dist/components/CreateModal.js +97 -259
- package/dist/components/DescriptionList.js +8 -8
- package/dist/components/Filter.js +2 -2
- package/dist/components/FilterPill.js +2 -2
- package/dist/components/HoverCard.d.ts +14 -0
- package/dist/components/HoverCard.js +33 -0
- package/dist/components/IconButton.d.ts +5 -5
- package/dist/components/IconButton.js +18 -22
- package/dist/components/InfoTip.d.ts +15 -0
- package/dist/components/InfoTip.js +60 -0
- package/dist/components/Input.js +5 -5
- package/dist/components/LetterBadge.js +2 -2
- package/dist/components/Loader.js +3 -3
- package/dist/components/Markdown.js +1 -1
- package/dist/components/MarkdownImpl.js +2 -2
- package/dist/components/Menu.d.ts +33 -0
- package/dist/components/Menu.js +86 -0
- package/dist/components/MenuEntries.d.ts +56 -0
- package/dist/components/MenuEntries.js +123 -0
- package/dist/components/Modal.d.ts +29 -0
- package/dist/components/Modal.js +47 -0
- package/dist/components/Overview.js +11 -10
- package/dist/components/PageHeader.d.ts +10 -16
- package/dist/components/PageHeader.js +69 -95
- package/dist/components/Pagination.js +5 -5
- package/dist/components/Provider.d.ts +5 -11
- package/dist/components/Provider.js +11 -14
- package/dist/components/Radio.d.ts +8 -0
- package/dist/components/Radio.js +16 -0
- package/dist/components/SectionHeader.js +2 -2
- package/dist/components/SegmentedControl.d.ts +6 -5
- package/dist/components/SegmentedControl.js +34 -30
- package/dist/components/Select.d.ts +27 -0
- package/dist/components/Select.js +78 -0
- package/dist/components/SettingModeOption.d.ts +5 -8
- package/dist/components/SettingModeOption.js +10 -12
- package/dist/components/SettingRow.js +4 -4
- package/dist/components/SettingsCard.js +4 -4
- package/dist/components/SettingsGroup.js +2 -2
- package/dist/components/Sort.js +1 -1
- package/dist/components/StatusBadge.js +7 -7
- package/dist/components/StatusIcons.js +4 -4
- package/dist/components/Switch.d.ts +22 -0
- package/dist/components/Switch.js +28 -0
- package/dist/components/Table.js +11 -11
- package/dist/components/Tooltip.d.ts +24 -20
- package/dist/components/Tooltip.js +58 -76
- package/dist/components/floating.d.ts +14 -0
- package/dist/components/floating.js +21 -0
- package/dist/components/search.d.ts +2 -0
- package/dist/components/search.js +14 -0
- package/dist/editor/Editor.js +1 -1
- package/dist/editor/EditorField.js +16 -21
- package/dist/editor/FormCodePanel.js +19 -19
- package/dist/editor/Monaco.js +3 -3
- package/dist/file-explorer/FileExplorer.js +77 -81
- package/dist/file-explorer/FileExplorerContext.js +2 -2
- package/dist/file-explorer/FilePreview/CodePreviewEditor.js +1 -1
- package/dist/file-explorer/FilePreview/Inline.js +1 -1
- package/dist/file-explorer/FilePreview/StreamedBadge.js +5 -6
- package/dist/file-explorer/FilePreview/Viewer.js +8 -8
- package/dist/file-explorer/FilePreview/index.d.ts +1 -1
- package/dist/file-explorer/FilePreview/index.js +49 -83
- package/dist/file-explorer/FileRow.d.ts +4 -3
- package/dist/file-explorer/FileRow.js +32 -38
- package/dist/file-explorer/FileRowsWindow.d.ts +3 -2
- package/dist/file-explorer/FileRowsWindow.js +4 -4
- package/dist/file-explorer/FileTable.d.ts +3 -2
- package/dist/file-explorer/FileTable.js +3 -3
- package/dist/file-explorer/LoadMoreRow.js +1 -1
- package/dist/file-explorer/TreeView.js +11 -16
- package/dist/file-explorer/helpers.js +11 -12
- package/dist/file-explorer/toasts.js +11 -11
- package/dist/form/FieldGroup.d.ts +11 -0
- package/dist/form/FieldGroup.js +36 -0
- package/dist/form/FieldWrapper.js +4 -4
- package/dist/form/Fields/BooleanField.js +23 -33
- package/dist/form/Fields/CheckboxGroupField.d.ts +1 -1
- package/dist/form/Fields/CheckboxGroupField.js +9 -13
- package/dist/form/Fields/ColorField.d.ts +1 -2
- package/dist/form/Fields/ColorField.js +6 -11
- package/dist/form/Fields/DropdownField.d.ts +3 -13
- package/dist/form/Fields/DropdownField.js +40 -27
- package/dist/form/Fields/DurationField.d.ts +1 -2
- package/dist/form/Fields/DurationField.js +25 -32
- package/dist/form/Fields/LabelField.js +2 -2
- package/dist/form/Fields/MultiDropdownField.d.ts +6 -12
- package/dist/form/Fields/MultiDropdownField.js +31 -22
- package/dist/form/Fields/NumberField.d.ts +1 -1
- package/dist/form/Fields/NumberField.js +65 -35
- package/dist/form/Fields/ObjectField.d.ts +1 -1
- package/dist/form/Fields/ObjectField.js +12 -43
- package/dist/form/Fields/RadioField.d.ts +1 -1
- package/dist/form/Fields/RadioField.js +30 -41
- package/dist/form/Fields/RangeField.d.ts +1 -2
- package/dist/form/Fields/RangeField.js +23 -16
- package/dist/form/Fields/StringField.d.ts +1 -2
- package/dist/form/Fields/StringField.js +58 -26
- package/dist/form/Fields/TextAreaField.js +12 -10
- package/dist/form/Form.d.ts +30 -48
- package/dist/form/Form.js +306 -412
- package/dist/form/FormLayout.js +9 -9
- package/dist/form/Wizard/WizardContainer.d.ts +1 -4
- package/dist/form/Wizard/WizardContainer.js +40 -56
- package/dist/form/Wizard/WizardNavigation.js +1 -1
- package/dist/form/Wizard/WizardStepContent.d.ts +1 -5
- package/dist/form/Wizard/WizardStepContent.js +11 -16
- package/dist/form/Wizard/WizardStepIndicator.js +6 -6
- package/dist/form/Wizard/types.d.ts +0 -14
- package/dist/form/fieldRegistry.d.ts +1 -1
- package/dist/form/fieldRegistry.js +6 -6
- package/dist/form/formEditing.js +1 -1
- package/dist/form/index.d.ts +5 -4
- package/dist/form/index.js +6 -7
- package/dist/form/types/fieldComponentTypes.d.ts +8 -10
- package/dist/form/useChoiceField.d.ts +20 -0
- package/dist/form/useChoiceField.js +49 -0
- package/dist/form/useFieldValue.d.ts +7 -0
- package/dist/form/useFieldValue.js +20 -0
- package/dist/form/useParsedOpts.d.ts +3 -1
- package/dist/form/useParsedOpts.js +12 -17
- package/dist/form/utils/dependentOptions.d.ts +8 -4
- package/dist/form/utils/dependentOptions.js +25 -17
- package/dist/form/utils/fieldItems.d.ts +10 -0
- package/dist/form/utils/fieldItems.js +11 -0
- package/dist/form/utils/fieldPath.d.ts +10 -0
- package/dist/form/utils/fieldPath.js +20 -0
- package/dist/form/utils/shareEqual.d.ts +6 -0
- package/dist/form/utils/shareEqual.js +38 -0
- package/dist/graph/AnnotationBanner.js +8 -8
- package/dist/graph/Collapse.d.ts +1 -0
- package/dist/graph/Collapse.js +6 -27
- package/dist/graph/Connectors.js +5 -5
- package/dist/graph/DependencyGraph.js +20 -19
- package/dist/graph/GraphEditor.js +30 -41
- package/dist/graph/GraphEditorDialogs.js +17 -17
- package/dist/graph/GraphNode.js +1 -1
- package/dist/graph/InputDialog.js +19 -22
- package/dist/graph/InputsEditor.js +58 -66
- package/dist/graph/JobSummary.js +42 -39
- package/dist/graph/MatrixGroup.js +1 -1
- package/dist/graph/ProblemsButton.js +18 -19
- package/dist/graph/Reveal.js +1 -1
- package/dist/graph/ShortcutsButton.js +15 -18
- package/dist/graph/SuggestionInput.d.ts +5 -10
- package/dist/graph/SuggestionInput.js +14 -18
- package/dist/graph/ToolbarPopover.d.ts +11 -6
- package/dist/graph/ToolbarPopover.js +35 -67
- package/dist/graph/TreeView.js +24 -37
- package/dist/graph/WorkflowSettingsDialog.js +4 -4
- package/dist/graph/editorChrome.js +13 -12
- package/dist/graph/editorFields.js +29 -29
- package/dist/graph/editorPrimitives.d.ts +1 -1
- package/dist/graph/editorPrimitives.js +10 -7
- package/dist/graph/editorRows.js +103 -97
- package/dist/graph/fieldProblems.js +2 -2
- package/dist/graph/graphEditorState.d.ts +4 -3
- package/dist/graph/inputRefs.js +9 -9
- package/dist/graph/settingsViews.js +6 -7
- package/dist/graph/stepWith.js +6 -6
- package/dist/index.d.ts +14 -15
- package/dist/index.js +15 -14
- package/dist/list/ActionToolbar.d.ts +6 -14
- package/dist/list/ActionToolbar.js +48 -96
- package/dist/list/ListPage.d.ts +6 -12
- package/dist/list/ListPage.js +46 -29
- package/dist/list/ListPager.js +4 -4
- package/dist/list/ListTable.js +5 -5
- package/dist/list/ListViewControls.d.ts +5 -4
- package/dist/list/ListViewControls.js +177 -267
- package/dist/list/UserHoverCard.d.ts +3 -17
- package/dist/list/UserHoverCard.js +21 -45
- package/dist/list/index.d.ts +3 -4
- package/dist/list/index.js +3 -4
- package/dist/list/listSearch.js +12 -11
- package/dist/list/rowMenu.d.ts +63 -0
- package/dist/list/rowMenu.js +134 -0
- package/dist/logviewer/LogViewer.js +26 -26
- package/dist/styles.css +1 -1
- package/package.json +7 -13
- package/dist/ai/ui/Dropdown.d.ts +0 -31
- package/dist/ai/ui/Dropdown.js +0 -110
- package/dist/components/AddMenu.d.ts +0 -18
- package/dist/components/AddMenu.js +0 -46
- package/dist/components/BareModal.d.ts +0 -17
- package/dist/components/BareModal.js +0 -77
- package/dist/components/CollapsiblePanel.d.ts +0 -27
- package/dist/components/CollapsiblePanel.js +0 -77
- package/dist/components/Dropdown.d.ts +0 -28
- package/dist/components/Dropdown.js +0 -355
- package/dist/components/Listbox.d.ts +0 -21
- package/dist/components/Listbox.js +0 -119
- package/dist/components/MultiSelect.d.ts +0 -22
- package/dist/components/MultiSelect.js +0 -168
- package/dist/components/SwitchToggle.d.ts +0 -15
- package/dist/components/SwitchToggle.js +0 -57
- package/dist/components/SwitchToggleSmall.d.ts +0 -6
- package/dist/components/SwitchToggleSmall.js +0 -14
- package/dist/components/Toggle.d.ts +0 -6
- package/dist/components/Toggle.js +0 -20
- package/dist/components/dropdownUtils.d.ts +0 -37
- package/dist/components/dropdownUtils.js +0 -99
- package/dist/form/SpecialTypes/DropdownWrapper.d.ts +0 -25
- package/dist/form/SpecialTypes/DropdownWrapper.js +0 -28
- package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +0 -51
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +0 -119
- package/dist/form/SpecialTypes/FormikCustomInput.d.ts +0 -19
- package/dist/form/SpecialTypes/FormikCustomInput.js +0 -121
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.d.ts +0 -13
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +0 -31
- package/dist/form/SpecialTypes/FormikNumericInput.d.ts +0 -9
- package/dist/form/SpecialTypes/FormikNumericInput.js +0 -60
- package/dist/form/SpecialTypes/index.d.ts +0 -3
- package/dist/list/HoverCard.d.ts +0 -24
- package/dist/list/HoverCard.js +0 -73
- package/dist/list/RowContextMenu.d.ts +0 -127
- package/dist/list/RowContextMenu.js +0 -515
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useNotify, useProvisionCorsRules, useStrings } from "../components/Provider.js";
|
|
2
1
|
import { BsFileEarmarkZip } from "../icons/bs/BsFileEarmarkZip.js";
|
|
3
2
|
import { FaRegFileImage } from "../icons/fa/FaRegFileImage.js";
|
|
4
3
|
import { FaRegFolder } from "../icons/fa/FaRegFolder.js";
|
|
@@ -15,15 +14,15 @@ import { MdRefresh } from "../icons/md/MdRefresh.js";
|
|
|
15
14
|
import { PiShareBold } from "../icons/pi/PiShareBold.js";
|
|
16
15
|
import { TbAlertTriangle } from "../icons/tb/TbAlertTriangle.js";
|
|
17
16
|
import { positionKeys } from "../components/keys.js";
|
|
17
|
+
import { useNotify, useProvisionCorsRules, useStrings } from "../components/Provider.js";
|
|
18
18
|
import Callout from "../components/Callout.js";
|
|
19
19
|
import { ListSkeleton } from "../list/ListTable.js";
|
|
20
20
|
import { formatFileSize, getFileExtension } from "./lib/utils.js";
|
|
21
21
|
import { CorsError } from "./lib/errors.js";
|
|
22
|
-
import
|
|
22
|
+
import { clsx } from "clsx";
|
|
23
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
24
|
import { useEffect, useState, useTransition } from "react";
|
|
24
25
|
import { useLocalStorage } from "usehooks-ts";
|
|
25
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
-
import Skeleton from "react-loading-skeleton";
|
|
27
26
|
//#region src/file-explorer/helpers.tsx
|
|
28
27
|
var SIDEBAR_WIDTH_STORAGE_KEY = "fileExplorerSidebarWidth";
|
|
29
28
|
var contentTypeIconMap = [
|
|
@@ -368,7 +367,7 @@ function PropagationStage({ status, label }) {
|
|
|
368
367
|
return /* @__PURE__ */ jsxs("li", {
|
|
369
368
|
className: "flex flex-col items-center gap-1.5",
|
|
370
369
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
371
|
-
className:
|
|
370
|
+
className: clsx("relative flex items-center justify-center w-6 h-6 rounded-full border transition-colors", status === "done" && "bg-green-500 border-green-500 text-white", status === "active" && "border-blue-500", status === "pending" && "theme-border"),
|
|
372
371
|
children: [
|
|
373
372
|
status === "done" && /* @__PURE__ */ jsx("svg", {
|
|
374
373
|
viewBox: "0 0 16 16",
|
|
@@ -381,11 +380,11 @@ function PropagationStage({ status, label }) {
|
|
|
381
380
|
"aria-hidden": "true",
|
|
382
381
|
children: /* @__PURE__ */ jsx("polyline", { points: "3.5 8.5 6.5 11.5 12.5 5" })
|
|
383
382
|
}),
|
|
384
|
-
status === "active" && /* @__PURE__ */ jsxs(Fragment
|
|
383
|
+
status === "active" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-blue-400/60" }), /* @__PURE__ */ jsx("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-blue-500" })] }),
|
|
385
384
|
status === "pending" && /* @__PURE__ */ jsx("span", { className: "inline-flex h-1.5 w-1.5 rounded-full theme-muted-text opacity-60" })
|
|
386
385
|
]
|
|
387
386
|
}), /* @__PURE__ */ jsx("span", {
|
|
388
|
-
className:
|
|
387
|
+
className: clsx("text-[11px] uppercase tracking-wider", status === "pending" ? "theme-muted-text opacity-60" : "theme-text"),
|
|
389
388
|
children: label
|
|
390
389
|
})]
|
|
391
390
|
});
|
|
@@ -393,20 +392,20 @@ function PropagationStage({ status, label }) {
|
|
|
393
392
|
function PropagationConnector({ active }) {
|
|
394
393
|
return /* @__PURE__ */ jsx("span", {
|
|
395
394
|
"aria-hidden": "true",
|
|
396
|
-
className:
|
|
395
|
+
className: clsx("h-px w-8 -mt-5 transition-colors", active ? "bg-blue-500" : "theme-border border-t")
|
|
397
396
|
});
|
|
398
397
|
}
|
|
399
398
|
function NoDataAvailablePreview({ selectedStorage, error, onRefresh, connectionIssueMessage = null, className, canWrite = true }) {
|
|
400
399
|
const t = useStrings().fileExplorer;
|
|
401
400
|
if (error instanceof CorsError) return /* @__PURE__ */ jsx("div", {
|
|
402
|
-
className:
|
|
401
|
+
className: clsx("flex-1 flex items-center justify-center w-full text-center", className),
|
|
403
402
|
children: /* @__PURE__ */ jsx(CorsIssuePreview, {
|
|
404
403
|
selectedStorage,
|
|
405
404
|
onRefresh
|
|
406
405
|
})
|
|
407
406
|
});
|
|
408
407
|
return /* @__PURE__ */ jsx("div", {
|
|
409
|
-
className:
|
|
408
|
+
className: clsx("flex-1 flex items-center justify-center w-full text-center", className),
|
|
410
409
|
children: !connectionIssueMessage ? /* @__PURE__ */ jsxs("div", {
|
|
411
410
|
className: "flex flex-col items-center justify-center max-w-sm p-8",
|
|
412
411
|
children: [
|
|
@@ -465,7 +464,7 @@ function SkeletonPreview() {
|
|
|
465
464
|
})
|
|
466
465
|
}), /* @__PURE__ */ jsx("div", {
|
|
467
466
|
className: "overflow-auto flex-1 px-2 py-2 space-y-1.5",
|
|
468
|
-
children: positionKeys(6, "skeleton").map((key) => /* @__PURE__ */ jsx(
|
|
467
|
+
children: positionKeys(6, "skeleton").map((key) => /* @__PURE__ */ jsx("div", { className: "h-3.5 animate-pulse rounded bg-(--theme-muted-panel-bg)" }, key))
|
|
469
468
|
})]
|
|
470
469
|
})
|
|
471
470
|
}), /* @__PURE__ */ jsxs("div", {
|
|
@@ -478,7 +477,7 @@ function DragDropZone({ onDropFiles, children, className = "" }) {
|
|
|
478
477
|
const [isDragging, setIsDragging] = useState(false);
|
|
479
478
|
return /* @__PURE__ */ jsx("div", {
|
|
480
479
|
role: "none",
|
|
481
|
-
className:
|
|
480
|
+
className: clsx("transition-[box-shadow,background-color] duration-150", className, isDragging && "ring-1 ring-(--theme-link) ring-inset bg-(--theme-link)/5"),
|
|
482
481
|
onDragOver: (e) => {
|
|
483
482
|
e.preventDefault();
|
|
484
483
|
if (onDropFiles) setIsDragging(true);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useStrings } from "../components/Provider.js";
|
|
2
1
|
import { BiExpandVertical } from "../icons/bi/BiExpandVertical.js";
|
|
3
2
|
import { FaAngleDown } from "../icons/fa/FaAngleDown.js";
|
|
4
3
|
import { FaAngleUp } from "../icons/fa/FaAngleUp.js";
|
|
@@ -7,10 +6,11 @@ import { IoMdClose } from "../icons/io/IoMdClose.js";
|
|
|
7
6
|
import { IoCloudUploadOutline } from "../icons/io5/IoCloudUploadOutline.js";
|
|
8
7
|
import { TbAlertTriangle } from "../icons/tb/TbAlertTriangle.js";
|
|
9
8
|
import { VscChromeMinimize } from "../icons/vsc/VscChromeMinimize.js";
|
|
9
|
+
import { useStrings } from "../components/Provider.js";
|
|
10
10
|
import { formatETA, formatFileSize } from "./lib/utils.js";
|
|
11
|
-
import
|
|
11
|
+
import { clsx } from "clsx";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
import { useState } from "react";
|
|
13
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
//#region src/file-explorer/toasts.tsx
|
|
15
15
|
function getSessionStatusInfo(session, queueLength, strings) {
|
|
16
16
|
switch (session.status) {
|
|
@@ -102,15 +102,15 @@ function FileProgressBar({ fileProgress, fileName, onCancelFile }) {
|
|
|
102
102
|
onMouseEnter: () => setIsHovered(true),
|
|
103
103
|
onMouseLeave: () => setIsHovered(false),
|
|
104
104
|
children: /* @__PURE__ */ jsxs("div", {
|
|
105
|
-
className:
|
|
105
|
+
className: clsx("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"),
|
|
106
106
|
children: [/* @__PURE__ */ jsx("div", {
|
|
107
|
-
className:
|
|
107
|
+
className: clsx("h-full transition-all duration-300 relative flex items-center justify-center", barColor({
|
|
108
108
|
isCompleted,
|
|
109
109
|
isCancelled,
|
|
110
110
|
isFailed
|
|
111
111
|
}), isHovered && "opacity-80"),
|
|
112
112
|
style: { width: `${percentage}%` }
|
|
113
|
-
}), isHovered && !isCompleted && totalBytes > 0 && /* @__PURE__ */ jsxs(Fragment
|
|
113
|
+
}), isHovered && !isCompleted && totalBytes > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
114
114
|
className: "absolute inset-0 flex items-center justify-center text-xs whitespace-nowrap p-0.5 z-10",
|
|
115
115
|
style: {
|
|
116
116
|
WebkitClipPath: `inset(0 ${100 - percentage}% 0 0)`,
|
|
@@ -214,7 +214,7 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
214
214
|
children: [!isToastExpanded && /* @__PURE__ */ jsxs("div", {
|
|
215
215
|
className: "flex items-center gap-3 flex-1",
|
|
216
216
|
children: [/* @__PURE__ */ jsx("div", {
|
|
217
|
-
className:
|
|
217
|
+
className: clsx("w-10 h-10 rounded-full flex items-center justify-center", statusInfo.bgColor),
|
|
218
218
|
children: statusInfo.icon
|
|
219
219
|
}), /* @__PURE__ */ jsxs("div", {
|
|
220
220
|
role: "none",
|
|
@@ -262,20 +262,20 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
262
262
|
children: /* @__PURE__ */ jsx("div", {
|
|
263
263
|
className: "flex-1 h-1.5 bg-(--theme-border) rounded-full overflow-hidden",
|
|
264
264
|
children: /* @__PURE__ */ jsx("div", {
|
|
265
|
-
className:
|
|
265
|
+
className: clsx("h-full transition-all duration-300", sessionBarColor),
|
|
266
266
|
style: { width: `${totalProgress}%` }
|
|
267
267
|
})
|
|
268
268
|
})
|
|
269
269
|
})
|
|
270
270
|
]
|
|
271
271
|
})]
|
|
272
|
-
}), isToastExpanded && /* @__PURE__ */ jsxs(Fragment
|
|
272
|
+
}), isToastExpanded && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
273
273
|
/* @__PURE__ */ jsxs("div", {
|
|
274
274
|
className: "flex items-center justify-between",
|
|
275
275
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
276
276
|
className: "flex items-center gap-3",
|
|
277
277
|
children: [/* @__PURE__ */ jsx("div", {
|
|
278
|
-
className:
|
|
278
|
+
className: clsx("w-10 h-10 rounded-full flex items-center justify-center", statusInfo.bgColor),
|
|
279
279
|
children: statusInfo.icon
|
|
280
280
|
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
281
281
|
className: "text-sm font-semibold theme-text",
|
|
@@ -342,7 +342,7 @@ function UploadSessionToast({ session, queueLength, onCancel, onCancelFile }) {
|
|
|
342
342
|
}), /* @__PURE__ */ jsx("div", {
|
|
343
343
|
className: "h-2 w-full bg-(--theme-border) rounded-full overflow-hidden",
|
|
344
344
|
children: /* @__PURE__ */ jsx("div", {
|
|
345
|
-
className:
|
|
345
|
+
className: clsx("h-full transition-all duration-300", sessionBarColor),
|
|
346
346
|
style: { width: `${totalProgress}%` }
|
|
347
347
|
})
|
|
348
348
|
})]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** A titled group of fields. Folding keeps them mounted, so they hold their
|
|
3
|
+
* values and validation while closed. */
|
|
4
|
+
export declare function FieldGroup({ title, actions, collapsible, defaultOpen, children, }: {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
/** Beside the title, outside the toggle, such as the group's info tip. */
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
collapsible?: boolean | undefined;
|
|
9
|
+
defaultOpen?: boolean | undefined;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FaAngleRight } from "../icons/fa/FaAngleRight.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Collapsible } from "@base-ui/react/collapsible";
|
|
4
|
+
//#region src/form/FieldGroup.tsx
|
|
5
|
+
/** A titled group of fields. Folding keeps them mounted, so they hold their
|
|
6
|
+
* values and validation while closed. */
|
|
7
|
+
function FieldGroup({ title, actions, collapsible = true, defaultOpen = true, children }) {
|
|
8
|
+
if (!collapsible) return /* @__PURE__ */ jsxs("section", {
|
|
9
|
+
className: "flex w-full flex-col",
|
|
10
|
+
children: [/* @__PURE__ */ jsxs("h3", {
|
|
11
|
+
className: "mb-[15px] flex items-center gap-1 text-md font-bold",
|
|
12
|
+
children: [title, actions]
|
|
13
|
+
}), children]
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsxs(Collapsible.Root, {
|
|
16
|
+
defaultOpen,
|
|
17
|
+
className: "flex w-full flex-col",
|
|
18
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
19
|
+
className: "mb-2 flex w-full items-center gap-2 border-b border-(--theme-border) pb-1 text-lg font-semibold",
|
|
20
|
+
children: [/* @__PURE__ */ jsxs(Collapsible.Trigger, {
|
|
21
|
+
"data-field-label": true,
|
|
22
|
+
className: "group flex flex-1 cursor-pointer items-center text-left",
|
|
23
|
+
children: [/* @__PURE__ */ jsx(FaAngleRight, {
|
|
24
|
+
"aria-hidden": "true",
|
|
25
|
+
className: "px-1 text-[1.25rem] transition-transform group-data-panel-open:rotate-90"
|
|
26
|
+
}), title]
|
|
27
|
+
}), actions]
|
|
28
|
+
}), /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
29
|
+
keepMounted: true,
|
|
30
|
+
className: "h-(--collapsible-panel-height) transition-[height] duration-300 ease-in-out data-starting-style:h-0 data-ending-style:h-0 data-starting-style:overflow-hidden data-ending-style:overflow-hidden",
|
|
31
|
+
children
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { FieldGroup };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RequiredMark } from "../components/RequiredMark.js";
|
|
2
2
|
import { resolvedFlag } from "./lib.js";
|
|
3
3
|
import { FieldProvider } from "./fieldContext.js";
|
|
4
|
-
import
|
|
5
|
-
import { useId, useMemo } from "react";
|
|
4
|
+
import { clsx } from "clsx";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useId, useMemo } from "react";
|
|
7
7
|
//#region src/form/FieldWrapper.tsx
|
|
8
8
|
function FieldWrapper({ label, tooltipComponent, description, labelPosition = "left", spaceCompact = false, optional = false, children }) {
|
|
9
9
|
const isOptional = Boolean(resolvedFlag(optional));
|
|
@@ -23,12 +23,12 @@ function FieldWrapper({ label, tooltipComponent, description, labelPosition = "l
|
|
|
23
23
|
descriptionId
|
|
24
24
|
]);
|
|
25
25
|
return /* @__PURE__ */ jsxs("div", {
|
|
26
|
-
className:
|
|
26
|
+
className: clsx("flex w-full", labelPosition === "left" ? "items-start" : "items-left flex-col"),
|
|
27
27
|
children: [/* @__PURE__ */ jsxs("label", {
|
|
28
28
|
htmlFor: id,
|
|
29
29
|
id: labelId,
|
|
30
30
|
"data-field-label": true,
|
|
31
|
-
className:
|
|
31
|
+
className: clsx("relative", labelPosition === "left" ? "form-label" : "form-label-top", spaceCompact && "form-label-compact"),
|
|
32
32
|
children: [
|
|
33
33
|
label,
|
|
34
34
|
!isOptional && /* @__PURE__ */ jsx(RequiredMark, {}),
|
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Tooltip } from "../../components/Tooltip.js";
|
|
2
|
+
import { Switch } from "../../components/Switch.js";
|
|
2
3
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
4
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
3
5
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { useField, useFormikContext } from "formik";
|
|
5
6
|
//#region src/form/Fields/BooleanField.tsx
|
|
6
7
|
function BooleanField(props) {
|
|
7
|
-
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact
|
|
8
|
-
const
|
|
9
|
-
const [fieldState] = useField(fieldName);
|
|
10
|
-
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
8
|
+
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact } = props;
|
|
9
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
11
10
|
const handleChange = (val) => {
|
|
12
11
|
if (disabled) return;
|
|
13
12
|
onChange?.(val);
|
|
14
|
-
|
|
15
|
-
setFieldValue(fieldName, val);
|
|
16
|
-
setFormDirty(true);
|
|
13
|
+
change(val);
|
|
17
14
|
};
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
offOption: String(field.options.offOption ?? false)
|
|
22
|
-
} : void 0;
|
|
23
|
-
const displayLabel = (option) => option.charAt(0).toUpperCase() + option.slice(1).toLowerCase();
|
|
15
|
+
const onOption = field.options ? String(field.options.onOption ?? true) : true;
|
|
16
|
+
const offOption = field.options ? String(field.options.offOption ?? false) : false;
|
|
17
|
+
const checked = value === true || value === "true" || value === onOption;
|
|
24
18
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
25
19
|
optional: true,
|
|
26
20
|
label,
|
|
27
|
-
tooltipComponent
|
|
21
|
+
tooltipComponent,
|
|
28
22
|
description: field.description,
|
|
29
23
|
labelPosition,
|
|
30
24
|
spaceCompact,
|
|
31
|
-
children: ({ id, describedBy }) =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onChange: handleChange,
|
|
45
|
-
value: value === true || value === "true",
|
|
46
|
-
disabled,
|
|
47
|
-
invalid: missing
|
|
25
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsx(Tooltip, {
|
|
26
|
+
content: field.disabled_message,
|
|
27
|
+
disabled: !disabled,
|
|
28
|
+
children: /* @__PURE__ */ jsx(Switch, {
|
|
29
|
+
id,
|
|
30
|
+
nativeButton: true,
|
|
31
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
32
|
+
checked,
|
|
33
|
+
onCheckedChange: (on) => handleChange(on ? onOption : offOption),
|
|
34
|
+
disabled,
|
|
35
|
+
"aria-describedby": describedBy,
|
|
36
|
+
"aria-invalid": missing || void 0
|
|
37
|
+
})
|
|
48
38
|
})
|
|
49
39
|
});
|
|
50
40
|
}
|
|
@@ -15,4 +15,4 @@ export interface ICheckboxGroupField extends BaseField {
|
|
|
15
15
|
*/
|
|
16
16
|
implies?: Record<string, string[]>;
|
|
17
17
|
}
|
|
18
|
-
export default function CheckboxGroupField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact,
|
|
18
|
+
export default function CheckboxGroupField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, }: FieldComponentProps<ICheckboxGroupField>): import("react").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
2
3
|
import { fieldOption } from "./fieldOption.js";
|
|
3
|
-
import
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { clsx } from "clsx";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
6
|
+
import { useState } from "react";
|
|
7
7
|
//#region src/form/Fields/CheckboxGroupField.tsx
|
|
8
8
|
function impliedFrom(values, implies = {}) {
|
|
9
9
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -13,17 +13,15 @@ function impliedFrom(values, implies = {}) {
|
|
|
13
13
|
function union(manual, forced) {
|
|
14
14
|
return [...manual, ...[...forced].filter((v) => !manual.includes(v))];
|
|
15
15
|
}
|
|
16
|
-
function CheckboxGroupField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact
|
|
17
|
-
const
|
|
18
|
-
const [fieldState] = useField(fieldName);
|
|
19
|
-
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
16
|
+
function CheckboxGroupField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact }) {
|
|
17
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
20
18
|
const implies = field.implies;
|
|
21
19
|
const rawOf = new Map((field.options ?? []).map((choice) => {
|
|
22
20
|
const option = fieldOption(choice);
|
|
23
21
|
return [option.value, option.raw];
|
|
24
22
|
}));
|
|
25
23
|
const [manual, setManual] = useState(() => {
|
|
26
|
-
const saved = (
|
|
24
|
+
const saved = (value || []).map(String);
|
|
27
25
|
const impliedBySaved = impliedFrom(saved, implies);
|
|
28
26
|
return saved.filter((v) => !impliedBySaved.has(v));
|
|
29
27
|
});
|
|
@@ -33,10 +31,8 @@ function CheckboxGroupField({ field, label, labelPosition, missing, disabled, on
|
|
|
33
31
|
const nextManual = manual.includes(value) ? manual.filter((v) => v !== value) : [...manual, value];
|
|
34
32
|
const next = union(nextManual, impliedFrom(nextManual, implies)).map((v) => rawOf.get(v) ?? v);
|
|
35
33
|
setManual(nextManual);
|
|
36
|
-
|
|
37
|
-
setFieldValue(fieldName, next);
|
|
34
|
+
change(next);
|
|
38
35
|
onChange?.(next);
|
|
39
|
-
setFormDirty(true);
|
|
40
36
|
};
|
|
41
37
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
42
38
|
optional: field.optional,
|
|
@@ -53,13 +49,13 @@ function CheckboxGroupField({ field, label, labelPosition, missing, disabled, on
|
|
|
53
49
|
const locked = forced.has(option.value);
|
|
54
50
|
const optionDisabled = disabled || locked;
|
|
55
51
|
return /* @__PURE__ */ jsxs("label", {
|
|
56
|
-
className:
|
|
52
|
+
className: clsx("-mx-2 flex items-start gap-2.5 rounded-md px-2 py-1.5 transition-colors", optionDisabled ? "cursor-not-allowed opacity-60" : "cursor-pointer hover:bg-(--theme-hover) has-[:focus-visible]:bg-(--theme-hover)"),
|
|
57
53
|
children: [/* @__PURE__ */ jsx("input", {
|
|
58
54
|
type: "checkbox",
|
|
59
55
|
checked: manual.includes(option.value) || locked,
|
|
60
56
|
disabled: optionDisabled,
|
|
61
57
|
onChange: () => handleToggle(option.value),
|
|
62
|
-
className:
|
|
58
|
+
className: clsx("h-4 min-h-0 w-4 rounded accent-(--theme-link)", optionDisabled ? "cursor-not-allowed" : "cursor-pointer", missing && "invalid")
|
|
63
59
|
}), /* @__PURE__ */ jsxs("div", {
|
|
64
60
|
className: "flex min-w-0 flex-col",
|
|
65
61
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
1
|
import type { FieldComponentProps } from '../types/fieldComponentTypes.js';
|
|
3
2
|
import type { BaseField } from '../types/fieldTypes.js';
|
|
4
3
|
export interface IColorField extends BaseField {
|
|
5
4
|
type: 'color';
|
|
6
5
|
default?: string;
|
|
7
6
|
}
|
|
8
|
-
export default function ColorField(props: FieldComponentProps<IColorField>):
|
|
7
|
+
export default function ColorField(props: FieldComponentProps<IColorField>): import("react").JSX.Element;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
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
|
|
8
|
-
const [fieldState] = useField(fieldName);
|
|
9
|
-
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
7
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
10
8
|
const handleChange = (e) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
setFieldTouched(fieldName, true);
|
|
14
|
-
setFieldValue(fieldName, val);
|
|
9
|
+
onChange?.(e.target.value);
|
|
10
|
+
change(e.target.value);
|
|
15
11
|
};
|
|
16
12
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
17
13
|
optional: field.optional,
|
|
@@ -19,13 +15,12 @@ function ColorField(props) {
|
|
|
19
15
|
tooltipComponent,
|
|
20
16
|
labelPosition,
|
|
21
17
|
spaceCompact,
|
|
22
|
-
children: ({ id }) => /* @__PURE__ */ jsx(
|
|
18
|
+
children: ({ id }) => /* @__PURE__ */ jsx("input", {
|
|
23
19
|
className: "theme-input h-8 w-18 rounded border border-neutral-400 placeholder:text-xs",
|
|
24
20
|
id,
|
|
25
21
|
name: field.name,
|
|
26
|
-
value:
|
|
22
|
+
value: value || "#fbbf24",
|
|
27
23
|
type: "color",
|
|
28
|
-
"aria-required": field.optional ? void 0 : true,
|
|
29
24
|
onChange: handleChange
|
|
30
25
|
})
|
|
31
26
|
});
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import type { FieldComponentProps } from '../types/fieldComponentTypes.js';
|
|
2
2
|
import type { BaseField } from '../types/fieldTypes.js';
|
|
3
|
+
import { type FieldOption } from '../utils/fieldItems.js';
|
|
3
4
|
export interface IDropdownField extends BaseField {
|
|
4
5
|
type: 'dropdown';
|
|
5
6
|
dropdownType?: string;
|
|
6
|
-
options:
|
|
7
|
-
label: string;
|
|
8
|
-
value: string;
|
|
9
|
-
secondaryLabel?: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
}> | Record<string, Array<{
|
|
12
|
-
label: string;
|
|
13
|
-
value: string;
|
|
14
|
-
secondaryLabel?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
}>>;
|
|
7
|
+
options: FieldOption[] | Record<string, FieldOption[]>;
|
|
17
8
|
parentValue?: string;
|
|
18
9
|
autoselect?: boolean;
|
|
19
10
|
allowCustomValue?: boolean;
|
|
20
|
-
customValueLabel?: string;
|
|
21
11
|
placeholder?: string;
|
|
22
12
|
}
|
|
23
|
-
export default function DropdownField(
|
|
13
|
+
export default function DropdownField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, }: FieldComponentProps<IDropdownField>): import("react").JSX.Element;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { Autocomplete, Combobox } from "../../components/Combobox.js";
|
|
1
2
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
3
|
+
import { useChoiceField } from "../useChoiceField.js";
|
|
4
|
+
import { useDependentOptions } from "../utils/dependentOptions.js";
|
|
5
|
+
import { toFieldItems } from "../utils/fieldItems.js";
|
|
4
6
|
import { getPlaceholder } from "../utils/getPlaceholder.js";
|
|
5
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { useMemo } from "react";
|
|
6
9
|
//#region src/form/Fields/DropdownField.tsx
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function DropdownField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact }) {
|
|
11
|
+
const { options } = useDependentOptions(field.options, field.depends_on);
|
|
12
|
+
const items = useMemo(() => toFieldItems(options), [options]);
|
|
13
|
+
const [value, choose] = useChoiceField({
|
|
14
|
+
name: field.name ?? "",
|
|
15
|
+
items,
|
|
16
|
+
autoselect: field.autoselect,
|
|
17
|
+
secondaryField: Array.isArray(field.secondaryField) ? field.secondaryField[0] : field.secondaryField,
|
|
18
|
+
onChange
|
|
19
|
+
});
|
|
20
|
+
const placeholder = getPlaceholder(field.placeholder, typeof field.default === "string" ? field.default : void 0);
|
|
15
21
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
16
22
|
optional: field.optional,
|
|
17
23
|
label,
|
|
@@ -19,26 +25,33 @@ function DropdownField(props) {
|
|
|
19
25
|
description: field.description,
|
|
20
26
|
labelPosition,
|
|
21
27
|
spaceCompact,
|
|
22
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
28
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsx("div", {
|
|
23
29
|
className: "grow min-w-0",
|
|
24
|
-
children: /* @__PURE__ */ jsx(
|
|
25
|
-
|
|
30
|
+
children: field.allowCustomValue ? /* @__PURE__ */ jsx(Autocomplete, {
|
|
31
|
+
id,
|
|
32
|
+
"aria-describedby": describedBy,
|
|
33
|
+
"aria-label": label,
|
|
34
|
+
"aria-invalid": missing,
|
|
35
|
+
required: !field.optional,
|
|
36
|
+
disabled,
|
|
26
37
|
className: "w-full",
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
placeholder,
|
|
39
|
+
items,
|
|
40
|
+
value: value == null ? "" : String(value),
|
|
41
|
+
onValueChange: choose
|
|
42
|
+
}) : /* @__PURE__ */ jsx(Combobox, {
|
|
43
|
+
id,
|
|
44
|
+
"aria-describedby": describedBy,
|
|
45
|
+
"aria-label": label,
|
|
46
|
+
"aria-invalid": missing,
|
|
47
|
+
required: !field.optional,
|
|
33
48
|
disabled,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setFieldTouched: setFieldTouched ?? missingSetter
|
|
41
|
-
}, field.name)
|
|
49
|
+
className: "w-full",
|
|
50
|
+
placeholder,
|
|
51
|
+
items,
|
|
52
|
+
value: value ?? null,
|
|
53
|
+
onValueChange: choose
|
|
54
|
+
})
|
|
42
55
|
})
|
|
43
56
|
});
|
|
44
57
|
}
|
|
@@ -9,5 +9,4 @@ export interface IDurationField extends BaseField {
|
|
|
9
9
|
disableValue?: number;
|
|
10
10
|
disableLabel?: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export default _default;
|
|
12
|
+
export default function DurationField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, }: FieldComponentProps<IDurationField>): import("react").JSX.Element;
|