oxy-uni-ui 1.1.0 → 1.2.3

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.
Files changed (123) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +59 -1
  3. package/components/common/path.ts +9 -0
  4. package/components/common/util.ts +42 -0
  5. package/components/composables/index.ts +1 -0
  6. package/components/composables/useGlobalLoading.ts +42 -0
  7. package/components/composables/useGlobalMessage.ts +48 -0
  8. package/components/composables/useGlobalToast.ts +84 -0
  9. package/components/composables/useVirtualScroll.ts +173 -0
  10. package/components/oxy-cell/oxy-cell.vue +15 -2
  11. package/components/oxy-cell/types.ts +4 -0
  12. package/components/oxy-checkbox/index.scss +1 -1
  13. package/components/oxy-checkbox/oxy-checkbox.vue +2 -2
  14. package/components/oxy-col-picker/oxy-col-picker.vue +3 -0
  15. package/components/oxy-col-picker/types.ts +5 -1
  16. package/components/oxy-corner/index.scss +121 -1
  17. package/components/oxy-corner/oxy-corner.vue +18 -5
  18. package/components/oxy-corner/types.ts +24 -3
  19. package/components/oxy-date-strip/index.scss +10 -0
  20. package/components/oxy-date-strip/oxy-date-strip.vue +198 -0
  21. package/components/oxy-date-strip/types.ts +98 -0
  22. package/components/oxy-date-strip/utils.ts +67 -0
  23. package/components/oxy-date-strip-item/index.scss +94 -0
  24. package/components/oxy-date-strip-item/oxy-date-strip-item.vue +102 -0
  25. package/components/oxy-date-strip-item/types.ts +53 -0
  26. package/components/oxy-datetime-picker/oxy-datetime-picker.vue +3 -1
  27. package/components/oxy-datetime-picker/types.ts +5 -1
  28. package/components/oxy-echarts/index.scss +17 -0
  29. package/components/oxy-echarts/index.ts +1 -0
  30. package/components/oxy-echarts/oxy-echarts.vue +32 -0
  31. package/components/oxy-echarts/types.ts +12 -0
  32. package/components/oxy-file-list/index.scss +26 -0
  33. package/components/oxy-file-list/oxy-file-list.vue +208 -34
  34. package/components/oxy-file-list/types.ts +58 -2
  35. package/components/oxy-global-loading/oxy-global-loading.vue +53 -0
  36. package/components/oxy-global-message/oxy-global-message.vue +64 -0
  37. package/components/oxy-global-toast/oxy-global-toast.vue +53 -0
  38. package/components/oxy-img-lazy/index.scss +17 -0
  39. package/components/oxy-img-lazy/oxy-img-lazy.vue +332 -0
  40. package/components/oxy-img-lazy/types.ts +69 -0
  41. package/components/oxy-link/index.scss +57 -0
  42. package/components/oxy-link/oxy-link.vue +130 -0
  43. package/components/oxy-link/types.ts +81 -0
  44. package/components/oxy-list/index.scss +8 -1
  45. package/components/oxy-list/oxy-list.vue +121 -40
  46. package/components/oxy-list/types.ts +3 -15
  47. package/components/oxy-picker/oxy-picker.vue +3 -0
  48. package/components/oxy-picker/types.ts +5 -1
  49. package/components/oxy-radio/index.scss +3 -3
  50. package/components/oxy-radio/oxy-radio.vue +1 -1
  51. package/components/oxy-rich-text/icon/emjio.svg +1 -0
  52. package/components/oxy-rich-text/icon/quote.svg +1 -0
  53. package/components/oxy-rich-text/icon/text.svg +1 -0
  54. package/components/oxy-rich-text/icon/title.svg +1 -0
  55. package/components/oxy-rich-text/index.scss +159 -0
  56. package/components/oxy-rich-text/mp-html/card/card.vue +122 -0
  57. package/components/oxy-rich-text/mp-html/card/index.js +7 -0
  58. package/components/oxy-rich-text/mp-html/editable/config.js +15 -0
  59. package/components/oxy-rich-text/mp-html/editable/index.js +553 -0
  60. package/components/oxy-rich-text/mp-html/emoji/index.js +203 -0
  61. package/components/oxy-rich-text/mp-html/highlight/config.js +5 -0
  62. package/components/oxy-rich-text/mp-html/highlight/index.js +96 -0
  63. package/components/oxy-rich-text/mp-html/highlight/prism.css +1 -0
  64. package/components/oxy-rich-text/mp-html/highlight/prism.min.js +7 -0
  65. package/components/oxy-rich-text/mp-html/img-cache/index.js +138 -0
  66. package/components/oxy-rich-text/mp-html/latex/index.js +80 -0
  67. package/components/oxy-rich-text/mp-html/latex/katex.css +1 -0
  68. package/components/oxy-rich-text/mp-html/latex/katex.min.js +1 -0
  69. package/components/oxy-rich-text/mp-html/markdown/index.js +50 -0
  70. package/components/oxy-rich-text/mp-html/markdown/marked.min.js +71 -0
  71. package/components/oxy-rich-text/mp-html/mp-html.d.ts +184 -0
  72. package/components/oxy-rich-text/mp-html/mp-html.vue +675 -0
  73. package/components/oxy-rich-text/mp-html/node/node.vue +1161 -0
  74. package/components/oxy-rich-text/mp-html/parser.js +1428 -0
  75. package/components/oxy-rich-text/mp-html/search/index.js +132 -0
  76. package/components/oxy-rich-text/mp-html/style/index.js +129 -0
  77. package/components/oxy-rich-text/mp-html/style/parser.js +175 -0
  78. package/components/oxy-rich-text/mp-html/template/index.js +67 -0
  79. package/components/oxy-rich-text/mp-html/txv-video/index.js +46 -0
  80. package/components/oxy-rich-text/oxy-rich-text.vue +642 -0
  81. package/components/oxy-rich-text/types.ts +71 -0
  82. package/components/oxy-select/index.scss +255 -0
  83. package/components/oxy-select/oxy-select.vue +421 -0
  84. package/components/oxy-select/types.ts +71 -0
  85. package/components/oxy-select-picker/oxy-select-picker.vue +3 -0
  86. package/components/oxy-select-picker/types.ts +5 -1
  87. package/components/oxy-stream-render/index.scss +6 -0
  88. package/components/oxy-stream-render/oxy-stream-render.vue +204 -0
  89. package/components/oxy-stream-render/types.ts +5 -0
  90. package/components/oxy-tree/index.scss +43 -5
  91. package/components/oxy-tree/oxy-tree.vue +233 -35
  92. package/components/oxy-tree/types.ts +54 -7
  93. package/components/oxy-tree/utils.ts +51 -0
  94. package/components/oxy-virtual-scroll/index.scss +1 -1
  95. package/components/oxy-virtual-scroll/oxy-virtual-scroll.vue +69 -110
  96. package/components/oxy-virtual-scroll/types.ts +95 -5
  97. package/components/oxy-waterfall/index.scss +18 -0
  98. package/components/oxy-waterfall/oxy-waterfall.vue +218 -0
  99. package/components/oxy-waterfall/types.ts +90 -0
  100. package/components/oxy-waterfall-item/index.scss +8 -0
  101. package/components/oxy-waterfall-item/oxy-waterfall-item.vue +89 -0
  102. package/components/oxy-waterfall-item/types.ts +16 -0
  103. package/global.d.ts +7 -0
  104. package/index.ts +3 -0
  105. package/locale/lang/en-US.ts +35 -9
  106. package/locale/lang/zh-CN.ts +31 -5
  107. package/oxy-uni-ui.zip +0 -0
  108. package/package.json +1 -1
  109. package/tags.json +1 -1
  110. package/uni-echarts/changelog.md +2 -0
  111. package/uni-echarts/components/index.js +1 -0
  112. package/uni-echarts/components/uni-echarts/events.js +95 -0
  113. package/uni-echarts/components/uni-echarts/types.d.ts +183 -0
  114. package/uni-echarts/components/uni-echarts/types.js +1 -0
  115. package/uni-echarts/components/uni-echarts/uni-echarts.vue +530 -0
  116. package/uni-echarts/components/uni-echarts/uni-echarts.vue.d.ts +19 -0
  117. package/uni-echarts/global.d.ts +7 -0
  118. package/uni-echarts/index.d.ts +440 -0
  119. package/uni-echarts/index.js +2 -0
  120. package/uni-echarts/package.json +105 -0
  121. package/uni-echarts/shared-core.d.ts +269 -0
  122. package/uni-echarts/shared-core.js +900 -0
  123. package/web-types.json +1 -1
