@parallelworks/ui 0.1.0 → 0.3.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 (146) hide show
  1. package/dist/assets/editor.worker-CuBRIwi-.js +14776 -0
  2. package/dist/assets/json.worker-8ytS02vz.js +22161 -0
  3. package/dist/assets/yaml.worker-DJC-VUcv.js +48367 -0
  4. package/dist/chunks/CodePreviewEditor-CSPRILMp.js +61 -0
  5. package/dist/chunks/Indicator-hBSIxOPK.js +39 -0
  6. package/dist/chunks/Loader-DQiZ75fa.js +25 -0
  7. package/dist/chunks/Markdown-C5Re2ezs.js +101 -0
  8. package/dist/chunks/MarkdownImpl-Bq4QhrtA.js +33 -0
  9. package/dist/chunks/Modal-sOUEwebV.js +121 -0
  10. package/dist/chunks/Monaco-CC4ak1JG.js +717 -0
  11. package/dist/chunks/Provider-DvVvScTQ.js +391 -0
  12. package/dist/chunks/StatusBadge-DXp4zkSd.js +46 -0
  13. package/dist/chunks/SwitchToggle-2uRw8ZeJ.js +725 -0
  14. package/dist/chunks/SwitchToggleSmall-FcsaYSTs.js +14 -0
  15. package/dist/chunks/Table-C5z6qWjM.js +91 -0
  16. package/dist/chunks/Tooltip-WgbiC_nd.js +71 -0
  17. package/dist/chunks/editor-D55tumuZ.js +372 -0
  18. package/dist/chunks/lib-DTgL8klR.js +191 -0
  19. package/dist/chunks/list-7PyDF1tz.js +465 -0
  20. package/dist/components/CollapsiblePanel.d.ts +27 -0
  21. package/dist/components/CopyToClipboard.d.ts +17 -0
  22. package/dist/components/Dropdown.d.ts +24 -0
  23. package/dist/components/Indicator.d.ts +4 -0
  24. package/dist/components/Listbox.d.ts +18 -0
  25. package/dist/components/Markdown.d.ts +7 -0
  26. package/dist/components/MarkdownImpl.d.ts +2 -0
  27. package/dist/components/MultiSelect.d.ts +19 -0
  28. package/dist/components/Overview.d.ts +12 -0
  29. package/dist/components/Provider.d.ts +438 -0
  30. package/dist/components/SectionHeader.d.ts +6 -0
  31. package/dist/components/SwitchToggle.d.ts +12 -0
  32. package/dist/components/SwitchToggleSmall.d.ts +6 -0
  33. package/dist/components/dropdownUtils.d.ts +18 -0
  34. package/dist/editor/Editor.d.ts +2 -0
  35. package/dist/editor/EditorField.d.ts +11 -0
  36. package/dist/editor/FormCodePanel.d.ts +8 -0
  37. package/dist/editor/Monaco.d.ts +31 -0
  38. package/dist/editor/index.d.ts +7 -0
  39. package/dist/editor/index.js +2 -0
  40. package/dist/editor/themes.d.ts +4 -0
  41. package/dist/editor/useCssIsDark.d.ts +6 -0
  42. package/dist/editor/workers.d.ts +6 -0
  43. package/dist/file-explorer/FileExplorer.d.ts +23 -0
  44. package/dist/file-explorer/FileExplorerContext.d.ts +17 -0
  45. package/dist/file-explorer/FilePreview/CodePreviewEditor.d.ts +6 -0
  46. package/dist/file-explorer/FilePreview/Inline.d.ts +13 -0
  47. package/dist/file-explorer/FilePreview/StreamedBadge.d.ts +1 -0
  48. package/dist/file-explorer/FilePreview/Viewer.d.ts +15 -0
  49. package/dist/file-explorer/FilePreview/index.d.ts +15 -0
  50. package/dist/file-explorer/FilePreview/parse.d.ts +24 -0
  51. package/dist/file-explorer/FilePreview/previewCache.d.ts +26 -0
  52. package/dist/file-explorer/FilePreview/previewType.d.ts +21 -0
  53. package/dist/file-explorer/FilePreview/readCappedBytes.d.ts +37 -0
  54. package/dist/file-explorer/FilePreview/useObjectBlobUrl.d.ts +16 -0
  55. package/dist/file-explorer/FilePreview/useObjectText.d.ts +23 -0
  56. package/dist/file-explorer/FilePreview/usePresignedUrl.d.ts +12 -0
  57. package/dist/file-explorer/FileRow.d.ts +35 -0
  58. package/dist/file-explorer/FileRowsWindow.d.ts +43 -0
  59. package/dist/file-explorer/FileTable.d.ts +26 -0
  60. package/dist/file-explorer/FileTableHeaders.d.ts +13 -0
  61. package/dist/file-explorer/LoadMoreRow.d.ts +15 -0
  62. package/dist/file-explorer/TreeView.d.ts +28 -0
  63. package/dist/file-explorer/helpers.d.ts +47 -0
  64. package/dist/file-explorer/index.d.ts +10 -0
  65. package/dist/file-explorer/index.js +5646 -0
  66. package/dist/file-explorer/lib/batch.d.ts +3 -0
  67. package/dist/file-explorer/lib/errors.d.ts +3 -0
  68. package/dist/file-explorer/lib/fileExplorer.d.ts +32 -0
  69. package/dist/file-explorer/lib/paging.d.ts +93 -0
  70. package/dist/file-explorer/lib/types.d.ts +92 -0
  71. package/dist/file-explorer/lib/utils.d.ts +37 -0
  72. package/dist/file-explorer/toasts.d.ts +9 -0
  73. package/dist/file-explorer/treeRows.d.ts +35 -0
  74. package/dist/file-explorer/useNearEnd.d.ts +7 -0
  75. package/dist/form/FieldWrapper.d.ts +10 -0
  76. package/dist/form/Fields/BooleanField.d.ts +12 -0
  77. package/dist/form/Fields/BucketReadOnlyField.d.ts +7 -0
  78. package/dist/form/Fields/CheckboxGroupField.d.ts +18 -0
  79. package/dist/form/Fields/ColorField.d.ts +8 -0
  80. package/dist/form/Fields/DropdownField.d.ts +24 -0
  81. package/dist/form/Fields/DurationField.d.ts +13 -0
  82. package/dist/form/Fields/LabelField.d.ts +9 -0
  83. package/dist/form/Fields/MultiDropdownField.d.ts +18 -0
  84. package/dist/form/Fields/NumberField.d.ts +13 -0
  85. package/dist/form/Fields/ObjectField.d.ts +8 -0
  86. package/dist/form/Fields/RadioField.d.ts +9 -0
  87. package/dist/form/Fields/RangeField.d.ts +11 -0
  88. package/dist/form/Fields/ResourceOptionIcon.d.ts +11 -0
  89. package/dist/form/Fields/StepField.d.ts +3 -0
  90. package/dist/form/Fields/StringField.d.ts +17 -0
  91. package/dist/form/Fields/TextAreaField.d.ts +8 -0
  92. package/dist/form/Fields/durationValidity.d.ts +2 -0
  93. package/dist/form/Form.d.ts +105 -0
  94. package/dist/form/SpecialTypes/DropdownWrapper.d.ts +14 -0
  95. package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +53 -0
  96. package/dist/form/SpecialTypes/FormikCustomInput.d.ts +17 -0
  97. package/dist/form/SpecialTypes/FormikMultiSelectDropdown.d.ts +13 -0
  98. package/dist/form/SpecialTypes/FormikNumericInput.d.ts +9 -0
  99. package/dist/form/SpecialTypes/index.d.ts +3 -0
  100. package/dist/form/Wizard/WizardContainer.d.ts +5 -0
  101. package/dist/form/Wizard/WizardNavigation.d.ts +2 -0
  102. package/dist/form/Wizard/WizardStepContent.d.ts +8 -0
  103. package/dist/form/Wizard/WizardStepIndicator.d.ts +2 -0
  104. package/dist/form/Wizard/types.d.ts +171 -0
  105. package/dist/form/Wizard/useWizardState.d.ts +28 -0
  106. package/dist/form/Wizard/utils.d.ts +2 -0
  107. package/dist/form/fieldRegistry.d.ts +7 -0
  108. package/dist/form/index.d.ts +16 -0
  109. package/dist/form/index.js +2319 -0
  110. package/dist/form/lib.d.ts +15 -0
  111. package/dist/form/types/fieldComponentTypes.d.ts +32 -0
  112. package/dist/form/types/fieldTypes.d.ts +80 -0
  113. package/dist/form/types/workflow-schema.d.ts +1107 -0
  114. package/dist/form/useParsedOpts.d.ts +5 -0
  115. package/dist/form/usePrevious.d.ts +1 -0
  116. package/dist/form/utils/checkShowIfObject.d.ts +1 -0
  117. package/dist/form/utils/getParentValue.d.ts +1 -0
  118. package/dist/form/utils/getPlaceholder.d.ts +2 -0
  119. package/dist/form/utils/getValueUsingPath.d.ts +1 -0
  120. package/dist/form/utils/pwResolver.d.ts +18 -0
  121. package/dist/form/utils/secondaryField.d.ts +8 -0
  122. package/dist/form/utils/slurmDuration.d.ts +15 -0
  123. package/dist/icons.d.ts +1 -1
  124. package/dist/icons.js +2 -2
  125. package/dist/index.d.ts +17 -0
  126. package/dist/index.js +42 -350
  127. package/dist/list/ListTable.d.ts +63 -0
  128. package/dist/list/RowContextMenu.d.ts +113 -0
  129. package/dist/list/index.d.ts +2 -0
  130. package/dist/list/index.js +2 -0
  131. package/dist/logviewer/LogViewer.d.ts +18 -0
  132. package/dist/logviewer/index.d.ts +1 -0
  133. package/dist/logviewer/index.js +534 -0
  134. package/dist/logviewer/logviewer.css +70 -0
  135. package/dist/styles/theme.css +30 -0
  136. package/dist/styles.css +1 -1
  137. package/dist/workflow/AnnotationBanner.d.ts +5 -0
  138. package/dist/workflow/Collapse.d.ts +6 -0
  139. package/dist/workflow/DependencyGraph.d.ts +15 -0
  140. package/dist/workflow/JobSummary.d.ts +38 -0
  141. package/dist/workflow/MatrixGroup.d.ts +41 -0
  142. package/dist/workflow/Reveal.d.ts +7 -0
  143. package/dist/workflow/TreeView.d.ts +42 -0
  144. package/dist/workflow/index.d.ts +1 -0
  145. package/dist/workflow/index.js +2331 -0
  146. package/package.json +71 -6
