UNPKG

@wordpress/edit-post

Version:
8 lines (7 loc) 2.76 kB
{ "version": 3, "sources": ["../../../src/components/preferences-modal/meta-boxes-section.js"], "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { privateApis as preferencesPrivateApis } from '@wordpress/preferences';\nimport EnableCustomFieldsOption from './enable-custom-fields';\nimport EnablePanelOption from './enable-panel';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { PreferencesModalSection } = unlock( preferencesPrivateApis );\n\nexport function MetaBoxesSection( sectionProps ) {\n\tconst { areCustomFieldsRegistered, metaBoxes } = useSelect( ( select ) => {\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getAllMetaBoxes } = select( editPostStore );\n\n\t\treturn {\n\t\t\tareCustomFieldsRegistered:\n\t\t\t\tgetEditorSettings().enableCustomFields !== undefined,\n\t\t\tmetaBoxes: getAllMetaBoxes(),\n\t\t};\n\t}, [] );\n\n\t// The 'Custom Fields' meta box is a special case that we handle separately.\n\tconst thirdPartyMetaBoxes = metaBoxes.filter(\n\t\t( { id } ) => id !== 'postcustom'\n\t);\n\n\tif ( ! areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PreferencesModalSection { ...sectionProps }>\n\t\t\t{ areCustomFieldsRegistered && (\n\t\t\t\t<EnableCustomFieldsOption label={ __( 'Custom fields' ) } />\n\t\t\t) }\n\t\t\t{ thirdPartyMetaBoxes.map( ( { id, title } ) => (\n\t\t\t\t<EnablePanelOption\n\t\t\t\t\tkey={ id }\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tpanelName={ `meta-box-${ id }` }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</PreferencesModalSection>\n\t);\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,kBAA0B;AAC1B,oBAAqC;AACrC,yBAAsD;AACtD,kCAAqC;AACrC,0BAA8B;AAC9B,mBAAuC;AACvC,yBAAuB;AA0BrB;AAxBF,IAAM,EAAE,wBAAwB,QAAI,2BAAQ,mBAAAA,WAAuB;AAE5D,SAAS,iBAAkB,cAAe;AAChD,QAAM,EAAE,2BAA2B,UAAU,QAAI,uBAAW,CAAE,WAAY;AACzE,UAAM,EAAE,kBAAkB,IAAI,OAAQ,cAAAC,KAAY;AAClD,UAAM,EAAE,gBAAgB,IAAI,OAAQ,aAAAC,KAAc;AAElD,WAAO;AAAA,MACN,2BACC,kBAAkB,EAAE,uBAAuB;AAAA,MAC5C,WAAW,gBAAgB;AAAA,IAC5B;AAAA,EACD,GAAG,CAAC,CAAE;AAGN,QAAM,sBAAsB,UAAU;AAAA,IACrC,CAAE,EAAE,GAAG,MAAO,OAAO;AAAA,EACtB;AAEA,MAAK,CAAE,6BAA6B,oBAAoB,WAAW,GAAI;AACtE,WAAO;AAAA,EACR;AAEA,SACC,6CAAC,2BAA0B,GAAG,cAC3B;AAAA,iCACD,4CAAC,4BAAAC,SAAA,EAAyB,WAAQ,gBAAI,eAAgB,GAAI;AAAA,IAEzD,oBAAoB,IAAK,CAAE,EAAE,IAAI,MAAM,MACxC;AAAA,MAAC,oBAAAC;AAAA,MAAA;AAAA,QAEA,OAAQ;AAAA,QACR,WAAY,YAAa,EAAG;AAAA;AAAA,MAFtB;AAAA,IAGP,CACC;AAAA,KACH;AAEF;", "names": ["preferencesPrivateApis", "editorStore", "editPostStore", "EnableCustomFieldsOption", "EnablePanelOption"] }