@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 1.82 kB
Source Map (JSON)
{"version":3,"file":"order-control.cjs","names":["__","WCSelectControl"],"sources":["../../../../src/query/edit/inspector-controls/order-control.jsx"],"sourcesContent":["import { SelectControl as WCSelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst defaultOrderByOptions = [\n\t{\n\t\tlabel: __( 'Newest to oldest' ),\n\t\tvalue: 'date/desc',\n\t},\n\t{\n\t\tlabel: __( 'Oldest to newest' ),\n\t\tvalue: 'date/asc',\n\t},\n\t{\n\t\t/* translators: Label for ordering posts by title in ascending order. */\n\t\tlabel: __( 'A → Z' ),\n\t\tvalue: 'title/asc',\n\t},\n\t{\n\t\t/* translators: Label for ordering posts by title in descending order. */\n\t\tlabel: __( 'Z → A' ),\n\t\tvalue: 'title/desc',\n\t},\n];\n\nfunction OrderControl( {\n\torder,\n\torderBy,\n\torderByOptions = defaultOrderByOptions,\n\tonChange,\n} ) {\n\treturn (\n\t\t<WCSelectControl\n\t\t\tlabel={ __( 'Order by' ) }\n\t\t\tvalue={ `${ orderBy }/${ order }` }\n\t\t\toptions={ orderByOptions }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tconst [ newOrderBy, newOrder ] = value.split( '/' );\n\t\t\t\tonChange( { order: newOrder, orderBy: newOrderBy } );\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nexport default OrderControl;\n"],"mappings":";;;;;;;;;AAGA,MAAM,wBAAwB;CAC7B;EACC,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,kBAAmB;EAC9B,OAAO;CACR;CACA;EACC,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,kBAAmB;EAC9B,OAAO;CACR;CACA;EAEC,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,OAAQ;EACnB,OAAO;CACR;CACA;EAEC,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,OAAQ;EACnB,OAAO;CACR;AACD;AAEA,SAAS,aAAc,EACtB,OACA,SACA,iBAAiB,uBACjB,YACG;CACH,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,eAAD;EACC,QAAA,GAAQD,gBAAAA,GAAAA,CAAI,UAAW;EACvB,OAAQ,GAAI,QAAS,GAAI;EACzB,SAAU;EACV,WAAa,UAAW;GACvB,MAAM,CAAE,YAAY,YAAa,MAAM,MAAO,GAAI;GAClD,SAAU;IAAE,OAAO;IAAU,SAAS;GAAW,CAAE;EACpD;CACA,CAAA;AAEH"}