@hzab/form-render 1.7.11 → 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
CHANGED
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,13 +179,12 @@ 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
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</FormLayout>
|
|
188
|
-
</PreviewText.Placeholder>
|
|
184
|
+
<FormLayout {...formLayoutProps}>
|
|
185
|
+
<SchemaField schema={schema}></SchemaField>
|
|
186
|
+
<div className="form-render-footer xxm">{footer}</div>
|
|
187
|
+
</FormLayout>
|
|
189
188
|
</Form>
|
|
190
189
|
</GlobalPropsContext.Provider>
|
|
191
190
|
);
|