UNPKG

@wordpress/editor

Version:
8 lines (7 loc) 2.57 kB
{ "version": 3, "sources": ["../../../src/components/post-comments/index.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tRadioControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst COMMENT_OPTIONS = [\n\t{\n\t\tlabel: _x( 'Open', 'Adjective: e.g. \"Comments are open\"' ),\n\t\tvalue: 'open',\n\t\tdescription: __( 'Visitors can add new comments and replies.' ),\n\t},\n\t{\n\t\tlabel: __( 'Closed' ),\n\t\tvalue: 'closed',\n\t\tdescription: [\n\t\t\t__( 'Visitors cannot add new comments or replies.' ),\n\t\t\t__( 'Existing comments remain visible.' ),\n\t\t].join( ' ' ),\n\t},\n];\n\nfunction PostComments() {\n\tconst commentStatus = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'comment_status' ) ??\n\t\t\t'open',\n\t\t[]\n\t);\n\tconst { editPost } = useDispatch( editorStore );\n\tconst handleStatus = ( newCommentStatus ) =>\n\t\teditPost( {\n\t\t\tcomment_status: newCommentStatus,\n\t\t} );\n\n\treturn (\n\t\t<form>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Comment status' ) }\n\t\t\t\t\toptions={ COMMENT_OPTIONS }\n\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\tselected={ commentStatus }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\n/**\n * A form for managing comment status.\n *\n * @return {React.ReactNode} The rendered PostComments component.\n */\nexport default PostComments;\n"], "mappings": ";AAGA,SAAS,IAAI,UAAU;AACvB;AAAA,EACC;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,aAAa,iBAAiB;AAKvC,SAAS,SAAS,mBAAmB;AAkCjC;AAhCJ,IAAM,kBAAkB;AAAA,EACvB;AAAA,IACC,OAAO,GAAI,QAAQ,qCAAsC;AAAA,IACzD,OAAO;AAAA,IACP,aAAa,GAAI,4CAA6C;AAAA,EAC/D;AAAA,EACA;AAAA,IACC,OAAO,GAAI,QAAS;AAAA,IACpB,OAAO;AAAA,IACP,aAAa;AAAA,MACZ,GAAI,8CAA+C;AAAA,MACnD,GAAI,mCAAoC;AAAA,IACzC,EAAE,KAAM,GAAI;AAAA,EACb;AACD;AAEA,SAAS,eAAe;AACvB,QAAM,gBAAgB;AAAA,IACrB,CAAE,WACD,OAAQ,WAAY,EAAE,uBAAwB,gBAAiB,KAC/D;AAAA,IACD,CAAC;AAAA,EACF;AACA,QAAM,EAAE,SAAS,IAAI,YAAa,WAAY;AAC9C,QAAM,eAAe,CAAE,qBACtB,SAAU;AAAA,IACT,gBAAgB;AAAA,EACjB,CAAE;AAEH,SACC,oBAAC,UACA,8BAAC,UAAO,SAAU,GACjB;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,qBAAmB;AAAA,MACnB,OAAQ,GAAI,gBAAiB;AAAA,MAC7B,SAAU;AAAA,MACV,UAAW;AAAA,MACX,UAAW;AAAA;AAAA,EACZ,GACD,GACD;AAEF;AAOA,IAAO,wBAAQ;", "names": [] }