ch3chi-commons-vue 0.1.14 → 1.2.0

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.
Files changed (39) hide show
  1. package/README.md +138 -5
  2. package/dist/api/ApiService.d.ts +109 -2
  3. package/dist/auth/AuthorizationService.d.ts +1 -2
  4. package/dist/auth/PermissionDescriptor.d.ts +37 -0
  5. package/dist/components/CAlertDefine.d.ts +2 -0
  6. package/dist/components/CGlobalSpinner.vue.d.ts +3 -0
  7. package/dist/components/CTable.vue.d.ts +24 -0
  8. package/dist/components/CTableDefine.d.ts +76 -0
  9. package/dist/components/CTableTD.vue.d.ts +7 -0
  10. package/dist/components/form/CChangePasswordFormField.vue.d.ts +14 -0
  11. package/dist/components/form/CCheckBoxFormField.vue.d.ts +30 -0
  12. package/dist/components/form/CDateFormField.vue.d.ts +17 -0
  13. package/dist/components/form/CDateQueryField.vue.d.ts +16 -0
  14. package/dist/components/form/CDateRangeFormField.vue.d.ts +17 -0
  15. package/dist/components/form/CFilePickerFormField.vue.d.ts +28 -0
  16. package/dist/components/form/CRadioFormField.vue.d.ts +30 -0
  17. package/dist/components/form/CSelectFormField.vue.d.ts +18 -0
  18. package/dist/components/form/CTextAreaFormField.vue.d.ts +16 -0
  19. package/dist/components/form/CTextInputFormField.vue.d.ts +22 -0
  20. package/dist/directive/CFTurnstileDirective.d.ts +6 -0
  21. package/dist/directive/PermissionDirective.d.ts +15 -0
  22. package/dist/index.cjs.js +16001 -2940
  23. package/dist/index.d.ts +38 -1
  24. package/dist/index.es.js +15961 -2901
  25. package/dist/model/BSFieldStyleConfig.d.ts +121 -0
  26. package/dist/model/BaseDictionary.d.ts +34 -0
  27. package/dist/model/BaseFormDataModel.d.ts +4 -0
  28. package/dist/model/BaseListViewModel.d.ts +21 -0
  29. package/dist/model/CMenuItem.d.ts +2 -0
  30. package/dist/model/FormOptions.d.ts +8 -3
  31. package/dist/model/LoginDataModel.d.ts +1 -0
  32. package/dist/model/QueryParameter.d.ts +3 -5
  33. package/dist/model/SessionUser.d.ts +17 -2
  34. package/dist/model/ShowMessageDataModel.d.ts +44 -0
  35. package/dist/model/TokenUser.d.ts +50 -0
  36. package/dist/stores/ViewStore.d.ts +314 -180
  37. package/dist/style.css +223 -0
  38. package/dist/utils/CToolUtils.d.ts +12 -0
  39. package/package.json +24 -4
