@web-utils/component 4.0.10 → 4.0.11

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.
@@ -1,7 +1,207 @@
1
- import "monaco-editor/esm/vs/editor/editor.api";
2
- import { M as i } from "../chunks/MonacoEditor.D31t4FTy.mjs";
3
- import "@web-utils/core";
4
- import "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
1
+ import * as i from "monaco-editor/esm/vs/editor/editor.api";
2
+ import { c as d } from "../chunks/json-beautifier.Bp3GslGm.mjs";
3
+ import { NOOP as r } from "@web-utils/core";
4
+ import { n as h } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
5
+ const a = {
6
+ name: "MonacoEditor",
7
+ props: {
8
+ diffEditor: { type: Boolean, default: !1 },
9
+ // 是否使用 diff 模式
10
+ width: { type: [String, Number], default: "100%" },
11
+ height: { type: [String, Number], default: "100%" },
12
+ original: String,
13
+ // 只有在 diff 模式下有效
14
+ value: [String, Object],
15
+ language: { type: String, default: "javascript" },
16
+ theme: { type: String, default: "vs" },
17
+ readOnly: { type: Boolean, default: !1 },
18
+ options: {
19
+ type: Object,
20
+ default() {
21
+ return {};
22
+ }
23
+ },
24
+ editorMounted: { type: Function, default: r },
25
+ editorBeforeMount: { type: Function, default: r },
26
+ keyIndex: { type: String }
27
+ },
28
+ data() {
29
+ return {
30
+ fullscreen: !1
31
+ };
32
+ },
33
+ computed: {
34
+ style() {
35
+ return this.fullscreen ? {} : {
36
+ width: /^\d+$/.test(this.width) ? `${this.width}px` : this.width,
37
+ height: /^\d+$/.test(this.height) ? `${this.height}px` : this.height,
38
+ position: "relative"
39
+ };
40
+ }
41
+ },
42
+ watch: {
43
+ options: {
44
+ deep: !0,
45
+ handler(e) {
46
+ var t;
47
+ (t = this.editor) == null || t.updateOptions(e);
48
+ }
49
+ },
50
+ keyIndex() {
51
+ let e = this.value;
52
+ typeof e == "object" && (e = d(e)), this.editor && e !== this._getValue() && this._setValue(e);
53
+ },
54
+ language() {
55
+ if (this.editor)
56
+ if (this.diffEditor) {
57
+ const { original: e, modified: t } = this.editor.getModel();
58
+ i.editor.setModelLanguage(e, this.language), i.editor.setModelLanguage(t, this.language);
59
+ } else
60
+ i.editor.setModelLanguage(this.editor.getModel(), this.language);
61
+ },
62
+ theme() {
63
+ this.editor && i.editor.setTheme(this.theme);
64
+ },
65
+ style() {
66
+ this.$nextTick(() => {
67
+ var e;
68
+ (e = this.editor) == null || e.layout();
69
+ });
70
+ },
71
+ value(e) {
72
+ this.editor && e !== this._getValue() && this._setValue(e);
73
+ }
74
+ },
75
+ mounted() {
76
+ this.initMonaco(), window.addEventListener("resize", this.onResize);
77
+ },
78
+ beforeDestroy() {
79
+ var e;
80
+ window.removeEventListener("resize", this.onResize), (e = this.editor) == null || e.dispose();
81
+ },
82
+ methods: {
83
+ initMonaco() {
84
+ const { value: e, language: t, theme: o, readOnly: n, options: s } = this;
85
+ Object.assign(s, this._editorBeforeMount()), this.editor = i.editor[this.diffEditor ? "createDiffEditor" : "create"](this.$el, {
86
+ value: typeof e == "string" ? e : d(e),
87
+ language: t,
88
+ theme: o,
89
+ readOnly: n,
90
+ ...s
91
+ }), this.diffEditor && this._setModel(this.value, this.original), this._editorMounted(this.editor), this.editor.addAction({
92
+ id: "f1",
93
+ label: "full screen",
94
+ keybindings: [i.KeyCode.F1],
95
+ run: (l) => {
96
+ this.toggleFullScreen();
97
+ }
98
+ }), this.editor.addAction({
99
+ id: "escape",
100
+ label: "exit full screen",
101
+ keybindings: [i.KeyCode.Escape],
102
+ run: (l) => {
103
+ this.fullscreen = !1;
104
+ }
105
+ });
106
+ },
107
+ toggleFullScreen() {
108
+ this.fullscreen = !this.fullscreen;
109
+ },
110
+ async onResize() {
111
+ await this.$nextTick();
112
+ const e = this.$el;
113
+ this.editor.layout({
114
+ width: e.clientWidth,
115
+ height: e.clientHeight
116
+ });
117
+ },
118
+ _handleFullScreen() {
119
+ this.isMaximum ? this.minEditor() : this.maxEditor();
120
+ },
121
+ // 放大
122
+ maxEditor() {
123
+ this.isMaximum = !0;
124
+ const e = this.$el;
125
+ this.originSize = {
126
+ width: e.clientWidth,
127
+ height: e.clientHeight
128
+ }, e.classList.add("editor-fullscreen"), this.editor.layout({
129
+ height: document.body.clientHeight,
130
+ width: document.body.clientWidth
131
+ }), document.addEventListener("keyup", this.handleEsc);
132
+ },
133
+ handleEsc(e) {
134
+ e.keyCode === 27 && this.minEditor();
135
+ },
136
+ // 缩小
137
+ minEditor() {
138
+ this.isMaximum = !1, this.$el.classList.remove("editor-fullscreen"), this.editor.layout({
139
+ height: this.originSize.height,
140
+ width: this.originSize.width
141
+ }), document.removeEventListener("keyup", this.handleEsc);
142
+ },
143
+ _getEditor() {
144
+ return this.editor ? this.diffEditor ? this.editor.modifiedEditor : this.editor : null;
145
+ },
146
+ _setModel(e, t) {
147
+ const { language: o } = this, n = i.editor.createModel(t, o), s = i.editor.createModel(e, o);
148
+ this.editor.setModel({
149
+ original: n,
150
+ modified: s
151
+ });
152
+ },
153
+ _setValue(e) {
154
+ const t = this._getEditor();
155
+ if (t) return t.setValue(e);
156
+ },
157
+ _getValue() {
158
+ const e = this._getEditor();
159
+ return e ? e.getValue() : "";
160
+ },
161
+ _editorBeforeMount() {
162
+ return this.editorBeforeMount(i) || {};
163
+ },
164
+ _editorMounted(e) {
165
+ this.editorMounted(e, i), this.diffEditor ? e.onDidUpdateDiff((t) => {
166
+ const o = this._getValue();
167
+ this._emitChange(o, t);
168
+ }) : e.onDidChangeModelContent((t) => {
169
+ const o = this._getValue();
170
+ this._emitChange(o, t);
171
+ });
172
+ },
173
+ _emitChange(e, t) {
174
+ this.$emit("change", e, t), this.$emit("input", e);
175
+ }
176
+ },
177
+ render(e) {
178
+ const t = this.options.fullScreen;
179
+ return e("div", { class: ["monaco_editor_container", this.fullscreen ? "fullscreen" : ""], style: this.style }, [
180
+ t ? e("i", {
181
+ class: "el-icon-full-screen",
182
+ style: {
183
+ width: "1.2em",
184
+ height: "1.2em",
185
+ position: "absolute",
186
+ left: "0px",
187
+ top: "0px",
188
+ zIndex: "1",
189
+ cursor: "pointer"
190
+ },
191
+ on: { click: this._handleFullScreen }
192
+ }) : ""
193
+ ]);
194
+ }
195
+ }, u = null, c = null;
196
+ var f = /* @__PURE__ */ h(
197
+ a,
198
+ u,
199
+ c,
200
+ !1,
201
+ null,
202
+ null
203
+ );
204
+ const y = f.exports;
5
205
  export {
6
- i as default
206
+ y as default
7
207
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@web-utils/component",
3
3
  "description": "Web Components",
4
- "version": "4.0.10",
4
+ "version": "4.0.11",
5
5
  "author": "Simple",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -1,9 +1,9 @@
1
1
  import o from "../page/index.mjs";
2
- import "./page/style.css";
2
+ import "../page/style.css";
3
3
  import n from "../nav-bar/index.mjs";
4
- import "./nav-bar/style.css";
4
+ import "../nav-bar/style.css";
5
5
  import r from "../page-header/index.mjs";
6
- import "./page-header/style.css";
6
+ import "../page-header/style.css";
7
7
  import { n as a } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
8
8
  const l = {
9
9
  name: "PageSkeleton",
@@ -2,7 +2,7 @@ import { copy as v, hasOwn as P } from "@web-utils/core";
2
2
  import S from "element-ui/lib/message";
3
3
  import { g as _, f as C, i as B, j as A } from "../chunks/index.B2TRddqf.mjs";
4
4
  import { merge as f } from "@web-utils/integrations/lodash";
5
- import { g as K } from "../chunks/dictionary.C6NmC-bT.mjs";
5
+ import { g as K } from "../chunks/dictionary.3O-Io7Vh.mjs";
6
6
  import { _ as T } from "../chunks/helper.BiMLcEEk.mjs";
7
7
  import "vue";
8
8
  import { n as b } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
@@ -1,5 +1,36 @@
1
- import { P as a } from "../chunks/PhotoSwipe.BunkqqPu.mjs";
2
- import "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
1
+ import { p as o } from "../chunks/index.BmYCjxZQ.mjs";
2
+ import { n } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
3
+ const i = {
4
+ name: "PhotoSwipe",
5
+ props: {
6
+ urls: Array,
7
+ selector: {
8
+ type: String,
9
+ default: "img"
10
+ }
11
+ },
12
+ methods: {
13
+ async preview(e) {
14
+ await o(e, this.$refs.wrapper, { selector: this.selector });
15
+ }
16
+ }
17
+ };
18
+ var a = function() {
19
+ var r = this, t = r._self._c;
20
+ return t("div", { ref: "wrapper" }, [r._t("default", function() {
21
+ return r._l(r.urls, function(s) {
22
+ return t("img", { key: s.src, staticStyle: { cursor: "pointer" }, attrs: { width: "100", src: s.src, alt: "" }, on: { click: r.preview } });
23
+ });
24
+ }, { urls: r.urls, preview: r.preview })], 2);
25
+ }, c = [], p = /* @__PURE__ */ n(
26
+ i,
27
+ a,
28
+ c,
29
+ !1,
30
+ null,
31
+ null
32
+ );
33
+ const _ = p.exports;
3
34
  export {
4
- a as default
35
+ _ as default
5
36
  };
@@ -1,7 +1,7 @@
1
1
  import { isInContainer as u, delay as m, hasOwn as a, toStringArray as h } from "@web-utils/core";
2
2
  import { merge as b } from "@web-utils/integrations/lodash";
3
3
  import p from "../resize-observer/index.mjs";
4
- import "./resize-observer/style.css";
4
+ import "../resize-observer/style.css";
5
5
  import { n as v } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
6
6
  const f = [
7
7
  "back",
@@ -1,6 +1,6 @@
1
1
  import { n as f } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
2
2
  import l from "../resize-observer/index.mjs";
3
- import "./resize-observer/style.css";
3
+ import "../resize-observer/style.css";
4
4
  function h(e, t) {
5
5
  for (let s = 0; s < t.length; s++)
6
6
  if (e === t[s])
package/swiper/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getEleWidth as r } from "@web-utils/core";
2
2
  import a from "../resize-observer/index.mjs";
3
- import "./resize-observer/style.css";
3
+ import "../resize-observer/style.css";
4
4
  import { n as o } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
5
5
  const h = {
6
6
  name: "Swiper",
@@ -1,8 +1,8 @@
1
1
  import { _ as T } from "../chunks/helper.BiMLcEEk.mjs";
2
2
  import { h as d } from "vue";
3
- import { g as C } from "../chunks/dictionary.C6NmC-bT.mjs";
3
+ import { g as C } from "../chunks/dictionary.3O-Io7Vh.mjs";
4
4
  import { n as B } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
5
- import { f as V } from "../chunks/core.0Exl13Mz.mjs";
5
+ import { f as V } from "../chunks/core.DJEgjQW6.mjs";
6
6
  const D = {
7
7
  name: "DictRender",
8
8
  inheritAttrs: !1,
@@ -2,8 +2,8 @@ import { isFunction as p, toStringArray as f, isString as o, isArray as c, trace
2
2
  import { merge as i } from "@web-utils/integrations/lodash";
3
3
  import { g as m, h as w } from "../chunks/index.B2TRddqf.mjs";
4
4
  import g from "../form-item-config-provider/index.mjs";
5
- import { r as v, p as _ } from "../chunks/configComponents.DQaqUQFs.mjs";
6
- import { t as a } from "../chunks/core.0Exl13Mz.mjs";
5
+ import { a as v, p as _ } from "../chunks/configComponents.CpKi15WN.mjs";
6
+ import { b as a } from "../chunks/core.DJEgjQW6.mjs";
7
7
  import y from "element-ui/lib/transitions/collapse-transition";
8
8
  import { n as S } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
9
9
  const T = [
@@ -1,6 +1,6 @@
1
1
  import { toStringArray as a } from "@web-utils/core";
2
2
  import { merge as n } from "@web-utils/integrations/lodash";
3
- import { p as l } from "../chunks/configComponents.DQaqUQFs.mjs";
3
+ import { p as l } from "../chunks/configComponents.CpKi15WN.mjs";
4
4
  import { n as i } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
5
5
  const u = [
6
6
  "back",
package/toolbar/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { h as p } from "vue";
2
2
  import { copy as m, NOOP as d } from "@web-utils/core";
3
- import { h as y, g } from "../chunks/configComponents.DQaqUQFs.mjs";
3
+ import { h as y, b as g } from "../chunks/configComponents.CpKi15WN.mjs";
4
4
  import { n as B } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
5
5
  const u = {
6
6
  back: {
@@ -1,5 +1,5 @@
1
1
  import { isFunction as n, isArray as r } from "@web-utils/core";
2
- import { h as a } from "../chunks/configComponents.DQaqUQFs.mjs";
2
+ import { h as a } from "../chunks/configComponents.CpKi15WN.mjs";
3
3
  import { n as l } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
4
4
  const s = {
5
5
  name: "ToolbarButton",
package/web-types.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "framework": "vue",
4
4
  "name": "@web-utils/component",
5
- "version": "4.0.10",
5
+ "version": "4.0.11",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "description-markup": "markdown",