@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,21 +1,24 @@
|
|
|
1
1
|
import { useStrings } from "../../components/Provider.js";
|
|
2
2
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
3
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
3
4
|
import { formatDuration, parseDuration } from "../utils/duration.js";
|
|
4
5
|
import { setDurationValidity } from "./durationValidity.js";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import { useFormContext } from "react-hook-form";
|
|
8
10
|
//#region src/form/Fields/DurationField.tsx
|
|
9
|
-
var DEBOUNCE_MS = 500;
|
|
10
11
|
var isNumericString = (value) => typeof value === "string" && /^\d+$/.test(value.trim());
|
|
11
12
|
var toDisplay = (value) => {
|
|
12
13
|
if (typeof value === "number") return formatDuration(value);
|
|
13
14
|
if (isNumericString(value)) return formatDuration(Number(value));
|
|
14
15
|
return "";
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
function DurationField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact }) {
|
|
17
18
|
const { form: t } = useStrings();
|
|
18
19
|
const name = field.name ?? "";
|
|
20
|
+
const [currentValue, change] = useFieldValue(name);
|
|
21
|
+
const { setValue } = useFormContext();
|
|
19
22
|
const min = field.min !== void 0 ? Number(field.min) : Number.NEGATIVE_INFINITY;
|
|
20
23
|
const max = field.max !== void 0 ? Number(field.max) : Number.POSITIVE_INFINITY;
|
|
21
24
|
const disableValue = field.disableValue;
|
|
@@ -23,12 +26,11 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
23
26
|
const isSentinel = hasDisableCheckbox && currentValue !== "" && Number(currentValue) === disableValue;
|
|
24
27
|
const [text, setText] = useState(() => toDisplay(currentValue));
|
|
25
28
|
const focusedRef = useRef(false);
|
|
26
|
-
const debounceRef = useRef(null);
|
|
27
29
|
useEffect(() => {
|
|
28
30
|
if (isSentinel) {
|
|
29
|
-
if (typeof currentValue !== "number")
|
|
30
|
-
} else if (isNumericString(currentValue))
|
|
31
|
-
else if ((currentValue === void 0 || currentValue === null || currentValue === "") && typeof field.default === "number")
|
|
31
|
+
if (typeof currentValue !== "number") setValue(name, disableValue);
|
|
32
|
+
} else if (isNumericString(currentValue)) setValue(name, Number(currentValue));
|
|
33
|
+
else if ((currentValue === void 0 || currentValue === null || currentValue === "") && typeof field.default === "number") setValue(name, field.default);
|
|
32
34
|
}, []);
|
|
33
35
|
useEffect(() => {
|
|
34
36
|
if (!focusedRef.current) setText(toDisplay(currentValue));
|
|
@@ -43,44 +45,35 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
43
45
|
useEffect(() => {
|
|
44
46
|
setDurationValidity(name, error === null);
|
|
45
47
|
}, [name, error]);
|
|
46
|
-
useEffect(() => () =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}, [name]);
|
|
50
|
-
const flushToFormik = (val) => {
|
|
51
|
-
setFieldValue?.(name, val);
|
|
48
|
+
useEffect(() => () => setDurationValidity(name, true), [name]);
|
|
49
|
+
const set = (val) => {
|
|
50
|
+
change(val);
|
|
52
51
|
onChange?.(val);
|
|
53
|
-
setFieldTouched?.(name, true);
|
|
54
52
|
};
|
|
55
53
|
const handleDisableToggle = (checked) => {
|
|
56
|
-
clearTimeout(debounceRef.current ?? void 0);
|
|
57
|
-
setFormDirty(true);
|
|
58
54
|
if (checked) {
|
|
59
55
|
setText("");
|
|
60
|
-
if (disableValue !== void 0)
|
|
61
|
-
} else
|
|
56
|
+
if (disableValue !== void 0) set(disableValue);
|
|
57
|
+
} else set(typeof field.default === "number" ? field.default : "");
|
|
62
58
|
};
|
|
63
59
|
const handleChange = (e) => {
|
|
64
60
|
const raw = e.target.value;
|
|
65
61
|
setText(raw);
|
|
66
|
-
setFormDirty(true);
|
|
67
|
-
clearTimeout(debounceRef.current ?? void 0);
|
|
68
62
|
const rawTrimmed = raw.trim();
|
|
69
63
|
const value = rawTrimmed === "" ? "" : parseDuration(rawTrimmed);
|
|
70
|
-
if (value === "" || typeof value === "number" && value >= min && value <= max)
|
|
64
|
+
if (value === "" || typeof value === "number" && value >= min && value <= max) set(value);
|
|
71
65
|
};
|
|
72
66
|
const handleFocus = () => {
|
|
73
67
|
focusedRef.current = true;
|
|
74
68
|
};
|
|
75
69
|
const handleBlur = () => {
|
|
76
70
|
focusedRef.current = false;
|
|
77
|
-
clearTimeout(debounceRef.current ?? void 0);
|
|
78
71
|
if (trimmed === "") {
|
|
79
72
|
setText("");
|
|
80
|
-
|
|
73
|
+
set("");
|
|
81
74
|
} else if (parsed !== null && parsed >= min && parsed <= max) {
|
|
82
75
|
setText(formatDuration(parsed));
|
|
83
|
-
|
|
76
|
+
set(parsed);
|
|
84
77
|
}
|
|
85
78
|
};
|
|
86
79
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
@@ -90,10 +83,10 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
90
83
|
labelPosition,
|
|
91
84
|
spaceCompact: spaceCompact ?? false,
|
|
92
85
|
...field.description !== void 0 && { description: field.description },
|
|
93
|
-
children: ({ id, describedBy }) => /* @__PURE__ */ jsxs(Fragment
|
|
86
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
87
|
!isSentinel && /* @__PURE__ */ jsx("input", {
|
|
95
88
|
"data-1p-ignore": true,
|
|
96
|
-
className:
|
|
89
|
+
className: clsx("w-full", disabled && "disabled", (missing || error !== null) && "invalid"),
|
|
97
90
|
id,
|
|
98
91
|
"aria-describedby": describedBy,
|
|
99
92
|
name,
|
|
@@ -111,13 +104,13 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
111
104
|
children: error
|
|
112
105
|
}),
|
|
113
106
|
hasDisableCheckbox && /* @__PURE__ */ jsxs("label", {
|
|
114
|
-
className:
|
|
107
|
+
className: clsx("flex items-center gap-2 mt-1", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"),
|
|
115
108
|
children: [/* @__PURE__ */ jsx("input", {
|
|
116
109
|
type: "checkbox",
|
|
117
110
|
checked: isSentinel,
|
|
118
111
|
disabled,
|
|
119
112
|
onChange: (e) => handleDisableToggle(e.target.checked),
|
|
120
|
-
className:
|
|
113
|
+
className: clsx("h-4 w-4 accent-(--theme-link)", disabled ? "cursor-not-allowed" : "cursor-pointer")
|
|
121
114
|
}), /* @__PURE__ */ jsx("span", {
|
|
122
115
|
className: "theme-text",
|
|
123
116
|
children: field.disableLabel
|
|
@@ -125,6 +118,6 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
125
118
|
})
|
|
126
119
|
] })
|
|
127
120
|
});
|
|
128
|
-
}
|
|
121
|
+
}
|
|
129
122
|
//#endregion
|
|
130
|
-
export {
|
|
123
|
+
export { DurationField as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/form/Fields/LabelField.tsx
|
|
4
4
|
function LabelField(props) {
|
|
@@ -10,7 +10,7 @@ function LabelField(props) {
|
|
|
10
10
|
whiteSpace: "pre-wrap",
|
|
11
11
|
...field.size ? { fontSize: `${field.size}px` } : {}
|
|
12
12
|
},
|
|
13
|
-
className:
|
|
13
|
+
className: clsx("relative", "text-md", field.bold !== false ? "font-bold" : ""),
|
|
14
14
|
children: field.text?.toString().replace(/(\r)/g, "").replace(/(\\n)/g, "\n") || label
|
|
15
15
|
})
|
|
16
16
|
});
|
|
@@ -1,18 +1,12 @@
|
|
|
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';
|
|
4
|
+
type MultiDropdownValue = string | boolean | number;
|
|
5
|
+
type MultiDropdownOption = FieldOption<MultiDropdownValue>;
|
|
3
6
|
export interface IMultiDropdownField extends BaseField {
|
|
4
7
|
type: 'multi-dropdown';
|
|
5
|
-
options:
|
|
6
|
-
label: string;
|
|
7
|
-
value: string | boolean | number;
|
|
8
|
-
secondaryLabel?: string;
|
|
9
|
-
selected?: boolean;
|
|
10
|
-
}> | Record<string, Array<string | {
|
|
11
|
-
label: string;
|
|
12
|
-
value: string | boolean | number;
|
|
13
|
-
secondaryLabel?: string;
|
|
14
|
-
selected?: boolean;
|
|
15
|
-
}>>;
|
|
8
|
+
options: MultiDropdownOption[] | Record<string, MultiDropdownOption[]>;
|
|
16
9
|
parentValue?: string | boolean | number;
|
|
17
10
|
}
|
|
18
|
-
export default function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing,
|
|
11
|
+
export default function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, onChange, }: FieldComponentProps<IMultiDropdownField>): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -1,36 +1,45 @@
|
|
|
1
|
+
import { Combobox } from "../../components/Combobox.js";
|
|
1
2
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
4
|
+
import { useDependentOptions } from "../utils/dependentOptions.js";
|
|
5
|
+
import { toFieldItems } from "../utils/fieldItems.js";
|
|
6
|
+
import { usePrevious } from "../usePrevious.js";
|
|
4
7
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
8
|
+
import { useEffect, useMemo } from "react";
|
|
6
9
|
//#region src/form/Fields/MultiDropdownField.tsx
|
|
7
|
-
function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing,
|
|
8
|
-
const
|
|
9
|
-
const dependent =
|
|
10
|
-
const
|
|
10
|
+
function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, onChange }) {
|
|
11
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
12
|
+
const dependent = useDependentOptions(field.options, field.depends_on);
|
|
13
|
+
const items = useMemo(() => toFieldItems(dependent.options), [dependent.options]);
|
|
11
14
|
const parentValue = field.depends_on ? dependent.parentValue : field.parentValue;
|
|
15
|
+
const previousParent = usePrevious(parentValue);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (previousParent !== void 0 && previousParent !== parentValue) change([]);
|
|
18
|
+
}, [
|
|
19
|
+
previousParent,
|
|
20
|
+
parentValue,
|
|
21
|
+
change
|
|
22
|
+
]);
|
|
12
23
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
13
24
|
optional: field.optional,
|
|
14
25
|
label,
|
|
15
26
|
tooltipComponent,
|
|
16
27
|
labelPosition,
|
|
17
28
|
spaceCompact,
|
|
18
|
-
children: ({ id }) =>
|
|
19
|
-
className: "theme-input h-7 w-full rounded border placeholder:text-xs",
|
|
29
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsx(Combobox, {
|
|
20
30
|
id,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, field.name)
|
|
31
|
+
"aria-describedby": describedBy,
|
|
32
|
+
multiple: true,
|
|
33
|
+
items,
|
|
34
|
+
value: value ?? [],
|
|
35
|
+
onValueChange: (next) => {
|
|
36
|
+
change(next);
|
|
37
|
+
onChange?.(next);
|
|
38
|
+
},
|
|
39
|
+
required: !field.optional,
|
|
40
|
+
disabled,
|
|
41
|
+
"aria-invalid": missing
|
|
42
|
+
})
|
|
34
43
|
});
|
|
35
44
|
}
|
|
36
45
|
//#endregion
|
|
@@ -10,4 +10,4 @@ export interface INumberField extends BaseField {
|
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
thousandsSeparator?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export default function NumberField(
|
|
13
|
+
export default function NumberField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, }: FieldComponentProps<INumberField>): import("react").JSX.Element;
|
|
@@ -1,52 +1,82 @@
|
|
|
1
|
+
import { FaAngleDown } from "../../icons/fa/FaAngleDown.js";
|
|
2
|
+
import { FaAngleUp } from "../../icons/fa/FaAngleUp.js";
|
|
1
3
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
-
import
|
|
3
|
-
import FormikNumericInput from "../SpecialTypes/FormikNumericInput.js";
|
|
4
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
4
5
|
import { getPlaceholder } from "../utils/getPlaceholder.js";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
8
|
import { useEffect } from "react";
|
|
6
|
-
import {
|
|
7
|
-
import { useField, useFormikContext } from "formik";
|
|
9
|
+
import { NumberField } from "@base-ui/react/number-field";
|
|
8
10
|
//#region src/form/Fields/NumberField.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/** A value held as text, as one read from a workflow's inputs may be, still shows as its number. */
|
|
12
|
+
function toNumber(value) {
|
|
13
|
+
if (typeof value === "number") return value;
|
|
14
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
15
|
+
const parsed = Number(value);
|
|
16
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var stepperClassName = "flex flex-1 items-center justify-center px-1 theme-muted-text hover:theme-text data-disabled:opacity-40 data-disabled:cursor-not-allowed";
|
|
21
|
+
function NumberField$1({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact }) {
|
|
22
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
23
|
+
const unset = value === void 0 || value === null || value === "";
|
|
24
|
+
const seed = field.prefillDefault && unset ? field.default : void 0;
|
|
14
25
|
useEffect(() => {
|
|
15
|
-
if (
|
|
16
|
-
}, [
|
|
17
|
-
field.prefillDefault,
|
|
18
|
-
field.default,
|
|
19
|
-
fieldName,
|
|
20
|
-
fieldState.value,
|
|
21
|
-
setFieldValue
|
|
22
|
-
]);
|
|
26
|
+
if (seed !== void 0) change(seed);
|
|
27
|
+
}, [seed, change]);
|
|
23
28
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
24
29
|
optional: field.optional,
|
|
25
30
|
label,
|
|
26
31
|
tooltipComponent,
|
|
32
|
+
description: field.description,
|
|
27
33
|
labelPosition,
|
|
28
34
|
spaceCompact,
|
|
29
|
-
children:
|
|
30
|
-
|
|
31
|
-
name:
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsx(NumberField.Root, {
|
|
36
|
+
id,
|
|
37
|
+
name: field.name,
|
|
38
|
+
value: toNumber(value),
|
|
39
|
+
onValueChange: (next) => {
|
|
40
|
+
const number = next ?? void 0;
|
|
41
|
+
onChange?.(number);
|
|
42
|
+
change(number);
|
|
43
|
+
},
|
|
34
44
|
min: field.min,
|
|
35
45
|
max: field.max,
|
|
36
|
-
...onChange && { onChange }
|
|
37
|
-
}, field.name) : /* @__PURE__ */ jsx(FormikCustomInput, {
|
|
38
|
-
invalid: missing,
|
|
39
|
-
name: fieldName,
|
|
40
|
-
type: "number",
|
|
41
|
-
placeholder: getPlaceholder(field.placeholder, field.default),
|
|
42
|
-
disabled,
|
|
43
46
|
step: field.step,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
disabled,
|
|
48
|
+
format: {
|
|
49
|
+
useGrouping: field.thousandsSeparator ?? false,
|
|
50
|
+
maximumFractionDigits: 20
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ jsxs(NumberField.Group, {
|
|
53
|
+
className: "relative w-full",
|
|
54
|
+
children: [/* @__PURE__ */ jsx(NumberField.Input, {
|
|
55
|
+
"aria-describedby": describedBy,
|
|
56
|
+
"aria-required": field.optional ? void 0 : true,
|
|
57
|
+
"aria-invalid": missing || void 0,
|
|
58
|
+
"data-1p-ignore": true,
|
|
59
|
+
className: clsx("w-full pr-6 tabular-nums", disabled && "disabled", missing && "invalid"),
|
|
60
|
+
placeholder: getPlaceholder(field.placeholder, field.default)
|
|
61
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: "absolute inset-y-px right-px flex flex-col",
|
|
63
|
+
children: [/* @__PURE__ */ jsx(NumberField.Increment, {
|
|
64
|
+
className: stepperClassName,
|
|
65
|
+
children: /* @__PURE__ */ jsx(FaAngleUp, {
|
|
66
|
+
"aria-hidden": "true",
|
|
67
|
+
className: "size-3"
|
|
68
|
+
})
|
|
69
|
+
}), /* @__PURE__ */ jsx(NumberField.Decrement, {
|
|
70
|
+
className: stepperClassName,
|
|
71
|
+
children: /* @__PURE__ */ jsx(FaAngleDown, {
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
className: "size-3"
|
|
74
|
+
})
|
|
75
|
+
})]
|
|
76
|
+
})]
|
|
77
|
+
})
|
|
78
|
+
})
|
|
49
79
|
});
|
|
50
80
|
}
|
|
51
81
|
//#endregion
|
|
52
|
-
export { NumberField as default };
|
|
82
|
+
export { NumberField$1 as default };
|
|
@@ -4,4 +4,4 @@ export interface IObjectField extends BaseField {
|
|
|
4
4
|
type: 'object';
|
|
5
5
|
options: DynamicFormSchema;
|
|
6
6
|
}
|
|
7
|
-
export default function ObjectField({ field, label, tooltipComponent,
|
|
7
|
+
export default function ObjectField({ field, label, tooltipComponent, labelPosition, spaceCompact, }: FieldComponentProps<IObjectField>): import("react").JSX.Element;
|
|
@@ -1,55 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FieldsFromOptions,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useFormikContext } from "formik";
|
|
1
|
+
import { FieldGroup } from "../FieldGroup.js";
|
|
2
|
+
import { FieldsFromOptions, resolveMetaOverrides } from "../Form.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useMemo } from "react";
|
|
6
5
|
//#region src/form/Fields/ObjectField.tsx
|
|
7
|
-
function ObjectField({ field, label, tooltipComponent,
|
|
6
|
+
function ObjectField({ field, label, tooltipComponent, labelPosition, spaceCompact }) {
|
|
8
7
|
const fieldName = field.name ?? "";
|
|
9
|
-
const [open, setOpen] = useState(field.collapsed !== void 0 ? !field.collapsed : true);
|
|
10
|
-
const { values, setFieldValue, setFieldTouched } = useFormikContext();
|
|
11
8
|
const meta = resolveMetaOverrides(field.options, labelPosition, spaceCompact ?? false);
|
|
12
|
-
const
|
|
13
|
-
|
|
9
|
+
const parentInfo = useMemo(() => ({ fieldNamePrefix: `${fieldName}.` }), [fieldName]);
|
|
10
|
+
return /* @__PURE__ */ jsx(FieldGroup, {
|
|
11
|
+
title: field.label || label,
|
|
12
|
+
actions: tooltipComponent,
|
|
13
|
+
collapsible: !field.noCollapse,
|
|
14
|
+
defaultOpen: !field.collapsed,
|
|
14
15
|
children: /* @__PURE__ */ jsx(FieldsFromOptions, {
|
|
15
16
|
options: field.options,
|
|
16
|
-
values,
|
|
17
|
-
setFormDirty,
|
|
18
|
-
setFieldValue,
|
|
19
|
-
setFieldTouched,
|
|
20
|
-
missingFields,
|
|
21
|
-
workflowForm,
|
|
22
17
|
labelPosition: meta.labelPosition,
|
|
23
18
|
spaceCompact: meta.spaceCompact,
|
|
24
|
-
parentInfo
|
|
25
|
-
parentName: fieldName,
|
|
26
|
-
fieldNamePrefix: `${fieldName}.`
|
|
27
|
-
}
|
|
19
|
+
parentInfo
|
|
28
20
|
})
|
|
29
21
|
});
|
|
30
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
31
|
-
className: "flex flex-col w-full",
|
|
32
|
-
children: [field.noCollapse && /* @__PURE__ */ jsx("div", {
|
|
33
|
-
className: "flex items-center w-full mb-[15px]",
|
|
34
|
-
children: /* @__PURE__ */ jsxs("h3", {
|
|
35
|
-
className: "flex items-center gap-1 text-md font-bold",
|
|
36
|
-
children: [
|
|
37
|
-
label,
|
|
38
|
-
" ",
|
|
39
|
-
tooltipComponent
|
|
40
|
-
]
|
|
41
|
-
})
|
|
42
|
-
}), field.noCollapse ? body : /* @__PURE__ */ jsx(ControlledCollapsiblePanel, {
|
|
43
|
-
open,
|
|
44
|
-
setOpen,
|
|
45
|
-
title: /* @__PURE__ */ jsx(GroupHeader, {
|
|
46
|
-
open,
|
|
47
|
-
setOpen,
|
|
48
|
-
title: field.label || label
|
|
49
|
-
}),
|
|
50
|
-
children: body
|
|
51
|
-
})]
|
|
52
|
-
});
|
|
53
22
|
}
|
|
54
23
|
//#endregion
|
|
55
24
|
export { ObjectField as default };
|
|
@@ -8,4 +8,4 @@ export interface IRadioField extends BaseField {
|
|
|
8
8
|
}>;
|
|
9
9
|
optionLabelPosition?: 'left' | 'top';
|
|
10
10
|
}
|
|
11
|
-
export default function RadioField(
|
|
11
|
+
export default function RadioField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, }: FieldComponentProps<IRadioField>): import("react").JSX.Element;
|
|
@@ -1,56 +1,45 @@
|
|
|
1
|
+
import { Radio, RadioGroup } from "../../components/Radio.js";
|
|
1
2
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
3
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
2
4
|
import { fieldOption } from "./fieldOption.js";
|
|
3
|
-
import
|
|
4
|
-
import { useId } from "react";
|
|
5
|
+
import { clsx } from "clsx";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useField, useFormikContext } from "formik";
|
|
7
7
|
//#region src/form/Fields/RadioField.tsx
|
|
8
|
-
function RadioField(
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const handleChange = (val) => {
|
|
15
|
-
if (disabled) return;
|
|
16
|
-
onChange?.(val);
|
|
17
|
-
setFieldTouched(fieldName, true);
|
|
18
|
-
setFieldValue(fieldName, val);
|
|
19
|
-
setFormDirty(true);
|
|
20
|
-
};
|
|
8
|
+
function RadioField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact }) {
|
|
9
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
10
|
+
const options = (field.options ?? []).map((raw) => ({
|
|
11
|
+
...fieldOption(raw),
|
|
12
|
+
unlabelled: typeof raw !== "object" || raw.label === void 0
|
|
13
|
+
}));
|
|
21
14
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
22
15
|
optional: field.optional,
|
|
23
16
|
label,
|
|
24
17
|
tooltipComponent,
|
|
25
18
|
labelPosition,
|
|
26
19
|
spaceCompact,
|
|
27
|
-
children: ({ labelId, describedBy }) => /* @__PURE__ */ jsx(
|
|
28
|
-
role: "radiogroup",
|
|
20
|
+
children: ({ labelId, describedBy }) => /* @__PURE__ */ jsx(RadioGroup, {
|
|
29
21
|
"aria-labelledby": labelId,
|
|
30
22
|
"aria-describedby": describedBy,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})]
|
|
52
|
-
}, field.name + option.value);
|
|
53
|
-
})
|
|
23
|
+
name: field.name,
|
|
24
|
+
required: !field.optional,
|
|
25
|
+
disabled,
|
|
26
|
+
value: value === void 0 || value === null ? null : String(value),
|
|
27
|
+
onValueChange: (next) => {
|
|
28
|
+
const picked = options.find((option) => option.value === next)?.raw;
|
|
29
|
+
onChange?.(picked);
|
|
30
|
+
change(picked);
|
|
31
|
+
},
|
|
32
|
+
className: clsx("flex py-1.5", field.optionLabelPosition === "top" ? "flex-col gap-2" : "flex-row flex-wrap gap-x-5 gap-y-2"),
|
|
33
|
+
children: options.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
34
|
+
className: clsx("flex items-center gap-2", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"),
|
|
35
|
+
children: [/* @__PURE__ */ jsx(Radio, {
|
|
36
|
+
value: option.value,
|
|
37
|
+
"aria-invalid": missing || void 0
|
|
38
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
39
|
+
className: clsx("theme-text", option.unlabelled && "capitalize"),
|
|
40
|
+
children: option.label
|
|
41
|
+
})]
|
|
42
|
+
}, option.value))
|
|
54
43
|
})
|
|
55
44
|
});
|
|
56
45
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
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 IRangeField extends BaseField {
|
|
@@ -8,4 +7,4 @@ export interface IRangeField extends BaseField {
|
|
|
8
7
|
max: number;
|
|
9
8
|
step?: number;
|
|
10
9
|
}
|
|
11
|
-
export default function RangeField(props: FieldComponentProps<IRangeField>):
|
|
10
|
+
export default function RangeField(props: FieldComponentProps<IRangeField>): import("react").JSX.Element;
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { FieldWrapper } from "../FieldWrapper.js";
|
|
2
|
-
import
|
|
2
|
+
import { useFieldValue } from "../useFieldValue.js";
|
|
3
|
+
import { clsx } from "clsx";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useFormContext } from "react-hook-form";
|
|
5
7
|
//#region src/form/Fields/RangeField.tsx
|
|
6
8
|
function RangeField(props) {
|
|
7
|
-
const { field, label, labelPosition, disabled, onChange, tooltipComponent, spaceCompact
|
|
8
|
-
const
|
|
9
|
-
const [
|
|
10
|
-
const {
|
|
9
|
+
const { field, label, labelPosition, disabled, onChange, tooltipComponent, spaceCompact } = props;
|
|
10
|
+
const name = field.name ?? "";
|
|
11
|
+
const [value, change] = useFieldValue(name);
|
|
12
|
+
const { setValue } = useFormContext();
|
|
11
13
|
const handleChange = (e) => {
|
|
12
14
|
let val = e.target.valueAsNumber;
|
|
13
15
|
if (!Number.isNaN(val)) {
|
|
14
16
|
val = Math.max(field.min, Math.min(field.max, val));
|
|
15
|
-
|
|
17
|
+
change(val);
|
|
16
18
|
onChange?.(val);
|
|
17
|
-
setFieldTouched(fieldName, true);
|
|
18
|
-
setFormDirty(true);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
const seedValue = field.default ?? field.min;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const seed = (value === void 0 || value === null) && seedValue !== void 0;
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (seed) setValue(name, seedValue);
|
|
25
|
+
}, [
|
|
26
|
+
seed,
|
|
27
|
+
seedValue,
|
|
28
|
+
name,
|
|
29
|
+
setValue
|
|
30
|
+
]);
|
|
31
|
+
const currentValue = value ?? seedValue ?? "";
|
|
24
32
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
25
33
|
optional: field.optional,
|
|
26
34
|
label,
|
|
@@ -29,8 +37,8 @@ function RangeField(props) {
|
|
|
29
37
|
spaceCompact,
|
|
30
38
|
children: ({ id, labelId }) => /* @__PURE__ */ jsxs("div", {
|
|
31
39
|
className: "flex items-center",
|
|
32
|
-
children: [/* @__PURE__ */ jsx(
|
|
33
|
-
className:
|
|
40
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
41
|
+
className: clsx("theme-input h-7 w-1/3 mr-5 text-center rounded border", disabled && "disabled"),
|
|
34
42
|
id,
|
|
35
43
|
type: "number",
|
|
36
44
|
value: currentValue,
|
|
@@ -39,13 +47,12 @@ function RangeField(props) {
|
|
|
39
47
|
step: field.step || 1,
|
|
40
48
|
disabled,
|
|
41
49
|
onChange: handleChange
|
|
42
|
-
}), /* @__PURE__ */ jsx(
|
|
43
|
-
className:
|
|
50
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
51
|
+
className: clsx("rounded w-full", disabled && "disabled"),
|
|
44
52
|
name: field.name,
|
|
45
53
|
value: currentValue,
|
|
46
54
|
type: "range",
|
|
47
55
|
"aria-labelledby": labelId,
|
|
48
|
-
"aria-required": field.optional ? void 0 : true,
|
|
49
56
|
min: field.min,
|
|
50
57
|
max: field.max,
|
|
51
58
|
step: field.step || 1,
|
|
@@ -13,5 +13,4 @@ export interface IStringField extends BaseField {
|
|
|
13
13
|
sanitize?: string;
|
|
14
14
|
prefillDefault?: boolean;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
export default _default;
|
|
16
|
+
export default function StringField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, }: FieldComponentProps<IStringField>): import("react").JSX.Element;
|