@wecode-team/we0-cms 1.1.19 → 1.1.22
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 +192 -3
- package/dist/components/fields/AssetField.d.ts +14 -0
- package/dist/components/page-shadcn.d.ts +6 -0
- package/dist/components/types.d.ts +1 -69
- package/dist/components/upload/context.d.ts +7 -0
- package/dist/i18n/types.d.ts +14 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/asset-utils.d.ts +7 -0
- package/dist/lib/enum-utils.d.ts +12 -0
- package/dist/services/index.d.ts +21 -0
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function isHttpUrl(v: string): boolean;
|
|
2
|
+
export declare function isProbablyImageUrl(v: string): boolean;
|
|
3
|
+
export declare function formatFileSize(bytes: number): string;
|
|
4
|
+
export declare function matchesAccept(file: Pick<File, "name" | "type">, accept?: string): boolean;
|
|
5
|
+
export declare function normalizeUploadResult(result: {
|
|
6
|
+
url: string;
|
|
7
|
+
}): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SchemaField } from "../services";
|
|
2
|
+
export type EnumValue = string | number;
|
|
3
|
+
export interface EnumOption {
|
|
4
|
+
value: EnumValue;
|
|
5
|
+
valueKey: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function hasEnumOptions(field?: Pick<SchemaField, "enum"> | null): boolean;
|
|
9
|
+
export declare function getEnumValueKey(value: unknown): string;
|
|
10
|
+
export declare function getEnumLabel(field: Pick<SchemaField, "enumLabels">, value: unknown): string;
|
|
11
|
+
export declare function getEnumOptions(field: Pick<SchemaField, "enum" | "enumLabels">, currentValue?: unknown): EnumOption[];
|
|
12
|
+
export declare function parseEnumValue(field: Pick<SchemaField, "enum">, valueKey: string): string | number;
|
package/dist/services/index.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export interface RelationOption {
|
|
|
19
19
|
label: string;
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
}
|
|
22
|
+
export interface UploadConfig {
|
|
23
|
+
accept?: string;
|
|
24
|
+
maxSize?: number;
|
|
25
|
+
directory?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
buttonText?: string;
|
|
28
|
+
}
|
|
22
29
|
export interface SchemaField {
|
|
23
30
|
name: string;
|
|
24
31
|
type: string;
|
|
@@ -56,6 +63,10 @@ export interface SchemaField {
|
|
|
56
63
|
* 例如:{ “active”: “激活”, “inactive”: “未激活” }
|
|
57
64
|
*/
|
|
58
65
|
enumLabels?: Record<string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* 上传配置(用于 asset 类型)
|
|
68
|
+
*/
|
|
69
|
+
upload?: UploadConfig;
|
|
59
70
|
}
|
|
60
71
|
export interface CmsModel {
|
|
61
72
|
id: number;
|
|
@@ -67,6 +78,15 @@ export interface CmsModel {
|
|
|
67
78
|
created_at: string;
|
|
68
79
|
updated_at: string;
|
|
69
80
|
}
|
|
81
|
+
export interface CmsUploadContext {
|
|
82
|
+
field: SchemaField;
|
|
83
|
+
model: CmsModel;
|
|
84
|
+
sessionId?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface CmsUploadResult {
|
|
87
|
+
url: string;
|
|
88
|
+
}
|
|
89
|
+
export type CmsUploadHandler = (file: File, context: CmsUploadContext) => Promise<CmsUploadResult>;
|
|
70
90
|
export interface TableData {
|
|
71
91
|
[key: string]: any;
|
|
72
92
|
}
|
|
@@ -81,6 +101,7 @@ export interface SupabaseFilter {
|
|
|
81
101
|
operator: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "in" | "is";
|
|
82
102
|
value: any;
|
|
83
103
|
}
|
|
104
|
+
export declare function getSessionId(): string | undefined;
|
|
84
105
|
export declare function setSessionId(sessionId: string): void;
|
|
85
106
|
export declare const modelApi: {
|
|
86
107
|
getModels: () => Promise<ApiResponse<CmsModel[]>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wecode-team/we0-cms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "A CMS component for React applications with shadcn/ui",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"publish:public": "npm run build && NPM_CONFIG_USERCONFIG=$(node -e \"process.stdout.write(require('fs').existsSync('.npmrc.public.local') ? '.npmrc.public.local' : '.npmrc.public')\") npm publish --access public --ignore-scripts",
|
|
29
29
|
"publish:private": "npm run build && NPM_CONFIG_USERCONFIG=$(node -e \"process.stdout.write(require('fs').existsSync('.npmrc.private.local') ? '.npmrc.private.local' : '.npmrc.private')\") npm publish --access public --ignore-scripts",
|
|
30
30
|
"publish:all": "npm run build && NPM_CONFIG_USERCONFIG=$(node -e \"process.stdout.write(require('fs').existsSync('.npmrc.public.local') ? '.npmrc.public.local' : '.npmrc.public')\") npm publish --access public --ignore-scripts && NPM_CONFIG_USERCONFIG=$(node -e \"process.stdout.write(require('fs').existsSync('.npmrc.private.local') ? '.npmrc.private.local' : '.npmrc.private')\") npm publish --access public --ignore-scripts",
|
|
31
|
-
"test": "
|
|
31
|
+
"test": "node --test test/*.test.cjs"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"react",
|