oxy-uni-ui 1.2.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 (116) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +51 -1
  3. package/components/common/path.ts +9 -0
  4. package/components/common/util.ts +42 -0
  5. package/components/composables/useGlobalLoading.ts +42 -0
  6. package/components/composables/useGlobalMessage.ts +48 -0
  7. package/components/composables/useGlobalToast.ts +84 -0
  8. package/components/composables/useVirtualScroll.ts +3 -2
  9. package/components/oxy-cell/oxy-cell.vue +15 -2
  10. package/components/oxy-cell/types.ts +4 -0
  11. package/components/oxy-checkbox/index.scss +1 -1
  12. package/components/oxy-checkbox/oxy-checkbox.vue +2 -2
  13. package/components/oxy-col-picker/oxy-col-picker.vue +3 -0
  14. package/components/oxy-col-picker/types.ts +5 -1
  15. package/components/oxy-corner/oxy-corner.vue +15 -3
  16. package/components/oxy-corner/types.ts +15 -1
  17. package/components/oxy-date-strip/index.scss +10 -0
  18. package/components/oxy-date-strip/oxy-date-strip.vue +198 -0
  19. package/components/oxy-date-strip/types.ts +98 -0
  20. package/components/oxy-date-strip/utils.ts +67 -0
  21. package/components/oxy-date-strip-item/index.scss +94 -0
  22. package/components/oxy-date-strip-item/oxy-date-strip-item.vue +102 -0
  23. package/components/oxy-date-strip-item/types.ts +53 -0
  24. package/components/oxy-datetime-picker/oxy-datetime-picker.vue +3 -1
  25. package/components/oxy-datetime-picker/types.ts +5 -1
  26. package/components/oxy-echarts/index.scss +17 -0
  27. package/components/oxy-echarts/index.ts +1 -0
  28. package/components/oxy-echarts/oxy-echarts.vue +32 -0
  29. package/components/oxy-echarts/types.ts +12 -0
  30. package/components/oxy-file-list/index.scss +26 -0
  31. package/components/oxy-file-list/oxy-file-list.vue +208 -34
  32. package/components/oxy-file-list/types.ts +58 -2
  33. package/components/oxy-global-loading/oxy-global-loading.vue +53 -0
  34. package/components/oxy-global-message/oxy-global-message.vue +64 -0
  35. package/components/oxy-global-toast/oxy-global-toast.vue +53 -0
  36. package/components/oxy-img-lazy/index.scss +17 -0
  37. package/components/oxy-img-lazy/oxy-img-lazy.vue +332 -0
  38. package/components/oxy-img-lazy/types.ts +69 -0
  39. package/components/oxy-link/index.scss +57 -0
  40. package/components/oxy-link/oxy-link.vue +130 -0
  41. package/components/oxy-link/types.ts +81 -0
  42. package/components/oxy-list/index.scss +7 -1
  43. package/components/oxy-list/types.ts +1 -1
  44. package/components/oxy-picker/oxy-picker.vue +3 -0
  45. package/components/oxy-picker/types.ts +5 -1
  46. package/components/oxy-radio/index.scss +3 -3
  47. package/components/oxy-radio/oxy-radio.vue +1 -1
  48. package/components/oxy-rich-text/icon/emjio.svg +1 -0
  49. package/components/oxy-rich-text/icon/quote.svg +1 -0
  50. package/components/oxy-rich-text/icon/text.svg +1 -0
  51. package/components/oxy-rich-text/icon/title.svg +1 -0
  52. package/components/oxy-rich-text/index.scss +159 -0
  53. package/components/oxy-rich-text/mp-html/card/card.vue +122 -0
  54. package/components/oxy-rich-text/mp-html/card/index.js +7 -0
  55. package/components/oxy-rich-text/mp-html/editable/config.js +15 -0
  56. package/components/oxy-rich-text/mp-html/editable/index.js +553 -0
  57. package/components/oxy-rich-text/mp-html/emoji/index.js +203 -0
  58. package/components/oxy-rich-text/mp-html/highlight/config.js +5 -0
  59. package/components/oxy-rich-text/mp-html/highlight/index.js +96 -0
  60. package/components/oxy-rich-text/mp-html/highlight/prism.css +1 -0
  61. package/components/oxy-rich-text/mp-html/highlight/prism.min.js +7 -0
  62. package/components/oxy-rich-text/mp-html/img-cache/index.js +138 -0
  63. package/components/oxy-rich-text/mp-html/latex/index.js +80 -0
  64. package/components/oxy-rich-text/mp-html/latex/katex.css +1 -0
  65. package/components/oxy-rich-text/mp-html/latex/katex.min.js +1 -0
  66. package/components/oxy-rich-text/mp-html/markdown/index.js +50 -0
  67. package/components/oxy-rich-text/mp-html/markdown/marked.min.js +71 -0
  68. package/components/oxy-rich-text/mp-html/mp-html.d.ts +184 -0
  69. package/components/oxy-rich-text/mp-html/mp-html.vue +675 -0
  70. package/components/oxy-rich-text/mp-html/node/node.vue +1161 -0
  71. package/components/oxy-rich-text/mp-html/parser.js +1428 -0
  72. package/components/oxy-rich-text/mp-html/search/index.js +132 -0
  73. package/components/oxy-rich-text/mp-html/style/index.js +129 -0
  74. package/components/oxy-rich-text/mp-html/style/parser.js +175 -0
  75. package/components/oxy-rich-text/mp-html/template/index.js +67 -0
  76. package/components/oxy-rich-text/mp-html/txv-video/index.js +46 -0
  77. package/components/oxy-rich-text/oxy-rich-text.vue +642 -0
  78. package/components/oxy-rich-text/types.ts +71 -0
  79. package/components/oxy-select/index.scss +255 -0
  80. package/components/oxy-select/oxy-select.vue +421 -0
  81. package/components/oxy-select/types.ts +71 -0
  82. package/components/oxy-select-picker/oxy-select-picker.vue +3 -0
  83. package/components/oxy-select-picker/types.ts +5 -1
  84. package/components/oxy-stream-render/index.scss +6 -0
  85. package/components/oxy-stream-render/oxy-stream-render.vue +204 -0
  86. package/components/oxy-stream-render/types.ts +5 -0
  87. package/components/oxy-tree/index.scss +17 -1
  88. package/components/oxy-tree/oxy-tree.vue +89 -8
  89. package/components/oxy-tree/types.ts +11 -1
  90. package/components/oxy-waterfall/index.scss +18 -0
  91. package/components/oxy-waterfall/oxy-waterfall.vue +218 -0
  92. package/components/oxy-waterfall/types.ts +90 -0
  93. package/components/oxy-waterfall-item/index.scss +8 -0
  94. package/components/oxy-waterfall-item/oxy-waterfall-item.vue +89 -0
  95. package/components/oxy-waterfall-item/types.ts +16 -0
  96. package/global.d.ts +7 -0
  97. package/index.ts +3 -0
  98. package/locale/lang/en-US.ts +26 -0
  99. package/locale/lang/zh-CN.ts +26 -0
  100. package/oxy-uni-ui.zip +0 -0
  101. package/package.json +1 -1
  102. package/tags.json +1 -1
  103. package/uni-echarts/changelog.md +2 -0
  104. package/uni-echarts/components/index.js +1 -0
  105. package/uni-echarts/components/uni-echarts/events.js +95 -0
  106. package/uni-echarts/components/uni-echarts/types.d.ts +183 -0
  107. package/uni-echarts/components/uni-echarts/types.js +1 -0
  108. package/uni-echarts/components/uni-echarts/uni-echarts.vue +530 -0
  109. package/uni-echarts/components/uni-echarts/uni-echarts.vue.d.ts +19 -0
  110. package/uni-echarts/global.d.ts +7 -0
  111. package/uni-echarts/index.d.ts +440 -0
  112. package/uni-echarts/index.js +2 -0
  113. package/uni-echarts/package.json +105 -0
  114. package/uni-echarts/shared-core.d.ts +269 -0
  115. package/uni-echarts/shared-core.js +900 -0
  116. package/web-types.json +1 -1
