tang-ui-x 1.3.5 → 1.3.6

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/index.uts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Tang UI - UniApp X UI 组件库
3
3
  * @description 基于 uni-app x 的移动端 UI 组件库
4
- * @version 1.0.2
4
+ * @version 1.3.5
5
5
  * @author sugar258596
6
6
  */
7
7
 
@@ -54,7 +54,7 @@ export type {
54
54
  } from './composables/i18n/types.uts'
55
55
 
56
56
  // 版本信息
57
- export const version: string = '1.0.5'
57
+ export const version: string = '1.3.5'
58
58
 
59
59
  // 组件列表(用于文档和类型提示)
60
60
  export const components: string[] = [
package/package.json CHANGED
@@ -1,28 +1,38 @@
1
1
  {
2
2
  "name": "tang-ui-x",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "UniApp X UI 组件库 - 基于 uni-app x 的移动端 UI 组件库",
5
- "main": "index.uts",
6
- "module": "index.uts",
7
- "types": "types/index.d.ts",
8
- "style": "static/tailwind.css",
9
- "sass": "uni.scss",
10
- "exports": {
11
- ".": {
12
- "types": "./types/index.d.ts",
13
- "import": "./index.uts",
14
- "default": "./index.uts"
15
- },
16
- "./components/*": "./components/*/index.uvue",
17
- "./components/*/index.uvue": "./components/*/index.uvue",
18
- "./composables/*": "./composables/*.uts",
19
- "./composables/i18n/*": "./composables/i18n/*.uts",
20
- "./locales": "./locales/index.uts",
21
- "./locales/*": "./locales/*",
22
- "./static/*": "./static/*",
23
- "./uni.scss": "./uni.scss",
24
- "./package.json": "./package.json"
25
- },
5
+ "main": "index.uts",
6
+ "module": "index.uts",
7
+ "types": "types/index.d.ts",
8
+ "style": "static/tailwind.css",
9
+ "sass": "uni.scss",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./types/index.d.ts",
13
+ "import": "./index.uts",
14
+ "default": "./index.uts"
15
+ },
16
+ "./components/*": {
17
+ "types": "./types/component.d.ts",
18
+ "import": "./components/*/index.uvue",
19
+ "default": "./components/*/index.uvue"
20
+ },
21
+ "./components/*/index.uvue": {
22
+ "types": "./types/component.d.ts",
23
+ "import": "./components/*/index.uvue",
24
+ "default": "./components/*/index.uvue"
25
+ },
26
+ "./composables/*": "./composables/*.uts",
27
+ "./composables/i18n/*": "./composables/i18n/*.uts",
28
+ "./utils/*": "./utils/*.uts",
29
+ "./utils": "./utils/index.uts",
30
+ "./locales": "./locales/index.uts",
31
+ "./locales/*": "./locales/*",
32
+ "./static/*": "./static/*",
33
+ "./uni.scss": "./uni.scss",
34
+ "./package.json": "./package.json"
35
+ },
26
36
  "files": [
27
37
  "components",
28
38
  "composables/useI18n.uts",
@@ -58,22 +68,22 @@
58
68
  "tang-ui"
59
69
  ],
60
70
  "author": "sugar258596",
61
- "license": "MIT",
62
- "packageManager": "pnpm@10.26.0",
63
- "engines": {
64
- "node": ">=18"
65
- },
66
- "publishConfig": {
67
- "access": "public"
68
- },
69
- "sideEffects": [
70
- "*.scss",
71
- "*.css",
72
- "*.uvue",
73
- "static/**",
74
- "uni.scss"
75
- ],
76
- "repository": {
71
+ "license": "MIT",
72
+ "packageManager": "pnpm@10.26.0",
73
+ "engines": {
74
+ "node": ">=18"
75
+ },
76
+ "publishConfig": {
77
+ "access": "public"
78
+ },
79
+ "sideEffects": [
80
+ "*.scss",
81
+ "*.css",
82
+ "*.uvue",
83
+ "static/**",
84
+ "uni.scss"
85
+ ],
86
+ "repository": {
77
87
  "type": "git",
78
88
  "url": "https://github.com/sugar258596/tang-ui.git"
79
89
  },
@@ -102,12 +112,12 @@
102
112
  "lint-staged": "^16.2.7",
103
113
  "prettier": "^3.7.4",
104
114
  "vue-eslint-parser": "^10.2.0"
105
- },
106
- "scripts": {
107
- "prepare": "husky",
108
- "prepublishOnly": "pnpm run lint",
109
- "prepack": "pnpm run build",
110
- "build": "pnpm run tailwind:build",
115
+ },
116
+ "scripts": {
117
+ "prepare": "husky",
118
+ "prepublishOnly": "pnpm run lint",
119
+ "prepack": "pnpm run build",
120
+ "build": "pnpm run tailwind:build",
111
121
  "lint": "pnpm exec eslint .",
112
122
  "lint:staged": "pnpm exec lint-staged --relative --concurrent false --max-arg-length 5000",
113
123
  "tailwind:build": "pnpm exec postcss ./tailwind.css -o ./static/tailwind.css",
@@ -119,4 +129,4 @@
119
129
  "pnpm exec eslint"
120
130
  ]
