jky-component-lib 0.0.49 → 0.0.54

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 (42) hide show
  1. package/dist/es/code-mirror-editor/CodeMirrorEditor.test.d.ts +1 -0
  2. package/dist/es/code-mirror-editor/CodeMirrorEditor.vue.d.ts +25 -0
  3. package/dist/es/code-mirror-editor/CodeMirrorEditor.vue.js +178 -0
  4. package/dist/es/code-mirror-editor/CodeMirrorEditor.vue3.js +5 -0
  5. package/dist/es/code-mirror-editor/index.d.ts +4 -0
  6. package/dist/es/code-mirror-editor/index.js +8 -0
  7. package/dist/es/code-mirror-editor/style.css +44 -0
  8. package/dist/es/components.d.ts +1 -0
  9. package/dist/es/components.js +4 -1
  10. package/dist/es/form/FormItem.vue.js +245 -94
  11. package/dist/es/index.js +2 -0
  12. package/dist/es/node_modules/@element-plus/icons-vue/dist/index.js +84 -0
  13. package/dist/es/package.json.js +2 -2
  14. package/dist/es/page-header/PopoverMenu.vue.d.ts +1 -1
  15. package/dist/es/style.css +125 -4
  16. package/dist/es/styles.css +1 -1
  17. package/dist/lib/button/Button.vue.js +10 -10
  18. package/dist/lib/button-nav/ButtonNav.vue.js +4 -4
  19. package/dist/lib/code-mirror-editor/CodeMirrorEditor.test.d.ts +1 -0
  20. package/dist/lib/code-mirror-editor/CodeMirrorEditor.vue.d.ts +25 -0
  21. package/dist/lib/code-mirror-editor/CodeMirrorEditor.vue.js +178 -0
  22. package/dist/lib/code-mirror-editor/CodeMirrorEditor.vue3.js +5 -0
  23. package/dist/lib/code-mirror-editor/index.d.ts +4 -0
  24. package/dist/lib/code-mirror-editor/index.js +8 -0
  25. package/dist/lib/code-mirror-editor/style.css +44 -0
  26. package/dist/lib/components.d.ts +1 -0
  27. package/dist/lib/components.js +15 -12
  28. package/dist/lib/form/Form.vue.js +6 -6
  29. package/dist/lib/form/FormItem.vue.js +248 -97
  30. package/dist/lib/index.js +10 -8
  31. package/dist/lib/menu/Aside.vue.js +2 -2
  32. package/dist/lib/menu/Menu.vue.js +2 -2
  33. package/dist/lib/node_modules/@element-plus/icons-vue/dist/index.js +84 -0
  34. package/dist/lib/package.json.js +2 -2
  35. package/dist/lib/page-header/PageHeader.vue.js +2 -2
  36. package/dist/lib/page-header/PopoverMenu.vue.d.ts +1 -1
  37. package/dist/lib/page-header/PopoverMenu.vue.js +12 -12
  38. package/dist/lib/style.css +125 -4
  39. package/dist/lib/styles.css +1 -1
  40. package/dist/umd/index.js +626 -104
  41. package/dist/umd/styles.css +1 -1
  42. package/package.json +6 -1
