@jctrans-materials/comps-vue2 1.0.37-beta.1 → 1.0.37-beta.11

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,157 @@
1
+ # Vue2 组件说明(jc-utils)
2
+
3
+ ## 组件清单
4
+
5
+ 当前 `packages/vue2` 对外导出的核心组件如下:
6
+
7
+ - `ApplyDataDialog`
8
+ - `GlobalModal`
9
+ - `JcSearch`
10
+ - `JcVerifySlide`
11
+ - `JcCarrierSearch`
12
+ - `AirCarrierSearch`
13
+ - `SeaCarrierSearch`
14
+ - `AirLineSearch`
15
+ - `SeaLineSearch`
16
+
17
+ ## 快速使用
18
+
19
+ ```ts
20
+ import Vue from "vue";
21
+ import JCtransComps from "@jctrans-materials/comps-vue2";
22
+ import "@jctrans-materials/comps-vue2/style.css";
23
+
24
+ Vue.use(JCtransComps);
25
+ ```
26
+
27
+ ## 组件能力速览
28
+
29
+ ### 1) `JcSearch`
30
+
31
+ - 用途:国家/城市/港口/机场等通用地点搜索
32
+ - 常用 Props:`value` / `modelValue`、`multiple`、`searchTypeList`、`historyKey`
33
+ - 常用事件:`select`、`change`、`input`、`update:modelValue`
34
+
35
+ ### 2) `JcVerifySlide`
36
+
37
+ - 用途:滑块验证码验证
38
+ - 常用 Props:`visible`、`lang`、`mode`、`imgSize`、`barSize`
39
+ - 常用事件:`success`、`update:visible`
40
+
41
+ ### 3) `JcCarrierSearch` 及包装组件
42
+
43
+ - 用途:承运人/航线搜索(海运、空运)
44
+ - 常用 Props:`value` / `modelValue`、`type`、`lineType`、`multiple`、`showApplyData`
45
+ - 常用事件:
46
+ - 业务:`change`、`apply`
47
+ - 输入框:`focus`、`blur`、`remove-tag`
48
+
49
+ 包装组件:
50
+
51
+ - `AirCarrierSearch`(航空公司)
52
+ - `SeaCarrierSearch`(船公司)
53
+ - `AirLineSearch`(空运航线)
54
+ - `SeaLineSearch`(海运航线)
55
+
56
+ ### 4) `ApplyDataDialog`
57
+
58
+ - 用途:申请补充数据弹窗
59
+ - 常用 Props:`value`
60
+ - 常用事件:`confirm`、`input` / `update:value`
61
+
62
+ ### 5) `GlobalModal`
63
+
64
+ - 用途:全局业务弹窗容器(配合插件/事件总线)
65
+
66
+ ## Playground 示例
67
+
68
+ 可在以下页面查看 Vue2 组件演示:
69
+
70
+ - `playground/v2play/src/App.vue`
71
+ - `Base Demo`:`JcSearch` + `ApplyDataDialog` + `GlobalModal`
72
+ - `Carrier Search Demo`:`JcCarrierSearch` 系列
73
+ - `Verify Slide Demo`:`JcVerifySlide`
74
+
75
+ ## GIO 埋点接入(Vue2)
76
+
77
+ ### 1) 按需启用(不传配置即不启用)
78
+
79
+ ```ts
80
+ import Vue from "vue";
81
+ import JCtransComps from "@jctrans-materials/comps-vue2";
82
+
83
+ Vue.use(JCtransComps, {
84
+ tracking: {
85
+ enabled: true,
86
+ autoInit: true,
87
+ directiveName: "gio-track",
88
+ accountId: process.env.VUE_APP_GIO_ACCOUNT_ID,
89
+ dataSourceId: process.env.VUE_APP_GIO_DATA_SOURCE_ID,
90
+ appId: process.env.VUE_APP_GIO_APP_ID,
91
+ initOptions: {
92
+ debug: process.env.NODE_ENV !== "production",
93
+ trackPage: false,
94
+ serverUrl: process.env.VUE_APP_GIO_SERVER_URL,
95
+ },
96
+ },
97
+ });
98
+ ```
99
+
100
+ 如果不传 `tracking`,则不会初始化 GIO。
101
+
102
+ ### 2) 指令与 API 用法
103
+
104
+ ```vue
105
+ <button v-gio-track="'order_submit'">提交订单</button>
106
+
107
+ <button
108
+ v-gio-track="{
109
+ event: 'order_submit',
110
+ attrs: { source: 'cart' },
111
+ onTracked: ({ eventName }) => console.log(eventName),
112
+ }"
113
+ >
114
+ 提交并回调
115
+ </button>
116
+ ```
117
+
118
+ ```ts
119
+ this.$trackEvent("manual_track", { source: "manual" });
120
+ this.$gio.track("direct_track", { source: "direct" }, () => {
121
+ console.log("done");
122
+ });
123
+ ```
124
+
125
+ ### 3) 配置优先级
126
+
127
+ 1. `window.__JCTRANS_GIO_CONFIG__`(或 `globalVarName` 指定对象)
128
+ 2. `tracking` 传入配置
129
+ 3. `import.meta.env.VITE_GIO_*`
130
+
131
+ ### 4) GIO 单测(Vue2)
132
+
133
+ 测试文件:`src/gio.test.ts`
134
+
135
+ 覆盖点:
136
+
137
+ - 初始化分支:
138
+ - 有 `appId`(4 参数 `init`)
139
+ - 无 `appId`(3 参数 `init`)
140
+ - 缺少必填配置时不初始化
141
+ - 指令行为:`bind` / `update` / `unbind` 的绑定、重绑、清理
142
+ - 回调行为:`onTracked` 在 `track` 回调后触发
143
+ - 暴露能力:`$trackEvent` 与 `$gio` 常用 API
144
+
145
+ 结合 GrowingIO WebJS 常用 API 文档(含 `trackTimerStart`)对齐了以下接口可用性:
146
+
147
+ - `setUserId`
148
+ - `clearUserId`
149
+ - `setVisitor`
150
+ - `trackTimerStart`
151
+ - `trackTimerEnd`
152
+
153
+ 运行方式:
154
+
155
+ ```bash
156
+ pnpm -C packages/vue2 test:run
157
+ ```
@@ -15,12 +15,17 @@ declare const _default: import('vue').DefineComponent<{
15
15
  type: StringConstructor;
16
16
  default: string;
17
17
  };
