@king-one/form-design 0.0.16 → 0.0.18
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/CHANGELOG.md +12 -0
- package/dist/es/index.mjs +16 -13
- package/dist/es/src/components/base/Carousel.vue.mjs +92 -0
- package/dist/es/src/components/base/Carousel.vue2.mjs +4 -0
- package/dist/es/src/components/base/json-preview.vue.mjs +215 -151
- package/dist/es/src/components/form-material.vue.mjs +168 -96
- package/dist/es/src/components/form-panel.vue.mjs +71 -65
- package/dist/es/src/components/panel/index.mjs +23 -13
- package/dist/es/src/components/panel/panel-item.vue.mjs +29 -29
- package/dist/es/src/components/panel/panel-wrapper.mjs +1 -1
- package/dist/es/src/components/panel/widget/date-range.vue.mjs +4 -0
- package/dist/es/src/components/panel/widget/date-range.vue2.mjs +28 -0
- package/dist/es/src/components/panel/widget/date-single.vue.mjs +4 -0
- package/dist/es/src/components/panel/widget/date-single.vue2.mjs +28 -0
- package/dist/es/src/components/panel/widget/kit.vue.mjs +4 -0
- package/dist/es/src/components/panel/widget/kit.vue2.mjs +48 -0
- package/dist/es/src/components/panel/widget/object.vue2.mjs +25 -25
- package/dist/es/src/components/panel/widget/select.vue2.mjs +3 -3
- package/dist/es/src/components/props/form-config.vue.mjs +1 -1
- package/dist/es/src/components/props/widget/BaseProps.vue2.mjs +31 -46
- package/dist/es/src/components/props/widget/InputNumberProps.vue2.mjs +94 -109
- package/dist/es/src/components/props/widget/InputProps.vue2.mjs +49 -64
- package/dist/es/src/components/props/widget/OvertimeProps.vue.mjs +4 -0
- package/dist/es/src/components/props/widget/OvertimeProps.vue2.mjs +17 -0
- package/dist/es/src/components/props/widget/PropsDecorator.mjs +34 -0
- package/dist/es/src/components/props/widget/SelectProps.vue.mjs +4 -0
- package/dist/es/src/components/props/widget/SelectProps.vue2.mjs +88 -0
- package/dist/es/src/components/props/widget/TextareaProps.vue2.mjs +48 -63
- package/dist/es/src/components/props/widget/index.mjs +44 -36
- package/dist/es/src/config/index.mjs +165 -15
- package/dist/es/src/core/Design.mjs +24 -19
- package/dist/es/src/core/Field.mjs +1 -1
- package/dist/es/src/core/FormSchema.mjs +28 -26
- package/dist/es/src/index.mjs +15 -13
- package/dist/es/src/plugins/index.mjs +10 -7
- package/dist/es/src/plugins/modules/drag-put.mjs +14 -0
- package/dist/es/src/utils/debounce.mjs +16 -0
- package/dist/es/src/utils/index.mjs +15 -13
- package/dist/lib/index.js +1 -1
- package/dist/lib/src/components/base/Carousel.vue.js +1 -0
- package/dist/lib/src/components/base/Carousel.vue2.js +1 -0
- package/dist/lib/src/components/base/json-preview.vue.js +6 -6
- package/dist/lib/src/components/form-material.vue.js +10 -1
- package/dist/lib/src/components/form-panel.vue.js +2 -2
- package/dist/lib/src/components/panel/index.js +1 -1
- package/dist/lib/src/components/panel/panel-item.vue.js +1 -1
- package/dist/lib/src/components/panel/panel-wrapper.js +1 -1
- package/dist/lib/src/components/panel/widget/date-range.vue.js +1 -0
- package/dist/lib/src/components/panel/widget/date-range.vue2.js +1 -0
- package/dist/lib/src/components/panel/widget/date-single.vue.js +1 -0
- package/dist/lib/src/components/panel/widget/date-single.vue2.js +1 -0
- package/dist/lib/src/components/panel/widget/kit.vue.js +1 -0
- package/dist/lib/src/components/panel/widget/kit.vue2.js +1 -0
- package/dist/lib/src/components/panel/widget/object.vue2.js +1 -1
- package/dist/lib/src/components/panel/widget/select.vue2.js +1 -1
- package/dist/lib/src/components/props/form-config.vue.js +1 -1
- package/dist/lib/src/components/props/widget/BaseProps.vue2.js +1 -1
- package/dist/lib/src/components/props/widget/InputNumberProps.vue2.js +1 -1
- package/dist/lib/src/components/props/widget/InputProps.vue2.js +1 -1
- package/dist/lib/src/components/props/widget/OvertimeProps.vue.js +1 -0
- package/dist/lib/src/components/props/widget/OvertimeProps.vue2.js +1 -0
- package/dist/lib/src/components/props/widget/PropsDecorator.js +1 -0
- package/dist/lib/src/components/props/widget/SelectProps.vue.js +1 -0
- package/dist/lib/src/components/props/widget/SelectProps.vue2.js +1 -0
- package/dist/lib/src/components/props/widget/TextareaProps.vue2.js +1 -1
- package/dist/lib/src/components/props/widget/index.js +1 -1
- package/dist/lib/src/config/index.js +1 -1
- package/dist/lib/src/core/Design.js +1 -1
- package/dist/lib/src/core/Field.js +1 -1
- package/dist/lib/src/core/FormSchema.js +1 -1
- package/dist/lib/src/index.js +1 -1
- package/dist/lib/src/plugins/index.js +1 -1
- package/dist/lib/src/plugins/modules/drag-put.js +1 -0
- package/dist/lib/src/utils/debounce.js +1 -0
- package/dist/lib/src/utils/index.js +1 -1
- package/dist/theme-chalk/carousel.css +1 -0
- package/dist/theme-chalk/icon.css +1 -1
- package/dist/theme-chalk/index.css +1 -1
- package/dist/theme-chalk/json-preview.css +1 -1
- package/dist/theme-chalk/kit-panel.css +1 -0
- package/dist/theme-chalk/material.css +1 -1
- package/dist/theme-chalk/panel.css +1 -1
- package/dist/types/src/components/base/Carousel.vue.d.ts +65 -0
- package/dist/types/src/components/panel/widget/date-range.vue.d.ts +8 -0
- package/dist/types/src/components/panel/widget/date-single.vue.d.ts +8 -0
- package/dist/types/src/components/panel/widget/kit.vue.d.ts +8 -0
- package/dist/types/src/components/props/widget/OvertimeProps.vue.d.ts +3 -0
- package/dist/types/src/components/props/widget/PropsDecorator.d.ts +3 -0
- package/dist/types/src/components/props/widget/SelectProps.vue.d.ts +3 -0
- package/dist/types/src/components/props/widget/index.d.ts +1 -9
- package/dist/types/src/components/types.d.ts +4 -3
- package/dist/types/src/config/index.d.ts +2 -1
- package/dist/types/src/core/Design.d.ts +93 -41
- package/dist/types/src/core/FormSchema.d.ts +22 -10
- package/dist/types/src/hooks/usePolling.d.ts +5 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/plugins/index.d.ts +3 -1
- package/dist/types/src/plugins/modules/drag-put.d.ts +5 -0
- package/dist/types/src/types.d.ts +29 -6
- package/dist/types/src/utils/debounce.d.ts +10 -0
- package/dist/types/src/utils/index.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/es/index.mjs
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import "./src/index.mjs";
|
|
2
|
-
import { default as t } from "./src/components/
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { default as t } from "./src/components/base/Carousel.vue.mjs";
|
|
3
|
+
import { default as a } from "./src/components/panel/panel-item.vue.mjs";
|
|
4
|
+
import { useInjectDesignContext as f } from "./src/context/design.mjs";
|
|
5
|
+
import { default as p } from "./src/components/form-desgin.mjs";
|
|
5
6
|
import { CreateFormDesign as i } from "./src/core/index.mjs";
|
|
6
|
-
import { default as
|
|
7
|
-
import { BaseSchema as d, ExtendSchema as
|
|
8
|
-
import { onDesignFieldChange as F, onDesignInit as
|
|
7
|
+
import { default as l } from "./src/components/props/form-config.vue.mjs";
|
|
8
|
+
import { BaseSchema as d, ExtendSchema as c, LayoutSchema as h, tempSchema as C } from "./src/config/index.mjs";
|
|
9
|
+
import { onDesignFieldChange as F, onDesignInit as S } from "./src/effects/onEffects.mjs";
|
|
9
10
|
export {
|
|
10
11
|
d as BaseSchema,
|
|
12
|
+
t as Carousel,
|
|
11
13
|
i as CreateFormDesign,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
c as ExtendSchema,
|
|
15
|
+
l as FormConfig,
|
|
16
|
+
p as FormDesign,
|
|
17
|
+
a as FormPanelItem,
|
|
18
|
+
h as LayoutSchema,
|
|
17
19
|
F as onDesignFieldChange,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
S as onDesignInit,
|
|
21
|
+
C as tempSchema,
|
|
22
|
+
f as useInjectDesignContext
|
|
20
23
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { defineComponent as C, ref as s, watch as V, nextTick as c, computed as z, onMounted as _, onUpdated as S, openBlock as T, createElementBlock as x, normalizeClass as A, unref as B, createElementVNode as E, normalizeStyle as N, renderSlot as $ } from "vue";
|
|
2
|
+
import "../../internal.mjs";
|
|
3
|
+
import { useNamespace as b } from "../../hooks/use-namespace/index.mjs";
|
|
4
|
+
const D = /* @__PURE__ */ C({
|
|
5
|
+
__name: "Carousel",
|
|
6
|
+
props: {
|
|
7
|
+
// Allows optional v-model binding or just internal state
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: Number,
|
|
10
|
+
default: 0
|
|
11
|
+
},
|
|
12
|
+
isAnimating: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: !0
|
|
15
|
+
},
|
|
16
|
+
direction: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "horizontal",
|
|
19
|
+
validator: (o) => ["horizontal", "vertical"].includes(o)
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
emits: ["update:modelValue", "afterChange"],
|
|
23
|
+
setup(o, { expose: f, emit: m }) {
|
|
24
|
+
const n = o, r = m, { b: d } = b("carousel"), l = s(), t = s(n.modelValue), u = s(0);
|
|
25
|
+
function a() {
|
|
26
|
+
l.value && (u.value = l.value.children.length);
|
|
27
|
+
}
|
|
28
|
+
V(() => n.modelValue, (e) => {
|
|
29
|
+
e !== t.value && (t.value = e);
|
|
30
|
+
});
|
|
31
|
+
function i(e) {
|
|
32
|
+
e < 0 || e >= u.value || (t.value = e, r("update:modelValue", e), n.isAnimating || r("afterChange", e));
|
|
33
|
+
}
|
|
34
|
+
function p(e) {
|
|
35
|
+
i(e);
|
|
36
|
+
}
|
|
37
|
+
function v() {
|
|
38
|
+
c(() => {
|
|
39
|
+
a(), t.value < u.value - 1 && i(t.value + 1);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function h() {
|
|
43
|
+
c(() => {
|
|
44
|
+
a(), t.value > 0 && i(t.value - 1);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function g() {
|
|
48
|
+
r("afterChange", t.value);
|
|
49
|
+
}
|
|
50
|
+
const k = z(() => {
|
|
51
|
+
const e = -t.value * 100;
|
|
52
|
+
return {
|
|
53
|
+
transform: n.direction === "horizontal" ? `translateX(${e}%)` : `translateY(${e}%)`,
|
|
54
|
+
transition: n.isAnimating ? "transform 0.3s ease-in-out" : "none",
|
|
55
|
+
flexDirection: n.direction === "horizontal" ? "row" : "column"
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return f({
|
|
59
|
+
next: v,
|
|
60
|
+
prev: h,
|
|
61
|
+
goTo: p,
|
|
62
|
+
currentIndex: t
|
|
63
|
+
}), _(a), S(a), (e, y) => (T(), x(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
class: A(B(d)())
|
|
67
|
+
},
|
|
68
|
+
[
|
|
69
|
+
E(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
ref_key: "trackRef",
|
|
73
|
+
ref: l,
|
|
74
|
+
class: "carousel-track",
|
|
75
|
+
style: N(k.value),
|
|
76
|
+
onTransitionend: g
|
|
77
|
+
},
|
|
78
|
+
[
|
|
79
|
+
$(e.$slots, "default")
|
|
80
|
+
],
|
|
81
|
+
36
|
|
82
|
+
/* STYLE, NEED_HYDRATION */
|
|
83
|
+
)
|
|
84
|
+
],
|
|
85
|
+
2
|
|
86
|
+
/* CLASS */
|
|
87
|
+
));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
export {
|
|
91
|
+
D as default
|
|
92
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ref as I, computed as J, onMounted as T, watch as V, openBlock as W, createElementBlock as K, normalizeClass as P, unref as Q, createElementVNode as $, createCommentVNode as U } from "vue";
|
|
2
|
+
import x from "highlight.js/lib/core";
|
|
3
|
+
import X from "highlight.js/lib/languages/json";
|
|
4
4
|
import "../../internal.mjs";
|
|
5
|
-
import { useNamespace as
|
|
6
|
-
const
|
|
5
|
+
import { useNamespace as Y } from "../../hooks/use-namespace/index.mjs";
|
|
6
|
+
const Z = { class: "code-container" }, re = {
|
|
7
7
|
__name: "json-preview",
|
|
8
8
|
props: {
|
|
9
9
|
data: {
|
|
@@ -14,242 +14,306 @@ const U = { class: "code-container" }, nt = {
|
|
|
14
14
|
type: Number,
|
|
15
15
|
default: 2
|
|
16
16
|
},
|
|
17
|
+
// 新增:控制初始是否折叠所有可折叠块
|
|
17
18
|
defaultFoldCollapsed: {
|
|
18
19
|
type: Boolean,
|
|
19
20
|
default: !1
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
|
-
setup(
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
setup(L) {
|
|
24
|
+
const y = L;
|
|
25
|
+
let m = null;
|
|
26
|
+
const { b: R } = Y("json-preview");
|
|
27
|
+
let S = null, w = !1;
|
|
28
|
+
async function k() {
|
|
29
|
+
w || (x.registerLanguage("json", X), S = x, w = !0);
|
|
27
30
|
}
|
|
28
|
-
const
|
|
29
|
-
let
|
|
30
|
-
const
|
|
31
|
+
const h = I(null);
|
|
32
|
+
let b = [];
|
|
33
|
+
const C = J(() => {
|
|
31
34
|
try {
|
|
32
|
-
const n =
|
|
35
|
+
const n = y.data;
|
|
33
36
|
if (typeof n == "string")
|
|
34
37
|
try {
|
|
35
|
-
const
|
|
36
|
-
return JSON.stringify(
|
|
38
|
+
const i = JSON.parse(n);
|
|
39
|
+
return JSON.stringify(i, null, y.indent);
|
|
37
40
|
} catch {
|
|
38
41
|
return n;
|
|
39
42
|
}
|
|
40
|
-
return JSON.stringify(n, null,
|
|
43
|
+
return JSON.stringify(n, null, y.indent);
|
|
41
44
|
} catch {
|
|
42
|
-
return String(
|
|
45
|
+
return String(y.data);
|
|
43
46
|
}
|
|
44
47
|
});
|
|
45
|
-
async function
|
|
46
|
-
const n =
|
|
48
|
+
async function E() {
|
|
49
|
+
const n = h.value;
|
|
47
50
|
if (!n)
|
|
48
51
|
return;
|
|
49
|
-
await
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
n.innerHTML =
|
|
52
|
+
await k();
|
|
53
|
+
const i = String(C.value).split(/\r\n|\r|\n/);
|
|
54
|
+
b = i;
|
|
55
|
+
const a = H(i, y.indent);
|
|
56
|
+
n.innerHTML = F(i, a), m = null, B(n, a), O(n), z(n), y.defaultFoldCollapsed ? D() : _();
|
|
54
57
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
|
|
58
|
+
T(() => {
|
|
59
|
+
E();
|
|
60
|
+
}), V(C, () => {
|
|
61
|
+
E();
|
|
59
62
|
});
|
|
60
|
-
function
|
|
61
|
-
const n =
|
|
63
|
+
function D() {
|
|
64
|
+
const n = h.value;
|
|
62
65
|
if (!n)
|
|
63
66
|
return;
|
|
64
|
-
const
|
|
65
|
-
for (let t =
|
|
66
|
-
const e =
|
|
67
|
+
const i = n.querySelectorAll(".fold-toggle"), a = (r) => n.querySelector(`tr[data-line="${r}"]`), f = (r, l) => {
|
|
68
|
+
for (let t = r + 1; t <= l - 1; t++) {
|
|
69
|
+
const e = a(t);
|
|
67
70
|
e && (e.style.display = "none");
|
|
68
71
|
}
|
|
69
|
-
}, d = (
|
|
70
|
-
if (!Array.isArray(
|
|
72
|
+
}, d = (r, l) => {
|
|
73
|
+
if (!Array.isArray(b))
|
|
71
74
|
return !1;
|
|
72
|
-
for (let t =
|
|
73
|
-
const e = (
|
|
75
|
+
for (let t = r + 1; t <= l - 1; t++) {
|
|
76
|
+
const e = (b[t - 1] || "").trim();
|
|
74
77
|
if (e && e !== "}" && e !== "]")
|
|
75
78
|
return !0;
|
|
76
79
|
}
|
|
77
80
|
return !1;
|
|
78
|
-
},
|
|
79
|
-
const
|
|
80
|
-
return
|
|
81
|
-
},
|
|
82
|
-
const t =
|
|
81
|
+
}, g = (r) => {
|
|
82
|
+
const l = a(r);
|
|
83
|
+
return l ? l.querySelector("td.hljs-ln-code") : null;
|
|
84
|
+
}, c = (r, l) => {
|
|
85
|
+
const t = g(r);
|
|
83
86
|
if (!t)
|
|
84
87
|
return;
|
|
85
88
|
let e = t.querySelector(".fold-ellipsis");
|
|
86
|
-
|
|
89
|
+
l ? (e || (e = document.createElement("span"), e.className = "fold-ellipsis", e.textContent = "…", t.appendChild(e)), e.style.display = "inline") : e && (e.style.display = "none");
|
|
87
90
|
};
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
+
i.forEach((r) => {
|
|
92
|
+
const l = Number(r.getAttribute("data-start")), t = Number(r.getAttribute("data-end"));
|
|
93
|
+
r.setAttribute("data-collapsed", "true"), r.textContent = "▸", f(l, t), d(l, t) && c(l, !0);
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
|
-
function
|
|
94
|
-
const n =
|
|
96
|
+
function _() {
|
|
97
|
+
const n = h.value;
|
|
95
98
|
if (!n)
|
|
96
99
|
return;
|
|
97
|
-
const
|
|
98
|
-
for (let
|
|
99
|
-
const t =
|
|
100
|
+
const i = n.querySelectorAll(".fold-toggle"), a = (c) => n.querySelector(`tr[data-line="${c}"]`), f = (c, r) => {
|
|
101
|
+
for (let l = c + 1; l <= r - 1; l++) {
|
|
102
|
+
const t = a(l);
|
|
100
103
|
t && (t.style.display = "");
|
|
101
104
|
}
|
|
102
|
-
}, d = (
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
},
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
105
|
+
}, d = (c) => {
|
|
106
|
+
const r = a(c);
|
|
107
|
+
return r ? r.querySelector("td.hljs-ln-code") : null;
|
|
108
|
+
}, g = (c, r) => {
|
|
109
|
+
const l = d(c);
|
|
110
|
+
if (!l)
|
|
108
111
|
return;
|
|
109
|
-
let t =
|
|
110
|
-
|
|
112
|
+
let t = l.querySelector(".fold-ellipsis");
|
|
113
|
+
r ? (t || (t = document.createElement("span"), t.className = "fold-ellipsis", t.textContent = "…", l.appendChild(t)), t.style.display = "inline") : t && (t.style.display = "none");
|
|
111
114
|
};
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
+
i.forEach((c) => {
|
|
116
|
+
const r = Number(c.getAttribute("data-start")), l = Number(c.getAttribute("data-end"));
|
|
117
|
+
c.setAttribute("data-collapsed", "false"), c.textContent = "▾", f(r, l), g(r, !1), g(l, !1);
|
|
115
118
|
});
|
|
116
119
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
120
|
+
function H(n) {
|
|
121
|
+
const i = [], a = [];
|
|
119
122
|
for (let d = 0; d < n.length; d++) {
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
122
|
-
if (
|
|
123
|
+
const c = n[d].trim(), r = c.charAt(c.length - 1), l = c.charAt(0);
|
|
124
|
+
if (r === "{" || r === "[") {
|
|
125
|
+
if (c.endsWith("{}") || c.endsWith("[]"))
|
|
123
126
|
continue;
|
|
124
|
-
|
|
127
|
+
a.push({ type: r, start: d + 1 });
|
|
125
128
|
}
|
|
126
|
-
if (
|
|
127
|
-
const t =
|
|
128
|
-
for (let e =
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
|
|
129
|
+
if (l === "}" || l === "]") {
|
|
130
|
+
const t = l;
|
|
131
|
+
for (let e = a.length - 1; e >= 0; e--)
|
|
132
|
+
if (a[e].type === "{" && t === "}" || a[e].type === "[" && t === "]") {
|
|
133
|
+
const o = a[e].start, s = d + 1;
|
|
134
|
+
a.splice(e, 1), s > o + 1 && i.push({ start: o, end: s, type: t });
|
|
132
135
|
break;
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
|
-
const
|
|
137
|
-
for (const d of
|
|
138
|
-
return
|
|
139
|
+
const f = {};
|
|
140
|
+
for (const d of i) f[d.start] = d;
|
|
141
|
+
return f;
|
|
139
142
|
}
|
|
140
|
-
function
|
|
141
|
-
let
|
|
142
|
-
for (let
|
|
143
|
-
const d =
|
|
144
|
-
let
|
|
145
|
-
for (let
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
<tr class="hljs-ln-line" data-line="${d}"><td class="hljs-ln-numbers" data-line-number="${d}"><div class="hljs-ln-n" data-line-number="${d}"></div></td><td class="hljs-ln-code" data-line-number="${d}">${
|
|
143
|
+
function F(n, i) {
|
|
144
|
+
let a = '<table class="hljs-ln">';
|
|
145
|
+
for (let f = 0; f < n.length; f++) {
|
|
146
|
+
const d = f + 1, g = n[f], c = g.length > 0 ? g : " ", r = c.match(/^[\t ]*/), t = (r ? r[0] : "").replace(/\t/g, " ".repeat(y.indent)), e = Math.floor(t.length / y.indent), o = S ? S.highlight(c, { language: "json" }).value : M(c), s = i[d], u = s ? `<span class="fold-toggle" data-start="${d}" data-end="${s.end}" data-collapsed="${y.defaultFoldCollapsed ? "true" : "false"}">${y.defaultFoldCollapsed ? "▸" : "▾"}</span>` : "";
|
|
147
|
+
let p = "";
|
|
148
|
+
for (let v = 0; v < e; v++)
|
|
149
|
+
p += `<i class="indent-guide" data-index="${v}" style="--guide-left: calc(var(--indent-char, 1ch) * var(--indent-size) * ${v})"></i>`;
|
|
150
|
+
const N = `<span class="indent-guides" style="--indent-size:${y.indent}">${p}</span>`, G = `<span class="fold-gutter">${u || " "}</span>`;
|
|
151
|
+
a += `
|
|
152
|
+
<tr class="hljs-ln-line" data-line="${d}"><td class="hljs-ln-numbers" data-line-number="${d}"><div class="hljs-ln-n" data-line-number="${d}"></div></td><td class="hljs-ln-code" data-line-number="${d}">${G}<span class="line-content">${N}${o}</span></td></tr>`;
|
|
150
153
|
}
|
|
151
|
-
return
|
|
152
|
-
</table>`,
|
|
154
|
+
return a += `
|
|
155
|
+
</table>`, a;
|
|
153
156
|
}
|
|
154
|
-
function
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
return
|
|
158
|
-
}, d = (
|
|
159
|
-
for (let
|
|
160
|
-
const
|
|
161
|
-
|
|
157
|
+
function B(n) {
|
|
158
|
+
const i = n.querySelectorAll(".fold-toggle"), a = (e) => n.querySelector(`tr[data-line="${e}"]`), f = (e) => {
|
|
159
|
+
const o = a(e);
|
|
160
|
+
return o ? o.querySelector("td.hljs-ln-code") : null;
|
|
161
|
+
}, d = (e, o) => {
|
|
162
|
+
for (let s = e + 1; s <= o - 1; s++) {
|
|
163
|
+
const u = a(s);
|
|
164
|
+
u && (u.style.display = "none");
|
|
162
165
|
}
|
|
163
|
-
},
|
|
164
|
-
for (let
|
|
165
|
-
const
|
|
166
|
-
|
|
166
|
+
}, g = (e, o) => {
|
|
167
|
+
for (let s = e + 1; s <= o - 1; s++) {
|
|
168
|
+
const u = a(s);
|
|
169
|
+
u && (u.style.display = "");
|
|
167
170
|
}
|
|
168
|
-
},
|
|
169
|
-
if (!Array.isArray(
|
|
171
|
+
}, c = (e, o) => {
|
|
172
|
+
if (!Array.isArray(b))
|
|
170
173
|
return !1;
|
|
171
|
-
for (let
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
+
for (let s = e + 1; s <= o - 1; s++) {
|
|
175
|
+
const u = (b[s - 1] || "").trim();
|
|
176
|
+
if (u && u !== "}" && u !== "]")
|
|
174
177
|
return !0;
|
|
175
178
|
}
|
|
176
179
|
return !1;
|
|
177
|
-
},
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
+
}, r = (e, o) => {
|
|
181
|
+
const s = f(e);
|
|
182
|
+
if (!s)
|
|
180
183
|
return;
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
},
|
|
184
|
-
for (let
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
d(
|
|
184
|
+
let u = s.querySelector(".fold-ellipsis");
|
|
185
|
+
o ? (u || (u = document.createElement("span"), u.className = "fold-ellipsis", u.textContent = "…", s.appendChild(u)), u.style.display = "inline") : u && (u.style.display = "none");
|
|
186
|
+
}, l = (e, o) => {
|
|
187
|
+
for (let s = e + 1; s <= o - 1; s++) {
|
|
188
|
+
const u = n.querySelector(`.fold-toggle[data-start="${s}"]`);
|
|
189
|
+
if (u && u.getAttribute("data-collapsed") === "true") {
|
|
190
|
+
const p = Number(u.getAttribute("data-start")), N = Number(u.getAttribute("data-end"));
|
|
191
|
+
d(p, N), c(p, N) && r(p, !0);
|
|
189
192
|
}
|
|
190
193
|
}
|
|
194
|
+
}, t = (e, o) => {
|
|
195
|
+
if (!m)
|
|
196
|
+
return;
|
|
197
|
+
const s = Number(m.getAttribute("data-line"));
|
|
198
|
+
if (!Number.isNaN(s) && s > e && s < o) {
|
|
199
|
+
m.classList.remove("selected");
|
|
200
|
+
const u = m.querySelector(".indent-guides");
|
|
201
|
+
u && u.classList.remove("selected"), m = null;
|
|
202
|
+
}
|
|
191
203
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
204
|
+
i.forEach((e) => {
|
|
205
|
+
e.addEventListener("click", () => {
|
|
206
|
+
const o = Number(e.getAttribute("data-start")), s = Number(e.getAttribute("data-end")), p = !(e.getAttribute("data-collapsed") === "true");
|
|
207
|
+
e.setAttribute("data-collapsed", p ? "true" : "false"), e.textContent = p ? "▸" : "▾", p ? (d(o, s), t(o, s), c(o, s) && r(o, !0)) : (g(o, s), r(o, !1), r(s, !1), l(o, s)), j(n), q(n);
|
|
196
208
|
});
|
|
197
209
|
});
|
|
198
210
|
}
|
|
199
|
-
function
|
|
200
|
-
const
|
|
201
|
-
return String(n).replace(/[&<>"']/g, (
|
|
211
|
+
function M(n) {
|
|
212
|
+
const i = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
213
|
+
return String(n).replace(/[&<>"']/g, (a) => i[a]);
|
|
202
214
|
}
|
|
203
|
-
function
|
|
204
|
-
n.getAttribute("data-copy-init") !== "true" && (n.setAttribute("data-copy-init", "true"), n.addEventListener("copy", (
|
|
205
|
-
const
|
|
206
|
-
if (!
|
|
215
|
+
function O(n) {
|
|
216
|
+
n.getAttribute("data-copy-init") !== "true" && (n.setAttribute("data-copy-init", "true"), n.addEventListener("copy", (i) => {
|
|
217
|
+
const a = window.getSelection();
|
|
218
|
+
if (!a || a.rangeCount === 0)
|
|
207
219
|
return;
|
|
208
|
-
const
|
|
209
|
-
if (!
|
|
210
|
-
|
|
211
|
-
`)),
|
|
220
|
+
const f = a.getRangeAt(0), d = (p) => p && (p.nodeType === 3 ? p.parentElement : p), g = d(f.startContainer), c = d(f.endContainer), r = g ? g.closest("tr.hljs-ln-line") : null, l = c ? c.closest("tr.hljs-ln-line") : null;
|
|
221
|
+
if (!r || !l || a.isCollapsed) {
|
|
222
|
+
i.clipboardData.setData("text/plain", b.join(`
|
|
223
|
+
`)), i.preventDefault();
|
|
212
224
|
return;
|
|
213
225
|
}
|
|
214
|
-
const t = Number(
|
|
226
|
+
const t = Number(r.getAttribute("data-line")), e = Number(l.getAttribute("data-line"));
|
|
215
227
|
if (Number.isNaN(t) || Number.isNaN(e)) {
|
|
216
|
-
|
|
217
|
-
`)),
|
|
228
|
+
i.clipboardData.setData("text/plain", b.join(`
|
|
229
|
+
`)), i.preventDefault();
|
|
218
230
|
return;
|
|
219
231
|
}
|
|
220
|
-
const
|
|
232
|
+
const o = Math.min(t, e), s = Math.max(t, e), u = b.slice(o - 1, s).join(`
|
|
221
233
|
`);
|
|
222
|
-
|
|
234
|
+
i.clipboardData.setData("text/plain", u), i.preventDefault();
|
|
223
235
|
}));
|
|
224
236
|
}
|
|
225
|
-
function
|
|
226
|
-
n.
|
|
227
|
-
|
|
228
|
-
|
|
237
|
+
function A(n) {
|
|
238
|
+
return n.querySelectorAll(".indent-guides .indent-guide").length;
|
|
239
|
+
}
|
|
240
|
+
function j(n) {
|
|
241
|
+
n.querySelectorAll(".indent-guide.active-guide").forEach((i) => i.classList.remove("active-guide"));
|
|
242
|
+
}
|
|
243
|
+
function q(n) {
|
|
244
|
+
if (!m)
|
|
245
|
+
return;
|
|
246
|
+
const i = Number(m.getAttribute("data-line")), a = A(m);
|
|
247
|
+
if (a < 1)
|
|
248
|
+
return;
|
|
249
|
+
const f = a - 1;
|
|
250
|
+
let d = null, g = null;
|
|
251
|
+
const c = Array.from(n.querySelectorAll(".fold-toggle"));
|
|
252
|
+
for (const l of c) {
|
|
253
|
+
const t = Number(l.getAttribute("data-start")), e = Number(l.getAttribute("data-end"));
|
|
254
|
+
!Number.isNaN(t) && !Number.isNaN(e) && t < i && i < e && (d === null || t > d) && (d = t, g = e);
|
|
255
|
+
}
|
|
256
|
+
const r = Array.from(n.querySelectorAll("tr.hljs-ln-line"));
|
|
257
|
+
for (let l = r.length - 1; l >= 0; l--) {
|
|
258
|
+
const t = r[l], e = Number(t.getAttribute("data-line"));
|
|
259
|
+
if (!(e >= i) && t.style.display !== "none")
|
|
260
|
+
if (d !== null) {
|
|
261
|
+
if (e <= d)
|
|
262
|
+
break;
|
|
263
|
+
if (A(t) > a) {
|
|
264
|
+
const s = t.querySelector(`.indent-guides .indent-guide[data-index="${f}"]`);
|
|
265
|
+
s && s.classList.add("active-guide");
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
if (A(t) <= a)
|
|
269
|
+
break;
|
|
270
|
+
const s = t.querySelector(`.indent-guides .indent-guide[data-index="${f}"]`);
|
|
271
|
+
s && s.classList.add("active-guide");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
for (const l of r) {
|
|
275
|
+
const t = Number(l.getAttribute("data-line"));
|
|
276
|
+
if (t <= i || l.style.display === "none")
|
|
277
|
+
continue;
|
|
278
|
+
if (g !== null && t >= g)
|
|
279
|
+
break;
|
|
280
|
+
const e = A(l);
|
|
281
|
+
if (g === null && e <= a)
|
|
282
|
+
break;
|
|
283
|
+
if (e > a) {
|
|
284
|
+
const o = l.querySelector(`.indent-guides .indent-guide[data-index="${f}"]`);
|
|
285
|
+
o && o.classList.add("active-guide");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function z(n) {
|
|
290
|
+
n.getAttribute("data-select-init") !== "true" && (n.setAttribute("data-select-init", "true"), n.addEventListener("click", (i) => {
|
|
291
|
+
const a = i.target;
|
|
292
|
+
if (!(a instanceof Element) || a.closest(".fold-toggle"))
|
|
229
293
|
return;
|
|
230
|
-
const
|
|
231
|
-
|
|
294
|
+
const f = a.closest("tr.hljs-ln-line");
|
|
295
|
+
f && (m && m !== f && m.classList.remove("selected"), f.classList.add("selected"), m = f, j(n), q(n));
|
|
232
296
|
}));
|
|
233
297
|
}
|
|
234
|
-
return (n,
|
|
298
|
+
return (n, i) => (W(), K(
|
|
235
299
|
"div",
|
|
236
300
|
{
|
|
237
|
-
class:
|
|
301
|
+
class: P(Q(R)())
|
|
238
302
|
},
|
|
239
303
|
[
|
|
240
|
-
|
|
241
|
-
|
|
304
|
+
$("div", Z, [
|
|
305
|
+
$(
|
|
242
306
|
"pre",
|
|
243
307
|
{
|
|
244
308
|
ref_key: "preRef",
|
|
245
|
-
ref:
|
|
309
|
+
ref: h,
|
|
246
310
|
class: "hljs"
|
|
247
311
|
},
|
|
248
312
|
null,
|
|
249
313
|
512
|
|
250
314
|
/* NEED_PATCH */
|
|
251
315
|
),
|
|
252
|
-
|
|
316
|
+
U(" 去掉 fade-mask 与动态高度样式 ")
|
|
253
317
|
])
|
|
254
318
|
],
|
|
255
319
|
2
|
|
@@ -258,5 +322,5 @@ const U = { class: "code-container" }, nt = {
|
|
|
258
322
|
}
|
|
259
323
|
};
|
|
260
324
|
export {
|
|
261
|
-
|
|
325
|
+
re as default
|
|
262
326
|
};
|