@flowtools/uplot 0.0.8 → 0.0.10

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/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as N, ref as D, onMounted as P, watch as v, nextTick as R, openBlock as p, createElementBlock as u, createTextVNode as j, toDisplayString as d, renderSlot as C, unref as m, createElementVNode as y, createCommentVNode as S, Fragment as U, renderList as L, normalizeClass as M, normalizeStyle as T } from "vue";
1
+ import { defineComponent as F, ref as D, onMounted as N, watch as v, nextTick as P, openBlock as p, createElementBlock as u, renderSlot as j, unref as d, createElementVNode as y, createTextVNode as U, toDisplayString as h, createCommentVNode as S, Fragment as L, renderList as M, normalizeClass as R, normalizeStyle as C } from "vue";
2
2
  import q from "uplot";
3
- import { useElementSize as G, useVModel as B } from "@vueuse/core";
4
- const E = (n) => {
3
+ import { useElementSize as G, useVModel as T } from "@vueuse/core";
4
+ const B = (n) => {
5
5
  if (typeof n == "object" && n !== null) {
6
6
  if (typeof Object.getPrototypeOf == "function") {
7
7
  const r = Object.getPrototypeOf(n);
@@ -16,19 +16,19 @@ const E = (n) => {
16
16
  "Arguments provided to ts-deepmerge must be objects, not arrays."
17
17
  );
18
18
  return a && Object.keys(a).forEach((o) => {
19
- ["__proto__", "constructor", "prototype"].includes(o) || (Array.isArray(r[o]) && Array.isArray(a[o]) ? r[o] = c.options.mergeArrays ? Array.from(new Set(r[o].concat(a[o]))) : a[o] : E(r[o]) && E(a[o]) ? r[o] = c(r[o], a[o]) : r[o] = a[o]);
19
+ ["__proto__", "constructor", "prototype"].includes(o) || (Array.isArray(r[o]) && Array.isArray(a[o]) ? r[o] = c.options.mergeArrays ? Array.from(new Set(r[o].concat(a[o]))) : a[o] : B(r[o]) && B(a[o]) ? r[o] = c(r[o], a[o]) : r[o] = a[o]);
20
20
  }), r;
21
- }, {}), $ = {
21
+ }, {}), E = {
22
22
  mergeArrays: !0
23
23
  };
24
- c.options = $;
24
+ c.options = E;
25
25
  c.withOptions = (n, ...r) => {
26
26
  c.options = {
27
27
  mergeArrays: !0,
28
28
  ...n
29
29
  };
30
30
  const a = c(...r);
31
- return c.options = $, a;
31
+ return c.options = E, a;
32
32
  };
33
33
  const H = { class: "__uplot-root" }, I = {
34
34
  key: 0,
@@ -39,7 +39,7 @@ const H = { class: "__uplot-root" }, I = {
39
39
  }, Y = {
40
40
  key: 2,
41
41
  class: "__uplot-legend-value"
42
- }, te = /* @__PURE__ */ N({
42
+ }, te = /* @__PURE__ */ F({
43
43
  __name: "uplot",
44
44
  props: {
45
45
  options: {},
@@ -52,7 +52,7 @@ const H = { class: "__uplot-root" }, I = {
52
52
  },
53
53
  emits: ["select", "cursor", "update:zoom", "update:series"],
54
54
  setup(n, { expose: r, emit: a }) {
55
- const o = n, _ = a, b = D(), { width: w, height: x } = G(b), z = B(o, "zoom", _, { passive: !0 }), i = B(o, "series", _, { passive: !0 }), F = {
55
+ const o = n, _ = a, b = D(), { width: w, height: x } = G(b), z = T(o, "zoom", _, { passive: !0 }), i = T(o, "series", _, { passive: !0 }), $ = {
56
56
  title: void 0,
57
57
  legend: {
58
58
  show: !1
@@ -73,12 +73,12 @@ const H = { class: "__uplot-root" }, I = {
73
73
  setCursor: [
74
74
  (e) => {
75
75
  _("cursor", e.cursor), i.value = e.series.map((l, t) => {
76
- var f, h;
76
+ var f, m;
77
77
  return {
78
78
  label: l.label,
79
79
  stroke: typeof l.stroke == "function" ? l.stroke(e, t) : null,
80
80
  value: e.cursor.idx && e.data[t][e.cursor.idx] ? typeof l.value == "function" ? l.value(e, e.data[t][e.cursor.idx], t, e.cursor.idx) : e.data[t][e.cursor.idx] : null,
81
- data: (f = e.cursor) != null && f.idx ? e.data[t][(h = e.cursor) == null ? void 0 : h.idx] : null,
81
+ data: (f = e.cursor) != null && f.idx ? e.data[t][(m = e.cursor) == null ? void 0 : m.idx] : null,
82
82
  show: l.show
83
83
  // ...s,
84
84
  };
@@ -106,14 +106,14 @@ const H = { class: "__uplot-root" }, I = {
106
106
  let s;
107
107
  const O = D();
108
108
  function A() {
109
- s && s.destroy(), s = new q({ width: 100, height: 100, ...c(o.options, F) }, o.data, b.value), O.value = s, o.zoom[0] !== null && o.zoom[1] !== null && s.setScale("x", { min: o.zoom[0], max: o.zoom[1] }), setTimeout(() => {
109
+ s && s.destroy(), s = new q({ width: 100, height: 100, ...c(o.options, $) }, o.data, b.value), O.value = s, o.zoom[0] !== null && o.zoom[1] !== null && s.setScale("x", { min: o.zoom[0], max: o.zoom[1] }), setTimeout(() => {
110
110
  k();
111
111
  }, 0);
112
112
  }
113
- P(() => {
113
+ N(() => {
114
114
  A();
115
115
  }), v([w, x], () => {
116
- R(() => {
116
+ P(() => {
117
117
  k();
118
118
  });
119
119
  }), v(o.data, (e) => {
@@ -135,9 +135,8 @@ const H = { class: "__uplot-root" }, I = {
135
135
  typeof e == "object" && (e = ((l = i.value) == null ? void 0 : l.indexOf(e)) || -1), s.setSeries(e, { show: !s.series[e].show }), (t = i.value) != null && t[e] && (i.value[e].show = s.series[e].show);
136
136
  }
137
137
  return r({ toggleShow: g, uplot: O }), (e, l) => (p(), u("div", H, [
138
- j(" r " + d(e.noResetScale) + " ", 1),
139
- C(e.$slots, "header", {
140
- series: m(i),
138
+ j(e.$slots, "header", {
139
+ series: d(i),
141
140
  toggleShow: g
142
141
  }),
143
142
  y("div", {
@@ -146,30 +145,30 @@ const H = { class: "__uplot-root" }, I = {
146
145
  class: "__uplot"
147
146
  }, null, 512),
148
147
  e.showDebug ? (p(), u("div", I, [
149
- j(d(m(w)) + " x " + d(m(x)) + " ", 1),
148
+ U(h(d(w)) + " x " + h(d(x)) + " ", 1),
150
149
  J,
151
- y("pre", K, d(m(i)), 1)
150
+ y("pre", K, h(d(i)), 1)
152
151
  ])) : S("", !0),
153
- e.noFooter ? S("", !0) : C(e.$slots, "footer", {
152
+ e.noFooter ? S("", !0) : j(e.$slots, "footer", {
154
153
  key: 1,
155
- series: m(i),
154
+ series: d(i),
156
155
  toggleShow: g
157
156
  }, () => [
158
157
  y("div", Q, [
159
- (p(!0), u(U, null, L(m(i), (t, f) => {
160
- var h;
158
+ (p(!0), u(L, null, M(d(i), (t, f) => {
159
+ var m;
161
160
  return p(), u("div", {
162
161
  key: t.label,
163
- class: M(["__uplot-legend-series", [`__uplot-${(h = t.label) == null ? void 0 : h.toLowerCase()}`, `__uplot-i-${f}`]]),
164
- style: T({ backgroundColor: t.show ? "" : "lightgrey" }),
162
+ class: R(["__uplot-legend-series", [`__uplot-${(m = t.label) == null ? void 0 : m.toLowerCase()}`, `__uplot-i-${f}`]]),
163
+ style: C({ backgroundColor: t.show ? "" : "lightgrey" }),
165
164
  onClick: (Z) => g(f)
166
165
  }, [
167
166
  f !== 0 ? (p(), u("span", {
168
167
  key: 0,
169
- style: T({ color: t.stroke || "black" }),
168
+ style: C({ color: t.stroke || "black" }),
170
169
  class: "__uplot-legend-label"
171
- }, d(t.label), 5)) : S("", !0),
172
- t.value ? (p(), u("span", X, d(t.value), 1)) : (p(), u("span", Y, "--"))
170
+ }, h(t.label), 5)) : S("", !0),
171
+ t.value ? (p(), u("span", X, h(t.value), 1)) : (p(), u("span", Y, "--"))
173
172
  ], 14, W);
174
173
  }), 128))
175
174
  ])
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("uplot"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","uplot","@vueuse/core"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["change-name"]={},i.vue,i.Uplot,i.core))})(this,function(i,o,D,g){"use strict";const b=c=>{if(typeof c=="object"&&c!==null){if(typeof Object.getPrototypeOf=="function"){const r=Object.getPrototypeOf(c);return r===Object.prototype||r===null}return Object.prototype.toString.call(c)==="[object Object]"}return!1},d=(...c)=>c.reduce((r,a)=>{if(Array.isArray(a))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return a&&Object.keys(a).forEach(t=>{["__proto__","constructor","prototype"].includes(t)||(Array.isArray(r[t])&&Array.isArray(a[t])?r[t]=d.options.mergeArrays?Array.from(new Set(r[t].concat(a[t]))):a[t]:b(r[t])&&b(a[t])?r[t]=d(r[t],a[t]):r[t]=a[t])}),r},{}),w={mergeArrays:!0};d.options=w,d.withOptions=(c,...r)=>{d.options={mergeArrays:!0,...c};const a=d(...r);return d.options=w,a};const E={class:"__uplot-root"},O={key:0,class:"extra-info"},A=o.createElementVNode("br",null,null,-1),j={style:{"text-align":"left"}},C={class:"__uplot-legend"},T=["onClick"],N={key:1,class:"__uplot-legend-value"},V={key:2,class:"__uplot-legend-value"},$=o.defineComponent({__name:"uplot",props:{options:{},data:{},noResetScale:{type:Boolean,default:!1},showDebug:{type:Boolean,default:!1},noFooter:{type:Boolean,default:!1},zoom:{default:()=>[null,null]},series:{}},emits:["select","cursor","update:zoom","update:series"],setup(c,{expose:r,emit:a}){const t=c,h=a,_=o.ref(),{width:y,height:S}=g.useElementSize(_),k=g.useVModel(t,"zoom",h,{passive:!0}),p=g.useVModel(t,"series",h,{passive:!0}),M={title:void 0,legend:{show:!1},hooks:{init:[e=>{t.showDebug&&console.log("init",e),p.value=e.series.map((n,l)=>({label:n.label,stroke:typeof n.stroke=="function"?n.stroke(e,l):null,value:null,data:null,show:n.show}))}],setCursor:[e=>{h("cursor",e.cursor),p.value=e.series.map((n,l)=>{var f,m;return{label:n.label,stroke:typeof n.stroke=="function"?n.stroke(e,l):null,value:e.cursor.idx&&e.data[l][e.cursor.idx]?typeof n.value=="function"?n.value(e,e.data[l][e.cursor.idx],l,e.cursor.idx):e.data[l][e.cursor.idx]:null,data:(f=e.cursor)!=null&&f.idx?e.data[l][(m=e.cursor)==null?void 0:m.idx]:null,show:n.show}})}],setSelect:[e=>{h("select",e.select),t.showDebug&&console.log("setSelect",e.select),k.value=[e.posToVal(e.select.left,"x"),e.posToVal(e.select.left+e.select.width,"x")]}],setScale:[e=>{t.showDebug&&console.log("setScale",e.scales),k.value=[e.scales.x.min||null,e.scales.x.max||null]}]}};let s;const x=o.ref();function z(){s&&s.destroy(),s=new D({width:100,height:100,...d(t.options,M)},t.data,_.value),x.value=s,t.zoom[0]!==null&&t.zoom[1]!==null&&s.setScale("x",{min:t.zoom[0],max:t.zoom[1]}),setTimeout(()=>{B()},0)}o.onMounted(()=>{z()}),o.watch([y,S],()=>{o.nextTick(()=>{B()})}),o.watch(t.data,e=>{if(t.noResetScale){s.setData(e,!1),s.redraw(!1);return}s.setData(e,!0)}),o.watch(t.options,(e,n)=>{t.showDebug&&console.log("watch options",e,n),z()}),o.watch(()=>t.zoom,(e,n)=>{e[0]!==null&&e[1]!==null&&(s.scales.x.min!==e[0]||s.scales.x.max!==e[1])&&(console.log("watch zoom setScale",s.scales.x.min,e[0],s.scales.x.max,e[1]),s.setScale("x",{min:e[0],max:e[1]}))});function B(){s.setSize({width:y.value,height:S.value}),t.showDebug&&console.log("resize",s)}function u(e){var n,l;typeof e=="object"&&(e=((n=p.value)==null?void 0:n.indexOf(e))||-1),s.setSeries(e,{show:!s.series[e].show}),(l=p.value)!=null&&l[e]&&(p.value[e].show=s.series[e].show)}return r({toggleShow:u,uplot:x}),(e,n)=>(o.openBlock(),o.createElementBlock("div",E,[o.createTextVNode(" r "+o.toDisplayString(e.noResetScale)+" ",1),o.renderSlot(e.$slots,"header",{series:o.unref(p),toggleShow:u}),o.createElementVNode("div",{ref_key:"el",ref:_,class:"__uplot"},null,512),e.showDebug?(o.openBlock(),o.createElementBlock("div",O,[o.createTextVNode(o.toDisplayString(o.unref(y))+" x "+o.toDisplayString(o.unref(S))+" ",1),A,o.createElementVNode("pre",j,o.toDisplayString(o.unref(p)),1)])):o.createCommentVNode("",!0),e.noFooter?o.createCommentVNode("",!0):o.renderSlot(e.$slots,"footer",{key:1,series:o.unref(p),toggleShow:u},()=>[o.createElementVNode("div",C,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(p),(l,f)=>{var m;return o.openBlock(),o.createElementBlock("div",{key:l.label,class:o.normalizeClass(["__uplot-legend-series",[`__uplot-${(m=l.label)==null?void 0:m.toLowerCase()}`,`__uplot-i-${f}`]]),style:o.normalizeStyle({backgroundColor:l.show?"":"lightgrey"}),onClick:P=>u(f)},[f!==0?(o.openBlock(),o.createElementBlock("span",{key:0,style:o.normalizeStyle({color:l.stroke||"black"}),class:"__uplot-legend-label"},o.toDisplayString(l.label),5)):o.createCommentVNode("",!0),l.value?(o.openBlock(),o.createElementBlock("span",N,o.toDisplayString(l.value),1)):(o.openBlock(),o.createElementBlock("span",V,"--"))],14,T)}),128))])])]))}});i.Uplot=$,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("uplot"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","uplot","@vueuse/core"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["change-name"]={},i.vue,i.Uplot,i.core))})(this,function(i,o,D,g){"use strict";const w=c=>{if(typeof c=="object"&&c!==null){if(typeof Object.getPrototypeOf=="function"){const r=Object.getPrototypeOf(c);return r===Object.prototype||r===null}return Object.prototype.toString.call(c)==="[object Object]"}return!1},d=(...c)=>c.reduce((r,a)=>{if(Array.isArray(a))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return a&&Object.keys(a).forEach(t=>{["__proto__","constructor","prototype"].includes(t)||(Array.isArray(r[t])&&Array.isArray(a[t])?r[t]=d.options.mergeArrays?Array.from(new Set(r[t].concat(a[t]))):a[t]:w(r[t])&&w(a[t])?r[t]=d(r[t],a[t]):r[t]=a[t])}),r},{}),S={mergeArrays:!0};d.options=S,d.withOptions=(c,...r)=>{d.options={mergeArrays:!0,...c};const a=d(...r);return d.options=S,a};const E={class:"__uplot-root"},O={key:0,class:"extra-info"},A=o.createElementVNode("br",null,null,-1),j={style:{"text-align":"left"}},C={class:"__uplot-legend"},T=["onClick"],N={key:1,class:"__uplot-legend-value"},V={key:2,class:"__uplot-legend-value"},$=o.defineComponent({__name:"uplot",props:{options:{},data:{},noResetScale:{type:Boolean,default:!1},showDebug:{type:Boolean,default:!1},noFooter:{type:Boolean,default:!1},zoom:{default:()=>[null,null]},series:{}},emits:["select","cursor","update:zoom","update:series"],setup(c,{expose:r,emit:a}){const t=c,h=a,_=o.ref(),{width:y,height:b}=g.useElementSize(_),k=g.useVModel(t,"zoom",h,{passive:!0}),p=g.useVModel(t,"series",h,{passive:!0}),M={title:void 0,legend:{show:!1},hooks:{init:[e=>{t.showDebug&&console.log("init",e),p.value=e.series.map((n,l)=>({label:n.label,stroke:typeof n.stroke=="function"?n.stroke(e,l):null,value:null,data:null,show:n.show}))}],setCursor:[e=>{h("cursor",e.cursor),p.value=e.series.map((n,l)=>{var f,m;return{label:n.label,stroke:typeof n.stroke=="function"?n.stroke(e,l):null,value:e.cursor.idx&&e.data[l][e.cursor.idx]?typeof n.value=="function"?n.value(e,e.data[l][e.cursor.idx],l,e.cursor.idx):e.data[l][e.cursor.idx]:null,data:(f=e.cursor)!=null&&f.idx?e.data[l][(m=e.cursor)==null?void 0:m.idx]:null,show:n.show}})}],setSelect:[e=>{h("select",e.select),t.showDebug&&console.log("setSelect",e.select),k.value=[e.posToVal(e.select.left,"x"),e.posToVal(e.select.left+e.select.width,"x")]}],setScale:[e=>{t.showDebug&&console.log("setScale",e.scales),k.value=[e.scales.x.min||null,e.scales.x.max||null]}]}};let s;const x=o.ref();function z(){s&&s.destroy(),s=new D({width:100,height:100,...d(t.options,M)},t.data,_.value),x.value=s,t.zoom[0]!==null&&t.zoom[1]!==null&&s.setScale("x",{min:t.zoom[0],max:t.zoom[1]}),setTimeout(()=>{B()},0)}o.onMounted(()=>{z()}),o.watch([y,b],()=>{o.nextTick(()=>{B()})}),o.watch(t.data,e=>{if(t.noResetScale){s.setData(e,!1),s.redraw(!1);return}s.setData(e,!0)}),o.watch(t.options,(e,n)=>{t.showDebug&&console.log("watch options",e,n),z()}),o.watch(()=>t.zoom,(e,n)=>{e[0]!==null&&e[1]!==null&&(s.scales.x.min!==e[0]||s.scales.x.max!==e[1])&&(console.log("watch zoom setScale",s.scales.x.min,e[0],s.scales.x.max,e[1]),s.setScale("x",{min:e[0],max:e[1]}))});function B(){s.setSize({width:y.value,height:b.value}),t.showDebug&&console.log("resize",s)}function u(e){var n,l;typeof e=="object"&&(e=((n=p.value)==null?void 0:n.indexOf(e))||-1),s.setSeries(e,{show:!s.series[e].show}),(l=p.value)!=null&&l[e]&&(p.value[e].show=s.series[e].show)}return r({toggleShow:u,uplot:x}),(e,n)=>(o.openBlock(),o.createElementBlock("div",E,[o.renderSlot(e.$slots,"header",{series:o.unref(p),toggleShow:u}),o.createElementVNode("div",{ref_key:"el",ref:_,class:"__uplot"},null,512),e.showDebug?(o.openBlock(),o.createElementBlock("div",O,[o.createTextVNode(o.toDisplayString(o.unref(y))+" x "+o.toDisplayString(o.unref(b))+" ",1),A,o.createElementVNode("pre",j,o.toDisplayString(o.unref(p)),1)])):o.createCommentVNode("",!0),e.noFooter?o.createCommentVNode("",!0):o.renderSlot(e.$slots,"footer",{key:1,series:o.unref(p),toggleShow:u},()=>[o.createElementVNode("div",C,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(p),(l,f)=>{var m;return o.openBlock(),o.createElementBlock("div",{key:l.label,class:o.normalizeClass(["__uplot-legend-series",[`__uplot-${(m=l.label)==null?void 0:m.toLowerCase()}`,`__uplot-i-${f}`]]),style:o.normalizeStyle({backgroundColor:l.show?"":"lightgrey"}),onClick:P=>u(f)},[f!==0?(o.openBlock(),o.createElementBlock("span",{key:0,style:o.normalizeStyle({color:l.stroke||"black"}),class:"__uplot-legend-label"},o.toDisplayString(l.label),5)):o.createCommentVNode("",!0),l.value?(o.openBlock(),o.createElementBlock("span",N,o.toDisplayString(l.value),1)):(o.openBlock(),o.createElementBlock("span",V,"--"))],14,T)}),128))])])]))}});i.Uplot=$,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@flowtools/uplot",
3
- "version": "0.0.8",
3
+ "type": "module",
4
+ "version": "0.0.10",
4
5
  "description": "Modern vue component for uplot",
5
6
  "keywords": [
6
7
  "add keywords"
@@ -50,7 +51,7 @@
50
51
  "uplot": "^1.6.28",
51
52
  "vi-canvas-mock": "^1.0.0",
52
53
  "vite": "^5.0.12",
53
- "vite-plugin-dts": "^3.7.1",
54
+ "vite-plugin-dts": "^3.7.2",
54
55
  "vitest": "^1.2.1",
55
56
  "vue": "^3.4.15"
56
57
  },
@@ -61,8 +62,8 @@
61
62
  "build": "vite build --mode production",
62
63
  "dev": "vite",
63
64
  "release": "pnpm build && bumpp --commit --push --tag && pnpm publish",
64
- "lint": "eslint --ext .ts,.tsx,.js,.jsx .",
65
- "lint:fix": "eslint --ext .ts,.tsx,.js,.jsx . --fix",
65
+ "lint": "eslint .",
66
+ "lint:fix": "eslint . --fix",
66
67
  "test": "vitest",
67
68
  "test:watch": "vitest --watch",
68
69
  "coverage": "vitest run --coverage"