@wordpress/components
Version:
UI components for WordPress.
103 lines (101 loc) • 4.2 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/components/src/angle-picker-control/index.tsx
var angle_picker_control_exports = {};
__export(angle_picker_control_exports, {
AnglePickerControl: () => AnglePickerControl,
default: () => angle_picker_control_default
});
module.exports = __toCommonJS(angle_picker_control_exports);
var import_clsx = __toESM(require("clsx"));
var import_element = require("@wordpress/element");
var import_i18n = require("@wordpress/i18n");
var import_flex = require("../flex");
var import_spacer = require("../spacer");
var import_number_control = __toESM(require("../number-control"));
var import_angle_circle = __toESM(require("./angle-circle"));
var import_angle_picker_control_styles = require("./styles/angle-picker-control-styles");
var import_jsx_runtime = require("react/jsx-runtime");
function UnforwardedAnglePickerControl(props, ref) {
const {
className,
label = (0, import_i18n.__)("Angle"),
onChange,
value,
...restProps
} = props;
const handleOnNumberChange = (unprocessedValue) => {
if (onChange === void 0) {
return;
}
const inputValue = unprocessedValue !== void 0 && unprocessedValue !== "" ? parseInt(unprocessedValue, 10) : 0;
onChange(inputValue);
};
const classes = (0, import_clsx.default)("components-angle-picker-control", className);
const unitText = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_angle_picker_control_styles.UnitText, {
children: "\xB0"
});
const [prefixedUnitText, suffixedUnitText] = (0, import_i18n.isRTL)() ? [unitText, null] : [null, unitText];
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_flex.Flex, {
...restProps,
ref,
className: classes,
gap: 2,
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_flex.FlexBlock, {
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_number_control.default, {
__next40pxDefaultSize: true,
label,
className: "components-angle-picker-control__input-field",
max: 360,
min: 0,
onChange: handleOnNumberChange,
step: "1",
value,
spinControls: "none",
prefix: prefixedUnitText,
suffix: suffixedUnitText
})
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spacer.Spacer, {
marginBottom: "1",
marginTop: "auto",
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_angle_circle.default, {
"aria-hidden": "true",
value,
onChange
})
})]
});
}
var AnglePickerControl = (0, import_element.forwardRef)(UnforwardedAnglePickerControl);
var angle_picker_control_default = AnglePickerControl;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AnglePickerControl
});
//# sourceMappingURL=index.js.map