@wordpress/block-library
Version:
Block library for the WordPress editor.
38 lines (37 loc) • 983 B
JavaScript
import { __ } from "@wordpress/i18n";
import { SelectControl } from "@wordpress/ui";
import { jsx } from "react/jsx-runtime";
// packages/block-library/src/terms-query/edit/inspector-controls/order-control.jsx
function OrderControl({ orderBy, order, onChange, help, ...props }) {
const orderOptions = [
{
label: __("Name: A → Z"),
value: "name/asc"
},
{
label: __("Name: Z → A"),
value: "name/desc"
},
{
label: __("Count, high to low"),
value: "count/desc"
},
{
label: __("Count, low to high"),
value: "count/asc"
}
];
return /* @__PURE__ */ jsx(SelectControl, {
items: orderOptions,
value: orderOptions.find((item) => item.value === orderBy + "/" + order) ?? null,
onValueChange: (item) => {
if (!item) return;
const [newOrderBy, newOrder] = item.value.split("/");
onChange(newOrderBy, newOrder);
},
description: help,
...props
});
}
export { OrderControl as default };
//# sourceMappingURL=order-control.mjs.map