analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
99 lines (92 loc) • 3.61 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js');
var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js');
// src/components/ColorPicker/ColorPicker.tsx
var _react = require('react');
var _WarningCircle = require('@phosphor-icons/react/dist/csr/WarningCircle');
var _jsxruntime = require('react/jsx-runtime');
var ColorPicker = _react.forwardRef.call(void 0,
({
label,
helperText,
errorMessage,
value = "#FFFFFF",
onChange,
placeholder = "#FFFFFF",
className,
disabled,
required,
id,
...props
}, ref) => {
const generatedId = _react.useId.call(void 0, );
const inputId = _nullishCoalesce(id, () => ( `color-picker-${generatedId}`));
const hasError = Boolean(errorMessage);
const inputClasses = _chunkTN3AYOMVjs.cn.call(void 0,
"bg-background w-full py-2 px-3 font-normal text-text-900 text-sm",
"border rounded-lg focus:outline-primary-950",
hasError ? "border-2 border-indicator-error" : "border-border-300 hover:border-border-400",
disabled && "cursor-not-allowed opacity-40"
);
const colorInputClasses = _chunkTN3AYOMVjs.cn.call(void 0,
"w-12 h-10 rounded cursor-pointer border",
hasError ? "border-indicator-error" : "border-border-200",
disabled && "cursor-not-allowed opacity-40"
);
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className, children: [
label && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
"label",
{
htmlFor: inputId,
className: "block font-bold text-text-900 mb-2 text-sm",
children: [
label,
" ",
required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-indicator-error", children: "*" })
]
}
),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-3", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"input",
{
type: "color",
value,
onChange,
disabled,
className: colorInputClasses,
"aria-label": label ? `${label} color picker` : "Color picker"
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"input",
{
ref,
id: inputId,
type: "text",
value,
onChange,
placeholder,
disabled,
required,
className: inputClasses,
"aria-invalid": hasError ? "true" : void 0,
...props
}
)
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1", children: [
helperText && !errorMessage && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", color: "text-text-500", children: helperText }),
errorMessage && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", color: "text-indicator-error", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _WarningCircle.WarningCircleIcon, { size: 14 }),
" ",
errorMessage
] })
] })
] });
}
);
ColorPicker.displayName = "ColorPicker";
var ColorPicker_default = ColorPicker;
exports.ColorPicker_default = ColorPicker_default;
//# sourceMappingURL=chunk-757U222P.js.map