@@ -0,0 +1,25 @@
1
+ import { CodeMirrorEditorProps } from './types';
2
+ import { EditorView } from '@codemirror/view';
3
+ declare const _default: import('vue').DefineComponent<CodeMirrorEditorProps, {
4
+ getEditor: () => EditorView | null;
5
+ getContent: () => string;
6
+ setContent: (content: string) => void;
7
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
8
+ change: (value: string) => any;
9
+ "update:modelValue": (value: string) => any;
10
+ }, string, import('vue').PublicProps, Readonly<CodeMirrorEditorProps> & Readonly<{
11
+ onChange?: ((value: string) => any) | undefined;
12
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
13
+ }>, {
14
+ disabled: boolean;
15
+ modelValue: string;
16
+ height: string;
17
+ readonly: boolean;
18
+ language: "javascript" | "typescript" | "json" | "css";
19
+ theme: "oneDark" | "default";
20
+ lineNumbers: boolean;
21
+ lineWrapping: boolean;
22
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
23
+ editorRef: HTMLDivElement;
24
+ }, HTMLDivElement>;
25
+ export default _default;
@@ -0,0 +1,178 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, normalizeStyle, createElementVNode } from "vue";
21
+ import { css } from "@codemirror/lang-css";
22
+ import { javascript } from "@codemirror/lang-javascript";
23
+ import { json } from "@codemirror/lang-json";
24
+ import { EditorState } from "@codemirror/state";
25
+ import { oneDark } from "@codemirror/theme-one-dark";
26
+ import { EditorView, lineNumbers } from "@codemirror/view";
27
+ import { basicSetup } from "codemirror";
28
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
29
+ name: "JkyCodeMirrorEditor"
30
+ }), {
31
+ __name: "CodeMirrorEditor",
32
+ props: {
33
+ modelValue: { default: "" },
34
+ height: { default: "400px" },
35
+ disabled: { type: Boolean, default: false },
36
+ readonly: { type: Boolean, default: false },
37
+ language: { default: "javascript" },
38
+ theme: { default: "oneDark" },
39
+ lineNumbers: { type: Boolean, default: true },
40
+ lineWrapping: { type: Boolean, default: false }
41
+ },
42
+ emits: ["update:modelValue", "change"],
43
+ setup(__props, { expose: __expose, emit: __emit }) {
44
+ var _a;
45
+ const props = __props;
46
+ const emit = __emit;
47
+ const editorRef = ref();
48
+ let editorView = null;
49
+ let innerValue = (_a = props.modelValue) != null ? _a : "";
50
+ function getLanguageExtension(language) {
51
+ switch (language) {
52
+ case "typescript":
53
+ case "javascript":
54
+ return javascript({
55
+ jsx: true,
56
+ typescript: language === "typescript"
57
+ });
58
+ case "json":
59
+ return json();
60
+ case "css":
61
+ return css();
62
+ default:
63
+ return javascript();
64
+ }
65
+ }
66
+ function initializeEditor() {
67
+ if (!editorRef.value)
68
+ return;
69
+ const extensions = [
70
+ basicSetup,
71
+ getLanguageExtension(props.language),
72
+ EditorView.updateListener.of((update) => {
73
+ if (update.docChanged) {
74
+ const newValue = update.state.doc.toString();
75
+ innerValue = newValue;
76
+ emit("change", newValue);
77
+ emit("update:modelValue", newValue);
78
+ }
79
+ }),
80
+ EditorView.editable.of(!props.disabled && !props.readonly),
81
+ EditorState.readOnly.of(props.readonly)
82
+ ];
83
+ if (props.theme === "oneDark") {
84
+ extensions.push(oneDark);
85
+ }
86
+ if (!props.lineNumbers) {
87
+ extensions.push(lineNumbers());
88
+ }
89
+ if (props.lineWrapping) {
90
+ extensions.push(EditorView.lineWrapping);
91
+ }
92
+ try {
93
+ editorView = new EditorView({
94
+ state: EditorState.create({
95
+ doc: innerValue,
96
+ extensions
97
+ }),
98
+ parent: editorRef.value
99
+ });
100
+ } catch (error) {
101
+ console.error("Failed to initialize CodeMirror Editor:", error);
102
+ }
103
+ }
104
+ watch(() => props.modelValue, (newValue) => {
105
+ if (newValue !== innerValue && editorView) {
106
+ const currentContent = editorView.state.doc.toString();
107
+ if (currentContent !== newValue) {
108
+ editorView.dispatch({
109
+ changes: {
110
+ from: 0,
111
+ to: currentContent.length,
112
+ insert: newValue
113
+ }
114
+ });
115
+ innerValue = newValue;
116
+ }
117
+ }
118
+ });
119
+ watch(() => props.language, () => {
120
+ if (editorView) {
121
+ const currentValue = editorView.state.doc.toString();
122
+ editorView.destroy();
123
+ innerValue = currentValue;
124
+ initializeEditor();
125
+ }
126
+ });
127
+ watch([() => props.disabled, () => props.readonly], () => {
128
+ if (editorView) {
129
+ const currentValue = editorView.state.doc.toString();
130
+ editorView.destroy();
131
+ innerValue = currentValue;
132
+ initializeEditor();
133
+ }
134
+ });
135
+ onMounted(() => {
136
+ initializeEditor();
137
+ });
138
+ onUnmounted(() => {
139
+ if (editorView) {
140
+ editorView.destroy();
141
+ editorView = null;
142
+ }
143
+ });
144
+ __expose({
145
+ getEditor: () => editorView,
146
+ getContent: () => {
147
+ var _a2;
148
+ return (_a2 = editorView == null ? void 0 : editorView.state.doc.toString()) != null ? _a2 : "";
149
+ },
150
+ setContent: (content) => {
151
+ if (editorView) {
152
+ editorView.dispatch({
153
+ changes: {
154
+ from: 0,
155
+ to: editorView.state.doc.length,
156
+ insert: content
157
+ }
158
+ });
159
+ }
160
+ }
161
+ });
162
+ return (_ctx, _cache) => {
163
+ return openBlock(), createElementBlock("div", {
164
+ class: "j-code-mirror-editor",
165
+ style: normalizeStyle({ height: __props.height })
166
+ }, [
167
+ createElementVNode("div", {
168
+ ref_key: "editorRef",
169
+ ref: editorRef,
170
+ class: "code-mirror-container"
171
+ }, null, 512)
172
+ ], 4);
173
+ };
174
+ }
175
+ }));
176
+ export {
177
+ _sfc_main as default
178
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./CodeMirrorEditor.vue.js";
2
+ /* empty css */
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,4 @@
1
+ import { InstallWithSFC } from '../utils';
2
+ import { default as CodeMirrorEditor } from './CodeMirrorEditor.vue';
3
+ export declare const JkyCodeMirrorEditor: InstallWithSFC<typeof CodeMirrorEditor>;
4
+ export default JkyCodeMirrorEditor;
@@ -0,0 +1,8 @@
1
+ import _sfc_main from "./CodeMirrorEditor.vue.js";
2
+ /* empty css */
3
+ import { installWithSFC } from "../utils/with-install.js";
4
+ const JkyCodeMirrorEditor = installWithSFC(_sfc_main);
5
+ export {
6
+ JkyCodeMirrorEditor,
7
+ JkyCodeMirrorEditor as default
8
+ };
@@ -0,0 +1,44 @@
1
+ :root {
2
+ /* CodeMirror 编辑器基础样式变量 */
3
+ --j-code-mirror-border-color: #dcdfe6;
4
+ --j-code-mirror-border-radius: 4px;
5
+ --j-code-mirror-height: 400px;
6
+ }
7
+ .j-code-mirror-editor {
8
+ width: 100%;
9
+ height: var(--j-code-mirror-height);
10
+ border: 1px solid var(--j-code-mirror-border-color);
11
+ border-radius: var(--j-code-mirror-border-radius);
12
+ overflow: hidden;
13
+ }
14
+ .code-mirror-container {
15
+ height: 100%;
16
+ width: 100%;
17
+ overflow: auto;
18
+ }
19
+
20
+ /* CodeMirror 基础样式覆盖 */
21
+ .code-mirror-container .cm-editor {
22
+ height: 100%;
23
+ }
24
+ .code-mirror-container .cm-scroller {
25
+ overflow: auto;
26
+ font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
27
+ font-size: 14px;
28
+ line-height: 1.5;
29
+ }
30
+ .code-mirror-container .cm-gutters {
31
+ background-color: #f5f7fa;
32
+ border-right: 1px solid #e4e7ed;
33
+ color: #909399;
34
+ }
35
+
36
+ /* 暗黑模式支持 */
37
+ html.dark .j-code-mirror-editor {
38
+ border-color: #4c4d4f;
39
+ }
40
+ html.dark .code-mirror-container .cm-gutters {
41
+ background-color: #2c2d2d;
42
+ border-color: #4c4d4f;
43
+ color: #909399;
44
+ }
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from 'vue';
2
2
  export * from './button';
3
3
  export * from './button-nav';
4
+ export * from './code-mirror-editor';
4
5
  export * from './form';
5
6
  export * from './menu';
6
7
  export * from './page-header';
@@ -1,5 +1,6 @@
1
1
  import { JkyButton } from "./button/index.js";
2
2
  import { JkyButtonNav } from "./button-nav/index.js";
3
+ import { JkyCodeMirrorEditor } from "./code-mirror-editor/index.js";
3
4
  import { JkyForm } from "./form/index.js";
4
5
  import { JkyMenu } from "./menu/index.js";
5
6
  import { JkyPageHeader } from "./page-header/index.js";
@@ -10,11 +11,13 @@ const components = [
10
11
  JkyButtonNav,
11
12
  JkyPageHeader,
12
13
  JkyMenu,
13
- JkyForm
14
+ JkyForm,
15
+ JkyCodeMirrorEditor
14
16
  ];
15
17
  export {
16
18
  JkyButton,
17
19
  JkyButtonNav,
20
+ JkyCodeMirrorEditor,
18
21
  JkyForm,
19
22
  JkyMenu,
20
23
  JkyPageHeader,