@@ -0,0 +1,14 @@
1
+ import cx from "classnames";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/components/SwitchToggleSmall.tsx
4
+ function SwitchToggleSmall({ value = false, disabled = false, className, ...buttonProps }) {
5
+ return /* @__PURE__ */ jsx("button", {
6
+ disabled,
7
+ ...buttonProps,
8
+ role: "switch",
9
+ "aria-checked": value,
10
+ className: cx("relative w-11 h-6 rounded-full transition-colors duration-400 ease-in-out", "before:content-[\"\"] before:absolute before:w-4 before:h-4 before:top-1 before:left-1", "before:bg-white before:rounded-full before:transition-transform before:duration-400 before:ease-in-out", disabled ? "bg-(--theme-border) cursor-not-allowed" : "cursor-pointer", !disabled && value ? "bg-(--theme-element) before:translate-x-5" : "bg-(--theme-border)", className)
11
+ });
12
+ }
13
+ //#endregion
14
+ export { SwitchToggleSmall as t };
@@ -0,0 +1,91 @@
1
+ import { t as Loader } from "./Loader-DQiZ75fa.js";
2
+ import cx from "classnames";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import React from "react";
5
+ //#region src/components/Table.tsx
6
+ function Item({ wrap = false, children, className, colspan = 1, ...tdProps }) {
7
+ const yPadding = className?.includes("py-") ? "" : "py-4";
8
+ const xPadding = className?.includes("px-") ? "" : "px-2";
9
+ return /* @__PURE__ */ jsx("td", {
10
+ ...tdProps,
11
+ colSpan: colspan,
12
+ className: cx(yPadding, xPadding, wrap ? "" : "whitespace-nowrap", className),
13
+ children
14
+ });
15
+ }
16
+ function CompactItem({ wrap = false, children, className, colspan = 1, ...tdProps }) {
17
+ return /* @__PURE__ */ jsx("td", {
18
+ ...tdProps,
19
+ colSpan: colspan,
20
+ className: cx("px-2 text-sm font-medium", !wrap && "whitespace-nowrap", className),
21
+ children
22
+ });
23
+ }
24
+ function Header({ children, className, style, colspan = 1, onClick, caps = true }) {
25
+ return /* @__PURE__ */ jsx("th", {
26
+ scope: "col",
27
+ colSpan: colspan,
28
+ style,
29
+ className: cx(className, className?.includes("py-") ? "" : "py-3", className?.includes("px-") ? "" : "px-3", className?.includes("text-") ? "" : "text-left", "text-xs font-medium", caps ? "uppercase tracking-wider" : "", onClick && "cursor-pointer hover:opacity-80 transition-opacity"),
30
+ onClick,
31
+ children
32
+ });
33
+ }
34
+ var isHeaderChild = (child) => {
35
+ if (!React.isValidElement(child)) return false;
36
+ return child.type === Header || typeof child.type === "function" && child.type.isTableHeader === true;
37
+ };
38
+ var getHeaders = (children) => children.filter(isHeaderChild);
39
+ function Table({ borderless = false, panel = true, className = "", wrapperClassName = "", tbodyClassName = "divide-y", theadClassName = "theme-muted-panel", children, roundedTop = false, rounded = false, roundedBottom = false, isLoading = false, tableProps }) {
40
+ const ChildrenArr = React.Children.toArray(children);
41
+ const Headers = getHeaders(ChildrenArr);
42
+ return /* @__PURE__ */ jsx("div", {
43
+ className: cx("flex flex-col w-full", !wrapperClassName.split(" ").some((cls) => cls.startsWith("overflow-")) && "overflow-hidden", wrapperClassName),
44
+ children: isLoading ? /* @__PURE__ */ jsx("div", {
45
+ className: "flex justify-center items-center h-32",
46
+ children: /* @__PURE__ */ jsx(Loader, {})
47
+ }) : /* @__PURE__ */ jsx("div", {
48
+ className: cx("align-middle inline-block min-w-full overflow-x-auto", panel && "theme-panel", !borderless && "border theme-border", rounded && "rounded-2xl", roundedBottom && "rounded-b-2xl", roundedTop && "rounded-t-2xl"),
49
+ children: /* @__PURE__ */ jsxs("table", {
50
+ className: cx(className, "min-w-full divide-y theme-border"),
51
+ ...tableProps,
52
+ children: [/* @__PURE__ */ jsx("thead", {
53
+ className: theadClassName,
54
+ children: /* @__PURE__ */ jsx("tr", { children: Headers })
55
+ }), /* @__PURE__ */ jsx("tbody", {
56
+ className: tbodyClassName,
57
+ children: ChildrenArr.filter((c) => !isHeaderChild(c))
58
+ })]
59
+ })
60
+ })
61
+ });
62
+ }
63
+ function CompactTable({ wrapperClassName = "", className = "", tbodyClassName = "divide-y", children, roundedTop = false, rounded = false, roundedBottom = false }) {
64
+ const ChildrenArr = React.Children.toArray(children);
65
+ const Headers = getHeaders(ChildrenArr);
66
+ return /* @__PURE__ */ jsx("div", {
67
+ className: cx("flex flex-col w-full", !wrapperClassName.split(" ").some((cls) => cls.startsWith("overflow-")) && "overflow-hidden", wrapperClassName),
68
+ children: /* @__PURE__ */ jsx("div", {
69
+ className: cx("theme-panel inline-block min-w-full align-middle overflow-x-auto", rounded && "rounded-2xl", roundedBottom && "rounded-b-2xl pb-1", roundedTop && "rounded-t-2xl"),
70
+ children: /* @__PURE__ */ jsxs("table", {
71
+ className: cx("min-w-full divide-y theme-border", className),
72
+ children: [/* @__PURE__ */ jsx("thead", {
73
+ className: "theme-muted-panel",
74
+ children: /* @__PURE__ */ jsx("tr", {
75
+ className: "divide-x",
76
+ children: Headers
77
+ })
78
+ }), /* @__PURE__ */ jsx("tbody", {
79
+ className: tbodyClassName,
80
+ children: ChildrenArr.filter((c) => !isHeaderChild(c))
81
+ })]
82
+ })
83
+ })
84
+ });
85
+ }
86
+ Table.Header = Header;
87
+ Table.Item = Item;
88
+ CompactTable.Header = Header;
89
+ CompactTable.Item = CompactItem;
90
+ //#endregion
91
+ export { Table as n, CompactTable as t };
@@ -0,0 +1,71 @@
1
+ import { TooltipIcon } from "../icons.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Fragment as Fragment$1 } from "react";
4
+ import { Tooltip } from "react-tooltip";
5
+ //#region src/components/Tooltip.tsx
6
+ var TOOLTIP_ID = "global-tooltip";
7
+ var linkRegex = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g;
8
+ function formatLine(line) {
9
+ const nodes = [];
10
+ let last = 0;
11
+ for (const match of line.matchAll(linkRegex)) {
12
+ if (match.index > last) nodes.push(line.slice(last, match.index));
13
+ nodes.push(/* @__PURE__ */ jsx("a", {
14
+ href: match[2],
15
+ target: "_blank",
16
+ rel: "noopener noreferrer",
17
+ className: "underline",
18
+ children: match[1]
19
+ }, match.index));
20
+ last = match.index + match[0].length;
21
+ }
22
+ if (last < line.length) nodes.push(line.slice(last));
23
+ return nodes;
24
+ }
25
+ /** Tooltip text can come from untrusted sources (workflow YAML), so all markup is literal text — only `[text](url)` links and newlines are parsed. */
26
+ function formatTooltipContent(content) {
27
+ if (typeof content !== "string") return content || null;
28
+ if (!content) return null;
29
+ return content.split(/<br\s*\/?>|\n/i).map((line, idx) => /* @__PURE__ */ jsxs(Fragment$1, { children: [idx > 0 && /* @__PURE__ */ jsx("br", {}), formatLine(line)] }, idx));
30
+ }
31
+ function KbdShortcut({ keys }) {
32
+ return /* @__PURE__ */ jsx("span", {
33
+ className: "inline-flex items-center gap-1 align-middle",
34
+ children: keys.split("+").map((part) => part.trim()).filter(Boolean).map((part, idx) => /* @__PURE__ */ jsxs(Fragment$1, { children: [idx > 0 && /* @__PURE__ */ jsx("span", {
35
+ className: "opacity-60 text-[11px]",
36
+ children: "+"
37
+ }), /* @__PURE__ */ jsx("kbd", {
38
+ className: "inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-white/30 bg-white/10 font-sans text-[11px] font-semibold leading-none",
39
+ children: part
40
+ })] }, `${part}-${idx}`))
41
+ });
42
+ }
43
+ /** Singleton rendered at layout root; anchors opt in via data-tooltip-id={TOOLTIP_ID}, data-tooltip-content, and data-tooltip-shortcut. */
44
+ function GlobalTooltip() {
45
+ return /* @__PURE__ */ jsx(Tooltip, {
46
+ id: TOOLTIP_ID,
47
+ className: "max-w-lg break-words config-tips normal-case text-left z-[10000]",
48
+ place: "top",
49
+ render: ({ content, activeAnchor }) => {
50
+ const body = formatTooltipContent(content);
51
+ const shortcut = activeAnchor?.getAttribute("data-tooltip-shortcut");
52
+ if (!shortcut) return body;
53
+ return /* @__PURE__ */ jsxs("span", {
54
+ className: "inline-flex items-center gap-2",
55
+ children: [body, /* @__PURE__ */ jsx(KbdShortcut, { keys: shortcut })]
56
+ });
57
+ }
58
+ });
59
+ }
60
+ function TooltipInfo({ text, className = "", children, place = "top", tabIndex }) {
61
+ return /* @__PURE__ */ jsx("div", {
62
+ "data-tooltip-id": TOOLTIP_ID,
63
+ "data-tooltip-content": text,
64
+ "data-tooltip-place": place,
65
+ className,
66
+ tabIndex,
67
+ children: children || /* @__PURE__ */ jsx(TooltipIcon, { className: "tooltip" })
68
+ });
69
+ }
70
+ //#endregion
71
+ export { formatTooltipContent as i, TOOLTIP_ID as n, TooltipInfo as r, GlobalTooltip as t };
@@ -0,0 +1,372 @@
1
+ import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon } from "../icons.js";
2
+ import { c as useStrings, i as useNotify } from "./Provider-DvVvScTQ.js";
3
+ import { t as Loader } from "./Loader-DQiZ75fa.js";
4
+ import { t as SwitchToggleSmall } from "./SwitchToggleSmall-FcsaYSTs.js";
5
+ import { c as FieldWrapper, n as flattenGroups, r as impureSetValueFromPath } from "./lib-DTgL8klR.js";
6
+ import cx from "classnames";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { Suspense, lazy, useEffect, useMemo, useRef, useState } from "react";
9
+ import { convertToDynamicForm, parseStringsOfObj, parseStringsOfObjReady } from "@parallelworks/workflow-parser";
10
+ import { useField, useFormikContext } from "formik";
11
+ //#region src/editor/Editor.tsx
12
+ var MonacoEditor = lazy(() => import("./Monaco-CC4ak1JG.js"));
13
+ function Editor({ ...props }) {
14
+ return /* @__PURE__ */ jsx(Suspense, {
15
+ fallback: /* @__PURE__ */ jsx(Loader, { text: "Loading editor..." }),
16
+ children: /* @__PURE__ */ jsx(MonacoEditor, { ...props })
17
+ });
18
+ }
19
+ //#endregion
20
+ //#region src/editor/EditorField.tsx
21
+ function hasResetKeys(obj) {
22
+ return obj.editorKeyPostfix !== void 0;
23
+ }
24
+ function EditorField(props) {
25
+ const { field, label, labelPosition, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
26
+ const [fieldState] = useField(field.name);
27
+ const { setFieldValue, setFieldTouched, values } = useFormikContext();
28
+ const debounceRef = useRef(null);
29
+ const touchedRef = useRef(false);
30
+ const handleChange = (val) => {
31
+ touchedRef.current = true;
32
+ if (debounceRef.current) clearTimeout(debounceRef.current);
33
+ debounceRef.current = setTimeout(() => {
34
+ if (onChange) onChange(val);
35
+ setFieldTouched(field.name, true);
36
+ setFieldValue(field.name, val);
37
+ setFormDirty(true);
38
+ }, 500);
39
+ };
40
+ let editorKeyPostfix = "";
41
+ if (hasResetKeys(values)) editorKeyPostfix = values.editorKeyPostfix;
42
+ const postfixKey = useMemo(() => {
43
+ const randomKey = Math.random().toString(36).substring(7);
44
+ return editorKeyPostfix || randomKey;
45
+ }, [editorKeyPostfix]);
46
+ const value = fieldState.value;
47
+ return /* @__PURE__ */ jsx(FieldWrapper, {
48
+ optional: field.optional,
49
+ label,
50
+ tooltipComponent,
51
+ labelPosition,
52
+ spaceCompact,
53
+ children: /* @__PURE__ */ jsx(Editor, {
54
+ height: "200px",
55
+ path: field.name,
56
+ value: touchedRef.current ? void 0 : value,
57
+ className: cx("bg-(--theme-input-bg) w-11 border focus:border rounded text-[10px] leading-4 pl-[6px]", disabled && "opacity-75"),
58
+ readOnly: disabled,
59
+ onChange: handleChange,
60
+ language: field.options?.language || "shell"
61
+ }, field.name + postfixKey)
62
+ });
63
+ }
64
+ //#endregion
65
+ //#region src/editor/FormCodePanel.tsx
66
+ var shouldIgnoreField = (fieldSchema, inputs, arrayIndex) => {
67
+ if (!fieldSchema?.ignore || !fieldSchema?.hidden) return false;
68
+ if (!parseStringsOfObjReady) return false;
69
+ return parseStringsOfObj({
70
+ inputs,
71
+ obj: convertToDynamicForm(fieldSchema),
72
+ index: arrayIndex ?? -1
73
+ }).hidden === true;
74
+ };
75
+ var filterFields = (formJSON, data, prefix, rootData, arrayIndex) => {
76
+ const filteredFields = [];
77
+ return {
78
+ filteredFields,
79
+ filtered: Object.keys(data).reduce((acc, key) => {
80
+ if (data[key] !== null && Array.isArray(data[key])) {
81
+ acc[key] = [];
82
+ if (!formJSON[key]) return acc;
83
+ for (let i = 0; i < data[key].length; i++) {
84
+ let filteredFieldsNested = [];
85
+ let filteredNested = {};
86
+ if (typeof data[key][i] === "object") {
87
+ const result = filterFields(formJSON[key].options, data[key][i], key + `[${i}].`, rootData || data, i);
88
+ filteredNested = result.filtered;
89
+ filteredFieldsNested = result.filteredFields;
90
+ } else filteredNested = data[key][i];
91
+ filteredFields.push(...filteredFieldsNested);
92
+ acc[key][i] = filteredNested;
93
+ }
94
+ return acc;
95
+ }
96
+ if (data[key] !== null && formJSON && formJSON[key] && typeof data[key] === "object") {
97
+ const { filteredFields: filteredFieldsNested, filtered: filteredNested } = filterFields(formJSON[key], data[key], key + ".", rootData || data, arrayIndex);
98
+ filteredFields.push(...filteredFieldsNested);
99
+ acc[key] = filteredNested;
100
+ return acc;
101
+ }
102
+ if (formJSON?.[key]?.sensitive) {
103
+ const name = prefix ? prefix + key : key;
104
+ filteredFields.push({
105
+ key: name,
106
+ value: data[key]
107
+ });
108
+ return acc;
109
+ }
110
+ const contextData = rootData || data;
111
+ if (formJSON && shouldIgnoreField(formJSON[key], contextData, arrayIndex)) return acc;
112
+ acc[key] = data[key];
113
+ return acc;
114
+ }, {})
115
+ };
116
+ };
117
+ var populateFiltered = (filteredFields, data) => {
118
+ filteredFields.forEach((element) => {
119
+ impureSetValueFromPath(data, element.key, element.value);
120
+ });
121
+ return data;
122
+ };
123
+ function FormCodePanel({ formJSON, data, mutate, height = "600px", disabled = false }) {
124
+ const notify = useNotify();
125
+ const { common: t } = useStrings();
126
+ const [jsonHasErrors, setJsonHasErrors] = useState(false);
127
+ const [showHidden, setShowHidden] = useState(false);
128
+ const [copied, setCopied] = useState(false);
129
+ const copyResetRef = useRef(void 0);
130
+ const isValidJson = (errors) => {
131
+ setJsonHasErrors(errors.length > 0);
132
+ };
133
+ const { filteredFields, filtered } = filterFields(flattenGroups(formJSON), data || {});
134
+ const hasHiddenFields = filteredFields.length > 0;
135
+ const displayObj = showHidden && hasHiddenFields ? populateFiltered(filteredFields, structuredClone(filtered)) : filtered;
136
+ const showHiddenRef = useRef(showHidden);
137
+ showHiddenRef.current = showHidden;
138
+ const filteredFieldsRef = useRef(filteredFields);
139
+ filteredFieldsRef.current = filteredFields;
140
+ const json = JSON.stringify(displayObj, null, 2);
141
+ const handleCopy = async () => {
142
+ try {
143
+ await navigator.clipboard.writeText(json);
144
+ setCopied(true);
145
+ clearTimeout(copyResetRef.current);
146
+ copyResetRef.current = setTimeout(() => setCopied(false), 2e3);
147
+ } catch {
148
+ notify.error(t.copyFailed);
149
+ }
150
+ };
151
+ return /* @__PURE__ */ jsxs("div", {
152
+ style: { height },
153
+ className: "flex w-full flex-col gap-2",
154
+ children: [/* @__PURE__ */ jsxs("div", {
155
+ className: cx("flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border", jsonHasErrors ? "border-red-500" : "border-(--theme-border)"),
156
+ children: [/* @__PURE__ */ jsxs("div", {
157
+ className: "bg-(--theme-muted-panel-bg) text-(--theme-muted-panel-color) flex shrink-0 items-center gap-3 border-b border-(--theme-border) px-3 py-2",
158
+ children: [hasHiddenFields && /* @__PURE__ */ jsxs("label", {
159
+ title: t.showHiddenFieldsHint,
160
+ className: "flex cursor-pointer select-none items-center gap-2 text-sm text-(--theme-app)",
161
+ children: [/* @__PURE__ */ jsx(SwitchToggleSmall, {
162
+ value: showHidden,
163
+ "aria-label": t.showHiddenFields,
164
+ onClick: () => setShowHidden((prev) => !prev)
165
+ }), /* @__PURE__ */ jsxs("span", {
166
+ className: "flex items-center gap-1.5",
167
+ children: [showHidden ? /* @__PURE__ */ jsx(EyeIcon, {}) : /* @__PURE__ */ jsx(EyeOffIcon, {}), t.showHiddenFields]
168
+ })]
169
+ }), /* @__PURE__ */ jsxs("button", {
170
+ type: "button",
171
+ onClick: handleCopy,
172
+ "aria-label": copied ? t.copied : t.copy,
173
+ className: "ml-auto flex shrink-0 items-center gap-1.5 rounded-md border border-(--theme-border) px-2.5 py-1.5 text-sm text-(--theme-app) transition-colors duration-150 hover:bg-(--theme-hover) focus:outline-none focus-visible:ring-2 focus-visible:ring-(--theme-link)",
174
+ children: [copied ? /* @__PURE__ */ jsx(CheckIcon, { className: "text-green-500" }) : /* @__PURE__ */ jsx(CopyIcon, { className: "text-(--theme-muted-text-color)" }), copied ? t.copied : t.copy]
175
+ })]
176
+ }), /* @__PURE__ */ jsx("div", {
177
+ className: "min-h-0 flex-1",
178
+ children: /* @__PURE__ */ jsx(Editor, {
179
+ height: "100%",
180
+ value: json,
181
+ onValidate: isValidJson,
182
+ className: "!rounded-none !border-0",
183
+ minimap: { enabled: false },
184
+ scrollBeyondLastLine: false,
185
+ overviewRulerLanes: 0,
186
+ overviewRulerBorder: false,
187
+ lineNumbersMinChars: 3,
188
+ lineDecorationsWidth: 8,
189
+ renderLineHighlight: "none",
190
+ padding: {
191
+ top: 12,
192
+ bottom: 12
193
+ },
194
+ fontSize: 13,
195
+ scrollbar: {
196
+ verticalScrollbarSize: 10,
197
+ horizontalScrollbarSize: 10
198
+ },
199
+ onChange: (e) => {
200
+ try {
201
+ const parsed = JSON.parse(e);
202
+ mutate(showHiddenRef.current ? parsed : populateFiltered(filteredFieldsRef.current, parsed));
203
+ } catch {
204
+ console.log("JSON.parse error in slurm editor");
205
+ }
206
+ },
207
+ language: "json",
208
+ disabled
209
+ })
210
+ })]
211
+ }), jsonHasErrors && /* @__PURE__ */ jsx("p", {
212
+ className: "shrink-0 text-sm text-red-500",
213
+ children: t.jsonHasErrors
214
+ })]
215
+ });
216
+ }
217
+ //#endregion
218
+ //#region src/editor/themes.ts
219
+ function expandShorthandHex(color) {
220
+ return /^#([0-9a-fA-F]{3,4})$/.test(color) ? "#" + color.slice(1).split("").map((c) => c + c).join("") : color;
221
+ }
222
+ function normalizeThemeColors(colors) {
223
+ return Object.fromEntries(Object.entries(colors).map(([key, value]) => [key, expandShorthandHex(value)]));
224
+ }
225
+ function themeVar(name, fallback) {
226
+ if (typeof window === "undefined") return fallback;
227
+ return getComputedStyle(document.documentElement).getPropertyValue(name).trim() || fallback;
228
+ }
229
+ function createEditorThemes() {
230
+ const dark = {
231
+ foreground: themeVar("--theme-app", "#e6edf3"),
232
+ background: themeVar("--theme-panel-bg", "#161b22"),
233
+ border: themeVar("--theme-border", "#30363d"),
234
+ lineHighlight: themeVar("--theme-muted-panel-bg", "#21262d"),
235
+ lineNumber: themeVar("--theme-muted-text-color", "#8b949e"),
236
+ selection: themeVar("--theme-element", "#2f81f7"),
237
+ selectionFg: themeVar("--theme-element-text", "#ffffff"),
238
+ disabledBg: themeVar("--theme-input-disabled-bg", "#1c2128"),
239
+ disabledFg: themeVar("--theme-muted-text-color", "#8b949e")
240
+ };
241
+ const light = {
242
+ disabledBg: themeVar("--theme-input-disabled-bg", "#f3f4f6"),
243
+ disabledFg: themeVar("--theme-muted-text-color", "#6c757d"),
244
+ border: themeVar("--theme-border", "#d1d5db"),
245
+ selection: themeVar("--theme-element", "#2f81f7"),
246
+ selectionFg: themeVar("--theme-element-text", "#ffffff")
247
+ };
248
+ return {
249
+ "app-dark": {
250
+ base: "vs-dark",
251
+ inherit: true,
252
+ rules: [],
253
+ colors: {
254
+ "editor.foreground": dark.foreground,
255
+ "editor.background": dark.background,
256
+ "editor.border": dark.border,
257
+ "editorCursor.foreground": dark.foreground,
258
+ "editor.lineHighlightBackground": dark.lineHighlight,
259
+ "editorLineNumber.foreground": dark.lineNumber,
260
+ "editor.selectionBackground": dark.selection,
261
+ "editor.selectionForeground": dark.selectionFg
262
+ }
263
+ },
264
+ "app-dark-disabled": {
265
+ base: "vs-dark",
266
+ inherit: true,
267
+ rules: [],
268
+ colors: {
269
+ "editor.foreground": dark.disabledFg,
270
+ "editor.background": dark.disabledBg,
271
+ "editor.border": dark.border,
272
+ "editorCursor.foreground": "transparent",
273
+ "editor.lineHighlightBackground": dark.disabledBg,
274
+ "editorLineNumber.foreground": dark.disabledFg,
275
+ "editor.selectionBackground": dark.selection,
276
+ "editor.selectionForeground": dark.selectionFg
277
+ }
278
+ },
279
+ "app-light-disabled": {
280
+ base: "vs",
281
+ inherit: true,
282
+ rules: [],
283
+ colors: {
284
+ "editor.foreground": light.disabledFg,
285
+ "editor.background": light.disabledBg,
286
+ "editor.border": light.border,
287
+ "editorCursor.foreground": "transparent",
288
+ "editor.lineHighlightBackground": light.disabledBg,
289
+ "editorLineNumber.foreground": light.disabledFg,
290
+ "editor.selectionBackground": light.selection,
291
+ "editor.selectionForeground": light.selectionFg
292
+ }
293
+ }
294
+ };
295
+ }
296
+ function defineEditorThemes(monacoEditor) {
297
+ const themes = createEditorThemes();
298
+ for (const [name, themeData] of Object.entries(themes)) monacoEditor.defineTheme(name, {
299
+ ...themeData,
300
+ colors: normalizeThemeColors(themeData.colors)
301
+ });
302
+ }
303
+ function getThemeName(isDark, disabled) {
304
+ if (isDark) return disabled ? "app-dark-disabled" : "app-dark";
305
+ return disabled ? "app-light-disabled" : "vs";
306
+ }
307
+ //#endregion
308
+ //#region src/editor/workers.ts
309
+ var monacoEnvironment = { getWorker(_moduleId, label) {
310
+ if (label === "json") return new Worker(new URL(
311
+ /* @vite-ignore */
312
+ "/assets/json.worker-8ytS02vz.js",
313
+ "" + import.meta.url
314
+ ), { type: "module" });
315
+ if (label === "yaml") return new Worker(new URL(
316
+ /* @vite-ignore */
317
+ "/assets/yaml.worker-DJC-VUcv.js",
318
+ "" + import.meta.url
319
+ ), { type: "module" });
320
+ return new Worker(new URL(
321
+ /* @vite-ignore */
322
+ "/assets/editor.worker-CuBRIwi-.js",
323
+ "" + import.meta.url
324
+ ), { type: "module" });
325
+ } };
326
+ /**
327
+ * Points window.MonacoEnvironment at the bundled workers. Idempotent, and a
328
+ * host that already configured its own MonacoEnvironment wins — the editor
329
+ * calls this on first load only when nothing is configured.
330
+ */
331
+ function setupMonacoWorkers() {
332
+ if (window.MonacoEnvironment) return;
333
+ window.MonacoEnvironment = monacoEnvironment;
334
+ }
335
+ //#endregion
336
+ //#region src/editor/useCssIsDark.ts
337
+ function readIsDark() {
338
+ const scheme = getComputedStyle(document.documentElement).colorScheme;
339
+ const dark = scheme.includes("dark");
340
+ if (dark !== scheme.includes("light")) return dark;
341
+ if (typeof window.matchMedia !== "function") return false;
342
+ return window.matchMedia("(prefers-color-scheme: dark)").matches;
343
+ }
344
+ /**
345
+ * Follows the host's CSS color-scheme, the same signal the log viewer's
346
+ * light-dark() palette uses — no provider API involved. For the rare concrete
347
+ * pick (editor themes, image variants) the tokens cannot express.
348
+ */
349
+ function useCssIsDark() {
350
+ const [isDark, setIsDark] = useState(readIsDark);
351
+ useEffect(() => {
352
+ const update = () => setIsDark(readIsDark());
353
+ const media = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
354
+ media?.addEventListener("change", update);
355
+ const observer = new MutationObserver(update);
356
+ observer.observe(document.documentElement, {
357
+ attributes: true,
358
+ attributeFilter: [
359
+ "style",
360
+ "class",
361
+ "data-theme"
362
+ ]
363
+ });
364
+ return () => {
365
+ media?.removeEventListener("change", update);
366
+ observer.disconnect();
367
+ };
368
+ }, []);
369
+ return isDark;
370
+ }
371
+ //#endregion
372
+ export { FormCodePanel as a, getThemeName as i, setupMonacoWorkers as n, EditorField as o, defineEditorThemes as r, Editor as s, useCssIsDark as t };