@beweco/aurora-ui 0.1.30 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/css/styles.css +1 -1
- package/dist/index.cjs.js +260 -6
- package/dist/index.esm.js +260 -8
- package/dist/types/components/accordion-list/AccordionList.d.ts.map +1 -1
- package/dist/types/components/color-picker/ColorPicker.d.ts +27 -0
- package/dist/types/components/color-picker/ColorPicker.d.ts.map +1 -0
- package/dist/types/components/color-picker/ColorPicker.types.d.ts +74 -0
- package/dist/types/components/color-picker/ColorPicker.types.d.ts.map +1 -0
- package/dist/types/components/color-picker/index.d.ts +4 -0
- package/dist/types/components/color-picker/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -192,7 +192,13 @@ function AccordionList(_a) {
|
|
|
192
192
|
}
|
|
193
193
|
return null;
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
/**
|
|
196
|
+
* Render Actions with Button Components
|
|
197
|
+
* ✅ Usado en: List Mode
|
|
198
|
+
*
|
|
199
|
+
* En el modo list, no hay problema de anidamiento de botones,
|
|
200
|
+
* por lo que podemos usar componentes Button normales.
|
|
201
|
+
*/
|
|
196
202
|
var renderActions = function (item) {
|
|
197
203
|
var visibleActions = actions.filter(function (action) {
|
|
198
204
|
if (action.show === undefined)
|
|
@@ -203,6 +209,53 @@ function AccordionList(_a) {
|
|
|
203
209
|
});
|
|
204
210
|
return (jsxRuntime.jsx("div", { className: "flex items-center gap-1", onClick: function (e) { return e.stopPropagation(); }, children: visibleActions.map(function (action) { return (jsxRuntime.jsx(react.Button, { variant: "light", color: action.color || "default", size: "sm", isIconOnly: true, onPress: function () { return action.onPress(item); }, className: action.className, title: action.tooltip, children: jsxRuntime.jsx(IconComponent, { icon: action.icon, className: "w-4 h-4" }) }, action.key)); }) }));
|
|
205
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Render Actions as DIV Elements with button role
|
|
214
|
+
* ✅ Usado en: Accordion Mode
|
|
215
|
+
*
|
|
216
|
+
* PROBLEMA RESUELTO: Botones anidados inválidos en HTML
|
|
217
|
+
* ❌ ANTES: <button trigger><button action></button></button>
|
|
218
|
+
* ✅ AHORA: <button trigger><div role="button"></div></button>
|
|
219
|
+
*
|
|
220
|
+
* En el modo accordion, el AccordionItem renderiza las acciones dentro
|
|
221
|
+
* del prop `title`, que a su vez está dentro del trigger button del accordion.
|
|
222
|
+
* Usar Button components generaría HTML inválido (button dentro de button)
|
|
223
|
+
* y causaría errores de hidratación en React.
|
|
224
|
+
*
|
|
225
|
+
* Solución: Renderizar las acciones como elementos div con role="button"
|
|
226
|
+
* que se ven y comportan como botones pero no generan HTML inválido.
|
|
227
|
+
*/
|
|
228
|
+
var renderActionsAsDiv = function (item) {
|
|
229
|
+
var visibleActions = actions.filter(function (action) {
|
|
230
|
+
if (action.show === undefined)
|
|
231
|
+
return true;
|
|
232
|
+
if (typeof action.show === "function")
|
|
233
|
+
return action.show(item);
|
|
234
|
+
return action.show;
|
|
235
|
+
});
|
|
236
|
+
return (jsxRuntime.jsx("div", { className: "flex items-center gap-1", onClick: function (e) { return e.stopPropagation(); }, children: visibleActions.map(function (action) {
|
|
237
|
+
var colorClasses = {
|
|
238
|
+
default: "text-default-500 hover:text-default-700 hover:bg-default-100",
|
|
239
|
+
primary: "text-primary-500 hover:text-primary-700 hover:bg-primary-50",
|
|
240
|
+
secondary: "text-secondary-500 hover:text-secondary-700 hover:bg-secondary-50",
|
|
241
|
+
success: "text-success-500 hover:text-success-700 hover:bg-success-50",
|
|
242
|
+
warning: "text-warning-500 hover:text-warning-700 hover:bg-warning-50",
|
|
243
|
+
danger: "text-danger-500 hover:text-danger-700 hover:bg-danger-50",
|
|
244
|
+
};
|
|
245
|
+
var colorClass = colorClasses[action.color || "default"];
|
|
246
|
+
return (jsxRuntime.jsx("div", { role: "button", tabIndex: 0, "aria-label": action.tooltip, title: action.tooltip, className: "\n\t\t\t\t\t\t\t\tinline-flex items-center justify-center\n\t\t\t\t\t\t\t\tw-8 h-8 rounded-md cursor-pointer\n\t\t\t\t\t\t\t\ttransition-colors duration-200\n\t\t\t\t\t\t\t\t".concat(colorClass, "\n\t\t\t\t\t\t\t\t").concat(action.className || "", "\n\t\t\t\t\t\t\t"), onClick: function (e) {
|
|
247
|
+
e.stopPropagation();
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
action.onPress(item);
|
|
250
|
+
}, onKeyDown: function (e) {
|
|
251
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
252
|
+
e.stopPropagation();
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
action.onPress(item);
|
|
255
|
+
}
|
|
256
|
+
}, children: jsxRuntime.jsx(IconComponent, { icon: action.icon, className: "w-4 h-4" }) }, action.key));
|
|
257
|
+
}) }));
|
|
258
|
+
};
|
|
206
259
|
// Render Metadata Chips
|
|
207
260
|
var renderMetadata = function (item) {
|
|
208
261
|
if (!header.getMetadata)
|
|
@@ -218,7 +271,7 @@ function AccordionList(_a) {
|
|
|
218
271
|
}
|
|
219
272
|
return (jsxRuntime.jsxs("div", { className: "h-full w-full ".concat(className), children: [(sectionTitle || sectionIcon) && (jsxRuntime.jsx("div", { className: "mb-4 flex items-center justify-between", children: jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [sectionIcon && (jsxRuntime.jsx(IconComponent, { icon: sectionIcon, className: "w-5 h-5 text-violet-600 dark:text-violet-400" })), sectionTitle && (jsxRuntime.jsx("h3", { className: "text-base font-semibold text-foreground", children: sectionTitle })), showCount && (jsxRuntime.jsx(react.Chip, { size: "sm", variant: "flat", color: "secondary", children: items.length }))] }) })), jsxRuntime.jsx(react.Accordion, { variant: accordionVariant, selectionMode: selectionMode, disableIndicatorAnimation: disableIndicatorAnimation, children: items.map(function (item) { return (jsxRuntime.jsx(react.AccordionItem, { "aria-label": header.getTitle(item), indicator: jsxRuntime.jsx(IconComponent, { icon: "solar:alt-arrow-down-outline", className: "w-4 h-4 text-default-400 transition-transform duration-200 data-[open=true]:rotate-180" }), classNames: {
|
|
220
273
|
indicator: "data-[open=true]:rotate-180 transition-transform duration-200",
|
|
221
|
-
}, title: jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full pr-4", children: [jsxRuntime.jsx("div", { className: "flex items-center gap-3 flex-1 min-w-0", children: header.customRender ? (header.customRender(item)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "text-sm text-default-900 truncate", children: header.getTitle(item) }), renderMetadata(item)] })) }), actions.length > 0 &&
|
|
274
|
+
}, title: jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full pr-4", children: [jsxRuntime.jsx("div", { className: "flex items-center gap-3 flex-1 min-w-0", children: header.customRender ? (header.customRender(item)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "text-sm text-default-900 truncate", children: header.getTitle(item) }), renderMetadata(item)] })) }), actions.length > 0 && renderActionsAsDiv(item)] }), children: jsxRuntime.jsx("div", { className: "pb-4", children: content.render(item) }) }, item.id)); }) }), pagination && pagination.totalPages > 1 && (jsxRuntime.jsx("div", { className: "flex justify-center mt-4", children: jsxRuntime.jsx(react.Pagination, { isCompact: pagination.isCompact, showControls: pagination.showControls, showShadow: true, color: "primary", page: pagination.currentPage, total: pagination.totalPages, onChange: pagination.onPageChange }) }))] }));
|
|
222
275
|
}
|
|
223
276
|
// List Mode
|
|
224
277
|
return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 ".concat(className), children: [(sectionTitle || sectionIcon) && (jsxRuntime.jsx("div", { className: "mb-1 flex items-center justify-between", children: jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [sectionIcon && (jsxRuntime.jsx(IconComponent, { icon: sectionIcon, className: "w-5 h-5 text-primary-600 dark:text-primary-400" })), sectionTitle && (jsxRuntime.jsx("h3", { className: "text-base font-semibold text-foreground", children: sectionTitle })), showCount && (jsxRuntime.jsx(react.Chip, { size: "sm", variant: "flat", color: "primary", children: items.length }))] }) })), items.map(function (item) { return (jsxRuntime.jsxs("div", { className: "flex items-start justify-between p-4 border border-default-100 rounded-lg transition-colors bg-default-50 hover:bg-default-100", children: [jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: header.customRender ? (header.customRender(item)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "flex items-center gap-2 mb-2", children: jsxRuntime.jsx("span", { className: "text-sm font-medium text-default-900 truncate", children: header.getTitle(item) }) }), header.getSubtitle && (jsxRuntime.jsx("p", { className: "text-sm text-default-700 line-clamp-2 leading-relaxed mb-2", children: header.getSubtitle(item) })), renderMetadata(item)] })) }), actions.length > 0 && (jsxRuntime.jsx("div", { className: "ml-4 flex-shrink-0", children: renderActions(item) }))] }, item.id)); }), pagination && pagination.totalPages > 1 && (jsxRuntime.jsx("div", { className: "flex justify-center mt-4", children: jsxRuntime.jsx(react.Pagination, { isCompact: pagination.isCompact, showControls: pagination.showControls, showShadow: true, color: "primary", page: pagination.currentPage, total: pagination.totalPages, onChange: pagination.onPageChange }) }))] }));
|
|
@@ -287,7 +340,7 @@ var Input = function (_a) {
|
|
|
287
340
|
} })));
|
|
288
341
|
};
|
|
289
342
|
|
|
290
|
-
var defaultTranslations$
|
|
343
|
+
var defaultTranslations$e = {
|
|
291
344
|
addHolidayTitle: "Add holiday",
|
|
292
345
|
dayOption: "Day",
|
|
293
346
|
dateRangeOption: "Date range",
|
|
@@ -311,7 +364,7 @@ var INITIAL_HOLIDAY_STATE = {
|
|
|
311
364
|
*/
|
|
312
365
|
var AddHolidayForm = function (_a) {
|
|
313
366
|
var onAddHoliday = _a.onAddHoliday, translations = _a.translations, className = _a.className, radioGroupProps = _a.radioGroupProps, dateRangePickerProps = _a.dateRangePickerProps, buttonProps = _a.buttonProps;
|
|
314
|
-
var t = __assign(__assign({}, defaultTranslations$
|
|
367
|
+
var t = __assign(__assign({}, defaultTranslations$e), translations);
|
|
315
368
|
var _b = React.useState(INITIAL_HOLIDAY_STATE), newHoliday = _b[0], setNewHoliday = _b[1];
|
|
316
369
|
/**
|
|
317
370
|
* A boolean flag that determines if a date has been set.
|
|
@@ -381,7 +434,7 @@ var P = function (_a) {
|
|
|
381
434
|
return (jsxRuntime.jsx("p", __assign({ className: react.cn("text-tiny text-default-500 font-normal", className) }, props, { children: children })));
|
|
382
435
|
};
|
|
383
436
|
|
|
384
|
-
var defaultTranslations$
|
|
437
|
+
var defaultTranslations$d = {
|
|
385
438
|
title: "Analytics",
|
|
386
439
|
description: "Monthly growth of your metrics during the selected period",
|
|
387
440
|
viewDetails: "View Details",
|
|
@@ -435,7 +488,7 @@ var formatMonth = function (month) {
|
|
|
435
488
|
var AnalyticsCard = function (_a) {
|
|
436
489
|
var _b, _c;
|
|
437
490
|
var data = _a.data, _d = _a.showTimePeriods, showTimePeriods = _d === void 0 ? true : _d, _e = _a.showDropdownMenu, showDropdownMenu = _e === void 0 ? true : _e, _f = _a.showMetricCards, showMetricCards = _f === void 0 ? true : _f, onChartChange = _a.onChartChange, onMenuAction = _a.onMenuAction, onTimePeriodChange = _a.onTimePeriodChange, _g = _a.translations, translations = _g === void 0 ? {} : _g, props = __rest(_a, ["data", "showTimePeriods", "showDropdownMenu", "showMetricCards", "onChartChange", "onMenuAction", "onTimePeriodChange", "translations"]);
|
|
438
|
-
var t = __assign(__assign({}, defaultTranslations$
|
|
491
|
+
var t = __assign(__assign({}, defaultTranslations$d), translations);
|
|
439
492
|
var _h = React.useState((_c = (_b = data[0]) === null || _b === void 0 ? void 0 : _b.key) !== null && _c !== void 0 ? _c : ""), activeChart = _h[0], setActiveChart = _h[1];
|
|
440
493
|
var activeChartData = React.useMemo(function () {
|
|
441
494
|
var _a;
|
|
@@ -526,6 +579,205 @@ var AuraAutocomplete = function (_a) {
|
|
|
526
579
|
} }))] }));
|
|
527
580
|
};
|
|
528
581
|
|
|
582
|
+
/**
|
|
583
|
+
* ColorPicker Types
|
|
584
|
+
*
|
|
585
|
+
* Defines the type system for the ColorPicker component used for brand configuration.
|
|
586
|
+
*/
|
|
587
|
+
/**
|
|
588
|
+
* Default predefined colors (Brand-safe palette)
|
|
589
|
+
*/
|
|
590
|
+
var DEFAULT_PREDEFINED_COLORS = [
|
|
591
|
+
// Primary colors
|
|
592
|
+
{ key: "blue", name: "Azul", value: "#3B82F6" },
|
|
593
|
+
{ key: "violet", name: "Violeta", value: "#8B5CF6" },
|
|
594
|
+
{ key: "purple", name: "Púrpura", value: "#A855F7" },
|
|
595
|
+
// Secondary colors
|
|
596
|
+
{ key: "green", name: "Verde", value: "#10B981" },
|
|
597
|
+
{ key: "teal", name: "Turquesa", value: "#14B8A6" },
|
|
598
|
+
{ key: "cyan", name: "Cian", value: "#06B6D4" },
|
|
599
|
+
// Accent colors
|
|
600
|
+
{ key: "pink", name: "Rosa", value: "#EC4899" },
|
|
601
|
+
{ key: "rose", name: "Rosa claro", value: "#F43F5E" },
|
|
602
|
+
{ key: "orange", name: "Naranja", value: "#F97316" },
|
|
603
|
+
// Neutral colors
|
|
604
|
+
{ key: "red", name: "Rojo", value: "#EF4444" },
|
|
605
|
+
{ key: "amber", name: "Ámbar", value: "#F59E0B" },
|
|
606
|
+
{ key: "yellow", name: "Amarillo", value: "#EAB308" },
|
|
607
|
+
// Gray scale (useful for text/backgrounds)
|
|
608
|
+
{ key: "gray-dark", name: "Gris oscuro", value: "#374151" },
|
|
609
|
+
{ key: "gray", name: "Gris", value: "#6B7280" },
|
|
610
|
+
{ key: "gray-light", name: "Gris claro", value: "#9CA3AF" },
|
|
611
|
+
];
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Default translations (Spanish)
|
|
615
|
+
*/
|
|
616
|
+
var defaultTranslations$c = {
|
|
617
|
+
label: "Color",
|
|
618
|
+
placeholder: "Ingresa código hex",
|
|
619
|
+
customColorLabel: "Color personalizado",
|
|
620
|
+
predefinedColorsLabel: "Colores predefinidos",
|
|
621
|
+
recentColorsLabel: "Colores recientes",
|
|
622
|
+
noRecentColors: "No hay colores recientes",
|
|
623
|
+
invalidColorFormat: "Formato de color inválido. Usa #RRGGBB",
|
|
624
|
+
colorPreview: "Vista previa del color",
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* Validates hex color format (#RRGGBB or #RGB)
|
|
628
|
+
*/
|
|
629
|
+
var isValidHexColor = function (color) {
|
|
630
|
+
var hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
631
|
+
return hexRegex.test(color);
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Normalizes hex color to 6-digit format (#RGB -> #RRGGBB)
|
|
635
|
+
*/
|
|
636
|
+
var normalizeHexColor = function (color) {
|
|
637
|
+
if (!color.startsWith("#")) {
|
|
638
|
+
color = "#".concat(color);
|
|
639
|
+
}
|
|
640
|
+
// Convert 3-digit to 6-digit
|
|
641
|
+
if (color.length === 4) {
|
|
642
|
+
var r = color[1];
|
|
643
|
+
var g = color[2];
|
|
644
|
+
var b = color[3];
|
|
645
|
+
return "#".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b).toUpperCase();
|
|
646
|
+
}
|
|
647
|
+
return color.toUpperCase();
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* ColorPicker - Advanced color selection component
|
|
651
|
+
*
|
|
652
|
+
* Features:
|
|
653
|
+
* - Native color picker input
|
|
654
|
+
* - Text input for hex codes
|
|
655
|
+
* - Predefined color palette
|
|
656
|
+
* - Recent colors with localStorage persistence
|
|
657
|
+
* - Full i18n support
|
|
658
|
+
* - Dark mode compatible
|
|
659
|
+
* - Accessible
|
|
660
|
+
*
|
|
661
|
+
* @component
|
|
662
|
+
* @example
|
|
663
|
+
* ```tsx
|
|
664
|
+
* <ColorPicker
|
|
665
|
+
* value={brandColor}
|
|
666
|
+
* onChange={setBrandColor}
|
|
667
|
+
* label="Color de marca"
|
|
668
|
+
* enableRecentColors
|
|
669
|
+
* />
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
var ColorPicker = function (_a) {
|
|
673
|
+
var value = _a.value, onChange = _a.onChange, label = _a.label, _b = _a.required, required = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.error, error = _d === void 0 ? false : _d, errorText = _a.errorText, _e = _a.predefinedColors, predefinedColors = _e === void 0 ? DEFAULT_PREDEFINED_COLORS : _e, _f = _a.enableRecentColors, enableRecentColors = _f === void 0 ? true : _f, _g = _a.maxRecentColors, maxRecentColors = _g === void 0 ? 6 : _g, _h = _a.recentColorsStorageKey, recentColorsStorageKey = _h === void 0 ? "aurora-ui-recent-colors" : _h, _j = _a.showPredefinedColors, showPredefinedColors = _j === void 0 ? true : _j, _k = _a.translations, translations = _k === void 0 ? {} : _k, _l = _a.className, className = _l === void 0 ? "" : _l, id = _a.id, name = _a.name;
|
|
674
|
+
var generatedId = React.useId();
|
|
675
|
+
var inputId = id || generatedId;
|
|
676
|
+
var t = __assign(__assign({}, defaultTranslations$c), translations);
|
|
677
|
+
// Local state for text input
|
|
678
|
+
var _m = React.useState(value), textValue = _m[0], setTextValue = _m[1];
|
|
679
|
+
var _o = React.useState(false), isInvalidFormat = _o[0], setIsInvalidFormat = _o[1];
|
|
680
|
+
// Recent colors state
|
|
681
|
+
var _p = React.useState([]), recentColors = _p[0], setRecentColors = _p[1];
|
|
682
|
+
// Load recent colors from localStorage on mount
|
|
683
|
+
React.useEffect(function () {
|
|
684
|
+
if (!enableRecentColors)
|
|
685
|
+
return;
|
|
686
|
+
try {
|
|
687
|
+
var stored = localStorage.getItem(recentColorsStorageKey);
|
|
688
|
+
if (stored) {
|
|
689
|
+
var colors = JSON.parse(stored);
|
|
690
|
+
setRecentColors(colors);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
catch (error) {
|
|
694
|
+
console.error("Error loading recent colors:", error);
|
|
695
|
+
}
|
|
696
|
+
}, [enableRecentColors, recentColorsStorageKey]);
|
|
697
|
+
// Save to recent colors when value changes
|
|
698
|
+
React.useEffect(function () {
|
|
699
|
+
if (!enableRecentColors || !value || !isValidHexColor(value))
|
|
700
|
+
return;
|
|
701
|
+
var normalizedValue = normalizeHexColor(value);
|
|
702
|
+
// Add to recent colors if not already present
|
|
703
|
+
setRecentColors(function (prev) {
|
|
704
|
+
// Remove if already exists
|
|
705
|
+
var filtered = prev.filter(function (c) { return c !== normalizedValue; });
|
|
706
|
+
// Add to beginning
|
|
707
|
+
var updated = __spreadArray([normalizedValue], filtered, true).slice(0, maxRecentColors);
|
|
708
|
+
// Save to localStorage
|
|
709
|
+
try {
|
|
710
|
+
localStorage.setItem(recentColorsStorageKey, JSON.stringify(updated));
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
console.error("Error saving recent colors:", error);
|
|
714
|
+
}
|
|
715
|
+
return updated;
|
|
716
|
+
});
|
|
717
|
+
}, [value, enableRecentColors, maxRecentColors, recentColorsStorageKey]);
|
|
718
|
+
// Sync text value when prop value changes
|
|
719
|
+
React.useEffect(function () {
|
|
720
|
+
setTextValue(value);
|
|
721
|
+
setIsInvalidFormat(false);
|
|
722
|
+
}, [value]);
|
|
723
|
+
/**
|
|
724
|
+
* Handle color picker (native input) change
|
|
725
|
+
*/
|
|
726
|
+
var handleColorPickerChange = function (e) {
|
|
727
|
+
var newColor = normalizeHexColor(e.target.value);
|
|
728
|
+
setTextValue(newColor);
|
|
729
|
+
setIsInvalidFormat(false);
|
|
730
|
+
onChange(newColor);
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Handle text input change
|
|
734
|
+
*/
|
|
735
|
+
var handleTextChange = function (newValue) {
|
|
736
|
+
setTextValue(newValue);
|
|
737
|
+
// Validate format
|
|
738
|
+
if (isValidHexColor(newValue)) {
|
|
739
|
+
var normalized = normalizeHexColor(newValue);
|
|
740
|
+
setIsInvalidFormat(false);
|
|
741
|
+
onChange(normalized);
|
|
742
|
+
}
|
|
743
|
+
else if (newValue.length >= 4) {
|
|
744
|
+
// Show error only if user has typed enough characters
|
|
745
|
+
setIsInvalidFormat(true);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
setIsInvalidFormat(false);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* Handle predefined color selection
|
|
753
|
+
*/
|
|
754
|
+
var handlePredefinedColorClick = function (colorValue) {
|
|
755
|
+
if (disabled)
|
|
756
|
+
return;
|
|
757
|
+
var normalized = normalizeHexColor(colorValue);
|
|
758
|
+
setTextValue(normalized);
|
|
759
|
+
setIsInvalidFormat(false);
|
|
760
|
+
onChange(normalized);
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* Render a color circle button
|
|
764
|
+
*/
|
|
765
|
+
var renderColorCircle = function (colorValue, colorName, isSelected) { return (jsxRuntime.jsx("button", { type: "button", disabled: disabled, onClick: function () { return handlePredefinedColorClick(colorValue); }, className: "\n\t\t\t\tw-8 h-8 rounded-full border-2 cursor-pointer transition-all\n\t\t\t\tfocus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-1\n\t\t\t\t".concat(disabled ? "opacity-50 cursor-not-allowed" : "hover:scale-110", "\n\t\t\t\t").concat(isSelected
|
|
766
|
+
? "border-primary-500 scale-110 ring-2 ring-primary-500 ring-offset-1"
|
|
767
|
+
: "border-default-700", "\n\t\t\t"), style: { backgroundColor: colorValue }, title: colorName, "aria-label": colorName }, colorValue)); };
|
|
768
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 ".concat(className), children: [label && (jsxRuntime.jsxs("label", { htmlFor: inputId, className: "block text-sm font-medium text-foreground", children: [label, required && jsxRuntime.jsx("span", { className: "text-danger ml-1", children: "*" })] })), jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("input", { type: "color", id: inputId, name: name, value: textValue, onChange: handleColorPickerChange, disabled: disabled, className: "\n\t\t\t\t\t\t\tw-10 h-10 rounded-lg cursor-pointer border-2 flex-shrink-0\n\t\t\t\t\t\t\ttransition-colors appearance-none bg-transparent p-0.5\n\t\t\t\t\t\t\tfocus:border-primary-500\n\t\t\t\t\t\t\t".concat(disabled ? "opacity-50 cursor-not-allowed" : "hover:border-default-400", "\n\t\t\t\t\t\t\t").concat(error
|
|
769
|
+
? "border-danger dark:border-danger-400"
|
|
770
|
+
: "border-default-300 dark:border-default-700", "\n\t\t\t\t\t\t"), "aria-label": t.customColorLabel, title: t.customColorLabel }), jsxRuntime.jsx(react.Input, { type: "text", value: textValue, onValueChange: handleTextChange, placeholder: t.placeholder, disabled: disabled, isInvalid: error || isInvalidFormat, size: "sm", variant: "bordered", classNames: {
|
|
771
|
+
input: "uppercase font-mono text-small",
|
|
772
|
+
inputWrapper: "min-h-8 h-8 focus-within:!border-primary-500",
|
|
773
|
+
}, startContent: jsxRuntime.jsx("span", { className: "text-default-400 text-sm", children: "#" }) })] }), (error || isInvalidFormat) && (jsxRuntime.jsx("p", { className: "text-tiny text-danger", children: isInvalidFormat ? t.invalidColorFormat : errorText }))] }), showPredefinedColors && predefinedColors.length > 0 && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("p", { className: "text-xs font-medium text-default-600 mb-2", children: t.predefinedColorsLabel }), jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: predefinedColors.map(function (color) {
|
|
774
|
+
return renderColorCircle(color.value, color.name, normalizeHexColor(value) === normalizeHexColor(color.value));
|
|
775
|
+
}) })] })), enableRecentColors && recentColors.length > 0 && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("p", { className: "text-xs font-medium text-default-600 mb-2", children: t.recentColorsLabel }), jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: recentColors.map(function (color) {
|
|
776
|
+
return renderColorCircle(color, color, normalizeHexColor(value) === color);
|
|
777
|
+
}) })] }))] }));
|
|
778
|
+
};
|
|
779
|
+
ColorPicker.displayName = "ColorPicker";
|
|
780
|
+
|
|
529
781
|
var ThemeContext = React.createContext({
|
|
530
782
|
mode: "light",
|
|
531
783
|
color: "blue",
|
|
@@ -4717,8 +4969,10 @@ exports.BreadcrumbsComponent = BreadcrumbsComponent;
|
|
|
4717
4969
|
exports.Button = Button;
|
|
4718
4970
|
exports.Card = Card;
|
|
4719
4971
|
exports.Chip = Chip;
|
|
4972
|
+
exports.ColorPicker = ColorPicker;
|
|
4720
4973
|
exports.ColorSelector = ColorSelector;
|
|
4721
4974
|
exports.ContentCarousel = ContentCarousel;
|
|
4975
|
+
exports.DEFAULT_PREDEFINED_COLORS = DEFAULT_PREDEFINED_COLORS;
|
|
4722
4976
|
exports.DatePicker = DatePicker;
|
|
4723
4977
|
exports.DateRangePicker = DateRangePicker;
|
|
4724
4978
|
exports.DateSelector = DateSelector;
|