ch3chi-commons-vue 0.1.11 → 0.1.13

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.
@@ -0,0 +1,94 @@
1
+ import { ApiResponse } from '../api/ApiService';
2
+ /**
3
+ * QuerySort 定義了查詢的排序條件
4
+ */
5
+ export interface QuerySort {
6
+ field: string;
7
+ direction: 'asc' | 'desc';
8
+ }
9
+ /**
10
+ * PageSizeOptions 定義了可用的分頁大小選項
11
+ */
12
+ export declare const PageSizeOptions: number[];
13
+ /**
14
+ * IQueryPage 定義了查詢的分頁資訊
15
+ */
16
+ export interface IQueryPage {
17
+ pageIndex: number;
18
+ pageSize: number;
19
+ totalPage: number;
20
+ totalCount: number;
21
+ }
22
+ /**
23
+ * QueryPage 實現了 IQueryPage 接口,提供分頁資訊的管理
24
+ */
25
+ export declare class QueryPage implements IQueryPage {
26
+ pageIndex: number;
27
+ pageSize: number;
28
+ totalPage: number;
29
+ private _totalCount;
30
+ pageRangeDisplayed: number;
31
+ constructor(data?: Partial<QueryPage>);
32
+ get totalCount(): number;
33
+ set totalCount(value: number);
34
+ get offset(): number;
35
+ /**
36
+ * 計算總頁數
37
+ */
38
+ calcTotalPage(): void;
39
+ hasPreviousPage(): boolean;
40
+ hasNextPage(): boolean;
41
+ previous(): void;
42
+ next(): void;
43
+ isShowFirstPage(): boolean;
44
+ isShowLastPage(): boolean;
45
+ usePageItemArray(): number[];
46
+ /**
47
+ * 生成分頁的顯示範圍,項目為從 0 開始的頁碼陣列
48
+ *
49
+ * @returns {number[]} 返回一個包含顯示頁碼的陣列
50
+ */
51
+ pageRange(): number[];
52
+ }
53
+ export interface QueryParameter {
54
+ keyword?: string | null;
55
+ page?: QueryPage;
56
+ sort?: QuerySort[];
57
+ }
58
+ export declare class QueryParameter implements QueryParameter {
59
+ keyword?: string | null;
60
+ page?: QueryPage;
61
+ sort?: QuerySort[];
62
+ constructor(data?: Partial<QueryParameter>);
63
+ /**
64
+ * 載入查詢參數資料
65
+ * @param data 部分或全部的查詢參數
66
+ */
67
+ load(data?: Partial<QueryParameter>): void;
68
+ /**
69
+ * 載入 API 回應資料
70
+ * @param response
71
+ */
72
+ loadResponse(response: ApiResponse): void;
73
+ /**
74
+ * 產生 API 使用的 payload
75
+ * @returns {Record<string, any>} 返回一個包含查詢參數的物件
76
+ */
77
+ toPayload(): Record<string, any>;
78
+ /**
79
+ * 產生 URL 查詢參數
80
+ */
81
+ toQueryStringParam(): Record<string, any>;
82
+ /**
83
+ * 清除查詢參數
84
+ */
85
+ clear(): void;
86
+ }
87
+ /**
88
+ * 適用於 Date Range 的查詢參數
89
+ */
90
+ export declare class DateRangeParam extends QueryParameter {
91
+ startsAt?: Date | null;
92
+ endsAt?: Date | null;
93
+ clear(): void;
94
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 用來描述操作人員的物件
3
+ * 用來保存已登入的使用者資訊
4
+ */
5
+ export declare class SessionUser {
6
+ sub?: string;
7
+ iat?: number;
8
+ account?: string;
9
+ name?: string;
10
+ email?: string;
11
+ roleCode?: string;
12
+ roleName?: string;
13
+ permissions?: string[];
14
+ constructor(data?: Partial<SessionUser>);
15
+ /**
16
+ * 載入資料
17
+ * @param data
18
+ */
19
+ load(data: Record<string, any>): SessionUser;
20
+ /**
21
+ * 合併資料
22
+ * @param data
23
+ */
24
+ merge(data: Partial<SessionUser>): SessionUser;
25
+ /**
26
+ * 對載入的資料進行預處理
27
+ * @param data
28
+ */
29
+ process(data: Record<string, any>): Record<string, any>;
30
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Backup Form Data Store
3
+ * This store is used to manage the system setting details in a backup form.
4
+ */
5
+ export declare const backupFormDataStore: import('pinia').StoreDefinition<"formData", {
6
+ store: Record<string, any>;
7
+ }, {
8
+ getBackupData: (state: {
9
+ store: Record<string, any>;
10
+ } & import('pinia').PiniaCustomStateProperties<{
11
+ store: Record<string, any>;
12
+ }>) => (dataName: string) => Record<string, any> | null;
13
+ }, {
14
+ backupData(dataName: string, data: Record<string, any>): void;
15
+ }>;
16
+ /**
17
+ * 用來保留查詢表單的資料到 local storage
18
+ */
19
+ export declare const useQueryFormDataStore: import('pinia').StoreDefinition<"queryFormData", {
20
+ store: Record<string, any>;
21
+ }, {
22
+ getQueryParam: (state: {
23
+ store: Record<string, any>;
24
+ } & import('pinia').PiniaCustomStateProperties<{
25
+ store: Record<string, any>;
26
+ }>) => (formName: string) => Record<string, any> | null;
27
+ }, {
28
+ save(formName: string, queryParam: Record<string, any>): void;
29
+ loadAllFromLocalStorage(): void;
30
+ clearQueryParam(formName: string): void;
31
+ }>;
@@ -0,0 +1,215 @@
1
+ import { ComponentPublicInstance } from 'vue';
2
+ import { default as CAlert } from '../components/CAlert.vue';
3
+ import { CAlertModalData } from '../components/CAlertDefine';
4
+ import { default as CBSToast } from '../components/CBSToast.vue';
5
+ import { default as CGlobalSpinner } from '../components/CGlobalSpinner.vue';
6
+ import { SessionUser } from '../model/SessionUser';
7
+ import { CMenuItem } from '../model/CMenuItem';
8
+ export type RouterNavigationType = 'push' | 'back' | 'forward' | 'unknown';
9
+ /**
10
+ * 保存視圖相關的狀態,例如側邊欄開啟狀態、模態框、Toast、全局加載等
11
+ */
12
+ export declare const useViewStore: import('pinia').StoreDefinition<"view", {
13
+ navigationType: RouterNavigationType;
14
+ isSidebarOpen: boolean;
15
+ mainBSModal: ComponentPublicInstance<typeof CAlert> | null;
16
+ toastView: ComponentPublicInstance<typeof CBSToast> | null;
17
+ globalSpinner: ComponentPublicInstance<typeof CGlobalSpinner> | null;
18
+ version: string;
19
+ }, {}, {
20
+ routerNavigationType(type: RouterNavigationType): void;
21
+ toggleSidebar(): void;
22
+ showModal(data: CAlertModalData): void;
23
+ showModalError(data: CAlertModalData): void;
24
+ showModelAlert(data: CAlertModalData): void;
25
+ showModalConfirm(data: CAlertModalData): void;
26
+ hideModal(): void;
27
+ addToast(data: CAlertModalData): void;
28
+ showSpinner(): void;
29
+ hideSpinner(): void;
30
+ setVersion(version: string): void;
31
+ }>;
32
+ /**
33
+ * 保存使用者會話相關的狀態,例如使用者資訊、是否已登入等
34
+ */
35
+ export declare const useSessionStore: import('pinia').StoreDefinition<"session", {
36
+ user: SessionUser | null;
37
+ isAuth: boolean;
38
+ sessionCheckTimer: number | null;
39
+ }, {
40
+ isAuthenticated: (state: {
41
+ user: {
42
+ sub?: string | undefined;
43
+ iat?: number | undefined;
44
+ account?: string | undefined;
45
+ name?: string | undefined;
46
+ email?: string | undefined;
47
+ roleCode?: string | undefined;
48
+ roleName?: string | undefined;
49
+ permissions?: string[] | undefined;
50
+ load: (data: Record<string, any>) => SessionUser;
51
+ merge: (data: Partial<SessionUser>) => SessionUser;
52
+ process: (data: Record<string, any>) => Record<string, any>;
53
+ } | null;
54
+ isAuth: boolean;
55
+ sessionCheckTimer: number | null;
56
+ } & import('pinia').PiniaCustomStateProperties<{
57
+ user: SessionUser | null;
58
+ isAuth: boolean;
59
+ sessionCheckTimer: number | null;
60
+ }>) => boolean;
61
+ userUid: (state: {
62
+ user: {
63
+ sub?: string | undefined;
64
+ iat?: number | undefined;
65
+ account?: string | undefined;
66
+ name?: string | undefined;
67
+ email?: string | undefined;
68
+ roleCode?: string | undefined;
69
+ roleName?: string | undefined;
70
+ permissions?: string[] | undefined;
71
+ load: (data: Record<string, any>) => SessionUser;
72
+ merge: (data: Partial<SessionUser>) => SessionUser;
73
+ process: (data: Record<string, any>) => Record<string, any>;
74
+ } | null;
75
+ isAuth: boolean;
76
+ sessionCheckTimer: number | null;
77
+ } & import('pinia').PiniaCustomStateProperties<{
78
+ user: SessionUser | null;
79
+ isAuth: boolean;
80
+ sessionCheckTimer: number | null;
81
+ }>) => string | undefined;
82
+ account: (state: {
83
+ user: {
84
+ sub?: string | undefined;
85
+ iat?: number | undefined;
86
+ account?: string | undefined;
87
+ name?: string | undefined;
88
+ email?: string | undefined;
89
+ roleCode?: string | undefined;
90
+ roleName?: string | undefined;
91
+ permissions?: string[] | undefined;
92
+ load: (data: Record<string, any>) => SessionUser;
93
+ merge: (data: Partial<SessionUser>) => SessionUser;
94
+ process: (data: Record<string, any>) => Record<string, any>;
95
+ } | null;
96
+ isAuth: boolean;
97
+ sessionCheckTimer: number | null;
98
+ } & import('pinia').PiniaCustomStateProperties<{
99
+ user: SessionUser | null;
100
+ isAuth: boolean;
101
+ sessionCheckTimer: number | null;
102
+ }>) => string | undefined;
103
+ userName: (state: {
104
+ user: {
105
+ sub?: string | undefined;
106
+ iat?: number | undefined;
107
+ account?: string | undefined;
108
+ name?: string | undefined;
109
+ email?: string | undefined;
110
+ roleCode?: string | undefined;
111
+ roleName?: string | undefined;
112
+ permissions?: string[] | undefined;
113
+ load: (data: Record<string, any>) => SessionUser;
114
+ merge: (data: Partial<SessionUser>) => SessionUser;
115
+ process: (data: Record<string, any>) => Record<string, any>;
116
+ } | null;
117
+ isAuth: boolean;
118
+ sessionCheckTimer: number | null;
119
+ } & import('pinia').PiniaCustomStateProperties<{
120
+ user: SessionUser | null;
121
+ isAuth: boolean;
122
+ sessionCheckTimer: number | null;
123
+ }>) => string | undefined;
124
+ email: (state: {
125
+ user: {
126
+ sub?: string | undefined;
127
+ iat?: number | undefined;
128
+ account?: string | undefined;
129
+ name?: string | undefined;
130
+ email?: string | undefined;
131
+ roleCode?: string | undefined;
132
+ roleName?: string | undefined;
133
+ permissions?: string[] | undefined;
134
+ load: (data: Record<string, any>) => SessionUser;
135
+ merge: (data: Partial<SessionUser>) => SessionUser;
136
+ process: (data: Record<string, any>) => Record<string, any>;
137
+ } | null;
138
+ isAuth: boolean;
139
+ sessionCheckTimer: number | null;
140
+ } & import('pinia').PiniaCustomStateProperties<{
141
+ user: SessionUser | null;
142
+ isAuth: boolean;
143
+ sessionCheckTimer: number | null;
144
+ }>) => string | undefined;
145
+ roleCode: (state: {
146
+ user: {
147
+ sub?: string | undefined;
148
+ iat?: number | undefined;
149
+ account?: string | undefined;
150
+ name?: string | undefined;
151
+ email?: string | undefined;
152
+ roleCode?: string | undefined;
153
+ roleName?: string | undefined;
154
+ permissions?: string[] | undefined;
155
+ load: (data: Record<string, any>) => SessionUser;
156
+ merge: (data: Partial<SessionUser>) => SessionUser;
157
+ process: (data: Record<string, any>) => Record<string, any>;
158
+ } | null;
159
+ isAuth: boolean;
160
+ sessionCheckTimer: number | null;
161
+ } & import('pinia').PiniaCustomStateProperties<{
162
+ user: SessionUser | null;
163
+ isAuth: boolean;
164
+ sessionCheckTimer: number | null;
165
+ }>) => string | undefined;
166
+ permissions: (state: {
167
+ user: {
168
+ sub?: string | undefined;
169
+ iat?: number | undefined;
170
+ account?: string | undefined;
171
+ name?: string | undefined;
172
+ email?: string | undefined;
173
+ roleCode?: string | undefined;
174
+ roleName?: string | undefined;
175
+ permissions?: string[] | undefined;
176
+ load: (data: Record<string, any>) => SessionUser;
177
+ merge: (data: Partial<SessionUser>) => SessionUser;
178
+ process: (data: Record<string, any>) => Record<string, any>;
179
+ } | null;
180
+ isAuth: boolean;
181
+ sessionCheckTimer: number | null;
182
+ } & import('pinia').PiniaCustomStateProperties<{
183
+ user: SessionUser | null;
184
+ isAuth: boolean;
185
+ sessionCheckTimer: number | null;
186
+ }>) => string[] | undefined;
187
+ menuItems(): CMenuItem[];
188
+ caseDataScope: (state: {
189
+ user: {
190
+ sub?: string | undefined;
191
+ iat?: number | undefined;
192
+ account?: string | undefined;
193
+ name?: string | undefined;
194
+ email?: string | undefined;
195
+ roleCode?: string | undefined;
196
+ roleName?: string | undefined;
197
+ permissions?: string[] | undefined;
198
+ load: (data: Record<string, any>) => SessionUser;
199
+ merge: (data: Partial<SessionUser>) => SessionUser;
200
+ process: (data: Record<string, any>) => Record<string, any>;
201
+ } | null;
202
+ isAuth: boolean;
203
+ sessionCheckTimer: number | null;
204
+ } & import('pinia').PiniaCustomStateProperties<{
205
+ user: SessionUser | null;
206
+ isAuth: boolean;
207
+ sessionCheckTimer: number | null;
208
+ }>) => never[];
209
+ }, {
210
+ saveUser(user: SessionUser | null): void;
211
+ checkSessionIsValid(): Promise<boolean>;
212
+ startSessionCheck(): void;
213
+ stopSessionCheck(): void;
214
+ logout(): void;
215
+ }>;
@@ -0,0 +1,41 @@
1
+ import * as yup from "yup";
2
+ /**
3
+ * 空函式
4
+ */
5
+ export declare const voidFunction: () => void;
6
+ /**
7
+ * 寫入 Vue ref 物件的值
8
+ * @param refObj
9
+ * @param value
10
+ */
11
+ export declare const writeVueRefValue: (refObj: any, value: any) => void;
12
+ /**
13
+ * Lodash 擴充工具
14
+ */
15
+ export declare const lodashExTools: {
16
+ getVal: (obj: any, path: string | null | undefined, defaultValue?: any) => any;
17
+ };
18
+ /**
19
+ * 檢查是否有相同的檔案
20
+ * @param fileList 檔案列表
21
+ * @param file 要檢查的檔案
22
+ */
23
+ export declare const checkHasSameFile: (fileList: File[], file: File) => boolean;
24
+ /**
25
+ * 格式化物件中的所有日期屬性為指定格式的字串。
26
+ * @param obj
27
+ */
28
+ export declare function formatDatesInObject(obj: any): any;
29
+ /**
30
+ * 建立一個日期區間驗證器,用於 yup 的 test 方法中。
31
+ * @param startDateKey
32
+ * @param endDateKey
33
+ * @param startDateMessage
34
+ * @param endDateMessage
35
+ */
36
+ export declare function makeDateRangeValidator({ startDateKey, endDateKey, startDateMessage, endDateMessage }: {
37
+ startDateKey: string;
38
+ endDateKey: string;
39
+ startDateMessage: string;
40
+ endDateMessage: string;
41
+ }): (this: yup.TestContext, formValues: Record<string, any>) => true | yup.ValidationError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ch3chi-commons-vue",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",