RepeaterWithState.js
3 years ago
repeater.add.new.js
3 years ago
repeater.add.or.js
3 years ago
repeater.js
3 years ago
repeater.state.js
3 years ago
safe.delete.toggle.js
3 years ago
repeater.add.or.js
34 lines
| 1 | import useRepeaterState from '../../hooks/useRepeaterState'; |
| 2 | import RepeaterStateContext from '../context/repeater.state'; |
| 3 | |
| 4 | const { |
| 5 | Button, |
| 6 | } = wp.components; |
| 7 | const { |
| 8 | useContext, |
| 9 | } = wp.element; |
| 10 | |
| 11 | function RepeaterAddOrOperator( props ) { |
| 12 | const { |
| 13 | onSetState, |
| 14 | functions, |
| 15 | children, |
| 16 | } = props; |
| 17 | |
| 18 | const { addNewItem } = functions |
| 19 | ?? useRepeaterState( onSetState ) |
| 20 | ?? useContext( RepeaterStateContext ); |
| 21 | |
| 22 | return <Button |
| 23 | isSecondary |
| 24 | icon={ 'randomize' } |
| 25 | onClick={ () => addNewItem( { |
| 26 | __visible: false, |
| 27 | or_operator: true, |
| 28 | } ) } |
| 29 | > |
| 30 | { children } |
| 31 | </Button>; |
| 32 | } |
| 33 | |
| 34 | export default RepeaterAddOrOperator; |