@jctrans-materials/comps-vue3 1.0.37-beta.1 → 1.0.37-beta.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/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
+ ```
@@ -2,26 +2,42 @@ declare function __VLS_template(): Partial<Record<NonNullable<string | number>,
2
2
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
3
  modelValue: {
4
4
  required: true;
5
- type: import('vue').PropType<any>;
5
+ type: import('vue').PropType<string | number>;
6
6
  };
7
7
  lang: StringConstructor;
8
8
  placeholder: StringConstructor;
9
+ showApplyData: {
10
+ type: BooleanConstructor;
11
+ default: boolean;
12
+ };
9
13
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ blur: (...args: any[]) => void;
10
15
  change: (...args: any[]) => void;
16
+ focus: (...args: any[]) => void;
11
17
  "update:modelValue": (...args: any[]) => void;
12
18
  apply: (...args: any[]) => void;
19
+ "remove-tag": (...args: any[]) => void;
13
20
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
14
21
  modelValue: {
15
22
  required: true;
16
- type: import('vue').PropType<any>;
23
+ type: import('vue').PropType<string | number>;
17
24
  };
18
25
  lang: StringConstructor;
19
26
  placeholder: StringConstructor;
27
+ showApplyData: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
20
31
  }>> & Readonly<{
32
+ onBlur?: ((...args: any[]) => any) | undefined;
21
33
  onChange?: ((...args: any[]) => any) | undefined;
34
+ onFocus?: ((...args: any[]) => any) | undefined;
22
35
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
23
36
  onApply?: ((...args: any[]) => any) | undefined;
24
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
37
+ "onRemove-tag"?: ((...args: any[]) => any) | undefined;
38
+ }>, {
39
+ showApplyData: boolean;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
25
41
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
26
42
  export default _default;
27
43
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -2,26 +2,42 @@ declare function __VLS_template(): Partial<Record<NonNullable<string | number>,
2
2
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
3
  modelValue: {
4
4
  required: true;
5
- type: import('vue').PropType<any>;
5
+ type: import('vue').PropType<string | number>;
6
6
  };
7
7
  lang: StringConstructor;
8
8
  placeholder: StringConstructor;
9
+ showApplyData: {
10
+ type: BooleanConstructor;
11
+ default: boolean;
12
+ };
9
13
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ blur: (...args: any[]) => void;
10
15
  change: (...args: any[]) => void;
16
+ focus: (...args: any[]) => void;
11
17
  "update:modelValue": (...args: any[]) => void;
12
18
  apply: (...args: any[]) => void;
19
+ "remove-tag": (...args: any[]) => void;
13
20
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
14
21
  modelValue: {
15
22
  required: true;
16
- type: import('vue').PropType<any>;
23
+ type: import('vue').PropType<string | number>;
17
24
  };
18
25
  lang: StringConstructor;
19
26
  placeholder: StringConstructor;
27
+ showApplyData: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
20
31
  }>> & Readonly<{
32
+ onBlur?: ((...args: any[]) => any) | undefined;
21
33
  onChange?: ((...args: any[]) => any) | undefined;
34
+ onFocus?: ((...args: any[]) => any) | undefined;
22
35
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
23
36
  onApply?: ((...args: any[]) => any) | undefined;
24
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
37
+ "onRemove-tag"?: ((...args: any[]) => any) | undefined;
38
+ }>, {
39
+ showApplyData: boolean;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
25
41
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
26
42
  export default _default;
27
43
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -2,26 +2,42 @@ declare function __VLS_template(): Partial<Record<NonNullable<string | number>,
2
2
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
3
  modelValue: {
4
4
  required: true;
5
- type: import('vue').PropType<any>;
5
+ type: import('vue').PropType<string | number>;
6
6
  };
7
7
  lang: StringConstructor;
8
8
  placeholder: StringConstructor;
9
+ showApplyData: {
10
+ type: BooleanConstructor;
11
+ default: boolean;
12
+ };
9
13
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ blur: (...args: any[]) => void;
10
15
  change: (...args: any[]) => void;
16
+ focus: (...args: any[]) => void;
11
17
  "update:modelValue": (...args: any[]) => void;
12
18
  apply: (...args: any[]) => void;
19
+ "remove-tag": (...args: any[]) => void;
13
20
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
14
21
  modelValue: {
15
22
  required: true;
16
- type: import('vue').PropType<any>;
23
+ type: import('vue').PropType<string | number>;
17
24
  };
18
25
  lang: StringConstructor;
19
26
  placeholder: StringConstructor;
27
+ showApplyData: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
20
31
  }>> & Readonly<{
32
+ onBlur?: ((...args: any[]) => any) | undefined;
21
33
  onChange?: ((...args: any[]) => any) | undefined;
34
+ onFocus?: ((...args: any[]) => any) | undefined;
22
35
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
23
36
  onApply?: ((...args: any[]) => any) | undefined;
24
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
37
+ "onRemove-tag"?: ((...args: any[]) => any) | undefined;
38
+ }>, {
39
+ showApplyData: boolean;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
25
41
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
26
42
  export default _default;
27
43
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -2,26 +2,42 @@ declare function __VLS_template(): Partial<Record<NonNullable<string | number>,
2
2
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
3
  modelValue: {
4
4
  required: true;
5
- type: import('vue').PropType<any>;
5
+ type: import('vue').PropType<string | number>;
6
6
  };
7
7
  lang: StringConstructor;
8
8
  placeholder: StringConstructor;
9
+ showApplyData: {
10
+ type: BooleanConstructor;
11
+ default: boolean;
12
+ };
9
13
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ blur: (...args: any[]) => void;
10
15
  change: (...args: any[]) => void;
16
+ focus: (...args: any[]) => void;
11
17
  "update:modelValue": (...args: any[]) => void;
12
18
  apply: (...args: any[]) => void;
19
+ "remove-tag": (...args: any[]) => void;
13
20
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
14
21
  modelValue: {
15
22
  required: true;
16
- type: import('vue').PropType<any>;
23
+ type: import('vue').PropType<string | number>;
17
24
  };
18
25
  lang: StringConstructor;
19
26
  placeholder: StringConstructor;
27
+ showApplyData: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
20
31
  }>> & Readonly<{
32
+ onBlur?: ((...args: any[]) => any) | undefined;
21
33
  onChange?: ((...args: any[]) => any) | undefined;
34
+ onFocus?: ((...args: any[]) => any) | undefined;
22
35
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
23
36
  onApply?: ((...args: any[]) => any) | undefined;
24
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
37
+ "onRemove-tag"?: ((...args: any[]) => any) | undefined;
38
+ }>, {
39
+ showApplyData: boolean;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
25
41
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
26
42
  export default _default;
27
43
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -50,14 +50,21 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
50
50
  type: BooleanConstructor;
51
51
  default: boolean;
52
52
  };
53
+ showApplyData: {
54
+ type: BooleanConstructor;
55
+ default: boolean;
56
+ };
53
57
  defaultOptions: {
54
58
  type: () => LocationUnifiedItem[];
55
59
  default: () => never[];
56
60
  };
57
61
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
62
+ blur: (...args: any[]) => void;
58
63
  change: (...args: any[]) => void;
64
+ focus: (...args: any[]) => void;
59
65
  "update:modelValue": (...args: any[]) => void;
60
66
  apply: (...args: any[]) => void;
67
+ "remove-tag": (...args: any[]) => void;
61
68
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
62
69
  modelValue: {
63
70
  type: PropType<string | number | Array<any> | null | undefined>;
@@ -83,18 +90,26 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
83
90
  type: BooleanConstructor;
84
91
  default: boolean;
85
92
  };
93
+ showApplyData: {
94
+ type: BooleanConstructor;
95
+ default: boolean;
96
+ };
86
97
  defaultOptions: {
87
98
  type: () => LocationUnifiedItem[];
88
99
  default: () => never[];
89
100
  };
90
101
  }>> & Readonly<{
102
+ onBlur?: ((...args: any[]) => any) | undefined;
91
103
  onChange?: ((...args: any[]) => any) | undefined;
104
+ onFocus?: ((...args: any[]) => any) | undefined;
92
105
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
93
106
  onApply?: ((...args: any[]) => any) | undefined;
107
+ "onRemove-tag"?: ((...args: any[]) => any) | undefined;
94
108
  }>, {
95
109
  modelValue: string | number | any[] | null | undefined;
96
110
  placeholder: string;
97
111
  lang: string;
112
+ showApplyData: boolean;
98
113
  lineType: "air" | "shipping";
99
114
  multiple: boolean;
100
115
  defaultOptions: LocationUnifiedItem[];
@@ -98,6 +98,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
98
98
  disabled: boolean;
99
99
  modelValue: SearchItem | SearchItem[] | null;
100
100
  lang: "" | "en" | "cn" | "en-US" | "zh-CN";
101
+ showApplyData: boolean;
101
102
  multiple: boolean;
102
103
  collapseTags: boolean;
103
104
  historyKey: string;
@@ -106,7 +107,6 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
106
107
  searchTypeList: string[];
107
108
  showSearchIcon: boolean;
108
109
  showItemTag: boolean;
109
- showApplyData: boolean;
110
110
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
111
111
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
112
112
  export default _default;
@@ -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 {};