UNPKG

@wordpress/components

Version:
70 lines (69 loc) • 1.87 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let _wordpress_i18n = require("@wordpress/i18n"); let colord = require("colord"); let __input_with_slider_tsx = require("./input-with-slider.cjs"); let react_jsx_runtime = require("react/jsx-runtime"); // packages/components/src/color-picker/rgb-input.tsx const RgbInput = ({ color, onChange, enableAlpha }) => { const { r, g, b, a } = color.toRgb(); return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__input_with_slider_tsx.InputWithSlider, { min: 0, max: 255, label: (0, _wordpress_i18n.__)("Red"), abbreviation: "R", value: r, onChange: (nextR) => onChange((0, colord.colord)({ r: nextR, g, b, a })) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__input_with_slider_tsx.InputWithSlider, { min: 0, max: 255, label: (0, _wordpress_i18n.__)("Green"), abbreviation: "G", value: g, onChange: (nextG) => onChange((0, colord.colord)({ r, g: nextG, b, a })) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__input_with_slider_tsx.InputWithSlider, { min: 0, max: 255, label: (0, _wordpress_i18n.__)("Blue"), abbreviation: "B", value: b, onChange: (nextB) => onChange((0, colord.colord)({ r, g, b: nextB, a })) }), enableAlpha && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__input_with_slider_tsx.InputWithSlider, { min: 0, max: 100, label: (0, _wordpress_i18n.__)("Alpha (RGB A value)"), abbreviation: "A", value: Math.trunc(a * 100), onChange: (nextA) => onChange((0, colord.colord)({ r, g, b, a: nextA / 100 })) }) ] }); }; exports.RgbInput = RgbInput; //# sourceMappingURL=rgb-input.cjs.map