@@ -0,0 +1,121 @@
1
+ /**
2
+ * BSFieldStyleConfig 配置物件
3
+ * 用於以配置方式自訂欄位外觀和行為
4
+ */
5
+ export interface IBSFieldStyleConfig {
6
+ containerClass?: string;
7
+ labelClass?: string;
8
+ labelPrefix?: string;
9
+ labelSuffix?: string;
10
+ hideLabel?: boolean;
11
+ requiredLabelClass?: string;
12
+ requiredLabelText?: string;
13
+ plainTextClass?: string;
14
+ inputClass?: string;
15
+ inputPrefix?: {
16
+ text?: string;
17
+ class?: string;
18
+ };
19
+ inputSuffix?: {
20
+ text?: string;
21
+ class?: string;
22
+ };
23
+ wrapperClass?: string;
24
+ selectClass?: string;
25
+ selectSize?: 'sm' | 'lg';
26
+ selectMultiple?: boolean;
27
+ selectPlaceholder?: string;
28
+ textareaClass?: string;
29
+ textareaRows?: number;
30
+ textareaResize?: 'none' | 'both' | 'horizontal' | 'vertical';
31
+ textareaAutoGrow?: boolean;
32
+ checkboxClass?: string;
33
+ checkboxLabelClass?: string;
34
+ checkboxWrapperClass?: string;
35
+ radioClass?: string;
36
+ radioLabelClass?: string;
37
+ radioWrapperClass?: string;
38
+ radioInline?: boolean;
39
+ fileClass?: string;
40
+ fileAccept?: string;
41
+ fileMultiple?: boolean;
42
+ fileDragDrop?: boolean;
43
+ calendarIconClass?: string;
44
+ calendarClearIconClass?: string;
45
+ changePasswordButtonClass?: string;
46
+ changePasswordButtonIcon?: string;
47
+ errorClass?: string;
48
+ errorPrefix?: string;
49
+ }
50
+ /**
51
+ * BSFieldStyleConfig 類別
52
+ */
53
+ export declare class BSFieldStyleConfig {
54
+ config: IBSFieldStyleConfig;
55
+ /**
56
+ * 單一實例
57
+ */
58
+ static instance: BSFieldStyleConfig;
59
+ /**
60
+ * 合併配置
61
+ * @param config 要合併到全域實例的配置
62
+ */
63
+ static merge(config: IBSFieldStyleConfig): void;
64
+ /**
65
+ * 混合多個樣式配置,建立新的 BSFieldStyleConfig 實例
66
+ * 優先順序:propStyle > defaultStyle > instance(全域設定)
67
+ *
68
+ * @param defaultStyle 預設樣式配置(例如組件內建的預設值)
69
+ * @param propStyle 組件 prop 傳入的樣式配置
70
+ * @returns 合併後的 BSFieldStyleConfig 實例
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * // 在組件中使用
75
+ * const bStyleConfig = BSFieldStyleConfig.mix(
76
+ * { plainTextClass: 'form-control-plaintext bg-light' }, // 組件預設值
77
+ * props.styleConfig // 從 prop 傳入的值
78
+ * );
79
+ * ```
80
+ */
81
+ static mix(defaultStyle: IBSFieldStyleConfig, propStyle?: IBSFieldStyleConfig): BSFieldStyleConfig;
82
+ constructor(config?: IBSFieldStyleConfig);
83
+ get containerClass(): string;
84
+ get labelClass(): string;
85
+ get inputClass(): string;
86
+ get wrapperClass(): string;
87
+ get errorClass(): string;
88
+ get hideLabel(): boolean;
89
+ get requiredLabelClass(): string;
90
+ get requiredLabelText(): string;
91
+ get plainTextClass(): string;
92
+ get hasInputPrefix(): boolean;
93
+ get hasInputSuffix(): boolean;
94
+ get inputPrefixText(): string;
95
+ get inputSuffixText(): string;
96
+ get inputPrefixClass(): string;
97
+ get inputSuffixClass(): string;
98
+ get selectClass(): string;
99
+ get selectMultiple(): boolean;
100
+ get selectPlaceholder(): string;
101
+ get textareaClass(): string;
102
+ get textareaRows(): number;
103
+ get textareaResizeStyle(): string;
104
+ get textareaAutoGrow(): boolean;
105
+ get checkboxClass(): string;
106
+ get checkboxLabelClass(): string;
107
+ get checkboxWrapperClass(): string;
108
+ get radioClass(): string;
109
+ get radioLabelClass(): string;
110
+ get radioWrapperClass(): string;
111
+ get radioInline(): boolean;
112
+ get fileClass(): string;
113
+ get fileAccept(): string;
114
+ get fileMultiple(): boolean;
115
+ get fileDragDrop(): boolean;
116
+ get calendarIconClass(): string;
117
+ get calendarClearIconClass(): string;
118
+ get changePasswordButtonClass(): string;
119
+ get changePasswordButtonIcon(): string;
120
+ }
121
+ export declare const __BSFieldStyleConfigDefine__: IBSFieldStyleConfig;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * BaseDictionary class
3
+ * 用於 distionary store 的基底類別
4
+ */
5
+ export declare abstract class BaseDictionary {
6
+ protected data: Record<string, any>;
7
+ dataProvider: (key: string) => Promise<any> | any;
8
+ lastUpdatedAt: number;
9
+ protected constructor(data?: Partial<BaseDictionary>);
10
+ /**
11
+ * 初始化方法,讓子類別可以覆寫以進行自訂初始化
12
+ * @protected
13
+ */
14
+ abstract init(): void;
15
+ val(key: string): any;
16
+ setVal(key: string, value: any): void;
17
+ hasVal(key: string): boolean;
18
+ /**
19
+ * 載入所有字典資料
20
+ * 使用 Promise.allSettled 確保即使某個載入失敗,其他的也能繼續執行
21
+ */
22
+ loadAll(): Promise<void>;
23
+ /**
24
+ * load dictionary data
25
+ * 支援 Promise 或是直接回傳資料物件
26
+ * @param key
27
+ */
28
+ loadDictionary(key: string): Promise<Record<string, any>>;
29
+ loadFromStore(storeData: Record<string, any>): this;
30
+ }
31
+ export declare class CBaseDictionary extends BaseDictionary {
32
+ constructor(data?: Partial<CBaseDictionary>);
33
+ init(): void;
34
+ }
@@ -7,8 +7,10 @@ import * as yup from "yup";
7
7
  * 子類別需要實現 initFormSchema 方法來定義具體的表單驗證邏輯。
