@wordpress/edit-post
Version:
Edit Post module for WordPress.
8 lines (7 loc) • 2.62 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/preferences-modal/meta-boxes-section.jsx"],
"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,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,eAAe,8BAA8B;AACtD,OAAO,8BAA8B;AACrC,OAAO,uBAAuB;AAC9B,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AA0BrB,SAEE,KAFF;AAxBF,IAAM,EAAE,wBAAwB,IAAI,OAAQ,sBAAuB;AAE5D,SAAS,iBAAkB,cAAe;AAChD,QAAM,EAAE,2BAA2B,UAAU,IAAI,UAAW,CAAE,WAAY;AACzE,UAAM,EAAE,kBAAkB,IAAI,OAAQ,WAAY;AAClD,UAAM,EAAE,gBAAgB,IAAI,OAAQ,aAAc;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,qBAAC,2BAA0B,GAAG,cAC3B;AAAA,iCACD,oBAAC,4BAAyB,OAAQ,GAAI,eAAgB,GAAI;AAAA,IAEzD,oBAAoB,IAAK,CAAE,EAAE,IAAI,MAAM,MACxC;AAAA,MAAC;AAAA;AAAA,QAEA,OAAQ;AAAA,QACR,WAAY,YAAa,EAAG;AAAA;AAAA,MAFtB;AAAA,IAGP,CACC;AAAA,KACH;AAEF;",
"names": []
}