@dovetail-v2/refine 0.0.31 → 0.0.32-beta.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 (34) hide show
  1. package/dist/{MonacoYamlDiffEditor-b0ea1b12.js → MonacoYamlDiffEditor-0d108b88.js} +1 -3
  2. package/dist/MonacoYamlEditor-e382457d.js +167 -0
  3. package/dist/{index-01ce45aa.js → index-3a367ae3.js} +9154 -6347
  4. package/dist/refine.js +133 -114
  5. package/dist/refine.umd.cjs +10170 -7210
  6. package/dist/style.css +40 -24
  7. package/lib/src/components/CronJobDropdown/index.d.ts +2 -0
  8. package/lib/src/components/CronjobJobsTable/index.d.ts +1 -0
  9. package/lib/src/components/K8sDropdown/index.d.ts +2 -0
  10. package/lib/src/components/RefineForm/RefineFormContent.d.ts +10 -0
  11. package/lib/src/components/RefineForm/RefineFormModal.d.ts +8 -0
  12. package/lib/src/components/RefineForm/RefineFormPage.d.ts +7 -0
  13. package/lib/src/components/RefineForm/index.d.ts +3 -0
  14. package/lib/src/components/RefineForm/type.d.ts +20 -0
  15. package/lib/src/components/RefineForm/useRefineForm.d.ts +10 -0
  16. package/lib/src/components/ShowContent/fields.d.ts +33 -23
  17. package/lib/src/components/ShowContent/groups.d.ts +11 -0
  18. package/lib/src/components/ShowContent/index.d.ts +2 -0
  19. package/lib/src/components/ShowContent/tabs.d.ts +12 -0
  20. package/lib/src/components/StateTag/StateTag.d.ts +1 -0
  21. package/lib/src/components/Tabs/index.d.ts +10 -0
  22. package/lib/src/components/Time/index.d.ts +2 -3
  23. package/lib/src/components/WorkloadDropdown/index.d.ts +2 -0
  24. package/lib/src/components/WorkloadReplicas/index.d.ts +1 -2
  25. package/lib/src/components/index.d.ts +2 -0
  26. package/lib/src/constants/k8s.d.ts +23 -0
  27. package/lib/src/contexts/component.d.ts +2 -0
  28. package/lib/src/hooks/useEagleTable/columns.d.ts +5 -3
  29. package/lib/src/i18n.d.ts +125 -10
  30. package/lib/src/locales/en-US/index.d.ts +95 -1
  31. package/lib/src/locales/zh-CN/index.d.ts +29 -9
  32. package/lib/src/pages/statefulsets/index.d.ts +4 -3
  33. package/lib/src/types/resource.d.ts +5 -1
  34. package/package.json +10 -8
@@ -1,4 +1,4 @@
1
- import { j as jsxRuntimeExports } from "./index-01ce45aa.js";
1
+ import { j as jsxRuntimeExports } from "./index-3a367ae3.js";
2
2
  import * as monaco from "monaco-editor";
3
3
  import { useRef, useEffect } from "react";
4
4
  import "i18next";
@@ -10,8 +10,6 @@ import "js-yaml";
10
10
  import "lodash-es";
11
11
  import "sunflower-antd";
12
12
  import "@cloudtower/icons-react";
13
- import "monaco-yaml";
14
- import "react-dom";
15
13
  import "antd";
16
14
  import "k8s-api-provider";