121
131
  }
122
- }
132
+ }
@@ -0,0 +1,5 @@
1
+ import type { DefineComponent } from 'vue';
2
+
3
+ declare const component: DefineComponent<any, any, any>;
4
+
5
+ export default component;
package/types/index.d.ts CHANGED
@@ -1,4 +1,15 @@
1
1
  import type { App, ComputedRef, Ref } from 'vue';
2
+ import type { DefineComponent } from 'vue';
3
+
4
+ declare module 'tang-ui-x/components/*' {
5
+ const component: DefineComponent<any, any, any>;
6
+ export default component;
7
+ }
8
+
9
+ declare module 'tang-ui-x/components/*/index.uvue' {
10
+ const component: DefineComponent<any, any, any>;
11
+ export default component;
12
+ }
2
13
 
3
14
  export type ComponentType = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
4
15
  export type PositionType = 'top' | 'center' | 'bottom';
@@ -44,6 +55,7 @@ export interface ModularLocaleMessages {
44
55
  }
45
56
 
46
57
  export type LocaleCode = 'zh-CN' | 'en-US' | 'zh-TW' | string;
58
+ export type TranslateParams = Record<string, string | number>;
47
59
 
48
60
  export interface I18nConfig {
49
61
  locale: LocaleCode;
@@ -51,10 +63,9 @@ export interface I18nConfig {
51
63
  messages: Record<string, LocaleMessages>;
52
64
  }
53
65
 
54
- export type TranslateParams = Record<string, string | number>;
55
-
56
66
  export interface UseI18nReturn {
57
- $t: (key: string, params?: TranslateParams) => string;
67
+ $t: (key: string, params?: TranslateParams | null) => string;
68
+ t: (key: string, params?: TranslateParams | null) => string;
58
69
  locale: ComputedRef<string>;
59
70
  availableLocales: ComputedRef<string[]>;
60
71
  setLocale: (locale: string) => boolean;
@@ -75,12 +86,12 @@ export interface ToastController {
75
86
  isShowing: Ref<boolean>;
76
87
  currentToast: Ref<ToastOptions | null>;
77
88
  toastQueue: Ref<ToastOptions[]>;
78
- show: (options: string | ToastOptions) => void;
79
- success: (message: string, duration?: number) => void;
80
- error: (message: string, duration?: number) => void;
81
- warning: (message: string, duration?: number) => void;
82
- info: (message: string, duration?: number) => void;
83
- loading: (message?: string) => () => void;
89
+ show: (options: string | ToastOptions, duration?: number | null) => void;
90
+ success: (message: string, duration?: number | null) => void;
91
+ error: (message: string, duration?: number | null) => void;
92
+ warning: (message: string, duration?: number | null) => void;
93
+ info: (message: string, duration?: number | null) => void;
94
+ loading: (message?: string | null) => () => void;
84
95
  hide: () => void;
85
96
  clear: () => void;
86
97
  setDefaults: (options: Partial<ToastOptions>) => void;
@@ -110,7 +121,6 @@ export interface HttpInitOptions {
110
121
  showLoading?: boolean;
111
122
  autoAuth?: boolean;
112
123
  timeout?: number;
113
- [key: string]: any;
114
124
  }
115
125
 
116
126
  export interface HttpRequestOptions {
@@ -122,9 +132,12 @@ export interface HttpRequestOptions {
122
132
  showLoading?: boolean;
123
133
  loadingText?: string;
124
134
  disableAuth?: boolean;
125
- [key: string]: any;
135
+ customError?: boolean;
136
+ isTotal?: boolean;
126
137
  }
127
138
 
139
+ export type HttpRequestExtraOptions = Omit<HttpRequestOptions, 'url' | 'data' | 'method'>;
140
+
128
141
  export interface ResponseData<T = any> {
129
142
  code: number;
130
143
  msg: string;
@@ -139,7 +152,7 @@ export interface DataResponse<T = any> {
139
152
 
140
153
  export interface HttpInterceptors {
141
154
  request?: (options: HttpRequestOptions) => HttpRequestOptions;
142
- response?: <T>(response: ResponseData<T>, options: HttpRequestOptions) => DataResponse<T> | T;
155
+ response?: (response: ResponseData<any>, options: HttpRequestOptions) => any;
143
156
  error?: (err: any, options: HttpRequestOptions) => void;
144
157
  }
145
158
 
@@ -154,69 +167,185 @@ export class HttpRequest {
154
167
  postFormData<T>(url: string, data?: Record<string, any> | null, options?: HttpRequestOptions | null): Promise<T>;
155
168
  }
156
169
 
157
- export function hexToRgb(hex: string): { r: number; g: number; b: number } | null;
158
- export function rgbToHex(r: number, g: number, b: number): string;
159
- export function darken(color: string, amount: number): string;
160
- export function lighten(color: string, amount: number): string;
161
- export function addOpacity(color: string, opacity: number): string;
162
- export function isLightColor(color: string): boolean;
170
+ export interface ValidationResult {
171
+ isValid: boolean;
172
+ message: string;
173
+ }
163
174
 
164
- export function isEmpty(value: any): boolean;
165
- export function isPhone(phone: string): boolean;
166
- export function isEmail(email: string): boolean;
167
- export function isIdCard(idCard: string): boolean;
168
- export function isUrl(url: string): boolean;
169
- export function isChinese(str: string): boolean;
170
- export function isNumber(value: any): boolean;
171
- export function isInteger(value: any): boolean;
172
- export function isPositiveInteger(value: any): boolean;
173
- export function isDecimal(value: any, decimal?: number): boolean;
174
- export function isPasswordStrong(password: string, level?: number): boolean;
175
- export function isBankCard(cardNo: string): boolean;
176
- export function isPlateNo(plateNo: string): boolean;
177
-
178
- export function debounce<T extends (...args: any[]) => any>(fn: T, delay?: number): (...args: Parameters<T>) => void;
179
- export function throttle<T extends (...args: any[]) => any>(fn: T, delay?: number): (...args: Parameters<T>) => void;
175
+ export function copyToClipboard(text: string, success?: () => void, fail?: (error?: any) => void): void;
176
+ export function copyToClipboardAsync(text: string): Promise<void>;
177
+ export function formatChatTime(date: Date): string;
178
+ export function debounce(func: (...args: any[]) => void, delay: number): (...args: any[]) => void;
179
+ export function throttle(func: (...args: any[]) => void, delay: number): (...args: any[]) => void;
180
+ export function formatNumber(num: number | string): string;
181
+ export function formatBytes(bytes: number, decimals?: number): string;
182
+ export function get(obj: any, path: string, defaultValue?: any | null): any | null;
180
183
  export function deepClone<T>(obj: T): T;
181
- export function generateId(prefix?: string): string;
182
- export function formatFileSize(bytes: number, decimals?: number): string;
183
- export function formatDate(date: Date | number, format?: string): string;
184
- export function getUrlParams(url: string): Record<string, string>;
185
- export function objectToUrlParams(obj: Record<string, any>): string;
186
- export function unique<T>(arr: T[]): T[];
187
- export function chunk<T>(arr: T[], size: number): T[][];
188
- export function sleep(ms: number): Promise<void>;
189
- export function random(min: number, max: number): number;
190
- export function randomString(length: number): string;
191
-
192
- export function getRect(selector: string, instance: any): Promise<any>;
193
- export function getRectAll(selector: string, instance: any): Promise<any[]>;
194
- export function getScrollOffset(selector: string, instance: any): Promise<any>;
195
- export function getSystemInfo(): any;
196
- export function pxToRpx(px: number): number;
197
- export function rpxToPx(rpx: number): number;
198
- export function addUnit(value: string | number, unit?: string): string;
199
- export function getStyle(element: any, property: string): string;
200
- export function setStyle(element: any, property: string, value: string): void;
201
- export function setStyles(element: any, styles: Record<string, string>): void;
202
- export function supportsCss(property: string): boolean;
203
- export function getComputedStyle(element: any): any;
204
- export function isInViewport(rect: any, offset?: number): boolean;
205
- export function getNodeInfo(selector: string, instance: any): Promise<any>;
206
- export function smoothScrollTo(scrollTop: number, duration?: number, selector?: string): void;
207
- export function getSafeArea(): any;
184
+ export function toQueryString(obj: Record<string, any>, prefix?: string): string;
185
+ export function truncate(str: string, length: number): string;
186
+ export function randomString(length?: number): string;
187
+ export function generateUUID(): string;
188
+ export function isEmpty(value: any): boolean;
189
+ export function isValid(value: any): boolean;
190
+ export function isValidPhone(phone: string): boolean;
191
+ export function isValidEmail(email: string): boolean;
192
+ export function blobToBase64(blob: Blob): Promise<string>;
193
+ export function pathToBase64(path: string, mimeType?: string): Promise<string>;
194
+
195
+ export function setStorage(key: string, value: any): boolean;
196
+ export function getStorage(key: string, defaultValue?: any): any;
197
+ export function hasStorage(key: string): boolean;
198
+ export function removeStorage(key: string): boolean;
199
+ export function clearStorage(): boolean;
200
+
201
+ export function validatePhone(phone: string): ValidationResult;
202
+ export function validateEmail(email: string): ValidationResult;
203
+ export function validateVerifyCode(code: string): ValidationResult;
204
+ export function validatePassword(password: string, minLen?: number, maxLen?: number): ValidationResult;
205
+ export function validateUsername(username: string, minLen?: number, maxLen?: number): ValidationResult;
206
+ export function validateIdCard(idCard: string): ValidationResult;
207
+ export function validateBankCard(bankCard: string): ValidationResult;
208
+ export function validateUrl(url: string): ValidationResult;
209
+ export function validateChineseName(name: string): ValidationResult;
210
+ export function validateRequired(value: any, fieldName?: string): ValidationResult;
211
+ export function validateNumberRange(
212
+ value: number | null,
213
+ min: number,
214
+ max: number,
215
+ fieldName?: string
216
+ ): ValidationResult;
217
+ export function validateLengthRange(value: any, min: number, max: number, fieldName?: string): ValidationResult;
218
+ export function validateBatch(validations: ValidationResult[]): ValidationResult;
219
+ export function validatePattern(value: string, pattern: RegExp, message: string): ValidationResult;
220
+ export function validateEquality(value1: any, value2: any, fieldName?: string): ValidationResult;
221
+ export function validateDate(date: string, format?: string): ValidationResult;
222
+ export function getFirstErrorMessage(validations: ValidationResult[]): string;
223
+ export function validatePostalCode(postalCode: string): ValidationResult;
224
+ export function validateLandline(phone: string): ValidationResult;
225
+ export function validatePhoneOrEmail(value: string): ValidationResult;
226
+ export function validateUrlSafeString(value: string): ValidationResult;
227
+
228
+ export type StorageItemValue<T = any> = {
229
+ value: T;
230
+ expireTime: string | number;
231
+ };
232
+
233
+ export type StorageData = Record<string, any>;
234
+
235
+ export type StorageOptions = {
236
+ defaultExpireTime?: number;
237
+ storageType?: 'sync';
238
+ autoCleanup?: boolean;
239
+ cleanupInterval?: number;
240
+ prefix?: string;
241
+ compress?: boolean;
242
+ maxSize?: number;
243
+ };
244
+
245
+ export type StorageResult<T = any> = {
246
+ success: boolean;
247
+ value?: T;
248
+ error?: string;
249
+ expired?: boolean;
250
+ };
251
+
252
+ export type StoragePromise<T = any> = Promise<StorageResult<T>>;
253
+
254
+ export type BatchStorageItem<T = any> = {
255
+ key: string;
256
+ storageKey: string;
257
+ value: T;
258
+ expireTime?: number;
259
+ };
260
+
261
+ export type StorageStats = {
262
+ totalKeys: number;
263
+ totalStorageKeys: number;
264
+ totalSize: number;
265
+ expiredKeys: number;
266
+ validKeys: number;
267
+ };
268
+
269
+ export type StorageEventType = 'set' | 'get' | 'remove' | 'clear' | 'expire';
270
+
271
+ export type StorageEvent<T = any> = {
272
+ type: StorageEventType;
273
+ key?: string;
274
+ storageKey?: string;
275
+ value?: T;
276
+ timestamp: number;
277
+ };
278
+
279
+ export type StorageListener<T = any> = (event: StorageEvent<T>) => void;
280
+
281
+ export type StorageQuery = {
282
+ keyPattern?: string;
283
+ storageKeyPattern?: string;
284
+ onlyValid?: boolean;
285
+ limit?: number;
286
+ sortBy?: 'key' | 'storageKey' | 'expireTime' | 'createTime';
287
+ sortOrder?: 'asc' | 'desc';
288
+ };
289
+
290
+ export type StorageExportData = {
291
+ version: string;
292
+ timestamp: number;
293
+ data: Record<string, any>;
294
+ };
295
+
296
+ export type StorageMigration = {
297
+ version: string;
298
+ migrate: (data: any) => StorageData;
299
+ };
300
+
301
+ export type UniStorageData = Record<string, any> | string | number | boolean | null;
302
+
303
+ export type UniStorageOptions = {
304
+ encrypt?: boolean;
305
+ dataType?: 'json' | 'string' | 'number' | 'boolean';
306
+ };
307
+
308
+ export class CustomStorage {
309
+ constructor(options?: StorageOptions);
310
+ set<T = any>(storageKey: string, value: T, expireTime?: number): StoragePromise<T>;
311
+ get<T = any>(storageKey: string): StoragePromise<T>;
312
+ remove(storageKey?: string): StoragePromise<boolean>;
313
+ has(storageKey: string): Promise<boolean>;
314
+ getKeys(): Promise<string[]>;
315
+ getAllKeys(): string[];
316
+ setBatch(items: Record<string, any>[]): StorageResult<boolean>;
317
+ getBatch<T = any>(storageKeys: string[]): StorageResult<T[]>;
318
+ cleanup(): StoragePromise;
319
+ clear(): StoragePromise<boolean>;
320
+ getStats(): StorageStats;
321
+ addEventListener(listener: StorageListener): void;
322
+ removeEventListener(listener: StorageListener): void;
323
+ destroy(): void;
324
+ }
325
+
326
+ export function setCustomStorage<T = any>(storageKey: string, value: T, expireTime?: number): StoragePromise<T>;
327
+ export function getCustomStorage<T = any>(storageKey: string): StoragePromise<T>;
328
+ export function removeCustomStorage(storageKey?: string): StoragePromise<boolean>;
329
+ export function hasCustomStorage(storageKey: string): Promise<boolean>;
330
+ export function clearCustomStorage(): StoragePromise<boolean>;
331
+ export function getStorageKeys(): Promise<string[]>;
332
+ export function getAllStorageKeys(): string[];
333
+ export function getStorageStats(): StorageStats;
334
+ export function cleanupStorage(): StoragePromise;
335
+ export function setBatchStorage(items: Record<string, any>[]): StorageResult<boolean>;
336
+ export function getBatchStorage<T = any>(storageKeys: string[]): StorageResult<T[]>;
208
337
 
209
338
  export function useTheme(): ThemeController;
210
339
  export function getThemeInstance(): ThemeController;
211
340
 
212
341
  export function useToast(): ToastController;
213
342
  export function getToastInstance(): ToastController;
214
- export function showToast(options: string | ToastOptions): void;
215
- export function showSuccess(message: string, duration?: number): void;
216
- export function showError(message: string, duration?: number): void;
217
- export function showWarning(message: string, duration?: number): void;
218
- export function showInfo(message: string, duration?: number): void;
219
- export function showLoadingToast(message?: string): () => void;
343
+ export function showToast(options: string | ToastOptions, duration?: number | null): void;
344
+ export function showSuccess(message: string, duration?: number | null): void;
345
+ export function showError(message: string, duration?: number | null): void;
346
+ export function showWarning(message: string, duration?: number | null): void;
347
+ export function showInfo(message: string, duration?: number | null): void;
348
+ export function showLoadingToast(message?: string | null): () => void;
220
349
  export function hideToast(): void;
221
350
  export function clearToast(): void;
222
351
 
@@ -0,0 +1,19 @@
1
+ export * from './functions/index.uts'
2
+ export * from './request/index.uts'
3
+
4
+ export {
5
+ CustomStorage,
6
+ cleanupStorage,
7
+ clearStorage as clearCustomStorage,
8
+ getAllStorageKeys,
9
+ getBatchStorage,
10
+ getStorage as getCustomStorage,
11
+ getStorageKeys,
12
+ getStorageStats,
13
+ hasStorage as hasCustomStorage,
14
+ removeStorage as removeCustomStorage,
15
+ setBatchStorage,
16
+ setStorage as setCustomStorage,
17
+ } from './storage/index.uts'
18
+
19
+ export type * from './storage/types.uts'