UNPKG

3.43 kBSource Map (JSON)View Raw
1{"version":3,"sources":["@wordpress/block-library/src/calendar/edit.js"],"names":["moment","memoize","Disabled","ServerSideRender","Component","withSelect","CalendarEdit","arguments","getYearMonth","bind","maxSize","getServerSideAttributes","date","momentDate","year","month","attributes","props","select","getEditedPostAttribute","postType","undefined"],"mappings":";;;;;;;;;AAAA;;;AAGA,OAAOA,MAAP,MAAmB,QAAnB;AACA,OAAOC,OAAP,MAAoB,QAApB;AAEA;;;;AAGA,SACCC,QADD,EAECC,gBAFD,QAGO,uBAHP;AAIA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,UAAT,QAA2B,iBAA3B;;IAEMC,Y;;;;;AACL,0BAAc;AAAA;;AAAA;;AACb,uFAAUC,SAAV;AACA,UAAKC,YAAL,GAAoBP,OAAO,CAC1B,MAAKO,YAAL,CAAkBC,IAAlB,uDAD0B,EAE1B;AAAEC,MAAAA,OAAO,EAAE;AAAX,KAF0B,CAA3B;AAIA,UAAKC,uBAAL,GAA+BV,OAAO,CACrC,MAAKU,uBAAL,CAA6BF,IAA7B,uDADqC,EAErC;AAAEC,MAAAA,OAAO,EAAE;AAAX,KAFqC,CAAtC;AANa;AAUb;;;;iCAEaE,I,EAAO;AACpB,UAAK,CAAEA,IAAP,EAAc;AACb,eAAO,EAAP;AACA;;AACD,UAAMC,UAAU,GAAGb,MAAM,CAAEY,IAAF,CAAzB;AACA,aAAO;AACNE,QAAAA,IAAI,EAAED,UAAU,CAACC,IAAX,EADA;AAENC,QAAAA,KAAK,EAAEF,UAAU,CAACE,KAAX,KAAqB;AAFtB,OAAP;AAIA;;;4CAEwBC,U,EAAYJ,I,EAAO;AAC3C,+BACII,UADJ,EAEI,KAAKR,YAAL,CAAmBI,IAAnB,CAFJ;AAIA;;;6BAEQ;AACR,aACC,cAAC,QAAD,QACC,cAAC,gBAAD;AACC,QAAA,KAAK,EAAC,eADP;AAEC,QAAA,UAAU,EAAG,KAAKD,uBAAL,CACZ,KAAKM,KAAL,CAAWD,UADC,EAEZ,KAAKC,KAAL,CAAWL,IAFC;AAFd,QADD,CADD;AAWA;;;;EA3CyBR,S;;AA8C3B,eAAeC,UAAU,CAAE,UAAEa,MAAF,EAAc;AAAA,gBAGpCA,MAAM,CAAE,aAAF,CAH8B;AAAA,MAEvCC,sBAFuC,WAEvCA,sBAFuC;;AAIxC,MAAMC,QAAQ,GAAGD,sBAAsB,CAAE,MAAF,CAAvC,CAJwC,CAKxC;AACA;AACA;;AACA,SAAO;AACNP,IAAAA,IAAI,EAAEQ,QAAQ,KAAK,MAAb,GACLD,sBAAsB,CAAE,MAAF,CADjB,GAELE;AAHK,GAAP;AAKA,CAbwB,CAAV,CAaVf,YAbU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDisabled,\n\tServerSideRender,\n} from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\n\nclass CalendarEdit extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.getYearMonth = memoize(\n\t\t\tthis.getYearMonth.bind( this ),\n\t\t\t{ maxSize: 1 }\n\t\t);\n\t\tthis.getServerSideAttributes = memoize(\n\t\t\tthis.getServerSideAttributes.bind( this ),\n\t\t\t{ maxSize: 1 }\n\t\t);\n\t}\n\n\tgetYearMonth( date ) {\n\t\tif ( ! date ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst momentDate = moment( date );\n\t\treturn {\n\t\t\tyear: momentDate.year(),\n\t\t\tmonth: momentDate.month() + 1,\n\t\t};\n\t}\n\n\tgetServerSideAttributes( attributes, date ) {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\t...this.getYearMonth( date ),\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Disabled>\n\t\t\t\t<ServerSideRender\n\t\t\t\t\tblock=\"core/calendar\"\n\t\t\t\t\tattributes={ this.getServerSideAttributes(\n\t\t\t\t\t\tthis.props.attributes,\n\t\t\t\t\t\tthis.props.date\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</Disabled>\n\t\t);\n\t}\n}\n\nexport default withSelect( ( select ) => {\n\tconst {\n\t\tgetEditedPostAttribute,\n\t} = select( 'core/editor' );\n\tconst postType = getEditedPostAttribute( 'type' );\n\t// Dates are used to overwrite year and month used on the calendar.\n\t// This overwrite should only happen for 'post' post types.\n\t// For other post types the calendar always displays the current month.\n\treturn {\n\t\tdate: postType === 'post' ?\n\t\t\tgetEditedPostAttribute( 'date' ) :\n\t\t\tundefined,\n\t};\n} )( CalendarEdit );\n"]}
\No newline at end of file