17
15
  const MonacoYamlDiffEditor = (props) => {
@@ -0,0 +1,167 @@
1
+ import { j as jsxRuntimeExports, c as cx_default, Y as YamlEditorStyle } from "./index-3a367ae3.js";
2
+ import * as monaco from "monaco-editor";
3
+ import { setDiagnosticsOptions } from "monaco-yaml";
4
+ import { useRef, useEffect } from "react";
5
+ import ReactDOM from "react-dom";
6
+ import "i18next";
7
+ import "@refinedev/core";
8
+ import "qs";
9
+ import "react-router-dom";
10
+ import "@cloudtower/eagle";
11
+ import "js-yaml";
12
+ import "lodash-es";
13
+ import "sunflower-antd";
14
+ import "@cloudtower/icons-react";
15
+ import "antd";
16
+ import "k8s-api-provider";
17
+ const schemaMap = /* @__PURE__ */ new Map();
18
+ const MonacoYamlEditor = (props) => {
19
+ const ref = useRef(null);
20
+ const instanceRef = useRef({ editor: null });
21
+ const {
22
+ defaultValue,
23
+ id,
24
+ height,
25
+ readOnly,
26
+ schema,
27
+ isScrollOnFocus,
28
+ onChange,
29
+ onValidate,
30
+ getInstance,
31
+ onEditorCreate,
32
+ onBlur
33
+ } = props;
34
+ const uri = id ? monaco.Uri.parse(`${id}.yaml`) : void 0;
35
+ useEffect(() => {
36
+ if (schema) {
37
+ schemaMap.set(id, {
38
+ // Id of the first schema
39
+ uri: String(uri),
40
+ // Associate with our model
41
+ fileMatch: uri ? [String(uri)] : [],
42
+ schema
43
+ });
44
+ }
45
+ const schemas = [...schemaMap.values()];
46
+ setDiagnosticsOptions({
47
+ enableSchemaRequest: false,
48
+ hover: true,
49
+ completion: true,
50
+ validate: true,
51
+ format: true,
52
+ isKubernetes: true,
53
+ schemas
54
+ });
55
+ const model = monaco.editor.createModel(defaultValue, "yaml", uri);
56
+ const editor = monaco.editor.create(ref.current, {
57
+ automaticLayout: true,
58
+ scrollBeyondLastLine: false,
59
+ model,
60
+ scrollbar: {
61
+ handleMouseWheel: !isScrollOnFocus
62
+ },
63
+ tabSize: 2,
64
+ readOnly,
65
+ autoIndent: {}.VITE_IS_TEST ? "none" : "advanced"
66
+ });
67
+ instanceRef.current.editor = editor;
68
+ getInstance == null ? void 0 : getInstance(editor);
69
+ onEditorCreate == null ? void 0 : onEditorCreate(editor);
70
+ return () => {
71
+ instanceRef.current.editor = null;
72
+ schemaMap.delete(id);
73
+ model.dispose();
74
+ editor.dispose();
75
+ };
76
+ }, [defaultValue, schema, id, readOnly, isScrollOnFocus, getInstance]);
77
+ useEffect(() => {
78
+ const editor = instanceRef.current.editor;
79
+ if (editor) {
80
+ const stop = editor.onDidChangeModelContent(() => {
81
+ ReactDOM.unstable_batchedUpdates(() => {
82
+ onChange == null ? void 0 : onChange(editor.getValue());
83
+ });
84
+ });
85
+ return () => {
86
+ stop.dispose();
87
+ };
88
+ }
89
+ }, [onChange, instanceRef.current.editor]);
90
+ useEffect(() => {
91
+ const editor = instanceRef.current.editor;
92
+ if (editor) {
93
+ const stop = monaco.editor.onDidChangeMarkers((uri2) => {
94
+ var _a;
95
+ const model = (_a = instanceRef.current.editor) == null ? void 0 : _a.getModel();
96
+ const currentEditorUri = model == null ? void 0 : model.uri;
97
+ if (model && uri2.toString() === (currentEditorUri == null ? void 0 : currentEditorUri.toString())) {
98
+ const marks = monaco.editor.getModelMarkers({ owner: "yaml", resource: currentEditorUri });
99
+ const yamlMarks = marks.filter((m) => m.source === "YAML");
100
+ const schemaMarks = marks.filter((m) => m.source !== "YAML");
101
+ const yamlValid = yamlMarks.length === 0;
102
+ const schemaValid = schemaMarks.length === 0;
103
+ onValidate == null ? void 0 : onValidate(yamlValid, schemaValid);
104
+ if (marks.some((mark) => {
105
+ var _a2;
106
+ return (_a2 = mark.source) == null ? void 0 : _a2.includes("yaml-schema");
107
+ })) {
108
+ monaco.editor.setModelMarkers(model, "yaml", marks.map((mark) => ({ ...mark, source: "", resource: {} })));
109
+ }
110
+ }
111
+ });
112
+ return () => {
113
+ stop.dispose();
114
+ };
115
+ }
116
+ }, [onValidate, instanceRef.current.editor]);
117
+ useEffect(() => {
118
+ const editor = instanceRef.current.editor;
119
+ if (editor) {
120
+ const stop = editor.onDidBlurEditorWidget(() => {
121
+ ReactDOM.unstable_batchedUpdates(() => {
122
+ onBlur == null ? void 0 : onBlur();
123
+ });
124
+ });
125
+ return () => {
126
+ stop.dispose();
127
+ };
128
+ }
129
+ }, [onBlur, instanceRef.current.editor]);
130
+ useEffect(() => {
131
+ const editor = instanceRef.current.editor;
132
+ const stops = [];
133
+ if (editor && isScrollOnFocus) {
134
+ stops.push(editor.onDidFocusEditorWidget(() => {
135
+ editor.updateOptions({
136
+ scrollbar: {
137
+ handleMouseWheel: true
138
+ }
139
+ });
140
+ }));
141
+ stops.push(editor.onDidBlurEditorWidget(() => {
142
+ editor.updateOptions({
143
+ scrollbar: {
144
+ handleMouseWheel: false
145
+ }
146
+ });
147
+ }));
148
+ }
149
+ return () => {
150
+ stops.forEach((stop) => stop.dispose());
151
+ };
152
+ }, [instanceRef.current.editor, isScrollOnFocus]);
153
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
154
+ "div",
155
+ {
156
+ ref,
157
+ className: cx_default(YamlEditorStyle, props.className),
158
+ style: {
159
+ width: "100%",
160
+ height: height || "500px"
161
+ }
162
+ }
163
+ );
164
+ };
165
+ export {
166
+ MonacoYamlEditor as default
167
+ };