8
8
  */
9
9
  export declare abstract class BaseFormDataModel {
10
+ _debug?: boolean;
10
11
  uid?: string;
11
12
  rowId?: string;
13
+ _formMode?: string;
12
14
  __rowNumber?: number;
13
15
  __isLastAndLastPage?: boolean;
14
16
  /**
@@ -152,6 +154,8 @@ export declare abstract class BaseFormDataModel {
152
154
  * @param propertyName 屬性名稱列表
153
155
  */
154
156
  parseStringToDate(data: Record<string, any>, propertyName: string[]): void;
157
+ set formMode(type: string);
158
+ get formMode(): string | undefined;
155
159
  /**
156
160
  * 將指定的屬性列表轉換為 JSON 格式的數據。
157
161
  * @param propertyList
@@ -2,10 +2,12 @@ import { QueryPage, QueryParameter } from './QueryParameter';
2
2
  import { BaseFormDataModel } from './BaseFormDataModel';
3
3
  import { CTableColumn, CTableColumnActionType } from '../components/CTableDefine';
4
4
  import { Router } from 'vue-router';
5
+ import { GlobalViewActions } from '../stores/ViewStore';
5
6
  import { ApiResponse } from '../api/ApiService';
6
7
  export interface ListApiEndpointMeta {
7
8
  key: string;
8
9
  pathParam?: Record<string, any>;
10
+ dataListFinder?: (response: ApiResponse) => any[];
9
11
  dataParser: (dataItem: any) => any;
10
12
  }
11
13
  /**
@@ -16,11 +18,20 @@ export declare abstract class BaseListViewModel<Q extends QueryParameter, V exte
16
18
  dataList: V[];
17
19
  tableColumnArray: CTableColumn[];
18
20
  router?: Router;
21
+ storeAction?: GlobalViewActions;
19
22
  enableQueryParamDefault?: boolean;
20
23
  queryParamDefaultValues?: Record<string, any>;
21
24
  saveOnQueryFormDataStore?: boolean;
22
25
  autoSearchOnClear?: boolean;
23
26
  protected constructor(data?: Partial<BaseListViewModel<Q, V>>);
27
+ /**
28
+ * 初始化方法
29
+ * @param options
30
+ */
31
+ init(options: {
32
+ router: Router;
33
+ storeAction?: GlobalViewActions;
34
+ }): this;
24
35
  /**
25
36
  * 查詢列表的 API 端點元資料
26
37
  */
@@ -58,6 +69,7 @@ export declare abstract class BaseListViewModel<Q extends QueryParameter, V exte
58
69
  * @param options 載入選項
59
70
  */
60
71
  loadApiResponse(response: ApiResponse, options: {
72
+ dataListFinder?: (response: ApiResponse) => any[];
61
73
  parser?: (data: any) => V;
62
74
  }): void;
63
75
  /**
@@ -100,6 +112,10 @@ export declare abstract class BaseListViewModel<Q extends QueryParameter, V exte
100
112
  * 從查詢表單數據存儲中讀取查詢參數
101
113
  */
102
114
  readQueryParamFromStore(): void;
115
+ /**
116
+ * 前往新增頁面
117
+ */
118
+ goToCreatePage(): void;
103
119
  /**
104
120
  * 執行搜尋操作
105
121
  * 查詢時會將查詢參數保存到 store 中,並呼叫 API 獲取資料
@@ -110,6 +126,10 @@ export declare abstract class BaseListViewModel<Q extends QueryParameter, V exte
110
126
  * 清除查詢參數,並根據設定決定是否重新執行搜尋
111
127
  */
112
128
  doClear(): Promise<void>;
129
+ /**
130
+ * 處理排序變更事件
131
+ */
132
+ onSortChange(): Promise<void>;
113
133
  /**
114
134
  * 處理分頁變更事件
115
135
  * @param params
@@ -142,3 +162,4 @@ export declare abstract class CheckableListViewModel<Q extends QueryParameter, V
142
162
  */
143
163
  resetCheckedData(): void;
144
164
  }
