zxl-common-utils 0.0.2 → 0.0.4

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/README.md CHANGED
@@ -1,9 +1,86 @@
1
1
  # zxl-common-utils
2
2
 
3
- 一个基于 Vue 3 和 TypeScript 的通用工具库,封装各种常用方法、组件和工具。
3
+ 一个基于 Vue 3 和 TypeScript 的通用工具库,封装常用方法、组件与工具。
4
4
 
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
8
  npm install zxl-common-utils
9
9
  ```
10
+
11
+ ## 使用组件
12
+ ### 滚动组件有两种:
13
+ #### domAutoScroll dom滚动
14
+
15
+ ```vue
16
+ <script setup lang="ts">
17
+ import { ref, computed } from 'vue';
18
+ import { domAutoScroll } from 'zxl-common-utils';
19
+
20
+ const props = defineProps<{
21
+ data: Array<{ id: number; name: string }>;
22
+ }>();
23
+
24
+ const scrollAreaRef = ref<HTMLElement | null>(null);
25
+
26
+ const bindCloneOverlayEvents = (cloneContainer: HTMLElement, index: number) => {
27
+ const curssEl = cloneContainer.querySelector('.curss');
28
+ cloneContainer.addEventListener('mouseenter', () => {
29
+ curssEl?.classList.add('curss-h');
30
+ });
31
+ cloneContainer.addEventListener('mouseleave', () => {
32
+ curssEl?.classList.remove('curss-h');
33
+ });
34
+ };
35
+ </script>
36
+
37
+ <template>
38
+ <domAutoScroll
39
+ :enabled="true"
40
+ :item-count="data.length"
41
+ :scroll-config="{mode: 'step', speed: 0.5, stepInterval: 1000, stepDuration: 500}"
42
+ :on-clone-created="bindCloneOverlayEvents"
43
+ >
44
+ <div v-for="item in props.data" :key="item.id" class="item">
45
+ {{ item.name }}
46
+ </div>
47
+ </domAutoScroll>
48
+ </template>
49
+ ```
50
+
51
+ #### echartsAutoScroll echarts滚动
52
+
53
+ ```vue
54
+ <script setup lang="ts">
55
+ import { ref } from 'vue';
56
+ import { echartsAutoScroll } from 'zxl-common-utils';
57
+ const chartRef = ref<HTMLElement | null>(null);
58
+
59
+ const bindCloneOverlayEvents = (cloneContainer: HTMLElement) => {
60
+ 事件逻辑按照自己的来,
61
+ };
62
+ const getOptions = () => {
63
+ return {
64
+ grid: ...,
65
+ legend: {show: false},
66
+ tooltip: ..,
67
+ xAxis: ...,
68
+ yAxis: ...,
69
+ series: ...,
70
+ } as echarts.EChartsOption;
71
+ };
72
+ </script>
73
+
74
+ <template>
75
+ <echartsAutoScroll
76
+ :chartRef="chartRef"
77
+ :enabled="true"
78
+ :itemCount="5"
79
+ :getOptions="getOptions"
80
+ :scrollConfig="{ speed: 0.5, stepInterval: 1000, stepDuration: 500 }"
81
+ @onCloneCreated="bindCloneOverlayEvents"
82
+ >
83
+ <div ref="chartRef" class="echarts-render"></div>
84
+ </echartsAutoScroll>
85
+ </template>
86
+ ```
@@ -2,5 +2,7 @@ declare const components: Record<string, any>;
2
2
  export default components;
3
3
  export declare const ComponentRatio: any;
4
4
  export declare const Image: any;
5
+ export declare const domAutoScroll: any;
6
+ export declare const echartsAutoScroll: any;
5
7
  export declare const TooltipBox: any;
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAC;AAY3C,eAAe,UAAU,CAAC;AAG1B,eAAO,MAAM,cAAc,KAA4B,CAAC;AACxD,eAAO,MAAM,KAAK,KAAmB,CAAC;AACtC,eAAO,MAAM,UAAU,KAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAC;AAY3C,eAAe,UAAU,CAAC;AAG1B,eAAO,MAAM,cAAc,KAA4B,CAAC;AACxD,eAAO,MAAM,KAAK,KAAmB,CAAC;AACtC,eAAO,MAAM,aAAa,KAA2B,CAAC;AACtD,eAAO,MAAM,iBAAiB,KAA+B,CAAC;AAC9D,eAAO,MAAM,UAAU,KAAwB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { useComponents } from './plugins/components';
2
2
  export { useComponents };
3
3
  export * from './utils';
4
4
  export * from './components';
5
- export type { ColorList, TemplateToolsType, DefaultPropsType, StaticConfig, StaticOptions, StaticResources, UseColorReturn, ColorMap, ComponentProps, } from './types';
5
+ export type { ColorList, TemplateToolsType, DefaultPropsType, StaticConfig, StaticOptions, StaticResources, UseColorReturn, ColorMap, ComponentProps, ScrollConfig, ScrollMode, } from './types';
6
6
  declare const defaultExport: Record<string, any>;
7
7
  export default defaultExport;
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,EAAE,aAAa,EAAE,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,QAAQ,EACR,cAAc,GACf,MAAM,SAAS,CAAC;AAIjB,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAItC,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,EAAE,aAAa,EAAE,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,SAAS,CAAC;AAIjB,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAItC,CAAC;AAEF,eAAe,aAAa,CAAC"}