@beweco/aurora-ui 0.0.6 → 0.0.9
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 +3 -0
- package/dist/assets/output-Ck0ffzyL.css +73 -0
- package/dist/index.cjs.js +313 -16
- package/dist/index.esm.js +307 -11
- package/dist/types/components/Menu/Menu.d.ts +1 -1
- package/dist/types/components/Menu/Menu.d.ts.map +1 -1
- package/dist/types/components/Menu/Menu.types.d.ts +1 -1
- package/dist/types/components/Menu/Menu.types.d.ts.map +1 -1
- package/dist/types/components/Menu/index.d.ts +2 -1
- package/dist/types/components/Menu/index.d.ts.map +1 -1
- package/dist/types/components/Menu/sidebar-items.d.ts.map +1 -1
- package/dist/types/components/menu-nav-list/MenuNavList.d.ts +19 -0
- package/dist/types/components/menu-nav-list/MenuNavList.d.ts.map +1 -1
- package/dist/types/components/menu-nav-list/MenuNavList.styles.d.ts +2 -14
- package/dist/types/components/menu-nav-list/MenuNavList.styles.d.ts.map +1 -1
- package/dist/types/components/menu-nav-list/MenuNavList.types.d.ts +2 -2
- package/dist/types/components/menu-nav-list/index.d.ts +2 -0
- package/dist/types/components/menu-nav-list/index.d.ts.map +1 -0
- package/dist/types/components/phone/Phone.d.ts +24 -0
- package/dist/types/components/phone/Phone.d.ts.map +1 -0
- package/dist/types/components/phone/index.d.ts +2 -0
- package/dist/types/components/phone/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/providers/theme/theme-provider.d.ts.map +1 -1
- package/package.json +10 -12
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
.container__menu {
|
|
2
|
+
@apply relative
|
|
3
|
+
flex
|
|
4
|
+
h-screen
|
|
5
|
+
bg-transparent
|
|
6
|
+
transition-all
|
|
7
|
+
duration-300;
|
|
8
|
+
}
|
|
9
|
+
.container__menu--expanded {
|
|
10
|
+
@apply max-w-72
|
|
11
|
+
flex-1
|
|
12
|
+
flex-col
|
|
13
|
+
xs:p-0
|
|
14
|
+
sm:px-4
|
|
15
|
+
sm:py-6
|
|
16
|
+
xs:rounded-r-xl
|
|
17
|
+
xs:bg-default-100
|
|
18
|
+
sm:bg-transparent
|
|
19
|
+
xs:fixed
|
|
20
|
+
xs:left-0
|
|
21
|
+
xs:top-0
|
|
22
|
+
xs:z-50
|
|
23
|
+
xs:w-full
|
|
24
|
+
xs:h-full;
|
|
25
|
+
}
|
|
26
|
+
.container__menu--collapsed {
|
|
27
|
+
@apply max-w-24
|
|
28
|
+
flex-1
|
|
29
|
+
flex-col
|
|
30
|
+
p-4;
|
|
31
|
+
}
|
|
32
|
+
.container__menu--collapsed .content__menu {
|
|
33
|
+
@apply px-2 py-6;
|
|
34
|
+
}
|
|
35
|
+
.container__menu--collapsed .content__menu--header {
|
|
36
|
+
@apply flex-col gap-4;
|
|
37
|
+
}
|
|
38
|
+
.container__menu--collapsed .content__menu--user {
|
|
39
|
+
@apply justify-center py-0;
|
|
40
|
+
}
|
|
41
|
+
.container__menu--collapsed .collapsible-item {
|
|
42
|
+
opacity: 0;
|
|
43
|
+
max-width: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.content__menu {
|
|
47
|
+
@apply w-full
|
|
48
|
+
h-full
|
|
49
|
+
rounded-2xl
|
|
50
|
+
p-6
|
|
51
|
+
bg-default-100
|
|
52
|
+
flex
|
|
53
|
+
flex-col;
|
|
54
|
+
}
|
|
55
|
+
.content__menu--header {
|
|
56
|
+
@apply flex
|
|
57
|
+
items-center
|
|
58
|
+
gap-2
|
|
59
|
+
justify-between;
|
|
60
|
+
}
|
|
61
|
+
.content__menu--user {
|
|
62
|
+
@apply flex
|
|
63
|
+
items-center
|
|
64
|
+
py-3;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.collapsible-item {
|
|
68
|
+
transition: all 300ms ease-in-out;
|
|
69
|
+
opacity: 1;
|
|
70
|
+
max-width: 1000px;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
white-space: nowrap;
|
|
73
|
+
}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react
|
|
5
|
-
var
|
|
6
|
-
var react$
|
|
4
|
+
var react = require('@heroui/react');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var react$1 = require('@iconify/react');
|
|
7
|
+
var useTheme = require('@heroui/use-theme');
|
|
7
8
|
|
|
8
9
|
/******************************************************************************
|
|
9
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -56,10 +57,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
56
57
|
*/
|
|
57
58
|
var ButtonPrueba = function (_a) {
|
|
58
59
|
var children = _a.children, startIcon = _a.startIcon, endIcon = _a.endIcon, _b = _a.loading, loading = _b === void 0 ? false : _b, disabled = _a.disabled, _c = _a.variant, variant = _c === void 0 ? "solid" : _c, _d = _a.color, color = _d === void 0 ? "primary" : _d, _e = _a.size, size = _e === void 0 ? "md" : _e, radius = _a.radius, _f = _a.fullWidth, fullWidth = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? "" : _g, props = __rest(_a, ["children", "startIcon", "endIcon", "loading", "disabled", "variant", "color", "size", "radius", "fullWidth", "className"]);
|
|
59
|
-
|
|
60
|
+
React.useEffect(function () {
|
|
60
61
|
// console.log("estamos dentro del botnon");
|
|
61
62
|
}, []);
|
|
62
|
-
return (jsxRuntime.jsx(react
|
|
63
|
+
return (jsxRuntime.jsx(react.Button, __assign({ variant: variant, color: color, size: size, radius: radius, fullWidth: fullWidth, isLoading: loading, isDisabled: disabled, startContent: startIcon, endContent: endIcon, className: className }, props, { children: children })));
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
var sizeMap = {
|
|
@@ -72,16 +73,311 @@ var IconComponent = function (_a) {
|
|
|
72
73
|
var _b;
|
|
73
74
|
var icon = _a.icon, _c = _a.size, size = _c === void 0 ? "md" : _c, className = _a.className, style = _a.style, color = _a.color, hFlip = _a.hFlip, vFlip = _a.vFlip, flip = _a.flip, rotate = _a.rotate, nativeProps = __rest(_a, ["icon", "size", "className", "style", "color", "hFlip", "vFlip", "flip", "rotate"]);
|
|
74
75
|
var iconSize = (_b = sizeMap[size]) !== null && _b !== void 0 ? _b : sizeMap.md;
|
|
75
|
-
return (jsxRuntime.jsx("span", __assign({}, nativeProps, { children: jsxRuntime.jsx(react$
|
|
76
|
+
return (jsxRuntime.jsx("span", __assign({}, nativeProps, { children: jsxRuntime.jsx(react$1.Icon, { icon: icon, width: iconSize, height: iconSize, className: className, style: style, color: color, hFlip: hFlip, vFlip: vFlip, flip: flip, rotate: rotate }) })));
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
function normalizeClass(value) {
|
|
80
|
+
if (typeof value === "string") {
|
|
81
|
+
return value || undefined;
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
return value.filter(Boolean).join(" ") || undefined;
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
var getSectionClasses = function (isCollapsed, sectionClassesProp) {
|
|
89
|
+
if (sectionClassesProp === void 0) { sectionClassesProp = {}; }
|
|
90
|
+
return (__assign(__assign({}, Object.fromEntries(Object.entries(sectionClassesProp).map(function (_a) {
|
|
91
|
+
var k = _a[0], v = _a[1];
|
|
92
|
+
return [k, normalizeClass(v)];
|
|
93
|
+
}))), { base: normalizeClass(react.cn(sectionClassesProp === null || sectionClassesProp === void 0 ? void 0 : sectionClassesProp.base, "w-full", {
|
|
94
|
+
"p-0 max-w-[44px]": isCollapsed,
|
|
95
|
+
})), group: normalizeClass(react.cn(sectionClassesProp === null || sectionClassesProp === void 0 ? void 0 : sectionClassesProp.group, {
|
|
96
|
+
"flex flex-col gap-1": isCollapsed,
|
|
97
|
+
})), heading: normalizeClass(react.cn(sectionClassesProp === null || sectionClassesProp === void 0 ? void 0 : sectionClassesProp.heading, {
|
|
98
|
+
hidden: isCollapsed,
|
|
99
|
+
})) }));
|
|
100
|
+
};
|
|
101
|
+
var getItemClasses = function (isCollapsed, itemClassesProp) {
|
|
102
|
+
if (itemClassesProp === void 0) { itemClassesProp = {}; }
|
|
103
|
+
return (__assign(__assign({}, Object.fromEntries(Object.entries(itemClassesProp).map(function (_a) {
|
|
104
|
+
var k = _a[0], v = _a[1];
|
|
105
|
+
return [k, normalizeClass(v)];
|
|
106
|
+
}))), { base: normalizeClass(react.cn(itemClassesProp === null || itemClassesProp === void 0 ? void 0 : itemClassesProp.base, {
|
|
107
|
+
"w-11 h-11 gap-0 p-0": isCollapsed,
|
|
108
|
+
})) }));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var EnumMenuNavListItem;
|
|
112
|
+
(function (EnumMenuNavListItem) {
|
|
113
|
+
EnumMenuNavListItem["Nest"] = "nest";
|
|
114
|
+
})(EnumMenuNavListItem || (EnumMenuNavListItem = {}));
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @component MenuNavList
|
|
118
|
+
* @description A versatile navigation list component that can be displayed in an expanded or collapsed state.
|
|
119
|
+
* It supports nested items, sections, and tooltips for items in the collapsed state.
|
|
120
|
+
*
|
|
121
|
+
* @param {MenuNavListProps} props - Props for configuring the component.
|
|
122
|
+
* @param {MenuNavListItem[]} props.items - Array of items to display in the list.
|
|
123
|
+
* @param {boolean} [props.isCollapsed] - If `true`, the menu is displayed in its collapsed state (icons only).
|
|
124
|
+
* @param {React.Key} [props.defaultSelectedKey] - The key of the default selected item.
|
|
125
|
+
* @param {(key: React.Key) => void} [props.onSelect] - Callback executed when an item is selected.
|
|
126
|
+
* @param {boolean} [props.hideEndContent] - If `true`, hides the end content of the items.
|
|
127
|
+
* @param {object} [props.sectionClasses] - CSS classes to customize the sections.
|
|
128
|
+
* @param {object} [props.itemClasses] - CSS classes to customize the items.
|
|
129
|
+
* @param {string} [props.iconClassName] - CSS class for the icons.
|
|
130
|
+
* @param {object} [props.classNames] - CSS classes to customize the Listbox component.
|
|
131
|
+
* @param {string} [props.className] - CSS class for the main container.
|
|
132
|
+
*
|
|
133
|
+
* @forwardRef
|
|
134
|
+
*/
|
|
135
|
+
var MenuNavList = React.forwardRef(function (_a, ref) {
|
|
136
|
+
var items = _a.items, isCollapsed = _a.isCollapsed, defaultSelectedKey = _a.defaultSelectedKey; _a.onSelect; var hideEndContent = _a.hideEndContent, _b = _a.sectionClasses, sectionClassesProp = _b === void 0 ? {} : _b, _c = _a.itemClasses, itemClassesProp = _c === void 0 ? {} : _c, iconClassName = _a.iconClassName, classNames = _a.classNames, className = _a.className, props = __rest(_a, ["items", "isCollapsed", "defaultSelectedKey", "onSelect", "hideEndContent", "sectionClasses", "itemClasses", "iconClassName", "classNames", "className"]);
|
|
137
|
+
var _d = React.useState(defaultSelectedKey), selected = _d[0], setSelected = _d[1];
|
|
138
|
+
// Component styles
|
|
139
|
+
var sectionClasses = getSectionClasses(isCollapsed, sectionClassesProp);
|
|
140
|
+
var itemClasses = getItemClasses(isCollapsed, itemClassesProp);
|
|
141
|
+
// Handles the click event on an item, updating the selection state.
|
|
142
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
143
|
+
var handleItemPress = React.useCallback(function (item, parentKey) {
|
|
144
|
+
var keySelected = typeof parentKey === "string" ? parentKey : item.key;
|
|
145
|
+
setSelected(keySelected);
|
|
146
|
+
// Force blur to remove hover state after click.
|
|
147
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
148
|
+
document.activeElement.blur();
|
|
149
|
+
}
|
|
150
|
+
}, [setSelected]);
|
|
151
|
+
// Renders the item displayed inside the Popover when the menu is collapsed.
|
|
152
|
+
var renderCompactItem = React.useCallback(function (item, parentKey) {
|
|
153
|
+
var _a, _b;
|
|
154
|
+
return (React.createElement(react.ListboxItem, __assign({}, item, { key: item.key, endContent: (_a = item.endContent) !== null && _a !== void 0 ? _a : null, startContent: item.icon ? (jsxRuntime.jsx(IconComponent, { className: react.cn("text-default-500", "group-data-[selected=true]:text-default-600", iconClassName), icon: item.icon, size: "lg" })) : (((_b = item.startContent) !== null && _b !== void 0 ? _b : null)), textValue: item.title, title: item.title, className: "data-[hover=true]:text-default-600", onPress: function () { return handleItemPress(item, parentKey); } })));
|
|
155
|
+
}, [handleItemPress, iconClassName]);
|
|
156
|
+
// Renders a nested item, i.e., an item that has sub-items.
|
|
157
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
158
|
+
var renderNestItem = React.useCallback(function (item) {
|
|
159
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
160
|
+
var isNestType = item.items &&
|
|
161
|
+
((_a = item.items) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
162
|
+
(item === null || item === void 0 ? void 0 : item.type) === EnumMenuNavListItem.Nest;
|
|
163
|
+
if (isNestType) {
|
|
164
|
+
item.href = undefined;
|
|
165
|
+
}
|
|
166
|
+
return (React.createElement(react.ListboxItem, __assign({}, item, { key: item.key, classNames: {
|
|
167
|
+
base: react.cn({
|
|
168
|
+
"h-auto p-0": !isCollapsed && isNestType,
|
|
169
|
+
}, {
|
|
170
|
+
"inline-block w-11": isCollapsed && isNestType,
|
|
171
|
+
}, {
|
|
172
|
+
"data-[selected=true]:bg-primary-100 h-11 justify-center items-center flex": isCollapsed && isNestType,
|
|
173
|
+
}, "rounded-large"),
|
|
174
|
+
}, endContent: isCollapsed || isNestType || hideEndContent
|
|
175
|
+
? null
|
|
176
|
+
: ((_b = item.endContent) !== null && _b !== void 0 ? _b : null), startContent: isCollapsed || isNestType ? null : item.icon ? (jsxRuntime.jsx(IconComponent, { className: react.cn("text-default-500 group-data-[selected=true]:text-foreground", iconClassName), icon: item.icon, size: "lg" })) : (((_c = item.startContent) !== null && _c !== void 0 ? _c : null)), title: isCollapsed || isNestType ? null : item.title }),
|
|
177
|
+
isCollapsed && isNestType ? (jsxRuntime.jsxs(react.Popover, { placement: "right", offset: 10, children: [jsxRuntime.jsx(react.PopoverTrigger, { children: jsxRuntime.jsx("div", { className: "flex w-full items-center justify-center", children: jsxRuntime.jsx(react.Tooltip, { content: item.title, placement: "right", classNames: {
|
|
178
|
+
base: "text-default-500",
|
|
179
|
+
}, children: jsxRuntime.jsx("div", { className: "flex w-full items-center justify-center", children: item.icon ? (jsxRuntime.jsx(IconComponent, { className: react.cn("text-default-500 group-data-[selected=true]:text-default-600", iconClassName), icon: item.icon, size: "lg" })) : (((_d = item.startContent) !== null && _d !== void 0 ? _d : null)) }) }) }) }), jsxRuntime.jsx(react.PopoverContent, { className: "p-0", children: jsxRuntime.jsxs("div", { className: "min-w-[200px] rounded-large p-2", children: [jsxRuntime.jsx("div", { className: "p-2 text-small font-semibold text-default-500", children: item.title }), jsxRuntime.jsx(react.Listbox, { className: "mt-0.5 text-default-500", "aria-label": "Nested menu items", items: item.items, variant: "flat", children: item.items && ((_e = item.items) === null || _e === void 0 ? void 0 : _e.length) > 0
|
|
180
|
+
? item.items.map(function (child) {
|
|
181
|
+
return renderCompactItem(child, item.key);
|
|
182
|
+
})
|
|
183
|
+
: renderCompactItem(item) })] }) })] })) : null,
|
|
184
|
+
!isCollapsed && isNestType ? (jsxRuntime.jsx(react.Accordion, { className: "p-0", children: jsxRuntime.jsx(react.AccordionItem, { "aria-label": item.title, classNames: {
|
|
185
|
+
heading: "pr-3 group-data-[selected=true]:bg-primary-100 rounded-large",
|
|
186
|
+
trigger: "p-0",
|
|
187
|
+
content: "py-0 pl-4",
|
|
188
|
+
}, title: item.icon ? (jsxRuntime.jsxs("div", { className: "flex h-11 items-center gap-2 px-3 py-1.5", children: [jsxRuntime.jsx(IconComponent, { className: react.cn("text-default-500 group-data-[selected=true]:text-default-600", iconClassName), icon: item.icon, size: "lg" }), jsxRuntime.jsx("span", { className: "text-small font-medium text-default-500 group-data-[selected=true]:text-default-600", children: item.title })] })) : (((_f = item.startContent) !== null && _f !== void 0 ? _f : null)), children: item.items && ((_g = item.items) === null || _g === void 0 ? void 0 : _g.length) > 0 ? (jsxRuntime.jsx(react.Listbox, { className: "mt-0.5 text-default-500", classNames: {
|
|
189
|
+
list: react.cn("border-l border-default-200 pl-4"),
|
|
190
|
+
}, items: item.items, variant: "flat", children: item.items.map(function (child) { return renderItem(child, item.key); }) })) : (renderItem(item)) }, item.key) })) : null));
|
|
191
|
+
}, [isCollapsed, hideEndContent, iconClassName, items, selected]);
|
|
192
|
+
// Renders a simple item (without children) in the navigation list.
|
|
193
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
194
|
+
var renderItem = React.useCallback(function (item, parentKey) {
|
|
195
|
+
var _a, _b, _c, _d;
|
|
196
|
+
var isNestType = item.items &&
|
|
197
|
+
((_a = item.items) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
198
|
+
(item === null || item === void 0 ? void 0 : item.type) === EnumMenuNavListItem.Nest;
|
|
199
|
+
if (isNestType) {
|
|
200
|
+
return renderNestItem(item);
|
|
201
|
+
}
|
|
202
|
+
var isItemSelected = selected === item.key;
|
|
203
|
+
return (React.createElement(react.ListboxItem, __assign({}, item, { key: item.key, endContent: isCollapsed || hideEndContent ? null : ((_b = item.endContent) !== null && _b !== void 0 ? _b : null), startContent: isCollapsed ? null : item.icon ? (jsxRuntime.jsx(IconComponent, { className: react.cn("text-default-500", "group-data-[selected=true]:text-default-600", iconClassName), icon: item.icon, size: "lg" })) : (((_c = item.startContent) !== null && _c !== void 0 ? _c : null)), textValue: item.title, title: isCollapsed ? null : item.title, onPress: function () { return handleItemPress(item, parentKey); }, "aria-selected": isItemSelected, "aria-label": item.title || "Menu item ".concat(item.key) }), isCollapsed ? (jsxRuntime.jsx(react.Tooltip, { content: item.title, placement: "right", closeDelay: 200, shouldCloseOnBlur: false, classNames: {
|
|
204
|
+
base: "text-default-500",
|
|
205
|
+
}, children: jsxRuntime.jsx("div", { className: "flex w-full items-center justify-center", "aria-hidden": "true", children: item.icon ? (jsxRuntime.jsx(IconComponent, { className: react.cn("text-default-500", "group-data-[selected=true]:text-default-600", iconClassName), icon: item.icon, size: "lg" })) : (((_d = item.startContent) !== null && _d !== void 0 ? _d : null)) }) })) : null));
|
|
206
|
+
},
|
|
207
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
208
|
+
[isCollapsed, hideEndContent, iconClassName, itemClasses === null || itemClasses === void 0 ? void 0 : itemClasses.base]);
|
|
209
|
+
return (jsxRuntime.jsx(react.Listbox, __assign({ ref: ref, hideSelectedIcon: true, as: "nav", className: react.cn("list-none", className), classNames: __assign(__assign({}, classNames), { list: react.cn("items-center", classNames === null || classNames === void 0 ? void 0 : classNames.list) }), color: "default", itemClasses: __assign(__assign({}, itemClasses), { base: react.cn("px-3 min-h-11 rounded-large h-[44px] data-[selected=true]:bg-primary-100", itemClasses === null || itemClasses === void 0 ? void 0 : itemClasses.base), title: react.cn("text-small font-medium text-default-500 group-data-[selected=true]:text-default-600 ", itemClasses === null || itemClasses === void 0 ? void 0 : itemClasses.title) }), items: items, selectedKeys: [selected], selectionMode: "single", variant: "flat" }, props, { children: function (item) {
|
|
210
|
+
var _a, _b;
|
|
211
|
+
return item.items &&
|
|
212
|
+
((_a = item.items) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
213
|
+
(item === null || item === void 0 ? void 0 : item.type) === EnumMenuNavListItem.Nest ? (renderNestItem(item)) : item.items && ((_b = item.items) === null || _b === void 0 ? void 0 : _b.length) > 0 ? (jsxRuntime.jsx(react.ListboxSection, { classNames: sectionClasses, showDivider: isCollapsed, title: item.title, children: item.items.map(renderItem) }, item.key)) : (renderItem(item));
|
|
214
|
+
} }), isCollapsed ? "compact" : "default"));
|
|
215
|
+
});
|
|
216
|
+
MenuNavList.displayName = "MenuNavList";
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Sidebar menu component for navigation and user actions.
|
|
220
|
+
* @param commerceInfo - Object with logo and name of the company.
|
|
221
|
+
* @param userInfo - Object with user avatar, name, and email.
|
|
222
|
+
* @param helpButton - Help button configuration.
|
|
223
|
+
* @param upgradeCard - Optional upgrade card configuration.
|
|
224
|
+
* @param isOpenSidebar - Controls sidebar visibility.
|
|
225
|
+
* @param onOpenSidebarChange - Callback to open/close sidebar.
|
|
226
|
+
*/
|
|
227
|
+
var MenuComponent = React.memo(function Menu(_a) {
|
|
228
|
+
var commerceInfo = _a.commerceInfo, userInfo = _a.userInfo, helpButton = _a.helpButton, upgradeCard = _a.upgradeCard, isOpenSidebar = _a.isOpenSidebar, onOpenSidebarChange = _a.onOpenSidebarChange, menuItems = _a.menuItems;
|
|
229
|
+
// State to control menu collapse on desktop devices
|
|
230
|
+
var _b = React.useState(false), isCollapsed = _b[0], setIsCollapsed = _b[1];
|
|
231
|
+
// Memoized handlers for performance
|
|
232
|
+
var handleSidebarClose = React.useCallback(function () {
|
|
233
|
+
onOpenSidebarChange === null || onOpenSidebarChange === void 0 ? void 0 : onOpenSidebarChange(false);
|
|
234
|
+
}, [onOpenSidebarChange]);
|
|
235
|
+
var handleCollapseToggle = React.useCallback(function () {
|
|
236
|
+
setIsCollapsed(function (prev) { return !prev; });
|
|
237
|
+
}, []);
|
|
238
|
+
var handleUpgradeClick = React.useCallback(function () {
|
|
239
|
+
if (upgradeCard) {
|
|
240
|
+
window.open(upgradeCard.buttonLink, "_blank");
|
|
241
|
+
}
|
|
242
|
+
}, [upgradeCard]);
|
|
243
|
+
var handleHelpClick = React.useCallback(function () {
|
|
244
|
+
window.open(helpButton.redirect, "_blank");
|
|
245
|
+
}, [helpButton]);
|
|
246
|
+
if (!isOpenSidebar) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { type: "button", "aria-label": "Close sidebar", className: "fixed inset-0 bg-black bg-opacity-40 z-40 xs:block sm:hidden", onClick: handleSidebarClose, style: { border: "none", padding: 0, margin: 0 } }), jsxRuntime.jsx("div", { className: "container__menu ".concat(isCollapsed
|
|
250
|
+
? "container__menu--collapsed"
|
|
251
|
+
: "container__menu--expanded"), children: jsxRuntime.jsxs("div", { className: "content__menu", children: [jsxRuntime.jsxs("div", { className: "content__menu--header", style: { flexDirection: isCollapsed ? "column-reverse" : "row" }, children: [jsxRuntime.jsxs("div", { className: "flex flex-row items-center justify-center ".concat(isCollapsed ? "gap-0" : "gap-2"), children: [jsxRuntime.jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-foreground", children: jsxRuntime.jsx("img", { src: commerceInfo.logo, alt: "Logo of ".concat(commerceInfo.name) }) }), jsxRuntime.jsx("span", { className: "collapsible-item text-small font-bold uppercase", children: commerceInfo.name })] }), jsxRuntime.jsxs("div", { className: "flex items-center", children: [jsxRuntime.jsx(IconComponent, { icon: "material-symbols-light:close", size: "lg", className: "cursor-pointer block sm:hidden", onClick: handleSidebarClose }), jsxRuntime.jsx(IconComponent, { icon: isCollapsed
|
|
252
|
+
? "solar:alt-arrow-right-outline"
|
|
253
|
+
: "solar:alt-arrow-left-outline", size: "lg", className: "hidden sm:block cursor-pointer", onClick: handleCollapseToggle })] })] }), jsxRuntime.jsx(react.Spacer, { y: 6 }), jsxRuntime.jsxs("div", { className: "content__menu--user ".concat(isCollapsed ? "gap-0" : "gap-3"), children: [jsxRuntime.jsx(react.Avatar, { size: "md", src: userInfo.avatar, color: userInfo.avatar === "" ? "warning" : "default", name: userInfo.name }), jsxRuntime.jsxs("div", { className: "collapsible-item flex flex-col", children: [jsxRuntime.jsx("p", { className: "text-small font-medium text-default-900", children: userInfo.name }), jsxRuntime.jsx("p", { className: "text-tiny text-default-400", children: userInfo.role })] })] }), jsxRuntime.jsx("div", { className: "".concat(!isCollapsed ? "flex-1" : "h-full", " min-h-0 py-6"), children: jsxRuntime.jsx("div", { className: "h-full overflow-y-auto pr-6 -mr-6 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]", children: jsxRuntime.jsx(MenuNavList, { defaultSelectedKey: menuItems.selectedKey, items: menuItems.items, isCollapsed: isCollapsed }) }) }), upgradeCard && (jsxRuntime.jsxs("div", { className: "collapsible-item relative", children: [jsxRuntime.jsxs(react.Card, { className: "border-none overflow-visible shadow-none", shadow: "sm", children: [jsxRuntime.jsxs(react.CardBody, { className: "items-center py-5 text-center gap-1", children: [jsxRuntime.jsx("h3", { className: "text-medium font-medium text-default-900", children: upgradeCard.title }), jsxRuntime.jsx("p", { className: "text-small text-default-500 pb-3 whitespace-normal", children: upgradeCard.description })] }), jsxRuntime.jsx(react.CardFooter, { className: "absolute justify-center", style: { bottom: "-30px" }, children: jsxRuntime.jsx(react.Button, { className: "px-10 shadow-md", color: "primary", radius: "full", variant: "shadow", onPress: handleUpgradeClick, children: upgradeCard.buttonText }) })] }), jsxRuntime.jsx(react.Spacer, { y: 9 })] })), jsxRuntime.jsx("div", { className: "mt-auto flex flex-col justify-center items-center", children: jsxRuntime.jsx(react.Button, { fullWidth: true, className: " text-default-600 data-[hover=true]:text-foreground", startContent: jsxRuntime.jsx(IconComponent, { className: "text-default-500", icon: "solar:info-circle-line-duotone", size: "md" }), variant: "light", onPress: handleHelpClick, isIconOnly: isCollapsed, children: !isCollapsed && (jsxRuntime.jsx("span", { className: "collapsible-item", children: helpButton.title })) }) })] }) })] }));
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// Lista simple de países con bandera emoji y código
|
|
257
|
+
var countries = [
|
|
258
|
+
{ code: "+57", name: "Colombia", flag: "🇨🇴" },
|
|
259
|
+
{ code: "+54", name: "Argentina", flag: "🇦🇷" },
|
|
260
|
+
{ code: "+55", name: "Brazil", flag: "🇧🇷" },
|
|
261
|
+
{ code: "+52", name: "Mexico", flag: "🇲🇽" },
|
|
262
|
+
{ code: "+503", name: "El Salvador", flag: "🇸🇻" },
|
|
263
|
+
{ code: "+51", name: "Peru", flag: "🇵🇪" },
|
|
264
|
+
{ code: "+56", name: "Chile", flag: "🇨🇱" },
|
|
265
|
+
{ code: "+1", name: "United States", flag: "🇺🇸" },
|
|
266
|
+
{ code: "+7", name: "Russia", flag: "🇷🇺" },
|
|
267
|
+
{ code: "+20", name: "Egypt", flag: "🇪🇬" },
|
|
268
|
+
{ code: "+27", name: "South Africa", flag: "🇿🇦" },
|
|
269
|
+
{ code: "+33", name: "France", flag: "🇫🇷" },
|
|
270
|
+
{ code: "+34", name: "Spain", flag: "🇪🇸" },
|
|
271
|
+
{ code: "+39", name: "Italy", flag: "🇮🇹" },
|
|
272
|
+
{ code: "+44", name: "United Kingdom", flag: "🇬🇧" },
|
|
273
|
+
{ code: "+49", name: "Germany", flag: "🇩🇪" },
|
|
274
|
+
{ code: "+51", name: "Peru", flag: "🇵🇪" },
|
|
275
|
+
{ code: "+52", name: "Mexico", flag: "🇲🇽" },
|
|
276
|
+
{ code: "+54", name: "Argentina", flag: "🇦🇷" },
|
|
277
|
+
{ code: "+55", name: "Brazil", flag: "🇧🇷" },
|
|
278
|
+
{ code: "+56", name: "Chile", flag: "🇨🇱" },
|
|
279
|
+
{ code: "+57", name: "Colombia", flag: "🇨🇴" },
|
|
280
|
+
{ code: "+60", name: "Malaysia", flag: "🇲🇾" },
|
|
281
|
+
{ code: "+61", name: "Australia", flag: "🇦🇺" },
|
|
282
|
+
{ code: "+62", name: "Indonesia", flag: "🇮🇩" },
|
|
283
|
+
{ code: "+64", name: "New Zealand", flag: "🇳🇿" },
|
|
284
|
+
{ code: "+65", name: "Singapore", flag: "🇸🇬" },
|
|
285
|
+
{ code: "+66", name: "Thailand", flag: "🇹🇭" },
|
|
286
|
+
{ code: "+81", name: "Japan", flag: "🇯🇵" },
|
|
287
|
+
{ code: "+82", name: "South Korea", flag: "🇰🇷" },
|
|
288
|
+
{ code: "+84", name: "Vietnam", flag: "🇻🇳" },
|
|
289
|
+
{ code: "+86", name: "China", flag: "🇨🇳" },
|
|
290
|
+
{ code: "+91", name: "India", flag: "🇮🇳" },
|
|
291
|
+
{ code: "+351", name: "Portugal", flag: "🇵🇹" },
|
|
292
|
+
{ code: "+503", name: "El Salvador", flag: "🇸🇻" },
|
|
293
|
+
{ code: "+966", name: "Saudi Arabia", flag: "🇸🇦" },
|
|
294
|
+
{ code: "+971", name: "UAE", flag: "🇦🇪" },
|
|
295
|
+
];
|
|
296
|
+
var uniqueCountries = Array.from(new Map(countries.map(function (item) { return [item.code + item.name, item]; })).values());
|
|
297
|
+
var defaultTranslations = {
|
|
298
|
+
label: "Teléfono",
|
|
299
|
+
placeholder: "Número de teléfono",
|
|
300
|
+
searchPlaceholder: "Buscar país...",
|
|
301
|
+
selectCountryAriaLabel: "Seleccionar país",
|
|
302
|
+
expandListAriaLabel: "Desplegar lista de países",
|
|
303
|
+
noCountriesFound: "No se encontraron países",
|
|
304
|
+
};
|
|
305
|
+
var Phone = function (_a) {
|
|
306
|
+
var label = _a.label, _b = _a.required, required = _b === void 0 ? false : _b, _c = _a.error, error = _c === void 0 ? false : _c, _d = _a.errorText, errorText = _d === void 0 ? "" : _d, _e = _a.value, value = _e === void 0 ? "" : _e, onChange = _a.onChange, onBlur = _a.onBlur, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.name, name = _g === void 0 ? "phone" : _g, _h = _a.translations, translations = _h === void 0 ? {} : _h;
|
|
307
|
+
var _j = React.useState(false), isDropdownOpen = _j[0], setIsDropdownOpen = _j[1];
|
|
308
|
+
var _k = React.useState(uniqueCountries[0]), selectedCountry = _k[0], setSelectedCountry = _k[1];
|
|
309
|
+
var _l = React.useState(""), inputValue = _l[0], setInputValue = _l[1];
|
|
310
|
+
var dropdownRef = React.useRef(null);
|
|
311
|
+
var _m = React.useState(uniqueCountries), filteredCountries = _m[0], setFilteredCountries = _m[1];
|
|
312
|
+
// Combinar traducciones por defecto con las proporcionadas
|
|
313
|
+
var t = __assign(__assign({}, defaultTranslations), translations);
|
|
314
|
+
// Usar la etiqueta de las traducciones si no se proporciona label explícitamente
|
|
315
|
+
var finalLabel = label || t.label;
|
|
316
|
+
// Sincroniza valor externo
|
|
317
|
+
React.useEffect(function () {
|
|
318
|
+
if (value) {
|
|
319
|
+
// Si value incluye el código, lo separamos
|
|
320
|
+
var found = uniqueCountries.find(function (c) { return value.startsWith(c.code); });
|
|
321
|
+
if (found) {
|
|
322
|
+
setSelectedCountry(found);
|
|
323
|
+
setInputValue(value.replace(found.code, "").trim());
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
setInputValue(value);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}, [value]);
|
|
330
|
+
// Open dropdown: reset filteredCountries
|
|
331
|
+
React.useEffect(function () {
|
|
332
|
+
if (isDropdownOpen) {
|
|
333
|
+
setFilteredCountries(uniqueCountries);
|
|
334
|
+
}
|
|
335
|
+
}, [isDropdownOpen]);
|
|
336
|
+
// Cierra dropdown al hacer click fuera
|
|
337
|
+
React.useEffect(function () {
|
|
338
|
+
var handleClickOutside = function (event) {
|
|
339
|
+
if (dropdownRef.current &&
|
|
340
|
+
!dropdownRef.current.contains(event.target)) {
|
|
341
|
+
setIsDropdownOpen(false);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
if (isDropdownOpen) {
|
|
345
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
346
|
+
}
|
|
347
|
+
return function () {
|
|
348
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
349
|
+
};
|
|
350
|
+
}, [isDropdownOpen]);
|
|
351
|
+
var handleCountrySelect = function (country) {
|
|
352
|
+
setSelectedCountry(country);
|
|
353
|
+
setIsDropdownOpen(false);
|
|
354
|
+
if (onChange) {
|
|
355
|
+
onChange(country.code + inputValue);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var handleInputChange = function (e) {
|
|
359
|
+
// Solo números
|
|
360
|
+
var val = e.target.value.replace(/\D/g, "");
|
|
361
|
+
setInputValue(val);
|
|
362
|
+
if (onChange) {
|
|
363
|
+
onChange(selectedCountry.code + val);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 w-full relative", children: [finalLabel && (jsxRuntime.jsxs("label", { htmlFor: "phone-input-".concat(name), className: "text-sm font-medium text-gray-700 dark:text-gray-200 mb-1", children: [finalLabel, " ", required && jsxRuntime.jsx("span", { className: "text-pink-600", children: "*" })] })), jsxRuntime.jsxs("div", { className: "flex items-center w-full min-h-[56px] bg-white dark:bg-gray-900 transition-colors shadow-sm border border-[#E4E4E7] dark:border-gray-700 rounded-2xl focus-within:border-blue-500 dark:focus-within:border-blue-400 ".concat(error
|
|
367
|
+
? "border-pink-500 dark:border-pink-600"
|
|
368
|
+
: "border-[#E4E4E7] dark:border-gray-700").concat(disabled ? " bg-gray-100 dark:bg-gray-800 opacity-60" : ""), children: [jsxRuntime.jsxs("div", { className: "relative ml-2", ref: dropdownRef, children: [jsxRuntime.jsxs("button", { type: "button",
|
|
369
|
+
///bg-gray-100
|
|
370
|
+
className: "flex items-center gap-1 px-4 h-10 rounded-xl dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 focus:outline-none transition-colors", onClick: function () { return setIsDropdownOpen(function (v) { return !v; }); }, disabled: disabled, tabIndex: 0, "aria-label": t.selectCountryAriaLabel, children: [jsxRuntime.jsx("span", { className: "text-lg", children: selectedCountry.flag }), jsxRuntime.jsx("span", { className: "text-xs text-gray-700 dark:text-gray-200", children: selectedCountry.code }), jsxRuntime.jsxs("svg", { className: "w-4 h-4 text-gray-400 dark:text-gray-300 ml-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": t.expandListAriaLabel, children: [jsxRuntime.jsx("title", { children: t.expandListAriaLabel }), jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })] })] }), isDropdownOpen && (jsxRuntime.jsxs("div", { className: "absolute z-30 mt-2 w-60 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg", children: [jsxRuntime.jsx("div", { className: "p-2", children: jsxRuntime.jsx("input", { type: "text", className: "w-full px-3 py-2 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-900 dark:text-gray-100 rounded-lg focus:outline-none focus:border-blue-500 dark:focus:border-blue-400", placeholder: t.searchPlaceholder, onChange: function (e) {
|
|
371
|
+
var searchTerm = e.target.value.toLowerCase();
|
|
372
|
+
var filtered = uniqueCountries.filter(function (country) {
|
|
373
|
+
return country.name.toLowerCase().includes(searchTerm) ||
|
|
374
|
+
country.code.toLowerCase().includes(searchTerm);
|
|
375
|
+
});
|
|
376
|
+
setFilteredCountries(filtered);
|
|
377
|
+
} }) }), jsxRuntime.jsx("div", { className: "max-h-60 overflow-y-auto", children: filteredCountries.length > 0 ? (filteredCountries.map(function (country) { return (jsxRuntime.jsxs("button", { type: "button", className: "flex items-center w-full px-4 py-2.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-800 ".concat(country.code === selectedCountry.code
|
|
378
|
+
? "bg-blue-50 dark:bg-blue-900"
|
|
379
|
+
: ""), onClick: function () { return handleCountrySelect(country); }, children: [jsxRuntime.jsx("span", { className: "mr-3 text-lg", children: country.flag }), jsxRuntime.jsx("span", { className: "flex-1 text-left dark:text-gray-100", children: country.name }), jsxRuntime.jsx("span", { className: "text-xs text-gray-500 dark:text-gray-400", children: country.code })] }, country.code)); })) : (jsxRuntime.jsx("div", { className: "px-4 py-2 text-sm text-gray-500 dark:text-gray-400", children: t.noCountriesFound })) })] }))] }), jsxRuntime.jsx(react.Input, { type: "tel", className: "flex-1 border-none bg-transparent text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 h-10 px-2", placeholder: t.placeholder, value: inputValue, onChange: handleInputChange, onBlur: onBlur, disabled: disabled, name: name, autoComplete: "tel", id: "phone-input-".concat(name) })] }), error && errorText && (jsxRuntime.jsx("span", { className: "text-xs text-pink-600 dark:text-pink-400 mt-1", children: errorText }))] }));
|
|
83
380
|
};
|
|
84
|
-
MenuPrueba.displayName = "MenuPrueba";
|
|
85
381
|
|
|
86
382
|
var themeColors = {
|
|
87
383
|
"purple-light": {
|
|
@@ -262,13 +558,13 @@ var themeColors = {
|
|
|
262
558
|
},
|
|
263
559
|
};
|
|
264
560
|
|
|
265
|
-
var ThemeContext =
|
|
561
|
+
var ThemeContext = React.createContext({
|
|
266
562
|
theme: "light",
|
|
267
563
|
// biome-ignore lint/suspicious/noEmptyBlockStatements: <explanation>
|
|
268
564
|
setTheme: function () { },
|
|
269
565
|
});
|
|
270
566
|
var useThemeContext = function () {
|
|
271
|
-
var context =
|
|
567
|
+
var context = React.useContext(ThemeContext);
|
|
272
568
|
if (!context) {
|
|
273
569
|
throw new Error("useThemeContext debe ser usado dentro de un ThemeProvider");
|
|
274
570
|
}
|
|
@@ -277,13 +573,14 @@ var useThemeContext = function () {
|
|
|
277
573
|
|
|
278
574
|
var ThemeProvider = function (_a) {
|
|
279
575
|
var children = _a.children;
|
|
280
|
-
var _b =
|
|
576
|
+
var _b = useTheme.useTheme(), theme = _b.theme, setTheme = _b.setTheme;
|
|
281
577
|
return (jsxRuntime.jsx(ThemeContext.Provider, { value: { theme: theme, setTheme: setTheme }, children: jsxRuntime.jsx("main", { className: "".concat(theme, " bg-background text-foreground "), children: children }) }));
|
|
282
578
|
};
|
|
283
579
|
|
|
284
580
|
exports.ButtonPrueba = ButtonPrueba;
|
|
285
581
|
exports.IconComponent = IconComponent;
|
|
286
|
-
exports.
|
|
582
|
+
exports.MenuComponent = MenuComponent;
|
|
583
|
+
exports.Phone = Phone;
|
|
287
584
|
exports.ThemeContext = ThemeContext;
|
|
288
585
|
exports.ThemeProvider = ThemeProvider;
|
|
289
586
|
exports.sizeMap = sizeMap;
|