165
+ export declare const __BaseListViewModelDefine__: ListApiEndpointMeta;
@@ -1,4 +1,5 @@
1
1
  import { Ref } from 'vue';
2
+ import { PermissionDescriptor } from '../auth/PermissionDescriptor';
2
3
  /**
3
4
  * MenuItem 介面用於描述左側選單項目結構
4
5
  * name: 顯示名稱
@@ -29,6 +30,7 @@ export declare class CMenuItem implements MenuItem {
29
30
  path?: string;
30
31
  needRoles?: string[];
31
32
  permission?: string | string[];
33
+ permissionDescriptors?: PermissionDescriptor[];
32
34
  activePaths?: string[];
33
35
  children?: CMenuItem[];
34
36
  isOpen?: Ref<boolean>;
@@ -11,6 +11,7 @@ export interface COptionItem {
11
11
  disabled?: boolean;
12
12
  selected?: boolean;
13
13
  children?: CCOptionItem[];
14
+ meta?: Record<string, any>;
14
15
  }
15
16
  /**
16
17
  * COptionItem 類別實現
@@ -22,6 +23,7 @@ export declare class CCOptionItem implements COptionItem {
22
23
  disabled?: boolean;
23
24
  selected?: boolean;
24
25
  children?: CCOptionItem[];
26
+ meta?: Record<string, any>;
25
27
  constructor(data?: Partial<COptionItem>);
26
28
  }
27
29
  /**
@@ -37,11 +39,13 @@ export declare class DataCategory {
37
39
  */
38
40
  export declare const ToggleStatusOptions: COptionItem[];
39
41
  /**
40
- * 通用選項,適用
41
- * 1. 帳號狀態選項
42
- * 2. 最新消息狀態選項
42
+ * 通用選項,適用當 value 為 boolean 時
43
43
  */
44
44
  export declare const CommonStatusOptions: COptionItem[];
45
+ /**
46
+ * 通用選項,適用當 value 為字串時
47
+ */
48
+ export declare const CommonStatusStrOptions: COptionItem[];
45
49
  /**
46
50
  * 是/否 選項
47
51
  */
@@ -53,3 +57,4 @@ export declare const OptionUtils: {
53
57
  */
54
58
  makeCommonStatusLabelText: (value: string | boolean) => string;
55
59
  };
