@hzab/form-render 1.7.10 → 1.7.12
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/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/components/ArrayBase/index.tsx +5 -3
- package/src/components/ArrayTable/index.tsx +7 -4
- package/src/index.tsx +1 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -147,6 +147,7 @@ import FormRender from "@hzab/form-render";
|
|
|
147
147
|
| initialValues | Object | 否 | - | form 初始值 |
|
|
148
148
|
| components | Object | 否 | - | 自定义组件 |
|
|
149
149
|
| formOptions | Object | 否 | - | createForm 的参数 |
|
|
150
|
+
| emptyValue | string | 否 | N/A | 只读模式 PreviewText emptyValue 配置 |
|
|
150
151
|
| disabled | boolean | 否 | - | 禁用状态 |
|
|
151
152
|
| readOnly | boolean | 否 | - | 只读状态 |
|
|
152
153
|
| onFormValuesChange | Function | 否 | - | 表单事件 (form)=>{} https://core.formilyjs.org/zh-CN/api/entry/form-effect-hooks |
|
package/package.json
CHANGED
|
@@ -52,6 +52,8 @@ export interface IArrayBaseProps {
|
|
|
52
52
|
onRemove?: (index: number) => void;
|
|
53
53
|
onMoveDown?: (index: number) => void;
|
|
54
54
|
onMoveUp?: (index: number) => void;
|
|
55
|
+
onSortStart?: (e) => void;
|
|
56
|
+
onSortEnd?: (e) => void;
|
|
55
57
|
deletePopconfirmTitle?: () => ReactNode;
|
|
56
58
|
deletePopconfirm?: boolean;
|
|
57
59
|
}
|
|
@@ -68,16 +70,16 @@ const ItemContext = createContext<IArrayBaseItemProps>(null);
|
|
|
68
70
|
|
|
69
71
|
const takeRecord = (val: any, index?: number) => (typeof val === "function" ? val(index) : val);
|
|
70
72
|
|
|
71
|
-
const useArray = () => {
|
|
73
|
+
export const useArray = () => {
|
|
72
74
|
return useContext(ArrayBaseContext);
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
const useIndex = (index?: number) => {
|
|
77
|
+
export const useIndex = (index?: number) => {
|
|
76
78
|
const ctx = useContext(ItemContext);
|
|
77
79
|
return ctx ? ctx.index : index;
|
|
78
80
|
};
|
|
79
81
|
|
|
80
|
-
const useRecord = (record?: number) => {
|
|
82
|
+
export const useRecord = (record?: number) => {
|
|
81
83
|
const ctx = useContext(ItemContext);
|
|
82
84
|
return takeRecord(ctx ? ctx.record : record, ctx?.index);
|
|
83
85
|
};
|
|
@@ -313,10 +313,10 @@ export const ArrayTable: ComposedArrayTable = observer((props) => {
|
|
|
313
313
|
});
|
|
314
314
|
};
|
|
315
315
|
const getWrapperComp = useCallback(
|
|
316
|
-
(dataSource: any[], start: number) => (
|
|
316
|
+
(dataSource: any[], start: number) => (wrapperProps: any) =>
|
|
317
317
|
(
|
|
318
318
|
<SortableBody
|
|
319
|
-
{...
|
|
319
|
+
{...wrapperProps}
|
|
320
320
|
start={start}
|
|
321
321
|
list={dataSource.slice()}
|
|
322
322
|
accessibility={{
|
|
@@ -324,11 +324,14 @@ export const ArrayTable: ComposedArrayTable = observer((props) => {
|
|
|
324
324
|
}}
|
|
325
325
|
onSortStart={(event) => {
|
|
326
326
|
addTdStyles(event.active.id as number);
|
|
327
|
+
props.onSortStart && props.onSortStart(event);
|
|
327
328
|
}}
|
|
328
|
-
onSortEnd={(
|
|
329
|
+
onSortEnd={(params) => {
|
|
330
|
+
const { oldIndex, newIndex } = params;
|
|
329
331
|
field.move(oldIndex, newIndex);
|
|
332
|
+
props.onSortEnd && props.onSortEnd(params);
|
|
330
333
|
}}
|
|
331
|
-
className={cls(`${prefixCls}-sort-helper`,
|
|
334
|
+
className={cls(`${prefixCls}-sort-helper`, wrapperProps.className)}
|
|
332
335
|
/>
|
|
333
336
|
),
|
|
334
337
|
[field],
|
package/src/index.tsx
CHANGED
|
@@ -179,6 +179,7 @@ const FormRender = forwardRef((props: any, parentRef) => {
|
|
|
179
179
|
wrapperCol={props.schema.form.wrapperCol}
|
|
180
180
|
onAutoSubmit={autoSubmit}
|
|
181
181
|
onAutoSubmitFailed={autoSubmitFailed}
|
|
182
|
+
previewTextPlaceholder={props?.emptyValue}
|
|
182
183
|
>
|
|
183
184
|
<FormLayout {...formLayoutProps}>
|
|
184
185
|
<SchemaField schema={schema}></SchemaField>
|