@jctrans-materials/comps-vue3 1.0.37-beta.2 → 1.0.37-beta.20
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 +172 -0
- package/dist/components/JcCarrierSearch/AirCarrierSearch.d.ts +6 -0
- package/dist/components/JcCarrierSearch/AirLineSearch.d.ts +6 -0
- package/dist/components/JcCarrierSearch/SeaCarrierSearch.d.ts +6 -0
- package/dist/components/JcCarrierSearch/SeaLineSearch.d.ts +6 -0
- package/dist/components/JcCarrierSearch/index.d.ts +6 -0
- package/dist/components/hooks/useModelValueHydration.d.ts +18 -0
- package/dist/gio.d.ts +60 -0
- package/dist/gio.test.d.ts +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +1 -1
- package/package.json +7 -3
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Vue3 组件说明(jc-utils)
|
|
2
|
+
|
|
3
|
+
## 组件清单
|
|
4
|
+
|
|
5
|
+
当前 `packages/vue3` 对外导出的核心组件如下:
|
|
6
|
+
|
|
7
|
+
- `ApplyDataDialog`
|
|
8
|
+
- `GlobalModal`
|
|
9
|
+
- `JcSearch`
|
|
10
|
+
- `JcMSearch`
|
|
11
|
+
- `JcVerifySlide`
|
|
12
|
+
- `JcCarrierSearch`
|
|
13
|
+
- `AirCarrierSearch`
|
|
14
|
+
- `SeaCarrierSearch`
|
|
15
|
+
- `AirLineSearch`
|
|
16
|
+
- `SeaLineSearch`
|
|
17
|
+
- `LineCascader`
|
|
18
|
+
- `ChineseCompanySearch`
|
|
19
|
+
- `JcLoginDialog`
|
|
20
|
+
- `CodeInput`
|
|
21
|
+
- `GoogleInput`
|
|
22
|
+
- `JcFloatInput`
|
|
23
|
+
- `JcFloatWrapper`
|
|
24
|
+
|
|
25
|
+
## 快速使用
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createApp } from "vue";
|
|
29
|
+
import App from "./App.vue";
|
|
30
|
+
import JCtransComps from "@jctrans-materials/comps-vue3";
|
|
31
|
+
import "@jctrans-materials/comps-vue3/index.css";
|
|
32
|
+
|
|
33
|
+
const app = createApp(App);
|
|
34
|
+
app.use(JCtransComps);
|
|
35
|
+
app.mount("#app");
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 组件能力速览
|
|
39
|
+
|
|
40
|
+
### 搜索类
|
|
41
|
+
|
|
42
|
+
- `JcSearch`:通用地点搜索(国家/城市/港口/机场)
|
|
43
|
+
- `JcMSearch`:移动端/轻量交互搜索
|
|
44
|
+
- `JcCarrierSearch` 及 `Air/Sea Carrier/Line`:承运人与航线搜索
|
|
45
|
+
- `LineCascader`:航线-国家级联选择
|
|
46
|
+
- `ChineseCompanySearch`:中国公司名称联想搜索
|
|
47
|
+
|
|
48
|
+
### 验证与登录类
|
|
49
|
+
|
|
50
|
+
- `JcVerifySlide`:滑块验证码
|
|
51
|
+
- `JcLoginDialog`:登录/注册弹窗
|
|
52
|
+
- `CodeInput` / `GoogleInput`:验证码输入
|
|
53
|
+
|
|
54
|
+
### 输入与弹窗基础类
|
|
55
|
+
|
|
56
|
+
- `JcFloatInput` / `JcFloatWrapper`:浮动标签输入容器
|
|
57
|
+
- `ApplyDataDialog`:补充数据申请
|
|
58
|
+
- `GlobalModal`:全局弹窗容器
|
|
59
|
+
|
|
60
|
+
## 重点事件补充
|
|
61
|
+
|
|
62
|
+
`JcCarrierSearch` 现已透出输入框事件:
|
|
63
|
+
|
|
64
|
+
- `focus`
|
|
65
|
+
- `blur`
|
|
66
|
+
- `remove-tag`
|
|
67
|
+
|
|
68
|
+
便于在业务侧跟踪输入焦点、标签移除行为。
|
|
69
|
+
|
|
70
|
+
## Playground 示例
|
|
71
|
+
|
|
72
|
+
可在以下页面查看 Vue3 组件演示:
|
|
73
|
+
|
|
74
|
+
- `playground/v3play/src/App.vue`
|
|
75
|
+
- `Base Demo`:`JcSearch` + `ApplyDataDialog`
|
|
76
|
+
- `Carrier/Line Demo`:`JcCarrierSearch` + `LineCascader`
|
|
77
|
+
- `MSearch Demo`:`JcMSearch`
|
|
78
|
+
- `Login Dialog Demo`:`JcLoginDialog`
|
|
79
|
+
- `Company Search Demo`:`ChineseCompanySearch`
|
|
80
|
+
- `Verify Slide Demo`:`JcVerifySlide`
|
|
81
|
+
|
|
82
|
+
`JcSearch` 的详细参数说明可参考:
|
|
83
|
+
|
|
84
|
+
- `packages/vue3/src/components/JcSearch/README.md`
|
|
85
|
+
|
|
86
|
+
## GIO 埋点接入(Vue3)
|
|
87
|
+
|
|
88
|
+
### 1) 按需启用(不传配置即不启用)
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { createApp } from "vue";
|
|
92
|
+
import App from "./App.vue";
|
|
93
|
+
import JCtransComps from "@jctrans-materials/comps-vue3";
|
|
94
|
+
|
|
95
|
+
const app = createApp(App);
|
|
96
|
+
|
|
97
|
+
app.use(JCtransComps, {
|
|
98
|
+
tracking: {
|
|
99
|
+
enabled: true,
|
|
100
|
+
autoInit: true,
|
|
101
|
+
directiveName: "gio-track",
|
|
102
|
+
accountId: import.meta.env.VITE_GIO_ACCOUNT_ID,
|
|
103
|
+
dataSourceId: import.meta.env.VITE_GIO_DATA_SOURCE_ID,
|
|
104
|
+
appId: import.meta.env.VITE_GIO_APP_ID,
|
|
105
|
+
initOptions: {
|
|
106
|
+
debug: import.meta.env.DEV,
|
|
107
|
+
trackPage: false,
|
|
108
|
+
serverUrl: import.meta.env.VITE_GIO_SERVER_URL,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
如果不传 `tracking`,则不会初始化 GIO。
|
|
115
|
+
|
|
116
|
+
### 2) 指令与 API 用法
|
|
117
|
+
|
|
118
|
+
```vue
|
|
119
|
+
<button v-gio-track="'order_submit'">提交订单</button>
|
|
120
|
+
|
|
121
|
+
<button
|
|
122
|
+
v-gio-track="{
|
|
123
|
+
event: 'order_submit',
|
|
124
|
+
attrs: { source: 'cart' },
|
|
125
|
+
onTracked: ({ eventName }) => console.log(eventName),
|
|
126
|
+
}"
|
|
127
|
+
>
|
|
128
|
+
提交并回调
|
|
129
|
+
</button>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
const vm = getCurrentInstance()?.proxy;
|
|
134
|
+
vm?.$trackEvent("manual_track", { source: "manual" });
|
|
135
|
+
vm?.$gio.track("direct_track", { source: "direct" }, () => {
|
|
136
|
+
console.log("done");
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3) 配置优先级
|
|
141
|
+
|
|
142
|
+
1. `window.__JCTRANS_GIO_CONFIG__`(或 `globalVarName` 指定对象)
|
|
143
|
+
2. `tracking` 传入配置
|
|
144
|
+
3. `import.meta.env.VITE_GIO_*`
|
|
145
|
+
|
|
146
|
+
### 4) GIO 单测(Vue3)
|
|
147
|
+
|
|
148
|
+
测试文件:`src/gio.test.ts`
|
|
149
|
+
|
|
150
|
+
覆盖点:
|
|
151
|
+
|
|
152
|
+
- 初始化分支:
|
|
153
|
+
- 有 `appId`(4 参数 `init`)
|
|
154
|
+
- 无 `appId`(3 参数 `init`)
|
|
155
|
+
- 缺少必填配置时不初始化
|
|
156
|
+
- 指令行为:`mounted` / `updated` / `beforeUnmount` 的绑定、重绑、清理
|
|
157
|
+
- 回调行为:`onTracked` 在 `track` 回调后触发
|
|
158
|
+
- 暴露能力:`$trackEvent` 与 `$gio` 常用 API
|
|
159
|
+
|
|
160
|
+
结合 GrowingIO WebJS 常用 API 文档(含 `trackTimerStart`)对齐了以下接口可用性:
|
|
161
|
+
|
|
162
|
+
- `setUserId`
|
|
163
|
+
- `clearUserId`
|
|
164
|
+
- `setVisitor`
|
|
165
|
+
- `trackTimerStart`
|
|
166
|
+
- `trackTimerEnd`
|
|
167
|
+
|
|
168
|
+
运行方式:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pnpm -C packages/vue3 test:run
|
|
172
|
+
```
|
|
@@ -11,9 +11,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
11
11
|
default: boolean;
|
|
12
12
|
};
|
|
13
13
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
blur: (...args: any[]) => void;
|
|
14
15
|
change: (...args: any[]) => void;
|
|
16
|
+
focus: (...args: any[]) => void;
|
|
15
17
|
"update:modelValue": (...args: any[]) => void;
|
|
16
18
|
apply: (...args: any[]) => void;
|
|
19
|
+
"remove-tag": (...args: any[]) => void;
|
|
17
20
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
18
21
|
modelValue: {
|
|
19
22
|
required: true;
|
|
@@ -26,9 +29,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
26
29
|
default: boolean;
|
|
27
30
|
};
|
|
28
31
|
}>> & Readonly<{
|
|
32
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
29
33
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
30
35
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
36
|
onApply?: ((...args: any[]) => any) | undefined;
|
|
37
|
+
"onRemove-tag"?: ((...args: any[]) => any) | undefined;
|
|
32
38
|
}>, {
|
|
33
39
|
showApplyData: boolean;
|
|
34
40
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -11,9 +11,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
11
11
|
default: boolean;
|
|
12
12
|
};
|
|
13
13
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
blur: (...args: any[]) => void;
|
|
14
15
|
change: (...args: any[]) => void;
|
|
16
|
+
focus: (...args: any[]) => void;
|
|
15
17
|
"update:modelValue": (...args: any[]) => void;
|
|
16
18
|
apply: (...args: any[]) => void;
|
|
19
|
+
"remove-tag": (...args: any[]) => void;
|
|
17
20
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
18
21
|
modelValue: {
|
|
19
22
|
required: true;
|
|
@@ -26,9 +29,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
26
29
|
default: boolean;
|
|
27
30
|
};
|
|
28
31
|
}>> & Readonly<{
|
|
32
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
29
33
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
30
35
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
36
|
onApply?: ((...args: any[]) => any) | undefined;
|
|
37
|
+
"onRemove-tag"?: ((...args: any[]) => any) | undefined;
|
|
32
38
|
}>, {
|
|
33
39
|
showApplyData: boolean;
|
|
34
40
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -11,9 +11,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
11
11
|
default: boolean;
|
|
12
12
|
};
|
|
13
13
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
blur: (...args: any[]) => void;
|
|
14
15
|
change: (...args: any[]) => void;
|
|
16
|
+
focus: (...args: any[]) => void;
|
|
15
17
|
"update:modelValue": (...args: any[]) => void;
|
|
16
18
|
apply: (...args: any[]) => void;
|
|
19
|
+
"remove-tag": (...args: any[]) => void;
|
|
17
20
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
18
21
|
modelValue: {
|
|
19
22
|
required: true;
|
|
@@ -26,9 +29,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
26
29
|
default: boolean;
|
|
27
30
|
};
|
|
28
31
|
}>> & Readonly<{
|
|
32
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
29
33
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
30
35
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
36
|
onApply?: ((...args: any[]) => any) | undefined;
|
|
37
|
+
"onRemove-tag"?: ((...args: any[]) => any) | undefined;
|
|
32
38
|
}>, {
|
|
33
39
|
showApplyData: boolean;
|
|
34
40
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -11,9 +11,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
11
11
|
default: boolean;
|
|
12
12
|
};
|
|
13
13
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
blur: (...args: any[]) => void;
|
|
14
15
|
change: (...args: any[]) => void;
|
|
16
|
+
focus: (...args: any[]) => void;
|
|
15
17
|
"update:modelValue": (...args: any[]) => void;
|
|
16
18
|
apply: (...args: any[]) => void;
|
|
19
|
+
"remove-tag": (...args: any[]) => void;
|
|
17
20
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
18
21
|
modelValue: {
|
|
19
22
|
required: true;
|
|
@@ -26,9 +29,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
26
29
|
default: boolean;
|
|
27
30
|
};
|
|
28
31
|
}>> & Readonly<{
|
|
32
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
29
33
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
30
35
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
36
|
onApply?: ((...args: any[]) => any) | undefined;
|
|
37
|
+
"onRemove-tag"?: ((...args: any[]) => any) | undefined;
|
|
32
38
|
}>, {
|
|
33
39
|
showApplyData: boolean;
|
|
34
40
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -59,9 +59,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
59
59
|
default: () => never[];
|
|
60
60
|
};
|
|
61
61
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
62
|
+
blur: (...args: any[]) => void;
|
|
62
63
|
change: (...args: any[]) => void;
|
|
64
|
+
focus: (...args: any[]) => void;
|
|
63
65
|
"update:modelValue": (...args: any[]) => void;
|
|
64
66
|
apply: (...args: any[]) => void;
|
|
67
|
+
"remove-tag": (...args: any[]) => void;
|
|
65
68
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
66
69
|
modelValue: {
|
|
67
70
|
type: PropType<string | number | Array<any> | null | undefined>;
|
|
@@ -96,9 +99,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
96
99
|
default: () => never[];
|
|
97
100
|
};
|
|
98
101
|
}>> & Readonly<{
|
|
102
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
99
103
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
104
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
100
105
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
101
106
|
onApply?: ((...args: any[]) => any) | undefined;
|
|
107
|
+
"onRemove-tag"?: ((...args: any[]) => any) | undefined;
|
|
102
108
|
}>, {
|
|
103
109
|
modelValue: string | number | any[] | null | undefined;
|
|
104
110
|
placeholder: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface HydrationBaseItem<TType extends string = string> {
|
|
2
|
+
id?: string | number | null;
|
|
3
|
+
type?: TType | null;
|
|
4
|
+
display?: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
interface FetchResponse<T> {
|
|
8
|
+
records?: T[];
|
|
9
|
+
}
|
|
10
|
+
type FetchByTypeFn<T extends HydrationBaseItem<TType>, TType extends string> = (ids: Array<string | number> | string | number, type: TType) => Promise<FetchResponse<T>>;
|
|
11
|
+
export declare function useModelValueHydration<TType extends string, T extends HydrationBaseItem<TType>>(fetchByType: FetchByTypeFn<T, TType>): {
|
|
12
|
+
hydrateMultiple: (list: T[]) => Promise<{
|
|
13
|
+
updatedList: T[];
|
|
14
|
+
hasChanged: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
hydrateSingle: (item: T | null | undefined) => Promise<T | null | undefined>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
package/dist/gio.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type TrackAttrs = Record<string, string | number | Array<string | number>>;
|
|
4
|
+
export type TrackDirectiveValue = string | {
|
|
5
|
+
event?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
attrs?: TrackAttrs;
|
|
8
|
+
attributes?: TrackAttrs;
|
|
9
|
+
trigger?: string;
|
|
10
|
+
once?: boolean;
|
|
11
|
+
stop?: boolean;
|
|
12
|
+
prevent?: boolean;
|
|
13
|
+
callback?: (payload: {
|
|
14
|
+
event: Event;
|
|
15
|
+
eventName: string;
|
|
16
|
+
attrs: TrackAttrs;
|
|
17
|
+
trigger: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
onTracked?: (payload: {
|
|
20
|
+
event: Event;
|
|
21
|
+
eventName: string;
|
|
22
|
+
attrs: TrackAttrs;
|
|
23
|
+
trigger: string;
|
|
24
|
+
}) => void;
|
|
25
|
+
};
|
|
26
|
+
export type TrackConfig = {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
autoInit?: boolean;
|
|
29
|
+
directiveName?: string;
|
|
30
|
+
globalVarName?: string;
|
|
31
|
+
accountId?: string;
|
|
32
|
+
dataSourceId?: string;
|
|
33
|
+
appId?: string;
|
|
34
|
+
serverUrl?: string;
|
|
35
|
+
initOptions?: {
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
trackPage?: boolean;
|
|
38
|
+
forceLogin?: boolean;
|
|
39
|
+
idMapping?: boolean;
|
|
40
|
+
hashtag?: boolean;
|
|
41
|
+
serverUrl?: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type GioPublicApi = {
|
|
45
|
+
isInitialized: () => boolean;
|
|
46
|
+
isBrowser: () => boolean;
|
|
47
|
+
init: (...args: any[]) => void;
|
|
48
|
+
track: (eventName: string, attrs?: TrackAttrs, callback?: () => void) => void;
|
|
49
|
+
setUserId: (userId: string) => void;
|
|
50
|
+
clearUserId: () => void;
|
|
51
|
+
setVisitor: (visitor: Record<string, any>) => void;
|
|
52
|
+
setGeneralProps: (props: Record<string, any>) => void;
|
|
53
|
+
setPageAttributes: (props: Record<string, any>) => void;
|
|
54
|
+
sendPage: () => void;
|
|
55
|
+
trackTimerStart: (eventName: string) => void;
|
|
56
|
+
trackTimerEnd: (eventName: string, attrs?: TrackAttrs) => void;
|
|
57
|
+
};
|
|
58
|
+
export declare function createGioTrackingPlugin(rawConfig?: TrackConfig): {
|
|
59
|
+
install(app: App): void;
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|