@uipath/apollo-wind 2.60.0 → 2.61.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 +13 -0
- package/dist/components/forms/field-actions.cjs +181 -0
- package/dist/components/forms/field-actions.d.ts +131 -0
- package/dist/components/forms/field-actions.js +129 -0
- package/dist/components/forms/field-control.cjs +415 -0
- package/dist/components/forms/field-control.d.ts +52 -0
- package/dist/components/forms/field-control.js +372 -0
- package/dist/components/forms/field-renderer.cjs +77 -420
- package/dist/components/forms/field-renderer.d.ts +2 -3
- package/dist/components/forms/field-renderer.js +78 -421
- package/dist/components/forms/form-designer.cjs +7 -1
- package/dist/components/forms/form-designer.js +7 -1
- package/dist/components/forms/form-schema.d.ts +121 -2
- package/dist/components/forms/form-strings.cjs +67 -0
- package/dist/components/forms/form-strings.d.ts +30 -0
- package/dist/components/forms/form-strings.js +30 -0
- package/dist/components/forms/index.cjs +53 -9
- package/dist/components/forms/index.d.ts +6 -1
- package/dist/components/forms/index.js +6 -1
- package/dist/components/forms/literal-value-context.cjs +37 -0
- package/dist/components/forms/literal-value-context.d.ts +5 -0
- package/dist/components/forms/literal-value-context.js +3 -0
- package/dist/components/forms/metadata-form.cjs +100 -21
- package/dist/components/forms/metadata-form.d.ts +5 -0
- package/dist/components/forms/metadata-form.js +101 -22
- package/dist/components/forms/mode-aware-field.cjs +589 -0
- package/dist/components/forms/mode-aware-field.d.ts +15 -0
- package/dist/components/forms/mode-aware-field.js +555 -0
- package/dist/components/forms/opaque-value.cjs +44 -0
- package/dist/components/forms/opaque-value.d.ts +7 -0
- package/dist/components/forms/opaque-value.js +7 -0
- package/dist/components/forms/rules-engine.cjs +13 -0
- package/dist/components/forms/rules-engine.js +13 -0
- package/dist/components/forms/schema-serializer.cjs +8 -0
- package/dist/components/forms/schema-serializer.js +8 -0
- package/dist/components/forms/string-list-field.cjs +36 -18
- package/dist/components/forms/string-list-field.d.ts +6 -0
- package/dist/components/forms/string-list-field.js +35 -20
- package/dist/components/forms/validation-converter.cjs +32 -2
- package/dist/components/forms/validation-converter.d.ts +17 -1
- package/dist/components/forms/validation-converter.js +30 -3
- package/dist/components/forms/value-modes.cjs +253 -0
- package/dist/components/forms/value-modes.d.ts +236 -0
- package/dist/components/forms/value-modes.js +180 -0
- package/dist/components/ui/accordion.cjs +1 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/avatar.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/boolean-radio-group.cjs +114 -0
- package/dist/components/ui/boolean-radio-group.d.ts +24 -0
- package/dist/components/ui/boolean-radio-group.js +77 -0
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts +7 -7
- package/dist/components/ui/dialog.cjs +1 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/drawer.cjs +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/field-addons/field-menu.cjs +1 -0
- package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
- package/dist/components/ui/field-addons/field-menu.js +1 -0
- package/dist/components/ui/field-addons/index.cjs +4 -0
- package/dist/components/ui/field-addons/index.d.ts +1 -0
- package/dist/components/ui/field-addons/index.js +2 -1
- package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
- package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
- package/dist/components/ui/form-field.cjs +2 -1
- package/dist/components/ui/form-field.d.ts +2 -0
- package/dist/components/ui/form-field.js +2 -1
- package/dist/components/ui/index.cjs +235 -191
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +4 -0
- package/dist/components/ui/input-group.cjs +6 -3
- package/dist/components/ui/input-group.d.ts +6 -5
- package/dist/components/ui/input-group.js +6 -3
- package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
- package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
- package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
- package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
- package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
- package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
- package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
- package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
- package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
- package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
- package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
- package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
- package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
- package/dist/components/ui/json-tree-view/RowActions.js +86 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
- package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
- package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
- package/dist/components/ui/json-tree-view/clipboard.js +29 -0
- package/dist/components/ui/json-tree-view/index.cjs +175 -0
- package/dist/components/ui/json-tree-view/index.d.ts +10 -0
- package/dist/components/ui/json-tree-view/index.js +11 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
- package/dist/components/ui/json-tree-view/strings.cjs +122 -0
- package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
- package/dist/components/ui/json-tree-view/strings.js +79 -0
- package/dist/components/ui/prompt-value-control.cjs +70 -0
- package/dist/components/ui/prompt-value-control.d.ts +28 -0
- package/dist/components/ui/prompt-value-control.js +36 -0
- package/dist/components/ui/sheet.cjs +2 -2
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/spinner.d.ts +1 -1
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/textarea.cjs +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/components/ui/variable-value-control.cjs +98 -0
- package/dist/components/ui/variable-value-control.d.ts +35 -0
- package/dist/components/ui/variable-value-control.js +64 -0
- package/dist/index.cjs +145 -16
- package/dist/index.d.ts +21 -3
- package/dist/index.js +11 -2
- package/dist/lib/index.cjs +4 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/utils.cjs +21 -1
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +18 -1
- package/dist/styles.css +278 -0
- package/dist/tailwind.css +72 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { JsonTreeNodeType } from './JsonTree.types';
|
|
3
|
+
export interface JsonTypeBadgeProps {
|
|
4
|
+
type: JsonTreeNodeType;
|
|
5
|
+
/** Replaces the default type icon (e.g. a paperclip for file nodes). */
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
/** Color/chrome overrides (e.g. from a node decoration). */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Tooltip content on hover. Defaults to the capitalized type name. */
|
|
10
|
+
tooltip?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compact badge for a JSON value type. Deliberately neutral: the value text
|
|
14
|
+
* carries the color coding, the badge only carries the type icon. Hovering it
|
|
15
|
+
* shows the type name (override via `tooltip`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function JsonTypeBadge({ type, icon, className, tooltip }: JsonTypeBadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../lib/index.js";
|
|
3
|
+
import { Braces, Brackets, CircleSlash2, Hash, ToggleLeft, Type } from "lucide-react";
|
|
4
|
+
import { JsonTreeTooltip } from "./JsonTreeTooltip.js";
|
|
5
|
+
const TYPE_ICON = {
|
|
6
|
+
string: Type,
|
|
7
|
+
number: Hash,
|
|
8
|
+
boolean: ToggleLeft,
|
|
9
|
+
object: Braces,
|
|
10
|
+
array: Brackets,
|
|
11
|
+
null: CircleSlash2
|
|
12
|
+
};
|
|
13
|
+
const TYPE_LABEL = {
|
|
14
|
+
string: 'String',
|
|
15
|
+
number: 'Number',
|
|
16
|
+
boolean: 'Boolean',
|
|
17
|
+
object: 'Object',
|
|
18
|
+
array: 'Array',
|
|
19
|
+
null: 'Null'
|
|
20
|
+
};
|
|
21
|
+
function JsonTypeBadge({ type, icon, className, tooltip }) {
|
|
22
|
+
const DefaultIcon = TYPE_ICON[type];
|
|
23
|
+
return /*#__PURE__*/ jsx(JsonTreeTooltip, {
|
|
24
|
+
content: /*#__PURE__*/ jsx("span", {
|
|
25
|
+
className: "break-all font-mono text-xs font-semibold leading-4",
|
|
26
|
+
children: tooltip ?? TYPE_LABEL[type]
|
|
27
|
+
}),
|
|
28
|
+
placement: "top",
|
|
29
|
+
delay: true,
|
|
30
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
31
|
+
className: cn('inline-flex h-4.5 min-w-4.5 shrink-0 items-center justify-center rounded border border-border bg-surface-overlay px-0.5 text-foreground-muted [&_svg]:size-2.75', className),
|
|
32
|
+
children: icon ?? /*#__PURE__*/ jsx(DefaultIcon, {})
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export { JsonTypeBadge };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
NodeKey: ()=>NodeKey
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
31
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
32
|
+
const external_JsonTreeTooltip_cjs_namespaceObject = require("./JsonTreeTooltip.cjs");
|
|
33
|
+
function NodeKey({ node, label, displayPath, onCopyPath, className }) {
|
|
34
|
+
const strings = (0, external_strings_cjs_namespaceObject.useJsonTreeViewStrings)();
|
|
35
|
+
const text = label ?? node.key;
|
|
36
|
+
const copyPathText = displayPath ?? node.path;
|
|
37
|
+
const keyClass = (0, index_cjs_namespaceObject.cn)('min-w-4 max-w-[45%] truncate text-xs text-foreground', null != label ? 'font-medium' : 'font-mono', void 0 === node.value && 'text-foreground-muted', className);
|
|
38
|
+
if (!onCopyPath) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
39
|
+
className: keyClass,
|
|
40
|
+
children: text
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeTooltip_cjs_namespaceObject.JsonTreeTooltip, {
|
|
43
|
+
placement: "top",
|
|
44
|
+
delay: true,
|
|
45
|
+
content: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
46
|
+
className: "flex max-w-60 flex-col gap-1",
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
49
|
+
className: "break-all font-mono text-xs font-semibold leading-4",
|
|
50
|
+
children: copyPathText
|
|
51
|
+
}),
|
|
52
|
+
node.schema?.description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
53
|
+
className: "text-xs leading-4",
|
|
54
|
+
children: node.schema.description
|
|
55
|
+
}),
|
|
56
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
57
|
+
className: "text-[11px] leading-4 opacity-70",
|
|
58
|
+
children: strings.copyPathHint
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
}),
|
|
62
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
63
|
+
type: "button",
|
|
64
|
+
onClick: ()=>onCopyPath(node),
|
|
65
|
+
"aria-label": strings.copyPathFor(copyPathText),
|
|
66
|
+
className: (0, index_cjs_namespaceObject.cn)(keyClass, 'cursor-pointer decoration-foreground-subtle underline-offset-2 hover:underline'),
|
|
67
|
+
children: text
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.NodeKey = __webpack_exports__.NodeKey;
|
|
72
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
73
|
+
"NodeKey"
|
|
74
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
75
|
+
Object.defineProperty(exports, '__esModule', {
|
|
76
|
+
value: true
|
|
77
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonTreeNode } from './JsonTree.types';
|
|
2
|
+
export interface NodeKeyProps {
|
|
3
|
+
node: JsonTreeNode;
|
|
4
|
+
/** Display text overriding the raw key (decoration label). */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** The path as it will be copied (after `pathForCopy`); shown in the tooltip. */
|
|
7
|
+
displayPath?: string;
|
|
8
|
+
onCopyPath?: (node: JsonTreeNode) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The field name. Hovering underlines it and (after a short delay) shows a
|
|
13
|
+
* popover titled with the node's full tree path, plus the schema description
|
|
14
|
+
* and a copy hint; clicking copies the path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function NodeKey({ node, label, displayPath, onCopyPath, className }: NodeKeyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../lib/index.js";
|
|
3
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
4
|
+
import { JsonTreeTooltip } from "./JsonTreeTooltip.js";
|
|
5
|
+
function NodeKey({ node, label, displayPath, onCopyPath, className }) {
|
|
6
|
+
const strings = useJsonTreeViewStrings();
|
|
7
|
+
const text = label ?? node.key;
|
|
8
|
+
const copyPathText = displayPath ?? node.path;
|
|
9
|
+
const keyClass = cn('min-w-4 max-w-[45%] truncate text-xs text-foreground', null != label ? 'font-medium' : 'font-mono', void 0 === node.value && 'text-foreground-muted', className);
|
|
10
|
+
if (!onCopyPath) return /*#__PURE__*/ jsx("span", {
|
|
11
|
+
className: keyClass,
|
|
12
|
+
children: text
|
|
13
|
+
});
|
|
14
|
+
return /*#__PURE__*/ jsx(JsonTreeTooltip, {
|
|
15
|
+
placement: "top",
|
|
16
|
+
delay: true,
|
|
17
|
+
content: /*#__PURE__*/ jsxs("div", {
|
|
18
|
+
className: "flex max-w-60 flex-col gap-1",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx("span", {
|
|
21
|
+
className: "break-all font-mono text-xs font-semibold leading-4",
|
|
22
|
+
children: copyPathText
|
|
23
|
+
}),
|
|
24
|
+
node.schema?.description && /*#__PURE__*/ jsx("span", {
|
|
25
|
+
className: "text-xs leading-4",
|
|
26
|
+
children: node.schema.description
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ jsx("span", {
|
|
29
|
+
className: "text-[11px] leading-4 opacity-70",
|
|
30
|
+
children: strings.copyPathHint
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
onClick: ()=>onCopyPath(node),
|
|
37
|
+
"aria-label": strings.copyPathFor(copyPathText),
|
|
38
|
+
className: cn(keyClass, 'cursor-pointer decoration-foreground-subtle underline-offset-2 hover:underline'),
|
|
39
|
+
children: text
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export { NodeKey };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
RowActions: ()=>RowActions
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_button_cjs_namespaceObject = require("../button.cjs");
|
|
31
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
32
|
+
const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
|
|
33
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
34
|
+
const external_react_namespaceObject = require("react");
|
|
35
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
36
|
+
const external_JsonTreeTooltip_cjs_namespaceObject = require("./JsonTreeTooltip.cjs");
|
|
37
|
+
const ACTION_BUTTON_CLASS = 'shrink-0 rounded text-foreground-subtle opacity-0 hover:text-foreground hover:bg-surface-raised group-hover:opacity-100 focus-visible:opacity-100';
|
|
38
|
+
const ACTION_TONE_CLASS = {
|
|
39
|
+
neutral: '',
|
|
40
|
+
info: 'text-info hover:text-info',
|
|
41
|
+
warning: 'text-warning hover:text-warning',
|
|
42
|
+
error: 'text-error hover:text-error'
|
|
43
|
+
};
|
|
44
|
+
function RowActions({ node, actions, maxInline }) {
|
|
45
|
+
const strings = (0, external_strings_cjs_namespaceObject.useJsonTreeViewStrings)();
|
|
46
|
+
const [menuOpen, setMenuOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
47
|
+
if (0 === actions.length) return null;
|
|
48
|
+
const overflowing = actions.length > maxInline;
|
|
49
|
+
const inline = overflowing ? [] : actions;
|
|
50
|
+
const overflow = overflowing ? actions : [];
|
|
51
|
+
const moreLabel = strings.moreActions;
|
|
52
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
53
|
+
className: "ml-auto flex shrink-0 items-center gap-0.5",
|
|
54
|
+
children: [
|
|
55
|
+
inline.map((action)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeTooltip_cjs_namespaceObject.JsonTreeTooltip, {
|
|
56
|
+
content: action.tooltip ?? action.label,
|
|
57
|
+
placement: "top",
|
|
58
|
+
delay: true,
|
|
59
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
60
|
+
variant: "ghost",
|
|
61
|
+
size: "4xs",
|
|
62
|
+
icon: true,
|
|
63
|
+
disabled: action.disabled,
|
|
64
|
+
onClick: ()=>action.onSelect(node),
|
|
65
|
+
"aria-label": action.label,
|
|
66
|
+
className: (0, index_cjs_namespaceObject.cn)(ACTION_BUTTON_CLASS, '[&_svg]:size-2.75', action.tone && ACTION_TONE_CLASS[action.tone], action.active && 'text-brand opacity-100 hover:text-brand'),
|
|
67
|
+
children: action.icon
|
|
68
|
+
})
|
|
69
|
+
}, action.id)),
|
|
70
|
+
overflow.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
|
|
71
|
+
open: menuOpen,
|
|
72
|
+
onOpenChange: setMenuOpen,
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeTooltip_cjs_namespaceObject.JsonTreeTooltip, {
|
|
75
|
+
content: moreLabel,
|
|
76
|
+
placement: "top",
|
|
77
|
+
delay: true,
|
|
78
|
+
hide: menuOpen,
|
|
79
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
|
|
80
|
+
asChild: true,
|
|
81
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
82
|
+
variant: "ghost",
|
|
83
|
+
size: "4xs",
|
|
84
|
+
icon: true,
|
|
85
|
+
"aria-label": moreLabel,
|
|
86
|
+
className: (0, index_cjs_namespaceObject.cn)(ACTION_BUTTON_CLASS, '[&_svg]:size-2.75', menuOpen && 'opacity-100'),
|
|
87
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.MoreHorizontal, {})
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
92
|
+
side: "left",
|
|
93
|
+
align: "start",
|
|
94
|
+
sideOffset: -12,
|
|
95
|
+
className: "min-w-40",
|
|
96
|
+
children: overflow.map((action)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
97
|
+
disabled: action.disabled,
|
|
98
|
+
onClick: ()=>action.onSelect(node),
|
|
99
|
+
className: (0, index_cjs_namespaceObject.cn)('gap-2 text-xs', 'error' === action.tone && 'text-error'),
|
|
100
|
+
children: [
|
|
101
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
102
|
+
className: "grid size-3.5 shrink-0 place-items-center [&_svg]:size-3.5",
|
|
103
|
+
children: action.icon
|
|
104
|
+
}),
|
|
105
|
+
action.label
|
|
106
|
+
]
|
|
107
|
+
}, action.id))
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.RowActions = __webpack_exports__.RowActions;
|
|
115
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
116
|
+
"RowActions"
|
|
117
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
118
|
+
Object.defineProperty(exports, '__esModule', {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JsonTreeNode, NodeAction } from './JsonTree.types';
|
|
2
|
+
export interface RowActionsProps {
|
|
3
|
+
node: JsonTreeNode;
|
|
4
|
+
/** Resolved actions for the row, in display order. */
|
|
5
|
+
actions: NodeAction[];
|
|
6
|
+
/** When the action count exceeds this cap, all actions collapse into one menu. */
|
|
7
|
+
maxInline: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The trailing icon-button group for a row. Renders `actions` uniformly (icon,
|
|
11
|
+
* tooltip, aria, tone, active highlight). Up to `maxInline` actions render
|
|
12
|
+
* inline; when the count exceeds that cap, every action moves into one menu so
|
|
13
|
+
* the row has a single, predictable overflow state.
|
|
14
|
+
*/
|
|
15
|
+
export declare function RowActions({ node, actions, maxInline }: RowActionsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "../button.js";
|
|
3
|
+
import { cn } from "../../../lib/index.js";
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu.js";
|
|
5
|
+
import { MoreHorizontal } from "lucide-react";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
8
|
+
import { JsonTreeTooltip } from "./JsonTreeTooltip.js";
|
|
9
|
+
const ACTION_BUTTON_CLASS = 'shrink-0 rounded text-foreground-subtle opacity-0 hover:text-foreground hover:bg-surface-raised group-hover:opacity-100 focus-visible:opacity-100';
|
|
10
|
+
const ACTION_TONE_CLASS = {
|
|
11
|
+
neutral: '',
|
|
12
|
+
info: 'text-info hover:text-info',
|
|
13
|
+
warning: 'text-warning hover:text-warning',
|
|
14
|
+
error: 'text-error hover:text-error'
|
|
15
|
+
};
|
|
16
|
+
function RowActions({ node, actions, maxInline }) {
|
|
17
|
+
const strings = useJsonTreeViewStrings();
|
|
18
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
19
|
+
if (0 === actions.length) return null;
|
|
20
|
+
const overflowing = actions.length > maxInline;
|
|
21
|
+
const inline = overflowing ? [] : actions;
|
|
22
|
+
const overflow = overflowing ? actions : [];
|
|
23
|
+
const moreLabel = strings.moreActions;
|
|
24
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
25
|
+
className: "ml-auto flex shrink-0 items-center gap-0.5",
|
|
26
|
+
children: [
|
|
27
|
+
inline.map((action)=>/*#__PURE__*/ jsx(JsonTreeTooltip, {
|
|
28
|
+
content: action.tooltip ?? action.label,
|
|
29
|
+
placement: "top",
|
|
30
|
+
delay: true,
|
|
31
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
32
|
+
variant: "ghost",
|
|
33
|
+
size: "4xs",
|
|
34
|
+
icon: true,
|
|
35
|
+
disabled: action.disabled,
|
|
36
|
+
onClick: ()=>action.onSelect(node),
|
|
37
|
+
"aria-label": action.label,
|
|
38
|
+
className: cn(ACTION_BUTTON_CLASS, '[&_svg]:size-2.75', action.tone && ACTION_TONE_CLASS[action.tone], action.active && 'text-brand opacity-100 hover:text-brand'),
|
|
39
|
+
children: action.icon
|
|
40
|
+
})
|
|
41
|
+
}, action.id)),
|
|
42
|
+
overflow.length > 0 && /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
43
|
+
open: menuOpen,
|
|
44
|
+
onOpenChange: setMenuOpen,
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ jsx(JsonTreeTooltip, {
|
|
47
|
+
content: moreLabel,
|
|
48
|
+
placement: "top",
|
|
49
|
+
delay: true,
|
|
50
|
+
hide: menuOpen,
|
|
51
|
+
children: /*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
52
|
+
asChild: true,
|
|
53
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
54
|
+
variant: "ghost",
|
|
55
|
+
size: "4xs",
|
|
56
|
+
icon: true,
|
|
57
|
+
"aria-label": moreLabel,
|
|
58
|
+
className: cn(ACTION_BUTTON_CLASS, '[&_svg]:size-2.75', menuOpen && 'opacity-100'),
|
|
59
|
+
children: /*#__PURE__*/ jsx(MoreHorizontal, {})
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
64
|
+
side: "left",
|
|
65
|
+
align: "start",
|
|
66
|
+
sideOffset: -12,
|
|
67
|
+
className: "min-w-40",
|
|
68
|
+
children: overflow.map((action)=>/*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
69
|
+
disabled: action.disabled,
|
|
70
|
+
onClick: ()=>action.onSelect(node),
|
|
71
|
+
className: cn('gap-2 text-xs', 'error' === action.tone && 'text-error'),
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ jsx("span", {
|
|
74
|
+
className: "grid size-3.5 shrink-0 place-items-center [&_svg]:size-3.5",
|
|
75
|
+
children: action.icon
|
|
76
|
+
}),
|
|
77
|
+
action.label
|
|
78
|
+
]
|
|
79
|
+
}, action.id))
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export { RowActions };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
valueColorClass: ()=>valueColorClass,
|
|
28
|
+
ScalarValueCell: ()=>ScalarValueCell
|
|
29
|
+
});
|
|
30
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
32
|
+
const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
|
|
33
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
34
|
+
const external_buildJsonTree_cjs_namespaceObject = require("./buildJsonTree.cjs");
|
|
35
|
+
const external_JsonLeafValueEditor_cjs_namespaceObject = require("./JsonLeafValueEditor.cjs");
|
|
36
|
+
function valueColorClass(type, value) {
|
|
37
|
+
if (null == value) return 'text-foreground-subtle';
|
|
38
|
+
if ('string' === type) return 'text-success';
|
|
39
|
+
if ('number' === type) return 'text-info';
|
|
40
|
+
if ('boolean' === type) return value ? 'text-success' : 'text-error';
|
|
41
|
+
return 'text-foreground';
|
|
42
|
+
}
|
|
43
|
+
const VALUE_CELL_CLASS = 'min-w-0 truncate rounded font-mono text-xs transition hover:bg-surface-raised';
|
|
44
|
+
function ScalarValueCell({ node, readOnly, editing, onStartEdit, onStopEdit, onEdit }) {
|
|
45
|
+
const strings = (0, external_strings_cjs_namespaceObject.useJsonTreeViewStrings)();
|
|
46
|
+
const missing = void 0 === node.value;
|
|
47
|
+
const display = missing ? strings.unsetValue : (0, external_buildJsonTree_cjs_namespaceObject.formatLeafValue)(node.type, node.value);
|
|
48
|
+
const colorClass = missing ? 'italic text-foreground-subtle' : valueColorClass(node.type, node.value);
|
|
49
|
+
const enumOptions = node.schema?.enum;
|
|
50
|
+
const isBoolean = 'boolean' === node.type;
|
|
51
|
+
if (editing) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonLeafValueEditor_cjs_namespaceObject.JsonLeafValueEditor, {
|
|
52
|
+
node: node,
|
|
53
|
+
onCommit: (value)=>{
|
|
54
|
+
onStopEdit();
|
|
55
|
+
onEdit?.(node, value);
|
|
56
|
+
},
|
|
57
|
+
onCancel: onStopEdit
|
|
58
|
+
});
|
|
59
|
+
if (readOnly || !onEdit) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
60
|
+
className: (0, index_cjs_namespaceObject.cn)('min-w-0 truncate font-mono text-xs', colorClass),
|
|
61
|
+
children: display
|
|
62
|
+
});
|
|
63
|
+
const editTitle = strings.editValueOf(node.key);
|
|
64
|
+
if (isBoolean && !enumOptions?.length) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
onClick: ()=>onEdit(node, true !== node.value),
|
|
67
|
+
"aria-label": editTitle,
|
|
68
|
+
title: strings.toggleHint,
|
|
69
|
+
className: (0, index_cjs_namespaceObject.cn)(VALUE_CELL_CLASS, 'cursor-pointer', colorClass),
|
|
70
|
+
children: display
|
|
71
|
+
});
|
|
72
|
+
if (enumOptions?.length) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
|
|
75
|
+
asChild: true,
|
|
76
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
77
|
+
type: "button",
|
|
78
|
+
"aria-label": editTitle,
|
|
79
|
+
title: strings.editHint,
|
|
80
|
+
className: (0, index_cjs_namespaceObject.cn)(VALUE_CELL_CLASS, 'cursor-pointer', colorClass),
|
|
81
|
+
children: display
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
85
|
+
align: "start",
|
|
86
|
+
className: "min-w-32",
|
|
87
|
+
children: enumOptions.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
88
|
+
onClick: ()=>onEdit(node, option),
|
|
89
|
+
className: (0, index_cjs_namespaceObject.cn)('font-mono text-xs', option === node.value ? 'text-foreground' : 'text-foreground-muted'),
|
|
90
|
+
children: (0, external_buildJsonTree_cjs_namespaceObject.formatLeafValue)((0, external_buildJsonTree_cjs_namespaceObject.inferValueType)(option), option)
|
|
91
|
+
}, String(option)))
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
onClick: ()=>onStartEdit(node),
|
|
98
|
+
"aria-label": editTitle,
|
|
99
|
+
title: missing ? strings.unsetEditHint : strings.editHint,
|
|
100
|
+
className: (0, index_cjs_namespaceObject.cn)(VALUE_CELL_CLASS, 'cursor-text', colorClass),
|
|
101
|
+
children: display
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.ScalarValueCell = __webpack_exports__.ScalarValueCell;
|
|
105
|
+
exports.valueColorClass = __webpack_exports__.valueColorClass;
|
|
106
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
107
|
+
"ScalarValueCell",
|
|
108
|
+
"valueColorClass"
|
|
109
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
110
|
+
Object.defineProperty(exports, '__esModule', {
|
|
111
|
+
value: true
|
|
112
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JsonTreeNode, JsonTreeNodeType, JsonValue } from './JsonTree.types';
|
|
2
|
+
/** Semantic color for a rendered leaf value (also used by the wrapped-row view). */
|
|
3
|
+
export declare function valueColorClass(type: JsonTreeNodeType, value: JsonValue | undefined): string;
|
|
4
|
+
export interface ScalarValueCellProps {
|
|
5
|
+
node: JsonTreeNode;
|
|
6
|
+
readOnly: boolean;
|
|
7
|
+
editing: boolean;
|
|
8
|
+
onStartEdit: (node: JsonTreeNode) => void;
|
|
9
|
+
onStopEdit: () => void;
|
|
10
|
+
onEdit?: (node: JsonTreeNode, value: JsonValue) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The value slot of a leaf row. Booleans toggle on a single click; schema
|
|
14
|
+
* enums edit through a dropdown; strings, numbers, and null values edit
|
|
15
|
+
* through an inline input. Missing values render as "unset" and editing them
|
|
16
|
+
* creates the value.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ScalarValueCell({ node, readOnly, editing, onStartEdit, onStopEdit, onEdit, }: ScalarValueCellProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../lib/index.js";
|
|
3
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu.js";
|
|
4
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
5
|
+
import { formatLeafValue, inferValueType } from "./buildJsonTree.js";
|
|
6
|
+
import { JsonLeafValueEditor } from "./JsonLeafValueEditor.js";
|
|
7
|
+
function valueColorClass(type, value) {
|
|
8
|
+
if (null == value) return 'text-foreground-subtle';
|
|
9
|
+
if ('string' === type) return 'text-success';
|
|
10
|
+
if ('number' === type) return 'text-info';
|
|
11
|
+
if ('boolean' === type) return value ? 'text-success' : 'text-error';
|
|
12
|
+
return 'text-foreground';
|
|
13
|
+
}
|
|
14
|
+
const VALUE_CELL_CLASS = 'min-w-0 truncate rounded font-mono text-xs transition hover:bg-surface-raised';
|
|
15
|
+
function ScalarValueCell({ node, readOnly, editing, onStartEdit, onStopEdit, onEdit }) {
|
|
16
|
+
const strings = useJsonTreeViewStrings();
|
|
17
|
+
const missing = void 0 === node.value;
|
|
18
|
+
const display = missing ? strings.unsetValue : formatLeafValue(node.type, node.value);
|
|
19
|
+
const colorClass = missing ? 'italic text-foreground-subtle' : valueColorClass(node.type, node.value);
|
|
20
|
+
const enumOptions = node.schema?.enum;
|
|
21
|
+
const isBoolean = 'boolean' === node.type;
|
|
22
|
+
if (editing) return /*#__PURE__*/ jsx(JsonLeafValueEditor, {
|
|
23
|
+
node: node,
|
|
24
|
+
onCommit: (value)=>{
|
|
25
|
+
onStopEdit();
|
|
26
|
+
onEdit?.(node, value);
|
|
27
|
+
},
|
|
28
|
+
onCancel: onStopEdit
|
|
29
|
+
});
|
|
30
|
+
if (readOnly || !onEdit) return /*#__PURE__*/ jsx("span", {
|
|
31
|
+
className: cn('min-w-0 truncate font-mono text-xs', colorClass),
|
|
32
|
+
children: display
|
|
33
|
+
});
|
|
34
|
+
const editTitle = strings.editValueOf(node.key);
|
|
35
|
+
if (isBoolean && !enumOptions?.length) return /*#__PURE__*/ jsx("button", {
|
|
36
|
+
type: "button",
|
|
37
|
+
onClick: ()=>onEdit(node, true !== node.value),
|
|
38
|
+
"aria-label": editTitle,
|
|
39
|
+
title: strings.toggleHint,
|
|
40
|
+
className: cn(VALUE_CELL_CLASS, 'cursor-pointer', colorClass),
|
|
41
|
+
children: display
|
|
42
|
+
});
|
|
43
|
+
if (enumOptions?.length) return /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
46
|
+
asChild: true,
|
|
47
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
48
|
+
type: "button",
|
|
49
|
+
"aria-label": editTitle,
|
|
50
|
+
title: strings.editHint,
|
|
51
|
+
className: cn(VALUE_CELL_CLASS, 'cursor-pointer', colorClass),
|
|
52
|
+
children: display
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
56
|
+
align: "start",
|
|
57
|
+
className: "min-w-32",
|
|
58
|
+
children: enumOptions.map((option)=>/*#__PURE__*/ jsx(DropdownMenuItem, {
|
|
59
|
+
onClick: ()=>onEdit(node, option),
|
|
60
|
+
className: cn('font-mono text-xs', option === node.value ? 'text-foreground' : 'text-foreground-muted'),
|
|
61
|
+
children: formatLeafValue(inferValueType(option), option)
|
|
62
|
+
}, String(option)))
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
return /*#__PURE__*/ jsx("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
onClick: ()=>onStartEdit(node),
|
|
69
|
+
"aria-label": editTitle,
|
|
70
|
+
title: missing ? strings.unsetEditHint : strings.editHint,
|
|
71
|
+
className: cn(VALUE_CELL_CLASS, 'cursor-text', colorClass),
|
|
72
|
+
children: display
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export { ScalarValueCell, valueColorClass };
|