Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 27x 27x 27x | import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import { Form } from 'react-final-form';
import { FieldArray } from 'react-final-form-arrays';
import arrayMutators from 'final-form-arrays';
import ActionListFieldArray from './ActionListFieldArray';
const propTypes = {
actionAssigner: PropTypes.func,
columnMapping: PropTypes.object,
contentData: PropTypes.arrayOf(PropTypes.object),
creatableFields: PropTypes.object,
createCallback: PropTypes.func,
defaultNewObject: PropTypes.object,
editableFields: PropTypes.object,
fieldComponents: PropTypes.object,
hideActionsColumn: PropTypes.bool,
hideCreateButton: PropTypes.bool,
intlKey: PropTypes.string,
intlNS: PropTypes.string,
label: PropTypes.oneOfType([
PropTypes.string,
PropTypes.node
]),
labelOverrides: PropTypes.object,
validateFields: PropTypes.object,
visibleFields: PropTypes.arrayOf(PropTypes.string)
};
const ActionList = forwardRef(({
actionAssigner,
columnMapping,
contentData,
creatableFields = {},
createCallback,
defaultNewObject = {},
editableFields = {},
fieldComponents = {},
hideActionsColumn = false,
hideCreateButton,
intlKey: passedIntlKey,
intlNS: passedIntlNS,
label,
labelOverrides = {},
validateFields,
visibleFields,
...mclProps // Assume anything left over is to directly apply to the MCL
}, ref) => {
const ActionListFieldArrayWithRef = (alfaProps) => (
<ActionListFieldArray ref={ref} {...alfaProps} />
);
return (
<>
<Form
enableReinitialize
initialValues={{ contentData }}
mutators={arrayMutators}
onSubmit={() => null}
subscription={{ contentData: true }}
>
{({ handleSubmit }) => (
<form onSubmit={e => { e.preventDefault(); }}>
<FieldArray
actionAssigner={actionAssigner}
columnMapping={columnMapping}
component={ActionListFieldArrayWithRef}
creatableFields={creatableFields}
createCallback={createCallback}
defaultNewObject={defaultNewObject}
editableFields={editableFields}
fieldComponents={fieldComponents}
hideActionsColumn={hideActionsColumn}
hideCreateButton={hideCreateButton}
intlKey={passedIntlKey}
intlNS={passedIntlNS}
label={label}
labelOverrides={labelOverrides}
name="contentData"
triggerFormSubmit={handleSubmit}
validateFields={validateFields}
visibleFields={visibleFields}
{...mclProps}
/>
</form>
)}
</Form>
</>
);
});
ActionList.propTypes = propTypes;
export default ActionList;
|