@uipath/apollo-react 6.0.0 → 6.2.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 (114) hide show
  1. package/dist/canvas/components/JsonTree/DecorationChip.cjs +81 -0
  2. package/dist/canvas/components/JsonTree/DecorationChip.d.ts +5 -0
  3. package/dist/canvas/components/JsonTree/DecorationChip.d.ts.map +1 -0
  4. package/dist/canvas/components/JsonTree/DecorationChip.js +47 -0
  5. package/dist/canvas/components/JsonTree/EditorChrome.cjs +93 -0
  6. package/dist/canvas/components/JsonTree/EditorChrome.d.ts +18 -0
  7. package/dist/canvas/components/JsonTree/EditorChrome.d.ts.map +1 -0
  8. package/dist/canvas/components/JsonTree/EditorChrome.js +56 -0
  9. package/dist/canvas/components/JsonTree/JsonContainerEditor.cjs +104 -0
  10. package/dist/canvas/components/JsonTree/JsonContainerEditor.d.ts +10 -0
  11. package/dist/canvas/components/JsonTree/JsonContainerEditor.d.ts.map +1 -0
  12. package/dist/canvas/components/JsonTree/JsonContainerEditor.js +70 -0
  13. package/dist/canvas/components/JsonTree/JsonLeafValueEditor.cjs +98 -0
  14. package/dist/canvas/components/JsonTree/JsonLeafValueEditor.d.ts +9 -0
  15. package/dist/canvas/components/JsonTree/JsonLeafValueEditor.d.ts.map +1 -0
  16. package/dist/canvas/components/JsonTree/JsonLeafValueEditor.js +64 -0
  17. package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.cjs +86 -0
  18. package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.d.ts +9 -0
  19. package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.d.ts.map +1 -0
  20. package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.js +52 -0
  21. package/dist/canvas/components/JsonTree/JsonTree.cjs +165 -0
  22. package/dist/canvas/components/JsonTree/JsonTree.d.ts +23 -0
  23. package/dist/canvas/components/JsonTree/JsonTree.d.ts.map +1 -0
  24. package/dist/canvas/components/JsonTree/JsonTree.js +131 -0
  25. package/dist/canvas/components/JsonTree/JsonTree.types.cjs +18 -0
  26. package/dist/canvas/components/JsonTree/JsonTree.types.d.ts +110 -0
  27. package/dist/canvas/components/JsonTree/JsonTree.types.d.ts.map +1 -0
  28. package/dist/canvas/components/JsonTree/JsonTree.types.js +0 -0
  29. package/dist/canvas/components/JsonTree/JsonTreeRow.cjs +358 -0
  30. package/dist/canvas/components/JsonTree/JsonTreeRow.d.ts +35 -0
  31. package/dist/canvas/components/JsonTree/JsonTreeRow.d.ts.map +1 -0
  32. package/dist/canvas/components/JsonTree/JsonTreeRow.js +321 -0
  33. package/dist/canvas/components/JsonTree/JsonTreeToolbar.cjs +224 -0
  34. package/dist/canvas/components/JsonTree/JsonTreeToolbar.d.ts +17 -0
  35. package/dist/canvas/components/JsonTree/JsonTreeToolbar.d.ts.map +1 -0
  36. package/dist/canvas/components/JsonTree/JsonTreeToolbar.js +190 -0
  37. package/dist/canvas/components/JsonTree/JsonTypeBadge.cjs +70 -0
  38. package/dist/canvas/components/JsonTree/JsonTypeBadge.d.ts +10 -0
  39. package/dist/canvas/components/JsonTree/JsonTypeBadge.d.ts.map +1 -0
  40. package/dist/canvas/components/JsonTree/JsonTypeBadge.js +36 -0
  41. package/dist/canvas/components/JsonTree/NodeKey.cjs +86 -0
  42. package/dist/canvas/components/JsonTree/NodeKey.d.ts +10 -0
  43. package/dist/canvas/components/JsonTree/NodeKey.d.ts.map +1 -0
  44. package/dist/canvas/components/JsonTree/NodeKey.js +52 -0
  45. package/dist/canvas/components/JsonTree/RowActions.cjs +114 -0
  46. package/dist/canvas/components/JsonTree/RowActions.d.ts +8 -0
  47. package/dist/canvas/components/JsonTree/RowActions.d.ts.map +1 -0
  48. package/dist/canvas/components/JsonTree/RowActions.js +80 -0
  49. package/dist/canvas/components/JsonTree/ScalarValueCell.cjs +132 -0
  50. package/dist/canvas/components/JsonTree/ScalarValueCell.d.ts +12 -0
  51. package/dist/canvas/components/JsonTree/ScalarValueCell.d.ts.map +1 -0
  52. package/dist/canvas/components/JsonTree/ScalarValueCell.js +95 -0
  53. package/dist/canvas/components/JsonTree/buildJsonTree.cjs +321 -0
  54. package/dist/canvas/components/JsonTree/buildJsonTree.d.ts +37 -0
  55. package/dist/canvas/components/JsonTree/buildJsonTree.d.ts.map +1 -0
  56. package/dist/canvas/components/JsonTree/buildJsonTree.js +254 -0
  57. package/dist/canvas/components/JsonTree/clipboard.cjs +63 -0
  58. package/dist/canvas/components/JsonTree/clipboard.d.ts +2 -0
  59. package/dist/canvas/components/JsonTree/clipboard.d.ts.map +1 -0
  60. package/dist/canvas/components/JsonTree/clipboard.js +29 -0
  61. package/dist/canvas/components/JsonTree/index.cjs +114 -0
  62. package/dist/canvas/components/JsonTree/index.d.ts +10 -0
  63. package/dist/canvas/components/JsonTree/index.d.ts.map +1 -0
  64. package/dist/canvas/components/JsonTree/index.js +9 -0
  65. package/dist/canvas/components/JsonTree/leafEditTypes.cjs +74 -0
  66. package/dist/canvas/components/JsonTree/leafEditTypes.d.ts +6 -0
  67. package/dist/canvas/components/JsonTree/leafEditTypes.d.ts.map +1 -0
  68. package/dist/canvas/components/JsonTree/leafEditTypes.js +34 -0
  69. package/dist/canvas/components/NodeIOView/NodeIOView.cjs +254 -0
  70. package/dist/canvas/components/NodeIOView/NodeIOView.d.ts +3 -0
  71. package/dist/canvas/components/NodeIOView/NodeIOView.d.ts.map +1 -0
  72. package/dist/canvas/components/NodeIOView/NodeIOView.js +220 -0
  73. package/dist/canvas/components/NodeIOView/NodeIOView.types.cjs +18 -0
  74. package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts +38 -0
  75. package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts.map +1 -0
  76. package/dist/canvas/components/NodeIOView/NodeIOView.types.js +0 -0
  77. package/dist/canvas/components/NodeIOView/PanelTitleBar.cjs +78 -0
  78. package/dist/canvas/components/NodeIOView/PanelTitleBar.d.ts +10 -0
  79. package/dist/canvas/components/NodeIOView/PanelTitleBar.d.ts.map +1 -0
  80. package/dist/canvas/components/NodeIOView/PanelTitleBar.js +44 -0
  81. package/dist/canvas/components/NodeIOView/index.cjs +72 -0
  82. package/dist/canvas/components/NodeIOView/index.d.ts +4 -0
  83. package/dist/canvas/components/NodeIOView/index.d.ts.map +1 -0
  84. package/dist/canvas/components/NodeIOView/index.js +3 -0
  85. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.cjs +20 -3
  86. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.d.ts +1 -1
  87. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.d.ts.map +1 -1
  88. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.js +20 -3
  89. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.types.d.ts +3 -0
  90. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.types.d.ts.map +1 -1
  91. package/dist/canvas/components/index.cjs +62 -48
  92. package/dist/canvas/components/index.d.ts +4 -2
  93. package/dist/canvas/components/index.d.ts.map +1 -1
  94. package/dist/canvas/components/index.js +4 -2
  95. package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.cjs +184 -0
  96. package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.d.ts +18 -0
  97. package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.d.ts.map +1 -0
  98. package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.js +144 -0
  99. package/dist/canvas/controls/NodeOutputModeSelect/index.cjs +42 -0
  100. package/dist/canvas/controls/NodeOutputModeSelect/index.d.ts +2 -0
  101. package/dist/canvas/controls/NodeOutputModeSelect/index.d.ts.map +1 -0
  102. package/dist/canvas/controls/NodeOutputModeSelect/index.js +2 -0
  103. package/dist/canvas/controls/index.cjs +14 -4
  104. package/dist/canvas/controls/index.d.ts +1 -0
  105. package/dist/canvas/controls/index.d.ts.map +1 -1
  106. package/dist/canvas/controls/index.js +2 -1
  107. package/dist/canvas/locales/en.cjs +1 -1
  108. package/dist/canvas/locales/en.d.ts.map +1 -1
  109. package/dist/canvas/locales/en.js +1 -1
  110. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  111. package/dist/i18n/useSafeLingui.cjs +21 -4
  112. package/dist/i18n/useSafeLingui.d.ts.map +1 -1
  113. package/dist/i18n/useSafeLingui.js +21 -4
  114. package/package.json +4 -3
