@wordpress/components
Version:
UI components for WordPress.
34 lines (33 loc) • 1.41 kB
JavaScript
import { __ } from "@wordpress/i18n";
import deprecated from "@wordpress/deprecated";
// packages/components/src/circular-option-picker/utils.tsx
function warnIfCircularOptionPickerAsButtonsIsSet(componentName, asButtons) {
if (asButtons === void 0) return;
deprecated(`\`asButtons\` prop in wp.components.${componentName}`, {
since: "7.2",
alternative: "`presentation`",
hint: "`asButtons={ true }` maps to `presentation=\"toggle-buttons\"`. Explicit `presentation` takes precedence."
});
}
function resolveCircularOptionPickerPresentation(presentation, asButtons) {
return presentation ?? (asButtons ? "toggle-buttons" : "listbox");
}
/**
* Computes the common props for the CircularOptionPicker.
*/
function getComputeCircularOptionPickerCommonProps(asButtons, loop, ariaLabel, ariaLabelledby, presentation) {
const resolvedPresentation = resolveCircularOptionPickerPresentation(presentation, asButtons);
return {
metaProps: resolvedPresentation === "listbox" ? {
presentation: "listbox",
loop
} : { presentation: resolvedPresentation },
labelProps: {
"aria-labelledby": ariaLabelledby,
"aria-label": ariaLabelledby ? void 0 : ariaLabel || __("Custom color picker")
},
resolvedPresentation
};
}
export { getComputeCircularOptionPickerCommonProps, resolveCircularOptionPickerPresentation, warnIfCircularOptionPickerAsButtonsIsSet };
//# sourceMappingURL=utils.mjs.map