@parallelworks/ui 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -18
- package/dist/ai/agent/toolStrings.d.ts +2 -0
- package/dist/ai/agent/toolStrings.js +20 -18
- package/dist/ai/ai.css +12 -0
- package/dist/ai/components/AllocationSelector.js +5 -1
- package/dist/ai/components/AttachmentManager.js +51 -42
- package/dist/ai/components/AttachmentUpload.d.ts +4 -2
- package/dist/ai/components/AttachmentUpload.js +9 -9
- package/dist/ai/components/BlockedGroupBanner.js +8 -14
- package/dist/ai/components/BranchNavigator.js +11 -12
- package/dist/ai/components/ChatEmptyState.js +12 -19
- package/dist/ai/components/ChatInput.d.ts +4 -3
- package/dist/ai/components/ChatInput.js +27 -13
- package/dist/ai/components/ChatMessage.js +45 -121
- package/dist/ai/components/ChatMessageList.d.ts +5 -2
- package/dist/ai/components/ChatMessageList.js +89 -51
- package/dist/ai/components/ChatSidebar.js +11 -7
- package/dist/ai/components/ChatThread.js +1 -13
- package/dist/ai/components/DragOverlay.js +3 -3
- package/dist/ai/components/MessageAttachments.d.ts +10 -0
- package/dist/ai/components/MessageAttachments.js +78 -0
- package/dist/ai/components/ModelSelector.js +4 -4
- package/dist/ai/components/PastedText.js +2 -2
- package/dist/ai/components/ProviderIssueBanner.js +19 -23
- package/dist/ai/components/ShareDialog.js +2 -2
- package/dist/ai/components/agent/ActivityLine.d.ts +0 -2
- package/dist/ai/components/agent/ActivityLine.js +8 -51
- package/dist/ai/components/agent/AgentMessageParts.js +117 -56
- package/dist/ai/core/ChatProvider.d.ts +16 -5
- package/dist/ai/core/ChatProvider.js +41 -8
- package/dist/ai/core/config.js +4 -3
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +3 -3
- package/dist/ai/strings.d.ts +29 -3
- package/dist/ai/strings.js +81 -26
- package/dist/ai/types.d.ts +4 -0
- package/dist/ai/ui/Notice.d.ts +2 -2
- package/dist/ai/ui/Notice.js +29 -62
- package/dist/ai/ui/sidebar.d.ts +5 -3
- package/dist/ai/ui/sidebar.js +21 -9
- package/dist/components/ActionMenu.d.ts +1 -0
- package/dist/components/ActionMenu.js +6 -1
- package/dist/components/AppLink.d.ts +26 -0
- package/dist/components/AppLink.js +51 -0
- package/dist/components/Avatar.d.ts +2 -1
- package/dist/components/Avatar.js +4 -2
- package/dist/components/Button.d.ts +15 -5
- package/dist/components/Button.js +47 -40
- package/dist/components/Callout.d.ts +31 -7
- package/dist/components/Callout.js +51 -24
- package/dist/components/Card.d.ts +11 -6
- package/dist/components/Card.js +14 -8
- package/dist/components/Checkbox.js +2 -1
- package/dist/components/ColorInput.js +5 -3
- package/dist/components/Combobox.js +49 -19
- package/dist/components/ConfirmModal.d.ts +19 -8
- package/dist/components/ConfirmModal.js +31 -53
- package/dist/components/CopyButton.d.ts +38 -0
- package/dist/components/CopyButton.js +68 -0
- package/dist/components/CreateModal.js +118 -111
- package/dist/components/DatePicker.js +12 -8
- package/dist/components/DescriptionList.d.ts +51 -17
- package/dist/components/DescriptionList.js +117 -31
- package/dist/components/Disclosure.js +1 -1
- package/dist/components/Drawer.js +10 -16
- package/dist/components/Field.d.ts +15 -5
- package/dist/components/Field.js +41 -9
- package/dist/components/IconButton.d.ts +14 -5
- package/dist/components/IconButton.js +25 -14
- package/dist/components/InfoTip.d.ts +4 -1
- package/dist/components/InfoTip.js +2 -1
- package/dist/components/Input.d.ts +14 -8
- package/dist/components/Input.js +46 -31
- package/dist/components/Loader.js +1 -1
- package/dist/components/MenuEntries.d.ts +43 -12
- package/dist/components/MenuEntries.js +34 -19
- package/dist/components/Meter.js +5 -4
- package/dist/components/Modal.d.ts +28 -4
- package/dist/components/Modal.js +37 -14
- package/dist/components/Overview.d.ts +20 -12
- package/dist/components/Overview.js +14 -9
- package/dist/components/PageHeader.d.ts +47 -65
- package/dist/components/PageHeader.js +275 -153
- package/dist/components/PageHeaderAction.d.ts +67 -0
- package/dist/components/PageHeaderAction.js +107 -0
- package/dist/components/Pagination.js +6 -16
- package/dist/components/Popover.js +3 -2
- package/dist/components/Provider.d.ts +79 -19
- package/dist/components/Provider.js +140 -130
- package/dist/components/Radio.js +2 -1
- package/dist/components/RefreshButton.js +7 -8
- package/dist/components/RequiredMark.js +1 -1
- package/dist/components/RunStatusIcon.js +2 -2
- package/dist/components/Section.js +1 -1
- package/dist/components/Select.d.ts +4 -9
- package/dist/components/Select.js +24 -11
- package/dist/components/SettingModeOption.d.ts +1 -1
- package/dist/components/SettingModeOption.js +7 -1
- package/dist/components/SettingsCard.d.ts +5 -3
- package/dist/components/SettingsCard.js +27 -20
- package/dist/components/Slider.js +1 -1
- package/dist/components/StatusBadge.js +2 -2
- package/dist/components/StatusIcons.js +2 -2
- package/dist/components/Switch.js +5 -4
- package/dist/components/Table.d.ts +30 -20
- package/dist/components/Table.js +50 -73
- package/dist/components/Tabs.d.ts +3 -7
- package/dist/components/Tabs.js +6 -10
- package/dist/components/ThemeEditor.js +24 -14
- package/dist/components/Toast.d.ts +11 -3
- package/dist/components/Toast.js +47 -22
- package/dist/components/buttonClasses.js +2 -2
- package/dist/components/comboboxItems.d.ts +4 -0
- package/dist/components/comboboxItems.js +6 -1
- package/dist/components/dismiss.d.ts +12 -0
- package/dist/components/dismiss.js +19 -0
- package/dist/components/fieldBox.d.ts +4 -0
- package/dist/components/fieldBox.js +7 -3
- package/dist/components/floating.d.ts +3 -3
- package/dist/components/floating.js +1 -1
- package/dist/components/markdownCodeBreaks.js +3 -4
- package/dist/components/pageHeaderStore.d.ts +41 -0
- package/dist/components/pageHeaderStore.js +67 -0
- package/dist/components/pathBreaks.d.ts +8 -0
- package/dist/components/pathBreaks.js +28 -0
- package/dist/components/segmented.js +1 -1
- package/dist/components/shortcutKey.d.ts +2 -1
- package/dist/components/shortcutKey.js +19 -2
- package/dist/components/splitter.js +1 -1
- package/dist/components/tone.d.ts +5 -2
- package/dist/components/tone.js +15 -6
- package/dist/components/useCssIsDark.js +40 -18
- package/dist/components/useTheme.js +9 -10
- package/dist/dev.d.ts +9 -0
- package/dist/dev.js +14 -0
- package/dist/editor/Editor.d.ts +3 -2
- package/dist/editor/Editor.js +11 -2
- package/dist/editor/EditorField.d.ts +2 -1
- package/dist/editor/EditorField.js +11 -29
- package/dist/editor/FormCodePanel.d.ts +7 -3
- package/dist/editor/FormCodePanel.js +14 -7
- package/dist/editor/Monaco.d.ts +14 -5
- package/dist/editor/Monaco.js +163 -112
- package/dist/editor/index.d.ts +5 -5
- package/dist/editor/index.js +3 -3
- package/dist/editor/themes.d.ts +8 -5
- package/dist/editor/themes.js +58 -30
- package/dist/editor/yaml.d.ts +6 -2
- package/dist/editor/yaml.js +11 -2
- package/dist/file-explorer/FileExplorer.js +143 -124
- package/dist/file-explorer/FileExplorerContext.js +1 -1
- package/dist/file-explorer/FilePreview/StreamedBadge.js +3 -1
- package/dist/file-explorer/FilePreview/Viewer.js +2 -2
- package/dist/file-explorer/FilePreview/index.js +4 -4
- package/dist/file-explorer/FileRow.js +1 -1
- package/dist/file-explorer/FileRowsWindow.js +34 -3
- package/dist/file-explorer/FileTable.js +3 -1
- package/dist/file-explorer/TreeView.js +37 -14
- package/dist/file-explorer/helpers.d.ts +2 -1
- package/dist/file-explorer/helpers.js +21 -20
- package/dist/file-explorer/toasts.js +27 -19
- package/dist/file-explorer/treeRows.d.ts +6 -0
- package/dist/file-explorer/treeRows.js +19 -1
- package/dist/file-explorer/useNearEnd.js +3 -6
- package/dist/form/Fields/CheckboxGroupField.js +12 -5
- package/dist/form/Fields/DurationField.js +1 -1
- package/dist/form/Fields/LabelField.js +1 -1
- package/dist/form/Fields/ObjectField.d.ts +1 -1
- package/dist/form/Fields/ObjectField.js +3 -2
- package/dist/form/Fields/StringField.js +16 -29
- package/dist/form/Fields/TextAreaField.js +3 -4
- package/dist/form/Form.js +3 -8
- package/dist/form/Wizard/WizardNavigation.js +1 -4
- package/dist/form/Wizard/WizardStepIndicator.js +1 -1
- package/dist/form/Wizard/utils.js +1 -1
- package/dist/form/fieldFrame.d.ts +1 -1
- package/dist/form/fieldFrame.js +2 -2
- package/dist/form/types/fieldComponentTypes.d.ts +2 -1
- package/dist/graph/AnnotationBanner.d.ts +1 -2
- package/dist/graph/AnnotationBanner.js +30 -32
- package/dist/graph/Connectors.js +4 -1
- package/dist/graph/DependencyGraph.js +2 -2
- package/dist/graph/GraphEditor.js +12 -10
- package/dist/graph/GraphEditorDialogs.js +2 -2
- package/dist/graph/GraphNode.js +7 -4
- package/dist/graph/InputDialog.js +1 -1
- package/dist/graph/InputsEditor.js +14 -11
- package/dist/graph/MatrixGroup.js +9 -3
- package/dist/graph/ProblemsButton.js +2 -2
- package/dist/graph/Reveal.js +18 -10
- package/dist/graph/ShortcutsButton.d.ts +11 -2
- package/dist/graph/ShortcutsButton.js +15 -4
- package/dist/graph/TreeView.js +35 -18
- package/dist/graph/WorkflowSettingsDialog.js +1 -1
- package/dist/graph/editorChrome.js +1 -1
- package/dist/graph/editorFields.js +1 -1
- package/dist/graph/editorRows.js +16 -10
- package/dist/graph/editorStrings.d.ts +7 -0
- package/dist/graph/editorStrings.js +8 -1
- package/dist/graph/fieldProblems.js +1 -1
- package/dist/graph/inputRefs.js +1 -1
- package/dist/graph/settingsViews.js +11 -18
- package/dist/graph/stepWith.js +2 -2
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +4 -2
- package/dist/index.d.ts +12 -12
- package/dist/index.js +16 -16
- package/dist/list/ActionToolbar.d.ts +44 -8
- package/dist/list/ActionToolbar.js +301 -102
- package/dist/list/ListPage.d.ts +15 -23
- package/dist/list/ListPage.js +46 -45
- package/dist/list/ListTable.d.ts +32 -7
- package/dist/list/ListTable.js +48 -12
- package/dist/list/ListViewControls.js +2 -2
- package/dist/list/UserHoverCard.js +7 -15
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.js +2 -2
- package/dist/list/listSearch.js +12 -10
- package/dist/list/listView.d.ts +10 -1
- package/dist/list/listView.js +15 -1
- package/dist/list/rowMenu.d.ts +2 -2
- package/dist/logviewer/LogViewer.d.ts +4 -2
- package/dist/logviewer/LogViewer.js +88 -70
- package/dist/logviewer/logviewer.css +3 -2
- package/dist/reducedMotion.d.ts +5 -0
- package/dist/reducedMotion.js +20 -0
- package/dist/safeUrl.d.ts +1 -1
- package/dist/safeUrl.js +4 -2
- package/dist/styles/theme.css +24 -10
- package/dist/styles.css +1 -1
- package/dist/theme/derive.d.ts +1 -1
- package/dist/theme/derive.js +46 -21
- package/dist/theme/fit.js +10 -4
- package/package.json +1 -1
- package/dist/components/Breadcrumbs.d.ts +0 -37
- package/dist/components/Breadcrumbs.js +0 -90
- package/dist/components/CopyToClipboard.d.ts +0 -17
- package/dist/components/CopyToClipboard.js +0 -66
- package/dist/components/Sort.d.ts +0 -9
- package/dist/components/Sort.js +0 -42
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
//#region src/components/shortcutKey.ts
|
|
3
|
-
|
|
3
|
+
var KEYS_ARE_INPUT = [
|
|
4
|
+
".xterm",
|
|
5
|
+
".monaco-editor",
|
|
6
|
+
".cm-editor",
|
|
7
|
+
"select",
|
|
8
|
+
"[role=\"dialog\"]",
|
|
9
|
+
"[role=\"alertdialog\"]",
|
|
10
|
+
"[role=\"textbox\"]",
|
|
11
|
+
"[role=\"combobox\"]",
|
|
12
|
+
"[role=\"listbox\"]",
|
|
13
|
+
"[role=\"menu\"]",
|
|
14
|
+
"[role=\"menubar\"]",
|
|
15
|
+
"[role=\"tree\"]",
|
|
16
|
+
"[role=\"grid\"]"
|
|
17
|
+
].join(", ");
|
|
18
|
+
/** Guards page shortcuts from firing inside text fields, editors, dialogs, and
|
|
19
|
+
* widgets with typeahead such as menus, lists and trees. */
|
|
4
20
|
function isTextEntryContext(target) {
|
|
5
21
|
const el = target;
|
|
6
22
|
if (!el) return false;
|
|
7
23
|
if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.isContentEditable) return true;
|
|
8
|
-
return Boolean(el.closest?.(
|
|
24
|
+
return Boolean(el.closest?.(KEYS_ARE_INPUT));
|
|
9
25
|
}
|
|
10
26
|
/** Calls `onPress` on a single key, such as F to filter, unless the key goes to a text field. */
|
|
11
27
|
function useShortcutKey(key, onPress) {
|
|
@@ -14,6 +30,7 @@ function useShortcutKey(key, onPress) {
|
|
|
14
30
|
useEffect(() => {
|
|
15
31
|
if (!key) return;
|
|
16
32
|
const onKey = (e) => {
|
|
33
|
+
if (e.defaultPrevented || e.repeat || e.isComposing) return;
|
|
17
34
|
if (e.metaKey || e.ctrlKey || e.altKey || e.key.toLowerCase() !== key.toLowerCase()) return;
|
|
18
35
|
if (isTextEntryContext(e.target)) return;
|
|
19
36
|
e.preventDefault();
|
|
@@ -67,7 +67,7 @@ function useSplitter({ width, onWidthChange, min, max, side, defaultWidth, label
|
|
|
67
67
|
onPointerCancel: onPointerUp,
|
|
68
68
|
onKeyDown,
|
|
69
69
|
...defaultWidth === void 0 ? {} : { onDoubleClick: () => onWidthChange(defaultWidth) },
|
|
70
|
-
className: cx("absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none transition-colors focus-visible:bg-(--theme-
|
|
70
|
+
className: cx("absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none transition-colors focus-visible:bg-(--theme-focus) focus-visible:outline-none", side === "left" ? "-left-0.75" : "-right-0.75", live === null ? "hover:bg-(--theme-border)" : "bg-(--theme-accent)")
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/** How a status reads: its colors come from the theme's tone tokens, so every
|
|
2
|
-
* theme, dark ones included, sets them once.
|
|
2
|
+
* theme, dark ones included, sets them once. Words take a status's text shade,
|
|
3
|
+
* and icons and dots its vivid one, which only graphics' 3:1 holds. */
|
|
3
4
|
export type Tone = 'default' | 'success' | 'warning' | 'error' | 'info' | 'muted';
|
|
4
5
|
/** Text in the tone, for a status line beside a dot or icon. */
|
|
5
6
|
export declare const toneText: Record<Tone, string>;
|
|
7
|
+
/** An icon in the tone, through `currentColor`. */
|
|
8
|
+
export declare const toneIcon: Record<Tone, string>;
|
|
6
9
|
/** A tinted surface with a border and text in the tone, for a badge or a callout. */
|
|
7
10
|
export declare const toneSurface: Record<Tone, string>;
|
|
8
|
-
/** A solid fill in the tone, for a dot. */
|
|
11
|
+
/** A solid fill in the tone, for a dot or a bar. */
|
|
9
12
|
export declare const toneFill: Record<Tone, string>;
|
package/dist/components/tone.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
//#region src/components/tone.ts
|
|
2
2
|
/** Text in the tone, for a status line beside a dot or icon. */
|
|
3
3
|
var toneText = {
|
|
4
|
+
default: "text-(--theme-app)",
|
|
5
|
+
success: "text-(--theme-success-text)",
|
|
6
|
+
warning: "text-(--theme-warning-text)",
|
|
7
|
+
error: "text-(--theme-error-text)",
|
|
8
|
+
info: "text-(--theme-info-text)",
|
|
9
|
+
muted: "text-(--theme-muted-text-color)"
|
|
10
|
+
};
|
|
11
|
+
/** An icon in the tone, through `currentColor`. */
|
|
12
|
+
var toneIcon = {
|
|
4
13
|
default: "text-(--theme-app)",
|
|
5
14
|
success: "text-(--theme-success)",
|
|
6
15
|
warning: "text-(--theme-warning)",
|
|
@@ -11,13 +20,13 @@ var toneText = {
|
|
|
11
20
|
/** A tinted surface with a border and text in the tone, for a badge or a callout. */
|
|
12
21
|
var toneSurface = {
|
|
13
22
|
default: "bg-(--theme-muted-panel-bg) text-(--theme-app) border-(--theme-border)",
|
|
14
|
-
success: "bg-(--theme-success-muted) text-(--theme-success) border-(--theme-success)/25",
|
|
15
|
-
warning: "bg-(--theme-warning-muted) text-(--theme-warning) border-(--theme-warning)/25",
|
|
16
|
-
error: "bg-(--theme-error-muted) text-(--theme-error) border-(--theme-error)/25",
|
|
17
|
-
info: "bg-(--theme-info-muted) text-(--theme-info) border-(--theme-info)/25",
|
|
23
|
+
success: "bg-(--theme-success-muted) text-(--theme-success-text) border-(--theme-success)/25",
|
|
24
|
+
warning: "bg-(--theme-warning-muted) text-(--theme-warning-text) border-(--theme-warning)/25",
|
|
25
|
+
error: "bg-(--theme-error-muted) text-(--theme-error-text) border-(--theme-error)/25",
|
|
26
|
+
info: "bg-(--theme-info-muted) text-(--theme-info-text) border-(--theme-info)/25",
|
|
18
27
|
muted: "bg-(--theme-muted-panel-bg)/50 text-(--theme-muted-text-color) border-(--theme-border)"
|
|
19
28
|
};
|
|
20
|
-
/** A solid fill in the tone, for a dot. */
|
|
29
|
+
/** A solid fill in the tone, for a dot or a bar. */
|
|
21
30
|
var toneFill = {
|
|
22
31
|
default: "bg-(--theme-app)",
|
|
23
32
|
success: "bg-(--theme-success)",
|
|
@@ -27,4 +36,4 @@ var toneFill = {
|
|
|
27
36
|
muted: "bg-(--theme-muted-text-color)"
|
|
28
37
|
};
|
|
29
38
|
//#endregion
|
|
30
|
-
export { toneFill, toneSurface, toneText };
|
|
39
|
+
export { toneFill, toneIcon, toneSurface, toneText };
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
2
|
//#region src/components/useCssIsDark.ts
|
|
3
|
+
var DARK = "(prefers-color-scheme: dark)";
|
|
3
4
|
/** Whether the host's CSS color-scheme reads dark, falling back to the system preference. */
|
|
4
5
|
function readIsDark() {
|
|
6
|
+
if (typeof document === "undefined") return false;
|
|
5
7
|
const scheme = getComputedStyle(document.documentElement).colorScheme;
|
|
6
8
|
const dark = scheme.includes("dark");
|
|
7
9
|
if (dark !== scheme.includes("light")) return dark;
|
|
8
10
|
if (typeof window.matchMedia !== "function") return false;
|
|
9
|
-
return window.matchMedia(
|
|
11
|
+
return window.matchMedia(DARK).matches;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
14
|
+
var current = false;
|
|
15
|
+
var stop;
|
|
16
|
+
function refresh() {
|
|
17
|
+
const next = readIsDark();
|
|
18
|
+
if (next !== current) {
|
|
19
|
+
current = next;
|
|
20
|
+
for (const listener of listeners) listener();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function subscribe(listener) {
|
|
24
|
+
listeners.add(listener);
|
|
25
|
+
if (!stop) {
|
|
26
|
+
current = readIsDark();
|
|
27
|
+
const media = typeof window.matchMedia === "function" ? window.matchMedia(DARK) : void 0;
|
|
28
|
+
media?.addEventListener("change", refresh);
|
|
29
|
+
const observer = new MutationObserver(refresh);
|
|
23
30
|
observer.observe(document.documentElement, {
|
|
24
31
|
attributes: true,
|
|
25
32
|
attributeFilter: [
|
|
@@ -28,12 +35,27 @@ function useCssIsDark() {
|
|
|
28
35
|
"data-theme"
|
|
29
36
|
]
|
|
30
37
|
});
|
|
31
|
-
|
|
32
|
-
media?.removeEventListener("change",
|
|
38
|
+
stop = () => {
|
|
39
|
+
media?.removeEventListener("change", refresh);
|
|
33
40
|
observer.disconnect();
|
|
34
41
|
};
|
|
35
|
-
}
|
|
36
|
-
return
|
|
42
|
+
}
|
|
43
|
+
return () => {
|
|
44
|
+
listeners.delete(listener);
|
|
45
|
+
if (listeners.size === 0) {
|
|
46
|
+
stop?.();
|
|
47
|
+
stop = void 0;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var snapshot = () => stop ? current : readIsDark();
|
|
52
|
+
/**
|
|
53
|
+
* Follows the host's CSS color-scheme, the same signal the log viewer's
|
|
54
|
+
* light-dark() palette uses — no provider API involved. For the rare concrete
|
|
55
|
+
* pick (editor themes, image variants) the tokens cannot express.
|
|
56
|
+
*/
|
|
57
|
+
function useCssIsDark() {
|
|
58
|
+
return useSyncExternalStore(subscribe, snapshot, () => false);
|
|
37
59
|
}
|
|
38
60
|
//#endregion
|
|
39
61
|
export { readIsDark, useCssIsDark };
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { modeOf, resolveMode, schemeFor } from "../theme/model.js";
|
|
2
2
|
import { generateTheme } from "../theme/derive.js";
|
|
3
3
|
import { applyTheme } from "../theme/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useLayoutEffect, useSyncExternalStore } from "react";
|
|
5
5
|
//#region src/components/useTheme.ts
|
|
6
6
|
var DARK = "(prefers-color-scheme: dark)";
|
|
7
7
|
var prefersDark = () => typeof matchMedia === "function" && matchMedia(DARK).matches;
|
|
8
|
+
function subscribeToScheme(onChange) {
|
|
9
|
+
if (typeof matchMedia !== "function") return () => {};
|
|
10
|
+
const media = matchMedia(DARK);
|
|
11
|
+
media.addEventListener("change", onChange);
|
|
12
|
+
return () => media.removeEventListener("change", onChange);
|
|
13
|
+
}
|
|
14
|
+
var ignore = () => () => {};
|
|
8
15
|
/** The mode a preference shows now, following the device while it's `system`. */
|
|
9
16
|
function useColorMode(preference) {
|
|
10
|
-
const
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (preference !== "system" || typeof matchMedia !== "function") return;
|
|
13
|
-
const media = matchMedia(DARK);
|
|
14
|
-
const update = () => setDark(media.matches);
|
|
15
|
-
update();
|
|
16
|
-
media.addEventListener("change", update);
|
|
17
|
-
return () => media.removeEventListener("change", update);
|
|
18
|
-
}, [preference]);
|
|
17
|
+
const dark = useSyncExternalStore(preference === "system" ? subscribeToScheme : ignore, prefersDark, () => false);
|
|
19
18
|
return resolveMode(preference, dark);
|
|
20
19
|
}
|
|
21
20
|
/**
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the host runs a development build, for checks that warn about misuse and cost too much
|
|
3
|
+
* to run in production.
|
|
4
|
+
*
|
|
5
|
+
* It reads `process.env.NODE_ENV`, which the host's bundler replaces, so a production build drops
|
|
6
|
+
* the checks and a development build keeps them. Vite's `DEV` flag would not do: this
|
|
7
|
+
* package's own library build replaces it with `false`, so no host would ever see the warning.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isDev(): boolean;
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/dev.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether the host runs a development build, for checks that warn about misuse and cost too much
|
|
4
|
+
* to run in production.
|
|
5
|
+
*
|
|
6
|
+
* It reads `process.env.NODE_ENV`, which the host's bundler replaces, so a production build drops
|
|
7
|
+
* the checks and a development build keeps them. Vite's `DEV` flag would not do: this
|
|
8
|
+
* package's own library build replaces it with `false`, so no host would ever see the warning.
|
|
9
|
+
*/
|
|
10
|
+
function isDev() {
|
|
11
|
+
return process.env.NODE_ENV !== "production";
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { isDev };
|
package/dist/editor/Editor.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { EditorProps } from './Monaco.js';
|
|
2
|
+
/** A Monaco code editor, loaded on first render so Monaco stays out of the host's first bundle. */
|
|
3
|
+
export declare function Editor(props: EditorProps): import("react").JSX.Element;
|
package/dist/editor/Editor.js
CHANGED
|
@@ -3,11 +3,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Suspense, lazy } from "react";
|
|
4
4
|
//#region src/editor/Editor.tsx
|
|
5
5
|
var MonacoEditor = lazy(() => import("./Monaco.js"));
|
|
6
|
+
/** A Monaco code editor, loaded on first render so Monaco stays out of the host's first bundle. */
|
|
6
7
|
function Editor(props) {
|
|
8
|
+
const { width = "100%", height = "100%" } = props;
|
|
7
9
|
return /* @__PURE__ */ jsx(Suspense, {
|
|
8
|
-
fallback: /* @__PURE__ */ jsx(
|
|
10
|
+
fallback: /* @__PURE__ */ jsx("div", {
|
|
11
|
+
style: {
|
|
12
|
+
width,
|
|
13
|
+
height
|
|
14
|
+
},
|
|
15
|
+
className: "flex items-center justify-center",
|
|
16
|
+
children: /* @__PURE__ */ jsx(Loader, {})
|
|
17
|
+
}),
|
|
9
18
|
children: /* @__PURE__ */ jsx(MonacoEditor, { ...props })
|
|
10
19
|
});
|
|
11
20
|
}
|
|
12
21
|
//#endregion
|
|
13
|
-
export { Editor
|
|
22
|
+
export { Editor };
|
|
@@ -7,4 +7,5 @@ export interface IEditorField extends BaseField {
|
|
|
7
7
|
language?: string;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/** A form field that edits its value as code, in the language its `options` name (shell by default). */
|
|
11
|
+
export declare function EditorField(props: FieldComponentProps<IEditorField>): import("react").JSX.Element;
|
|
@@ -1,45 +1,27 @@
|
|
|
1
|
-
import { cx } from "../cx.js";
|
|
2
1
|
import { Field } from "../components/Field.js";
|
|
3
2
|
import { fieldFrame } from "../form/fieldFrame.js";
|
|
4
3
|
import { useFieldValue } from "../form/useFieldValue.js";
|
|
5
|
-
import Editor from "./Editor.js";
|
|
4
|
+
import { Editor } from "./Editor.js";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { useMemo, useRef } from "react";
|
|
8
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
9
6
|
//#region src/editor/EditorField.tsx
|
|
7
|
+
/** A form field that edits its value as code, in the language its `options` name (shell by default). */
|
|
10
8
|
function EditorField(props) {
|
|
11
9
|
const { field, label, disabled, onChange } = props;
|
|
12
|
-
const
|
|
13
|
-
const [value, change] = useFieldValue(fieldName);
|
|
14
|
-
const touchedRef = useRef(false);
|
|
15
|
-
const handleChange = (val) => {
|
|
16
|
-
touchedRef.current = true;
|
|
17
|
-
onChange?.(val);
|
|
18
|
-
change(val);
|
|
19
|
-
};
|
|
20
|
-
const { control } = useFormContext();
|
|
21
|
-
const resetKey = useWatch({
|
|
22
|
-
control,
|
|
23
|
-
name: "editorKeyPostfix"
|
|
24
|
-
});
|
|
25
|
-
const editorKeyPostfix = typeof resetKey === "string" ? resetKey : "";
|
|
26
|
-
const postfixKey = useMemo(() => {
|
|
27
|
-
const randomKey = Math.random().toString(36).substring(7);
|
|
28
|
-
return editorKeyPostfix || randomKey;
|
|
29
|
-
}, [editorKeyPostfix]);
|
|
10
|
+
const [value, change] = useFieldValue(field.name ?? "");
|
|
30
11
|
return /* @__PURE__ */ jsx(Field, {
|
|
31
12
|
...fieldFrame(props),
|
|
32
13
|
children: /* @__PURE__ */ jsx(Editor, {
|
|
33
14
|
ariaLabel: label,
|
|
34
15
|
height: "200px",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
value: value ?? "",
|
|
17
|
+
disabled,
|
|
18
|
+
onChange: (text) => {
|
|
19
|
+
onChange?.(text);
|
|
20
|
+
change(text);
|
|
21
|
+
},
|
|
40
22
|
language: field.options?.language || "shell"
|
|
41
|
-
}
|
|
23
|
+
})
|
|
42
24
|
});
|
|
43
25
|
}
|
|
44
26
|
//#endregion
|
|
45
|
-
export { EditorField
|
|
27
|
+
export { EditorField };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export interface FormCodePanelProps {
|
|
2
|
+
/** The form's input definitions, which say which values are sensitive or hidden. */
|
|
2
3
|
formJSON: Record<string, unknown>;
|
|
4
|
+
/** The form's values, shown as JSON. */
|
|
3
5
|
data: Record<string, unknown>;
|
|
6
|
+
/** Called with the values each time the JSON parses as an object. */
|
|
4
7
|
mutate: (values: Record<string, unknown>) => void;
|
|
5
8
|
height?: string;
|
|
6
9
|
disabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
10
|
+
}
|
|
11
|
+
/** A form's values as editable JSON, with sensitive and hidden fields left out unless asked for. */
|
|
12
|
+
export declare function FormCodePanel({ formJSON, data, mutate, height, disabled, }: FormCodePanelProps): import("react").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { useStrings, useWorkflowEngine } from "../components/Provider.js";
|
|
|
5
5
|
import { useCopy } from "../components/useCopy.js";
|
|
6
6
|
import { Switch } from "../components/Switch.js";
|
|
7
7
|
import { flattenGroups, impureSetValueFromPath } from "../form/lib.js";
|
|
8
|
-
import Editor from "./Editor.js";
|
|
8
|
+
import { Editor } from "./Editor.js";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { useRef, useState } from "react";
|
|
11
11
|
//#region src/editor/FormCodePanel.tsx
|
|
@@ -68,6 +68,7 @@ var populateFiltered = (filteredFields, data) => {
|
|
|
68
68
|
});
|
|
69
69
|
return data;
|
|
70
70
|
};
|
|
71
|
+
/** A form's values as editable JSON, with sensitive and hidden fields left out unless asked for. */
|
|
71
72
|
function FormCodePanel({ formJSON, data, mutate, height = "600px", disabled = false }) {
|
|
72
73
|
const engine = useWorkflowEngine();
|
|
73
74
|
const { common: t } = useStrings();
|
|
@@ -85,12 +86,14 @@ function FormCodePanel({ formJSON, data, mutate, height = "600px", disabled = fa
|
|
|
85
86
|
const filteredFieldsRef = useRef(filteredFields);
|
|
86
87
|
filteredFieldsRef.current = filteredFields;
|
|
87
88
|
const json = JSON.stringify(displayObj, null, 2);
|
|
89
|
+
const typedRef = useRef(null);
|
|
90
|
+
const shown = typedRef.current?.json === json ? typedRef.current.text : json;
|
|
88
91
|
const handleCopy = () => void copy(json, { quiet: true });
|
|
89
92
|
return /* @__PURE__ */ jsxs("div", {
|
|
90
93
|
style: { height },
|
|
91
94
|
className: "flex w-full flex-col gap-2",
|
|
92
95
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
93
|
-
className: cx("flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border", jsonHasErrors ? "border-
|
|
96
|
+
className: cx("flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border", jsonHasErrors ? "border-(--theme-error)" : "border-(--theme-border)"),
|
|
94
97
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
95
98
|
className: "bg-(--theme-muted-panel-bg) text-(--theme-muted-text-color) flex shrink-0 items-center gap-3 border-b border-(--theme-border) px-3 py-2",
|
|
96
99
|
children: [hasHiddenFields && /* @__PURE__ */ jsx(Tooltip, {
|
|
@@ -111,13 +114,13 @@ function FormCodePanel({ formJSON, data, mutate, height = "600px", disabled = fa
|
|
|
111
114
|
onClick: handleCopy,
|
|
112
115
|
"aria-label": copied ? t.copied : t.copy,
|
|
113
116
|
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)",
|
|
114
|
-
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, { className: "text-
|
|
117
|
+
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, { className: "text-(--theme-success)" }) : /* @__PURE__ */ jsx(CopyIcon, { className: "text-(--theme-muted-text-color)" }), copied ? t.copied : t.copy]
|
|
115
118
|
})]
|
|
116
119
|
}), /* @__PURE__ */ jsx("div", {
|
|
117
120
|
className: "min-h-0 flex-1",
|
|
118
121
|
children: /* @__PURE__ */ jsx(Editor, {
|
|
119
122
|
height: "100%",
|
|
120
|
-
value:
|
|
123
|
+
value: shown,
|
|
121
124
|
onValidate: isValidJson,
|
|
122
125
|
className: "!rounded-none !border-0",
|
|
123
126
|
minimap: { enabled: false },
|
|
@@ -140,7 +143,11 @@ function FormCodePanel({ formJSON, data, mutate, height = "600px", disabled = fa
|
|
|
140
143
|
try {
|
|
141
144
|
const parsed = JSON.parse(e);
|
|
142
145
|
if (!isObject(parsed)) return;
|
|
143
|
-
|
|
146
|
+
typedRef.current = {
|
|
147
|
+
text: e,
|
|
148
|
+
json: JSON.stringify(parsed, null, 2)
|
|
149
|
+
};
|
|
150
|
+
mutate(showHiddenRef.current ? parsed : populateFiltered(filteredFieldsRef.current, structuredClone(parsed)));
|
|
144
151
|
} catch {}
|
|
145
152
|
},
|
|
146
153
|
language: "json",
|
|
@@ -148,10 +155,10 @@ function FormCodePanel({ formJSON, data, mutate, height = "600px", disabled = fa
|
|
|
148
155
|
})
|
|
149
156
|
})]
|
|
150
157
|
}), jsonHasErrors && /* @__PURE__ */ jsx("p", {
|
|
151
|
-
className: "shrink-0 text-sm text-
|
|
158
|
+
className: "shrink-0 text-sm text-(--theme-error-text)",
|
|
152
159
|
children: t.jsonHasErrors
|
|
153
160
|
})]
|
|
154
161
|
});
|
|
155
162
|
}
|
|
156
163
|
//#endregion
|
|
157
|
-
export { FormCodePanel
|
|
164
|
+
export { FormCodePanel };
|
package/dist/editor/Monaco.d.ts
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import * as monaco from 'monaco-editor';
|
|
2
2
|
import { type NestedWorkflowText } from './nestedText.js';
|
|
3
|
-
|
|
3
|
+
/** A problem Monaco or the YAML service found in the text, as `onValidate` reports it. */
|
|
4
|
+
export type ValidationMarker = monaco.editor.IMarker;
|
|
4
5
|
/** A problem to mark on one line of the editor. */
|
|
5
6
|
export interface EditorMarker {
|
|
6
7
|
line: number;
|
|
7
8
|
message: string;
|
|
8
9
|
}
|
|
9
|
-
export interface
|
|
10
|
+
export interface EditorProps extends monaco.editor.IStandaloneEditorConstructionOptions {
|
|
10
11
|
className?: string;
|
|
12
|
+
/** Shows the text greyed out and read-only, as a disabled field does. */
|
|
11
13
|
disabled?: boolean | undefined;
|
|
14
|
+
/** The text as the person edits it, with carriage returns removed. */
|
|
12
15
|
onChange?: (value: string) => void;
|
|
13
|
-
|
|
16
|
+
/** Every marker on the text, each time they change: the schema's, the lint's and the host's. */
|
|
17
|
+
onValidate?: (markers: ValidationMarker[]) => void;
|
|
14
18
|
width?: string | number;
|
|
15
19
|
height?: string | number;
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The model's URI. A YAML schema registered with `configureEditorYaml` applies where its
|
|
22
|
+
* `fileMatch` matches this path, and `revealLines` finds the editor by it. Each editor gets one
|
|
23
|
+
* of its own when left out. It is read once: give the editor a `key` to edit another path.
|
|
24
|
+
*/
|
|
25
|
+
path?: string;
|
|
17
26
|
/** Apply outside `value` changes as undoable edits instead of resetting the undo history. */
|
|
18
27
|
preserveUndo?: boolean;
|
|
19
28
|
/** Checks a whole workflow for what the schema can't, such as needs read but never listed. */
|
|
@@ -23,4 +32,4 @@ export interface IEditorProps extends monaco.editor.IStandaloneEditorConstructio
|
|
|
23
32
|
/** Set when the text is one job or step, for completions that touch the rest of the workflow. */
|
|
24
33
|
nested?: NestedWorkflowText;
|
|
25
34
|
}
|
|
26
|
-
export default function MonacoEditor({ className, disabled, onChange, onValidate, width, height, path, preserveUndo, lint, markers, nested, ...options }:
|
|
35
|
+
export default function MonacoEditor({ className, disabled, onChange, onValidate, width, height, path: pathProp, preserveUndo, lint, markers, nested, value, language, ...options }: EditorProps): import("react").JSX.Element;
|