@orchidui/dashboard 0.0.1 → 0.2.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.
@@ -0,0 +1,63 @@
1
+ import { defineComponent as o, ref as i, onMounted as r, openBlock as s, createElementBlock as c } from "vue";
2
+ import { getHighlighter as u } from "shikiji";
3
+ import m from "./Dashboard/CodeBlock/customTheme.js";
4
+ const d = Object.freeze({ displayName: "JSON", name: "json", patterns: [{ include: "#value" }], repository: { array: { begin: "\\[", beginCaptures: { 0: { name: "punctuation.definition.array.begin.json" } }, end: "\\]", endCaptures: { 0: { name: "punctuation.definition.array.end.json" } }, name: "meta.structure.array.json", patterns: [{ include: "#value" }, { match: ",", name: "punctuation.separator.array.json" }, { match: "[^\\s\\]]", name: "invalid.illegal.expected-array-separator.json" }] }, comments: { patterns: [{ begin: "/\\*\\*(?!/)", captures: { 0: { name: "punctuation.definition.comment.json" } }, end: "\\*/", name: "comment.block.documentation.json" }, { begin: "/\\*", captures: { 0: { name: "punctuation.definition.comment.json" } }, end: "\\*/", name: "comment.block.json" }, { captures: { 1: { name: "punctuation.definition.comment.json" } }, match: "(//).*$\\n?", name: "comment.line.double-slash.js" }] }, constant: { match: "\\b(?:true|false|null)\\b", name: "constant.language.json" }, number: { match: `(?x) # turn on extended mode
5
+ -? # an optional minus
6
+ (?:
7
+ 0 # a zero
8
+ | # ...or...
9
+ [1-9] # a 1-9 character
10
+ \\d* # followed by zero or more digits
11
+ )
12
+ (?:
13
+ (?:
14
+ \\. # a period
15
+ \\d+ # followed by one or more digits
16
+ )?
17
+ (?:
18
+ [eE] # an e character
19
+ [+-]? # followed by an option +/-
20
+ \\d+ # followed by one or more digits
21
+ )? # make exponent optional
22
+ )? # make decimal portion optional`, name: "constant.numeric.json" }, object: { begin: "\\{", beginCaptures: { 0: { name: "punctuation.definition.dictionary.begin.json" } }, end: "\\}", endCaptures: { 0: { name: "punctuation.definition.dictionary.end.json" } }, name: "meta.structure.dictionary.json", patterns: [{ comment: "the JSON object key", include: "#objectkey" }, { include: "#comments" }, { begin: ":", beginCaptures: { 0: { name: "punctuation.separator.dictionary.key-value.json" } }, end: "(,)|(?=\\})", endCaptures: { 1: { name: "punctuation.separator.dictionary.pair.json" } }, name: "meta.structure.dictionary.value.json", patterns: [{ comment: "the JSON object value", include: "#value" }, { match: "[^\\s,]", name: "invalid.illegal.expected-dictionary-separator.json" }] }, { match: "[^\\s\\}]", name: "invalid.illegal.expected-dictionary-separator.json" }] }, objectkey: { begin: '"', beginCaptures: { 0: { name: "punctuation.support.type.property-name.begin.json" } }, end: '"', endCaptures: { 0: { name: "punctuation.support.type.property-name.end.json" } }, name: "string.json support.type.property-name.json", patterns: [{ include: "#stringcontent" }] }, string: { begin: '"', beginCaptures: { 0: { name: "punctuation.definition.string.begin.json" } }, end: '"', endCaptures: { 0: { name: "punctuation.definition.string.end.json" } }, name: "string.quoted.double.json", patterns: [{ include: "#stringcontent" }] }, stringcontent: { patterns: [{ match: `(?x) # turn on extended mode
23
+ \\\\ # a literal backslash
24
+ (?: # ...followed by...
25
+ ["\\\\/bfnrt] # one of these characters
26
+ | # ...or...
27
+ u # a u
28
+ [0-9a-fA-F]{4}) # and four hex digits`, name: "constant.character.escape.json" }, { match: "\\\\.", name: "invalid.illegal.unrecognized-string-escape.json" }] }, value: { patterns: [{ include: "#constant" }, { include: "#number" }, { include: "#string" }, { include: "#array" }, { include: "#object" }, { include: "#comments" }] } }, scopeName: "source.json" });
29
+ var p = [
30
+ d
31
+ ];
32
+ const l = ["innerHTML"], h = /* @__PURE__ */ o({
33
+ __name: "OcCodeBlock",
34
+ props: {
35
+ jsonObject: {
36
+ type: String,
37
+ required: !0
38
+ },
39
+ lang: {
40
+ type: String,
41
+ default: "json"
42
+ }
43
+ },
44
+ setup(a) {
45
+ const n = a, e = i();
46
+ return r(async () => {
47
+ const t = await u({
48
+ themes: [m],
49
+ langs: [p]
50
+ });
51
+ e.value = t.codeToHtml(n.jsonObject, {
52
+ theme: "Custom Theme",
53
+ lang: n.lang
54
+ });
55
+ }), (t, g) => (s(), c("div", {
56
+ class: "p-5 rounded bg-oc-gray-900 code-block",
57
+ innerHTML: e.value
58
+ }, null, 8, l));
59
+ }
60
+ });
61
+ export {
62
+ h as default
63
+ };
@@ -0,0 +1,161 @@
1
+ import { ref as p, computed as f, onMounted as v, openBlock as b, createElementBlock as h } from "vue";
2
+ import * as w from "echarts";
3
+ import { useChart as g } from "./Dashboard/composables/useChart.js";
4
+ const L = {
5
+ __name: "OcLineChart",
6
+ props: {
7
+ showTooltip: Boolean,
8
+ showLegend: Boolean,
9
+ showGrid: Boolean,
10
+ chartData: Array,
11
+ labelData: Array,
12
+ tooltipFormatter: Function,
13
+ tooltipValueFormatter: Function
14
+ },
15
+ setup(u) {
16
+ const t = u, o = p({
17
+ index: 0,
18
+ value: 0
19
+ }), l = f(() => ({
20
+ xAxis: {
21
+ type: "category",
22
+ data: t.labelData,
23
+ axisTick: {
24
+ show: !1
25
+ },
26
+ axisLabel: {
27
+ color: "#9295A5"
28
+ },
29
+ axisLine: {
30
+ lineStyle: {
31
+ color: "#F2F2F4"
32
+ }
33
+ },
34
+ axisPointer: {
35
+ show: !0,
36
+ label: {
37
+ show: !1,
38
+ formatter: (r) => {
39
+ const e = l.value.xAxis.data.indexOf(r.value);
40
+ o.value.index = r.value;
41
+ const a = l.value.series[0].data[e];
42
+ o.value.value = (a == null ? void 0 : a.value) || a;
43
+ }
44
+ },
45
+ lineStyle: {
46
+ color: "rgba(0,0,0,0)",
47
+ type: "dashed"
48
+ }
49
+ }
50
+ },
51
+ yAxis: {
52
+ type: "value",
53
+ splitLine: {
54
+ show: !1
55
+ },
56
+ axisLabel: {
57
+ formatter: (r) => Intl.NumberFormat("en", { notation: "compact" }).format(r)
58
+ }
59
+ },
60
+ grid: {
61
+ show: t.showGrid,
62
+ right: 0,
63
+ left: 0,
64
+ top: "10px",
65
+ bottom: 0,
66
+ containLabel: !0
67
+ },
68
+ legend: {
69
+ show: t.showLegend
70
+ },
71
+ tooltip: {
72
+ show: t.showTooltip,
73
+ trigger: "axis",
74
+ padding: 0,
75
+ borderWidth: 0,
76
+ borderRadius: 8,
77
+ formatter: (r) => {
78
+ var n, i, c, d;
79
+ const e = r[0];
80
+ if (t.tooltipFormatter)
81
+ return t.tooltipFormatter(e);
82
+ let a = e.value;
83
+ t.tooltipValueFormatter && (a = t.tooltipValueFormatter(a));
84
+ let x = `<div class="text-oc-text-400 text-sm font-medium flex items-center gap-x-1">
85
+ <div
86
+ class="w-0 h-0 rounded-xs border-l-[4px] border-l-transparent border-r-[4px] border-r-transparent ${((n = e.data) == null ? void 0 : n.percent) < 0 ? "border-t-[6px] border-t-oc-error" : "border-b-[6px] border-b-oc-success"}"
87
+ ></div>
88
+ <div>${((i = e.data) == null ? void 0 : i.percent) === 0 ? "-" : `${Math.abs((c = e.data) == null ? void 0 : c.percent)}%`}</div>
89
+ </div>`;
90
+ return `
91
+ <div class="py-3 px-4 leading-normal">
92
+ <div class="flex w-full justify-between items-center">
93
+ <span class="uppercase text-[10px] font-medium">
94
+ ${e.name}
95
+ </span>
96
+ </div>
97
+ <div class="text-oc-text font-medium text-base flex items-center gap-x-3">
98
+ ${a}
99
+ ${isNaN((d = e.data) == null ? void 0 : d.percent) ? "" : x}
100
+ </div>
101
+ </div>
102
+
103
+ `;
104
+ }
105
+ },
106
+ series: [
107
+ {
108
+ data: t.chartData,
109
+ type: "line",
110
+ smooth: !0,
111
+ showSymbol: !1,
112
+ symbol: "circle",
113
+ areaStyle: {
114
+ color: new w.graphic.LinearGradient(0, 0, 0, 1, [
115
+ {
116
+ offset: 0,
117
+ color: "rgba(36, 101, 222, 0.15)"
118
+ // Start color
119
+ },
120
+ {
121
+ offset: 1,
122
+ color: "rgba(36, 101, 222, 0)"
123
+ // End color
124
+ }
125
+ ])
126
+ },
127
+ lineStyle: {
128
+ color: "#2465DE"
129
+ },
130
+ markLine: {
131
+ symbol: "none",
132
+ animation: !1,
133
+ data: [
134
+ [
135
+ {
136
+ coord: [o.value.index, 0]
137
+ },
138
+ {
139
+ coord: [o.value.index, o.value.value]
140
+ }
141
+ ]
142
+ ],
143
+ silent: !0
144
+ }
145
+ }
146
+ ]
147
+ })), s = p(), { chart: m } = g(s, l);
148
+ return v(() => {
149
+ m.value.getZr().on("globalout", () => {
150
+ o.value.index = 0, o.value.value = 0;
151
+ });
152
+ }), (r, e) => (b(), h("div", {
153
+ ref_key: "lineChart",
154
+ ref: s,
155
+ class: "w-full"
156
+ }, null, 512));
157
+ }
158
+ };
159
+ export {
160
+ L as default
161
+ };
@@ -0,0 +1,136 @@
1
+ import { computed as _, ref as C, openBlock as t, createElementBlock as a, createElementVNode as r, Fragment as n, renderList as h, createBlock as f, unref as x, withCtx as y, normalizeClass as b, normalizeStyle as F, toDisplayString as i, createTextVNode as g, createCommentVNode as T } from "vue";
2
+ import { Tooltip as B, Icon as V } from "@orchidui/core";
3
+ import { useChart as L } from "./Dashboard/composables/useChart.js";
4
+ const O = { class: "flex flex-col items-center" }, S = {
5
+ key: 0,
6
+ class: "flex gap-x-5"
7
+ }, A = ["onClick"], N = {
8
+ key: 1,
9
+ class: "text-sm font-medium text-oc-text-500"
10
+ }, $ = { class: "py-2 text-sm text-oc-text-400 font-medium px-3 w-max" }, E = {
11
+ __name: "OcPieChart",
12
+ props: {
13
+ showTooltip: Boolean,
14
+ showLegend: Boolean,
15
+ showGrid: Boolean,
16
+ chartData: Array,
17
+ tooltipFormatter: Function,
18
+ tooltipValueFormatter: Function,
19
+ additionalOptions: {
20
+ type: Object,
21
+ default: () => ({})
22
+ }
23
+ },
24
+ setup(c, { expose: w }) {
25
+ const l = c, d = _(() => ({
26
+ legend: {
27
+ show: !1
28
+ },
29
+ tooltip: {
30
+ show: l.showTooltip,
31
+ padding: 0,
32
+ formatter: (o) => {
33
+ if (l.tooltipFormatter)
34
+ return l.tooltipFormatter(o);
35
+ let s = o.value;
36
+ return l.tooltipValueFormatter && (s = l.tooltipValueFormatter(s)), `
37
+ <div class="py-3 px-4 leading-normal">
38
+ <div class="flex w-full justify-between items-center">
39
+ <span class="uppercase text-[10px] font-medium">
40
+ ${o.name}
41
+ </span>
42
+ </div>
43
+ <div class="text-oc-text-500 font-medium text-base flex items-center gap-x-3">
44
+ ${s}
45
+ (${o.percent}%)
46
+ </div>
47
+ </div>
48
+
49
+ `;
50
+ }
51
+ },
52
+ series: [
53
+ {
54
+ name: "Payment by",
55
+ type: "pie",
56
+ radius: "80%",
57
+ data: l.chartData,
58
+ label: {
59
+ show: !1
60
+ },
61
+ emphasis: {
62
+ itemStyle: {
63
+ shadowBlur: 10,
64
+ shadowOffsetX: 0,
65
+ shadowColor: "rgba(0, 0, 0, 0.5)"
66
+ }
67
+ }
68
+ }
69
+ ],
70
+ grid: {
71
+ show: l.showGrid,
72
+ right: 0,
73
+ left: 0,
74
+ top: "10px",
75
+ bottom: 0,
76
+ containLabel: !0
77
+ },
78
+ ...l.additionalOptions
79
+ })), p = C(), { chart: v } = L(p, d), u = (o) => {
80
+ v.value.dispatchAction({
81
+ type: "legendToggleSelect",
82
+ name: o.name
83
+ }), o.hide = !o.hide;
84
+ };
85
+ return w({
86
+ toggleLegendName: u
87
+ }), (o, s) => (t(), a("div", O, [
88
+ r("div", {
89
+ ref_key: "pieChart",
90
+ ref: p,
91
+ class: "h-full w-full"
92
+ }, null, 512),
93
+ c.showLegend ? (t(), a("div", S, [
94
+ (t(!0), a(n, null, h(d.value.series[0].data, (e) => (t(), f(x(B), {
95
+ key: e.name,
96
+ position: "top",
97
+ class: "flex items-center",
98
+ distance: 10
99
+ }, {
100
+ default: y(() => [
101
+ r("div", {
102
+ class: b(["flex items-center gap-x-2 cursor-pointer transition-opacity", { "opacity-30": e.hide }]),
103
+ onClick: (m) => u(e)
104
+ }, [
105
+ r("div", {
106
+ class: "w-3 h-3 rounded-full",
107
+ style: F({ background: e.itemStyle.color })
108
+ }, null, 4),
109
+ e.icon ? (t(), f(x(V), {
110
+ key: 0,
111
+ name: e.icon,
112
+ width: "32",
113
+ height: "32"
114
+ }, null, 8, ["name"])) : (t(), a("div", N, i(e.name), 1))
115
+ ], 10, A)
116
+ ]),
117
+ popper: y(() => [
118
+ r("div", $, [
119
+ e.legendTooltip ? (t(), a(n, { key: 0 }, [
120
+ Array.isArray(e.legendTooltip) ? (t(!0), a(n, { key: 0 }, h(e.legendTooltip, (m, k) => (t(), a("div", { key: k }, i(m), 1))), 128)) : (t(), a(n, { key: 1 }, [
121
+ g(i(e.legendTooltip), 1)
122
+ ], 64))
123
+ ], 64)) : (t(), a(n, { key: 1 }, [
124
+ g(i(e.name), 1)
125
+ ], 64))
126
+ ])
127
+ ]),
128
+ _: 2
129
+ }, 1024))), 128))
130
+ ])) : T("", !0)
131
+ ]));
132
+ }
133
+ };
134
+ export {
135
+ E as default
136
+ };