@pisell/materials 3.3.87 → 3.3.88
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +4 -4
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +25 -25
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +15 -15
- package/es/components/PisellLayouts/index.d.ts +0 -1
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceSubForm/index.d.ts +13 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/index.js +274 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/index.less +19 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +544 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/schema-simple-example.json +174 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/types.d.ts +117 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/types.js +1 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.d.ts +9 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.js +61 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/WithMode.d.ts +4 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +176 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/index.d.ts +12 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/index.js +11 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/type.d.ts +87 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Tabs/ReadPretty.d.ts +9 -0
- package/es/components/dataSourceComponents/fields/Tabs/ReadPretty.js +16 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.d.ts +23 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.js +93 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.less +64 -0
- package/es/components/dataSourceComponents/fields/Tabs/WithMode.d.ts +6 -0
- package/es/components/dataSourceComponents/fields/Tabs/WithMode.js +9 -0
- package/es/components/dataSourceComponents/fields/Tabs/index.d.ts +12 -0
- package/es/components/dataSourceComponents/fields/Tabs/index.js +18 -0
- package/es/components/dataSourceComponents/fields/Tabs/type.d.ts +38 -0
- package/es/components/dataSourceComponents/fields/Tabs/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/index.d.ts +44 -7
- package/es/components/dataSourceComponents/fields/index.js +5 -1
- package/es/components/dataSourceComponents/fields/utils.js +3 -0
- package/es/components/pisellLookup/PisellLookup.d.ts +4 -0
- package/es/components/pisellLookup/PisellLookup.js +8 -1
- package/es/components/productCard/components/Packages/utils.d.ts +2 -2
- package/es/index.d.ts +4 -0
- package/es/index.js +3 -0
- package/lib/components/PisellLayouts/index.d.ts +0 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.d.ts +13 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.js +229 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.less +19 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +544 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/schema-simple-example.json +174 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/types.d.ts +117 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/types.js +17 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.d.ts +9 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.js +64 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/WithMode.d.ts +4 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +157 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/index.d.ts +12 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/index.js +40 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/type.d.ts +87 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Tabs/ReadPretty.d.ts +9 -0
- package/lib/components/dataSourceComponents/fields/Tabs/ReadPretty.js +45 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.d.ts +23 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.js +95 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.less +64 -0
- package/lib/components/dataSourceComponents/fields/Tabs/WithMode.d.ts +6 -0
- package/lib/components/dataSourceComponents/fields/Tabs/WithMode.js +39 -0
- package/lib/components/dataSourceComponents/fields/Tabs/index.d.ts +12 -0
- package/lib/components/dataSourceComponents/fields/Tabs/index.js +40 -0
- package/lib/components/dataSourceComponents/fields/Tabs/type.d.ts +38 -0
- package/lib/components/dataSourceComponents/fields/Tabs/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/index.d.ts +44 -7
- package/lib/components/dataSourceComponents/fields/index.js +5 -1
- package/lib/components/dataSourceComponents/fields/utils.js +3 -0
- package/lib/components/pisellLookup/PisellLookup.d.ts +4 -0
- package/lib/components/pisellLookup/PisellLookup.js +5 -1
- package/lib/components/productCard/components/Packages/utils.d.ts +2 -2
- package/lib/index.d.ts +4 -0
- package/lib/index.js +9 -0
- package/lowcode/auto-resize-text/meta.ts +9 -9
- package/lowcode/data-source-form/constants.ts +3 -0
- package/lowcode/data-source-form/utils.ts +31 -5
- package/lowcode/data-source-sub-form/meta.ts +259 -0
- package/lowcode/data-source-sub-form/snippets.ts +21 -0
- package/lowcode/form-item-record-list-wrapper/meta.ts +180 -0
- package/lowcode/form-item-record-list-wrapper/snippets.ts +18 -0
- package/lowcode/form-item-tabs/meta.ts +172 -0
- package/package.json +3 -3
- package/es/components/PisellCards/components/GraphicTextCard/components/BadgeWrapper.d.ts +0 -5
- package/es/components/PisellCards/components/GraphicTextCard/components/TextContent.d.ts +0 -27
- package/es/components/PisellCards/components/GraphicTextCard/hooks/index.d.ts +0 -5
- package/es/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardClick.d.ts +0 -15
- package/es/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardStyle.d.ts +0 -18
- package/es/components/PisellCards/components/GraphicTextCard/types.d.ts +0 -290
- package/es/components/PisellCards/components/GraphicTextCard/utils/index.d.ts +0 -19
- package/es/components/PisellCards/components/TextCard/TextCard.d.ts +0 -8
- package/es/components/PisellCards/components/TextCard/components/BadgeWrapper.d.ts +0 -26
- package/es/components/PisellCards/components/TextCard/components/IconWrapper.d.ts +0 -17
- package/es/components/PisellCards/components/TextCard/components/TextContent.d.ts +0 -21
- package/es/components/PisellCards/components/TextCard/components/index.d.ts +0 -6
- package/es/components/PisellCards/components/TextCard/index.d.ts +0 -5
- package/es/components/PisellCards/components/TextCard/types.d.ts +0 -270
- package/es/components/PisellCards/index.d.ts +0 -15
- package/es/components/config-provider/index.d.ts +0 -10
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -84
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +0 -27
- package/es/components/dataSourceComponents/fields/Upload/constants.d.ts +0 -9
- package/es/components/drag-sort-tree/index.d.ts +0 -5
- package/es/components/filter/components/Dropdown/types.d.ts +0 -13
- package/es/components/filter/components/FilterButton/types.d.ts +0 -24
- package/es/components/filter/types.d.ts +0 -48
- package/es/components/login-and-register/index.d.ts +0 -82
- package/es/components/pisellCurrency/PisellCurrency.d.ts +0 -39
- package/es/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +0 -24
- package/es/components/pisellEmail/PisellEmail.d.ts +0 -37
- package/es/components/pisellFilter/type.d.ts +0 -5
- package/es/components/pisellGridPro/index.d.ts +0 -4
- package/es/components/pisellLongText/PisellLongText.d.ts +0 -39
- package/es/components/pisellMultipleSelect/PisellMultipleSelect.d.ts +0 -9
- package/es/components/pisellMultipleSelect/components/EditView.d.ts +0 -8
- package/es/components/pisellNumber/PisellNumber.d.ts +0 -42
- package/es/components/pisellPhone/PisellPhone.d.ts +0 -36
- package/es/components/pisellPhone/components/EditView.d.ts +0 -19
- package/es/components/pisellPhone/constants/countryCodes.d.ts +0 -20
- package/es/components/pisellPhone/types.d.ts +0 -209
- package/es/components/pisellPhone/utils/countryCodeHelper.d.ts +0 -35
- package/es/components/pisellQuickFilter/type.d.ts +0 -12
- package/es/components/pisellRating/PisellRating.d.ts +0 -31
- package/es/components/pisellRecordBoard/shellFrame/BatchActionBar/index.d.ts +0 -8
- package/es/components/pisellRecordBoard/shellFrame/Search/index.d.ts +0 -10
- package/es/components/pisellRecordBoard/shellFrame/ToolBarReset/index.d.ts +0 -16
- package/es/components/pisellSingleLineText/PisellSingleLineText.d.ts +0 -40
- package/es/components/pisellSingleSelect/PisellSingleSelect.d.ts +0 -9
- package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +0 -32
- package/es/components/pisellUrl/PisellUrl.d.ts +0 -37
- package/es/components/productCard/components/Header/DeleteButton/index.d.ts +0 -4
- package/es/components/productCard/components/Time/components/SelectHolder/index.d.ts +0 -4
- package/es/components/productCard/components/Time/components/SelectResource/index.d.ts +0 -19
- package/es/components/sort/index.d.ts +0 -5
- package/es/components/table/Actions/component/ViewMode/index.d.ts +0 -9
- package/es/components/table/Gallery/components/GalleryItem/index.d.ts +0 -14
- package/es/components/table/types.d.ts +0 -268
- package/es/components/translation/index.d.ts +0 -17
- package/es/components/translation/utils.d.ts +0 -9
- package/lib/components/PisellCards/components/GraphicTextCard/components/BadgeWrapper.d.ts +0 -5
- package/lib/components/PisellCards/components/GraphicTextCard/components/TextContent.d.ts +0 -27
- package/lib/components/PisellCards/components/GraphicTextCard/hooks/index.d.ts +0 -5
- package/lib/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardClick.d.ts +0 -15
- package/lib/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardStyle.d.ts +0 -18
- package/lib/components/PisellCards/components/GraphicTextCard/types.d.ts +0 -290
- package/lib/components/PisellCards/components/GraphicTextCard/utils/index.d.ts +0 -19
- package/lib/components/PisellCards/components/TextCard/TextCard.d.ts +0 -8
- package/lib/components/PisellCards/components/TextCard/components/BadgeWrapper.d.ts +0 -26
- package/lib/components/PisellCards/components/TextCard/components/IconWrapper.d.ts +0 -17
- package/lib/components/PisellCards/components/TextCard/components/TextContent.d.ts +0 -21
- package/lib/components/PisellCards/components/TextCard/components/index.d.ts +0 -6
- package/lib/components/PisellCards/components/TextCard/index.d.ts +0 -5
- package/lib/components/PisellCards/components/TextCard/types.d.ts +0 -270
- package/lib/components/PisellCards/index.d.ts +0 -15
- package/lib/components/config-provider/index.d.ts +0 -10
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -84
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +0 -27
- package/lib/components/dataSourceComponents/fields/Upload/constants.d.ts +0 -9
- package/lib/components/drag-sort-tree/index.d.ts +0 -5
- package/lib/components/filter/components/Dropdown/types.d.ts +0 -13
- package/lib/components/filter/components/FilterButton/types.d.ts +0 -24
- package/lib/components/filter/types.d.ts +0 -48
- package/lib/components/login-and-register/index.d.ts +0 -82
- package/lib/components/pisellCurrency/PisellCurrency.d.ts +0 -39
- package/lib/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +0 -24
- package/lib/components/pisellEmail/PisellEmail.d.ts +0 -37
- package/lib/components/pisellFilter/type.d.ts +0 -5
- package/lib/components/pisellGridPro/index.d.ts +0 -4
- package/lib/components/pisellLongText/PisellLongText.d.ts +0 -39
- package/lib/components/pisellMultipleSelect/PisellMultipleSelect.d.ts +0 -9
- package/lib/components/pisellMultipleSelect/components/EditView.d.ts +0 -8
- package/lib/components/pisellNumber/PisellNumber.d.ts +0 -42
- package/lib/components/pisellPhone/PisellPhone.d.ts +0 -36
- package/lib/components/pisellPhone/components/EditView.d.ts +0 -19
- package/lib/components/pisellPhone/constants/countryCodes.d.ts +0 -20
- package/lib/components/pisellPhone/types.d.ts +0 -209
- package/lib/components/pisellPhone/utils/countryCodeHelper.d.ts +0 -35
- package/lib/components/pisellQuickFilter/type.d.ts +0 -12
- package/lib/components/pisellRating/PisellRating.d.ts +0 -31
- package/lib/components/pisellRecordBoard/shellFrame/BatchActionBar/index.d.ts +0 -8
- package/lib/components/pisellRecordBoard/shellFrame/Search/index.d.ts +0 -10
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarReset/index.d.ts +0 -16
- package/lib/components/pisellSingleLineText/PisellSingleLineText.d.ts +0 -40
- package/lib/components/pisellSingleSelect/PisellSingleSelect.d.ts +0 -9
- package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +0 -32
- package/lib/components/pisellUrl/PisellUrl.d.ts +0 -37
- package/lib/components/productCard/components/Header/DeleteButton/index.d.ts +0 -4
- package/lib/components/productCard/components/Time/components/SelectHolder/index.d.ts +0 -4
- package/lib/components/productCard/components/Time/components/SelectResource/index.d.ts +0 -19
- package/lib/components/sort/index.d.ts +0 -5
- package/lib/components/table/Actions/component/ViewMode/index.d.ts +0 -9
- package/lib/components/table/Gallery/components/GalleryItem/index.d.ts +0 -14
- package/lib/components/table/types.d.ts +0 -268
- package/lib/components/translation/index.d.ts +0 -17
- package/lib/components/translation/utils.d.ts +0 -9
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModeType } from '../dataSourceForm/type';
|
|
3
|
+
/**
|
|
4
|
+
* @title 字段选项接口
|
|
5
|
+
* @description 用于下拉框、单选框等组件的选项配置
|
|
6
|
+
*/
|
|
7
|
+
export interface DataSourceSubFormOption {
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
value: string | number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @title 字段 Schema 接口
|
|
13
|
+
* @description 定义表单字段的结构和配置
|
|
14
|
+
*/
|
|
15
|
+
export interface DataSourceSubFormFieldSchema {
|
|
16
|
+
/** 字段名称(必填) */
|
|
17
|
+
name: string;
|
|
18
|
+
/** 字段标签 */
|
|
19
|
+
label?: React.ReactNode;
|
|
20
|
+
/** 组件类型(兼容多种命名方式) */
|
|
21
|
+
component?: string;
|
|
22
|
+
componentName?: string;
|
|
23
|
+
/** 字段数据类型 */
|
|
24
|
+
type?: string;
|
|
25
|
+
/** 接口类型,用于映射到具体组件(如 Select、Input 等) */
|
|
26
|
+
interface?: string;
|
|
27
|
+
/** 字段选项列表(用于 Select、Radio 等) */
|
|
28
|
+
options?: DataSourceSubFormOption[];
|
|
29
|
+
/** 组件额外配置 */
|
|
30
|
+
props?: Record<string, any>;
|
|
31
|
+
/** 子字段(用于嵌套结构,如 Input.JSON) */
|
|
32
|
+
children?: DataSourceSubFormFieldSchema[];
|
|
33
|
+
_children?: DataSourceSubFormFieldSchema[];
|
|
34
|
+
/** 字段 Schema 配置 */
|
|
35
|
+
schema?: Record<string, any>;
|
|
36
|
+
/** UI Schema 配置(支持低代码平台的各种配置项) */
|
|
37
|
+
uiSchema?: {
|
|
38
|
+
title?: React.ReactNode;
|
|
39
|
+
enum?: DataSourceSubFormOption[];
|
|
40
|
+
'x-component'?: string;
|
|
41
|
+
'x-component-props'?: Record<string, any>;
|
|
42
|
+
'x-read-pretty'?: boolean;
|
|
43
|
+
'x-validator'?: string;
|
|
44
|
+
'x-display'?: 'visible' | 'hidden' | 'none';
|
|
45
|
+
'x-pattern'?: 'editable' | 'disabled' | 'readPretty';
|
|
46
|
+
'x-data-source'?: {
|
|
47
|
+
type?: string;
|
|
48
|
+
options?: Array<{
|
|
49
|
+
id?: string;
|
|
50
|
+
label: string | Record<string, any>;
|
|
51
|
+
value: string;
|
|
52
|
+
color?: string;
|
|
53
|
+
}>;
|
|
54
|
+
labelField?: string;
|
|
55
|
+
valueField?: string;
|
|
56
|
+
dataSource?: any;
|
|
57
|
+
extraParams?: Record<string, any>;
|
|
58
|
+
};
|
|
59
|
+
'x-record-schema'?: DataSourceSubFormSchema | DataSourceSubFormFieldSchema[] | string;
|
|
60
|
+
default?: any;
|
|
61
|
+
type?: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @title Schema 接口
|
|
66
|
+
* @description 表单字段集合的结构定义
|
|
67
|
+
*/
|
|
68
|
+
export interface DataSourceSubFormSchema {
|
|
69
|
+
/** 字段列表 */
|
|
70
|
+
fields?: DataSourceSubFormFieldSchema[];
|
|
71
|
+
/** 属性映射(key-value 形式) */
|
|
72
|
+
properties?: Record<string, any>;
|
|
73
|
+
/** 子字段列表 */
|
|
74
|
+
children?: DataSourceSubFormFieldSchema[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @title DataSourceSubForm 组件 Props
|
|
78
|
+
* @description
|
|
79
|
+
* 独立的子表单组件,用于渲染一组表单字段。
|
|
80
|
+
* 支持通过 xRecordSchema 配置字段,或直接传入 children 低代码子组件。
|
|
81
|
+
*/
|
|
82
|
+
export interface DataSourceSubFormProps {
|
|
83
|
+
/** 渲染模式:edit(编辑)、disabled(禁用)、preview(预览) */
|
|
84
|
+
renderMode?: ModeType;
|
|
85
|
+
/**
|
|
86
|
+
* 表单值对象
|
|
87
|
+
* @example { "fieldName1": "value1", "fieldName2": "value2" }
|
|
88
|
+
*/
|
|
89
|
+
value?: Record<string, any>;
|
|
90
|
+
/**
|
|
91
|
+
* 值变化回调
|
|
92
|
+
* @param value 更新后的表单值对象
|
|
93
|
+
*/
|
|
94
|
+
onChange?: (value: Record<string, any>) => void;
|
|
95
|
+
/**
|
|
96
|
+
* xRecordSchema:定义表单字段结构
|
|
97
|
+
* 支持三种格式:
|
|
98
|
+
* 1. JSON 字符串
|
|
99
|
+
* 2. Schema 对象(包含 fields/properties/children)
|
|
100
|
+
* 3. 字段数组
|
|
101
|
+
*/
|
|
102
|
+
xRecordSchema?: string | DataSourceSubFormSchema | DataSourceSubFormFieldSchema[];
|
|
103
|
+
/**
|
|
104
|
+
* 容器 children:低代码引擎渲染的子组件节点
|
|
105
|
+
* 优先使用 children,如果没有则回退到 xRecordSchema 渲染
|
|
106
|
+
*/
|
|
107
|
+
children?: React.ReactNode;
|
|
108
|
+
/** 低代码设计模式标识 */
|
|
109
|
+
__designMode?: string;
|
|
110
|
+
/** 表单布局方式 */
|
|
111
|
+
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
112
|
+
/** 自定义类名 */
|
|
113
|
+
className?: string;
|
|
114
|
+
/** 自定义样式 */
|
|
115
|
+
style?: React.CSSProperties;
|
|
116
|
+
[key: string]: any;
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
declare const Subdomain: React.FC<import("antd").InputProps & {
|
|
3
3
|
onChange: (value: string) => void;
|
|
4
4
|
onBlur?: ((e: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
5
|
-
rootDomain: "
|
|
5
|
+
rootDomain: "custom" | "saas" | "xzero";
|
|
6
6
|
customDomain?: string | undefined;
|
|
7
7
|
value?: string | undefined;
|
|
8
8
|
tenantId: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RecordListWrapperProps } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* @title: RecordListWrapper 只读态
|
|
5
|
+
* @description: 低代码详情模式下展示每个 option 对应的 record 数据。
|
|
6
|
+
* 值结构: { optionValue: { field1: v1, field2: v2 } }
|
|
7
|
+
*/
|
|
8
|
+
declare const RecordListWrapperReadPretty: React.FC<RecordListWrapperProps>;
|
|
9
|
+
export default RecordListWrapperReadPretty;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* @title: RecordListWrapper 只读态
|
|
11
|
+
* @description: 低代码详情模式下展示每个 option 对应的 record 数据。
|
|
12
|
+
* 值结构: { optionValue: { field1: v1, field2: v2 } }
|
|
13
|
+
*/
|
|
14
|
+
var RecordListWrapperReadPretty = function RecordListWrapperReadPretty(props) {
|
|
15
|
+
var value = props.value,
|
|
16
|
+
_props$options = props.options,
|
|
17
|
+
options = _props$options === void 0 ? [] : _props$options;
|
|
18
|
+
|
|
19
|
+
/** 安全获取 Map 值 */
|
|
20
|
+
var safeValue = value && _typeof(value) === 'object' && !Array.isArray(value) ? value : {};
|
|
21
|
+
var entries = Object.entries(safeValue);
|
|
22
|
+
if (!entries.length) {
|
|
23
|
+
return /*#__PURE__*/React.createElement("span", null, "-");
|
|
24
|
+
}
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
style: {
|
|
27
|
+
marginBottom: 8
|
|
28
|
+
}
|
|
29
|
+
}, "Records: ", entries.length), entries.map(function (_ref) {
|
|
30
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
31
|
+
key = _ref2[0],
|
|
32
|
+
record = _ref2[1];
|
|
33
|
+
var option = options.find(function (o) {
|
|
34
|
+
return String(o.value) === key;
|
|
35
|
+
});
|
|
36
|
+
var label = (option === null || option === void 0 ? void 0 : option.label) || key;
|
|
37
|
+
var displayLabel = _typeof(label) === 'object' ? JSON.stringify(label) : label;
|
|
38
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
key: key,
|
|
40
|
+
style: {
|
|
41
|
+
marginBottom: 8
|
|
42
|
+
}
|
|
43
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
style: {
|
|
45
|
+
fontWeight: 500,
|
|
46
|
+
marginBottom: 4
|
|
47
|
+
}
|
|
48
|
+
}, displayLabel), /*#__PURE__*/React.createElement("pre", {
|
|
49
|
+
style: {
|
|
50
|
+
margin: 0,
|
|
51
|
+
padding: 8,
|
|
52
|
+
background: '#f7f8fa',
|
|
53
|
+
borderRadius: 4,
|
|
54
|
+
fontSize: 12,
|
|
55
|
+
maxHeight: 200,
|
|
56
|
+
overflow: 'auto'
|
|
57
|
+
}
|
|
58
|
+
}, JSON.stringify(record, null, 2)));
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
export default RecordListWrapperReadPretty;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
import React, { useEffect, useMemo, useState, useRef } from 'react';
|
|
14
|
+
import { withMode } from "../../dataSourceForm/utils";
|
|
15
|
+
import ReadPretty from "./ReadPretty";
|
|
16
|
+
import Tabs from "../Tabs/Tabs";
|
|
17
|
+
import DataSourceSubForm from "../../dataSourceSubForm";
|
|
18
|
+
|
|
19
|
+
// ===================== 主组件 =====================
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @title RecordListWrapper 编辑器
|
|
23
|
+
* @description
|
|
24
|
+
* 上部为插槽区域(topSlot),通过 cloneElement 注入 options/value/onChange,默认展示 Tabs 导航。
|
|
25
|
+
* 下部委托给 DataSourceSubForm 渲染当前 activeKey 对应的子表单。
|
|
26
|
+
* 切换 tab 时通过 key={activeKey} 强制重新挂载 DataSourceSubForm,实现值自动同步。
|
|
27
|
+
*
|
|
28
|
+
* 值结构: { [optionValue]: { field1: v1, field2: v2 } }
|
|
29
|
+
*/
|
|
30
|
+
var RecordListWrapperBase = function RecordListWrapperBase(props) {
|
|
31
|
+
var value = props.value,
|
|
32
|
+
_onChange = props.onChange,
|
|
33
|
+
_props$options = props.options,
|
|
34
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
35
|
+
children = props.children,
|
|
36
|
+
xRecordSchema = props.xRecordSchema,
|
|
37
|
+
topSlot = props.topSlot,
|
|
38
|
+
slot = props.slot,
|
|
39
|
+
renderMode = props.renderMode,
|
|
40
|
+
__designMode = props.__designMode,
|
|
41
|
+
defaultValue = props.defaultValue;
|
|
42
|
+
var isMounted = useRef(false);
|
|
43
|
+
var dataSourceSubFormRef = useRef(null);
|
|
44
|
+
|
|
45
|
+
/** value 是 Map: { optionValue: { field1: v1 } } */
|
|
46
|
+
var safeValue = useMemo(function () {
|
|
47
|
+
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
return {};
|
|
51
|
+
}, [value]);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 当前选中的 option key
|
|
55
|
+
* 优先级:defaultActiveKey > options[0].value
|
|
56
|
+
*/
|
|
57
|
+
var _useState = useState(function () {
|
|
58
|
+
var _options$;
|
|
59
|
+
if (defaultValue != null) return String(defaultValue);
|
|
60
|
+
return String(((_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value) || '');
|
|
61
|
+
}),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
activeKey = _useState2[0],
|
|
64
|
+
setActiveKey = _useState2[1];
|
|
65
|
+
|
|
66
|
+
/** defaultValue 变化时同步更新 activeKey */
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
if (defaultValue != null) {
|
|
69
|
+
setActiveKey(String(defaultValue));
|
|
70
|
+
}
|
|
71
|
+
}, [defaultValue]);
|
|
72
|
+
|
|
73
|
+
/** options 变化时校正 activeKey(仅在无 defaultValue 且当前 key 不合法时回退) */
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (options.length && !options.find(function (o) {
|
|
76
|
+
return String(o.value) === activeKey;
|
|
77
|
+
})) {
|
|
78
|
+
var _options$2;
|
|
79
|
+
setActiveKey(defaultValue != null ? String(defaultValue) : String(((_options$2 = options[0]) === null || _options$2 === void 0 ? void 0 : _options$2.value) || ''));
|
|
80
|
+
}
|
|
81
|
+
}, [options]);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 初始化所有 option 的值:
|
|
85
|
+
* 以字段 schema 中的 uiSchema.default 作为每个 option 的默认值模板,
|
|
86
|
+
* 已有值(safeValue)优先覆盖,确保已填写的数据不丢失。
|
|
87
|
+
* 仅执行一次(由 isMounted 守卫),避免重复触发 onChange。
|
|
88
|
+
*/
|
|
89
|
+
useEffect(function () {
|
|
90
|
+
if (isMounted.current) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if ((options === null || options === void 0 ? void 0 : options.length) > 0 && dataSourceSubFormRef.current) {
|
|
94
|
+
var _dataSourceSubFormRef, _dataSourceSubFormRef2, _dataSourceSubFormRef3;
|
|
95
|
+
var defaultValues = (_dataSourceSubFormRef = (_dataSourceSubFormRef2 = (_dataSourceSubFormRef3 = dataSourceSubFormRef.current).getFieldsValue) === null || _dataSourceSubFormRef2 === void 0 ? void 0 : _dataSourceSubFormRef2.call(_dataSourceSubFormRef3)) !== null && _dataSourceSubFormRef !== void 0 ? _dataSourceSubFormRef : {};
|
|
96
|
+
var completeValue = options.reduce(function (acc, option) {
|
|
97
|
+
if (option.value === null || option.value === undefined) return acc;
|
|
98
|
+
acc[String(option.value)] = _objectSpread(_objectSpread({}, defaultValues), safeValue[String(option.value)] || {});
|
|
99
|
+
return acc;
|
|
100
|
+
}, {});
|
|
101
|
+
_onChange === null || _onChange === void 0 || _onChange(completeValue);
|
|
102
|
+
isMounted.current = true;
|
|
103
|
+
}
|
|
104
|
+
}, [options, safeValue]);
|
|
105
|
+
|
|
106
|
+
// ---- 上部: 插槽区域 ----
|
|
107
|
+
var renderTopSlot = function renderTopSlot() {
|
|
108
|
+
var slotElement = topSlot || slot;
|
|
109
|
+
if (slotElement && /*#__PURE__*/React.isValidElement(slotElement)) {
|
|
110
|
+
// cloneElement 注入 options / value(activeKey) / onChange(setActiveKey)
|
|
111
|
+
return /*#__PURE__*/React.cloneElement(slotElement, {
|
|
112
|
+
options: options,
|
|
113
|
+
value: activeKey,
|
|
114
|
+
onChange: setActiveKey
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// TabOption.label 为必填,RecordListWrapperOption.label 可选,fallback 到 value
|
|
119
|
+
var tabOptions = options.map(function (o) {
|
|
120
|
+
var _o$label;
|
|
121
|
+
return _objectSpread(_objectSpread({}, o), {}, {
|
|
122
|
+
label: (_o$label = o.label) !== null && _o$label !== void 0 ? _o$label : String(o.value)
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
if (!options.length) {
|
|
126
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
style: {
|
|
128
|
+
color: '#999',
|
|
129
|
+
fontSize: 16
|
|
130
|
+
}
|
|
131
|
+
}, "\u6682\u65E0\u9009\u9879\uFF0C\u8BF7\u914D\u7F6E\u6570\u636E\u6E90\u3002");
|
|
132
|
+
}
|
|
133
|
+
return /*#__PURE__*/React.createElement(Tabs, {
|
|
134
|
+
options: tabOptions,
|
|
135
|
+
value: activeKey,
|
|
136
|
+
onChange: function onChange(key) {
|
|
137
|
+
return setActiveKey(String(key));
|
|
138
|
+
},
|
|
139
|
+
disabled: renderMode === 'disabled'
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// ---- 下部: 委托给 DataSourceSubForm ----
|
|
144
|
+
var renderBottom = function renderBottom() {
|
|
145
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataSourceSubForm, {
|
|
146
|
+
activeKey: activeKey,
|
|
147
|
+
value: safeValue[activeKey],
|
|
148
|
+
onChange: function onChange(recordValue) {
|
|
149
|
+
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(_objectSpread(_objectSpread({}, safeValue || {}), {}, _defineProperty({}, activeKey, recordValue || {})));
|
|
150
|
+
},
|
|
151
|
+
xRecordSchema: xRecordSchema,
|
|
152
|
+
renderMode: renderMode,
|
|
153
|
+
__designMode: __designMode
|
|
154
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
155
|
+
style: {
|
|
156
|
+
width: '100%',
|
|
157
|
+
height: 0,
|
|
158
|
+
visibility: 'hidden',
|
|
159
|
+
overflow: 'hidden'
|
|
160
|
+
}
|
|
161
|
+
}, /*#__PURE__*/React.createElement(DataSourceSubForm, {
|
|
162
|
+
key: "record-list-wrapper-default-value-form",
|
|
163
|
+
ref: dataSourceSubFormRef,
|
|
164
|
+
xRecordSchema: xRecordSchema,
|
|
165
|
+
renderMode: renderMode,
|
|
166
|
+
__designMode: __designMode
|
|
167
|
+
}, children)));
|
|
168
|
+
};
|
|
169
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
style: {
|
|
171
|
+
marginBottom: 12
|
|
172
|
+
}
|
|
173
|
+
}, renderTopSlot()), renderBottom());
|
|
174
|
+
};
|
|
175
|
+
var RecordListWrapperWithMode = withMode(RecordListWrapperBase, ReadPretty);
|
|
176
|
+
export default RecordListWrapperWithMode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const RecordListWrapperWithDataSource: (props: import("./type").RecordListWrapperProps & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps & {
|
|
3
|
+
options?: any;
|
|
4
|
+
optionSourceType?: "default" | "custom" | "api" | undefined;
|
|
5
|
+
labelField: string;
|
|
6
|
+
valueField: string;
|
|
7
|
+
extraParams?: Record<string, any> | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
dataSource?: any;
|
|
10
|
+
extraParams?: Record<string, any> | undefined;
|
|
11
|
+
}) => React.JSX.Element;
|
|
12
|
+
export default RecordListWrapperWithDataSource;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { withDataSource, withFormItem, withOptions } from "../../dataSourceForm/utils";
|
|
2
|
+
import RecordListWrapperWithMode from "./WithMode";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @title: RecordListWrapper 字段封装
|
|
6
|
+
* @description: 复用 DataSourceForm 的 FormItem/DataSource/Options 三层能力,保持与 Select 一致的数据源接入方式。
|
|
7
|
+
*/
|
|
8
|
+
var RecordListWrapperWithFormItem = withFormItem(RecordListWrapperWithMode);
|
|
9
|
+
var RecordListWrapperWithOptions = withOptions(RecordListWrapperWithFormItem);
|
|
10
|
+
var RecordListWrapperWithDataSource = withDataSource(RecordListWrapperWithOptions);
|
|
11
|
+
export default RecordListWrapperWithDataSource;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModeType } from '../../dataSourceForm/type';
|
|
3
|
+
export interface RecordListWrapperOption {
|
|
4
|
+
label?: React.ReactNode;
|
|
5
|
+
value: string | number;
|
|
6
|
+
}
|
|
7
|
+
export interface RecordListWrapperFieldSchema {
|
|
8
|
+
name: string;
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
component?: string;
|
|
11
|
+
componentName?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
/** 接口类型,用于映射到具体组件(如 Select、Input 等) */
|
|
14
|
+
interface?: string;
|
|
15
|
+
options?: RecordListWrapperOption[];
|
|
16
|
+
props?: Record<string, any>;
|
|
17
|
+
/** 子字段(用于嵌套结构,如 Input.JSON) */
|
|
18
|
+
children?: RecordListWrapperFieldSchema[];
|
|
19
|
+
_children?: RecordListWrapperFieldSchema[];
|
|
20
|
+
schema?: Record<string, any>;
|
|
21
|
+
uiSchema?: {
|
|
22
|
+
title?: React.ReactNode;
|
|
23
|
+
enum?: RecordListWrapperOption[];
|
|
24
|
+
'x-component'?: string;
|
|
25
|
+
'x-component-props'?: Record<string, any>;
|
|
26
|
+
'x-read-pretty'?: boolean;
|
|
27
|
+
'x-validator'?: string;
|
|
28
|
+
'x-display'?: 'visible' | 'hidden' | 'none';
|
|
29
|
+
'x-pattern'?: 'editable' | 'disabled' | 'readPretty';
|
|
30
|
+
'x-data-source'?: {
|
|
31
|
+
type?: string;
|
|
32
|
+
options?: Array<{
|
|
33
|
+
id?: string;
|
|
34
|
+
label: string | Record<string, any>;
|
|
35
|
+
value: string;
|
|
36
|
+
color?: string;
|
|
37
|
+
}>;
|
|
38
|
+
labelField?: string;
|
|
39
|
+
valueField?: string;
|
|
40
|
+
dataSource?: any;
|
|
41
|
+
extraParams?: Record<string, any>;
|
|
42
|
+
};
|
|
43
|
+
'x-record-schema'?: RecordListWrapperSchema | RecordListWrapperFieldSchema[] | string;
|
|
44
|
+
default?: any;
|
|
45
|
+
type?: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface RecordListWrapperSchema {
|
|
49
|
+
fields?: RecordListWrapperFieldSchema[];
|
|
50
|
+
properties?: Record<string, any>;
|
|
51
|
+
children?: RecordListWrapperFieldSchema[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @title RecordListWrapper 组件 Props
|
|
55
|
+
* @description
|
|
56
|
+
* 值结构为 Map:key 是 xDataSource option 的 value,value 是该 option 对应的表单字段值。
|
|
57
|
+
* 例如:{ "5": { "code": "xxx", "type": "yyy" }, "3": { "code": "aaa" } }
|
|
58
|
+
*/
|
|
59
|
+
export interface RecordListWrapperProps {
|
|
60
|
+
renderMode: ModeType;
|
|
61
|
+
/**
|
|
62
|
+
* 值: Map 结构
|
|
63
|
+
* - key: xDataSource option 的 value
|
|
64
|
+
* - value: 该 option 对应的 xRecordSchema 字段值对象
|
|
65
|
+
*/
|
|
66
|
+
value?: Record<string, Record<string, any>>;
|
|
67
|
+
onChange?: (value: Record<string, Record<string, any>>) => void;
|
|
68
|
+
/** xDataSource 选项列表,驱动 tabs 导航和 records 结构 */
|
|
69
|
+
options?: RecordListWrapperOption[];
|
|
70
|
+
/**
|
|
71
|
+
* 上部插槽:用户可在低代码平台拖入自定义导航组件。
|
|
72
|
+
* RecordListWrapper 会通过 cloneElement 注入 options、value(activeKey)、onChange。
|
|
73
|
+
*/
|
|
74
|
+
topSlot?: React.ReactNode;
|
|
75
|
+
slot?: React.ReactNode;
|
|
76
|
+
/** xRecordSchema:定义每条记录的子字段结构 */
|
|
77
|
+
xRecordSchema?: string | RecordListWrapperSchema | RecordListWrapperFieldSchema[];
|
|
78
|
+
/** 容器 children:低代码引擎渲染的子组件节点 */
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
/** 低代码设计模式标识 */
|
|
81
|
+
__designMode?: string;
|
|
82
|
+
/**
|
|
83
|
+
* 默认激活的 Tab key,外部传入时优先于 options[0].value
|
|
84
|
+
*/
|
|
85
|
+
defaultValue?: string;
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const SelectWithDataSource: (props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps & {
|
|
3
3
|
options?: any;
|
|
4
|
-
optionSourceType?: "default" | "
|
|
4
|
+
optionSourceType?: "default" | "custom" | "api" | undefined;
|
|
5
5
|
labelField: string;
|
|
6
6
|
valueField: string;
|
|
7
7
|
extraParams?: Record<string, any> | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import useValueMap from "../../hooks/useValueMap";
|
|
2
|
+
import { renderValueWithMap } from "../../dataSourceForm/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tabs 只读展示组件
|
|
6
|
+
*
|
|
7
|
+
* @description 在 view / tableView 模式下展示选中的标签名称文本。
|
|
8
|
+
*/
|
|
9
|
+
var TabsReadPretty = function TabsReadPretty(_ref) {
|
|
10
|
+
var value = _ref.value,
|
|
11
|
+
options = _ref.options,
|
|
12
|
+
renderMode = _ref.renderMode;
|
|
13
|
+
var valueMap = useValueMap(options || []);
|
|
14
|
+
return renderValueWithMap(value, valueMap, renderMode);
|
|
15
|
+
};
|
|
16
|
+
export default TabsReadPretty;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TabsProps } from './type';
|
|
3
|
+
import './Tabs.less';
|
|
4
|
+
/**
|
|
5
|
+
* Tabs 胶囊风格选项卡组件
|
|
6
|
+
*
|
|
7
|
+
* @description 提供类似 Segmented 控件的胶囊风格选项卡,支持受控与非受控模式。
|
|
8
|
+
* 用于表单中替代 Radio.Group,展示更为直观的标签页切换交互。
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Tabs
|
|
13
|
+
* value={current}
|
|
14
|
+
* options={[
|
|
15
|
+
* { label: '校区', value: 'campus' },
|
|
16
|
+
* { label: '场地', value: 'venue' },
|
|
17
|
+
* ]}
|
|
18
|
+
* onChange={(val) => setCurrent(val)}
|
|
19
|
+
* />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare const Tabs: React.FC<TabsProps>;
|
|
23
|
+
export default Tabs;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import "./Tabs.less";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Tabs 胶囊风格选项卡组件
|
|
13
|
+
*
|
|
14
|
+
* @description 提供类似 Segmented 控件的胶囊风格选项卡,支持受控与非受控模式。
|
|
15
|
+
* 用于表单中替代 Radio.Group,展示更为直观的标签页切换交互。
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <Tabs
|
|
20
|
+
* value={current}
|
|
21
|
+
* options={[
|
|
22
|
+
* { label: '校区', value: 'campus' },
|
|
23
|
+
* { label: '场地', value: 'venue' },
|
|
24
|
+
* ]}
|
|
25
|
+
* onChange={(val) => setCurrent(val)}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
var Tabs = function Tabs(_ref) {
|
|
30
|
+
var value = _ref.value,
|
|
31
|
+
defaultValue = _ref.defaultValue,
|
|
32
|
+
_ref$options = _ref.options,
|
|
33
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
34
|
+
_ref$disabled = _ref.disabled,
|
|
35
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
36
|
+
onChange = _ref.onChange,
|
|
37
|
+
className = _ref.className,
|
|
38
|
+
style = _ref.style;
|
|
39
|
+
/** 内部选中值,支持受控与非受控 */
|
|
40
|
+
var _React$useState = React.useState(defaultValue),
|
|
41
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
42
|
+
internalValue = _React$useState2[0],
|
|
43
|
+
setInternalValue = _React$useState2[1];
|
|
44
|
+
|
|
45
|
+
/** 最终使用的选中值:受控优先 */
|
|
46
|
+
var selectedValue = value !== undefined ? value : internalValue;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 处理选项点击
|
|
50
|
+
*/
|
|
51
|
+
var handleSelect = function handleSelect(option) {
|
|
52
|
+
if (disabled || option.disabled) return;
|
|
53
|
+
var newValue = option.value;
|
|
54
|
+
if (value === undefined) {
|
|
55
|
+
setInternalValue(newValue);
|
|
56
|
+
}
|
|
57
|
+
onChange === null || onChange === void 0 || onChange(newValue);
|
|
58
|
+
};
|
|
59
|
+
var tabItems = useMemo(function () {
|
|
60
|
+
return options.map(function (option) {
|
|
61
|
+
var isActive = selectedValue != null && selectedValue !== undefined && String(selectedValue) === String(option.value);
|
|
62
|
+
var isDisabled = disabled || option.disabled;
|
|
63
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
key: option.value,
|
|
65
|
+
className: classNames('pisell-form-tabs-item', {
|
|
66
|
+
'pisell-form-tabs-item--active': isActive,
|
|
67
|
+
'pisell-form-tabs-item--disabled': isDisabled
|
|
68
|
+
}),
|
|
69
|
+
onClick: function onClick() {
|
|
70
|
+
return handleSelect(option);
|
|
71
|
+
},
|
|
72
|
+
role: "tab",
|
|
73
|
+
"aria-selected": isActive,
|
|
74
|
+
"aria-disabled": isDisabled,
|
|
75
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
76
|
+
onKeyDown: function onKeyDown(e) {
|
|
77
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
handleSelect(option);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
className: "pisell-form-tabs-item-label"
|
|
84
|
+
}, option.label));
|
|
85
|
+
});
|
|
86
|
+
}, [options, selectedValue, disabled]);
|
|
87
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: classNames('pisell-form-tabs', className),
|
|
89
|
+
style: style,
|
|
90
|
+
role: "tablist"
|
|
91
|
+
}, tabItems);
|
|
92
|
+
};
|
|
93
|
+
export default Tabs;
|