@uipath/apollo-wind 2.57.0 → 2.57.1
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/dist/components/ui/alert-dialog.cjs +7 -6
- package/dist/components/ui/alert-dialog.js +7 -6
- package/dist/components/ui/code-editors.shared.cjs +323 -0
- package/dist/components/ui/code-editors.shared.d.ts +936 -0
- package/dist/components/ui/code-editors.shared.js +264 -0
- package/dist/components/ui/dialog.cjs +2 -1
- package/dist/components/ui/dialog.js +2 -1
- package/dist/components/ui/index.cjs +12 -12
- package/dist/lib/dialog-surface.cjs +36 -0
- package/dist/lib/dialog-surface.d.ts +1 -0
- package/dist/lib/dialog-surface.js +2 -0
- package/dist/styles.css +7 -9
- package/package.json +1 -1
|
@@ -43,6 +43,7 @@ const external_react_namespaceObject = require("react");
|
|
|
43
43
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
44
44
|
const external_portal_container_cjs_namespaceObject = require("./portal-container.cjs");
|
|
45
45
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
46
|
+
const dialog_surface_cjs_namespaceObject = require("../../lib/dialog-surface.cjs");
|
|
46
47
|
const AlertDialog = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_alert_dialog_namespaceObject.Root, {
|
|
47
48
|
"data-slot": "alert-dialog",
|
|
48
49
|
...props
|
|
@@ -75,7 +76,7 @@ const AlertDialogContent = /*#__PURE__*/ external_react_namespaceObject.forwardR
|
|
|
75
76
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_alert_dialog_namespaceObject.Content, {
|
|
76
77
|
ref: ref,
|
|
77
78
|
"data-slot": "alert-dialog-content",
|
|
78
|
-
className: (0, index_cjs_namespaceObject.cn)('fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4
|
|
79
|
+
className: (0, index_cjs_namespaceObject.cn)(dialog_surface_cjs_namespaceObject.dialogSurfaceClassName, 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', className),
|
|
79
80
|
...props
|
|
80
81
|
})
|
|
81
82
|
]
|
|
@@ -84,27 +85,27 @@ const AlertDialogContent = /*#__PURE__*/ external_react_namespaceObject.forwardR
|
|
|
84
85
|
AlertDialogContent.displayName = react_alert_dialog_namespaceObject.Content.displayName;
|
|
85
86
|
const AlertDialogHeader = ({ className, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
86
87
|
"data-slot": "alert-dialog-header",
|
|
87
|
-
className: (0, index_cjs_namespaceObject.cn)('flex flex-col
|
|
88
|
+
className: (0, index_cjs_namespaceObject.cn)('flex flex-col gap-2 text-center sm:text-left', className),
|
|
88
89
|
...props
|
|
89
90
|
});
|
|
90
91
|
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
|
91
92
|
const AlertDialogFooter = ({ className, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
92
93
|
"data-slot": "alert-dialog-footer",
|
|
93
|
-
className: (0, index_cjs_namespaceObject.cn)('flex flex-col-reverse sm:flex-row sm:justify-end
|
|
94
|
+
className: (0, index_cjs_namespaceObject.cn)('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className),
|
|
94
95
|
...props
|
|
95
96
|
});
|
|
96
97
|
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
|
97
98
|
const AlertDialogTitle = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_alert_dialog_namespaceObject.Title, {
|
|
98
99
|
ref: ref,
|
|
99
100
|
"data-slot": "alert-dialog-title",
|
|
100
|
-
className: (0, index_cjs_namespaceObject.cn)('text-lg font-semibold', className),
|
|
101
|
+
className: (0, index_cjs_namespaceObject.cn)('text-lg leading-none font-semibold', className),
|
|
101
102
|
...props
|
|
102
103
|
}));
|
|
103
104
|
AlertDialogTitle.displayName = react_alert_dialog_namespaceObject.Title.displayName;
|
|
104
105
|
const AlertDialogDescription = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_alert_dialog_namespaceObject.Description, {
|
|
105
106
|
ref: ref,
|
|
106
107
|
"data-slot": "alert-dialog-description",
|
|
107
|
-
className: (0, index_cjs_namespaceObject.cn)('text-
|
|
108
|
+
className: (0, index_cjs_namespaceObject.cn)('text-foreground-muted text-sm', className),
|
|
108
109
|
...props
|
|
109
110
|
}));
|
|
110
111
|
AlertDialogDescription.displayName = react_alert_dialog_namespaceObject.Description.displayName;
|
|
@@ -120,7 +121,7 @@ const AlertDialogCancel = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
120
121
|
"data-slot": "alert-dialog-cancel",
|
|
121
122
|
className: (0, index_cjs_namespaceObject.cn)((0, external_button_cjs_namespaceObject.buttonVariants)({
|
|
122
123
|
variant: 'outline'
|
|
123
|
-
}),
|
|
124
|
+
}), className),
|
|
124
125
|
...props
|
|
125
126
|
}));
|
|
126
127
|
AlertDialogCancel.displayName = react_alert_dialog_namespaceObject.Cancel.displayName;
|
|
@@ -5,6 +5,7 @@ import { forwardRef } from "react";
|
|
|
5
5
|
import { buttonVariants } from "./button.js";
|
|
6
6
|
import { useResolvedPortalContainer } from "./portal-container.js";
|
|
7
7
|
import { cn } from "../../lib/index.js";
|
|
8
|
+
import { dialogSurfaceClassName } from "../../lib/dialog-surface.js";
|
|
8
9
|
const AlertDialog = (props)=>/*#__PURE__*/ jsx(Root, {
|
|
9
10
|
"data-slot": "alert-dialog",
|
|
10
11
|
...props
|
|
@@ -37,7 +38,7 @@ const AlertDialogContent = /*#__PURE__*/ forwardRef(({ className, container, ...
|
|
|
37
38
|
/*#__PURE__*/ jsx(Content, {
|
|
38
39
|
ref: ref,
|
|
39
40
|
"data-slot": "alert-dialog-content",
|
|
40
|
-
className: cn('fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4
|
|
41
|
+
className: cn(dialogSurfaceClassName, 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', className),
|
|
41
42
|
...props
|
|
42
43
|
})
|
|
43
44
|
]
|
|
@@ -46,27 +47,27 @@ const AlertDialogContent = /*#__PURE__*/ forwardRef(({ className, container, ...
|
|
|
46
47
|
AlertDialogContent.displayName = Content.displayName;
|
|
47
48
|
const AlertDialogHeader = ({ className, ...props })=>/*#__PURE__*/ jsx("div", {
|
|
48
49
|
"data-slot": "alert-dialog-header",
|
|
49
|
-
className: cn('flex flex-col
|
|
50
|
+
className: cn('flex flex-col gap-2 text-center sm:text-left', className),
|
|
50
51
|
...props
|
|
51
52
|
});
|
|
52
53
|
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
|
53
54
|
const AlertDialogFooter = ({ className, ...props })=>/*#__PURE__*/ jsx("div", {
|
|
54
55
|
"data-slot": "alert-dialog-footer",
|
|
55
|
-
className: cn('flex flex-col-reverse sm:flex-row sm:justify-end
|
|
56
|
+
className: cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className),
|
|
56
57
|
...props
|
|
57
58
|
});
|
|
58
59
|
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
|
59
60
|
const AlertDialogTitle = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Title, {
|
|
60
61
|
ref: ref,
|
|
61
62
|
"data-slot": "alert-dialog-title",
|
|
62
|
-
className: cn('text-lg font-semibold', className),
|
|
63
|
+
className: cn('text-lg leading-none font-semibold', className),
|
|
63
64
|
...props
|
|
64
65
|
}));
|
|
65
66
|
AlertDialogTitle.displayName = Title.displayName;
|
|
66
67
|
const AlertDialogDescription = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Description, {
|
|
67
68
|
ref: ref,
|
|
68
69
|
"data-slot": "alert-dialog-description",
|
|
69
|
-
className: cn('text-
|
|
70
|
+
className: cn('text-foreground-muted text-sm', className),
|
|
70
71
|
...props
|
|
71
72
|
}));
|
|
72
73
|
AlertDialogDescription.displayName = Description.displayName;
|
|
@@ -82,7 +83,7 @@ const AlertDialogCancel = /*#__PURE__*/ forwardRef(({ className, ...props }, ref
|
|
|
82
83
|
"data-slot": "alert-dialog-cancel",
|
|
83
84
|
className: cn(buttonVariants({
|
|
84
85
|
variant: 'outline'
|
|
85
|
-
}),
|
|
86
|
+
}), className),
|
|
86
87
|
...props
|
|
87
88
|
}));
|
|
88
89
|
AlertDialogCancel.displayName = Cancel.displayName;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
registerAllMonacoThemes: ()=>registerAllMonacoThemes,
|
|
37
|
+
editorThemeConfigs: ()=>editorThemeConfigs,
|
|
38
|
+
LiveMonacoEditor: ()=>LiveMonacoEditor,
|
|
39
|
+
useEditorThemeConfig: ()=>useEditorThemeConfig,
|
|
40
|
+
monacoSample: ()=>monacoSample,
|
|
41
|
+
monacoFullSample: ()=>monacoFullSample
|
|
42
|
+
});
|
|
43
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
44
|
+
const react_namespaceObject = require("@monaco-editor/react");
|
|
45
|
+
var react_default = /*#__PURE__*/ __webpack_require__.n(react_namespaceObject);
|
|
46
|
+
const external_react_namespaceObject = require("react");
|
|
47
|
+
const index_cjs_namespaceObject = require("../../editor-themes/index.cjs");
|
|
48
|
+
const editorThemeConfigs = [
|
|
49
|
+
{
|
|
50
|
+
key: 'future-dark',
|
|
51
|
+
label: 'Future Dark',
|
|
52
|
+
monacoThemeName: 'apollo-future-dark',
|
|
53
|
+
monacoExport: 'apolloFutureDarkMonaco',
|
|
54
|
+
cmExport: 'apolloFutureDarkCodeMirror',
|
|
55
|
+
monacoThemeObj: index_cjs_namespaceObject.apolloFutureDarkMonaco,
|
|
56
|
+
cmTokens: index_cjs_namespaceObject.apolloFutureDarkCodeMirror,
|
|
57
|
+
isDark: true,
|
|
58
|
+
family: 'Future'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: 'future-light',
|
|
62
|
+
label: 'Future Light',
|
|
63
|
+
monacoThemeName: 'apollo-future-light',
|
|
64
|
+
monacoExport: 'apolloFutureLightMonaco',
|
|
65
|
+
cmExport: 'apolloFutureLightCodeMirror',
|
|
66
|
+
monacoThemeObj: index_cjs_namespaceObject.apolloFutureLightMonaco,
|
|
67
|
+
cmTokens: index_cjs_namespaceObject.apolloFutureLightCodeMirror,
|
|
68
|
+
isDark: false,
|
|
69
|
+
family: 'Future'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: 'dark',
|
|
73
|
+
label: 'Dark',
|
|
74
|
+
monacoThemeName: 'apollo-core-dark',
|
|
75
|
+
monacoExport: 'apolloCoreDarkMonaco',
|
|
76
|
+
cmExport: 'apolloCoreDarkCodeMirror',
|
|
77
|
+
monacoThemeObj: index_cjs_namespaceObject.apolloCoreDarkMonaco,
|
|
78
|
+
cmTokens: index_cjs_namespaceObject.apolloCoreDarkCodeMirror,
|
|
79
|
+
isDark: true,
|
|
80
|
+
family: 'Core'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: 'light',
|
|
84
|
+
label: 'Light',
|
|
85
|
+
monacoThemeName: 'apollo-core-light',
|
|
86
|
+
monacoExport: 'apolloCoreLightMonaco',
|
|
87
|
+
cmExport: 'apolloCoreLightCodeMirror',
|
|
88
|
+
monacoThemeObj: index_cjs_namespaceObject.apolloCoreLightMonaco,
|
|
89
|
+
cmTokens: index_cjs_namespaceObject.apolloCoreLightCodeMirror,
|
|
90
|
+
isDark: false,
|
|
91
|
+
family: 'Core'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: 'dark-hc',
|
|
95
|
+
label: 'Dark High Contrast',
|
|
96
|
+
monacoThemeName: 'apollo-core-dark-hc',
|
|
97
|
+
monacoExport: 'apolloCoreDarkHCMonaco',
|
|
98
|
+
cmExport: 'apolloCoreDarkHCCodeMirror',
|
|
99
|
+
monacoThemeObj: index_cjs_namespaceObject.apolloCoreDarkHCMonaco,
|
|
100
|
+
cmTokens: index_cjs_namespaceObject.apolloCoreDarkHCCodeMirror,
|
|
101
|
+
isDark: true,
|
|
102
|
+
family: 'Core HC'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
key: 'light-hc',
|
|
106
|
+
label: 'Light High Contrast',
|
|
107
|
+
monacoThemeName: 'apollo-core-light-hc',
|
|
108
|
+
monacoExport: 'apolloCoreLightHCMonaco',
|
|
109
|
+
cmExport: 'apolloCoreLightHCCodeMirror',
|
|
110
|
+
monacoThemeObj: index_cjs_namespaceObject.apolloCoreLightHCMonaco,
|
|
111
|
+
cmTokens: index_cjs_namespaceObject.apolloCoreLightHCCodeMirror,
|
|
112
|
+
isDark: false,
|
|
113
|
+
family: 'Core HC'
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
const monacoFullSample = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
117
|
+
|
|
118
|
+
type SortDirection = 'asc' | 'desc';
|
|
119
|
+
|
|
120
|
+
interface Column<T> {
|
|
121
|
+
key: keyof T;
|
|
122
|
+
header: string;
|
|
123
|
+
sortable?: boolean;
|
|
124
|
+
render?: (value: T[keyof T], row: T) => ReactNode;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface TableProps<T> {
|
|
128
|
+
data: T[];
|
|
129
|
+
columns: Column<T>[];
|
|
130
|
+
pageSize?: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function DataTable<T extends { id: string | number }>({
|
|
134
|
+
data,
|
|
135
|
+
columns,
|
|
136
|
+
pageSize = 10,
|
|
137
|
+
}: TableProps<T>) {
|
|
138
|
+
const [query, setQuery] = useState('');
|
|
139
|
+
const [sortKey, setSortKey] = useState<keyof T | null>(null);
|
|
140
|
+
const [sortDir, setSortDir] = useState<SortDirection>('asc');
|
|
141
|
+
const [page, setPage] = useState(1);
|
|
142
|
+
|
|
143
|
+
useEffect(() => { setPage(1); }, [query, sortKey, sortDir]);
|
|
144
|
+
|
|
145
|
+
const filtered = useMemo(() => {
|
|
146
|
+
if (!query.trim()) return data;
|
|
147
|
+
const q = query.toLowerCase();
|
|
148
|
+
return data.filter((row) =>
|
|
149
|
+
columns.some((col) => String(row[col.key]).toLowerCase().includes(q))
|
|
150
|
+
);
|
|
151
|
+
}, [data, columns, query]);
|
|
152
|
+
|
|
153
|
+
const sorted = useMemo(() => {
|
|
154
|
+
if (!sortKey) return filtered;
|
|
155
|
+
return [...filtered].sort((a, b) => {
|
|
156
|
+
const cmp = a[sortKey] < b[sortKey] ? -1 : a[sortKey] > b[sortKey] ? 1 : 0;
|
|
157
|
+
return sortDir === 'asc' ? cmp : -cmp;
|
|
158
|
+
});
|
|
159
|
+
}, [filtered, sortKey, sortDir]);
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div className="flex flex-col gap-4">
|
|
163
|
+
<input
|
|
164
|
+
className="rounded-lg border border-border px-3 py-2 text-sm"
|
|
165
|
+
placeholder="Search..."
|
|
166
|
+
value={query}
|
|
167
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
168
|
+
/>
|
|
169
|
+
<table className="w-full text-sm">
|
|
170
|
+
<thead>
|
|
171
|
+
<tr className="border-b border-border">
|
|
172
|
+
{columns.map((col) => (
|
|
173
|
+
<th key={String(col.key)} className="px-4 py-2 text-left">
|
|
174
|
+
{col.header}
|
|
175
|
+
</th>
|
|
176
|
+
))}
|
|
177
|
+
</tr>
|
|
178
|
+
</thead>
|
|
179
|
+
</table>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}`.trim();
|
|
183
|
+
const monacoSample = `interface WorkflowNode {
|
|
184
|
+
id: string;
|
|
185
|
+
type: 'action' | 'condition' | 'trigger';
|
|
186
|
+
executionStatus: 'NotExecuted' | 'InProgress' | 'Completed' | 'Failed';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function getNextNodes(node: WorkflowNode): string[] {
|
|
190
|
+
if (node.executionStatus === 'Completed') {
|
|
191
|
+
return node.type === 'condition'
|
|
192
|
+
? ['true-branch', 'false-branch']
|
|
193
|
+
: ['next'];
|
|
194
|
+
}
|
|
195
|
+
return [];
|
|
196
|
+
}`.trim();
|
|
197
|
+
let monacoThemesRegistered = false;
|
|
198
|
+
function registerAllMonacoThemes(monaco) {
|
|
199
|
+
if (monacoThemesRegistered) return;
|
|
200
|
+
for (const cfg of editorThemeConfigs)monaco.editor.defineTheme(cfg.monacoThemeName, cfg.monacoThemeObj);
|
|
201
|
+
monacoThemesRegistered = true;
|
|
202
|
+
}
|
|
203
|
+
let demoDefaultsUsers = 0;
|
|
204
|
+
let savedTypescriptDefaults = null;
|
|
205
|
+
function acquireDemoTypescriptDefaults(monaco) {
|
|
206
|
+
demoDefaultsUsers += 1;
|
|
207
|
+
if (demoDefaultsUsers > 1) return;
|
|
208
|
+
const ts = monaco.languages.typescript.typescriptDefaults;
|
|
209
|
+
savedTypescriptDefaults = {
|
|
210
|
+
diagnostics: ts.getDiagnosticsOptions(),
|
|
211
|
+
compiler: ts.getCompilerOptions()
|
|
212
|
+
};
|
|
213
|
+
ts.setDiagnosticsOptions({
|
|
214
|
+
...ts.getDiagnosticsOptions(),
|
|
215
|
+
noSemanticValidation: true
|
|
216
|
+
});
|
|
217
|
+
ts.setCompilerOptions({
|
|
218
|
+
...ts.getCompilerOptions(),
|
|
219
|
+
jsx: monaco.languages.typescript.JsxEmit.Preserve
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function releaseDemoTypescriptDefaults(monaco) {
|
|
223
|
+
demoDefaultsUsers -= 1;
|
|
224
|
+
if (demoDefaultsUsers > 0 || !savedTypescriptDefaults) return;
|
|
225
|
+
const ts = monaco.languages.typescript.typescriptDefaults;
|
|
226
|
+
ts.setDiagnosticsOptions(savedTypescriptDefaults.diagnostics);
|
|
227
|
+
ts.setCompilerOptions(savedTypescriptDefaults.compiler);
|
|
228
|
+
savedTypescriptDefaults = null;
|
|
229
|
+
}
|
|
230
|
+
function LiveMonacoEditor({ themeConfig, height = '220px', value, onChange, onMount, language = "typescript", options = {} }) {
|
|
231
|
+
const extension = 'json' === language ? 'json' : 'tsx';
|
|
232
|
+
const modelPath = `file:///editor-${(0, external_react_namespaceObject.useId)().replace(/[^a-zA-Z0-9]/g, '')}.${extension}`;
|
|
233
|
+
const monacoRef = (0, external_react_namespaceObject.useRef)(null);
|
|
234
|
+
(0, external_react_namespaceObject.useEffect)(()=>()=>{
|
|
235
|
+
if (monacoRef.current) releaseDemoTypescriptDefaults(monacoRef.current);
|
|
236
|
+
monacoRef.current = null;
|
|
237
|
+
}, []);
|
|
238
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_default(), {
|
|
239
|
+
height: height,
|
|
240
|
+
path: modelPath,
|
|
241
|
+
defaultLanguage: language,
|
|
242
|
+
...onChange ? {
|
|
243
|
+
value: value ?? ''
|
|
244
|
+
} : {
|
|
245
|
+
defaultValue: value ?? monacoSample
|
|
246
|
+
},
|
|
247
|
+
theme: themeConfig.monacoThemeName,
|
|
248
|
+
beforeMount: (monaco)=>{
|
|
249
|
+
registerAllMonacoThemes(monaco);
|
|
250
|
+
if (!monacoRef.current) {
|
|
251
|
+
monacoRef.current = monaco;
|
|
252
|
+
acquireDemoTypescriptDefaults(monaco);
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
onChange: onChange,
|
|
256
|
+
onMount: onMount,
|
|
257
|
+
options: {
|
|
258
|
+
fontSize: 13,
|
|
259
|
+
lineHeight: 20,
|
|
260
|
+
minimap: {
|
|
261
|
+
enabled: false
|
|
262
|
+
},
|
|
263
|
+
scrollBeyondLastLine: false,
|
|
264
|
+
wordWrap: 'on',
|
|
265
|
+
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
|
266
|
+
padding: {
|
|
267
|
+
top: 16,
|
|
268
|
+
bottom: 16
|
|
269
|
+
},
|
|
270
|
+
lineNumbers: 'on',
|
|
271
|
+
glyphMargin: false,
|
|
272
|
+
folding: false,
|
|
273
|
+
renderLineHighlight: 'line',
|
|
274
|
+
hideCursorInOverviewRuler: true,
|
|
275
|
+
overviewRulerBorder: false,
|
|
276
|
+
scrollbar: {
|
|
277
|
+
vertical: 'auto',
|
|
278
|
+
horizontal: 'hidden',
|
|
279
|
+
alwaysConsumeMouseWheel: false
|
|
280
|
+
},
|
|
281
|
+
automaticLayout: true,
|
|
282
|
+
fixedOverflowWidgets: true,
|
|
283
|
+
...options
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const futureDarkConfig = editorThemeConfigs[0];
|
|
288
|
+
function getStorybookThemeConfig() {
|
|
289
|
+
const keys = editorThemeConfigs.map((c)=>c.key);
|
|
290
|
+
const found = Array.from(document.body.classList).find((c)=>keys.includes(c));
|
|
291
|
+
return editorThemeConfigs.find((c)=>c.key === found) ?? futureDarkConfig;
|
|
292
|
+
}
|
|
293
|
+
function useEditorThemeConfig() {
|
|
294
|
+
const [themeConfig, setThemeConfig] = (0, external_react_namespaceObject.useState)(getStorybookThemeConfig);
|
|
295
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
296
|
+
const observer = new MutationObserver(()=>setThemeConfig(getStorybookThemeConfig()));
|
|
297
|
+
observer.observe(document.body, {
|
|
298
|
+
attributes: true,
|
|
299
|
+
attributeFilter: [
|
|
300
|
+
'class'
|
|
301
|
+
]
|
|
302
|
+
});
|
|
303
|
+
return ()=>observer.disconnect();
|
|
304
|
+
}, []);
|
|
305
|
+
return themeConfig;
|
|
306
|
+
}
|
|
307
|
+
exports.LiveMonacoEditor = __webpack_exports__.LiveMonacoEditor;
|
|
308
|
+
exports.editorThemeConfigs = __webpack_exports__.editorThemeConfigs;
|
|
309
|
+
exports.monacoFullSample = __webpack_exports__.monacoFullSample;
|
|
310
|
+
exports.monacoSample = __webpack_exports__.monacoSample;
|
|
311
|
+
exports.registerAllMonacoThemes = __webpack_exports__.registerAllMonacoThemes;
|
|
312
|
+
exports.useEditorThemeConfig = __webpack_exports__.useEditorThemeConfig;
|
|
313
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
314
|
+
"LiveMonacoEditor",
|
|
315
|
+
"editorThemeConfigs",
|
|
316
|
+
"monacoFullSample",
|
|
317
|
+
"monacoSample",
|
|
318
|
+
"registerAllMonacoThemes",
|
|
319
|
+
"useEditorThemeConfig"
|
|
320
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
321
|
+
Object.defineProperty(exports, '__esModule', {
|
|
322
|
+
value: true
|
|
323
|
+
});
|