@@ -0,0 +1,530 @@
1
+ <template>
2
+ <view
3
+ ref="root"
4
+ class="uni-echarts"
5
+ :class="props.customClass"
6
+ :style="props.customStyle"
7
+ @click="emit('native:click', $event)"
8
+ @dblclick="emit('native:dblclick', $event)"
9
+ @mouseout="emit('native:mouseout', $event)"
10
+ @mouseover="emit('native:mouseover', $event)"
11
+ @mouseup="emit('native:mouseup', $event)"
12
+ @mousedown="emit('native:mousedown', $event)"
13
+ @mousemove="emit('native:mousemove', $event)"
14
+ @contextmenu="emit('native:contextmenu', $event)"
15
+ @mousewheel="emit('native:mousewheel', $event)"
16
+ @drag="emit('native:drag', $event)"
17
+ @dragstart="emit('native:dragstart', $event)"
18
+ @dragend="emit('native:dragend', $event)"
19
+ @dragenter="emit('native:dragenter', $event)"
20
+ @dragleave="emit('native:dragleave', $event)"
21
+ @dragover="emit('native:dragover', $event)"
22
+ @drop="emit('native:drop', $event)"
23
+ @touchstart="emit('native:touchstart', $event)"
24
+ @touchmove="emit('native:touchmove', $event)"
25
+ @touchcancel="emit('native:touchcancel', $event)"
26
+ @touchend="emit('native:touchend', $event)"
27
+ @tap="emit('native:tap', $event)"
28
+ @longpress="emit('native:longpress', $event)"
29
+ @longtap="emit('native:longtap', $event)"
30
+ @transitionend="emit('native:transitionend', $event)"
31
+ @animationstart="emit('native:animationstart', $event)"
32
+ @animationiteration="emit('native:animationiteration', $event)"
33
+ @animationend="emit('native:animationend', $event)"
34
+ @touchforcechange="emit('native:touchforcechange', $event)"
35
+ >
36
+ <canvas
37
+ v-if="useCanvas2D"
38
+ :id="canvasId"
39
+ class="uni-echarts__canvas"
40
+ type="2d"
41
+ :disable-scroll="props.disableScroll"
42
+ @touchstart="touch.onStart"
43
+ @touchmove="touch.onMove"
44
+ @touchend="touch.onEnd"
45
+ ></canvas>
46
+
47
+ <canvas
48
+ v-else
49
+ :id="canvasId"
50
+ class="uni-echarts__canvas"
51
+ :canvas-id="canvasId"
52
+ :disable-scroll="props.disableScroll"
53
+ @touchstart="touch.onStart"
54
+ @touchmove="touch.onMove"
55
+ @touchend="touch.onEnd"
56
+ ></canvas>
57
+
58
+ <view
59
+ v-if="isPc || isMpAlipay"
60
+ class="uni-echarts__mask"
61
+ @mousedown="touch.onStart"
62
+ @mousemove="touch.onMove"
63
+ @mouseup="touch.onEnd"
64
+ @touchstart="touch.onStart"
65
+ @touchmove="touch.onMove"
66
+ @touchend="touch.onEnd"
67
+ ></view>
68
+
69
+ <slot></slot>
70
+ </view>
71
+ </template>
72
+
73
+ <script setup>
74
+ import { computed, nextTick, onBeforeUnmount, onMounted, reactive, shallowRef, watch, watchEffect } from 'vue'
75
+ import {
76
+ canIUseCanvas2d,
77
+ defaultTo,
78
+ getIsPc,
79
+ getWindowInfo,
80
+ isEmpty,
81
+ isMpAlipay,
82
+ querySelect,
83
+ setupEchartsCanvas,
84
+ sleep,
85
+ UniCanvas,
86
+ useAutoresize,
87
+ useEcharts,
88
+ useEchartsInitOptions,
89
+ useEchartsMouseWheel,
90
+ useEchartsOption,
91
+ useEchartsTheme,
92
+ useEchartsTouch,
93
+ useEchartsUpdateOptions,
94
+ useLoading,
95
+ usePublicApi,
96
+ useUid,
97
+ useVueThis
98
+ } from '../../shared-core'
99
+ import { ECHARTS_EVENTS, EVENTS } from './events'
100
+
101
+ defineOptions({
102
+ name: 'UniEcharts',
103
+ options: {
104
+ // #ifdef MP-WEIXIN || MP-ALIPAY
105
+ virtualHost: true
106
+ // #endif
107
+ }
108
+ })
109
+
110
+ const props = defineProps({
111
+ customClass: [String, Object, Array],
112
+ customStyle: [String, Object],
113
+ option: Object,
114
+ optionKey: String,
115
+ theme: [Object, String],
116
+ initOptions: Object,
117
+ updateOptions: Object,
118
+ group: String,
119
+ manualUpdate: Boolean,
120
+ autoresize: [Boolean, Object],
121
+ loading: Boolean,
122
+ loadingOptions: Object,
123
+ canvasType: {
124
+ type: String,
125
+ default: '2d'
126
+ },
127
+ disableScroll: Boolean,
128
+ supportHover: Boolean,
129
+ initDelay: {
130
+ type: Number,
131
+ default: 30
132
+ }
133
+ })
134
+
135
+ const emit = defineEmits(EVENTS)
136
+
137
+ const vueThis = useVueThis()
138
+
139
+ const echarts = useEcharts()
140
+
141
+ const isPc = getIsPc()
142
+
143
+ const root = shallowRef(null)
144
+
145
+ const canvasId = `uni-chart${useUid()}`
146
+
147
+ const chart = shallowRef(null)
148
+
149
+ const manualOption = shallowRef(null)
150
+
151
+ const { innerOption, injectOption } = useEchartsOption(props.optionKey, () => defaultTo(manualOption.value, props.option))
152
+ const { innerTheme } = useEchartsTheme(() => props.theme)
153
+ const { innerInitOptions } = useEchartsInitOptions(() => props.initOptions)
154
+ const { innerUpdateOptions } = useEchartsUpdateOptions(() => props.updateOptions)
155
+
156
+ const useCanvas2D = computed(() => {
157
+ if (!canIUseCanvas2d()) {
158
+ return false
159
+ }
160
+
161
+ return props.canvasType === '2d'
162
+ })
163
+
164
+ const canvasRect = reactive({
165
+ top: 0,
166
+ left: 0,
167
+ width: 0,
168
+ height: 0
169
+ })
170
+
171
+ function getFirstTouch(touches) {
172
+ if (isEmpty(touches)) {
173
+ return null
174
+ }
175
+
176
+ return touches[0]
177
+ }
178
+
179
+ function getRelativeTouch(event, touches) {
180
+ let clientX = 0
181
+ let clientY = 0
182
+
183
+ const touch = getFirstTouch(touches)
184
+
185
+ if (touch != null) {
186
+ clientX = touch.clientX
187
+ clientY = touch.clientY
188
+ }
189
+
190
+ return {
191
+ x: Math.max(0, clientX - canvasRect.left),
192
+ y: Math.max(0, clientY - canvasRect.top),
193
+ wheelDelta: defaultTo(event.wheelDelta, 0)
194
+ }
195
+ }
196
+
197
+ function getTouch(event, touches) {
198
+ const touch = defaultTo(getFirstTouch(touches), {})
199
+
200
+ return touch.x != null ? touch : getRelativeTouch(event, touches)
201
+ }
202
+
203
+ const touch = useEchartsTouch({
204
+ vueThis,
205
+ supportHover: () => props.supportHover,
206
+ isPc,
207
+ canvasId,
208
+ chart,
209
+ canvasRect,
210
+ getTouch
211
+ })
212
+
213
+ // #ifdef WEB
214
+
215
+ useEchartsMouseWheel({
216
+ isPc,
217
+ chart,
218
+ getTouch
219
+ })
220
+
221
+ // #endif
222
+
223
+ async function getContext() {
224
+ const { top, left, width, height, node } = await querySelect(vueThis, `#${canvasId}`, {
225
+ rect: true,
226
+ size: true,
227
+ node: useCanvas2D.value
228
+ })
229
+
230
+ const devicePixelRatio = getWindowInfo().pixelRatio
231
+
232
+ let dpr = devicePixelRatio
233
+
234
+ let canvas
235
+
236
+ if (node != null) {
237
+ canvas = new UniCanvas(canvasId, node.getContext('2d'), node)
238
+ } else {
239
+ // #ifdef WEB
240
+ dpr = 1
241
+ // #endif
242
+ // #ifdef MP-ALIPAY || MP-LARK
243
+ dpr = devicePixelRatio
244
+ // #endif
245
+ // #ifdef MP-TOUTIAO
246
+ dpr = isPc ? 1 : devicePixelRatio
247
+ // #endif
248
+ // #ifndef WEB || MP-ALIPAY || MP-LARK || MP-TOUTIAO
249
+ dpr = isPc ? devicePixelRatio : 1
250
+ // #endif
251
+
252
+ canvas = new UniCanvas(canvasId, uni.createCanvasContext(canvasId, vueThis), null)
253
+ }
254
+
255
+ return {
256
+ top,
257
+ left,
258
+ width,
259
+ height,
260
+ node,
261
+ canvas,
262
+ dpr
263
+ }
264
+ }
265
+
266
+ async function init(option) {
267
+ if (props.initDelay > 0) {
268
+ await sleep(props.initDelay)
269
+ }
270
+
271
+ const context = await getContext()
272
+
273
+ canvasRect.top = context.top
274
+ canvasRect.left = context.left
275
+ canvasRect.width = context.width
276
+ canvasRect.height = context.height
277
+
278
+ setupEchartsCanvas(echarts, {
279
+ canvas: context.canvas,
280
+ node: context.node
281
+ })
282
+ chart.value = echarts.init(context.canvas, innerTheme.value, {
283
+ devicePixelRatio: context.dpr,
284
+ renderer: 'canvas',
285
+ width: context.width,
286
+ height: context.height,
287
+ ...innerInitOptions.value
288
+ })
289
+ const instance = chart.value
290
+
291
+ if (props.group) {
292
+ instance.group = props.group
293
+ }
294
+
295
+ const zr = instance.getZr()
296
+
297
+ for (const evt of ECHARTS_EVENTS) {
298
+ if (evt.indexOf('zr:') === 0) {
299
+ zr.on(evt.substring(3), (...args) => {
300
+ emit(evt, ...args)
301
+ })
302
+ } else {
303
+ instance.on(evt, (...args) => {
304
+ emit(evt, ...args)
305
+ })
306
+ }
307
+ }
308
+
309
+ // #ifdef WEB
310
+ const _resize = () => {
311
+ if (instance == null || instance.isDisposed()) {
312
+ return
313
+ }
314
+
315
+ const { offsetWidth, offsetHeight } = root.value.$el
316
+
317
+ instance.resize({
318
+ width: offsetWidth,
319
+ height: offsetHeight
320
+ })
321
+ }
322
+ // #endif
323
+
324
+ const _commit = () => {
325
+ emit('inited')
326
+
327
+ const opt = defaultTo(option, innerOption.value)
328
+
329
+ if (isEmpty(opt)) {
330
+ return
331
+ }
332
+
333
+ instance.setOption(opt, innerUpdateOptions.value)
334
+ }
335
+
336
+ // #ifdef WEB
337
+ if (props.autoresize) {
338
+ await nextTick()
339
+
340
+ _resize()
341
+ _commit()
342
+ } else {
343
+ _commit()
344
+ }
345
+ // #endif
346
+
347
+ // #ifndef WEB
348
+ _commit()
349
+ // #endif
350
+ }
351
+
352
+ function setOption(option, updateOptions) {
353
+ if (props.manualUpdate) {
354
+ manualOption.value = option
355
+ }
356
+
357
+ if (chart.value == null) {
358
+ init(option)
359
+ } else {
360
+ chart.value.setOption(option, defaultTo(updateOptions, {}))
361
+ }
362
+ }
363
+
364
+ async function resize(options = {}) {
365
+ if (chart.value == null) {
366
+ return
367
+ }
368
+
369
+ let { width, height } = options
370
+
371
+ const updateWidth = isEmpty(width) || width === 'auto'
372
+ const updateHeight = isEmpty(height) || height === 'auto'
373
+
374
+ if (updateWidth || updateHeight) {
375
+ const el = await querySelect(vueThis, `#${canvasId}`, {
376
+ size: true
377
+ })
378
+
379
+ if (updateWidth) {
380
+ width = el.width
381
+ }
382
+ if (updateHeight) {
383
+ height = el.height
384
+ }
385
+ }
386
+
387
+ chart.value.resize({
388
+ ...options,
389
+ width,
390
+ height
391
+ })
392
+ }
393
+
394
+ function cleanup() {
395
+ if (chart.value == null) {
396
+ return
397
+ }
398
+
399
+ touch.cleanup()
400
+
401
+ chart.value.dispose()
402
+ chart.value = null
403
+ }
404
+
405
+ let unwatchOption
406
+
407
+ watch(
408
+ () => props.manualUpdate,
409
+ (manual) => {
410
+ if (typeof unwatchOption === 'function') {
411
+ unwatchOption()
412
+ unwatchOption = null
413
+ }
414
+
415
+ if (manual) {
416
+ return
417
+ }
418
+
419
+ unwatchOption = watch(
420
+ () => defaultTo(props.option, injectOption.value),
421
+ (value, oldValue) => {
422
+ if (isEmpty(value)) {
423
+ return
424
+ }
425
+
426
+ if (chart.value == null) {
427
+ init()
428
+ } else {
429
+ chart.value.setOption(value, {
430
+ notMerge: value !== oldValue,
431
+ ...innerUpdateOptions.value
432
+ })
433
+ }
434
+ },
435
+ {
436
+ deep: true
437
+ }
438
+ )
439
+ },
440
+ {
441
+ immediate: true
442
+ }
443
+ )
444
+
445
+ watch(
446
+ [innerTheme, innerInitOptions],
447
+ () => {
448
+ cleanup()
449
+ init()
450
+ },
451
+ {
452
+ deep: true
453
+ }
454
+ )
455
+
456
+ watchEffect(() => {
457
+ if (props.group && chart.value != null) {
458
+ chart.value.group = props.group
459
+ }
460
+ })
461
+
462
+ const publicApi = usePublicApi(chart)
463
+
464
+ useLoading(chart, {
465
+ loading: () => props.loading,
466
+ loadingOptions: () => props.loadingOptions
467
+ })
468
+
469
+ // #ifdef WEB
470
+
471
+ useAutoresize(chart, {
472
+ echarts,
473
+ autoresize: () => props.autoresize,
474
+ root
475
+ })
476
+
477
+ // #endif
478
+
479
+ function toTempFilePath(options) {
480
+ if (chart.value == null || chart.value.isDisposed()) {
481
+ return
482
+ }
483
+
484
+ const canvas = chart.value.getDom()
485
+
486
+ if (canvas == null) {
487
+ return
488
+ }
489
+
490
+ return canvas.toTempFilePath(options)
491
+ }
492
+
493
+ onMounted(() => {
494
+ init()
495
+ })
496
+
497
+ onBeforeUnmount(() => {
498
+ cleanup()
499
+ })
500
+
501
+ defineExpose({
502
+ root,
503
+ canvasId,
504
+ chart,
505
+ setOption,
506
+ resize,
507
+ ...publicApi,
508
+ toTempFilePath
509
+ })
510
+ </script>
511
+
512
+ <style scoped>
513
+ .uni-echarts {
514
+ position: relative;
515
+ }
516
+
517
+ .uni-echarts__canvas {
518
+ width: 100%;
519
+ height: 100%;
520
+ }
521
+
522
+ .uni-echarts__mask {
523
+ position: absolute;
524
+ top: 0;
525
+ right: 0;
526
+ bottom: 0;
527
+ left: 0;
528
+ z-index: 1;
529
+ }
530
+ </style>
@@ -0,0 +1,19 @@
1
+ /* eslint-disable ts/no-empty-object-type */
2
+ import type { DefineComponent } from "vue";
3
+ import type { AllowedComponentProps } from "../../shared-core";
4
+ import type { UniEchartsEmits, UniEchartsProps } from "./types";
5
+
6
+ type UniEcharts = DefineComponent<
7
+ AllowedComponentProps & UniEchartsProps,
8
+ {},
9
+ {},
10
+ {},
11
+ {},
12
+ {},
13
+ {},
14
+ UniEchartsEmits
15
+ >;
16
+
17
+ declare const _default: UniEcharts;
18
+
19
+ export default _default;
@@ -0,0 +1,7 @@
1
+ declare module "vue" {
2
+ export interface GlobalComponents {
3
+ UniEcharts: typeof import("./components/uni-echarts/uni-echarts.vue")["default"];
4
+ }
5
+ }
6
+
7
+ export {};