index.js
42 lines
| 1 | import Edit from './edit'; |
| 2 | import metadata from '../../../../block.json'; |
| 3 | import './style.scss'; |
| 4 | |
| 5 | const { name, icon = '' } = metadata; |
| 6 | |
| 7 | export { name }; |
| 8 | export { metadata }; |
| 9 | |
| 10 | export const settings = { |
| 11 | icon: <span dangerouslySetInnerHTML={ { __html: icon } }></span>, |
| 12 | description: 'Add an international phone number input field with country flags, dial codes, and validation.', |
| 13 | edit: Edit, |
| 14 | jfbResolveBlock() { |
| 15 | const base = { |
| 16 | clientId: this.clientId, |
| 17 | name: this.name, |
| 18 | }; |
| 19 | |
| 20 | if ( ! this.attributes.name ) { |
| 21 | return base; |
| 22 | } |
| 23 | |
| 24 | return { |
| 25 | ...base, |
| 26 | fields: [ |
| 27 | { |
| 28 | value: this.attributes.name, |
| 29 | name: this.attributes.name, |
| 30 | label: this.attributes.label || this.attributes.name, |
| 31 | }, |
| 32 | ], |
| 33 | }; |
| 34 | }, |
| 35 | useEditProps: [ 'uniqKey', 'attrHelp' ], |
| 36 | example: { |
| 37 | attributes: { |
| 38 | isPreview: true, |
| 39 | }, |
| 40 | }, |
| 41 | }; |
| 42 |