@@ -0,0 +1,900 @@
1
+ import { watch, provide, inject, computed, toValue, onMounted, onBeforeUnmount, shallowRef, watchEffect, getCurrentInstance } from 'vue';
2
+
3
+ function useAutoresize(chart, {
4
+ echarts,
5
+ autoresize,
6
+ root
7
+ }) {
8
+ watch(
9
+ [chart, autoresize, root],
10
+ (values, _, onCleanup) => {
11
+ const _chart = values[0];
12
+ const _autoresize = values[1];
13
+ const _root = values[2];
14
+ let observer = null;
15
+ if (_chart != null && _root != null && _autoresize) {
16
+ const { offsetWidth, offsetHeight } = _root.$el;
17
+ const autoresizeOptions = _autoresize === true ? {} : _autoresize;
18
+ const { throttle: wait = 100, onResize } = autoresizeOptions;
19
+ let triggered = false;
20
+ const callback = () => {
21
+ _chart.resize({
22
+ width: _root.$el.offsetWidth,
23
+ height: _root.$el.offsetHeight
24
+ });
25
+ if (onResize != null) {
26
+ onResize();
27
+ }
28
+ };
29
+ const resizeCallback = wait ? echarts.throttle(callback, wait) : callback;
30
+ observer = new ResizeObserver(() => {
31
+ if (!triggered) {
32
+ triggered = true;
33
+ if (_root.$el.offsetWidth === offsetWidth && _root.$el.offsetHeight === offsetHeight) {
34
+ return;
35
+ }
36
+ }
37
+ if (_root.$el.offsetWidth === 0 || _root.$el.offsetHeight === 0) {
38
+ return;
39
+ }
40
+ resizeCallback();
41
+ });
42
+ observer.observe(_root.$el);
43
+ }
44
+ onCleanup(() => {
45
+ if (observer == null) {
46
+ return;
47
+ }
48
+ observer.disconnect();
49
+ observer = null;
50
+ });
51
+ }
52
+ );
53
+ }
54
+
55
+ const ECHARTS_KEY = Symbol("UniEcharts.echarts");
56
+ function provideEcharts(echarts) {
57
+ provide(ECHARTS_KEY, echarts);
58
+ }
59
+ function useEcharts() {
60
+ return inject(ECHARTS_KEY);
61
+ }
62
+
63
+ function isEmpty(value) {
64
+ if (value == null) {
65
+ return true;
66
+ }
67
+ if (typeof value === "string" || Array.isArray(value)) {
68
+ return value.length === 0;
69
+ }
70
+ if (typeof value === "object") {
71
+ return Object.keys(value).length === 0;
72
+ }
73
+ return false;
74
+ }
75
+ function defaultTo(value, ...defaultValues) {
76
+ if (defaultValues.length === 0) {
77
+ return value;
78
+ }
79
+ if (value == null || value !== value) {
80
+ return defaultTo(defaultValues[0], ...defaultValues.slice(1));
81
+ }
82
+ return value;
83
+ }
84
+ function sleep(timeout) {
85
+ return new Promise((resolve) => {
86
+ setTimeout(resolve, timeout);
87
+ });
88
+ }
89
+ function upperFirst(value) {
90
+ return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
91
+ }
92
+ function lowerFirst(value) {
93
+ return `${value.charAt(0).toLowerCase()}${value.slice(1)}`;
94
+ }
95
+
96
+ function mitt(events) {
97
+ const _events = defaultTo(events, /* @__PURE__ */ new Map());
98
+ return {
99
+ events: _events,
100
+ on(topic, handler) {
101
+ const handlers = _events.get(topic);
102
+ if (handlers) {
103
+ handlers.push(handler);
104
+ } else {
105
+ _events.set(topic, [handler]);
106
+ }
107
+ },
108
+ off(topic, handler) {
109
+ const handlers = _events.get(topic);
110
+ if (handlers) {
111
+ if (handler) {
112
+ handlers.splice(handlers.indexOf(handler) >>> 0, 1);
113
+ } else {
114
+ _events.set(topic, []);
115
+ }
116
+ }
117
+ },
118
+ emit(topic, event) {
119
+ const handlers = _events.get(topic);
120
+ if (handlers) {
121
+ for (const handler of handlers.slice()) {
122
+ handler(event);
123
+ }
124
+ }
125
+ const hdlrs = _events.get("*");
126
+ if (hdlrs) {
127
+ for (const handler of hdlrs.slice()) {
128
+ handler(topic, event);
129
+ }
130
+ }
131
+ }
132
+ };
133
+ }
134
+
135
+ const platform = process.env.UNI_PLATFORM;
136
+ const appPlatform = (function() {
137
+ let plat;
138
+ // #ifdef APP-ANDROID
139
+ plat = "android";
140
+ // #endif
141
+ // #ifdef APP-IOS
142
+ plat = "ios";
143
+ // #endif
144
+ // #ifdef APP-HARMONY
145
+ plat = "harmony";
146
+ // #endif
147
+ return plat;
148
+ })();
149
+ const isApp = platform === "app";
150
+ const isWeb = platform === "web" || platform === "h5";
151
+ const isMp = /^mp-/i.test(platform);
152
+ const isQuickapp = /^quickapp-webview/i.test(platform);
153
+ const isAppAndroid = appPlatform === "android";
154
+ const isAppIos = appPlatform === "ios";
155
+ const isAppHarmony = appPlatform === "harmony";
156
+ const isMp360 = platform === "mp-360";
157
+ const isMpAlipay = platform === "mp-alipay";
158
+ const isMpBaidu = platform === "mp-baidu";
159
+ const isMpHarmony = platform === "mp-harmony";
160
+ const isMpJd = platform === "mp-jd";
161
+ const isMpKuaishou = platform === "mp-kuaishou";
162
+ const isMpLark = platform === "mp-lark";
163
+ const isMpQq = platform === "mp-qq";
164
+ const isMpToutiao = platform === "mp-toutiao";
165
+ const isMpWeixin = platform === "mp-weixin";
166
+ const isMpXhs = platform === "mp-xhs";
167
+ const isQuickappHuawei = platform === "quickapp-webview-huawei";
168
+ const isQuickappUnion = platform === "quickapp-webview-union";
169
+
170
+ function getDeviceInfo() {
171
+ if (uni.canIUse("getDeviceInfo") || uni.getDeviceInfo) {
172
+ return uni.getDeviceInfo();
173
+ } else {
174
+ return uni.getSystemInfoSync();
175
+ }
176
+ }
177
+ function getWindowInfo() {
178
+ if (uni.canIUse("getWindowInfo") || uni.getWindowInfo) {
179
+ return uni.getWindowInfo();
180
+ } else {
181
+ return uni.getSystemInfoSync();
182
+ }
183
+ }
184
+ function getAppBaseInfo() {
185
+ if (uni.canIUse("getAppBaseInfo") || uni.getAppBaseInfo) {
186
+ return uni.getAppBaseInfo();
187
+ } else {
188
+ return uni.getSystemInfoSync();
189
+ }
190
+ }
191
+ function getVersion() {
192
+ if (isMpAlipay) {
193
+ return my.SDKVersion;
194
+ }
195
+ return getAppBaseInfo().SDKVersion;
196
+ }
197
+ function compareVersion(v1, v2) {
198
+ const s1 = v1.split(".");
199
+ const s2 = v2.split(".");
200
+ for (let i = 0; i < Math.max(s1.length, s2.length); i += 1) {
201
+ const num1 = Number.parseInt(defaultTo(s1[i], "0"));
202
+ const num2 = Number.parseInt(defaultTo(s2[i], "0"));
203
+ if (num1 > num2) {
204
+ return 1;
205
+ } else if (num1 < num2) {
206
+ return -1;
207
+ }
208
+ }
209
+ return 0;
210
+ }
211
+ function gte(version) {
212
+ return compareVersion(getVersion(), version) >= 0;
213
+ }
214
+ function canIUseCanvas2d() {
215
+ if (isMpWeixin) {
216
+ if (getDeviceInfo().platform === "mac") {
217
+ return false;
218
+ }
219
+ return gte("2.9.0");
220
+ }
221
+ if (isMpAlipay) {
222
+ return gte("2.7.0");
223
+ }
224
+ if (isMpToutiao) {
225
+ return gte("1.78.0");
226
+ }
227
+ return false;
228
+ }
229
+ function querySelect(component, selector, fields) {
230
+ return new Promise((resolve, reject) => {
231
+ uni.createSelectorQuery().in(component).select(selector).fields(fields, () => {
232
+ }).exec(([node]) => {
233
+ if (node) {
234
+ resolve(node);
235
+ } else {
236
+ reject();
237
+ }
238
+ });
239
+ });
240
+ }
241
+
242
+ const SHORT_HEX_REGEX = /#([0-9a-f])([0-9a-f])([0-9a-f])\b/gi;
243
+ class UniCanvas {
244
+ tagName = "canvas";
245
+ attrs = {};
246
+ canvasId;
247
+ context;
248
+ canvasNode;
249
+ _emitter;
250
+ constructor(canvasId, context, canvasNode) {
251
+ this.canvasId = canvasId;
252
+ this.context = context;
253
+ this.canvasNode = canvasNode;
254
+ if (canvasNode == null) {
255
+ this._setupContext(context);
256
+ }
257
+ this._emitter = mitt();
258
+ }
259
+ _setupContext(context) {
260
+ const styles = [
261
+ "fillStyle",
262
+ "fontSize",
263
+ "globalAlpha",
264
+ "lineCap",
265
+ "lineDash",
266
+ "lineJoin",
267
+ "lineWidth",
268
+ "miterLimit",
269
+ "strokeStyle",
270
+ "textAlign",
271
+ "textBaseline",
272
+ "opacity",
273
+ "shadowOffsetX",
274
+ "shadowOffsetY",
275
+ "shadowBlur",
276
+ "shadowColor",
277
+ "font"
278
+ ];
279
+ const shadow = {
280
+ offsetX: 0,
281
+ offsetY: 0,
282
+ blur: 0,
283
+ color: "#000000"
284
+ };
285
+ for (const key of styles) {
286
+ Object.defineProperty(context, key, {
287
+ set(value) {
288
+ if (key === "opacity") {
289
+ context.setGlobalAlpha(value);
290
+ return;
291
+ }
292
+ if (key === "font") {
293
+ const fontSize = UniCanvas.parseFontSize(value);
294
+ if (fontSize) {
295
+ context.setFontSize(fontSize);
296
+ }
297
+ return;
298
+ }
299
+ if (key.indexOf("shadow") === 0) {
300
+ if (key !== "shadowColor") {
301
+ shadow[lowerFirst(key.slice(6))] = value;
302
+ } else {
303
+ shadow.color = UniCanvas.normalizeColor(context, value);
304
+ context.setShadow(
305
+ shadow.offsetX,
306
+ shadow.offsetY,
307
+ shadow.blur,
308
+ shadow.color
309
+ );
310
+ }
311
+ return;
312
+ }
313
+ if (key === "fillStyle" || key === "strokeStyle") {
314
+ value = UniCanvas.normalizeColor(context, value);
315
+ }
316
+ context[`set${upperFirst(key)}`](value);
317
+ }
318
+ });
319
+ }
320
+ const _drawImage = context.drawImage.bind(context);
321
+ context.drawImage = (...args) => {
322
+ _drawImage(args[0].src, ...args.slice(1));
323
+ };
324
+ if (context.strokeText == null) {
325
+ context.strokeText = (...args) => {
326
+ context.fillText(...args);
327
+ };
328
+ }
329
+ if (context.createRadialGradient == null) {
330
+ context.createRadialGradient = (...args) => {
331
+ return context.createCircularGradient(...args.slice(-3));
332
+ };
333
+ }
334
+ if (context.measureText == null || getDeviceInfo().osName === "harmonyos") {
335
+ const strlen = (str) => {
336
+ let len = 0;
337
+ for (let i = 0; i < str.length; i += 1) {
338
+ const unicode = str.charCodeAt(i);
339
+ if (unicode > 0 && unicode < 128) {
340
+ len += 1;
341
+ } else {
342
+ len += 2;
343
+ }
344
+ }
345
+ return len;
346
+ };
347
+ context.measureText = (text, font) => {
348
+ const fontSize = defaultTo(
349
+ // @ts-expect-error whatever
350
+ context.state && context.state.fontSize,
351
+ UniCanvas.parseFontSize(font) || 12
352
+ ) / 2;
353
+ const factor = fontSize >= 16 ? 1.3 : 1;
354
+ return {
355
+ width: strlen(text) * fontSize * factor
356
+ };
357
+ };
358
+ }
359
+ }
360
+ get width() {
361
+ if (this.canvasNode == null) {
362
+ return this.getAttribute("width");
363
+ }
364
+ return this.canvasNode.width;
365
+ }
366
+ set width(value) {
367
+ if (this.canvasNode == null) {
368
+ this.setAttribute("width", value);
369
+ return;
370
+ }
371
+ this.canvasNode.width = value;
372
+ }
373
+ get height() {
374
+ if (this.canvasNode == null) {
375
+ return this.getAttribute("height");
376
+ }
377
+ return this.canvasNode.height;
378
+ }
379
+ set height(value) {
380
+ if (this.canvasNode == null) {
381
+ this.setAttribute("height", value);
382
+ return;
383
+ }
384
+ this.canvasNode.height = value;
385
+ }
386
+ getContext(type) {
387
+ if (type === "2d") {
388
+ return this.context;
389
+ }
390
+ }
391
+ setAttribute(key, value) {
392
+ this.attrs[key] = value;
393
+ }
394
+ getAttribute(key) {
395
+ return this.attrs[key];
396
+ }
397
+ addEventListener(type, listener) {
398
+ this._emitter.on(type, listener);
399
+ }
400
+ removeEventListener(type, listener) {
401
+ this._emitter.off(type, listener);
402
+ }
403
+ dispatchEvent(type, event) {
404
+ if (typeof type === "object") {
405
+ this._emitter.emit(type.type, type);
406
+ } else {
407
+ this._emitter.emit(type, event);
408
+ }
409
+ return true;
410
+ }
411
+ attachEvent() {
412
+ }
413
+ detachEvent() {
414
+ }
415
+ requestAnimationFrame(callback) {
416
+ if (this.canvasNode != null && typeof this.canvasNode.requestAnimationFrame === "function") {
417
+ return this.canvasNode.requestAnimationFrame(callback);
418
+ }
419
+ if (typeof requestAnimationFrame === "function") {
420
+ return requestAnimationFrame(callback);
421
+ }
422
+ return setTimeout(callback, 1e3 / 60);
423
+ }
424
+ cancelAnimationFrame(id) {
425
+ if (this.canvasNode != null && typeof this.canvasNode.cancelAnimationFrame === "function") {
426
+ this.canvasNode.cancelAnimationFrame(id);
427
+ return;
428
+ }
429
+ if (typeof cancelAnimationFrame === "function") {
430
+ cancelAnimationFrame(id);
431
+ return;
432
+ }
433
+ clearTimeout(id);
434
+ }
435
+ toTempFilePath(options = {}) {
436
+ const opts = {};
437
+ if (this.canvasNode != null) {
438
+ opts.canvas = this.canvasNode;
439
+ } else {
440
+ opts.canvasId = this.canvasId;
441
+ }
442
+ return uni.canvasToTempFilePath({
443
+ ...opts,
444
+ ...options
445
+ });
446
+ }
447
+ static parseFontSize(font) {
448
+ if (!font) {
449
+ return 0;
450
+ }
451
+ const match = font.match(/([\d.]+)px/);
452
+ if (match == null) {
453
+ return 0;
454
+ }
455
+ return Number.parseFloat(match[1]);
456
+ }
457
+ static normalizeColor(context, color) {
458
+ if (typeof color === "string") {
459
+ // #ifdef MP-TOUTIAO
460
+ SHORT_HEX_REGEX.lastIndex = 0;
461
+ if (SHORT_HEX_REGEX.test(color)) {
462
+ return color.replace(SHORT_HEX_REGEX, "#$1$1$2$2$3$3");
463
+ }
464
+ // #endif
465
+ }
466
+ return color;
467
+ }
468
+ static dispatch(handler, event, touch) {
469
+ handler.dispatch(event, {
470
+ zrX: touch.x,
471
+ zrY: touch.y,
472
+ zrDelta: touch.wheelDelta,
473
+ preventDefault: () => {
474
+ },
475
+ stopImmediatePropagation: () => {
476
+ },
477
+ stopPropagation: () => {
478
+ }
479
+ });
480
+ }
481
+ }
482
+ class UniImage {
483
+ tagName = "img";
484
+ width;
485
+ height;
486
+ onload;
487
+ onerror;
488
+ _src;
489
+ constructor() {
490
+ this._src = null;
491
+ this.width = 0;
492
+ this.height = 0;
493
+ }
494
+ get src() {
495
+ return this._src;
496
+ }
497
+ set src(value) {
498
+ uni.getImageInfo({
499
+ src: value,
500
+ success: (res) => {
501
+ this._src = res.path;
502
+ this.width = res.width;
503
+ this.height = res.height;
504
+ if (this.onload) {
505
+ this.onload(res);
506
+ }
507
+ },
508
+ fail: (err) => {
509
+ if (this.onerror) {
510
+ this.onerror(err);
511
+ }
512
+ }
513
+ });
514
+ }
515
+ }
516
+ function setupEchartsCanvas(echarts, {
517
+ canvas,
518
+ node
519
+ }) {
520
+ echarts.registerPreprocessor((option) => {
521
+ if (option == null) {
522
+ return;
523
+ }
524
+ if (option.series != null) {
525
+ if (Array.isArray(option.series)) {
526
+ if (!isEmpty(option.series)) {
527
+ for (const item of option.series) {
528
+ item.progressive = 0;
529
+ }
530
+ }
531
+ } else if (typeof option.series === "object") {
532
+ option.series.progressive = 0;
533
+ }
534
+ }
535
+ });
536
+ echarts.setPlatformAPI({
537
+ createCanvas() {
538
+ return canvas;
539
+ },
540
+ loadImage(src, onload, onerror) {
541
+ if (node != null && node.createImage) {
542
+ const image2 = node.createImage();
543
+ image2.onload = onload;
544
+ image2.onerror = onerror;
545
+ image2.src = src;
546
+ return image2;
547
+ }
548
+ const image = new UniImage();
549
+ image.onload = onload;
550
+ image.onerror = onerror;
551
+ image.src = src;
552
+ return image;
553
+ }
554
+ });
555
+ }
556
+
557
+ function getIsPc() {
558
+ // #ifdef WEB
559
+ if (!("ontouchstart" in window)) {
560
+ return true;
561
+ }
562
+ // #endif
563
+ if (isMpWeixin || isMpToutiao || isMpAlipay) {
564
+ return /windows/i.test(getDeviceInfo().platform);
565
+ }
566
+ return false;
567
+ }
568
+
569
+ const INIT_OPTIONS_KEY = Symbol("UniEcharts.initOptions");
570
+ function provideEchartsInitOptions(value) {
571
+ provide(INIT_OPTIONS_KEY, value);
572
+ }
573
+ function useEchartsInitOptions(value) {
574
+ const injectInitOptions = inject(INIT_OPTIONS_KEY, null);
575
+ const unwrapInjectInitOptions = computed(() => {
576
+ return toValue(injectInitOptions);
577
+ });
578
+ const innerInitOptions = computed(() => {
579
+ return defaultTo(toValue(value), unwrapInjectInitOptions.value, {});
580
+ });
581
+ return {
582
+ injectInitOptions: unwrapInjectInitOptions,
583
+ innerInitOptions
584
+ };
585
+ }
586
+
587
+ function useEchartsMouseWheel({
588
+ isPc,
589
+ chart,
590
+ getTouch
591
+ }) {
592
+ function mouseWheelHandler(event) {
593
+ if (chart.value == null) {
594
+ return;
595
+ }
596
+ const { handler } = chart.value.getZr();
597
+ UniCanvas.dispatch(handler, "mousewheel", getTouch(event));
598
+ }
599
+ onMounted(() => {
600
+ if (isPc) {
601
+ document.addEventListener("wheel", mouseWheelHandler);
602
+ }
603
+ });
604
+ onBeforeUnmount(() => {
605
+ if (isPc) {
606
+ document.removeEventListener("wheel", mouseWheelHandler);
607
+ }
608
+ });
609
+ }
610
+
611
+ const OPTION_KEY = "UniEcharts.option";
612
+ function getEchartsOptionKey(key) {
613
+ if (isEmpty(key)) {
614
+ return OPTION_KEY;
615
+ }
616
+ return `${OPTION_KEY}_${key}`;
617
+ }
618
+ function provideEchartsOption(keyOrValue, value) {
619
+ if (typeof keyOrValue === "string") {
620
+ provide(getEchartsOptionKey(keyOrValue), value);
621
+ return;
622
+ }
623
+ provide(getEchartsOptionKey(), keyOrValue);
624
+ }
625
+ function useEchartsOption(key, value) {
626
+ const injectOption = inject(getEchartsOptionKey(key), null);
627
+ const unwrapInjectOption = computed(() => {
628
+ return toValue(injectOption);
629
+ });
630
+ const innerOption = computed(() => {
631
+ return defaultTo(toValue(value), unwrapInjectOption.value);
632
+ });
633
+ return {
634
+ injectOption: unwrapInjectOption,
635
+ innerOption
636
+ };
637
+ }
638
+
639
+ const THEME_KEY = Symbol("UniEcharts.theme");
640
+ function provideEchartsTheme(value) {
641
+ provide(THEME_KEY, value);
642
+ }
643
+ function useEchartsTheme(value) {
644
+ const injectTheme = inject(THEME_KEY, null);
645
+ const unwrapInjectTheme = computed(() => {
646
+ return toValue(injectTheme);
647
+ });
648
+ const innerTheme = computed(() => {
649
+ return defaultTo(toValue(value), unwrapInjectTheme.value, {});
650
+ });
651
+ return {
652
+ injectTheme: unwrapInjectTheme,
653
+ innerTheme
654
+ };
655
+ }
656
+
657
+ function useEchartsTouch({
658
+ vueThis,
659
+ supportHover,
660
+ isPc,
661
+ canvasId,
662
+ chart,
663
+ canvasRect,
664
+ getTouch
665
+ }) {
666
+ const touching = shallowRef(false);
667
+ const state = {
668
+ x: 0,
669
+ y: 0,
670
+ t: 0
671
+ };
672
+ let timer = 0;
673
+ let ticking = false;
674
+ let rafId = 0;
675
+ let lastMoveEvent = null;
676
+ function destroyTimer() {
677
+ if (timer === 0) {
678
+ return;
679
+ }
680
+ clearTimeout(timer);
681
+ timer = 0;
682
+ }
683
+ function getCanvas() {
684
+ if (chart.value == null) {
685
+ return null;
686
+ }
687
+ return chart.value.getDom();
688
+ }
689
+ function normalizeTouches(touches) {
690
+ if (Array.isArray(touches)) {
691
+ return touches;
692
+ }
693
+ if (typeof touches === "object" && touches != null) {
694
+ return Object.values(touches);
695
+ }
696
+ return touches;
697
+ }
698
+ function transformTouchesEvent(event) {
699
+ for (let i = 0; i < event.touches.length; i += 1) {
700
+ const item = event.touches[i];
701
+ item.offsetX = item.x;
702
+ item.offsetY = item.y;
703
+ }
704
+ return event;
705
+ }
706
+ function onStart(event) {
707
+ touching.value = true;
708
+ state.t = Date.now();
709
+ const next = () => {
710
+ if (chart.value == null) {
711
+ return;
712
+ }
713
+ const touch = getTouch(event, normalizeTouches(event.touches));
714
+ state.x = touch.x;
715
+ state.y = touch.y;
716
+ const { handler } = chart.value.getZr();
717
+ UniCanvas.dispatch(handler, "mousedown", touch);
718
+ UniCanvas.dispatch(handler, "mousemove", touch);
719
+ handler.processGesture(transformTouchesEvent(event), "start");
720
+ destroyTimer();
721
+ };
722
+ querySelect(vueThis, `#${canvasId}`, {
723
+ rect: true
724
+ }).then(({ top, left }) => {
725
+ canvasRect.top = top;
726
+ canvasRect.left = left;
727
+ }).finally(() => {
728
+ next();
729
+ });
730
+ }
731
+ function _onMove(event) {
732
+ if (isPc && toValue(supportHover) && !touching.value) {
733
+ touching.value = true;
734
+ }
735
+ if (chart.value == null || !touching.value) {
736
+ return;
737
+ }
738
+ const { handler } = chart.value.getZr();
739
+ UniCanvas.dispatch(handler, "mousemove", getTouch(event, normalizeTouches(event.touches)));
740
+ handler.processGesture(transformTouchesEvent(event), "change");
741
+ }
742
+ function onMove(event) {
743
+ const canvas = getCanvas();
744
+ if (canvas == null) {
745
+ return;
746
+ }
747
+ lastMoveEvent = event;
748
+ if (ticking) {
749
+ return;
750
+ }
751
+ ticking = true;
752
+ rafId = canvas.requestAnimationFrame(() => {
753
+ try {
754
+ if (lastMoveEvent != null) {
755
+ _onMove(lastMoveEvent);
756
+ }
757
+ } finally {
758
+ lastMoveEvent = null;
759
+ ticking = false;
760
+ }
761
+ });
762
+ }
763
+ function onEnd(event) {
764
+ touching.value = false;
765
+ if (chart.value == null) {
766
+ return;
767
+ }
768
+ const touch = getTouch(event, normalizeTouches(event.changedTouches));
769
+ const { handler } = chart.value.getZr();
770
+ UniCanvas.dispatch(handler, "mouseup", touch);
771
+ handler.processGesture(transformTouchesEvent(event), "end");
772
+ const isClick = Math.abs(touch.x - state.x) < 10 && Date.now() - state.t < 200;
773
+ if (isClick) {
774
+ UniCanvas.dispatch(handler, "click", touch);
775
+ } else {
776
+ if (timer > 0) {
777
+ destroyTimer();
778
+ }
779
+ timer = setTimeout(() => {
780
+ UniCanvas.dispatch(handler, "mousemove", { x: 999999999, y: 999999999 });
781
+ UniCanvas.dispatch(handler, "mouseup", { x: 999999999, y: 999999999 });
782
+ }, 50);
783
+ }
784
+ }
785
+ function cleanup() {
786
+ destroyTimer();
787
+ if (rafId !== 0) {
788
+ const canvas = getCanvas();
789
+ if (canvas != null) {
790
+ canvas.cancelAnimationFrame(rafId);
791
+ }
792
+ rafId = 0;
793
+ }
794
+ lastMoveEvent = null;
795
+ ticking = false;
796
+ }
797
+ return {
798
+ onStart,
799
+ onMove,
800
+ onEnd,
801
+ cleanup
802
+ };
803
+ }
804
+
805
+ const UPDATE_OPTIONS_KEY = Symbol("UniEcharts.updateOptions");
806
+ function provideEchartsUpdateOptions(value) {
807
+ provide(UPDATE_OPTIONS_KEY, value);
808
+ }
809
+ function useEchartsUpdateOptions(value) {
810
+ const injectUpdateOptions = inject(UPDATE_OPTIONS_KEY, null);
811
+ const unwrapInjectUpdateOptions = computed(() => {
812
+ return toValue(injectUpdateOptions);
813
+ });
814
+ const innerUpdateOptions = computed(() => {
815
+ return defaultTo(toValue(value), unwrapInjectUpdateOptions.value, {});
816
+ });
817
+ return {
818
+ injectUpdateOptions: unwrapInjectUpdateOptions,
819
+ innerUpdateOptions
820
+ };
821
+ }
822
+
823
+ const LOADING_OPTIONS_KEY = Symbol("UniEcharts.loadingOptions");
824
+ function provideEchartsLoadingOptions(value) {
825
+ provide(LOADING_OPTIONS_KEY, value);
826
+ }
827
+ function useLoading(chart, {
828
+ loading,
829
+ loadingOptions
830
+ }) {
831
+ const injectLoadingOptions = inject(LOADING_OPTIONS_KEY, null);
832
+ const unwrapInjectLoadingOptions = computed(() => {
833
+ return toValue(injectLoadingOptions);
834
+ });
835
+ const innerLoadingOptions = computed(() => {
836
+ return {
837
+ ...defaultTo(unwrapInjectLoadingOptions.value, {}),
838
+ ...defaultTo(toValue(loadingOptions), {})
839
+ };
840
+ });
841
+ watchEffect(() => {
842
+ const instance = chart.value;
843
+ if (instance == null) {
844
+ return;
845
+ }
846
+ if (toValue(loading)) {
847
+ instance.showLoading(innerLoadingOptions.value);
848
+ } else {
849
+ instance.hideLoading();
850
+ }
851
+ });
852
+ }
853
+
854
+ const ECHARTS_APIS = [
855
+ "getWidth",
856
+ "getHeight",
857
+ "getDom",
858
+ "getOption",
859
+ "dispatchAction",
860
+ "convertToPixel",
861
+ "convertFromPixel",
862
+ "containPixel",
863
+ "getDataURL",
864
+ "getConnectedDataURL",
865
+ "appendData",
866
+ "clear",
867
+ "isDisposed",
868
+ "dispose"
869
+ ];
870
+ function usePublicApi(chart) {
871
+ function makePublicMethod(name) {
872
+ return (...args) => {
873
+ if (chart.value == null) {
874
+ throw new Error("ECharts is not initialized yet.");
875
+ }
876
+ return chart.value[name].apply(chart.value, args);
877
+ };
878
+ }
879
+ function makePublicMethods() {
880
+ const methods = /* @__PURE__ */ Object.create(null);
881
+ for (const name of ECHARTS_APIS) {
882
+ methods[name] = makePublicMethod(name);
883
+ }
884
+ return methods;
885
+ }
886
+ return makePublicMethods();
887
+ }
888
+
889
+ let uid = 0;
890
+ function useUid() {
891
+ uid += 1;
892
+ return uid;
893
+ }
894
+
895
+ function useVueThis() {
896
+ const vm = getCurrentInstance();
897
+ return vm.proxy;
898
+ }
899
+
900
+ export { ECHARTS_KEY, INIT_OPTIONS_KEY, LOADING_OPTIONS_KEY, OPTION_KEY, THEME_KEY, UPDATE_OPTIONS_KEY, UniCanvas, UniImage, appPlatform, canIUseCanvas2d, compareVersion, defaultTo, getAppBaseInfo, getDeviceInfo, getEchartsOptionKey, getIsPc, getVersion, getWindowInfo, isApp, isAppAndroid, isAppHarmony, isAppIos, isEmpty, isMp, isMp360, isMpAlipay, isMpBaidu, isMpHarmony, isMpJd, isMpKuaishou, isMpLark, isMpQq, isMpToutiao, isMpWeixin, isMpXhs, isQuickapp, isQuickappHuawei, isQuickappUnion, isWeb, lowerFirst, mitt, platform, provideEcharts, provideEchartsInitOptions, provideEchartsLoadingOptions, provideEchartsOption, provideEchartsTheme, provideEchartsUpdateOptions, querySelect, setupEchartsCanvas, sleep, upperFirst, useAutoresize, useEcharts, useEchartsInitOptions, useEchartsMouseWheel, useEchartsOption, useEchartsTheme, useEchartsTouch, useEchartsUpdateOptions, useLoading, usePublicApi, useUid, useVueThis };