@kne/form-creator 0.1.26 → 0.1.28
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 +343 -22
- package/dist/index.css +584 -79
- package/dist/index.css.map +1 -1
- package/dist/index.js +1910 -472
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1924 -513
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +65 -0
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +65 -0
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +65 -0
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +65 -0
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm i --save @kne/form-creator
|
|
|
12
12
|
|
|
13
13
|
### 概述
|
|
14
14
|
|
|
15
|
-
配置式表单搭建组件:通过字段列表 UI 产出 Schema,并用 `@kne/form-info`
|
|
15
|
+
配置式表单搭建组件:通过字段列表 UI 产出 Schema,并用 `@kne/form-info` 实时预览与运行时渲染;支持矩阵量表(MatrixScale)、带「其他」的单选/复选组(RadioGroupOther / CheckboxGroupOther)及 modern / block / indexType 选项样式。
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
### 示例
|
|
@@ -33,19 +33,62 @@ npm i --save @kne/form-creator
|
|
|
33
33
|
#### 示例代码
|
|
34
34
|
|
|
35
35
|
- 配置式表单搭建(全屏)
|
|
36
|
-
-
|
|
37
|
-
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],_JsonView(@kne/json-view)[import * as _JsonView from "@kne/json-view"],(@kne/json-view/dist/index.css)[import "@kne/json-view/dist/index.css"],antd(antd)[import antd from "antd"],
|
|
36
|
+
- 模块搭建与实时预览;工具栏可导入/导出 Schema JSON(弹窗内 JSONEditor)
|
|
37
|
+
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],_JsonView(@kne/json-view)[import * as _JsonView from "@kne/json-view"],(@kne/json-view/dist/index.css)[import "@kne/json-view/dist/index.css"],antd(antd)[import antd from "antd"],remoteLoader(@kne/remote-loader)[import * as remoteLoader from "@kne/remote-loader"]
|
|
38
38
|
|
|
39
39
|
```jsx
|
|
40
|
-
const {
|
|
40
|
+
const {
|
|
41
|
+
default: FormCreator,
|
|
42
|
+
defaultSchema,
|
|
43
|
+
createBlock,
|
|
44
|
+
createField,
|
|
45
|
+
createStep,
|
|
46
|
+
createChoiceOption,
|
|
47
|
+
normalizeSchema
|
|
48
|
+
} = _FormCreator;
|
|
41
49
|
const {default: JsonView} = _JsonView;
|
|
42
|
-
const {
|
|
43
|
-
const {
|
|
50
|
+
const {createWithRemoteLoader, preset: remoteLoaderPreset} = remoteLoader;
|
|
51
|
+
const {useState, useRef} = React;
|
|
52
|
+
const {Typography, Button, Space, Alert, message, Modal} = antd;
|
|
44
53
|
|
|
45
54
|
const {Text} = Typography;
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
/** 仅在用到 JSONEditor 时声明 components-thirdparty(merge 进全局 remotes,不覆盖 core) */
|
|
57
|
+
remoteLoaderPreset({
|
|
58
|
+
remotes: {
|
|
59
|
+
'components-thirdparty': {
|
|
60
|
+
url: 'https://uc.fatalent.cn',
|
|
61
|
+
tpl: '{{url}}/packages/@kne-components/{{remote}}/{{version}}/build',
|
|
62
|
+
remote: 'components-thirdparty',
|
|
63
|
+
defaultVersion: '0.1.64'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const SchemaJsonEditor = ({JSONEditorField, initialText, textRef}) => {
|
|
69
|
+
const [text, setText] = useState(initialText);
|
|
70
|
+
return (
|
|
71
|
+
<JSONEditorField
|
|
72
|
+
height={420}
|
|
73
|
+
value={text}
|
|
74
|
+
onChange={next => {
|
|
75
|
+
setText(next);
|
|
76
|
+
textRef.current = next;
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const BaseExample = createWithRemoteLoader({
|
|
83
|
+
// JSONEditor.Field:纯 UI(value/onChange);默认 JSONEditor 是 FormInfo 字段
|
|
84
|
+
// Schema 弹窗用 antd Modal 受控打开(示例页未挂 ModalContextHolder,useModal 会静默无效果)
|
|
85
|
+
modules: ['components-thirdparty:JSONEditor.Field']
|
|
86
|
+
})(({remoteModules}) => {
|
|
87
|
+
const [JSONEditorField] = remoteModules;
|
|
88
|
+
const [schemaJsonOpen, setSchemaJsonOpen] = useState(false);
|
|
89
|
+
const schemaJsonTextRef = useRef('');
|
|
90
|
+
const [schemaJsonInitial, setSchemaJsonInitial] = useState('');
|
|
91
|
+
const [schema, setSchema] = useState(() => ({
|
|
49
92
|
...defaultSchema(),
|
|
50
93
|
actions: {
|
|
51
94
|
showSubmit: true,
|
|
@@ -104,6 +147,42 @@ const BaseExample = () => {
|
|
|
104
147
|
block: true,
|
|
105
148
|
description: '选填',
|
|
106
149
|
props: {rows: 3, placeholder: '补充说明'}
|
|
150
|
+
}),
|
|
151
|
+
createField({
|
|
152
|
+
type: 'RadioGroupOther',
|
|
153
|
+
name: 'channel',
|
|
154
|
+
label: '了解渠道',
|
|
155
|
+
rule: 'REQ',
|
|
156
|
+
block: true,
|
|
157
|
+
props: {
|
|
158
|
+
modern: true,
|
|
159
|
+
block: true,
|
|
160
|
+
indexType: 'letter',
|
|
161
|
+
options: [
|
|
162
|
+
{label: '招聘网站', value: 'website'},
|
|
163
|
+
{label: '内部推荐', value: 'referral'},
|
|
164
|
+
{label: '校园宣讲', value: 'campus'}
|
|
165
|
+
],
|
|
166
|
+
otherProps: {placeholder: '请说明其他渠道'}
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
createField({
|
|
170
|
+
type: 'CheckboxGroupOther',
|
|
171
|
+
name: 'benefits',
|
|
172
|
+
label: '期望福利',
|
|
173
|
+
block: true,
|
|
174
|
+
props: {
|
|
175
|
+
modern: true,
|
|
176
|
+
block: true,
|
|
177
|
+
indexType: 'check',
|
|
178
|
+
options: [
|
|
179
|
+
{label: '五险一金', value: 'insurance'},
|
|
180
|
+
{label: '带薪年假', value: 'vacation'},
|
|
181
|
+
{label: '餐补', value: 'meal'}
|
|
182
|
+
],
|
|
183
|
+
otherOption: {label: '其他福利', value: 'other'},
|
|
184
|
+
otherProps: {placeholder: '请描述其他福利'}
|
|
185
|
+
}
|
|
107
186
|
})
|
|
108
187
|
]
|
|
109
188
|
}),
|
|
@@ -401,6 +480,42 @@ const BaseExample = () => {
|
|
|
401
480
|
maxLength: 3,
|
|
402
481
|
minLength: 1
|
|
403
482
|
}),
|
|
483
|
+
createBlock('matrixScale', {
|
|
484
|
+
title: '一天中各项活动的时间占比',
|
|
485
|
+
name: 'timeShare',
|
|
486
|
+
rowTitle: '活动',
|
|
487
|
+
layout: 'options',
|
|
488
|
+
fieldType: 'RadioGroup',
|
|
489
|
+
rule: 'REQ',
|
|
490
|
+
rows: [
|
|
491
|
+
{ label: '工作/学习', name: 'work' },
|
|
492
|
+
{ label: '通勤', name: 'commute' },
|
|
493
|
+
{ label: '休闲娱乐', name: 'leisure' }
|
|
494
|
+
],
|
|
495
|
+
options: [
|
|
496
|
+
{ label: '几乎没有(0%)', value: 'none' },
|
|
497
|
+
{ label: '少量(1%-20%)', value: 'little' },
|
|
498
|
+
{ label: '约一半(41%-60%)', value: 'half' },
|
|
499
|
+
{ label: '大部分(81%-100%)', value: 'most' }
|
|
500
|
+
]
|
|
501
|
+
}),
|
|
502
|
+
createBlock('matrixScale', {
|
|
503
|
+
title: '近一周每天的时长(小时)',
|
|
504
|
+
name: 'weekHours',
|
|
505
|
+
rowTitle: '项目',
|
|
506
|
+
layout: 'columns',
|
|
507
|
+
fieldType: 'InputNumber',
|
|
508
|
+
rule: 'REQ',
|
|
509
|
+
rows: [
|
|
510
|
+
{ label: '工作', name: 'work' },
|
|
511
|
+
{ label: '运动', name: 'exercise' }
|
|
512
|
+
],
|
|
513
|
+
columns: [
|
|
514
|
+
{ label: '周一', name: 'mon' },
|
|
515
|
+
{ label: '周二', name: 'tue' },
|
|
516
|
+
{ label: '周三', name: 'wed' }
|
|
517
|
+
]
|
|
518
|
+
}),
|
|
404
519
|
createBlock('steps', {
|
|
405
520
|
title: '入职补充信息',
|
|
406
521
|
autoStep: true,
|
|
@@ -475,14 +590,91 @@ const BaseExample = () => {
|
|
|
475
590
|
]
|
|
476
591
|
}));
|
|
477
592
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
593
|
+
const handleSchemaJson = () => {
|
|
594
|
+
const initialText = JSON.stringify(schema, null, 2);
|
|
595
|
+
schemaJsonTextRef.current = initialText;
|
|
596
|
+
setSchemaJsonInitial(initialText);
|
|
597
|
+
setSchemaJsonOpen(true);
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const handleCopySchemaJson = () => {
|
|
601
|
+
const text = schemaJsonTextRef.current;
|
|
602
|
+
if (navigator.clipboard?.writeText) {
|
|
603
|
+
navigator.clipboard.writeText(text).then(
|
|
604
|
+
() => message.success('已复制 Schema JSON'),
|
|
605
|
+
() => message.error('复制失败')
|
|
606
|
+
);
|
|
607
|
+
} else {
|
|
608
|
+
message.info(text);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
const handleApplySchemaJson = () => {
|
|
613
|
+
const text = schemaJsonTextRef.current;
|
|
614
|
+
if (!String(text || '').trim()) {
|
|
615
|
+
message.warning('请先编辑 Schema JSON');
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
setSchema(normalizeSchema(JSON.parse(text)));
|
|
620
|
+
message.success('已应用 Schema');
|
|
621
|
+
setSchemaJsonOpen(false);
|
|
622
|
+
} catch (e) {
|
|
623
|
+
message.error('JSON 无效,请检查后再试');
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
return (
|
|
628
|
+
<Space direction="vertical" size={16} style={{width: '100%'}}>
|
|
629
|
+
<Alert
|
|
630
|
+
type="info"
|
|
631
|
+
showIcon
|
|
632
|
+
message="Schema JSON"
|
|
633
|
+
description={
|
|
634
|
+
<span>
|
|
635
|
+
工具栏「Schema JSON」打开弹窗(远程 <Text code>components-thirdparty:JSONEditor.Field</Text>
|
|
636
|
+
):「复制」导出当前内容,「应用」把修改写回编辑器(经 <Text code>normalizeSchema</Text>)。
|
|
637
|
+
</span>
|
|
638
|
+
}
|
|
639
|
+
/>
|
|
640
|
+
<FormCreator
|
|
641
|
+
value={schema}
|
|
642
|
+
onChange={setSchema}
|
|
643
|
+
extraToolbar={
|
|
644
|
+
<Button size="small" onClick={handleSchemaJson}>
|
|
645
|
+
Schema JSON
|
|
646
|
+
</Button>
|
|
647
|
+
}
|
|
648
|
+
/>
|
|
649
|
+
<Modal
|
|
650
|
+
title="Schema JSON"
|
|
651
|
+
open={schemaJsonOpen}
|
|
652
|
+
onCancel={() => setSchemaJsonOpen(false)}
|
|
653
|
+
width={860}
|
|
654
|
+
destroyOnHidden
|
|
655
|
+
footer={
|
|
656
|
+
<Space>
|
|
657
|
+
<Button onClick={() => setSchemaJsonOpen(false)}>取消</Button>
|
|
658
|
+
<Button onClick={handleCopySchemaJson}>复制</Button>
|
|
659
|
+
<Button type="primary" onClick={handleApplySchemaJson}>
|
|
660
|
+
应用
|
|
661
|
+
</Button>
|
|
662
|
+
</Space>
|
|
663
|
+
}
|
|
664
|
+
>
|
|
665
|
+
{schemaJsonOpen ? (
|
|
666
|
+
<SchemaJsonEditor key={schemaJsonInitial} JSONEditorField={JSONEditorField} initialText={schemaJsonInitial} textRef={schemaJsonTextRef} />
|
|
667
|
+
) : null}
|
|
668
|
+
</Modal>
|
|
669
|
+
<div>
|
|
670
|
+
<JsonView data={schema} theme="light" collapsedFrom={2} searchable={false} />
|
|
671
|
+
<Text type="secondary">
|
|
672
|
+
初始示例已包含表单分组、列表、表格列表、行内编辑列表、列表嵌套、选项切换、多字段、分步、矩阵量表等模块。
|
|
673
|
+
</Text>
|
|
674
|
+
</div>
|
|
675
|
+
</Space>
|
|
676
|
+
);
|
|
677
|
+
});
|
|
486
678
|
|
|
487
679
|
render(<BaseExample />);
|
|
488
680
|
|
|
@@ -590,6 +782,118 @@ render(<SchemaRenderExample />);
|
|
|
590
782
|
|
|
591
783
|
```
|
|
592
784
|
|
|
785
|
+
- 步骤展示样式
|
|
786
|
+
- steps 模块的 stepsStyle:default 完整步骤条(默认),focus 突出当前步骤标题与分段进度
|
|
787
|
+
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],antd(antd)[import antd from "antd"]
|
|
788
|
+
|
|
789
|
+
```jsx
|
|
790
|
+
const { SchemaRenderer, createBlock, createField, createStep } = _FormCreator;
|
|
791
|
+
const { useMemo, useState } = React;
|
|
792
|
+
const { Alert, Flex, Segmented, Typography } = antd;
|
|
793
|
+
const { Text } = Typography;
|
|
794
|
+
|
|
795
|
+
const createOnboardingSteps = stepsStyle =>
|
|
796
|
+
createBlock('steps', {
|
|
797
|
+
title: '入职信息登记',
|
|
798
|
+
subtitle: '按步骤完成,每步校验通过后进入下一步',
|
|
799
|
+
stepsStyle,
|
|
800
|
+
items: [
|
|
801
|
+
createStep({
|
|
802
|
+
title: '个人信息',
|
|
803
|
+
column: 2,
|
|
804
|
+
list: [
|
|
805
|
+
createField({ type: 'Input', name: 'name', label: '姓名', rule: 'REQ', props: { placeholder: '请输入姓名' } }),
|
|
806
|
+
createField({ type: 'Input', name: 'mobile', label: '手机号', rule: 'REQ TEL', props: { placeholder: '请输入手机号' } }),
|
|
807
|
+
createField({ type: 'Input', name: 'email', label: '邮箱', rule: 'REQ EMAIL', props: { placeholder: 'name@company.com' } }),
|
|
808
|
+
createField({ type: 'DatePicker', name: 'birthday', label: '出生日期', props: { placeholder: '请选择日期' } })
|
|
809
|
+
]
|
|
810
|
+
}),
|
|
811
|
+
createStep({
|
|
812
|
+
title: '岗位与入职安排(含所属部门、岗位名称与入职日期确认,请与 HR 沟通后填写)',
|
|
813
|
+
column: 2,
|
|
814
|
+
list: [
|
|
815
|
+
createField({
|
|
816
|
+
type: 'Select',
|
|
817
|
+
name: 'department',
|
|
818
|
+
label: '所属部门',
|
|
819
|
+
rule: 'REQ',
|
|
820
|
+
props: {
|
|
821
|
+
placeholder: '请选择部门',
|
|
822
|
+
options: [
|
|
823
|
+
{ label: '产品研发中心', value: 'rd' },
|
|
824
|
+
{ label: '市场营销部', value: 'marketing' },
|
|
825
|
+
{ label: '人力资源部', value: 'hr' }
|
|
826
|
+
]
|
|
827
|
+
}
|
|
828
|
+
}),
|
|
829
|
+
createField({ type: 'Input', name: 'position', label: '岗位名称', rule: 'REQ', props: { placeholder: '例如:高级前端工程师' } }),
|
|
830
|
+
createField({ type: 'DatePicker', name: 'joinDate', label: '入职日期', rule: 'REQ', props: { placeholder: '请选择日期' } })
|
|
831
|
+
]
|
|
832
|
+
}),
|
|
833
|
+
createStep({
|
|
834
|
+
title: '紧急联系人',
|
|
835
|
+
column: 2,
|
|
836
|
+
list: [
|
|
837
|
+
createField({ type: 'Input', name: 'contactName', label: '联系人姓名', rule: 'REQ', props: { placeholder: '请输入姓名' } }),
|
|
838
|
+
createField({ type: 'Input', name: 'contactMobile', label: '联系人电话', rule: 'REQ TEL', props: { placeholder: '请输入手机号' } })
|
|
839
|
+
]
|
|
840
|
+
}),
|
|
841
|
+
createStep({
|
|
842
|
+
title: '银行卡与薪资账户',
|
|
843
|
+
column: 2,
|
|
844
|
+
list: [
|
|
845
|
+
createField({ type: 'Input', name: 'bankName', label: '开户银行', rule: 'REQ', props: { placeholder: '例如:招商银行上海分行' } }),
|
|
846
|
+
createField({ type: 'Input', name: 'bankAccount', label: '银行卡号', rule: 'REQ', props: { placeholder: '请输入银行卡号' } })
|
|
847
|
+
]
|
|
848
|
+
}),
|
|
849
|
+
createStep({
|
|
850
|
+
title: '其他说明',
|
|
851
|
+
column: 1,
|
|
852
|
+
list: [createField({ type: 'TextArea', name: 'remark', label: '备注', block: true, props: { rows: 3, placeholder: '如有特殊情况请说明' } })]
|
|
853
|
+
})
|
|
854
|
+
]
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
const StepsStyleExample = () => {
|
|
858
|
+
const [stepsStyle, setStepsStyle] = useState('focus');
|
|
859
|
+
const schema = useMemo(
|
|
860
|
+
() => ({
|
|
861
|
+
actions: { showSubmit: true, showReset: true, submitText: '提交登记' },
|
|
862
|
+
blocks: [createOnboardingSteps(stepsStyle)]
|
|
863
|
+
}),
|
|
864
|
+
[stepsStyle]
|
|
865
|
+
);
|
|
866
|
+
|
|
867
|
+
return (
|
|
868
|
+
<Flex vertical gap={16}>
|
|
869
|
+
<Alert
|
|
870
|
+
type="info"
|
|
871
|
+
showIcon
|
|
872
|
+
message="步骤展示样式"
|
|
873
|
+
description={
|
|
874
|
+
<span>
|
|
875
|
+
steps 模块通过 <Text code>stepsStyle</Text> 切换导航样式:<Text code>default</Text>(默认)为完整步骤条;
|
|
876
|
+
<Text code>focus</Text> 突出当前步骤标题(长标题自动换行)与分段进度,已完成的进度段可点击回退,适合步骤多、标题长或窄屏场景。编辑器中可在「编辑模块」里配置。
|
|
877
|
+
</span>
|
|
878
|
+
}
|
|
879
|
+
/>
|
|
880
|
+
<Segmented
|
|
881
|
+
value={stepsStyle}
|
|
882
|
+
onChange={setStepsStyle}
|
|
883
|
+
options={[
|
|
884
|
+
{ label: '聚焦当前步骤(focus)', value: 'focus' },
|
|
885
|
+
{ label: '完整步骤条(default)', value: 'default' }
|
|
886
|
+
]}
|
|
887
|
+
/>
|
|
888
|
+
<SchemaRenderer key={stepsStyle} schema={schema} />
|
|
889
|
+
</Flex>
|
|
890
|
+
);
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
render(<StepsStyleExample />);
|
|
894
|
+
|
|
895
|
+
```
|
|
896
|
+
|
|
593
897
|
- 列表嵌套与选项切换
|
|
594
898
|
- 列表每一条里可再放分组或子列表;选项切换支持单选/多选,每个选项可添加填写项
|
|
595
899
|
- _FormCreator(@kne/current-lib_form-creator)[import * as _FormCreator from "@kne/form-creator"],(@kne/current-lib_form-creator/dist/index.css)[import "@kne/form-creator/dist/index.css"],_JsonView(@kne/json-view)[import * as _JsonView from "@kne/json-view"],(@kne/json-view/dist/index.css)[import "@kne/json-view/dist/index.css"],antd(antd)[import antd from "antd"]
|
|
@@ -2066,14 +2370,16 @@ import { SchemaContent, SchemaContentInner } from '@kne/form-creator';
|
|
|
2066
2370
|
},
|
|
2067
2371
|
blocks: [{
|
|
2068
2372
|
id: string,
|
|
2069
|
-
kind: 'formInfo' | 'list' | 'tableList' | 'editableList' | 'multiField' | 'object' | 'choice' | 'steps',
|
|
2373
|
+
kind: 'formInfo' | 'list' | 'tableList' | 'editableList' | 'multiField' | 'matrixScale' | 'object' | 'choice' | 'steps',
|
|
2070
2374
|
title?, subtitle?, column?, gap?, bordered?, important?,
|
|
2071
2375
|
name?, label?, addText?, addPosition?, maxLength?, minLength?, fieldType?, autoStep?,
|
|
2376
|
+
layout?, rowTitle?, rule?, rows?, columns?, // matrixScale
|
|
2072
2377
|
mode?, selectorName?, selectorInData?, discriminator?,
|
|
2378
|
+
stepsStyle?: 'default' | 'focus', // steps 导航样式,默认 default
|
|
2073
2379
|
list?: [{ id, type, name, label, tips?, description?, rule?, block?, hidden?, locked?, visibleWhen?, props? }],
|
|
2074
2380
|
itemBlocks?: Block[], // list / editableList:列表项内子模块
|
|
2075
2381
|
blocks?: Block[], // formInfo / object:子模块
|
|
2076
|
-
options?: [{ id, title, list?, blocks?: Block[] }], // choice
|
|
2382
|
+
options?: [{ id, title, list?, blocks?: Block[] }] | [{ label, value }], // choice 选项 或 matrixScale 量表选项
|
|
2077
2383
|
items?: [{ id, title, column, list: [...], blocks?: Block[] }] // steps 专用
|
|
2078
2384
|
}]
|
|
2079
2385
|
}
|
|
@@ -2112,7 +2418,7 @@ import { SchemaContent, SchemaContentInner } from '@kne/form-creator';
|
|
|
2112
2418
|
|
|
2113
2419
|
- `field` 为提交数据中的路径,object 模块内字段带前缀,如 `contact.phone`
|
|
2114
2420
|
- 不满足条件的字段不渲染、不参与校验,已填的值会被清空;`SchemaContent` 按数据同样隐藏
|
|
2115
|
-
- 列表类模块(list / tableList / editableList / multiField)内的字段既不能配置条件,也不能作为触发字段
|
|
2421
|
+
- 列表类模块(list / tableList / editableList / multiField / matrixScale)内的字段既不能配置条件,也不能作为触发字段
|
|
2116
2422
|
- 条件引用的字段不存在、位于列表类模块内或正则无效时,该条件被忽略(编辑器显示「条件失效」);全部条件失效时字段照常显示
|
|
2117
2423
|
- 编辑器会拦截循环依赖;触发字段改名时自动同步引用
|
|
2118
2424
|
- `schemaToDataSchema` 中条件字段不进入 `required`,并在 `description` 中附加条件说明
|
|
@@ -2126,7 +2432,7 @@ Schema 内的展示文案既可以是字符串,也可以是按语言区分的
|
|
|
2126
2432
|
| 支持多语言的位置 | 说明 |
|
|
2127
2433
|
|------|------|
|
|
2128
2434
|
| 字段 | label、tips、description、props.placeholder、props.options[].label / description、Switch 的 checkedChildren / unCheckedChildren |
|
|
2129
|
-
| 模块 | title、subtitle、label、addText;tableList 列 title;choice 选项 title;steps 步骤 title |
|
|
2435
|
+
| 模块 | title、subtitle、label、addText;tableList 列 title;choice 选项 title;steps 步骤 title;matrixScale 的 rowTitle、rows[].label、options[].label、columns[].label |
|
|
2130
2436
|
| actions | submitText、resetText、cancelText |
|
|
2131
2437
|
|
|
2132
2438
|
支持哪些语言由调用方通过 `languages` 决定,组件不内置语言列表:
|
|
@@ -2168,7 +2474,8 @@ FormCreator 不传 `languages` 时为单语言输入(与改造前一致,存
|
|
|
2168
2474
|
| object | 对象分组 | name, title, column, gap, bordered, list(字段名渲染为 `name.field`), **blocks** |
|
|
2169
2475
|
| choice | 选项分支 | title, **mode**(`single`\|`multiple`), **minLength** / **maxLength**(仅多选:最少/最多选几项), selectorName, selectorInData, options[{ title, list, **blocks** }] |
|
|
2170
2476
|
| multiField | 同类型多值 | name, label, fieldType, addText(不支持子模块) |
|
|
2171
|
-
|
|
|
2477
|
+
| matrixScale | 矩阵量表(`@kne/form-info` MatrixScale):每行共用同一 `fieldType` | name, title, **rowTitle**, **layout**(`options` 选项矩阵 \| `columns` 单元格矩阵 \| `field` 每行一个字段), fieldType(默认 RadioGroup), rule(如 `REQ`), **rows**`[{ label, name }]`, **options**(layout=options), **columns**`[{ label, name }]`(layout=columns);不支持子模块 |
|
|
2478
|
+
| steps | 步骤表单 | title, subtitle, bordered, autoStep, stepsStyle(`default` 完整步骤条 / `focus` 突出当前步骤标题与分段进度), items[{ title, column, list, **blocks** }] |
|
|
2172
2479
|
|
|
2173
2480
|
`choice`:顶部同一条选项 UI;`single` 只挂载当前选项内容,`multiple` 平铺所有选中项。多选时可配置 `minLength` / `maxLength` 限制最少、最多选择几个(提交时校验;达到上限后未选项禁用)。JSON Schema 的 oneOf/anyOf 可分别映射为 `mode: 'single'/'multiple'`。`allOf` 无需独立 kind,展开为多个 sibling blocks 即可。
|
|
2174
2481
|
|
|
@@ -2177,7 +2484,20 @@ FormCreator 不传 `languages` 时为单语言输入(与改造前一致,存
|
|
|
2177
2484
|
#### 字段类型
|
|
2178
2485
|
|
|
2179
2486
|
基础:Input、TextArea、InputNumber、Switch、Checkbox、DatePicker
|
|
2180
|
-
选择:Select、RadioGroup、CheckboxGroup、SuperSelect、SuperSelectPlus
|
|
2487
|
+
选择:Select、RadioGroup、CheckboxGroup、RadioGroupOther、CheckboxGroupOther、SuperSelect、SuperSelectPlus
|
|
2488
|
+
|
|
2489
|
+
`RadioGroup` / `CheckboxGroup` / `RadioGroupOther` / `CheckboxGroupOther` 的 `props` 额外支持(透传 `@kne/react-form-antd@>=4.1.14`):
|
|
2490
|
+
|
|
2491
|
+
| 属性 | 类型 | 说明 |
|
|
2492
|
+
|------|------|------|
|
|
2493
|
+
| inline | boolean | 编辑器侧「横向排列」;渲染时若未开 `block` 且 `inline=false`,沿用纵向兜底 |
|
|
2494
|
+
| modern | boolean | 新版序号色块样式 |
|
|
2495
|
+
| block | boolean | 块级纵向占满选项 |
|
|
2496
|
+
| indexType | `'letter'\|'number'\|'check'` | 仅 `modern` 时生效;默认字母 |
|
|
2497
|
+
| otherOption | `{ label?, value? }` | 仅 Other:自定义「其他」选项文案/值(默认 value=`other`) |
|
|
2498
|
+
| otherProps | object | 仅 Other:选中「其他」后 TextArea 的 props(如 `placeholder`) |
|
|
2499
|
+
|
|
2500
|
+
Other 字段提交值为 `{ value, other? }`(单选 `value` 为字符串,多选为数组)。
|
|
2181
2501
|
|
|
2182
2502
|
#### 工具方法
|
|
2183
2503
|
|
|
@@ -2204,6 +2524,7 @@ const dataSchema = schemaToDataSchema(schema);
|
|
|
2204
2524
|
| object | `properties[name]` = nested object(字段名为相对 name) |
|
|
2205
2525
|
| list / tableList / editableList | `properties[name]` = array of object |
|
|
2206
2526
|
| multiField | `properties[name]` = array,元素为 `fieldType` 的 valueSchema |
|
|
2527
|
+
| matrixScale | `properties[name]` = object:options/field 时每行一个属性;columns 时每行嵌套 object(列为格子) |
|
|
2207
2528
|
| steps | 各 step 字段/子块并入当前层 |
|
|
2208
2529
|
| choice(single) | `oneOf`:每支含 selector `const` + 该 option 字段 |
|
|
2209
2530
|
| choice(multiple) | 当前层 selector 为数组 + `anyOf` 各 option 字段支 |
|