@wecode-team/we0-cms 1.1.14 → 1.1.16

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.
@@ -4,7 +4,7 @@ export interface ApiResponse<T = any> {
4
4
  data?: T;
5
5
  error?: string;
6
6
  }
7
- export type RelationType = 'belongsTo' | 'hasMany' | 'belongsToMany';
7
+ export type RelationType = "belongsTo" | "hasMany" | "belongsToMany";
8
8
  export interface RelationConfig {
9
9
  type: RelationType;
10
10
  target: string;
@@ -31,13 +31,31 @@ export interface SchemaField {
31
31
  /**
32
32
  * 后台是否允许编辑该字段(前端表单会禁用,并在提交时跳过该字段)
33
33
  * - 默认 true
34
- * - 可用 `editable: false` 标记“后台不可编辑”
34
+ * - 可用 `editable: false` 标记”后台不可编辑”
35
35
  */
36
36
  editable?: boolean;
37
37
  /**
38
38
  * 兼容常见字段名:readOnly=true 等价于 editable=false
39
39
  */
40
40
  readOnly?: boolean;
41
+ /**
42
+ * 时间格式(用于date/datetime/timestamp类型)
43
+ * - “date”: 仅日期(YYYY-MM-DD)
44
+ * - “datetime”: 日期时间(YYYY-MM-DD HH:mm:ss)
45
+ * - “time”: 仅时间(HH:mm:ss)
46
+ * - “timestamp”: Unix时间戳(毫秒)
47
+ * - “iso”: ISO 8601格式
48
+ */
49
+ format?: "date" | "datetime" | "time" | "timestamp" | "iso";
50
+ /**
51
+ * 枚举选项(用于select/radio类型)
52
+ */
53
+ enum?: Array<string | number>;
54
+ /**
55
+ * 枚举选项标签映射(可选)
56
+ * 例如:{ “active”: “激活”, “inactive”: “未激活” }
57
+ */
58
+ enumLabels?: Record<string, string>;
41
59
  }
42
60
  export interface CmsModel {
43
61
  id: number;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 格式化时间戳为字符串
3
+ * @param value 时间戳值(可能是毫秒或秒)
4
+ * @param format 格式类型
5
+ * @returns 格式化后的字符串
6
+ */
7
+ export declare function formatTimestamp(value: any, format?: 'date' | 'datetime' | 'time' | 'timestamp' | 'iso'): string;
8
+ /**
9
+ * 解析用户输入的时间字符串为时间戳或标准格式
10
+ * @param value 用户输入的值
11
+ * @param format 目标格式
12
+ * @returns 解析后的值
13
+ */
14
+ export declare function parseTimeInput(value: string, format?: 'date' | 'datetime' | 'time' | 'timestamp' | 'iso'): any;
15
+ /**
16
+ * 转换时间值为表单输入格式
17
+ * @param value 数据库中的值
18
+ * @param format 格式类型
19
+ * @returns 表单输入框的值
20
+ */
21
+ export declare function convertToInputValue(value: any, format?: 'date' | 'datetime' | 'time' | 'timestamp' | 'iso'): string;
22
+ /**
23
+ * 获取表单输入框的type属性
24
+ * @param fieldType 字段类型
25
+ * @param format 格式类型
26
+ * @returns HTML input type
27
+ */
28
+ export declare function getInputType(fieldType: string, format?: 'date' | 'datetime' | 'time' | 'timestamp' | 'iso'): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wecode-team/we0-cms",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
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",