@lumal/charts 0.0.1-beta

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lumal contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @lumal/charts
2
+
3
+ Lumal 可选图表包,基于 ECharts 与 vue-echarts 封装轻量图表组件。ECharts 作为 peer dependency,不进入 `@lumal/core` 默认依赖。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @lumal/charts echarts vue-echarts vue
9
+ ```
10
+
11
+ ## 用法
12
+
13
+ ```ts
14
+ import { LumalChart, LumalChartPanel, useChartResize } from '@lumal/charts'
15
+ import '@lumal/charts/style.css'
16
+ ```
17
+
18
+ ```vue
19
+ <LumalChartPanel
20
+ v-model:view="view"
21
+ title="访问趋势"
22
+ :options="options"
23
+ :error="error"
24
+ summary="最近七天访问趋势"
25
+ show-view-toggle
26
+ show-export
27
+ height="320px"
28
+ @retry="reload"
29
+ @export="handleExport"
30
+ >
31
+ <template #query>查询条件</template>
32
+ <template #table>可访问的数据表格</template>
33
+ </LumalChartPanel>
34
+ ```
35
+
36
+ ## 导出
37
+
38
+ - `LumalChart`:基础图表组件,透传 ECharts `options`,容器自适应,并默认响应 reduced-motion。
39
+ - `LumalChartPanel`:支持查询区、图表/表格切换、导出、重试、loading/empty/error 和无障碍摘要的工作流面板。
40
+ - `useChartResize`:监听容器尺寸变化并触发图表 resize。
41
+ - `resolveChartPanelStyle`:图表区/表格区宽度到 CSS 变量的映射。
@@ -0,0 +1,2 @@
1
+ .lumal-chart[data-v-648e0699],.lumal-chart__canvas[data-v-648e0699]{width:100%;height:100%}.lumal-chart-panel[data-v-f90a8d18]{flex-direction:column;gap:12px;display:flex}.lumal-chart-panel__header[data-v-f90a8d18]{justify-content:space-between;align-items:center;gap:16px;display:flex}.lumal-chart-panel__query[data-v-f90a8d18]{border-radius:var(--lumal-radius-base,8px);background:var(--el-fill-color-light,Canvas);padding:12px}.lumal-chart-panel__title[data-v-f90a8d18]{margin:0;font-size:15px;font-weight:600}.lumal-chart-panel__body[data-v-f90a8d18]{width:100%;min-height:160px;position:relative;overflow:hidden}.lumal-chart-panel__body.is-table[data-v-f90a8d18]{overflow:auto}.lumal-chart-panel__status[data-v-f90a8d18]{height:100%;color:var(--el-text-color-secondary,CanvasText);text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:12px;display:flex}.lumal-chart-panel__status button[data-v-f90a8d18],.lumal-chart-panel__actions button[data-v-f90a8d18]{border:1px solid var(--el-border-color,currentColor);border-radius:var(--lumal-radius-base,8px);min-width:44px;min-height:44px;color:var(--el-text-color-primary,CanvasText);background:var(--el-bg-color,Canvas);cursor:pointer;padding:0 14px}.lumal-chart-panel__actions[data-v-f90a8d18]{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.lumal-chart-panel__view-toggle[data-v-f90a8d18]{display:inline-flex}.lumal-chart-panel__view-toggle button[aria-pressed=true][data-v-f90a8d18]{border-color:var(--el-color-primary,Highlight);color:var(--el-color-primary,Highlight);background:var(--el-color-primary-light-9,Canvas)}.lumal-chart-panel__summary[data-v-f90a8d18]{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.lumal-chart-panel button[data-v-f90a8d18]:focus-visible{outline:2px solid var(--el-color-primary,Highlight);outline-offset:2px}@media (width<=640px){.lumal-chart-panel__header[data-v-f90a8d18]{flex-direction:column;align-items:flex-start}.lumal-chart-panel__actions[data-v-f90a8d18]{justify-content:flex-start;width:100%}}
2
+ /*$vite$:1*/
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("vue"),l=require("vue-echarts");l=s(l,1);function u(e,t,n={}){if(n.enabled===!1)return;let r;function i(){e.value?.resize()}function a(e){r?.disconnect(),e&&typeof ResizeObserver<`u`&&(r=new ResizeObserver(()=>i()),r.observe(e))}(0,c.onMounted)(()=>{t&&(a(t.value),(0,c.watch)(t,e=>a(e))),typeof window<`u`&&window.addEventListener(`resize`,i)}),(0,c.onBeforeUnmount)(()=>{r?.disconnect(),typeof window<`u`&&window.removeEventListener(`resize`,i)})}var d=[`aria-label`],f=(0,c.defineComponent)({__name:`LumalChart`,props:{options:{},updateOptions:{default:void 0},autoResize:{type:Boolean,default:!0},animation:{type:Boolean,default:void 0},ariaLabel:{default:`数据图表`},width:{default:`100%`},height:{default:`100%`}},setup(e,{expose:t}){let n=e,r=(0,c.shallowRef)(!1),i=(0,c.shallowRef)(!1),a=(0,c.computed)(()=>({...n.options,animation:n.animation??!i.value})),o;function s(e){i.value=e.matches}let f=(0,c.useTemplateRef)(`chartRef`);return(0,c.onMounted)(()=>{typeof window<`u`&&typeof window.matchMedia==`function`&&(o=window.matchMedia(`(prefers-reduced-motion: reduce)`),s(o),o.addEventListener?.(`change`,s)),(0,c.nextTick)(()=>{r.value=!0})}),(0,c.onBeforeUnmount)(()=>{o?.removeEventListener?.(`change`,s)}),u(f),t({resize:()=>f.value?.resize()}),(t,n)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,{class:`lumal-chart`,role:`img`,"aria-label":e.ariaLabel,style:(0,c.normalizeStyle)({height:e.height,width:e.width})},[r.value?((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.default),{key:0,ref_key:`chartRef`,ref:f,class:`lumal-chart__canvas`,option:a.value,"update-options":e.updateOptions,autoresize:e.autoResize},null,8,[`option`,`update-options`,`autoresize`])):(0,c.createCommentVNode)(``,!0)],12,d))}}),p=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},m=p(f,[[`__scopeId`,`data-v-648e0699`]]);function h(e){if(typeof e==`number`)return Number.isFinite(e)?`${e}px`:void 0;if(typeof e==`string`&&e.trim())return e}function g(e){let t=h(e.chartWidth),n=h(e.tableWidth),r={};return t&&(r[`--lumal-chart-panel-chart-width`]=t),n&&(r[`--lumal-chart-panel-table-width`]=n),Object.keys(r).length>0?r:void 0}var _={key:0,class:`lumal-chart-panel__query`},v={key:1,class:`lumal-chart-panel__header`},y={key:0,class:`lumal-chart-panel__title`},b={class:`lumal-chart-panel__actions`},x={key:0,class:`lumal-chart-panel__view-toggle`,"aria-label":`图表展示方式`},S=[`aria-pressed`],C=[`aria-pressed`],w=[`aria-busy`,`aria-describedby`],T={key:0,class:`lumal-chart-panel__status`,role:`status`},E={key:1,class:`lumal-chart-panel__status is-error`,role:`alert`},D={key:2,class:`lumal-chart-panel__status`,role:`status`},O=p((0,c.defineComponent)({__name:`LumalChartPanel`,props:(0,c.mergeModels)({title:{default:``},options:{default:void 0},loading:{type:Boolean,default:!1},noData:{type:Boolean,default:!1},emptyText:{default:`暂无数据`},height:{default:`320px`},chartWidth:{default:void 0},tableWidth:{default:void 0},error:{type:[Boolean,Error,String],default:!1},errorText:{default:`数据加载失败`},retryText:{default:`重新加载`},summary:{default:``},showExport:{type:Boolean,default:!1},showViewToggle:{type:Boolean,default:!1},animation:{type:Boolean,default:void 0}},{view:{default:`chart`},viewModifiers:{}}),emits:(0,c.mergeModels)([`export`,`retry`],[`update:view`]),setup(e,{expose:t,emit:n}){let r=e,i=n,a=(0,c.useModel)(e,`view`),o=(0,c.useTemplateRef)(`chartRef`),s=`lumal-chart-summary-${(0,c.useId)()}`,l=(0,c.computed)(()=>r.error instanceof Error?r.error.message||r.errorText:typeof r.error==`string`?r.error:r.errorText),u=(0,c.computed)(()=>g({chartWidth:r.chartWidth,tableWidth:r.tableWidth}));return t({resize:()=>o.value?.resize()}),(t,n)=>((0,c.openBlock)(),(0,c.createElementBlock)(`section`,{class:`lumal-chart-panel`,style:(0,c.normalizeStyle)(u.value)},[t.$slots.query?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,_,[(0,c.renderSlot)(t.$slots,`query`,{},void 0,!0)])):(0,c.createCommentVNode)(``,!0),e.title||t.$slots.actions||e.showExport||e.showViewToggle?((0,c.openBlock)(),(0,c.createElementBlock)(`header`,v,[e.title?((0,c.openBlock)(),(0,c.createElementBlock)(`h4`,y,(0,c.toDisplayString)(e.title),1)):(0,c.createCommentVNode)(``,!0),(0,c.createElementVNode)(`div`,b,[(0,c.renderSlot)(t.$slots,`actions`,{},void 0,!0),e.showViewToggle?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,x,[(0,c.createElementVNode)(`button`,{type:`button`,"aria-pressed":a.value===`chart`,onClick:n[0]||=e=>a.value=`chart`},` 图表 `,8,S),(0,c.createElementVNode)(`button`,{type:`button`,"aria-pressed":a.value===`table`,onClick:n[1]||=e=>a.value=`table`},` 表格 `,8,C)])):(0,c.createCommentVNode)(``,!0),e.showExport?((0,c.openBlock)(),(0,c.createElementBlock)(`button`,{key:1,type:`button`,onClick:n[2]||=e=>i(`export`,a.value)},` 导出 `)):(0,c.createCommentVNode)(``,!0)])])):(0,c.createCommentVNode)(``,!0),e.summary?((0,c.openBlock)(),(0,c.createElementBlock)(`p`,{key:2,id:s,class:`lumal-chart-panel__summary`},(0,c.toDisplayString)(e.summary),1)):(0,c.createCommentVNode)(``,!0),(0,c.createElementVNode)(`div`,{class:(0,c.normalizeClass)([`lumal-chart-panel__body`,`is-${a.value}`]),style:(0,c.normalizeStyle)({height:e.height}),"aria-busy":e.loading,"aria-describedby":e.summary?s:void 0},[e.loading?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,T,[(0,c.renderSlot)(t.$slots,`loading`,{},()=>[n[4]||=(0,c.createTextVNode)(` 加载中… `,-1)],!0)])):e.error?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,E,[(0,c.renderSlot)(t.$slots,`error`,{message:l.value,retry:()=>i(`retry`)},()=>[(0,c.createElementVNode)(`span`,null,(0,c.toDisplayString)(l.value),1),(0,c.createElementVNode)(`button`,{type:`button`,onClick:n[3]||=e=>i(`retry`)},(0,c.toDisplayString)(e.retryText),1)],!0)])):e.noData?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,D,[(0,c.renderSlot)(t.$slots,`empty`,{},()=>[(0,c.createTextVNode)((0,c.toDisplayString)(e.emptyText),1)],!0)])):a.value===`table`?(0,c.renderSlot)(t.$slots,`table`,{key:3},void 0,!0):e.options?((0,c.openBlock)(),(0,c.createBlock)(m,{key:4,ref_key:`chartRef`,ref:o,options:e.options,height:e.height,animation:e.animation,"aria-label":e.title||`数据图表`},null,8,[`options`,`height`,`animation`,`aria-label`])):(0,c.renderSlot)(t.$slots,`chart`,{key:5},void 0,!0)],14,w)],4))}}),[[`__scopeId`,`data-v-f90a8d18`]]);function k(e,t){let n=e;return n.install=function(n){n.component(t,e)},n}var A=k(m,`LumalChart`),j=k(O,`LumalChartPanel`);exports.LumalChart=A,exports.LumalChartPanel=j,exports.resolveChartPanelStyle=g,exports.useChartResize=u;
package/dist/index.js ADDED
@@ -0,0 +1,232 @@
1
+ import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, defineComponent as o, mergeModels as s, nextTick as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, renderSlot as m, shallowRef as h, toDisplayString as g, unref as _, useId as v, useModel as y, useTemplateRef as b, watch as x } from "vue";
2
+ import S from "vue-echarts";
3
+ //#region src/useChartResize.ts
4
+ function C(e, t, n = {}) {
5
+ if (n.enabled === !1) return;
6
+ let r;
7
+ function i() {
8
+ e.value?.resize();
9
+ }
10
+ function a(e) {
11
+ r?.disconnect(), e && typeof ResizeObserver < "u" && (r = new ResizeObserver(() => i()), r.observe(e));
12
+ }
13
+ f(() => {
14
+ t && (a(t.value), x(t, (e) => a(e))), typeof window < "u" && window.addEventListener("resize", i);
15
+ }), d(() => {
16
+ r?.disconnect(), typeof window < "u" && window.removeEventListener("resize", i);
17
+ });
18
+ }
19
+ //#endregion
20
+ //#region src/LumalChart.vue?vue&type=script&setup=true&lang.ts
21
+ var w = ["aria-label"], T = /*@__PURE__*/ o({
22
+ __name: "LumalChart",
23
+ props: {
24
+ options: {},
25
+ updateOptions: { default: void 0 },
26
+ autoResize: {
27
+ type: Boolean,
28
+ default: !0
29
+ },
30
+ animation: {
31
+ type: Boolean,
32
+ default: void 0
33
+ },
34
+ ariaLabel: { default: "数据图表" },
35
+ width: { default: "100%" },
36
+ height: { default: "100%" }
37
+ },
38
+ setup(i, { expose: a }) {
39
+ let o = i, s = h(!1), l = h(!1), m = e(() => ({
40
+ ...o.options,
41
+ animation: o.animation ?? !l.value
42
+ })), g;
43
+ function v(e) {
44
+ l.value = e.matches;
45
+ }
46
+ let y = b("chartRef");
47
+ return f(() => {
48
+ typeof window < "u" && typeof window.matchMedia == "function" && (g = window.matchMedia("(prefers-reduced-motion: reduce)"), v(g), g.addEventListener?.("change", v)), c(() => {
49
+ s.value = !0;
50
+ });
51
+ }), d(() => {
52
+ g?.removeEventListener?.("change", v);
53
+ }), C(y), a({ resize: () => y.value?.resize() }), (e, a) => (p(), r("div", {
54
+ class: "lumal-chart",
55
+ role: "img",
56
+ "aria-label": i.ariaLabel,
57
+ style: u({
58
+ height: i.height,
59
+ width: i.width
60
+ })
61
+ }, [s.value ? (p(), t(_(S), {
62
+ key: 0,
63
+ ref_key: "chartRef",
64
+ ref: y,
65
+ class: "lumal-chart__canvas",
66
+ option: m.value,
67
+ "update-options": i.updateOptions,
68
+ autoresize: i.autoResize
69
+ }, null, 8, [
70
+ "option",
71
+ "update-options",
72
+ "autoresize"
73
+ ])) : n("", !0)], 12, w));
74
+ }
75
+ }), E = (e, t) => {
76
+ let n = e.__vccOpts || e;
77
+ for (let [e, r] of t) n[e] = r;
78
+ return n;
79
+ }, D = /*#__PURE__*/ E(T, [["__scopeId", "data-v-648e0699"]]);
80
+ //#endregion
81
+ //#region src/panel-style.ts
82
+ function O(e) {
83
+ if (typeof e == "number") return Number.isFinite(e) ? `${e}px` : void 0;
84
+ if (typeof e == "string" && e.trim()) return e;
85
+ }
86
+ function k(e) {
87
+ let t = O(e.chartWidth), n = O(e.tableWidth), r = {};
88
+ return t && (r["--lumal-chart-panel-chart-width"] = t), n && (r["--lumal-chart-panel-table-width"] = n), Object.keys(r).length > 0 ? r : void 0;
89
+ }
90
+ //#endregion
91
+ //#region src/LumalChartPanel.vue?vue&type=script&setup=true&lang.ts
92
+ var A = {
93
+ key: 0,
94
+ class: "lumal-chart-panel__query"
95
+ }, j = {
96
+ key: 1,
97
+ class: "lumal-chart-panel__header"
98
+ }, M = {
99
+ key: 0,
100
+ class: "lumal-chart-panel__title"
101
+ }, N = { class: "lumal-chart-panel__actions" }, P = {
102
+ key: 0,
103
+ class: "lumal-chart-panel__view-toggle",
104
+ "aria-label": "图表展示方式"
105
+ }, F = ["aria-pressed"], I = ["aria-pressed"], L = ["aria-busy", "aria-describedby"], R = {
106
+ key: 0,
107
+ class: "lumal-chart-panel__status",
108
+ role: "status"
109
+ }, z = {
110
+ key: 1,
111
+ class: "lumal-chart-panel__status is-error",
112
+ role: "alert"
113
+ }, B = {
114
+ key: 2,
115
+ class: "lumal-chart-panel__status",
116
+ role: "status"
117
+ }, V = /*#__PURE__*/ E(/* @__PURE__ */ o({
118
+ __name: "LumalChartPanel",
119
+ props: /*@__PURE__*/ s({
120
+ title: { default: "" },
121
+ options: { default: void 0 },
122
+ loading: {
123
+ type: Boolean,
124
+ default: !1
125
+ },
126
+ noData: {
127
+ type: Boolean,
128
+ default: !1
129
+ },
130
+ emptyText: { default: "暂无数据" },
131
+ height: { default: "320px" },
132
+ chartWidth: { default: void 0 },
133
+ tableWidth: { default: void 0 },
134
+ error: {
135
+ type: [
136
+ Boolean,
137
+ Error,
138
+ String
139
+ ],
140
+ default: !1
141
+ },
142
+ errorText: { default: "数据加载失败" },
143
+ retryText: { default: "重新加载" },
144
+ summary: { default: "" },
145
+ showExport: {
146
+ type: Boolean,
147
+ default: !1
148
+ },
149
+ showViewToggle: {
150
+ type: Boolean,
151
+ default: !1
152
+ },
153
+ animation: {
154
+ type: Boolean,
155
+ default: void 0
156
+ }
157
+ }, {
158
+ view: { default: "chart" },
159
+ viewModifiers: {}
160
+ }),
161
+ emits: /*@__PURE__*/ s(["export", "retry"], ["update:view"]),
162
+ setup(o, { expose: s, emit: c }) {
163
+ let d = o, f = c, h = y(o, "view"), _ = b("chartRef"), x = `lumal-chart-summary-${v()}`, S = e(() => d.error instanceof Error ? d.error.message || d.errorText : typeof d.error == "string" ? d.error : d.errorText), C = e(() => k({
164
+ chartWidth: d.chartWidth,
165
+ tableWidth: d.tableWidth
166
+ }));
167
+ return s({ resize: () => _.value?.resize() }), (e, s) => (p(), r("section", {
168
+ class: "lumal-chart-panel",
169
+ style: u(C.value)
170
+ }, [
171
+ e.$slots.query ? (p(), r("div", A, [m(e.$slots, "query", {}, void 0, !0)])) : n("", !0),
172
+ o.title || e.$slots.actions || o.showExport || o.showViewToggle ? (p(), r("header", j, [o.title ? (p(), r("h4", M, g(o.title), 1)) : n("", !0), i("div", N, [
173
+ m(e.$slots, "actions", {}, void 0, !0),
174
+ o.showViewToggle ? (p(), r("div", P, [i("button", {
175
+ type: "button",
176
+ "aria-pressed": h.value === "chart",
177
+ onClick: s[0] ||= (e) => h.value = "chart"
178
+ }, " 图表 ", 8, F), i("button", {
179
+ type: "button",
180
+ "aria-pressed": h.value === "table",
181
+ onClick: s[1] ||= (e) => h.value = "table"
182
+ }, " 表格 ", 8, I)])) : n("", !0),
183
+ o.showExport ? (p(), r("button", {
184
+ key: 1,
185
+ type: "button",
186
+ onClick: s[2] ||= (e) => f("export", h.value)
187
+ }, " 导出 ")) : n("", !0)
188
+ ])])) : n("", !0),
189
+ o.summary ? (p(), r("p", {
190
+ key: 2,
191
+ id: x,
192
+ class: "lumal-chart-panel__summary"
193
+ }, g(o.summary), 1)) : n("", !0),
194
+ i("div", {
195
+ class: l(["lumal-chart-panel__body", `is-${h.value}`]),
196
+ style: u({ height: o.height }),
197
+ "aria-busy": o.loading,
198
+ "aria-describedby": o.summary ? x : void 0
199
+ }, [o.loading ? (p(), r("div", R, [m(e.$slots, "loading", {}, () => [s[4] ||= a(" 加载中… ", -1)], !0)])) : o.error ? (p(), r("div", z, [m(e.$slots, "error", {
200
+ message: S.value,
201
+ retry: () => f("retry")
202
+ }, () => [i("span", null, g(S.value), 1), i("button", {
203
+ type: "button",
204
+ onClick: s[3] ||= (e) => f("retry")
205
+ }, g(o.retryText), 1)], !0)])) : o.noData ? (p(), r("div", B, [m(e.$slots, "empty", {}, () => [a(g(o.emptyText), 1)], !0)])) : h.value === "table" ? m(e.$slots, "table", { key: 3 }, void 0, !0) : o.options ? (p(), t(D, {
206
+ key: 4,
207
+ ref_key: "chartRef",
208
+ ref: _,
209
+ options: o.options,
210
+ height: o.height,
211
+ animation: o.animation,
212
+ "aria-label": o.title || "数据图表"
213
+ }, null, 8, [
214
+ "options",
215
+ "height",
216
+ "animation",
217
+ "aria-label"
218
+ ])) : m(e.$slots, "chart", { key: 5 }, void 0, !0)], 14, L)
219
+ ], 4));
220
+ }
221
+ }), [["__scopeId", "data-v-f90a8d18"]]);
222
+ //#endregion
223
+ //#region src/index.ts
224
+ function H(e, t) {
225
+ let n = e;
226
+ return n.install = function(n) {
227
+ n.component(t, e);
228
+ }, n;
229
+ }
230
+ var U = H(D, "LumalChart"), W = H(V, "LumalChartPanel");
231
+ //#endregion
232
+ export { U as LumalChart, W as LumalChartPanel, k as resolveChartPanelStyle, C as useChartResize };
@@ -0,0 +1,24 @@
1
+ import type { EChartsOption, SetOptionOpts } from 'echarts';
2
+ /***********************属性定义*********************/
3
+ type __VLS_Props = {
4
+ options: EChartsOption;
5
+ updateOptions?: SetOptionOpts;
6
+ autoResize?: boolean;
7
+ animation?: boolean;
8
+ ariaLabel?: string;
9
+ width?: string;
10
+ height?: string;
11
+ };
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
13
+ resize: () => void | undefined;
14
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
15
+ updateOptions: SetOptionOpts;
16
+ autoResize: boolean;
17
+ animation: boolean;
18
+ ariaLabel: string;
19
+ width: string;
20
+ height: string;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
24
+ //# sourceMappingURL=LumalChart.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LumalChart.vue.d.ts","sourceRoot":"","sources":["../../src/LumalChart.vue"],"names":[],"mappings":"AA8FA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM3D,kDAAkD;AAClD,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,aAAa,CAAA;IACtB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC;AAwHF,QAAA,MAAM,YAAY;;;mBA9HA,aAAa;gBAChB,OAAO;eACR,OAAO;eACP,MAAM;WACV,MAAM;YACL,MAAM;6EA6Hf,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,79 @@
1
+ import type { EChartsOption } from 'echarts';
2
+ import type { ChartPanelWidth } from './panel-style';
3
+ /***********************属性定义*********************/
4
+ type __VLS_Props = {
5
+ title?: string;
6
+ options?: EChartsOption;
7
+ loading?: boolean;
8
+ noData?: boolean;
9
+ emptyText?: string;
10
+ height?: string;
11
+ chartWidth?: ChartPanelWidth;
12
+ tableWidth?: ChartPanelWidth;
13
+ error?: boolean | Error | string;
14
+ errorText?: string;
15
+ retryText?: string;
16
+ summary?: string;
17
+ showExport?: boolean;
18
+ showViewToggle?: boolean;
19
+ animation?: boolean;
20
+ };
21
+ type __VLS_ModelProps = {
22
+ 'view'?: 'chart' | 'table';
23
+ };
24
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
25
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {
26
+ message: string;
27
+ retry: () => void;
28
+ }, __VLS_9: {}, __VLS_11: {}, __VLS_20: {};
29
+ type __VLS_Slots = {} & {
30
+ query?: (props: typeof __VLS_1) => any;
31
+ } & {
32
+ actions?: (props: typeof __VLS_3) => any;
33
+ } & {
34
+ loading?: (props: typeof __VLS_5) => any;
35
+ } & {
36
+ error?: (props: typeof __VLS_7) => any;
37
+ } & {
38
+ empty?: (props: typeof __VLS_9) => any;
39
+ } & {
40
+ table?: (props: typeof __VLS_11) => any;
41
+ } & {
42
+ chart?: (props: typeof __VLS_20) => any;
43
+ };
44
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
45
+ resize: () => void | undefined;
46
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
47
+ export: (view: "chart" | "table") => any;
48
+ retry: () => any;
49
+ "update:view": (value: "chart" | "table") => any;
50
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
51
+ onExport?: ((view: "chart" | "table") => any) | undefined;
52
+ onRetry?: (() => any) | undefined;
53
+ "onUpdate:view"?: ((value: "chart" | "table") => any) | undefined;
54
+ }>, {
55
+ error: boolean | Error | string;
56
+ options: EChartsOption;
57
+ animation: boolean;
58
+ height: string;
59
+ title: string;
60
+ loading: boolean;
61
+ summary: string;
62
+ noData: boolean;
63
+ emptyText: string;
64
+ chartWidth: ChartPanelWidth;
65
+ tableWidth: ChartPanelWidth;
66
+ errorText: string;
67
+ retryText: string;
68
+ showExport: boolean;
69
+ showViewToggle: boolean;
70
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
71
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
72
+ declare const _default: typeof __VLS_export;
73
+ export default _default;
74
+ type __VLS_WithSlots<T, S> = T & {
75
+ new (): {
76
+ $slots: S;
77
+ };
78
+ };
79
+ //# sourceMappingURL=LumalChartPanel.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LumalChartPanel.vue.d.ts","sourceRoot":"","sources":["../../src/LumalChartPanel.vue"],"names":[],"mappings":"AAuPA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAKpD,kDAAkD;AAClD,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAC;AA+CF,KAAK,gBAAgB,GAAG;IACxB,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B,CAAC;AAsBF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA6LxD,QAAA,IAAI,OAAO,IAAU,EAAE,OAAO,IAAU,EAAE,OAAO,IAAU,EAAE,OAAO;;;CAAU,EAAE,OAAO,IAAU,EAAE,QAAQ,IAAW,EAAuB,QAAQ,IAAY,CAAE;AACnK,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC1C;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC5C;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC5C;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC1C;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC1C;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU;;;;;;;;;;;WA1RN,OAAO,GAAG,KAAK,GAAG,MAAM;aAPtB,aAAa;eAaX,OAAO;YATV,MAAM;WALP,MAAM;aAEJ,OAAO;aASP,MAAM;YARP,OAAO;eACJ,MAAM;gBAEL,eAAe;gBACf,eAAe;eAEhB,MAAM;eACN,MAAM;gBAEL,OAAO;oBACH,OAAO;6EA0RxB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { App } from 'vue';
2
+ import LumalChartComp from './LumalChart.vue';
3
+ import LumalChartPanelComp from './LumalChartPanel.vue';
4
+ /***********************导出*********************/
5
+ export declare const LumalChart: typeof LumalChartComp & {
6
+ install: (app: App) => void;
7
+ };
8
+ export declare const LumalChartPanel: typeof LumalChartPanelComp & {
9
+ install: (app: App) => void;
10
+ };
11
+ export { resolveChartPanelStyle, } from './panel-style';
12
+ export type { ChartPanelStyle, ChartPanelWidth, } from './panel-style';
13
+ export { useChartResize, } from './useChartResize';
14
+ export type { ChartResizeTarget, UseChartResizeOptions, } from './useChartResize';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAevD,gDAAgD;AAChD,eAAO,MAAM,UAAU,EAAsF,OAAO,cAAc,GAAG;IAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAAE,CAAA;AACpK,eAAO,MAAM,eAAe,EAAgG,OAAO,mBAAmB,GAAG;IAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAAE,CAAA;AAExL,OAAO,EACL,sBAAsB,GACvB,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,cAAc,GACf,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { CSSProperties } from 'vue';
2
+ /***********************面板尺寸变量*********************/
3
+ export type ChartPanelWidth = number | string;
4
+ export type ChartPanelStyle = CSSProperties & {
5
+ '--lumal-chart-panel-chart-width'?: string;
6
+ '--lumal-chart-panel-table-width'?: string;
7
+ };
8
+ /**
9
+ * 把图表区/表格区宽度映射为 CSS 变量;空值省略以保留样式表默认值。
10
+ */
11
+ export declare function resolveChartPanelStyle(options: {
12
+ chartWidth?: ChartPanelWidth;
13
+ tableWidth?: ChartPanelWidth;
14
+ }): ChartPanelStyle | undefined;
15
+ //# sourceMappingURL=panel-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-style.d.ts","sourceRoot":"","sources":["../../src/panel-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAExC,oDAAoD;AACpD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAA;AAE7C,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,iCAAiC,CAAC,EAAE,MAAM,CAAA;IAC1C,iCAAiC,CAAC,EAAE,MAAM,CAAA;CAC3C,CAAA;AAcD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,UAAU,CAAC,EAAE,eAAe,CAAA;CAC7B,GAAG,eAAe,GAAG,SAAS,CAc9B"}
@@ -0,0 +1,15 @@
1
+ import type { Ref } from 'vue';
2
+ /***********************图表尺寸自适应*********************/
3
+ export interface ChartResizeTarget {
4
+ resize: () => void;
5
+ }
6
+ export interface UseChartResizeOptions {
7
+ /** 是否启用监听,默认 true。 */
8
+ enabled?: boolean;
9
+ }
10
+ /**
11
+ * 监听容器尺寸变化并触发图表实例 resize。
12
+ * 优先使用 ResizeObserver 观察容器元素,回退到 window resize 事件。
13
+ */
14
+ export declare function useChartResize(chartRef: Ref<ChartResizeTarget | null | undefined>, containerRef?: Ref<HTMLElement | null | undefined>, options?: UseChartResizeOptions): void;
15
+ //# sourceMappingURL=useChartResize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChartResize.d.ts","sourceRoot":"","sources":["../../src/useChartResize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG9B,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,GAAG,CAAC,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC,EACnD,YAAY,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EAClD,OAAO,GAAE,qBAA0B,GAClC,IAAI,CAsCN"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@lumal/charts",
3
+ "type": "module",
4
+ "version": "0.0.1-beta",
5
+ "description": "Lumal optional ECharts-based chart components.",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "lumal",
9
+ "vue",
10
+ "echarts",
11
+ "charts"
12
+ ],
13
+ "sideEffects": [
14
+ "**/*.css",
15
+ "**/*.scss"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/src/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ },
26
+ "./style.css": "./dist/charts.css"
27
+ },
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/src/index.d.ts",
31
+ "files": [
32
+ "README.md",
33
+ "dist"
34
+ ],
35
+ "peerDependencies": {
36
+ "echarts": "^5.5.0",
37
+ "vue": "^3.5.0",
38
+ "vue-echarts": "^7.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "echarts": "^5.5.0",
42
+ "vue-echarts": "^7.0.3"
43
+ },
44
+ "scripts": {
45
+ "build": "vite build --config vite.config.ts && vue-tsc -p tsconfig.json --emitDeclarationOnly --outDir dist && node ../../scripts/clean-package-dist.mjs dist",
46
+ "typecheck": "vue-tsc --noEmit -p tsconfig.json",
47
+ "test": "vitest run --config ../../vitest.config.ts tests"
48
+ }
49
+ }