@parallelworks/ui 0.19.0 → 0.20.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.
Files changed (233) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunks/memoryStore-CC91S5LP.js → ai/adapter/memoryStore.js} +2 -2
  3. package/dist/ai/adapter/mock/index.js +2 -80
  4. package/dist/ai/adapter/mock/mockAdapter.js +81 -0
  5. package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
  6. package/dist/ai/adapter/openai/errors.js +37 -0
  7. package/dist/ai/adapter/openai/index.js +5 -333
  8. package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
  9. package/dist/ai/adapter/openai/responses.js +108 -0
  10. package/dist/ai/adapter/openai/sse.js +112 -0
  11. package/dist/{chunks/types-Yy0NrerF.js → ai/adapter/types.js} +1 -1
  12. package/dist/ai/agent/classifier.js +12 -0
  13. package/dist/ai/agent/diff.js +223 -0
  14. package/dist/ai/agent/diffHighlight.js +101 -0
  15. package/dist/ai/agent/permissions.js +29 -0
  16. package/dist/ai/agent/toolfmt.js +383 -0
  17. package/dist/ai/agent/transcript.js +127 -0
  18. package/dist/ai/components/AllocationSelector.js +56 -0
  19. package/dist/ai/components/AttachmentManager.js +147 -0
  20. package/dist/ai/components/AttachmentUpload.js +179 -0
  21. package/dist/ai/components/BlockedGroupBanner.js +29 -0
  22. package/dist/ai/components/BranchNavigator.js +57 -0
  23. package/dist/ai/components/ChatEmptyState.js +171 -0
  24. package/dist/ai/components/ChatInput.js +265 -0
  25. package/dist/ai/components/ChatLayout.js +15 -0
  26. package/dist/ai/components/ChatMessage.js +341 -0
  27. package/dist/ai/components/ChatMessageList.js +301 -0
  28. package/dist/ai/components/ChatSidebar.js +345 -0
  29. package/dist/ai/components/ChatThread.js +198 -0
  30. package/dist/ai/components/ComposerChrome.js +50 -0
  31. package/dist/ai/components/ComposerFrame.js +33 -0
  32. package/dist/ai/components/DragOverlay.js +20 -0
  33. package/dist/ai/components/ModelSelector.js +343 -0
  34. package/dist/ai/components/ShareDialog.js +260 -0
  35. package/dist/ai/components/SlashMenu.js +91 -0
  36. package/dist/ai/components/agent/ActivityLine.js +151 -0
  37. package/dist/ai/components/agent/AgentMessageParts.js +721 -0
  38. package/dist/ai/components/agent/PermissionPicker.js +38 -0
  39. package/dist/ai/components/attachmentKeys.js +10 -0
  40. package/dist/ai/core/ChatProvider.js +848 -0
  41. package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
  42. package/dist/ai/core/chatReducer.js +223 -0
  43. package/dist/ai/core/config.js +46 -0
  44. package/dist/ai/core/events.js +4 -0
  45. package/dist/ai/core/exportConversation.js +42 -0
  46. package/dist/ai/core/greeting.js +38 -0
  47. package/dist/ai/core/parts.js +84 -0
  48. package/dist/ai/core/useDragDrop.js +36 -0
  49. package/dist/ai/core/useKeyboardShortcuts.js +77 -0
  50. package/dist/ai/core/useSSEStream.js +98 -0
  51. package/dist/ai/index.js +43 -6644
  52. package/dist/ai/strings.js +175 -0
  53. package/dist/ai/ui/Avatar.js +35 -0
  54. package/dist/ai/ui/Dropdown.js +110 -0
  55. package/dist/ai/ui/Markdown.js +79 -0
  56. package/dist/ai/ui/Notice.js +77 -0
  57. package/dist/ai/ui/codeBreaks.js +36 -0
  58. package/dist/ai/ui/prose.js +13 -0
  59. package/dist/ai/ui/sidebar.js +148 -0
  60. package/dist/ai/utils.js +23 -0
  61. package/dist/assets/editor.worker-DfmPPyOL.js +60 -0
  62. package/dist/assets/json.worker-Dqgjpq9F.js +92 -0
  63. package/dist/assets/yaml.worker-DLx0whrM.js +1441 -0
  64. package/dist/components/AddMenu.js +46 -0
  65. package/dist/components/Avatar.js +46 -0
  66. package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
  67. package/dist/components/Breadcrumbs.js +83 -0
  68. package/dist/components/Button.js +83 -0
  69. package/dist/components/Callout.js +23 -0
  70. package/dist/components/Card.js +31 -0
  71. package/dist/components/CollapsiblePanel.js +77 -0
  72. package/dist/{chunks/ConfirmModal-aOR4O1QE.js → components/ConfirmModal.js} +4 -9
  73. package/dist/components/CopyToClipboard.js +81 -0
  74. package/dist/{chunks/Markdown-CM-FenNE.js → components/CreateModal.js} +9 -116
  75. package/dist/components/DescriptionList.js +42 -0
  76. package/dist/components/Dropdown.js +349 -0
  77. package/dist/components/EmptyState.js +27 -0
  78. package/dist/components/Filter.js +32 -0
  79. package/dist/components/FilterPill.js +13 -0
  80. package/dist/components/IconButton.js +34 -0
  81. package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
  82. package/dist/components/Input.js +88 -0
  83. package/dist/components/LetterBadge.js +13 -0
  84. package/dist/components/Listbox.js +123 -0
  85. package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
  86. package/dist/components/Markdown.js +15 -0
  87. package/dist/components/MultiSelect.js +171 -0
  88. package/dist/components/Overview.js +39 -0
  89. package/dist/components/PageHeader.js +194 -0
  90. package/dist/components/Pagination.js +35 -0
  91. package/dist/{chunks/Provider-CDYurraE.js → components/Provider.js} +13 -5
  92. package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
  93. package/dist/components/SectionHeader.js +11 -0
  94. package/dist/components/SettingModeOption.js +30 -0
  95. package/dist/components/SettingRow.js +35 -0
  96. package/dist/components/SettingsCard.js +31 -0
  97. package/dist/components/SettingsGroup.js +17 -0
  98. package/dist/components/Sort.js +42 -0
  99. package/dist/components/StatusBadge.js +63 -0
  100. package/dist/components/SwitchToggle.js +59 -0
  101. package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
  102. package/dist/{chunks/Table-DU2MW8xz.js → components/Table.js} +3 -3
  103. package/dist/components/Toggle.js +20 -0
  104. package/dist/{chunks/Tooltip-K5HJr4_p.js → components/Tooltip.js} +2 -27
  105. package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
  106. package/dist/{chunks/focus-D_iZJTW1.js → components/focus.js} +1 -1
  107. package/dist/components/ghostButton.js +7 -0
  108. package/dist/components/inputClasses.js +4 -0
  109. package/dist/components/keys.js +27 -0
  110. package/dist/components/relativeTime.js +32 -0
  111. package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
  112. package/dist/{chunks/duration-BOv8Phl8.js → duration.js} +1 -1
  113. package/dist/editor/Editor.js +13 -0
  114. package/dist/editor/EditorField.js +53 -0
  115. package/dist/editor/FormCodePanel.js +173 -0
  116. package/dist/{chunks/Monaco-DJ8MW-Dq.js → editor/Monaco.js} +5 -26
  117. package/dist/editor/index.js +6 -1
  118. package/dist/editor/themes.js +91 -0
  119. package/dist/editor/workers.d.ts +5 -0
  120. package/dist/editor/workers.js +35 -0
  121. package/dist/editor/yaml.d.ts +9 -1
  122. package/dist/editor/yaml.js +15 -0
  123. package/dist/editor/yaml.worker.d.ts +1 -0
  124. package/dist/editor/yamlLanguage.d.ts +6 -0
  125. package/dist/editor/yamlLanguage.js +312 -0
  126. package/dist/file-explorer/FileExplorer.js +1405 -0
  127. package/dist/file-explorer/FileExplorerContext.js +370 -0
  128. package/dist/{chunks/CodePreviewEditor-YqQBz1YL.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
  129. package/dist/file-explorer/FilePreview/Inline.js +45 -0
  130. package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
  131. package/dist/file-explorer/FilePreview/Viewer.js +526 -0
  132. package/dist/file-explorer/FilePreview/index.js +266 -0
  133. package/dist/file-explorer/FilePreview/parse.js +63 -0
  134. package/dist/file-explorer/FilePreview/previewCache.js +98 -0
  135. package/dist/file-explorer/FilePreview/previewType.js +151 -0
  136. package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
  137. package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
  138. package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
  139. package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
  140. package/dist/file-explorer/FileRow.js +165 -0
  141. package/dist/file-explorer/FileRowsWindow.js +92 -0
  142. package/dist/file-explorer/FileTable.js +172 -0
  143. package/dist/file-explorer/FileTableHeaders.js +49 -0
  144. package/dist/file-explorer/LoadMoreRow.js +46 -0
  145. package/dist/file-explorer/TreeView.js +376 -0
  146. package/dist/file-explorer/helpers.js +537 -0
  147. package/dist/file-explorer/index.js +7 -5671
  148. package/dist/file-explorer/lib/batch.js +39 -0
  149. package/dist/file-explorer/lib/errors.js +9 -0
  150. package/dist/file-explorer/lib/paging.js +124 -0
  151. package/dist/file-explorer/lib/utils.js +322 -0
  152. package/dist/file-explorer/toasts.js +400 -0
  153. package/dist/file-explorer/treeRows.js +73 -0
  154. package/dist/file-explorer/useNearEnd.js +27 -0
  155. package/dist/form/FieldWrapper.js +54 -0
  156. package/dist/form/Fields/BooleanField.js +51 -0
  157. package/dist/form/Fields/CheckboxGroupField.js +72 -0
  158. package/dist/form/Fields/ColorField.js +33 -0
  159. package/dist/form/Fields/DropdownField.js +49 -0
  160. package/dist/form/Fields/DurationField.js +130 -0
  161. package/dist/form/Fields/LabelField.js +19 -0
  162. package/dist/form/Fields/MultiDropdownField.js +40 -0
  163. package/dist/form/Fields/NumberField.js +51 -0
  164. package/dist/form/Fields/ObjectField.js +54 -0
  165. package/dist/form/Fields/RadioField.js +49 -0
  166. package/dist/form/Fields/RangeField.js +58 -0
  167. package/dist/form/Fields/ResourceOptionIcon.js +21 -0
  168. package/dist/form/Fields/StepField.js +6 -0
  169. package/dist/form/Fields/StringField.js +37 -0
  170. package/dist/form/Fields/TextAreaField.js +31 -0
  171. package/dist/form/Fields/durationValidity.js +11 -0
  172. package/dist/form/Form.js +643 -0
  173. package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
  174. package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
  175. package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
  176. package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
  177. package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
  178. package/dist/form/Wizard/WizardContainer.js +138 -0
  179. package/dist/form/Wizard/WizardNavigation.js +92 -0
  180. package/dist/form/Wizard/WizardStepContent.js +35 -0
  181. package/dist/form/Wizard/WizardStepIndicator.js +108 -0
  182. package/dist/form/Wizard/useWizardState.js +118 -0
  183. package/dist/form/Wizard/utils.js +34 -0
  184. package/dist/form/fieldContext.js +26 -0
  185. package/dist/form/fieldRegistry.js +50 -0
  186. package/dist/form/index.js +17 -2321
  187. package/dist/{chunks/FieldWrapper-Cszwg-4B.js → form/lib.js} +2 -97
  188. package/dist/form/useParsedOpts.js +62 -0
  189. package/dist/form/usePrevious.js +11 -0
  190. package/dist/form/utils/checkShowIfObject.js +14 -0
  191. package/dist/form/utils/duration.js +69 -0
  192. package/dist/form/utils/getParentValue.js +23 -0
  193. package/dist/form/utils/getPlaceholder.js +9 -0
  194. package/dist/form/utils/getValueUsingPath.js +23 -0
  195. package/dist/form/utils/secondaryField.js +22 -0
  196. package/dist/graph/AnnotationBanner.js +141 -0
  197. package/dist/graph/Collapse.js +41 -0
  198. package/dist/graph/DependencyGraph.js +1398 -0
  199. package/dist/graph/JobSummary.js +104 -0
  200. package/dist/graph/MatrixGroup.js +107 -0
  201. package/dist/graph/Reveal.js +57 -0
  202. package/dist/graph/TreeView.js +711 -0
  203. package/dist/graph/index.js +1 -2519
  204. package/dist/graph/types.js +6 -0
  205. package/dist/icons.d.ts +4 -4
  206. package/dist/icons.js +5 -5
  207. package/dist/index.js +46 -599
  208. package/dist/list/ActionToolbar.js +184 -0
  209. package/dist/list/HoverCard.js +73 -0
  210. package/dist/list/ListPage.js +145 -0
  211. package/dist/list/ListPager.js +59 -0
  212. package/dist/list/ListTable.js +163 -0
  213. package/dist/list/ListViewControls.js +372 -0
  214. package/dist/list/RowContextMenu.js +351 -0
  215. package/dist/list/UserHoverCard.js +117 -0
  216. package/dist/list/index.js +11 -2
  217. package/dist/list/listSearch.js +137 -0
  218. package/dist/list/listView.js +210 -0
  219. package/dist/list/textEntry.js +10 -0
  220. package/dist/{chunks/logviewer-BTKuQWzw.js → logviewer/LogViewer.js} +4 -82
  221. package/dist/logviewer/index.js +2 -1
  222. package/dist/logviewer/segments.js +80 -0
  223. package/dist/safeUrl.d.ts +6 -0
  224. package/dist/safeUrl.js +22 -0
  225. package/package.json +7 -9
  226. package/dist/assets/editor.worker-BmHUIVG4.js +0 -14807
  227. package/dist/assets/json.worker-D8bJ92nw.js +0 -22207
  228. package/dist/assets/yaml.worker-C4gyGAko.js +0 -50201
  229. package/dist/chunks/PageHeader-0kG_iypP.js +0 -692
  230. package/dist/chunks/SwitchToggle-DShNdcao.js +0 -758
  231. package/dist/chunks/editor-Dk1rbV75.js +0 -361
  232. package/dist/chunks/list-CJm875m7.js +0 -1418
  233. /package/dist/{chunks/MarkdownImpl-CyeTVvSt.js → components/MarkdownImpl.js} +0 -0
@@ -1,2322 +1,18 @@
1
- import { d as useWorkflowEngine, l as useSlots, u as useStrings } from "../chunks/Provider-CDYurraE.js";
2
- import { AngleRightIcon, EyeIcon, EyeOffIcon, TrashIcon } from "../icons.js";
3
- import { r as TooltipInfo } from "../chunks/Tooltip-K5HJr4_p.js";
4
- import { a as Dropdown, c as UncontrolledCollapsiblePanel, i as CustomListbox, n as SectionHeader, o as ControlledCollapsiblePanel, r as MultiSelectDropdown, t as SwitchToggle } from "../chunks/SwitchToggle-DShNdcao.js";
5
- import { c as isCategory, n as StatusDot } from "../chunks/StatusBadge-C1Blx_cW.js";
6
- import { t as Loader } from "../chunks/Loader-BXoXTZGc.js";
7
- import { n as Table } from "../chunks/Table-DU2MW8xz.js";
8
- import { a as initializeValues, c as findSecondaryOption, d as useFieldLabelledByProps, f as useFieldRequired, i as impureSetValueFromPath, l as FieldProvider, n as enforceOneMustBeTrue, o as resolvedFlag, r as flattenGroups, s as applySecondaryField, t as FieldWrapper, u as useFieldControlProps } from "../chunks/FieldWrapper-Cszwg-4B.js";
9
- import cx from "classnames";
10
- import React, { Suspense, createContext, memo, useCallback, useContext, useEffect, useEffectEvent, useId, useMemo, useRef, useState } from "react";
11
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
- import deepEqual from "fast-deep-equal";
13
- import { Duration } from "luxon";
14
- import { Field, Form, Formik, useField, useFormikContext } from "formik";
15
- import { NumericFormat } from "react-number-format";
16
- //#region src/form/Fields/durationValidity.ts
17
- var invalidPaths = /* @__PURE__ */ new Set();
18
- function setDurationValidity(path, valid) {
19
- if (valid) invalidPaths.delete(path);
20
- else invalidPaths.add(path);
21
- }
22
- function getInvalidDurationPaths() {
23
- return [...invalidPaths];
24
- }
25
- //#endregion
26
- //#region src/form/SpecialTypes/FormikCustomDropdown.tsx
27
- function toComparableOptions(options) {
28
- return options?.map((option) => {
29
- if (typeof option === "string") return option;
30
- if (isCategory(option)) return {
31
- category: option.category,
32
- options: option.options.map((o) => {
33
- const base = {
34
- label: o.label,
35
- value: o.value,
36
- disabled: o.disabled
37
- };
38
- return o.description !== void 0 ? {
39
- ...base,
40
- description: o.description
41
- } : base;
42
- })
43
- };
44
- const base = {
45
- label: option.label,
46
- value: option.value,
47
- disabled: option.disabled
48
- };
49
- return option.description !== void 0 ? {
50
- ...base,
51
- description: option.description
52
- } : base;
53
- });
54
- }
55
- function arePropsEqual(prev, next) {
56
- for (const key of Object.keys(next)) if (key === "options") {
57
- if (!deepEqual(toComparableOptions(prev.options), toComparableOptions(next.options))) return false;
58
- } else if (prev[key] !== next[key]) return false;
59
- return true;
60
- }
61
- var FormikCustomDropdown_default = memo(function FormikCustomDropdown({ name, ariaLabel, options, setFormDirty, onChange, parentValue, className, secondaryField, disabled = false, loading = false, invalid = false, autoselect, value, allowCustomValue = false, customValueLabel, placeholder, currentValue, setFieldValue, setFieldTouched }) {
62
- const required = useFieldRequired();
63
- const controlProps = useFieldControlProps();
64
- const prevParentRef = useRef(parentValue);
65
- const handleChange = (val) => {
66
- if (secondaryField && typeof options[0] !== "string") {
67
- const option = findSecondaryOption(options, val);
68
- if (option) applySecondaryField(secondaryField, option.secondaryValue, setFieldValue);
69
- }
70
- if (onChange) onChange(val);
71
- setFieldValue(name, val);
72
- setFieldTouched(name, true);
73
- setFormDirty(true);
74
- };
75
- useEffect(() => {
76
- prevParentRef.current = parentValue;
77
- });
78
- const prevOptions = useRef(null);
79
- const syncAutoselect = useEffectEvent((options, autoselect) => {
80
- if (deepEqual(prevOptions.current, toComparableOptions(options))) return;
81
- if (prevOptions.current === null && currentValue !== void 0 && currentValue !== null) {
82
- prevOptions.current = toComparableOptions(options);
83
- return;
84
- }
85
- prevOptions.current = toComparableOptions(options);
86
- if (autoselect === false || !options?.length) return;
87
- if (autoselect === void 0) {
88
- if (options.length && isCategory(options[0])) {
89
- let optionCount = 0;
90
- for (const category of options) {
91
- if (isCategory(category)) optionCount += category.options.length;
92
- if (optionCount > 1) return;
93
- }
94
- } else if (options.length !== 1) return;
95
- }
96
- if (!options?.find((option) => {
97
- if (typeof option === "string") return option === currentValue;
98
- else if (isCategory(option)) return option.options.some((subOption) => {
99
- return subOption.value === currentValue;
100
- });
101
- return option.value === currentValue;
102
- }) || autoselect) {
103
- let val;
104
- for (const option of options) if (typeof option === "string") {
105
- val = option;
106
- break;
107
- } else if (isCategory(option)) {
108
- const enabled = option.options.find((o) => !o.disabled);
109
- if (enabled) {
110
- val = enabled.value;
111
- break;
112
- }
113
- } else if (!option.disabled) {
114
- val = option.value;
115
- break;
116
- }
117
- if (val !== void 0) handleChange(val);
118
- }
119
- });
120
- useEffect(() => {
121
- syncAutoselect(options, autoselect);
122
- }, [options, autoselect]);
123
- return /* @__PURE__ */ jsx(Dropdown, {
124
- ...controlProps,
125
- textBoxClassName: cx(className, invalid && "invalid"),
126
- ariaLabel,
127
- required,
128
- onChange: (val) => handleChange(val),
129
- value: options?.length === 0 && !allowCustomValue ? value : currentValue,
130
- options,
131
- placeholder,
132
- disabled,
133
- loading,
134
- allowCustomValue,
135
- customValueLabel
136
- });
137
- }, arePropsEqual);
138
- //#endregion
139
- //#region src/form/SpecialTypes/FormikCustomInput.tsx
140
- var DEBOUNCE_MS$2 = 500;
141
- function FormikCustomInput({ name, type, step, placeholder, onChange, disabled, min, max, sanitize, invalid = false, lowercase = false, minLength, maxLength, defaultValue = "", value }) {
142
- const [field] = useField(name);
143
- const required = useFieldRequired();
144
- const controlProps = useFieldControlProps();
145
- const { setFieldValue, setFieldTouched } = useFormikContext();
146
- const [showPassword, setShowPassword] = useState(false);
147
- const isPassword = type === "password";
148
- const [localValue, setLocalValue] = useState(value ?? field.value);
149
- const isFocused = useRef(false);
150
- const debounceRef = useRef(null);
151
- useEffect(() => {
152
- if (!isFocused.current) setLocalValue(value ?? field.value);
153
- }, [field.value, value]);
154
- const sanitizeName = useCallback((val) => {
155
- if (sanitize === void 0) return lowercase ? val.toLowerCase() : val;
156
- try {
157
- const regexp = new RegExp(sanitize);
158
- if (lowercase) val = val.toLowerCase();
159
- return val.replace(regexp, "");
160
- } catch {
161
- console.error("Invalid regex for sanitization:", sanitize);
162
- }
163
- return val;
164
- }, [sanitize, lowercase]);
165
- const flushToFormik = useCallback((val) => {
166
- if (onChange) onChange(val);
167
- setFieldTouched(name, true);
168
- setFieldValue(name, val);
169
- }, [
170
- name,
171
- onChange,
172
- setFieldTouched,
173
- setFieldValue
174
- ]);
175
- const handleChange = (e) => {
176
- const text = sanitize ? sanitizeName(e.target.value) : e.target.value;
177
- let val = text;
178
- if (type === "number") {
179
- const parsed = parseFloat(text);
180
- val = isNaN(parsed) ? void 0 : parsed;
181
- }
182
- if (type === "password" && val === "") val = defaultValue;
183
- setLocalValue(val);
184
- clearTimeout(debounceRef.current ?? void 0);
185
- debounceRef.current = setTimeout(() => flushToFormik(val), DEBOUNCE_MS$2);
186
- };
187
- const handleFocus = () => {
188
- isFocused.current = true;
189
- };
190
- const handleBlur = () => {
191
- isFocused.current = false;
192
- clearTimeout(debounceRef.current ?? void 0);
193
- const current = localValue;
194
- if (current === void 0 || current === null) return;
195
- const text = current.toString();
196
- let val = text;
197
- if (type === "number") {
198
- const parsed = parseFloat(text);
199
- if (Number.isNaN(parsed)) val = void 0;
200
- else if (min !== void 0 && parsed < min) val = min;
201
- else if (max !== void 0 && parsed > max) val = max;
202
- else val = parsed;
203
- }
204
- setLocalValue(val);
205
- flushToFormik(val);
206
- };
207
- const displayValue = isPassword && localValue === defaultValue ? "" : localValue ?? "";
208
- const resolvedType = isPassword ? showPassword ? "text" : "password" : type === "string" ? "text" : type;
209
- const input = /* @__PURE__ */ jsx("input", {
210
- ...controlProps,
211
- "data-1p-ignore": true,
212
- className: cx("w-full", disabled && "disabled", invalid && "invalid", isPassword && "pr-8"),
213
- name,
214
- value: displayValue,
215
- type: resolvedType,
216
- "aria-required": required || void 0,
217
- disabled,
218
- placeholder,
219
- minLength,
220
- maxLength,
221
- onChange: handleChange,
222
- onFocus: handleFocus,
223
- onBlur: handleBlur,
224
- min,
225
- max,
226
- step
227
- });
228
- if (!isPassword) return input;
229
- return /* @__PURE__ */ jsxs("div", {
230
- className: "relative w-full",
231
- children: [input, /* @__PURE__ */ jsx("button", {
232
- type: "button",
233
- className: "absolute right-2 top-1/2 -translate-y-1/2 theme-muted-text",
234
- onClick: () => setShowPassword((prev) => !prev),
235
- disabled,
236
- tabIndex: -1,
237
- "aria-label": showPassword ? "Hide value" : "Show value",
238
- children: showPassword ? /* @__PURE__ */ jsx(EyeOffIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeIcon, { className: "h-4 w-4" })
239
- })]
240
- });
241
- }
242
- //#endregion
243
- //#region src/form/SpecialTypes/FormikNumericInput.tsx
244
- var DEBOUNCE_MS$1 = 500;
245
- function FormikNumericInput({ name, placeholder, onChange, disabled, min, max, invalid = false }) {
246
- const [field] = useField(name);
247
- const required = useFieldRequired();
248
- const controlProps = useFieldControlProps();
249
- const { setFieldValue, setFieldTouched } = useFormikContext();
250
- const [localValue, setLocalValue] = useState(field.value);
251
- const isFocused = useRef(false);
252
- const debounceRef = useRef(null);
253
- useEffect(() => {
254
- if (!isFocused.current) setLocalValue(field.value);
255
- }, [field.value]);
256
- const flush = (val) => {
257
- onChange?.(val);
258
- setFieldTouched(name, true);
259
- setFieldValue(name, val);
260
- };
261
- const handleBlur = () => {
262
- isFocused.current = false;
263
- clearTimeout(debounceRef.current ?? void 0);
264
- let val = localValue;
265
- if (val !== void 0) {
266
- if (min !== void 0 && val < min) val = min;
267
- if (max !== void 0 && val > max) val = max;
268
- }
269
- setLocalValue(val);
270
- flush(val);
271
- };
272
- return /* @__PURE__ */ jsx(NumericFormat, {
273
- ...controlProps,
274
- "data-1p-ignore": true,
275
- className: cx("w-full", disabled && "disabled", invalid && "invalid"),
276
- name,
277
- ...localValue === void 0 ? {} : { value: localValue },
278
- "aria-required": required || void 0,
279
- thousandSeparator: ",",
280
- decimalScale: 20,
281
- allowNegative: true,
282
- disabled,
283
- placeholder,
284
- onValueChange: (v) => {
285
- setLocalValue(v.floatValue);
286
- clearTimeout(debounceRef.current ?? void 0);
287
- debounceRef.current = setTimeout(() => flush(v.floatValue), DEBOUNCE_MS$1);
288
- },
289
- onFocus: () => {
290
- isFocused.current = true;
291
- },
292
- onBlur: handleBlur
293
- });
294
- }
295
- //#endregion
296
- //#region src/form/utils/getPlaceholder.ts
297
- /** `placeholder=""` (empty string) intentionally overrides the default; undefined does not. */
298
- function getPlaceholder(placeholder, defaultValue) {
299
- if (placeholder !== void 0) return placeholder;
300
- if (defaultValue && (typeof defaultValue === "string" || typeof defaultValue === "number")) return defaultValue.toString();
301
- return "";
302
- }
303
- //#endregion
304
- //#region src/form/Fields/NumberField.tsx
305
- function NumberField(props) {
306
- const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact } = props;
307
- const [fieldState] = useField(field.name);
308
- const { setFieldValue } = useFormikContext();
309
- useEffect(() => {
310
- if (field.prefillDefault && field.default !== void 0 && (fieldState.value === void 0 || fieldState.value === null || fieldState.value === "")) setFieldValue(field.name, field.default);
311
- }, [
312
- field.prefillDefault,
313
- field.default,
314
- field.name,
315
- fieldState.value,
316
- setFieldValue
317
- ]);
318
- return /* @__PURE__ */ jsx(FieldWrapper, {
319
- optional: field.optional,
320
- label,
321
- tooltipComponent,
322
- labelPosition,
323
- spaceCompact,
324
- children: field.thousandsSeparator ? /* @__PURE__ */ jsx(FormikNumericInput, {
325
- invalid: missing,
326
- name: field.name,
327
- placeholder: getPlaceholder(field.placeholder, field.default),
328
- disabled,
329
- min: field.min,
330
- max: field.max,
331
- ...onChange && { onChange }
332
- }, field.name) : /* @__PURE__ */ jsx(FormikCustomInput, {
333
- invalid: missing,
334
- name: field.name,
335
- type: "number",
336
- placeholder: getPlaceholder(field.placeholder, field.default),
337
- disabled,
338
- step: field.step,
339
- min: field.min,
340
- max: field.max,
341
- defaultValue: field.default,
342
- ...onChange && { onChange }
343
- }, field.name)
344
- });
345
- }
346
- //#endregion
347
- //#region src/form/Fields/ResourceOptionIcon.tsx
348
- function ResourceOptionIcon({ imageUrl, fallbackIcon, alt, variant = "success", dotSize = 6 }) {
349
- return /* @__PURE__ */ jsxs("span", {
350
- className: "flex items-center gap-1.5 shrink-0",
351
- children: [/* @__PURE__ */ jsx(StatusDot, {
352
- variant,
353
- size: dotSize
354
- }), /* @__PURE__ */ jsx("img", {
355
- src: imageUrl || fallbackIcon,
356
- alt,
357
- className: "h-4 w-4 object-contain",
358
- onError: (e) => {
359
- e.currentTarget.src = fallbackIcon;
360
- }
361
- })]
362
- });
363
- }
364
- //#endregion
365
- //#region src/form/Fields/BooleanField.tsx
366
- function BooleanField(props) {
367
- const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
368
- const [fieldState] = useField(field.name);
369
- const { setFieldValue, setFieldTouched } = useFormikContext();
370
- const handleChange = (val) => {
371
- if (disabled) return;
372
- if (onChange) onChange(val);
373
- setFieldTouched(field.name, true);
374
- setFieldValue(field.name, val);
375
- setFormDirty(true);
376
- };
377
- const value = fieldState.value;
378
- const options = field.options ? {
379
- onOption: String(field.options.onOption ?? true),
380
- offOption: String(field.options.offOption ?? false)
381
- } : void 0;
382
- const displayLabel = (option) => option.charAt(0).toUpperCase() + option.slice(1).toLowerCase();
383
- return /* @__PURE__ */ jsx(FieldWrapper, {
384
- optional: true,
385
- label,
386
- tooltipComponent: /* @__PURE__ */ jsx("div", { children: tooltipComponent }),
387
- description: field.description,
388
- labelPosition,
389
- spaceCompact,
390
- children: ({ id, describedBy }) => options ? /* @__PURE__ */ jsx(SwitchToggle, {
391
- id,
392
- "aria-describedby": describedBy,
393
- onChange: (on) => handleChange(on ? options.onOption : options.offOption),
394
- value: value === true || value === options.onOption,
395
- yesLabel: displayLabel(options.onOption),
396
- noLabel: displayLabel(options.offOption),
397
- disabled,
398
- invalid: missing
399
- }) : /* @__PURE__ */ jsx(SwitchToggle, {
400
- id,
401
- "aria-describedby": describedBy,
402
- datatip: field.disabled_message,
403
- onChange: handleChange,
404
- value: value === true || value === "true",
405
- disabled,
406
- invalid: missing
407
- })
408
- });
409
- }
410
- //#endregion
411
- //#region src/form/Fields/CheckboxGroupField.tsx
412
- function impliedFrom(values, implies = {}) {
413
- const result = /* @__PURE__ */ new Set();
414
- for (const value of values) for (const target of implies[value] ?? []) result.add(target);
415
- return result;
416
- }
417
- function union(manual, forced) {
418
- return [...manual, ...[...forced].filter((v) => !manual.includes(v))];
419
- }
420
- function CheckboxGroupField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty }) {
421
- const [fieldState] = useField(field.name);
422
- const { setFieldValue, setFieldTouched } = useFormikContext();
423
- const implies = field.implies;
424
- const [manual, setManual] = useState(() => {
425
- const saved = fieldState.value || [];
426
- const impliedBySaved = impliedFrom(saved, implies);
427
- return saved.filter((v) => !impliedBySaved.has(v));
428
- });
429
- const forced = impliedFrom(manual, implies);
430
- const handleToggle = (value) => {
431
- if (disabled) return;
432
- const nextManual = manual.includes(value) ? manual.filter((v) => v !== value) : [...manual, value];
433
- const next = union(nextManual, impliedFrom(nextManual, implies));
434
- setManual(nextManual);
435
- setFieldTouched(field.name, true);
436
- setFieldValue(field.name, next);
437
- if (onChange) onChange(next);
438
- setFormDirty(true);
439
- };
440
- return /* @__PURE__ */ jsx(FieldWrapper, {
441
- optional: field.optional,
442
- label,
443
- tooltipComponent,
444
- labelPosition,
445
- spaceCompact,
446
- children: ({ labelId, describedBy }) => /* @__PURE__ */ jsx("fieldset", {
447
- "aria-labelledby": labelId,
448
- "aria-describedby": describedBy,
449
- className: "flex min-w-0 max-w-lg flex-col gap-1",
450
- children: field.options?.map((option) => {
451
- const locked = forced.has(option.value);
452
- const optionDisabled = disabled || locked;
453
- return /* @__PURE__ */ jsxs("label", {
454
- className: cx("-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)"),
455
- children: [/* @__PURE__ */ jsx("input", {
456
- type: "checkbox",
457
- checked: manual.includes(option.value) || locked,
458
- disabled: optionDisabled,
459
- onChange: () => handleToggle(option.value),
460
- className: cx("mt-px h-4 w-4 rounded accent-(--theme-link)", optionDisabled ? "cursor-not-allowed" : "cursor-pointer", missing && "invalid")
461
- }), /* @__PURE__ */ jsxs("div", {
462
- className: "flex min-w-0 flex-col",
463
- children: [/* @__PURE__ */ jsx("span", {
464
- className: "font-medium leading-tight theme-text",
465
- children: option.label
466
- }), option.description && /* @__PURE__ */ jsx("span", {
467
- className: "mt-0.5 text-xs leading-snug theme-muted-text",
468
- children: option.description
469
- })]
470
- })]
471
- }, field.name + option.value);
472
- })
473
- })
474
- });
475
- }
476
- //#endregion
477
- //#region src/form/Fields/ColorField.tsx
478
- function ColorField(props) {
479
- const { field, label, labelPosition, onChange, tooltipComponent, spaceCompact } = props;
480
- const [fieldState] = useField(field.name);
481
- const { setFieldValue, setFieldTouched } = useFormikContext();
482
- const handleChange = (e) => {
483
- const val = e.target.value;
484
- if (onChange) onChange(val);
485
- setFieldTouched(field.name, true);
486
- setFieldValue(field.name, val);
487
- };
488
- return /* @__PURE__ */ jsx(FieldWrapper, {
489
- optional: field.optional,
490
- label,
491
- tooltipComponent,
492
- labelPosition,
493
- spaceCompact,
494
- children: ({ id }) => /* @__PURE__ */ jsx(Field, {
495
- className: "theme-input h-8 w-18 rounded border border-neutral-400 placeholder:text-xs",
496
- id,
497
- name: field.name,
498
- value: fieldState.value || "#fbbf24",
499
- type: "color",
500
- "aria-required": field.optional ? void 0 : true,
501
- onChange: handleChange
502
- })
503
- });
504
- }
505
- //#endregion
506
- //#region src/form/Fields/DropdownField.tsx
507
- function DropdownField(props) {
508
- const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFieldValue, setFieldTouched, currentValue } = props;
509
- let parentValue = field.parentValue;
510
- let options = Array.isArray(field.options) && field.options || [];
511
- if (field.depends_on) {
512
- parentValue = field.depends_on;
513
- if (!Array.isArray(field.options)) options = field.options[parentValue] ?? [];
514
- }
515
- const secondaryField = Array.isArray(field.secondaryField) ? field.secondaryField[0] : field.secondaryField;
516
- return /* @__PURE__ */ jsx(FieldWrapper, {
517
- optional: field.optional,
518
- label,
519
- tooltipComponent,
520
- description: field.description,
521
- labelPosition,
522
- spaceCompact,
523
- children: /* @__PURE__ */ jsx("div", {
524
- className: "grow min-w-0",
525
- children: /* @__PURE__ */ jsx(FormikCustomDropdown_default, {
526
- invalid: missing,
527
- className: "w-full",
528
- name: field.name,
529
- ariaLabel: label,
530
- options,
531
- setFormDirty: props.setFormDirty,
532
- parentValue,
533
- onChange,
534
- secondaryField,
535
- disabled,
536
- resetOnChange: field.resetOnChange ? field.name : "",
537
- loading: false,
538
- autoselect: field.autoselect,
539
- allowCustomValue: field.allowCustomValue,
540
- customValueLabel: field.customValueLabel,
541
- placeholder: getPlaceholder(field.placeholder, typeof field.default === "string" ? field.default : void 0),
542
- currentValue,
543
- setFieldValue,
544
- setFieldTouched
545
- }, field.name)
546
- })
547
- });
548
- }
549
- //#endregion
550
- //#region src/form/utils/duration.ts
551
- var WITH_DAYS = /^(\d+)-(\d{1,2})(?::(\d{1,2})(?::(\d{1,2}))?)?$/;
552
- var WITHOUT_DAYS = /^(\d+):(\d{1,2}):(\d{1,2})$/;
553
- function parseDuration(text) {
554
- const trimmed = text.trim();
555
- let days = 0;
556
- let hours;
557
- let minutes;
558
- let seconds;
559
- const withDays = trimmed.match(WITH_DAYS);
560
- if (withDays) {
561
- days = Number(withDays[1]);
562
- hours = Number(withDays[2]);
563
- minutes = Number(withDays[3] ?? 0);
564
- seconds = Number(withDays[4] ?? 0);
565
- if (hours > 23) return null;
566
- } else {
567
- const withoutDays = trimmed.match(WITHOUT_DAYS);
568
- if (!withoutDays) return null;
569
- hours = Number(withoutDays[1]);
570
- minutes = Number(withoutDays[2]);
571
- seconds = Number(withoutDays[3]);
572
- }
573
- if (minutes > 59 || seconds > 59) return null;
574
- return days * 86400 + hours * 3600 + minutes * 60 + seconds;
575
- }
576
- function formatDuration(totalSeconds) {
577
- if (!Number.isFinite(totalSeconds) || totalSeconds < 0) return "";
578
- const parts = Duration.fromObject({ seconds: Math.floor(totalSeconds) }).shiftTo("days", "hours", "minutes", "seconds");
579
- const pad = (n) => String(n).padStart(2, "0");
580
- const time = `${pad(parts.hours)}:${pad(parts.minutes)}:${pad(parts.seconds)}`;
581
- return parts.days > 0 ? `${parts.days}-${time}` : time;
582
- }
583
- var FLEX_MAX_DURATION_RANGE = {
584
- min: 600,
585
- max: 604800
586
- };
587
- var FLEX_WAIT_TIME_RANGE = {
588
- min: 30,
589
- max: 604800
590
- };
591
- var STANDARD_MAX_DURATION_RANGE = {
592
- min: 30,
593
- max: 10368e3
594
- };
595
- var DURATION_PATH = /^partitions\[\d+\]\.(maxDuration|flexStartWaitTime|suspendTime)$/;
596
- function collectPartitionDurationIssues(partitions, invalidDurationPaths) {
597
- const issues = new Set(invalidDurationPaths.filter((path) => DURATION_PATH.test(path)));
598
- (partitions ?? []).forEach((partition, i) => {
599
- const p = partition;
600
- const check = (fieldName, range, required) => {
601
- const raw = p?.[fieldName];
602
- if (raw === void 0 || raw === null || raw === "") {
603
- if (required) issues.add(`partitions[${i}].${fieldName}`);
604
- return;
605
- }
606
- const value = Number(raw);
607
- if (!Number.isFinite(value) || value < range.min || value > range.max) issues.add(`partitions[${i}].${fieldName}`);
608
- };
609
- if (p?.provisioningMode === "flex") {
610
- check("maxDuration", FLEX_MAX_DURATION_RANGE, true);
611
- check("flexStartWaitTime", FLEX_WAIT_TIME_RANGE, true);
612
- } else check("maxDuration", STANDARD_MAX_DURATION_RANGE, false);
613
- });
614
- return [...issues];
615
- }
616
- //#endregion
617
- //#region src/form/Fields/DurationField.tsx
618
- var DEBOUNCE_MS = 500;
619
- var isNumericString = (value) => typeof value === "string" && /^\d+$/.test(value.trim());
620
- var toDisplay = (value) => {
621
- if (typeof value === "number") return formatDuration(value);
622
- if (isNumericString(value)) return formatDuration(Number(value));
623
- return "";
624
- };
625
- var DurationField_default = memo(function DurationField({ field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty, currentValue, setFieldValue, setFieldTouched }) {
626
- const { form: t } = useStrings();
627
- const name = field.name;
628
- const min = field.min !== void 0 ? Number(field.min) : Number.NEGATIVE_INFINITY;
629
- const max = field.max !== void 0 ? Number(field.max) : Number.POSITIVE_INFINITY;
630
- const disableValue = field.disableValue;
631
- const hasDisableCheckbox = disableValue !== void 0 && field.disableLabel !== void 0;
632
- const isSentinel = hasDisableCheckbox && currentValue !== "" && Number(currentValue) === disableValue;
633
- const [text, setText] = useState(() => toDisplay(currentValue));
634
- const focusedRef = useRef(false);
635
- const debounceRef = useRef(null);
636
- useEffect(() => {
637
- if (isSentinel) {
638
- if (typeof currentValue !== "number") setFieldValue?.(name, disableValue);
639
- } else if (isNumericString(currentValue)) setFieldValue?.(name, Number(currentValue));
640
- else if ((currentValue === void 0 || currentValue === null || currentValue === "") && typeof field.default === "number") setFieldValue?.(name, field.default);
641
- }, []);
642
- useEffect(() => {
643
- if (!focusedRef.current) setText(toDisplay(currentValue));
644
- }, [currentValue]);
645
- const trimmed = text.trim();
646
- const parsed = trimmed === "" ? null : parseDuration(trimmed);
647
- let error = null;
648
- if (!isSentinel && trimmed !== "") {
649
- if (parsed === null) error = t.invalidDuration;
650
- else if (parsed < min || parsed > max) error = Number.isFinite(max) ? t.durationOutOfRange(formatDuration(Math.max(min, 0)), formatDuration(max)) : t.durationBelowMin(formatDuration(Math.max(min, 0)));
651
- }
652
- useEffect(() => {
653
- setDurationValidity(name, error === null);
654
- }, [name, error]);
655
- useEffect(() => () => {
656
- setDurationValidity(name, true);
657
- clearTimeout(debounceRef.current ?? void 0);
658
- }, [name]);
659
- const flushToFormik = (val) => {
660
- setFieldValue?.(name, val);
661
- onChange?.(val);
662
- setFieldTouched?.(name, true);
663
- };
664
- const handleDisableToggle = (checked) => {
665
- clearTimeout(debounceRef.current ?? void 0);
666
- setFormDirty(true);
667
- if (checked) {
668
- setText("");
669
- flushToFormik(disableValue);
670
- } else flushToFormik(typeof field.default === "number" ? field.default : "");
671
- };
672
- const handleChange = (e) => {
673
- const raw = e.target.value;
674
- setText(raw);
675
- setFormDirty(true);
676
- clearTimeout(debounceRef.current ?? void 0);
677
- const rawTrimmed = raw.trim();
678
- const value = rawTrimmed === "" ? "" : parseDuration(rawTrimmed);
679
- if (value === "" || typeof value === "number" && value >= min && value <= max) debounceRef.current = setTimeout(() => flushToFormik(value), DEBOUNCE_MS);
680
- };
681
- const handleFocus = () => {
682
- focusedRef.current = true;
683
- };
684
- const handleBlur = () => {
685
- focusedRef.current = false;
686
- clearTimeout(debounceRef.current ?? void 0);
687
- if (trimmed === "") {
688
- setText("");
689
- flushToFormik("");
690
- } else if (parsed !== null && parsed >= min && parsed <= max) {
691
- setText(formatDuration(parsed));
692
- flushToFormik(parsed);
693
- }
694
- };
695
- return /* @__PURE__ */ jsx(FieldWrapper, {
696
- optional: field.optional ?? false,
697
- label,
698
- tooltipComponent,
699
- labelPosition,
700
- spaceCompact: spaceCompact ?? false,
701
- ...field.description !== void 0 && { description: field.description },
702
- children: ({ id, describedBy }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
703
- !isSentinel && /* @__PURE__ */ jsx("input", {
704
- "data-1p-ignore": true,
705
- className: cx("w-full", disabled && "disabled", (missing || error !== null) && "invalid"),
706
- id,
707
- "aria-describedby": describedBy,
708
- name,
709
- value: text,
710
- type: "text",
711
- "aria-required": field.optional ? void 0 : true,
712
- disabled,
713
- placeholder: field.placeholder ?? "DD-HH:MM:SS",
714
- onChange: handleChange,
715
- onFocus: handleFocus,
716
- onBlur: handleBlur
717
- }),
718
- error && /* @__PURE__ */ jsx("div", {
719
- className: "text-xs text-red-500 mt-1",
720
- children: error
721
- }),
722
- hasDisableCheckbox && /* @__PURE__ */ jsxs("label", {
723
- className: cx("flex items-center gap-2 mt-1", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"),
724
- children: [/* @__PURE__ */ jsx("input", {
725
- type: "checkbox",
726
- checked: isSentinel,
727
- disabled,
728
- onChange: (e) => handleDisableToggle(e.target.checked),
729
- className: cx("h-4 w-4 accent-(--theme-link)", disabled ? "cursor-not-allowed" : "cursor-pointer")
730
- }), /* @__PURE__ */ jsx("span", {
731
- className: "theme-text",
732
- children: field.disableLabel
733
- })]
734
- })
735
- ] })
736
- });
737
- });
738
- //#endregion
739
- //#region src/form/Fields/LabelField.tsx
740
- function LabelField(props) {
741
- const { field, label } = props;
742
- return /* @__PURE__ */ jsx("div", {
743
- className: "flex items-center w-full",
744
- children: /* @__PURE__ */ jsx("h3", {
745
- style: field.size ? {
746
- fontSize: field.size.toString() + "px",
747
- whiteSpace: "pre-wrap"
748
- } : { whiteSpace: "pre-wrap" },
749
- className: cx("relative", "text-md", field.bold !== false ? "font-bold" : ""),
750
- children: field.text && field.text.toString().replace(/(\r)/g, "").replace(/(\\n)/g, "\n") || label
751
- })
752
- });
753
- }
754
- //#endregion
755
- //#region src/form/Fields/MultiDropdownField.tsx
756
- function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spaceCompact, disabled, missing, setFormDirty, onChange }) {
757
- let parentValue = field.parentValue;
758
- let options = field.options;
759
- if (field.depends_on) {
760
- parentValue = field.depends_on;
761
- if (!Array.isArray(field.options)) options = field.options[parentValue] || [];
762
- }
763
- return /* @__PURE__ */ jsx(FieldWrapper, {
764
- optional: field.optional,
765
- label,
766
- tooltipComponent,
767
- labelPosition,
768
- spaceCompact,
769
- children: ({ id }) => disabled ? /* @__PURE__ */ jsx(Field, {
770
- className: "theme-input h-7 w-full rounded border placeholder:text-xs",
771
- id,
772
- type: "search",
773
- name: field.name,
774
- disabled: true,
775
- onChange
776
- }, field.name) : /* @__PURE__ */ jsx(MultiSelectionDropdown, {
777
- className: "themee-input h-7 w-full rounded border flex items-center px-3 py-2",
778
- name: field.name,
779
- label: field.label || label,
780
- options: Array.isArray(options) ? options : [],
781
- setFormDirty,
782
- parentValue,
783
- onChange,
784
- secondaryField: typeof field.secondaryField === "string" ? field.secondaryField : void 0,
785
- invalid: missing
786
- }, field.name)
787
- });
788
- }
789
- //#endregion
790
- //#region src/form/Fields/ObjectField.tsx
791
- function ObjectField({ field, label, tooltipComponent, missingFields, setFormDirty, workflowForm, labelPosition, spaceCompact }) {
792
- const [open, setOpen] = useState(field.collapsed !== void 0 ? !field.collapsed : true);
793
- const { values, setFieldValue, setFieldTouched } = useFormikContext();
794
- const meta = resolveMetaOverrides(field.options, labelPosition, spaceCompact ?? false);
795
- const HeaderElement = field.noCollapse ? React.Fragment : ControlledCollapsiblePanel;
796
- return /* @__PURE__ */ jsxs("div", {
797
- className: "flex flex-col w-full",
798
- children: [field.noCollapse && /* @__PURE__ */ jsx("div", {
799
- className: "flex items-center w-full mb-[15px]",
800
- children: /* @__PURE__ */ jsxs("h3", {
801
- className: "flex items-center gap-1 text-md font-bold",
802
- children: [
803
- label,
804
- " ",
805
- tooltipComponent
806
- ]
807
- })
808
- }), /* @__PURE__ */ jsx(HeaderElement, {
809
- open,
810
- setOpen,
811
- title: /* @__PURE__ */ jsx(GroupHeader, {
812
- open,
813
- setOpen,
814
- title: field.label || label
815
- }),
816
- children: /* @__PURE__ */ jsx("div", {
817
- className: "w-full",
818
- children: /* @__PURE__ */ jsx(FieldsFromOptions, {
819
- options: field.options,
820
- values,
821
- setFormDirty,
822
- setFieldValue,
823
- setFieldTouched,
824
- missingFields,
825
- workflowForm,
826
- labelPosition: meta.labelPosition,
827
- spaceCompact: meta.spaceCompact,
828
- parentInfo: {
829
- parentName: field.name,
830
- fieldNamePrefix: `${field.name}.`
831
- }
832
- })
833
- })
834
- })]
835
- });
836
- }
837
- //#endregion
838
- //#region src/form/Fields/RadioField.tsx
839
- function RadioField(props) {
840
- const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
841
- const uid = useId();
842
- const { setFieldValue, setFieldTouched } = useFormikContext();
843
- const handleChange = (val) => {
844
- if (disabled) return;
845
- if (onChange) onChange(val);
846
- setFieldTouched(field.name, true);
847
- setFieldValue(field.name, val);
848
- setFormDirty(true);
849
- };
850
- return /* @__PURE__ */ jsx(FieldWrapper, {
851
- optional: field.optional,
852
- label,
853
- tooltipComponent,
854
- labelPosition,
855
- spaceCompact,
856
- children: ({ labelId, describedBy }) => /* @__PURE__ */ jsx("div", {
857
- role: "radiogroup",
858
- "aria-labelledby": labelId,
859
- "aria-describedby": describedBy,
860
- "aria-required": field.optional ? void 0 : true,
861
- className: cx("flex", field.optionLabelPosition === "top" ? "flex-col" : "flex-row"),
862
- children: field.options?.map((option) => /* @__PURE__ */ jsxs("label", {
863
- htmlFor: `${uid}-${option}`,
864
- className: "capitalize",
865
- children: [/* @__PURE__ */ jsx(Field, {
866
- id: `${uid}-${option}`,
867
- className: cx("theme-input mr-1", disabled && "disabled", missing && "invalid"),
868
- name: field.name,
869
- type: "radio",
870
- value: option,
871
- disabled,
872
- onChange: (e) => {
873
- handleChange(e.target.value);
874
- }
875
- }), option]
876
- }, field.name + option))
877
- })
878
- });
879
- }
880
- //#endregion
881
- //#region src/form/Fields/RangeField.tsx
882
- function RangeField(props) {
883
- const { field, label, labelPosition, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
884
- const [fieldState] = useField(field.name);
885
- const { setFieldValue, setFieldTouched } = useFormikContext();
886
- const handleChange = (e) => {
887
- let val = e.target.valueAsNumber;
888
- if (!isNaN(val)) {
889
- val = Math.max(field.min, Math.min(field.max, val));
890
- setFieldValue(field.name, val);
891
- if (onChange) onChange(val);
892
- setFieldTouched(field.name, true);
893
- setFormDirty(true);
894
- }
895
- };
896
- const seedValue = field.default ?? field.min;
897
- if ((fieldState.value === void 0 || fieldState.value === null) && seedValue !== void 0) setFieldValue(field.name, seedValue);
898
- const currentValue = fieldState.value !== void 0 ? fieldState.value : seedValue;
899
- return /* @__PURE__ */ jsx(FieldWrapper, {
900
- optional: field.optional,
901
- label,
902
- tooltipComponent,
903
- labelPosition,
904
- spaceCompact,
905
- children: ({ id, labelId }) => /* @__PURE__ */ jsxs("div", {
906
- className: "flex items-center",
907
- children: [/* @__PURE__ */ jsx(Field, {
908
- className: cx("theme-input h-7 w-1/3 mr-5 text-center rounded border", disabled && "disabled"),
909
- id,
910
- type: "number",
911
- value: currentValue,
912
- min: field.min,
913
- max: field.max,
914
- step: field.step || 1,
915
- disabled,
916
- onChange: handleChange
917
- }), /* @__PURE__ */ jsx(Field, {
918
- className: cx("rounded w-full", disabled && "disabled"),
919
- name: field.name,
920
- value: currentValue,
921
- type: "range",
922
- "aria-labelledby": labelId,
923
- "aria-required": field.optional ? void 0 : true,
924
- min: field.min,
925
- max: field.max,
926
- step: field.step || 1,
927
- disabled,
928
- onChange: handleChange
929
- })]
930
- })
931
- });
932
- }
933
- //#endregion
934
- //#region src/form/Fields/StepField.tsx
935
- function StepField(_props) {
936
- return null;
937
- }
938
- //#endregion
939
- //#region src/form/Fields/StringField.tsx
940
- var StringField_default = memo(function StringField(props) {
941
- const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, currentValue } = props;
942
- const value = field.prefillDefault ? currentValue : void 0;
943
- return /* @__PURE__ */ jsx(FieldWrapper, {
944
- optional: field.optional,
945
- label,
946
- tooltipComponent,
947
- description: field.description,
948
- labelPosition,
949
- spaceCompact,
950
- children: /* @__PURE__ */ jsx(FormikCustomInput, {
951
- invalid: missing,
952
- name: field.name,
953
- type: field.type,
954
- lowercase: field.lowercase,
955
- placeholder: field.type === "password" && field.placeholder === void 0 ? "•".repeat((field.default ?? "").toString().length > 0 ? 16 : 0) : getPlaceholder(field.placeholder, field.default),
956
- disabled,
957
- step: field.step,
958
- min: field.min,
959
- max: field.max,
960
- minLength: field.minLength,
961
- maxLength: field.maxLength,
962
- sanitize: field.sanitize,
963
- defaultValue: field.default,
964
- value,
965
- ...onChange && { onChange }
966
- }, field.name)
967
- });
968
- });
969
- //#endregion
970
- //#region src/form/Fields/TextAreaField.tsx
971
- function TextAreaField(props) {
972
- const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact } = props;
973
- return /* @__PURE__ */ jsx(FieldWrapper, {
974
- optional: field.optional,
975
- label,
976
- tooltipComponent,
977
- description: field.description,
978
- labelPosition,
979
- spaceCompact,
980
- children: ({ id, describedBy }) => /* @__PURE__ */ jsx(Field, {
981
- className: cx("theme-input h-[82px] w-full rounded leading-4 overflow-y-scroll", disabled && "disabled", missing && "border-red-600 focus:border-red-600 focus:ring-red-500"),
982
- as: "textarea",
983
- id,
984
- "aria-describedby": describedBy,
985
- "aria-required": field.optional ? void 0 : true,
986
- name: field.name,
987
- type: "search",
988
- placeholder: getPlaceholder(field.placeholder, field.default),
989
- disabled,
990
- ...onChange && { onChange }
991
- }, field.name)
992
- });
993
- }
994
- //#endregion
995
- //#region src/form/fieldRegistry.tsx
996
- var CORE_FIELD_COMPONENTS = {
997
- string: StringField_default,
998
- password: StringField_default,
999
- number: NumberField,
1000
- boolean: BooleanField,
1001
- dropdown: DropdownField,
1002
- textarea: TextAreaField,
1003
- range: RangeField,
1004
- duration: DurationField_default,
1005
- radio: RadioField,
1006
- label: LabelField,
1007
- color: ColorField,
1008
- "multi-dropdown": MultiDropdownField,
1009
- "checkbox-group": CheckboxGroupField,
1010
- object: ObjectField,
1011
- step: StepField
1012
- };
1013
- var FieldRegistryContext = createContext({});
1014
- /** Returns null for field types no registry knows. Per-form `fields` win over
1015
- * the provider's `slots.formFields`, which win over the core registry. */
1016
- function Registry(props) {
1017
- const injected = useContext(FieldRegistryContext);
1018
- const { formFields } = useSlots();
1019
- const Component = injected[props.field.type] ?? formFields?.[props.field.type] ?? CORE_FIELD_COMPONENTS[props.field.type];
1020
- if (!Component) return null;
1021
- return /* @__PURE__ */ jsx(Suspense, {
1022
- fallback: null,
1023
- children: /* @__PURE__ */ jsx(Component, { ...props })
1024
- });
1025
- }
1026
- //#endregion
1027
- //#region src/form/useParsedOpts.ts
1028
- var EMPTY_VARS = {};
1029
- var EMPTY_KEYS = [];
1030
- /**
1031
- * useMemo won't work here — Formik values changes on every keystroke, so this hook extracts which inputs.* keys the schema references and re-parses only when those change. Defaults `userVars`/`secretKeys` to empty — callers in React scope should pass them from `useUserVars()` so the parser leaves `${{ var.SECRET }}` literal during template eval (otherwise the recursive substitution turns `"https://${{ var.PAT }}@host/"` into `"https://@host/"`).
1032
- */
1033
- function useParsedOpts(rawOptions, values, organizationVariables, userVars = EMPTY_VARS, secretKeys = EMPTY_KEYS, remoteVars = EMPTY_VARS) {
1034
- const engine = useWorkflowEngine();
1035
- const c = useRef({
1036
- rawOptions: null,
1037
- orgVars: void 0,
1038
- userVars: null,
1039
- secretKeys: null,
1040
- remoteVars: null,
1041
- converted: {},
1042
- inputDeps: /* @__PURE__ */ new Set(),
1043
- hasExpressions: false,
1044
- relevantSnapshot: {},
1045
- result: null
1046
- }).current;
1047
- if (rawOptions !== c.rawOptions) {
1048
- c.rawOptions = rawOptions;
1049
- c.converted = engine.convertInputs(rawOptions);
1050
- const { inputDeps, hasExpressions } = engine.inputDependencies(c.converted);
1051
- c.inputDeps = inputDeps;
1052
- c.hasExpressions = hasExpressions;
1053
- c.result = null;
1054
- }
1055
- if (organizationVariables !== c.orgVars || userVars !== c.userVars || secretKeys !== c.secretKeys || remoteVars !== c.remoteVars) {
1056
- c.orgVars = organizationVariables;
1057
- c.userVars = userVars;
1058
- c.secretKeys = secretKeys;
1059
- c.remoteVars = remoteVars;
1060
- c.result = null;
1061
- }
1062
- if (c.result !== null) {
1063
- if (c.inputDeps.size === 0) return c.result;
1064
- let inputsChanged = false;
1065
- for (const key of c.inputDeps) if (!deepEqual(values[key], c.relevantSnapshot[key])) {
1066
- inputsChanged = true;
1067
- break;
1068
- }
1069
- if (!inputsChanged) return c.result;
1070
- }
1071
- const parsed = engine.evaluate({
1072
- inputs: values,
1073
- obj: c.converted,
1074
- orgVars: organizationVariables,
1075
- userVars,
1076
- secretKeys,
1077
- remoteVars
1078
- });
1079
- c.result = parsed;
1080
- c.relevantSnapshot = {};
1081
- for (const key of c.inputDeps) c.relevantSnapshot[key] = values[key];
1082
- return parsed;
1083
- }
1084
- //#endregion
1085
- //#region src/form/usePrevious.ts
1086
- function usePrevious(value) {
1087
- const ref = useRef(void 0);
1088
- useEffect(() => {
1089
- ref.current = value;
1090
- });
1091
- return ref.current;
1092
- }
1093
- //#endregion
1094
- //#region src/form/utils/getValueUsingPath.ts
1095
- function getValueUsingPath(obj, path) {
1096
- if (typeof path !== "string" || !path) return;
1097
- const keys = path.split(".");
1098
- let current = obj;
1099
- for (const key of keys) {
1100
- if (!current || typeof current !== "object") return;
1101
- const container = current;
1102
- if (key.includes("[")) {
1103
- const [arrayKey = "", indexStr = ""] = key.split("[");
1104
- const index = parseInt(indexStr.slice(0, -1), 10);
1105
- const list = container[arrayKey];
1106
- if (!Array.isArray(list) || isNaN(index)) return;
1107
- current = list[index];
1108
- } else {
1109
- if (!(key in container)) return;
1110
- current = container[key];
1111
- }
1112
- }
1113
- return current;
1114
- }
1115
- //#endregion
1116
- //#region src/form/utils/checkShowIfObject.ts
1117
- function checkShowIfObject(showIfObject, formValues, index) {
1118
- const valueList = [];
1119
- for (let [key, value] of Object.entries(showIfObject)) {
1120
- if (index !== void 0) key = key.replace("[index]", `[${index}]`);
1121
- const dependsOnValue = getValueUsingPath(formValues, key);
1122
- if (typeof value === "boolean" || typeof value === "string" || typeof value === "number") valueList.push(dependsOnValue !== null && dependsOnValue !== void 0 && dependsOnValue.toString() === value.toString());
1123
- else if (Array.isArray(value)) valueList.push(value.includes(dependsOnValue));
1124
- }
1125
- return valueList;
1126
- }
1127
- //#endregion
1128
- //#region src/form/utils/getParentValue.ts
1129
- function getParentValue(index, targetField, values, dependentPath, field) {
1130
- let parentValue;
1131
- if (typeof targetField === "object" && targetField !== null && !Array.isArray(targetField)) parentValue = !checkShowIfObject(targetField, values, index).includes(false);
1132
- else if (field.depends_on) {
1133
- dependentPath = field.depends_on;
1134
- if (index !== void 0) dependentPath = field.depends_on.replace("[index]", `[${index}]`);
1135
- const dependsOnValue = getValueUsingPath(values, dependentPath);
1136
- const dependsOnText = dependsOnValue === null || dependsOnValue === void 0 ? void 0 : String(dependsOnValue);
1137
- if (Array.isArray(targetField)) parentValue = targetField.includes(dependsOnValue) || targetField.includes(dependsOnText);
1138
- else if (typeof targetField === "string") parentValue = dependsOnText !== void 0 && targetField.includes(dependsOnText);
1139
- else parentValue = targetField === dependsOnValue;
1140
- } else {
1141
- dependentPath = typeof targetField === "string" ? targetField : "";
1142
- if (index !== void 0 && typeof targetField === "string") dependentPath = targetField.replace("[index]", `[${index}]`);
1143
- parentValue = getValueUsingPath(values, dependentPath);
1144
- }
1145
- return parentValue;
1146
- }
1147
- //#endregion
1148
- //#region src/form/Wizard/utils.ts
1149
- function isWizardMeta(value) {
1150
- return typeof value === "object" && value !== null && "wizard" in value;
1151
- }
1152
- function isStepField(field) {
1153
- return typeof field === "object" && field !== null && "type" in field && field.type === "step";
1154
- }
1155
- function parseWizardConfig(options) {
1156
- const meta = options["$meta"];
1157
- const wizardConfig = isWizardMeta(meta) ? meta.wizard : void 0;
1158
- if (!wizardConfig || wizardConfig.mode !== "wizard") return null;
1159
- const steps = {};
1160
- const stepOrder = [];
1161
- const otherFields = {};
1162
- Object.entries(options).forEach(([key, field]) => {
1163
- if (key === "$meta") return;
1164
- if (isStepField(field)) {
1165
- steps[key] = field;
1166
- stepOrder.push(key);
1167
- } else otherFields[key] = field;
1168
- });
1169
- if (stepOrder.length === 0) {
1170
- console.warn("Wizard mode enabled but no steps found");
1171
- return null;
1172
- }
1173
- return {
1174
- config: wizardConfig,
1175
- steps,
1176
- stepOrder,
1177
- otherFields
1178
- };
1179
- }
1180
- //#endregion
1181
- //#region src/form/Wizard/useWizardState.ts
1182
- function useWizardState({ stepOrder, steps, validateStep, initialStep }) {
1183
- const firstStep = initialStep || stepOrder[0] || "";
1184
- const [currentStep, setCurrentStep] = useState(firstStep);
1185
- const [visitedSteps, setVisitedSteps] = useState(/* @__PURE__ */ new Set([firstStep]));
1186
- const [invalidSteps, setInvalidSteps] = useState(/* @__PURE__ */ new Set());
1187
- const currentStepIndex = stepOrder.indexOf(currentStep);
1188
- const isLastStep = currentStepIndex === stepOrder.length - 1;
1189
- const canGoBack = currentStepIndex > 0;
1190
- /**
1191
- * Mark step as visited
1192
- */
1193
- const markStepVisited = useCallback((stepKey) => {
1194
- setVisitedSteps((prev) => /* @__PURE__ */ new Set([...prev, stepKey]));
1195
- }, []);
1196
- /**
1197
- * Mark step as invalid
1198
- */
1199
- const markStepInvalid = useCallback((stepKey, invalid) => {
1200
- setInvalidSteps((prev) => {
1201
- const next = new Set(prev);
1202
- if (invalid) next.add(stepKey);
1203
- else next.delete(stepKey);
1204
- return next;
1205
- });
1206
- }, []);
1207
- const goToNext = useCallback(async () => {
1208
- if (isLastStep) return false;
1209
- if (steps[currentStep]?.validateOnNext !== false) {
1210
- if (!await validateStep(currentStep)) {
1211
- markStepInvalid(currentStep, true);
1212
- return false;
1213
- }
1214
- }
1215
- markStepInvalid(currentStep, false);
1216
- const nextStepKey = stepOrder[currentStepIndex + 1];
1217
- setCurrentStep(nextStepKey ?? "");
1218
- markStepVisited(nextStepKey ?? "");
1219
- return true;
1220
- }, [
1221
- currentStep,
1222
- currentStepIndex,
1223
- isLastStep,
1224
- steps,
1225
- stepOrder,
1226
- validateStep,
1227
- markStepInvalid,
1228
- markStepVisited
1229
- ]);
1230
- const goToPrevious = useCallback(() => {
1231
- if (!canGoBack) return;
1232
- const prevStepKey = stepOrder[currentStepIndex - 1];
1233
- setCurrentStep(prevStepKey ?? "");
1234
- }, [
1235
- canGoBack,
1236
- currentStepIndex,
1237
- stepOrder
1238
- ]);
1239
- const jumpToStep = useCallback((stepKey) => {
1240
- if (!stepOrder.includes(stepKey)) return false;
1241
- if (!visitedSteps.has(stepKey) && stepKey !== currentStep) return false;
1242
- setCurrentStep(stepKey);
1243
- return true;
1244
- }, [
1245
- stepOrder,
1246
- visitedSteps,
1247
- currentStep
1248
- ]);
1249
- /**
1250
- * Reset wizard to initial state
1251
- */
1252
- const reset = useCallback(() => {
1253
- setCurrentStep(firstStep);
1254
- setVisitedSteps(/* @__PURE__ */ new Set([firstStep]));
1255
- setInvalidSteps(/* @__PURE__ */ new Set());
1256
- }, [firstStep]);
1257
- /**
1258
- * Get current wizard state
1259
- */
1260
- const getState = useCallback(() => {
1261
- return {
1262
- currentStep,
1263
- visitedSteps,
1264
- invalidSteps,
1265
- stepOrder,
1266
- totalSteps: stepOrder.length,
1267
- isLastStep,
1268
- canProceedToNext: !isLastStep,
1269
- canGoBack
1270
- };
1271
- }, [
1272
- currentStep,
1273
- visitedSteps,
1274
- invalidSteps,
1275
- stepOrder,
1276
- isLastStep,
1277
- canGoBack
1278
- ]);
1279
- return {
1280
- currentStep,
1281
- visitedSteps,
1282
- invalidSteps,
1283
- isLastStep,
1284
- canGoBack,
1285
- currentStepIndex,
1286
- totalSteps: stepOrder.length,
1287
- goToNext,
1288
- goToPrevious,
1289
- jumpToStep,
1290
- reset,
1291
- markStepVisited,
1292
- markStepInvalid,
1293
- getState
1294
- };
1295
- }
1296
- //#endregion
1297
- //#region src/form/Wizard/WizardNavigation.tsx
1298
- function WizardNavigation({ currentStep, stepOrder, canGoToNext, canGoBack, isCurrentStepValid, nextLabel, prevLabel, submitLabel = "Submit", onNext, onPrevious, onSubmit }) {
1299
- const [isLoading, setIsLoading] = useState(false);
1300
- const [error, setError] = useState(null);
1301
- const isLastStep = stepOrder.indexOf(currentStep) === stepOrder.length - 1;
1302
- const handleNext = async () => {
1303
- setIsLoading(true);
1304
- setError(null);
1305
- try {
1306
- if (!await onNext()) setError("Please fix errors before proceeding");
1307
- } catch (err) {
1308
- setError(err instanceof Error ? err.message : "An error occurred");
1309
- } finally {
1310
- setIsLoading(false);
1311
- }
1312
- };
1313
- const handleSubmit = async () => {
1314
- setIsLoading(true);
1315
- setError(null);
1316
- try {
1317
- await onSubmit();
1318
- } catch (err) {
1319
- setError(err instanceof Error ? err.message : "An error occurred");
1320
- } finally {
1321
- setIsLoading(false);
1322
- }
1323
- };
1324
- return /* @__PURE__ */ jsxs("div", { children: [error && /* @__PURE__ */ jsx("div", {
1325
- className: "mb-4 p-3 bg-red-50 border border-red-200 rounded text-sm text-red-700",
1326
- children: error
1327
- }), /* @__PURE__ */ jsxs("div", {
1328
- className: "flex gap-3 justify-between pt-4",
1329
- children: [/* @__PURE__ */ jsx("button", {
1330
- type: "button",
1331
- onClick: onPrevious,
1332
- disabled: !canGoBack || isLoading,
1333
- className: "px-6 py-3 rounded-lg font-medium transition-all duration-200 border flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",
1334
- style: {
1335
- color: "var(--theme-app)",
1336
- borderColor: "var(--theme-border)",
1337
- backgroundColor: "var(--theme-app-bg)"
1338
- },
1339
- onMouseEnter: (e) => {
1340
- if (!(!canGoBack || isLoading)) e.currentTarget.style.backgroundColor = "var(--theme-hover)";
1341
- },
1342
- onMouseLeave: (e) => {
1343
- e.currentTarget.style.backgroundColor = "var(--theme-app-bg)";
1344
- },
1345
- "aria-label": "Go to previous step",
1346
- children: prevLabel || "← Previous"
1347
- }), isLastStep ? /* @__PURE__ */ jsxs("button", {
1348
- type: "button",
1349
- onClick: handleSubmit,
1350
- disabled: !isCurrentStepValid || isLoading,
1351
- className: "px-8 py-3 rounded-lg font-medium transition-all duration-200 text-white flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-md hover:shadow-lg",
1352
- style: { backgroundColor: "var(--theme-element)" },
1353
- onMouseEnter: (e) => {
1354
- if (!(!isCurrentStepValid || isLoading)) e.currentTarget.style.filter = "brightness(0.9)";
1355
- },
1356
- onMouseLeave: (e) => {
1357
- e.currentTarget.style.filter = "brightness(1)";
1358
- },
1359
- "aria-label": submitLabel,
1360
- children: [isLoading && /* @__PURE__ */ jsx(Loader, {
1361
- size: 16,
1362
- full: false
1363
- }), submitLabel]
1364
- }) : /* @__PURE__ */ jsxs("button", {
1365
- type: "button",
1366
- onClick: handleNext,
1367
- disabled: !canGoToNext || isLoading,
1368
- className: "px-8 py-3 rounded-lg font-medium transition-all duration-200 text-white flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-md hover:shadow-lg",
1369
- style: { backgroundColor: "var(--theme-element)" },
1370
- onMouseEnter: (e) => {
1371
- if (!(!canGoToNext || isLoading)) e.currentTarget.style.filter = "brightness(0.9)";
1372
- },
1373
- onMouseLeave: (e) => {
1374
- e.currentTarget.style.filter = "brightness(1)";
1375
- },
1376
- "aria-label": "Go to next step",
1377
- children: [isLoading && /* @__PURE__ */ jsx(Loader, {
1378
- size: 16,
1379
- full: false
1380
- }), nextLabel || "Next →"]
1381
- })]
1382
- })] });
1383
- }
1384
- //#endregion
1385
- //#region src/form/Wizard/WizardStepContent.tsx
1386
- function WizardStepContent({ currentStep, stepConfig, flatten = true, values, onValuesChange, setFormDirty, setFieldValue, setFieldTouched, ...fieldsProps }) {
1387
- if (!stepConfig?.options) return null;
1388
- return /* @__PURE__ */ jsxs("div", {
1389
- className: "mb-4 w-full",
1390
- children: [
1391
- stepConfig.title && /* @__PURE__ */ jsx("h2", {
1392
- className: "text-2xl font-bold mb-2",
1393
- style: { color: "var(--theme-app)" },
1394
- children: stepConfig.title
1395
- }),
1396
- stepConfig.description && /* @__PURE__ */ jsx("p", {
1397
- className: "mb-4 leading-relaxed",
1398
- style: { color: "var(--theme-muted-text-color)" },
1399
- children: stepConfig.description
1400
- }),
1401
- /* @__PURE__ */ jsx(FieldsFromOptions, {
1402
- options: stepConfig.options,
1403
- values,
1404
- setFormDirty,
1405
- setFieldValue,
1406
- setFieldTouched,
1407
- ...flatten === false ? { parentInfo: {
1408
- parentName: currentStep,
1409
- fieldNamePrefix: `${currentStep}.`
1410
- } } : {},
1411
- ...fieldsProps
1412
- }, currentStep)
1413
- ]
1414
- });
1415
- }
1416
- //#endregion
1417
- //#region src/form/Wizard/WizardStepIndicator.tsx
1418
- function WizardStepIndicator({ stepOrder, currentStep, steps, visitedSteps, invalidSteps, onStepClick, allowJump = false, hideStepNumbers = false }) {
1419
- const currentIndex = useMemo(() => stepOrder.indexOf(currentStep), [stepOrder, currentStep]);
1420
- const getStepStatus = (stepKey, index) => {
1421
- if (stepKey === currentStep) return "active";
1422
- if (index < currentIndex) return "completed";
1423
- return "upcoming";
1424
- };
1425
- const handleStepClick = (stepKey) => {
1426
- if (!allowJump || !visitedSteps.has(stepKey)) return;
1427
- onStepClick?.(stepKey);
1428
- };
1429
- const isClickable = (stepKey) => {
1430
- return allowJump && visitedSteps.has(stepKey) && stepKey !== currentStep;
1431
- };
1432
- return /* @__PURE__ */ jsx("div", {
1433
- className: "flex items-start justify-between w-full mb-2 gap-4 py-2",
1434
- children: stepOrder.map((stepKey, index) => {
1435
- const stepConfig = steps[stepKey];
1436
- const status = getStepStatus(stepKey, index);
1437
- const isInvalid = invalidSteps.has(stepKey);
1438
- const isClickable_ = isClickable(stepKey);
1439
- const isDotActive = status === "active";
1440
- const isDotCompleted = status === "completed";
1441
- const isDotUpcoming = status === "upcoming";
1442
- return /* @__PURE__ */ jsxs("div", {
1443
- className: "flex flex-col items-center flex-1 relative",
1444
- children: [
1445
- /* @__PURE__ */ jsxs("button", {
1446
- type: "button",
1447
- onClick: () => handleStepClick(stepKey),
1448
- disabled: !isClickable_,
1449
- className: cx("w-12 h-12 rounded-full border-3 flex items-center justify-center font-bold text-base transition-all duration-300 flex-shrink-0 relative", {
1450
- "cursor-pointer": isClickable_,
1451
- "cursor-not-allowed": !isClickable_
1452
- }, {
1453
- "text-white": isDotActive,
1454
- "bg-green-500 border-green-600 text-white shadow-md": isDotCompleted && !isInvalid,
1455
- "bg-(--theme-border) theme-border theme-muted-text shadow-sm": isDotUpcoming && !isInvalid,
1456
- "bg-(--theme-muted-panel-bg) theme-border theme-muted-text shadow-sm": !isDotActive && !isDotCompleted && !isDotUpcoming && !isInvalid,
1457
- "bg-red-50 border-red-500 text-red-600 shadow-sm": isInvalid && status !== "active"
1458
- }),
1459
- style: isDotActive ? {
1460
- backgroundColor: "var(--theme-element)",
1461
- borderColor: "var(--theme-element)",
1462
- color: "var(--theme-element-text)",
1463
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
1464
- zIndex: 10
1465
- } : { zIndex: 10 },
1466
- "aria-label": `Step ${index + 1}: ${stepConfig?.title}`,
1467
- title: stepConfig?.title,
1468
- children: [!hideStepNumbers && /* @__PURE__ */ jsx("span", {
1469
- className: cx({ hidden: status === "completed" }),
1470
- children: index + 1
1471
- }), status === "completed" && /* @__PURE__ */ jsx("svg", {
1472
- "aria-hidden": "true",
1473
- className: "w-4 h-4",
1474
- fill: "none",
1475
- stroke: "currentColor",
1476
- viewBox: "0 0 24 24",
1477
- children: /* @__PURE__ */ jsx("path", {
1478
- strokeLinecap: "round",
1479
- strokeLinejoin: "round",
1480
- strokeWidth: 3,
1481
- d: "M5 13l4 4L19 7"
1482
- })
1483
- })]
1484
- }),
1485
- index < stepOrder.length - 1 && /* @__PURE__ */ jsx("div", {
1486
- className: cx("absolute h-1 transition-all duration-300", {
1487
- "bg-green-500": index < currentIndex,
1488
- "bg-(--theme-border)": index >= currentIndex,
1489
- "opacity-25": index >= currentIndex
1490
- }),
1491
- style: {
1492
- top: "24px",
1493
- left: "calc(50% + 24px)",
1494
- right: "-50%",
1495
- boxShadow: index < currentIndex ? "0 1px 2px rgba(34, 197, 94, 0.2)" : "none"
1496
- },
1497
- "aria-hidden": "true"
1498
- }),
1499
- /* @__PURE__ */ jsxs("div", {
1500
- className: "mt-2 text-center",
1501
- children: [/* @__PURE__ */ jsx("div", {
1502
- className: cx("text-sm text-center transition-colors duration-300 max-w-30", {
1503
- "font-bold text-green-600": isDotCompleted && !isInvalid,
1504
- "font-bold text-red-600": isInvalid && status !== "active",
1505
- "font-semibold theme-muted-text": !isDotActive && !isDotCompleted && !isInvalid,
1506
- "font-bold text-white": isDotActive
1507
- }),
1508
- style: isDotActive ? { color: "var(--theme-element)" } : {},
1509
- children: stepConfig?.title
1510
- }), stepConfig?.description && /* @__PURE__ */ jsx("div", {
1511
- className: "text-xs theme-muted-text mt-1 text-center max-w-30",
1512
- children: stepConfig.description
1513
- })]
1514
- })
1515
- ]
1516
- }, stepKey);
1517
- })
1518
- });
1519
- }
1520
- //#endregion
1521
- //#region src/form/Wizard/WizardContainer.tsx
1522
- function hasNestedError(stepErrors, fieldName) {
1523
- return typeof stepErrors === "object" && stepErrors !== null && fieldName in stepErrors;
1524
- }
1525
- function WizardContainer({ wizardConfig, values, onChange, onSubmit, className = "", labelPosition = "left", missingFields = [], spaceCompact = false, workflowForm = false, setFieldValue, setFieldTouched }) {
1526
- const { validateForm, setTouched, touched } = useFormikContext();
1527
- const { config, steps, stepOrder } = wizardConfig;
1528
- const { currentStep, visitedSteps, invalidSteps, isLastStep, canGoBack, goToNext, goToPrevious, jumpToStep } = useWizardState({
1529
- stepOrder,
1530
- steps,
1531
- validateStep: useCallback(async (stepKey) => {
1532
- const stepConfig = steps[stepKey];
1533
- if (!stepConfig?.options) return true;
1534
- const stepFieldNames = Object.keys(stepConfig.options);
1535
- const shouldFlatten = config.flatten !== false;
1536
- const errors = await validateForm();
1537
- const hasStepErrors = shouldFlatten ? stepFieldNames.some((fieldName) => errors[fieldName]) : stepFieldNames.some((fieldName) => hasNestedError(errors[stepKey], fieldName));
1538
- if (hasStepErrors) {
1539
- const touchedFields = stepFieldNames.reduce((acc, fieldName) => {
1540
- acc[fieldName] = true;
1541
- return acc;
1542
- }, {});
1543
- if (shouldFlatten) setTouched({
1544
- ...touched,
1545
- ...touchedFields
1546
- }, false);
1547
- else setTouched({
1548
- ...touched,
1549
- [stepKey]: touchedFields
1550
- }, false);
1551
- }
1552
- return !hasStepErrors;
1553
- }, [
1554
- steps,
1555
- config,
1556
- validateForm,
1557
- setTouched,
1558
- touched
1559
- ])
1560
- });
1561
- const currentStepConfig = steps[currentStep];
1562
- const config_ = config.navigation || {};
1563
- const handleGoToNext = useCallback(async () => {
1564
- const success = await goToNext();
1565
- if (success) onChange?.(values);
1566
- return success;
1567
- }, [
1568
- goToNext,
1569
- values,
1570
- onChange
1571
- ]);
1572
- const handleJumpToStep = useCallback((stepKey) => {
1573
- if (!config_.allowJump || !visitedSteps.has(stepKey)) return false;
1574
- return jumpToStep(stepKey);
1575
- }, [
1576
- jumpToStep,
1577
- config_.allowJump,
1578
- visitedSteps
1579
- ]);
1580
- const handleSubmit = useCallback(async () => {
1581
- if (!isLastStep) return;
1582
- const errors = await validateForm();
1583
- if (Object.keys(errors).length > 0) {
1584
- const touchedFields = Object.keys(values).reduce((acc, fieldName) => {
1585
- acc[fieldName] = true;
1586
- return acc;
1587
- }, {});
1588
- setTouched({
1589
- ...touched,
1590
- ...touchedFields
1591
- }, false);
1592
- throw new Error("Please fix errors before submitting");
1593
- }
1594
- await onSubmit?.(values);
1595
- }, [
1596
- isLastStep,
1597
- validateForm,
1598
- values,
1599
- setTouched,
1600
- touched,
1601
- onSubmit
1602
- ]);
1603
- return /* @__PURE__ */ jsxs("div", {
1604
- className,
1605
- children: [
1606
- config_.showSteps !== false && /* @__PURE__ */ jsx(WizardStepIndicator, {
1607
- stepOrder,
1608
- currentStep,
1609
- steps,
1610
- visitedSteps,
1611
- invalidSteps,
1612
- onStepClick: handleJumpToStep,
1613
- allowJump: config_.allowJump,
1614
- hideStepNumbers: config_.hideStepNumbers
1615
- }),
1616
- currentStepConfig && /* @__PURE__ */ jsx("div", {
1617
- className: "mb-4",
1618
- children: /* @__PURE__ */ jsx(WizardStepContent, {
1619
- currentStep,
1620
- stepConfig: currentStepConfig,
1621
- flatten: config.flatten,
1622
- values,
1623
- onValuesChange: onChange,
1624
- labelPosition,
1625
- missingFields,
1626
- spaceCompact,
1627
- setFormDirty: () => onChange?.(values),
1628
- workflowForm,
1629
- setFieldValue,
1630
- setFieldTouched
1631
- })
1632
- }),
1633
- /* @__PURE__ */ jsx(WizardNavigation, {
1634
- currentStep,
1635
- stepOrder,
1636
- canGoToNext: !isLastStep,
1637
- canGoBack,
1638
- isCurrentStepValid: !invalidSteps.has(currentStep),
1639
- nextLabel: currentStepConfig?.nextLabel,
1640
- prevLabel: currentStepConfig?.prevLabel,
1641
- submitLabel: config.submitLabel || "Execute",
1642
- onNext: handleGoToNext,
1643
- onPrevious: goToPrevious,
1644
- onSubmit: handleSubmit
1645
- })
1646
- ]
1647
- });
1648
- }
1649
- //#endregion
1650
- //#region src/form/Form.tsx
1651
- function asSchemaField(value) {
1652
- return value && typeof value === "object" ? value : null;
1653
- }
1654
- function asRecord(value) {
1655
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1656
- }
1657
- function flagValue(value, fallback) {
1658
- return value && (typeof value === "string" || typeof value === "boolean") ? value : fallback;
1659
- }
1660
- /** Applies `$meta` overrides for `labelPosition` / `spaceCompact`. */
1661
- function resolveMetaOverrides(options, labelPosition, spaceCompact) {
1662
- const meta = options?.["$meta"];
1663
- return {
1664
- labelPosition: meta?.labelPosition ?? labelPosition,
1665
- spaceCompact: meta?.spaceCompact ?? spaceCompact
1666
- };
1667
- }
1668
- /** Cheap signature of every list's length; gates the expensive collect walk. */
1669
- function listLengthsSignature(options, values = {}, prefix = "") {
1670
- if (!options || typeof options !== "object") return "";
1671
- const parts = [];
1672
- for (const [fieldName, rawField] of Object.entries(options)) {
1673
- const field = asSchemaField(rawField);
1674
- if (fieldName === "$meta" || !field) continue;
1675
- const fullName = prefix ? `${prefix}${fieldName}` : fieldName;
1676
- if (field.type === "list") {
1677
- const items = values?.[fieldName];
1678
- const len = Array.isArray(items) ? items.length : 0;
1679
- parts.push(`${fullName}:${len}`);
1680
- const template = field.template || field.options;
1681
- if (template && Array.isArray(items)) for (let i = 0; i < items.length; i++) parts.push(listLengthsSignature(template, asRecord(items[i]), `${fullName}[${i}].`));
1682
- } else if (field.type === "group") {
1683
- const groupItems = field.items || field.options;
1684
- if (groupItems) parts.push(listLengthsSignature(groupItems, values, prefix));
1685
- } else if (field.type === "object") {
1686
- const groupItems = field.items || field.options;
1687
- if (groupItems) {
1688
- const nestedValues = asRecord(values?.[fieldName]);
1689
- parts.push(listLengthsSignature(groupItems, nestedValues, `${fullName}.`));
1690
- }
1691
- }
1692
- }
1693
- return parts.join("|");
1694
- }
1695
- /** Collects every field with a `default` for the form-level sync to track. */
1696
- function collectFieldsWithDefaults(options, values = {}, prefix = "") {
1697
- const result = [];
1698
- if (!options || typeof options !== "object") return result;
1699
- for (const [fieldName, rawField] of Object.entries(options)) {
1700
- const field = asSchemaField(rawField);
1701
- if (!field) continue;
1702
- if (fieldName === "$meta") continue;
1703
- const fullName = prefix ? `${prefix}${fieldName}` : fieldName;
1704
- if (field.type === "group") {
1705
- const groupItems = field.items || field.options;
1706
- if (groupItems) result.push(...collectFieldsWithDefaults(groupItems, values, prefix));
1707
- continue;
1708
- }
1709
- if (field.type === "object") {
1710
- const groupItems = field.items || field.options;
1711
- if (groupItems) {
1712
- const nestedValues = asRecord(values?.[fieldName]);
1713
- result.push(...collectFieldsWithDefaults(groupItems, nestedValues, `${fullName}.`));
1714
- }
1715
- continue;
1716
- }
1717
- if (field.type === "list") {
1718
- const listTemplate = field.template || field.options;
1719
- const listValues = values?.[fieldName];
1720
- if (listTemplate && Array.isArray(listValues)) for (let i = 0; i < listValues.length; i++) {
1721
- const itemValues = asRecord(listValues[i]);
1722
- result.push(...collectFieldsWithDefaults(listTemplate, itemValues, `${fullName}[${i}].`));
1723
- }
1724
- continue;
1725
- }
1726
- if (resolvedFlag(field.hidden) === true && field.ignore !== void 0 && resolvedFlag(field.ignore) !== false) continue;
1727
- if (field.default !== void 0) result.push({
1728
- name: fullName,
1729
- defaultValue: field.default,
1730
- ...field.secondaryField ? { hasSecondary: true } : {}
1731
- });
1732
- }
1733
- return result;
1734
- }
1735
- function defaultReferencesField(defaultValue, fieldPath) {
1736
- if (typeof defaultValue !== "string" || !defaultValue.includes("${{")) return false;
1737
- const escaped = fieldPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1738
- return new RegExp(`\\binputs\\.${escaped}(?![\\w.[-])`).test(defaultValue);
1739
- }
1740
- function findSelfReferencingFieldNames(schema, values = {}) {
1741
- return collectFieldsWithDefaults(schema, values).filter(({ name, defaultValue }) => defaultReferencesField(defaultValue, name)).map(({ name }) => name);
1742
- }
1743
- /** Resolves schema defaults into form values as dependencies change. Store-agnostic so the Formik
1744
- * form and hosts with their own store share one implementation. */
1745
- function useDynamicDefaultsSync({ options, values, setValue, isTouched }) {
1746
- const engine = useWorkflowEngine();
1747
- const listSig = useMemo(() => listLengthsSignature(options, values), [options, values]);
1748
- const fieldsWithDefaults = useMemo(() => collectFieldsWithDefaults(options, values).map((f) => {
1749
- if (typeof f.defaultValue !== "string" || !f.defaultValue.includes("${{")) return f;
1750
- const lastRowIndex = [...f.name.matchAll(/\[(\d+)\]/g)].at(-1)?.[1];
1751
- const index = lastRowIndex === void 0 ? -1 : Number(lastRowIndex);
1752
- const parsed = engine.evaluate({
1753
- inputs: values,
1754
- obj: { v: f.defaultValue },
1755
- orgVars: {},
1756
- index
1757
- });
1758
- const resolved = parsed && typeof parsed === "object" && "v" in parsed ? parsed.v : f.defaultValue;
1759
- return {
1760
- ...f,
1761
- defaultValue: resolved
1762
- };
1763
- }), [options, listSig]);
1764
- const prevDefaultsRef = useRef(/* @__PURE__ */ new Map());
1765
- const synthTouchedRef = useRef(/* @__PURE__ */ new Set());
1766
- const prevListLensRef = useRef(/* @__PURE__ */ new Map());
1767
- const fieldsWithDefaultsRef = useRef(null);
1768
- if (!deepEqual(fieldsWithDefaultsRef.current, fieldsWithDefaults)) {
1769
- fieldsWithDefaultsRef.current = fieldsWithDefaults;
1770
- const currentNames = new Set(fieldsWithDefaults.map((f) => f.name));
1771
- for (const name of prevDefaultsRef.current.keys()) if (!currentNames.has(name)) {
1772
- prevDefaultsRef.current.delete(name);
1773
- synthTouchedRef.current.delete(name);
1774
- }
1775
- const listLens = /* @__PURE__ */ new Map();
1776
- for (const part of listSig.split("|")) {
1777
- const sep = part.lastIndexOf(":");
1778
- if (sep > 0) listLens.set(part.slice(0, sep), Number(part.slice(sep + 1)));
1779
- }
1780
- for (const [list, prevLen] of prevListLensRef.current) {
1781
- const nowLen = listLens.get(list);
1782
- if (nowLen !== void 0 && nowLen < prevLen) {
1783
- for (const name of [...prevDefaultsRef.current.keys()]) if (name.startsWith(`${list}[`)) prevDefaultsRef.current.delete(name);
1784
- for (const name of [...synthTouchedRef.current]) if (name.startsWith(`${list}[`)) synthTouchedRef.current.delete(name);
1785
- }
1786
- }
1787
- prevListLensRef.current = listLens;
1788
- for (const { name, defaultValue, hasSecondary } of fieldsWithDefaults) {
1789
- if (hasSecondary) continue;
1790
- if (synthTouchedRef.current.has(name)) continue;
1791
- if (isTouched(name)) continue;
1792
- if (typeof defaultValue === "string" && defaultValue.includes("${{")) continue;
1793
- const wasSeen = prevDefaultsRef.current.has(name);
1794
- const serializedDefault = JSON.stringify(defaultValue ?? null);
1795
- const prevDefault = prevDefaultsRef.current.get(name);
1796
- prevDefaultsRef.current.set(name, serializedDefault);
1797
- if (!wasSeen) {
1798
- const rawValue = getValueUsingPath(values, name);
1799
- const currVal = JSON.stringify(rawValue);
1800
- const trimmedValue = typeof rawValue === "string" ? rawValue.trim() : "";
1801
- const unresolvedValue = trimmedValue.startsWith("${{") && trimmedValue.endsWith("}}");
1802
- if (!unresolvedValue && currVal !== void 0 && currVal !== serializedDefault) {
1803
- synthTouchedRef.current.add(name);
1804
- continue;
1805
- }
1806
- if (!unresolvedValue) continue;
1807
- }
1808
- if (prevDefault === serializedDefault) continue;
1809
- if (defaultValue === null || defaultValue === void 0) continue;
1810
- if (JSON.stringify(getValueUsingPath(values, name)) !== serializedDefault) setValue(name, defaultValue);
1811
- }
1812
- }
1813
- }
1814
- function DynamicDefaultsSync({ options }) {
1815
- const { setFieldValue, getFieldMeta, values } = useFormikContext();
1816
- useDynamicDefaultsSync({
1817
- options,
1818
- values,
1819
- setValue: setFieldValue,
1820
- isTouched: (name) => getFieldMeta(name).touched
1821
- });
1822
- return null;
1823
- }
1824
- function GroupHeader({ children, open, setOpen, title }) {
1825
- return /* @__PURE__ */ jsxs(SectionHeader, {
1826
- className: "flex items-center justify-between pb-1 mb-2 border-b",
1827
- children: [/* @__PURE__ */ jsxs("button", {
1828
- type: "button",
1829
- "aria-expanded": open,
1830
- className: cx("w-full flex items-center text-left transform ease-in transition cursor-pointer"),
1831
- onClick: () => setOpen((open) => !open),
1832
- children: [/* @__PURE__ */ jsx(AngleRightIcon, { className: cx(open && "transform rotate-90 ", "px-1 text-[1.25rem] transition ease-in ") }), /* @__PURE__ */ jsx("span", { children: title })]
1833
- }), children]
1834
- });
1835
- }
1836
- function deleteFieldByPath(obj, path) {
1837
- if (!path) return;
1838
- const parts = path.replaceAll("[", ".").replaceAll("]", "").split(".");
1839
- const fieldToRemove = parts.pop();
1840
- if (!fieldToRemove) {
1841
- console.error("Invalid path");
1842
- return;
1843
- }
1844
- const parent = parts.reduce((acc, curr) => {
1845
- if (acc && typeof acc === "object") return acc[curr];
1846
- return {};
1847
- }, obj);
1848
- if (parent && typeof parent === "object" && Object.hasOwn(parent, fieldToRemove)) delete parent[fieldToRemove];
1849
- }
1850
- function getClosestParentIndex(parentPath) {
1851
- for (let i = parentPath.length - 1; i >= 0; i--) if (parentPath[i] === "]") {
1852
- let j = i - 1;
1853
- while (j >= 0 && parentPath[j] !== "[") j--;
1854
- return parseInt(parentPath.slice(j + 1, i));
1855
- }
1856
- }
1857
- function MultiSelectionDropdown({ name, label = "", invalid = false, options: initialOptions = [], setFormDirty, onChange, parentValue }) {
1858
- const [field] = useField(name);
1859
- const required = useFieldRequired();
1860
- const controlProps = useFieldControlProps();
1861
- const { setFieldValue } = useFormikContext();
1862
- const options = useMemo(() => {
1863
- return initialOptions.map((option) => {
1864
- const op = typeof option === "string" ? {
1865
- label: option,
1866
- value: option,
1867
- selected: false
1868
- } : { ...option };
1869
- if (field.value?.includes(op.value)) op.selected = true;
1870
- return op;
1871
- });
1872
- }, [initialOptions, field.value]);
1873
- const handleOptionSelected = (selectedValue) => {
1874
- let selected = [];
1875
- if (field.value) selected = [...field.value];
1876
- selected.push(selectedValue);
1877
- setFieldValue(name, selected);
1878
- if (onChange) onChange(options);
1879
- setFormDirty(true);
1880
- };
1881
- const t = useStrings().common;
1882
- const handleRemoveOption = (key) => {
1883
- const selected = [...field.value.filter((item) => item !== key)];
1884
- setFieldValue(name, selected);
1885
- if (onChange) onChange(options);
1886
- setFormDirty(true);
1887
- };
1888
- const prevParent = usePrevious(parentValue);
1889
- useEffect(() => {
1890
- if (prevParent && parentValue && prevParent !== parentValue) setFieldValue(name, []);
1891
- }, [
1892
- parentValue,
1893
- prevParent,
1894
- name,
1895
- setFieldValue
1896
- ]);
1897
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomListbox, {
1898
- ...controlProps,
1899
- options,
1900
- required,
1901
- type: label.toLowerCase(),
1902
- handleOptionSelected,
1903
- className: "mb-3",
1904
- invalid,
1905
- closeOnSelect: false
1906
- }), /* @__PURE__ */ jsx(Table, { children: field.value && field.value.length > 0 ? options.filter((option) => option.selected).map((option) => {
1907
- return /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx(Table.Item, {
1908
- className: "w-full",
1909
- children: option?.label
1910
- }), /* @__PURE__ */ jsx(Table.Item, { children: /* @__PURE__ */ jsx("button", {
1911
- type: "button",
1912
- "aria-label": t.remove,
1913
- className: "inline-flex bg-transparent p-0 cursor-pointer",
1914
- onClick: () => handleRemoveOption(option.value),
1915
- children: /* @__PURE__ */ jsx(TrashIcon, { className: "link mr-4" })
1916
- }) })] }, String(option.value));
1917
- }) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs(Table.Item, { children: [
1918
- "No ",
1919
- label !== "" ? label.toLowerCase() : "options",
1920
- " selected"
1921
- ] }) }) })] });
1922
- }
1923
- var InputField = React.memo(function InputField({ label, field, setFormDirty, onChange, disabled = false, labelPosition = "left", missingFields = [], computeOn, spaceCompact = false, workflowForm = false, setFieldValue, setFieldTouched, values, currentValue }) {
1924
- const prevField = useRef(field);
1925
- const fieldObj = useMemo(() => {
1926
- if (deepEqual(prevField.current, field)) return prevField.current;
1927
- prevField.current = field;
1928
- return { ...field };
1929
- }, [field]);
1930
- const tooltipComponent = useMemo(() => {
1931
- if (!fieldObj.tooltip) return null;
1932
- return /* @__PURE__ */ jsx(TooltipInfo, {
1933
- className: "pr-2",
1934
- place: "top",
1935
- text: typeof fieldObj.tooltip === "string" ? fieldObj.tooltip.replace(/\r/g, "") : fieldObj.tooltip.filter(Boolean).join("\n")
1936
- });
1937
- }, [fieldObj.tooltip]);
1938
- const missing = missingFields.includes(fieldObj.name ?? "");
1939
- return /* @__PURE__ */ jsx(Registry, {
1940
- field: fieldObj,
1941
- label,
1942
- labelPosition,
1943
- missing,
1944
- missingFields,
1945
- values,
1946
- setFormDirty,
1947
- onChange,
1948
- disabled,
1949
- computeOn,
1950
- spaceCompact,
1951
- tooltipComponent,
1952
- workflowForm,
1953
- setFieldTouched,
1954
- setFieldValue,
1955
- currentValue
1956
- });
1957
- }, (prev, next) => {
1958
- if (!deepEqual(prev.field, next.field)) return false;
1959
- for (const key of Object.keys(prev)) {
1960
- if (key === "field" || key === "values") continue;
1961
- if (prev[key] !== next[key]) return false;
1962
- }
1963
- return true;
1964
- });
1965
- function FormikStateBridge({ onChange }) {
1966
- const { values } = useFormikContext();
1967
- const prevEmitted = useRef(null);
1968
- useEffect(() => {
1969
- const { editorKeyPostfix: _, ...next } = values;
1970
- if (prevEmitted.current !== null && prevEmitted.current !== void 0 && deepEqual(prevEmitted.current, next)) return;
1971
- prevEmitted.current = next;
1972
- onChange(next);
1973
- }, [values, onChange]);
1974
- return null;
1975
- }
1976
- function DirtyStateBridge({ setFormDirty }) {
1977
- const { dirty } = useFormikContext();
1978
- useEffect(() => {
1979
- setFormDirty(dirty);
1980
- }, [dirty, setFormDirty]);
1981
- return null;
1982
- }
1983
- /** Three-tier cache: no expressions → raw pass-through; input-dep expressions → re-parse on dep change; org-var/path expressions → parse once. */
1984
- function useFieldParse(optionsField, values, arrayIndex) {
1985
- const engine = useWorkflowEngine();
1986
- const c = useRef({
1987
- lastOptField: null,
1988
- convertedField: null,
1989
- inputDeps: /* @__PURE__ */ new Set(),
1990
- hasExpressions: false,
1991
- lastRelevant: {},
1992
- lastIndex: void 0,
1993
- result: null
1994
- }).current;
1995
- if (optionsField !== c.lastOptField) {
1996
- c.lastOptField = optionsField;
1997
- c.convertedField = engine.convertInputs(asRecord(optionsField));
1998
- const { inputDeps, hasExpressions } = engine.inputDependencies(c.convertedField);
1999
- c.inputDeps = inputDeps;
2000
- c.hasExpressions = hasExpressions;
2001
- c.result = null;
2002
- }
2003
- if (!c.hasExpressions) return optionsField;
2004
- if (c.inputDeps.size === 0) {
2005
- if (c.result !== null) return c.result;
2006
- }
2007
- if (c.result !== null) {
2008
- let changed = arrayIndex !== c.lastIndex;
2009
- if (!changed) {
2010
- for (const key of c.inputDeps) if (!deepEqual(values[key], c.lastRelevant[key])) {
2011
- changed = true;
2012
- break;
2013
- }
2014
- }
2015
- if (!changed) return c.result;
2016
- }
2017
- c.result = engine.evaluate({
2018
- inputs: values,
2019
- obj: c.convertedField,
2020
- orgVars: {},
2021
- index: arrayIndex
2022
- });
2023
- c.lastIndex = arrayIndex;
2024
- c.lastRelevant = {};
2025
- for (const key of c.inputDeps) c.lastRelevant[key] = values[key];
2026
- return c.result;
2027
- }
2028
- var FormField = React.memo(function FormField({ id, optionsField, fieldName, values, setFormDirty, setFieldValue, setFieldTouched, parentInfo, labelPosition = "left", missingFields = [], spaceCompact = false, workflowForm = false }) {
2029
- const parsedField = useFieldParse(optionsField, values, parentInfo?.arrayIndex);
2030
- const field = asSchemaField(parentInfo ? parsedField : optionsField);
2031
- if (field === null) return null;
2032
- const fieldNamePrefix = parentInfo?.fieldNamePrefix || "";
2033
- const fieldObj = {
2034
- ...field,
2035
- label: field.label || fieldName.charAt(0).toUpperCase() + fieldName.slice(1),
2036
- name: fieldNamePrefix + fieldName,
2037
- optional: resolvedFlag(field.optional) ?? field.default !== void 0
2038
- };
2039
- if (!fieldObj["name"] || fieldName === "v3") return null;
2040
- if (field.hidden === true || !field.type) {
2041
- if (resolvedFlag(field.ignore) && !workflowForm) deleteFieldByPath(values, fieldObj["name"]);
2042
- return null;
2043
- }
2044
- if (!field.type && field.options) fieldObj["type"] = "dropdown";
2045
- let onChange;
2046
- if (field.one_must_be_true && parentInfo?.onChange) {
2047
- const parentOnChange = parentInfo.onChange;
2048
- const parentArrayIndex = parentInfo.arrayIndex ?? 0;
2049
- const fieldOptions = fieldObj["options"];
2050
- onChange = (val) => parentOnChange(fieldName, parentArrayIndex, flagValue(fieldOptions?.["offOption"], false), flagValue(fieldOptions?.["onOption"], true), val);
2051
- }
2052
- if (field.show_if !== void 0 || field.show_if_not !== void 0) {
2053
- let index;
2054
- if (parentInfo) {
2055
- if (!parentInfo?.arrayIndex) index = getClosestParentIndex(parentInfo.fieldNamePrefix);
2056
- else index = parentInfo.arrayIndex;
2057
- }
2058
- let shouldShowField = true;
2059
- if (field.show_if !== void 0) shouldShowField = !!getParentValue(index, field.show_if, values, "", field);
2060
- if (shouldShowField && field.show_if_not !== void 0) shouldShowField = !getParentValue(index, field.show_if_not, values, "", field);
2061
- if (!shouldShowField) {
2062
- if (!workflowForm) deleteFieldByPath(values, fieldObj["name"]);
2063
- return null;
2064
- }
2065
- }
2066
- if (field.depends_on) {
2067
- if (parentInfo?.arrayIndex !== void 0) fieldObj["depends_on"] = field.depends_on.replace("[index]", `[${parentInfo.arrayIndex}]`);
2068
- }
2069
- if (field.enable_if && field.disabled === false) {
2070
- if (typeof field.enable_if === "string") {
2071
- let path = field.enable_if;
2072
- if (parentInfo?.arrayIndex !== void 0) path = field.enable_if.replace("[index]", `[${parentInfo.arrayIndex}]`);
2073
- if (getValueUsingPath(values, path) === false) fieldObj["disabled"] = true;
2074
- }
2075
- }
2076
- if (field.type === "group") {
2077
- const hideHeader = field.noCollapse;
2078
- const HeaderElement = hideHeader ? React.Fragment : UncontrolledCollapsiblePanel;
2079
- const meta = resolveMetaOverrides(field.options, labelPosition, spaceCompact);
2080
- return /* @__PURE__ */ jsx("div", {
2081
- className: "flex flex-col w-full",
2082
- children: /* @__PURE__ */ jsx(HeaderElement, {
2083
- ...!hideHeader && {
2084
- title: (open, setOpen) => /* @__PURE__ */ jsx(GroupHeader, {
2085
- open,
2086
- setOpen,
2087
- title: field.label
2088
- }),
2089
- initialState: field.collapsed !== void 0 ? !field.collapsed : true
2090
- },
2091
- children: /* @__PURE__ */ jsx("div", {
2092
- className: "w-full",
2093
- children: /* @__PURE__ */ jsx(FieldsFromOptions, {
2094
- options: field.options ?? {},
2095
- setFormDirty,
2096
- setFieldValue,
2097
- setFieldTouched,
2098
- values,
2099
- parentInfo,
2100
- workflowForm,
2101
- labelPosition: meta.labelPosition,
2102
- spaceCompact: meta.spaceCompact,
2103
- missingFields
2104
- })
2105
- })
2106
- })
2107
- }, fieldObj["name"]);
2108
- }
2109
- if (typeof field.type === "object" && field.depends_on) {
2110
- const parentValue = getValueUsingPath(values, field.depends_on);
2111
- const resolvedType = field.type[String(parentValue)];
2112
- if (!resolvedType) return null;
2113
- fieldObj["type"] = resolvedType;
2114
- }
2115
- if (field.type === "range" && field.depends_on) {
2116
- const parentValue = getValueUsingPath(values, field.depends_on);
2117
- const { min, max } = field;
2118
- if (typeof min === "object" && typeof max === "object") {
2119
- fieldObj["min"] = min[String(parentValue)];
2120
- fieldObj["max"] = max[String(parentValue)];
2121
- }
2122
- }
2123
- if (field.resetOnChange) {
2124
- const parentValue = getValueUsingPath(values, field.resetOnChange);
2125
- const prevParentValue = field.prevParentValue;
2126
- if (prevParentValue !== void 0 && prevParentValue !== parentValue) deleteFieldByPath(values, fieldObj["name"]);
2127
- field.prevParentValue = parentValue;
2128
- }
2129
- if (field.secondaryField) {
2130
- if (Array.isArray(field.secondaryField)) fieldObj["secondaryField"] = field.secondaryField.map((secondaryField) => fieldNamePrefix + secondaryField);
2131
- else fieldObj["secondaryField"] = fieldNamePrefix + field.secondaryField;
2132
- }
2133
- return /* @__PURE__ */ jsx("div", {
2134
- className: cx("flex w-full", labelPosition === "left" ? "mb-[15px]" : "mb-[5px]"),
2135
- children: /* @__PURE__ */ jsx(InputField, {
2136
- field: fieldObj,
2137
- label: fieldObj["label"],
2138
- setFormDirty,
2139
- setFieldValue,
2140
- setFieldTouched,
2141
- values,
2142
- currentValue: getValueUsingPath(values, fieldObj["name"]),
2143
- onChange,
2144
- disabled: Boolean(fieldObj["disabled"]),
2145
- computeOn: parentInfo?.computeOn || fieldObj["computeOn"],
2146
- labelPosition,
2147
- missingFields,
2148
- spaceCompact,
2149
- workflowForm
2150
- })
2151
- }, `field-${id}`);
2152
- }, (prev, next) => {
2153
- if (!deepEqual(prev.optionsField, next.optionsField)) return false;
2154
- if (prev.values !== next.values) return false;
2155
- if (!deepEqual(prev.parentInfo, next.parentInfo)) return false;
2156
- if (!deepEqual(prev.missingFields, next.missingFields)) return false;
2157
- if (prev.labelPosition !== next.labelPosition) return false;
2158
- if (prev.spaceCompact !== next.spaceCompact) return false;
2159
- if (prev.workflowForm !== next.workflowForm) return false;
2160
- return true;
2161
- });
2162
- function FieldsFromOptions({ options = {}, values, setFormDirty, setFieldValue, setFieldTouched, parentInfo, labelPosition = "left", missingFields = [], spaceCompact = false, workflowForm = false }) {
2163
- return Object.keys(options).map((fieldName, idx) => /* @__PURE__ */ jsx(FormField, {
2164
- id: idx,
2165
- optionsField: options[fieldName],
2166
- fieldName,
2167
- values,
2168
- setFormDirty,
2169
- setFieldValue,
2170
- setFieldTouched,
2171
- parentInfo,
2172
- labelPosition,
2173
- missingFields,
2174
- spaceCompact,
2175
- workflowForm
2176
- }, fieldName));
2177
- }
2178
- var noop = () => {};
2179
- function DynamicFormContent({ options, setValues, setFormDirty, labelPosition, missingFields, spaceCompact, organizationVariables, remoteVars, workflowForm, onSubmit, submitLabel, values, contextKey }) {
2180
- const { setFieldValue, setFieldTouched } = useFormikContext();
2181
- const opts = useParsedOpts(options, values, organizationVariables, void 0, void 0, remoteVars);
2182
- const handleChange = useCallback((state) => {
2183
- if (setValues) setValues(state);
2184
- }, [setValues]);
2185
- const wizardConfig = parseWizardConfig(opts);
2186
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2187
- /* @__PURE__ */ jsx(DirtyStateBridge, { setFormDirty }),
2188
- /* @__PURE__ */ jsx(FormikStateBridge, { onChange: handleChange }),
2189
- /* @__PURE__ */ jsx(DynamicDefaultsSync, { options: opts }, contextKey ?? ""),
2190
- wizardConfig !== null && wizardConfig ? /* @__PURE__ */ jsx(WizardContainer, {
2191
- wizardConfig,
2192
- values,
2193
- onChange: handleChange,
2194
- onSubmit,
2195
- className: "w-full",
2196
- ...resolveMetaOverrides(options, labelPosition, spaceCompact),
2197
- missingFields,
2198
- workflowForm,
2199
- setFieldValue,
2200
- setFieldTouched
2201
- }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FieldsFromOptions, {
2202
- ...resolveMetaOverrides(options, labelPosition, spaceCompact),
2203
- options: opts,
2204
- values,
2205
- setFormDirty,
2206
- setFieldValue,
2207
- setFieldTouched,
2208
- missingFields,
2209
- workflowForm
2210
- }), onSubmit !== void 0 && !workflowForm && /* @__PURE__ */ jsx("div", {
2211
- className: "mt-4",
2212
- children: /* @__PURE__ */ jsx("input", {
2213
- type: "submit",
2214
- className: "btn btn-info",
2215
- value: submitLabel
2216
- })
2217
- })] })
2218
- ] });
2219
- }
2220
- var NO_FIELDS = {};
2221
- function DynamicForm({ formJSONs: options = {}, reinitialize = false, initialValues, setValues, setFormDirty = noop, formikRef, labelPosition = "left", missingFields = [], spaceCompact = false, organizationVariables, remoteVars, needsOrganizationVariables = false, onSubmit = void 0, submitLabel = "Submit", className = "w-full", workflowForm = false, contextKey, skipValueParse = false, fields = NO_FIELDS }) {
2222
- const engine = useWorkflowEngine();
2223
- const [parseReady, setParseReady] = useState(() => engine.isReady());
2224
- useEffect(() => {
2225
- engine.init();
2226
- return engine.onReady(setParseReady);
2227
- }, [engine]);
2228
- if (!parseReady) return /* @__PURE__ */ jsx(Loader, {});
2229
- const parsedInitVals = skipValueParse ? initialValues : initialValues && engine.evaluate({
2230
- inputs: initialValues,
2231
- obj: initialValues,
2232
- orgVars: organizationVariables,
2233
- remoteVars
2234
- });
2235
- return /* @__PURE__ */ jsx(FieldRegistryContext.Provider, {
2236
- value: fields,
2237
- children: /* @__PURE__ */ jsx("div", {
2238
- className,
2239
- children: (!needsOrganizationVariables || organizationVariables) && initialValues && /* @__PURE__ */ jsx(Formik, {
2240
- enableReinitialize: reinitialize,
2241
- initialValues: parsedInitVals,
2242
- onSubmit: onSubmit ?? (() => {}),
2243
- onReset: () => {
2244
- setFormDirty(false);
2245
- },
2246
- ...formikRef ? { innerRef: formikRef } : {},
2247
- children: ({ values }) => /* @__PURE__ */ jsx(Form, {
2248
- className: "w-full text-[13px]",
2249
- children: /* @__PURE__ */ jsx(DynamicFormContent, {
2250
- values,
2251
- options,
2252
- setValues,
2253
- setFormDirty,
2254
- labelPosition,
2255
- missingFields,
2256
- spaceCompact,
2257
- organizationVariables,
2258
- remoteVars,
2259
- workflowForm,
2260
- onSubmit,
2261
- submitLabel,
2262
- contextKey
2263
- })
2264
- })
2265
- })
2266
- })
2267
- });
2268
- }
2269
- //#endregion
2270
- //#region src/form/SpecialTypes/DropdownWrapper.tsx
2271
- function DropdownWrapper({ options, onChange, fieldObj, setFormDirty, invalid = false, loading = false, disabled = void 0, allowCustomValue = void 0, currentValue, setFieldValue, setFieldTouched }) {
2272
- return /* @__PURE__ */ jsx(FormikCustomDropdown_default, {
2273
- invalid,
2274
- className: "w-full",
2275
- onChange,
2276
- loading,
2277
- setFormDirty,
2278
- options,
2279
- disabled: disabled ?? Boolean(fieldObj.disabled),
2280
- placeholder: getPlaceholder(fieldObj.placeholder, typeof fieldObj.default === "string" ? fieldObj.default : void 0),
2281
- name: fieldObj.name ?? "",
2282
- ariaLabel: fieldObj.label,
2283
- parentValue: fieldObj.parentValue,
2284
- secondaryField: fieldObj.secondaryField,
2285
- resetOnChange: fieldObj.resetOnChange,
2286
- value: fieldObj.value,
2287
- autoselect: fieldObj.autoselect === void 0 ? void 0 : Boolean(fieldObj.autoselect),
2288
- allowCustomValue: allowCustomValue ?? fieldObj.allowCustomValue,
2289
- customValueLabel: fieldObj.customValueLabel,
2290
- currentValue,
2291
- setFieldValue,
2292
- setFieldTouched
2293
- });
2294
- }
2295
- //#endregion
2296
- //#region src/form/SpecialTypes/FormikMultiSelectDropdown.tsx
2297
- function FormikMultiSelectDropdown({ name, options, setFormDirty, onChange, disabled = false, loading = false, invalid = false, placeholder, compareBy }) {
2298
- const [field] = useField(name);
2299
- const required = useFieldRequired();
2300
- const labelledByProps = useFieldLabelledByProps();
2301
- const { setFieldValue, setFieldTouched } = useFormikContext();
2302
- const handleChange = (next) => {
2303
- setFieldValue(name, next);
2304
- setFieldTouched(name, true);
2305
- setFormDirty(true);
2306
- onChange?.(next);
2307
- };
2308
- return /* @__PURE__ */ jsx(MultiSelectDropdown, {
2309
- ...labelledByProps,
2310
- textBoxClassName: invalid ? "invalid" : void 0,
2311
- options,
2312
- required,
2313
- value: Array.isArray(field.value) ? field.value : [],
2314
- onChange: handleChange,
2315
- disabled,
2316
- loading,
2317
- placeholder,
2318
- compareBy
2319
- });
2320
- }
2321
- //#endregion
1
+ import { FieldProvider, useFieldControlProps, useFieldLabelledByProps, useFieldRequired } from "./fieldContext.js";
2
+ import { applySecondaryField, findSecondaryOption } from "./utils/secondaryField.js";
3
+ import { enforceOneMustBeTrue, flattenGroups, impureSetValueFromPath, initializeValues, resolvedFlag } from "./lib.js";
4
+ import { FieldWrapper } from "./FieldWrapper.js";
5
+ import { getInvalidDurationPaths, setDurationValidity } from "./Fields/durationValidity.js";
6
+ import FormikCustomDropdown_default from "./SpecialTypes/FormikCustomDropdown.js";
7
+ import FormikCustomInput from "./SpecialTypes/FormikCustomInput.js";
8
+ import FormikNumericInput from "./SpecialTypes/FormikNumericInput.js";
9
+ import { getPlaceholder } from "./utils/getPlaceholder.js";
10
+ import NumberField from "./Fields/NumberField.js";
11
+ import { ResourceOptionIcon } from "./Fields/ResourceOptionIcon.js";
12
+ import { FLEX_MAX_DURATION_RANGE, FLEX_WAIT_TIME_RANGE, STANDARD_MAX_DURATION_RANGE, collectPartitionDurationIssues, formatDuration, parseDuration } from "./utils/duration.js";
13
+ import { FieldRegistryContext, Registry } from "./fieldRegistry.js";
14
+ import { useParsedOpts } from "./useParsedOpts.js";
15
+ import { DynamicDefaultsSync, DynamicForm, FieldsFromOptions, GroupHeader, MultiSelectionDropdown, collectFieldsWithDefaults, findSelfReferencingFieldNames, resolveMetaOverrides, useDynamicDefaultsSync } from "./Form.js";
16
+ import DropdownWrapper from "./SpecialTypes/DropdownWrapper.js";
17
+ import FormikMultiSelectDropdown from "./SpecialTypes/FormikMultiSelectDropdown.js";
2322
18
  export { DropdownWrapper, DynamicDefaultsSync, DynamicForm, FLEX_MAX_DURATION_RANGE, FLEX_WAIT_TIME_RANGE, FieldProvider, FieldRegistryContext, FieldWrapper, FieldsFromOptions, FormikCustomDropdown_default as FormikCustomDropdown, FormikCustomInput, FormikMultiSelectDropdown, FormikNumericInput, GroupHeader, MultiSelectionDropdown, NumberField, Registry, ResourceOptionIcon, STANDARD_MAX_DURATION_RANGE, applySecondaryField, collectFieldsWithDefaults, collectPartitionDurationIssues, enforceOneMustBeTrue, findSecondaryOption, findSelfReferencingFieldNames, flattenGroups, formatDuration, getInvalidDurationPaths, getPlaceholder, impureSetValueFromPath, initializeValues, parseDuration, resolveMetaOverrides, resolvedFlag, setDurationValidity, useDynamicDefaultsSync, useFieldControlProps, useFieldLabelledByProps, useFieldRequired, useParsedOpts };