jetformbuilder
/
assets
/
src
/
package
/
block-conditions
/
components
/
ConditionsRepeaterContextProvider.js
BeforeConditionOptions.js
2 years ago
ConditionItem.js
2 years ago
ConditionOptions.js
2 years ago
ConditionsRepeaterContextProvider.js
2 years ago
EditCustomRenderStates.js
2 years ago
HumanReadableConditions.js
2 years ago
RenderStateOptions.js
2 years ago
ConditionsRepeaterContextProvider.js
35 lines
| 1 | import RepeaterHeadContext |
| 2 | from '../../repeater/context/repeater.custom.item.head'; |
| 3 | import RepeaterButtonsContext |
| 4 | from '../../repeater/context/repeater.custom.item.buttons'; |
| 5 | import humanReadableCondition from '../helpers/humanReadableCondition'; |
| 6 | |
| 7 | const { |
| 8 | __, |
| 9 | } = wp.i18n; |
| 10 | |
| 11 | function ConditionsRepeaterContextProvider( { children } ) { |
| 12 | return <RepeaterHeadContext.Provider |
| 13 | value={ { |
| 14 | isSupported: () => true, |
| 15 | render: ( { currentItem } ) => <span |
| 16 | className={ 'repeater-item-title' } |
| 17 | dangerouslySetInnerHTML={ { |
| 18 | __html: currentItem?.or_operator |
| 19 | ? __( 'OR', 'jet-form-builder' ) |
| 20 | : humanReadableCondition( currentItem ), |
| 21 | } } |
| 22 | />, |
| 23 | } } |
| 24 | > |
| 25 | <RepeaterButtonsContext.Provider |
| 26 | value={ { |
| 27 | edit: item => !item.or_operator, |
| 28 | } } |
| 29 | > |
| 30 | { children } |
| 31 | </RepeaterButtonsContext.Provider> |
| 32 | </RepeaterHeadContext.Provider>; |
| 33 | } |
| 34 | |
| 35 | export default ConditionsRepeaterContextProvider; |