60
+ export declare const __FormOptionsTypes__: COptionItem & DataCategory;
@@ -4,6 +4,7 @@ export declare class LoginDataModel extends BaseFormDataModel {
4
4
  account?: string;
5
5
  password?: string;
6
6
  turnstileToken?: string;
7
+ enableCFTurnstile: boolean;
7
8
  constructor(data?: Partial<LoginDataModel>);
8
9
  dataFieldNameList(): string[];
9
10
  initFormSchema(): ObjectSchema<any>;
@@ -1,15 +1,12 @@
1
1
  import { ApiResponse } from '../api/ApiService';
2
+ export type SortDirection = 'ASC' | 'asc' | 'DESC' | 'desc';
2
3
  /**
3
4
  * QuerySort 定義了查詢的排序條件
4
5
  */
5
6
  export interface QuerySort {
6
7
  field: string;
7
- direction: 'asc' | 'desc';
8
+ direction: SortDirection;
8
9
  }
9
- /**
10
- * PageSizeOptions 定義了可用的分頁大小選項
11
- */
12
- export declare const PageSizeOptions: number[];
13
10
  /**
14
11
  * IQueryPage 定義了查詢的分頁資訊
15
12
  */
@@ -92,3 +89,4 @@ export declare class DateRangeParam extends QueryParameter {
92
89
  endsAt?: Date | null;
93
90
  clear(): void;
94
91
  }
92
+ export declare const __QueryParameterDefine__: SortDirection;
@@ -1,9 +1,17 @@
1
+ /**
2
+ * Role model
3
+ */
4
+ export declare class Role {
5
+ uid?: string;
6
+ name?: string;
7
+ type?: string;
8
+ }
1
9
  /**
2
10
  * 用來描述操作人員的物件
3
11
  * 用來保存已登入的使用者資訊
4
12
  */
5
13
  export declare class SessionUser {
6
- sub?: string;
14
+ userUid?: string;
7
15
  iat?: number;
8
16
  account?: string;
9
17
  name?: string;
@@ -16,7 +24,12 @@ export declare class SessionUser {
16
24
  * 載入資料
17
25
  * @param data
18
26
  */
19
- load(data: Record<string, any>): SessionUser;
27
+ load(data: Record<string, any>): this;
28
+ /**
29
+ * 從驗證會話資料載入
30
+ * @param data
31
+ */
32
+ loadFromValidateSession(data: any): this;
20
33
  /**
21
34
  * 合併資料
22
35
  * @param data
@@ -27,4 +40,6 @@ export declare class SessionUser {
27
40
  * @param data
28
41
  */
29
42
  process(data: Record<string, any>): Record<string, any>;
43
+ toJSON(): Record<string, any>;
44
+ loadJSON(data: Record<string, any>): this;
30
45
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * ShowMessage 訊息類型列舉
3
+ */
4
+ export declare enum ShowMessageType {
5
+ /** 忘記密碼郵件已發送 */
6
+ FORGOT_PASSWORD_SENT = "FP_SENT",
7
+ /** 重置密碼成功 */
8
+ RESET_PASSWORD_SUCCESS = "RP_OK",
9
+ /** 認證過期 */
10
+ AUTH_EXPIRED = "AUTH_EXP"
11
+ }
12
+ /**
13
+ * ShowMessage 頁面訊息資料模型
14
+ * 用於定義系統各種訊息的標題、內容、狀態碼等資訊
15
+ */
16
+ export interface IShowMessageData {
17
+ title: string;
18
+ message: string;
19
+ code?: string;
20
+ showLoginButton?: boolean;
21
+ showHomeButton?: boolean;
22
+ }
23
+ /**
24
+ * ShowMessage 訊息定義
25
+ */
26
+ export declare class ShowMessageDataModel {
27
+ private static _messageMap;
28
+ static set messageMap(map: Record<ShowMessageType, IShowMessageData>);
29
+ /**
30
+ * 根據訊息類型取得訊息資料
31
+ */
32
+ static getMessageData(type: ShowMessageType): IShowMessageData;
33
+ /**
34
+ * 根據 key 字串取得訊息資料(用於從 query string 解析)
35
+ */
36
+ static getMessageDataByKey(key: string): IShowMessageData | null;
37
+ /**
38
+ * 將訊息類型轉換為路由參數(path params)
39
+ */
40
+ static toRouteParams(type: ShowMessageType): {
41
+ type: string;
42
+ };
43
+ }
44
+ export declare const __ShowMessageDataModelDefine__: ShowMessageType & IShowMessageData;
@@ -0,0 +1,50 @@
1
+ import { SessionUser } from './SessionUser';
2
+ /**
3
+ * 存放存取權杖相關資訊
4
+ */
5
+ export declare class AccessToken {
6
+ tokenType?: string;
7
+ accessToken?: string;
8
+ accessTokenExpiresAt?: string;
9
+ refreshToken?: string;
10
+ refreshTokenExpiresAt?: string;
11
+ sessionUid?: string;
12
+ constructor(data?: Partial<AccessToken>);
13
+ /**
14
+ * 存取權杖是否已過期
15
+ */
16
+ isExpired(): boolean;
17
+ /**
18
+ * 刷新權杖是否已過期
19
+ */
20
+ isRefreshTokenExpired(): boolean;
21
+ /**
22
+ * 載入資料
23
+ * @param data
24
+ */
25
+ loadToken(data: Record<string, any>): this;
26
+ /**
27
+ * 轉換為 JSON 物件
28
+ */
29
+ toJSON(): Record<string, any>;
30
+ /**
31
+ * 從 JSON 資料載入
32
+ * @param data
33
+ */
34
+ loadJSON(data: Record<string, any>): this;
35
+ /**
36
+ * 取得 Bearer Token 字串
37
+ */
38
+ get bearerToken(): string;
39
+ }
40
+ /**
41
+ * 帶有 Token 資訊的使用者物件
42
+ */
43
+ export declare class TokenUser extends SessionUser {
44
+ tokens?: AccessToken;
45
+ profile?: Record<string, any>;
46
+ constructor(data?: Partial<AccessToken>);
47
+ load(data: Record<string, any>): this;
48
+ toJSON(): Record<string, any>;
49
+ loadJSON(data: Record<string, any>): this;
50
+ }