ActionFieldsMap.js
2 years ago
DynamicPropertySelect.js
2 years ago
WrapperRequiredControl.js
2 years ago
ActionFieldsMap.js
47 lines
| 1 | import ActionFieldsMapContext from '../context/ActionFieldsMapContext'; |
| 2 | |
| 3 | const { |
| 4 | BaseControl, |
| 5 | } = wp.components; |
| 6 | |
| 7 | function ActionFieldsMap( { |
| 8 | fields = [], |
| 9 | label = '[Empty label]', |
| 10 | children = null, |
| 11 | plainHelp = '', |
| 12 | customHelp = false, |
| 13 | } ) { |
| 14 | |
| 15 | return <BaseControl |
| 16 | label={ label } |
| 17 | key="jet_fields_map" |
| 18 | > |
| 19 | <div className="jet-user-fields-map__list"> |
| 20 | { ( |
| 21 | customHelp && 'function' === typeof customHelp |
| 22 | ) && customHelp() } |
| 23 | |
| 24 | { Boolean( plainHelp.length ) && <span |
| 25 | className={ 'description-controls' } |
| 26 | >{ plainHelp }</span> } |
| 27 | |
| 28 | { fields.map( ( [ fieldId, fieldData ], index ) => <React.Fragment |
| 29 | key={ `field_in_map_${ fieldId + index }` } |
| 30 | > |
| 31 | <ActionFieldsMapContext.Provider value={ { |
| 32 | name: fieldId, |
| 33 | data: fieldData, |
| 34 | index, |
| 35 | } }> |
| 36 | { 'function' === typeof children |
| 37 | ? children( { fieldId, fieldData, index } ) |
| 38 | : children } |
| 39 | </ActionFieldsMapContext.Provider> |
| 40 | </React.Fragment> ) } |
| 41 | </div> |
| 42 | </BaseControl>; |
| 43 | } |
| 44 | |
| 45 | export default ActionFieldsMap; |
| 46 | |
| 47 |