18
+ showApplyData: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
18
22
  }, {
19
23
  carrierId: import('vue').WritableComputedRef<string | number>;
20
24
  currentPlaceholder: import('vue').ComputedRef<string>;
21
25
  onCarrierChange: (value: string | number) => void;
22
26
  lang: string;
23
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply")[], string, Readonly<import('vue').ExtractPropTypes<{
27
+ showApplyData: boolean;
28
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply" | "focus" | "blur" | "remove-tag")[], string, Readonly<import('vue').ExtractPropTypes<{
24
29
  value: {
25
30
  type: (StringConstructor | NumberConstructor)[];
26
31
  default: string;
@@ -37,10 +42,15 @@ declare const _default: import('vue').DefineComponent<{
37
42
  type: StringConstructor;
38
43
  default: string;
39
44
  };
45
+ showApplyData: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
40
49
  }>>, {
41
50
  value: string | number;
42
51
  modelValue: string | number;
43
52
  lang: string;
44
53
  placeholder: string;
54
+ showApplyData: boolean;
45
55
  }>;
46
56
  export default _default;
@@ -15,12 +15,17 @@ declare const _default: import('vue').DefineComponent<{
15
15
  type: StringConstructor;
16
16
  default: string;
17
17
  };
18
+ showApplyData: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
18
22
  }, {
19
23
  carrierId: import('vue').WritableComputedRef<string | number>;
20
24
  currentPlaceholder: import('vue').ComputedRef<string>;
21
25
  onCarrierChange: (value: string | number) => void;
22
26
  lang: string;
23
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply")[], string, Readonly<import('vue').ExtractPropTypes<{
27
+ showApplyData: boolean;
28
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply" | "focus" | "blur" | "remove-tag")[], string, Readonly<import('vue').ExtractPropTypes<{
24
29
  value: {
25
30
  type: (StringConstructor | NumberConstructor)[];
26
31
  default: string;
@@ -37,10 +42,15 @@ declare const _default: import('vue').DefineComponent<{
37
42
  type: StringConstructor;
38
43
  default: string;
39
44
  };
45
+ showApplyData: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
40
49
  }>>, {
41
50
  value: string | number;
42
51
  modelValue: string | number;
43
52
  lang: string;
44
53
  placeholder: string;
54
+ showApplyData: boolean;
45
55
  }>;
46
56
  export default _default;
@@ -15,12 +15,17 @@ declare const _default: import('vue').DefineComponent<{
15
15
  type: StringConstructor;
16
16
  default: string;
17
17
  };
18
+ showApplyData: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
18
22
  }, {
19
23
  carrierId: import('vue').WritableComputedRef<string | number>;
20
24
  currentPlaceholder: import('vue').ComputedRef<string>;
21
25
  onCarrierChange: (value: string | number) => void;
22
26
  lang: string;
23
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply")[], string, Readonly<import('vue').ExtractPropTypes<{
27
+ showApplyData: boolean;
28
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply" | "focus" | "blur" | "remove-tag")[], string, Readonly<import('vue').ExtractPropTypes<{
24
29
  value: {
25
30
  type: (StringConstructor | NumberConstructor)[];
26
31
  default: string;
@@ -37,10 +42,15 @@ declare const _default: import('vue').DefineComponent<{
37
42
  type: StringConstructor;
38
43
  default: string;
39
44
  };
45
+ showApplyData: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
40
49
  }>>, {
41
50
  value: string | number;
42
51
  modelValue: string | number;
43
52
  lang: string;
44
53
  placeholder: string;
54
+ showApplyData: boolean;
45
55
  }>;
46
56
  export default _default;
@@ -15,12 +15,17 @@ declare const _default: import('vue').DefineComponent<{
15
15
  type: StringConstructor;
16
16
  default: string;
17
17
  };
18
+ showApplyData: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
18
22
  }, {
19
23
  carrierId: import('vue').WritableComputedRef<string | number>;
20
24
  currentPlaceholder: import('vue').ComputedRef<string>;
21
25
  onCarrierChange: (value: string | number) => void;
22
26
  lang: string;
23
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply")[], string, Readonly<import('vue').ExtractPropTypes<{
27
+ showApplyData: boolean;
28
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply" | "focus" | "blur" | "remove-tag")[], string, Readonly<import('vue').ExtractPropTypes<{
24
29
  value: {
25
30
  type: (StringConstructor | NumberConstructor)[];
26
31
  default: string;
@@ -37,10 +42,15 @@ declare const _default: import('vue').DefineComponent<{
37
42
  type: StringConstructor;
38
43
  default: string;
39
44
  };
45
+ showApplyData: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
40
49
  }>>, {
41
50
  value: string | number;
42
51
  modelValue: string | number;
43
52
  lang: string;
44
53
  placeholder: string;
54
+ showApplyData: boolean;
45
55
  }>;
46
56
  export default _default;
@@ -29,6 +29,10 @@ declare const _default: import('vue').DefineComponent<{
29
29
  type: BooleanConstructor;
30
30
  default: boolean;
31
31
  };
32
+ showApplyData: {
33
+ type: BooleanConstructor;
34
+ default: boolean;
35
+ };
32
36
  defaultOptions: {
33
37
  type: () => LocationUnifiedItem[];
34
38
  default: () => never[];
@@ -63,9 +67,12 @@ declare const _default: import('vue').DefineComponent<{
63
67
  handleClear: () => void;
64
68
  handleChange: (val: any) => void;
65
69
  handleApply: () => void;
70
+ handleRemoveTag: (tag: any) => void;
66
71
  ICON_MORE: string;
72
+ showApplyData: boolean;
73
+ normalizeOptionValue: (id: any) => any;
67
74
  multiple: boolean;
68
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply")[], string, Readonly<import('vue').ExtractPropTypes<{
75
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("input" | "update:modelValue" | "update:value" | "change" | "apply" | "focus" | "blur" | "remove-tag")[], string, Readonly<import('vue').ExtractPropTypes<{
69
76
  value: {
70
77
  type: (StringConstructor | NumberConstructor | ArrayConstructor)[];
71
78
  default: undefined;
@@ -94,6 +101,10 @@ declare const _default: import('vue').DefineComponent<{
94
101
  type: BooleanConstructor;
95
102
  default: boolean;
96
103
  };
104
+ showApplyData: {
105
+ type: BooleanConstructor;
106
+ default: boolean;
107
+ };
97
108
  defaultOptions: {
98
109
  type: () => LocationUnifiedItem[];
99
110
  default: () => never[];
@@ -105,6 +116,7 @@ declare const _default: import('vue').DefineComponent<{
105
116
  lineType: "air" | "shipping";
106
117
  placeholder: string;
107
118
  multiple: boolean;
119
+ showApplyData: boolean;
108
120
  defaultOptions: LocationUnifiedItem[];
109
121
  }>;
110
122
  export default _default;
@@ -163,12 +163,12 @@ declare const _default: import('vue').DefineComponent<{
163
163
  lang: string;
164
164
  placeholder: string;
165
165
  multiple: boolean;
166
+ showApplyData: boolean;
166
167
  disabled: boolean;
167
168
  collapseTags: boolean;
168
169
  searchTypeList: unknown[];
169
170
  historyKey: string;
170
171
  showSearchIcon: boolean;
171
172
  showItemTag: boolean;
172
- showApplyData: boolean;
173
173
  }>;
174
174
  export default _default;
package/dist/gio.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { VueConstructor } 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(Vue: VueConstructor): void;
60
+ };
@@ -0,0 +1,2 @@
1
+ /** 🤡 Powered by My Super Rules */
2
+ export {};