@@ -0,0 +1,64 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { cn } from "@uipath/apollo-wind";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useSafeLingui } from "../../../i18n/index.js";
5
+ import { isNumericEdit, parseLeafValue, resolveLeafEditType } from "./leafEditTypes.js";
6
+ function JsonLeafValueEditor({ node, onCommit, onCancel, className }) {
7
+ const { _ } = useSafeLingui();
8
+ const editType = resolveLeafEditType(node.type, node.schema);
9
+ const initial = void 0 === node.value || null === node.value ? String(node.schema?.default ?? '') : String(node.value);
10
+ const [raw, setRaw] = useState(initial);
11
+ const cancelledRef = useRef(false);
12
+ const inputRef = useRef(null);
13
+ const invalid = void 0 === parseLeafValue(raw, editType);
14
+ useEffect(()=>{
15
+ inputRef.current?.focus();
16
+ }, []);
17
+ const commit = ()=>{
18
+ const parsed = parseLeafValue(raw, editType);
19
+ if (void 0 === parsed) return;
20
+ onCommit(parsed);
21
+ };
22
+ return /*#__PURE__*/ jsx("input", {
23
+ ref: inputRef,
24
+ type: "text",
25
+ value: raw,
26
+ inputMode: 'integer' === editType ? 'numeric' : 'number' === editType ? 'decimal' : void 0,
27
+ onChange: (e)=>setRaw(e.target.value),
28
+ onFocus: (e)=>e.target.select(),
29
+ onBlur: ()=>{
30
+ if (cancelledRef.current) {
31
+ cancelledRef.current = false;
32
+ return;
33
+ }
34
+ if (invalid) onCancel();
35
+ else commit();
36
+ },
37
+ onKeyDown: (e)=>{
38
+ if ('Enter' === e.key) commit();
39
+ if ('Escape' === e.key) {
40
+ e.preventDefault();
41
+ e.stopPropagation();
42
+ cancelledRef.current = true;
43
+ onCancel();
44
+ }
45
+ },
46
+ "aria-label": _({
47
+ id: 'canvas.json_value_panel.edit_value_of',
48
+ message: 'Edit value of {key}',
49
+ values: {
50
+ key: node.key
51
+ }
52
+ }),
53
+ "aria-invalid": invalid || void 0,
54
+ placeholder: isNumericEdit(editType) ? _({
55
+ id: 'canvas.json_value_panel.enter_number',
56
+ message: 'Enter a number'
57
+ }) : _({
58
+ id: 'canvas.json_value_panel.enter_value',
59
+ message: 'Enter a value'
60
+ }),
61
+ className: cn('min-w-0 flex-1 rounded bg-transparent font-mono text-xs text-foreground outline-none ring-1', invalid ? 'ring-error' : 'ring-brand', className)
62
+ });
63
+ }
64
+ export { JsonLeafValueEditor };
@@ -0,0 +1,86 @@
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
+ JsonMultilineLeafEditor: ()=>JsonMultilineLeafEditor
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
31
+ const external_react_namespaceObject = require("react");
32
+ const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
33
+ const external_EditorChrome_cjs_namespaceObject = require("./EditorChrome.cjs");
34
+ const external_leafEditTypes_cjs_namespaceObject = require("./leafEditTypes.cjs");
35
+ function JsonMultilineLeafEditor({ node, onCommit, onCancel, className }) {
36
+ const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
37
+ const editType = (0, external_leafEditTypes_cjs_namespaceObject.resolveLeafEditType)(node.type, node.schema);
38
+ const initial = void 0 === node.value || null === node.value ? String(node.schema?.default ?? '') : String(node.value);
39
+ const [raw, setRaw] = (0, external_react_namespaceObject.useState)(initial);
40
+ const invalid = void 0 === (0, external_leafEditTypes_cjs_namespaceObject.parseLeafValue)(raw, editType);
41
+ const apply = ()=>{
42
+ const parsed = (0, external_leafEditTypes_cjs_namespaceObject.parseLeafValue)(raw, editType);
43
+ if (void 0 === parsed) return;
44
+ onCommit(parsed);
45
+ };
46
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
47
+ className: (0, apollo_wind_namespaceObject.cn)('flex flex-col gap-1.5', className),
48
+ children: [
49
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_EditorChrome_cjs_namespaceObject.EditorTextarea, {
50
+ value: raw,
51
+ onChange: setRaw,
52
+ onApply: apply,
53
+ onCancel: onCancel,
54
+ invalid: invalid,
55
+ rows: Math.min(10, Math.max(3, raw.split('\n').length + 1)),
56
+ ariaLabel: _({
57
+ id: 'canvas.json_value_panel.edit_value_of',
58
+ message: 'Edit value of {key}',
59
+ values: {
60
+ key: node.key
61
+ }
62
+ }),
63
+ placeholder: (0, external_leafEditTypes_cjs_namespaceObject.isNumericEdit)(editType) ? _({
64
+ id: 'canvas.json_value_panel.enter_number',
65
+ message: 'Enter a number'
66
+ }) : _({
67
+ id: 'canvas.json_value_panel.enter_value',
68
+ message: 'Enter a value'
69
+ }),
70
+ className: "whitespace-pre-wrap"
71
+ }),
72
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_EditorChrome_cjs_namespaceObject.EditorActions, {
73
+ onApply: apply,
74
+ onCancel: onCancel,
75
+ applyDisabled: invalid
76
+ })
77
+ ]
78
+ });
79
+ }
80
+ exports.JsonMultilineLeafEditor = __webpack_exports__.JsonMultilineLeafEditor;
81
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
82
+ "JsonMultilineLeafEditor"
83
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
84
+ Object.defineProperty(exports, '__esModule', {
85
+ value: true
86
+ });
@@ -0,0 +1,9 @@
1
+ import type { JsonTreeNode, JsonValue } from './JsonTree.types';
2
+ export interface JsonMultilineLeafEditorProps {
3
+ node: JsonTreeNode;
4
+ onCommit: (value: JsonValue) => void;
5
+ onCancel: () => void;
6
+ className?: string;
7
+ }
8
+ export declare function JsonMultilineLeafEditor({ node, onCommit, onCancel, className, }: JsonMultilineLeafEditorProps): import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=JsonMultilineLeafEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonMultilineLeafEditor.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/JsonMultilineLeafEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGhE,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,EAAE,4BAA4B,2CA8C9B"}
@@ -0,0 +1,52 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@uipath/apollo-wind";
3
+ import { useState } from "react";
4
+ import { useSafeLingui } from "../../../i18n/index.js";
5
+ import { EditorActions, EditorTextarea } from "./EditorChrome.js";
6
+ import { isNumericEdit, parseLeafValue, resolveLeafEditType } from "./leafEditTypes.js";
7
+ function JsonMultilineLeafEditor({ node, onCommit, onCancel, className }) {
8
+ const { _ } = useSafeLingui();
9
+ const editType = resolveLeafEditType(node.type, node.schema);
10
+ const initial = void 0 === node.value || null === node.value ? String(node.schema?.default ?? '') : String(node.value);
11
+ const [raw, setRaw] = useState(initial);
12
+ const invalid = void 0 === parseLeafValue(raw, editType);
13
+ const apply = ()=>{
14
+ const parsed = parseLeafValue(raw, editType);
15
+ if (void 0 === parsed) return;
16
+ onCommit(parsed);
17
+ };
18
+ return /*#__PURE__*/ jsxs("div", {
19
+ className: cn('flex flex-col gap-1.5', className),
20
+ children: [
21
+ /*#__PURE__*/ jsx(EditorTextarea, {
22
+ value: raw,
23
+ onChange: setRaw,
24
+ onApply: apply,
25
+ onCancel: onCancel,
26
+ invalid: invalid,
27
+ rows: Math.min(10, Math.max(3, raw.split('\n').length + 1)),
28
+ ariaLabel: _({
29
+ id: 'canvas.json_value_panel.edit_value_of',
30
+ message: 'Edit value of {key}',
31
+ values: {
32
+ key: node.key
33
+ }
34
+ }),
35
+ placeholder: isNumericEdit(editType) ? _({
36
+ id: 'canvas.json_value_panel.enter_number',
37
+ message: 'Enter a number'
38
+ }) : _({
39
+ id: 'canvas.json_value_panel.enter_value',
40
+ message: 'Enter a value'
41
+ }),
42
+ className: "whitespace-pre-wrap"
43
+ }),
44
+ /*#__PURE__*/ jsx(EditorActions, {
45
+ onApply: apply,
46
+ onCancel: onCancel,
47
+ applyDisabled: invalid
48
+ })
49
+ ]
50
+ });
51
+ }
52
+ export { JsonMultilineLeafEditor };
@@ -0,0 +1,165 @@
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
+ JsonTree: ()=>JsonTree
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
31
+ const tooltip_namespaceObject = require("@uipath/apollo-wind/components/ui/tooltip");
32
+ const external_react_namespaceObject = require("react");
33
+ const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
34
+ const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
35
+ const external_buildJsonTree_cjs_namespaceObject = require("./buildJsonTree.cjs");
36
+ const external_clipboard_cjs_namespaceObject = require("./clipboard.cjs");
37
+ const external_JsonTreeRow_cjs_namespaceObject = require("./JsonTreeRow.cjs");
38
+ function valueAsText(node) {
39
+ if ('string' == typeof node.value) return node.value;
40
+ if (void 0 === node.value) return 'null';
41
+ return JSON.stringify(node.value, null, 2);
42
+ }
43
+ const DefaultRowWrapper = ({ className, style, onClick, children })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
44
+ className: className,
45
+ style: style,
46
+ onClick: onClick,
47
+ children: children
48
+ });
49
+ function JsonTree({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, emptyMessage, className }) {
50
+ const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
51
+ const RowWrapper = rowWrapper ?? DefaultRowWrapper;
52
+ const [editingPath, setEditingPath] = (0, external_react_namespaceObject.useState)(null);
53
+ const [jsonEditingPath, setJsonEditingPath] = (0, external_react_namespaceObject.useState)(null);
54
+ const [wrappedPaths, setWrappedPaths] = (0, external_react_namespaceObject.useState)({});
55
+ const [copied, setCopied] = (0, external_react_namespaceObject.useState)(null);
56
+ const copyTimerRef = (0, external_react_namespaceObject.useRef)(null);
57
+ (0, external_react_namespaceObject.useEffect)(()=>()=>{
58
+ if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
59
+ }, []);
60
+ const copy = (node, kind, text)=>{
61
+ (0, external_clipboard_cjs_namespaceObject.copyTextToClipboard)(text).then((ok)=>{
62
+ if (!ok) return;
63
+ setCopied({
64
+ path: node.path,
65
+ kind
66
+ });
67
+ if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
68
+ copyTimerRef.current = setTimeout(()=>setCopied(null), 1500);
69
+ onCopy?.({
70
+ kind,
71
+ path: node.path,
72
+ text
73
+ });
74
+ });
75
+ };
76
+ const copyPath = (node)=>copy(node, 'path', pathForCopy?.(node.path) ?? node.path);
77
+ const copyValue = (node)=>copy(node, 'value', valueAsText(node));
78
+ const toggleWrapped = (node)=>{
79
+ setWrappedPaths((prev)=>({
80
+ ...prev,
81
+ [node.path]: !prev[node.path]
82
+ }));
83
+ if (editingPath === node.path) setEditingPath(null);
84
+ };
85
+ const commitEdit = (node, value)=>onEdit?.(node, value);
86
+ const canEdit = !readOnly && !!onEdit;
87
+ const rows = (0, external_react_namespaceObject.useMemo)(()=>(0, external_buildJsonTree_cjs_namespaceObject.flattenJsonTree)(nodes, {
88
+ collapsed,
89
+ query,
90
+ filterPredicate,
91
+ displayTexts: decorateNode
92
+ }), [
93
+ nodes,
94
+ collapsed,
95
+ query,
96
+ filterPredicate,
97
+ decorateNode
98
+ ]);
99
+ const templateItemLabel = _({
100
+ id: 'canvas.json_value_panel.array_item',
101
+ message: 'item'
102
+ });
103
+ const filtering = !!query?.trim() || !!filterPredicate;
104
+ const resolvedEmptyMessage = filtering ? _({
105
+ id: 'canvas.json_value_panel.empty_search',
106
+ message: 'No fields match your search.'
107
+ }) : emptyMessage ?? _({
108
+ id: 'canvas.json_value_panel.empty_default',
109
+ message: 'No fields to display.'
110
+ });
111
+ const rowContext = {
112
+ collapsed,
113
+ onToggleCollapsed,
114
+ readOnly,
115
+ decorateNode,
116
+ deriveTypeIcon,
117
+ renderValue,
118
+ nodeActions,
119
+ maxInlineActions,
120
+ renderCodeEditor,
121
+ pathForCopy,
122
+ canEdit,
123
+ RowWrapper,
124
+ templateItemLabel,
125
+ editingPath,
126
+ jsonEditingPath,
127
+ wrappedPaths,
128
+ copied,
129
+ setEditingPath,
130
+ setJsonEditingPath,
131
+ copyPath,
132
+ copyValue,
133
+ toggleWrapped,
134
+ commitEdit
135
+ };
136
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(tooltip_namespaceObject.TooltipProvider, {
137
+ delayDuration: 300,
138
+ skipDelayDuration: 100,
139
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltipProviderMarker, {
140
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeRow_cjs_namespaceObject.JsonTreeRowContextProvider, {
141
+ value: rowContext,
142
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
143
+ className: (0, apollo_wind_namespaceObject.cn)('h-full overflow-y-auto overflow-x-hidden', className),
144
+ children: [
145
+ rows.map(({ node, depth })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeRow_cjs_namespaceObject.JsonTreeRow, {
146
+ node: node,
147
+ depth: depth
148
+ }, node.path)),
149
+ 0 === rows.length && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
150
+ className: "py-4 text-center text-xs text-foreground-subtle",
151
+ children: resolvedEmptyMessage
152
+ })
153
+ ]
154
+ })
155
+ })
156
+ })
157
+ });
158
+ }
159
+ exports.JsonTree = __webpack_exports__.JsonTree;
160
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
161
+ "JsonTree"
162
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
163
+ Object.defineProperty(exports, '__esModule', {
164
+ value: true
165
+ });
@@ -0,0 +1,23 @@
1
+ import type { CopyEvent, DeriveTypeIcon, JsonTreeNode, JsonTreeRowWrapper, JsonValue, NodeActionsResolver, NodeDecoration, RenderCodeEditor, RenderValueCell } from './JsonTree.types';
2
+ export interface JsonTreeProps {
3
+ nodes: JsonTreeNode[];
4
+ collapsed?: Record<string, boolean>;
5
+ onToggleCollapsed?: (path: string) => void;
6
+ query?: string;
7
+ filterPredicate?: (node: JsonTreeNode) => boolean;
8
+ readOnly?: boolean;
9
+ onEdit?: (node: JsonTreeNode, value: JsonValue | undefined) => void;
10
+ rowWrapper?: JsonTreeRowWrapper;
11
+ decorateNode?: (node: JsonTreeNode) => NodeDecoration | undefined;
12
+ deriveTypeIcon?: DeriveTypeIcon;
13
+ renderValue?: RenderValueCell;
14
+ nodeActions?: NodeActionsResolver;
15
+ maxInlineActions?: number;
16
+ renderCodeEditor?: RenderCodeEditor;
17
+ pathForCopy?: (path: string) => string;
18
+ onCopy?: (event: CopyEvent) => void;
19
+ emptyMessage?: string;
20
+ className?: string;
21
+ }
22
+ export declare function JsonTree({ nodes, collapsed, onToggleCollapsed, query, filterPredicate, readOnly, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions, renderCodeEditor, pathForCopy, onCopy, emptyMessage, className, }: JsonTreeProps): import("react/jsx-runtime").JSX.Element;
23
+ //# sourceMappingURL=JsonTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonTree.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/JsonTree.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAO1B,MAAM,WAAW,aAAa;IAE5B,KAAK,EAAE,YAAY,EAAE,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAE3C,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;IAElD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAMpE,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAEhC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,cAAc,GAAG,SAAS,CAAC;IAElE,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,WAAW,CAAC,EAAE,eAAe,CAAC;IAM9B,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAKlC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEvC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoBD,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,SAAc,EACd,iBAAiB,EACjB,KAAK,EACL,eAAe,EACf,QAAgB,EAChB,MAAM,EACN,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,EACX,gBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,YAAY,EACZ,SAAS,GACV,EAAE,aAAa,2CA4Hf"}
@@ -0,0 +1,131 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@uipath/apollo-wind";
3
+ import { TooltipProvider } from "@uipath/apollo-wind/components/ui/tooltip";
4
+ import { useEffect, useMemo, useRef, useState } from "react";
5
+ import { useSafeLingui } from "../../../i18n/index.js";
6
+ import { CanvasTooltipProviderMarker } from "../CanvasTooltip.js";
7
+ import { flattenJsonTree } from "./buildJsonTree.js";
8
+ import { copyTextToClipboard } from "./clipboard.js";
9
+ import { JsonTreeRow, JsonTreeRowContextProvider } from "./JsonTreeRow.js";
10
+ function valueAsText(node) {
11
+ if ('string' == typeof node.value) return node.value;
12
+ if (void 0 === node.value) return 'null';
13
+ return JSON.stringify(node.value, null, 2);
14
+ }
15
+ const DefaultRowWrapper = ({ className, style, onClick, children })=>/*#__PURE__*/ jsx("div", {
16
+ className: className,
17
+ style: style,
18
+ onClick: onClick,
19
+ children: children
20
+ });
21
+ function JsonTree({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, emptyMessage, className }) {
22
+ const { _ } = useSafeLingui();
23
+ const RowWrapper = rowWrapper ?? DefaultRowWrapper;
24
+ const [editingPath, setEditingPath] = useState(null);
25
+ const [jsonEditingPath, setJsonEditingPath] = useState(null);
26
+ const [wrappedPaths, setWrappedPaths] = useState({});
27
+ const [copied, setCopied] = useState(null);
28
+ const copyTimerRef = useRef(null);
29
+ useEffect(()=>()=>{
30
+ if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
31
+ }, []);
32
+ const copy = (node, kind, text)=>{
33
+ copyTextToClipboard(text).then((ok)=>{
34
+ if (!ok) return;
35
+ setCopied({
36
+ path: node.path,
37
+ kind
38
+ });
39
+ if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
40
+ copyTimerRef.current = setTimeout(()=>setCopied(null), 1500);
41
+ onCopy?.({
42
+ kind,
43
+ path: node.path,
44
+ text
45
+ });
46
+ });
47
+ };
48
+ const copyPath = (node)=>copy(node, 'path', pathForCopy?.(node.path) ?? node.path);
49
+ const copyValue = (node)=>copy(node, 'value', valueAsText(node));
50
+ const toggleWrapped = (node)=>{
51
+ setWrappedPaths((prev)=>({
52
+ ...prev,
53
+ [node.path]: !prev[node.path]
54
+ }));
55
+ if (editingPath === node.path) setEditingPath(null);
56
+ };
57
+ const commitEdit = (node, value)=>onEdit?.(node, value);
58
+ const canEdit = !readOnly && !!onEdit;
59
+ const rows = useMemo(()=>flattenJsonTree(nodes, {
60
+ collapsed,
61
+ query,
62
+ filterPredicate,
63
+ displayTexts: decorateNode
64
+ }), [
65
+ nodes,
66
+ collapsed,
67
+ query,
68
+ filterPredicate,
69
+ decorateNode
70
+ ]);
71
+ const templateItemLabel = _({
72
+ id: 'canvas.json_value_panel.array_item',
73
+ message: 'item'
74
+ });
75
+ const filtering = !!query?.trim() || !!filterPredicate;
76
+ const resolvedEmptyMessage = filtering ? _({
77
+ id: 'canvas.json_value_panel.empty_search',
78
+ message: 'No fields match your search.'
79
+ }) : emptyMessage ?? _({
80
+ id: 'canvas.json_value_panel.empty_default',
81
+ message: 'No fields to display.'
82
+ });
83
+ const rowContext = {
84
+ collapsed,
85
+ onToggleCollapsed,
86
+ readOnly,
87
+ decorateNode,
88
+ deriveTypeIcon,
89
+ renderValue,
90
+ nodeActions,
91
+ maxInlineActions,
92
+ renderCodeEditor,
93
+ pathForCopy,
94
+ canEdit,
95
+ RowWrapper,
96
+ templateItemLabel,
97
+ editingPath,
98
+ jsonEditingPath,
99
+ wrappedPaths,
100
+ copied,
101
+ setEditingPath,
102
+ setJsonEditingPath,
103
+ copyPath,
104
+ copyValue,
105
+ toggleWrapped,
106
+ commitEdit
107
+ };
108
+ return /*#__PURE__*/ jsx(TooltipProvider, {
109
+ delayDuration: 300,
110
+ skipDelayDuration: 100,
111
+ children: /*#__PURE__*/ jsx(CanvasTooltipProviderMarker, {
112
+ children: /*#__PURE__*/ jsx(JsonTreeRowContextProvider, {
113
+ value: rowContext,
114
+ children: /*#__PURE__*/ jsxs("div", {
115
+ className: cn('h-full overflow-y-auto overflow-x-hidden', className),
116
+ children: [
117
+ rows.map(({ node, depth })=>/*#__PURE__*/ jsx(JsonTreeRow, {
118
+ node: node,
119
+ depth: depth
120
+ }, node.path)),
121
+ 0 === rows.length && /*#__PURE__*/ jsx("span", {
122
+ className: "py-4 text-center text-xs text-foreground-subtle",
123
+ children: resolvedEmptyMessage
124
+ })
125
+ ]
126
+ })
127
+ })
128
+ })
129
+ });
130
+ }
131
+ export { JsonTree };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -0,0 +1,110 @@
1
+ import type { ComponentType, CSSProperties, MouseEvent, ReactNode } from 'react';
2
+ export type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
3
+ export interface JsonObject {
4
+ [key: string]: JsonValue;
5
+ }
6
+ export type JsonContainer = JsonObject | JsonValue[];
7
+ export type JsonSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
8
+ export interface JsonSchema {
9
+ type?: JsonSchemaTypeName | JsonSchemaTypeName[];
10
+ title?: string;
11
+ description?: string;
12
+ format?: string;
13
+ enum?: Array<string | number | boolean | null>;
14
+ default?: JsonValue;
15
+ properties?: Record<string, JsonSchema>;
16
+ required?: string[];
17
+ items?: JsonSchema;
18
+ additionalProperties?: boolean | JsonSchema;
19
+ }
20
+ export type JsonTreeNodeType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
21
+ export type PathSegment = string | number;
22
+ export interface JsonTreeNode {
23
+ key: string;
24
+ path: string;
25
+ segments: PathSegment[];
26
+ type: JsonTreeNodeType;
27
+ value?: JsonValue;
28
+ schema?: JsonSchema;
29
+ required?: boolean;
30
+ children?: JsonTreeNode[];
31
+ isArrayItemTemplate?: boolean;
32
+ }
33
+ export interface JsonTreeFilterOption {
34
+ id: string;
35
+ label: string;
36
+ predicate: (node: JsonTreeNode) => boolean;
37
+ count?: number;
38
+ }
39
+ export type NodeDecorationTone = 'neutral' | 'info' | 'warning' | 'error';
40
+ export type DeriveTypeIcon = (node: JsonTreeNode) => ReactNode;
41
+ export interface NodeDecorationChip {
42
+ label?: string;
43
+ icon?: ReactNode;
44
+ tooltip?: string;
45
+ tone?: NodeDecorationTone;
46
+ }
47
+ export interface NodeDecorationBadge {
48
+ icon?: ReactNode;
49
+ className?: string;
50
+ }
51
+ export interface NodeDecoration {
52
+ label?: string;
53
+ sublabel?: string;
54
+ badge?: NodeDecorationBadge;
55
+ chip?: NodeDecorationChip;
56
+ hideCount?: boolean;
57
+ }
58
+ export interface RenderValueContext {
59
+ readOnly: boolean;
60
+ commit: (value: JsonValue) => void;
61
+ clear: () => void;
62
+ }
63
+ export type RenderValueCell = (node: JsonTreeNode, ctx: RenderValueContext) => ReactNode;
64
+ export interface NodeAction {
65
+ id: string;
66
+ icon: ReactNode;
67
+ label: string;
68
+ tooltip?: string;
69
+ onSelect: (node: JsonTreeNode) => void;
70
+ active?: boolean;
71
+ disabled?: boolean;
72
+ tone?: NodeDecorationTone;
73
+ }
74
+ export interface NodeActionContext {
75
+ readOnly: boolean;
76
+ defaultActions: NodeAction[];
77
+ commit: (value: JsonValue) => void;
78
+ clear: () => void;
79
+ }
80
+ export type NodeActionsResolver = (node: JsonTreeNode, ctx: NodeActionContext) => NodeAction[] | undefined;
81
+ export interface CopyEvent {
82
+ kind: 'path' | 'value';
83
+ path: string;
84
+ text: string;
85
+ }
86
+ export interface JsonTreeChange {
87
+ path: string;
88
+ segments: PathSegment[];
89
+ value?: JsonValue;
90
+ previous?: JsonValue;
91
+ }
92
+ export interface JsonTreeRowWrapperProps {
93
+ node: JsonTreeNode;
94
+ className?: string;
95
+ style?: CSSProperties;
96
+ onClick?: (event: MouseEvent) => void;
97
+ children: ReactNode;
98
+ }
99
+ export type JsonTreeRowWrapper = ComponentType<JsonTreeRowWrapperProps>;
100
+ export interface JsonCodeEditorRenderProps {
101
+ value: string;
102
+ onChange: (value: string) => void;
103
+ onApply: () => void;
104
+ onCancel: () => void;
105
+ invalid: boolean;
106
+ language: 'json';
107
+ autoFocus: boolean;
108
+ }
109
+ export type RenderCodeEditor = (props: JsonCodeEditorRenderProps) => ReactNode;
110
+ //# sourceMappingURL=JsonTree.types.d.ts.map